akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<functional>
using namespace std;

//0:Xy[h 1:N[o[ 2:n[g 3:_C
int point[4][13];

//u^AyAAc[yAAX[J[hAXg[gAtbV
//tnEXAtH[J[hAXg[gtbVACXg[gtbV
int mul[10];

//SÌÊAX[c
//mod100 : 
int strtoint(string s) {
  int res = 0;
  if(s.at(0) == 'A') res += 1;
  if(s.at(0) == 'J') res += 11;
  if(s.at(0) == 'Q') res += 12;
  if(s.at(0) == 'K') res += 13;
  if(s.at(0) == 'T') res += 10;
  if(s.at(0) >= '2' && s.at(0) <= '9') res += s.at(0) - '0';
  if(s.at(1) == 'C') res += 100;
  if(s.at(1) == 'H') res += 200;
  if(s.at(1) == 'D') res += 300;
  return res;
}

int hand(vector<int> h) {
  bool stp=true,flp=true;
  vector<int> num;
  for(int i=0; i<5; ++i) {
    num.push_back(h[i]%100);
  }
  sort(num.begin(), num.end());
  for(int i=1; i<5; ++i) {
    if(num[i-1]+1 != num[i]) stp = false;
    if(h[i]/100 != h[0]/100) flp = false;
  }

  //CXg[gtbV
  if(num[0] == 1 && num[1] == 10 && num[2] == 11
     && num[3] == 12 && num[4] == 13 && flp) return 9;

  //Xg[gtbV
  if(stp && flp) return 8;

  if(num[0] == 1 && num[1] == 10 && num[2] == 11
     && num[3] == 12 && num[4] == 13) stp = true;

  //tH[J[h
  if((num[0] == num[1] && num[1] == num[2] && num[2] == num[3])
     ||(num[1] == num[2] && num[2] == num[3] && num[3] == num[4])) return 7;
  //tnEX
      if((num[0] == num[1] && num[2] == num[3] && num[3] == num[4])
     || (num[0] == num[1] && num[1] == num[2] && num[3] == num[4])) return 6;

  //tbV
  if(flp) return 5;

  //Xg[g
  if(stp) return 4;

  //X[J[h
  if((num[0] == num[1] && num[1] == num[2])
     ||(num[1] == num[2] && num[2] == num[3])
     ||(num[2] == num[3] && num[3] == num[4])) return 3;

  //c[yA
  if((num[0] == num[1] && num[2] == num[3])
     ||(num[0] == num[1] && num[3] == num[4])
     ||(num[1] == num[2] && num[3] == num[4])) return 2;

  //yA
  if((num[0] == num[1]) || (num[1] == num[2]) || (num[2] == num[3])
     ||(num[3] == num[4])) return 1;

  return 0;
}

int main() {
  int n,k=0;
  mul[0] = 0;
  while(cin>>n) {
    if(k) cout<<endl;
    for(int i=0; i<4; ++i)
      for(int j=0; j<13; ++j)
    cin>>point[i][j];

    for(int i=1; i<10; ++i)
      cin>>mul[i];


    string s;
    for(int i=0; i<n; ++i) {
      vector<int> h;
      int p = 0;
      for(int j=0; j<5; ++j) {
    cin>>s;
    h.push_back(strtoint(s));
    p += point[h[j]/100][h[j]%100-1];
      }
      //cout<<p<<" * "<<hand(h)<<" = "<<p*mul[hand(h)]<<endl;
      cout<<p*mul[hand(h)]<<endl;
    }
    k++;
  }
}

Measured memory_bytes: 928
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;

signed main()
{
	int N;
	cin >> N;
	int A = -1145141919, B = 1145141919, C = 0;
	for(int i=0; i<N; i++){
		int a;
		cin >> a;
		A = max(A, a);
		B = min(B, a);
		C += a;
	}
	cout << B << " " << A << " " << C << endl;
}


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

int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i % 3 ==0 || i % 10 == 3 || (i/10)%10==3|| (i/100)%10==3 || (i/1000)%10==3){
            cout << " " << i;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int x,a,b;
    cin>>x>>a>>b;
    x-=a;
    x%=b;
    cout<<x<<endl;
    return 0;
}


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

int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    int flag=0;
    for(int i=a; i<=b; i++)
    {
        if(i%k==0)
        {
            flag=1;
            break;
        }
    }
    if(flag)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

#define INF 2047
#define WHITE 0
#define BLACK 1

int n,a[100][100],A[100],C[100];

int Prim(int);

int main(){
  int i,j,s=0;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    A[i]=INF;
  
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      scanf("%d",&a[i][j]);
  
  Prim(0);

  for(i=0;i<n;i++)
    s+=A[i];
    printf("%d\n",s);
  
  return 0;
}

int Prim(int x){
  int i,mincost,mini;
  
  A[x]=0;
  while(1){
    mincost=INF;
    for(i=0;i<n;i++){
      if(C[i]!=BLACK&&A[i]<mincost){
	mincost=A[i];
	mini=i;
      }
    }
    if(mincost==INF)
      break;
    
    C[mini]=BLACK;
    
    for(i=0;i<n;i++)
      if(C[i]!=BLACK&&a[mini][i]<A[i]&&a[mini][i]!=-1){
	A[i]=a[mini][i];
      }
  }
  return 0;
}

Measured memory_bytes: 640
N = int(input())
A = sorted(map(int, input().split()))
M = max(A)
cs = [0]
for i in A:
    cs.append(cs[-1] + i)
A.append(A[-1])
ans = 0
for i in range(N, 0, -1):
    if cs[i] * 2 >= A[i]:
        ans += 1
    else:
        break
print(ans)

Measured memory_bytes: 20328
import java.util.Scanner;

public class Main{
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;

        double area = Math.pow(r,2)*pi;
        double length = 2*pi*r;
        System.out.printf("%f %f",area,length);
    }
}


Measured memory_bytes: 28372
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<endl;}return os;}

namespace ndifix{
template<class T>void sort(T &v){std::sort(v.begin(),v.end());}
}

int main(){
  int a,b,c;cin>>a>>b>>c;
  if(a>b)std::swap(a,b);
  if(a<c && c<b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;  
  return 0;
}


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

typedef pair<int,int> P;

struct UnionFind{
	// (parent, offset_from_parent)
	vector<P> uf;
	
	UnionFind(int N){
		for(int i=0 ; i < N ; i++ ){
			uf.push_back( P(i, 0) );
		}
	}
	
	// Returns (root, offset_from_root> while compressing the path.
	P find(int x){
		if( uf[x].first != x ){
			P p = find(uf[x].first);
			uf[x] = P(p.first, uf[x].second + p.second);
		}
		return uf[x];
	}
	
	void unite(int a, int b, int w){ // [a] + w = [b]
		P aa = find(a); // [aa.first] + aa.second = [a]
		P bb = find(b); // [bb.first] + bb.second = [b]
		// Then, [bb.first] + (bb.second - w - aa.second) = [aa.first]
		if( aa.first != bb.first ){
			uf[aa.first] = P(bb.first, bb.second - w - aa.second);
		}
	}
};

int main(){
	int N, M;
	while( cin >> N >> M , N || M ){
		UnionFind uf(N);
		
		for(int i=0 ; i < M ; i++ ){
			char q;
			cin >> q;
			if( q == '!' ){
				int a, b, w;
				cin >> a >> b >> w;
				a--; b--;
				uf.unite(a, b, w);
			}else if( q == '?' ){
				int a, b;
				cin >> a >> b;
				a--; b--;
				P aa = uf.find(a);
				P bb = uf.find(b);
				if( aa.first != bb.first ){
					cout << "UNKNOWN" << endl;
				}else{
					cout << bb.second - aa.second << endl;
				}
			}
		}
	}
}

Measured memory_bytes: 3852
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}
template <class T>
ostream &operator<<(ostream &out, vector<T> const &v) {
    for (auto &&a : v) out << a << " ";
    out << endl;
    return out;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int K, N;
    cin >> K >> N;
    vi a(N);
    REP(i, N) {
        cin >> a[i];
    }
    int diff = K - a[N - 1] + a[0];
    REP(i, N - 1) {
        chmax(diff, a[i + 1] - a[i]);
    }
    cout << K - diff;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 4748
# Problem:
# Python  Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def palindromic(Num):
    result = False
    strNum = str(Num)
    strRevNum = strNum[::-1]
    checkDigit = 0
    for j in range(0, len(strNum)):
        if strNum[j] == strRevNum[j]:
            checkDigit = checkDigit + 1
    if checkDigit == len(strNum):
        result = True
    return result


def solver(fromNum, ToNum):

    result = 0
    for j in range(fromNum, ToNum+1, +1):
        if palindromic(j):
            result = result + 1
    return result


if __name__ == "__main__":
    A, B = MI()
    print("{}".format(solver(A, B)))


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

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

    if(n==1)
    {
        printf("! 1\n");
        fflush(stdout);
        return 0;
    }

    vector<int> dist0(n+1);
    for(int i=2; i<=n; ++i)
    {
        printf("? 1 %d\n", i);
        fflush(stdout);

        scanf(" %d", &dist0[i]);
    }

    int A=-1;
    int max_dist0=0;
    for(int i=2; i<=n; ++i)
    {
        if(max_dist0 < dist0[i])
        {
            max_dist0 = dist0[i];
            A = i;
        }
    }

    assert(A>0);

    vector<int> x(n);
    x[0]=A;
    for(int i=1; i<=n; ++i)if(A!=i)
    {
        printf("? %d %d\n", A,i);
        fflush(stdout);

        int d;
        scanf(" %d", &d);
        x[d]=i;
    }

    // output
    printf("!");
    rep(i,n) printf(" %d", x[i]);
    printf("\n");
    fflush(stdout);
    return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
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 = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out




int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    //dp[i]=点数の合計がNの時の配点の最大値
    int n;
    cin>>n;
    vi dp(n+1,-1);
    dp[0]=0;
    dp[1]=1;
    for(int i=2;i<=n;i++){
        if(dp[i-1]*(dp[i-1]+1)/2<i)dp[i]=dp[i-1]+1;
        else dp[i]=dp[i-1];
    }
    while(n>0){
        cout<<dp[n]<<endl;
        n-=dp[n];
    }

//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 39296
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    a, b, c = LI()
    if a + b == c or a + c == b or b + c == a:
        print("Yes")
    else:
        print("No")


solve()

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin>>s;
  int n=s.size();
  bool j=1;
  rep(i,(n-1)/2-1) if(s.at(i)!=s.at((n-1)/2-1-i)) j=0;
  string sR=s;
  rep(i,n) sR.at(i)=s.at(n-1-i);
  if(sR!=s) j=0;
  (j)?cout<<"Yes"<<endl:cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

const int MAXN = 1<<20;
int n, dat[2*MAXN-1];

void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;

    for (int i = 0; i < 2*n-1; i++) dat[i] = (1ll<<31)-1;
}

void update(int k, int a) {
    k += n-1;
    dat[k] = a;
    while (k>0) {
        k = (k-1) / 2;
        dat[k] = min(dat[k*2+1], dat[k*2+2]);
    }
}

int query(int a, int b, int k = 0, int l = 0, int r = n) {
    if (r <= a || b <= l) return (1ll<<31)-1;
    if (a <= l && r <= b) return dat[k];
    int vl = query(a, b, k*2+1, l, (l+r)/2);
    int vr = query(a, b, k*2+2, (l+r)/2, r);
    return min(vl, vr);
}

void print() {
    cout << dat[0] << endl;
    cout << dat[1] << "  " << dat[2] << endl;
    cout << dat[3] << "  " << dat[4] << "  " << dat[5] << "  " << dat[6] << endl;
}

int main(void) {
    int N, Q;
    cin >> N >> Q;
    init(N);
    while (Q--) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            update(x, y);
        } else {
            cout << query(x, y+1) << endl;
        }
    }
    return 0;
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int a, b, c;
    cin >> a >> b >> c;
    cout << (a < b && b < c ? "Yes" : "No") << endl;
    return 0;
}



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

int main() {
    int N,count=1;
    cin >> N;
    string S;
    cin >> S ;
    if(N%2!=0) cout << "No" << endl;
    else {
        for(int i=0;i<N/2;i++) if(S.at(i)!=S.at(i+N/2)) count=0;
        if(count) cout << "Yes" << endl;
        else cout << "No" << endl;
    }/*
    cout << r*r << endl;*/
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
from operator import mul

N, K = map(int, input().split())

MOD = 10**9 + 7


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(
                pow(self.x, other.x, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    def __radd__(self, other):
        return ModInt(other + self.x)

    def __rsub__(self, other):
        return ModInt(other - self.x)

    def __rmul__(self, other):
        return ModInt(other * self.x)

    def __rtruediv__(self, other):
        return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rpow__(self, other):
        return ModInt(pow(other, self.x, MOD))


f = [ModInt(1)] + list(
    accumulate(
        map(ModInt, range(1, N + 1)),
        mul
    )
)

# i - 1 > N - K ならばちょうどi回する操作は存在しない
# そうでなければ K - 1)C(i - 1) * (N - K + 1)C(N - K - i + 1)
ans = '\n'.join(
    str(
        0 if i - 1 > N - K else
        (f[K - 1] / (f[K - i] * f[i - 1])) *
        (f[N - K + 1] / (f[i] * f[N - K - i + 1]))
    )
    for i in range(1, K + 1)
)

print(ans)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
long long x[1005], y[1005], r[1005];
double dist[1005];
bool vis[1005];
double d(double dx, double dy, double sr) {
  return max(0.0, sqrt(dx * dx + dy * dy) - sr);
}
int main() {
  scanf("%lld %lld %lld %lld", &x[0], &y[0], &x[1], &y[1]);
  int n;
  scanf("%d", &n);
  for (int i = 2; i <= n + 1; i++) {
    scanf("%lld %lld %lld", &x[i], &y[i], &r[i]);
  }
  priority_queue<pair<double, int> > pq;
  pq.push({0.0, 0});
  while (!pq.empty()) {
    auto p = pq.top();
    pq.pop();
    if (vis[p.second]) continue;
    vis[p.second] = true;
    dist[p.second] = -p.first;
    for (int i = 0; i <= n + 1; i++) {
      if (vis[i]) continue;
      pq.push({p.first - d(x[p.second] - x[i], y[p.second] - y[i], r[p.second] + r[i]), i});
    }
  }
  printf("%.9lf\n", max(0.0, dist[1]));
  return 0;
}


Measured memory_bytes: 8684
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int d, t ,s; cin >> d >> t >> s;
	if((d+s-1)/s<=t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

int main(void) {

    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[N-1] - a[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
inline void solve(void){
  ll N;
  in(N);
  vector<ll>A(N);
  ins(A);
  ll ans=0;
  map<ll,ll>cnt;
  rep(i,N){
    ans+=cnt[i-A[i]];
    cnt[i+A[i]]++;
  }
  out(ans);
}
int main(void){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 27468
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; ll a, b;
    cin>>n>>a>>b;
    int p[5003];
    for(int i=1; i<=n; i++) cin>>p[i];
    p[n+1]=n+1, p[0]=0;
    ll dp[5001];
    dp[0]=0;
    for(int i=1; i<=n+1; i++){
        ll s=0;
        dp[i]=1e18;
        for(int j=i-1; j>=0; j--){
            if(p[i]<p[j]){
                s+=a;
            }else{
                dp[i]=min(dp[i], dp[j]+s);
                s+=b;
            }
        }
    }
    cout<<dp[n+1]<<endl;
    return 0;
}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------

string s_;
string s, t;
int cnt = 0;
string news = {}, temps;

bool flag = false;

bool check(int i){

    REP(j, t.size()){
        /*
        if (s[i + j] == '?' || s[i + j] == t[j]){
            //s[i + j] = t[j];
        }*/
        if(s[i + j] != '?' && s[i + j] != t[j]){

            return false;
        }

    }

    return true;
}


int main(){

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


    cin >> s >> t;

    for(int i = s.size() - t.size(); i >= 0; i-- ){

                //s_ = s.substr(i, t.size());
                //dump(s_);
                //dump(check(i));
                if( check(i)){

                    //s.replace(i, s_.size(), s_);
                    //dump(s);
                    REP(j, t.size()){
                        s[i + j] = t[j];
                    }
                    replace(s.begin(), s.end(), '?', 'a');
                    flag = true;
                    cout << s << endl;
                    break;
                }

    }

    if( !flag){
        cout << "UNRESTORABLE" << endl;

    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define M (L+R)/2
#define N 500009
#define inf 99999999999
#define ll long long
#define mod 1000000007
#define sz size();
using namespace std;

ll k;
string s;

int main(){

	ios::sync_with_stdio(0);
	
	cin>>k;
	s="";
	for(int i=1;i<=k;i++){
		s+="ACL";
	}
	cout<<s<<endl;


	return 0;
}


Measured memory_bytes: 3584
a=[i for i in input()]
b=[i for i in input()]
a=sorted(a)
b=sorted(b)
b=b[::-1]

#print(a)
#print(b)

hantei=True
if len(a)<len(b):
	for i in range(len(a)):
		if a[i]>b[i]:
			hantei=False
			break
		elif a[i]<b[i]:
			hantei=True
			break
else:
	hantei=False
	for i in range(len(b)):
		if a[i]>b[i]:
			hantei=False
			break
		elif a[i]<b[i]:
			hantei=True
			break
if hantei == True:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp> 

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

int main(void){
	int n;
	cin >> n;
	map<int, int> mp;
	auto add = [&](int a){
		mp[a]++;
	};
	auto update = [&](int a, int b){
		mp[b] += mp[a];
		long long upd = 1LL * (b * mp[a] - a * mp[a]);
		mp[a] = 0;
		return upd;
	};
	long long sum = 0;
	for(int i = 0 ; i < n; i++){
		int x;
		cin >> x;
		sum += x;
		add(x);
	}
	int q;
	cin >> q;
	for(int i = 0 ; i < q ; i++){
		int b, c;
		cin >> b >> c;
		sum += update(b, c);
		cout << sum << endl;
	}
}

Measured memory_bytes: 8028
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int H,W;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

template<typename T>
void cout_mat(vector<vector<T>  > &mat){
    for(int i=0; i<mat.size(); i++){
        vector<T> vec = mat[i];
        cout_vec(mat[i]);
    }
}

vector<vector<int> > move_={{1,0},{0,1}};

int bfs(vector<vector<char> > &grid, vector<vector<int> > memo){
    priority_queue<tuple<int, int, int> ,vector<tuple<int, int, int> >, greater<tuple<int, int, int> > > que;
    if(grid[1][1]=='.'){
        que.push(make_tuple(0,1,1));
    }else if(grid[1][1]=='#'){
        que.push(make_tuple(1,1,1));
    }

    while((int)que.size()>0){
        int cost = get<0>(que.top());
        int y = get<1>(que.top());
        int x = get<2>(que.top());

        vector<int> vec={cost,y,x};
        //cout_vec(vec);

        que.pop();
        if(y==H && x==W){
            return cost;
        }

        for(auto m:move_){
            int y1=y+m[0];
            int x1=x+m[1];
            int next=cost;
            if(grid[y1][x1]=='*'){
                continue;
            }else if(grid[y1][x1]!=grid[y][x]){
                next++;
            }

            if(memo[y1][x1]>next){
                memo[y1][x1]=next;
                que.push(make_tuple(next,y1,x1));
            }
        }

    }
}

int main(){
    cin >> H >> W;
    vector<vector<char> > grid(H+2, vector<char>(W+2,'*'));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> grid[i+1][j+1];
        }        
    }

    vector<vector<int> > memo(H+2,vector<int>(W+2,99999999));
    cout << (bfs(grid, memo)+1)/2 << endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

N, K = IA()
AB = IM(N - 1)

P = 1000000007

tree = {}
for a, b in AB:
    tree.setdefault(a, set()).add(b)
    tree.setdefault(b, set()).add(a)


def f(root):
    stack = [(None, None, root, K - 1)]
    v = K
    while stack:
        grand_parent, parent, current, k = stack.pop()

        for i, child in enumerate(tree[current] - {parent}):
            v = v * (k - i) % P
            stack.append((parent, current, child, K - 2))
    return v


print(f(AB[0][0]) if AB else K)


Measured memory_bytes: 69720
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
ll N,K,t,d;
pair<ll,int> A[100010];
int main(){
	cin >> N >> K;
	for(int i=1;i<=N;i++){
		cin >> t >> d;
		A[i] = {d,t};
	}
	map<int,ll> m;
	sort(A+1,A+N+1);
	ll ans = 0,sum = 0,r = 0;
	for(int i=N;i>=1;i--){
		if(i>=N-K+1){
			m[A[i].second]++;
			sum += A[i].first;
			if(i==N-K+1){
				ll s = m.size();
				ans = sum + s*s;
				r = N-K+1;
			}
		}else{
			if(!m.count(A[i].second)){
				m[A[i].second]++;
				while(r<=N && m[A[r].second]==1) r++;
				if(r==N+1) break;
				sum += A[i].first-A[r].first;
				m[A[r].second]--; r++;
				ll s = m.size();
				ans = max(ans,sum+s*s);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5760
import sys
n=int(sys.stdin.readline())
arr=list(map(int,sys.stdin.readline().split()))
dp=[0]
dp.append(abs(arr[1]-arr[0]))
for i in range(2,n):
    a=min(dp[-1]+abs(arr[i]-arr[i-1]),dp[-2]+abs(arr[i]-arr[i-2]))
    dp.append(a)
print(dp[-1])


Measured memory_bytes: 13708
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <iomanip>
using namespace std;
int main(void){
    // Your code here!
    ostringstream oss;
    string a,b,c;
    
    cin>>a>>b>>c;

 oss<<a[0]<<b[0]<<c[0];
 string str =oss.str();
 
 cout<<str<<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();
		boolean[] color = new boolean[8];
		int tensai = 0;
		for(int i=0; i<n; i++){
			int a = sc.nextInt();
			if(a>=3200){
				tensai++;
			}else{
				color[a/400]=true;
			}
		}
		int ans = 0;
		for(int i=0; i<8; i++){
			if(color[i]) ans++;
		}
		
		if(ans==0){
			System.out.print(1+" ");
		}else{
			System.out.print(ans+" ");
		}
		
		System.out.println(ans+tensai);
		return;
	}
}

Measured memory_bytes: 21332
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
//typedef pair<ll,ll> p; 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.size(),p=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]==s[n-1-i])
        continue;
        else
        p=1;
    }
    int l=(n-1)/2;
    for(int i=0;i<(n-1)/2;i++)
    {
       if(s[i]==s[l-1-i])
       continue;
       else
       p=1;
    }
    l=(n+3)/2;
    int j=0;
    for(int i=l-1;i<n;i++)
    {
       if(s[i]==s[n-1-j])
       j++;
       else
       p=1;
    }
    if(p==1)
    cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;
    
    
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    char S[10];
    char *s1 = "hi";
    char *s2 = "hihi";
    char *s3 = "hihihi";
    char *s4 = "hihihihi";
    char *s5 = "hihihihihi";
    scanf("%s",S);
    if (strcmp(S, s1) == 0)
    {
        printf("Yes");
    }
    else if (strcmp(S, s2) == 0)
    {
        printf("Yes");
    }
    else if (strcmp(S, s3) == 0)
    {
        printf("Yes");
    }
    else if (strcmp(S, s4) == 0)
    {
        printf("Yes");
    }
    else if (strcmp(S, s5) == 0)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n;
    cin>>n;
    vector<pair<ll,ll>> v;
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        v.push_back({a-b,a+b});
    }

    sort(v.begin(),v.end());

    pair<ll,ll> pre = v[0];
    ll ans = 0;

    for(int i=1;i<n;i++){
        if(v[i].first<pre.second){
            //cout<<pre.second<<" "<<v[i].first<<endl;
            ans++;
            if(v[i].second>pre.second){
            }else{
                pre = v[i];
            }
        }else{
            pre=v[i];
        }

    }
    cout<<n-ans<<endl;




return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
const int maxn=2e5+100;
int a[maxn];
map < int,int > mapa,mapb;
struct{
	int sum[maxn*4],id[maxn*4];
	void down(int x,int l,int r){
		if (sum[x]){
			sum[x*2]=sum[x];
			sum[x*2+1]=sum[x];
			sum[x]=0;
		}
	}
	void build(int x,int l,int r){
		sum[x]=0;
		if (l==r){
			id[l]=x;
			return;
		} 
		int mid=(l+r)/2;
		build(x*2,l,mid);
		build(x*2+1,mid+1,r);
	}
	int find(int x,int l,int r,int L,int xx){
//		cout << "find:" << x << ' ' << l << ' ' << r << ' ' << sum[x] << ' ' << L << ' ' << xx << endl;
		if (l==L && l==r){
			while (l && sum[id[l]]==xx){
				l--;
//				cout << "find repeat:" << l << ' ' << x << ' ' << sum[x] << endl;
			}
			return l;
		}
		down(x,l,r);
		int mid=(l+r)/2;
		if (L<=mid) return find(x*2,l,mid,L,xx);
		return find(x*2+1,mid+1,r,L,xx);
	}
	void update(int x,int l,int r,int L,int R,bool ope){
		if (l==L && r==R){
			sum[x]=ope?sum[x]+1:1;
			return;
		}
		down(x,l,r);
		int mid=(l+r)/2;
		if (L<=mid) update(x*2,l,mid,L,min(R,mid),ope);
		if (R>mid) update(x*2+1,mid+1,r,max(L,mid+1),R,ope);
	}
	void print(int x,int l,int r){
		cout << "print_seg:" << x << ' ' << l << ' ' << r << ' ' << sum[x] << endl;
		if (l==r) return;
		int mid=(l+r)/2;
		print(x*2,l,mid);
		print(x*2+1,mid+1,r);
	} 
}seg;
vector < int > ve;
void myinit2(){
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> a[i];
		mapa[a[i]]++;
	}
	map < int,int > :: iterator it;
//	for (it=mapa.begin();it!=mapa.end();it++){
//		cout << it->first << ' ' << it->second << endl;
//	}
	int last=0,befo=-1;
	for (it=mapa.begin();it!=mapa.end();it++){
		if (befo==-1) last=min(it->first,it->second);
		else last=min(last+(it->second),last+(it->first)-befo);
//		cout << it->first << ' ' << last << endl; 
		mapb[it->first]=last;
		befo=it->first;
	}
	for (int i=1;i<=n;i++){
		a[i]=mapb[a[i]];
	}
//	for (int i=1;i<=n;i++) cout << a[i] << ' ';cout << endl;
}
bool check(int x){
	seg.build(1,1,n);
	seg.update(1,1,n,1,a[1],0);
	for (int i=2;i<=n;i++){
		if (a[i]>a[i-1]) seg.update(1,1,n,a[i-1]+1,a[i],0);
		else{
//			seg.print(1,1,n);
			int id=seg.find(1,1,n,a[i],x);
//			cout << i << ' ' << id << endl;
			if (id==0) return false;
			seg.update(1,1,n,id,id,1);
			if (id<a[i]) seg.update(1,1,n,id+1,a[i],0);
		}
	}
	return true;
}
signed main(){
	myinit2();
//	cout << check(1) << endl;
//  return 0;
	int l=1,r=1e6;
	while (r-l>1){
		int mid=(l+r)/2;
		if (check(mid)) r=mid;
		else l=mid;
	}
//	cout << l << ' ' << r << endl;
	int ans=check(l)?l:r;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35456
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  long long N, M, ans=1;
  cin >> N >> M;
  for(int i = 1; i <= sqrt(M); i++){
    if(M%i == 0 && i*N <= M && ans < i) ans = i;
    if(M%(M/i) == 0 && (M/i)*N <= M && ans < (M/i)) ans = M/i;
  }
  cout << ans << endl;
  return 0;
}

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

struct road
{
    int cost,time;
}ro[102];

bool cmp(road a,road b)
{
    return a.cost < b.cost;
}
int main()
{
    int n,t,k;
    while(cin >> n >> t)
    {
        for(int i = 0;i < n;i ++)
        cin >> ro[i].cost >> ro[i].time;
        sort(ro,ro + n,cmp);
        for(k = 0;k < n;k ++)
        {
            if(ro[k].time <= t)
            {
                cout << ro[k].cost << endl;
                break;
            }
        }
        if(k == n)
        cout << "TLE" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
def main():
    _ = int(input())
    aa = list(map(int, input().split()))
    x = aa[0]
    y = sum(aa[1:])
    res = abs(x - y)
    for a in aa[1:-1]:
        x += a
        y -= a
        res = min(res, abs(x - y))
    print(res)


if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin>>n;
  vector<int> a1(n),a2(n);
  int max_ans=0;
  rep(i,n){
    cin>>a1[i];
  }
  rep(i,n){
    cin>>a2[i];
  }
  rep(i,n){
    int ans=0;
    rep(j,i+1){
      ans+=a1[j];
    }
    for(int k=i;k<=n-1;k++){
      ans+=a2[k];
    }
    max_ans=max(max_ans,ans);
  }
  cout<<max_ans<<endl;
}

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

int main()
{
	std::set<long> s;
	long n, m;

	cin >> n;

	for (long i = 0; i < n; i++) {
		long t;
		cin >> t;
		s.insert(t);
	}

	cin >> m;

	for (long i = 0; i < m; i++) {
		long t;
		cin >> t;
		s.insert(t);
	}

	for (std::set<long>::iterator itr = s.begin(); itr != s.end(); itr++)
		cout << *itr << endl;

	return 0;
}


Measured memory_bytes: 21864
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    constexpr int inf = std::numeric_limits<int>::max();
    int n, m;
    std::cin >> n >> m;
    std::vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        int k;
        std::cin >> a[i] >> k;
        for (int j = 0; j < k; j++) {
            int c;
            std::cin >> c;
            b[i] |= (1 << (c - 1));
        }
    }

    std::vector<int> dp(1 << n, inf);
    dp[0] = 0;
    for (int i = 0; i < m; i++) {
        auto next(dp);
        for (int j = 0; j < (1 << n); j++) {
            if (dp[j] == inf) continue;
            next[j | b[i]] = std::min(next[j | b[i]], dp[j] + a[i]);
        }
        std::swap(dp, next);
    }

    std::cout << (dp.back() == inf ? -1 : dp.back()) << std::endl;

    return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n, ans = 0;
  cin >> n;
  int sum[10][10];
  Fill(sum, 0);
  rep(i, 1, n + 1) {
    int j = i % 10, k = i;
    while (k >= 10) k /= 10;
    ++sum[j][k];
  }

  rep(i, 1, 10) {
    rep(j, 1, 10) { ans += sum[i][j] * sum[j][i]; }
  }

  cout << ans << '\n';
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    int i;
    for (i=0; i<n; i++) cin >> a[i];
    int counter = 0;
    bool is_even = true;

    while (is_even) {
        counter++;
        for (i = 0; i < n; i++) {
            if (a[i] % 2 == 0) {
                a[i] /= 2;
            }
            else {
                is_even = false;
                counter--;
                break;
            }
        }
    }

    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#define llint long long
#define inf 1000000000000000000

using namespace std;

llint n;
llint dp[2005][4005][2];
llint r[2005], a[2005], w[2005], t[2005];
llint order[2005];

bool comp(llint i, llint j)
{
	return r[i]+t[i] < r[j]+t[j];
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> r[i] >> a[i] >> w[i] >> t[i];
	}
	for(int i = 1; i <= n; i++) order[i] = i;
	sort(order+1, order+n+1, comp);
	reverse(order+1, order+n+1);
	
	for(int i = 1; i <= n+1; i++){
		for(int j = 0; j <= 4000; j++){
			for(int k = 0; k < 2; k++){
				dp[i][j][k] = -inf;
			}
		}
		//dp[i][t[order[i]]][1] = a[order[i]];
	}
	dp[1][4000][0] = 0;
	for(int i = 1; i <= n; i++){
		int id = order[i];
		for(int j = 4000; j >= 0; j--){
			dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][0]);
			dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][1]);
			if(j >= r[id]){
				dp[i][min(t[id], j-r[id])][1] = max(dp[i][min(t[id], j-r[id])][1], dp[i][j][0] + a[id]);
				dp[i][min(t[id], j-r[id])][1] = max(dp[i][min(t[id], j-r[id])][1], dp[i][j][1] + w[id]);
			}
		}
	}
	llint ans = 0;
	for(int i = 1; i <= 4000; i++){
		for(int j = 0; j < 2; j++){
			ans = max(ans, dp[n+1][i][j]);
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 128472
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A,B,C;
  cin >> A >> B >> C;
  
  if (A%2==0 || B%2==0 || C%2==0){
    cout << 0 << endl;
  }
  else {
    vector<long long>D(3);
    D.at(0) = A;
    D.at(1) = B;
    D.at(2) = C;
    sort(D.begin(), D.end());
    long long E = D.at(0)*D.at(1);
    cout << E << endl;
  }
}

Measured memory_bytes: 3588
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <utility>
#include <functional>
#include <algorithm>
#include <iomanip>

using namespace std;

void solve(int r, int n) {
	vector<int> interval_height(42, 0);
	for (int i = 0; i < n; i++) {
		int left, right, h;
		cin >> left >> right >> h;
		for (int j = left + 21; j < right + 21; j++) {
			if (interval_height[j] < h) {
				interval_height[j] = h;
			}
		}
	}
	vector<int> height(r + 1, 0);
	for (int i = 0; i < r; i++) {
		int left_min = min(interval_height[-i + 21 - 1], interval_height[-i + 21]);
		int right_min = min(interval_height[i + 21 - 1], interval_height[i + 21]);
		height[i] = min(left_min, right_min);
	}

	double t = 2 << 15;
	for (int i = 0; i < r; i++) {
		double tt = height[i] + r - sqrt(r * r - i * i);
		if (tt < t) {
			t = tt;
		}
	}

	cout << fixed << setprecision(4) << t << endl;
}

int main() {
	int r, n;
	while (cin >> r >> n) {
		if (r == 0 && n == 0) {
			return 0;
		}
		solve(r, n);
	}
}

Measured memory_bytes: 3196
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A, B, T;
	
	cin >> A >> B >> T;

	cout <<  T / A * B << endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys
from itertools import accumulate, combinations
import numpy as np

read = sys.stdin.read

N, K, *a = map(int, read().split())

a = accumulate([0] + a)
seq = []
for i, j in combinations(a, 2):
    seq.append(j - i)

seq = np.array(seq, np.int64)
m = (10 ** 9 * 1000).bit_length()
answer = 0
bit = 1 << (m - 1)
for _ in range(m):
    tmp = seq[seq & bit == bit]
    if np.count_nonzero(tmp) >= K:
        answer += bit
        seq = tmp
    bit >>= 1

print(answer)


Measured memory_bytes: 36060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  int a, b, c, ans = 0;
  cin >> a >> b >> c;
  for (int i = a; i <= b; i++) {
    if (c % i == 0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int a,b;
    long long cnt = 0;

    cin >> a >> b;
    //a1+a2+a3 == b
    for(int i = 0;i <= a;i++){
        for(int j = 0;j <= a;j++){
            int k = b-i-j;
            if(k >= 0 && k <= a) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)








int main() {
    bool f[10] = {};
    int n1, n2, n3, n4;
    cin >> n1 >> n2 >> n3 >> n4;
    f[n1] = f[n2] = f[n3] = f[n4] = true;
    if(f[1] && f[9] && f[7] && f[4]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256