akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int rec(int sum, int one)
{
    if (sum > 21)
        return -1;
    else if (one == 0 && sum > 21)
        return -1;
    else if (one == 0 && sum <= 21)
        return sum;

    int res = rec(sum + 1, one - 1);
    res = max(res, rec(sum + 11, one - 1));

    return res;
}

bool solve(string &s)
{
    int sum = 0, one = 0;
    int index = 0;

    s += " ";
    while (index < s.size()) {
        int num = 0;

        while (index < s.size()) {
            if ('0' <= s[index] && s[index] <= '9') {
                num *= 10;
                num += (int)(s[index] - '0');
                index++;
            }
            else
                break;
        }

        if (num == 1)
            one++;
        else if (num / 10 == 1)
            sum += 10;
        else
            sum += num;
        index++;
    }

    if (sum == 0 && one == 0)
        return false;

    if (sum > 21) {
        cout << 0 << endl;
        return true;
    }
    else if (one == 0) {
        cout << sum << endl;
        return true;
    }
    else {

        int ans = rec(sum, one);
        if (ans >= 0)
            cout << ans << endl;
        else
            cout << 0 << endl;
        return true;
    }
}

int main()
{
    string s;

    while (true) {
        getline(cin, s);
        if (!solve(s))
            break;
    }

    return 0;
}

Measured memory_bytes: 1176
#include <cstdio>
#include <cmath>
#include <algorithm>
struct point{
	int x, y;
	point(int _x = 0, int _y = 0){ x = _x, y = _y; }
	void read(){ scanf("%d%d", &x, &y); }
	point operator + (const point &rhs) const { return point(x + rhs.x, y + rhs.y); }
	point operator - (const point &rhs) const { return point(x - rhs.x, y - rhs.y); }
}A, B, C, D;
int q;
int dot_product(point a, point b){
	return a.x * b.x + a.y * b.y;
}
int cross_product(point a, point b){
	return a.x * b.y - a.y * b.x;
}
bool intersection(point a, point b, point c, point d){
	if (std :: min(a.x, b.x) > std :: max(c.x, d.x)) return 0;
	if (std :: min(c.x, d.x) > std :: max(a.x, b.x)) return 0;
	if (std :: min(a.y, b.y) > std :: max(c.y, d.y)) return 0;
	if (std :: min(c.y, d.y) > std :: max(a.y, b.y)) return 0;
	int p1 = cross_product(b - a, c - a), p2 = cross_product(b - a, d - a);
	if (1ll * p1 * p2 > 0) return 0;
	p1 = cross_product(d - c, a - c), p2 = cross_product(d - c, b - c);
	if (1ll * p1 * p2 > 0) return 0;
	return 1;
}
int main(){
	scanf("%d", &q);
	for (register int i = 1; i <= q; ++i){
		A.read(), B.read(), C.read(), D.read();
		if (intersection(A, B, C, D)) printf("1\n");
		else printf("0\n");
	}
}


Measured memory_bytes: 2700
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x, n;
    cin>>x>>n;
    set<ll> s;
    while(n--) {
    	ll temp;
    	cin>>temp;
    	s.insert(temp);
    }
    ll l = x, r = x;
    while(true) {
    	if(s.find(l) == s.end()) {
    		cout<<l<<"\n";
    		return 0;
    	}
    	if(s.find(r) == s.end()) {
    		cout<<r<<"\n";
    		return 0;
    	}
    	l--;
    	r++;
    }
}

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

using namespace std;
typedef long long ll;
long long mod = 1000000007;
const int INF = 100100100;

int main(){
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  string ans = "";
  for(int i=0;i<n;i++){
    ans.push_back(s.at(i));
    ans.push_back(t.at(i));
  }
  cout << ans << endl;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<int>v;
	for (int i = 0; i < n; i++)
	{
		int z;
		cin >> z;
		z--;
		v.push_back(z);
	}
	int now = 0,c = 0;
	for (;;)
	{
		if (now == 1)
		{
			cout << c << endl;
			break;
		}
		if (c >= n)
		{
			cout << "-1" << endl;
			break;
		}
		c++;
		now = v[now];
	}
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=2e5+9,mod=1e9+7;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*x*ret%mod;
			x=1LL*x*x%mod,y>>=1;
		}
		return ret;
	}

	int n,m,f[N],sum[N];char s[N];
	int main(){
		n=read<int>(),m=read<int>(),scanf("%s",s+1);
		
		int peg=1;
		for(int i=2;i<=m;i++) if(s[1]!=s[i]) peg=0;
		if(peg){
			f[0]=1,f[1]=0,sum[0]=sum[1]=1;
			for(int i=2;i<=n;i++)
				f[i]=sum[i-2],sum[i]=add(sum[i-1],f[i]);
		//	for(int i=1;i<=n;i++) cout<<f[i]<<" ";cout<<endl;
			int ans=0;
			for(int i=2;i<=n;i++) ans=add(ans,1LL*f[n-i]*i%mod);
			printf("%d\n",add(ans,1));
			return 0;
		}
		int mx=0,i,t;
		for(i=1;i<=m;i++)
			if(s[i]!=s[1]){mx=i-1+(~(i-1)&1);break;}
		for(t=0;i<=m;i++)
			if(s[i]!=s[1]){
				if(t&1) mx=min(mx,t);
				t=0;
			}else t++;

		f[0]=1,f[1]=0,sum[0]=sum[1]=1;
		for(i=2;i<=n;i++){
			if(~i&1) f[i]=sub(sum[i-2],i-mx-2>=0?sum[i-mx-2]:0);
			sum[i]=sum[i-1];
			if(~i&1) sum[i]=add(sum[i],f[i]);
		}
	//	for(int i=1;i<=n;i++) cout<<f[i]<<" ";cout<<endl;
		int ans=0;
		for(int i=2;i<=mx+1;i++) if(~i&1) ans=add(ans,1LL*f[n-i]*i%mod);
		printf("%d\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

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

using namespace std;

typedef pair<int, int> pi;
const int MAXN = 1e5 + 1;
int arr[MAXN],cnt[2][MAXN];
int n;
vector<int> even, odd;
vector<pi> a, b;

bool cmp(pi a, pi b) {
	return a.second > b.second;
}

int main() {
	ios::sync_with_stdio(false);

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		if (i % 2 == 0) {
			cnt[0][arr[i]]++;
			if (cnt[0][arr[i]] == 1) {
				even.push_back(arr[i]);
			}
		}
		else {
			cnt[1][arr[i]]++;
			if (cnt[1][arr[i]] == 1) {
				odd.push_back(arr[i]);
			}
		}

	}

	if (n == 1) {
		cout << 0 << "\n";
		return 0;
	}

	for (auto next : even) {
		a.push_back({ next,cnt[0][next] });
	}

	for (auto next : odd) {
		b.push_back({ next,cnt[1][next] });
	}

	sort(a.begin(), a.end(), cmp);
	sort(b.begin(), b.end(), cmp);

	int t = a[0].first;
	int t2 = b[0].first;

	if (a[0].first == b[0].first) {
		if (a.size() == 1 && b.size() == 1) t2 = t + 1;
		else if(a.size()>1 && b.size()>1){
			if (a[1].second < b[1].second) t2 = b[1].first;
			else t = a[1].first;
		}
		else if (a.size() > 1) {
			t = a[1].first;
		}
		else if (b.size() > 1) {
			t2 = b[1].first;
		}
	}

	int ans = 0;

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0 && t != arr[i]) ans++;
		else if (i % 2 == 1 && t2 != arr[i]) ans++;
	}

	cout << ans << "\n";

	return 0;
}

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

int main(){
    int k;
    cin >> k;
    if(k%2 == 0 || k%5 == 0){
        cout << -1 << endl;
    }
    else if(k == 7){
        cout << 1 << endl;
    }
    else{
        if(k%7 == 0){
            k /= 7;
        }
        //x = 10^n のkのあまり
        //y = Σk = 0　→　k = n(x)
        long long x = 1,y = 0,count = 0;
        while(1){
            x *= 10;
            x = x%k;
            y += x;
            count++;
            if(y%k == 0){
                break;
            }
        }
        //cout << y << endl;
        cout << count << endl;
        
    }
}

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

int main() {
  int n, d;
  cin >> n >> d;
  int x[n+1][d+1];
  
  for(int i=1;i<=n;i++)
    for(int j=1;j<=d;j++)
      cin >> x[i][j];
  
  double dis;
  int cnt = 0;
  for(int i=1;i<n;i++) {
    for(int j=i+1;j<=n;j++) {
      dis = 0;
      for(int k=1;k<=d;k++) {
        dis += pow(x[i][k] - x[j][k], 2);
      }
      dis = sqrt(dis);
      if(ceil(dis) == floor(dis))
        cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9+7;
#define el "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358
#define F first
#define S second
#define pb push_back 
#define mp make_pair
#define f(i,x,y) for(i=x;i<y;i++) 
#define fo(i,x,y) for(i=x;i>=y;i--)
#define all(v) v.begin(),v.end()
#define ss(v) sort(all(v))
//cout<<setprecision(9);
// sieve
/*bool prime[100000];
void sieve(ll n) 
{ 
    
    memset(prime, true, sizeof(prime)); 
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    

}
*/
void solve(){
 ll n,i,k;
 cin>>n>>k;
 ll a[n],b[n];
 f(i,0,n)cin>>a[i];
 if(k>=n-1){
     cout<<a[n-1]-a[0];
     return;
 }
 
 b[0]=0;
 for(i=1;i<=k;i++)
 b[i]=abs(a[i]-a[0]);
 for(i=k+1;i<n;i++){
     b[i]=abs(a[i]-a[i-1])+b[i-1];
     for(ll j=i-2;j>=i-k;j--)
     b[i]=min(b[i],b[j]+abs(a[i]-a[j]));
 }
 cout<<b[n-1]<<el;
}

int main() {
fastio
ll _;
_=1;
//cin>>_;
while(_--)
{
solve();

}
return 0;
}



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

int main(){
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    if (A>K){
        cout << K;
    }else if(A+B>K){
        cout << A;
    }else{
        cout << A-(K-A-B);
    }
}

Measured memory_bytes: 3620
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if(A == B){
            System.out.println(C);
            return;
        }
        if(B == C){
            System.out.println(A);
            return;
        }
        if(A == C){
            System.out.println(B);
        }
    }
}

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

using namespace std;

int main(){
	int x, y;
	bool consegue = false;
	
	cin>>x>>y;
	for(int i = 1; i <= x; i++){
		if((2*i +4*(x-i)) == y ||  (4*i +2*(x-i)) == y){
			consegue = true;
			break;
		}
	}
	if(consegue)cout<<"Yes";
	else cout<<"No";
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
int main(void){
    long int i, sum=0, N;
    scanf("%ld", &N);
    for(i=1; i<=N; i++){
        if(i%3!=0 && i%5!=0){
            sum+=i;
        }
    }
    printf("%ld\n", sum);
    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;
int number[5000];

void solve()
{
	int n;
	while(cin >> n, n)
	{
		memset(number, 0, sizeof(number));
		set<int> Set;
		for(int i = 1; i < n; ++i)
		{
			Set.insert((i * i) % n);
		}
		vector<int> num;
		int size = (n - 1) / 2;
		set<int>::iterator it = Set.begin();
		while(it != Set.end())
		{
			set<int>::iterator it2 = Set.begin();
			while(it2 != Set.end())
			{
				int temp = *it2 - *it;
				if(temp < 0)
				{
					temp += n;
				}
				if(temp > size)
				{
					temp = n - temp;
				}
				++number[temp];
				++it2;
			}
			++it;
		}
		for(int i = 1; i <= size; ++i)
		{
			cout << number[i] << endl;
		}
	}
}

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

Measured memory_bytes: 1456
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int n;
vector<int> node[1005];
int other_min[1005]={0};
int xi[1005]={0};
int dp[1005][5005];
bool dps(int pos){
  if(node[pos].size()==0){
    return true;
  }
  for(int i=0;i<=node[pos].size();i++){
    for(int j=0;j<5005;j++) dp[i][j]=1e7;
  }
  dp[0][0]=0;
  for(int i=0;i<node[pos].size();i++){
    for(int j=0;j<5005;j++){
      if(dp[i][j]<1e7){
        int son=node[pos][i];
        if(j+xi[son]<5005){
          dp[i+1][j+xi[son]]=min(dp[i+1][j+xi[son]],dp[i][j]+other_min[son]);
        }
        if(j+other_min[son]<5005){
          dp[i+1][j+other_min[son]]=min(dp[i+1][j+other_min[son]],dp[i][j]+xi[son]);
        }
      }
    }
  }
  int minest=1e7;
  for(int i=0;i<=xi[pos];i++){
    minest=min(minest,dp[node[pos].size()][i]);
  }
  other_min[pos]=minest;
  return minest<1e7;
}
int main(){
  cin>>n;
  for(int i=2;i<=n;i++){
    int p;
    cin>>p;
    node[p].push_back(i);
  }
  for(int i=1;i<=n;i++) cin>>xi[i];
//  cout<<node[3].size()<<endl;
  for(int i=n;i>=1;i--) {
    //cout<<i<<endl;
    bool f=dps(i);
    if(!f){
      cout<<"IMPOSSIBLE"<<endl;
      return 0;
    }
  //  else cout<<"end"<<endl;
  }
//  for(int i=1;i<=n;i++) cout<<other_min[i]<<" ";
  //cout<<endl;
  cout<<"POSSIBLE"<<endl;
}


Measured memory_bytes: 19840
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();
        Console.WriteLine(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	long long int n;
	cin >> n;

	vector<int> name;
	while(n != 0){
		n--;
		name.push_back(n % 26);
		n /= 26;
	}

	for(int i = name.size() - 1; 0 <= i; i--){
		cout << (char)(name[i] + 'a');
	}

	/*
	cout << endl;
	for(int i = name.size() - 1; 0 <= i; i--){
		cout << name[i] << " ";
	}
	*/

	return 0;
}

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

using namespace std;

int main(void)
{
	int n,m;cin>>n>>m;
	int ans_n,ans_m;
	ans_n = n*(n-1);
	ans_n = ans_n/2;
	ans_m = m*(m-1);
	ans_m = ans_m/2;
	
	int ans = ans_n+ans_m;
	
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
def main():
    n, *a = map(int, read().split())
    r = 0
    maxtall = a[0]
    for i1 in range(1, n):
        if a[i1] > maxtall:
            maxtall =  a[i1]
        else:
            r += maxtall - a[i1]
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 110604
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    long long int N,M,A[100001],MAX=0;
    cin >> N;
    cin >> S;
    map<string,int> mp;
    long long int l = -1;
    long long int r = S.size();
    while(true){
        
        long long int i = l + (r-l)/2;
        if(l+1 == r)break;
        for(int j=0;j<S.size()-i;j++){
            if(mp[S.substr(j,i+1)] == 1){
                MAX = max(i+1,MAX);
                l = i;
                break;
            }else if(j-i >= 0)
                mp[S.substr(j-i,i+1)] = 1;
            if(j == S.size()-i-1){
                r = i;
            }
        }
    }
    cout << (l+1) << endl;
    return 0;
}

Measured memory_bytes: 76928
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	vector<int> cnt(2 * n);
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'o') cnt[i] = cnt[i + c + 1] + 1;
		else cnt[i] = cnt[i + 1];
	}
	rep(i, n) {
		if (s[i] == 'o') {
			if (k - 1 == cnt[i + 1]) cout << i + 1 << endl;
			k--;
			i += c;
		}
	}
}

Measured memory_bytes: 5012
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    rep(i, s.size()){
        int tmp = s[i] - 'A';
        s[i] = 'A' + (tmp+n) % 26;
    }
    cout << s << endl;
    return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int a,b,c;
    Scd3(a,b,c);
    printf("%d\n" , min( c, b/a ) );

    return 0;
}



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

#define INF 100000000
#define MAX_H 1000
#define MAX_W 1000

using namespace std;

typedef pair <int,int> P;

int sx,sy,gx,gy;

char maze[MAX_H][MAX_W];
int H,W,N;
int sum;

int d[MAX_H][MAX_W];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

void bfs(int n){
	if (n==N) {
		return;
	}
	else{
		queue<P> que;
		if(n!=0){
			for (int i=0; i<H; i++) {
				for (int j=0; j<W; j++) {
					d[i][j]=INF;
					if (maze[i][j]==n+48) {
						sx=j;
						sy=i;
					}
					if (maze[i][j]==n+49) {
						gx=j;
						gy=i;
					}
				}
			}
		}
		que.push(P(sy,sx));
		d[sy][sx]=0;
		while (que.size()) {
			P p=que.front();
			que.pop();
			if (p.first==gy&&p.second==gx) {
				break;
			}
			for (int i=0; i<4; i++) {
				int nx=p.second+dx[i],ny=p.first+dy[i];
				if (0<=nx&&nx<W&&0<=ny&&ny<H&&maze[ny][nx]!='X'&&d[ny][nx]==INF) {
					que.push(P(ny,nx));
					d[ny][nx]=d[p.first][p.second]+1;
				}
			}
		}
	
	sum+=d[gy][gx];
	
	bfs(n+1);
	return;
	}
}

int main(){
	cin>>H>>W>>N;
	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			d[i][j]=INF;
			cin>>maze[i][j];
			if (maze[i][j]=='S') {
				sx=j;
				sy=i;
			}
			if (maze[i][j]=='1') {
				gx=j;
				gy=i;
			}
		}
	}

	bfs(0);
	cout << sum <<endl;
	
}

Measured memory_bytes: 0
n = int(input())
s = list(input())
b=0
if n%2 == 1:
  print("No")
else:
  for i in range(n//2):
    if s[i] != s[(n//2)+i]:
      b=1
  if b==0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
	int N,temp,*array;
	cin >> N;
	array = new int[N];
	for( int i = 1; i < N;i++)
	    array[i]=0;
	for( int i = 1; i < N;i++)
	{
	    cin >> temp;
	    array[temp-1]++;
	}
    for( int i = 0; i < N;i++)
	    cout << array[i] << endl;

	return 0;
}


Measured memory_bytes: 4368
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()




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

	int a, b, d;
	cin >> a >> b >> d;
	cout << b / d - (a - 1) / d << endl;

	return 0;
}


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

using ll = long long;
using ld = long double;

int main(void)
{
    int x;
    ll n,k;
    cin >> n >> k;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    ll b[k];
    for(int i=0;i<n-k;i++)
    {
        if(a[i]<a[i+k])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5232
#include <bits/stdc++.h>
#define int long long
#define INF 1e+18
using namespace std;

signed main(){
	int n,cnt[5] = {},ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		if(s[0] == 'M') cnt[0]++;
		else if(s[0] == 'A') cnt[1]++;
		else if(s[0] == 'R') cnt[2]++;
		else if(s[0] == 'C') cnt[3]++;
		else if(s[0] == 'H') cnt[4]++;
	}
	for(int i = 0;i < 5;i++){
		for(int j = i + 1;j < 5;j++){
			for(int k = j + 1;k < 5;k++) ans += cnt[i] * cnt[j] * cnt[k];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,c,d=0,f=0;cin>>a>>b;
  vector<ll>e(a+1,0);
  rep(i,b){
    cin>>c;
    e[c-1]++;
    cin>>c;
    e[c]--;
  }
  rep(i,a){
    d+=e[i];
    if(d==b)f++;
  }
  cout<<f;
}



Measured memory_bytes: 27480
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        1000000007
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
    ll i,j,k,n,m,a,r;
    char c;
    cin>>c;
    if(c>='A' && c<='Z') cout<<"A";
    else cout<<"a";
}

int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(std::string S){
    if (S.back() == 's') {
        cout << S + "es" << endl;
    } else {
        cout << S + 's' << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	int n;
	ll cb = 0;
	ll ca = 0;
	cin>>n;
	vector<pair<ll,ll>> pr(n);
	for(int i = 0; i < n; i++){
		ll a,b;
		cin>>a>>b;
	    pr[i] = make_pair(b,a);
	}
	sort(pr.begin(),pr.end());

	ll prev = 0;
	for(int i = 0; i<pr.size();i++){
	   ll b = pr[i].first;
	   ll a = pr[i].second;
	   if(a+prev>b){
	   	cout<<"No";
	   	return 0;
	   }
      prev = a+prev;
	}
	cout<<"Yes";
}

Measured memory_bytes: 3328
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

signed main()
{
    int n,m;
    map <int,int> cnt;
    cin >>n >> m;
    for (int i=1;i<=m;i++){
        int a,b; cin >> a>>b;
        cnt[a]++,cnt[b]++;
    }
    bool ok=true;
    for (int i=1;i<=n;i++){
        if (cnt[i]&1) ok=false;
    }
    cout << ((ok)?"YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 9880
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


const int Max=10000000;
bool prime[Max];
int main(void){
  int n, sum=100000;
  cin >> n;

  for(int i=0; i<n; i++){
    sum *= 1.05;
    if(sum%1000 != 0) sum = (sum/1000+1)*1000;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define sanyes ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long int
#define pb push_back
#define bpc __builtin_popcount
#define f first
#define s second

const llong mxn = 1e5 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

llong n, m, dp[1001][1001], pref[mxn], cnt = 0;
char a[1001][1001];

int main(){
    cin >> n >> m;
    for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= m; j ++){
            cin >> a[i][j];
        }
    }if(a[1][1] != '#'){
        cout << "Impossible";
        return 0;
    }
    for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= m; j ++){
            if(a[i][j] == '#'){
                cnt ++;
            }
        }
    }if(cnt == n + m - 1) cout << "Possible";
    else cout << "Impossible";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    long long a, b, r, x = 1, z = 0;
    cin >> b >> a;
    r = a / b;
    while(r >= x)
    {
        z++;
        x *= 2;
    }
    cout << z << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  ll mod = 1000000007;
  ll n;
  cin >> n;

  if(n==1) {
    cout << 0 << endl;
    return 0;
  }

  ll a, b, c;
  a = b = c = 1;

  rep(i, n) {
    a = (a * 10) % mod;
    b = (b * 9) % mod;
    c = (c * 8) % mod;
  }
  ll r = a - 2 * b + c;
  while(r < 0) {
    r += mod;
  }
  cout << r % mod << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int a,b;
    cin >> a >> b;
    if (a <= b * 2) {
        cout << 0 << endl;
    }else{
        cout << a - b * 2 << endl;
    }
    return 0;
}


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

const int N = 1e5 + 10;

vector<int> V[N];
int n, dp[N];
set<int> ST;

void dfs(int x, int fa){
    dp[x] = 0;
    for(int i=0; i<V[x].size(); i++){
        int j = V[x][i];
        if(j == fa) continue;
        dfs(j, x);
        dp[x] ^= (dp[j] + 1);
    }
}

int main(){
    int x, y;
    while(~scanf("%d", &n)){
        for(int i=1; i<=n; i++) V[i].clear();
        for(int i=1; i<n; i++){
            scanf("%d %d", &x, &y);
            V[x].push_back(y);
            V[y].push_back(x);
        }
        dfs(1, -1);
        puts(dp[1] ? "Alice" : "Bob");
    }
    return 0;
}


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = ReadLine().ToArray();
            var rN = N.Reverse().ToArray();
            if (string.Join("", N) == string.Join("", rN))
                WriteLine("Yes");
            else
                WriteLine("No");
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

const int MOD = 1e9+7;
const int MAX_N = 2e6+10;
ll N, M;
ll fac[MAX_N+1], inv[MAX_N+1];

ll powmod(ll x, int y)
{
	ll res = 1;
	while(y){
		if(y&1) (res*=x)%=MOD;
		(x*=x)%=MOD;
		y>>=1;
	}
	return res;
}

ll nCk(int n, int k)
{
	if(k<0||k>n) return 0;
	return ((fac[n]*inv[k])%MOD)*inv[n-k]%MOD;
}

map<int,int> cal(ll x)
{
	map<int,int> res;
	for(ll i=2;i*i<=x;++i)if(x%i==0){
		int cnt = 0;
		while(x%i == 0){
			cnt++;
			x/=i;
		}
		res[i] = cnt;
	}
	if(x!=1) res[x]=1;
	return res;
}

void solve()
{
	if(M==1){
		cout<<1<<'\n';
		return;
	}
	fac[0]=1LL;
	for(int i=1;i<=MAX_N;++i) fac[i] = (1LL*i*fac[i-1])%MOD;
	inv[MAX_N] = powmod(fac[MAX_N], MOD-2);
	for(int i=MAX_N-1;i>=0;--i) inv[i] = (1LL*(i+1)*inv[i+1])%MOD;
	map<int,int> f = cal(M);
	ll res = 1LL;
	for(auto p : f){
		int b = p.second;
		(res *= nCk(b+N-1, b))%=MOD;
	}
	cout<<res<<'\n';
}

int main()
{
	cin >> N >> M;
	solve();
	return 0;
}

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

int main() {
  int n, h;
  cin >> n >> h;

  vector<int64_t> a(n), b(n + 1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i + 1];
  }

  int64_t max_a = 0;
  for (auto &i : a) max_a = max(max_a, i);

  sort(b.begin() + 1, b.end(), greater<int64_t>());
  for (int i = 1; i <= n; ++i) {
    b[i] += b[i - 1];
  }

  int64_t ans = 1001001001001001001ll;
  for (int i = 0; i <= n; ++i) {
    ans = min(ans, i + max(int64_t(0), (h - b[i] + max_a - 1) / max_a));
  }

  cout << ans << endl;
}


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

int main()
{
        char input[1200];
        char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
        char num[26];

        for (int i = 0; i < 26; i++) {
                        num[i] = 0;
        }

        while (fgets(input, sizeof(input), stdin) != NULL) {
                int i = 0;
                while(input[i] != '\0') {
                                if (65 <= input[i] && input[i] <= 90) {
                                                num[input[i]-65]++;
                                } else if (97 <= input[i] && input[i] <= 122) {
                                                num[input[i]-97]++;
                                }
                                i++;
                }
        }
        for (int i = 0; i < 26; i++) {
                        printf("%c : %d\n", alpha[i], num[i]);
        }
}



Measured memory_bytes: 2104
#include <iostream>
using namespace std;
int main(){
    int a,b;
    while(cin>>a>>b){
        if(a==0)break;
        int s[b][a];
        for(int i = 0; b > i; i++){
            for(int j = 0; a > j; j++){
                cin>>s[i][j];
            }
        }
        int ans = 0;
        for(int i = 0; a > i; i++){
            int sm = 0;
            for(int j = 0; b > j; j++){
                sm += s[j][i];
            }
            ans = max(sm,ans);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3292
#include <iostream>

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		int c[10]={};
		while(n--){
			int x; cin>>x;
			c[x]++;
		}
		for(int i=0;i<10;i++){
			if(c[i]==0)
				cout<<'-'<<endl;
			else
				cout<<string(c[i],'*')<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int[][] di=new int[10][10];
int count=0;
int max=0;
String str;
while((str=br.readLine())!=null){
String[] value=str.split(",");
int x=Integer.parseInt(value[0]);
int y=Integer.parseInt(value[1]);
int s=Integer.parseInt(value[2]);
drop(x,y,s,di);
}
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
max=Math.max(max,di[i][j]);
if(di[i][j]==0){
count++;
}
}
}
System.out.println(count);
System.out.println(max);
}
static void drop(int x,int y,int s,int[][] di){
if(s==1||s==2||s==3){
di[x][y]++;
int[] sx={1,0,-1,0};
int[] sy={0,1,0,-1};
for(int i=0;i<sx.length;i++){
if(x+sx[i]>=0&&x+sx[i]<10&&y+sy[i]>=0&&y+sy[i]<10){
di[x+sx[i]][y+sy[i]]++;
}
}
if(s==2||s==3){
int[] mx={-1,-1,1,1};
int[] my={-1,1,-1,1};
for(int i=0;i<mx.length;i++){
if(x+mx[i]>=0&&x+mx[i]<10&&y+my[i]>=0&&y+my[i]<10){
di[x+mx[i]][y+my[i]]++;
}
}
if(s==3){
int[] lx={-2,0,2,0};
int[] ly={0,-2,0,2};
for(int i=0;i<lx.length;i++){
if(x+lx[i]>=0&&x+lx[i]<10&&y+ly[i]>=0&&y+ly[i]<10){
di[x+lx[i]][y+ly[i]]++;
}
}
}
}
}
}
}

Measured memory_bytes: 16924
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string S; cin >> S;
  int ans = 1000;
  rep(i,S.size()-2) {
    int t = int(S[i]-48) * 100 + int(S[i+1]-48) * 10 + int(S[i+2]-48);
    ans = min(ans, abs(t - 753));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
const int N = 401;
long long dp[N][N];
long long MAX = 1e18;
long long a[N], n;
long long pre[N];
long long solve(int l, int r)
{
	if(l == r)
		return a[l];

	if(dp[l][r] != -1)
		return dp[l][r];
	
	dp[l][r] = MAX;
	for(int i=l;i<r;i++)
		dp[l][r] = min(dp[l][r], solve(l, i) + solve(i+1, r) + (i>l?pre[i+1]-pre[l]:0) + (i+1<r?pre[r+1]-pre[i+1]:0));

	return dp[l][r];
}
int main()
{
	memset(dp, -1, sizeof(dp));
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];

	for(int i=1;i<=n;i++)
		pre[i] = pre[i-1] + a[i-1];
	cout<<solve(0, n-1);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define sorted(vector) sort(vector.begin(),vector.end())
#define vmax(vector) *max_element(vector.begin(),vector.end())
#define vsum(vector) accumulate(vector.begin(),vector.end(),0)
#define append(a) push_back(a)
#define int(a) stoi(a)
#define str(a) to_string(a)


int main(void){
    int n,k,tmp;
    vector<int> v,motimono,ans;
    cin>>n>>k;
    for(int i=0  ;i<n  ;i++){
        cin>>tmp;
        v.push_back(tmp);
    }
    
    
    if (k>=n){
        k-=n;
        ans.append(vsum(v));
        sorted(v);
        for(int i=0  ;i< min<unsigned long>(k,n) ;i++){
            v[i]=0;
            ans.append(vsum(v));
            }
    }else{
        for(int i=0  ;i<n  ;i++){
            v.append(v[i]);
        }
        for(int j=1  ;j<k+1  ;j++){  //長さ
            for(int i=n-j  ;i<n+1  ;i++){ //開始index
                vector<int> motimono = vector<int>(v.begin()+i,v.begin()+i+j);
                ans.append(vsum(motimono));
                sorted(motimono);
                for(int i=0  ;i< min<unsigned long>(k-j,motimono.size())  ;i++){
                    motimono[i]=0;
                    ans.append(vsum(motimono));
                }
            }
        }
    }
    cout<<vmax(ans)<<endl;
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

ll solve() {
    ll N;
    cin >> N;
    auto A = make_v<ll>(-1, N, N - 1);
    for(auto &&v : A) for(auto &&ele : v) {
        cin >> ele;
        ele--;
    }
    V<ll> idx(N, 0);
    V<ll> ok(N, -1);
    ll ans = 0;
    for(;; ans++) {
        bool update = false;
        for(auto &&ele : ok) ele = -1;
        for(ll i = 0; i < N; i++) {
            if(idx[i] == N - 1) continue;
            if(ok[i] != -1) continue;
            ll p = A[i][idx[i]];
            if(idx[p] == N - 1) return -1;
            if(ok[p] != -1) continue;
            if(A[p][idx[p]] == i) {
                ok[i] = p;
                ok[p] = i;
                idx[i]++;
                idx[p]++;
                update = true;
            }
        }
        if(!update) break;
    }
    for(ll i = 0; i < N; i++) if(idx[i] != N - 1) return -1;
    return ans;
}

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


Measured memory_bytes: 10112
H, W, A, B = map(int, input().split())

MAX = 2 * 10 ** 5 + 1
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    
# Inverse factorial
finv = [0] * (MAX + 1)
finv[MAX] = pow(fac[MAX], MOD - 2, MOD)
for i in reversed(range(1, MAX + 1)):
    finv[i - 1] = finv[i] * i % MOD


def comb(a, b):
    return fac[a + b] * finv[a] * finv[b]


ans = 0
for i in range(B, W):
    ans += comb(i, H - A - 1) * comb(W - i - 1, A - 1) % MOD
    ans %= MOD

print(ans)


Measured memory_bytes: 44268
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int A[n]={};
    int MaxA;
    int MinA;
    int ans;
    for(int i=0;i<n;i++){
        cin >>A[i];
        if(i==0){
            MaxA=A[i];
            MinA=A[i];
        }
        MaxA=max(MaxA,A[i]);
        MinA=min(MinA,A[i]);
    }
    cout << MaxA-MinA <<endl;
    
    return 0;
}

Measured memory_bytes: 256
lst=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
for i in range (28):
    a=int(input())
    lst.remove(a)

print(lst[0])
print(lst[1])



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

#define     bip(a)         __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front ///for list
#define     mp             make_pair
#define     is             insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));


int main()
{
    string str;
    cin>>str;
    if(str[str.length()-1]=='2'||str[str.length()-1]=='4'||str[str.length()-1]=='5'||str[str.length()-1]=='7'||str[str.length()-1]=='9')
        cout<<"hon\n";
    else if(str[str.length()-1]=='3')
        cout<<"bon\n";
    else cout<<"pon\n";
}



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

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

int digit(int n) { return (int)(log10(n) + 1); }

// 152-d
int main() {
    int n;
    cin >> n;

    vector<vector<int>> mat(10, vector<int>(10, 0));

    string mstr = "";
    int fst = 0, lst = 0;
    repe(m, 1, n) {
        mstr = to_string(m);
        fst = (int)mstr[0] - 48, lst = (int)mstr[mstr.size() - 1] - 48;
        mat[fst][lst]++;
    }

    int cnt = 0;
    repe(m, 1, n) {
        mstr = to_string(m);
        fst = (int)mstr[0] - 48, lst = (int)mstr[mstr.size() - 1] - 48;
        if (lst == 0) continue;
        cnt += mat[lst][fst];
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256