akhauriyash/Code-Regression huggingface dataset:
#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>
using namespace std;
#define INF 1LL << 61
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge
{
    ll to, cost, val;
};
template <class T, class U>
bool chmin(T &a, const U &b)
{
    if (a <= b)
        return false;
    a = b;
    return true;
}
template <class T, class U>
bool chmax(T &a, const U &b)
{
    if (a >= b)
        return false;
    a = b;
    return true;
}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll


signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll N,A,B;
    cin>>N>>A>>B;
    ll ans=INF;
    if((B-A)%2==0){
        chmin(ans,(B-A)/2);
    }else{
        chmin(ans,(N-B+1)+(B-A-1)/2);
        chmin(ans,A+(B-A-1)/2);
    }
    chmin(ans,N-A);
    chmin(ans,B-1);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using System.Linq;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tmp = ReadLine().Split(' ').Select(int.Parse).ToArray();
            WriteLine(tmp[0] * tmp[1] % 2 == 0 ? "Even": "Odd");
        }
    }
}

Measured memory_bytes: 13268
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)

temp = P[:X] + Q[:Y] + R

temp.sort(reverse=True)
ans = sum(temp[:X+Y])

print(ans)

Measured memory_bytes: 106480
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   

int main(){
    std::ios::sync_with_stdio(false);
    ll h,w,i,a,b,mini=inf;
    mini*=inf;
    //cout<<abs(mini)<<endl;
    cin>>h>>w;
    if(h%3==0 || w%3==0){
    	cout<<0<<endl;
    	return 0;
    }
    if(h%2==0){
    	rep(i,w+1){
    		a=h*i;
    		b=(h/2)*(w-i);
    		mini=min(mini,abs(a-b));

    	}
    }
    else{
    	f(i,0,w+1){
    		a=h*i;
    		if((w-i)%2==0){
    			b=h*((w-i)/2);
    			mini=min(mini,abs(a-b));
    		}
    		else{
    			b=h*((w-i)/2);
    			mini=min(mini,max(h,max(abs(a-b),abs(a-b-h))));
    			b=(w-i)*(h/2);
    			mini=min(mini,max(w-i,max(abs(a-b),abs(a-b-w+i))));
    		}

    		
    	}
    }
    swap(h,w);
    if(h%2==0){
    	f(i,0,w+1){
    		a=h*i;
    		b=(h/2)*(w-i);
    		mini=min(mini,abs(a-b));
    	}
    }
    else{
    	f(i,0,w+1){
    		a=h*i;
    		if((w-i)%2==0){
    			b=h*((w-i)/2);
    			mini=min(mini,abs(a-b));
    		}
    		else{
    			b=h*((w-i)/2);
    			mini=min(mini,max(h,max(abs(a-b),abs(a-b-h))));
    			b=(w-i)*(h/2);
    			mini=min(mini,max(w-i,max(abs(a-b),abs(a-b-w+i))));
    		}

    		
    	}
    }
    cout<<mini<<endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fir first
#define sec second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 200;
const int MAXM = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EXP = 1e-8;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, r;
    cin >> n >> r;
    int cnt = 0;
    while (n)
    {
        cnt++;
        n/=r;
    }
    cout << cnt ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  bool ok = false;

  FOR(i, 1, 1e3 + 1) {
    int ax = i * 0.08;
    int bx = i * 0.1;

    if (ax < a || bx < b) continue;
    if (i <= a || i <= b) continue;
    if (ax == 0 || bx == 0) continue;
    if (ax == a && bx == b) {
      ans = i;
      ok = true;
      break;
    }
  }

  print(ok ? ans : -1);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    String[][] btn = {
	{},
	{".", ",", "!", "?", " "},
	{"a", "b", "c"},
	{"d", "e", "f"},
	{"g", "h", "i"},
	{"j", "k", "l"},
	{"m", "n", "o"},
	{"p", "q", "r", "s"},
	{"t", "u", "v"},
	{"w", "x", "y", "z"},
    };

    Main(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    int n = sc.nextInt();
	    for(int t = 0; t < n; t++){
		char[] ch = (sc.next()).toCharArray();
		String res = "";

		for(int i = 0; i < ch.length;){
		    int cnt = 0;
		    char p = ch[i++];
		    while(i < ch.length && ch[i] == p){
			cnt++; i++;
		    }

		    if(p != '0'){
			int q = (int)(p-'0');
			res += btn[q][cnt%btn[q].length];
		    }
		}

		System.out.println(res);
	    }
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n,k;
    cin>>n>>k;
    ll a[n];
    ll maxi = -1;
    for (ll i = 0; i < n; i++)
    {
        /* code */
        cin>>a[i];
        maxi = max(a[i], maxi);
    }
    vector< vector<ll> > dp(n + 1, vector<ll>(k + 1, 0));
    dp[0][0] = 1;
    for (ll i = 1; i <=k; i++)
    {
        dp[0][i] += dp[0][i-1];
    }
    
    for(ll i=1; i<=n; i++)
    {
        for (ll j = 0; j <= k; j++)
        {
            if(j == 0)
            {
                dp[i][j] = 1;
            }
            else
            {
                ll l = max(j - a[i-1], (ll)0);
                if(l>0)
                    dp[i][j] = (dp[i-1][j] - dp[i-1][l - 1] + mod)%mod;
                else
                {
                    dp[i][j] = dp[i-1][j];
                }
            }  
        }
        if(i == n) 
            break;
        for (ll j = 1; j <=k; j++)
        {
            dp[i][j] = (dp[i][j - 1] + dp[i][j])%mod;
        }
    }
    cout<<dp[n][k]<<'\n';
}

Measured memory_bytes: 83104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
vector<ll> fac(1e6),inv(1e6),finv(1e6);
void initcom(){
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int compress(vector<int> &x,int w){
    vector<int> sx;
    for(int i=0;i<(int)x.size();++i){
        for(int d=-2;d<=2;++d){
            int t=x[i]+d;
            if(t>=0&&t<w) sx.push_back(t);
        }
    }
    sort(sx.begin(),sx.end());
    sx.erase(unique(sx.begin(),sx.end()),sx.end());
    for(int i=0;i<(int)x.size();++i){
        x[i]=lower_bound(x.begin(),x.end(),x[i])-x.begin();
    }
    return (int)sx.size();
}
int main(){
    string s;cin>>s;
    int n=(int)s.size();
    if(s[0]==s[n-1]){
        if(n%2==0) cout<<"First"<<endl;
        else cout<<"Second"<<endl;
    }
    else{
        if(n%2==1) cout<<"First"<<endl;
        else cout<<"Second"<<endl;
    }
    return 0;
}

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

int	main()
{
	int	N;
	cin >> N;
	vector<int>	A_vec(N);
	map<int, int>	cnt_map;
	int			A;
	for (int i = 0; i < N; ++i) {
		cin >> A;
		A_vec.at(i) = A;
		if (cnt_map.count(A))
			++cnt_map.at(A);
		else
			cnt_map[A] = 1;
	}
	int	max_A = *max_element(A_vec.begin(), A_vec.end());
	vector<bool>	not_div_vec(max_A + 1, true);
	for (auto pr : cnt_map) {
		A = pr.first;
		if (!not_div_vec.at(A))
			continue;
		int	multiple;
		if (pr.second > 1)
			not_div_vec.at(A) = false;
		for (int i = 2; (multiple = i * A) <= max_A; ++i)
			not_div_vec.at(multiple) = false;
	}
	int	cnt = 0;
	for (int A : A_vec) {
		if (not_div_vec.at(A))
			++cnt;
	}
	cout << cnt << endl;
}



Measured memory_bytes: 13468
H, W, D = gets.split.map(&:to_i)
MAP = H.times.map{ gets.split.map(&:to_i) }
Q = gets.to_i
QS = Q.times.map{ gets.split.map(&:to_i) }

poss = Array.new(H*W + 1)
H.times do |y|
  W.times do |x|
    poss[MAP[y][x]] = [x, y]
  end
end
#p poss: poss

dists = Array.new(H*W)
for i in 1..(H*W)
  x1, y1 = poss[i]
  x2, y2 = poss[i+D]
  if x2.nil?
    dists[i] = 0
  else
    dists[i] = (x1-x2).abs + (y1-y2).abs
  end
end
#p dists: dists

cumu = Array.new(H*W)
cumu[0] = 0
for m in 0..(D-1)
  (1+m).step(H*W, D) do |i|
    cumu[i] = (i-D<0 ? 0 : cumu[i-D]) + dists[i]
  end
end
#p cumu: cumu

QS.each do |l, r|
  p (r-D<0 ? 0 : cumu[r-D]) - (l-D<0 ? 0 : cumu[l-D])
end


Measured memory_bytes: 28308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, k; cin >> n >> k;
    VI a(n); cin >> a;
    rSORT(a, greater<int>());
    int ans = 0;
    FOR(i, 0, k)ans += a[i];
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using i64 = long long;

std::vector<long long> fact, inv;

constexpr auto pow(long long x, long long n, const long long mod) {
    long long ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

constexpr auto inverse(const long long x, const long long p) {
    return pow(x, p - 2, p);
}

void init_factorial(const int n, const long long mod) {
    fact.resize(n + 1);
    inv.resize(n + 1);
    fact[0] = 1;
    for (long long i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    inv[n] = inverse(fact[n], mod);
    for (long long i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}


int main() {
    constexpr i64 mod = 1000000007;
    int k;
    std::string s;
    std::cin >> k >> s;
    const int n = s.size();
    init_factorial(n + k, mod);

    i64 a = 0, f = pow(25, n + k, mod);
    constexpr i64 i25 = inverse(25, mod);
    for (int i = 0; i < n; i++) {
        a = (a + f * fact[n + k] % mod * inv[i] % mod * inv[n + k - i] % mod) % mod;
        f = f * i25 % mod;
    }

    const i64 ret = (pow(26, n + k, mod) + mod - a) % mod;
    std::cout << ret << std::endl;

    return 0;
}


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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n;

vi v;

void read() {
  cin >> n;

  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    v.pb(x);
  }
}

void solve() {
  sort(v.begin(), v.end());
  for(int i = 1; i < n; ++i) {
    int a = v[i - 1];
    int b = v[i];
    while(a > 0 && b > 0) {
      if (b >= a)
        b = b - b / a * a;
      else a = a - a / b * b;
    }
    v[i] = max(a, b);
  }
  cout << v[n - 1];
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
//  cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}



int main() {
string s;
  cin >>s;
  ll c=s.size();
  if(s.at(c-1)=='s') {
    rep(i,c) {
      cout<<s.at(i);
    }
    cout<<"es"<<endl;
  }
else {
  cout<<s<<'s'<<endl;
}

  
}
    

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

using namespace std;
const int maxn = 3010;

int n;
double niz[maxn];
double dp[maxn][maxn];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> niz[i];

    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            dp[i][j] = dp[i - 1][j] * (1.0 - niz[i]);
            if (j > 0) dp[i][j] += dp[i - 1][j - 1] * niz[i];
        }
    }
    double sol = 0;
    for (int i = (n + 1) / 2; i <= n; i++)
        sol += dp[n][i];

    //for (int i = (n + 1) / 2; i <= n; i++) cout << dp[n][i] << " "; cout << endl;
    cout << fixed << setprecision(10) << sol << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll A[200100];
ll DP[200100][10];

int main(){
    ll N;
    cin >> N;
    REP(i,N){
        cin >> A[i];
    }

    REP(i,N){
        REP(j,5){
            DP[i][j] = -1e18;
        }
    }

    DP[0][0] = A[0];
    DP[1][1] = A[1];
    DP[2][2] = A[2];
    REP(i,N){
        //ll a = A[i];
        REP(j,3){
            chmax(DP[i+2][j], DP[i][j] + A[i+2]);
            chmax(DP[i+3][j+1], DP[i][j] + A[i+3]);
            chmax(DP[i+4][j+2], DP[i][j] + A[i+4]);
        }
    }

    //ll num = N - (2*(N/2) - 1);
    //ll ans = -1;
    //for(int k = 0; k <= num; k++)
    //    //chmax(ans, DP[N-1][k]);
    //    chmax(ans, DP[N-1-k][num-k]);

    ll ans = LLONG_MIN;
    ll num = 1 + N%2;
    for(int d = 0; d <= num; d++){
        int i = N-1-d;
        chmax(ans, DP[i][num-d]);
    }

    //REP(i,N){
    //    REP(j,3){
    //        if(DP[i][j] < 0)
    //            printf("x ");
    //        else
    //            printf("%lld ", DP[i][j]);
    //    }
    //    printf("\n");
    //}

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


Measured memory_bytes: 20816
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;
		int A[] = new int[N];
		for (int i=0;i<N;i++) {
			A[i] = sc.nextInt()*N;
			sum +=A[i];
		}
		int balance = sum /N;
		int min = Integer.MAX_VALUE;
		int num =0;
		for (int i=0;i<N;i++) {
			if (Math.abs(A[i]-balance)<min) {
				min = Math.abs(A[i]-balance);
				num =i;
			}
		}
		System.out.println(num);
	}
}

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

int main()
{
	cin.tie(0);
	cout.tie(0);
	int a,sm=0;
	for(int i=0;i<5;i++)
	{
		cin>>a;
		sm+=a;
	}
	cout<<15-sm<<endl;
	return 0;
}

Measured memory_bytes: 3636
// Problem Code: abc170_d

#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

int not_divisible(int N, vector<int>& A) {
	int cnt = 0, limit = *max_element(A.begin(), A.end());
	vector<int> freq(limit + 1);
	vector<bool> mark(limit + 1);

	for (int x: A)
		freq[x]++;

	for (int i = 1; i <= limit; i++) {
		if (freq[i] == 0 || mark[i])
			continue;
		for (int x = i; x <= limit; x += i)
			mark[x] = true;
		cnt += freq[i] == 1;
	}

	return cnt;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	cout << not_divisible(N, A);
	return 0;
}

Measured memory_bytes: 8080
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+100;
#define ll long long

vector<int> s[N];

void add(int x,int y){
    s[x].push_back(y);
    s[y].push_back(x);
}

int a[N];
vector<int> v;

void solve(){
    int n,x,y;
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<n;++i){
        add(i,i+1);
    }
    add(x,y);
    for(int i=1;i<=n;++i){
        priority_queue<pair<int,int> > Q;
        Q.push(make_pair(0,i));
        int vis[N]={0};
        vis[i]=1;
        while(!Q.empty()){
            pair<int,int> p=Q.top();
            Q.pop();
            a[-p.first]++;
            for(int j=0,st=s[p.second].size();j<st;++j){
                int m=s[p.second][j];
                if(!vis[m]){
                    vis[m]=1;
                    Q.push(make_pair(p.first-1,m));
                }
            }
        }
    }
    for(int i=1;i<n;++i){
        printf("%d\n",a[i]/2);
    }
}

int main(){
    solve();
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll POW3(ll x,ll n,ll m){
  x%=m;
  if(n==0)return 1;
  if(n%2==0)return POW3(x*x,n/2,m)%m;
  return x*POW3(x,n-1,m)%m;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)//xのm進数でのx^nの位の値
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)//xのn進数での桁数
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)//x!のnで割り切れる回数
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)//xのnで割り切れる回数
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

ll SGS(ll x,ll y, ll m)//1+x+…+x^(y-1)をmで割った余り
{
  if(y==0)return 0;
  if(y%2==0){
    return (1+POW3(x,y/2,m))*SGS(x,y/2,m)%m;
  }
  return (1+x*SGS(x,y-1,m))%m;
}

ll SSGS(ll x,ll y,ll m)//Σ[k=1→y](1+x+…+x^(k-1))をmで割った余り
{
  if(y==0)return 0;
  if(y==1)return 1;
  if(y%2==0){
    return (SSGS(x,y/2,m)*(POW3(x,y/2,m)+1)%m+SGS(x,y/2,m)*y/2%m)%m;
  }
  return (SSGS(x,y-1,m)*x%m+y)%m;
}

int main()
{
  ll n,x[60],y[60],a,b,c=0,ans=0;
  cin >> n;
  vector<pair<ll,ll>>p(n);
  rep(i,n){
    cin >> x[i] >> y[i];
    p[i]=make_pair(x[i],y[i]);
  }
  sort(all(p));
  rep(i,n){
    rep(j,n){
      if(i<=j)break;
      a=p[i].first-p[j].first;
      b=p[i].second-p[j].second;
      rep(k,n){
        rep(l,n){
          if(k>l&&p[k].first-p[l].first==a&&p[k].second-p[l].second==b)c++;
        }
      }
      ans=max(ans,c);
      c=0;
    }
  }
  printf("%lld",n-ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	rep(i,0,3){
		char c=getchar();
		putchar(c^8);
	}
}

Measured memory_bytes: 128
p = [True] * (1000000)
p[0] = p[1] = False
for i in range(2, int(len(p)**0.5)+1):
	if p[i]:
		for j in range(i*2, len(p), i):
			p[j] = False

while True:
	a, d, n = map(int, input().split())
	if (a,d,n) == (0,0,0):
		break
	count = 0
	for i in range(a, 1000000, d):
		if p[i]:
			count += 1
		if count == n:
			print(i)
			break

Measured memory_bytes: 15080
#include <bits/stdc++.h>
#include<iostream>
#include <math.h>//pow(x,y)=x^y
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(i,n) for (int i=0; i <(n);i++)
#define ll long long
#define rev(s) reverse(s.begin(),s.end())
#define sor(v) sort(v.begin(),v.end())

using namespace std;


int main() {
int N;
cin >> N;
vector<string> S(N);
rep(i,N){
    cin >> S.at(i);
}
int ac = 0;
int wa = 0;
int tle = 0;
int re = 0;

rep(i,N){
    if(S.at(i).at(0)=='A'){
        ac += 1;
    }else if(S.at(i).at(0)=='W'){
        wa += 1;
    }else if(S.at(i).at(0)=='T'){
        tle += 1;
    }else if(S.at(i).at(0)=='R'){
        re += 1;
    }
}
cout << "AC x " << ac << endl;
cout << "WA x " << wa << endl;
cout << "TLE x " << tle << endl;
cout << "RE x " << re << endl;


}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353;
int A, B, C, D;
int main() {
	cin >> A >> B >> C >> D;
	vector<vector<ll>> b(C+1, vector<ll>(D+1));
	b[A][B] = 1;
	for (int i = A+1; i <= C; ++ i) {
		b[i][B] = b[i-1][B] * B % mod;
	}
	for (int i = B+1; i <= D; ++ i) {
		b[A][i] = b[A][i-1] * A % mod;
	}
	for (int i = A+1; i <= C; ++ i) {
		for (int j = B+1; j <= D; ++ j) {
			(b[i][j] += b[i-1][j] * j) %= mod;
			(b[i][j] += b[i][j-1] * i) %= mod;
			(b[i][j] += mod - b[i-1][j-1] * (i-1) % mod * (j-1) % mod) %= mod;
		}
	}
	cout << b[C][D] << endl;
}


Measured memory_bytes: 73576
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint calc(llint x){
    return x*(x+1)/2;
}
void solve(){
    llint n;
    cin >> n;
    vector<int>dp(n+1,1);
    for(int i=2;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            dp[j]++;
        }
    }
    llint ans=0;
    llint y=0;
    for(int x:dp){
        ans+=(x*y);
        y++;
    }
    cout << ans << endl;
}

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




Measured memory_bytes: 42244
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[3],b[3];
	for(int i=0;i<3;i++)
	  cin>>a[i];
	int cnt=0;
	while(1){
		if(a[0]%2!=0 || a[1]%2!=0 || a[2]%2!=0){
			cout<<cnt<<endl;
			break;
		}
		if(a[0]==a[1] && a[1]==a[2]){
			cout<<-1<<endl;
			break;
		}
		for(int i=0;i<3;i++)
		  b[i]=0;
		b[0]+=a[1]/2+a[2]/2;
		b[1]+=a[0]/2+a[2]/2;
		b[2]+=a[0]/2+a[1]/2;
		cnt++;
		for(int i=0;i<3;i++)
		  a[i]=b[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int n,i,j,k;
  scanf("%d",&n);
  char s[n+1][11];
  int p[n+1],num[n+1];
  for(i=0;i<n;i++){
    scanf("%s %d",s[i],&p[i]);
    num[i]=i+1;
  }
  char c[11];
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++)
      if(strcmp(s[i],s[j])>0 || (strcmp(s[i],s[j])==0 && p[i]<p[j])){
        strcpy(c,s[i]);
        strcpy(s[i],s[j]);
        strcpy(s[j],c);
        k=p[i];
        p[i]=p[j];
        p[j]=k;
        k=num[i];
        num[i]=num[j];
        num[j]=k;
      }
    printf("%d\n",num[i]);
  }
  return 0;
}


Measured memory_bytes: 1712
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

const int MAX = 670000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  COMinit();
  
  ll x,y;
  cin>>x>>y;
  
  if((x+y)%3 != 0 || y>2*x || 2*y<x){
    cout<<0<<endl;
    return 0;
  }
  
  int a,b;
  a=(x+y)/3;
  b=2*a-y;
  
  cout<<COM(a,b)<<endl;

  return 0;
}

Measured memory_bytes: 16000
#include <complex>
#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>
#define X real()
#define Y imag()
#define EPS 1e-10
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef vector<P> Poly;

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

int ccw(P a, P b, P c){
  if(cross(b-a,c-a) > EPS) return 1;
  if(cross(b-a,c-a) < -EPS) return -1;
  if(dot(b-a,c-a) < -EPS) return 2;
  if(norm(b-a)+EPS < norm(c-a)) return -2;
  return 0;
}

bool is_cross(L a, L b){
  if(ccw(a.first,a.second,b.first)*ccw(a.first,a.second,b.second) <= 0 &&
     ccw(b.first,b.second,a.first)*ccw(b.first,b.second,a.second) <= 0) return true;
  return false;
}

int in_poly(P a, Poly p){
  int n = p.size(), c = 0;
  /*
  P ex = a;
  for(int i = 0; i < n; ++i) ex.X = max(ex.X,p[i].X+1);
  */
  p.push_back(p[0]);
  for(int i = 0; i < n; ++i){
    P s = p[i]-a, t = p[i+1]-a;
    if(!ccw(s,t,P(0,0))) return 1;//??????
    if(s.Y > t.Y + EPS) swap(s,t);
    if((s.Y*t.Y < 0 || (s.Y*t.Y < EPS && t.Y > EPS)) && cross(s,t) < EPS) ++c;
  }
  if(c%2) return 2;//?????¨
  return 0;//?????¨
}

int main(){
  int g, q;
  cin >> g;
  Poly p(g);
  double x, y, Mx = 0, My = 0;
  for(int i = 0; i < g; ++i){
    cin >> x >> y;
    p[i] = P(x,y);
  }
  cin >> q;
  for(int i = 0; i < q; ++i){
    cin >> x >> y;
    cout << in_poly(P(x,y),p) << endl;
  }
  return 0;
}

Measured memory_bytes: 3284
a = list(map(int, input().split()))
a.sort()
cnt = 0
if (a[0]%2==0 and a[1]%2!=0 and a[2]%2==0) or (a[0]%2!=0 and a[1]%2==0 and a[2]%2!=0):
  while a[2] > a[1]:
    a[1] += 2
    cnt += 1
  a.sort()
elif (a[0]%2!=0 and a[1]%2==0 and a[2]%2==0) or (a[0]%2==0 and a[1]%2!=0 and a[2]%2!=0):
  while a[2] > a[0]:
    a[0]+= 2
    cnt += 1
  a.sort()

if (a[0]%2!=0 and a[1]%2!=0) or (a[0]%2==0 and a[1]%2==0):
  cnt += (a[1]-a[0])//2
  a[0] = a[1]
  cnt += a[2]-a[1]
print(cnt)

Measured memory_bytes: 3064
n = int(input())
inf = float("INF")
dp = [inf] * n

h_list = list(map(int, input().split()))

dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[i], dp[i - 1] + abs(h_list[i] - h_list[i - 1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i - 2] + abs(h_list[i] - h_list[i - 2]))
print(int(dp[n - 1]))

Measured memory_bytes: 52976
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)


n,x=map(int,input().split())

if n==1:
    a=int(input())
    print(abs(a-x))
    exit()
else:
    str=input()
    lst=str.split(" ")
    a=int(lst[0])
    b=int(lst[1])
    maxim=gcd(abs(a-x),abs(b-x))
    for i in range(2,n):
        c=int(lst[i])
        maxim=gcd(maxim,abs(c-x))
print(maxim)


Measured memory_bytes: 11096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    rep(i,n-2) {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
    }
    Cout(ans)

    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>

int main() {
  std::string text = {};
  std::cin >> text;
  int first = std::stoi(text.substr(0, 2));
  int second = std::stoi(text.substr(2, 2));
  std::string result;
  if ((0 < first && first <= 12) && 0 <= second) {
      if (0 < second && second <= 12)
        result = "AMBIGUOUS";
      else
        result = "MMYY";
  }
  else if ((0 < second && second <= 12) && 0 <= first) {
      if (0 < first && first <= 12)
        result = "AMBIGUOUS";
      else
        result = "YYMM";
  }
  else {
      result = "NA";
  }
  std::cout << result;
  return 0;
}


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

#define sz 100005
#define nl printf("\n");
#define ll long long int

char f,g;
bool flag;
pair < int ,int > pi;
map < int , int > mp;
vector < int > v,va,vb;
int arr[sz],brr[sz],crr[sz];



int main(){

    int n,m, i,j,k, x=0,y=0,z=0, a,b,c;

    cin>>a>>b;
    b/=2;
    cout<<a+b<<endl;


    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n, l; cin>>n>>l;
    vector<string> v(n);
    REP(i,n)cin>>v[i];
    sort(ALL(v));
    REP(i,n)cout<<v[i];
    return 0;
}


Measured memory_bytes: 3576
#include<iostream>

using namespace std;

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

int merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = R[n2] = SENTINEL;
  int i = 0;
  int j = 0;
  for (int k = left; k < right; k++) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
   
int mergeSort(int A[], int left, int right){
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
   
int main() {
  int A[MAX], N;

  cnt = 0;

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

  mergeSort(A, 0, N);

  for (int i = 0; i < N; i++) {
    if (i) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 7004
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
ans = 0
for i in range(n):
    if i+a[i] < n:
        b[i+a[i]] += 1
    if a[i] <= i and b[i-a[i]]:
        ans += b[i-a[i]]
print(ans)

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

namespace abc115_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList(); 
            var h = new List<int>();
            var r = int.MaxValue;

            for (int i = 0; i < NK[0]; i++)
                h.Add(int.Parse(Console.ReadLine()));

            h.Sort();

            for (int i = 0; i <= NK[0] - NK[1]; i++)
            {
                var rr = h[i + NK[1] - 1] - h[i];
                if (r > rr) r = rr;
            }

            Console.WriteLine(r);
        }

    }
}


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

int dmax=0;

int dsum(vector<int> a, vector<vector<int>> b){
    int sum=0;
    for(int i=0; i<b.size(); i++){
        if(a.at(b.at(i).at(1)-1)-a.at(b.at(i).at(0)-1) == b.at(i).at(2))
            sum += b.at(i).at(3);
    }
    return sum;
}

void tancho(vector<int> a, int i, int m, vector<vector<int>> b){
    if(i==a.size()){
        //cout << "ok" << endl;
        dmax = max(dmax, dsum(a,b));
        return;
    }
    
    int k= a.at(i);
    for(int j=k; j<=m; j++){
        for(int l=i; l<a.size(); l++){
            a.at(l) = j;
        }
        tancho(a,i+1,m,b);
        //cout << "ok" << endl;
        
    }
    for(int l=i; l<a.size(); l++){
        a.at(l) = k;
    }
    return;
}



int main(){
    int n, m, q;
    cin >> n >> m >> q;
    
    
    vector<int> a(n,1);
    vector<vector<int>> b(q, vector<int>(4));
    
    for(int i=0; i<q; i++){
        for(int j=0; j<4; j++){
            cin >> b.at(i).at(j);
        }
    }
    
    tancho(a,1,m,b);
    
    cout << dmax << endl;
    return 0;
}


Measured memory_bytes: 3632
//#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#define FOR(N) for(int i=0;i<N;i++)
#define FOR2(N) for(int j=0;j<N;j++)
using namespace std;
typedef long long ll;


int main() {
	int N;
	cin >> N;
	if (N % 10 == 7 || N / 100 == 7 || (N / 10) % 10 == 7)
		cout << "Yes" << endl;
	else
		cout << "No"<<endl;
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
struct node{
	int hao,t=0,limit,drink;
}num[101];
int a[101],b[101];
int main(){
	int n,m;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>num[i].drink ;
	}
	cin>>m;
	for(int i=1;i<=m;i++){
		cin>>num[i].hao >>num[i].limit ;
	}
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(j==num[i].hao )continue;
			num[i].t+=num[j].drink ;
		}
		cout<<num[i].t +num[i].limit <<endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<string>S(N);
  for(int i=0;i<N;i++)
    cin >> S.at(i);
  map<int,int>k;
  map<int,int>h;
  for(int i=0;i<28;i++)
    k[i]=1000000000;
  for(int i=0;i<N;i++){
    for(int i=0;i<28;i++)
    h[i]=0;
    for(int j=0;j<S.at(i).size();j++)
      h[S.at(i).at(j)-'a']++;
    for(int j=0;j<28;j++)
      k[j]=min(k[j],h[j]);
  }
  string ans="";
  for(int i=0;i<28;i++){
    for(int j=0;j<k[i];j++)
      ans+='a'+i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
import numpy as np

n = int(input())
A = np.array([int(i) for i in input().split()])

A=np.sort(A)
s=A[0]
for i in range(max([n, s])):
    c = A[0]
    A = A % c
    A[0] = c
    z=len(A) - np.count_nonzero(A)
    A=np.sort(A)[z:]
    if len(A) == 1:
        break
print (A[0])



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

struct Node {
    int index = -1;
    int depth = -1;
    int parent = -1;
    int *child;
    int ccnt = 0;
    int type = 0;
};

void depth(Node *node, int x, int d) {
    node[x].depth = d;
    for (int i = 0; i < node[x].ccnt; ++i) {
        depth(node, node[x].child[i], d+1);
    }
}

int Root(Node *node, int x) {
    if (node[x].parent > -1) {
        Root(node, node[x].parent);
    } else {
        return x;
    }
}

int main() {
    int n, x, root;
    string type[] = {"leaf", "internal node", "root"};
    cin >> n;
    Node a[n];
    for (int i = 0; i < n; ++i) {
        cin >> x;
        cin >> a[x].ccnt;
        a[x].index = x;
        a[x].child = new int[a[x].ccnt];
        for (int j = 0; j < a[x].ccnt; ++j) {
            a[x].type = 1;
            cin >> a[x].child[j];
            a[a[x].child[j]].parent = x;
        }
    }
    
    root = Root(a, 0);
    a[root].type = 2;
    depth(a, root, 0);
    
    for (auto& i : a) {
        cout << "node " << i.index << ": ";
        cout << "parent = " << i.parent << ", ";
        cout << "depth = " << i.depth << ", ";
        cout << type[i.type] << ", ";
        cout << "[";
        for (int j = 0; j < i.ccnt-1; ++j) {
            cout << i.child[j] << ", ";
        }
        if (i.ccnt) { 
            cout << i.child[i.ccnt-1] << "]" << endl;
        } else {
            cout << "]\n";
        }
    }
    
    return 0;
}

Measured memory_bytes: 9820
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
1500 2000 1600 3 2
)");
#define cin input
#endif

int main()
{
	int a, b, c, x, y, sum;
	cin >> a >> b >> c >> x >> y;
	int suma, sumb;
	suma = sumb = 0;

	suma = a+b;
	sumb = c*2;

	if (suma < sumb)
		sum = suma * min(x,y);
	else
		sum = sumb * min(x,y);

	if (x > y)
	{
		if (a < c*2)
			sum += a*(x-y);
		else
			sum += c*2*(x-y);
	}
	else
	{
		if (b < c*2)
			sum += b*(y-x);
		else
			sum += c*2*(y-x);
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
S = input()
n1 = int(S[:2])
n2 = int(S[2:])

if 0 < n1 < 13 and 0 < n2 < 13:
    print('AMBIGUOUS')
elif 0 < n1 < 13 and 0 <= n2 < 100:
    print('MMYY')
elif 0 < n2 < 13 and 0 <= n1 < 100:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
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
#include <bits/stdc++.h>
using namespace std;
using ll=long long;using ull=unsigned ll;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v).begin(),(v).end()
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<v.first<<' '<<v.second;return o;}

int main(){
    int s;
    set<int> a;
    cin>>s;
    int m=1;
    a.insert(s);
    while(true){
        if(s%2){
            s=s*3+1;
        }else{
            s=s/2;
        }
        m++;
        if(a.count(s)){
            cout<<m<<endl;
            break;
        }else{
            a.insert(s);
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	
		public static void main(String[] args) {
			try(Scanner sc = new Scanner(System.in)){
				int n = sc.nextInt();
				long[] s = new long[n];
				long[] f = new long[n+1];
				int mod = 1000000007;
				f[0] = 0;
				 long d = 0;
				for(int x = 0;x < n;x++) {
					s[x] = sc.nextInt();
				}
				for(int x = 1;x <= n;x++) {
					f[x] = f[x-1]+s[x-1];
				}
				for(int x = 0;x < n;x++) {
					long sum = (f[n] - f[x + 1]) % mod;
					d += s[x] * sum; 
					d = d % mod;
				}
				System.out.println(d);
			}
		}
}

Measured memory_bytes: 62000
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

        private static void solve(InputReader in, PrintWriter out) {
            Double b=in.nextDouble();
            System.out.println(2*Math.PI*b);
        }
        public static void main(String args[]){
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            InputReader in = new InputReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            solve(in,out);
            out.close();
        }
        private static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

Measured memory_bytes: 33200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine());
		int[] A = new int[N];
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		for(int i=0; i<N; i++)
			A[i] = Integer.parseInt(st.nextToken());
		Arrays.sort(A);
		String ans = "YES";
		
		for(int i=1; i<N; i++) {
			if(A[i] == A[i-1]) {
				ans = "NO";
				break;
			}
		}
		
		System.out.println(ans);
	}

}

Measured memory_bytes: 55416
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stdio.h>
using namespace std;
typedef long long ll;
ll mod = 998244353;

int main(){
	string S;
	cin>>S;
	char base = S[0];
	char now = base;
	ll cnt = 0;
	for(int i = 1; i < S.size(); i++){
		if(S[i] != now){
			now=S[i];
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 512
// #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>
using namespace std;

#ifdef BOI
#include "debug.h"
#else
#define debug(args...)
#endif

#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define eps 1e-7
#define inf 0x3f3f3f3f
#define endl '\n'

int main() {
    cin.tie(0)->sync_with_stdio(0), cin.exceptions(cin.failbit);
    int n; cin >> n;
    vector<vector<int>> g(n, vector<int>(2, 0));
    for (auto& it : g) {
        cin >> it[0] >> it[1];
    }

    int ans = 0;
    for (int i = 0; i + 2 < n; ++i) {
        if (g[i][0] == g[i][1] && g[i + 1][0] == g[i + 1][1] && g[i + 2][0] == g[i + 2][1]) ++ans;
    }
    cout << (ans ? "Yes" : "No");
}


Measured memory_bytes: 3644