akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a,b)<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long ans = 0, l1 = 1, l2 = 2;
		if (n == 1) {
			ans = 1;
		} else {
			for (int i = 2; i <= n; i++) {
				ans = l1 + l2;
				l2 = l1;
				l1 = ans;
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 22356
n,k = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(n)]

xy.sort()
ans = 10**20

for i in range(n):
    for j in range(i,n):
        xy_tmp = xy[i:j+1]
        if len(xy_tmp) >= k:
            l1 = xy_tmp[0][0]
            r1 = xy_tmp[-1][0]
            xy_tmp.sort(key = lambda x: x[1])
            for jj in range(len(xy_tmp) - k + 1):
                ans = min(ans, (r1-l1) * (xy_tmp[k+jj-1][1] - xy_tmp[jj][1]))

print(ans)


Measured memory_bytes: 39792
import numpy as np
N = int(input())

A = []
B = []
val = []

for i in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)
    val.append(a + b)

A = np.array(A)
B = np.array(B)
val = np.array(val)

sort_index = val.argsort()

A = (A[sort_index][::-1])
B = (B[sort_index][::-1])

taka = (A[0::2])
aoki = (B[1::2])

print(sum(taka) - sum(aoki))

Measured memory_bytes: 25660
include Math
require 'matrix'

def fractal(x1,y1,x2,y2)
    third = one_third(x1,y1,x2,y2)
    s = [x1+third[0],y1+third[1]]
    t = [x1+third[0]*2,y1+third[1]*2]
    vector = (Matrix[[1/2.to_f,-sqrt(3)/2.to_f],[sqrt(3)/2.to_f,1/2.to_f]]*Matrix[[third[0]],[third[1]]]).to_a
    u = [s[0]+vector[0][0],s[1]+vector[1][0]]
    return s,u,t,[x2,y2]
end

def one_third(x1,y1,x2,y2)
    return [((x2-x1)/3).to_f,((y2-y1)/3).to_f]
    #return (sqrt((x1-x2)**2+(y1-y2)**2))/3
end

n = gets.chomp.to_i
arrays = [[0.000000000,0.000000000],[100.000000000,0.000000000]]
n.times do
    array1 = arrays[0]
    new_arrays = [[0.000000000,0.000000000]]
    arrays[1..(arrays.length-1)].each do |array2|
        new_array = fractal(array1[0],array1[1],array2[0],array2[1])
        new_array.each do |a|
            new_arrays.push(a)
        end
        array1 = array2
    end
    arrays = new_arrays
end
arrays.each do |array|
    puts array[0].to_s+' '+array[1].to_s
end

Measured memory_bytes: 9224
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>

template <class T>
struct SuffixArray {
    std::vector<int> ord, rank;

    template <class It>
    explicit SuffixArray(const It& begin, const It& end) {
        std::vector<T> dat(begin, end);
        int n = dat.size();

        ord.resize(n);
        std::iota(ord.begin(), ord.end(), 0);
        std::sort(ord.begin(), ord.end(),
                  [&](int i, int j) { return dat[i] < dat[j]; });

        rank.resize(n);
        {
            int cnt = 1;
            rank[ord[0]] = 1;
            for (int i = 1; i < n; ++i) {
                if (dat[ord[i - 1]] != dat[ord[i]]) ++cnt;
                rank[ord[i]] = cnt;
            }
        }

        // sentinel
        ord.insert(ord.begin(), n);
        rank.push_back(0);

        std::vector<int> bucket(n + 1), nrank(n + 1), idxs(n + 1);

        for (int k = 1; k < n; k <<= 1) {
            std::fill(bucket.begin(), bucket.end(), 0);

            // idxs is in acsending order by the last k characters
            for (int i = 0; i <= n; ++i) {
                idxs[i] = (ord[i] - k + n + 1) % (n + 1);
                ++bucket[rank[idxs[i]]];
            }

            for (int i = 1; i <= n; ++i) {
                bucket[i] += bucket[i - 1];
            }
            for (int i = n; i >= 0; --i) {
                ord[--bucket[rank[idxs[i]]]] = idxs[i];
            }

            int cnt = 0;
            for (int i = 0;; ++i) {
                nrank[ord[i]] = cnt;
                if (i == n) break;

                if (rank[ord[i]] != rank[ord[i + 1]] ||
                    rank[(ord[i] + k) % (n + 1)] !=
                        rank[(ord[i + 1] + k) % (n + 1)]) ++cnt;
            }
            std::swap(rank, nrank);
        }
    }
};

void solve() {
    int n, k;
    std::string s;
    std::cin >> n >> k >> s;

    std::string t = s;
    std::reverse(t.begin(), t.end());
    auto u = s + t;
    SuffixArray<char> sa(u.begin(), u.end());

    {
        int i;
        for (i = 0; i <= n * 2; ++i) {
            if (sa.ord[i] < n) break;
        }
        u = u.substr(sa.ord[i], n);
    }

    int l;
    for (l = 0; l < n && u[l] == u[0]; ++l) {}
    auto back = u.substr(l);

    --k;
    while (l < n && k > 0) {
        l = std::min(n, l * 2);
        --k;
    }

    auto ans = std::string(l, u[0]) + back;
    ans = ans.substr(0, n);
    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}


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

int main() {
  int C, R;
  cin >> C >> R;
  vector<int> vec(2 * R);
  for (int i = 0; i < 2 * R; i++)
    cin >> vec.at(i);
  for (int i = 0; i < C; i++){
    int sum = 0;
    for (int j = 0; j < R; j++){
      if (vec.at(2 * j) == i + 1 || vec.at(2 * j + 1) == i + 1)
        sum++;
    }
    cout << sum << endl;
  }
}   
  

Measured memory_bytes: 3556
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <unordered_map>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

//const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,m,ans=0;
  std::cin>>n>>m;

  std::priority_queue<ll> value;

  rep(i,0,n){
    ll a;
    std::cin>>a;
    ans+=a;
    value.push(a);
  }

  rep(i,0,m){
    ll temp=value.top();value.pop();
    ans-=(temp-temp/2);
    value.push(temp/2);
  }

  std::cout<<ans;

  return 0;
}


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

bool in(vector<char> &s, char sr){
    for(int i = 0;i < s.size();i++){
        if(s[i] == sr) return true;
    }
    return false;
}

int main(void){
    unsigned short N;
    vector<char> s;
    cin >> N;
    for(int i = 0; i < N; i++){
        char sr;
        cin >> sr;
        if(!in(s, sr)) s.push_back(sr);
    }
    cout << (s.size() == 3 ? "Three" : "Four");
}


Measured memory_bytes: 256
N, L = map(int, input().split())
ans = 0
if L > 0:
    for i in range(L + 1, L + N):
        ans += i
    print(ans)
elif L + N > 0:
    for i in range(L, L + N):
        ans += i
    print(ans)
else:
    for i in range(L, L + N - 1):
        ans += i
    print(ans)

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

int main(){
    int n;
    cin>>n;
    string s;
    cin >> s;
    int ans=0;
    for(int i=1;i<n;i++){
        int cnt=0;
        for(char c='a';c<='z';c++){
            bool left=false,right=false;
            for(int j=0;j<i;j++){
                if(s[j]==c){
                    left=true;
                }
            }
            for(int j=i;j<n;j++){
                if(s[j]==c)
                right=true;
            }
            if(left&&right){
                cnt++;
            }
            
            
        }
        if(ans<cnt)ans=cnt;
    }

    cout<<ans<<endl;

}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    double START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 q; cin >> q;
    string s, t;
    vii dp;

    rep(i,q) {
        cin >> s >> t;
        dp.assign(s.size()+1, vi(t.size()+1));
        rep(i, s.size()) rep(j, t.size()) {
            if(s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
        
        // debug
//        rep(i,s.size()+1)rep(j, t.size()+1) cout << dp[i][j] << (j == t.size() ? '\n' : ' ');

        cout << dp[s.size()][t.size()] << '\n';
    }

//     printf("ElapsedTime: %5.3f ms\n",1000*((clock()-START_TIME)/CLOCKS_PER_SEC));
}



Measured memory_bytes: 10840
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; ll k; cin >> n >> k;
  vector dp(60, vector(n, 0));
  REP(j, n) cin >> dp[0][j], --dp[0][j];
  REP(i, 59) REP(j, n) dp[i + 1][j] = dp[i][dp[i][j]];
  int ans = 0;
  REP(i, 60) {
    if (k >> i & 1) ans = dp[i][ans];
  }
  cout << ans + 1 << '\n';
  return 0;
}


Measured memory_bytes: 50984
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int[] v = new int[n];
        for(int i = 0; i < n; i++){
            v[i] = Integer.parseInt(sc.next());
        }
        
        int max = 0;
        PriorityQueue<Integer> queue;
        int x = Math.min(n, k);
        for(int a = 1; a <= x; a++){
            for(int b = 0; b <= a; b++){
                
                queue = new PriorityQueue<>();
                for(int c = 0; c < n; c++){
                    if(b <= c && c < (b+n-a)){
                        continue;
                    }
                    queue.offer(v[c]);
                }
                for(int i = 0; i < k-a; i++){
                    if(queue.isEmpty()) break;
                    if(queue.peek() < 0){
                        queue.poll();
                    }
                }
                int value = 0;
                while(!queue.isEmpty()){
                    value += queue.poll();
                }
                if(value > max){
                    max = value;
                }
                if(a == n) break;
            }
        }
        
        System.out.println(max);
    }
}

Measured memory_bytes: 26964
#include<iostream>
using namespace std;
int main(){
  int arr[5];
  int ans;
  for(int i = 0;i<5;i++)
  {
    cin>>arr[i];
    if(arr[i]==0)
      ans = i+1;
  }
  cout<<ans<<"\n";
  return 0;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if((a==1&&b==2)||(a==2)&&(b==1)){
      cout<<3<<endl;
  }
  else{
      if((a==3&&b==1)||(a==1&&b==3)){
          cout<<2<<endl;
      }
      else{
          cout<<1<<endl;
      }
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  char last = 'A';
  int cnt = 0;
  while (n--) {
    char c;
    cin >> c;
    if (c == last)
      continue;
    last = c;
    ++cnt;
  }

  cout << cnt << endl;
}

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

int main() {
  int s;
  cin >> s;
  int a = s / 100;
  int b = s % 100;
  if (a > 0 && a < 13) {
    if (b > 0 && b < 13) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }
  else {
    if (b > 0 && b < 13) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
}


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

using namespace std;

int mint(int p,int q){
  if(p > q) return q;
  else return p;
}

int main(int argc,char* argv[]){
  int N;
  long sum=0;
  cin >> N;
  int B[N];
  for(int i=0;i<N-1;i++) cin >> B[i];
  sum += B[0];
  for(int i=0;i<N-2;i++){
    sum += mint(B[i],B[i+1]);
  }
  sum += B[N-2];
  cout << sum << endl;
  return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    REP(i, N) {
        cin >> A[i] >> B[i];
    }
    long long int dp[N + 1][10010];
    REP(i, N + 1) REP(j, 10010) dp[i][j] = iINF;
    dp[0][0] = 0;
    REP(i, N) {
        REP(j, 10010) {

            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if (j + A[i] <= 10010) {
                dp[i + 1][j + A[i]] = min(dp[i + 1][j + A[i]], dp[i + 1][j] + B[i]);
            } 
        }
    }

    long long int ans = iINF;

    REP(i, 10010) {
        if (H <= i) {
            ans = min(ans, dp[N][i]);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 78592
s = list(input())

a = b = c = 0
for i in s:
    if i == "a":
        a += 1
    elif i == "b":
        b += 1
    else:
        c += 1

if a*b*c == 0 and a+b+c > 2:
    print("NO")
elif max(a,b,c)-min(a,b,c) >= 2:
    print("NO")
else:
    print("YES")





Measured memory_bytes: 77044
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
a = LI()

ANS = [0]*(10**5+1)
for i in range(N):
    b = a[i]
    if b == 0:
        ANS[b] += 1
        ANS[b+1] += 1
    else:
        ANS[b-1] += 1
        ANS[b] += 1
        ANS[b+1] += 1
        
print(max(ANS))


Measured memory_bytes: 84632
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  int ans = 0;
  string s;

  cin >> N;

  for(int i = 1; i <= N; i++){
    ans+=i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  char n[4];
  scanf("%s", n);
  for (int i = 0; i < 3; i++) {
    if (n[i] == '1') {
      printf("9");
    } else {
      printf("1");
    }
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define MAX 100

int main(void)
{
    int i, j;

    int nums[MAX];

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

    for (i = 0; i < length; i++) {
        scanf("%d", &nums[i]);
        if (i != 0) {
            printf(" ");
        }
        printf("%d", nums[i]);
    }
    printf("\n");

    int key;
    for (i = 1; i < length; i++) {
        key = nums[i];
        j = i - 1;
        while (j >= 0 && nums[j] > key) {
            nums[j + 1] = nums[j];
            j--;
        }
        nums[j + 1] = key;

        for (j = 0; j < length; j++) {
            if (j != 0) {
                printf(" ");
            }
            printf("%d", nums[j]);
        }
        printf("\n");
    }

    return 0;
}

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

using namespace std;

const int N = 10010;

int n;
int ans[N];

int main()
{
    cin >> n;
    int ceil = sqrt(n);
    for(int x = 1; x <= ceil; x++)
        for(int y = 1; y <= ceil; y++)
            for(int z = 1; z <= ceil; z++)
            {
                int tmp = x * x + y * y + z * z + x * y + x * z + y * z;
                if(tmp < N)
                    ans[tmp]++;
            }
        
    for(int i = 1; i <= n; i++)
        cout << ans[i] << endl;

    return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c ;
  if(b>c) cout << b+c << endl;
  if(b<=c){
       if(a+b>=c){
	   		cout <<  b+c << endl;
	   }
	   if(a+b<c){
	   		cout  << a+2*b+1 << endl;
	   }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
lli a[200020];
lli d[200020];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k=0,n=0;lli sum=0ll,m=0ll;
    cin>>k>>n;
    cin>>a[0];
    for(int i=1;i<n;++i)
    {
        cin>>a[i];
        d[i]=a[i]-a[i-1];
        sum+=d[i];
        m=max(m,d[i]);
    }
    if(k-a[n-1]+a[0]<m)
        sum+=(k-a[n-1]+a[0]-m);
    cout<<sum<<endl;
}


Measured memory_bytes: 3328
n = int(input())

S = list(str(input()) for i in range(n))
SortedS = sorted(S) #辞書式にソート
s = [] #各文字列の回数
S2 = [] #各文字列
count = 1
for i in range(n - 1):
    if i == n - 2 and SortedS[i] != SortedS[i + 1]:
        s.append(count)
        s.append(1)
        S2.append(SortedS[i])
        S2.append(SortedS[i + 1])
    
    else:
        if SortedS[i] == SortedS[i + 1]:
            count += 1
            if i == n - 2:
                s.append(count)
                S2.append(SortedS[i])
        else:
            s.append(count)
            S2.append(SortedS[i])
            count = 1

M = max(s)
for i in range(len(s)):
    if s[i] == M:
        print(S2[i])

Measured memory_bytes: 24340
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;
int n;

int vis[20];
char s[20];

void dfs(int cur)
{
	if(cur==n+1){
		rep(i,1,n) putchar(s[i]);
		puts("");
		return ;
	}
	int i;
	for(i=1;vis[i];++i)
	{
		s[cur]=i-1+'a';	
		dfs(cur+1);
		s[cur]=0;
	}
	vis[i]=1;
	s[cur]=i-1+'a';
	dfs(cur+1);
	s[cur]=0;
	vis[i]=0;
}

int main()
{
//	freopen("std.in","r",stdin);
	cin>>n;
	dfs(1);
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define deb(x) cout<<#x<<" " <<x<<"\n";
#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define cr7 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
int main()
{
    cr7
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif
    ll x;
    cin >> x;
    ll p =100;
    ll t = 0;
    while(p < x){
        p += (p)/100;
        t++;
    }
    cout << t <<"\n";
    return 0;
}

Measured memory_bytes: 3588
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a,bbb=b;i<=bbb;++i)
#define repd(i,a,b) for(register int i=a,bbb=b;i>=bbb;--i)
#define reps(s) for(register int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define gmn(a,b) a=min(a,b)
#define gmx(a,b) a=max(a,b)
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
typedef double db;
const ll inf=4e18;
const ll mod=1e9+7;
const int MAX_N=2e5+5;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ql(){
	ll f=0;int fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline db qd(){
    char c=getchar();int flag=1;double ans=0;
    while((!(c>='0'&&c<='9'))&&c!='-') c=getchar();
    if(c=='-') flag=-1,c=getchar();
    while(c>='0'&&c<='9') ans=ans*10+(c^48),c=getchar();
    if(c=='.'){c=getchar();for(register int Bit=10;c>='0'&&c<='9';Bit=(Bit<<3)+(Bit<<1)) ans+=(double)(c^48)*1.0/Bit,c=getchar();}
    return ans*flag;
}
//start!
struct node{ ll x,y; }p[MAX_N];
int main()
{
	int n=qi();
	repi(i,1,n) p[i].x=ql(),p[i].y=ql();
	
	ll ans=-inf,mn=inf,mx=-inf;
	repi(i,1,n) gmx(mx,p[i].x+p[i].y),gmn(mn,p[i].x+p[i].y);
	gmx(ans,mx-mn);
	
	mn=inf,mx=-inf;
	repi(i,1,n) gmx(mx,p[i].x-p[i].y),gmn(mn,p[i].x-p[i].y);
	gmx(ans,mx-mn);
	
	mn=inf,mx=-inf;
	repi(i,1,n) gmx(mx,-p[i].x+p[i].y),gmn(mn,-p[i].x+p[i].y);
	gmx(ans,mx-mn);	
	
	mn=inf,mx=-inf;
	repi(i,1,n) gmx(mx,-p[i].x-p[i].y),gmn(mn,-p[i].x-p[i].y);
	gmx(ans,mx-mn);
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6872
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		double r = scan.nextDouble();
		double ans1 = r * r * Math.PI;
		double ans2 = r * 2 * Math.PI;

		System.out.printf("%.6f %.6f", ans1, ans2);
	}

}

Measured memory_bytes: 18892
/*
 * 2663.cc: RUPC
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 300000;
const int MAX_M = 300000;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N], bs[MAX_M];
ll asums[MAX_N + 1], cs[MAX_M];

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> as[i];
  sort(as, as + n);

  asums[0] = 0;
  for (int i = 0; i < n; i++) asums[i + 1] = asums[i] + as[i];

  int m;
  cin >> m;
  for (int i = 0; i < m; i++) cin >> bs[i];
  for (int i = 0; i < m; i++) cin >> cs[i];

  for (int i = 0; i < m; i++) {
    int k = upper_bound(as, as + n, bs[i]) - as;
    //printf("%d\n", k);
    cout << (asums[k] >= cs[i] ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 8164
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int K;
  string S;
  string Ans;
  cin>>K>>S;
  if (S.length()<=K)
    Ans=S;
  else
    Ans=S.substr(0,K)+"...";
  cout<<Ans;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string s = "", t = "";
    rep(i, ty-sy){
        s += 'U';
        t += 'D';
    }
    rep(i, tx-sx){
        s += 'R';
        t += 'L';
    }

    cout << s + t + "LU" + s + "RDRD" + t + "LU" << endl; 

    return 0;
}

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

int main( void ) {
    int n, m;
    while(cin >> n >> m && n + m){
        for( int i = 1; i <= n; ++i ) {
            for( int j = 1; j <= m; ++j ) {
                if( i == 1 || i == n || j == 1 || j == m ) cout << '#';
                else cout << '.';
            }
            cout << '\n';
        }
        cout << '\n';
    }
    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int a,b,c;cin>>a>>b>>c;
  int ans=0;
  if(a==b)ans=c;
  if(b==c)ans=a;
  if(c==a)ans=b;
  cout<<ans<<endl;
  return 0;
}


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

//def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

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

    ll n, m;
    cin >> n >> m;
    vl a(n);
    rep(i, n) {
        cin >> a[i];
        a[i] /= 2;
    }

    vi own_two_nums;
    bool ok = true;
    rep(i, n) {
        ll cp_a = a[i];
        int cnt = 0;
        while (cp_a % 2 == 0) {
            cp_a /= 2;
            cnt++;
        }
        own_two_nums.push_back(cnt);
    }
    sort(all(own_two_nums));
    if (own_two_nums.front() != own_two_nums.back()) ok = false;

    if (ok) {
        ll cnt = 1;
        rep(i, n) {
            cnt = lcm(cnt, a[i]);
        }
        ll ans = m / (cnt * 2);
        if (ans != (m + cnt) / (cnt * 2)) ans++;
        out(ans);
    } else {
        out(0);
    }

    return 0;
}


Measured memory_bytes: 1660
#include <cstdio>
#include <iostream>
using namespace std;
static const int MAX = 301;
static const int MAX_t = 1000;
int dev[MAX];
int testa[MAX_t], testb[MAX_t], testc[MAX_t];
bool solved[MAX_t];

int main() {

    int n, a, b, c, t, ta, tb, tc, res;
    for (; ;) {
        scanf("%d %d %d", &a, &b, &c);
        if (a == 0 && b == 0 && c == 0) break;
        n = a+b+c;
        fill(dev, dev+n+1, 2);
        scanf("%d", &t);
        fill(solved, solved+t, 0);
        for (int i = 0; i < t; i++) {
            scanf("%d %d %d %d", &ta, &tb, &tc, &res);
            if (res == 1) {
                dev[ta] = dev[tb] = dev[tc] = 1;
                solved[i] = true;
            }
            testa[i] = ta, testb[i] = tb, testc[i] = tc;
        }
        for (int i = 0; i < t; i++) {
            if (!solved[i] && ((dev[testa[i]] == 1 && dev[testb[i]] == 1) || (dev[testa[i]] == 1 && dev[testc[i]] == 1) ||
                               (dev[testb[i]] == 1 && dev[testc[i]] == 1))) {
                if (dev[testa[i]] == 2) dev[testa[i]] = 0;
                else if (dev[testb[i]] == 2) dev[testb[i]] = 0;
                else if (dev[testc[i]] == 2) dev[testc[i]] = 0;
                solved[i] = true;
            }
        }

        for (int i = 1; i <=n; i++) {
            printf("%d\n", dev[i]);
        }
    }


    return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define IOFAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define ll long long
#define fo(i,n) for(int i=0;i<n;i++)
 
#define pb push_back  
 
 
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            break;
        }
        
    }

}

Measured memory_bytes: 3588
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
else:
    res = 2019
    for i in range(l, r):
        for j in range(i+1, r+1):
            tmp = (i * j) % 2019
            res = min(res, tmp)
    print(res)

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

typedef unsigned long long ull;

mt19937_64 r(std::chrono::high_resolution_clock::now().time_since_epoch().count());

ull const MASK30 = (1<<30)-1;
ull const MASK31 = INT_MAX;
ull const MOD = (1LL<<61)-1;
ull const MOD5 = MOD*5;
ull const base = r()%MOD;

struct RollingHash {
private:
    vector<ull> power,hash;
public:
    inline ull mul(ull a,ull b) {
        ull au = a>>31;
        ull ad = (a&MASK31);
        ull bu = b>>31;
        ull bd = (b&MASK31);
        ull mid = au*bd+ad*bu;
        return ((au*bu)<<1)+ad*bd+(mid>>30)+((mid&MASK30)<<31);
    }

    inline ull calcmod(ull a) {
        a = (a&MOD)+(a>>61);
        if (a > MOD) a -= MOD;
        return a;
    }

    RollingHash(string& s) {
        int n = s.size();
        power.resize(n+1);
        hash.resize(n+1);
        power[0] = 1;
        hash[0] = 0;
        for (int i = 0;i < n;++i) power[i+1] = calcmod(mul(power[i],base));
        for (int i = 0;i < n;++i) hash[i+1] = calcmod(mul(hash[i],base)+s[i]);
    }

    ull get(int l, int r)  {
        if (l) return calcmod(hash[r]+MOD5-mul(hash[l],power[r-l]));
        return hash[r];
    }

    ull connect(ull h1,int l,int r) {
        ull h2 = get(l,r);
        return calcmod(mul(h1,power[r-l])+h2);
    }

    // [l,r)
    int LCP(int l1,int r1,RollingHash& rh,int l2,int r2) {
        int ok = 0,ng = min(r1-l1,r2-l2)+1;
        while (ng-ok > 1) {
            int mid = (ok+ng)/2;
            if (get(l1,l1+mid) == rh.get(l2,l2+mid)) ok = mid;
            else ng = mid;
        }
        return ok;
    }
};

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    RollingHash rh(s);
    int ok = 0,ng = n/2+1;
    while (ng-ok > 1) {
        map<ll,int> mp;
        int mid = (ok+ng)/2;
        bool f = false;
        for (int i = 0;i < n-mid+1;++i) {
            ull key = rh.get(i,i+mid);
            auto it = mp.find(key);
            if (it != mp.end()) {
                if (it->second < i+2-mid) {
                    f = true;
                    break;
                }
            } else mp[key] = i+1;
        }
        (f ? ok : ng) = mid;
    }
    cout << ok << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

const ll maxn =2e6;
const ll mod = 1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b) {
    return (!b ? 1 : (b & 1 ? a * pw(a * a % mod, b / 2) % mod : pw(a * a % mod, b / 2) % mod));
}

string s , t;
int  n;

int main(){
    migmig
    cin >> n >> s >> t;
    for (int i = 0 ; i < n ; i ++){
        cout << s[i] << t[i];
    }


    return(0);
}


//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.


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

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    char b;
    cin >> b;
    if (b == 'A')
    {
        Cout('T');
    }
    else if (b == 'C')
    {
        Cout('G');
    }
    else if (b == 'T')
    {
        Cout('A');
    }
    else
    {
        Cout('C');
    }
    return 0;
}

Measured memory_bytes: 256
until (given = gets.split.map(&:to_i)) == [0, 0]
  n, m = given
  g = n.times.map {gets.split.map(&:to_f)}
  memo = Array.new(101) {Array.new(101)}
  
  compost = ->(num, left) {
    return memo[num][left] if memo[num][left]
    memo[num][left] = if left.zero?
      1.0
    else
      n.times.map {|j| g[num][j] * compost.(j, left - 1)}.max
    end
  }
  printf "%.02f\n", n.times.map {|i| compost.(i, m - 1)}.max.round(2)
end


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

long long int monmo(long long int n,long long int k,int keta){
  if(n==0){return 0;
  }else if(keta<0){return n;
  }else{
  long long int tmpk;
  tmpk=k;
  for(int i=0;i<keta;i++){
    tmpk*=10;
  }
  while(n>=tmpk){
    n-=tmpk;
  }
  return monmo(n,k,keta-1);
  }
}

int main(void){
  long long int n,k,a,b,na,ka;
  int cn=0,ck=0;
  cin>>n>>k;
  na=n;
  ka=k;
  while(na>9){
      na/=10;
      cn++;
  }
  while(ka>9){
      ka/=10;
      ck++;
  }
  a=monmo(n,k,cn-ck);
  b=a-k;
  b*=-1;
  if(a>b)cout<<b;
  else cout<<a;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	REP(i, N - 2) {
		if (S[i] == 'A'&&S[i + 1] == 'B'&&S[i + 2] == 'C')ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D;
    cin >> D;
    if(D == 25) cout << "Christmas" << endl;
    else if(D == 24) cout << "Christmas Eve" << endl;
    else if(D == 23) cout << "Christmas Eve Eve" << endl;
    else cout << "Christmas Eve Eve Eve" << endl;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,z;
  cin>>x>>y>>z;
  int sum=z;
  for(int i=1;;i++){
    sum+=y+z;
    if(sum>x){
      cout<<i-1<<endl;
      break;
    }
  }
  return 0;
}


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

int n;

int func(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0){
            return 0;
        }
    }
    return 1;
}

int main(){
    cin >> n;
    while(!func(n)){
        n++;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
A = []
for i in range(h):
    s = list(map(int, input().split()))
    A.append(s)

#print(A)
S = []
for i in range(h):
    if i & 1:
        for j in range(w-1):
            if A[i][j] & 1:
                S.append([i+1, j+1, i+1, j+2])
                A[i][j+1] += 1
        if A[i][w-1] & 1 and i < h-1:
            S.append([i+1, w, i+2, w])
            A[i+1][w-1] += 1
    else:
        for j in reversed(range(1, w)):
            if A[i][j] & 1:
                S.append([i+1, j+1, i+1, j])
                A[i][j-1] += 1
        if A[i][0] & 1 and i < h-1:
            S.append([i+1, 1, i+2, 1])
            A[i+1][0] += 1

print(len(S))
for x in S:
    print(" ".join([str(n) for n in x]))


Measured memory_bytes: 66268
#include<iostream>
using namespace std;
int n,k,a,i;
long dp[111][2<<17],mod=1e9+7;
main()
{
	cin>>n>>k;
	dp[0][k]=1;
	for(;cin>>a;i++)
	{
		for(int j=k;j>=0;j--)
		{
			(dp[i+1][j]=dp[i][j]+dp[i+1][j+1]-dp[i][j+a+1]+mod)%=mod;
		}
	}
	cout<<dp[i][0]<<endl;
}

Measured memory_bytes: 205056
#include <stdio.h> 
int main(void)
{
	int A[100][100] = { 0 }, b[100] = { 0 }, c[100] = { 0 };
	int m, n, i, j;
	scanf("%d %d", &n, &m);
	for (i = 0;i < n;i++)
	{
		for (j = 0;j < m;j++)
		{
			scanf("%d", &A[i][j]);
		}
	}
	for (i = 0;i < m;i++)
	{
		scanf("%d", &b[i]);
	}
	for (i = 0;i < n;i++)
	{
		for (j = 0;j < m;j++)
		{
			c[i] = c[i] + A[i][j] * b[j];
		}
	}
	for (i = 0;i < n;i++)
	{
		printf("%d\n", c[i]);
	}

	return 0;
}

Measured memory_bytes: 648
#include<cstdio>
char s[300][301];
int main() {
	int n, i, j, k, sum = 0;
	bool flag;
	scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%s", s[i]);
	for (i = 0; i < n; i++) {
		flag = true;
		for (j = 0; j < n; j++) {
			for (k = 0; k < j; k++) {
				if (s[(i + j) % n][k] != s[(i + k) % n][j])flag = false;
			}
		}
		if (flag)sum++;
	}
	printf("%d", sum*n);
	return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n; readV(n);
  string[] s; readM(n, s);

  auto t = ['M', 'A', 'R', 'C', 'H'];

  auto h = new long[](5);
  foreach (si; s) {
    auto i = t.countUntil(si[0]);
    if (i >= 0) h[i]++;
  }

  auto calc(int a, int b, int c)
  {
    return h[a].to!long * h[b] * h[c];
  }

  auto r =
    calc(0, 1, 2) + calc(0, 1, 3) + calc(0, 1, 4) + calc(0, 2, 3) + calc(0, 2, 4) +
    calc(0, 3, 4) + calc(1, 2, 3) + calc(1, 2, 4) + calc(1, 3, 4) + calc(2, 3, 4);
  writeln(r);
}


Measured memory_bytes: 4988
s = input()
li = [int(a) for a in s]
tem = []
cnt = 0
for i in range (len(li)):
    if i%2 == 1:
        tem.append(0)
    else:
        tem.append(1)
    if li[i] == tem[i]:
        cnt+= 1
if cnt <= (len(li) / 2):
    print(str(cnt))
else:
    print(str(len(li) - cnt))


Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sidha(i,a,b) for(int i=a;i<b;i++)
#define vi vector<int> 
#define pb push_back
#define st string
#define pairi pair<int,int>

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  double n;cin>>n;
	double x=ceil(n/2);
	cout<<x<<endl;
  return 0;
}

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

int main()
{
	int P;
	int Q;
	int R;
	int minsum=0;
	scanf("%d %d %d",&P,&Q,&R);
	if((P<=Q)&(R<=Q)) minsum=P+R;
	if((Q<=P)&(R<=P)) minsum=R+Q;
	if((P<=R)&(Q<=R)) minsum=P+Q;
	printf("%d\n",minsum);
	return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    val a = intArrayOf(1, 3, 5, 7, 8, 10, 12)
    val b = intArrayOf(4, 6, 9, 11)
    val (x, y) = readLine()!!.split(' ').map(String::toInt)
    println(if ((x == 2 && y == 2) || (x in a && y in a) || (x in b && y in b)) "Yes" else "No")
}


Measured memory_bytes: 38272
import java.util.Scanner;
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(a<b){
            if(b<c){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26328
cnt = Hash.new(0)
s = gets.chomp.split("")
s.each do |ch|
  cnt[ch] += 1
end
flag = 0
cnt.each do |key, num|
  if num % 2 == 1
    puts "No"
    flag += 1
    break
  end
end
if flag == 0
  puts "Yes"
end

Measured memory_bytes: 1788
local mfl, mce, mmi = math.floor, math.ceil, math.min
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  for i = 1, n do self.stage[stagenum][i] = i end
  for i = n + 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local start_stage = 1
  while right - left + 1 < self.size[start_stage] do
    start_stage = start_stage + 1
  end
  local ret = self.emptyvalue
  local t1, t2, t3 = {start_stage}, {left}, {right}
  while 0 < #t1 do
    local stage, l, r = t1[#t1], t2[#t1], t3[#t1]
    table.remove(t1) table.remove(t2) table.remove(t3)
    local sz = self.size[stage]
    if (l - 1) % sz ~= 0 then
      local newr = mmi(r, mce((l - 1) / sz) * sz)
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)
      l = newr + 1
    end
    if sz <= r + 1 - l then
      ret = self.func(ret, self.stage[stage][mce(l / sz)])
      l = l + sz
    end
    if l <= r then
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)
    end
  end
  return ret
end
SegTree.update = function(self, idx, value)
  for i = self.stagenum - 1, 1, -1 do
    local dst = mce(idx / 2)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
    idx = dst
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local n, m = io.read("*n", "*n", "*l")
local s = io.read()
local map = {}
for i = 1, n + 1 do
  map[i] = s:sub(i, i) == "0"
end
local len = {}
local inf = n + 2
for i = 1, n do
  len[i] = inf
end
len[n + 1] = 0
len[n + 2] = inf
local st = SegTree.new(n + 2, function(a, b) return len[a] < len[b] and a or b end, n + 2)
st:updateAll()
for i = n, 1, -1 do
  if map[i] then
    local right = mmi(n + 1, i + m)
    local minpos = st:getRange(i + 1, right)
    len[i] = len[minpos] + 1
    st:update(i)
  end
end
if inf <= len[1] then
  print(-1)
else
  local cur, curpos = len[1], 1
  local ret = {}
  for i = 2, n + 1 do
    if cur == len[i] + 1 then
      table.insert(ret, i - curpos)
      cur, curpos = cur - 1, i
    end
  end
  print(table.concat(ret, " "))
end


Measured memory_bytes: 9952