akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    int a, b;
    std::cin >> a >> b;

    if (a <= 8 && b <= 8) {
        std::cout << "Yay!" << std::endl;
    } else {
        std::cout << ":(" << std::endl;
    }
}


Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {

	ll N;
	cin >> N;
	vector<vll> F(N, vll(10)), P(N, vll(11));
	rep(i, N) rep(j, 10) cin >> F[i][j];
	rep(i, N) rep(j, 11) cin >> P[i][j];

	ll ans = -INF;
	fori(bit, 1, 1ll << 10) {
		ll tmp = 0;
		rep(i, N) {
			ll count = 0;
			rep(j, 10) {
				if (((bit >> j) & 1) == F[i][j] && F[i][j] == 1) ++count;
			}
			tmp += P[i][count];
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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


Measured memory_bytes: 3588
import java.util.Scanner;

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

		//String str = sc.nextLine();
		//String sl[] = str.split(" ");
		int a = Integer.parseInt(sc.nextLine());
		int b = Integer.parseInt(sc.nextLine());
		int c = Integer.parseInt(sc.nextLine());
		int x = Integer.parseInt(sc.nextLine());

		int s = 0;
		
		for(int i = 0; i <= a; i++)
			for(int j = 0; j <= b; j++)
				for(int k = 0; k <= c; k++)
					s += (500 * i + 100 * j + 50 * k == x ? 1 : 0);
		System.out.println(s);
	}
}

Measured memory_bytes: 23252
// Problem : B - Product Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、 
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	ll A,B,C,D;
	cin>>A>>B>>C>>D;
	ll ans=LLONG_MIN;
	ans=max(A*C,C*B);
	ckmax(ans,max(D*A,D*B));
	cout<<ans<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

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

#define                                 ff                                          first
#define                                 ss                                          second
#define                                 pai                                         acos(-1)
#define                                 ll                                          long long


const ll mod  = 1e9 +07;
const ll mxn  = 1e6 +10;

int  main()
{
    ll i,j,k,a,b,c,d,n,m,t,h,u,v,x,y,z;
    string s;
    cin>>s;
    if(s[0]=='R'&&(s[0]==s[1]&&s[1]==s[2]))
    {
        cout<<3<<endl;
    }
    else if(s[1]=='R'&&(s[0]==s[1]||s[1]==s[2]))
    {
        cout<<2<<endl;
    }
    else if(count(s.begin(),s.end(),'R')>0)
    {
        cout<<1<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
    return 0;
}



Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace  std;
#define NOP			int noOp=0;
#define f(i,n) 		for(i=0;i<n;i++)
#define fr(i,n,a) 	for(i=n;i>=a;i--)
#define fa(i,a,n) 	for(i=a;i<n;i++)
#define deb(x)		cout<<#x<<" "<<x<<endl;
#define deb2(x,y)	cout<<#x<<","<<#y<<" "<<x<<","<<y<<endl;
#define buf(x)		cout<<"Check"<<x<<endl;
#define ll			long long int 
#define ft			first
#define s			second
#define pb			push_back
#define mp			make_pair
#define do			double
#define all(v)		v.begin(),v.end()	
#define et(v)		for(auto itr:v)
#define mod			1000000007
inline void p(vector<ll> x,int n)	{	int i;f(i,n)cout<<x[i]<<" ";cout<<endl; }
 

void solve()
{  	
	ll M,K,i,j,tot,pos,ro=0,re=0,bo=0,be=0;
	ll N;
	string s="ACL";
	cin>>K;
	f(i,K)
		cout<<s;
	


}

	

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

	ll t=1,c=1;
	//cin>>t;
	while(t--)
	{
		
 
		//cout<<"Case #"<<c++<<": "<<endl;
		solve();
		cout<<"\n";
		
	}
	return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

ll solve(ll a) {
	if (a <= 0) return 0;
	if (a % 2 == 1) return ((a + 1) / 2) % 2;
	else return a ^ solve(a-1);
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	ll a, b;
	cin >> a >> b;
	ll answer = solve(b) ^ solve(a-1);
	printf("%lld\n", answer);
}


Measured memory_bytes: 256
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}

int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int a,b,c;
	cin>>a>>b>>c;
	int k;
	cin>>k;
	int count = 0;
	while( a >= b ){
		count++;
		b *= 2;
	}
	while( b >= c){
		count++;
		c *= 2;
	}
	if(count <= k)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

using namespace std;

using lint = long long;

struct Ant {
    int dir, x, id;
    Ant(int dir = 0, int x = 0, int id = 0)
        : dir(dir), x(x), id(id) {}
};

bool solve() {
    int n, l;
    cin >> n >> l;
    if (n == 0) return false;

    vector<Ant> ants(n);
    {
        int id = 1;
        for (auto& a : ants) {
            char d;
            cin >> d >> a.x;
            a.dir = (d == 'R' ? 1 : -1);
            a.id = id++;
        }
    }

    vector<Ant> last;
    int t;
    for (t = 0; !ants.empty(); ++t) {
        last.clear();

        for (auto& a : ants) a.x += a.dir;

        for (int i = 0; i < ants.size(); ++i) {
            for (int j = i + 1; j < ants.size(); ++j) {
                if (ants[i].x == ants[j].x) {
                    swap(ants[i].id, ants[j].id);
                }
            }
        }

        for (auto it = ants.begin(); it != ants.end();) {
            if (it->x == 0 || it->x == l) {
                last.push_back(*it);
                it = ants.erase(it);
            } else {
                ++it;
            }
        }
    }

    sort(last.begin(), last.end(), [](Ant a, Ant b) {
        return a.x < b.x;
    });

    cout << t << ' ' << last.front().id << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}



Measured memory_bytes: 2996
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum MO = 10L^^9 + 7;
enum LIM = 3 * 10^^6;

long[] inv, fac, invFac;
void prepare() {
  inv = new long[LIM];
  fac = new long[LIM];
  invFac = new long[LIM];
  inv[1] = 1;
  foreach (i; 2 .. LIM) {
    inv[i] = MO - ((MO / i) * inv[cast(size_t)(MO % i)]) % MO;
  }
  fac[0] = invFac[0] = 1;
  foreach (i; 1 .. LIM) {
    fac[i] = (fac[i - 1] * i) % MO;
    invFac[i] = (invFac[i - 1] * inv[i]) % MO;
  }
}

int N;

void main() {
  prepare();
  
  try {
    for (; ; ) {
      N = readInt();
      auto dp = new long[][](N + 1, 2);
      dp[0] = [1, 0];
      foreach (k; 0 .. N) {
        dp[k + 1][0] = (dp[k][1] + dp[k][1]) % MO;
        dp[k + 1][1] = (dp[k][0] + dp[k][1]) % MO;
      }
      long ans = 0;
      foreach (k; 1 .. N + 1) {
        long tmp = fac[N] * invFac[k] % MO * invFac[N - k] % MO;
        debug {
          writeln(k, " ", tmp, " ", dp[k][1]);
        }
        (tmp *= dp[k][1]) %= MO;
        (tmp *= inv[3]) %= MO;
        (tmp *= inv[k]) %= MO;
        (tmp *= inv[N]) %= MO;
        (ans += tmp) %= MO;
      }
      foreach (_; 0 .. N - 1) {
        (ans *= inv[3]) %= MO;
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 125180
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*; 
import java.util.*;
import java.util.regex.*;

/*
			  br = new BufferedReader(new FileReader("input.txt"));
			  pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
			  br = new BufferedReader(new InputStreamReader(System.in));
			  pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		//int qq = 1;
		int qq = Integer.MAX_VALUE;
		//int qq = readInt();
		for(int casenum = 1; casenum <= qq; casenum++) {
			int n = readInt();
			String s = readToken();
			String t = readToken();
			int ret = n;
			while(true) {
				String test = s + t.substring(t.length() + n - ret);
				if(test.startsWith(s) && test.endsWith(t)) {
					pw.println(ret);
					break;
				}
				ret++;
			}
		}
		exitImmediately();
	}

	private static void exitImmediately() {
		pw.close();
		System.exit(0);
	}

	private static long readLong() throws IOException {
		return Long.parseLong(readToken());
	}

	private static double readDouble() throws IOException {
		return Double.parseDouble(readToken());
	}

	private static int readInt() throws IOException {
		return Integer.parseInt(readToken());
	}

	private static String readLine() throws IOException  {
		String s = br.readLine();
		if(s == null) {
			exitImmediately();
		}
		st = null;
		return s;
	}

	private static String readToken() throws IOException  {
		while(st == null || !st.hasMoreTokens())  {
			st = new StringTokenizer(readLine().trim());
		}
		return st.nextToken();
	}
}

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

#define FOR(i,start,end) for(int i=start; i<(int)(end); i++)
#define REP(i,n) FOR(i,0,n)
#define SIZE_OF_ARRAY(array)  (sizeof(array)/sizeof((array)[0]))

template<class T> void print(const T& value) { cout << value << "\n"; }

int main() {

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

    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    int has_coin = 0;
    int day = 0;
    while(has_coin < c) {
        day += 1;
        has_coin += a;
        if(day % 7 == 0) {
            has_coin += b;
        }
    }
    printf("%d\n", day);


    return 0;
}



Measured memory_bytes: 3244
from sys import stdin
import sys
# sys.setrecursionlimit(10**8)

def nextLine(): return next(stdin)
def nextStrList(): return nextLine().split()
def nextIntList(): return [int(_) for _ in nextStrList()]


def main():
	n=int(nextLine())
	s=nextLine()

# 	n=4000
# 	import numpy as np
# 	rr=np.random.randint(0,3,n)
# 	s=[]
# 	for r in rr:
# 		if r==0: s.append("R")
# 		if r==1: s.append("G")
# 		if r==2: s.append("B")
# 	s="".join(s)
# 	print(s)
	
# 	index=([],[],[])
# 	for i,si in enumerate(s):
# 		if si=="R": index[0].append(i)
# 		elif si=="G": index[1].append(i)
# 		elif si=="B": index[2].append(i)
# 	print(index)
		
	nums=[0,0,0]
	for i,si in enumerate(s):
		if si=="R": nums[0]+=1
		elif si=="G": nums[1]+=1
		elif si=="B": nums[2]+=1
# 	print(nums)
	
	ss=nums[0]*nums[1]*nums[2]
	for skip in range(n):
		length=skip*2+3
		if length>n: break
		for i0 in range(n-length+1):
			i1=i0+skip+1
			i2=i1+skip+1
			if s[i0]!=s[i1] and s[i1]!=s[i2] and s[i2]!=s[i0]:
				ss-=1
	print(ss)
			
	
if __name__=="__main__":
	main()


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

using namespace std;
int main()
{
    long long int n,i,x[300]= {0},p=0,k,m=0;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>x[i];
        m+=x[i];
    }

        k=round(m*1.00/n);

    for(i=0; i<n; i++)
    {
        p+=((x[i]-k)*(x[i]-k));
    }
    cout<<p<<endl;

    return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <iomanip>
#include <functional>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout<<fixed<<setprecision(10);

    int N;
    cin>>N;
    map<string,int> M;
    map<int,string> m;
    vector<pii> v;
    int count=0;
    for(int i=0;i<N;i++){
        string s;
        cin>>s;
        if(M.find(s)!=M.end()){
            int x=M[s];
            v[x].first++;
        }else{
            M[s]=count;
            m[count]=s;
            v.push_back({1,count});
            count++;
        }
    }
    sort(v.rbegin(),v.rend());
    vector<string> S;
    S.push_back(m[v[0].second] );
    for(int i=1;i<count;i++){
        if(v[0].first==v[i].first) S.push_back(m[v[i].second]);
    }
    sort(S.begin(),S.end());
    for(auto i:S){
        cout<<i<<endl;
    }

}

Measured memory_bytes: 39664
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600
#define MOD 924844033

long fact[2005];
long dp[4005][2005][2];

int main(){
  fill(fact, fact+2005, 0);
  fact[0]=1;
  repl(i,1,2003) fact[i] = fact[i-1]*i%MOD;

  long n,k;
  cin>>n>>k;

  // dp[node][#used][just prev used?]
  fill(dp[0][0], dp[2001][0], 0);
  dp[0][0][0] = 1;
  int idx=0;
  rep(loop,2){ // 上下ある
    repl(i,1,k+1){ // pathの開始点
      rep(j,n+1){
        (dp[idx][j][0]+=dp[idx][j][1])%=MOD;
        dp[idx][j][1]=0;
      }
      for(int x=i; x<=n-k; x+=k){
        rep(j,n+1){
          (dp[idx+1][j][0]+=dp[idx][j][0]+dp[idx][j][1])%=MOD; // いま使わない
          (dp[idx+1][j+1][1]+=dp[idx][j][0])%=MOD;  //ここで使う
        }
        idx++;
      }
    }
  }

  long ans = fact[n];
  long muls=-1;
  repl(i,1,n+1){
    // N個中i個を固定したとき
    long select=0; // 固定するものの選び方の個数．
    (select = dp[idx][i][0]+dp[idx][i][1])%=MOD;
    (ans += muls*select*fact[n-i])%=MOD;
    muls*=-1;
  }

  cout<<(ans+MOD)%MOD<<endl;

  return 0;
}


Measured memory_bytes: 125568
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  vi a(n);
  rep(i,n){
    cin>>a[i];
    a[i]-=i+1;
  }
  sort(all(a));

  int b=a[n/2];

  int ans=0;
  rep(i,n){
    ans+=abs(a[i]-b);
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

ll solve(int n, int ga, int sa, int ba, int gb, int sb, int bb){
	vector<ll> dp(n + 1);
	for(int i = 0; i <= n; ++i){
		ll y = i;
		if(i >= ga){ y = max(y, dp[i - ga] + gb); }
		if(i >= sa){ y = max(y, dp[i - sa] + sb); }
		if(i >= ba){ y = max(y, dp[i - ba] + bb); }
		dp[i] = y;
	}
	return dp.back();
}

int main(){
	ios_base::sync_with_stdio(false);
	int n, ga, sa, ba, gb, sb, bb;
	cin >> n;
	cin >> ga >> sa >> ba;
	cin >> gb >> sb >> bb;
	const ll k = solve(n, ga, sa, ba, gb, sb, bb);
	const ll answer = solve(k, gb, sb, bb, ga, sa, ba);
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 195584
#include <cstdio>

#define abs(x) (x > 0 ? (x) : -(x))

struct Point
{
    int x, y;

    Point(int X, int Y)
    {
        x = X, y = Y;
    }
};

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

    int is_possible = true;
    int last_time = 0;
    Point location = Point(0, 0);

    while(no_of_steps--)
    {
        int time, x, y;
        scanf("%d %d %d", &time, &x, &y);

        int distance = abs(x - location.x) + abs(y - location.y);
        int interval = time - last_time;

        int excess_time = interval - distance;

        if(distance > interval || excess_time%2 == 1)
            is_possible = false;

        location = Point(x, y);
        last_time = time;
    }

    printf(is_possible ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
	int S;
	int h;
	int m;
	int s;
		scanf("%d",&S);
		h = S/3600;
		m = (S%3600)/60;
		s = S%60;
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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;}
const int INF = 1LL<<28;

bool updated = false;
vector<vector<int>> G;
vector<int> P, Pmin, Pmax, Podd;

bool dfs1(int v, int p, int mn, int mx, int odd) {
    int M = 1e6;
    if ( P[v] != INF ) {
        if ( mx < P[v] ) return false;
        if ( mn > P[v] ) return false;
        if ( Pmax[v] < P[v] ) return false;
        if ( Pmin[v] > P[v] ) return false;
        updated |= chmin(Pmax[v], P[v]);
        updated |= chmax(Pmin[v], P[v]);
        int vodd = P[v] % 2;
        if ( vodd < 0 ) vodd = 1;
        if ( vodd != odd ) return false;
        Podd[v] = vodd;
    } else {
        updated |= chmin(Pmax[v], mx);
        updated |= chmax(Pmin[v], mn);
        if ( Pmax[v] < Pmin[v] ) return false;
        if ( Podd[v] == -1 ) {
            Podd[v] = odd;
        } else if ( Podd[v] != odd ) {
            return false;
        }
    }
    for ( int u : G[v] ) {
        if ( u == p ) continue;
        if ( !dfs1(u, v, Pmin[v] - 1, Pmax[v] + 1, 1 - Podd[v]) ) return false;
        updated |= chmin(Pmax[v], Pmax[u] + 1);
        updated |= chmax(Pmin[v], Pmin[u] - 1);
    }
    if ( (Pmax[v] + M) % 2 != odd ) Pmax[v]--, updated = true;
    if ( (Pmin[v] + M) % 2 != odd ) Pmin[v]++, updated = true;
    if ( Pmax[v] < Pmin[v] ) return false;
    return true;
}

bool dfs2(int v, int p, int x) {
    if ( P[v] = INF ) {
        P[v] = x;
    }
    for ( int u : G[v] ) {
        if ( u == p ) continue;
        if ( Pmin[u] <= x + 1  && x + 1 <= Pmax[u] ) {
            if ( !dfs2(u, v, x + 1) ) return false;
        } else if ( Pmin[u] <= x - 1  && x - 1 <= Pmax[u] ) {
            if ( !dfs2(u, v, x - 1) ) return false;
        } else {
            return false;
        }
    }
    return true;
}

void solve() {
    ll N, K;
    cin >> N;
    G.resize(N);
    P.resize(N, INF), Pmin.resize(N, -INF), Pmax.resize(N, INF), Podd.resize(N, -1);
    ll a, b;
    for ( int i = 0; i < N - 1; i++ ) {
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cin >> K;
    int v, p, v0;
    for ( int i = 0; i < K; i++ ) {
        cin >> v >> p;
        v--;
        P[v] = p;
        if ( i == 0 ) v0 = v;
    }

    bool ok = true;
    while ( ok ) {
        updated = false;
        ok = dfs1(v0, -1, -INF, INF, P[v0] % 2);
        if ( !updated ) break;
    }
    if ( ok ) {
        ok = dfs2(v0, -1, P[v0]);
    }

    if ( ok ) {
        cout << "Yes\n";
        for ( int i = 0; i < N; i++ ) {
            cout << P[i] << "\n";
        }
    } else {
        cout << "No\n";
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 15744
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    ll a[101],b[101];
    std::cin >> n;
    ll suma[102],sumb[102];
    suma[0] = 0;
    sumb[0] = 0;
    for (int i = 0; i < n; i++) {
        cin>>a[i];
        suma[i+1] = suma[i]+a[i];
    }
    for (int i = 0; i < n; i++) {
        cin>>b[i];
        sumb[i+1] = sumb[i]+b[i];
    }
    ll result = 0;
    for (int i = 0; i < n; i++) {
        result = max(result, suma[i+1]+sumb[n]-sumb[i]);
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a=0;
  int b=0;
  int c=0;
  int d=1;
  while(scanf("%d %d",&a,&b)!=EOF){
    c=a+b;
    while(c>9){
      c=c/10;
      d=d+1;
    }
    printf("%d\n",d);
    d=1;
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//freopen("in", "r", stdin);
	string s1, s2, s3;
	while(getline(cin, s1)){
		  getline(cin, s2);
		  
	if(s1=="" || s2==""){cout<<0<<endl;continue;}
	
	int l1 = s1.size();
	int l2 = s2.size();
	int dp[l2+1][l1+1];
	for(int i = 0; i<=l1; i++)dp[0][i]=0;
	for(int i = 0; i<=l2; i++)dp[i][0]=0;


	for(int i = 1; i<=l2; i++){
		for(int j = 1; j<=l1; j++){

			if(s2[i-1]==s1[j-1]){
				dp[i][j] = dp[i-1][j-1]+1;
			}
			else{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	//cout<<dp[l2][l1]<<endl;
	string result="";
	int i = l2, j = l1;

	while(dp[i][j]){
		if(dp[i-1][j]==dp[i][j]){
			i--;
		}
		else if(dp[i][j-1]==dp[i][j]){
			j--;
		}
		else{
			i--; j--;
			result += s2[i];
		}
	}
	reverse(result.begin(), result.end());
	cout<<result<<endl;
	
	}
}


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

int main() {
    int n,x;
    cin>>n>>x;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    long can=0,lc=0;
    for(int i=1;i<n;i++){
        if(a[i]+a[i-1]>x){
            lc=a[i]+a[i-1]-x;
            can+=lc;
            if(a[i]-lc<0)a[i]=0;
            else a[i]=a[i]-lc;
        }
    }
    cout<<can<<endl;
}

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

int main() {
  string S;
  cin >> S;
  ll ans = 0;
  ll cnt = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'W') {
      ans += i - cnt;
      cnt++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
from collections import defaultdict

def longest_common_subsequence(X, Y):
    len_X = len(X)
    len_Y = len(Y)
    c = [0] * len_Y

    for i in range(1, len_X):
        c_ = c[:]

        for j in range(1, len_Y):

            if X[i] == Y[j]:
                c[j] = c_[j - 1] + 1
            elif c_[j] < c[j - 1]:
                c[j] = c[j - 1]
    
    return c[-1]

def Main():
    Q = int(input())

    for q in range(Q):
        X = " " + input()
        Y = " " + input()
        print(longest_common_subsequence(X, Y))

Main()


Measured memory_bytes: 6020
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 2019;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  string S;
  cin >> S;
  ll N = S.size(), num = S[N-1]-'0', ans=0, pow10=1;
  
  vl mod2019(2019);
  mod2019[0] = 1;
  ++mod2019[num];
  rep2(i, N-1) {
    pow10 *= 10;
    pow10 %= MOD;
    num += (S[N-1-i]-'0')*pow10;
    num %= MOD;
    ++mod2019[num];
  }

  
  rep(i, 2019) {
    ans += mod2019[i]*(mod2019[i]-1)/2;
  }
  cout << ans << newl;
  return 0;
}

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

long long combi(long long n) {
    return n*(n - 1) /2;
}

int main(){
  map<int,int> mball;
  int N,a;
  long long sum=0,bcombi,acombi;
  vector<int> vball;
  cin >> N;
  for(int i = 0;i < N;i++){
  	cin >> a;
    vball.push_back(a);
    mball[a] += 1;
  }
  for(auto itr = mball.begin(); itr != mball.end(); ++itr) {
        if(itr->second ==  1){
        }else{
        	sum += combi(itr->second);
        }
    }
  for(int i = 0;i < N;i++){
    bcombi=0,acombi=0;
	auto itr = mball.find(vball.at(i));
    if( itr != mball.end()) {
        bcombi = combi((itr->second));
      	acombi = combi((itr->second - 1));
      }
    cout << sum + acombi - bcombi<< endl;
  }
  
}


Measured memory_bytes: 8308
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  const int COIN = 500;
  int K, X;
  string result = "Yes";

  // 入力
  cin >> K >> X;

  int totalValue = K * COIN;
  if (totalValue < X) {
    result = "No";
  }

  // 出力
  cout << result << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
struct Node{
  int no;
  int par;
  int col;
  bool comp;
  vector<Node*> child;
  void build(int i){
    no=i;par=i;col=0;comp=true;
  }
};
int s=100000;
void dfs(Node& node,int& x_buf,int& y_buf){
    //if(!node.comp)return;
    int num=node.child.size();
    rep(i,num){
        if(node.child[i]->comp){
            if(node.col==0)++y_buf;
            else ++x_buf;
            node.child[i]->comp=false;
            dfs(*node.child[i],x_buf,y_buf);
        }
    }
}
signed main(){
  int n;cin>>n;
  vector<Node> x(s+1);
  vector<Node> y(s+1);
  rep1(i,s){
      x[i].build(i);
      y[i].build(i);y[i].col=1;
  }
  rep(i,n){
      int a,b;cin>>a>>b;
      x[a].child.push_back(&y[b]);
      y[b].child.push_back(&x[a]);
  }
  int res=0;
  rep1(i,s){
      if(x[i].comp){
          int x_buf=1;int y_buf=0;
          x[i].comp=false;
          dfs(x[i],x_buf,y_buf);
          res+=x_buf*y_buf;
      }
  }
  cout<<res-n<<"\n";
  return 0;
}

Measured memory_bytes: 17280
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll>v[100004];
ll level[100004];
bool visited[100004] = {false};
ll sign[100004] = {0};
void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
void dfs(){
    ll k=1;
    visited[k]=true;
    level[k]=1;
    queue<ll>q;
    q.push(k);
    while(!q.empty()){
        ll p = q.front();
        q.pop();
        ll i;
        for(i=0;i<v[p].size();i++){
            if(visited[v[p][i]]==false){
                level[v[p][i]] = level[p]+1;
                visited[v[p][i]] = true;
                q.push(v[p][i]);
                sign[v[p][i]] = p;
            }
        }
    }
}
int main(){
    boost();
    ll n,m,i;
    cin >> n >> m;
    while(m--){
        ll a,b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs();
    
    for(i=1;i<=n;i++){
        if(visited[i]==false){
            cout << i << endl;
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(i=2;i<=n;i++)
    cout << sign[i] << endl;
}

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

int main(){
	int r, g, b;
	cin >> r >> g >> b;
	int value = 10 * g + b;
	if (value % 4 == 0)
	{
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

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

    int n = sc.nextInt();
    int k = sc.nextInt();

    long count = 0;

    for (int b=k+1; b <= n; b++) {
      count += (b-k) * (n/b);
      if (n%b >= k && k == 0) {
        count += n%b - k;
      } else if (n%b >= k) {
        count += n%b - k + 1;
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }

bool dp1[8000][20000];
bool dp2[8000][20000];

vector<pair<char, ll>> RLE(string &s){
	ll cnt = 0;
	vector<pair<char, ll>> res;
	for(ll i = 0; i < s.size(); i++){
		cnt++;
		if(i == (ll)s.size() - 1){
			res.push_back(make_pair(s[i], cnt));
			break;
		}
		if(s[i] != s[i+1]){
			res.push_back(make_pair(s[i], cnt));
			cnt = 0;
		}
	}
	return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s1;
    cin >> s1;
    ll x, y;
    cin >> x >> y;
    x += 8000;
    y += 8000;
    string s;
    ll ini_x = 8000;
    ll ini_y = 8000;
    bool flag = true;
    for(ll i = 0; i < s1.size(); i++){
    	if(flag){
    		if(s1[i] == 'F') ini_x++;
    		else{
    			s += s1[i];
    			flag = false;
    		}
    	}
    	else s += s1[i];
    }
    vector<ll> fx, fy;
    vector<pair<char, ll>> vp = RLE(s);
    bool turn = true;
    for(ll i = 0; i < vp.size(); i++){
    	if(vp[i].first == 'T'){
    		if(vp[i].second & 1) turn = !turn;
    	}
    	else{
    		if(turn) fx.push_back(vp[i].second);
    		else fy.push_back(vp[i].second);
    	}
    }
    dp1[0][ini_x] = true;
    dp2[0][ini_y] = true;
    for(ll i = 0; i < fx.size(); i++){
    	for(ll j = 0; j < 20000; j++){
    		if(dp1[i][j]){
    			if(j+fx[i] < 20000) dp1[i+1][j+fx[i]] = true;
    			if(j-fx[i] >= 0) dp1[i+1][j-fx[i]] = true;
    		}
    	}
    }
    for(ll i = 0; i < fy.size(); i++){
    	for(ll j = 0; j < 20000; j++){
    		if(dp2[i][j]){
    			if(j+fy[i] < 20000) dp2[i+1][j+fy[i]] = true;
    			if(j-fy[i] >= 0) dp2[i+1][j-fy[i]] = true;
    		}
    	}
    }
    if(dp1[fx.size()][x] && dp2[fy.size()][y]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 80896
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
int mod = (int) 1e9 + 7;

int is_prime(long n){
    
    if(n == 1) return 0;
    if(n == 2) return 1;
    long i = 2;
    while(i * i <= n){
        if(n % i == 0) return 0;
        i++;
    }
    return 1;

}

int main(){
    
    long n;
    cin >> n;
    
    long i = 2;
    int ans = 0;
    
    if (n == 1){
        cout << ans << "\n";
        return 0;
    }
    
    while(1){
        if(n == 1) break;
        
        if(is_prime(n) == 1){
            ans++;
            break;
        }
        
        while(n % i > 0) i++;
        
        int count = 0;
        while(n % i == 0){
            count++;
            n /= i;
        }
        
        int x = 0;
        while(count - x > 0){
            x++;
            count -= x;
        }
        
        ans += x;
        
        i++;
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 3608
main :: IO ()
main = do
  [a,b] <- map read . words <$> getLine
  putStrLn . isSquare' $ concatenate a b

isSquare 
  :: Int -> Bool
isSquare = helper 1
  where
    helper :: Int -> Int -> Bool
    helper 1 1 = True
    helper x y
      | x^2 <  y  = helper (x+1) y
      | x^2 == y  = True
      | otherwise = False

isSquare' 
  :: Int -> String
isSquare' n
  | isSquare n = "Yes"
  | otherwise  = "No"

concatenate
  :: Int -> Int -> Int
concatenate a b = read $ (show a) ++ (show b)

Measured memory_bytes: 508
import numpy as np

a,b,h,m=[int(i) for i in input().split()]

def get_angle(h,m):
    long_angle=2*np.pi*m/60
    short_angle=2*np.pi*h/12+(2*np.pi/12)*m/60
    big_angle=max(long_angle,short_angle)
    small_angle = min(long_angle, short_angle)
    angle=min(big_angle-small_angle,2*np.pi-big_angle+small_angle)
    return angle

def yogen(a,b,theta):
    ans=a**2+b**2-2*a*b*np.cos(theta)
    return ans**0.5

print(yogen(a,b,get_angle(h,m)))

Measured memory_bytes: 27228
n = int(input())

pv = []
con = 0

while n > 0:
    n -= 1
    s = str(input())
    d = s.split()
    if d[0] == d[1]:
        con += 1
    else:
        if con >= 3:
            break
        pv += [con]
        con = 0

pv += [con]
ans = max(pv)

if ans >= 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62148
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int A,B;
vector<int> vec;

//解法
void solve() {

	for (int i = A / 1000; i <= B / 1000; i++) {
		rep(j, 10) {
			vec.emplace_back(i * 1000 + j * 100 + i % 10 * 10 + i / 10);
		}
	}

	int ans = 0;
	rep(i,vec.size()) {
		if (A <= vec[i] && vec[i] <= B) ans++;
	}

	cout << ans;
	return;
}

int main() {
	//入力
	cin >> A >> B;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

main()

{
    int N, X, min, sum = 0, i, z=0, y=0;
    scanf("%d%d",&N,&X);
    int m[N];

    for(i=0; i<N; i++)
    {
        scanf("%d",&m[i]);
        sum = sum + m[i];
    }

    min = m[0];

    for(i=0; i<N; i++)
    {
        if(m[i] < min)
        {
            min = m[i];
        }
    }

    if(sum == X)
    {
        printf("%d\n",N);
    }

    else if(sum < X)
    {
        z = (X - sum);
        y = z/min;
        printf("%d\n",N+y);
    }



}


Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
int mod = 1e9 + 7;

int main(void)
{
    ll a, b;
    cin >> a >> b;
    if(a%b==0)
        cout << -1 << endl;
        else
            cout << a << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

vector<string> split(string s,char ch){
	vector<string> ret;
	string tmp ="";
	rep(i,s.size()){
		if(s[i]==ch){
			ret.pb(tmp);
			tmp = "";
		}else tmp+=s[i];
	}
	if(tmp.size())ret.pb(tmp);
	return ret;
}

double calc(int r1,int r2){
	return sqrt((r1+r2)*(r1+r2)-abs(r1-r2)*abs(r1-r2));
}

double solve(vector<int> v){
	double dp[1<<12][12];
	rep(i,1<<12)rep(j,12)dp[i][j] = 10000;
	
	rep(i,v.size()){
		dp[1<<i][i] = v[i];
	}
	
	for(int bit=1;bit<(1<<v.size());bit++){
		rep(use,v.size()){
			if((bit&(1<<use))!=0)continue;
			rep(last,v.size()){
				dp[bit | (1<<use)][use] = min( dp[bit | (1<<use)][use] , dp[bit][last] + calc(v[last],v[use]) );
			}
		}
	}
	
	double ret = 100000;
	rep(i,v.size()){
		ret = min(ret,dp[(1<<v.size())-1][i]+v[i]);
	}
	return ret;
}

int main(){
	string s;
	while(getline(cin,s)){
		vector<string> vvvvv = split(s,' ');
		int w = stoi(vvvvv[0]);
		vector<int> v;
		for(int i=1;i<vvvvv.size();i++)v.pb(stoi(vvvvv[i]));
		
		double res = solve(v);
		
		if(res-(1e-9)<=w)cout<<"OK"<<endl;
		else cout<<"NA"<<endl;
	}
}

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

int main()
{
  int64_t N, x, ans = 0;
  cin >> N >> x;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++)
  {
    if (x - A.at(i) >= 0)
    {
      x -= A.at(i);
      ans++;
    }
  }
  if (x > 0 && ans > 0 && ans == N)
    ans--;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  int A, B;
  cin >> A >> B;
  cout << (A + B) % 24 << endl;
}

Measured memory_bytes: 256
let n, p = Scanf.scanf " %d %d" @@ fun a b -> a, b
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let o = Array.fold_left (fun o a -> if a mod 2 = 1 then o + 1 else o) 0 a_s
let e = n - o
let _ = Printf.printf "%d\n" @@ if o = 0 then if p = 1 then 0 else 1 lsl e else 1 lsl (n - 1)

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

#define N 100


void output( unsigned char n, int num[N]);


int main(int argc, char **argv)
{
	unsigned char i,j;
	unsigned char n;
	char inputs[100100];
	char *pointer;
	int num[N];
	int swap;
	
	

	fgets( inputs, sizeof(inputs), stdin );
	sscanf( inputs, "%d", &n );
	
	fgets( inputs, sizeof(inputs), stdin );
	pointer = strtok( inputs, " " );
	sscanf( pointer, "%d", &num[0] );
	for( i = 1; i < n; i++ ){
		pointer = strtok( NULL, " " );
		sscanf(pointer, "%d", &num[i]);
	}
	
	output(n, num);
	
	for( i = 0; i < n-1 ; i++ ){
		swap = num[i+1];
		for( j = i+1; j > 0; j--){
			if( num[j-1] < swap ) break;
			num[j] = num[j-1];
			num[j-1] = swap;
		}
		output( n, num );
	}
	
	return 0;

}



void output( unsigned char n, int num[N])
{
	char i;
	printf("%d", num[0]);
	for ( i = 1; i < n; i++ )
		printf(" %d", num[i]);
	printf("\n");
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

namespace solver {
  using namespace std;
  typedef long long ll;

  // static const int MAX = 100010;
  int N, table[10][10];

  void init() {
    cin >> N;
  }

  void solve() {
    REPC(i, 1, N) {
      int s = i;
      while(s / 10 > 0) s /= 10;
      int t = i % 10;
      table[s][t]++;
    }
    ll ans = 0;
    REPC(i, 1, 9) REPC(j, 1, 9) {
      ans += table[i][j] * table[j][i];
    }
    cout << ans << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 256
import collections

n = int(input())

numbers = []

while n%2 == 0:
    numbers.append(2)
    n //= 2

i = 3
while i*i <= n:
    if n%i == 0:
        numbers.append(i)
        n //= i
    else:
        i += 2

if n != 1:
    numbers.append(n)

factors = collections.Counter(numbers)

ans = 0

for num in factors.values():
    k = 1
    while num >= k:
        num -= k
        ans += 1
        k += 1

print(ans)


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

using ll = long long;
const int MAXN = 1000005;
const ll INF = (ll)1e9;
int n;
ll a[MAXN];

ll f(int b) {
    ll c_ans = 0;
    for (int i = 0; i < n; ++i) {
        c_ans += abs(a[i] - (b + i + 1));
    }
    return c_ans;
}

int main() {
#ifdef LOCAL_PROJECT
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif


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

    ll l = -INF, r = INF;

    while (r - l > 1) {
        ll mid = (r + l) >> 1LL;
        if (f(mid) < f(mid + 1)) {
            r = mid;
        } else {
            l = mid;
        }
        // cout << f(l) << " " << f(r) << "\n";
    }
    cout << min(f(l), f(r)) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
 
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const int MOD=(1e9)+7;
const int mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};

signed main(){
  int n,k;
  cin >>n>>k;
  vector<int> l(k),r(k);
  for(int i=0;i<k;i++) cin >>l[i]>>r[i];
  vector<lol> ans(n+10,0);
  ans[0]=0;
  lol sum=1;
  for(int i=1;i<n;i++){
    sum+=ans[i];
    sum%=mod;
    ans[i]=sum;
    for(int j=0;j<k;j++){
      if(i+l[j]<=n) ans[i+l[j]]+=ans[i];
      if(i+r[j]+1<=n) ans[i+r[j]+1]-=ans[i];
    }
  }
  cout <<((ans[n]%mod)+mod)%mod<<'\n';
  return(0);
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;

// auto mod int
// depends on Template

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

mint dp[2020][2020];

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll>s(n),t(m);
    rep(i,n)cin>>s[i];
    rep(i,m)cin>>t[i];
    rep(i,2020){
        dp[0][i]=1;
        dp[i][0]=1;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            dp[i][j]+=dp[i-1][j];
            dp[i][j]+=dp[i][j-1];
            if(s[i-1]!=t[j-1])dp[i][j]-=dp[i-1][j-1];
        }
    }
    cout << dp[n][m] << endl;

    return 0;
}


Measured memory_bytes: 35508