akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int r;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> r;
  if(r < 1200){
    cout << "ABC" << endl;
  }else if(r < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int n, a, b;
  cin >> n >> a >> b;

  if (a*n < b) pr(a*n);
  else pr(b);


  return 0;
}


Measured memory_bytes: 256
#include <iostream>

char group(int x) {
    char res;
    if (x == 2) res = 'C';
    else if (x == 4 || x == 6 || x == 9 || x == 11) res = 'B';
    else res = 'A';
    return res;
}

int x, y;
std::string res;

int main() {
    std::cin >> x >> y;
    res = (group(x) == group(y)) ? "Yes" : "No";
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
if n>=1:
    if m>=1:
        print((n-1)*n//2+(m-1)*m//2)
    else:
        print((n-1)*n//2)
else:
    if m>=1:
        print((m-1)*m//2)
    else:
        print(0)

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

typedef long long ll;
typedef unsigned long long ull;
typedef  unsigned int uint;
typedef  long double ld;

unordered_map<ll, ll> f;

void primeFactors(ll n)  
{  
    while (n % 2 == 0)  
    {  
    	f[2]++;
        n = n/2;  
    }  
  
    for (ll i = 3; i * i <= n; i = i + 2)  
    {  
        while (n % i == 0)  
        {  
        	f[i]++;
            n = n/i;  
        }  
    }  

    if (n > 2)  
        f[n]++;
}  

int main()
{

	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll n;
	cin >> n;

	primeFactors(n);

	// for (auto &it : f)
	// 	cout << it.first << ": " << it.second<< "\n";

	ll ans = 0;
	for (auto &it: f)
	{
		ll i = 1;
		while (it.second >= i)
		{
			it.second -= i;
			ans++;
			i++;
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(),v.end());
    int ans = 0;
    if((v[2] - v[0])%2&&(v[2] - v[1])%2){
        ans = v[2] - v[1] + (v[1] - v[0])/2;
    }else {
        if((v[2] - v[0])%2) ans += (v[2] - v[0] + 1)/2 + 1;
        else ans += (v[2] - v[0])/2;
        if((v[2] - v[1])%2) ans += (v[2] - v[1] + 1)/2 + 1;
        else ans += (v[2] - v[1])/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main()
    {
        long x = long.Parse(Console.ReadLine());
        long ans = x / 11 * 2;
        if (x % 11 == 0) ;
        else if (x % 11 <= 6) ans += 1;
        else ans += 2;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
bc = [[0] * 2] * m

for i in range(m):
    bc[i] = list(map(int, input().split()))

a.sort()
bc = sorted(bc, key=lambda x: -x[1])
new = []

cnt = 0

for e in bc:
    new.extend([e[1]] * e[0])
    cnt += e[0]

    if (n <= cnt):
        break

for i in range(min(n, cnt)):
    a[i] = max(a[i], new[i])

print(sum(a))


Measured memory_bytes: 83180
fun main(args : Array<String>) {
    var S = readLine()!!
    val T = readLine()!!

    val length = S.length

    var answer = false

    if (S == T) {
        println("Yes")
        return
    }
    for (i in 1..length) {
        S = S.last() + S.dropLast(1)
        if (S == T) {
            answer = true
            break
        }
    }

    if (answer) {
        println("Yes")
    } else {
        println("No")
    }
}

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

int main() {
    ll n, m;
    cin >> n >> m;

    ll ans = 0;
    if (n <= m / 2) {
        ans += n;
        m -= n * 2;
        ans += m / 4;
    } else {
        ans = m / 2;
    }

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


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;

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

	string a,b;
	cin>>a>>b;
	int ans=0;
	for(int i=0;i<3;i++){
		if(a[i]==b[i]) ans++;
	}
	cout<<ans<<endl;

	return 0;
}

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

int main() {
    int cnt[26]{};
    string s;cin>>s;
    for (char c:s)
        cnt[c-'a']++;
    for (int i=0;i<26;i++)
        if (cnt[i]==0) {
            cout<<char('a'+i)<<endl;
            return 0;
        }
    puts("None");
    return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

        long[] arr = new long[N];

        long[] res = new long[N];


        for(int i = 0; i < N; i++) {
            arr[i] = 2 * sc.nextInt();
        }

        int test = 0;
        long sum = 0;
        for(int j = 0; j < N; j++) {
            if (test == 0) {
                sum = sum + arr[j];
                test = 1;
            }
            else {
                sum = sum - arr[j];
                test = 0;
            }
        }
        long first = sum / 2;


        for(int i = 0; i < N; i++) {
            long temp = first;
            first = arr[i] - first;
            res[i] = temp;

        }

        for(int i = 0; i < N; i++) {
            System.out.print(res[i] + " ");
        }
    }
}


Measured memory_bytes: 64512
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define pb push_back 
#define F first 
#define S second 
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 

using namespace std;

void test(){
	double x;
	cin>>x;
	x = 2*x;
	x = x*(3.14159);
	cout<<x<<"\n";
}

int main(){
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}

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

int main(){
    long long N;
    scanf("%lld", &N);

    vector<long long> A(N), B(N);
    long long sa(0), sb(0);

    for(auto& i : A){
        scanf("%lld", &i);
        sa += i;
    }
    for(auto& i : B){
        scanf("%lld", &i);
        sb += i;
    }

    if(sa < sb)return 0 & puts("-1");

    vector<long long> lg({0});
    long long S(0), a(0);

    for(int i = 0; i < N; ++i){
        if(A[i] < B[i]){
            S += B[i] - A[i];
            ++a;
        }else{
            lg.push_back(A[i] - B[i]);
        }
    }

    sort(lg.rbegin(), lg.rend() - 1);
    partial_sum(lg.begin(), lg.end(), lg.begin());

    printf("%lld", a + (lower_bound(lg.begin(), lg.end(), S) - lg.begin()));

    return 0;
}

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

int main(){
  ll N; cin>>N;
  map<ll, ll> A;
  for(ll i=0; i<N; i++){
    ll a; cin>>a;
    if(A.count(a)) A[a]++;
    else A[a]=1;
  }
  ll ans=0;
  for(auto p:A){
    auto k=p.first;
    auto v=p.second;
    if(v<k) ans+=v;
    else if(v>=k) ans+=(v-k);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6272
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

int main() {
   int a,b,c;
   cin>>a>>b>>c;
   if(a==b&&b==c){
       cout<<1<<endl;
   }
   else{
       if(a!=b&&b!=c&&a!=c){
           cout<<3<<endl;
       }
       else{
           cout<<2<<endl;
       }
   }
}


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

int main()
{
    long D;
    cin >> D;
    long c[26];
    long sd[D][26];
    for (long i = 0; i < 26; i++)
        cin >> c[i];
    for (long i = 0; i < D; i++)
    {
        for (long k = 0; k < 26; k++)
        {
            cin >> sd[i][k];
        }
    }
    long ans[D];
    ans[0] = 0;
    long lastDay[26];
    for (long i = 0; i < 26; i++)
    {
        lastDay[i] = 0;
    }
    long diff = -99999999999999999;
    long tmp = 0;
    for (long i = 0; i < D; i++)
    {
        for (long j = 0; j < 26; j++)
        {
            if (diff<sd[i][j]+c[j] * ((i + 1) - lastDay[j])){
                diff = sd[i][j] +c[j] * ((i + 1) - lastDay[j]);
                tmp = j;
            }
        }
        lastDay[tmp] = i;
        ans[i] = tmp+1;
        diff = -999999999999999999;
    }
    for (long i = 0; i < D; i++)
        cout << ans[i] << endl;
}


Measured memory_bytes: 3676
use std::cmp::max;
use std::cmp::min;
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|e| e.parse().unwrap());
    let n: i64 = itr.next().unwrap();
    let x: i64 = itr.next().unwrap();
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut a: Vec<i64> = s.split_whitespace().map(|e| e.parse().unwrap()).collect();
    let mut ans = 0;

    for e in &mut a {
        let t = min(*e, x);
        ans += *e - t;
        *e = t;
    }

    for i in 1..a.len() {
        let mut t = max(0, a[i] + a[i - 1] - x);
        ans += t;
        a[i - 1] = min(a[i] + a[i - 1] - t, a[i - 1]);
        a[i] = max(0, a[i] - t);
    }

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <stdio.h>
#include <stdlib.h>
int i,s[100],top,a,b,x;
char t[100];
void push(int x){
    top++;
    s[top]=x;
}
int pop(){
    top--;
    return s[top+1];
}
int main(void){
    for(;~scanf("%s",t);){
        switch(t[0]){
            case'+':a=pop();b=pop();push(a+b);break;
            case'-':a=pop();b=pop();push(b-a);break;
            case'*':a=pop();b=pop();push(a*b);break;
            default:push(atoi(t));
        }
    }
    printf("%d\n",s[1]);

}

Measured memory_bytes: 1856
a = list(input())
b = list(input())
c = len(a)
p = 0
d = [0 for i in range(27)]
l = [[]for i in range(27)]
h = [[]for i in range(27)]
ll = [0 for i in range(27)]
if a == b:
	print("Yes")
else:
	for i in range(c):
		k = ord(b[i])-97
		if a[i] in l[k]:
			p = 0
		else:
			if len(l[k]) == 0:
				l[k].append(a[i])
			else:
				p = 1
				break
		k = ord(a[i])-97
		if b[i] in h[k]:
			p = 0
		else:
			if len(h[k]) == 0:
				h[k].append(b[i])
			else:
				p = 1
				break
	if p == 1:
		print("No")
	else:
		print("Yes")

Measured memory_bytes: 6832
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 55
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<string,string> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};


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

    int N;
    string S;
    cin>>N>>S;
    map<P,int> M;
    for(int B=0;B<(1L<<N);B++){
        string a="",b="";
        for(int i=0;i<N;i++){
            if(bit(B,i)) a.push_back(S[i+N]);
            else b.push_back(S[i+N]);
        }
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        M[P(a,b)]++;
    }
    ll ans=0;
    for(int B=0;B<(1L<<N);B++){
        string a="",b="";
        for(int i=0;i<N;i++){
            if(bit(B,i)) a.push_back(S[i]);
            else b.push_back(S[i]);
        }
        ans+=M[P(b,a)];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 87040
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  LL N; cin >> N;
  vector<LL> A(N); cin >> A;
  sort(A.begin(), A.end());

  LL mid = ceil((double)A[N-1]/2);
  LL vmin = 1e18;
  LL k = 0;
  for (int i = 0; i < N; ++i) {
    LL x = min(A[i], A[N-1]-A[i]);
    if (vmin > (mid - x)) {
      k = A[i];
      vmin = mid - x;
    }
  }
  cout << A[N-1] << " " << k << endl;
}


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

int main(){
    //入力
    int H,W;
    cin >> H >> W;

    vector<vector<char>> a(H,vector<char>(W));
    vector<vector<char>> ans(H+2,vector<char>((W+2),'#'));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> a.at(i).at(j);
        }
    }

    //処理
    for(int i=1;i<H+1;i++){
        for(int j=1;j<W+1;j++){
            ans.at(i).at(j)=a.at(i-1).at(j-1);
        }
    }


    //出力
    for(int i=0;i<H+2;i++){
        for(int j=0;j<W+2;j++){
            cout << ans.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#168 - F
import sys
import numpy as np
#from numba import njit


def main():
    N, M = map(int, sys.stdin.buffer.readline().split())
    LineData = np.int64(sys.stdin.buffer.read().split())

    INF = 10**9 + 1

    LineData = LineData.reshape(-1, 3)
    A, B, C = LineData[:N].T
    D, E, F = LineData[N:].T
    #X = np.unique(np.concatenate([D, [-INF, 0, INF]]))
    #Y = np.unique(np.concatenate([C, [-INF, 0, INF]]))
    X = np.unique(np.concatenate([D, [-INF, INF]]))
    Y = np.unique(np.concatenate([C, [-INF, INF]]))
    A = np.searchsorted(X, A)
    B = np.searchsorted(X, B, 'right') - 1
    C = np.searchsorted(Y, C)
    D = np.searchsorted(X, D)
    E = np.searchsorted(Y, E)
    F = np.searchsorted(Y, F, 'right') - 1

    area = cal_area(A, B, C, D, E, F, X, Y)

    if area == 0:
        print("INF")
    else:
        print(area)


#@njit
def cal_area(A, B, C, D, E, F, X, Y):
    x = np.searchsorted(X, 0, 'right') - 1
    y = np.searchsorted(Y, 0, 'right') - 1

    DX = X[1:] - X[:-1]
    DY = Y[1:] - Y[:-1]

    A = A.tolist()
    B = B.tolist()
    C = C.tolist()
    D = D.tolist()
    E = E.tolist()
    F = F.tolist()
    X = X.tolist()
    Y = Y.tolist()
    DX = DX.tolist()
    DY = DY.tolist()

    LenX = len(X)
    LenY = len(Y)

    visit = [[False] * LenY for _ in range(LenX)]
    visit[x][y] = True
    area = 0
    queue = [(x, y)]

    LineX = [[False] * LenY for _ in range(LenX)]
    LineY = [[False] * LenY for _ in range(LenX)]

    for x1, x2, y in zip(A, B, C):
        for x in range(x1, x2):
            LineY[x][y] = True

    for x, y1, y2 in zip(D, E, F):
        for y in range(y1, y2):
            LineX[x][y] = True

    LenX -= 1
    LenY -= 1
    
    while queue:
        x, y = queue.pop()

        if x == 0 or x == LenX or y == 0 or y == LenY:
            area = 0
            break
        
        area += DX[x] * DY[y]

        if not LineX[x][y] and not visit[x - 1][y]:
            visit[x - 1][y] = True
            queue.append((x - 1, y))
        if not LineY[x][y] and not visit[x][y - 1]:
            visit[x][y - 1] = True
            queue.append((x, y - 1))
        if not LineX[x + 1][y] and not visit[x + 1][y]:
            visit[x + 1][y] = True
            queue.append((x + 1, y))
        if not LineY[x][y + 1] and not visit[x][y + 1]:
            visit[x][y + 1] = True
            queue.append((x, y + 1))

    return area


if __name__ == '__main__':
	main()

sys.exit()


Measured memory_bytes: 66128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    for(int i = 1; i < N; i++)
    {
        int cnt = 0;
        for(char c = 'a'; c <= 'z'; c++)
        {
            bool left = false,right = false;
            for(int j = 0; j < i; j++) //左側の判定
            {
                if(S.at(j) == c)
                {
                    left = true;
                }
            }
            for(int j = i; j < N; j++) //右側の判定
            {
                if(S.at(j) == c)
                {
                    right = true;
                }
            }
            if(left && right)
            {
                cnt++;
            }
        }
        if(ans < cnt)
        {
            ans = cnt;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<bool> ans(N);
  for(int i = 0; i < K; i++) {
    int D;
    cin >> D;
    vector<int> snack(D);
    for (int l = 0; l<D ; l++) {
      cin >> snack.at(l);
    }
    for (int l = 0; l<D ; l++) {
      ans.at(snack.at(l)-1) = true;
    }
  }
  int answer = 0;
  for(int i=0; i < N; i++) {
    if (!(ans.at(i))) {
      answer++;
    }
  }
  cout << answer << endl;
    }

Measured memory_bytes: 3616
import math
N=int(input())
MOD = (10**9)+7
a=pow(10,N,MOD)
b=pow(8,N,MOD)
c=pow(9,N,MOD)
d=(c*2)%MOD
if a+b-d<0:
  print((a+b-d+MOD)%MOD)
else:
  print((a+b-d)%MOD)

Measured memory_bytes: 8920
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    N = II()
    l_list = LI()

    # 短い順
    l_list = sorted(l_list)
    ind_list = list(range(len(l_list)))

    from bisect import bisect_left, bisect_right
    from itertools import combinations
    dprint(l_list)
    cnt = 0
    for a, b in combinations(ind_list, 2):
        # 2つえらぶ

        # 残りでできたl_listを作る
        # cand_list = []
        # for c in range(len(l_list)):
        #     if c != a and c!= b:
        #         cand_list.append(l_list[c])

        # cのmax, min
        la = l_list[a]
        lb = l_list[b]

        mx = la + lb
        mn = max(la, lb) - min(la, lb)

        # cand_listをbisectする
        right_ind_plus1 = bisect_left(l_list, mx)
        left_ind = bisect_right(l_list, mn)

        # dprint(la, lb, mn, mx, l_list, left_ind, right_ind_plus1, cnt)

        cnt += right_ind_plus1 - left_ind

        if left_ind <= a and a < right_ind_plus1:
            cnt -= 1

        if left_ind <= b and b < right_ind_plus1:
            cnt -= 1

    print(cnt//3)

solve()

Measured memory_bytes: 48480
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,x;
  cin>>n>>x;
  ll ans=n;
  n-=x;
  if(x>n) swap(x,n);
  while(1){
   ll k=n/x;
   n-=x*k;
   ans+=x*2*k;
   if(x>n) swap(x,n);
   if(n==x||x==0){
    cout<<ans-n<<endl;
    return 0;
}
}
  return 0;
}

Measured memory_bytes: 256
q, h, s, d = map(int, input().split())
n = int(input())

l = min(q*4, h*2, s)
l2 = min(q*8, h*4, s*2, d)
if n % 2 == 0:
    ans = l2 * (n//2)
else:
    ans = l2 * (n//2) + l
print(ans)

Measured memory_bytes: 3060
#include <cstdio>

#define MOD 1000000007
#define MAXN 1000
#define ll long long


int main() {
    ll n, a, b, x;
    ll rez = 0;
    scanf("%lld%lld%lld%lld", &n, &a, &b, &x);
    for(ll i = 2; i <= n; i++) {
        ll y;
        scanf("%lld", &y);
        if( (y - x) * a < b)
            rez += (y - x) * a;
        else
            rez += b;
        x = y;
    }
    printf("%lld", rez);
}


Measured memory_bytes: 128
class UnionFindBySize():
    def __init__(self, n):
        self.parents = list(range(n+1))
        self.size = [1] * (n+1)

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    # 根が同一かどうかを判定する
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[y]
            self.parents[y] = x

n, m = map(int, input().split())
XY_dict = {x:[] for x in range(1, n+1)}
XYZ = []
UF = UnionFindBySize(n)

for _ in range(m):
    x, y, z = map(int, input().split())
    XY_dict[x].append(y)
    XY_dict[y].append(x)
    XYZ.append([x,y,z])

for ab in XYZ:
    a = ab[0]
    b = ab[1]
    UF.union(a,b)

Parents = UF.parents
ans = 0

for i in range(1, n+1):
    if i == Parents[i]:
        ans += 1
print(ans)

Measured memory_bytes: 45632
#include<iostream>
#include<cmath>
using namespace std;
double angle(int n){
  return n * (3.14159265358979/180);
}
int main(){
  int l,r,n=0;
  double x,y;
  x = y = 0;
  char c;
  while(cin>>l>>c>>r){
    if(l==0&&r==0) break;
    x += l*cos(angle(n));
    y += l*sin(angle(n));
    n += r; 
  }
  cout << int(y) << endl << int(x) << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

ll ten[30];

ll dfs(int l, int r, ll d) {
    if(l > r) return !d;
    if(l == r) return d ? 0 : 10;
    ll k = ten[r] - ten[l];
    ll t = d / k;
    ll res = 0;
    if(t < 10) res += dfs(l + 1, r - 1, d - k * t) * (10 - t - !l);
    if(++t < 10) res += dfs(l + 1, r - 1, k * t - d) * (10 - t - !l);
    return res;
}

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

    ten[0] = 1;
    rep(i, 25) ten[i + 1] = ten[i] * 10;

    ll D;
    cin >> D;
    ll ans = 0;
    FOR(i, 1, 19) ans += dfs(0, i, D);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = input()
print('ABC' if s == 'ARC' else 'ARC')

Measured memory_bytes: 10292
#include <iostream>
using namespace std;
int main(void){
    int n,min_s=100000,cnt=0;
    long long v;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> v;
        cnt = 0;
        while(1){
            if(v % 2 != 0) break;
            v /= 2;
            cnt++;
        }
        if(min_s>cnt) min_s = cnt;
    }
    cout << min_s;
}


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

int main()
{
  // 標準入力
  int H,A;
  cin >> H >> A;

  int answer =0;
  
  answer = H / A;

  if (H % A > 0) {
    answer++;
  }

  cout << answer;

  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int M,N;
    cin >> M >> N;
    while(M){
        const int MAX = 7368791;
        vector<bool> used(MAX + 1);
        int i;
        for(i = M;N || used[i];i++){
            if(used[i])continue;
            for(int j = i;j <= MAX;j += i){
                used[j] = 1;
            }
            N--;
        }
        cout << i << endl;
        cin >> M >> N;
    }
}


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

int main(){
  string c="";
  string flag = "consonant";

  cin >> c;
  if((c == "a") || (c == "i") || (c == "u") || (c == "e") || (c == "o"))
    flag = "vowel";

  cout << flag << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; i++)
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
#define all(vec) vec.begin(), vec.end()
namespace mp = boost::multiprecision;
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
};

class dijkstra {
  private:
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<>> que;

  public:
	dijkstra(int v, int s, vector<edge> G[]) {
		V = v;
		update(s, G);
	}

	void update(int s, vector<edge> G[]) {
		fill(d, d + V + 1, 100000000000ll);
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)
				continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
	}

	int find(int e) {
		return d[e];
	}
};

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

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

bool prime(int a) {
	if (a == 1)
		return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0)
			return false;
	}
	return true;
}

class Union_Find {
  private:
	vector<int> t, s;

  public:
	Union_Find(int max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(int x, int y) {
		if (same(x, y))
			return;
		int tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}

	int Find(int n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(int x, int y) {
		return Find(x) == Find(y);
	}

	int get_Size(int a) {
		return s[a];
	}
};

set<int> prime_num_factor(int n) {
	if (n < 2)
		return set<int>();
	set<int> prime;
	prime.insert(2);
	for (int i = 3; i <= n; i++) {
		for (int it : prime) {
			if (it * it > i) {
				prime.insert(i);
				break;
			}
			if (i % it == 0)
				break;
		}
	}
	return prime;
}
vector<int> primeFactorization(int n) {
	vector<int> re;
	int cnt = 2;
	while (n != 1) {
		if (n % cnt != 0) {
			cnt++;
			continue;
		}
		n /= cnt;
		re.push_back(cnt);
	}
	return re;
}
signed main() {
	int ans = 0;
	string n;
	cin >> n;
	rep(i, n.size() / 2) {
		ans += 9 * pow(10, (i * 2));
		dout << ans << endl;
	}
	if (n.size() % 2 == 1) {
		ans += stoi(n) - pow(10, n.size() - 1)+1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[4];
	int i;
	int train;
	int bus;
	
	for (i = 0; i < 4; i++){
		scanf("%d", &a[i]);
	}
	
	if (a[0] > a[1]){
		train = a[1];
	}
	else {
		train = a[0];
	}
	
	if (a[2] > a[3]){
		bus = a[3];
	}
	else {
		bus = a[2];
	}
	
	printf("%d\n", train + bus);
	
	return (0);
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc079/tasks/abc079_b
#include <bits/stdc++.h>
using namespace std;

int64_t lucas(int x, vector<int64_t> &memo) {
  if (x == 0 || x == 1 || memo.at(x)) return memo.at(x);
  memo.at(x) = lucas(x - 1, memo) + lucas(x - 2, memo);
  return memo.at(x);
}

int main() {
  int N;
  cin >> N;

  vector<int64_t> memo(100, 0);
  memo.at(0) = 2;
  memo.at(1) = 1;

  cout << lucas(N, memo) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char alpha;
  cin >> alpha;
  if (alpha == 'a' || alpha == 'i' || alpha == 'u' || alpha == 'e' || alpha == 'o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctype.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    Int res = 0;
    char a;
    for (Int i = 0; i < (Int)s.size(); i++) {
        a = i % 2 == 0 ? 'g' : 'p';
        if (s[i] == 'g' && a == 'p') res++;
        else if (s[i] == 'p' && a == 'g') res--;
    }
    dump(res);
    return 0;  
}

Measured memory_bytes: 512
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

int main(void){
	int n=nextint();
	for(int i=1; i<=n; i++){
		if(i*360%n==0){
			printf("%d\n", i*360/n);
			return 0;
		}
	}
}


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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int n,a;
    int min=-1,max=-1;
    cin >> n;
    
    rep(i,n){
        cin >> a;
        if(min==-1 || a < min){
            min = a;
        }

        if(max == -1 || a > max){
            max = a;
        }
    }

    cout << max - min <<endl;
}

Measured memory_bytes: 3576
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    char a;
    
    scanf("%c",&a);
    
    if((a>='a')&&(a<='z')){
        printf("a");
    }else if((a>='A')&&(a<='Z')){
        printf("A");

    }
    
    return 0;
}


Measured memory_bytes: 1584
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (n, k) = input_tuple();
    let mut p_vec = input_vec();
    p_vec.sort();
    let mut sum = 0;
    for i in 0..k {
        sum += p_vec[i as usize];
    }
    println!("{}", sum);
}


Measured memory_bytes: 2152
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

int n;
vvi G;
vi c,cnt,siz,out;
void dfs(int a,int p){
	siz[a]++;
	int tmp=cnt[c[a]];
	rep(i,G[a].size())if(G[a][i]-p){
		cnt[c[a]]=0;
		dfs(G[a][i],a);
		siz[a]+=siz[G[a][i]];
		int s=siz[G[a][i]]-cnt[c[a]];
		out[c[a]]+=s*(s+1)/2;
//		cout<<a<<" "<<cnt[c[a]]<<endl;
	}
	cnt[c[a]]=tmp+siz[a];
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>n;
	G=vvi(n);
	c=cnt=siz=out=vi(n);
	rep(i,n)cin>>c[i],c[i]--;
	rep(i,n-1){
		int a,b;
		cin>>a>>b;a--;b--;
		G[a].pb(b);G[b].pb(a);
	}
	dfs(0,-1);
	rep(i,n)out[i]=n*(n+1)/2-out[i]-(n-cnt[i])*(n-cnt[i]+1)/2;
	rep(i,n)cout<<out[i]<<endl;
}







Measured memory_bytes: 35840
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		String s = nextString();

			for(int k=0;k<=7;k++){
				String tmp=s.substring(0,k)+s.substring(s.length()-7+k,s.length());
				if("keyence".equals(tmp)){
					System.out.println("YES");
					return ;
				}
			}
		System.out.println("NO");
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

import numpy as np
def main():
    N = int(input())
    grid = np.array([list(input()) for _ in range(N)],'S1')
    
    ans = 0
    for i in range(N):
        X = np.vstack((grid[i:,:],grid[:i,:]))
        if np.all(X == X.T):
            ans += N
    print(ans)
if __name__ == '__main__':
    main()

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

int main()
{
	ll n, k;
	cin >> n >> k;
	ll H[n];
	f(i, 0, n)
	cin >> H[i];
	if(n == 2)
	{
		cout << abs(H[0] - H[1]);
		return 0;
	}
	ll ans[n];
	ans[1] = abs(H[1] - H[0]);
	ans[0] = 0;
	f(i, 2, n)
	{
		ll x = INT_MAX;
		ll y;
		if(i > k)
		y = i-k;
		else
		y = 0;
		while(y < i)
		{
			x = min(x, ans[y] + abs(H[i] - H[y]));
			y++;
		}
		ans[i] = x;
	}
	cout << ans[n-1];
}

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

int main(){
  int s;
  cin >> s;
  if(s%100>=1 && s%100<=12){
    if(s/100>=1 && s/100<=12){
      cout << "AMBIGUOUS";
    }else{
      cout << "YYMM";
    }
  }else{
    if(s/100>=1 && s/100<=12){
      cout << "MMYY";
    }else{
      cout << "NA";
    }
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}




int main(){//
	int H, N;
	cin >> H >> N;
	vector<int> A(N), B(N);
	for(int i=0; i<N; i++) cin >> A[i] >> B[i];

	const int H_MAX = 10000;
	const int B_MAX = 10000;
	const int INF = H_MAX*B_MAX+1;
	//dp[n][h]: 0~n-1番目までの魔法を考慮して体力hを減らすのに必要な最小魔力
	vector<vector<int>> dp(N+1, vector<int>(H+1, INF));
	dp[0][0] = 0;//魔法使わないで体力0を減らすのに必要な魔力は0
	for(int n=0; n<=N; n++) dp[n][0] = 0;

	//解1 //dp[n][h]: 魔法0~n-1番目まで考慮した時，体力h以下の敵を倒すのに必要な最小魔力
	//解2に(★)の行を足しただけで，　解2の最後のansを探すforループがいらなくなる
	for(int h=0; h<=H; h++){
		for(int n=0; n<N; n++){
			if(h<A[n]) dp[n+1][h] = min(dp[n+1][h], dp[n][0]+B[n]);//........(★)
			dp[n+1][h] = min(dp[n+1][h], dp[n][h]+0*B[n]);//魔法n番を使わない
			if(h+A[n] < (int)dp[0].size()) dp[n+1][h+A[n]] = min(dp[n+1][h+A[n]], dp[n][h] + B[n]);//魔法nを使う(1回目)
			if(h+A[n] < (int)dp[0].size()) dp[n+1][h+A[n]] = min(dp[n+1][h+A[n]], dp[n+1][h]+B[n]);//魔法nを使う(2回目以降)(1回目の時のh+A[n]が今回のhと等しくなる時に影響)
		}
	}
	cout << dp[N][H] << endl;

	//解2
	// vector<vector<int>> dp(N+1, vector<int>(H+H_MAX+1, INF));
	//
	// // for(int n=0; n<N; n++){
	// // 	for(int h=0; h<=H+H_MAX; h++){
	// for(int h=0; h<H+H_MAX; h++){
	// 	for(int n=0; n<N; n++){
	// 		dp[n+1][h] = min(dp[n+1][h], dp[n][h]+0*B[n]);//魔法n番を使わない
	// 		if(h+A[n] < (int)dp[0].size()) dp[n+1][h+A[n]] = min(dp[n+1][h+A[n]], dp[n][h] + B[n]);//魔法nを使う(1回目)
	// 		if(h+A[n] < (int)dp[0].size()) dp[n+1][h+A[n]] = min(dp[n+1][h+A[n]], dp[n+1][h]+B[n]);//魔法nを使う(2回目以降)(1回目の時のh+A[n]が今回のhと等しくなる時に影響)
	// 	}
	// }
	// //print_vec2(dp);
	// int ans = INF;
	// for(int h=H; h<=H+H_MAX; h++){//答えは体力H以上削った場合の最小消費体力
	// 	ans = min(ans, dp[N][h]);
	// }
	// cout << ans << endl;

}


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

int main() {
  int N;
  string S;

  cin >> N >> S;

  int x = 0, ans = 0;
  rep(i, N) {
    if (S[i] == 'I')
      x++;
    else
      x--;
    ans = max(ans, x);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {n:usize,
    mut a:[i64;n],}
    ///
    /// a[i], a[j] -> a[i]+a[j], j
    /// 2倍以下ならOK
    ///
    /// 最初はn通り
    /// 大きいやつは生き残れそう
    /// 残れないやつをカウント
    /// にぶたん？
    ///
    a.sort();

    let mut ans = n;

    let mut ok = n as i64;
    let mut ng = -1i64;
    let mut csum = vec![0i64; n + 1];
    for i in 0..n {
        csum[i + 1] = csum[i] + a[i];
    }

    let mut dp = vec![0; n + 1];
    let mut sm = 0;
    let mut cnt = 0;
    // dbg!(&csum);
    // csum<=2*a
    for i in (1..n).rev() {
        if 2 * csum[i] < a[i] {
            // dbg!(csum[i + 1], a[i + 1], i);
            println!("{}", ans - i);
            return;
        }
    }

    println!("{}", ans - cnt);
}


Measured memory_bytes: 4780
n=int(input())
d={}
for i in range(n):
    s=input()
    d[i]={}
    for c in s:
        if c in d[i]:
            d[i][c]+=1
        else:
            d[i][c]=1
# print(d)
k={chr(i)for i in range(97,123)}
for e in d:
    k&=set(d[e].keys())
# print(k)
for t in sorted(k):
    m=float('inf')
    for e in d:
        m=min(m,d[e][t])
    print(t*m,end='')
print('')


Measured memory_bytes: 8984
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

a1 = l()
a2 = l()
a3 = l()
AB = a1+a2+a3
c = Counter(AB)
if 1 in AB and 2 in AB and 3 in AB and 4 in AB and list(reversed(sorted(list(c.values()))))[0] == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 77344
using namespace std;
#include<bits/stdc++.h>
#define ll long long int
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    if(s[2]==s[3] and s[4]==s[5]){
        cout<<"Yes";
    }
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, i, j, k, l;
    cin >> n;
    vector<ll> Data(n + 1, 0);
    for (i = 1; i <= n;i++){
        cin >> Data[i];
    }
    vector<ll> Dp(n + 1, 0);
    Dp[1] = 0;
    Dp[2] = abs(Data[1] - Data[2]);
    for (i = 3; i <= n;i++){
        Dp[i] = min(Dp[i - 1] + abs(Data[i - 1]- Data[i]), Dp[i - 2] + abs(Data[i - 2] - Data[i]));
    }
    cout << Dp[n];
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;
typedef pair<ll, ll> p;

ll n, cnt, chk[1010101];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n;
    int now = 0;
    while(1){
        now = now * 10 + 7; now %= n;
        cnt++;
        if(chk[now]) break;
        chk[now] = 1;
        if(!now){ cout << cnt; return 0; }
    }
    cout << -1;
}

Measured memory_bytes: 11408
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ff first
#define ss second
#define maxn 1000000007
#define PI 3.14159265358979323846
#define MAX 1000007 
using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    //cout<<fixed<<setprecision(20);
    ll a,b;
    cin>>a>>b;
    cout<<(3*a+b)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
k, a, b = map(int, input().split())

if 1 + k <= a or b - a <= 2:
    print(1 + k)
else:
    cnt = (k - (a - 1)) // 2
    mod = (k - (a - 1)) % 2
    ans = (b - a)*cnt + a + mod
    print(max(ans, k + 1))

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
  char s[4];
  int o = 0;
  scanf("%s", s);
  for(int i = 0; i < 3; i++)
    o |= 1 << s[i] - 'a';
  if(o == 7)
    printf("Yes\n");
  else
    printf("No");
}

Measured memory_bytes: 128