akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
// #include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
// using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

typedef vector<int> vec;
typedef vector<vec> mat;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int A, B; cin >> A >> B;
    cout << max(A - 2*B, 0) << endl;
}

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

using namespace std;

int c1[100005],c2[100005],x[1000005],y[100005],c3[100005];

int main(){
    int a,b,m;
    scanf("%d%d%d",&a,&b,&m);
    for(int i = 1; i<=a; i++)
        scanf("%d",&c1[i]);
    for(int i = 1; i<=b; i++)
        scanf("%d",&c2[i]);
    int m1 = c1[1];
    for(int i = 2; i<=a; i++)
        m1 = min(m1,c1[i]);
    int m2 = c2[1];
    for(int i = 2; i<=b; i++)
        m2= min(m2,c2[i]);
    int ans = m1+m2;
    for(int i = 1; i<=m; i++){
        scanf("%d%d%d",&x[i],&y[i],&c3[i]);
        ans = min(ans,c1[x[i]]+c2[y[i]]-c3[i]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2176
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <utility>

using namespace std;
bool first_row_or_column(int row, int col) {
		return (row > 0) && (col > 0);
}

int main() {
	string s,t;
	getline(cin,s);
	getline(cin,t);
	int n = (int)s.size();
	int m = (int)t.size();
	int lcs[n+1][m+1];
	for(int i = 0; i < n+1; i++) {lcs[i][0]=0; }
	for(int i = 0; i < m+1; i++) {lcs[0][i]=0;  }
	string res = "";
	for(int i = 1; i<n+1; i++) {
		for(int j = 1; j <m+1; j++) {
			if(s[i-1]==t[j-1]){
				lcs[i][j] = lcs[i-1][j-1] + 1;
			}else {
				lcs[i][j] = max(lcs[i-1][j] ,lcs[i][j-1]);
			}
		}
	}
	int j = m, i = n;
	while(first_row_or_column(i,j)) {
		if(lcs[i][j] == lcs [i][j-1]) {
			j--;
		}else if(lcs[i][j] == lcs[i-1][j]) {
			i--;
		}else {
			res +=s[i-1];
			i--,j--;
		}
	}
	reverse(res.begin(),res.end());
	cout << res;
	return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+5,mod=998244353,Mx=1e6;
int mu[N],sum[N];
int prime[N],cnt,vis[N];
void add(int &x,int y){
	y%=mod;
	x=(x+y+mod)%mod;
}
void init(int n){
	mu[1]=1;
	for(int i=2;i<=n;++i){
		if(!vis[i]) vis[i]=1,prime[++cnt]=i,mu[i]=-1;
		for(int j=1;j<=cnt;++j){
			if(prime[j]>n/i) break;
			vis[i*prime[j]]=1;
			if(i%prime[j]) mu[i*prime[j]]=-mu[i];
			else break;
		}
	}
	for(int i=1;i<=n;++i)
		for(int j=i;j<=n;j+=i)
			add(sum[j],mu[i]*i);
}
int ksm(int b,int n){
	int res=1;
	while(n){
		if(n&1) res=res*b%mod;
		b=b*b%mod; n>>=1;
	}
	return res;
}
int a[N],s,c[N];
signed main(){
//	freopen("01-04.txt","r",stdin);
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i],s=(s+a[i])%mod,c[a[i]]++;
	for(int i=0;i<=Mx;++i)
		c[i]%=mod;
	init(Mx);
//	cout<<sum[Mx]<<endl;
	int ans=0,tmp,Sum=0;
	for(int T=1;T<=Mx;++T){
		tmp=T*sum[T]%mod;Sum=0;
		for(int i=1;i<=Mx/T;++i)
			add(Sum,i*c[i*T]);
		add(ans,tmp*Sum%mod*Sum);
	}
//	cout<<ans<<endl;
	add(ans,mod-s);
	ans*=ksm(2,mod-2);ans%=mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 36984
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int A,B,C;
    cin >> A >> B >> C;
    int X,Y;
    cin >> X >> Y;
    vector<int> c(max(X,Y));
    REP(i, min(X,Y)){
        c[i] = min(A+B, 2*C);
    }
    Rep(i, min(X,Y), max(X,Y)){
        if(X>Y) c[i] = min(A, 2*C);
        else c[i] = min(B, 2*C);
    }

    int total = 0;
    REP(i, max(X,Y)){
        total += c[i];
    }
    pr(total);
}

Measured memory_bytes: 640
N, C, K = map(int, input().split())
T = []
for i in range(N):
  t = int(input())
  T.append(t)
  
T.sort()
ans = 1
cnt = 0
time = T[0]
for t in T:
  if (t<=time+K) and (cnt<C):
    cnt += 1
  else:
    ans += 1
    cnt = 1
    time = t
print(ans)

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

using namespace std;

int main(void)
{
    int N;
    cin >>N;
    int time = N/100;
    if(time*100<=N && N<=time*105){
        cout<<1<<endl;
    }
    else{
        cout<<0<<endl;
    }
    return 0;
}

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

int gcd(int n,int m){return m?gcd(m,n%m):n;}

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

    int zeroCnt = 0;
    int oneCnt = 0;
    for(char c : S){
        if(c == '0'){
            if(oneCnt) oneCnt--;
            else zeroCnt++;
        } 
        if(c == '1'){
            if(zeroCnt) zeroCnt--;
            else oneCnt++;
        }
    }

    cout << S.size() - zeroCnt - oneCnt << endl;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

func sum_of_digit(n int) int {
	var sum int
	for n > 0 {
		sum += n % 10
		n /= 10
	}
	return sum
}
func main() {
	var n, a, b, sum int
	fmt.Scan(&n, &a, &b)
	for i := 1; i < n+1; i++ {
		if v := sum_of_digit(i); a <= v && v <= b {
			sum += i
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);
#define int long long
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds_;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;


int binomialCoeff(int n,int r){
    int res=1;
    if(r>n-r)r=n-r;
    for(int i=0;i<r;i++){
        res*=(n-i);
        res/=(i+1);
    }
    return res;
}



int power(int x,int n,int mod){
//(x^n)%mod
    int result=1;
    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

int inverseMod(int x,int mod){

return power(x,mod-2,mod);
}


int32_t main() {

    simplify

    int n;
    cin>>n;
    //n--;
    string s;
    while(n>0){
        n--;
        int add=(n+1)%26;
        //cout<<add<<endl;
        char c;
        if(add==0)c='z';
        else c='a'+(add-1);
        s.push_back(c);
        n/=26;
        
    }
    //cout<<s;
    reverse(s.begin(),s.end());
    cout<<s;



    return 0;
}


Measured memory_bytes: 3640
n=int(input())
lipp = []
lipm = []
limm = []
allcnt = 0
for _ in range(n):
    s = input()
    cnt = 0
    mi = 0
    for x in s:
        cnt += 1 if x == '(' else -1
        mi = min(mi,cnt)

    if cnt >= 0:
        lipm.append([mi,cnt])
    else:
        limm.append([mi - cnt, -cnt])
    allcnt += cnt
if allcnt != 0:
    print('No')
    exit()

lipm.sort(reverse = True)
limm.sort(reverse = True)

def solve(l):
    now = 0
    for mi, cnt in l:
        if mi + now < 0:
            print('No')
            exit()
        now += cnt

solve(lipm)
solve(limm)

print("Yes")

Measured memory_bytes: 186760
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = ll(1e9) + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = 1 << 12;
const double EPS = 10e-8;
const double PI = 3.14159265359;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main() {
    int n, ans = 99999999;
    cin >> n;
    REP(i,n-1){
        int a,b,t=0;
        a = i+1;
        b = n-i-1;
        while(a>0){
            t += a%10;
            a/=10;
        }
        while(b>0){
            t += b%10;
            b/=10;
        }
        ans = min(ans,t);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
  ll a, b, c, x, y;
  scanf("%lld %lld %lld %lld %lld", &a, &b, &c, &x, &y);
  ll ans = a * x + b * y;
  if (x > y) {
    ans = min(ans, c * 2 * y + (x - y) * a);
    ans = min(ans, c * 2 * x);
  }
  else {
    ans = min(ans, c * 2 * x + (y - x) * b);
    ans = min(ans, c * 2 * y);
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
A = [input() for i in range(H)]

dx = [1,-1,0,0]

dy = [0,0,1,-1]
B = [[-1 for i in range(W)] for j in range(H)]
qu = deque([])
for i in range(H):
  for j in range(W):
    if A[i][j] == '#':
      B[i][j] = 0
      qu.append((i,j))
      
      
while qu:
  base = qu.popleft()
  for i in range(4):
    if base[0]+dx[i] < 0 or base[0]+dx[i] >=H or base[1]+dy[i] < 0 or base[1]+dy[i] >=W:
      continue
    if B[base[0]+dx[i]][base[1]+dy[i]] == -1:#未訪問
      qu.append((base[0]+dx[i],base[1]+dy[i]))
      B[base[0]+dx[i]][base[1]+dy[i]] = B[base[0]][base[1]] + 1
      
ans = 0
for i in range(H):
  ans = max(ans,max(B[i]))
print(ans)

Measured memory_bytes: 88804
k = list(map(int,input()))
jsum = 0
ans = str(k[0])
for i in range(2 ** 3):
    for j in range(3):
        bit = (i >> j) & 1
        jsum += (-1) ** bit * k[j + 1]
        if bit == 1:
            ans += "-"+str(k[j+1])
        else:
            ans += "+"+str(k[j+1])
    if k[0] + jsum == 7:
        print(ans+'=7')
        break
    jsum =0
    ans= str(k[0])

Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input!(n: usize, a: [u32; n]);
    let mut ans = std::collections::VecDeque::new();
    for (i, x) in a.iter().copied().enumerate() {
        if i % 2 == 0 {
            ans.push_back(x);
        } else {
            ans.push_front(x);
        }
    }
    let ans: Vec<_> = if n % 2 == 0 {
        ans.iter().collect()
    } else {
        ans.iter().rev().collect()
    };
    println!(
        "{}",
        ans.iter()
            .map(|&x| x.to_string())
            .fold(String::new(), |acc, x| if acc.is_empty() {
                x
            } else {
                acc + " " + x.as_ref()
            })
    );
}


Measured memory_bytes: 9592
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    ll ans = 0;
    rep(i, s.size()) if(s[i] == '1') ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

class Program
{
    

    static void Main(string[] args)
    {
        int[] AB = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int A = AB[0];
        int B = AB[1];

        int n = Math.Max(A, B);

        if (A == B)
        {
            Console.WriteLine(2 * n);
        }
        else
        {
            Console.WriteLine(2 * n - 1);
        }

        
    }
    
}


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

using namespace std;

int main(void) {
    vector<char> s(3);
    int count = 0;
    int max = 0;
    for(int i = 0; i < 3; i++){
        cin >> s.at(i);
        if(s.at(i) == 'S' && i != 2){
            count = 0;
        }
        else if(s.at(i) == 'R'){
            count += 1;
            if(max < count){
                max = count;
            }
        }
    }
    // for(int i = 0; i < 3; i++){
    //     if(s.at(i) == 'S' && i != 2){
    //         count = 0;
    //     }
    //     else if(s.at(i) == 'R'){
    //         count += 1;
    //     }
    // }
    // cin >> s;
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 3616
MOD = 10 ** 9 + 7
n = int(input())
x = list(map(int, input().split()))
f = 1
for i in range(n - 1):
    f *= (i + 1)
    f %= MOD
ans = 0
t = 0
for i in range(n - 1):
    t += f * pow(i + 1, MOD - 2, MOD)
    t %= MOD
    ans += t * (x[i + 1] - x[i])
print(ans % MOD)


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

class range_map {
public:
	struct range {
		range(int b, int e) :begin(b), end(e) {};
		int begin;
		int end;
	};
	void add(int b,int e) {
		range r(b, e);

		int i = search(b);

		if (i < 0) {
			ranges.insert(ranges.begin(), r);
			i = 0;
		}
		else if (ranges[i].end >= e) {
			return;
		}
		else if (ranges[i].end > b - 1){
			ranges[i].end = e;
		}
		else{
			if(i + 1 < ranges.size())ranges.insert(ranges.begin() + i + 1,r);
			else ranges.push_back(r);
			i++;
		}

		int j = search(ranges[i].end + 1);
		ranges[i].end = max(ranges[i].end, ranges[j].end);
		for (; i < j; j--) {
			ranges.erase(ranges.begin() + i + 1);
		}
		
	}
	bool inside(int b, int e) {
		int i = search(b);
		if (i < 0)return false;
		return e <= ranges[i].end;
	}
private:
	int search(int b) {
		int begin = 0;
		int end = ranges.size();
		int mid = -1;

		while (begin < end) {
			mid = (begin + end) / 2;
			if (ranges[mid].begin == b) {
				break;
			}
			else if (ranges[mid].begin < b) {
				begin = mid + 1;
			}
			else {
				end = mid;
				mid--;
			}
		}
		return mid;
	}
	vector<range> ranges;
};
int main() {
	int N, W, H;
	range_map rmx, rmy;

	cin >> N >> W >> H;
	for (int i = 0; i < N; i++) {
		int x, y, w;
		cin >> x >> y >> w;

		rmx.add(x - w, x + w);
		rmy.add(y - w, y + w);
	}

	if (rmx.inside(0, W) || rmy.inside(0, H)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>  
#define endl "\n"
using namespace std;
	typedef long long ll;
	const int maxn=3050;
	const int inf=0x3f3f3f3f;
	const int mod=1e9+7;
	double ans;
	double a[maxn];
	double dp[maxn][maxn];
	ll n,m;
	int main(){
		IOS
		cin>>n;
		for(int i=1;i<=n;i++)
			cin>>a[i];
		dp[0][0]=1;
		for(int i=1;i<=n;i++){
			for(int j=0;j<=n;j++){
				if(j==0)
					dp[i][j]=dp[i-1][j]*(1.0-a[i]);
				else
					dp[i][j]=dp[i-1][j]*(1.0-a[i])+dp[i-1][j-1]*a[i];
			}
		}
		int limit=ceil(n/2.0);
		for(int i=limit;i<=n;i++)
			ans+=dp[n][i];
		cout<<setprecision(10)<<ans<<endl;
	}

Measured memory_bytes: 75228
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){	
	ios_base::sync_with_stdio(0);cin.tie(0);
  	ll a[5];
  ll ans=0;
  	for(int i=0;i<5;i++){
    	cin>>a[i];if(a[i]==0)ans=i+1;
    }
  cout<<ans<<"\n";
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
const int N = 105;
const int K = N * 3;
int n , k;
int w[N] , v[N];
int dp[N][K];
int ans;
int main(){
	scanf("%d %d" , &n , &k);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d %d" , w + i , v + i);
	}
	for(int i = 1 ; i <= n ; ++i){
		int w = ::w[i] - ::w[1];
		int v = ::v[i];
		for(int j = n ; j >= 1 ; --j){
			for(int k = K - 1 ; k >= w ; --k){
				dp[j][k] = max(dp[j][k] , dp[j - 1][k - w] + v);
			}
		}
	}
	for(int i = 1 ; i <= n ; ++i){
		if(1LL * i * w[1] <= k){
			int tmp = k - i * w[1];
			tmp = min(tmp , K - 1);
			ans = max(ans , dp[i][tmp]);
		}
	}
	printf("%d\n" , ans);
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		long k = Long.parseLong(sc.next());


		if(k >=  a + b) {
			a = 0;
			b = 0;
		}else if(k >= a) {
			k -= a;
			a = 0;
			b -= k;
		}else {
			a -= k;
		}
		
		
		System.out.println(a + " " + b);	}
}

Measured memory_bytes: 23124
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  vector<uint32_t> group1{1, 3, 5, 7, 8, 10, 12};
  vector<uint32_t> group2{4, 6, 9, 11};
  vector<uint32_t> group3{2};

  uint32_t x, y;
  cin >> x >> y;

  uint32_t group_x = 0, group_y = 0;
  for (uint32_t i = 0; i < group1.size(); i++) {
    if (x == group1[i]) group_x = 1;
    if (y == group1[i]) group_y = 1;
  }

  for (uint32_t i = 0; i < group2.size(); i++) {
    if (x == group2[i]) group_x = 2;
    if (y == group2[i]) group_y = 2;
  }

  for (uint32_t i = 0; i < group3.size(); i++) {
    if (x == group3[i]) group_x = 3;
    if (y == group3[i]) group_y = 3;
  }

  if (group_x == group_y)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

void add(int& x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

const int MX = 3007;
int f[MX][MX], sf[MX][MX];

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n;
    cin >> n;
    string s;
    cin >> s;
    s = "$$" + s;
    f[1][1] = 1;
    for (int i = 1; i < MX; i++) {
        sf[1][i] = 1;
    }
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= i; j++) {
            if (s[i] == '<') {
                f[i][j] = sf[i - 1][j - 1];
            } else {
                f[i][j] = (sf[i - 1][MX - 1] - sf[i - 1][j - 1] + MOD) % MOD;
            }
        }
        for (int j = 1; j < MX; j++) {
            sf[i][j] = (sf[i][j - 1] + f[i][j]) % MOD;
        }
    }

    cout << sf[n][MX - 1] << "\n";
    return 0;
}



Measured memory_bytes: 70784
#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 pb push_back
typedef long long ll;
using namespace std;

const int MAXN = 1e3+5;
const int MOD = 1e9+7;

int main()
{
    ll h, res = 2;
    scanf("%lld", &h);
    while (res <= h)
    {
        res <<= 1;
    }
    printf("%lld\n", res-1);

    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <complex>

using namespace std;
using pii = pair<int, int>;
using ll = long long;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k, n;
	cin >> k >> n;
	if (k * 500 >= n) cout << "Yes";
	else cout << "No";

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

static const int MAX = 100;

int main() {
  int n, a[MAX], sw = 0;
  scanf("%d", &n);

  for ( int i = 0; i < n; i++ ) scanf("%d", &a[i]);

  for ( int i = 0; i < n; i++ ) {
    int min = i;
    for ( int j = i; j < n; j++ ) {
      if ( a[j] < a[min] ) min = j;
    }

    if (i != min) {
      swap(a[i], a[min]);
      sw++;
    }
  }

  for ( int i = 0; i < n; i++ ) {
    if ( i > 0 ) {
      printf(" ");
    }

    printf("%d", a[i]);
  }

  printf("\n");

  printf("%d", sw);

  printf("\n");

  return 0;
}



Measured memory_bytes: 2744
#include <iostream>
#include <algorithm>
#include <tuple>
using namespace std;
typedef tuple<int, int, int> T;

int n, m;
T rec[20000];

int main() {
	int i;
	
	while (cin >> n >> m) {
		if (!n) break;
		for (i = 0; i < m; i++) {
			int t, s, d;
			cin >> t >> s >> d; s--; d--;
			rec[i] = T(t, s, d);
		}
		sort(rec, rec + m);
		
		bool infected[20000] = {false};
		infected[0] = true;
		for (i = 0; i < m; i++) {
			int s = get<1>(rec[i]);
			int d = get<2>(rec[i]);
			if (infected[s]) infected[d] = true;
		}
		
		int ans = 0;
		for (i = 0; i < n; i++) ans += infected[i];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3304
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    int n, s;
    vector<int> v;

    while (true) {
        cin >> n;

        if (!n) { break; }

        // 全要素を削除
        v.clear();

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

        int max_v = *max_element(v.begin(), v.end());
        int min_v = *min_element(v.begin(), v.end());
        int sum_v = accumulate(v.begin(), v.end(), 0);

        cout << (sum_v - max_v - min_v) / (n-2) << endl;
    }

    return 0;
}


Measured memory_bytes: 3036
#include <iostream>
#include <vector>
#include <climits>
using namespace  std;

#define llong long long

void fnInput(vector<int>& rvnSort)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  rvnSort.resize(nMaxSiz);
  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnSort[i];
}

void fnMerge(vector<int>& rvnSort, llong& rnInvCnt, int nLeft, int nMid, int nRight)
{
  vector<int> vnLeft, vnRight;
  int nLeftSiz = nMid - nLeft;
  int nRightSiz = nRight - nMid;
  
  vnLeft.resize(nLeftSiz + 1);
  vnRight.resize(nRightSiz + 1);
  for (int i = 0; i < nLeftSiz; i++)
    vnLeft[i] = rvnSort[nLeft + i];
  for (int i = 0; i < nRightSiz; i++)
    vnRight[i] = rvnSort[nMid + i];

  vnLeft[nLeftSiz] = INT_MAX;
  vnRight[nRightSiz] = INT_MAX;

  int i = 0, j = 0;
  for (int n = nLeft; n < nRight; n++)
    if (vnLeft[i] <= vnRight[j])
      rvnSort[n] = vnLeft[i++];
    else
    {
      rvnSort[n] = vnRight[j++];
      if (vnLeft[i] != INT_MAX)
        rnInvCnt += (nLeftSiz - i);
      else;
    }  
}

void fnMergeSort(vector<int>& rvnSort, llong& rnInvCnt, int nLeft, int nRight)
{
  if (nLeft + 1 < nRight)
  {
    int nMid = (nLeft + nRight) / 2;
    fnMergeSort(rvnSort, rnInvCnt, nLeft, nMid);
    fnMergeSort(rvnSort, rnInvCnt, nMid, nRight);
    fnMerge(rvnSort, rnInvCnt, nLeft, nMid, nRight);
  }
}

void fnResult(llong nInvCnt)
{
  cout << nInvCnt << endl; 
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnSort;

  fnInput(vnSort);

  int nLeft = 0;
  int nRight = vnSort.size();
  llong nInvCnt = 0;
  fnMergeSort(vnSort, nInvCnt, nLeft, nRight);

  fnResult(nInvCnt);

  return 0;
}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N;
    cin >> N;
    vector<double> x(N);
    vector<string> u(N);
    rep(i,N) cin >> x[i] >> u[i];
    
    double ans = 0;
    
    rep(i,N){
        if (u[i] == "BTC") {
            ans += x[i]*380000;
        }else{
            ans += x[i];
        }
    }
    cout << fixed << setprecision(5);
    cout << ans << endl;
    
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 1; i < 10001 ; i++) {
            int x = sc.nextInt();

            if (x == 0){
                i = 10000;
            } else  {
                System.out.printf("Case %d: %d\n", i, x);
            }
        }
    }
}


Measured memory_bytes: 72352
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int C = scanner.nextInt();
    if (A > B) {
      int tmp = A;
      A = B;
      B = tmp;
    }
    for (int i = A; i < B; i++) {
      if (i == C) {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }

}


Measured memory_bytes: 22612
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    string alph="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int h, w; cin >> h >> w;
    string s[30][30];
    rep(i,0,h) rep(j,0,w) {
        cin >> s[i][j];
        if(s[i][j] == "snuke") {
            cout << alph[j] << i+1 << endl;
        }
    }
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N = 1e5+100;
int dp[N];
int arr[N];

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    for(i = 0; i < n; i++) cin>>arr[i];
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    for(i = 2; i < n; i++) dp[i] = min(dp[i-1] + abs(arr[i-1] - arr[i]), dp[i-2] + abs(arr[i-2] - arr[i]));
    cout << dp[n-1] << endl;
    return 0;
}


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

int main()
{
	int A,B;
	cin >> A >> B;
	if (A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

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

using namespace std;

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

    int num = 0;
    int length = s.length();
    
    for(int i = 0; i < length / 2; ++i) {
        if(s[i] != s[length - i - 1]){
            num++;
        }
    }

    cout << num;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 10000

int main(void)
{
	int a[N];
	int i=0, j;
	
	do{
		scanf("%d", &a[i]);
		i++;
	}while(a[i-1]!=0);
	
	for(j=0; j<i-1; j++){
		printf("Case %d: %d\n", j+1, a[j]);
	}
	return 0;
}


Measured memory_bytes: 1984
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int MAX_V = 100010;
struct edge{ int cost, to; };


int V;
vector<edge> G[MAX_V];
bool used[MAX_V];

auto compare = [](edge a, edge b){
    return a.cost > b.cost;
};

int res = 0;
int prim_pq(int s){
    for(int i = 0; i < V; i++) used[i] = false;
    used[s] = true;
    
    priority_queue<edge,vector<edge>,decltype(compare)> pq{compare};
    for(int i = 0; i < G[s].size(); i++) pq.push(G[s][i]);
    
    while(!pq.empty()){
        edge e = pq.top(); pq.pop();
        if(used[e.to]) continue;
        used[e.to] = true;
        res += e.cost;
        for(int i = 0; i < G[e.to].size(); i++) pq.push(G[e.to][i]);
    }
    return res;
}

int main(){
    cin >> V;
    for(int i = 0; i < V; i++){
        for(int j = 0; j < V; j++){
            int x; cin >> x;
            if(x == -1) continue;
            edge e;
            e.to = j; e.cost = x;
            G[i].push_back(e);
        }
    }
    cout << prim_pq(0) << endl;
    return 0;
}


Measured memory_bytes: 5504
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i).map {|i| i/400}
monster_count = 0
arr.each do |num|
  if num >= 8
    monster_count += 1
  end
end
arr.delete_if{|num| num >= 8}
ans = arr.uniq.size
puts [1,ans].max.to_s + " " + (ans + monster_count).to_s

Measured memory_bytes: 14212
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
bool vis[1000][1000];
int n,m;
int main() {
	
string st;
set<char>s;
cin>>st;
for(int i=0;i<3;i++)
s.insert(st[i]);
cout<<(s.size()==2?"Yes":"No");

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[][] c = new int[3][3];
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    c[i][j] = in.nextInt();
                }
            }
            int[] a = new int[3];
            int[] b = new int[3];
            for (a[0] = 0; a[0] < 101; a[0]++) {
                b[0] = c[0][0] - a[0];
                for (a[1] = 0; a[1] < 101; a[1]++) {
                    b[1] = c[1][1] - a[1];
                    for (a[2] = 0; a[2] < 101; a[2]++) {
                        b[2] = c[2][2] - a[2];
                        boolean ok = true;
                        for (int i = 0; i < 3; i++) {
                            for (int j = 0; j < 3; j++) {
                                if (c[i][j] != a[i] + b[j]) {
                                    ok = false;
                                }
                            }
                        }
                        if (ok) {
                            out.println("Yes");
                            return;
                        }
                    }
                }
            }
            out.println("No");
        }

    }
}



Measured memory_bytes: 24744
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6+5;
#define mod 2147483648
#define inf 0x7fffffff
int main(){
    int a,b,c,k;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    while(k--) {
        if(a>=b) b*=2;
        else if(b>=c) c*=2;
    }
    if(a<b&&b<c) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

int main() {
  int n;cin>>n;
  string s;cin>>s;
  int an[26];rep(i,26)an[i]=1;
  for (auto c:s) {
    int i=c-'a';
    an[i]++;
  }
  ll cnt=1;
  ll MOD=1e9+7;
  rep(i,26) {
    cnt = (cnt * an[i]) % MOD;
  }
  cnt = (cnt+MOD-1)%MOD;
  cout<<cnt;
}


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

using namespace std;

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

  int n; 
  cin >> n;
  vector<map<char, int>> hash(n);
  string s;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    for (auto &c : s) hash[i][c]++;
  }
  for (char i = 'a'; i <= 'z'; ++i) {
    int mn = 1e9;
    for (int j = 0; j < n; ++j) {
      if (hash[j][i] < mn) 
        mn = hash[j][i];
    }
    if (mn > 0) cout << string(mn, i);
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 384
from sys import stdin, setrecursionlimit
from collections import defaultdict


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans = sum(a)
    dic = defaultdict(int)
    for ai in a:
        dic[ai] += 1
    q = int(input())
    bc = [list(map(int, input().split())) for _ in range(q)]
    for b, c in bc:
        count = dic[b]
        ans += count * (c - b)
        print(ans)
        dic[b] -= count
        dic[c] += count


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

int main()
{
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for(int i = n; i >= 0; i--){
        //cout << t.substr(0, i) << " " << s.substr(n-i) << endl;
        if(t.substr(0, i) == s.substr(n-i)){
            cout << n*2 - i << endl;
            return 0;
        }
    }
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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;}

int main(){
  ll n,k;cin>>n>>k;
  ll ans=0;
  for(int i=k;k<=n+1;k++){
    ll st=k*(k-1)/2;
    ll en=n*(n+1)/2-(n-k)*(n-k+1)/2;
    ll c=en-st+1;
    ans=(ans+c)%mod;
  }
  cout<<ans;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][][] periods = new int[n][3][2];
        int[][] check_point = new int[3][n];
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < 3; ++j) {
                for (int k = 0; k < 2; ++k) {
                    int h = sc.nextInt(), m = sc.nextInt();
                    periods[i][j][k] = h * 60 + m;
                    if (k == 1) check_point[j][i] = periods[i][j][k];
                }
            }
        }
        int max_n = 0;
        for (int b : check_point[0]) {
            for (int l : check_point[1]) {
                for (int d : check_point[2]) {
                    int res = 0;
                    for (int i = 0; i < n; ++i) {
                        if (b >= periods[i][0][0] && b <= periods[i][0][1] &&
                                l >= periods[i][1][0] && l <= periods[i][1][1] &&
                                d >= periods[i][2][0] && d <= periods[i][2][1]) ++res;
                    }
                    max_n = Math.max(max_n, res);
                }
            }
        }
        System.out.println(max_n);
    }
}


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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T1, typename T2>
inline auto mini(T1 a, T2 b) { return (a < b ? a : b); }
template<typename T, typename... Args>
inline auto mini(T a, Args... args) { return mini(a, mini(args...)); }
template <typename T1, typename T2>
inline auto maxi(T1 a, T2 b) { return (a > b ? a : b); }
template<typename T, typename... Args>
inline auto maxi(T a, Args... args) { return maxi(a, maxi(args...)); }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // use mt19937_64 for 64 bit

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int n, k;
    cin >> n >> k;
    vi a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    int ans = 0;
    for(int i=0; i<k; i++) {
        ans += a[i];
    }
    cout << ans << "\n";
    return 0;
}



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

using namespace std;

//#define FILE_IO

int N;
char s[105], a[2][105];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%s", s + 1);
    N = strlen(s + 1);

    int mn = 1 << 30;
    for(char ch = 'a'; ch <= 'z'; ch++)
    {
        int cnt = 0;
        for(int i = 1; i <= N; i++) cnt += s[i] == ch;
        if(!cnt)    continue;

        for(int i = 1; i <= N; i++) a[0][i] = s[i];

        cnt = 0;
        bool ok = false;
        int M = N;
        int k = 0;
        while(!ok)
        {
            ok = true;
            for(int i = 1; i <= M; i++)
                if(a[k][i] != ch)   ok = false;

            if(ok)  break;

            cnt++;
            k ^= 1;
            M--;
            for(int i = 1; i <= M; i++)
                if(a[k ^ 1][i] == ch || a[k ^ 1][i + 1] == ch)
                    a[k][i] = ch;
                else
                    a[k][i] = a[k ^ 1][i];
        }
        mn = min(mn, cnt);
    }

    printf("%d\n", mn);

    return 0;
}


Measured memory_bytes: 256
def resolve():
    n, a, b = map(int, input().split())
    
    ans = 0
    for i in range(n, 0, -1):
        snum = str(i)
        total = 0
        for c in snum:
            total += int(c)
        if a <= total and total <= b:
            ans += i
    print(ans)
resolve()

Measured memory_bytes: 9164
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=[]
cnt=0
fusoku=0 #正の値とする
for i in range(N):
  C.append([A[i],B[i],A[i]-B[i]])
  if A[i]-B[i]<0:
    cnt += 1
    fusoku += abs(A[i]-B[i])
    
#print(C)
#print(fusoku)
  
if sum(A)<sum(B):
  print(-1)
else:
  C.sort(key=lambda x:x[2],reverse=True)
  for t in C:
    if fusoku<=0:
      break
    else:
      cnt +=1
      fusoku -= t[2]
  print(cnt)

Measured memory_bytes: 26356
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    for (int i = 0; i < a.length; i++)
      a[i] = sc.nextInt();

    for (int i = n - 1; i >= 0; i--)
      if (i != 0)
        System.out.print(a[i] + " ");
      else
        System.out.println(a[i]);
  }
}

Measured memory_bytes: 26224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] str = sc.nextLine().toCharArray();
		for(int i=0; i<str.length; i++) {
			str[i] = Character.toUpperCase(str[i]);
		}
		System.out.println(str);
	}
}



Measured memory_bytes: 25864
def resolve():
    N,K=(int(i) for i in input().split())
    R,S,P=(int(i) for i in input().split())
    pdic={'r':P,'s':R,'p':S}
    T=list(input())
    points=sum([pdic[i] for i in T[:K]])
    for i in range(K):
        for j in range(i+K,N,K):
            if T[j]!=T[j-K]:
                points+=pdic[T[j]]
            else:
                T[j]='x'
    print(points)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 50032
# Dice for AOJ
class Dice
  def initialize(input)
    @t, @s, @e, @w, @n, @b = input
  end

  def roll_e
    tmp = @e
    @e = @t
    @t = @w
    @w = @b
    @b = tmp
  end

  def roll_n
    tmp = @n
    @n = @t
    @t = @s
    @s = @b
    @b = tmp
  end

  def roll_w
    tmp = @w
    @w = @t
    @t = @e
    @e = @b
    @b = tmp
  end

  def roll_s
    tmp = @s
    @s = @t
    @t = @n
    @n = @b
    @b = tmp
  end

  def print_t
    puts @t
  end
end

d = gets.split.map(&:to_i)
dice = Dice.new(d)
cmd = gets.chomp
cmd.length.times do |i|
  c = cmd[i]
  case c
  when 'E'
    dice.roll_e
  when 'N'
    dice.roll_n
  when 'W'
    dice.roll_w
  when 'S'
    dice.roll_s
  end
end
dice.print_t



Measured memory_bytes: 8908
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <map>

template <typename C>
void print_container(const C &c, const std::string &name)
{
  std::cout << name << ": ";
  std::for_each(c.cbegin(), c.cend(),
                [](auto &x) { std::cout << x << ", "; });
  std::cout << std::endl;
}

int main()
{
  int N, M;
  std::cin >> N >> M;

  const std::vector<int> a_vs_m = {
    // 1  2  3  4  5  6  7  8  9
    0, 2, 5, 5, 4, 5, 6, 3, 7, 6
  };

  std::set<int> as;
  std::set<int> ms;
  std::map<int, int> m2a;
  for(int i=0; i<M; i++) {
    int a;
    std::cin >> a;
    as.insert(a);
    int m = a_vs_m[a];
    ms.insert(m);
    m2a[m] = std::max(m2a[m], a);
  }

  // the max number of digits by i-matches.
  // -1 if we cannot create a number.
  std::vector<int> dp(N+1);
  std::vector<std::string> dp_num(N+1);
  dp[0] = 0;
  dp_num[0] = "";

  for(int i=1; i<=N; i++) {
    dp[i] = -1;
    for(auto m: ms) {
      //std::cout << "i: " << i
      //          << " m: " << m
      //          << " i-m: " << i-m
      //          << " dp[i-m]" << (i-m >= 0 ? dp[i-m] : -1)
      //          << std::endl;

      if(m <= i && dp[i-m] >= 0) {
        int nd = dp[i-m] + 1;
        std::string nd_num = std::to_string(m2a[m]) + dp_num[i-m];
        if(dp[i] <= nd) {
          dp[i] = nd;
          if(dp[i] < 0 || dp_num[i][0] < nd_num[0]) {
            dp_num[i] = nd_num;
          }
        }
      }
    }
  }
  // print_container(dp, "dp");
  // print_container(dp_num, "dp_num");

  std::cout << dp_num[N] << std::endl;

  return 0;
}


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

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

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

int main() {
  int i, N, C0=0, C1=0, C2=0, C3=0, C4=0;
  
  scanf("%d", &N);
  
  char S[N][4];
  
  for(i=0; i<N; i++) {
    scanf("%s", S[i]);
  }
  
  for(i=0; i<N; i++) {
    if(strcmp(S[i],"AC") == 0) {
      C0++;
    } else if(strcmp(S[i],"WA") == 0) {
      C1++;
    } else if(strcmp(S[i],"TLE") == 0) {
      C2++;
    } else if(strcmp(S[i],"RE") == 0) {
      C3++;
    } else {
      C4++;
    }
  }
  
  printf("AC x %d\n", C0);
  printf("WA x %d\n", C1);
  printf("TLE x %d\n", C2);
  printf("RE x %d\n", C3);
  
  return 0;
}

Measured memory_bytes: 2120
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
	BufferedReader br =
	    new BufferedReader(new InputStreamReader(System.in));
	String buf;
	int n;
	while(true){
	    int comb=0;
	    if((buf=br.readLine())==null)break;
	    if(buf.length()==0)break;
	    n=Integer.parseInt(buf);
	
	    for(int i=0;i<10;i++){
		if(i>n)break;
		for(int j=0;j<10;j++){
		    if((i+j)>n)break;
		    for(int k=0;k<10;k++){
			if((i+j+k)>n)break;
			for(int l=0;l<10;l++){
			    if((i+j+k+l)>n)break;
			    if((i+j+k+l)==n)comb++;
			}
		    }
		}
	    }
	    System.out.println(comb);
	}
    }
}

Measured memory_bytes: 9488