akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main(){
  int N,K;
  cin >>  N >> K;
  int sum = 0;
  vector<int> x(N);
  for(int i = 0; i < N; i++){
     cin >> x.at(i);
   }
  for(int i = 0; i < N; i++){
    if(abs(K-x.at(i)) < x.at(i)){
      sum+= abs(K-x.at(i))*2;
    }
      else {
        sum+= x.at(i)*2;
    }
}
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
#define endl "\n"
//#define int long long
#define all(V) V.begin(),V.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
//関数とか

//宣言とか
int ans;
/*signed*/int main(void) {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    rep(i, n) {
        if (p[i] == i + 1) {
            swap(p[i], p[i + 1]);
            ++ans;
        }
    }
    cout << ans << endl;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var K = input[1];

            Console.WriteLine(K * 2 - 1 <= N ? "YES" : "NO");
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out
 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
#define M 201
 
#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"
 
#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)
 
#define all(v) v.begin(), v.end()
#define print(v) for (auto i: v) cerr << i << " ";
 
int main() {
    fast
    string s;
      cin>>s;
      if(s[s.length()-2]=='B')cout<<"ARC"<<endl;
       else cout<<"ABC"<<endl;
}


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

using namespace std;

int main(){
  int n, k, q, ans=0, tmp;
  vector<int> v;
  
  cin>> n >> k >> q;
  v.resize(n+1);
  
  for(int i=1;i<=n;i++) v[i]=0;
  
  for(int i=0;i<q;i++){
    cin>> tmp;
    v[tmp]++;
  }

  for(int i=1;i<=n;i++){
    if(k+v[i]-q>0) cout<< "Yes" <<endl;
    else cout<< "No" <<endl;
  }
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>

using namespace std;

int dp[1000][1001],t[1000],w[1000];

int main(){
  for(int c=1;;c++){
    int n,q,i,j;
    scanf("%d",&q); if(q==0) break;
    scanf("%d",&n);

    for(i=0; i<n; i++)
      scanf("%d,%d",&t[i],&w[i]);

    for(i=0; i<=q; i++)
      dp[0][i] = (i>=w[0])?t[0]:0;

    for(i=1; i<n; i++)
      for(j=0; j<=q; j++)
	if(j>=w[i])
	  dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+t[i]);
	else
	  dp[i][j] = dp[i-1][j];

    int mw=0,mt=0;
    for(j=0; j<=q; j++)
      if(dp[n-1][j]>mt){
	mt = dp[n-1][j];
	mw = j;
      }

    printf("Case %d:\n%d\n%d\n",c,mt,mw);
  }
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL N, X;
  cin >> N >> X;
  LL sum = 0;
  LL cnt = 1;
  REP(i,N){
    LL L;
    cin >> L;
    sum += L;
    if(sum<=X){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int N,K,ans;
  cin>>N>>K;
  ans = 0;
  while(N!=0) {
      N/=K;
      ++ans;
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Solver {
    public void Solve() {
        int a = sc.nextInt();
        int b = sc.nextInt();
        for (int i = 1; i < 1100; i++) {
            if (Math.floor(i * 0.08) == a && Math.floor(i * 0.1) == b) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
}


Measured memory_bytes: 23764
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;
//0/26 done
public class Main { //CHANGE TO MAIN WHEN SUBMITTING
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++) a[i] = in.nextInt();
        int[] dp = new int[n];
        Arrays.fill(dp,(int)1e5);
        dp[0] = 0;
        if(dp.length==1){
            out.print(0);
        }
        else{
            dp[1] = Math.abs(a[1]-a[0]);
            for(int i = 2; i<n; i++){
                dp[i] = Math.min(Math.abs(a[i-1]-a[i])+dp[i-1],Math.abs(a[i-2]-a[i])+dp[i-2]);
            }
            out.print(dp[n-1]);
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 43388
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n, m, q;
	int rui[501][501] = {};
	cin >> n >> m >> q;
	int l, r;
	for (int i = 0; i < m; ++i)
	{
		cin >> l >> r;
		++rui[l][r];
	}
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			rui[i][j] += rui[i][j-1];
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			rui[j][i] += rui[j-1][i];
		}
	}
	for (int Q = 0; Q < q; ++Q)
	{
		cin >> l >> r;
		int ma = max(l, r);
		int mi = min(l, r);
		cout << rui[ma][ma] - rui[ma][mi-1] - rui[mi-1][ma] + rui[mi-1][mi-1] << endl;
	}
	return 0;
}

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

int main(){
	int arr[30] = {};
	string a;
	while(getline(cin, a)){
		for(int i = 0; i < a.length(); i++){
			if(a[i] > 96 && a[i] < 123)
				a[i] -= 32;
			if((a[i] > 64 && a[i] < 91))
				arr[a[i] - 65]++;
		}
		for(int i = 0; i < a.length(); i++){
		}
	}
	
	
	for(int i = 0; i < 26; i++)
		cout << (char)(i+97) << " : " << arr[i] << endl;
}


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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    // ostr << p.first << ", " << p.second;
    ostr << "(" << p.first << ", " << p.second << ")";
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll v(n); v[i]=x;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll v(m,vll(n)); v[i][j]=x;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll v(n); v[i]=make_pair(x,y); v[i].first/second;
// v.front() : v[0]
// v.back()  : v[v.size()-1]

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF ((ll)1e+12)
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<=(b); i++)
#define FORR(i,a,b) for(ll i=(b); i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T>& v){return accumulate(all(v), (T)0);}
template<typename T> inline void sort(vector<T>& v){sort(all(v));}
template<typename T> inline void rsort(vector<T>& v){sort(all(v), greater<T>());}
template<typename T> inline void chmin(T& a, T b){if(a>b) a=b;}
template<typename T> inline void chmax(T& a, T b){if(a<b) a=b;}

int main(){
    ll n, m, ans = 0;
    cin >> n >> m;
    vll a(m), b(m);
    if(n%2==1){
        REP(i,m){
            a[i] = i+1;
            b[i] = n-i;
        }
    }
    else{
        ll r = min(n/4, m);
        REP(i,r){
            a[i] = i+1;
            b[i] = n-i;
        }
        if(r<m){
            FOR(i,r,m-1){
                a[i] = i+1;
                b[i] = n-i-1;
            }
        }
    }
    REP(i,m) cout << a[i] << " " << b[i] << endl;
    return 0;
}


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

int main(void){
    

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

for(i=n-1;i>0;i--){
  if(a[i-1]-1 == a[i]){
    a[i-1] = a[i-1] - 1;
  }
}

for(i=0;i<n-1;i++){

  if(a[i]  > a[i+1]){
    cout <<"No" << endl;
    c = 1;
    break;
  }
    
 
  
}
  if(c == 0){
    cout <<"Yes" << endl;
  }
  return 0;
  
}

Measured memory_bytes: 1024
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// #define MAX         2000000000000000000
#define M           1000000007
using namespace std;

#define F first 
#define S second 
#define MAX 10000003 
const int mod = 1000000007; 
  
int prime[MAX]; 
unordered_map<int, int> max_map; 
  
// Function to return a^n 
int power(int a, int n) 
{ 
    if (n == 0) 
        return 1; 
    int p = power(a, n / 2) % mod; 
    p = (p * p) % mod; 
    if (n & 1) 
        p = (p * a) % mod; 
    return p; 
} 
  
// Function to find the smallest prime factors 
// of numbers upto MAX 
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
  
// Function to return the LCM modulo M 
int lcmModuloM(const int* ar, int n) 
{ 
  
    for (int i = 0; i < n; i++) { 
        int num = ar[i]; 
        unordered_map<int, int> temp; 
  
        // Temp stores mapping of prime factor to 
        // its power for the current element 
        while (num > 1) { 
  
            // Factor is the smallest prime factor of num 
            int factor = prime[num]; 
  
            // Increase count of factor in temp 
            temp[factor]++; 
  
            // Reduce num by its prime factor 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
  
            // Store the highest power of every prime 
            // found till now in a new map max_map 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
    int ans = 1; 
  
    for (auto it : max_map) { 
  
        // LCM is product of primes to their highest powers modulo M 
        ans = (ans * power(it.F, it.S)) % mod; 
    } 
  
    return ans; 
} 

int mod_inv(int x){
    return power(x, mod-2);
}
 
signed main()
{
    tezz
    
    sieve(); 
    
    int n;
    cin>>n;

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

    int lcm = lcmModuloM(arr, n);

    int sum = 0;
    for(int i=0;i<n;i++){
        sum = (sum + (lcm * (mod_inv(arr[i]))) % mod) % mod;
    }

    cout<<sum;
} 

Measured memory_bytes: 78848
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

long long solve(long long n, long long x)
{
    long long y = n - x;
    if (n % y == 0)
        return x + n - y;
    long long ret = y;
    long long len = x;
    long long times = len / y;
    len %= y;
    ret += times * y * 2;
    return ret + len + solve(y, y - len);
}

int main()
{
    long long n, x;
    cin >> n >> x;
    cout << solve(n, x) + x << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int w;
	int n;
	int n2;
	int i;
	int a, b;
	int lot[30];
	int emp;
	
	for (i = 1; i <= 30; i++){
		lot[i-1] = i;
	}
	
	scanf("%d", &w);
	scanf("%d", &n);
	
	n2 = n;
	while (n2-- > 0){
		scanf("%d,%d", &a,&b);
		emp = lot[a-1];
		lot[a-1] = lot[b-1];
		lot[b-1] = emp;
	}
	
	for (i = 0; i < w; i++){
		printf("%d\n", lot[i]);
	}
	
	return (0);
}

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

using namespace std;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	vector<int> v={a,b,c};
	sort(v.begin(), v.end());
	if(v[0]!=v[1])cout<<v[0];
	if(v[1]!=v[2])cout<<v[2];
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iterator>

using namespace std;

void print_contained(vector<bool>& contained)
{
	cout << "contained: ";
	for (int i = 0; i < contained.size(); i++) {
		cout << contained[i];
	}
	cout << endl;
}

long calculateSum(string& S, vector<bool>& contained)
{
	long sum = 0;
	long base = 1, val = 0;
	for (int i = S.length() - 1; i >= 0; --i) {
		if (contained[i]) {
			//cout << i << " val: " << val << endl;
			sum += val;
			base = 1;
			val = 0;
		} else {
			int c = S[i] - '0';
			//cout << "c: " << c << endl;
			val +=  c * base;
			base *= 10;
		}
	}
	sum += val;
	return sum;
}

long allSum(string& S, int depth, vector<bool>& contained)
{
	//cout << "depth: " << depth << endl;
	if (depth == S.length()) {
		return calculateSum(S, contained);
	}
	// pattern without adding '+'
	vector<bool> _contained;
	copy(contained.begin(), contained.end(), back_inserter(_contained));
	//cout << depth << " =: "; print_contained(contained);
	long sum1 = allSum(S, depth + 1, _contained);
	// pattern with adding '+'
	contained[depth] = true;
	//cout << depth << " +: "; print_contained(contained);
	long sum2 = allSum(S, depth + 1, contained);
	return sum1 + sum2;
}

long solve(string& S, vector<bool>& contained)
{
	return allSum(S, 0, contained);
}

int main(int argc, char** argv, char** env)
{
	string S;
	cin >> S;
	//
	vector<bool> contained(S.length(), false);
	long sum = solve(S, contained);
	//
	cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define ll  long long
  #define ld long double
  #define pb push_back
  #define mp3 make_pair
  #define rep1(i,a,b) for(ll i=a;i<=b;i++)
  #define rep2(i,a,b) for(ll i=a;i<b;i++)
  int main(){
    IOS;
    ll n;
    cin>>n;
    ll a[n],b[n];
    vector<ll> p,q;
    for(ll i=0;i<n;i++){
      cin>>a[i]>>b[i];
     p.pb(a[i]+b[i]);
     q.pb(a[i]-b[i]);
    }
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  cout<<max(p[n-1]-p[0],q[n-1]-q[0])<<endl;
  }

Measured memory_bytes: 9780
#include <cstdio>
#include <iostream>
#include <set>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

const int CMax = 100002;

int n, A[CMax];
long long sum;

int main() {
    scanf("%d", &n);

    if (n < 1200) printf("ABC\n");
    else if (n < 2800) printf("ARC\n");
    else printf("AGC\n");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
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 (b<a) { a=b; return 1; } return 0; }
using namespace std;

int main(){
  ll n,m;
  string S,T;
  cin >> n >> m >> S >> T;

  ll lcm = n*m/__gcd(n,m);
  if (n>m){
    swap(n,m);
    swap(S,T);
  }
  rep(i,n){
    ll div = i*m / n;
    if((i*m)%n==0 && div<=(m-1)){
      if(S[i] != T[div]){
        cout << -1 << endl;
        return 0;
      }
    }

  }
  
  cout << lcm << endl;



  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n,t;
 	cin >> n>>t;
 	ll ans=0;
 	int x;
 	cin >> x;
 	for (int i = 1; i < n; i++){
 		int y;
 		cin >> y;
 		if(x+t>y){
 			ans+=y-x;
 		}else{
 			ans+=t;
 		}
 		x=y;
 	}
 	cout << ans+t << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  long long w, h;
  cin>>w>>h;
  long long p[w], q[h];
  REP(i, w) cin>>p[i];
  REP(i, h) cin>>q[i];
  
  typedef pair<long long, bool> P;
  vector<P> vec;
  REP(i, w) vec.push_back(P(p[i], false));
  REP(i, h) vec.push_back(P(q[i], true));
  sort(ALL(vec));
  
  long long used_w = 0, used_h = 0;
  long long ans = 0;
  REP(i, w + h){
    if(vec[i].second){
      ans += (w + 1 - used_w) * vec[i].first;
      used_h++;
    }else{
      ans += (h + 1 - used_h) * vec[i].first;
      used_w++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 9036
n, k, q = map(int, input().split())
k -= q

if k > 0:
    for i in range(n):
        print('Yes')
    exit()

a = [int(input()) for i in range(q)]
n_a = [k] * n

for i in range(q):
    n_a[a[i] - 1] += 1

ans = 0
for i in n_a:
    if i <= 0:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 55896
#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 k, x;
  cin >> k >> x;
  if (500 * k >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define MAX 102
#define MOD 100000

using namespace std;

struct node
{
	long long u_stright;
	long long u_turn;
	long long h_stright;
	long long h_turn;
};

node dp[MAX][MAX];

int main(void)
{
	int w,h;
	node n;
	int ans;
	int i1,i2;

	while(1){
		cin>>w>>h;
		if(w+h==0) break;

		n.u_stright=0;
		n.u_turn=0;
		n.h_stright=0;
		n.h_turn=0;

		for(i1=0;i1<MAX;i1++){
			for(i2=0;i2<MAX;i2++){
				dp[i1][i2]=n;
			}
		}

		dp[1][1].u_stright=1;
		dp[1][1].u_turn=0;
		dp[1][1].h_stright=1;
		dp[1][1].h_turn=0;

		for(i1=1;i1<=h;i1++){
			for(i2=1;i2<=w;i2++){
				if(i1==1 && i2==1) continue;

				dp[i1][i2].u_stright=(dp[i1-1][i2].u_stright+dp[i1-1][i2].u_turn)%MOD;
				dp[i1][i2].u_turn	=(dp[i1-1][i2-1].h_stright+dp[i1-1][i2-1].h_turn)%MOD;
				dp[i1][i2].h_stright=(dp[i1][i2-1].h_stright+dp[i1][i2-1].h_turn)%MOD;
				dp[i1][i2].h_turn	=(dp[i1-1][i2-1].u_stright+dp[i1-1][i2-1].u_turn)%MOD;
			}
		}
		ans=(dp[h][w].u_stright+dp[h][w].u_turn+dp[h][w].h_stright+dp[h][w].h_turn)%MOD;
		cout<<ans<<endl;

		/*for(i1=1;i1<=h;i1++){
			for(i2=1;i2<=w;i2++){
				cout<<dp[i1][i2].u_stright<<" "<<dp[i1][i2].u_turn<<" "<<dp[i1][i2].h_stright<<" "<<dp[i1][i2].h_turn<<endl;

				ans=(dp[i1][i2].u_stright+dp[i1][i2].u_turn+dp[i1][i2].h_stright+dp[i1][i2].h_turn);
				cout<<ans<<endl;
			}
			cout<<endl;
		}*/

	}
	return 0;

}

Measured memory_bytes: 1484
def levenshtein(s1, s2):

    n, m = len(s1), len(s2)

    dp = [[0] * (m+1) for _ in range(n+1)]

    

    for i in range(n+1):

        dp[i][0] = i

    

    for j in range(m+1):

        dp[0][j] = j



    for i in range(1, n+1):

        for j in range(1, m+1):

            cost = 0 if s1[i-1] == s2[j-1] else 1

            dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1]+1, dp[i-1][j-1] + cost)

            

    return dp[n][m]



def solve():

    

    s1 = input()

    s2 = input()



    print(levenshtein(s1, s2))

    

if __name__ == '__main__':

    solve()


Measured memory_bytes: 43072
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>

using namespace std;

typedef long long ll;

int main()
{
  string S;
  cin >> S;

  int i;
  for(i=0;i<S.size();i++)
    {
      if(i%2==0)
	{
	  if(S[i]=='R'||S[i]=='U'||S[i]=='D')
	    continue;
	  else
	    {
	      cout << "No" << endl;
	      return 0;
	    }
	}
      else
	{
	  if(S[i]=='L'||S[i]=='U'||S[i]=='D')
	    continue;
	  else
	    {
	      cout << "No" << endl;
	      return 0;
	    }
	} 
    }
  cout << "Yes" << endl;

  return 0;
}



Measured memory_bytes: 256
import sys
input=sys.stdin.readline
N=int(input())
P=[0 for i in range(N+1)]

L=[[]for i in range(N+1)]
for i in range(N-1):
    a,b=map(int,input().split())
    L[a].append(b)
    L[b].append(a)
#print(L)

d1=[10**9 for i in range(N+1)]
d1[1]=0
Q=[]
for i in L[1]:
    Q.append([i,1])
#print(Q)
#print(d1)
for i in range(N-1):
    d1[Q[i][0]]=Q[i][1]
    for j in L[Q[i][0]]:
        if d1[j]==10**9:
            Q.append([j,Q[i][1]+1])
#print(d1)
ODD=0
EVE=0
for i in range(1,N+1):
    if d1[i]%2==0:
        EVE+=1
    else:
        ODD+=1
#print(ODD,EVE)
M1=[]
M2=[]
M3=[]
for i in range(1,N+1):
    if i%3==1:
        M1.append(i)
    elif i%3==2:
        M2.append(i)
    else:
        M3.append(i)
if min(ODD,EVE)*2<max(ODD,EVE):
    if ODD<EVE:
        D={}
        ans=[0 for i in range(N+1)]
        cnt=0
        for i in range(1,N+1):
            if d1[i]%2==1:
                ans[i]=M3[cnt]
                D[M3[cnt]]=1
                cnt+=1
        num=1
        for i in range(1,N+1):
            #print(D)
            if d1[i]%2==0:
                if num in D:
                    #print(True)
                    num+=1
                ans[i]=num
                num+=1
    else:
        D={}
        ans=[0 for i in range(N+1)]
        cnt=0
        for i in range(1,N+1):
            if d1[i]%2==0:
                ans[i]=M3[cnt]
                D[M3[cnt]]=1
                cnt+=1
        num=1
        for i in range(1,N+1):
            #print(D)
            if d1[i]%2==1:
                if num in D:
                    #print(True)
                    num+=1
                ans[i]=num
                num+=1
    print(*ans[1:])
else:
    ans=[0 for i in range(N+1)]
    m1=0
    m2=0
    m3=0
    for i in range(1,N+1):
        if d1[i]%2==0:
            if m1<len(M1):
                ans[i]=M1[m1]
                m1+=1
            else:
                ans[i]=M3[m3]
                m3+=1
        else:
            if m2<len(M2):
                ans[i]=M2[m2]
                m2+=1
            else:
                ans[i]=M3[m3]
                m3+=1
    print(*ans[1:])


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

using namespace std;
int n,m,s,t;
vector<int> rad[100005];
int dp[100005];
int vdp[3][100005];

struct tor{
    int n,c,t;
    tor(int nn,int cc,int tt){
        n = nn;c = cc;t = tt;
    }
};
queue<tor> que;

void dfs(int now,int cnt,int toq)
{
    if(toq!=0)
    {
        if(vdp[toq][now]<=cnt) return;
        vdp[toq][now] = cnt;
        for(int i=0;i<rad[now].size();++i)
        {
            //dfs(rad[now][i],cnt,toq-1);
            que.push(tor(rad[now][i],cnt,toq-1));
        }
        return;
    }

    if(dp[now]<=cnt) return;
    dp[now] = cnt;
    for(int i=0;i<rad[now].size();++i)
    {
        //dfs(rad[now][i],cnt+1,2);
        que.push(tor(rad[now][i],cnt+1,2));
    }
}

int main()
{
    scanf("%d%d",&n,&m);
    int u,v;
    memset(dp,0x3f,sizeof(dp));
    memset(vdp,0x3f,sizeof(vdp));

    for(int i=0;i<m;++i)
    {
        scanf("%d%d",&u,&v);
        rad[u].push_back(v);
    }

    scanf("%d%d",&s,&t);

    que.push(tor(s,0,0));
    while(!que.empty())
    {
        tor now = que.front();
        que.pop();
        dfs(now.n,now.c,now.t);
    }
    if(dp[t]==dp[n+1])printf("-1\n");
    else printf("%d\n",dp[t]);
    return 0;
}


Measured memory_bytes: 7296
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    System.out.println(a+b+c < 22 ? "win" : "bust");
    sc.close();
  } 
}


Measured memory_bytes: 21844
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
#include <ctype.h>
int main() {
	int n;
	cin >> n;
	int bo = 0;
	for (int i = 3; i <= n; ++i) {
		int ans = 0;
		if(i % 2 == 1)
		for (int q = 1; q <= i; ++q) {
			if (i % q == 0) {
				ans++;
			}
		}
		if (ans == 8) {
			bo++;
		}
	}
	cout << bo << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    int a, b;
    cin >> a >> b;
    ((a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) ? (puts("Possible")) : (puts("Impossible")));
    return 0;
}

Measured memory_bytes: 256
MAX = 2000
MOD = 10**9+7

fac = [0] * (MAX+1)
finv = [0] * (MAX+1)
inv = [0] * (MAX+1)

def comb_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX+1):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD


if __name__ == '__main__':
    n, k = map(int, input().split())
    comb_init()
    for i in range(1, k+1):
        print(comb(n-k+1, i) * comb(k-1, i-1) % MOD)


Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
int a[2];
int main()
{
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]!=a[1] && a[0]!=a[2]) cout<<a[0]<<endl;
	if(a[1]!=a[0] && a[1]!=a[2]) cout<<a[1]<<endl;
	if(a[2]!=a[0] && a[2]!=a[1]) cout<<a[2]<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3
    ^lb   ^ub */
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont,from,to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
int N;
string s;
int main() {
    int c=0;
    cin >> N >> s;
    REP(i,N)
        if (s[i]=='R')
            c++;
        else
            c--;
    if (c>0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n,x;
cin >> n >> x;
ll m[n];
for (ll i = 0; i < n; i++) cin >> m[i];
sort(m, m + n);
for (ll i = 0;i<n;i++){
    x -= m[i];
}
ll ans = n + x / m[0];
cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <bits/stdc++.h>
#define scan(n)      scanf("%I64d",&n);
#define scan2(a,b)   scanf("%I64d%I64d",&a,&b);
#define scan3(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c);
#define sc(n)        scanf("%c",&n);
#define sf(n)        scanf("%lf",&n);
#define ss(n)        scanf("%s",n);
#define forall(i,a,b)for(long long int i=a;i<b;i++)
#define all(a)       a.begin(), a.end()
#define pb           push_back
#define mp           make_pair
#define FAST_IO      ios_base::sync_with_stdio(false); cin.tie(NULL);
#define minimum(a)   *min_element(a.begin(),a.end())
#define maximum(a)   *max_element(a.begin(), a.end())
#define display(a)   for(auto i : a) cout<<i<<" ";
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
using namespace std;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<ll> scanVector(ll n, vector<ll> &v)
{
  ll temp;
  for(ll i = 0; i < n ; i++)
  {
     cin>>temp;
     v.pb(temp);
  }
  return v;
}

int main() {
    FAST_IO
    ll t;
    //cin>>t;
    t = 1;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a1,b1,c1;
        vector<ll> a;
        vector<ll> b;
        vector<ll> c;
        for(ll i = 1; i <=n ; i++)
        {
            cin>>a1>>b1>>c1;
            a.pb(a1);
            b.pb(b1);
            c.pb(c1);
        }
        ll dp[n][3];
        dp[0][0] = a[0];
        dp[0][1] = b[0];
        dp[0][2] = c[0];
        for(ll i = 1; i <n; i++)
        {
            dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
            dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
            dp[i][2] = c[i] + max(dp[i-1][1],dp[i-1][0]);
        }
        cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
    }
    return 0;
}

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

int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
    if((a+b+c)%2==1){
		int max=0;
		max=std::max({a,b,c});
		int d=0;
		d=(max*2-(a+b+c-max))/2;
		if(max%2==0)d+=2;
		printf("%d\n",d);
	}else{
		int max=0;
		max=std::max({a,b,c});
		if(max%2==0){
		int d=0;
		d=(max*2-(a+b+c-max))/2;
		printf("%d\n",d);
		}else{
		int d=0;
		d=((max+1)*3-(a+b+c))/2;
		printf("%d\n",d);		
		}
	}
/*
for(int i=1;i<=x;i++){
	ans++;
	plus+=i;
	if(plus>=x)break;
}
printf("%d\n",ans);
*/
	
//	printf("%lld\n",ans);
}

Measured memory_bytes: 256
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

######
# URL: https://atcoder.jp/contests/abc106/tasks/abc106_b
######

def main():
    n = i_inpl()
    ans = 0
    for i in range(1, n+1):
        if i % 2 == 0:
            continue
        tmp = 1
        for j in range(2, n+1):
            if i % j == 0:
                tmp += 1
        if tmp == 8:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 38768
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <vector>
 
using namespace std;
 
int64_t calc_expect(int p)
{
    int64_t sum = 0;
    for (int i = 1; i <= p; i++) {
        sum += i;
    }
    return (int64_t)((double)sum / p * 2);
}
 
int main()
{
    int n, k;
    cin >> n >> k;
    int *p = new int[n];
    map<int, int64_t> expect;
 
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        if (expect.count(p[i]) == 0) {
            expect[p[i]] = calc_expect(p[i]);
        }
    }
 
    int64_t *e = new int64_t[k];
    int64_t now_e = 0;
    int64_t max_e = 0;
 
    for (int i = 0; i < k; i++) {
        e[i] = expect[p[i]];
        now_e += e[i];
    }
    max_e = now_e;
    for (int i = k; i < n; i++) {
        int64_t tmp = e[i%k];
        e[i%k] = expect[p[i]];
        if (tmp > e[i%k]) {
            now_e -= (tmp - e[i%k]);
        }
        else {
            now_e += (e[i%k] - tmp);
        }
        if (max_e < now_e) {
            max_e = now_e;
        }
    }
    printf("%.10f\n", (double)max_e / 2);
 
    delete[] e;
    delete[] p;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main(){
  int N,X; cin>>N>>X;
  int sum=0,min=2000;
  int m[N];
  for(int i=0;i<N;i++){
    cin>>m[i]; 
    if(m[i]<min) min=m[i];
    sum+=m[i];
  }
  int ans=N+(X-sum)/min;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 764
a, b = map(int,input().split())

def main(_old, _fee):
    if int(_old) >= 13:
        return int(_fee)
    elif 6 <= int(_old) <= 12:
        return int(_fee) // 2
    else:
        return 0

if __name__ == '__main__':
    print(main(a, b))

Measured memory_bytes: 3060
import sys
input=sys.stdin.readline
import copy
def knapsack(N,W,weight,value):
  dp=[[999999999999 for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=0
 
  for i in range(N):
    for w in range(W+1):
      if weight[i]<=w:
        if dp[i][w-weight[i]]+value[i]>dp[i][w]:
          dp[i+1][w]=dp[i][w-weight[i]]+value[i]
        else:
          dp[i+1][w]=dp[i][w]
      else:
        dp[i+1][w]=dp[i][w]
  return dp
 
n,t=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
a=[];b=[]
for i in range(n):
  a.append(l[i][0])
  b.append(l[i][1])
dp=knapsack(n,t-1,a,b)
ans=[]
for i in range(n):
  if i!=n:
    ans.append(dp[i][t-1]+b[i])
  else:
    ans.append(dp[n][t-i])
print(max(ans))

Measured memory_bytes: 121180
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a>=-100&&a<=100)&&(b>=-100&&b<=100)&&(b>=-100&&b<=100)&&(a==b&&b==c&&a==c))
        printf("Yes\n");
    else if((a>=-100&&a<=100)&&(b>=-100&&b<=100)&&(b>=-100&&b<=100)&&(c>a&&c<b))
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <map>
#include <set>
#include <list>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int>v[100005]; 
int get_sg(int u,int pre){ 
    int ret=0; 
    for(int i=0;i<v[u].size();i++){ 
        if(v[u][i]!=pre) 
            ret^=(1+get_sg(v[u][i],u)); 
    } 
    return ret; 
} 
int main(){ 
    int n;
    scanf("%d",&n); 
    for(int i=1;i<=n;i++) v[i].clear(); 
    for(int i=1;i<n;i++){ 
    	int x,y; 
        scanf("%d%d",&x,&y); 
        v[x].push_back(y); 
        v[y].push_back(x); 
    } 
    if(get_sg(1,-1)) puts("Alice"); else puts("Bob"); 
    return 0; 
} 
/*
Sample Input 1
5
1 2
2 3
2 4
4 5
Sample Output 1
Alice
Sample Input 2
5
1 2
2 3
1 4
4 5
Sample Output 2
Bob
Sample Input 3
6
1 2
2 4
5 1
6 3
3 2
Sample Output 3
Alice
Sample Input 4
7
1 2
3 7
4 6
2 3
2 4
1 5
Sample Output 4
Bob
*/

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

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, int> psi;
typedef pair<string, ll> psl;
typedef pair<pii, int> tri;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<tri> viii;
 
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef map<string, int> msi;
typedef map<string, vi> msv;
typedef unordered_map<int, int> umap;
typedef unordered_map<ll, ll> umapl;
typedef priority_queue<int> pq;

#define fi(i,a,b) for(auto i=a;i<b;i++)
#define fd(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ss second
#define ff first
#define sz(a) a.size()
#define cini(a) int a; cin >> a;
#define cinii(a, b) int a, b; cin >> a >> b;
#define ciniii(a, b, c) int a, b, c; cin >> a >> b >> c;
#define cinl(a) ll a; cin >> a;
#define cinll(a, b) ll a, b; cin >> a >> b;
#define cinlll(a, b, c) ll a, b, c; cin >> a >> b >> c;
#define cinc(c) char c; cin >> c;
#define cins(s) string s; cin >> s;
#define cinss(s1, s2) string s1, s2; cin >> s1 >> s2;
#define cinvi(v, n) vi v(n, 0); fi(i, 0, n) cin >> v[i];
#define cinvl(v, n) vl v(n, 0); fi(i, 0, n) cin >> v[i];
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define flush fflush(stdout)

#define print(v) for (auto it = v.begin(); it != v.end(); ++it) cout << *it << ' '; cout << endl;
#define print2(v) for (auto it = v.begin(); it != v.end(); ++it) cout << *it << endl;
#define printmap(m) for (auto it = m.begin(); it != m.end(); ++it) cout << it->first<<' '<<it->second << endl; cout << endl;
#define disparr(arr,n) for(ll i=0;i<(n);++i)   cout<<arr[i]<<' ';  cout<<endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

#define LC(i) 2*(i)+1
#define RC(i) 2*(i)+2
#define MID(i,j) ((i)+(j))/2
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))

#define nn "\n"
#define sp << " " <<
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const int MOD = 1000000007;
const ll INF = 1e18;
const ld PI=3.141592653589793238462643383279502884197169399375105820974944;

int main()
{
	fastio; //Remove for interactive problems

	cini(n);
	cins(stones);

	int ans = 0, count = 0;
	fi(i, 0, n)
	{
		if(stones[i] == 'R')
			count++;
	}
	int already = 0;
	fi(i, 0, count)
	{
		if(stones[i] == 'R')
			already++;
	}

	ans = count-already;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3768