akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	ll a;
	string s;
	cin >> a >> s;

	if (a >= 3200) cout << s;
	else cout << "red";

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 888
'use strict'

function main(s) {  
  
  const input = s.split('\n')[1].split(' ').map(x => Number(x));
  const avg = Math.round(input.reduce((a, b) => a + b) / input.length);
  const result = input.map(x => Math.pow(avg - x, 2)).reduce((a, b) => a + b);
  
  console.log(result);
}

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


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(void)
{
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  ll ans = 0;
  ll a2, d;
  REP(i, n - 1) {
    a2 = a[i] + a[i + 1];
    if(a2 > x) {
      d = a2 - x;
      if(d > a[i + 1]) {
	a[i] -= d - a[i + 1];
	a[i + 1] = 0;
      } else {
	a[i + 1] -= d;
      }
      ans += d;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

int main() {
  map<int, int> mp;
  int num;
  bool c = false;

  cin >> num;

  rep(i,num) {
    int n;
    cin >> n;
    if(mp[n] > 0) {
      c = true;
      cout << "NO" << endl;
      return 0;
    }
    mp[n]++; //これでmapに挿入できる、同じのはvalueに+1してる
  }

  if(c == false) cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class ARingring {
public:
	void solve(istream& in, ostream& out) {
        vector<int> a(3);
        rep(i,3) in >> a[i];
        sort(a.begin(),a.end());
        int ans = 0;
        ans = a[0] + a[1];
        out << ans << endl;
	}
};

int main() {
	ARingring solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
int main() {
	ll n;
	cin>>n;
	vector<ll>ch;
	ll no;
	cin>>no;
	ch.push_back(-1*no);
	for(ll i=0;i<n-1;i++){
		ll now;
		cin>>now;
		now*=-1;
		auto itr=lower_bound(ch.begin(),ch.end(),now+1);
		if(itr!=ch.end()){
			ch[itr-ch.begin()]=now;
		}
		else{
			ch.push_back(now);
		}
	//	sort(ch.begin(),ch.end());
	//	cout << ch.size()<<endl;
	}
	cout <<ch.size();
	// your code goes here
	return 0;
}

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


public class Main {
	static final int T=540;
	static int student[][];
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N,M,r,i,j;
		int t,n,m,s;
		int t1,t2,q;
		int count[];

		while(true){
			N=sc.nextInt();
			M=sc.nextInt();
			if(N==0 && M==0) break;
			
			r=sc.nextInt();
			student=new int[M+1][720];
			count=new int[M+1];
			Arrays.fill(count, 0);
			for(i=1;i<=M;i++){
				for(j=0;j<720;j++){
					student[i][j]=0;
				}
			}
			for(i=0;i<r;i++){
				t=sc.nextInt();
				n=sc.nextInt();
				m=sc.nextInt();
				s=sc.nextInt();
				if(s==1){
					if(count[m]==0){
					student[m][t-T]=1;
					count[m]++;
					}
					else{
						count[m]++;
					}
				}
				if(s==0){
					if(count[m]==1){
						drow(m,t-1);
						count[m]--;
					}
					else{
						count[m]--;
					}
				}//
			}
			q=sc.nextInt();
			for(i=0;i<q;i++){
				t1=sc.nextInt();
				t2=sc.nextInt();
				m=sc.nextInt();
				System.out.println(sum(m,t1,t2));
			}
		}
	}
	static void drow(int m,int f){
		int i;
		for(i=f;0<=i;i--){
			if(student[m][i-T]==1) break;
			else student[m][i-T]=1;
		}
	}
	static int sum(int m,int t1,int t2){
		int i,sum=0;
		for(i=t1;i<t2;i++){
			sum+=student[m][i-T];
		}
		return sum;
	}
}

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

class ModInt {
public:
    ModInt(int64_t v, int64_t m) 
      : val(v % m), 
        mod(m)
    {
    }

    inline int64_t getVal() const noexcept {
        return this->val;
    }

    inline int64_t getMod() const noexcept {
        return this->mod;
    }

    inline ModInt operator - () const noexcept {
        return this->val ? ModInt(this->mod - this->val, this->mod) : ModInt(0, this->mod);
    }

    inline ModInt operator + (const ModInt& r) const noexcept {
        return ModInt(*this) += r;
    }

    inline ModInt operator - (const ModInt& r) const noexcept {
        return ModInt(*this) -= r;
    }

    inline ModInt operator * (const ModInt& r) const noexcept {
        return ModInt(*this) *= r;
    }

    inline ModInt operator / (const ModInt& r) const noexcept {
        return ModInt(*this) /= r;
    }

    inline ModInt& operator += (const ModInt& r) noexcept {
        this->val += r.val;
        this->val %= this->mod;
        return *this;
    }

    inline ModInt& operator -= (const ModInt& r) noexcept {
        this->val -= r.val;
        if (this->val < 0) {
            this->val += this->mod;
        }
        return *this;
    }

    inline ModInt& operator *= (const ModInt& r) noexcept {
        this->val = this->val * r.val % this->mod;
        return *this;
    }

    inline ModInt& operator /= (const ModInt& r) noexcept {
        int64_t a = r.val, b = this->mod, u = 1, v = 0;
        while (b) {
            int64_t t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        this->val = this->val * u % this->mod;
        if (val < 0) {
            val += this->mod;
        }

        return *this;
    }

    inline bool operator == (const ModInt& r) const noexcept {
        return this->val == r.val;
    }

    inline bool operator != (const ModInt& r) const noexcept {
        return this->val != r.val;
    }

    friend std::ostream& operator << (std::ostream& os, const ModInt& x) noexcept {
        return os << x.val;
    }

private:
    int64_t val;
    int64_t mod;
};

ModInt modpow(int64_t a, int64_t n, int64_t mod) {
    ModInt ret(1, mod);
    ModInt ma(a, mod);
    while (n > 0) {
        if (n & 1) {
            ret *= ma;
        }
        ma *= ma;
        n >>= 1;
    }

    return ret;
}

ModInt modconb(int64_t n, int64_t k, int64_t mod) {
    ModInt nu(1, mod);
    ModInt de(1, mod);

    for (int64_t i = 0; i < k; ++i) {
        nu *= ModInt(n-i, mod);
        de *= ModInt(i+1, mod);
    }

    return nu / de;
}

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

    static constexpr int64_t MOD = 1000000007;

    const ModInt c = modpow(2, n, MOD) - ModInt(1, MOD);
    const ModInt d = modconb(n, a, MOD);
    const ModInt e = modconb(n, b, MOD);

    std::cout <<  c - d - e << std::endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
const int N=1e4+10;
int a[N];
int mp[N];
int n,k;
char s1[15];
char s2[15];
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=0;
    if(k>a){
        k-=a;
        ans+=a;
    }
    else{
        ans+=k;
        k=0;

    }
    if(k>b){
        k-=b;

    }
    else{

        k=0;

    }
    if(k>c){
        k-=c;
        ans-=c;
    }
    else{
        ans-=k;
        k=0;

    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
S=input()
N=len(S)
l=(N-1)//2
for i in range(l):
  if S[i]!=S[N-1-i]:
    print('No')
    exit()
L=S[:l]
for i in range(l):
  if S[i]!=S[l-1-i]:
    print('No')
    exit()
print('Yes')


Measured memory_bytes: 61732
#include <stdio.h>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, h, w;
  scanf("%lld%lld%lld", &h, &w, &k);
  ll dp[h + 1][w + 2], cnt[20];
  cnt[0] = 1, cnt[1] = 1, cnt[2] = 1;
  for(i = 3; i < 20; ++i) cnt[i] = cnt[i - 1] + cnt[i - 2];
  for(i = 0; i < w + 2; ++i) dp[0][i] = (i == 1 ? 1 : 0);
  for(i = 0; i <= h; ++i) dp[i][0] = dp[i][w + 1] = 0;
  for(i = 1; i <= h; ++i) {
    for(j = 1; j <= w; ++j) {
      dp[i][j] = dp[i - 1][j - 1] * (cnt[j - 1] * cnt[w - j + 1]);
      dp[i][j] += dp[i - 1][j + 1] * (cnt[j] * cnt[w - j]);
      dp[i][j] += dp[i - 1][j] * (cnt[j] * cnt[w - j + 1]);
      dp[i][j] %= mod;
    }
  }
  printf("%lld", dp[h][k]);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repeq(i,a,b) for(int i=a;i<=(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vi a(n),b(n),dp1(n),dp2(n);
    rep(i,0,n) cin>>a[i];
    rep(i,0,n) cin>>b[i];
    dp1[0]=a[0];
    int acc=a[0]+b[0];
    rep(i,1,n) {
        dp1[i]=dp1[i-1]+a[i];
        acc=max(acc+b[i],dp1[i]+b[i]);
    }
    cout<<acc<<endl;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
if x in { 1, 3, 5, 7, 8, 10, 12 } and y in { 1, 3, 5, 7, 8, 10, 12 }:
  print("Yes")
elif x in { 4, 6, 9, 11 } and y in { 4, 6, 9, 11 }:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 2940
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define pb push_back
using namespace std;
const int P=139;
const int mod=998244353;
const int maxn=1e6+5;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int minn=0xc0c0c0c0;
ll k,n,l[maxn],r[maxn],dp[maxn],sum[maxn];
int main()
{
    scanf("%lld%lld",&n,&k);
	for(int i=1;i<=k;i++)
		scanf("%lld%lld",&l[i],&r[i]);
	sum[1]=1;
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
			dp[i]=(dp[i]+sum[max((ll)0,i-l[j])]-sum[max((ll)0,i-r[j]-1)])%mod;
		sum[i]=(sum[i-1]+dp[i])%mod;
	}
	printf("%lld\n",(dp[n]+mod)%mod);
    return 0;
}

Measured memory_bytes: 6868
#include <stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 100000

int prim(void);
int A[N][N],n;

int main()
{
    int i,j;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d",&A[i][j]);
            if(A[i][j] == -1) A[i][j] = INFTY;
            else;
        }
    }
    printf("%d\n", prim());
    
    return 0;
}

int prim()
{
    int i,u,v,minv,sum=0;
    int d[N],p[N],color[N];
    
    for(i=0;i<n;i++){
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }
    d[0] = 0;
    
    while(1){
        minv = INFTY;
        u = -1;
        for(i=0;i<n;i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) break;
        color[u] = BLACK;
        for(v=0;v<n;v++){
            if(color[v] != BLACK && A[u][v] != INFTY){
                if(d[v] > A[u][v]){
                    d[v] = A[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    for(i=0;i<n;i++){
        if(p[i] != -1) sum += A[i][p[i]];
    }
    return sum;
}



Measured memory_bytes: 2036
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
using T=tuple<int,int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};
template <typename Typ>
bool chmin(Typ &a, const Typ& b) {if (a > b) {a = b; return true;} return false;}
template <typename Typ>
bool chmax(Typ &a, const Typ& b) {if (a < b) {a = b; return true;} return false;}

string s;
int n;

bool check(vector<bool> x){
    bool ret =true;
    if(x[0]){
        if(s[0]=='o' && x[1]!=x[n-1]) ret =false;
        if(s[0]=='x' && x[1]==x[n-1]) ret =false;
    }
    else{
        if(s[0]=='x' && x[1]!=x[n-1]) ret =false;
        if(s[0]=='o' && x[1]==x[n-1]) ret =false;
    }

    if(x[n-1]){
        if(s[n-1]=='o' && x[0]!=x[n-2]) ret =false;
        if(s[n-1]=='x' && x[0]==x[n-2]) ret =false;
    }
    else{
        if(s[n-1]=='x' && x[0]!=x[n-2]) ret =false;
        if(s[n-1]=='o' && x[0]==x[n-2]) ret =false;
    }
    return ret;
}

int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
//cout << fixed << setprecision(10);
    cin>>n>>s;
    bool ok=false;
//ww
    vector<bool> ww(n,false);//w:false
    REP(i,1,n-1){
        if(s[i]=='o') ww[i+1]=ww[i-1];
        else ww[i+1]=(!ww[i-1]);
        if(!ww[i]) ww[i+1] =(!ww[i+1]);
    }
    ok=check(ww);
    if(ok){
        rep(i,n){
            cout<<(ww[i]?'S':'W');
        }
        cout<<endl;
        return 0;
    }
//ws
    vector<bool> ws(n,false);//w:false
    ws[1]=true;
    REP(i,1,n-1){
        if(s[i]=='o') ws[i+1]=ws[i-1];
        else ws[i+1]=(!ws[i-1]);
        if(!ws[i]) ws[i+1] =(!ws[i+1]);
    }
    ok=check(ws);
    if(ok){
        rep(i,n){
            cout<<(ws[i]?'S':'W');
        }
        cout<<endl;
        return 0;
    }
//sw
    vector<bool> sw(n,false);//w:false
    sw[0]=true;
    REP(i,1,n-1){
        if(s[i]=='o') sw[i+1]=sw[i-1];
        else sw[i+1]=(!sw[i-1]);
        if(!sw[i]) sw[i+1] =(!sw[i+1]);
    }
    ok=check(sw);
    if(ok){
        rep(i,n){
            cout<<(sw[i]?'S':'W');
        }
        cout<<endl;
        return 0;
    }
//ss
    vector<bool> ss(n,true);//w:false
    REP(i,1,n-1){
        if(s[i]=='o') ss[i+1]=ss[i-1];
        else ss[i+1]=(!ss[i-1]);
        if(!ss[i]) ss[i+1] =(!ss[i+1]);
    }
    ok=check(ss);
    if(ok){
        rep(i,n){
            cout<<(ss[i]?'S':'W');
        }
        cout<<endl;
        return 0;
    }
//ダメだった
    cout<<-1<<endl;
}/*
./problem.exe
*/


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

int main() {
  int N;
  cin >> N ; 
  for (int i = 0; i < N; i++) {
   int l, r, x;
    cin >> l >> r;
  x = x + r - l + 1;
    if (i == N -1){
      cout << x;
  }
 }     
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); ++i)
#define per(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,n) for (int i=(0); i<(n); ++i)
#define cmin(x,y) ((y)<(x)?(x)=(y):0)
#define cmax(x,y) ((y)>(x)?(x)=(y):0)
#define sqr(x) ((x) * (x))
using namespace std;

const int N = 16;
double x[N], y[N], a[N], d[N][N], f[1<<N];
int n;

int main() {
	scanf("%d", &n);
	rep (i, 1, n) scanf("%lf%lf%lf", &x[i], &y[i], &a[i]);
	rep (i, 1, n) rep (j, 1, n)
		d[i][j] = sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j]));
	fill(f, f + (1 << n), 1e99); f[0] = 0;
	REP (i, n) f[1<<i] = 0;
	REP (s, 1 << n) rep (i, 0, n - 1) rep (j, 0, n - 1)
		if ((s >> i & 1) && !(s >> j & 1))
			cmin(f[s|(1<<j)], f[s] + d[i+1][j+1]);
	REP (s, 1 << n) {
		f[s] = -f[s];
		REP (i, n) if (s >> i & 1) f[s] += a[i+1];
		f[s] /= __builtin_popcount(s);
		for (int t=(s-1)&s; t; t=(t-1)&s)
			cmax(f[s], min(f[t], f[s-t]));
	}
	printf("%.10lf\n", f[(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] arg) {
        Scanner sc = new Scanner(System.in);
        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();
        System.out.println(Math.max(a1, Math.max(a2, a3))-Math.min(a1, Math.min(a2, a3)));
    }
}

Measured memory_bytes: 23892
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


l = lc()

MOD = 10**9 + 7

llen = len(l)

dp = [[0]*2 for _ in range(llen+1)]

dp[1][0] = 1
dp[1][1] = 2

for i in range(1, llen):
    if l[i] == "0":
        dp[i+1][1] = dp[i][1]
        dp[i+1][0] = 3*dp[i][0]

    else:
        dp[i+1][1] = 2*dp[i][1]
        dp[i+1][0] = 3*dp[i][0] + dp[i][1]

    dp[i+1][1] %= MOD
    dp[i+1][0] %= MOD

print(sum(dp[llen]) % MOD)

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



int main(){
  string s;
  cin >> s;
  ll n = s.size();
  
  ll count=0;
  ll ans=0;
  for(int i=0; i<n; i++){
    if(s[i]=='T')count++;
    else count--;
    ans = max(count,ans);
  }

  ans*=2;
  
  cout << ans << endl;
  
}
       
        
      
  
    


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

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

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int main() {
   string s;
   getline(cin,s);
   rep(i,0,s.length()){
       if('a'<=s[i]&&s[i]<='z'){
           s[i]-='a'-'A';
       }
   }
   cout<<s<<endl;
    
    return 0;
}



Measured memory_bytes: 2992
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 1e9
using namespace std;
typedef long long ll;
static const ll MOD = 1000000007LL;

signed main() {
  // std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());
  int n;
  cin >> n;
  
  int max_1 = 0;
  int max_2 = 0;
  int max_1_idx = -1;

  REP(i, n){
    int tmp;
    cin >> tmp;
    if (tmp > max_1){
      max_2 = max_1;
      max_1 = tmp;
      max_1_idx = i;
    }
    else if (tmp > max_2){
      max_2 = tmp;
    }
  }
  REP(i, n){
    if (i == max_1_idx){
      cout << max_2 << endl;
    }
    else{
      cout << max_1 << endl;
    }
  }
}



Measured memory_bytes: 1664
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

k,s=MI()
count=0
for i in range(0,k+1):
    for j in range(0,k+1):
        if 0<=s-i-j<=k:
            count+=1
print(count)

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b;cin>>n>>a>>b;
  a-=b;
  vector<int> h(n);
  rep(i,n)cin>>h[i];
  int l=0,r=1e9+2;
  while(l+1<r){
      ll mid=(l+r)/2,cnt=0;
      vector<int> k;
      rep(i,n){
          if(h[i]>mid*b)cnt+=(h[i]-mid*b+a-1)/a;
      }
      if(cnt<=mid)r=mid;
      else l=mid;
  }
  cout<<r<<endl;
  return 0;
  }


Measured memory_bytes: 640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


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

	if (a != 2 && b != 2) {
		ANS("Yes")
	}
	else {
		ANS("No")
	}


	return 0;
}



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

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

    double D, E;
    while (cin >> D >> E, D||E) {
        double ans = DBL_MAX;
        for (int i = 0; i <= D/2; i++) {
            int j = D-i;
            ans = min(ans, abs(sqrt(i*i + j*j) - E));
        }
        printf("%.10f\n", ans);
    }

    return 0;
}

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

int main(){
  int N,A,B,C,F=1,Q=167167167;
  cin>>N>>A>>B>>C;
  vector<int> l(N);
  for(int i=0;i<N;i++){
    cin>>l[i];
    F*=4;
  }
  for(int i=1;i<F;i++){
    int D=i,X=0,Y=0,Z=0,K=0;
    for(int j=0;j<N;j++){
      if(D%4==1){
        X+=l[j];
      }
      else if(D%4==2){
        Y+=l[j];
      }
      else if(D%4==3){
        Z+=l[j];
      }
      else{
        K++;
      }
      D/=4;
    }
    if(X*Y*Z){
      Q=min(Q,abs(A-X)+abs(B-Y)+abs(C-Z)+10*(N-K-3));
    }
  }
  cout<<Q<<endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, K;
    cin >> N >> K;
    ll xi, yi;
    vector<ll> X, Y;
    for(int i=0;i<N;i++){
        cin >> xi >> yi;
        X.push_back(xi);
        Y.push_back(yi);
    }
    auto Xs = X;
    auto Ys = Y;
    sort(Xs.begin(), Xs.end());
    sort(Ys.begin(), Ys.end());
    vector<vector<ll>> sum(Xs.size(), vector<ll>(Ys.size(), 0));
    for(int i=0;i<N;i++){
        auto x = distance(Xs.begin(), lower_bound(Xs.begin(), Xs.end(), X[i]));
        auto y = distance(Ys.begin(), lower_bound(Ys.begin(), Ys.end(), Y[i]));
        sum[x][y]++;
    }
    for(int i=0;i<Xs.size();i++){
        for(int j=0;j<Ys.size();j++){
            if(i>0) sum[i][j] += sum[i-1][j];
            if(j>0) sum[i][j] += sum[i][j-1];
            if(i>0 && j>0) sum[i][j] -= sum[i-1][j-1];
        }
    }

    ll res = LLONG_MAX;
    for(int i1=0;i1<Xs.size();i1++){
        for(int i2=i1+1;i2<Xs.size();i2++){
            for(int j1=0;j1<Ys.size();j1++){
                for(int j2=j1+1;j2<Ys.size();j2++){
                    ll c = sum[i2][j2];
                    if(i1>0) c -= sum[i1-1][j2];
                    if(j1>0) c -= sum[i2][j1-1];
                    if(i1>0 && j1>0) c += sum[i1-1][j1-1];
                    if(c >= K){
                        res = min(res, (Xs[i2]-Xs[i1]) * (Ys[j2]-Ys[j1]));
                    }
                }
            }
        }
    }
    
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main( int argc, char *argv[] )
{
    char s[4];

    scanf( "%s", s );

    if( ! strcmp( s, "RRR" ) ) {
        puts( "3" ); exit( 0 );
    } else if( ! strcmp( s, "RRS" ) ) {
        puts( "2" ); exit( 0 );
    } else if( ! strcmp( s, "RSR" ) ) {
        puts( "1" ); exit( 0 );
    } else if( ! strcmp( s, "RSS" ) ) {
        puts( "1" ); exit( 0 );
    } else if( ! strcmp( s, "SSS" ) ) {
        puts( "0" ); exit( 0 );
    } else if( ! strcmp( s, "SSR" ) ) {
        puts( "1" ); exit( 0 );
    } else if( ! strcmp( s, "SRS" ) ) {
        puts( "1" ); exit( 0 );
    } else if( ! strcmp( s, "SRR" ) ) {
        puts( "2" ); exit( 0 );
    }

    puts( "0" );
}


Measured memory_bytes: 1624
#include<stdio.h>
#include<math.h>

int main(){
  long long a,i,j,wa=1000000000001;
  scanf("%lld",&a);
  for(i=1;i<=sqrt(a);i++){
    if(a%i==0){
      long long x=a/i;
      wa=wa>(x+i)?(x+i):wa;
    }
  }
  printf("%lld",wa-2);
  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int[] a = new int[5];
        for(int i = 0; i < 5; i++) {
            a[i] = Integer.parseInt(br.readLine());
        }
        int k = Integer.parseInt(br.readLine());

        boolean flag = false;
        for(int i = 0; i < 4; i++) {
            for(int j = i + 1; j < 5; j++) {
                if(a[j] - a[i] > k) {
                    flag = true;
                    break;
                }
            }
        }

        System.out.println(flag? ":(" : "Yay!");
    }
}

Measured memory_bytes: 22996
=begin
1. Nを素因数分解し、N = p[0]**e[0] * p[1]**e[1] * ... * p[M-1]**e[M-1]と置く
2. それぞれのi∈[0, M)について、e[i]をk[i]個までの正の整数の和に分解することができる最大のk[i]を求める
3. k[i]の総和を出力する

2.において、鳩ノ巣原理よりe[i] >= k[i]*(k[i]+1)/2
=end

require "prime"

n = gets.to_i

cnt = n.prime_division(Prime::EratosthenesGenerator.new).sum do |(_, e)|
  ac, wa = 0, 10000000
  while ac + 1 < wa
    wj = (ac + wa) / 2
    if wj*(wj+1)/2 <= e
      ac = wj
    else
      wa = wj
    end
  end
  ac
end

p cnt

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

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    int ans = max(H, W);
    int flag = 0;
    if (N % ans != 0) flag = 1;
    ans = N / ans + flag;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

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

int main()
{
    int n,W;
    cin>>n>>W;
    long long int dp[W+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++){
        long long int val;
        int wt;
        cin>>wt>>val;
        for(int w=W-wt;w>=0;w--){
            dp[w+wt]=max(dp[w+wt],dp[w]+val);
        }
    }
    long long int ans=*max_element(dp,dp+W+1);
    cout<<ans;
    //printf("Hello World");

    return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 1e6 + 10;
int n, q;
ll ans;
int a[N], cnt[N];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		ans += a[i];
		cnt[a[i]]++;
	}
	scanf("%d", &q);
	while (q--) {
		int b, c;
		scanf("%d%d", &b, &c);
		ans += 1ll*(c - b)*cnt[b];
		cnt[c] += cnt[b];
		cnt[b] = 0;
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 4612
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)

#define debug(n) cout << n << endl;

#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

template<typename T> bool chmax(T&a,T b) { if(a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T&a,T b) { if(a > b) {a = b; return true;} return false;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const ll MOD = 1000000007;

ll N, T;
vector<ll> a;
ll best_profit = -1;
ll ans = 0;

typedef vector<ll>::iterator it;

ll search_distance(it l, it r)
{
    if (l == r) return 0;

    it max = max_element(l, r);
    it min = min_element(l, max);

    ll t_best = *max - *min;
    if (t_best > best_profit) {
        best_profit = t_best;
        ans = 1;
    }
    else if (t_best == best_profit) {
        ans++; // count up
    }

    ll r_best = search_distance(max+1, r);

    ll best = t_best;
    chmax(best, r_best);
    return best;
}

int main(void)
{
    cin >> N >> T;
    rep(i, N) {
        ll tmp;
        scanf("%lld", &tmp);
        a.emplace_back(tmp);
    }

    ll max = search_distance(a.begin(), a.end());
    debug(ans);

    return 0;
}


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

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

  int N;
  cin >> N;

  if(N == 1) {
    cout << "Hello World" << endl;
  } else {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int n;
  while(cin >> n ,n){
    int k, s=0, f=0;
    for(int i=0; i<n; i++){
      cin >> k;
      if(k >= 1) s++;
      if(k > 1) f=1;
    }
    if(!f)cout << "NA" << endl;
    else cout << s+1 << endl;
  }
}


Measured memory_bytes: 3104
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


S = sys.stdin.readline().rstrip()
T = sys.stdin.readline().rstrip()

table = {}
ok = True
for i, t in enumerate(T):
    if t not in table:
        table[t] = S[i]
    if table[t] != S[i]:
        ok = False
if ok and len(set(table.values())) == len(table):
    print('Yes')
else:
    print('No')




Measured memory_bytes: 15688
s=input()
for bit in range(1<<3):
  ans=int(s[0])
  f=s[0]
  for i in range(3):
    if bit & (1<<i):
      ans+=int(s[i+1])
      f+="+"
    else:
      ans-=int(s[i+1])
      f+="-"
    f+=s[i+1]
  if ans==7:
    print(f+"=7")
    break
      

Measured memory_bytes: 38384
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def warshall_floyd(d):
    V = len(d)
    for k in range(V):
        for i in range(V):
            for j in range(V):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

def resolve():
    H, W = LI()
    c = [LI() for _ in range(10)]
    A = [LI() for _ in range(H)]

    min_cost = warshall_floyd(c)
    # for i in min_cost:
    #     print(i)
    ans = 0
    for i in A:
        for j in i:
            if 0<=j<=9:
                ans += min_cost[j][1]
    print(ans)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3444
// https://atcoder.jp/contests/abc099/tasks/abc099_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int a, b;

  cin >> a >> b;

  int i = b - a - 1;

  int x = i * (i + 1) / 2 - a;

  cout << x << '\n';

  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, c1, c2, a, b;
vector<int> e[N];
vector<int> q1, q2, t1, t2;
bool visited[N];

int main() {
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    q1.push_back(1);
    q2.push_back(n);
    visited[1] = true;
    visited[n] = true;
    while (!q1.empty() || !q2.empty()) {
        if (!q1.empty()) {
            c1 += q1.size();
            for (auto i : q1) {
                for (auto j : e[i]) {
                    if (!visited[j]) {
                        visited[j] = true;
                        t1.push_back(j);
                    }
                }
            }
            q1 = t1;
            t1.clear();
        }
        if (!q2.empty()) {
            c2 += q2.size();
            for (auto i : q2) {
                for (auto j : e[i]) {
                    if (!visited[j]) {
                        visited[j] = true;
                        t2.push_back(j);
                    }
                }
            }
            q2 = t2;
            t2.clear();
        }
    }
    if (c1 > c2)
        cout << "Fennec" << endl;
    else
        cout << "Snuke" << endl;
    return 0;
}


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

int n;
vector <pair<int, int> > adj[10000];

//dijkstra
void dijkstra() {
  priority_queue<pair<int, int> > PQ;
  int d[10000];
  for ( int i = 0; i < n; i++ ) {
    d[i] = 10000000;
  }
  d[0] = 0;
  PQ.push(make_pair(0,0));

  while ( !PQ.empty() ) {
    pair<int, int> f = PQ.top(); PQ.pop();
    int u = f.second;
    if ( d[u] < f.first * -1 ) continue;

    for ( int j = 0; j < adj[u].size(); j++ ) {
      int v = adj[u][j].first;
      if ( d[v] > d[u] + adj[u][j].second ) {
	d[v] = d[u] + adj[u][j].second;
	PQ.push(make_pair(d[v] * -1,v));
      }
    }
  }

  //出力
  for ( int i = 0; i < n; i++ ) {
    cout << i << " " << d[i] << endl;
  }
  
}

int main() {
  int k,u,v,c;
  
  //入力
  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> u >> k;
    for ( int j = 0; j < k; j++ ) {
      cin >> v >> c;
      adj[u].push_back(make_pair(v,c));
    }
  }

  dijkstra();

  return 0;
}

Measured memory_bytes: 6296
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var list = new List<string>();
            for (int i = 0; i < n; i++)
            {
                var st = Read();
                list.Add(st);
            }
            var X = Read();

            var ans = 0;
            var Count = false;
            for (int i = 0; i < n; i++)
            {
                if (Count == true)
                {
                    ans += int.Parse(list[i].Split(' ')[1]);
                }
                if(list[i].Split(' ')[0] == X)
                {
                    Count = true;
                }
            }
            WriteLine(ans);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main(){
    int n; cin >> n;
    int f[n][10], p[n][10];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> f[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= 10; j++){
            cin >> p[i][j];
        }
    }

    int ans = -(1<<30);
    for(int i = 1; i < (1<<10); i++){//10個の時間帯の組み合わせを考える
        int sum = 0;
        for(int  j = 0; j < n; j++){
            int count = 0;
            for(int k = 0; k < 10; k++){
                if((i>>k&1) && f[j][k]) count++;
            }
            sum += p[j][count];
        }
        chmax(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int ans = 0;
  int max1 = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
      ans++;
      max1 = max(ans,max1);
    }
    else{
      ans = 0;
    }
  }
  cout << max1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;

int main() {
    cin >> n;
    
    llong ans = 1;
    while (ans <= n) ans <<= 1;
    ans >>= 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*
      author : Nishikawa
      created: 05.08.2020 21:05:19
*/

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


int main(){
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3624
import numpy as np

def main():
    s = np.array([str(i) for i in input()], dtype=np.unicode)
    t = np.array([str(i) for i in input()], dtype=np.unicode)

    num_s = int(s.shape[0])
    num_t = int(t.shape[0])


    dp = np.zeros((num_s +1, num_t +1), dtype='int64')

    eq = s[:,None] == t[None,:]
    # print(len(eq[0]))

    for i in range(num_s):
        np.maximum(dp[i, 1:], dp[i, :-1] + eq[i], out=dp[i+1, 1:])
        np.maximum.accumulate(dp[i+1], out=dp[i+1])
    # print(dp)

    res=''
    pos_s = num_s
    pos_t = num_t


    while len(res) < np.max(dp[num_s]):
        temp = dp[pos_s, pos_t]
        # print(temp)
        if dp[pos_s-1, pos_t] == temp:
            pos_s -= 1

        if dp[pos_s, pos_t-1] == temp:
            pos_t -= 1

        if s[pos_s - 1] == t[pos_t - 1]:
            res += s[pos_s-1]
            pos_s -= 1
            pos_t -= 1

        # print(res, pos_s-1)
        
    print(res[::-1])

main()

Measured memory_bytes: 91360
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
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(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N)cin >> A[i];
    sort(All(A));
    int minus_cnt = 0;
    ll res = 0;
    int mini = 1e9+10;
    for(int i=0;i<N;i++){
        if(A[i]<0)minus_cnt++;
        if(abs(A[i])<mini)mini=abs(A[i]);
        res+=abs(A[i]);
    }
    if(minus_cnt%2==1)res-=mini*2;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
/*
 ***
 Question Name:
 ***
 Question Link:
 
 ***
 Idea:
 */

#include <memory.h>
#include <iomanip>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef unordered_set<int> ui;
typedef pair<LL,LL> pLL;

class ColoringDominoes{
    const LL MOD = 1000000007;
    int N;
    string s1, s2;
public:
    int solve(){
        cin>>N>>s1>>s2;
        vector<vector<vL>> dp(N, vector<vL>(3, vL(3, (LL)0)));
        LL ans = (LL)0;
        for(int j=0;j<3;++j) for(int k=0;k<3;++k) if((s1[0]==s2[0]) == (j == k)) dp[0][j][k] = 1;
        for(int i=1;i<N;++i) for(int j=0;j<3;++j) for(int k=0;k<3;++k){
            if((s1[i]==s2[i]) != (j == k)) continue;
            for(int r=0;r<3;++r) for(int t=0;t<3;++t){
                if((s1[i-1]==s2[i-1])!= (r==t)) continue;
                if((s1[i]==s1[i-1]) != (r==j)) continue;
                if((s2[i]==s2[i-1]) != (t==k)) continue;
                dp[i][j][k] += dp[i-1][r][t];
            }
            dp[i][j][k]%=MOD;
        }
        for(int j=0;j<3;++j) for(int k=0;k<3;++k) ans += dp[N-1][j][k];
        return (int)(ans%MOD);
    }
};



int main(){
    cout<< ColoringDominoes().solve() <<endl;
    return 0;
}

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

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 long long INF = 1LL << 60;

int main() {
    int n, k;
    long long h[100100];
    long long dp[100100];

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

    for (int i = 0; i < 100100; i++) dp[i] = INF;

    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;



int main(void) {
    ll N, K;
    cin >> N >> K;
    ll a[111];
    ll dp[101010];
    ll i, j;
    
    for(i=0; i<N; i++) cin >> a[i];
    
    dp[0]=0;
    for(i=1; i<=K; i++) {
        for(j=0; j<N; j++) {
            if(i>=a[j] && dp[i-a[j]]==0) {
                dp[i]=1;
                break;
            }
        }
    }
    
    if(dp[K]) puts("First");
    else puts("Second");
    
}






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

using namespace std;
typedef long long ll;

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

    int ans = 10000000;
    for (int i = 0; i < s.size() - 2; i++){
        int tmp = int(s[i] - '0') * 100 + int(s[i + 1] - '0') * 10 + int(s[i + 2] - '0');
        ans = min(ans, abs(753 - tmp));
    }

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

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

int main()
{
	int n, j = 0;
	long long a, s = 0, m = 1000000000;

	cin >> n;

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

		if (a < 0)
			j++;

		s += abs(a);
		m = min(m, abs(a));
	}

	if (j % 2 == 0)
		cout << s << endl;
	else
		cout << s - m * 2 << endl;

	return 0;
}

Measured memory_bytes: 256