akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define inf 0x7fffffff
#define ll long long
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
ll solve (ll n)
{
        ll x = n/3;
        ll y = n/5;
        ll z = n/15;
        return (n*(n+1))/2 - 3*(x*(x+1))/2 - 5*(y*(y+1))/2 + 15*(z*(z+1))/2;
}
int main() {
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        // Code Starts... 
        ll n;
        cin>>n;
        cout<<solve(n)<<endl;
        // Code Ends...
        return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, D, X;
    cin >> N >> D >> X;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    ll sum = X;
    REP(i,0,N) sum += (D - 1) / A[i] + 1;
    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 3608
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
       var N = int.Parse(Console.ReadLine());
       var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
       long ans = a.Sum(x => x - 1);
       Console.WriteLine(ans);
       
    }
}


Measured memory_bytes: 13268
import numpy as np

a = []
b = []
for i in range(3) :
  a.append(list(map(int,input().split())))
n = int(input())
for i in range(n) :
  b.append(int(input()))

a = np.array(a)
b = np.array(b)
  
for i in range(n) :
  num = b[i]
  for j in range(3) :
    for k in range(3) :
      if num == a[j][k] :
        a[j][k] = 0
        break
        
ans = 'No'
for i in range(3) :
  if all(j==0 for j in a[:,i]) or all(j==0 for j in a[i,:]) :
    ans = 'Yes'
    
af = np.fliplr(a)
if all(j==0 for j in np.diag(a)) or all(j==0 for j in np.diag(af)) :
  ans = 'Yes'

print(ans)

Measured memory_bytes: 12512
//
// Created on 2019-02-09.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

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

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


    int N;
    string s;

    cin >> N >> s;

    int L = s.length();
    int num_R = 0;
    REP(i, N){
        if (s[i] == 'R') num_R++;
    }

    if (L/2 < num_R) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
  FAST();

  int n, i, j;
  cin >> n;
  vi arr(n);
  REP(i, 0, n)  cin >> arr[i];

  int ans = 0;
  int last = arr[0];
  REP(i, 0, n){
      if(arr[i] <= last){
        ans++;
        last = arr[i];
      }
  }

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


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

const int INF = (1 << 28);
/*int min(double a,double b){
  if(a >= b)return b;
  return a;
  }*/
int main(){
  
  cout.flags(ios::fixed);
  cout.precision(3);
  //  cout << INF << endl;
  //return 0;
  while(1){
    
    int n,m,p,a,b;
    cin >> n >> m >> p >> a >> b;
    if(n == 0 && m == 0 && p == 0 && a == 0 && b == 0)break;
    vector<int> t(n,0);
    for(int i = 0;i < n;i++){
      cin >> t[i];
    }
    /*vector<int> x(p,0);
    vector<int> y(p,0);
    vector<int> z(p,0);*/
    vector<vector<double> > cost(m,vector<double>(m,INF*11.0));
    for(int i = 0;i < p;i++){
      double x,y,z;
      cin >> x >> y >> z;
      cost[x-1][y-1] = z;
      cost[y-1][x-1] = z;
    }
    unsigned int nNum = (1 << n);
    vector<vector<double> > mp(nNum,vector<double>(m,INF));
    vector<vector<int> > used(nNum,vector<int>(m,0));
    mp[nNum -1][a - 1] = 0;
    while(1){
      int flagT = -1;
      int flagM = -1;
      for(int i = 0;i < nNum;i++){
	for(int j = 0;j < m;j++){
	  if(!used[i][j] && (flagT == -1 || mp[i][j] < mp[flagT][flagM])){
	    flagT = i;
	    flagM = j;
	    
	  }
	}
      }
      if(flagT == -1)break;
      used[flagT][flagM] = 1;
      for(unsigned int i = 0;i < n;i++){
	for(int j = 0;j < m;j++){
	  unsigned int keepFlagT;
	  if( (flagT & (1<<i)) != 0 ){
	    keepFlagT = (flagT ^ (1<<i));
	    mp[keepFlagT][j] = min<double>(mp[flagT][flagM] + cost[flagM][j]/(double)t[i],mp[keepFlagT][j]);
	  }
	}
      }
    }
    /*
    for(int i = 0;i < nNum;i++){
      cout << i << endl;
      for(int j = 0;j < m;j++){
	if(mp[i][j] >= INF){
	  cout << -1 << " " ;
	}else{
	  cout << mp[i][j] << " ";
	}
      }
      cout << endl;
      }*/
    //cout << "----------------------" << endl;
    //-------------------
    double ans = mp[0][b - 1];
    for(int i = 0;i < nNum;i++){

      ans = min<double>(ans,mp[i][b-1]);
    }
    
    if(ans >= INF-10)cout << "Impossible" << endl;
    else cout << ans << endl;
    
  }
  return 0;
}

Measured memory_bytes: 1428
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,0,n) cin>>a[i];
    sort(all(a));
    
    vector<pair<int,int>> ans;
    if(a[0]>0){
        rep(i,1,n-1){
            ans.emplace_back(a[0],a[i]);
            a[0]-=a[i];
        }
        ans.emplace_back(a[n-1],a[0]);
        a[n-1]-=a[0];
        
        cout<<a[n-1]<<endl;
        for(auto p:ans) cout<<p.first<<" "<<p.second<<endl;
    }
    else if(a[0]<=0 && a[n-1]>0){
        int x=0;
        while(a[x]<=0) x++;
        
        rep(i,x,n-1){
            ans.emplace_back(a[0],a[i]);
            a[0]-=a[i];
        }
        
        rep(i,0,x){
            ans.emplace_back(a[n-1],a[i]);
            a[n-1]-=a[i];
        }
        
        cout<<a[n-1]<<endl;
        for(auto p:ans) cout<<p.first<<" "<<p.second<<endl;
    }
    else {
        rep(i,0,n-1){
            ans.emplace_back(a[n-1],a[i]);
            a[n-1]-=a[i];
        }
        
        cout<<a[n-1]<<endl;
        for(auto p:ans) cout<<p.first<<" "<<p.second<<endl;
    }
}



Measured memory_bytes: 3188
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

  cin >> n;
  vector<ll> ya = divisor(n);
  rep(i, Size(ya)) {
    tmp = ya[i] - 1;
    if (tmp == 0) continue;
    if (n / tmp == n % tmp) ans += tmp;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <string>
using namespace std;
int main() {
  int N, K;
  string S;
  char c;

  cin >> N >> S >> K;

  c = S[K - 1];

  for (int i = 0; i < N; ++i)
    if (S[i] != c) S[i] = '*';

  cout << S << endl;

  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;


int main(){
  ll h,w;
  cin >> h >> w;
  vector<vector<ll>> vec(h,vector<ll>(w));
  vector<vector<ll>> score(h,vector<ll>(w,0));
  rep(i,h){
    rep(j,w){
      cin >> t1;
      if(t1 == 0){
        vec[i][j] = 1;
      }else{
        vec[i][j] = 0;
      }
    }
  }
  rep(i,h){
    rep(j,w){
      if(vec[i][j] == 0){
        score[i][j] = 0;
      }else{
        if(i == 0 || j == 0){
          score[i][j] = vec[i][j];
        }else{
          score[i][j] = min(score[i][j-1],score[i-1][j]);
          if(score[i-1][j-1] >= score[i][j]){
            score[i][j]++;
          }
        }
      }
    }
  }
  ll ans = 0;
  rep(i,h){
    rep(j,w){
      //cout << score[i][j] << " ";
      chmax(ans,score[i][j]);
    }
    //cout << endl;
  }
  cout << ans*ans << endl;
}


Measured memory_bytes: 33368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    int ans = 0;
    for(int i = 1; i < n - 1; i++) {
        if((v[i] > v[i + 1] && v[i] < v[i - 1]) ||
           (v[i] > v[i - 1] && v[i] < v[i + 1]) ) {
            ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}




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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  bool prime[60000];
  memset(prime, true, sizeof(prime));
  prime[0] = prime[1] = false;
  for (int i = 2; i * i <= 60000; i++) {
  	if (prime[i]) {
  		for (int j = 2 * i; j <= 60000; j += i) {
  			prime[j] = false;
  		}
  	}
  }

  int n;
  while(true) {
    cin >> n;
    if(!n) break;
    int ret = 0;
    FOR(i, 1, n/2+1) {
      if(prime[i] && prime[n-i]) ret++;
    }
    cout << ret << endl;
  }

  return 0;
}

Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
struct Macho {int c, w;};
int main() {
  int N;
  cin >> N;
  vector<Macho> macho(N);
  for(auto& m: macho) cin >> m.c >> m.w;
  vector<vector<int>> liftable(N, vector<int>(N, INF));
  for(int i = 0; i < N; ++i) liftable[i][i] = macho[i].w;
  for(int range = 1; range < N; ++range) {
    for(int i = 0; i < N - range; ++i) {
      int j = i + range;
      if(liftable[i + 1][j] <= macho[i].c) liftable[i][j] = liftable[i + 1][j] + macho[i].w;
    }
    for(int i = range; i < N; ++i) {
      int j = i - range;
      if(liftable[j][i - 1] <= macho[i].c) liftable[j][i] = liftable[j][i - 1] + macho[i].w;
    }
  }
  vector<int> dp(N + 1, INF);
  dp[0] = 0;
  for(int i = 1; i <= N; ++i) for(int j = i; j <= N; ++j) {
    if(liftable[i - 1][j - 1] != INF) dp[j] = min(dp[j], dp[i - 1] + 1);
  }
  cout << dp[N] << endl;
}

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

int main() {
    string s; cin >> s;
    if (s[0] == s.back()) {
        if (s.size() & 1) puts("Second");
        else puts("First");
    }
    else {
        if (s.size() & 1) puts("First");
        else puts("Second");
    }
}

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

int main() {
	int n; cin >> n;
	map<string, int> mp;
	rep(i, n) {
		string s; cin >> s;
		mp[s]++;
	}
	vector<pair<int, string>> p;
	for (auto& c : mp) {
		p.emplace_back(c.second, c.first);
	}
	sort(p.rbegin(), p.rend());
	int res = p[0].first;
	vector<string> ans;
	rep(i, p.size()) {
		if (p[i].first < res) break;
		ans.emplace_back(p[i].second);
	}
	sort(ans.begin(), ans.end());
	for (auto& c : ans) cout << c << endl;
	return 0;
}


Measured memory_bytes: 32876
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int c[3][3];
	int sum = 0;
	rep(i,3)rep(j,3){
		cin >> c[i][j];
		sum += c[i][j];
	}
	if((c[0][0]+c[1][1]+c[2][2])*3 == sum )cout <<"Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int [] num = new int[9];
		int[][] bingo = {{0,1,2}, {3,4,5}, {6,7,8}, {0,3,6}, {1,4,7}, {2,5,8}, {0,4,8}, {2,4,6}};
		boolean ok = false;
		
		for (int i=0; i<9; i++) {
			num[i] = sc.nextInt();
		}
		
		int N = sc.nextInt();
		
		for (int i=0; i<N; i++) {
			int b = sc.nextInt();
			for (int j=0; j<9; j++) {
				if (num[j] == b) {
					num[j] = 0;
				}
			}
		}
		
		for (int i=0; i<8; i++) {
			if (num[bingo[i][0]] + num[bingo[i][1]] + num[bingo[i][2]] == 0){
				ok = true;
			}
		}
		System.out.println(ok ? "Yes" : "No");
	}
}

Measured memory_bytes: 21972
s = input()
minc = 101
maxf = 0

for i in range(len(s)):
    if minc == 101:
        if s[i] == 'C':
            minc = i

    if maxf == 0:
        if s[-i - 1] == 'F':
            maxf = len(s) - i - 1

if minc < maxf:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iomanip>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



using namespace std;
typedef unsigned long long ull;
typedef long long ll;

const double cos60 = cos(M_PI/3);
const double sin60 = sin(M_PI/3);
const double cos120 = cos(2*M_PI/3);
const double sin120 = sin(2*M_PI/3);

class point{
private:
  double x, y;
public:
  point(): x(0), y(0) {}
  point(double x_, double y_): x(x_), y(y_) {}
  point rot60(){
    double a = cos60 * x - sin60 * y;
    double b = sin60 * x + cos60 * y;
    return point(a, b);
  }
  point rot120(){
    double a = cos120 * x - sin120 * y;
    double b = sin120 * x + cos120 * y;
    return point(a, b);    
  }
  point plus(point p){
    return point(p.x + x, p.y + y);
  }
  point mul(double a){
    return point(a*x, a*y);
  }
  point rot60(point p){
    return this->plus(p.mul(-1)).rot60().plus(p);
  }
  point rot120(point p){
    return this->plus(p.mul(-1)).rot120().plus(p);
  }
  void print(){
    cout << setprecision(10) << x << " " << y << endl;
  }
};

vector<point> koch(point p, point q){
  point q_p = q.plus(p.mul(-1));
  point a = p.plus(q_p.mul(1.0/3));
  point b = p.plus(q_p.mul(2.0/3));
  point c = q_p.mul(1.0/3).rot60().plus(a);
  vector<point> ret(4);
  ret[0] = p;
  ret[1] = a;
  ret[2] = c;
  ret[3] = b;
  return ret;
}
vector<point> koch(vector<point> v, int n){
  if(n == 0) return v;
  vector<point> ret(v.size() + (v.size()-1) * 3);
  size_t pos = 0;
  for (size_t i = 0; i < v.size()-1; i++) {
    vector<point> buf = koch(v[i], v[i+1]);
    for (size_t j = 0; j < buf.size(); j++) {
      ret[pos++] = buf[j];      
    }
  }
  ret.back() = v.back();
  return koch(ret, n-1);
}

int main(int argc, char *argv[]){
  point p(0,0);
  point q(100, 0);
  vector<point> v(2);
  v[0] = p;
  v[1] = q;
  int n;
  cin >> n;
  vector<point> ret = koch(v, n);
  for (size_t i = 0; i < ret.size(); i++) {
    ret[i].print();
  }

  
  return 0;
}

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

int main(){
	string s;cin>>s;
  	map<char,int>cnt;
  	for(auto&& u:s)cnt[u]++;
   bool flg=true;
  for(auto&& u:cnt)if(u.second&1)flg=false;
	cout<<(flg?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) { // ?¨??????\???????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for (int i = 0; i < values.length; i++) {
			values[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1; // a??¨b????????£???values??????????????????

			int c = values[a];
			values[a] = values[b];
			values[b] = c;
		}
		for (int i = 0; i < w; i++) {
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 26204
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    s[k - 1] += 'a' - 'A';
    cout << s << endl;
}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  if (n % 1000 == 0) {
    cout << 0;
  } else {
    cout << ((n / 1000) + 1) * 1000 - n;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int M = 1e9 + 7;

int cnt[60][2], a[300005];

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	int ans = 0;
	for(int i=0;i<n;i++) {
		if(i) {
			for(int j=0;j<60;j++) {
				for(int k=0;k<2;k++) {
					ans += cnt[j][k] * ((((a[i] >> j & 1) ^ k) << j) % M) % M;
				}
			}
		}
		for(int j=0;j<60;j++)
			cnt[j][a[i]>>j&1]++;
	}
	cout << ans % M << endl;
	

}



	

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

int main(){
    int h1,h2,k1,k2,a,b,c,d;
    int hiroshi,kenjirou;
    cin>>h1>>h2;
    cin>>k1>>k2;
    cin>>a>>b>>c>>d;
    hiroshi=h1*a+h2*b+c*(h1/10)+d*(h2/20);
    kenjirou=k1*a+k2*b+c*(k1/10)+d*(k2/20);
    if(hiroshi>kenjirou){
        cout<<"hiroshi"<<endl;
    }else if(hiroshi<kenjirou){
        cout<<"kenjiro"<<endl;
    }else{
        cout<<"even"<<endl;
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;

int main() {
	int q=rd();
	while(q--) {
		int a=rd(), b=rd(), c=rd(), d=rd(), k=(a+b)/(std::min(a, b)+1), l, r;
		char ans[101];
		if(1ll*a*k>=b) {
			int p;
			for(l=0, r=std::min(a/k, b); l<r; ) {
				int m=(l+r+1)/2;
				if(1ll*(a-m*k)*k<b-m) r=m-1; else l=m;
			}
			p=l, a-=p*k, b-=p;
			for(l=1, r=a; l<r; ) {
				int m=(l+r+1)/2;
				if(1ll*(a-m)*k<b-k) r=m-1; else l=m;
			}
			a-=l, l+=p*(k+1);
		} else l=0;
		r=l+b-a*k;
		for(int i=c; i<=d; ++i) {
			if(i<=l) {
				ans[i-c]='A'+(i%(k+1)==0);
			} else if(i<=r) {
				ans[i-c]='B';
			} else {
				ans[i-c]='A'+((i-r)%(k+1)!=1);
			}
		}
		ans[d-c+1]=0;
		puts(ans);
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<int> v1, v2;
    v1.push_back(-INF2);
    v2.push_back(-INF2);
    rep(i, A) {
        int e; cin >> e;
        v1.push_back(e);
    }
    rep(i, B) {
        int e; cin >> e;
        v2.push_back(e);
    }
    v1.push_back(INF2);
    v2.push_back(INF2);

    while(Q--) {
        int x; cin >> x;
        int l1, r1, l2, r2;
        l1 = *(--upper_bound(v1.begin(), v1.end(), x));
        r1 = *(lower_bound(v1.begin(), v1.end(), x));
        l2 = *(--upper_bound(v2.begin(), v2.end(), x));
        r2 = *(lower_bound(v2.begin(), v2.end(), x));
        //cout << "*" << l1 << " " << l2 << " " << r1 << " " << r2 << endl;
        int ans = INF2;
        ans = min(ans, x - min(l1, l2));
        ans = min(ans, max(r1, r2) - x);
        ans = min(ans, x - l1 + r2 - l1);
        ans = min(ans, r2 - x + r2 - l1);
        ans = min(ans, x - l2 + r1 - l2);
        ans = min(ans, r1 - x + r1 - l2);
        cout << ans << endl;
    }


    return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

bool isRightTriangle(int a, int b, int c) {
    return(a*a + b*b == c*c);
}

int main(void) {
    int num; cin >> num;
    vector<int> vec(3);
    for(int r = 0; r < num; r++) {
        cin >> vec[0] >> vec[1] >> vec[2];
        sort(vec.begin(), vec.end());
        cout << (isRightTriangle(vec[0], vec[1], vec[2]) ? "YES" : "NO") << endl;
    }
    return(0);
}

Measured memory_bytes: 1204
#include<stdio.h>

int d[7];

int main(){
	for(int i=1;i<=6;i++)scanf("%d",d+i);
	int ue=1,mae=2,migi=3;
	char c;
	while(c=0,scanf(" %c",&c),c){
		int nue,nmae,nmigi;
		switch(c){
			case 'N':
				nue=mae;
				nmae=7-ue;
				nmigi=migi;
				break;
			case 'E':
				nue=7-migi;
				nmae=mae;
				nmigi=ue;
				break;
			case 'S':
				nue=7-mae;
				nmae=ue;
				nmigi=migi;
				break;
			case 'W':
				nue=migi;
				nmae=mae;
				nmigi=7-ue;
		}
		ue=nue;
		mae=nmae;
		migi=nmigi;
	}
	printf("%d\n",d[ue]);
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S    = [None] * H # S[h][w]
for h in range(H):
    S[h] = list(input())

# find temporary start
Q_start = []
for h in range(H):
    for w in range(W):
        if S[h][w] == '.':
            Q_start.append((h, w))

answer = 0

# find start
for h_goal, w_goal in Q_start:
    STEPs                 = [[-1 for w in range(W)] for h in range(H)] # STEPs[x][y]
    STEPs[h_goal][w_goal] = 0
    max_STEP              = 0

    Q = [(h_goal, w_goal)]
    while len(Q) > 0:
        Q_new = []
        for q in Q:
            step     = STEPs[q[0]][q[1]]
            max_STEP = max(max_STEP, step)
            for h, w in [(q[0]-1, q[1]), (q[0], q[1]-1), (q[0], q[1]+1), (q[0]+1, q[1])]:
                if (h < 0 or w < 0) or (h >= H or w >= W) or (STEPs[h][w] != -1) or S[h][w] != '.':
                    continue
                else:
                    STEPs[h][w] = step+1
                    Q_new.append((h, w))
        Q = Q_new
    answer = max(answer, max_STEP)

print(answer)


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int a;
	while(scanf("%d",&a),a){
		while(a--){
			int b,c,d,e,f,g,h,i;
			scanf("%d%d%d%d%d%d%d%d",&b,&c,&d,&e,&f,&g,&h,&i);
			printf("%d %d %d %d\n",b*f-c*g-d*h-e*i,b*g+c*f+d*i-e*h,b*h-c*i+d*f+e*g,b*i+c*h-d*g+e*f);
		}
	}
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=200005;
int a[N],n,Q,A,B;
struct Tree{
	int l,r,num1,num2,num3,flag;
}T[N*4];
void down(int x){
	T[x*2].flag+=T[x].flag;
	T[x*2+1].flag+=T[x].flag;
	T[x*2].num1+=T[x].flag;
	T[x*2+1].num1+=T[x].flag;
	T[x*2].num2+=T[x].flag;
	T[x*2+1].num2+=T[x].flag;
	T[x*2].num3+=T[x].flag;
	T[x*2+1].num3+=T[x].flag;
	T[x].flag=0;
}
void update(int x){
	T[x].num1=min(T[x*2].num1,T[x*2+1].num1);
	T[x].num2=min(T[x*2].num2,T[x*2+1].num2);
	T[x].num3=min(T[x*2].num3,T[x*2+1].num3);
}
void build(int x,int l,int r){
	T[x].l=l;T[x].r=r;
	if (l==r){
		T[x].num1=min(abs(A-l)+abs(B-a[1]),abs(A-a[1])+abs(B-l));
		T[x].num2=T[x].num1-l;
		T[x].num3=T[x].num1+l;
		return;
	}
	int mid=(l+r)/2;
	build(x*2,l,mid);
	build(x*2+1,mid+1,r);
	update(x);
}
void insert(int x,int y,int z){
	if (T[x].l==T[x].r){
		T[x].num1=min(T[x].num1,z);
		T[x].num2=T[x].num1-T[x].l;
		T[x].num3=T[x].num1+T[x].l;
		return;
	}
	down(x);
	int mid=(T[x].l+T[x].r)/2;
	if (y<=mid)insert(x*2,y,z);
	else insert(x*2+1,y,z);
	update(x);
}
int find2(int x,int l,int r){
	if (T[x].l>r||l>T[x].r)return 1e18;
	if (T[x].l>=l&&T[x].r<=r)return T[x].num2;
	down(x);
	return min(find2(x*2,l,r),find2(x*2+1,l,r));
}
int find3(int x,int l,int r){
	if (T[x].l>r||l>T[x].r)return 1e18;
	if (T[x].l>=l&&T[x].r<=r)return T[x].num3;
	down(x);
	return min(find3(x*2,l,r),find3(x*2+1,l,r));
}
signed main(){
	scanf("%lld%lld%lld%lld",&n,&Q,&A,&B);
	for (int i=1;i<=Q;i++)scanf("%lld",&a[i]);
	build(1,1,n);
	for (int i=2;i<=Q;i++){
		int k1=find2(1,1,a[i]),k2=find3(1,a[i],n);
		T[1].flag+=abs(a[i]-a[i-1]);
		insert(1,a[i-1],min(k1+a[i],k2-a[i]));
	}
	printf("%lld\n",T[1].num1);
	return 0;
}

Measured memory_bytes: 29056
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

class segtree():#seg=segtree(A),単位元とsegfuncを指定すること
    def __init__(self,A,ide=0):#単位元とsegfuncを指定すること
        n=len(A)
        num=2**(n-1).bit_length()#n以上の最小の2のべき乗
        seg=[ide]*(2*num-1)
        segfunc=self.segfunc
        self.ide,self.n,self.num,self.seg = ide, n, num, seg
        for i in range(n): seg[i+num-1]=A[i]#setvalue
        for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])#build
    
    def segfunc(self,x,y):return x|y #seg木の基本関数
    
    def update(self,k,x):#Aのk番目の要素をxに置き換える,計算量log(N)
        k += self.num-1
        seg,segfunc=self.seg,self.segfunc
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
    def query(self,p,q):#区間[p,q)の累積segfuncを求める,計算量log(N)
        if q<=p: return self.ide
        num,segfunc,seg=self.num,self.segfunc,self.seg
        p += num-1; q += num-2
        res=self.ide
        while q-p>1:
            if p&1 == 0: res = segfunc(res,seg[p])
            if q&1 == 1:
                res = segfunc(res,seg[q])
                q -= 1
            p,q = p//2, (q-1)//2
        if p == q: res = segfunc(res,seg[p])
        else: res = segfunc(segfunc(res,seg[p]),seg[q])
        return res 

def main():
    mod = 10**9+7
    alpha2num = lambda c: 2**(ord(c) - ord('a'))
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    S=input()
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    A=list(map(alpha2num, list(S)))
    #print(A)
    #exit()
    seg=segtree(A)
    #print(A)
    Q=int(input())
    for i in range(Q):
        t, a,b =input().split()
        if t=='1':
            a=int(a)
            seg.update(a-1,alpha2num(b))
        else:
            a,b=int(a),int(b)
            x=seg.query(a-1,b)
            count=0
            for i in range(26):
                count+= (x>>i & 1)
            print(count)






if __name__ == "__main__":
    main()

Measured memory_bytes: 117040
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 100010
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
ll read(){
    ll w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
ll n,k;
int main(){
	n=read(),k=read();
	n%=k;
	printf("%lld\n",min(n,k-n));
    return 0;
}

Measured memory_bytes: 256
def p_d():
    n = int(input())
    *a, = map(int, input().split())
    *b, = filter(lambda x: x <= 0, a)
    *c, = map(abs, a)
    if len(b) & 1 == 0:
        print(sum(c))
    else:
        print(sum(c) - 2 * sorted(c)[0])


if __name__ == '__main__':
    p_d()

Measured memory_bytes: 74640
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll dp[12][1201];

int main(){
  ll d,g;cin>>d>>g;
  vector<ll> p(d+1),c(d+1);
  // 1-indexed
  FOR(i,1,d){
    cin>>p[i]>>c[i];
  }

  FOR(i,1,d){
  	FOR(k,0,1010){
  	  FOR(j,0,p[i]){
  	  	if(j!=p[i]){
	  	  	dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*i*j);
	  	  }else{
	  	  	dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*i*j+c[i]);
	  	  }
	  	} 
  	}
  }
  rep(i,1010){
  	if(dp[d][i]>=g){
  		cout<<i<<endl;
 			break;
  	}
  }   
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))
 
int main(){
  int k,n;
  double p[200000];
  cin>>n>>k;
  int a;
  for(int i=0;i<n;i++){
    cin>>a;
    p[i]=(1.0+a)/2.0;
  }
  long double count=0.0,ans=0.0;
  for(int i=0;i<k;i++){
      count+=p[i];
  }
  ans=count;
  for(int i=0;i<n-k;i++){
  count-=p[i];
  count+=p[i+k];
  ans=max(count,ans);
  }
  printf("%.12Lf",ans);
  return 0;
}

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

typedef long long ll;
#define pb push_back
#define mod 1000000007

// int gcd(int a, int b) {   if (b == 0) return a; return gcd(b, a % b);  }
// int lcm(int a,int b){return a/gcd(a,b)*b;}
int solve(){
    double x,e=1e-10;
    cin>>x;
    if((x-0)<e) return 1;
    else return 0;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // int t;
    // cin>>t;
    // while(t--){
    //     cout<<solve()<<"\n";
    // }
    cout<<solve();
    return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
signed main()
{
    fast;
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(all(a));
    int ans = 0;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            int sum = a[i]+a[j];
            int low = j+1;
            int high = n-1;
            int idx = -1;
            while(low<=high)
            {
                int mid = (low+high)/2;
                if(sum>a[mid])
                {
                    idx = mid;
                    low = mid+1;
                }
                else high = mid-1;
            }
            if(idx!=-1)
            {
                //cout<<i<<" "<<j<<" "<<idx<<endl;
                ans+=(idx-j);
            }
        }
    }
    cout<<ans;
}   

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k, x, y; cin>>n>>k>>x>>y;

	if (n<=k){
		cout << x*n << "\n";
	}else{
		cout << x*k+y*(n-k) << "\n";
	}
	return 0;
}

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

int main() {
  long long H,W;
  cin>>H>>W;
  if(H==1||W==1){
    cout<<"1"<< endl;
    return 0;
  }
  if(H*W%2==0){
    cout<<H*W/2<< endl;
  }
  else{
    cout<<H*W/2+1<< endl;
  }
}
    

Measured memory_bytes: 256
// ------- PBDS ------ //
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// ------- PBDS ------ //

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define testcase ll tt; cin>>tt; while(tt--)
#define pb push_back
#define nn cout<<"\n"
#define MOD 1000000007
#define pi 3.1415926535
#define endl "\n"
#define vll vector<ll>
#define MULTI int T; cin >> T; while(T--)
#define all(a)      (a).begin(),(a).end()
#define here cout<<"I'm here\n";
void vout(vector<ll> ans){
    for(auto ele:ans) cout<<ele<<" "; cout<<endl;
}
vector<ll> adj[200001];
bool vis[200001];

// ------- PBDS ------ //
typedef tree<
// change this for any data-type
string,
null_type,
// change this for any data-type
less<string>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

/*
    to get the position of an element in set , do
    s.order_of_key(ele);
    this returns the number of elements strictly lesser than ele in set s
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    s.order_of_key(6) : Count of elements strictly smaller than 6 is 2.
    s.order_of_key(25) : Count of elements strictly smaller than 25 is 4.

    to get the element at position k
    s.find_by_order(k);
    returns an iterator to the ele counting from 0
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    *(s.find_by_order(2)) : 3rd element in the set i.e. 6
    *(s.find_by_order(4)) : 5th element in the set i.e. 88
*/

// ------- PBDS ------ //

clock_t time_p=clock();
void purvansh11()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

//BINARY EXPONENTIATION  -- O(log2(b))
ll power(ll a, ll b) {
    /*
        for 3^11 :
        as 11 -> 1011, we mean 3^8 * 3^2 * 3^1
        so multiply for all ones in binary rep of b
    */

    ll ans = 1;
    ll num = a;
    while (b > 0) {
        if (b & 1) ans = ((ans % MOD) * (num % MOD)) % MOD;
        num = ((num % MOD) * (num % MOD)) % MOD;
        b /= 2;
    }
    return ans;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    SPEED;
    cout.precision(8);
    cout << fixed;
    ll x,k,d;
    cin>>x>>k>>d;
    // x=abs(x);
    if(x>=0){
        if(k<=(x/d)) cout<<x-(k*d);
        else{
            ll left=k-(x/d);
            ll pocha=x-((x/d)*d);
            // cout<<pocha<<" "<<left<<" ";
            if(left&1) cout<<abs(pocha-d);
            else cout<<abs(pocha);
        }
    }
    else{
        if(k<=(abs(x)/d)) cout<<abs(x+(k*d));
        else{
            ll left=k-(abs(x)/d);
            ll pocha=x-((x/d)*d);
            // cout<<pocha<<" "<<left<<" ";
            if(left&1) cout<<abs(pocha+d);
            else cout<<abs(pocha);
        }
    }
    purvansh11();
    return 0;
}

Measured memory_bytes: 8436
n = int(input())
a = list(map(int, input().split()))
kabu = 0
money = 1000
for i in range(n-1):
    if a[i] < a[i+1]:
        kabu += money//a[i]
        money -= a[i] * (money//a[i])
    else:
        money += kabu * a[i]
        kabu = 0
money += kabu * a[n-1]
print(money)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
using ll = long long;
using namespace std;
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;
}

vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

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

    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    REP(i, H) { cin >> S[i]; }

    REP(i, H) {
        REP(j, W) {
            if (S[i][j] == '#')
                continue;
            int cnt = 0;
            REP(k, 8) {
                int y = i + dy[k];
                int x = j + dx[k];
                if (y < 0 || H <= y)
                    continue;
                if (x < 0 || W <= x)
                    continue;
                if (S[y][x] == '#')
                    cnt++;
            }
            S[i][j] = '0' + cnt;
        }
    }

    REP(i, H) std::cout << S[i] << '\n';
    return 0;
}

Measured memory_bytes: 256
cup_cost = list(map(int, input().split()))
l = int(input())

#基準を2リットルとした場合のコスト
cost = [cup_cost[0]*8, cup_cost[1]*4, cup_cost[2]*2, cup_cost[3]]

#2リットルの最小コスト
cost_2 = min(cost)

#1リットルの最小コスト
cost_1 = int(min(cost[:-1]) / 2)

#2リットル容器の必要数
cup_2 = l // 2

#1リットル容器の必要数
cup_1 = l % 2

#表示
print(cup_2*cost_2 + cup_1*cost_1)

Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std ;
int A,B;
int main(){
    cin >> A >> B;
    if(A<=2*B){
        cout << "0\n";
        return 0;
    }else{
        int c = A - 2*B;
        cout << c << "\n";
        return 0;
    }
}

Measured memory_bytes: 3620
func main(text1: String = readLine()!, text2: String = readLine()!) {
    let text2Count = text2.count
    var searchText1 = text1
    searchText1.removeLast(text2Count - 1)
    var result = text2Count
    for text1Index in searchText1.indices {
        var difference = 0
        for (character1, character2) in zip(text1[text1Index...], text2) where character1 != character2 {
            difference += 1
        }
        if result > difference {
            result = difference
        }
    }
    print(result)
}

main()

Measured memory_bytes: 7748
import sys
input = sys.stdin.readline

INF = 10 ** 9 + 7
N = int(input())
a = list(map(int, input().split()))
cnt = [0] * 60
for i in a:
    for j in range(60):
        cnt[j] += (i >> j) % 2
ans = 0
for b in range(60):
    ans += cnt[b] * (N - cnt[b]) << b
    ans %= INF
print(ans)

Measured memory_bytes: 123132
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>M;
    ll ans = 1;
    set<ll> div;
    reps(i,1,M+1){
        if(M%i == 0){
            div.insert(i);
            div.insert(M/i);
        }
        if(i*i > M) break;
    }
    for(ll d : div){
        if(M/d >= N) ans = d;
        else break;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<bitset>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
int h[maxn],dp[maxn];
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&h[i]);
    memset(dp,INF,sizeof(dp));
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i-j>=1) dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    printf("%d\n",dp[n]);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
#define vi vector<int>
#define vpii vector<pair<int,int> >
#define pii pair<int,int>
using namespace std;
const int mod = 1e9+7;
int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int lcs(string a, string b) {
  int n = a.size(), m = b.size();
  int dp[2][m+1];
  for(int i = 0;i <= n;i++) {
    for(int j = 0;j <= m;j++) {
      if(i==0||j==0) dp[i%2][j] = 0;
      else {
        if(a[i-1] == b[j-1]) dp[i%2][j] = 1 + dp[1-i%2][j-1];
        else dp[i%2][j] = max(dp[i%2][j-1], dp[1-i%2][j]);
      }
    }
  }
  return dp[n%2][m];
}

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

bool equal(string s) {
  for(int i = 0,j = s.size()/2;j < s.size();i++,j++) {
    if(s[i] != s[j]) return false;
  }
  return true;
}

ll fact(int n) {
  ll ans = 1;
  fr(i,2,n+1) ans = (ans*i)%mod;
  return ans;
}

ull f(ll a, ll x) {
  if(a < 0) return 0;
  return (a/x+1);
}

int main() {
  int n;
  cin>>n;
  vpii a[n];
  frn(i,n) {
    int ai;
    cin>>ai;
    while(ai--) {
      int x,y;
      cin>>x>>y;
      a[i].pb({x-1,y});
    }
  }
  int ans = 0;
  frn(i, 1<<n) {
    bool testimony = true;
    frn(j,n) {
      if(i & (1 << j)) {
        bool ind_testimony = true;
        trav(x,a[j]) {
          if((x.second == 1 && !(i & (1 << x.first))) || (x.second == 0 && (i & (1 << x.first)))) {
            ind_testimony = false;
            break;
          }
        }
        if(!ind_testimony) testimony = false;
      }
    }
    if(testimony) ans = max(ans, __builtin_popcount(i));
  }
  cout<<ans;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n,ans=100000;
	cin>>n;
	
	for(int i=0;i<n;i++){
		ans*=1.05;
		if(ans%1000!=0){
			ans=ans-(ans%1000);
			ans+=1000;
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3636