akhauriyash/Code-Regression huggingface dataset:
/*
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;
 
signed main()
{
    tezz
    
    int n;
    cin>>n;

    string s;
    cin>>s;

    int l = s.length();
    for(int i=0;i<l;i++){
        s[i] = ((s[i] + n - 'A') % 26 + 'A');
    }

    cout<<s;
} 

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <functional>
#include <set> 
#include <map> 

using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)

signed main()
{
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b)*h / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>

using namespace std;
const double PI (acos(-1));


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

  if(s[0] == s[1] && s[0] == s[2])
  {
    cout << "No";
  }else
  {
    cout << "Yes";
  }
  


  }


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	cin >> n;
	vector<pair<string, int>> a = {{"AC", 0}, {"WA", 0}, {"TLE", 0}, {"RE", 0}, };
	for (int i = 0; i < n; i++) {
		cin >> s;
		for (int j = 0; j < 4; j++) {
			if (a[j].first == s) {
				a[j].second++;
				break;
			}
		}
	}
	for (int i = 0; i < 4; i++) {
		cout << a[i].first << " x " << a[i].second << '\n';
	}
	return 0;
}


Measured memory_bytes: 3648
def main():
    S = input()
    y, m, d = map(int, S.split('/', 2))
    
    if y < 2019:
        print('Heisei')
    elif y > 2019:
        print('TBD')
    else: # 2019
        if m < 4:
            print('Heisei')
        elif m > 4:
            print('TBD')
        else: # 2019/04
            if d <= 30:
                print('Heisei')
            else:
                print('TBD')

main()

Measured memory_bytes: 3060
n = int(input())
dp = [0 for i in range(n)]
a = [1]
i = 1
_ = 6
while _ <= n:
    a.append(_)
    i += 1
    _ = 6 ** i
i = 1
_ = 9
while _ <= n:
    a.append(_)
    i += 1
    _ = 9 ** i
len_a = len(a)
for i in range(n):
    target = []
    for j in range(len_a):
        if i + 1 >= a[j]:
            target.append(dp[i - a[j]])
    dp[i] = min(target) + 1
print(dp[n-1])

Measured memory_bytes: 3864
#include <stdio.h>
int main(void)
{
    int a, b, d, r;
    double f;
    
    scanf("%d %d",&a ,&b);
    
    d = a/b;
    r = a%b;
    f = (double)a/(double)b;
    
	printf("%d %d %.8f\n",d ,r ,f);

    return 0;
}

Measured memory_bytes: 640
def selectionSort(A, N):
    count = 0
    for i in xrange(N):
        minj = i
        cflag = 0
        for j in xrange(i, N):
            if A[j] < A[minj]:
                minj = j
                cflag = 1
        A[i], A[minj] = A[minj], A[i]
        count+=cflag
    return count

# MAIN
N = input()
A = map(int, raw_input().split())
c = selectionSort(A, N)
print " ".join(map(str, A))
print c

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    string s;
    cin >> s;

    map<char, int> ms;
    rep(i, s.size()){
        ms[s[i]]++;
    }

    bool ok = true;
    for (auto& p : ms) {
        if(p.second % 2 == 1){
            ok = false;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}

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

int main() {
    int n; cin >> n;
    set <string> a;
    for(int i = 0; i < n; i++) {
        string x; cin >> x;
        a.insert(x);
    }

    cout << a.size();
    return 0;
}

Measured memory_bytes: 19256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<cmath>
#include<functional>
using namespace std;

int main(){
    long N, H;
    cin >> N >> H;
    vector<long> A(N);
    vector<long> B(N);
    for(long i=0; i<N; i++){
        cin >> A.at(i) >> B.at(i);
    }
    auto amax = max_element(A.begin(), A.end());
    sort(B.begin(), B.end(), greater<long>());
    long c = 0;
    long r = 0;
    for(auto i=B.begin(); i<B.end(); i++){
        if (*amax >= *i){
            break;
        }
        c += *i;
        r++;
        if(c >= H){
            break;
        }
    }
    if(c < H){
        r += long(ceil(double(H-c)/ double(*amax)));
    }
    cout << r << endl;
}


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

using namespace std;

int main() {
    int c_size = 26;

    int d;
    cin >> d;

    vector<int> c(c_size);
    for (int i = 0; i < c_size; i++) {
        cin >> c[i];
    }

    vector<vector<int>> s(d, vector<int>(c_size));
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < c_size; j++) {
            cin >> s[i][j];
        }
    }

    vector<int> t(d);
    for (int i = 0; i < d; i++) {
        cin >> t[i];
        t[i]--;
    }

    int res = 0;
    vector<int> last(c_size, -1);
    for (int i = 0; i < d; i++) {
        last[t[i]] = i;
        res += s[i][t[i]];
        for (int j = 0; j < c_size; j++) {
            res -= c[j] * (i - last[j]);
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string S, T;
    cin >> S >> T;
    int ans = 0;
    REP(i, S.size()) if(S[i] != T[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;

signed main(){
    int n; cin>>n;
    cout<<n*(n-1)/2-n/2<<endl;
    for(int i=1; i<=n-1; i++){
        for(int j=1; i+j<=n; j++){
            if(!((n%2==0 and i*2+j==n+1) or (n%2==1 and i*2+j==n))){
                cout<<i<<' '<<i+j<<endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	long long int n,sum=0;
	scanf("%lld",&n);
		for(int i=1;i<=n;i++){
		if(i%3 == 0 && i%5 ==0) continue;
		else if(i%3==0) continue;
		else if(i%5==0) continue;
		sum += i;
		}
			printf("%lld\n",sum);
 	return 0;
}

Measured memory_bytes: 3180
// Author:: MOHAMMAD FAISAL
"use strict";

const main = (input) =>{
  	
  const arr = input.trim().split("\n");
  let n = parseInt(arr[0]);
  let s = arr[1];
  
  
  if(s.length <= n)
    console.log(s);
  else{
    let start = s.substr(0,n);
    console.log(start+"...");
  }
};

main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 29596
import java.util.Arrays;
import java.util.Scanner;

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

		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}

		long[] b = new long[n];
		Arrays.fill(b, Long.MAX_VALUE);
		b[0] = 0;

		for (int i = 0; i < k - 1; i++) {
			b[0] += Math.abs(a[i + 1] - a[i]);
		}
		for (int i = 1; i + k - 1 < a.length; i++) {
			b[i] = b[i - 1] + Math.abs(a[i + k - 1] - a[i + k - 2]) - Math.abs(a[i] - a[i - 1]);
		}

		long answer = Long.MAX_VALUE;
		for (int i = 0; i + k - 1 < a.length; i++) {
			if (a[i + k - 1] < 0) {
				// - -
				answer = Math.min(answer, b[i] + Math.abs(a[i + k - 1]));

			} else if (a[i] < 0) {
				// - +
				answer = Math.min(answer, b[i] + Math.min(Math.abs(a[i + k - 1]), Math.abs(a[i])));
			} else {
				// + +
				answer = Math.min(answer, b[i] + Math.abs(a[i]));
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 49832
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif


template<long long mod>
class modint{
	public:
		long long x;
		modint(long long a){x=a%mod;if(x<0)x+=mod;}
		modint(){x=0;}

		modint pow(long long a){
			modint res(1), b(x);
			while(a){
				if(a&1)res*=b;
				b*=b;
				a>>=1;
			}
			return res;
		}

		modint inv(){return pow(mod-2);}

		modint& operator+=(modint a){x=(x+a.x)%mod;return *this;}
		modint& operator-=(modint a){x=x-a.x;if(x<0)x+=mod;return *this;}
		modint& operator*=(modint a){x=x*a.x%mod;return *this;}
		modint& operator/=(modint a){x=x*a.inv().x%mod;return *this;}

		modint operator+(modint a){return modint(x)+=a;}
		modint operator-(modint a){return modint(x)-=a;}
		modint operator*(modint a){return modint(x)*=a;}
		modint operator/(modint a){return modint(x)/=a;}

		modint operator-(){return modint(x);}

		bool operator==(const modint a){return x == a.x;}
		bool operator<(const modint a){return x < a.x;}
		bool operator>(const modint a){return x > a.x;}
};

template<long long mod>
ostream& operator<<(ostream& os, const modint<mod>& a){
	os << a.x;
	return os;
}


ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

using mint = modint<MOD>;
int n;

mint factorial(ll x){
	static vector<mint> memo;
	if(memo.empty()){
		const int N = n + 5;
		memo.resize(N);
		memo[1] = mint(1);
		repa(i,N-1){
			memo[i+1] = mint(i+1) * memo[i];
		}
	}
	if(x<=1)return mint(1);
	return memo[x];
}

vector<mint> input(int n){
	vector<mint> slime(n);
	foreach(i,slime){
		int d;
		cin >> d;
		i.x = d;
	}
	reverse(all(slime));

	repa(i,n){
		slime[i] = slime[0] - slime[i];
	}
	slime[0] = 0;
	return slime;
}
int main(){
	cin >> n;

	vector<mint> slime = input(n);
	
	mint ans(0);
	mint sum(1);

	for(int i=n-1;i>0;--i){
		ans += (slime[i]-slime[i-1]) * sum;
		sum += mint(n-i+1).inv();
	}

	cout << ans * factorial(n-1) << endl;

	return 0;
}



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

int main() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,s.size()){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong w,h,x,y;
    double s;
    cin >> w >> h >> x >> y;
    s = (double)(w*h)/2;
    cout << fixed << setprecision(6) << s << " ";
    // if(x == y) if(w == h) if(x!=0 || x!=w){
    //     cout << 1 << endl;
    //     return 0;
    // }
    if(w%2 == 0 && h%2 == 0) if(w/2 == x && h/2 == y){
        cout << 1 << endl;
        return 0;
    }
    cout << 0 << endl;
    return 0;
}

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

M,D = map(int,input().split())

ans =0
for i in range(4,M+1):
    for j in range(22,D+1):
        j_s = str(j)
        if(int(j_s[0])>=2 and int(j_s[1])>=2):

            if((int(j_s[0]) * int(j_s[1])) == i):
                ans +=1

print(ans)

Measured memory_bytes: 40048
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



////////////////////////////////////////

bool asc(const ll a,const ll b){
    return a>b;
}

int main(){
    ll n,w;cin>>n>>w;
    vector <ll>a[4];
    ll w1,v1;cin>>w1>>v1;
    a[0].push_back(v1);
    for(int i=1;i<=n-1;i++){
        ll ww,vv;cin>>ww>>vv;
        a[ww-w1].push_back(vv);
    }
    for(int i=0;i<=3;i++){
        sort(a[i].begin(),a[i].end(),asc);
    }
    ll b[4][100],size[4];
    for(int i=0;i<=3;i++){
        b[i][0]=0;
        size[i]=a[i].size();
        for(int j=1;j<=size[i];j++){
            b[i][j]=b[i][j-1]+a[i][j-1];
        }
    }
    ll ans=0;
    for(int i=0;i<=size[0];i++){
        for(int j=0;j<=size[1];j++){
            for(int k=0;k<=size[2];k++){
                if(w-i*w1-j*(w1+1)-k*(w1+2)>=0){
                    ll an=b[0][i]+b[1][j]+b[2][k];
                    ll kosuu=(w-i*w1-j*(w1+1)-k*(w1+2))/(w1+3);
                    if(kosuu>=size[3])kosuu=size[3];
                    an+=b[3][kosuu];
                    /*cout<<i<<" "<<j<<" "<<k<<" "<<kosuu<<"  "<<an<<endl;*/
                    if(an>ans)ans=an;
                }
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/abc106/tasks/abc106_d>
 問題文============================================================
 =================================================================
 解説=============================================================
 (L,R)がきたら、G[L].push_back(R)みたいにしてソート
 あとはクエリきたらp<=x<=qのxに対してG[x]が持つq以下の値の個数の総和がクエリの答え。
 
 G[x]に対して upper_bound(all(G),q) - G[x].begin()で個数求まるから
 かなり多めに見積もってもO(NQlogM/N)で溶ける
 ================================================================
 */
ll solveD(){
    ll res = 0;
    ll N,M,Q; cin >> N >> M >> Q;
    vector<ll> L(M),R(M);
    vector<vector<ll>> G(N);
    for(int i = 0; i < M;i++){
        cin >> L[i] >> R[i]; L[i]--; R[i]--;
        G[L[i]].push_back(R[i]);
    }
    for(int i = 0; i < N;i++){
        sort(G[i].begin(),G[i].end());
    }
    while(Q--){
        ll p,q; cin >> p >> q;
        p--; q--;
        
        ll Ans = 0;
        for(ll x = p; x <= q;x++){
            Ans += (upper_bound(G[x].begin(), G[x].end(), q) - G[x].begin());
        }
        cout << Ans << endl;
    }
    return 0;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solveD();
    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll n;
    cin >> n;
    ll a = 1;
    for(ll i=1; i*i<=n; i++){
        if(n%i == 0) a = i;
    }
    cout << a + n/a - 2 << endl;
    return 0;
}


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

using namespace std;

int main() {
    string A, B, C;

    cin >> A >> B >> C;

    if (A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

inline bool Is_sqr(int n) {
	bool flg = false;

	for (int i = sqrt(n); i >= 1; i--)
	{
		if (i*i == n) {
			flg = true;
			break;
		}
	}

	return flg;
}

int main() {
	int n;
	int ans;
	cin >> n;

	for (int i = n; i >= 1; i--)
	{
		if (Is_sqr(i)) {
			ans = i;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
   	public long knapsack(int n, int w, int[] weights, long[] values) {
        long[][] memo = new long[n][w + 1];
        for (long[] row: memo) {
            Arrays.fill(row, -1);
        }
        return dfs(weights, values, w, 0, 0, memo);
    }
	private long dfs(int[] weights, long[] values, int maxCapacity, int currPosition, int currWeight, long[][] memo) {
        int n = weights.length;
        if (currPosition >= n) {
            return 0;
        }
        if (memo[currPosition][currWeight] != -1) {
            return memo[currPosition][currWeight];
        }
        long maxVal = 0;
        long take = 0;
        if (currWeight + weights[currPosition] <= maxCapacity) {
            take = values[currPosition] + dfs(weights, values, maxCapacity, currPosition + 1, currWeight + weights[currPosition], memo);
        }
        long skip = dfs(weights, values, maxCapacity, currPosition + 1, currWeight, memo);
        return memo[currPosition][currWeight] = Math.max(take, skip);
    }

    public static void main(String[] args)  {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String[] split = br.readLine().split(" ");
            int n = Integer.parseInt(split[0]);
            int w = Integer.parseInt(split[1]);
          	int[] weights = new int[n];
          	long[] values = new long[n];
            for (int i = 0; i < n; i++) {
                split = br.readLine().split(" ");
                weights[i] = Integer.parseInt(split[0]);
                values[i] = Long.parseLong(split[1]);
            }
          	Main app = new Main();
            long result = app.knapsack(n, w, weights, values);
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


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

int main(){
    int N;
    string S;
    cin >> N >> S ;
    if(N % 2 == 1){
        cout << "No\n";
        return 0 ;
    }else{
        for(int i = 0 ; i < N / 2 ; i++){
            if(S[i] != S[i + N/2]){
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
  vin a(5);
  rep(i,5) cin>>a[i];
  int ans=0;
  int mn=10;
  rep(i,5){
   ans+=(a[i]+9)/10*10;
    if(a[i]%10!=0)
    mn=min(mn,a[i]%10);
    //cout<<ans<<endl;
  }
  cout<<ans-10+mn<<endl;
 
  
}

Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
-----------------------
local N, K = read.nn()
local P = read.N(N)
table.sort(P)
local s = 0
for i=1,K do
    s = s + P[i]
end
print(s)

Measured memory_bytes: 2972
program incremental_scoring
  implicit none
  integer :: d, c(26) = 0, s(26, 365) = 0, t(365) = 0, m, p, q, i
  read(*,*) d
  read(*,*) c
  read(*,*) (s(:, i), i = 1, d)
  read(*,*) (t(i), i = 1, d)
  read(*,*) m
  do i = 1, m
    read(*,*) p, q
    t(p) = q
    write(*,'(i0)') score()
  end do
contains
  integer function score() result(res)
    integer :: last(26), i
    last = 0
    res = 0
    do i = 1, d
      last(t(i)) = i
      res = res + s(t(i), i) - sum(c * (i - last))
    end do
  end
end program incremental_scoring

Measured memory_bytes: 2868
// Ballazt
//0a..brute force
//0b..greedy
//1..memorizatton of some sort	remember something cleverly
//2..sort
//3..binary search	keep check a particular solution
//4..dp				repeating strucutre,limited choices
//5..dfs/bfs		matrix with obstacles
//6..correlate to graph in some way		each state is a point
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"


int main()

{
	ios::sync_with_stdio(0);
	cin.tie(0);

	
	int n;
	cin>>n;

	set<string> st;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		st.insert(s);

	}

	cout<<st.size();

	
	return 0;

	
}

Measured memory_bytes: 19248
s = input()

f1 = False
f2 = False
f3 = False

if s[0] == "A":
    f1 = True

s2 = s[2:-1:]
found = s2.find("C")
if found != -1:
    s2 = s2.replace("C", "", 1)
found2 = s2.find("C")
if found >= 0 and found2 == -1:
    f2 = True
if f1 and f2:
    s = s.replace("A", "").replace("C", "")

if s.islower():
    f3 = True
if f1 and f2 and f3:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

constexpr double PI = 3.1415926535;
int main(int argc, char const *argv[]) {
    double r; cin>>r;
    double ans = r*2*PI;
    cout << ans << '\n';    
    return 0;
}

Measured memory_bytes: 3752
import sys
from collections import deque
sys.setrecursionlimit(10**7)

n = int(input())
graph = {i : [] for i in range(n)}
ls = []
for i in range(n-1):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    ls.append((a,b))
    graph[a].append(b)
    graph[b].append(a)
_max = 0
_max_node = None
for k, v in graph.items():
    if len(v) > _max:
        _max = len(v)
        _max_node = k

parent = [_max_node] * (n)
order = []
stack = [_max_node]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

colors = [-1 for i in range(n)]
for i in order:
    c = 1
    for _next in graph[i]:
        if _next == parent[i]:
            continue
        if c == colors[i]:
            c += 1
        colors[_next] = c
        c += 1
print(_max)
for a, b in ls:
    if parent[a] == b:
        print(colors[a])
    else:
        print(colors[b])

Measured memory_bytes: 40956
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int N;
	cin >> N;
	ll count = 0;
	repd(i,1,N+1) if(i%3!=0 && i%5!=0) count += i;
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int inf = 1e9;

template <class T>
istream& operator>>(istream& ss, vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss >> v[i];
    return ss;
}

template <class T> 
ostream& operator<<(ostream& ss, const vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss << v[i] << ' ';
    return ss;
}

ll binpow(ll a, ll n, ll m) {
    ll res = 1;
    while (n) {
        if (n & 1) {
            res *= a;
            res %= m;
        }
        a *= (a % m);
        a %= m;
        n >>= 1;
    }
    return res % m;
}

ll gcd(ll a, ll b) {
    return b ? gcd (b, a % b) : a;
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a,b);
}

void solve() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.size() <= k) cout << s;
    else cout << s.substr(0, k) << "...";
}

int main() {
    speed;
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000001, n, k, w[200], c[200], dp[101][100001], ans, sum, minn = 1000000001;
int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i ++){
		cin >> w[i] >> c[i];
		minn = min (minn, c[i]);
		sum += c[i];
	}
	dp[0][0] = 0;
	for (int i = 0; i <= n; i ++)
	{
		for (int j = 1; j <= sum; j ++)
			dp[i][j] = INF;
	}	
	for (int i = 1; i <= n; i ++)
	{
		for (int j = 1; j <= sum; j ++)
		{
			if (j >= minn)
			{
				if (j - c[i] >= 0 && dp[i-1][j-c[i]] != INF)
					dp[i][j] = min (dp[i][j], dp[i-1][j - c[i]] + w[i]);
				if (dp[i-1][j] != INF && dp[i-1][j])	
					dp[i][j] = min (dp[i][j], dp[i-1][j]);	
			}
		}
	}	
		
	for (int i = 1; i <= sum; i ++)
	{
		if (dp[n][i] != INF && dp[n][i] <= k)
			ans = i;
	}	
	cout << ans;	
}

Measured memory_bytes: 79104
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef pair<int,P> PP;
string s[1005];
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int dis[1005][1005];
signed main(){
    int h,w;cin>>h>>w;
    for(int i=0;i<h;i++)cin>>s[i];
    queue<PP>Q;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#')Q.push(PP(0,P(i,j)));
            else dis[i][j]=1e7;
        }
    }
    while(Q.size()){
        PP p=Q.front();Q.pop();
        int vr=p.second.first,vc=p.second.second;
        if(dis[vr][vc]<p.first)continue;
        for(int i=0;i<4;i++){
            int nr=vr+dx[i],nc=vc+dy[i];
            if(0<=nr&&nr<h&&0<=nc&&nc<w&&dis[nr][nc]==1e7){
                dis[nr][nc]=dis[vr][vc]+1;
                Q.push(PP(dis[nr][nc],P(nr,nc)));
            }
        }
    }
    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans=max(ans,dis[i][j]);
        }
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 25524
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
	int n, a, b, c, d, ans = 1000000;
	cin >> n >> a >> b >> c >> d;
	--a;
	--b;
	--c;
	--d;
	for(int i = 1; i <= n; ++i){
		int t = abs(a/i - b/i) + abs(a%i - b%i);
		int u = abs(c/i - d/i) + abs(c%i - d%i);
		ans = min(ans, t + u);
	}
	cout << ans << endl;
}

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

typedef long long ll;

const int INF = 100000000;

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

    int cnt = 0;
    char word = ' ';
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '1') {
            cnt++;
        } else {
            word = S[i];
            break;
        }
    }

    if (word == ' ') {
        cout << 1 << endl;
    } else {
        if (K <= cnt) {
            cout << 1 << endl;
        } else {
            cout << word << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()
t = [0]*(n+1)
for i in range(n):
    t[i+1] = t[i]+(1 if s[i:i+2] =="AC"else 0)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])

Measured memory_bytes: 9540
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;


int main(){
    string s,t,u; cin>>s>>t>>u;
    s[0]=char(s[0]-32);
    cout<<s[0];
    t[0]=char(t[0]-32);
    cout<<t[0];
    u[0]=char(u[0]-32);
    cout<<u[0]<<endl;

}








Measured memory_bytes: 256
N,M = map(int,input().split())
ks = [list(map(int,input().split())) for _ in range(M)]
p = list(map(int,input().split()))

ans = 0
sw = [0] * N
for i in range(2 ** N):
    state = [0] * M
    S = list(bin(i))
    S = S[2:]
    while len(S) < N:
        S = ['0'] + S
    
    for j in range(N):
        sw[j] = int(S[N-1-j])
    for j in range(M):
        cnt = 0
        for k in ks[j][1:]:
            if sw[k-1] == 1:
                cnt += 1
        if cnt % 2 == p[j]:
            state[j] = 1
            
    if not(0 in state):
        ans += 1
    
print(ans)
        
        
        
    
    


Measured memory_bytes: 3064
N, K = map(int, input().split())
import numpy as np
A = np.array(input().split(), dtype=int)
I = np.arange(0, N)
for i in range(K):
  X = np.zeros(N + 1, int)
  np.add.at(X, np.maximum(0, I - A), 1)
  np.add.at(X, np.minimum(N, I + A + 1), -1)
  A = X.cumsum()[:-1]
  if np.all(A == N):
    break
print(*A)

Measured memory_bytes: 50188
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	s := sc.Text()
	tmp := strings.Split(s, " ")
	input := mapInt(tmp)
	calc := []int{0, 0, 0}
	for n, cnt := input[3], 0; cnt < 3; cnt++ {
		if n - input[cnt] <= 0 {calc[cnt] = n; break}
		calc[cnt] = input[cnt]
		n -= input[cnt]
	}
	total := calc[0] * 1 + calc[1] * 0 + ((calc[2] * 1) * -1)
	fmt.Println(total)
}

func mapInt(input []string) []int {
	r := make([]int, len(input))
	for i, e := range input {
		r[i], _ = strconv.Atoi(e)
	}
	return r
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/
ll N,A,B;
vector<ll> X;

int main(){
    cin >> N >> A >> B;
    X.resize(N);
    rep(i,N) cin>>X[i];

    ll ans = 0;
    for(int i=1;i<N;i++){
        ans += min(B,(X[i]-X[i-1])*A);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1152
/** ------------------------------------------------------------------------ **/
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

template<typename T> using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> using ordered_map =
tree<T1, T2, less<T1>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using hash_set = gp_hash_table<T, null_type>;
template<typename T1, typename T2> using hash_map = gp_hash_table<T1, T2>;

mt19937 rng(time(nullptr));
mt19937_64 rng64(time(nullptr));

#define rep(i, s, t) for (int i = s; i < int(t); ++i)
#define for_iter(i, c) for (auto i = c.begin(); i != c.end(); ++i)
#define for_const_iter(i, c) for (auto i = c.cbegin(); i != c.cend(); ++i)

#define sc	scanf
#define pr	printf
#define ff	first
#define ss	second
#define mp	make_pair
#define pb	push_back
#define eb	emplace_back
#define range(c)	c.begin(), c.end()
#define const_range(c)	c.cbegin(), c.cend()
#define lowbit(x)	((x) & -(x))
#define pop_count	__builin_popcount
#define pop_count64	__builtin_popcountll
#define tail_count	__builtin_ctz
#define tail_count64	__builtin_ctzll
#define lead_count	__builtin_clz
#define lead_count64	__builtin_clzll

template<typename T1, typename T2>
ostream& operator<< (ostream& os, const pair<T1, T2>& p) {
	return os << "<" << p.ff << "," << p.ss << ">";
}
#define container_ostream(container)				\
template<typename... T>						\
ostream& operator<< (ostream& os, const container<T...>& c) {	\
	if (c.empty()) return os << "{ }";			\
	auto iter = c.cbegin();					\
	os << "{ " << *iter;					\
	while (++iter != c.cend()) os << ", " << *iter;		\
	return os << " }";					\
}
container_ostream(vector)
container_ostream(set)
container_ostream(map)

void dbg() { cerr << endl;}
template<typename Head, typename... Tail> void dbg(Head h, Tail... t) {
	cerr << " " << h;
	dbg(t...);
}

#ifdef LOCAL
#define debug(...) cerr << "[ "#__VA_ARGS__" ] :", dbg(__VA_ARGS__)
#else
#define debug(...) 0
#endif

typedef long long i64;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

constexpr const int mod = 998244353;
constexpr int mul(int a, int b) { return 1LL * a * b % mod; }
#define more_para(type, func) \
template<typename... T> constexpr type func(type a, type b, T... c) { return func(func(a, b), c...); }
more_para(int, mul)
constexpr int square(int a) { return mul(a, a); }
constexpr int fpow(int a, int b) { return b ? mul(b & 1 ? a : 1, square(fpow(a, b >> 1))) : 1; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	vi d(n), cnt(n);
	rep(i, 0, n) cin >> d[i], ++cnt[d[i]];
	if (d[0]) return cout << "0" << endl, 0;
	rep(i, 1, n) if (!d[i]) return cout << "0" << endl, 0;
	int m = 0;
	while (m != n && cnt[m]) ++m;
	if (*max_element(range(d)) > m) return cout << "0" << endl, 0;
	int ans = 1;
	debug(d, cnt, m);
	rep(i, 1, m) ans = mul(ans, fpow(cnt[i - 1], cnt[i]));
	cout << ans << endl;
}


Measured memory_bytes: 1024
import heapq

N = int(input())
A = [-int(x) for x in input().split()]
A.sort()
pq = []
heapq.heapify(pq)
heapq.heappush(pq, A[0])
ans = 0
for a in A[1:]:
    ans += heapq.heappop(pq)
    heapq.heappush(pq, a)
    heapq.heappush(pq, a)
print(-ans)


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

int main()
{
	int w,n;
	vector<int> list;

	cin >> w >> n;

	for(int i=0;i<w;++i)
		list.push_back(i);

	for(int i=0;i<n;++i){
		int a,b,tmp;
		char dummy;
		cin >> a >> dummy >> b;

		a--;
		b--;

		tmp		= list[a];
		list[a]	= list[b];
		list[b]	= tmp;

	}

	for(int i=0;i<w;++i){
		cout << list[i]+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

#define N 10000000

int main() {
  vector<bool> p(N,1);
  p[0]=p[1]=0;
  REP(i,N) if (p[i])
    for(int j=i*2;j<N;j+=i)
      p[j] = 0;
  int n;
  while(cin>>n,n) {
    for (int i=n; i>=0; --i) {
      if (p[i]&&p[i-2]&&p[i-6]&&p[i-8]) {
        cout << i << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 2116
import math
def I(): return int(input())
##################################################
N = I()
ans = 0
for i in range(1,N+1):
    for j in range(1,N+1):
        temp = math.gcd(i,j)
        for k in range(1,N+1):
            ans += math.gcd(temp,k)
print(ans)


Measured memory_bytes: 67868
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

ll INF = 1ll<<60;
vvll dp(3001, vll(3001, INF));

ll rdp(ll a, ll b, const vll &A){
    if(a == b){
        return dp[a][b] = A[a];
    }
    if(dp[a][b] < INF){
        return dp[a][b];
    }
    return dp[a][b] = max(A[a] - rdp(a+1, b, A), A[b] - rdp(a, b-1, A));
}

int main(){
    ll N; cin >> N;
    vll a(N);
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    rdp(0, N-1, a);
    cout << dp[0][N-1];
}

Measured memory_bytes: 72960
import math
A, B, H, M = map(int, input().split())
rad_a = 30 * H + 0.5 * M
rad_b = 6 * M

K = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(rad_a - rad_b))
print(K ** 0.5)

Measured memory_bytes: 9496
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N, X;
  std::cin >> N >> X;
  std::vector< ll > vl(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> vl[i];
  }

  ll d = 0LL;
  ll ans = 1LL;
  for (ll i = 0; i < N; i++) {
    d += vl[i];
    if (d <= X) ans++;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S, T;
    cin >> S >> T;
    int count = 0;
    for (int i = 0; i < S.length(); i++)
    {
        if (S[i] != T[i])
            count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3848
n, x, m = map(int, input().split())
mn = min(n, m)
P = [] # (x,pre_sum)
sum_p = 0 # sum of pre + cycle
X = [-1] * m # for cycle check
for i in range(mn):
    if X[x] > -1:
        cyc_len = len(P) - X[x]
        pre = P[X[x]]
        cyc = (sum_p - pre) * ((n - X[x]) // cyc_len)
        nxt = P[X[x] + (n - X[x]) % cyc_len] - P[X[x]]
        print(pre + cyc + nxt)
        exit()
    P.append(sum_p)
    sum_p += x
    X[x] = i
    x = x*x % m
print(sum_p)


Measured memory_bytes: 13724
#include<bits/stdc++.h>
using namespace std;
int main(){
        while(1){
                int d,e;cin >> d >> e;
                if(d==0&&e==0) break;
                if(d==e){
                         cout << 0 << endl;
                         continue;
                }
                double ans=10000000000;
                //int ax=-1;
                for(int x=0;x<=d;x++){
                        int y = d-x;
                        double tmp = abs(sqrt(pow(x,2)+pow(y,2))-e);
                        if(ans>tmp){
                                //ax = x;
                                ans = tmp;
                        }

                }
                printf("%.10lf\n",ans);
                //printf("ax=%d\n",ax);
        }
        return 0;
}



Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int X = scan.nextInt();
		int Y = scan.nextInt();

		int result = 0;
		if (N>K) {			
			result = X*K;
			result += Y*(N-K);
		} else {
			result = X*N;
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define For(i,a,b) for(int i=a; i>b ;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define endl "\n"
#define mod 1000000007

void solve()
{
	
}

int main()
{
	IOS;
	ll int t, ans=0;
	cin>>t;
	ll int a[t+1];
	FOR(i,0,t) cin>>a[i];
	FOR(i,1,t)
	{
		if(a[i]<a[i-1])
		{
			ans+=abs(a[i-1]-a[i]);
			a[i]=a[i-1];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5100
function Main(input){
  input = input.split(' ');
  var x = Number(input[0]);
  var y = Number(input[1]);


  if( x + y >= 10) {
      console.log('error');
  } else {
      console.log(x + y);
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
	ios_base::sync_with_stdio( false );

	string A, B;
	cin >> A >> B;

	if( A.size() > B.size() ) {
		cout << "GREATER\n";
	}
	else if( A.size() < B.size() ) {
		cout << "LESS\n";
	}
	else {
		int x = 0;
		for( int i = 0; i < A.size(); ++i ) {
			if( A[i] == B[i] ) { continue; }

			x = (A[i] > B[i]) + 1;
			break;
		}

		string result[] = { "EQUAL\n", "LESS\n", "GREATER\n" };
		cout << result[x];
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
const ll base = 31;
const ll MOD = 1e9+9;
const ll  maxN = 1e6+9;

using namespace std ;
int main()
{ string s;
 cin >> s;
 int a= 0,  b=0;
 for ( int i = 0 ;i < s.size() ; i++)
    if ( s[i]=='A' ) a++ ;
   else b++;
    if ( a == 2 || b==2) cout<<"Yes";else cout<<"No";
    return 0;
}


Measured memory_bytes: 256