akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	ll mn = INF;
	for (int ab = 0; ab <= max(X, Y); ++ab) {
		ll tmp = ab * C * 2 + max(X - ab, 0) * A + max(Y - ab, 0) * B;
		//if(ab == 100000) cout << ab << " " << ab * C * 2 << endl;
		mn = min(mn, tmp);
	}

	cout << mn << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 2e18

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

    if(n%2==1){
        repr(i, 1, m){
            cout << i << " " << n-i << endl;    
        }
    }else{
        int cnt = 0;
        int t1 = n/2-1;
        int t2 = n/2-2;
        for (int i = 1; i < 2+t1-i; i++)
        {
            cout << i << " " << 2+t1-i << endl;    
            cnt++;
            if(cnt>=m) return 0;
        }
        
        for (int i = n; 2*n -t2-i < i; i--)
        {
            cout << i << " " << 2*n-t2-i << endl;    
            cnt++;
            if(cnt>=m) return 0;
        }
        
        
    }
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3648
let () = Scanf.scanf "%d %d\n" @@ function
  | 1 -> fun q ->
      for i = 0 to q - 1 do
        Printf.printf "%d\n" @@ Scanf.scanf "%d %d\n" min
      done
  | n -> fun q ->
      let up v = (v - 1) / n in
      let rec upn v = function
        | 0 -> v
        | n -> upn (up v) (n - 1) in
      let rec depth acc = function
        | 0 -> acc
        | v -> depth (1 + acc) (up v) in
      let depth = depth 0 in
      let rec lca v w =
        if v = w then v
        else lca (up v) (up w) in
      let lca v w =
        let dv = depth v in
        let dw = depth w in
        if dv <= dw
        then lca v (upn w (dw - dv))
        else lca (upn v (dv - dw)) w in
      for i = 0 to q - 1 do
        Scanf.scanf "%d %d\n" @@ fun v w ->
          Printf.printf "%d\n" @@ succ @@ lca (v - 1) (w - 1)
      done


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

ll n;
int M[101010][3]={};
ll dp[101010][3]={};
ll cnt=LLONG_MAX;




int main(){
   //int a,b;
   cin>>n;
   rep(i,(n/2)+1){
      if(n<(i+1)*(i+1))break;
      ll a=n/(i+1);
      if(a*(i+1)==n){
         cnt=cnt<a+i-1?cnt:a+i-1;
      }
   }
   if(cnt==LLONG_MAX){
      cnt=n-1;
   }
   cout<<cnt<<endl;
}



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")
           
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
           
//#define int long long
  
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

template<typename T>
using kawaii_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
  
void FAST_IO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.setf(ios::fixed);
    //cout.precision(20);
    #ifndef _offline
    //freopen("mincost.in", "r", stdin);
    //freopen("mincost.out", "w", stdout);
    #endif
}

const int MAXN = 1e6 + 100;
int fact[MAXN];

int c(int n, int k) {
    int res = fact[n] - fact[k] - fact[n - k];
    return (res ^ 1);
}

signed main() {
    FAST_IO();
    for (int i = 1; i < MAXN; ++i) {
        fact[i] = fact[i - 1] + __builtin_ctz(i);
    }
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < n; ++i) {
        s[i]--;
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '1' && c(n - 1, i) == 1) {
            res ^= 1;
        }
    }
    if (res == 1) {
        cout << 1 << '\n';
        return 0;
    }
    bool f = false;
    for (int i = 0; i < n; ++i) {
        f |= (s[i] == '1');
    }
    if (f) {
        cout << 0 << '\n';
        return 0;
    }
    for (int i = 0; i < n; ++i) {
        if (s[i] == '2' && c(n - 1, i) == 1) {
            res ^= 2;
        }
    }
    cout << res << '\n';
}  

Measured memory_bytes: 5788
#!/usr/bin/env python3
# スペース区切りの整数の入力
n, k = map(int, input().split())
#配列の入力
data = list(map(int, input().split()))

for i in range(n-k):
    if data[i] < data[k+i]:
        print("Yes")
    else:
        print("No")




Measured memory_bytes: 31604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,i,j,k,ans=0;cin>>a>>b>>c>>x;
  for(i=0;i<=a;i++)for(j=0;j<=b;j++) for(k=0;k<=c;k++) if(500*i+100*j+50*k==x)ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static final long MOD = 1_000_000_000 + 7;

	public static void main(String[] args) {
		// input
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] x = new long[n];
		long[] y = new long[m];

		for (int i = 0; i < n; i++) {
			x[i] = sc.nextLong();
		}
		for (int i = 0; i < m; i++) {
			y[i] = sc.nextLong();
		}

		long xsum = 0;
		for (int i = 0; i < n; i++) {
			long tmp = ((2 * i - n + 1) * x[i]) % MOD;
			xsum += tmp;
			xsum %= MOD;
			//	long add = (i * x[i]) % MOD;
			//	long subtract = ((n - i - 1) * x[i]) % MOD;
			//	long sum = (add - subtract) % MOD;
			//	xsum += sum;
			//	xsum %= MOD;
		}

		long ysum = 0;
		for (int i = 0; i < m; i++) {
			long tmp = ((2 * i - m + 1) * y[i]) % MOD;
			ysum += tmp;
			ysum %= MOD;
			// 	long add = (i * y[i]) % MOD;
			// 	long subtract = ((m - i - 1) * y[i]) % MOD;
			// 	long sum = (add - subtract) % MOD;
			// 	ysum += sum;
			// 	ysum %= MOD;
		}

		long ans = (xsum * ysum) % MOD;

		// output
		System.out.println(ans);
	}
}


Measured memory_bytes: 92336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    rep(i, 0, 1000) {
        string t;
        int tmp = i;
        rep(j, 0, 3) {
            t += '0' + tmp % 10;
            tmp /= 10;
        }
        reverse(all(t));
        int a = 0;
        rep(j, 0, n) {
            if (s[j] == t[a]) a++;
            if (a == 3) break;
        }
        if (a == 3) ans ++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

vector<string> split(const string &s,char c=' '){
	vector<string> ret;
	stringstream ss(s);
	string t;
	while(getline(ss,t,c)){
		ret.pb(t);
	}
	return ret;
}

int main(){
	string s;
	while(getline(cin,s)){
		if(s=="END OF INPUT") break;
		vector<string> ss=split(s,' ');
		string ans="";
		rep(i,0,ss.size()) cout<<ss[i].size();
		cout<<endl;
		/*rep(i,0,ss.size()){
			stringstream stream;
			stream<<ss[i].size();
			ans+=stream.str();
		}
		o(ans);*/
	}
}

Measured memory_bytes: 1208
n,m=map(int,input().split())
List=list(map(int,input().split()))
List.insert(0,0)
l=[1]*n
l.insert(0,0)
for i in range(m):
  s=list(map(int,input().split()))
  if List[s[0]]>List[s[1]]:
    l[s[1]]=0
  elif List[s[0]]<List[s[1]]:
    l[s[0]]=0
  else:
    l[s[1]]=0
    l[s[0]]=0
print(l.count(1))

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

using namespace std;

const int N = 100 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
long long a[N];

bool read() {
    if (!(cin >> n))
        return false;

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

    return true;
}

void solve() {
    auto ans = a[0] - 1;
    a[0] = 1;

    for (int i = 1, k = 2; i < n; ++i) {
        if (a[i] % k != 0) {
            ans += a[i] / k;
            a[i] %= k;
        } else {
            if (a[i] == k) {
                ++k;
                continue;
            }

            ++ans;
            a[i] -= k + 1;
            ans += a[i] / k;
            a[i] %= k;
        }
    }

    cout << ans << endl;
}

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

    while (read())
        solve();

    return 0;
}



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 55;
const ll MOD = 1e9 + 7;

const int MAXN = 5e5 + 5;

int d[MAXN], dis[MAXN], mn[MAXN];

void solve(){
	int n, q;
	scanf("%d%d", &n, &dis[0]);
	REPN(i, 1, n) {
		scanf("%d", &d[i]);
		dis[i] = min(dis[i - 1], abs(dis[i - 1] - d[i]));
	}
	mn[n + 1] = 1;
	for(int i = n; i >= 1; i--) {
		if (d[i] >= mn[i + 1] * 2) {
			mn[i] = mn[i + 1];
		} else {
			mn[i] = min(INF, mn[i + 1] + d[i]);
		}
	}
	
	/*REPN(i, 1, n) {
		printf("%d %d\n", dis[i - 1], mn[i + 1]);
	}*/
	
	scanf("%d", &q);
	while(q--) {
		int x;
		scanf("%d", &x);
		if (dis[x - 1] >= mn[x + 1]) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 7808
#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>;

int n, l;

bool comp (string x, string y) {
    return x+y<y+x;
}

int main() {
    cin >> n >> l;
    vector<string> s(n);
    rep(i,n) cin >> s.at(i);

    sort(s.begin(), s.end(), comp);
    string ans = "";
    ans.reserve(n*l);
    rep(i,n) ans += s.at(i);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    char[] s = sc.next().toCharArray();

    int lcs[][] = new int[N+1][N+1];
    int len = 0, index = 0;
    for (int i = 1; i <= N; i++) {
      for (int j = i + 1; j <= N; j++) {
        if (s[i-1] == s[j-1] && lcs[i-1][j-1] < j - i) {
          lcs[i][j] = lcs[i-1][j-1] + 1;
          if (lcs[i][j] > len) {
            len = lcs[i][j];
            index = Math.max(i, index);
          }
        } else {
          lcs[i][j] = 0;
        }
      }
    }

    System.out.println(len);
  }
}


Measured memory_bytes: 169632
import sys
sys.setrecursionlimit(3000)

import numpy as np

h,w = map(int,input().split())
s = []

for i in range(h):
    s.append(list(input()))

from collections import deque

def bfs(i,j,dist):
    seen[i][j] = dist
    lis = [[i-1,j],[i,j-1],[i+1,j],[i,j+1]]
    for place in lis:
        if place[0]<0 or place[0]>=h or place[1]<0 or place[1]>=w:
            continue
        if seen[place[0]][place[1]] != -1 or s[place[0]][place[1]]=="#":
            continue
        if [place[0],place[1],dist+1] in que:
            continue
        que.append([place[0],place[1],dist+1])
    if len(que):
        new = que.popleft()
        bfs(new[0],new[1],new[2])
    else:
        return


mx = 0
for i in range(h):
    for  j in range(w):
        if s[i][j]=="#":
            continue
        seen = [[-1 for _ in range(w)]for _ in range(h)]
        que = deque()
        bfs(i,j,0)
        ast = np.array(seen)
        tmp = np.amax(ast)
        mx = max(mx,tmp)
        #print(seen)
            #print(*seen,sep="\n")
print(mx)


Measured memory_bytes: 27432
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
  int a;
  cin>>a;
  cout<<setprecision(14)<<a*2*M_PI<<endl;
}

Measured memory_bytes: 3748
/*
lakshaygpt28
Lakshay Gupta
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 2e5 + 10;

ll a[N];
multiset < ll > s;

int main() {
    fast_io();
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        s.insert(a[i]);
    }
    for (ll i = 0; i < n; i++) {
        s.erase(s.find(a[i]));
        cout << *s.rbegin() << "\n";
        s.insert(a[i]);
    }
    return 0;
}


Measured memory_bytes: 12544
//by kcz 1552920354@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;

template <typename T> void chmin(T &x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define pb push_back
#define mp make_pair
#define gc (c=getchar())
char readc()
{
	char c;
	while(gc<'-');
	return c;
}
int read()
{
    char c;
    while(gc<'-');
    if(c=='-')
    {
        int x=gc-'0';
        while(gc>='0')x=x*10+c-'0';
        return -x;
    }
    int x=c-'0';
    while(gc>='0')x=x*10+c-'0';
    return x;
}
#undef gc

const int N=2000+5;
int n,m;
char s[N][N];
struct SUM
{
int s[N][N];
int* operator [](int x)
{
	return s[x];
}
int operator ()(int x1,int y1,int x2,int y2)
{
	return s[x2][y2]+s[x1-1][y1-1]-s[x2][y1-1]-s[x1-1][y2];
}
void init()
{
	rep(i,1,n)
	rep(j,1,m)s[i][j]+=s[i][j-1];
	rep(i,1,n)
	rep(j,1,m)s[i][j]+=s[i-1][j];
}
};
SUM sum,sumh,sums;

int main()
{
//	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
	n=read();m=read();int q=read();
	rep(i,1,n)scanf("%s",s[i]+1);
	rep(i,1,n)
	rep(j,1,m)
	if(s[i][j]=='1')
	{
		sum[i][j]=1;
		sumh[i][j]=s[i][j+1]=='1';
		sums[i][j]=s[i+1][j]=='1';
	}
	sum.init();sumh.init();sums.init();
	while(q--)
	{
		int x1=read(),y1=read(),x2=read(),y2=read();
		printf("%d\n",sum(x1,y1,x2,y2)-sumh(x1,y1,x2,y2-1)-sums(x1,y1,x2-1,y2));
	}
}


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

int main() {
  int N, A;
  
  cin >> N >> A;
  
  if (N % 500 == 0){
    cout << "Yes" << endl;
  }
  
  else if (N % 500 <= A){
    cout << "Yes" << endl;
  }
  
  else if (N % 500 > A){
    cout << "No" << endl;
  }
  
  
}

Measured memory_bytes: 256
def solve(string):
    n, m, *ab = map(int, string.split())
    ab = sorted([(a, b) for a, b in zip(ab[::2], ab[1::2])], key=lambda x: x[0])
    ans = 0
    for a, b in ab:
        if m <= b:
            ans += a * m
            break
        ans += a * b
        m -= b
    return str(ans)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 26124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    string s;cin>>s;
    int n=s.size();
    int odd=0,even=0;
    vector<int>Ans(n,0);
    rep(i,n){
        if(s[i]=='R'){
            if(i%2==0)even++;
            else odd++;
        }
        else{
            if(i%2==0){Ans[i]+=even;Ans[i-1]+=odd;}
            else{Ans[i]+=odd;Ans[i-1]+=even;}
            odd=0;even=0;
        }
    }
    odd=0;even=0;
    rep(i,n){
        if(s[i]=='R')s[i]='L';
        else s[i]='R';
    }
    reverse(all(s));
    rep(i,n){
        if(s[i]=='R'){
            if(i%2==0)even++;
            else odd++;
        }
        else{
            if(i%2==0){Ans[n-i-1]+=even;Ans[n-i]+=odd;}
            else{Ans[n-i-1]+=odd;Ans[n-i]+=even;}
            odd=0;even=0;
        }
    }
    rep(i,n)cout<<Ans[i]<<' ';
}

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

bool dp[2][5002][5001];
int x[5001];

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	f(i, 1, n + 1)scanf("%d", x + i);
	sort(x + 1, x + n + 1);
	n = lower_bound(x + 1, x + n + 1, k) - x - 1;
	dp[0][0][0] = true;
	dp[1][n + 1][0] = true;
	f(i, 1, n + 1)for (int j = k; j >= 0; --j)if (dp[0][i - 1][j]){
		dp[0][i][j] = true;
		int z = j + x[i];
		if (z <= k)dp[0][i][z] = true;
	}
	for (int i = n; i > 0; --i)for (int j = k; j >= 0; --j)if (dp[1][i + 1][j]){
		dp[1][i][j] = true;
		int z = j + x[i];
		if (z <= k)dp[1][i][z] = true;
	}
	int an = 0;
	f(i, 1, n + 1){
		int w = k;
		f(j, 0, k + 1)if (dp[0][i - 1][j]){
			while (w >= 0 && (!dp[1][i + 1][w] || w + j >= k))--w;
			if (w == -1)break;
			if (w + j + x[i] >= k) { ++an; break; }
		}
	}
	printf("%d\n", n - an);
}


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

int sumOf(int n) {

	int sum=0;
	while (n) {
		sum += n % 10;
		n = n / 10;
	}
	return sum;

}


int main() {

	int N;
	cin >> N;

	vector<int>num;

	for (int i = 1; i < N; i++) {
			num.push_back(sumOf(i) + sumOf(N-i));
	}

	int min = num[0];
	for (unsigned int i = 0; i < num.size(); i++) {
		if (min > num[i]) {
			min = num[i];
		}
	}

	cout << min << endl;

	return 0;

}

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

int main(){
	string s,t;
	cin>>s>>t;
	string ds=s+s;
	vector<vector<int>> abc(26);
	for (int i = 0; i < ds.length(); i++) {
		abc[ds[i]-'a'].push_back(i);
	}
	for (int i = 0; i < 26; i++) {
		sort(abc[i].begin(),abc[i].end());
	}
	//now:今のsでの添字
	int now=-1;
	long long int ans=0;
	for (int i = 0; i < t.length(); i++) {
		vector<int>& temp=abc[t[i]-'a'];
		auto itr=lower_bound(temp.begin(),temp.end(),now+1);
		if (itr!=temp.end()) {
			ans+=*itr-now;
			now=*itr%s.length();
		}else {
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1980
// abc161_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

string s = "0";
int cnt = 0;
int K;
ll ans = -1;

void dfs(void){

    if (ans != -1){
        return;
    }

    if (s.size() == 14){
        cnt++;
        if (cnt == K + 1){ // 0の分
            ans = stol(s);
        }
        return;
    }

    int c = s.back() - '0';
    REP(i, 10){
        if (stol(s) != 0 && abs(c - i) > 1) continue;
        s += i + '0';
        dfs();
        s.pop_back();
    }
}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    cin >> K;

    dfs();

    print(ans);

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import static java.lang.Math.round;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int inputCount = sc.nextInt();
		List<Integer> inputList = new ArrayList<Integer>();
		for(int i=0;i<inputCount;i++){
			inputList.add(sc.nextInt());
		}
		
		//平均値を求める
		int sum = 0;
		for(Integer input : inputList){
			sum += input;
		}
		int ave = (int)round((double)sum/(double)inputCount);
		
		//コスト計算
		int cost = 0;
		for(Integer input : inputList){
			cost += (ave - input)*(ave - input);
		}
		sc.close();
		System.out.print(cost);
	}
}


Measured memory_bytes: 10064
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
         	int N = cin.ReadInt;
          	decimal sum = 0;
         	for (int i = 0; i < N; i++)
            {
              decimal k = cin.ReadDecimal;
          	  sum += 1 / k;
            }
            WriteLine(Round(1 / sum, 5, MidpointRounding.AwayFromZero));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public decimal ReadDecimal { get { return decimal.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 11348
#include <stdio.h>
int area(int,int,int,int);
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d", &a,&b,&c,&d);
	printf("%d", area(a,b,c,d));
	return 0;
}
int area(int a,int b,int c,int d){
	if(a*b>=c*d)
		return a*b;
	else
		return c*d;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

int main(void) {
	int n, T;
	cin >> n >> T;

	int ans = INT_MAX;
	
	int c, t;

	for(int i=0;i<n;i++) {
		cin >> c >> t;
		if(t<=T) {
			ans = min(ans, c);
		}
	}

	if(ans == INT_MAX) cout << "TLE" << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <vector>
using namespace std; 
const int Nmax = 10000;
const int INF = 1000000000;
const int MOD = 1000000007;

int main()
{   
    int n,k;
    cin>>n>>k;
    std::vector<int> v;
    for(int i=0;i<n;i++){
    	int num;
    	cin>>num;
    	v.push_back(num);
    }
    sort(v.begin(),v.end());
    long long int ans=0;
    for(int i=0;i<k;i++){
    	ans+=v[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
int main()
{
    char a[11],b[11],c[11];
    int p,q,i=0,j=0,k=0;
    scanf("%s %s %s",a,b,c);
    p=strlen(a);
    q=strlen(b);
    if(a[p-1]==b[0] && b[q-1]==c[0])
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
H, W = gets.strip.split(/ /).collect{|n| n.to_i}

pos = 0

begin
	H.times{|y|
		data = gets.strip.split(//).collect{|d| d == '#'}
		
		(0...pos).each{|x|
			raise "a #{pos}, #{y}, #{x}" if data[x]
		}
		while pos < W
			break unless data[pos + 1]
			pos += 1
		end
		
		((pos + 1)...W).each{|x|
			raise "b #{pos}, #{y}, #{x}" if data[x]
		}
	}
	puts "Possible"
rescue
	puts "Impossible"
end


Measured memory_bytes: 1788
s = list(input())
t = list(input())

cnt = 0
cnt_list = []

for i in range(len(s)-len(t)+1):
	for j in range(len(t)):
		if(s[i+j] != t[j]):
			cnt += 1
	cnt_list.append(cnt)
	cnt = 0


print(min(cnt_list))

Measured memory_bytes: 9020
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        n: usize,
        a_s: [usize; n],
    }
    let len_num_s = a_s
        .iter()
        .enumerate()
        .map(|(i, a)| (*a, i + 1))
        .collect::<Vec<(usize, usize)>>();
    let mut deque = std::collections::VecDeque::new();
    for (len, num) in len_num_s {
        for _ in 0..len {
            deque.push_back(num);
        }
    }
    let mut v = vec![vec![0; w]; h];
    for i in (0..h).step_by(2) {
        for j in 0..w {
            v[i][j] = deque.pop_front().unwrap();
        }
        if i + 1 != h {
            for j in (0..w).rev() {
                v[i + 1][j] = deque.pop_front().unwrap();
            }
        }
    }
    let ans = v
        .iter()
        .map(|item| {
            item.iter()
                .map(|i| i.to_string())
                .collect::<Vec<_>>()
                .join(" ")
        })
        .collect::<Vec<_>>()
        .join("\n");
    println!("{}", ans);
}


Measured memory_bytes: 2484
S = input()
N = len(S) + 1
a = [0] * N

for i in range(-1, N-1):
    if (i == -1 and S[i+1] == '<') or (i == N - 2 and S[i] == '>') or (S[i] == '>' and S[i+1] == '<'):
        j = 0
        while i - j >= 0 and S[i-j] == '>' and a[i-j] < j + 1:
            a[i-j] = j + 1
            j += 1
        j = 0
        while i + 2 + j < N and S[i+1+j] == '<' and a[i+2+j] < j + 1:
            a[i+2+j] = j + 1
            j += 1
print(sum(a))


Measured memory_bytes: 23380
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  for(int i = sx; i < tx; i++) cout << 'R';
  for(int i = sy; i < ty; i++) cout << 'U';
  for(int i = sx; i < tx; i++) cout << 'L';
  for(int i = sy; i < ty; i++) cout << 'D';
  cout << 'D';
  for(int i = sx; i < tx + 1; i++) cout << 'R';
  for(int i = sy; i < ty + 1; i++) cout << 'U';
  cout << 'L';
  cout << 'U';
  for(int i = sx; i < tx + 1; i++) cout << 'L';
  for(int i = sy; i < ty + 1; i++) cout << 'D';
  cout << 'R' << endl;
}


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

const int LLINF = 1LL << 60;

signed main()
{
  int N, C, K;
  int T[100005];

  cin >> N >> C >> K;

  Rep(i, N) cin >> T[i];
  sort(T, T + N);
  
  int p = 0;
  int cnt = 0;
  while(p < N) {
    int bus = T[p] + K;
    int i = 0;
    while(p < N && i < C && T[p] <= bus) p++, i++;
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int int64_t

signed main(){
	int n,x,ans=0;
	cin>>n>>x;
	int l[n+1],d=0;
	l[0]=0;
	rep(i,n)cin>>l[i+1];
	while(d<=x){
		ans++;
		d+=l[ans];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  int flag = 1;
  REP(i, SZ(s)) {
    if (i & 1) flag &= (s[i] == s[1]);
    else flag &= (s[i] == s[0]);
  }
  if (flag) {
    cout << "Second" << endl;
    return 0;
  }
  cout << ((s[0] == s.back())^(SZ(s) % 2 == 0) ? "Second" : "First") << endl;

  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int d=sc.nextInt();
			int n=sc.nextInt();
			if(d==0) {
				if(n<100) {
					System.out.println(n);
				}
				else {
					System.out.println(n+n/100);
				}
			}
			else if(d==1) {
				if(n<100) {
					System.out.println(100*n);
				}
				else {
					System.out.println((100+n/100)*n);
				}
			}
			else if(d==2) {
				if(n<100) {
					System.out.println(10000*n);
				}
				else {
					System.out.println((100+n/100)*100*n);
				}
			}
		}
	}
}

Measured memory_bytes: 22736
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    int cnt=0;
    while(A>=B) B*=2,cnt++;
    while(B>=C) C*=2,cnt++;
    if(cnt<=K) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3648
s=list(input())
#print(s)
if s[0] != "A":
  print("WA");exit()
#print(s[2:-1])
if "C" not in s[2:-1]:
  print("WA");exit()
s_remove=s.remove
s_remove("A");s_remove("C")
#print(s)
s="".join(s)
#print(s)
if s.islower():
  print("AC")
else:
  print("WA")

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
using namespace std;
ll N, M;
ll A, B;
ll ans;
string S;
ll K;
int main() {
	cin >> S >> K;
	ll nowpos = 0;
	rep(i, 0, S.size()) {
		if (S[i] != '1') {
			cout << S[i] << endl;
			break;
		}
		if (i == K - 1) {
			cout << S[i] << endl;
			break;
		}
	}
	cin >> ans;
	return 0;
}

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

using namespace std; 

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl; 
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1e9; 
const int Maxn = 1005; 
const int dx[] = {-1, 0, 1, 0}; 
const int dy[] = {0, 1, 0, -1}; 

struct pos { int first, second, third; }; 

int n; 
map <int, int> a; 
int ans; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin); 
		freopen("output.txt", "w", stdout); 
	#endif
	
	scanf("%d", &n); 
	while (n--)
	{
		int x; 
		scanf("%d", &x); 
		a[x]++; 
	}
	
	while (!a.empty())
	{
		map <int, int> :: iterator it = a.end(); 
		it--; 
		int x = it -> st; 
		if (!a[x]) throw; 
		a[x]--; 
		if (!a[x]) a.erase(x); 
		int z = 1; 
		while (z <= x) z <<= 1; 
		if (a.count(z - x) > 0)
		{
			a[z - x]--; 
			if (a[z - x] == 0) a.erase(z - x); 
			ans++; 
		}
	}
	
	printf("%d\n", ans); 
	
	return 0; 
}

Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;


int main(){
    int n; cin >> n;
    vector<int> v;
    for(int i = 1; i <= n; ++i){
        int x; cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    double sum = v[0];
    for(int i = 0; i < v.size(); ++i){
        sum = (sum + v[i]) / 2;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())

SP =[]
for i in range(N):
    SP.append([i+1] + list(map(str,input().split())))
    SP[i][2] = int(SP[i][2])

SP = sorted(SP,key = lambda x: x[2], reverse=True)
SP = sorted(SP,key = lambda x: x[1])

for i in range(N):
    print(SP[i][0])


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1E+9 + 7;

/* 差がdiffの壊れ床間の移動法 -> フィボナッチ数列の第diff-1項 */
long long int combination(int diff)
{
  if (diff == 1)
    return 0;
  if (diff == 2)
    return 1;
  long long int a, b, c;
  a = 0;
  b = 1;
  for (int i = 1; i < diff - 1; i++)
  {
    c = a + b;
    c %= mod;
    a = b;
    b = c;
  }
  return c;
}

int main()
{
  int N, M;
  cin >> N >> M;

  vector<int> a(M + 2);
  a.at(0) = -1;
  for (int i = 1; i <= M; i++)
  {
    cin >> a.at(i);
  }
  a.at(M + 1) = N + 1;

  long long int ans = 1;
  for (int i = 0; i < M + 1; i++)
  {
    ans = (ans * (combination(a.at(i + 1) - a.at(i)) % mod)) % mod;
  };
  cout << ans << endl;
}

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

int main() {
  ll n,k,a[114514];
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>a[i];
  ll ans=1e15,num;
  for(int i=0;i<n-k+1;i++){
    num=min(abs(a[i])+abs(a[i]-a[i+k-1]),abs(a[i+k-1])+abs(a[i+k-1]-a[i]));
    ans=min(ans,num);
  }
  cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import math
#N = int(input())
#S = str(input())
#A, B = map(int, input().split())
#C = list(map(int, input().split()))

N, K = map(int, input().split())

ans = 0
for i in range(1, N + 1):
  if i < K:
    tt = math.log2(K/i)
    if tt % 1 == 0:
      time = int(tt)
    else:
      time = int(tt) + 1
    ans += (1 / N) * ((1 / 2) ** time)
  else:
    ans += (1/ N)
#  print(time, ans)
  
print(ans)  

Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
using namespace std;

int main(){
    int x;
    cin >> x;
    for(int i=1;i<=x;i++){
        if(i%3==0){
            printf(" %d", i);
            continue;
        }
        int j = i;
        while(1){
            if(j==0)break;
            if(j%10==3){
                printf(" %d", i);
                break;
            }
            j = j / 10;
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 3196
#!/usr/bin/env python3
import sys


def solve(S: int):

    if 0 <= int(S[:2]) <= 99 and 1 <= int(S[2:]) <= 12:
        if 1 <= int(S[:2]) <= 12:
            print("AMBIGUOUS")
        else:
            print("YYMM")
    elif 1 <= int(S[:2]) <= 12 and 0 <= int(S[2:]) <= 99:
        if 1 <= int(S[2:]) <= 12:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        print("NA")

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 3003
#define inf LLONG_MAX
#define hahaha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    hahaha
    
    string s,t;
    cin>>s>>t;
    int n=s.length(),m=t.length();
    int dp[n+1][m+1],i,j,k;
    memset(dp,0,sizeof dp);
    
    int ma=0,x,y;
    
    for(i=0;i<=m;++i)
        dp[0][i]=0;
    for(i=0;i<=n;++i)
        dp[i][0]=0;
    
    for(i=1;i<=n;++i)
    {
        for(j=1;j<=m;++j)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            dp[i][j]=max({dp[i][j],dp[i-1][j],dp[i][j-1]});
            if(dp[i][j]>ma)
                ma=dp[i][j],x=i,y=j;
        }
    }
    
    string ans("");
    while(ma)
    {
        if(s[x-1]==t[y-1])
            ans+=s[x-1],--x,--y,--ma;
        else
        {
            if(dp[x][y-1]==dp[x][y])
                --y;
            else
                --x;
        }   
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N, M;
vector<ll> X;

const ll base = 100001;

signed main()
{
    cin >> N >> M;
    X.resize(M);
    REP(i, M) {
        cin >> X[i];
        X[i] += base;
    }
    SORT(X);

    if(N >= M) {
        printf("0\n");
        return 0;
    }

    // first: 間隔の大きさ second: 左インデックス
    vector< pair<ll, ll> > interval;
    REP(i, M-1) {
        interval.push_back(make_pair(X[i+1] - X[i], i));
    }
    sort(interval.begin(), interval.end(), greater< pair<ll, ll> >());
    // 間隔がでかいやつを N-1 個選ぶ
    vector<ll> choise;
    REP(i, N-1) {
        choise.push_back(interval[i].second);
    }
    choise.push_back(M-1);
    choise.push_back(-1);
    SORT(choise);

    // DEBUG
    //DBG("choise: ");
    //REP(i, choise.size()) {
    //    DBG("%lld ", choise[i]);
    //}
    //DBG("\n");

    ll ans = 0;
    for(int i = 1; i < choise.size(); ++i) {
        ans += X[choise[i]] - X[choise[i-1] + 1];
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 4208
n = int(input())
sum = 0;

nn = n//2;
nnn = n-nn
if n <= 5000000:
    for i in range(1,n+1):
        x = n//i;
        sum += i*x*(x+1)//2;
else:
    for i in range(1,5000000+1):
        x = n//i;
        sum += i*x*(x+1)//2;
    sum += (n-5000000)*(5000001+n)//2;
print(sum);

Measured memory_bytes: 9136
// Black Radius
// * frank_c1
// * 2017 / 12 / 28

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

const int maxn = (int)(2e5) + 5;
const int INF = (int)(1e9);
vector<int> nxt[maxn];
char s[maxn];
int f[maxn], g[maxn];
int mi[maxn], mx[maxn];
multiset<int> h[maxn];
int su;

void _dfs(int x, int fa) {
	g[x] = (s[x] == '1');
	mi[x] = (s[x] == '1' ? 0 : INF);
	for (int i = 0; i < (int)nxt[x].size(); ++i)
		if (nxt[x][i] != fa) {
			_dfs(nxt[x][i], x);
			f[x] = max(f[x], f[nxt[x][i]] + 1);
			g[x] += g[nxt[x][i]];
			if (g[nxt[x][i]]) mi[x] = min(mi[x], f[nxt[x][i]] + 1);
			h[x].insert(f[nxt[x][i]]);
		}
}

void dfs(int x, int fa, int v) {
	mx[x] = min(max(v, f[x]) - 1, f[x] + 1);
	for (int i = 0; i < (int)nxt[x].size(); ++i)
		if (nxt[x][i] != fa) {
			h[x].erase(h[x].find(f[nxt[x][i]]));
			int c = max(v, (h[x].empty() ? -1 : *h[x].rbegin()) + 1) + 1;
			if (su - g[nxt[x][i]]) mi[nxt[x][i]] = min(mi[nxt[x][i]], c);
			dfs(nxt[x][i], x, c); mx[x] = min(mx[x], c);
			h[x].insert(f[nxt[x][i]]);
		}
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		nxt[u].push_back(v); nxt[v].push_back(u);
	} 
	scanf("%s", s + 1);
	for (int i = 1; i <= n; ++i) su += (s[i] == '1');
	_dfs(1, 0); dfs(1, 0, 0);
	LL ret = 0;
	for (int i = 1; i <= n; ++i) ret += max(mx[i] - mi[i] + 1, 0);
	return printf("%lld\n", ret + 1), 0;
}

Measured memory_bytes: 47488
#include <iostream>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <vector>

#define rep(i, s, N) for(long i = s; i < N; i++)
#define YesNo(result) do {if (result) std::cout << "Yes" << '\n'; else std::cout << "No" << '\n';} while(0)
#define resetarr(arr, val) for(long i = 0; i < sizeof(arr) / 4; i++){ arr[i] = val; }

int main(int argc, char const *argv[]) {
  long a,b,k;
  std::cin >> a >> b >> k;
  //long list[b+1];
  //resetarr(list,0);
  for(long i = a; i <= b; i++){
    if(i < a+k || b-k < i) std::cout << i << '\n';
  }
  // for(long i= 0; i < k; i++) {
  //   if (a+i <= b) list[a+i] = 1;
  //   if (b-i >= a) list[b-i] = 1;
  // }
  // return 0;
  // rep(i, 0, b+1) {
  //   if(list[i] == 1){
  //     std::cout << i << '\n';
  //   }
  // }
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;


signed main() {
	cin1(n);
	int x;cin1(x);

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

	int ans = 0;
	for (int i = 0; i < n-1; i++) {
		int sum = a[i] + a[i+1];
		if (sum > x) {
			int eat = sum - x;
			a[i+1] -= eat;
			if (a[i+1] < 0) {
				int more_eat = -1 * a[i+1];
				a[i+1] = 0;
				a[i] -= more_eat;
			}
			ans += eat;
		}
		/*
		while(sum > x) {
			if (a[i+1] > 0) {
				a[i+1]--;
			}else if(a[i] > 0) {
				a[i]--;
			}
			ans++;
			sum--;
		}
		*/
	}
	cout(ans);

	return 0;
}





Measured memory_bytes: 1024