akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;
void LF_Prime_Sequence(const long &n, vector<long> &viPrime){
    if(n < 2){
        return;
    }
    viPrime.clear();
    vector<char> aiType(n + 1,0);
    long iTmp = 2;
    while(true){
        if(iTmp * iTmp > n){
            break;
        }
        for(long j = iTmp; j * iTmp <= n; j++){
            aiType[j * iTmp] = 1;
        }
        for(long j = iTmp+1; j <= n; j++){
            if(aiType[j] == 0){
               iTmp = j;
               break;
            }
        }
    }
    for (long i = 2; i <= n; i++){
        if(aiType[i] == 0){
            viPrime.push_back(i);
        }
    }
    return;
}

//素因数分解(上とセット)
void LF_Factorization(long n, vector<pair<long, long>> &viiFactor){
    if(n < 2){
        return;
    }
    vector<long> viPrime;
    LF_Prime_Sequence(sqrt(n)+1, viPrime);

    for(long i = 0; i < viPrime.size(); i++){
        if(n == 1){
            break;
        }
        long nCount = 0;
        while(n % viPrime[i] == 0){
            n /= viPrime[i];
            nCount++;
        }
        if(nCount > 0){
            viiFactor.push_back(make_pair(viPrime[i], nCount));
        }
    }
    if(n > 1){
        viiFactor.push_back(make_pair(n, 1));
    }
    return;
}

int main(){
    long n;
    scanf("%ld", &n);
    vector<pair<long, long>> viiFactor;
    LF_Factorization(2*n, viiFactor);
    int m = viiFactor.size();
    vector<long> viPowOfFactor(m,1);
    for(int i = 0; i < m; i++){
        for(int j = 0; j < viiFactor[i].second; j++){
            viPowOfFactor[i] *= viiFactor[i].first;
        }
    }
    
    long nAns = 1.0e+18;
    for(int i = 0; i < 1<<m; i++){//相異なる素因数の個数はどうせ高々15個程度なので大丈夫
        long a = 1,b = 1;   //(a,b):互いに素かつab=2nとなるように素因数を分配する
        for(int j = 0; j < m; j++){
            if((i >> j) % 2 == 0){
                a *= viPowOfFactor[j];
            } else {
                b *= viPowOfFactor[j];
            }
        }
        //(k+1)|a, k|bなるkを求める
        long aTmp = a, bTmp = b, u = 1, v = 0; 
        while (bTmp > 0) {
            long t = aTmp / bTmp;
            aTmp -= t * bTmp;
            swap(aTmp, bTmp);
            u -= t * v;
            swap(u, v);
        }
        u %= b;
        if (u <= 0){
            u += b;
        }
        if(a == 1){
            u += b;
        }
        nAns = min(a*u-1, nAns);
    }
    
    printf("%ld", nAns);
    
    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    int n;
    scanf("%d",&n);
    vector<array<ll,2>> v(n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&v[i][0]);
        v[i][1]=i;
    }
    sort(v.begin(),v.end());
    vector<vector<ll>> dp(n,vector<ll>(n,0));
    for(int i=0;i<n;i++) dp[i][i]=(v[0][0]*abs(v[0][1]-i));
    for(int o=1;o<=n-1;o++)
    {
        for(int l=0;l+o<n;l++)
        {
            int r=l+o;
            dp[l][r]=max(dp[l][r-1]+v[o][0]*abs(v[o][1]-r),dp[l+1][r]+v[o][0]*abs(v[o][1]-l));
        }
    }
    printf("%lld\n",dp[0][n-1]);
    return 0;
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

template<class T> ostream& operator<<(ostream& os, const V<T> &v) {
    cout << "[";
    for (auto p: v) cout << p << ", ";
    cout << "]";
    return os;
}

struct Prime {
    int n;
    vector<bool> used;
    vector<int> pr;
    vector<ull> bpr;
    Prime(int n) : n(n) {
        used = vector<bool>(n+1, false);
        for (int i = 2; i <= n; i++) {
            if (used[i]) continue;
            pr.push_back(i);
            bpr.push_back(((__int128(1)<<64)+i-1) / i);
            for (int j = 2*i; j <= n; j += i) {
                used[j] = true;
            }
        }
    }
    map<ll, int> fact(ll x) {
        assert(x <= (ll)n*n);
        int pc = (int)pr.size();
        map<ll, int> mp;
        for (int i = 0; i < pc; i++) {
            ll d = pr[i]; ull rd = bpr[i];
            if (x < d*d) break;
            while (true) {
                ll xd = __int128(x)*rd >> 64;
                if (xd * d != x) break;
                x = xd;
                mp[d]++;
            }
        }
        if (x > 1) mp[x]++;
        return mp;
    }
};

const int MN = 500;
//const int MN = 10;

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;
    Prime pr(100000);
//    cout << pr.pr[499] * pr.pr[500] << endl;
//    cout << pr.pr[999] * pr.pr[1000] << endl;
    VV<ll> mat(MN, V<ll>(MN, 1));
    int cnt = 0;
//    set<ll> st;
    for (int y = 0; y < MN; y++) {
        for (int x = 0; x < MN; x++) {
            if ((x + y) % 2) continue;
//            assert(mat[y][x] == 1);
            mat[y][x] = pr.pr[(x+y)/2] * pr.pr[MN + (MN/2+(x-y)/2)];
//            assert(st.count(mat[y][x]) == 0);
//            st.insert(mat[y][x]);
        }
    }
/*    for (int y = 0; y < MN; y++) {
        cout << mat[y] << endl;
    }*/
    ll ans = 0;
    for (int y = 0; y < MN; y++) {
        for (int x = 0; x < MN; x++) {
            if (mat[y][x] > 1) continue;
            ll z = 1;
            if (y) z = lcm(z, mat[y-1][x]);
            if (x) z = lcm(z, mat[y][x-1]);
            if (y < MN-1) z = lcm(z, mat[y+1][x]);
            if (x < MN-1) z = lcm(z, mat[y][x+1]);
            z++;
            mat[y][x] = z;
//            assert(st.count(z) == 0);
//            st.insert(z);
//            ans = max(ans, z);
        }
    }
//    cout << ans << endl;

    int n;
    cin >> n;
    for (int y = 0; y < n; y++) {
        for (int x = 0; x < n; x++) {
            cout << mat[y][x] << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define l_ength size
using ll = long long;
const int mod = 1000000007;
const ll infll = (1ll<<60);
using namespace std;

ll dp[2500000];

int main(){
	int n; cin >> n;
	int a[n][n];
	for( int i = 0; i < n; ++i ){
		for( int j = 0; j < n; ++j ){
			cin >> a[i][j];
		}
	}
	int bound = (1<<(n));
	dp[0] = 1;
	for( int cond = 0; cond < bound; ++cond ){
		for( int j = 0; j < n; ++j ){
			int i = (bitset<22>(cond)).count();
			if( a[i][j] == 1 && !(cond&(1<<j)) ){
				dp[cond|(1<<j)] += dp[cond];
				dp[cond|(1<<j)] %= mod;
			}
		}
	}
	cout << dp[bound-1] << endl;
}

Measured memory_bytes: 18688
#include<bits/stdc++.h>
using ll = int_fast64_t;

int main(){
        ll a, b, q;
        scanf("%ld %ld %ld", &a, &b, &q);

        std::vector<ll> shrine(a+2);
        shrine[0]=-1e18; shrine[a+1]=1e18;
        for(ll i=1; i<=a; i++) scanf("%ld", &shrine[i]);

        std::vector<ll> temple(b+2);
        temple[0] = -1e18; temple[b+1] = 1e18;
        for(ll i=1; i<=b; i++) scanf("%ld", &temple[i]);


        for(ll i=0; i<q; i++){
                ll x;
                scanf("%ld", &x);

                ll tmps = std::lower_bound(shrine.begin(), shrine.end(), x) - shrine.begin();
                ll tmpt = std::lower_bound(temple.begin(), temple.end(), x) - temple.begin();

                ll mins=shrine[tmps-1]-x, maxs=shrine[tmps]-x;
                ll mint=temple[tmpt-1]-x, maxt=temple[tmpt]-x;

                ll ltol = -std::min(mins, mint), rtor = std::max(maxs, maxt);
                ll ltor = std::min(maxt-mins*2, maxs-mint*2), rtol = std::min(maxt*2-mins, maxs*2-mint);

                printf("%ld\n", std::min({ltol, rtor, ltor, rtol}));
        }
        return 0;
}

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

int main()
{
   int d, t, s;
   cin>>d>>t>>s;
   int acutaltime = (d+s-1) / s;
   if(acutaltime<=t){
      cout<<"Yes"<<"\n";
   }
   else cout<<"No"<<"\n";
   return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
char mas[110][110];
int dx[4] = {0,-1,0,1},dy[4] = {-1,0,1,0};
int H,W;
int ans;
void dfs(int x, int y);
int main(){
  while(1){
    scanf("%d %d",&H,&W);
    ans = 0;
    if(H == 0 && W == 0)break;
    for(int i = 0; i < H; i++){
      cin >> mas[i];
    }
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
	if(mas[i][j] != '.'){
	  dfs(j,i);
	  ans++;
	}
      }
    }
    printf("%d\n",ans);
  }
}
void dfs(int x, int y){
  char m = mas[y][x];
  mas[y][x] = '.';
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(m == mas[ny][nx] && nx < W && nx >= 0 && ny < H && ny >= 0 && mas[ny][nx] != '.'){
      dfs(nx,ny);
    }
  }
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  char c;
  cin >> c;
  if(c >= 'A' && c <= 'Z')
    cout << 'A' << endl;
  else
    cout << 'a' << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(void){
    int n,i,j,y;
    while(scanf("%d",&n) != EOF){
        for(i = n-1;i >= 0;i--){
            y = 1;
            for(j = 2;j <= i - 1;j++){
                if (!(i % j)){
                    y = 0;
                    break;
                }
            }
            if (y){
                printf("%d " , i);
                break;
            }
        }
        for (i = n+1;i <= 99999;i++){
            y = 1;
            for (j = 2;j <= i - 1;j++){
                if(!(i % j)){
                    y = 0;
                    break;
                }
            }
            if(y){
                printf("%d\n" , i);
                break;
            }
        }
    }
    return 0;
}

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

int main(){
  int n, x, ans, min = 10e4, mi;
  cin >> n >> x;
  while(cin >> mi){
    x -= mi;
    ans++;
    if(min > mi){
      min = mi;
    }
  }
  cout << ans + (int)(x / min) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
    char s[11];
    scanf("%s", s);
    if (strlen(s)%2==1) printf("No\n");
    else {
        for (int i=0;s[i]!='\0';i++) {
            if (i%2==0&&s[i]!='h'||i%2==1&&s[i]!='i') {
                printf("No\n");
                return 0;
            }
        }
        printf("Yes\n");
    }
}


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    
    int row,col,thres;
    cin>>row>>col>>thres;

    vector<vector<int>> matrix(row, vector<int>(col));

    vector<int> c(row);

    for(int i=0;i<row;i++) {
        int cost;
        cin>>cost;
        c[i]=cost;
        for(int j=0;j<col;j++) {
            int num;
            cin>>num;
            matrix[i][j]=num;
        }
    }

    int all=1<<row;
    int ans=12345678;

    for(int mask=0;mask<all;mask++) {
        vector<int> level(col);
        int total_cost=0;

        for(int i=0;i<row;i++) {
            if((mask>>i)&1) {
                total_cost+=c[i];
                for(int j=0;j<col;j++) {
                    level[j]+=matrix[i][j];
                }
            }
        }

        bool ok=true;
        for(int z=0;z<level.size();z++) {
            if(level[z]<thres) ok=false;
        }

        if(ok) ans=min(ans,total_cost);
    }

    if(ans==12345678) cout<<-1<<endl;
    else cout<<ans<<endl;

}




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

int main() {
  int A,B,j;
  cin >> A >> B;
  for(int i=0; i<=B; i++){
    if(i<A){
      continue;
    }
    if((i/10000) == (i-10*(i/10)) && 10*(i/10000)-(i/1000) == 10*(i/100)-(i/10)){
      j++;
    }
  }
  cout << j << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	int w,a,b,c,d;
	cin>>w>>a>>b;
	c=min(a,b);
	d=max(a,b);
	if (d-(c+w)>0){
    	cout<<d-(c+w);
    }else{
    	cout<<0;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] main_1){
        Scanner scanner = new Scanner(System.in);
        int main_2 = scanner.nextInt();
        String[] main_3 = new String[main_2];
        for(int main_4 = 0;main_4 < main_2;main_4++){
            String main_5 = scanner.next();
            main_3[main_4] = main_5;
        }
        if(main_a(Arrays.asList(main_3))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
    static boolean main_a(List<String> main_a_1){
        Set<String> main_a_2 = new HashSet<String>();
        for(String main_a_3 : main_a_1) {
            if(main_a_2.contains(main_a_3)) {
                return false;
            } else {
                main_a_2.add(main_a_3);
            }
        }
        for(int main_a_5 = 0;main_a_5 < main_a_1.size();main_a_5++){
            if(main_a_5 != 0){
                String main_a_6 = main_a_1.get(main_a_5 - 1);
                String main_a_7 = main_a_1.get(main_a_5);
                if(!main_a_6.substring(main_a_6.length() - 1).equalsIgnoreCase(main_a_7.substring(0, 1))){
                    return false;
                }
            }
        }
        return true;
    }
}

Measured memory_bytes: 23120
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    # 素因数分解　10**12でもOK
    def prime_factorize(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a

    n = ni()

    diver = []

    for i in range(2, n + 1):
        tmp = prime_factorize(i)
        diver.extend(tmp)

    c = collections.Counter(diver)

    ans = 1
    for v in c.values():
        ans *= v + 1
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14428
from itertools import combinations
from cmath import phase
N = int(input())
XY = [complex(*map(int, input().split())) for _ in range(N)]
XY.sort(key=phase)
XY += XY
print(max(abs(sum(XY[i:j])) for i, j in combinations(range(N*2+1), 2) if j-i<=N))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  cin >> N >> M;
  vector<bool> A(N+1,false);
  rep(i,M) {
    int a; cin >> a;
    A[a] = true;
  }
  int ans = 0;
  vi step(N+1,0);
  step[0] = 1;
  if(A[1]) step[1] = 0;
  else step[1] = 1;
  repa(i,2,N+1){
    if (A[i] == true) step[i] = 0;
    else step[i] = step[i-1]+step[i-2];
    step[i] %= mod;
  }
  cout << step[N] << endl;
  return 0;
}


Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int k;
  cin >> n>>k;
  set<int> s;
  for(int i=0;i<k;i++){
    int d;
    cin >> d;
    s.insert(d);
  }
  int ans;
  bool ok=1;
  for(ans=n;ans<100000;ans++){
    int v=ans;
    ok=1;
    while(v>=1){
      if(s.count(v%10)){
        ok=0;
        break;
      }else{
        v/=10;
      }
    }
    if(ok){
      cout<<ans<<endl;
      return 0;
    }
  }
}
   



Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int g, int[][] ps) {
    int n = cast(int)ps.length;

    int ans = int.max;
    for (int i = 0; i < (1 << n); i++) {
        int score = 0;
        int solved = 0; // 解いた問題数
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) { // j は全て解く
                score += 100 * (j+1) * ps[j][0] + ps[j][1];
                solved += ps[j][0];
            }
        }

        if (score >= g) {
            ans = min(ans, solved);
        }
        else {
            // score が足りないなら、まだ解いていない問題から点数の高い問題を解く
            for (int j = n-1; j >= 0; j--) {
                if (i & (1 << j)) continue;

                int s = 100 * (j+1) * ps[j][0]; // 得られるスコア
                int x = g - score; // 不足分のスコア
                if (x <= s) {
                    int r = x / (100 * (j+1));
                    int m = x % (100 * (j+1));

                    solved += r + (m > 0 ? 1 : 0);
                    ans = min(ans, solved);
                }
                break;
            }
        }
    }

    return ans;
}

void main() {
    auto dg = readints;
    int d = dg[0], g = dg[1];

    int[][] ps;
    for (int i = 0; i < d; i++) {
        ps ~= readints;
    }
    writeln(calc(g, ps));
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <algorithm>

typedef int32_t i32;
typedef int64_t i64;

template<typename T>
inline bool update_min(T &min, T const &new_one) {
    if (new_one < min) {
        min = new_one;
        return true;
    }
    return false;
}

constexpr size_t kMaxN = 2e5 + 5;

i32 a[kMaxN];
i64 suma[kMaxN];

i64 diff_sum(size_t begin, size_t p, size_t end) {
    i64 l = suma[p] - suma[begin];
    i64 r = suma[end] - suma[p];
    return std::abs(r - l);
}

void pointer_forward(size_t begin, size_t &p, size_t end) {
    while (p <= begin) {
        ++p;
    }

    i64 min = diff_sum(begin, p, end);
    while (p < end &&
            update_min(min,
                diff_sum(begin, p+1, end))) {
        ++p;
    }
}

i64 min_diff_sum(size_t x, size_t y, size_t z, size_t n) {
    i64 s[] = {
        suma[x],
        suma[y] - suma[x],
        suma[z] - suma[y],
        suma[n] - suma[z]
    };

    // printf("%zd %zd %zd\n", x, y, z);

    return std::abs(*std::max_element(s, s+4) -
            *std::min_element(s, s+4));
}

int main() {
    size_t n;
    scanf("%zd", &n);

    for (size_t i = 0; i < n; ++i) {
        scanf("%" SCNi32, a+i);
    }

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

    i64 min_diff;
    if (true) {
        size_t l = 1;
        size_t d = 2;
        size_t r = 3;
        // [0, l) [l, d) [d, r) [r, n)

        pointer_forward(d, r, n);

        min_diff = min_diff_sum(l, d, r, n);

        for (d += 1; d <= n-2; ++d) {
            pointer_forward(0, l, d);
            pointer_forward(d, r, n);
            update_min(min_diff, min_diff_sum(l, d, r, n));
        }
    }

    printf("%" PRIi64 "\n", min_diff);
    return 0;
}



Measured memory_bytes: 2560
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        r: u32
    }
    if r < 1200 {
        println!("ABC");
    } else if r < 2800 {
        println!("ARC");
    } else {
        println!("AGC");
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#define N 101
#define INF 10000000
#define NIL -1

int main()
{
  int n, i, j, u, min=0, sum=0;
  int G[N][N];
  int d[N], pi[N], color[N];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &G[i][j]);
      if(G[i][j] == -1) G[i][j] = INF;
    }
  }

  for(i = 0; i < n; i++){
    d[i] = INF;
    pi[i] = NIL;
    color[i] = 1;
  }

  d[0] = 0;

  while(1){
    min = INF;
    for(i = 0; i < n; i++){
      if(color[i] != 2 && d[i] < min){
  	min = d[i];
  	u = i;
      }
    }

    if(min == INF) break;

    color[u] = 2;
    for(i = 0; i < n; i++){
      if(color[i] != 2 && G[u][i] < d[i]){
  	pi[i] = u;
  	d[i] = G[u][i];
      }
    }
  }

  for(i = 0; i < n; i++){
    if(pi[i] != NIL) sum += G[i][pi[i]];
  }

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

  return 0;
}

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

int main ()
{
	long long int a,b,c,d1,d2;
	scanf ("%lld %lld",&a,&b);
	c= ((b-a)/2);
	d1= (a+c);
	d2= (b-c);
	if (d1==d2)
	{
		printf ("%lld\n",d1);
	}
	else 
	{
		printf ("IMPOSSIBLE\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
int main(){
    using namespace std;
    vector<int> vec(26);
    string str;
    while(getline(cin,str)){
    for(int i{0}; i<str.size(); i++){
        if(str[i]>='a'&&str[i]<='z') {vec[ str[i] - 'a' ]++;}
        else if(str[i]>='A'&&str[i]<='Z') {vec[ str[i] - 'A' ]++;}
    }}
    for(int i{0}; i<26; i++){
        cout << (char)('a'+i) << " : " << vec[i] << endl;
    }
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  S += 'A';
  
  vector<char> f;
  for(int i,j; i < N+1; j++ ){
    int count = 1;
    if(i < N){
    while(S.at(i) == S.at(i+count)){
      count++;
    }
    }
    f.push_back(S.at(i));
    i += count;
    
  }
  
  cout << f.size()-1 << endl;

}

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

using namespace std;

int main()
{
    int H, W, i;
    string dot, t;

    while (i < 100000)
    {
        t = "";
        dot = "#";

        cin >> H >> W;
        if (H == 0 && W == 0)
        {
            break;
        }

        for (int i = 0; i < W; i++)
        {
            t += "#";
        }

        for (int i = 0; i < W - 2; i++)
        {
            dot += ".";
        }
        dot += "#";

        cout << t << endl;
        for (int i = 0; i < H - 2; i++)
        {
            cout << dot << endl;
        }
        cout << t << endl;
        cout << endl;
    }
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,su,i,f=0,j,a;
  cin >> n >> k;
  
  for(i=1;true;i++)
  {
    a=k;
    for(j=1;j<i;j++)
    {
      a*=k;
    }
    if(a>n)
      break;
  }
  
  cout << i << endl;
  
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>


using namespace std;

typedef long long LL;

LL nall[55];
LL p1[55];

LL h1(int n,LL k)
{
    LL ans =0;
    if (k == 0)
        return 0;
    if (n == 0)
        return 1;

    if (k >= 1+nall[n-1])
        ans += p1[n-1];
    else
    {
        //cout<<n<<' '<<k<<' '<<ans<<"break"<<endl;
        return h1(n-1,k-1);
    }
    if (k >= 2+nall[n-1])
        ans ++;
    if (k >= 3+nall[n-1])
        ans += h1(n-1,k-nall[n-1]-2);
    //cout<<n<<' '<<k<<' '<<ans<<endl;
    return ans;
}


int main()
{
    
    LL k=1;
    LL p=1;
    nall[0] =1;
    p1[0] =1;
    for (int i=1; i<=50; i++)
    {
        k *=2;
        p *=2;
        ++p;
        k+=3;
        nall[i] = k;
        p1[i] = p;
        //cout<<k<<' '<<p<<endl;
    }
    LL N,K;
    cin>>N>>K;
    cout<<h1(N,K)<<endl;





#ifdef VSCode
    system("pause");
#endif
    return 0;
}

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

int main() {
  int A, B;
  string op;
  cin >> A >> op >> B;

  if (op == "+")
    cout << A+B << endl;
  else if (op == "-")
    cout << A-B << endl;
    // ここにプログラムを追記
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int MaxSize = 100005;
int main()
{
    int a, b;
    int c, d;
    cin >> a >> b;
    cin >> c >> d;
    if(a == 1 && b == 31 && c == 2 && d == 1)
    {
        cout << "1" << endl;
    }
    else if(a == 2 && b == 28 && c == 3 && d == 1)
    {
        cout << "1" << endl;
    }
    else if(a == 3 && b == 31 && c == 4 && d == 1)
    {
        cout << "1" << endl;
    }
    else if(a == 4 && b == 30 && c == 5 && d == 1)
    {
        cout << "1" << endl;
    }
    else if(a == 5 && b == 31 && c == 6 && d == 1)
    {
        cout << "1" << endl;
    }
    else if(a == 6 && b == 30 && c == 7 && d == 1)
    {
        cout << "1" << endl;
    }
    else if(a == 7 && b == 31 && c == 8 && d == 1)
    {
        cout << "1" << endl;
    }
    else if(a == 8 && b == 31 && c == 9 && d == 1)
    {
        cout << "1" << endl;
    }
    else if(a == 9 && b == 30 && c == 10 && d == 1)
    {
        cout << "1" << endl;
    }
    else if(a == 10 && b == 31 && c == 11 && d == 1)
    {
        cout << "1" << endl;
    }
    else if(a == 11 && b == 30 && c == 12 && d == 1)
    {
        cout << "1" << endl;
    }
    else if(a == 12 && b == 31 && c == 1 && d == 1)
    {
        cout << "1" << endl;
    }
    else
    {
        cout << "0" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
a = [-int(x) for x in input().split()]
heapq.heapify(a)

for i in range(m):
    l = -heapq.heappop(a)
    heapq.heappush(a, -(l//2))
    
print(-sum(a))

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

int main(){
    long long n, k; cin >> n >> k;
    vector<long long> h(n);

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

    sort(h.begin(),h.end(), greater<long long>());
    
    long long sum = 0;
	for(long long i = k; i < n; i++){
        sum += h[i];
    } 
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  init();
  ll N;
  cin >> N;
  ll nn = N;
  ll a = 0;
  while (N > 0) {
    ll b = N % 10;
    a += b;
    N /= 10;
  }

  if (nn % a == 0) {
    COUT("Yes");
  } else {
    COUT("No");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << endl;}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	var(int, a, b);
	print((a * b & 1) ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        for(int i=0;i<9;i++){
            String name=sc.next();
            int s1=sc.nextInt();
            int s2=sc.nextInt();
            System.out.println(name+" "+(s1+s2)+" "+(s1*200+s2*300));
        }
    }
}


Measured memory_bytes: 26428
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

template <class Integer>
auto boost_irange(Integer last) { return boost::irange(static_cast<Integer>(0), last); }
template <class Integer>
auto boost_irange(Integer first, Integer last) { return boost::irange(first, last); }

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }
};

int main()
{
    input in;
    output out;

    std::uint64_t L, R;
    in >> L, R;

    auto min = std::numeric_limits<std::uint64_t>::max();
    for (auto i : boost::irange(L, std::min(L + 2019, R + 1))) {
        for (auto j : boost::irange(i + 1, std::min(L + 2019, R + 1))) {
            min = std::min(min, (i * j) % 2019);
        }
    }
    out << min;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
//以下数组下标统一0开始
char s[20];
long long ans, n;//n存下字符串长，方便使用
bool pls[20];//第i个为true表示在数字i和i+1间有加号
long long calc() {//计算结果
    //main函数提前处理了字符（s[i]-='0'）
    long long t = 0, sum = 0;
    for (int i = 0; i < n - 1; ++i) {//注意边界是<n-1
        t = t * 10 + s[i];//先加当前位
        if (pls[i]) {//如果有+
            sum += t;
            t = 0;//记得清0
        }
    }
    t = t * 10 + s[n - 1];//不要忘记最后一位数
    return t + sum;//结果也要加上
}
void dfs(int k) {
    if (k == n - 1) {
        ans += calc();
        return;
    }
    pls[k] = false;//不加+
    dfs(k + 1);
    pls[k] = true;
    dfs(k + 1);
}
int main() {
    cin >> s;
    n = strlen(s);
    for (int i = 0; i < n; ++i) {
        s[i] -= '0';
    }
    dfs(0);//是从0开始
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
//const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int mod = 2020;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n, int m) {
  if (n == 0) return 1;
  mint x = f(n/2,m);
  x *= x;
  if (n%2 == 1) x *= m;
  return x;
}

int main() {
    int n; cin >> n;
    int ans = log2(n);
    ans = pow(2,ans);
    cout << ans << endl;
}

Measured memory_bytes: 256
num = input()

ls = [0] * 3
for i in range(2 ** 3):
    make7 = int(num[0])
    for j in range(3):
        if (i >> j) & 1:
            make7 += int(num[j+1])
            ls[j] = "+"
        else:
            make7 -= int(num[j+1])
            ls[j] = "-"
    if make7 == 7:
        print(num[0] + ls[0] + num[1] + ls[1] + num[2] + ls[2] + num[3] + "=7")
        exit()


Measured memory_bytes: 9148
#include<bits/stdc++.h>
#define rg register long long
#define inf 21474899993647
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define ll long long
#define maxn 100005
#define endl "\n"
#define   N 6000
const double eps=1e-8;
using namespace std;
inline ll read()
{
    char ch=getchar();
    ll s=0,w=1;
    while(ch<48||ch>57)
    {
        if(ch=='-')
            w=-1;
        ch=getchar();
    }
    while(ch>=48&&ch<=57)
    {
        s=(s<<1)+(s<<3)+(ch^48);
        ch=getchar();
    }
    return s*w;
}
inline void write(ll x)
{
    if(x<0)
        putchar('-'),x=-x;
    if(x>9)
        write(x/10);
    putchar(x%10+48);
}
priority_queue<double,vector<double>,greater<double> >q;
int main()
{
  ll n=read();
  for(rg i=1;i<=n;i++)
  {
      double x=read();
      q.push(x);
  }
  double ans=0;
  while(!q.empty())
  {
      double a=q.top();
      q.pop();
      if(!q.empty())
      {double b=q.top();
      q.pop();
      q.push((a+b)/2.0);
      ans=(a+b)/2.0;
      }
  }
  cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a;
  cin >> a;
  int ans = 1;
  int tmax = 0;
  for(int i = 2; i <= 9;i ++){
    REP(j, 34){
      if(pow(j, i)<= a){
	int tmp = pow(j, i);
	ans =max(ans, tmp);
      }else{
	break;
      }
    }
  }
  cout << ans << endl;
}


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

//#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
    int n;
    cin>>n;
    int a[n];
    int su=1;
    int co=0;
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        if (su==a[i]){
            su++;
        }
        else{
            co++;
        }
    }
    if ((co!=n) ? cout<<co<<endl : cout<<-1<<endl);  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N = 1e5 + 5;
int a[N], b[N];
int n, w;
ll mem[100][N];
int oo = 0x3f3f3f3f;
ll solve(int i, int rem){
    if(rem <= 0)
        return 0;
    if(i == n)
        return oo;
    ll &ret = mem[i][rem];
    if(~ret)
        return ret;
    return ret = min(solve(i+1, rem), solve(i+1, rem-b[i]) + a[i]);
}

int main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false), cin.tie(0);
#endif
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    memset(mem, -1, sizeof(mem));
    cin>>n>>w;
    for(int i=0; i<n; i++)
        cin>>a[i]>>b[i];
    int low = 0, hi = 1e5, mid;
    while(low < hi){
        mid = (low+hi+1)>>1;
        if(solve(0, mid) <= w)
            low = mid;
        else
            hi = mid-1;
    }
    cout<<low<<endl;
}

Measured memory_bytes: 81764
import itertools as itr

a = int(input())
p = list(map(int,input().split()))
mod = 10**9 + 7
ans =0
sum_list = list(itr.accumulate(p))
for i in range(len(p)-1):
    o = p[i+1]
    w =sum_list[i]
    ans = (ans+o*w%mod)%mod
print(ans)

Measured memory_bytes: 31064
#include <bits/stdc++.h>
#define INF 99999999999

using namespace std;

typedef long long ll;

int main(){
	int n, k;
	cin >> n >> k;
	ll cost[n];
	fill(cost, cost+n, INF);
	cost[0] = 0;
	int h[n];
	for(int i = 0; i < n; i++){
		cin >> h[i];
		for(int j = 0; j < k; j++){
			if(i-j > 0)cost[i] = min(cost[i-j-1]+abs(h[i]-h[i-j-1]), cost[i]);
		}
	}
	cout << cost[n-1] << endl;
    return 0;
}


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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int n;
	cin >> n;
	int num = 1;
	while(1){
		if(num*2 > n){
			P(num);
			return;
		}else {
			num *= 2;
		}
	}
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
    
int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2; i<n; i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	string s;
	cin >> s;
	bool ans = true;
	ll n;
	n = s.size();
	string rs;
	rs = s;
	reverse(rs.begin(), rs.end());
	rep(i, n)
	{
		if (s[i] != rs[i])
		{
			ans = false;
		}
	}
	string a, b;
	rep(i, (n - 1) / 2)
	{
		a.push_back(s[i]);
		b.push_back(s[i + (n + 1) / 2]);
	}

	string ra, rb;
	ra = a;
	reverse(ra.begin(), ra.end());
	rb = b;
	reverse(rb.begin(), rb.end());
	rep(i, a.size())
	{
		if (a[i] != ra[i]||b[i]!=rb[i])
		{
			ans = false;
		}
	}

	if (ans) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 3648
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut m: usize = itr.next().unwrap().parse().unwrap();

    let mut a: Vec<(usize, usize)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();

    a.sort();

    let mut ans = 0;
    let mut i = 0;
    while m > 0 {
        let buy = min(a[i].1, m);

        ans += buy * a[i].0;
        m -= buy;
        i += 1;
    }
    println!("{}", ans);
}

Measured memory_bytes: 5700
#C問題
H,W = map(int,input().split())
G = [list(str(input())) for i in range(H)]
ans = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
    g = G[i]
    cnow = -1
    for j in range(W):
        if g[j] == "c":
            cnow = j
            ans[i][j] = 0
        else:
            if cnow == -1:
                ans[i][j] = -1
            else:
                ans[i][j] = j-cnow
                
for a in ans:
    print(*a)




Measured memory_bytes: 6484
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	S := sc.nextStr()
	s, e := 0, 0
	for i := 0; i < N; i++ {
		if S[i] == '(' {
			s++
		} else {
			if s > 0 {
				s--
			} else {
				e++
			}
		}
	}
	head, tail := "", ""
	for i := 0; i < e; i++ {
		head += "("
	}
	for i := 0; i < s; i++ {
		tail += ")"
	}

	fmt.Fprintln(wtr, head+S+tail)
}


Measured memory_bytes: 640
#!/usr/bin/env python3
def main():
    N, M = map(int, input().split())
    A = set([int(input()) for x in range(M)])

    mod = 10 ** 9 + 7
    dp = [0] * 10 ** 6
    dp[0] = 1
    for i in range(N + 1):
        if i in A:
            continue
        dp[i + 1] += dp[i] % mod
        dp[i + 2] += dp[i] % mod
    print(dp[N] % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23932
# coding: utf-8

n, m = map(int, input().split())
total = [0] * m

for i in range(n+1):
    if i < n:
        line = [int(j) for j in input().split()]
        print(" ".join([str(k) for k in line]),sum(line))
        total = [total[i] + line[i] for i in range(m)]
    else:
        print(" ".join([str(k) for k in total]),sum(total))

Measured memory_bytes: 7724