akhauriyash/Code-Regression huggingface dataset:
N=int(input())
ans = 1000

for A in range(1,N):
  Asum = sum(list(map(int, str(A)))) 
  Bsum = sum(list(map(int, str(N-A)))) 
  if ans > (Asum+Bsum):
    ans = (Asum+Bsum)

print(ans)


Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
typedef struct Node{
  int key;
  struct Node *right,*left,*parent;
}Node;

Node *root;

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;
  z=malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[20];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      }
  }
  return 0;
}

Measured memory_bytes: 24036
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='C')
		{
			for(int j=i+1;j<s.length();j++)
			{
				if(s[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

x,y = map(int,readline().split())

if not even(y):
    print("No")
    exit()

mn = 2*x
mx = 4*x

if mn <= y <= mx:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61864
#include<iostream>
#include<vector>
#include<set>
using namespace std;

vector<int> vc[4];

bool solve(int i, set<int> st) {
  if (st.find(i) != st.end()) return false;
  st.insert(i);
  if (st.size() == 4) return true;
  for (auto itr = vc[i].begin(); itr != vc[i].end(); ++itr) {
    if (solve(*itr, st)) return true;
  }
  return false;
}

int main() {
  for (int i = 0; i < 3; i++) {
    int a, b;
    cin >> a >> b;
    vc[a - 1].push_back(b - 1);
    vc[b - 1].push_back(a - 1);
  }

  bool result = false;
  for (int i = 0; i < 4; i++) {
    set<int> st;
    if (solve(i, st)) {
      result = true;
      break;
    }
  }

  if (result) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    if(a-b>c)
        cout << 0 << endl;
    else
        cout << c-(a-b) << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
count=0
ans=0
tmp=5
if N<11:
	if N<=6:
		print(1)
	else:
		print(2)
else:
	ans=(N//11)*2
	if N%11==0:
		print(ans)
	elif N%11>6:
		print(ans+2)
	else:
		print(ans+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

ll n;
ll a[100010];
vpl v;

ll ans[100010];

int main(){

  n = in();
  REP( i , n ){
    a[i] = in();
    v.pb( a[i] , i );
  }

  v.pb( 0 , -1 );

  SORT( v );
  REVERSE( v );

  ll id = INF;
  REP( i , n ){
    chmin( id , v[i].se );
    ans[id] += ( v[i].fi - v[i+1].fi ) * ( i + 1 );
  }

  REP( i , n ){
    printf( "%lld\n" , ans[i] );
  }
  

  return 0;
}


Measured memory_bytes: 4720
a, b, c = map(int, input().split())
if a == 5 and b == 5 and c == 7:
  print('YES')
elif a == 5 and b == 7 and c == 5:
  print('YES')
elif a == 7 and b == 5 and c == 5:
  print('YES')
else:
  print('NO')

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

using namespace std;

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pll pair<long long ,long long >
#define ppll pair < pll , pll >
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define INF 1e18
#define eps 0.00001
#define le length
#define debug(n1) cout << n1 << endl
#define rep(i , j , n) for(ll i = j ; i <= n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
const ll N = 2e3 + 5;
const ll M = 1e7 + 5;
const ll mod = 1e18 + 7;
ll MODULAR_POWER(ll a , ll b , ll MOD) {
    if(b == 0) return 1LL;
    ll d = MODULAR_POWER(a , b / 2 , MOD);
    d *= d;
    d %= MOD;
    if(b % 2) d *= a;
    d %= MOD;
    return d;
}
ll BINARY_SEARCH(ll dp[] , ll n , ll key) {
    ll s = 1;
    ll e = n;
    while(s <= e) {
        ll mid = (s + e) / 2;
        if(dp[mid] == key) return mid;
        else if (dp[mid] > key) e = mid - 1;
        else s = mid + 1;
    }
    return -1;
}
string CONVERT_TO_BINARY(ll s) {
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}
bool PALIN(string s) {
    int i = 0;
    int j = s.le() - 1;
    while(i <= j) {
        if(s[i] != s[j]) return false;
        j-- , i++;
    }
    return true;
}
ll n;
ll a[N];
int main() {
    SPEED;
    cout.precision(8);
    cout << fixed;
    ll k;
    cin >> n;
    cin >> k;
    ll d = 1;
    rep(i , 1 , n) {
        if(d + k < 2 * d) {
            d += k;
        }
        else {
            d *= 2;
        }
    }
    cout << d << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            double N = double.Parse(Console.ReadLine());
            for (double i = N;  0 < i; i = i - 1)
            {
                 decimal num = Convert.ToDecimal(Math.Sqrt(i));
                if (num * num == Convert.ToDecimal(i))
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }

    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(ans);

Measured memory_bytes: 27508
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int mod = 1000000007;
		int n = in.nextInt();
		int m = in.nextInt();
		int[] ans = new int[n+1];
		for(int i=0;i<m;i++) {
			ans[in.nextInt()] = -1;
		}
		ans[0] = 1;
		if(ans[1]==0) ans[1] = 1;
		for(int i=2;i<=n;i++) {
			if(ans[i]==-1) continue;
			else if(ans[i-1]==-1 && ans[i-2]==-1) ans[i] = 0;
			else if(ans[i-1]==-1) ans[i] = ans[i-2];
			else if(ans[i-2]==-1) ans[i] = ans[i-1];
			else ans[i] = (ans[i-1] + ans[i-2]) % mod;
		}
		System.out.println(ans[n]);
		in.close();

	}

}


Measured memory_bytes: 46936
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <ctype.h>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
// #include <pair> 
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    int n;
    int m;
    cin>>n>>m;
    int cnt[100]={0};
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        cnt[x]++;
        cnt[y]++;
    }
    for(int i=1;i<=n;i++)
        cout<<cnt[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,m;
int use[10001][1500];
int flag[10001];
main()
{
	while(cin>>n>>m,n)
	{
		int r;cin>>r;
		for(int i=0;i<m;i++)
		{
			flag[i]=0;
			for(int j=0;j<1500;j++)use[i][j]=0;
		}
		for(int i=0;i<r;i++)
		{
			int T,N,M,S;cin>>T>>N>>M>>S;
			use[M][T]+=S?1:-1;
		}
		int q;cin>>q;
		for(int i=0;i<q;i++)
		{
			int t1,t2,M;cin>>t1>>t2>>M;
			if(!flag[M]++)for(int j=1;j<1500;j++)use[M][j]+=use[M][j-1];
			int cnt=0;
			for(int j=t1;j<t2;j++)cnt+=!!use[M][j];
			cout<<cnt<<endl;
		}
	}
}



Measured memory_bytes: 59832
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
using namespace std;
const int maxn=5e5+10;
int n,pos,ans,cnt,a[maxn],dp[maxn][3];
char str[maxn];
int work(){
//    cout<<"pos="<<pos<<'\t';
//    for (int i=0;i<pos;i++) cout<<a[i]<<" ";cout<<endl;

    if (pos<=1) return 0;
    dp[0][0]=0;dp[0][1]=a[0];dp[0][2]=a[1];
    for (int i=1;i<pos-1;i++){
        dp[i][0]=max(dp[i-1][0],dp[i-1][1]);
        dp[i][0]=max(dp[i][0],dp[i-1][2]);
        dp[i][1]=dp[i-1][0]+a[i];
        if (a[i]>1){
            dp[i][1]=max(dp[i][1],dp[i-1][1]+a[i]-1);
            dp[i][1]=max(dp[i][1],dp[i-1][2]);
        }
        dp[i][2]=dp[i-1][0]+a[i+1];
        if (a[i]>1){
            dp[i][2]=max(dp[i][2],dp[i-1][1]+a[i+1]);
            dp[i][2]=max(dp[i][2],dp[i-1][2]+a[i+1]-1);
        }
    }

//    for (int i=0;i<3;i++){
//        for (int j=0;j<pos-1;j++) cout<<dp[j][i]<<" ";cout<<endl;
//    }
//    cout<<"check:"<<dp[pos-2][0]<<" "<<dp[pos-2][1]<<" "<<dp[pos-2][2]<<endl;
    int now=max(dp[pos-2][0],dp[pos-2][1]);
    now=max(now,dp[pos-2][2]);
//    cout<<"now="<<now<<endl;
    return now;
}
int main(){
    #ifdef VGel
    freopen("test.in","r",stdin);
    #endif // VGel
    while (~scanf("%d",&n)){
        scanf("%s",str);str[n]='2';
        pos=0,ans=0,cnt=1;
        for (int i=1;i<=n;i++){
            if (str[i]==str[i-1]) {cnt++;continue;}
            if (str[i-1]=='1'){
                a[pos++]=cnt;cnt=1;
            }else{
                if (cnt==1) cnt=1;
                else{
                    ans+=work();
                    pos=0;cnt=1;
                }
            }
        }
        ans+=work();
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2816
#include <stdio.h>
 
int main(void)
{
    int i;
    float mt;
    float max;
    float min;
     
    max = 0; min = 999999;
    while (scanf("%f", &mt) != EOF){
        if (mt > max){
            max = mt;
        }
        if (mt < min){
            min = mt;
        }
    }
    printf("%.1f\n", max - min);
     
    return (0);
}

Measured memory_bytes: 648
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=200010;
int n,nxt[41][N],a[N],b[N],d[N],c[N],len,last[N];
ll k;
int main(){
	n=gi();scanf("%lld",&k);
	memset(b,127,sizeof(b));
	for(int i=1;i<=n;i++){a[i]=gi();b[a[i]]=min(b[a[i]],i);}
	nxt[0][n+1]=1;
	for(int i=n;i;i--){
		if(!last[a[i]])nxt[0][i]=b[a[i]]+1;
		else nxt[0][i]=nxt[0][last[a[i]]+1];
		last[a[i]]=i;
	}
	for(int j=1;j<=40;j++)
		for(int i=1;i<=n+1;i++)
			nxt[j][i]=nxt[j-1][nxt[j-1][i]];
	int now=1;k--;
	for(int j=40;~j;j--)
		if(k&(1ll<<j))
			now=nxt[j][now];
	for(int i=now;i<=n;i++)
		if(!d[a[i]])c[++len]=a[i],d[a[i]]=i;
		else{
			while(c[len]!=a[i]){d[c[len]]=0;len--;}
			len--;d[a[i]]=0;
		}
	for(int i=1;i<=len;i++)printf("%d%c",c[i],i==len?'\n':' ');
	return 0;
}


Measured memory_bytes: 37376
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, k;
	int h[100000];
	cin>>n>>k;
	for(int i=0; i<n; i++) cin>>h[i];
	int dp[100000];
	dp[0]=0;
	for(int i=1; i<n; i++){
		dp[i]=2e9;
		for(int j=i-1; (j>=0 && j>=i-k); j--){
			dp[i]=min(dp[i], dp[j]+abs(h[i]-h[j]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    int n, k, q;
    cin >> n >> k >> q;

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

    for(int i = 1; i <= n; i++)
    {
        if(k - q + a[i] > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] A = new int[N];
    int count = 0;
    long sum = 0;

    for (int i = 0; i < N; i++) {
      int v = sc.nextInt();
      if (v < 0) {
        count++;
      }
      A[i] = Math.abs(v);
      sum += A[i];
    }

    sc.close();

    Arrays.sort(A);
   
    if (count % 2 != 0) {
      sum -= (2 * A[0]);
    }

    System.out.println(sum);

  }

}

Measured memory_bytes: 51608
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<long long> sum(n + 1), xsum(n + 1);
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		sum[i] = sum[i - 1] + x;
		xsum[i] = xsum[i - 1] ^ x;
	}
	long long ans = 0;
	int j = 0;
	for (int i = 1; i <= n; i++) {
		while (sum[i] - sum[j] != (xsum[i] ^ xsum[j])) j++;
		ans += i - j;
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i, l, r) for(size_t i = (l); i < (r); i = i + 1)
#define REP(i, n) FOR(i, 0, n)
const double PI=3.14159265358979323846;

using ll = long long;
 
int main() {
    int R;
    cin >> R;
    cout << 2 * PI * R<< endl;
 
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;cin>>N;
    vector<int> L(N);
    for(int i=0;i<N;i++){
        cin >> L[i];        
    }
    vector<int>::iterator iter = max_element(L.begin(), L.end());
    size_t index = distance(L.begin(), iter);
    
    int sum = accumulate(L.begin(), L.end(), 0);
    if((sum-L[index] > L[index]))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[3][105],dp[3][105];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            dp[i][j]=max(dp[i][j-1],dp[i-1][j])+a[i][j];
        }
    }
    printf("%d\n",dp[2][n]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(int i=0,_i=(n);i<_i;++i)
#define _rep3(i,a,b) for(int i=(a),_i=(b),_ii=(b)>(a)?1:-1;abs(_i-i)>0;i+=_ii)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// === debug ===
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// === end ===

int main() {
  int N;
  ins(N);

  vector<ll> L(N);
  rep(i, N) {
    cin >> L[i];
  }

  int count = 0;
  rep(i, N) rep(j, i+1, N) rep(k, j+1, N) {
    if (L[i] == L[j] || L[i] == L[k] || L[j] == L[k])
      continue;
    ll z = max(L[i], max(L[j], L[k]));
    if (2 * z < L[i] + L[j] + L[k]) {
      ++count;
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <memory>
#include <initializer_list>
#include <iomanip>
#include <stack>
#include <bitset>
#include <cstdio>
// #include <complex>
#include <random>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll INF = 1e18;
// const ld INF = 1e20;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;
//const double PI = acos(-1);

void solve() {
    ll n;
    cin >> n;
    ll ans = INF;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ll x = i;
            ll y = n / i;
            ans = min(ans, x + y - 2);
        }
    }
    cout << ans << "\n";
}

int main() {
    // freopen("moscow.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    solve();
    return 0;
}


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

#ifndef DEBUG
#define DEBUG false
#endif

#define REP(t,i,a,b) for(t i = a; i < b; ++i)

typedef long long ll;

using namespace std;

long compute_cost(
    const int n, const int a, const int b, const int c,
    const int index, vector<int>& l
) {
    vector<int> l_ret(3, 0);
    vector<long> cost_(3, 0);

    // indexをn桁の4進数に変換、その4進数がn本の棒の使用方法に対応
    int tmp = index;
    REP(int, i, 0, n) {
        int use = tmp % 4; // 0: 不使用; 1,2,3: 長さa,b,cの棒の材料にする
        tmp /= 4;

        if (use == 0) continue;
        
        if (l_ret[use-1] > 0) cost_[use - 1] += 10;  // 合成魔法のコスト計算
        l_ret[use - 1] += l[i];  // 合成魔法後の棒の長さ
    }

    // 合成魔法で棒が3本できていない場合を除外
    int l_min = *min_element(l_ret.begin(), l_ret.end());
    if (l_min <= 0) return LONG_MAX;

    long sum_cost = cost_[0] + cost_[1] + cost_[2];
    sum_cost += abs(l_ret[0] - a) + abs(l_ret[1] - b) + abs(l_ret[2] - c); // 他の魔法のコスト
    return sum_cost;
}

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

    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> l(n);
    REP(int, i, 0, n) {
        cin >> l[i];
    }

    int num_all = pow(4, n);
    long cost_min = LONG_MAX;
    REP (int, i, 0, num_all) {
        long cost = compute_cost(n, a, b, c, i, l);
        cost_min = min(cost_min, cost);
    }
    cout << cost_min << endl;

    return 0;
}


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

int main() {
    char c[1];
    cin >> c[0];

    if (c[0] == 'a' || c[0] == 'e' || c[0] == 'i' || c[0] == 'o' || c[0] == 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, K, S; cin >> N >> K >> S;
    vec<lint> ans(N);
    range(i, 0, K) ans.at(i) = S;
    lint others = S < 1e9 ? 1e9 : 1e9 - 1;
    range(i, K, N) ans.at(i) = others;
    range(i, 0, N) cout << ans.at(i) << " ";
    cout << "\n";
}


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

using namespace std;

char mapa[60][60];
int confere[60][60];
int n,m;
int cont=0;

queue<pair<int,int>>q;


int bfs(){

	if(q.size()==0 ) return 0;
	int i = q.front().first;
	int j = q.front().second;

	q.pop();

	if(mapa[i+1][j] == '.' and confere[i+1][j]==-1){
		confere[i+1][j]= confere[i][j]+1;
		q.push(make_pair(i+1,j));
	}
	if(i > 0  and mapa[i-1][j] == '.' and confere[i-1][j]==-1){
		confere[i-1][j]= confere[i][j]+1;
		q.push(make_pair(i-1,j));
	}
	if(mapa[i][j+1] == '.' and confere[i][j+1]==-1){
		confere[i][j+1]= confere[i][j]+1;
		q.push(make_pair(i,j+1));
	}
	if(j>0 and mapa[i][j-1] == '.' and confere[i][j-1]==-1){
		confere[i][j-1]= confere[i][j]+1;
		q.push(make_pair(i,j-1));
	}

		
	return bfs();

}

int main(){

	int cont=0;
	char c;
	int n,m;

	cin >> n >> m;


	cin.ignore();
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> mapa[i][j];
			confere[i][j]=-1;
			if(mapa[i][j]=='#') cont++;
		}
		cin.ignore();
	}

	confere[0][0]=1;
	q.push(make_pair(0,0));
	bfs();
	if(confere[n-1][m-1]!=-1)
		cout << n*m - cont - confere[n-1][m-1] << endl;
	else cout << "-1\n";

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return(t*t);
    else
        return(t*t*x);
}

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

bool cmp(const pair<int , int> &a , const pair<int , int> &b){
    return (a.first < b.first);
}

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

vector<int>a;
ll ans;
int n;
void solve(int i,int cur){
    if(i==n){
        ans+=cur;
        return;
    }
    solve(i+1,cur|a[i]);
    solve(i+1,cur);
}

int main()
{
    weewoo;
    double n;
    cin >> n;
    double ans = 0;
    double u1 = n/3;
    double u2 = n-u1-u1;
    ans=u2*u1*u1;
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {

    public Main(){
        Scanner SC = new Scanner(System.in);
        int N = SC.nextInt();
        int R = SC.nextInt();

        if(N >= 10){
            System.out.println(R);
        } else {
            System.out.println(R+100*(10-N));
        }
    }

    public static void main(String[] args){
        Main main = new Main();
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,q,l,r;
    cin>>n>>q;
    string s;
    cin>>s;
    std::map<int, int> map;
    int flag=0;
    int count=0;
    for (int i=0;i<n;i++) {
        if (s.at(i)=='A') {
            flag=1;
        } else if (flag==1&&s.at(i)=='C') {
            flag=0;
            count++;
        } else {
            flag=0;
        }
        map.emplace(i+1,count);
    }
    for (int j=0;j<q;j++) {
        cin>>l>>r;
        cout<<map.at(r)-map.at(l)<<endl;
    }
}

Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

string s;
bool ops[3] = { 0 };
int a[4];
bool key = false;

void cal(int t, bool op) {
	if (!key) {
		int ans = a[0];
		ops[t] = op;
		if (t < 2) {
			cal(t + 1, true);
			cal(t + 1, false);
		}
		else if (t == 2) {
			rep(i, 0, 3) {
				if (ops[i]) ans += a[i + 1];
				else ans -= a[i + 1];
			}
		}
		if (ans == 7) {
			key = true;
			return;
		}
	}
	return;
}

int main() {

	cin >> s;

	a[0] = (int)s[0] - 48;
	a[1] = (int)s[1] - 48;
	a[2] = (int)s[2] - 48;
	a[3] = (int)s[3] - 48;

	cal(0, 1);
	cal(0, 0);

	rep(i, 0, 3) {
		cout << a[i];
		if (ops[i])cout << '+';
		else cout << '-';
	}
	cout << a[3] << "=7" << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
counter =dict(Counter(a))
c_key =list(counter.keys())
c_value =list(counter.values())
cnt = 0
sl = len(c_value)
for i in range(sl):
  if int(c_key[i]) <  c_value[i]:
      cnt += (c_value[i]- int(c_key[i]))
  elif int(c_key[i]) >  c_value[i]:
 	  cnt += c_value[i] 
print(cnt)

Measured memory_bytes: 24812
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

int sum, n;
int a[101], odd, evn, pos[101];
int b[101], cnt;

void work()
{
	if(n == 1)
	{
		if(a[1] == 1) b[++cnt] = 1;
		else b[++cnt] = 1, b[++cnt] = a[1] - 1;
		return;
	}
	if(a[1] & 1) b[++cnt] = a[1] + 1;
	else b[++cnt] = 1, b[++cnt] = a[1];
	for(int i=2; i<n; i++) b[++cnt] = a[i];
	if(a[n]==1) return;
	else b[++cnt] = a[n]-1;
}

int main()
{
	scanf("%d%d", &sum, &n);
	for(int i=1; i<=n; i++) scanf("%d", &a[i]);
	for(int i=1; i<=n; i++)
		if(a[i] & 1) pos[++odd] = i;
		else evn++;
	if(odd > 2) printf("Impossible\n"), exit(0);
	if(odd == 0) work();
	else if(odd == 1) swap(a[pos[1]], a[1]), work();
	else swap(a[pos[1]], a[1]), swap(a[pos[2]], a[n]), work();
	for(int i=1; i<=n; i++) printf("%d ", a[i]); putchar('\n');
	printf("%d\n", cnt);
	for(int i=1; i<=cnt; i++) printf("%d ", b[i]); putchar('\n');
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

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

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<ll>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

ll popHeap(vector<ll>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  ll i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,cnt=0;
  ll n;
  cin>>n;
  if(n%2==1){
    cout<<0<<endl;
    return 0;
  }
  ll ans=0;
  n/=10;
  while(n!=0){
    ans+=n;
    n/=5;
  }
  cout<<ans<<endl;
}

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

typedef pair<int, int> PII;
typedef long long ll;

const int MOD = 1e9 + 7;

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

	ll n,a[200005];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<vector<ll>> last;
	for (int i=n-1; i >=0; --i) {
		ll cnt=1,stool=0;
		while (last.size()&&last.back()[0]<a[i]) {
			cnt+=last.back()[1];
			stool+=last.back()[2]+last.back()[1]*(a[i]-last.back()[0]);
			last.pop_back();
		}
		last.pb({a[i],cnt,stool});
	}
	ll ans = 0;
	for (auto k : last) {
		ans+=k[2];
	}
	cout << ans << "\n";
}

Measured memory_bytes: 15748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    string l;
    cin>>l;
    ll dp[100005][2];
    rep(i,100005)rep(j,2) dp[i][j]=0;
    dp[0][0] = 1;
    rep(i,l.size()){
        { // a+b ==0
            if(l[i]=='0'){
                dp[i+1][0] += dp[i][0]%mod;
                dp[i+1][1] += dp[i][1]%mod;
                dp[i+1][1] %=mod;
                dp[i+1][0] %=mod; 
            } else {
                dp[i+1][1] += (dp[i][1] + dp[i][0])%mod;
                dp[i+1][1] %=mod;
                dp[i+1][0] %=mod; 
            }
        }
        { // a+b ==1
            if(l[i]=='0'){
                dp[i+1][1] += 2*dp[i][1]%mod;
                dp[i+1][1] %=mod;
                // dp[i+1][0] %=mod; 
            } else {
                dp[i+1][1] += (2*dp[i][1])%mod;
                dp[i+1][0] += (2*dp[i][0])%mod;
                dp[i+1][1] %=mod;
                dp[i+1][0] %=mod;                
            }
        }
    }
    cout<<(dp[l.size()][1] + dp[l.size()][0])%mod<<endl;
    return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <stdlib.h>

int max(int a, int b){
	return a >= b ? a : b;
}

int main(){
	int N, i;
	scanf("%d", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	int *b = (int *)malloc(sizeof(int) * N);
	int *c = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
	}
	int *dpa = (int *)malloc(sizeof(int) * N);
	int *dpb = (int *)malloc(sizeof(int) * N);
	int *dpc = (int *)malloc(sizeof(int) * N);
	dpa[0] = a[0];
	dpb[0] = b[0];
	dpc[0] = c[0];
	for(i = 1; i < N; i++){
		dpa[i] = a[i] + max(dpb[i - 1], dpc[i - 1]);
		dpb[i] = b[i] + max(dpc[i - 1], dpa[i - 1]);
		dpc[i] = c[i] + max(dpa[i - 1], dpb[i - 1]);
	}
	printf("%d\n", max(dpa[N - 1], max(dpb[N - 1], dpc[N - 1])));
	return 0;
}

Measured memory_bytes: 2560
x,n = map(int,input().split())
a = sorted(list(map(int,input().split())))
dif = 10**10
ans = -1
for i in range(102):
    if not i in a:
        if dif>abs(x-i):
            dif = abs(x-i)
            ans = i

print(ans) 


Measured memory_bytes: 9172
#include<iostream>
using namespace std;
int main(){
    string s;
    getline(cin, s);
    for(int i=0; i<s.length(); i++){
        if(s[i]>='a' && s[i]<='z')
            s[i]=s[i]+'A'-'a';
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3004
#include <iostream>
#include <vector>
#include <cassert>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 300000;
int const base = 8;
int const modulo = 1000000007;

int dp[1 + nmax][1 + base];
int transform[1 + base][2];
/*
0 - empt
1 - 0
2 - 1
3 - 00
4 - 01
5 - 10
6 - 11
7 - 100
*/

void initialize() {
  transform[0][0] = 1;
  transform[0][1] = 2;
  transform[1][0] = 3;
  transform[1][1] = 4;
  transform[2][0] = 5;
  transform[2][1] = 6;
  transform[3][0] = transform[3][1] = 1;
  transform[4][0] = 1;
  transform[4][1] = 2;
  transform[5][0] = 7;
  transform[5][1] = 2;
  transform[6][0] = transform[6][1] = 6;
  transform[7][0] = 5;
  transform[7][1] = 5;
}

int main() {
  initialize();
  std::string s;
  std::cin >> s;
  s = "#" + s;
  dp[0][0] = 1;
  for(int i = 1;i < s.size(); i++) {
    for(int j = 0; j < base; j++) {
      if(s[i] != '1') {
        dp[i][transform[j][0]] += dp[i - 1][j];
        if(modulo <= dp[i][transform[j][0]])
          dp[i][transform[j][0]] -= modulo;
      }
      if(s[i] != '0') {
        dp[i][transform[j][1]] += dp[i - 1][j];
        if(modulo <= dp[i][transform[j][1]])
          dp[i][transform[j][1]] -= modulo;
      }
    }
  }
  std::cout << (dp[s.size() - 1][2] + dp[s.size() - 1][6]) % modulo;
}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    int j = 1;
    for (int i = 0;i < n;++i) if (a[i] == j) j++;
    if (j == 1) cout << -1 << endl;
    else cout << n-j+1 << endl;
}

Measured memory_bytes: 1024
using System;
using System.Linq;

public class Problem_C
{
  public static void Main()
  {
    var N = int.Parse(Console.ReadLine());
    var deck = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    decimal total = deck.Sum();
    decimal snuke = 0;
    decimal minDiff = decimal.MaxValue;
    for (var i = 0; i < N - 1; i++)
    {
      snuke += deck[i];
      decimal kuma = total - snuke;
      decimal diff = snuke - kuma;
      minDiff = Math.Min(minDiff, Math.Abs(diff));
    }
    Console.WriteLine($"{minDiff}");
  }
}


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

int main()
{
  string o, e;
  cin >> o >> e;
  rep(i, o.size())
  {
    cout << o[i];
    if(i < e.size())
      cout << e[i];
  }
}

Measured memory_bytes: 256
import sys
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
import heapq


n = int(input())
graph = {j:[] for j in range(n)}
for j in range(n-1):
    a, b, c = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append([b,c])
    graph[b].append([a,c])
q, k = [int(i) for i in sys.stdin.readline().split()]
k -= 1
#res = dijkstra(csr_matrix(graph), indices=k)
candidates = [(k,0)]
res = [-1 for i in range(n)]
res[k] = 0
already = set()
while len(candidates) > 0 or len(already) < n:
    candidate, cost = heapq.heappop(candidates)
    already.add(candidate)
    res[candidate] = cost
    for goal, distance in graph[candidate]:
        if res[goal] < 0:
            heapq.heappush(candidates, (goal, cost + distance))

for i in range(q):
    x, y = [int(i) for i in sys.stdin.readline().split()]
    x -= 1
    y -= 1
    print(int(res[x] + res[y]))

Measured memory_bytes: 104548
#include<iostream>
#include<vector>
#include<string>
using namespace std;

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

typedef long long ll;

const int INF=1e9+7;
const int MAX_N=1e2;
int data[MAX_N];
int s[5]={5,7,5,7,7};
int main(){
	int n;
	while(cin>>n && n){
		fill(data,data+MAX_N,0);
		rep(i,n){
			string str;
			cin>>str;
			data[i]=str.size();
		}
		int ans=0;
		rep(i,n){
			if(ans!=0)break;
			int k=0;
			rep(j,5){
				int tmp=0;
				while(tmp<s[j] && i+k<n){
					tmp+=data[i+k++];
				}
				if(tmp!=s[j])break;
				if(j==4)ans=i+1;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3184
/* 2017-12-30-18.01.58 */

#include<bits/stdc++.h>
#define ll long long int
#define N 100010
using namespace std;

int main()
{
    int A,B,i;
    cin >> A >> B;
    string s;
    cin >> s;
    for(i=0;i<s.length();i++)
    {
        if(i==A )
        {
            if(s[i]=='-') continue;
            printf("No\n");
            return 0;
        }
        if((s[i]-'0')>=0) continue;
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Here your code !
    int a=0,b=0;
    scanf("%d%d",&a,&b);
    if(a>b) printf("a > b\n");
    else if (a<b) printf("a < b\n");
    else printf("a == b\n");
    
    return 0; 
    
}

Measured memory_bytes: 580
MOD=10**9+7

n = int(input())
a = map(int, input().split())

c = 0
ans = 1

for ai in a:
  c += 1
  if ai < 2*c-1:
    ans = (ans*c)%MOD
    c -= 1

for ci in range(1, c+1):
  ans = (ans*ci)%MOD

print(ans)

Measured memory_bytes: 11068
n, m = gets.split.map(&:to_i)
abs = n.times.map { gets.split.map(&:to_i) }.sort!

ans = 0
abs.each do |a, b|
  if b >= m
    ans += a * m
    m = 0
    break
  end

  ans += a * b
  m -= b
end

puts ans


Measured memory_bytes: 10488
def main() :
    W, H, x, y, r = [int(i) for i in input().split()]
    
    if ((x-r)>=0) and ((x+r)<=W) and ((y-r)>=0) and ((y+r)<=H) :
        print("Yes")
    else :
        print("No")

if __name__ == '__main__' :
    main()

Measured memory_bytes: 7780
# frozen_string_literal: true

l, r = gets.split.map(&:to_i)

min = 4 * 10**18 + 1
if r >= l + 2018
  puts 0
else
  l.upto(r - 1) do |i|
    (i + 1).upto(r) do |j|
      m = (i * j) % 2019
      min = m if min > m
    end
  end
  puts min
end


Measured memory_bytes: 3836
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
int n,m;
cin>>n>>m;
vector<P> dat(n);
for(int i=0;i<n;i++)cin>>dat[i].fi>>dat[i].se;
sort(all(dat));
int j=0;
ll ans=0;
priority_queue<ll> pq;
for(int i=m-1;i>=0;i--){
  while(j<n&&dat[j].fi+i<=m){
      pq.push(dat[j].se);
      j++;
  }
  if(pq.empty())continue;
  ans+=pq.top();
  pq.pop();
}
cout<<ans<<endl;
}



Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> Q;
  vector<int> P;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    P.push_back(x);
  }
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    Q.push_back(x);
  } 
  vector<int> data(N);
  for(int i=0;i<N;i++){
    data[i]=i+1;
  }
  int a=0;
  int b=0;
  int cnt=0;
  do{
    cnt++;
   // cout<<cnt<<endl;
    if(data==P){
      a=cnt;
    }
    if(data==Q){
      b=cnt;
    }
  }while(next_permutation(data.begin(),data.end()));
cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int a;
    int b = 0;
    cin >> a;
    if(a/100 == 1){
        a -= 100;
        b++;
    }
    if(a/10 == 1){
        a -= 10;
        b++;
    }
    if(a == 1){
        b++;
    }
    cout << b << endl;
}

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

public class Main {

    long MOD = (long) 2019;

    void run() {
        Scanner sc = new Scanner(System.in);
        long L = sc.nextInt(), R = sc.nextInt();

        long l = L / 2019, r = R / 2019;
        long lr = L % 2019, rr = R % 2019;
        if (l < r) {
            System.out.println(0);
        } else {
            if (lr > rr) {
                long tmp = l;
                lr = rr;
                rr = tmp;
            }
            long min = 2018;
            for (long i = lr; i <= rr; i++) for (long j = i + 1; j <= rr; j++) {
                min = Math.min(min, i * j % 2019);
            }
            System.out.println(min);
        }
    }
    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 22740
use std::io;

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).unwrap();
    let input_vec: Vec<i64> = buffer
        .trim()
        .split_whitespace()
        .map(|c| c.parse().unwrap())
        .collect();

    let height = input_vec[0];
    let width = input_vec[1];
    if height == 1 || width == 1 {
        println!("{}", 1);
    } else {
        println!("{}", (width * height + 1) / 2);
    }
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long N, T;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> T;
	vector<long long> C;

	for(int i=0; i<N; i++){
		long long c, t;
		cin >> c >> t;
		if(t <= T){
			C.push_back(c);
		}
	}
	
	if(C.size() == 0){
		printf("TLE\n");
		return 0;
	}

	sort(C.begin(), C.end());
	printf("%lld\n", C[0]);
	return 0;
}

Measured memory_bytes: 3712