akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 200000;
int main()
{
	int n;
	scanf("%d", &n);
	vector<int> v[2];
	for (int it = 0; it < 2; ++it) {
		v[it].resize(n);
		for (int i = 0, x; i < n; ++i) {
			scanf("%d", &x);
			v[it][i] = x;
		}
	}
	int res = 0;
	for (int i = 0; i < 30; ++i) {
		vector<int> w;
		int M = (1 << (i + 1));
		int L = M - 1;
		for (auto &x : v[0])
			w.push_back(x&L);
		sort(w.begin(), w.end());
		int Z = 1 << i;
		for (auto &x : v[1]) {
			int cur = x&L;
			if (cur >= Z) {
				int idx = upper_bound(w.begin(), w.end(), M - cur - 1) - w.begin();
				if (idx & 1)
					res ^= Z;
				int need = M - cur + Z;
				idx = lower_bound(w.begin(), w.end(), need) - w.begin();
				if ((n - idx) & 1)
					res ^= Z;
			}
			else {
				int l = Z - cur;
				int left = lower_bound(w.begin(), w.end(), l) - w.begin();
				int right = upper_bound(w.begin(), w.end(), M - cur - 1) - w.begin();
				if ((right - left) & 1)
					res ^= Z;
			}
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N;
    int a[101][2];
    for(int j=0;j<2;j++){
      for(int i=0;i<N;i++){
        cin>>a[i][j];
      }
    }
    int res = -1;
    for(int j=0;j<N;j++){
      int s=0;
      for(int i=0;i<N;i++){
        if(i==j){
          s = s+a[i][0]+a[i][1];
        }else if(i>j){
           s+=a[i][1];
        }else{ s+=a[i][0];}
      }
      res = max(res, s);
    }

    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
// TogglingCases.cc
// 与えられた文字列の小文字と大文字を入れ替えるプログラムを作成してください。
// 【入力】
// 文字列が1行に与えられます。
// 【出力】
// 与えられた文字列の小文字と大文字を入れ替えた文字列を出力して下さい。
// アルファベット以外の文字はそのまま出力して下さい。
// 【制約】
// 入力される文字列の長さ < 1200
// 【例】
// 入力：
// fAIR, LATER, OCCASIONALLY CLOUDY.
// 出力：
// Fair, later, occasionally cloudy.
#include<cstdio>
#include<cctype>
using namespace std;

int main( void) {
  char ch[1200];
  int counter = 0;

  for ( int i = 0; i < 1200 - 1; i++) {
    scanf( "%c", &ch[i]);
    if ( ch[i] == '\n') break;
    counter++;
  }

  for ( int i = 0; i < counter; i++) {
    if ( isupper( ch[i])) ch[i] = tolower( ch[i]);
    else if ( islower( ch[i])) ch[i] = toupper( ch[i]);

    printf( "%c", ch[i]);
  }
  printf( "\n");

  return 0;
}



Measured memory_bytes: 2588
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	string s;
    	cin>>s;
    	ll l = s.length();
    	int fl = 1;
    	for(int i=0;i<l;i++)
    	{
    		if(s[i]!=s[l-i-1])
    			fl = 0;
    	}
    	for(int i=0;i<(l-1)/2;i++)
    	{
    		if(s[i]!=s[(l-1)/2-i-1])
    			fl = 0;
    	}
    	for(int i = (l+3)/2;i<l;i++)
    	{
    		if(s[i]!=s[l-i-1])
    			fl = 0;
    	}
    	if(fl)
    		cout<<"Yes"<<endl;
    	else
    		cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int t,n,s,f,i;
    while (1) {
        scanf("%d",&t);
        if (t==0) break;
        scanf("%d",&n);
        for (i=0; i<n; i++) {
            scanf("%d %d",&s,&f);
            t-=(f-s);
        }
        if (t<=0) {
            printf("OK\n");
        } else {
            printf("%d\n",t);
        }
    }
    return 0;
}

Measured memory_bytes: 612
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N = int(input())
    L = read_list()
    res = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                T = [L[i], L[j], L[k]]
                if len(set(T)) == 3 and sum(T) > 2 * max(T):
                    res += 1
    print(res)



if __name__ == "__main__":
    main()



Measured memory_bytes: 69064
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n, k = map(int, input().split())
    aa = list(map(int, input().split()))
    ss = []
    for i in range(n):
        s = 0
        for j in range(i, n):
            s += aa[j]
            ss.append(s)
    ss.sort(reverse=True)
    # print(ss)
    msk = 1 << 50
    ans = 0
    for _ in range(50):
        msk >>= 1
        # print(format(msk,"b"),ss)
        if msk > ss[0]: continue
        pen = []
        for s in ss:
            if s & msk:
                pen.append(s)
        if len(pen) >= k:
            ss = pen
            ans += msk
    print(ans)

main()


Measured memory_bytes: 28168
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
const int mod = 998244353;
//const int mod = 1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
int mygcd(int a, int b){
	if(b == 0){
		return a;
	}
	return mygcd(b, a % b);
}
int mypow(int a, int b, int mod) {
	int res = 1;
	while(b) {
		if(b & 1)
			res = (res * a) % mod;
		a = ( a * a ) % mod;
		b >>= 1;
	}
	return res;
}
void solve(){
	int n, k;
	cin >> n >> k;
	vi h(n);
	rep(i, 0, n){
		cin >> h[i];
	}
	vi dp(n, infl);
	dp[0] = 0;
	for(int i = 0; i < n - 1; i++){
		for(int j = i + 1; j <= min(n - 1, i + k); j++){
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n - 1] << '\n';

}
signed main(){
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>                                        
#include<iostream>
using namespace std;

int main(){
    int a[3];

    scanf("%d %d %d",&a[0],&a[1],&a[2]);

    sort(a,a+3);

    printf("%d %d %d\n",a[0],a[1],a[2]);

    return 0;
}



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

using I = long long;
const I M = 1e9 + 7;

int main() {
  I N, C;
  cin >> N >> C;
  vector<I> A(N), B(N);
  for(auto& i: A) cin >> i;
  for(auto& i: B) cin >> i;

  vector<vector<I>> pow(400+1, vector<I>(C+1, 1));
  for(auto i=1; i<=400; ++i)
    for(auto j=1; j<=C; ++j)
      pow[i][j] = i * pow[i][j-1] % M;

  vector<vector<I>> dp(N+1, vector<I>(C+1, 0));
  for(auto i=0; i<N; ++i)
    for(auto j=0; j<=C; ++j)
      for(auto x=A[i]; x<=B[i]; ++x)
        (dp[i][j] += pow[x][j]) %= M;

  vector<vector<I>> memo(N+1, vector<I>(C+1, -1));
  function<I(I, I)> dfs  = [&](I i, I j) {
    if(i == N) return (j == 0) ? I(1) : I(0);
    if(memo[i][j] != -1) return memo[i][j];
    I res = 0;
    for(auto k=0; k<=j; ++k) (res += dp[i][k] * dfs(i+1, j-k) % M) %= M;
    return memo[i][j] = res;
  };

  cout << dfs(0, C) << endl;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(long int I=X;I<Y;I++)
#define REP(I,X) for(long int I=X;I>=0;I--)
#define INF 1e9+7
using namespace std;

int main(){
  int n,k,q;
  vector<int> ans;
  while(1){
    cin >> n >> k;
    if(n == 0 && k == 0)break;
    vector<bool> given(n+2,0);
    vector<int> left(n+2,0);
    vector<int> right(n+2,0);
    FOR(i,0,k){
      cin >> q;
      given[q] = 1;
    }
    if(given[0]){
      given[0] = 0;
      FOR(i,1,n+1)if(given[i])left[i] = left[i-1] + 1;
      REP(i,n)if(given[i] && i)right[i] = right[i+1] + 1;
      int ma = 0;
      FOR(i,1,n+1)ma = max(ma,left[i-1]+right[i+1]+1);
      ans.push_back(ma);
    }
    else{
      FOR(i,1,n+1)if(given[i])left[i] = left[i-1] + 1;
      int ma = 0;
      FOR(i,1,n+1)ma = max(ma,left[i]);
      ans.push_back(ma);
    }
  }
  for(auto x:ans)cout << x << endl;
}



Measured memory_bytes: 3572
#include<stdio.h>
#include<math.h>
int main(){
    int a[100],d,i,e,x,n;

    scanf("%d",&n);
    for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
    d=a[0];
     for(i=1;i<n;i++){
        if(d>a[i]){
           d=a[i];
          }
    }

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

    x=abs(e-d);
    printf("%d\n",x);

return 0;
}


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

using namespace std;

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

  int n, m;
  cin >> n >> m;
  int lmax = 1;
  int rmin = n;
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    lmax = max(lmax, l);
    rmin = min(rmin, r);
  }
  int ans = max(0, rmin - lmax + 1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
A,B,C=map(int,input().split())
K=int(input())
a=0
 
if A<=B:
    d=B
else:
    d=A
if d>C: 
	d=d
else:
	d=C

if d==A:
	all=B+C
if d==B:
	all=A+C
if d==C:
	all=B+A

while a<K:
	d*=2
	a+=1

all+=d
print (all)

Measured memory_bytes: 3064
import std.stdio, std.array, std.conv;

void main() {
    int[] tmp = readln.split.to!(int[]);
    int k = tmp[0], x = tmp[1];
    foreach (i; x-k+1 .. x+k) {
        i.write;
        if (i != x + k - 1) " ".write;
        else writeln;
    }
}

Measured memory_bytes: 256
#include<cstdio>

const int mod=1e9+7;

#define add(a,b) (a+=b)>=mod&&(a-=mod)

int dp[302][301][301],first[301];

struct query{ int l,x,nx; }q[301];

int main()
{
	int i,j,k,l,m,n,ans=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
		scanf("%d%d%d",&q[i].l,&j,&q[i].x),
			q[i].nx=first[j],first[j]=i;
	dp[0][0][0]=1;
	for(i=0;i<=n;i++)
		for(j=0;j<i||!j;j++)
			for(k=0;k<j||!k;k++)
				if(dp[i][j][k])
				{
					for(l=first[i];l;l=q[l].nx)
						switch(q[l].x){
						case 1:if(j>=q[l].l)goto loop;break;
						case 2:if(k>=q[l].l||j<q[l].l)goto loop;break;
						case 3:if(k<q[l].l)goto loop;break;
						}
					if(i==n)add(ans,dp[i][j][k]);
					else
					{
						add(dp[i+1][j][k],dp[i][j][k]);
						add(dp[i+1][i][k],dp[i][j][k]);
						add(dp[i+1][i][j],dp[i][j][k]);
					}
				loop:;
				}
	printf("%d\n",ans);
}

Measured memory_bytes: 104704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


class Main{
    //読み込みのテンプレ(stringオブジェクトまで)
    public static void main(String[] args) throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String string = reader.readLine();
        StringTokenizer token = new StringTokenizer(string," ");
        
        int x = Integer.parseInt((String)token.nextElement());
        int y = Integer.parseInt((String)token.nextElement());
        
        int answer = gcd(x,y);
        System.out.println(answer);
    }
    
    public static int gcd(int x,int y){
        
        int answer;
        
        if(x > y){
            
            while(x%y != 0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
            
            
        }else{
            int x_y = x;
            int y_x = y;
            
            x = y_x;
            y = x_y;
            
            while(x%y !=0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
        
        }
        return answer;
    }
}

Measured memory_bytes: 16904
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

// #define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

istream& operator>> (istream& a, pii& b) {
    cin >> b.first >> b.second;
    return a;
}

ostream& operator<< (ostream& a, const pii& b) {
    cout << "{" << b.first << ", " << b.second << "}";
    return a;
}

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 100;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e9;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    multiset<int, greater<int>> a;
    int x;
    for (int i = 0; i < (1 << n); i++) {
        cin >> x;
        a.insert(x);
    }
    multiset<int> have;
    have.insert(*a.begin());
    a.erase(a.begin());
    for (int i = 0; i < n; i++) {
        multiset<int> add;
        for (auto val : have) {
            auto it = a.upper_bound(val);
            if (it == a.end()) {
                cout << "No\n";
                return 0;
            }
            add.insert(*it);
            a.erase(it);
        }
        for (auto val : add) {
            have.insert(val);
        }
    }
    cout << "Yes\n";
}
/*

*/  

Measured memory_bytes: 18688
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a == b)cout << "a == b" << endl;
	else if (a > b)cout << "a > b" << endl;
	else cout << "a < b" << endl;
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;



int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    double t,x;
    cin >> t >> x;
    cout << fixed << setprecision(5) << t/x;
}


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

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

  vector<int> a(n);
  unordered_map<int, long long> b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    b[a[i]] += 1;
  }

  long long sum = 0;
  for (auto t: b) {
    sum += t.second*(t.second-1)/2;
  }

  for (auto t : a) {
    cout << sum - (b[t]-1) << endl;
  }

  return 0;
}


Measured memory_bytes: 7936
N = int(input())
a_list = list(map(int, input().split()))

from collections import defaultdict

cnt = defaultdict(int)

for i in range(N):
    for j in range(61):
        if a_list[i] & (1 << j):
            cnt[j] += 1


ans = 0
mod = 10 ** 9 + 7

for i in range(61):
    ans += cnt[i] * (N - cnt[i]) * (1 << i)
    ans %= mod
print(ans)


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

int main()
{
    int n,k;
    std::string s;
    std::cin >> n >> k;
    std::cin >> s;
    std::vector<int> nums;
    if(s[0] == '0')nums.push_back(0);
    for(int i = 0; i < (int)s.size();){
        int j = i;
        while(j < (int)s.size() && s[j] == s[i])j++;
        nums.push_back(j - i);
        i = j;
    }
    if(s[n-1] == ('0'))nums.push_back(0);

    std::vector<int> sums((int)nums.size() + 1);
    for(int i = 0; i < (int)nums.size(); i++)sums[i + 1] = sums[i] + nums[i];

    //偶数番目の添字から始まる長さ2k+1の区間の総和の最大値
    int res = 0;
    for(int left = 0; left < (int)sums.size(); left += 2){
        int right = left + 2 * k + 1;
        if(right >= (int)sums.size())right = (int)sums.size() - 1;
        res = std::max(res, sums[right] - sums[left]);
     }
     std::cout << res << std::endl;
}

Measured memory_bytes: 1272
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;
const double EPS=1e-8;

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

}


Measured memory_bytes: 256
N = int(input())
F = [int(input().replace(' ',''), 2) for _ in range(N)]
P = [[int(i) for i in input().split()] for _ in range(N)]

ma = -1e20
for i in range(1, 2 ** 10):
    count = 0
    for f, p in zip(F, P):
        count += p[bin(f & i).count("1")]
    ma = max(ma, count)
print(ma)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
    int N, Rd, Ri;

    scanf("%d %d", &N, &Rd);

    if(N < 10) {
        Ri = Rd + (100*(10-N));
    } else {
        Ri = Rd;
    }

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

    return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, t, a, ans = 0;
  cin >> n >> t >> a;
  vector<int> h(n);
  arep(i, h) cin >> i;

  double cnt = INF;

  rep(i, 0, n) {
    double ne = abs(a - t + h[i] * 0.006);
    if (ne < cnt) {
      cnt = ne;
      ans = i + 1;
    }
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n,k=map(int,input().split())
l=list(map(int,input().split()))
a=defaultdict(int)
for i in l:
	a[i] += 1
a=list(a.items())
if len(a) <= k:
	print(0)
else:
	ans = 0
	a.sort(key = lambda x: x[1])
	for i in range(len(a) - k):
		ans += a[i][1]
	print(ans)


Measured memory_bytes: 42628
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i * j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

#define ll long long
#define endl "\n"
#define FILEIN freopen("input.txt", "r", stdin)


int main(){
    // FILEIN;

    ll n, k; cin>>n>>k;
    ll ar[n] = {};
    for(ll i = 0; i<n; i++){
        cin>>ar[i];
    }

    ll dp[n] = {};
    dp[0] = 0, dp[1] = abs(ar[0] - ar[1]);
    for(ll i = 0; i<n; i++){
        ll min1 = INT64_MAX;
        for(int j = 1; j<=k && j <= i; j++){
            min1 = min(min1, (dp[i-j] + abs(ar[i-j] - ar[i])));
        }
        if(min1 == INT64_MAX){
            dp[i] = 0;
        }else{
            dp[i] = min1;
        }
    }
    
    cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
static const long long MAX = (long long) pow(10, 18);

int main() {
    int a, b, c;
    long long k;
    scanf("%d %d %d %lld", &a, &b, &c, &k);

    int result;
    if (k % 2 == 0) {
        result = a - b;
    } else {
        result = b - a;
    }

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

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

vector<ll> s(51, 0);

ll f(ll L, ll X) {
    if (L == 0) {
        if (X <= 0) {
            return 0;
        } else {
            return 1;
        }
    } else {
        if (X <= 1) {
            return 0;
        } else if (2 <= X && X <= s[L-1]+1) {
            return f(L-1, X-1);
        } else if (X == s[L-1] + 2) {
            return f(L-1, s[L-1])+1;
        } else if (s[L-1] + 3 <= X && X <= 2 * s[L-1] + 2) {
            return f(L-1, s[L-1]) + 1 + f(L-1, X-s[L-1]-2);
        } else {
            return 2*f(L-1, s[L-1]) + 1;
        }
    }
}

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

    ll N, X;
    cin >> N >> X;

    s[0] = 1;
    Rep (i, 50) {
        s[i+1] = 2*s[i] + 3;
    }
    // cout << s[50] << "\n";
    cout << f(N, X) << "\n";
}

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

int main(){
  int N,K,i = 0;
  cin >> N >> K;
  for (int k = 0; k < N; k++){
    int S;
    cin >> S;
    if (K - S < S){
      i += (K - S) * 2;
    }else{
      i += S * 2; 
    }
  }
    cout << i << endl;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
/* VARIABLE DECLARATION START */
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
inline ll foo(ll base,ll num)
{
  ll sum=0;
  while(num>0)
  {
    sum+=(num%base);
    num/=base;
  }
  return sum;

}

/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   ll n,s;cin>>n>>s;
   if(s<=n)
   {
    if(s==n)
    {
      cout<<n+1<<endl;return 0;
    }
    for(ll i=2;i*i<=n;++i)
    {
      ll sum=foo(i,n);
      if(sum==s)
      {
        cout<<i<<endl;return 0;
      }
    }
    ll ans=-1;
    for(ll i=1;i*i<=n;++i)
    {
      ll base=(n-s)/i+1;
      if(base<=1)
        continue;
      ll sum=foo(base,n);
      if(sum==s)
        ans=base;
    }
    cout<<ans<<endl;return 0;
   }
   cout<<-1<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }   
    cout<<ceil((1.0*(n-1))/(k-1))<<endl;
 return 0;   
}

Measured memory_bytes: 640
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.inr(),r=t.inr(),n=e.length,i=r.length,o=new Map,s=0;s<n;s++)o[e[s]]||(o[e[s]]=[]),o[e[s]].push(s);for(var u=1,c=-1,a=0;a<i;a++){var f=r[a];if(!o[f])return void console.log(-1);for(var l=o[f].length,p=l,d=-1;Math.abs(p-d)>1;){var h=Math.floor((p+d)/2);o[f][h]>c?p=h:d=h}var v=o[f][p];p==l||v<=c?(c=o[f][0],u++):c=v}var b=(u-1)*n+c+1;console.log(b)}}]);

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

using namespace std;

int n, dp[100001], k;
short heights[100001];

int main() {
    cin.sync_with_stdio(0); cin.tie(0); 
    cin >> n >> k;
    
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;

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

    for(int i = 0; i < n-1; i++) {
        for(int j = 1; j <= k; j++) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(heights[i + j] - heights[i]));
        }
    }
    
    cout << dp[n - 1] << "\n";
    
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <math.h>
 
int main(){
 
 double x1,y1,x2,y2;
 scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
 printf("%f",sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)));
 
 return 0;
}

Measured memory_bytes: 652
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

unsigned long long int a = 0, b = 0, c = 1, x = 0, y = 0, z = 0, maxy = -1, mini = 9999, counter = 0, startp = 0, endp = 0, checker = 0;
std::vector<std::string> vec{}, vecsec{};
int iremono[100001];
std::vector<long long int>kinds{}, ans{}, kaku{};
char moji, moji2;
bool okada = false, okada2 = false;
std::string output, output2, input, one, two;
char cutcount[201];
int kakunou2[50][50] = {};
unsigned long long int M, A, R, C, H;

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{

	cin >> input >> a;
	if (input.size() == 1) {
		cout << input << endl;
		return 0;
	}
	if (input.size() <= 5) {
		y = input.size();
	}
	else {
		y = 5;
	}
	for (int i = 1; i <=y; i++) {
		for (int j = 0; j < input.size()-i+1; j++) {
			vec.push_back(input.substr(j, i));
		}
	}
	std::sort(vec.begin(), vec.end());
	x = vec.size();
	vec.push_back("qawsedrf");
	for (int i = 0; i < x ;i++) {
		if (vec[i] != vec[i + 1]) {
			vecsec.push_back(vec[i]);
		}
	}
	std::sort(vecsec.begin(),vecsec.end());

	cout << vecsec[a - 1] << endl;
}


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int n;
long double s, b;
int main(){
    cin >> n;
    for(int i = 1 ; i <=  n ; i++){
        cin >> b;
        s += 1/b;
    }
    cout.precision(10);
    cout << 1/s;
    return 0;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())

S = []
ICHIGO = []
for _ in range(H):
    s = list(input())
    ICHIGO.append('#' in s)
    S.append(s)
    
#print(S)
#print(ICHIGO)

cnt = 1
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            S[h][w] = cnt
            cnt += 1
        else:
            S[h][w] = -1
            
#print(S)
        
      
for h in range(H):
    num = -1
    for w in range(W):
        if S[h][w] != -1:
            num = S[h][w]
        S[h][w] = num
        
    num = -1
    for w in reversed(range(W)):
        if S[h][w] != -1:
            num = S[h][w]
        S[h][w] = num
        
for h in range(1, H):
    if ICHIGO[h] == False and ICHIGO[h-1] == True:
        S[h] = S[h-1]
        ICHIGO[h] = True
  
        
for h in reversed(range(0, H-1)):
    if ICHIGO[h] == False and ICHIGO[h+1] == True:
        S[h] = S[h+1]
        ICHIGO[h] = True
        
#print(S)

for h in range(H):
    print(' '.join(map(str, S[h])))

Measured memory_bytes: 47852
#include <iostream>
using namespace std;
   
int F[102][102];
int xg,yg,w,h;
   
   
void DFS(int Y,int X,int c){
  //if(Y < 1 || X < 1)
    //return;
  if(F[Y][X] != c){
    return;
  }
   
  F[Y][X] = -1;
  DFS(Y+1,X  ,c);
  DFS(Y-1  ,X,c);
  DFS(Y,X+1  ,c);
  DFS(Y  ,X-1,c);
}
   
   
int main(){
  int xs,ys,n;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0)
      break;
for(int i=0; i<102; i++){
      for(int j=0; j<102; j++){
        F[i][j] = 10;
      }
    }
       
    cin >> xs >> ys >> xg >> yg >> n;
   
   
    for(int i=0;i<n;i++){
      int c,d,x,y;
      cin >> c >> d >> x >> y;
 
      if(d == 0){
        for(int j=0;j<4;j++){
          F[x+j][y] = c;
          F[x+j][y+1] = c;
        }
      } else {
        for(int j=0;j<4;j++){
          F[x][y+j] = c;
          F[x+1][y+j] = c;
        }
      }
    }
  DFS(xs,ys,F[xs][ys]);
   
  if(F[xg][yg] == -1){
    cout << "OK" << endl;
  } else {
    cout << "NG" <<endl;
  }
  }
}


Measured memory_bytes: 3744
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Solve
{
    public Solve() { }
    public static int Main()
    {
        new Solve().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int A = cin.nextInt();
        int B = cin.nextInt();
        string S = cin.next();

        bool isYes = true;
        for (int i = 0; i < S.Length;i++){
            if(i == A){
                if(S.Substring(i,1) != "-"){
                    isYes = false;
                    break;
                }
                    
            }else{
                int o = 0;
                if (!int.TryParse(S.Substring(i, 1), out o))
                {
                    isYes = false;
                    break;
                }
            }
        }

        Console.WriteLine(isYes ? "Yes" : "No");
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

int main() {
  int N,X,M;
  cin >> N >> M >> X;
  int pay=0,right=0,left=0,a;
  for(int i=0;i<M;i++) {
    cin >> a;
    if(a<X) left++;
    else right++;
  }
  int ans = min(right,left);
  cout << ans << endl;
}
	   
  


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <cmath>
#include <bitset>
using namespace std;

int main()
{
    long long A,B,i,firstA,firstB,r,k;
    cin >> A >> B;
    bitset<60> bitA(A);
    bitset<60> bitB(B);
    r = -1;
    k= -1;
    for (i=59;i>=0;i--){
        if (bitA.test(i)!= bitB.test(i)){
            r = i;
            break;
        }else{
            bitA.reset(i);
            bitB.reset(i);
        }
    }
    A = bitA.to_ullong();
    B = bitB.to_ullong();

    if (r== -1){
        cout << 1 << endl;
    }else{
        for (i=r-1;i>=0;i--){
            if (bitB.test(i)){
                k = i;
                break;
            }
        }

        if (pow(2,k+1) >= A){
            cout << dec <<(long long)((1LL<<(r+1)) - A) << endl;
        }else{
            cout << dec << (2 * (long long)((1LL<<r) - A) + (1LL<<(k+1))) <<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char a[1000];
bool c;
int main()
{
	scanf("%s",a);
	for(int i=0;i<strlen(a);++i)
	{
		if(!c)
		{
			if(a[i]=='C')	c=1;
		}
		else
		{
			if(a[i]=='F')
			{
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

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

result = 0
word_list = {}

for i in range(n):
    input_word = "".join(sorted(input()))
    if input_word in word_list:
        word_list[input_word] += 1
        result += word_list[input_word]
    else:
        word_list[input_word] = 0

print(result)

Measured memory_bytes: 17852
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
ll dp[2000][2000];
int main(){
int h,w;
cin>>h>>w;
vector<string> a(h);
for(int i=0;i<h;i++)cin>>a[i];
dp[0][0]=1;
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        if(i+1<h&&a[i+1][j]!='#')(dp[i+1][j]+=dp[i][j])%=mod;
        if(j+1<w&&a[i][j+1]!='#')(dp[i][j+1]+=dp[i][j])%=mod;
    }
}
cout<<dp[h-1][w-1]<<endl;
}




Measured memory_bytes: 17152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
ll a[maxn],n,k;
ll dp[maxn];
ll go(ll i){
    if(i==(n-1)) return 0;
    ll &ans=dp[i];
    if(ans!=-1) return ans;
    ans=inf;
    for(ll j=1;j<=k;j++){
        if(i+j>=n) break;
        ans=min(ans,abs(a[i]-a[i+j])+go(i+j));
    }
    //if((i+2)<n) ans=min(ans,abs(a[i]-a[i+2])+go(i+2));
    return ans;
}
int main()
{
    ll i;
    cin>>n>>k;
    for(i=0;i<n;i++) cin>>a[i];
    SET(dp,-1);
    cout<<go(0);
}


Measured memory_bytes: 6528
#include<iostream>
#include<string>

using namespace std;

int main(){
  string str;
  string lstr;

  string astr;

  cin >> str >> astr;

  lstr = str + str;

  if(lstr.find(astr)!=string::npos)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3196
import sys

N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return (a // gcd(a,b)) * b

tx = 1
for a in A:
    tx = lcm(tx, a)

B = []
for a in A:
    B.append(tx // a)

for b in B:
    if b % 2 == 0:
        print(0)
        sys.exit()
ans = ((M // (tx//2)) + 1) // 2
print(ans)

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

  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}



Measured memory_bytes: 384
import math
n,m=map(int,input().split())

if abs(n-m)>=2:
    ans=0
elif abs(n-m)==1:
    nper=math.factorial(n)%(10**9+7)
    mper=math.factorial(m)%(10**9+7)
    ans=(nper*mper)%(10**9+7)
else:
    nper=math.factorial(n)%(10**9+7)
    mper=math.factorial(m)%(10**9+7)
    ans=((nper*mper)*2)%(10**9+7)

print(ans)

Measured memory_bytes: 10004
#include <iostream>
#include <vector>

using namespace std;

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

	int four_num = 0;
	int two_num = 0;
	int not_num = 0;

	for(auto x : a){
		if(x % 4 == 0){
			four_num++;
			continue;
		}
		if(x % 2 == 0){
			two_num++;
			continue;
		}
		not_num++;
	}

	if(two_num > 0){
		if(four_num  >= not_num){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		if(four_num + 1 >= not_num){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 640
#!python3

LI = lambda: list(map(int, input().split()))

# input
N = int(input())
A = LI()


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def main():
    l, r = [None] * N, [None] * N
    l[0] = A[0]
    r[0] = A[-1]
    for i in range(1, N):
        l[i] = gcd(l[i - 1], A[i])
        r[i] = gcd(r[i - 1], A[-i - 1])
    
    ans = 1
    for i in range(N):
        if i == 0:
            x = r[-2]
        elif i == N - 1:
            x = l[-2]
        else:
            x = gcd(l[i - 1], r[N - i - 2])
        ans = max(ans, x)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

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

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

    ll sum = 0;
    REP(i, n) {
        ll a;
        cin >> a;
        sum += (a-1);
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MAX_N = 100000;
const int MAX_K = 1000;

ll N, K, ans;
ll xys[2][4*MAX_K][4*MAX_K];

ll sum_rect(int p1, int q1, int p2, int q2, int wb) {
  ll res = 0;
  res += xys[wb][p2][q2];
  if (0 < p1) res -= xys[wb][p1-1][q2];
  if (0 < q1) res -= xys[wb][p2][q1-1];
  if (0 < p1 && 0 < q1) res += xys[wb][p1-1][q1-1];
  return res;
}

int main() {
  cin >> N >> K;

  for (int i=0; i<N; i++) {
    ll x, y;
    char c;
    scanf("%lld %lld %c", &x, &y, &c);
    int wb = (c == 'W') ? 0 : 1;
    xys[wb][x%(2*K)][y%(2*K)]++;
    xys[wb][x%(2*K)+2*K][y%(2*K)]++;
    xys[wb][x%(2*K)][y%(2*K)+2*K]++;
    xys[wb][x%(2*K)+2*K][y%(2*K)+2*K]++;
  }

  for (int wb=0; wb<2; wb++) {
    for (int i=0; i<4*K; i++) {
      for (int j=0; j<4*K; j++) {
        if (i == 0 && j != 0) {
          xys[wb][i][j] += xys[wb][i][j-1];
        } else if (i != 0 && j == 0) {
          xys[wb][i][j] += xys[wb][i-1][j];
        } else if (i != 0 && j != 0) {
          xys[wb][i][j] += xys[wb][i][j-1] + xys[wb][i-1][j] - xys[wb][i-1][j-1];
        }
      }
    }
  }

  ll ans1 = 0, ans2 = 0, sum1, sum2;
  for (int i=0; i<2*K; i++) {
    for (int j=0; j<2*K; j++) {
      int m = i + K, n = j + K;
      int k = i + 2*K-1, l = j + 2*K-1;
      sum1 = sum2 = 0;
      sum1 += sum_rect(i, j, m-1, n-1, 0) + sum_rect(m, n, k,   l, 0);
      sum1 += sum_rect(i, n, m-1,   l, 1) + sum_rect(m, j, k, n-1, 1);
      sum2 += sum_rect(i, j, m-1, n-1, 1) + sum_rect(m, n, k,   l, 1);
      sum2 += sum_rect(i, n, m-1,   l, 0) + sum_rect(m, j, k, n-1, 0);
      ans1 = max(ans1, sum1);
      ans2 = max(ans2, sum2);
    }
  }

  ans = max(ans1, ans2);
  cout << ans << endl;
  return 0;
}


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

int main() {
    string s; getline(cin, s);
    for (int i = 0; i < s.size(); ++i) {
        char c = s[i];
        int c_code = c - '0'; // convert ascii code
        
        if ('a' <= c && c <= 'z') c = c - 32;
        else if ('A' <= c && c <= 'Z') c = c + 32;
        
        cout << c;
    }
    cout << endl;
    
    return 0;
}


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

using namespace std;

int main() {

	string s1,s2;
	cin >> s1 >> s2;
	
	int cont = 0;
	for (int i = 0; i < s1.size(); i++) {
		if(s1[i] == s2[i])
			cont++;
	}
	cout << cont << endl;
 	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i,N){
        cin >> a[i];
        a[i]--;
    }
    int count = 0;
    REP(i,N){
        if(a[a[i]] == i)count++;
    }
    cout << count/2 << "\n";
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int n;
    int h[20];      // n max = 20
    int num = 1;

    // char s[101];
    // 整数の入力
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }
    
    // スペース区切りの整数の入力
//    scanf("%d %d",&b,&c);
    // 文字列の入力
//    scanf("%s",s);

    for (int k = 1; k < n; k++) {
        char flag = 1;
        for (int i = 0; i < k; i++) {
            if (h[k] < h[i]) {
                flag = 0;
                break;
            }
        }
        if (flag == 1) num++;
    }
    
    // 出力
    printf("%d\n", num);
//    printf("%d %s\n",a+b+c,s);
    return 0;
}


Measured memory_bytes: 128