akhauriyash/Code-Regression huggingface dataset:
//
//  Road2Master.cpp
//  Road2Master
//
//  Created by Rakhman Abdirashov on 12/14/19.
//  Copyright © 2019 Rakhman Abdirashov. All rights reserved.
//
 
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
 
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer {cout << "NO"; exit(0);}
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)
 
const long long MXN = 1e5 + 10;
const long long MNN = 1e4 + 520;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9;
 
typedef long long llong;
typedef unsigned long long ullong;
 
using namespace std;
 
llong n, m;
pair<llong, llong> t[MXN * 4];
string s;
 
void build(llong v, llong tl, llong tr){
    if(tl == tr) {
        t[v].F = INF;
        return ;
    }
    llong tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v].F = min(t[v * 2].F, t[v * 2 + 1].F);
}
 
pair<llong, llong> get(llong v, llong tl, llong tr, llong L, llong R){
    if(L <= tl && tr <= R){
        return t[v];
    }
    if(R < tl || tr < L) return {INF, INF};
    llong tm = (tl + tr) / 2;
    pair<llong, llong> a = get(v * 2, tl, tm, L, R);
    pair<llong, llong> b = get(v * 2 + 1, tm + 1, tr, L, R);
    if(a.F > b.F) return b;
    else return a;
}
 
void upd(llong v, llong tl, llong tr, llong ind, llong x){
    if(tl == tr) {
        t[v].F = x;
        t[v].S = tl;
        return ;
    }
    llong tm = (tl + tr) / 2;
    if(ind <= tm){
        upd(v * 2, tl, tm, ind, x);
    }else{
        upd(v * 2 + 1, tm + 1, tr, ind, x);
    }
    if(t[v + v].F > t[v + v + 1].F) t[v] = t[v + v + 1];
    else t[v] = t[v + v];
}
 
int main(){
    ios;
    cin >> n >> m;
    cin >> s;
    build(1, 1, n);
    upd(1, 1, n, n, 0);
    for(llong i = n - 1; i >= 1; i--){
        if(s[i] == '0'){
            pair<llong, llong> ans = get(1, 1, n, i + 1, min(n, i + m));
            upd(1, 1, n, i, ans.F + 1);
        }
    }
    if(get(1, 1, n, 1, min(n, m)).F == INF){
        cout << -1;
        return 0;
    }
    vector<llong> v;
    int cur = 0, last = 0;
    while(cur != n){
        last = cur;
        pair<llong, llong> lol = get(1, 1, n, cur + 1, min(cur + m, n));
        cur = lol.S;
        v.pb(cur - last);
    }
    for(int i = 0; i < v.size(); i++){
        cout << v[i] << ' ';
    }
}


Measured memory_bytes: 7624
def ok(i, j, _x, _y, _a)
  if _a == 1
    i < _x
  elsif _a == 2
    i >= _x
  elsif _a == 3
    j < _y
  elsif _a == 4
    j >= _y
  end
end

w, h, n = gets.chomp.split(" ").map{|i| i.to_i}
x = Array.new(n)
y = Array.new(n)
a = Array.new(n)
for i in 0...n
  x[i], y[i], a[i] = gets.chomp.split(" ").map{|i| i.to_i}  
end

field = Array.new(w){Array.new(h){false}}

for k in 0...n
  for i in 0...w
    for j in 0...h
      if ok(i, j, x[k], y[k], a[k])
        field[i][j] = true
      end
    end
  end
end

ans = 0

for i in 0...w
  for j in 0...h
    if !field[i][j]
      ans += 1
    end
  end
end

puts ans



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

int main(void){
    int a[2],c;
    cin >> a[0] >> a[1];
    if((a[0]+a[1]) % 3 == 0)c = 1;
    else if(a[0] % 3 == 0)c = 1;
    else if(a[1] % 3 == 0)c = 1;
    else c = 0;
    if(c == 0)cout << "Impossible" << endl;
    else cout << "Possible" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

map<ll, int> prime_factorization(ll a) {
  map<ll, int> mp;
  for(ll i=2; i*i<=a; i++) {
    while (a%i == 0) { mp[i]++; a /= i; }
  }
  if (a > 1) mp[a]++;
  return mp;
}

// return A[i]: The length of the longest substring starting from S[i]
// which is also a prefix of S. Obviously, A[0] = S.size();
void Zalgorithm(vector<int>& A, string& S) {
  A[0] = S.size();
  int i = 1, j = 0;
  while (i < S.size()) {
    while (i+j < S.size() && S[j] == S[i+j]) ++j;
    A[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
    i += k; j -= k;
  }
}

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

  string s; cin >> s;
  int n = s.size();
  // check if all character is the same
  bool flag = true;
  rep(i, n) {
    if (s[i] != s[0]) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << n << endl;
    cout << 1 << endl;
    return 0;
  }

  vector<int> a(n);
  Zalgorithm(a, s);

  vector<bool> good(n+1, true);
  for(int p=1; p<n; p++) {
    for(int k=2; (k-1)*p <= a[p]; k++) {
      good[k*p] = false;
    }
  }

  if (good[n]) {
    cout << 1 << endl;
    cout << 1 << endl;
    return 0;
  }

  reverse(s.begin(), s.end());
  Zalgorithm(a, s);
  vector<bool> good2(n+1, true);
  for(int p=1; p<n; p++) {
    for(int k=2; (k-1)*p <= a[p]; k++) {
      good2[k*p] = false;
    }
  }

  int ans = 0;
  for(int i=1; i<n; i++) {
    if (good[i] && good2[n-i]) ans++;
  }
  cout << 2 << endl;
  cout << ans << endl;
}


Measured memory_bytes: 2844
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        Set<Integer> removedH = new HashSet<>();
        Set<Integer> removedW = new HashSet<>();
        String a[] = new String[h];
        for (int i=0; i<h; i++) {
            a[i] = sc.next();
            if (!a[i].contains("#")) {
                removedH.add(i);
            }
        }

        for (int j=0; j<w; j++) {
            boolean blackPresent = false;
            for (int i=0; i<h; i++) {
                if (a[i].charAt(j) == '#') {
                    blackPresent = true;
                    break;
                }
            }
            if (!blackPresent) removedW.add(j);
        }

        for (int i=0; i<h; i++) {
            if (removedH.contains(i)) continue;
            for (int j=0; j<w; j++) {
                if (removedW.contains(j)) continue;
                System.out.print(a[i].charAt(j));                
            }
            System.out.println();
        }
    }
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

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

void Main(){
    int n;
    cin >> n;
    if (n % 10 == 2 
        || n % 10 == 4
        || n % 10 == 5
        || n % 10 == 7
        || n % 10 == 9) cout << "hon";
    else if (n % 10 == 3) cout << "bon";
    else cout << "pon";
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3604
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let n:usize = read();
    let a:Vec<usize> = (1..n).map(|_| read()).collect();
    let mut map = HashMap::new();

    for jyoushi in a.iter() {
        let count = map.entry(*jyoushi).or_insert(0);
        *count += 1;
    }

    for i in 1..=n {
        println!("{:?}",map.get(&i).unwrap_or(&0));
    }
}


Measured memory_bytes: 10216
def main():
  K = int(input())
  A, B = map(int, input().split())
  flag = False
  for  num in range(A,B+1):
    if num % K == 0:
      flag = True
      break
  if flag:
    print('OK')
  else:
    print('NG')

if __name__ == "__main__":
  main()
  pass

Measured memory_bytes: 9168
#include <bits/stdc++.h>
     
    using namespace std;
     
    int main(){
     
        int a, b, c, sum;
        cin >> a >> b >> c;
        sum = a+b+c;
        if (sum == 17){
            cout << "YES" << "\n";
        }else{
            cout << "NO" << "\n";
        }
     
        return 0;
      
    }

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

typedef long long ll;
#define INF (1000000001)
int N;
int A[(1<<21)+1];
int T[(1<<21)+1];
ll res = 0;
void marge(int l,int r){
  if( r - l == 2 ){
    if( A[l] > A[r-1] ){
      res++;
      swap(A[l],A[r-1]);
    }
  } else {
    int m = (l+r)/2;
    marge(l,m);
    marge(m,r);
    for(int i=l,j=m,k=l;k<r;k++){
      if( (j < r && A[i] > A[j]) || i == m ){
        res += (m-i);
        T[k] = A[j++];
      } else {
        T[k] = A[i++];
      }
    }
    for(int i=l;i<r;i++) A[i] = T[i];
  }
  /*
  cout <<"( " <<  l << " , "<< r << " ) " << endl;
  for(int i=l;i<r;i++) cout << A[i] << " ";
  cout << endl;
  cout << "res = "<< res << endl;
  */
}


int main(){
  cin >> N;
  for(int i=0;i<N;i++) cin >> A[i];
  if( N == 1 ) cout << 0 << endl;
  else {
    int n = 1;
    while( n < N ) n *= 2; 
    for(int i=N;i<n;i++) A[i] = INF+i;
    N = n;
    marge(0,N);
    cout << res << endl;
  }
}

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

int main() {
	int k;
	cin >> k;
	int res;
	if(k % 2 == 0) res = (k/2) * (k/2);
	else res = (k/2) * (k/2+1);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string W[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string S; cin >> S;
    int cnt = 0;
    for (int i=0; i<7; i++) {
        if (S == W[i]) {
            cnt = i - 7;
        }
    }
    cout << abs(cnt) << endl;
    return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    int ans = 1;
    for(int in=0;in<n;in++) {
        ans = min(ans*2, ans+k);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int a[1005];
int b[1005];
int c[1005];
int dist[105][105];

int min(int x,int y){
	if(x<y){return x;}
	else{return y;}
}

int main(){

	int N,M;

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

	int i,j,k;

	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			if(i==j){dist[i][j]=0;}
			else{dist[i][j]=1<<25;}
		}
	}

	for(i=0;i<M;i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
		a[i]--;
		b[i]--;
		dist[a[i]][b[i]]=c[i];
		dist[b[i]][a[i]]=c[i];
	}

	for(k=0;k<N;k++){
		for(i=0;i<N;i++){
			for(j=0;j<N;j++){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	int ans=0;
	for(i=0;i<M;i++){
		if(dist[a[i]][b[i]]<c[i]){ans++;}
	}
	printf("%d\n",ans);

	return 0;
}

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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long int ll;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
	setprecision(100);
	fixed;
	long double minute=c*60.000+d;
	long double hourhand=(360.0/(12.0*60.000))*minute;
	long double minhand=(360.000/60.000)*d;
	long double angle=abs(hourhand-minhand);
	angle=min(angle,360-angle);
	angle*=(3.141592653589793238)/180.0;
	cout<<setprecision(100)<<sqrt(a*a+b*b-2*a*b*cos(angle));
}

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

using namespace std;

using ll = long long;

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

    std::vector<int> h(N);
    std::for_each(h.begin(), h.end(), [](auto &x) { cin >> x; });

    const auto max_height_it = std::max_element(h.crbegin(), h.crend());

    ll ans = 0;

    auto l = h.begin();
    while (*max_height_it > 0) {
        const auto r = std::find_if(l, h.end(), [](auto &x) { return x == 0; });
        if (r > l) {
            std::for_each(l, r, [](auto &x) { --x; });
            ++ans;
        }

        l = r;

        while (*max_height_it > 0) {
            if (l == h.end()) { l = h.begin(); }
            if (*l != 0) { break; }
            ++l;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll a, b,c,d;
    cin >> a >> b >> c >> d;
    ll x = c * d / euclidean_gcd(c, d);
    ll aa = a-1 - (a - 1) / c - (a - 1) / d + (a - 1) / x;
    ll bb = b - b / c - b / d + b / x;
    cout << bb - aa << endl;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;
const int mod = 1e9+7;


int main()
{
    string s;
    int sz,k;
    cin >> sz >> k >> s;
    int cnt = 0;
    char bef = s[0];
    _for(i,1,sz){
        if(s[i] == bef) cnt++;
        bef = s[i];
    }
    cout << min(sz-1,k*2 + cnt) << endl;

    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    t.pop_back();
    if (s == t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
int main(){
  int i;
  long long res = 0;
  rd(N);
  for(i=(1);i<(N+1);i++){
    res += (long long) (N/i) * (N/i+1) / 2 * i;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int N;
// {
//   ll res = 0;
//   rd(N);
//   rep(i,1,N+1) res += (ll) (N/i) * (N/i+1) / 2 * i;
//   wt(res);
// }


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> Vec;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define sum(v) accumulate(ALL(v),0)

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    if(n>=3200){
        cout<<s<<endl;
    }else{
        cout<<"red"<<endl;
    }
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int maxn=0x7fffff;
long long a[200005];
ll ans=1000000000000000000;
int main(){
	long long n,i,sum=0,x=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	for(i=0;i<n-1;i++){
		x+=a[i];
		ans=min(ans,abs(2*x-sum));
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
bool judge(string s){
  ll n=s.length();
  for(int i=0;i<n;i++){
    if(s[i]!=s[n-i-1]){
      return false;
    }
  }
  return true;
}
int main(){
  string s;
  cin>>s;
  ll n=s.length();
  string s1,s2;
  for(int i=1;i<=(n-1)/2;i++) s1.push_back(s[i-1]);
  for(int i=(n+3)/2;i<=n;i++) s2.push_back(s[i-1]);
  if(judge(s)&&judge(s1)&&judge(s2)){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;

}


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

int K;
string S;

int main() {
    //cout<<"Triple Dots\n";
    cin>>K;
    cin>>S;
    if(S.length()>K)
    {
        for(int i=0; i<K; i++) cout<<S[i];
        cout<<"...";
    }else{
        cout<<S;
    }
    
    return 0;
}


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

inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
    return x * f;
}

int n,m,l,r,ans,a,b;

int main ()
{
	cin >> n >> m;
    l = 1, r = n;
    
    while ( m -- )
	{
        cin >> a >> b;
        l = max ( l , a );
		r = min ( r , b );
    }
    
    if ( l > r )
	   ans = 0;
    else
	   ans = r - l + 1;
	
	cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

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

const long long int INF = 1LL<<50;

int main() {
    long long int N, a, b, c;
    cin >> N;
    vector<vii> AdjList(N+5, vii());
    for(long long int i = 1; i <= N-1; ++i) {
        cin >> a >> b >> c;
        AdjList[a].push_back(ii(b,c));
        AdjList[b].push_back(ii(a,c));
    }
    vi dist(N+5,INF);
    long long int Q, K;
    cin >> Q >> K;
    dist[K] = 0;
    priority_queue<ii, vector<ii>, greater<ii>> pq;
    pq.push(ii(0,K));
    while(!pq.empty()) {
        ii front = pq.top();
        pq.pop();
        long long int d = front.first, u = front.second;
        if(d > dist[u]) continue;
        for(long long int j = 0; j < (long long int)AdjList[u].size(); j++) {
            ii v = AdjList[u][j];
            if(dist[u] + v.second < dist[v.first]) {
                dist[v.first] = dist[u] + v.second;
                pq.push(ii(dist[v.first],v.first));
            }
        }
    }
    long long int x, y;
    for(long long int i = 1; i <= Q; ++i) {
        cin >> x >> y;
        cout << dist[x] + dist[y] << endl;
    }
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
vint G[111111];
int c[111111];

int r;
int sz[111111];
int cnt[111111];
int w[111111];

int bs;
void dfs(int v,int p){
    for(auto u:G[v]){
        if(u==p)continue;
        dfs(u,v);
        sz[v]+=sz[u];
        if(sz[u])cnt[v]++;
    }
    if(sz[v]||c[v])sz[v]++;
    if(p!=-1)cnt[v]++;
    if(sz[v]){
        w[v]=(cnt[v]+c[v])&1;
        bs+=w[v];
    }
}

int dp[111111];
int ans;
void dfs2(int v,int p){
    if(sz[v]==0)return;
    dp[v]=-1001001001;
    if(c[v]){
        dp[v]=w[v]?1:-1;
    }
    for(auto u:G[v]){
        if(u==p)continue;
        if(sz[u]==0)continue;
        dfs2(u,v);
        chmin(ans,bs-dp[u]-dp[v]-2);
        chmax(dp[v],dp[u]+1+(w[v]?1:-1));
    }
}

signed main(){
    cin>>N;
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }
    string uku;
    cin>>uku;
    rep(i,N)c[i]=uku[i]=='W';

    if(count(c,c+N,1)==0){
        cout<<0<<endl;
        return 0;
    }
    rep(i,N)if(c[i])r=i;
    dfs(r,-1);

    if(sz[r]==1){
        cout<<1<<endl;
        return 0;
    }

    bs+=(sz[r]-1)*2;

    ans=bs;
    dfs2(r,-1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 15104
#include<iostream>
#include<string.h>
#include<string>
using namespace std;

int f[1000010];

int main(){
	string a,b;
	int alen,blen,x,y;
	getline(cin,b);
	getline(cin,a);
		alen=a.size();
		blen=b.size();
		
		y=0;
		x=1;
		while(x<alen){
			if(a[x]==a[y]){
				y++;
				f[x]=y;
				x++;
			}else{
				if(y!=0){
					y=f[y-1];
				}else{
					f[x]=0;
					x++;
				}
			}
		}
		x=y=0;
		while(x<blen){
			if(a[y]==b[x]){
				x++;
				y++;
			}
			if(y==alen){
				cout<<x-y<<endl;
				y=f[y-1];
			}
			else if(x<blen&&a[y]!=b[x]){
				if(y!=0)y=f[y-1];
				else x=x+1;
			}
		}
	
	return 0;
}


Measured memory_bytes: 3224
use std::io::{self};
use std::collections::HashMap;

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).unwrap();
    buffer.clear();
    io::stdin().read_line(&mut buffer).unwrap();
    let mut xs: Vec<i32> = buffer
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    
    xs.sort();
    let mut counter = HashMap::new();
    loop {
        let (key, c) = count_and_truncate(&mut xs);
        counter.insert(key, c);
        if xs.is_empty() {break;}
    }
    let m = counter.keys().map(
        |key| {
            get_default(&counter, *key-1)
            + get_default(&counter, *key)
            + get_default(&counter, *key+1)
        }).max().unwrap();
    println!("{}", m);
}


fn count_and_truncate(xs: &mut Vec<i32>) -> (i32, i32) {
    let mut cnt = 0;
    let key = &xs[0].clone();
    for x in xs.iter() {
        if x != key {
            break;
        }
        cnt += 1;
    }
    xs.drain(..cnt as usize);
    // println!("{:?}", xs);
    (*key, cnt)
}

fn get_default(hashmap: &HashMap<i32, i32>, key: i32) -> i32 {
    match hashmap.get(&key) {
        None => 0,
        Some(x) => *x,
    }
}

Measured memory_bytes: 10492
#include <bits/stdc++.h>
#define int long long
#define moder 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
int a[105];
using namespace std;
signed main(){
   int n;
   cin>>n;
   rep(i,n)cin>>a[i];
   sort(a,a+n);
   reverse(a,a+n);
   int ans=0;
   rep(i,n){
	   if(i%2==0)ans+=a[i];
	   else ans-=a[i];
   }
   cout<<ans<<endl;
}



Measured memory_bytes: 256
if __name__ == '__main__':
    A, B, C = raw_input().split()
    c = 0
    if A == '7':
        c += 1
    if B == '7':
        c += 1
    if C == '7':
        c += 1
    if c == 1:
        print 'YES'
    else:
        print 'NO'


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

using namespace std;

typedef long long ll;

ll dp[305][305];
vector<int> g[305];
int ans[305][305];
const int IN = 1e9;
const ll INF = 1e14;
vector<int> A;
int main() {
  int n,m,l,q;
  cin >> n >> m >> l;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      if(i != j) {
      dp[i][j] = INF;
      ans[i][j] = IN;
      }
    }
  }
  for(int i = 0; i < m; i++) {
    int a,b,c;
    cin >> a >> b >> c;
    --a;--b;
    if(c > l) continue;
    dp[a][b] = c;
    dp[b][a] = c;
  }

  for(int k = 0; k < n; k++) {
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
	dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);
      }
    }
  }

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      if(i == j) continue;
      if(dp[i][j] <= l) ans[i][j] = 1;
    }
  }

   for(int k = 0; k < n; k++) {
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
	ans[i][j] = min(ans[i][j],ans[i][k] + ans[k][j]);
      }
    }
  }

   cin >> q;

   for(int i = 0; i < q; i++) {
     int s,t;
     cin >> s >> t;
     --s;--t;
     if(ans[s][t] == IN) A.push_back(-1);
     else A.push_back(ans[s][t] - 1);
   }

   for(int i = 0; i < A.size(); i++) cout << A[i] << endl;
}

  
  
  


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

int main(void)
{
    int n,r,p,c;
    while(1) {
        cin >> n >> r;
        if(n==0 && r==0) break;
        int a[n],b[n];
        for(int i=0; i<n; i++)
            a[i] = n - i;
        for(int i=0; i<r; i++) {
            cin >> p >> c;
            for(int j=0; j<n; j++)
                b[j] = a[j];
            for(int j=0; j<p-1; j++)
                b[j+c] = a[j];
            for(int j=0; j<c; j++)
                b[j] = a[j+(p-1)];
            for(int j=0; j<n; j++)
                a[j] = b[j];
        }
        cout << a[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void){
	int Am,Ai,As,Ae,Bm,Bi,Bs,Be,A,B;
	scanf("%d%d%d%d%d%d%d%d",&Am,&Ai,&As,&Ae,&Bm,&Bi,&Bs,&Be);
	A=Am+Ai+As+Ae;
	B=Bm+Bi+Bs+Be;
	if (A<B)
	printf ("%d\n",B);
	else
	printf("%d\n",A);
	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cassert>
#include <string>
#include <map>
#include <vector>
using namespace std;

int mat[7][6] = {{1, 2, 3, 4, 5, 6},
                 {2, 6, 3, 1, 5, 4},
                 {3, 1, 2, 6, 4, 5},
                 {4, 1, 3, 6, 5, 2},
                 {5, 4, 6, 2, 1, 3},
                 {6, 4, 3, 2, 5, 1}};
const int INFI = 99999999;
map<string, int> colors;

struct Cube {

    int face[7], face_backup[7];


    int GetIndex(const string& color) {
        if (colors.find(color) == colors.end()) {
            colors[color] = colors.size() - 1;
        }
        return colors[color];
    }

    void read() {
        string color;
        for (int i = 1; i <= 6; ++i) {
            cin >> color;
            face[i] = GetIndex(color);
        }
        swap(face[4], face[5]);
        for (int i = 1; i <= 6; ++i) face_backup[i] = face[i];
    }

    void rotate(int iter_number) {
        if (iter_number % 4 == 0) {
            int ino = iter_number / 4;
            for (int i = 1; i <= 6; ++i)
                face[i] = face_backup[mat[ino][i-1]];
/*
            for (int i = 1; i <= 6; ++i)
                printf("%d ",face[i]);
            printf("\n");
*/
            //system("pause");
        } else {
            int face_5 = face[5];
            for (int i = 5; i > 2; --i)
                face[i] = face[i-1];
            face[2] = face_5;
        }
    }

    void show() const {
        for (int fno = 1; fno <= 6; ++fno) {
            printf("%d ", face[fno]);
        }
        cout << endl;
    }
};
vector<Cube> cubes;
int ans;

int CalcDiff(const vector<Cube>& cubes) {
    int counter[30];
    int total_diff = 0;
    for (int fno = 1; fno <= 6; ++fno) {
        for (int i = 0; i < colors.size(); ++i) counter[i] = 0;
        for (int cno = 0; cno < cubes.size(); ++cno) {
            ++counter[ cubes[cno].face[fno] ];
        }
        int most_color_number = 0;
        for (int i = 0; i < colors.size(); ++i)
        if (counter[i] > most_color_number) {
            most_color_number = counter[i];
        }
        total_diff += cubes.size() - most_color_number;
        //cout << "cubes.size() = " << cubes.size() - most_color_number << endl;
    }
    //for (int i = 0; i < cubes.size(); ++i) cubes[i].show();
    //cout << "total_diff = " << total_diff << " " << ans << endl << endl;
    //if (total_diff == 1) { total_diff /= 0; }
    return total_diff;
}

void dfs(int cno) {
    if (cno == cubes.size()) {
        ans = min(ans, CalcDiff(cubes));
        return;
    }
    for (int i = 0; i < 24; ++i) {
        cubes[cno].rotate(i);
        dfs(cno + 1);
    }
}

int main() {
    int n;
    while (cin >> n && n != 0) {
        colors.clear();
        cubes.resize(n);
        for (int i = 0; i < n; ++i)
            cubes[i].read();

        //cout << "colors.size() = " << colors.size() << endl;
        assert(colors.size() <= 24);
        ans = INFI;
        dfs(0);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1240
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
constexpr int MX = 405;
vector<ll> a(MX);
vector<vector<ll>> dp(MX, vector<ll>(MX, LINF));
vector<ll> cum(MX);

ll dfs(int l, int r) {
    if(dp[l][r]!=LINF) return dp[l][r];
    ll res = LINF;
    for(int i=l; i<r; i++) {
        chmin(res, dfs(l, i)+dfs(i+1,r)+cum[r]-cum[l]+a[l]);
    }
    return dp[l][r] = res;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int n; cin >> n;
    rep(i,n) cin >> a[i];
    cum[0] = a[0];
    FOR(i,1,n-1) {
        cum[i] = cum[i-1] + a[i];
    }
    rep(i,n) {
        dp[i][i] = 0;
        // if(i < n-1) dp[i][i+1] = a[i] + a[i+1];
    }   
    cout << dfs(0, n-1) << endl;
    return 0;
}


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

public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int x = Integer.parseInt(tokenizer.nextToken());
        int y = Integer.parseInt(tokenizer.nextToken());
        StringBuilder firstAndLast = new StringBuilder();
        for (int i = 0; i < y + 2; i++) {
            firstAndLast.append('#');
        }
        StringBuilder out = new StringBuilder();
        out.append(firstAndLast).append('\n');
        for (int i = 0; i < x; i++) {
            out.append('#').append(input.readLine()).append('#').append('\n');
        }
        out.append(firstAndLast).append('\n');
        System.out.print(out);
    }
}


Measured memory_bytes: 22612
import sys

input = sys.stdin.readline

def main():
    ans = 'Positive'
    a, b = map(int, input().split())
    if a <= 0 <= b:
        ans = 'Zero' 
    elif b < 0:
        if abs(a-b)%2 == 0:
            ans = 'Negative'
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long h, w;
    scan(h, w);
    long ans = INF;
    foreach (i; iota(1, h))
    {
        long a, b, c, r;
        a = i * w;
        r = h * w - a;
        if ((h - i) % 2 == 0 || w % 2 == 0)
        {
            b = c = r / 2;
            ans = min(ans, abs(a - b));
        }
        else
        {
            b = (max(h, w) / 2) * min(h - i, w);
            c = r - b;
            ans = min(ans, only(abs(a - b), abs(a - c), abs(b - c)).array().reduce!(max));
        }
    }
    foreach (j; iota(1, w))
    {
        long a, b, c, r;
        a = j * h;
        r = h * w - a;
        if (h % 2 == 0 || (w - j) % 2 == 0)
        {
            b = c = r / 2;
            ans = min(ans, abs(a - b));
        }
        else
        {
            b = max(h, w) / 2 * min(h, w - j);
            c = r - b;
            ans = min(ans, only(abs(a - b), abs(a - c), abs(b - c)).array().reduce!(max));
        }
    }
    ans.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 3668
def dijkstra(graph,weight,s,N):
    distance=[1e10 for i in range(N)]
    distance[s]=0
    unvisited=[i for i in range(N)]
    while len(unvisited)>0:
        unvisited.sort(key=lambda x:distance[x])
        v=unvisited.pop(0)
        for w in graph[v]:
            if distance[w]>distance[v]+weight[(v,w)]:
                distance[w] = distance[v] + weight[(v, w)]
    return distance

def e_check(e,d_list,weight,N):
    for i in range(N):
        for j in range(N):
            if e[0]!=i and e[1]!=j and d_list[e[0]][i]+weight[(i,j)]==d_list[j][e[1]]:
                return True
    return False

def e_check_2(E,d_list,weight):
    count=0
    for e in E:
        if d_list[e[0]][e[1]]!=weight[e]:
            count+=1
    return count


if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    graph={i:[] for i in range(N)}
    weight={(i,j):1e10 for i in range(N) for j in range(N)}
    E=[]

    for i in range(M):
        a,b,c = list(map(int, input().split()))
        E.append((a-1,b-1))
        E.append((b-1,a-1))
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
        weight[(a-1,b-1)]=c
        weight[(b-1,a-1)]=c
    d_list={i:dijkstra(graph,weight,i,N) for i in range(N)}

    ans=e_check_2(E,d_list,weight)

    print(ans//2)

Measured memory_bytes: 44252
#include <bits/stdc++.h>
using namespace std;
#define int long long int
pair<int,int> ar[100005];
int32_t main(){
	int n,m;cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>ar[i].first>>ar[i].second;
	}
	sort(ar+1,ar+n+1,
		[](pair<int,int>a,pair<int,int>b){
			return a.first<b.first||(a.first==b.first&&a.second>b.second);});
	int ans=0;
	for(int i=1;i<=n;i++){
		ans += min(m,ar[i].second)*ar[i].first;
		m -= min(m,ar[i].second);
		if(!m){
			break;
		}
	}
	cout<<ans;
}


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a = s.indexOf('A');
        int z = s.lastIndexOf('Z');
        int result = z - a + 1;
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 25584
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    int h, w, k; cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int>> cumsums(h, vector<int>(w));
    rep(i, h){
        int sum = 0;
        rep(j, s[i].size()){
            sum += s[i][j] - '0';
            cumsums[i][j] = sum;
        }
    }
    int ans = INF;
    rep(i, 1 << (h - 1)){
        vector<int> group_num(h);
        int g = 0;
        rep(j, h){
            group_num[j] = g;
            if (i >> j & 1) g++;
        }
        vector<int> group(g + 1, 0);
        int line = g;
        rep(l, w){
            rep(j, h){
                group[group_num[j]] += s[j][l] - '0';
                if (group[group_num[j]] > k){
                    line += 1;
                    group = vector<int>(g + 1, 0);
                    rep(re_j, h) {
                        group[group_num[re_j]] += s[re_j][l] - '0';
                        if (group[group_num[re_j]] > k){
                            line = INF;
                            break;
                        }
                    }
                    break;
                }
            }
        }
        ans = min(ans, line);
    }
    cout << ans << endl;
}



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

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

def gcd3(a,b,c):
  gcd_ab = gcd(a,b)
  return(gcd(gcd_ab,c))


sum_gcd = 0
for i in range(1,k+1):
  for j in range(1,k+1):
    for n in range(1,k+1):
      sum_gcd += gcd3(i,j,n)
print(sum_gcd)

Measured memory_bytes: 81468
#include<stdio.h>

int main()
{

    int a, b, i, j;
    while(1){
    scanf("%d%d", &a, &b);

    if(a == 0 && b == 0) break;
    for(i=1; i<=a;i++){
	for(j=1; j<=b; j++){
	    if((i+j)%2  ==0) printf("#");
	    else printf(".");}
	printf("\n");
    }
    printf("\n");
}

    return 0;
}


Measured memory_bytes: 2000
#include<iostream>

using namespace std;

int main()
{
	const int B = 4;
	const int F = 3;
	const int R = 10;

	int a[B][F][R];
	for (int i = 0; i < B; i++)
		for (int j = 0; j < F; j++)
			for (int k = 0; k < R; k++)
				a[i][j][k] = 0;

	int n;
	cin >> n;

	int b, r, f, v;
	for (int i = 0; i < n; i++)
	{
		cin >> b >> f >> r >> v;
		a[b - 1][f - 1][r - 1] += v;
	}

	for (int i = 0; i < B; i++)
	{
		if(i != 0)
			cout << "####################" << endl;

		for (int j = 0; j < F; j++)
		{
			for (int k = 0; k < R; k++)
			{
					cout << " " << a[i][j][k];
			}
			cout << endl;
		}

	}
}

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

vector<vector<int>> v;
int pnum[100100];

std::vector<std::vector<int>> iig(int vn, int en) {
	std::vector<std::vector<int>> res(vn);
        for(int i = 0; i < en; i++) {
                int s, t;
                std::cin >> s >> t;
                s--; t--;
                res[s].push_back(t);
		pnum[t]++;
        }
        return res;
}

int ans[100100];
int n, m;

void dfs(int i) {
	for(int j: v[i]) {
		if (--pnum[j] == 0) {
			ans[j] = i + 1;
		}
	}
	for(int j: v[i]) {
		if (pnum[j] == 0) dfs(j);
	}
}

int main() {
	cin >> n >> m;
	v = iig(n, n - 1 + m);
	int root;
	rep(i, n) if (pnum[i] == 0) {
		root = i;
		break;
	}
	dfs(root);
	rep(i, n) cout << ans[i] << endl;
}



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

using namespace std;
using ll = long long;

template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
const ll MOD = (ll)1e9 + 7;

int main() {
    int N;
    cin >> N;
    V<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int mb = 60;
    V<ll> cnt1(mb, 0LL);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < mb; j++) {
            if ((A[i] >> j) & 1) {
                cnt1[j]++;
            }
        }
    }

    ll ans = 0LL;
    for (int i = 0; i < mb; i++) {
        ll add = (N - cnt1[i]) * cnt1[i] % MOD;
        add = add * ((1LL << i) % MOD) % MOD;
        ans += add;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2688
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

struct Node{
	int key;
	Node *prev,*next;
};

Node *nil;
void init(){
	nil=(Node *)malloc(sizeof(Node));
	nil->next=nil;
	nil->prev=nil;
}

void insert(int key){
	Node *x=(Node *)malloc(sizeof(Node));
	x->key=key;
	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;
}

Node* listSearch(int key){
	Node *cur=nil->next;
	while(cur!=nil && cur->key!=key){
		cur=cur->next;
	}
	return cur;
}

void deleteNode(Node *t){
	if(t==nil)return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key){
	deleteNode(listSearch(key));
}

int n;
int main(void){
	init();
	char com[21];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int key;
		scanf("%s",com);
		if(com[0]=='i'){
			scanf("%d",&key);
			insert(key);
		}
		else if(com[0]=='d'){
			if(strlen(com)>6){
				if(com[6]=='F')deleteFirst();
				if(com[6]=='L')deleteLast();
			}else{
				scanf("%d",&key);
				deleteKey(key);
			}
		}
	}
	Node *now=nil->next;
	while(now!=nil){
		printf("%d%c",now->key,now->next==nil?'\n':' ');
		now=now->next;
	}
	return 0;
}

Measured memory_bytes: 33784
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  string s;
  cin >> s;
  int cr, cl;
  int l = 0, r = 0;
  int count = 1;
  int n = s.length();
  int ans[100000] = {};
  FOR(i, 1, n)
  {
    if (s[i] != s[i - 1])
    {
      if (s[i] == 'L')
      {
        cl = count;
        l = i - 1;
        r = i;
      }
      else
      {
        cr = count;
        ans[l] = (cl + 1) / 2 + cr / 2;
        ans[r] = cl / 2 + (cr + 1) / 2;
      }
      count = 1;
    }
    else
    {
      count++;
    }
  }

  cr = count;
  ans[l] = (cl + 1) / 2 + cr / 2;
  ans[r] = cl / 2 + (cr + 1) / 2;

  REP(i, n)
  {
    cout << ans[i];
    if (i != n - 1)
    {
      cout << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod=1e9+7;
int main() {
int n;
cin>>n;
bool flag=false;
if(n%4==0||n%7==0) flag=true;
for(int i=0;true;i++){
   if(n<0) break;
   if(n%4==0){
      flag=true;
      break;
   }
   else n-=4;
   if(n<0) break;
  if(n%7==0){
      flag=true;
      break;
  }
  else n-=7;
}
if(flag){
   cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;

}


Measured memory_bytes: 256