akhauriyash/Code-Regression huggingface dataset:
#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;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int x;
	cin >> x;
	x /= 200;
	cout << 10 - x;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, C;
    cin >> N >> C;
    vector<vector<P>> items(C);
    rep(i, N) {
        ll s, t, c;
        cin >> s >> t >> c;
        c--;
        items[c].emplace_back(s, t);
    }
    vector<vector<ll>> imos(C, vector<ll>(200005, 0));
    vector<ll> ans(200005, 0);
    rep(i, C) {
        rep(j, items[i].size()) {
            P p = items[i][j];
            imos[i][2 * p.first - 1]++;
            imos[i][2 * p.second]--;
        }
        rep(j, 200004) {
            imos[i][j + 1] += imos[i][j];
            ans[j + 1] += (imos[i][j + 1] >= 1 ? 1: 0);
        }
    }
    cout << (*max_element(ans.begin(), ans.end())) << '\n';
}

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


Measured memory_bytes: 51328
#include <iostream>
#define inf 1e9

using namespace std;

int N;
int pos[2005][2];
int dp[4005][2005];

struct BIT{
	int bit[4005];
	BIT(){
		for(int i = 1; i <= 2*N; i++) bit[i] = 0;
	}
	int query(int i)
	{
		int ret = 0;
		while(i > 0){
			ret += bit[i];
			i -= i & (-i);
		}
		return ret;
	}
	void add(int i, int j)
	{
		while(i <= 2*N){
			bit[i] += j;
			i += i & (-i);
		}
	}
};

BIT bit[2005];

int getpos(int i, int j, int x, int c)
{
	return pos[x][c] + (i+j) - bit[i].query(pos[x][c]);
}

int main(void)
{
	cin >> N;
	char c; int a;
	for(int i = 1; i <= 2*N; i++){
		cin >> c >> a;
		if(c == 'W') pos[a][0] = i;
		else pos[a][1] = i;
	}
	
	for(int i = 0; i <= N; i++){
		for(int j = 1; j <= i; j++){
			bit[i].add(pos[j][0], 1);
		}
	}
	
	for(int i = 0; i <= 2*N; i++){
		for(int j = 0; j <= N; j++){
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for(int i = 0; i < 2*N; i++){
		for(int j = 0; j <= N; j++){
			int b = i-j;
			if(j < N) dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + getpos(j, b, j+1, 0) - (i+1));
			if(b < N) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + getpos(j, b, b+1, 1) - (i+1));
		}
		for(int j = 0; j <= min(i, N); j++){
			if(i+1-j > N) continue;
			bit[j].add(pos[(i+1)-j][1], 1);
		}
		
		/*for(int j = 0; j <= N; j++){
			for(int k = 1; k <= 2*N; k++){
				cout << bit[j].query(k) << " ";
			}
			cout << endl;
		}
		cout << endl;*/
		
	}
	
	/*for(int i = 0; i <= 2*N; i++){
		for(int j = 0; j <= N; j++){
			cout << dp[i][j] << " "; 
		}
		cout << endl;
	}*/
	
	cout << dp[2*N][N] << endl;
	return 0;
}

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

int main() {
    string n;
    std::cin >> n;
    for (int i = 1; i < n.length(); i++) {
        if(n[i] == '9'){
            continue;
        }else{
            std::cout << (n.length()-1)*9+n[0]-'0'-1 << std::endl;
            return 0;
        }
    }
    std::cout << (n.length()-1)*9+n[0]-'0' << std::endl;
    
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////
ll n,m;
vector<string> a;
vector<string> b;

bool ck(int x,int y){
    bool ans = true;
    if(x+b[0].size()> a[0].size())return false;
    if(y+b.size() > a.size())return false;
    rep(i,b.size()){
        rep(j,b[0].size()){
            if(a[x+i][j+y] != b[i][j])ans = false;
        }
    }
    return ans ;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>m;
    a.resize(n); b.resize(m);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,m){
        cin>>b[i];
    }
    bool ans = false;
    rep(i,n){
        rep(j,a[0].size()){
            if(ck(j,i))ans=true;
        }
    }
    Yes(ans);
    return 0;
}

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

using namespace std;

int main(){
    int N,M,X;

    cin >> N >> M >> X;

    int A[M];

    int boundary;
    int cost=0;


    for(int i=0;i<M;++i){
        cin >> A[i];
        if(A[i]<X){
            cost += 1;
        }
    }

   cout << min(cost,M-cost);


}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed May  2 21:28:06 2018
ALDS1_5a
@author: maezawa
"""
import itertools as itr

n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

sum_array = []
for r in range(1,n+1):
    for comb in itr.combinations(a, r):
        sum_array.append(sum(comb))

for i in m:
    yesorno = 'no'
    for j in sum_array:
        #print(i, j)
        if i == j:
            yesorno = 'yes'
            break
    print(yesorno)



Measured memory_bytes: 43060
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
//cin.tie(0);ios::sync_with_stdio(false);
////////////////////////////////////////////////
long long int m[5];

int main()
{
	int n=0;cin>>n;
	char s[15]={0};
	REP(i,n)
	{
		cin>>s;
		if(s[0]=='M')m[0]++;
		else if(s[0]=='A')m[1]++;
		else if(s[0]=='R')m[2]++;
		else if(s[0]=='C')m[3]++;
		else if(s[0]=='H')m[4]++;
	}
	long long int ans=0;
	ans+=(m[0]*m[1]*m[2]);
	ans+=(m[0]*m[1]*m[3]);
	ans+=(m[0]*m[1]*m[4]);
	ans+=(m[0]*m[2]*m[3]);
	ans+=(m[0]*m[2]*m[4]);
	ans+=(m[0]*m[3]*m[4]);
	ans+=(m[1]*m[2]*m[3]);
	ans+=(m[1]*m[2]*m[4]);
	ans+=(m[1]*m[3]*m[4]);
	ans+=(m[2]*m[3]*m[4]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int N,i,A;
  char S[100];
  scanf("%d\n%s",&N,S);
  A=1;
  
  if(N%2==1){
    A=0;
  }else{
    for(i=0;i<=N/2-1;i++){
      if(S[i]!=S[N/2+i]){
        A=0;
      }
    }
  }
  
  if(A==1){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
}

Measured memory_bytes: 128
import sys
while(True):
    try:
        hit=0
        blow=0
        a=[int(i) for i in input().split()]
        b=[int(i) for i in input().split()]
        for i in range(len(a)):
            for j in range(len(b)):
                if a[i]==b[j]:
                    if i==j:
                        hit+=1
                    else:
                        blow+=1
                    break
        print(hit,blow)
    except EOFError:
        sys.exit()
        

Measured memory_bytes: 7616
#include<bits/stdc++.h>
using namespace std;
//#define int long long  
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	    
signed main(){
// __builtin_ctz(N);      Nを２で何回割り切れるかを返す
//(n+1)*n/2;              １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c=5,d;
    cin>>a;
    b=a%100;
    d=a/100;
    c=d*c;
    if(b<=c) cout<<"1";
    else cout<<"0";
    cout<<"\n";
}



Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if(Math.abs(c-a) <= d){
            System.out.println("Yes");
        }else if(Math.abs(b-a) <= d && Math.abs(c-b) <= d){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        sc.close();
    }
}

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

using namespace std;

typedef long long ll;

ll dp[20001][256];

int main(){

  ll n,m,c[16],x[20000];

  while(cin>>n>>m,n){

    for(ll i=0;i<m;i++)cin>>c[i];
  
    for(ll i=0;i<n;i++)cin>>x[i];
  
    for(ll i=0;i<20001;i++)
      for(ll j=0;j<256;j++)dp[i][j]=1e15;

    dp[0][128]=0;

    for(ll i=0;i<n;i++)
      for(ll j=0;j<256;j++)
	for(ll k=0;k<m;k++){
	  ll y=min(255LL,max(0LL,j+c[k]));
	  dp[i+1][y]=min(dp[i][j]+(y-x[i])*(y-x[i]),dp[i+1][y]);
	}
  
    ll ans=1e15;
    for(ll i=0;i<256;i++)ans=min(ans,dp[n][i]);

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

Measured memory_bytes: 43148
import collections

N, P = map(int, input().split())
S = input()
ans = 0

if P == 2 or P == 5:
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i + 1
    print(ans)
else:
    S = S[::-1]
    a, temp = [int(S[0]) % P], 1
    for i in range(1, N):
        temp *= 10
        temp %= P
        a.append((a[i-1] + (int(S[i]) % P * temp) % P) % P)

    c = collections.Counter(a)
    if 0 in c:
        ans += c[0]
        ans += c[0] * (c[0] - 1) // 2
        del c[0]
    for x in c.keys():
        ans += c[x] * (c[x]-1) // 2 
    print(ans)

Measured memory_bytes: 12000
def get_max_candies(n, grid):
    cache = [[0 for _ in range(n)] for _ in range(2)]
    for row in range(2):
        for col in range(n):
            cache[row][col] = grid[row][col]
            max_from_col = 0
            max_from_row = 0
            if col >= 1:
                max_from_col = cache[row][col - 1]
            if row >= 1:
                max_from_row = cache[row - 1][col]
            cache[row][col] += max(max_from_col, max_from_row)
    return cache[-1][-1]

if __name__ == '__main__':
    n = int(input())
    grid = []
    grid.append(list(map(int, input().split(" "))))
    grid.append(list(map(int, input().split(" "))))
    print(get_max_candies(n, grid))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int N; cin >> N;
  int X[N];
  rep(i,N) cin >> X[i];

  int retval = 1000000009;
  int res = 0;
  for (int P=1;P<=100;P++){
    res = 0;
    rep(i,N){
      res += (X[i]-P)*(X[i]-P);
    }
    retval = min(retval, res);
  }
  
  cout << retval << endl;
  return 0;
}


Measured memory_bytes: 256
function main(input) {
    input = input.trim().split(" ");
    var x = ["SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"];
    console.log(x.indexOf(input[0]) + 1);
  }
   
  main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

typedef long long ll;
const ll MOD = 1000000007;

ll mod_pow(ll x, ll n) {
    if (n == 0) {
        return 1;
    }
    ll res = mod_pow(x * x % MOD, n / 2);
    if (n % 2) res = res * x % MOD;
    return res;
}

ll C(ll n, ll k) {
    ll res = 1;
    for (int i = 1; i <= k; i++) {
        res = res * (n - i + 1) % MOD;
        res = res * mod_pow(i, MOD - 2) % MOD;
    }
    return res;
}

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

    ll res = mod_pow(2, n) - 1;
    res -= C(n, a) + C(n, b);
    res %= MOD;
    if (res < 0) res += MOD;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
H, W = [int(x) for x in input().split()]
C = [[int(x) for x in input().split()] for _ in range(10)]
A = [[int(x) for x in input().split()] for _ in range(H)]

import heapq
def dijkstra(adj, n, st=1):
    dj = [2**64] * (n + 1)
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                heapq.heappush(q, (dj[tn], tn))
    return dj

adj = {}
for j in range(10):
    t = []
    for i in range(10):
        t.append([i, C[i][j]])
    adj[j] = t
costs = dijkstra(adj, 9, 1)

from itertools import chain
print(sum(costs[x] for x in chain(*A) if x != -1))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define pb push_back
#define ALL(v) v.begin(),v.end()
const long long INF = 1LL << 60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using LLP = pair<ll, P>;
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; }

struct Edge {
  int to;
  P cost;//time, coin
  Edge(int to, P cost) : to(to), cost(cost) {}
};
using Graph = vector<vector<Edge>>;
int main()
{
    int N, M, S;
    cin >> N >> M >> S;
    int SMAX = 2500;
    chmin(S, SMAX);

int AMAX = 0;
    Graph G(N);
    rep(i, M){
        int a, b, c, d;
        cin >> a >> b >> c >> d;//c : coin
        --a;--b;
        G[a].emplace_back(b, P(d, c));
        G[b].emplace_back(a, P(d, c));
        chmax(AMAX, c);
    }
    vector<vector<P>> Ext(N);
    rep(i, N)
    {
        int c, d;
        cin >> c >> d;
        Ext[i].emplace_back(d, c);//minute, coin
    }

    priority_queue<LLP, vector<LLP>, greater<LLP>> q;
    vector<vector<ll>> dp(N, vector<ll>(SMAX+1, INF));//dp[pos][coin] = time/ coin wo hojisite pos he iku saitan jikan
    dp[0][S] = 0;
    q.emplace(0, P(0, S));

    while (q.size()) {
        // long long cost;
        // LLP v;
        LLP x = q.top();
        q.pop();
        ll time = x.first;
        ll pos  = x.second.first;
        ll coin = x.second.second;
        if (dp[pos][coin] != time) {
          continue;
        }
        dp[pos][coin] = time;
        //rep2(i, 1, SMAX)//get coin
        if(coin < AMAX*(N-1))
        {
            auto y = Ext[pos];
            auto z = y.back();
            auto c = z.second;
            auto d = z.first;
            auto nn = min(coin+c, (ll)SMAX);
            if(chmin(dp[pos][nn], time+d)){
                q.emplace(time+d, P(pos, nn));
            }
        }
        for (auto e : G[pos]) {
            int to = e.to;
            P cost = e.cost;
            ll ntime = cost.first;
            ll ncoin = cost.second;
            if(coin-ncoin>=0 && chmin(dp[to][coin-ncoin], time + ntime))
            q.emplace(time + ntime, P(to, coin-ncoin));
        }
    }
    rep2(i, 1, N){
        ll ans = INF;
        rep(j, SMAX+1) chmin(ans, dp[i][j]);
        cout << ans << endl;
    }
    return 0;
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int h,n;
	cin>>h>>n;
	vi vs(n);
	for(int &x:vs) cin>>x;
	sort(all(vs));
	for(int i=n-1;i>=0;--i){
		h-=vs[i];
	}
	if(h<=0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    string s;
    cin >> s;
	int ans = INT32_MAX;
	for (char c = 'a'; c <= 'z'; c++) {
		int count = 0,maxc = 0;
		for (auto&& var : s) {
			if (var == c) {
				count = 0;
			}
			else {
				count++;
				maxc = max(maxc,count);
			}
		}
		ans = min(ans,maxc);
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define N 200005
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;





void solve()
{
	int n,k;
	cin>>n>>k;
	
	int a[n];
	
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	sort(a,a+n);
	int sum=0;
	
	
	for(int i=0;i<k;i++)
	sum+=a[i];
	
	cout<<sum<<endl;
}
signed main()
{
    
	nuenxfiu
	//TT
	solve();
     return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  string s; cin >> s;
  int n = s.size();
	vector<int> evn(n, 0), odd(n, 0);
	for (int i = 0; i < n - 1; i++) {
    if (s[i] != 'R') continue;
		int j = i;
    while (s[j + 1] == 'R') j++;
    int c = j - i + 1;
    if (c % 2 == 0) {
      evn[j] += c / 2;
      evn[j + 1] += c / 2;
    } else {
      evn[j] += c / 2 + 1;
      evn[j + 1] += c / 2;
    }
    i = j;
	}
  for (int i = n - 1; i > 0; i--) {
    if (s[i] != 'L') continue;
    int j = i;
    while (s[j - 1] == 'L') j--;
    int c = i - j + 1;
    if (c % 2 == 0) {
      evn[j] += c / 2;
      evn[j - 1] += c / 2;
    } else {
      evn[j] += c / 2 + 1;
      evn[j - 1] += c / 2;
    }
    i = j;
  }
  for (int i = 0; i < n; i++) {
    cout << evn[i] << ' ';
  }
  cout << '\n';
}


Measured memory_bytes: 4960
N,M,X=map(int,input().split())
import numpy as np
Q=[]
list1 = [list(map(int,input().split())) for i in range(N)]
for i in range(1,2**len(list1)):  # 空集合を除く場合はrange(1, 2**len(list1))
    list2 = []
    for j in range(len(list1)):
        if (i >> j) &1 == 1:
            list2.append(list1[j])
    Q.append(list2)
R=[]

for q in range(0,len(Q)):
    Q[q]=np.array(Q[q])
    r=np.sum(Q[q], axis=0)
    R.append(r)
R=np.array(R) #17行目までで本の買い方を全て羅列。
S=R[:,1:] #18行目でアルゴリズムの理解度のみの行列を作る。
T=[]
for g in range(0,len(S)):
    if all(i >= X for i in S[g]): #Sのなかでアルゴリズムの理解度がすべてX以上の行のみ取り出す。
        T.append(R[g])
    else:
        T=T
if len(T)>0:
    T=np.array(T)
    T=T[T[:,0].argsort(), :] #本の値段の合計が安い順にする。
    print(T[0][0])
else:
    print(-1)

Measured memory_bytes: 32024
#include <bits/stdc++.h>
 
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int ans=0;
	int dp[n+1]={};
	for(int i=1;i<n;i++)
		dp[i]=1e9;

	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i-j<0)
				break;
			dp[i]=min(dp[i],abs(a[i]-a[i-j])+dp[i-j]);
		}
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
/*---> 07 March 2020 <--- > 02:32:40 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int n,m,x,y;
	cin>>n>>m;
	if(n==1){
		int ans=0;
		bool ok=false;
		for(int j=0;j<m;j++){
			cin>>x>>y;
			x--;
			if(x!=0){
				return cout<<-1<<"\n",0;
			}
			if(ok && y!=ans)
				return cout<<-1<<"\n",0;
			ok=true;
			ans=y;
		}
		cout<<ans<<"\n";
	}
	else{
		string ans="1";
		for(int j=0;j<n-1;j++)
			ans+='0';
		vi vis(n);
		for(int j=0;j<m;j++){
			cin>>x>>y;
			x--;
			if(x>=n)
				return cout<<-1<<"\n",0;
			if(vis[x] && (y+'0')!=ans[x])
				{	
					// debug()<< imie(j);
					return cout<<-1<<"\n",0;
				}
			vis[x]=1;
			ans[x]=y+'0';
		}
		int res=stoll(ans);
		int dig=log10(res)+1;
		if(dig!=n)
			return cout<<-1<<"\n",0;
		cout<<ans<<"\n";
	}
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    
    int W,H,x,y,r;
    scanf("%d %d %d %d %d" , &W,&H,&x,&y,&r );
    if((x+r)<=W && (y+r)<=H && x>=r && y>=r){ 
        printf("Yes\n");
                            }
    else                    {
        printf("No\n");
                            }
    
    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,i,j;scanf("%d%d",&n,&k);
  int a[n],C[n];
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  for(i=0;i<k;i++){
    for(j=0;j<n;j++){
      C[j] = a[j];a[j] = 0;
    }
    for(j=0;j<n;j++){
      a[max(0,j-C[j])]++;
      if(j+C[j]+1<n) a[j+C[j]+1]--;
    }
    for(j=1;j<n;j++) a[j] += a[j-1];
    if(*min_element(a,a+n) == n){
      for(j=0;j<n;j++) printf("%d ",n);
      printf("\n");return 0;
    }
  }
  for(i=0;i<n;i++) printf("%d ",a[i]);
  printf("\n");return 0;
}

Measured memory_bytes: 5364
from collections import defaultdict


def dd(N, abc, ne_table, start_i):
    used_edge = set()
    pivot = start_i

    kouho = {start_i: (0, 0, True)}  # value: (d, path,kakutei)

    for _ in range(N - 1):

        current_dist, path, kaku = kouho[pivot]
        assert kaku
        edges_i = ne_table[pivot]  # エッジリスト取得
        for i in edges_i:
            a, b, weight = abc[i]
            target = a if a != pivot else b

            if target in kouho:
                tmp_d, tmp_path, kakutei = kouho[target]
                if kakutei:
                    continue
                if current_dist + weight < tmp_d:  # 更新
                    kouho[target] = (current_dist + weight, i, False)
                continue
            kouho[target] = (current_dist + weight, i, False)

        min_kouho = min([(k, d, p) for k, (d, p, kakutei) in kouho.items() if not kakutei], key=lambda q: q[1])
        min_kouho_i = min_kouho[0]
        used_edge.add(min_kouho[2])
        kouho[min_kouho_i] = (kouho[min_kouho_i][0], kouho[min_kouho_i][1], True)
        pivot = min_kouho_i
    return used_edge


def main():
    N, M = [int(a) for a in input().split()]

    def pre(a, b, c):
        return a - 1, b - 1, c

    abc = [
        pre(*[int(a) for a in input().split()])
        for _ in range(M)
    ]

    ne_table = defaultdict(lambda: [])
    for i, (a, b, c) in enumerate(abc):
        ne_table[a].append(i)
        ne_table[b].append(i)

    total_used = set()

    for i in range(N):
        used = dd(N, abc, ne_table, i)
        total_used.update(used)

    print(M - len(total_used))


if __name__ == '__main__':
    main()


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

    string s;
    cin >> s;
    
    int q;
    cin >> q;
    
    vector<string> data(2*4*100000);
    int right = 2*2*100000+1;
    int left = 2*2*100000-1;
    
    int count = 0;
    for(int i=0; i<q; i++) {
        int t;
        cin >> t;
        if(t == 1) {
            count++;
        }
        else if(t == 2) {
            int f;
            string c;
            cin >> f >> c;
            
            bool isEven = (count%2 == 0)? true:false;
            
            if(f == 1) {
                if(isEven) data[left--] = c;
                else data[right++] = c;
            }
            else if(f == 2) {
                if(isEven) data[right++] = c;
                else data[left--] = c;
            }
        }
    }
    
    bool isEven = (count%2 == 0)? true:false;

    if(isEven) {
        for(int i = left+1; i < right; i++) {
            if(i == 2*2*100000) {
                cout << s;
            }
            else {
                cout << data[i];
            }
        }   
    }
    else {
        reverse(s.begin(), s.end());
        for(int i = right-1; i > left; i--) {
            if(i == 2*2*100000) {
                cout << s;
            }
            else {
                cout << data[i];
            }
        }
    }
    
    cout << endl;
    
    return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 0) {
    cout << (a + b) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

typedef long long ll;
const ll INF = 1000000000000;
const ll MOD = 1000000000 + 7;
const ll MAX_N = 100;
const ll MAX_V = 1000;
ll dp[MAX_N + 1][MAX_V * MAX_N + 1];
ll v[MAX_N];
ll w[MAX_N];

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

  ll N, W;
  cin >> N >> W;

  for (ll i = 1; i <= N; i++) cin >> w[i] >> v[i];

  for (ll j = 0; j <= MAX_V * MAX_N; j++) dp[0][j] = INF;
  dp[0][0] = 0;
  
  for (ll i = 1; i <= N; i++) {
    for (ll j = 0; j <= MAX_V * MAX_N; j++) {
      if (j - v[i] >= 0) dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
      else dp[i][j] = dp[i-1][j];
    }
  }


  ll ans = 0;
  for (ll j = 0; j <= MAX_V * MAX_N; j++) {
    if (dp[N][j] == INF) continue;
    if (dp[N][j] <= W) ans = j;
  }
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 82080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using Tuple = tuple<int, int, int>;


int main() {
    int a,b; cin >> a >> b;
    int ans = 0;
    for(int i=a; i <= b; i++) {
        string rev = to_string(i);
        reverse(rev.begin(), rev.end());
        if(to_string(i) == rev) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
n = int(input())
h = int(input())
w = int(input())
print((n-h+1)*(n-w+1))

Measured memory_bytes: 9472
#include <stdio.h>
 
int main(void){
    int N, i, j, minj;
    int count = 0, swap;
    
    scanf("%d", &N);
    
    int A[N];
    for(i = 0; i < N; i ++) scanf("%d", &A[i]);
    
    for(i = 0; i < N; i ++) {
        minj = i;
        for(j = i; j < N; j ++) {
            if(A[j] < A[minj]) {
                minj = j;
            }
        }
        swap = A[i];
        A[i] = A[minj];
        A[minj] = swap;
        if (minj != i) count ++;
    }
    
    for(i = 0; i < N-1; i ++) printf("%d ", A[i]);
    printf("%d\n", A[N-1]);
    printf("%d\n", count);
    
    return 0;
}

Measured memory_bytes: 1848
/*
*
*   Bismillah Hir Rahman Nir Raheem
*   Name: Jaied Al Sabid
*
*/

#include <iostream>
#include <string>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s,t,r;

    cin>>s>>t;

    cout<<t<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
import random
X=int(input())

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

while not is_prime3(X):
    X+=1
print(X)

Measured memory_bytes: 3316
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, n)
		id, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		vNum, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		for j := 0; j < vNum; j++ {
			v, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			matrix[id-1][v-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		printRow(matrix[i])
	}
}

func printRow(row []int) {
	xs := make([]string, len(row))
	for i := 0; i < len(row); i++ {
		xs[i] = strconv.Itoa(row[i])
	}
	fmt.Println(strings.Join(xs, " "))
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}



Measured memory_bytes: 1404
buildings = [ [
    [ 0 for _ in range(10) ] for _ in range(3)
] for _ in range(4) ]

n = int(input())

for _ in range(n):
    b, f, r, v = map(int, input().split())
    buildings[b-1][f-1][r-1] += v

sep = ''

for building in buildings:
    if sep:
        print(sep)

    for floor in building:
        print(" "+" ".join([str(x) for x in floor]))

    sep = '#'*20


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  bool ans = 1;
  for(int i=0;i<s.size();i++){
    if(i%2 == 0 && s.at(i) == 'L'){
      ans = 0;
    }
    else if(i%2 == 1 && s.at(i) == 'R'){
      ans = 0;
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

namespace _1142
{
    class Program
    {
        static string rev(string s)
        {
            return new string(s.Reverse().ToArray());
        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                if (s.Length == 1) Console.WriteLine(1);
                else
                {
                    HashSet<string> ret = new HashSet<string>();
                    for (int j = 1; j < s.Length; j++)
                    {
                        string a = s.Substring(0,j);
                        string b = s.Substring(j,s.Length - j);
                        ret.Add(a + b); ret.Add(a + rev(b));
                        ret.Add(rev(a) + b); ret.Add(rev(a) + rev(b));
                        ret.Add(b + a); ret.Add(b + rev(a));
                        ret.Add(rev(b) + a); ret.Add(rev(b) + rev(a));
                    }
                    Console.WriteLine(ret.Count);
                }
            }
        }
    }
}


Measured memory_bytes: 10048
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    ll n, T, t, ans = 0;
    cin >> n >> T;
    ll i = 0, j = 0;
    while (n--) {
        cin >> t;
        if (t > j) {
            ans += j-i;
            i = t;
        }
        j = t+T;
    }
    ans += j-i;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct activity{
    int A , B , C;
};
int maxmimum_gain(vector<activity> a , int n){
    int dp[n+1][3] = {0};
    dp[1][0] = a[1].A;
    dp[1][1] = a[1].B;
    dp[1][2] = a[1].C;
    
    for(int i=2 ; i<=n ; i++){
        dp[i][0] = a[i].A + max(dp[i-1][1] , dp[i-1][2]);
        dp[i][1] = a[i].B + max(dp[i-1][2] , dp[i-1][0]);
        dp[i][2] = a[i].C + max(dp[i-1][0] , dp[i-1][1]);
    }

    return max(dp[n][0] , max(dp[n][1] , dp[n][2]));
}
int main(){
    int n;
    cin>>n;
    vector<activity> a(n+1);
    for(int i=1 ; i<=n ; i++){
        cin>>a[i].A>>a[i].B>>a[i].C;
    }
    cout<<maxmimum_gain(a , n);
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n,k,i;
  cin>>n>>k;
  n--;
  for(int i=k-n;i<= k+n;i++)
  cout<<i<<" ";
 
  return 0;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,ans;
    scanf("%lld %lld %lld",&a,&b,&c);
    if(a>=b&&a>=c)
    {
        ans=b+c;
        printf("%lld\n",ans);
    }
    else if(b>=c&&b>=a)
    {
        ans=c+a;
        printf("%lld\n",ans);
    }
    else
    {
        ans=a+b;
    printf("%lld\n",ans);
    }


}


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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    string S;
    cin>>S;
    ll N=S.size();
    ll ans=N;
    REP(i,N-1){
        if(S[i]!=S[i+1]){
            ll tmp=max(i+1,N-i-1);
            ans=min(ans,tmp);
        }
    }
    cout<<ans<<endl;
}

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

int main(int argc, char **argv)
{
    int H, W;
    int N;

    std::cin >> H >> W >> N;
    std::vector<int> a(N);
    std::vector<std::vector<int>> m(H, std::vector<int>(W));

    for(int i = 0; i < N; i++){
        std::cin >> a.at(i);
    }

    int h = 0, w = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < a.at(i); j++){
            m.at(h).at(w) = (i+1);
            w++;
            if(w == W){
                w = 0;
                h++;
            }
        }
    }
    bool flip = false;
    for(int i = 0; i < H; i++){
        std::string sep = "";
        if(flip){
            for(int j = W-1; j >= 0; j--){
                std::cout << sep << m.at(i).at(j);
                sep = " ";
            }
        }else{
            for(int j = 0; j < W; j++){
                std::cout << sep << m.at(i).at(j);
                sep = " ";
            }
        }
        std::cout << std::endl;
        flip = !flip;
    }
    
}


Measured memory_bytes: 384
r=range
h,*s=open(0)
h,w,k=map(int,h.split())
m=9e9
for i in r(1<<h-1):
  t,v,l=[],-1,1
  for j in r(h):
    if i>>j&1:
      t+=j+1,
      l+=1
  t+=h,
  c=[0]*l
  for i in r(w):
    b=f=g=0
    u=[]
    for j in r(l):
      d,b=sum(s[j][i]>'0'for j in r(b,t[j])),t[j]
      u+=d,
      g|=d>k
      c[j]+=d
      f|=c[j]>k
    v+=f
    if f:c=u
  if not g:m=min(m,v+l)
print(m)

Measured memory_bytes: 50904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  if(n==2){
    cout<<1<<" "<<2<<" "<<2<<endl;
    return 0;
  }
  if(n==3){
    cout<<1<<" "<<6<<" "<<6<<endl;
    return 0;
  }
  for(ll h=n/4;h<=3500;h++){
    for(ll w=h;w<=3500;w++){
      for(ll m=w;m<=3500;m++){
        if(4*h*w*m==n*(m*w+h*w+h*m)){
          cout<<h<<" "<<w<<" "<<m<<endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
package main

import (
    "bufio"
    "fmt"
    "os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
    var s string
    if sc.Scan() {
        s = sc.Text()
    }
  if (s=="25"){
  fmt.Println("Christmas")
  }
   if (s=="24"){
  fmt.Println("Christmas Eve")
  }
   if (s=="23"){
  fmt.Println("Christmas Eve Eve")
  }
   if (s=="22"){
  fmt.Println("Christmas Eve Eve Eve")
  }
  
  

  
  
}

Measured memory_bytes: 640
#include<iostream>
#include<stdlib.h>
#include<cstring>
using namespace std;

#define Maxnum 100000
int main() {
    int n, k;
    cin >> n >> k;
    int a[Maxnum];
    int sum[Maxnum] = {0};
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    memset(sum, 1000000, n * sizeof(int));
    sum[0] = 0;
    for (int i = 1; i < n; ++i) {
        for (int j = max(0,i-k); j < i; ++j) {
            sum[i] = min(sum[i], sum[j] + abs(a[i] - a[j]));
        }
        
    }
    cout << sum[n-1] <<endl;
}

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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);
 

void solve() {
    int N;
    cin >> N;
    map<int, int> m;
    REP(i, N){
        int a;
        cin >> a;
        if(m.find(a) == m.end()) {
            m[a] = 0;
        }
        if(m.find(a-1) == m.end()) {
            m[a-1] = 0;
        }        
        if(m.find(a+1) == m.end()) {
            m[a+1] = 0;
        }
        m[a]++;
        m[a-1]++;
        m[a+1]++;
    }
    int ans = 0;
    for(auto &x : m){
        ans = max(ans, x.second);
    }
    cout << ans << endl;
}
 
int main() {
    solve();
    return 0;
}


Measured memory_bytes: 4736
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <cmath>


using namespace std;

int main()
{ 
	double r;
	cin>>r;
	printf("%f %f\n",M_PI*pow(r,2),2*M_PI*r);
	
}

Measured memory_bytes: 1232
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
using namespace std;


struct edge {
	int to;
	char c;
};

const int inf = (int)1e9;


vector<bool> search_reachable(const vector<vector<edge> > &g, int t)
{
	const int n = g.size();
	vector<bool> visited(n, false);
	queue<int> q;

	vector<vector<int> > rev_g;

	rev_g.resize(n);
	for(int i = 0; i < n; ++i) {
		for(auto w_e : g[i]) {
			int w = w_e.to;
			rev_g[w].push_back(i);
		}
	}

	q.push(t);

	while(!q.empty()) {

		int v = q.front();
		q.pop();
		if(visited[v])
			continue;
		visited[v] = true;

		for(auto w : rev_g[v])
			q.push(w);
	}

	return visited;
}


int main()
{
	while(true) {

		int n, arrow, s, t;
		vector<vector<edge> > g;
		scanf("%d%d%d%d", &n, &arrow, &s, &t);

		if(n == 0)
			break;

		g.resize(n);

		for(int i = 0; i < arrow; ++i) {

			char buf[128];
			int a, b;
			int len, base = g.size();

			scanf("%d%d%s", &a, &b, buf);
			len = strlen(buf);
			g.resize(g.size() + (len - 1));

			if(len == 1) {
				g[a].push_back({b, buf[0]});
				continue;
			}

			g[a].push_back({base, buf[0]});
			for(int pos = 1; pos < len - 1; ++pos)
				g[base - 1 + pos].push_back({base + pos, buf[pos]});
			g[base + len - 2].push_back({b, buf[len - 1]});
		}

		n = g.size();

		/*for(int i = 0; i < n; ++i) {
			printf("%d: ", i);
			for(int j = 0; j < g[i].size(); ++j)
				printf("(%d, %c) ", g[i][j].to, g[i][j].c);
			printf("\n");
		}*/

		vector<bool> reachable = search_reachable(g, t);

		vector<bool> cur, next;
		string ans = "";
		bool ok = false;

		cur.resize(n);
		next.resize(n);
		cur[s] = true;

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

			char nc = 'z';

			fill(next.begin(), next.end(), false);

			for(int v = 0; v < n; ++v) {
				if(!cur[v])
					continue;
				for(auto e : g[v]) {
					if(reachable[e.to] && nc > e.c)
						nc = e.c;
				}
			}

			for(int v = 0; v < n; ++v) {
				if(!cur[v])
					continue;
				for(auto e : g[v]) {
					if(reachable[e.to] && nc == e.c)
						next[e.to] = true;
				}
			}

			swap(cur, next);

			ans += nc;

			if(cur[t]) {
				ok = true;
				break;
			}
		}

		printf("%s\n", ok ? ans.c_str() : "NO");
	}

	return 0;
}

Measured memory_bytes: 1260
#include <stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a==1||b==1){
    if(a==1&&b==1) printf("Draw");
    else if(b!=1)printf("Alice");
    else printf("Bob");
  }
  
  else if (a>b) printf("Alice");
  else if (b>a) printf("Bob");
  
  else printf("Draw");
  return 0;
}

Measured memory_bytes: 128