akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> vec(N);
  vector<int> zana(100005);
  rep(i,N)
  {
    cin >> vec[i];
    zana[vec[i]] ++;
  }
  sort(ALL(vec));
  int M = 0;
  rep(i,100000)
  {
    int X = zana[i] + zana[i+1] + zana[i+2];
    M = max(M,X);
  }
  cout << M << endl;
  return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;
typedef long long int lli;


void solve(){
	int n;
	cin>>n;
	int a[n], b[n], c[n];
	for(int i=0; i<n; i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	int dp[n][3];
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(int i=1; i<n; i++){
		dp[i][0]=max(dp[i-1][1], dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0], dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][1], dp[i-1][0])+c[i];
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
}

signed main(){
	//#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
   // freopen("output.txt", "w", stdout);
   // #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}


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

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

  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);

  int sum = 0;
  int count = 0;

  for(int i=0;i<n;i++)
  {
    sum += a[i];
    if(sum <= x) count++;
    else break;
  }
  if(count == n && sum < x) count--;

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define S second
#define F first
#define ll long long
#define ld double

using namespace std;

const ll N = 2e5 + 5, M = N * 2;

int main()
{
    ll r;
    scanf("%lld", &r);
    ld ans = 2 * acos(-1) * r;
    printf("%.3lf\n", ans);
}


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

#define ll long long

using namespace std;

const ll P = 7;
const ll M = (ll)1e9 + 7, M2 = (ll)1e9 + 9;

int main()
{
    //freopen("printer.in", "r", stdin);
    //freopen("printer.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i <= n; i++)
    {
        bool ok = true;
        for (int j = i; j < n; j++)
            if (s[j] != t[j - i])
                ok = false;
        if (ok)
        {
            cout << n + i << endl;
            break;
        }
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

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

  vi a(n);
  rep(i, n) cin >> a[i];

  int ma = 0, mi = a[0];
  repi(i, 1, n){
    ma = max(ma, a[i] - mi);
    mi = min(mi, a[i]);
  }

  int ans = 0;
  mi = a[0];
  repi(i, 1, n){
    if(a[i] - mi == ma) ans++;
    mi = min(mi, a[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment(" -Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,ans;
int a[100005];
char c[100005];
bool used[100005];
int id[100005];
signed main(){
//	freopen("data.txt","r",stdin);
	cin>>n;cin>>a[1]; 
	for(int i=2;i<=n;i++){
		cin>>c[i]>>a[i];
	}
	vector<int>vec;
	for(int i=1;i<=n;i++){
		if(used[i])continue;
		int now=i+1;
		while(now<=n&&c[now]=='+'){
			now++;
		}
		int sum=0;
		for(int j=i;j<now;j++){
			used[j]=1;
			sum+=a[j];
			id[j]=vec.size();
		}
		vec.push_back(sum);
	}
	if(vec.size()==1){
		cout<<vec[0]<<endl;
	}else{
		int sum=0;
		for(int i=1;i<=n;i++)sum+=a[i];
		for(int i=2;i<=n;i++){
			if(c[i]=='-'){
//				cerr<<i<<" "<<sum-vec[id[i]]*2ll<<endl;
				ans=max(ans,sum-vec[id[i]]*2ll);
				sum-=a[i]*2ll;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2932
s = input()

count1 = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "1":
            count1 += 1
    else:
        if s[i] == "0":
            count1 += 1
count2 = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "0":
            count2 += 1
    else:
        if s[i] == "1":
            count2 += 1

print(min(count1, count2))


Measured memory_bytes: 40176
#include<bits/stdc++.h>
int main()
{
  int n;
  scanf("%d",&n);
  long long sum=0;
  for(int i=1;i<=n;i++)
  {
    if(i%3&&i%5) sum+=i;
  }
      printf("%lld\n",sum);
  return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'001;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ans += x >= k;
  }
  cout << ans << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

int main()
{
    string S;
    int K;
    cin >> K >> S;
    int len = S.length();

    if (len <= K)
    {
        cout << S << endl;
    }
    else
    {
        cout << S.substr(0, K) + "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned long;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        string S; cin >> S;
        UL N; cin >> N;
        rep(i, N) {
            string c; cin >> c;
            if (c == "replace") {
                UL a, b; cin >> a >> b;
                string T; cin >> T;
                rep(i, b - a + 1) S[i + a] = T[i];
            }
            else if (c == "reverse") {
                UL a, b; cin >> a >> b;
                reverse(S.begin() + a, S.begin() + b + 1);
            }
            else if (c == "print") {
                UL a, b; cin >> a >> b;
                for (UL i = a; i <= b; i++) cout << S[i];
                cout << endl;
            }
        }
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



Measured memory_bytes: 3204
#include<iostream>
#include<stdio.h>
#include <bits/stdc++.h>
#include<string>
#include<vector>
#include<iterator>
#include<algorithm>

using namespace std;

int main()
{
    double r;

    cin>>r;

    cout<<2*r*3.14156;

    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
#include<tr1/unordered_map>
using namespace std;
typedef long long ll;
#define pb push_back
const ll INF=1e18;
const int inf=0x3f3f3f3f;
const int M=2e6+6;
void py(){
    cout<<"Yes"<<'\n';
}
void pn(){
    cout<<"No"<<'\n';
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
    for(int k=1;k<=n;k++){
        ans+=1ll*__gcd(i,__gcd(j,k));
    }
    cout<<ans<<endl;
    return 0;
}


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

int		main(void)
{
	char buf_str[500002];
	int q;
	int start_h = 230001;
	int end_h = start_h;
	scanf("%s", &buf_str[start_h]);
	scanf("%d", &q);

	int index = start_h;
	while (buf_str[end_h] != '\0')
		end_h++;
	start_h = start_h - 1;

	int dq;
	int f;
	char c;
	int flag = 1;

	index = 0;
	while (index <q)
	{
		scanf("%d", &dq);
		if (dq == 1)
		{
			flag = flag * (-1);
		}
		else if (dq == 2)
		{
			scanf("%d %c", &f, &c);
			if ((f == 1 && flag == 1) || (f == 2 && flag == -1))
			{
				buf_str[start_h] = c;
				start_h = start_h -1;
			}
			else if ((f == 2 && flag ==1) || (f == 1 && flag == -1))
			{
				buf_str[end_h] = c;
				buf_str[end_h+1] = '\0';
				end_h++;
			}
		}
		index++;
	}
	index = 0;
	char *r_str = &buf_str[start_h +1];
	if (flag == -1)
	{
		while (index < (end_h - start_h - 1))
		{
			putchar_unlocked(buf_str[end_h-1-index]);
			index++;
		}
		putchar_unlocked('\n');
	}
	else
		printf("%s\n",r_str);
	return (0);
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template <typename T>
struct SegTree{
    vector<T> dat;
    int n;
    const T Default;
    SegTree(int n_, const T& def) : Default(def){init(n_);}
    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        dat = vector<T>(2*n-1, Default);
    }
    T f(const T& a, const T& b) {
        return (a+b)%MOD;
    }
    void update(int k, const T& a){
        k += n-1;
        (dat[k] += a) %= MOD;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    T query(int a, int b, int k, int l, int r ){
        if(r <= a || b <= l) return Default;
        if(a <= l && r <= b) return dat[k];
        T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }
};

int main(){
    ll n, k;
    cin >> n >> k;
    vl a(n);
    rep(i, n) cin >> a[i];
    SegTree<ll> seg(2010, 0LL);
    ll cnt = 0;
    rep(i, n) {
        (cnt += seg.query(a[i]+1, 2010)) %= MOD;
        seg.update(a[i], 1);
    }
    ll cnt2 = 0;
    rep(i, n) {
        (cnt2 += seg.query(0, a[i])) %= MOD;
    }
    ll m = k*(k-1)/2;
    m %= MOD;
    cout << ((cnt*k)%MOD+(m*cnt2)%MOD)%MOD << endl;
    // cout << cnt << " " << cnt2 << endl;
    return 0;
}

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

int main(){
    long a[105][105], b[105][105], c[105][105]= {{0}};
    int  n, m, l;
    
    cin >> n >> m >> l;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> a[i][j];
        }
    }
    for(int j = 1; j <= m; j++){
        for(int k = 1; k <= l; k++){
            cin >> b[j][k];
        }
    }
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= l; j++){
            for(int k = 1; k <= m; k++){
                c[i][j] += a[i][k]*b[k][j];
            }
        }
    }
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= l; j++){
                if(j == 1)  cout << c[i][j];
                else    cout << " " << c[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3328
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0221().doIt();
	}
	
	class AOJ0221{
		boolean[] person;
		int m,n;
		void doIt(){
			while(true){
				m = in.nextInt();n = in.nextInt();
				if(m+n==0)break;
				person = new boolean[m];
				int user = 0;
				int cnt = 0;
				for(int i=1;i<=n;i++){
					String input = in.next();
					String talk = getTalk(i);
//					System.out.println("User talk = "+input);
//					System.out.println("shouled talk = "+talk);
					if(input.equals(talk)==false&&m-cnt>1){
						person[user] = true;cnt++;
					}
					user = getUser(user);
//					System.out.println("next user is "+user);System.out.println();
				}
//				System.out.println(Arrays.toString(person));
				int i;
				for(i=0;i<m;i++)if(person[i]==false){
					System.out.print(i+1);
					break;
				}
				for(i=i+1;i<m;i++)if(person[i]==false)System.out.print(" "+(i+1));
				System.out.println();
			}
		}
		
		String getTalk(int num){
			return num%15==0? "FizzBuzz" : num%3==0? "Fizz" : num%5==0? "Buzz":Integer.toString(num);
		}
		
		int getUser(int currentUser){
			for(int i=1;i<=m;i++)if(!person[(currentUser+i)%m])return (currentUser+i)%m;
			return -1;
		}
		
	}
	
}

Measured memory_bytes: 70696
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define mod 1000000007
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
	
//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
	
	double n,k,t;
	cin>>n>>k>>t;
	double m=(n/k);
	int x=ceil(m);
	cout<<fixed<<setprecision(0)<<x*t<<endl;
	return 0;
}

Measured memory_bytes: 3852
def main():
    n = int(input())
    a = list(map(int,input().split()))
    d = {}
    for i in range(n):
        if d.get(a[i]) == None:
            d[a[i]] = 1
        else:
            d[a[i]] += 1
    ans = 0
    for k in d.keys():
        ans += d[k] * (d[k]-1) //2
    for i in range(n):
        print(ans - ((d[a[i]]*(d[a[i]]-1))//2 - (d[a[i]]-1) * (d[a[i]]-2)//2))

if __name__ == "__main__":
    main()


Measured memory_bytes: 33256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  
  map<ll, ll> mp;
  if (m==0) {
    if (n != 1) cout << pow(10, n - 1) << '\n';
    else cout << 0 << '\n';
  } else {
    for (ll i = 0; i < m; ++i) {
      ll a, b;
      cin >> a >> b;
      if (a == 1 && b == 0 && n != 1) {
        cout << -1 << '\n';
        return 0;
      } else if (mp.count(a)) {
        if (mp[a] != b) {
          cout << -1 << '\n';
          return 0;
        }
      } else {
        mp[a] = b;
      }
    }
  
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      if (mp.count(i)) {
        ans += mp[i] * pow(10, n - i);
      } else if (i == 1) {
        ans += pow(10, n - i);
      }
    }
    cout << ans << '\n';
  }
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	string s; cin>>s;
	int n=s.length();

	int cnt=0,del=0;
	rep(i,n){
		if(s[i]=='S'){
			cnt++;
		}
		else{
			if(cnt>0){
				cnt--;
				del++;
			}
		}
	}
	printf("%d\n",n-2*del);

	return 0;
}


Measured memory_bytes: 640
s = input()
t = input()
ans = len(s)

for i in range(len(s)):
  if (i + len(t) - 1 >= len(s)): break
  dif = 0
  for j in range(len(t)):
    if (s[i + j] != t[j]):
      dif += 1
  ans = min(ans, dif)
print(ans)

Measured memory_bytes: 9124
from bisect import bisect
from collections import deque

N = int(input())
A = list(map(int, input().split()))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

BC_ruiseki = deque([0])
for i, b in enumerate(B):
  BC_ruiseki.append(BC_ruiseki[i] + N - bisect(C, b))

ans = 0
for a in A:
  idx = bisect(B, a)
  ans += BC_ruiseki[-1] - BC_ruiseki[idx]
print(ans)

Measured memory_bytes: 107236
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

A, B, C, D = map(int, input().split())

cd_lcm = int(C * D / gcd(C, D))

def not_devide(i):
  ans = i - i//C - i//D + i//cd_lcm
  
  return ans

print(not_devide(B) - not_devide(A-1))

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

int main() {
  int a,c=0;
  cin>>a;
  vector <int> b(a);
  for (int i=0;i<a;i++){
    cin>>b.at(i);
  }
  sort(b.rbegin(),b.rend());
  for(int i=0;i<a-2;i++){
    for(int j=i+1;j<a-1;j++){
      for(int k=j+1;k<a;k++){
        if(b.at(k)+b.at(j)>b.at(i)&&!(b.at(k)==b.at(j))&&!(b.at(j)==b.at(i)))c++;
      }
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
using namespace std;

int main(){
    int N;
    scanf("%d",&N);
    int sum =0;

    for(int i= 1;i<=N;i++){
        if(0 < i && i < 10){
            sum++;
        }
        else if(99 < i && i < 1000){
            sum++;
        }
        else if(9999 < i && i < 100000){
            sum++;
        }
    }

    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	l := Scanner()
	ans := 1
	for i := 1; i <= len(l); i++ {
		if string(l[len(l)-i]) == "1" {
			ans = ans*2 + repeatPow(3, i-1, mod)
			ans %= mod
		}
	}
	fmt.Println(ans)
}
func repeatPow(x, y, d int) int {
	if y == 0 {
		return 1
	}
	if y == 1 {
		return x
	} else {
		z := repeatPow(x, y/2, d)
		if y%2 == 0 {
			return z * z % d
		} else {
			return z * z % d * x % d
		}
	}
}


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

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    int cost1=0, cost2=0;
    int a;
    for(int i=0; i<M; i++){
        cin >> a;
        if(a<X) cost1++;
        else cost2++;
    }
    cout << min(cost1,cost2) << endl;
}

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

using namespace std;
typedef long long ll;

template <int MD>
struct ModInt {
    typedef ModInt M;
    int v;
    ModInt(int _v = 0) : v(_v) {}

    M& operator += (const M &r) {
        if ((v += r.v - MD) < 0) v += MD;
        return *this;
    }
    M& operator *= (const M &r) {
        v = ll(v) * r.v % MD;
        return *this;
    }

    M operator + (const M &r) const { return M(*this) += r; }
    M operator * (const M &r) const { return M(*this) *= r; }
};
typedef ModInt<1000000007> Mint;

const int MN = 3010;
int n;
char s[MN];
Mint dp[MN][MN];

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

    dp[1][1] = 1;
    for (int i = 1; i < n; i++) {
        Mint sum = 0;
        if (s[i - 1] == '<') {
            for (int j = 1; j <= i + 1; j++) {
                dp[i + 1][j] = sum;
                sum += dp[i][j];
            }
        } else {
            for (int j = i + 1; j >= 1; j--) {
                sum += dp[i][j];
                dp[i + 1][j] = sum;
            }
        }
    }

    Mint sm = 0;
    for (int i = 1; i <= n; i++) sm += dp[n][i];
    cout << sm.v << endl;
    return 0;
}

Measured memory_bytes: 35584
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
using namespace std;
typedef long long ll;

int main(){
    int h,n; cin>>h>>n;
    int sum=0;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        sum+=a;
    }
    if(h>sum) cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    var args = chunk.split(' ').map(Number);
    var w = args[0];
    var h = args[1];
    var x = args[2];
    var y = args[3];
    var r = args[4];

    console.log('%s', 0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h ? 'Yes' : 'No');
});

Measured memory_bytes: 7648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a1 = sc.nextInt();
			int a2 = sc.nextInt();
			int a3 = sc.nextInt();

			if (a1 + a2 + a3 <= 21) {
				System.out.println("win");
			} else {
				System.out.println("bust");
			}
		}
	}
}


Measured memory_bytes: 22480
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(VEC(int)) Counts(10, VEC(int)(10, 0));
    FOR(i, 1, N + 1) {
        ostringstream out;
        out << i;
        string s = out.str();
        int f = s[0] - '0', l = s.back() - '0';
        Counts[f][l]++;
    }

    lint ret = 0;
    FOR(fd, 1, 10)
        FOR(ld, 0, 10)
            ret += Counts[fd][ld] * 1LL * Counts[ld][fd];
    cout << ret << endl;
    return 0;
};

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x,y,a;
  int d, k;
  scanf("%d%d",&x,&y);
  
  if(x > y){
    d = x % y;
    for(k = d; k > 0; k--){
      if(x%k==0 && d%k==0)break;
    }
    printf("%d\n",k);
  }else if(x < y){
    d = y % x;
    for(k = d; k > 0; k--){
      if(y%k==0 && d%k==0)break;
    }
    printf("%d\n",k);
  }else{
    printf("%d\n",x);
  }
  return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

int main(int argc, char const *argv[]) {
    int N, T;
    cin >> N >> T;

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<pair<int, int>> city_idxs;
    set<pair<int, int>> left_cities;
    int profit = 0;

    for (int i = N-2; i >= 0; --i) {
        left_cities.insert(make_pair(A[i+1], i+1));
        auto iter = left_cities.rbegin();  // find highest one

        int pr = iter->first - A[i];
        if (pr > profit) {
            profit = pr;
            city_idxs.clear();
            city_idxs.push_back(make_pair(i, iter->second));
        } else if (pr == profit) {
            city_idxs.push_back(make_pair(i, iter->second));
        }
    }

    cout << city_idxs.size() << endl;

    return 0;
}


Measured memory_bytes: 5752
n,k = map(int,input().split())
a = list(map(int,input().split()))

#hyouten = []


for i in range(n-k+1):

    
    if i>0:
        score_old = a[i-1]
        score = a[i+k-1]
#        print(score_old,score)
        if score >score_old:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 94160
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000009
#define pb push_back
#define endl '\n'
#define tez_chal ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e9+7;
int solve()
{
	ll n,W;cin>>n>>W;
	vector<ll>dp(W+1,0);
	for(ll item=0;item<n;item++){
		ll weight,value; cin>>weight>>value;
		for(ll w=W;w>=0;w--){
			if(w-weight>=0){
				dp[w]=max(dp[w],dp[w-weight]+value);
			}
		}
	}
	cout<<dp[W]<<endl;



return 0;
}


 








int main()
{  
    tez_chal;     ll t=1;  //cin>>t;
    
    while(t--) solve();

    // ll testcase=1;
    // while(t--){
    // 	cout<<"Case #"<<testcase++<<": ";
    // 	solve();
    // }

    return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define int long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pb push_back

using namespace std;
int pallindr(string s, int i, int j)
{
	while (i <= j)
	{
		if (s[i] != s[j])
			return 0;
		i++;
		j--;
	}
	return 1;
}
int dp[1001][1001];
int pallindrome_partitioning(string s, int i, int j)
{
	if (i >= j)
		return 0;
	if (pallindr(s, i, j))
	{
		return dp[i][j] = 0;

	}

	if (dp[i][j] != -1)
		return dp[i][j];

	int ans = INT_MAX;
	for (int k = i; k < j; k++)
	{
		int left, right;
		if (dp[i][k] != -1)
			left = dp[i][k];
		else
		{
			left = pallindrome_partitioning(s, i, k);
			dp[i][k] = left;
		}

		if (dp[k + 1][j] != -1)
			right = dp[k + 1][j];
		else
		{
			right = pallindrome_partitioning(s, k + 1, j);
			dp[k + 1][j] = right;
		}

		int xx = left + right + 1;
		ans = min(ans, xx);
	}
	return dp[i][j] = ans;


}


void dfs(vector<int>v[], int u, int vis[], int col)
{
	vis[u] = col;

	for (auto i : v[u])
	{
		if (!vis[i])
		{
			dfs(v, i, vis, col);
		}
	}
}
int32_t main()
{
	std::ios::sync_with_stdio(false);


	int n, m;
	cin >> n >> m;
	vector<int>v[n + 1];
	for (int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;
		v[x].pb(y); v[y].pb(x);
	}


	int vis[n + 1] = {};

	int col = 1;
	for (int i = 1; i <= n; i++)
	{
		if (!vis[i])
		{
			dfs(v, i, vis, col);
			col++;
		}
	}

	map<int, int>ma;

	for (int i = 1; i <= n; i++)
		ma[vis[i]]++;
	int res = 0;
	for (auto i : ma)
	{
		res = max(res, i.s);
	}
	cout << res << endl;
	return 0;
}


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

int dp[100005];
int frog1(int *arr, int i, int n){
    if(dp[i]!=-1){
        return dp[i];
    }
    if(i>=n-1){
        return 0;
    }
    int ans = INT_MAX;
    if(i+2<n){
        ans = min(ans,abs(arr[i]-arr[i+2]) +  frog1(arr,i+2, n));
    }
    ans = min(ans,abs(arr[i] - arr[i+1] )+  frog1(arr,i+1, n));

    return dp[i] = ans;
}
int main() {
    int n;
    cin >> n;

    int *arr = new int[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }

    for(int i=0;i<100005;i++){
        dp[i] = -1;
    }

    cout << frog1(arr,0, n)<<endl;
}


Measured memory_bytes: 8300
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define scd(x) scanf("%d", &x)
#define scdd(x, y) scanf("%d %d", &x, &y)
#define scddd(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define icc ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef long double ld;

const int MAX = 10 + 1;
const int INF = 1000000;

int n, V;
int mp[MAX][MAX], d[MAX];

void solve() {
    for (int i = 0; i <= V; ++i) mp[i][i] = 0;
    for (int k = 0; k <= V; ++k)
        for (int i = 0; i <= V; ++i)
            for (int j = 0; j <= V; ++j) mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);

    memset(d, 0, sizeof(d));
    int num, res = INF;
    for (int i = 0; i <= V; ++i){
        for (int j = 0; j <= V; ++j) d[i] += mp[i][j];
        if (res > d[i]){
            res = d[i];
            num = i;
        }
    }
    printf("%d %d\n", num, res);
    return;
}

int main() {
    int x, y, t;
    while (~scd(n) && n){
        V = 0;
        fill(mp[0], mp[0] + MAX * MAX, INF);
        for (int i = 0; i < n; ++i){
            scddd(x, y, t);
            mp[x][y] = mp[y][x] = t;
            V = max(V, max(x, y));
        }
        solve();
    }
    return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k,ans;
	cin>>a>>b>>c>>k;
	if(k<=a) ans=k;
	else{
		if(k<=a+b) ans=a;
		else ans=a-(k-a-b);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3612
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

//Author: Jiangsu Nanjing Li Zongtai
//强壮标记*10000,手牌*10000,血量10000 lyl+hzj也打不死我哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈~~~~

const int inf=2147483647;

string s;

int app[111];
long long ans;

int main()
{
	cin>>s;
	
	for(int i=0;i<s.size();i++)
	{
		app[s[i]-'a']++;
	}
	
	ans=s.size()*1LL*(s.size()-1)/2;
	ans++;
	
	for(int i=0;i<26;i++)
	{
		if(app[i]>1)
		{
			ans=ans-app[i]*1LL*(app[i]-1)/2;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 640
N = int(input())
a = []
for i in range(N):
    a.append(input())
flag = True
for j in range(N-1):
    a_i = a[j]
    a_ii = a[j+1]
    if a_i[-1] != a_ii[0]:
        flag = None
        break
    for k in range(j+1, N):
        if a[j] == a[k]:
            flag = None
            break
if flag:
    print('Yes')
else:
    print('No')

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

public class Main{
	static void main() throws Exception{
		int n=sc.nextInt();
		int[]in=sc.intArr(n);
		int ans=0;
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				if(in[i]==in[j])continue;
				for(int k=j+1;k<n;k++) {
					if(in[k]==in[i] || in[k]==in[j])continue;
					long sum=in[i];
					sum+=in[j];
					sum+=in[k];
					int max=Math.max(Math.max(in[i], in[j]), in[k]);
					if(sum-max>max) {
						ans++;
					}
				}
			}
		}
		pw.println(ans);
	}
	public static void main(String[] args) throws Exception{
		sc=new MScanner(System.in);
		pw = new PrintWriter(System.out);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 26252
import java.util.*;

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

    int s=n/500;
    int t=s*500;

    if ((n-t)<=a) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21972
// AOJ 1203: Napoleon's Grumble
// 2017.12.4 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define HASHSIZ 5003
typedef struct { char *s; int w; char odd; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;			// Hash table

int lookup(char *s, int w, char odd)
{
	int i = (101 * *s + 103 * *(s+1)) % HASHSIZ;
	HASH *tp = hash + i;

	while (tp->s != NULL) {
		if (tp->odd == odd && tp->w >= w && !memcmp(tp->s, s, w)) return 0;
		if (++tp == hashend) tp = hash;
	}
	tp->s = s, tp->w = w, tp->odd = odd;
	return 1;
}

typedef struct { char *s; int w; char odd; } T;
T ans[2010]; int sz;

char s[1010], tmp[5010]; int len;
int first;

void print(char *s, int w)
{
	char c;

	c = s[w], s[w] = 0;
	if (first) first = 0;
	else putchar(' ');
	printf(s);
	s[w] = c;
}

void oddchk(int pos)
{
	int w;
	char *p, *q;

	p = s+pos-1, q = p+2, w = 1;
	while (p >= s) {
		if (*p != *q) break;
		p--, q++, w += 2;
	}
	if (w > 2) {
		ans[sz].s = p+1, ans[sz].w = w, ans[sz++].odd = 1;
	}
}

void evenchk(int pos)
{
	int w;
	char *p, *q;

	p = s+pos, q = p+1, w = 0;
	while (p >= s) {
		if (*p != *q) break;
		p--, q++, w += 2;
	}
	if (w > 2) {
		ans[sz].s = p+1, ans[sz].w = w, ans[sz++].odd = 0;
	}
}

int cmp(T *a, T *b) { if (b->w - a->w) return b->w - a->w; return memcmp(a->s, b->s, a->w); }

int main()
{
	int i, w, odd;
	char *p, *q;

	while (fgets(tmp, sizeof(tmp), stdin) != NULL) {
		memset(hash, 0, sizeof(hash));
		p = tmp, q = s; while (*p >= ' ') {
			if (isalpha(*p)) *q++ = toupper(*p);
			p++;
		}
		len = q - s, s[len] = 0;

		for (sz = 0, i = 1; i < len; i++) oddchk(i), evenchk(i);
		qsort(ans, sz, sizeof(T), cmp);

		for (first = 1, i = 0; i < sz; i++) {
			p = ans[i].s, w = ans[i].w, odd = ans[i].odd;
			if (lookup(p+w/2, (odd+w)/2, odd)) print(p, w);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 1724
N,M = map(int, input().split())
A = set([int(input()) for i in range(M)])

dp = [0]*(N+1)
dp[0] = 1

for next in range(1,N+1):
    if next in A:
        dp[next] = 0
    else:
        dp[next] = (dp[next-1] + dp[next-2])%1000000007

print(dp[N])

Measured memory_bytes: 13196
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		int n=sc.nextInt();
		Set <Integer>set=new TreeSet<Integer>();
		
		for(int i=0;i<n;i++){
			int num=sc.nextInt();
			set.add(num);
		}
		
		if(n==set.size())System.out.println("YES");
		else System.out.println("NO");
	}
}

Measured memory_bytes: 102948
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    ll x;
    cin >> x;
    for ( ll i = -2000; i <= 2000; ++i ) {
        for ( ll j = -2000; j <= 2000; ++j ) {
            if ( i * i * i * i * i - j * j * j * j * j == x ) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    ll cnt = 0;
    ll s = 0;
    rep(i,n-1){
        s += a[i];
        if (s*2>=a[i+1]){
            cnt++;
        }
        else{
            cnt = 0;
        }
    }
    cout << cnt + 1 << endl;
}

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

int main() {
  int a, b, c, s = 0;
  cin >> a >> b;
  c = b - a;
  rep(i, c) s += i + 1;
  cout << s - b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
long long a[200005];
long long b[200005];
int main()
{
	int n;
	cin >> n;
	long long sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (i == 0)
			b[i] = a[i];
		else
			b[i] = b[i - 1] + a[i];
		sum = sum + a[i];
	}
	long long min;
	if (b[0] > sum - b[0])
		min = 2 * b[0] - sum;
	else
		min = sum - (2 * b[0]);
	for (int i = 1; i < (n - 1); i++)
	{
		if (min > abs(sum - (2 * b[i])))
			min = abs(sum - (2 * b[i]));
	}
	cout << min << endl;
	return 0;
}
		

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

using namespace std;

typedef long long ll;
#define IoFast ios_base::sync_with_stdio(0);cin.tie(0);

const int eps = 1e-9;
const int mod = 1e9 + 7;
const int inf = 1e9;
const int maxn = 1e5 + 20;
int n, cnt;

int main()
{
	IoFast;
	string s, l1 ,l2;
	cin >> s;
	n = int(s.size());
	l1 = s[0], l2 = s[1];
	for(int i = 2; i < n + 1; i++) {
		if(l1 != l2) {
	//	    cout << l1 << " " << l2;
			cnt++;
			l1 = l2;
			l2 = s[i];
			
		}
		else {
			if(i < n) {
				l2 += s[i];	
			}
	//		cout << l1 << " " << l2;
			cnt++;
			i++;
			if(i < n) {
				l1 = l2;
	    	    l2 = s[i];
			}
		
		}
	//	cout << endl;
		if(i == n) {
			if(l1 == l2) {
				cnt--;
	        }
		}
	}
	//cout << l1 << l2 << "boz";
	if(l1 == l2) {
		cnt--;
	}
	cout << cnt + 1;
}

Measured memory_bytes: 720
#include<iostream>
#include<algorithm>
int main(){
    int N,i,sum=0,L[202];
    std::cin>>N;
    for(i=0;i<N*2;++i)std::cin>>L[i];
    std::sort(L,L+i);
    for(i=0;i<N*2;i+=2)sum+=L[i];
    std::cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
    int n ;
    cin >> n ;
    ll ans = 0 ;
    int  m = 105 ;
    int count = 0 ;
    rep(i,n){
        int s ;
        cin >> s ;
        if( s%10 != 0 ) m = min(m,s) ;
        else count++ ;
        ans += s ;
    }
    if( count == n ) cout << 0 << endl;
    else if(ans%10 != 0 ) cout << ans << endl;
    else cout << ans - m << endl;
}

Measured memory_bytes: 256
#include<iostream>

long long A,B,res;

int main(){

    std::cin>>A>>B;

    if(A==B){
    res=A;
    }

    else{

    if(B-A==1)
    res=A^B;

    else{
    if(A%2==1){
    if(B%2==0){
    if((B-A-1)%4)
    res=A^B^1;
    else
    res=A^B^0;
    }
    else{
    if((B-A)%4)
    res=A^1;
    else
    res=A^0;
    }
    }
    else{
    if(B%2==0){
    if((B-A)%4)
    res=B^1;
    else
    res=B^0;
    }
    else{
    if((B-A+1)%4)
    res=1;
    else
    res=0;
    }
    }
    }
    }

    std::cout<<res<<std::endl;

    return 0;
}

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

void solve(int ar[],int n)
{
    int limit;
    int ok=0,item;

    for(int j=0; j<n; j++)
    {
        item=ar[j];
        limit=sqrt(item+1);

        for(int i=2; i<=limit; i++)
        {
            if(item%i==0){
                ok++;
                break;
            }
        }
    }
    cout<<n-ok<<"\n";
}

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

   int ar[n];

    for(int i=0; i<n; i++)
    {
        cin>>ar[i];
    }

    solve(ar,n);

    return 0;
}



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

using namespace std;

int CMMDC(int a, int b)
{
    int r;
    while(b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main()
{
    long long a, b, d, sol=1, n;
    cin>>a>>b;
    n=__gcd(a,b);
    for(d=2;d*d<=n;d++)
    {
        if(n%d==0)
        {
            sol++;
            while(n%d==0)
            {
                n/=d;
            }
        }
    }
    if(n!=1)
    {
        sol++;
    }
    cout<<sol;
}


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

int main(void){
    int n,a[100] = {0};
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    cout << a[n-1];
    for(int i = n-2; i >= 0; i--){
        cout << " " << a[i];
    }
    cout << endl;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    ll a,b;
    cin>>a>>b;
    cout<<(a*b);

    return 0;   
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
using namespace std;
int main(){
    int i,a,b,n,k,c[100]={0},m=0;
    cin >>a>>b>>k;
    if(a>b){
        n = b;
    }
    else{
        n = a;
    }
    for(i=1;i<=n;i++){
        if(a%i==0&&b%i==0){
            c[m]=i;
            m++;
        }
    }
    cout << c[m-k];

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n;
  std::cin >> n;
  vt<int> h(n);
  rep(i,n)
    std::cin >> h[i];

  //solve
  bool f = true;
  --h[0];
  rep(i,n-1) {
    if(i > 0) {
      if(h[i] > h[i+1] || h[i] > h[i-1])
        --h[i];
    }

    if(h[i] > h[i+1] || h[i-1] > h[i] && i > 0) {
      f = false;
      break;
    }
  }

  std::cout << (f ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 640