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

#define INF (1<<29)
#define all(c) (c).begin(),(c).end()

using namespace std;


int main(void){

  string s,t,in;
  bool f=false;
  while(true){
    s.clear();
    t.clear();
    while(true){
      getline(cin,in);
      if(in.size()==0)break;
      s+=in;
    }

    while(true){
      getline(cin,in);
      if(in.size()==0)break;
      t+=in;
    }

    if(s.size()==0 && t.size()==0)break;

    //if(f)cout << endl;
    f=true;

    int sl=s.size(),tl=t.size();
    int now[tl],ans=0;
    string res="";

    fill(now,now+tl,INF);

    int tmp=0;
    for(int i=0;i<sl;i++){
      for(int j=0;j<tl;j++){
        if(s[i]==t[j]){
          now[j]=min(now[j],i);
        }
      }
    }

    bool flag=false;
    for(int i=0;i<tl;i++){
      flag|=(now[i]>=INF);
    }
    if(flag){
      cout << 0 << endl << endl;;
      continue;
    }

    int left=INF,right=-1,lid,rid;
    for(int i=0;i<tl;i++){
      if(left>now[i])left=now[i],lid=i;
      if(right<now[i])right=now[i],rid=i;
    }
    ans++;
    res=s.substr(left,right-left+1);

    while(true){
      int mn=INF,id=0;
      for(int i=0;i<tl;i++){
        if(mn>now[i])mn=now[i],id=i;
      }
      while(now[id]<sl && s[++now[id]]!=t[id]);
      if(s[now[id]]!=t[id])break;
      int l=INF,r=0;
      bool fg=true;
      for(int i=0;i<tl;i++){
        l=min(l,now[i]);
        r=max(r,now[i]);
        fg&=(now[i]>=sl-1);
      }
      if(fg)break;
      if(res.size()>r-l+1){
        ans=0;
        res=s.substr(l,r-l+1);
      }
      if(res.size()==r-l+1)ans++;
    }
    cout << ans << endl << endl;
    for(int i=0;i<res.size();i++){
      cout << res[i];
      if((i+1)%72==0)cout << endl;
    }
    if(res.size()%72>0)cout << endl;
    cout << endl;
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007

ll calc(vector<ll> &x) {
    ll sum = 0;
    ll n = x.size();
    for(ll i = 1;i <= n;i++) {
        sum += (n - i) * x[i - 1] - (i - 1) * x[i - 1];
        sum %= MOD;
    }
    return sum;
}

int main(void) {
    ll n, m;
    vector<ll> x;
    vector<ll> y;
    cin >> n >> m;
    x.resize(n);
    y.resize(m);
    for(ll i = 0;i < n;i++) cin >> x[i];
    for(ll i = 0;i < m;i++) cin >> y[i];
    cout << calc(x) * calc(y) % MOD << endl;    
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9+5;
int main(){
    int n;
    scanf("%d",&n);
    vector<int> h(n);
    vector<int> dp(n,INF);
    for(int& i : h)
        scanf("%d",&i);
    dp[0]=0;
    for(int i=0; i<n; i++){
        for(int j: {i+1,i+2}){
            if(j<n)
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    printf("%d\n",dp[n-1]);
    //while(1);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
struct po
{
	double x,y;
}a[10];

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].x>>a[i].y;
	}
	double ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			ans+=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y));
		}
	}
	double sum;
	sum=ans/n;
	printf("%.10lf",sum);
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
vector< vector<long long> > f;
int w[103], v[103];
int n, W;

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

    f.assign(n+1, vector<long long>(W+1, 0) );

    for(int i = 1; i<= n; i++) cin >> w[i] >> v[i];

    for(int i = 1; i<= n; i++)
        for(int j = 0; j <= W; j++)
        {
            f[i][j] = f[i-1][j];
            if ( j >= w[i]) f[i][j] = max(f[i][j], f[i-1][j - w[i]] + v[i]);
        }

    cout << f[n][W];
    return 0;
}



Measured memory_bytes: 80256
N,Q=map(int,input().split())
S=list(input())
C=[0]
for i in range(1,N):
  if S[i-1]=="A" and S[i]=="C":
    C.append(C[i-1]+1)
  else:
    C.append(C[i-1])

for _ in range(Q):
  l,r=map(int,input().split())
  print(C[r-1]-C[l-1])

Measured memory_bytes: 6876
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll cur = 0, ans;
    ll a, b;
    forn(i, n)
    {
        cin >> a >> b;
        if (a > cur)
            cur = a, ans = a + b;
    }
    cout << ans;
    return 0;
}

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

#define say(obj) (cout << (obj) << endl)
#define endline (cout << endl)
#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to, cost;
	edge_(ll to, ll cost) : to(to), cost(cost) {}
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr int		INF = (int)1e7;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

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

template <typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const vector<vector<T>>& mat) {
	for (const vector<T>& m : mat) os << m << endl;
	return os;
}

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

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

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

template <typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

int main()
{
	int H, W;
	cin >> H >> W;
	int h, w;
	cin >> h >> w;

	int ans = H * W;
	ans -= h * W;
	ans -= H * w;
	ans += h * w;
	say(ans);

	return 0;
}

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

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

        int ans[] = new int[n + 1];
        Arrays.fill(ans, 0);
        int count = 0;
        for (int i = n; i > 0; i--) {
            int need = a[i];
            int wa = 0;
            for (int j = 1; j * i < n + 1; j++) {
                wa += ans[i * j];
            }
            int mod = wa % 2;
            if (mod == need) {
                ans[i] = 0;
            } else {
                ans[i] = 1;
                count++;
            }
        }
        System.out.println(count);
        for (int i = 1; i < n + 1; i++) {
            if (ans[i] != 0) {
                System.out.println(i);
                System.out.print(" ");
            }
        }
        System.out.println("");

        sc.close();
    }
}


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

int H, A;
int ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> H >> A;
}

void solve(){
    ans = (H + A - 1) / A;
}

void out(){
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
  ll n;
  cin >> n;
  VS s(n);
  VL t(n);
  rep(i, 0, n) cin >> s[i] >> t[i];
  string x;
  cin >> x;
  ll ans = 0;
  rep(i, 0, n){
    ans += t[i];
    if(s[i] == x) break;
  }
  cout << accumulate(ALL(t),0LL) - ans << endl;
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly char[][] table = new char[][]
        {
            new char[] { 'a', 'b', 'c', 'd', 'e' },
            new char[] { 'f', 'g', 'h', 'i', 'j' },
            new char[] { 'k', 'l', 'm', 'n', 'o' },
            new char[] { 'p', 'q', 'r', 's' ,'t' },
            new char[] { 'u', 'v', 'w', 'x', 'y' },
            new char[] { 'z', '.', '?', '!', ' ' }
        };

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                sb.AppendLine(Convert(input));
            }
            Console.Write(sb);
        }

        static string Convert(string source)
        {
            if (source.Length % 2 == 1) return "NA";

            StringBuilder ret = new StringBuilder();

            for (int i = 0; i < source.Length; i += 2)
            {
                int a = int.Parse(source[i].ToString()) - 1;
                int b = int.Parse(source[i + 1].ToString()) - 1;

                if (!IsValid(a, b)) return "NA";

                ret.Append(table[a][b]);
            }
            return ret.ToString();
        }

        static bool IsValid(int a, int b)
        {
            if (a < 0) return false;
            if (a > 5) return false;
            if (b < 0) return false;
            if (b > 4) return false;
            return true;
        }
    }
}

Measured memory_bytes: 9064
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();

		int money=0;

		while(true){
			money+=1000;
			if(money>=A){
				break;
			}
		}

		System.out.println(money-A);


	}

}


Measured memory_bytes: 35664
#include <iostream>

using namespace std;

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

typedef long long ll;

int mod = (int)1e9 + 7;

int main(){
	int h, w, k;
	cin >> h >> w >> k;
	    
    ll g[w];
    g[0] = 1;
    g[1] = 1;
    rep(i,w-2) g[i+2] = g[i+1] + g[i];
	
    ll f[h+1][w];
    f[0][0] = 1;
    rep(j,w-1) f[0][j+1] = 0;
    rep(i,h) rep(j,w) {
        f[i+1][j] = g[j] * g[w-j-1] % mod * f[i][j] % mod;
        if(j != 0) f[i+1][j] = (f[i+1][j] + g[j-1] * g[w-j-1] % mod * f[i][j-1] % mod) % mod; 
        if(j != w-1) f[i+1][j] = (f[i+1][j] + g[j] * g[w-j-2] % mod * f[i][j+1] % mod) % mod;
    }
	
	cout << f[h][k-1] << endl;
	return 0;
}


Measured memory_bytes: 256
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];
    String A1 = "";
    int count1 = 0;
    int count2 = 0;

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

    for (int i = 0; i < N; i++) {
      if (A[i] % 2 == 0) {
        count1++;
        if (A[i] % 3 == 0 || A[i] % 5 == 0) {
          count2++;
        }
      }
    }
      if (count1 == count2) {
        A1 = "APPROVED";
      } else if(count1!= count2) {
        A1 = "DENIED";
      }
      System.out.println(A1);
    }
  }

Measured memory_bytes: 23124
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

#define sz(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define all(a) (a).begin(), (a).end()
#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 

using namespace std;

void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(15);
    solve();
}

const int INF = 1e18, MAXN = 1e5 + 10;

void solve() {                         
	int a;
	cin >> a;
	string s;
	cin >> s;

	if (a < 3200) {
	 	cout << "red" << endl;
	}
	else {
	 	cout << s << endl;
	}
}	


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

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  ll ans = 0;
  rep(i,n) cin >> a[i];
  rep(i,n) {
    if (i==0) continue;
    ll d = a[i-1] - a[i];
    if (d > 0) {
      ans += d;
      a[i] = a[i-1];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4836
N = int(input())
H = list(map(int, input().split()))

max_cnt = 0
cnt = 0
i = 1

while i < N:
  if H[i-1] >= H[i]:
    cnt += 1
  else:
    max_cnt = max(max_cnt, cnt)
    cnt = 0
  i += 1


max_cnt = max(max_cnt, cnt)

print(max_cnt)


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

int main(void)
{
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }
    
    string march = "MARCH";
    vector<int> category(march.size(), 0);

    for(int i = 0 ; i < N; i++){
        for(int head = 0; head < march.size(); head++){
            if(S[i][0] == march[head]){
                category[head]++;
            }
        }
    }

    int size = category.size();
    ll totCombi = 0;
    for(int i = 0; i < size - 2; i++){
        for(int j = i + 1; j < size - 1; j++){
            for(int k = j+1; k < size; k++){
                ll combi = (ll)category[i] * (ll)category[j] * (ll)category[k];
                totCombi += combi;
            }
        }
    }

    cout << totCombi << endl;

    return 0;
}


Measured memory_bytes: 6412
#include <cstdio>
#include <cmath>

int main(){
    int x,y;
    scanf("%d%d",&x,&y);
    while(x%y!=0){
        int temp = x;
        x = y;
        y = temp%y;
    }
    
    printf("%d\n", y);
    
    return 0;
}


Measured memory_bytes: 2748
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

const int N = 3e5 + 7;

int cnt[N];
int ps[N + 1];
int f[N];

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		cnt[x]++;
	}
	sort(cnt, cnt + N);
	for (int i = 0; i < N; i++) {
		ps[i + 1] = ps[i] + cnt[i];
	}
	for (int i = 1; i < N; i++) {
		//select i arrays 
		//sum(min(cnt[j], i)) / i
		int cntl = lower_bound(cnt, cnt + N, i) - cnt;
		f[i] = (ps[cntl] + (N - cntl) * i) / i;
	}
	//f[x] > f[x + 1]
	for (int k = 1; k <= n; k++) {
		int p = 0;
		for (int j = 20; j >= 0; j--) {
			if (p + (1 << j) < N && f[p + (1 << j)] >= k) {
				p += (1 << j);
			}
		}
		cout << p << '\n';
	}
}



Measured memory_bytes: 7936
n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for _ in range(n)]

dp = [0] * (w+1)
for wi, vi in wv:
    for sum_w in range(w, wi-1, -1):
        dp[sum_w] = max(dp[sum_w], dp[sum_w - wi] + vi)
print(dp[w])



Measured memory_bytes: 41708
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N, L;

		N = Integer.parseInt(sc.next());
		L = Integer.parseInt(sc.next());

		String S[] = new String[N];
		String answer = "";


		for(int i = 0; i < N; i++){
			S[i] = sc.next();
		}

		for(int i = 0; i < N-1; i++){
			for(int j = i + 1; j < N; j++){
				if(S[i].compareTo(S[j]) >= 0){
					String temp = S[i];
					S[i] = S[j];
					S[j] = temp;
				}
			}
		}

		for(int i = 0; i < N; i++){
			answer += S[i];
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 13652
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  int sum;
  while(cin >> str && str!="0"){
    sum = 0;
    for(int i=0,l=str.size();i<l;i++) sum += str[i]-'0';
    cout << sum << endl;
  }
}



Measured memory_bytes: 3148
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> data(10019,0);
	for (int i = 1; i <= 100; i++) {
		for (int j = 1; j <= 100; j++) {
			for (int k = 1; k <= 100; k++) {
				if (i * i + j * j + k * k + i * j + j * k + k * i <= 10007)data.at(i * i + j * j + k * k + i * j + j * k + k * i + 1)+=1;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		cout << data.at(i + 2) << endl;
	}
}



Measured memory_bytes: 3660
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long long LL;

int N;
int a[1010];
LL ans = 1;
LL mod = 1e9 + 7;

int main(){
	scanf("%d" , &N);
	repm(i,N,1){
		int x = i;
		repp(j,2,i+1){
			while(x % j == 0){
				++a[j];
				x /= j;
			}
		}
	}
	repp(i,2,N+1){
		(ans *= a[i] + 1) %= mod;
	}
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 128
# include <bits/stdc++.h>
using namespace std ;
int a[100+10] ;

bool cmp(int a , int b )
{
	return a > b ;
}

int main(void)
{
	int n , m ;
	int sum = 0 ;
	scanf("%d%d",&n,&m) ;
	int i ;
	for(  i = 0 ; i < n ; i++)
	{
		scanf("%d",&a[i]) ;
		sum = sum + a[i] ;
	}
	sort(a,a+i,cmp) ;   
	double ave = sum * 1.0  / (4 * m) ;  
	if(a[m-1] < ave) 
	  printf("No\n") ;
	else 
	  printf("Yes\n") ;
	return 0 ;
}

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

#define vti vector<int>
#define forn(i,a,n) for(int i=(a);i<(n);i++)
#define ford(i,a,d) for(int i=(a);i>(d);i--)
#define mset(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define mkp(a,b) make_pair(a,b)
using namespace std;
const long long N=1e5+6;
const long long inf=0x3f3f3f3f;
typedef long long ll;


int main()
{
//    ios::sync_with_stdio(false);
//    freopen("a.in","r",stdin);
//    freopen("ao","w",stdout);

    int h,n,a,f=0;
    cin>>h>>n;
    while(n--)
    {
        cin>>a;
        h-=a;
        if(h<=0) {
            cout<<"Yes",f=1;
            break;
            }
    }
    if(f==0) cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def gen_prime_table(last: int, first=2) -> list:
    if last < 1:
        return [False]
    elif last < 2:
        return [False, False]
    primes = []
    table = [True] * (last + 1)
    table[0] = False
    table[1] = False

    for i in range(first, last + 1):
        if table[i]:
            primes.append(i)
            for j in range(i * 2, last + 1, i):
                table[j] = False
    return table


def main():
    q = input_int()
    prime_table = gen_prime_table(10**5 + 1)
    prime_cusum = [0] * (10**5 + 1)
    for i in range(1, 10**5):
        if prime_table[i] and prime_table[(i + 1) // 2]:
            prime_cusum[i] = prime_cusum[i - 1] + 1
        else:
            prime_cusum[i] = prime_cusum[i - 1]

    for _ in range(q):
        l, r = input_int_list()
        print(prime_cusum[r] - prime_cusum[l - 1])

    return


if __name__ == "__main__":
    main()


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using v = vector<T>;
template <class T>
using vv = v<v<T>>;
#define ALL(c) (c).begin(), (c).end()

int main()
{
    ll mod = 1000000007;
    ll ans = 0, k = 0;
    int N;
    cin >> N;
    v<ll> A(N), B(N + 1, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        B[i + 1] = (B[i] + A[i]) % mod;
    }

    for (int i = 1; i < N; i++)
    {
        k = A[i] * B[i];
        ans += k;
        ans = ans % mod;
    }

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


Measured memory_bytes: 6408
#include <stdio.h>
#include <stdlib.h>
int main(){
	char a[10], count=0, sn=0;
	printf("%s", (scanf("%s", a), (a[count]?sn+=a[count++]-'0':0), (a[count]?sn+=a[count++]-'0':0), (a[count]?sn+=a[count++]-'0':0), (a[count]?sn+=a[count++]-'0':0), (a[count]?sn+=a[count++]-'0':0), (a[count]?sn+=a[count++]-'0':0), (a[count]?sn+=a[count++]-'0':0), (a[count]?sn+=a[count++]-'0':0), (a[count]?sn+=a[count++]-'0':0), (a[count]?sn+=a[count++]-'0':0), (!(((int)atoi(a))%sn)?"Yes":"No")));
}

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

int main() {
    int a, b;
    cin >> a>>b;
    if (a>=13)cout << b << endl;
    else if (6 <= a && a <= 12) cout << b/2 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <stack>
using namespace std;
const int MAX_N = 100;

int A[MAX_N+1][MAX_N+1];
pair<int, int> TIMESTAMPS[MAX_N+1];
int N;

void solve() {
  int ts = 0;
  stack<int> S;

  for (int i = N; i > 0; i--) {
    if (TIMESTAMPS[i].first == 0) S.push(i);
  }

  while (!S.empty()) {
    int c = S.top();

    if (TIMESTAMPS[c].first == 0)
      TIMESTAMPS[c].first = ++ts;

    for (int i = N; i > 0; i--) {
      if (A[c][i] == 1 && TIMESTAMPS[i].first == 0)
        S.push(i);
    }

    if (S.top() == c) {
      if (TIMESTAMPS[c].second == 0)
        TIMESTAMPS[c].second = ++ts;
      S.pop();
    }
  }
}

int main() {
  cin >> N;

  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      A[i][j] = 0;

    }
    TIMESTAMPS[i] = make_pair(0, 0);
  }

  for (int i = 0; i < N; i++) {
    int u, k; cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int t; cin >> t;
      A[u][t] = 1;
    }
  }

  solve();

  for (int i = 1; i <= N; i++) {
    cout << i << ' '
         << TIMESTAMPS[i].first << ' '
         << TIMESTAMPS[i].second << endl;
  }

  return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 1000000007;

int main(){
    double a,b,x;
    cin >> a >> b >> x;
    double s = x/a;
    double rad;
    if(s >= a*b/2){
        double h = (a*b-s)*2/a;
        rad = atan2(h,a);
    }
    else{
        double w = s*2/b;
        rad = atan2(b,w);
    }
    double PI = acos(-1);
    double deg = rad/(2*PI)*360;
    printf("%.10f\n",deg);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
	fio();
	int n, k;
	cin >> n >> k;
	int ans = 0;
	while (n > 0) {
		n /= k;
		ans++;
	}
	cout << ans << endl;
}

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

using namespace std;

#define endl            "\n"
#define sz(x)          (int) (x.size())
#define all(v)          v.begin(), v.end()
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int n; cin >> n;
    int mxp = INT_MIN, mnn = INT_MAX, mnp = mnn, mxn = mxp;
    for(int i = 0; i < n; i++){
        int x, y; cin >> x >> y;
        mxp = max(mxp, x + y);
        mnp = min(mnp, x + y);
        mxn = max(mxn, x - y);
        mnn = min(mnn, x - y);
    }
    cout << max(mxp - mnp, abs(mxn - mnn));
    return 0;
}


Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
    sc.Split(bufio.ScanWords)
    var n int = nextInt()
    var A []int
    for i := 0; i < n; i++ {
        A=append(A,nextInt())
    }
	
	for k := 0;k<n; k++ {
			if k!= 0{
				fmt.Print(" ")
			}
			fmt.Print(A[k])
		}
		fmt.Println()
	
	for i := 1;i<n; i++ {
		key := A[i]
		/* insert A[i] into the sorted sequence A[0,...,j-1] */
		j := i - 1
		for ; (j >= 0) && (A[j] > key);{
			A[j+1] = A[j]
			j--
		}
		A[j+1] = key
		
		for k := 0;k<n; k++ {
			if k!= 0{
				fmt.Print(" ")
			}
			fmt.Print(A[k])
		}
		fmt.Println()
	}
    
}


Measured memory_bytes: 1156
#include<cstdio>
using namespace std;
#define ll long long 
int n,a[10002],b[10002];
ll sum,opt1,opt2;
int main(void){
	register int i;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i]),sum-=a[i];
	for(i=1;i<=n;++i)scanf("%d",&b[i]),sum+=b[i];
	if(sum<0){
		puts("No");
		return 0;
	}
	if(sum==0){
		for(i=1;i<=n;++i)
			if(a[i]!=b[i]){
				puts("No");
				return 0;
			}
		puts("Yes");
		return 0;
	}
	opt1=opt2=sum;
	for(i=1;i<=n;++i){
		if(a[i]<b[i]){
			if((b[i]-a[i])&1){
				opt1-=(b[i]-a[i]+1)>>1;
				opt2-=1;
			}else opt1-=(b[i]-a[i])>>1;
		}else if(a[i]>b[i]){
			opt2-=a[i]-b[i];
		}
	}
	if(opt1<0||opt2<0)puts("No");
	else if(2*opt1==opt2)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
int n,q,l[N],r[N],tot;
vector<int>g[N];
void dfs(int x,int f){
	l[x]=++tot;
	for(int i=0;i<g[x].size();i++){
		int to=g[x][i];
		if(to==f)continue;
		dfs(to,x);
	}
	r[x]=tot;
}
int t[N];
void add(int x,int k){
	while(x<=n)t[x]+=k,x+=x&-x;
}
int query(int x){
	int res=0;
	while(x)res+=t[x],x-=x&-x;
	return res;
}
int main() {
	scanf("%d%d",&n,&q);
	for(int i=1;i<n;i++){
		int s,t;
		scanf("%d%d",&s,&t);
		g[s].push_back(t);
		g[t].push_back(s);
	}
	dfs(1,0);
	while(q--){
		int a,b;
		scanf("%d%d",&a,&b);
		add(l[a],b),add(r[a]+1,-b);
	}
	for(int i=1;i<=n;i++)printf("%d ",query(l[i]));
	return 0;
}


Measured memory_bytes: 27904
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-19 20:45:36
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template <class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '(' << p.first << ", " << p.second << ')'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { int flag = 0; for (auto e : vec) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { int flag = 0; for (auto e : st) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { int flag = 0; for (auto e : mp) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { for (T& e : vec) is >> e; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

const double PI = acos(-1);

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

  double r; cin >> r;

  cout << setprecision(17) << 2 * PI * r << endl;

  return 0;
}

Measured memory_bytes: 3816
#include<iostream>
using namespace std;
int main(){
	int i,a,b;
	char op;
	for (i = 0; i < 20000; i++){
		cin >> a >> op >> b;
		if (op == '?' ){ break; }
		else if (op == '+'){cout << a + b << endl;}
		else if (op == '*'){ cout << a * b << endl; }
		else if (op == '-'){ cout << a - b << endl; }
		else if (op == '/'){ cout << a /b << endl; }
	}
	return 0;
}



Measured memory_bytes: 3096
#include<stdio.h>

int main()
{
    int t,i,a,c1=0,c2=0;
    scanf("%d",&t);
    for(i=1;i<=t;i++)
    {
        scanf("%d",&a);
        if(a%2==0)
        {
           c1++;
           if(a%3==0 || a%5==0)
           {
               c2++;
           }
        }
    }
        if(c1==c2)
            printf("APPROVED");
        else
            printf("DENIED");

    return 0;
}



Measured memory_bytes: 128
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int price = 700;
        String order = sc.next();
        if(order.substring(0,1).equals("o")) {
            price +=100;
        }
        if(order.substring(1,2).equals("o")) {
            price +=100;
        }
        if(order.substring(2,3).equals("o") ){
            price +=100;
        }
        
        System.out.println(price);
    }
}

Measured memory_bytes: 20692
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long t = sc.nextLong();
		int n = sc.nextInt();
		long[] starts = new long[n + 1];
		long[] ends = new long[n + 1];
		long[] times = new long[n + 1];
		for (int i = 1; i <= n; i++) {
		    starts[i] = sc.nextLong();
		    ends[i] = sc.nextLong();
		    times[i] = times[i - 1] + ends[i] - starts[i];
		}
		int right = 1;
		long max = 0;
		for (int left = 1; left <= n; left++) {
		    while(right < n && starts[left] + t >= ends[right]) {
		        right++;
		    }
		    long time = times[right - 1] - times[left - 1];
		    if (starts[left] + t >= ends[right]) {
		        time += ends[right] - starts[right];
		    } else if (starts[left] + t >= starts[right]) {
		        time += starts[left] + t - starts[right];
		    }
		    max = Math.max(max, time);
		}
	    System.out.println(max);
	}
}



Measured memory_bytes: 104224
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
H = li()

m = min(H)
cnt = H[0]

for i in range(1, N):
    if H[i] >= H[i-1]:
        cnt += H[i] - H[i-1]

print(cnt)

Measured memory_bytes: 9192
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;
int T,n,m,l,r;
int work(int a,int b){
	if(a%b==0) return a/b;
	return a/b+1;
}
bool check(int A,int B,int pos,int k){
	int tmp=pos/(k+1);
	A-=tmp*k;B-=tmp;A-=pos-tmp*(k+1);
	return B<=(ll)A*k;
}
int cal(int a,int k){
	if(a%(k+1)==0) return 1;
	return 0;
}
int main()
{
	scanf("%d",&T);
	while(T--){
		scanf("%d%d%d%d",&n,&m,&l,&r);
		int k=work(max(n,m),min(n,m)+1),pos=-1;
		int li=0,ri=n+m+1;
		while(li<ri){
			int mid=(li+ri)>>1;
			if(check(n,m,mid,k)) li=mid+1;
			else ri=mid;
		}
		pos=li;
		for(int i=l;i<=r;i++){
			int op=0;
			if(i<=pos) op=cal(i,k);
			else op=cal(n+m-i+1,k)^1;
			if(op==0) printf("A");
			else printf("B");
		}
		puts("");
	}
	return 0;
} 

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

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

const int mod = 1e9 + 7;
long long dp[100001];

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

	    int N, M;
    cin >> N >> M;
 
    int a;
    for (int i=0; i<M; ++i) {
        cin >> a;
        dp[a] = -1;
    }
 
    dp[0] = 1;
    for (int i=0; i<N; ++i) {
        if (dp[i] == -1) continue;
        if (dp[i+1] != -1) {
            dp[i+1] += dp[i];
            dp[i+1] %= mod;
        }
        if (dp[i+2] != -1) {
            dp[i+2] += dp[i];
            dp[i+2] %= mod;
        }
    }
 
    cout << dp[N] << endl;
 

    return 0;
}



Measured memory_bytes: 1024
from collections import defaultdict

N, M = map(int, input().split())
ab = [[int(i) for i in input().split()] for _ in range(M)]

cnt = defaultdict(int)
for a, b in ab :
    if a > b :
        a, b = b, a
        
    if a == 1 :
        cnt[(a, b)] += 1
    else :
        cnt[(1, a)] += 1
        cnt[(1, b)] += 1
        
flag = True
for i in cnt.values() :
    if i % 2 == 1 :
        flag = False
        
if flag :
    print('YES')
else :
    print('NO')

Measured memory_bytes: 71356
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll INF = 1LL << 60;
int MOD = 1e9+7;
struct Edge{
    int from,to;
    ll cost;
};
int V,E;
Edge edge[2020];
ll dist[1010];
//find_negative_loop
bool find_positive_loop(){
    fill(dist,dist+V,0);
    for(int i = 0;i < V;i++){
        for(int j = 0;j < E;j++){
            Edge e = edge[j];
            if(dist[e.to] > dist[e.from] + e.cost){
                dist[e.to] = dist[e.from] + e.cost;
                if(i == V-1) return true;
            }
        }
    }
    return false;
}
bool bellman_ford(int s,int t){
    fill(dist,dist+V,-INF);
    dist[s] = 0;
    for(int i = 0;i < V*2;i++){
        for(int j = 0;j < E;j++){
            Edge e = edge[j];
            if(dist[e.from] != -INF && dist[e.to] < dist[e.from] + e.cost){
                dist[e.to] = dist[e.from] + e.cost;
                if(i >= V-1 && e.to == t)return true;
            }
        }
    }
    return false;
}
main(){
    cin >> V >> E;
    for(int i = 0;i < E;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        edge[i].from = a-1;
        edge[i].to = b-1;
        edge[i].cost = c;
    }
    //正閉路の検出+Bellman_Ford
    if(bellman_ford(0,V-1)){
        cout << "inf" << endl;
        return 0;
    }
    cout << dist[V-1] << endl;
    
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V
 
getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]
 
type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)
 
mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
fi = fromInteger
fig = fromIntegral
rf = realToFrac
 
(.<.) f g -- combination
    | f < g = 0 
    | g < 1 || f < 1 = 1
    | True = foldr1 (*) (take g [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)
 
unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)
 
mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a
 
countIf f = length . filter f
 
-- 
--
--
main = do
  i <- getI
  let a = do
      case i of
        3 -> "YES"
        5 -> "YES"
        7 -> "YES"
        otherwise -> "NO"
  putStrLn a


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

int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int  k;
    cin >> k;
    int ans = 1;
    if(b - a > k){
        ans = 0;
    }
    if(c - b > k){
        ans = 0;
    }
    if(d - c > k){
        ans = 0;
    }
    if(e - d > k){
        ans = 0;
    }
    if(e - a > k){
        ans = 0;
    }
    if(ans == 1){
        cout << "Yay!" << endl;
    }
    
    else{
        cout << ":(" << endl;
    }
}

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

int main(void){

	char A[105],B[105];
	int n,i,j,a,b,f;
	scanf("%d",&n);
	a=0;b=0;
	for(i=0;i<n;i++){
	scanf("%s %s",A,B);
	j=0;f=0;
	while(A[j]!='\0' ||  B[j]!='\0'){
		if(A[j]>B[j]){a=a+3;f=1;break;}
		else if(B[j]>A[j]){b=b+3;f=2;break;}
		j++;
	}
	if(f==0){a++;b++;}
}
printf("%d %d\n",a,b);
	return 0;
}

Measured memory_bytes: 596
import fractions
from functools import reduce

N = int(input())
T = list(int(input()) for _ in range(N))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))


Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int l[n],r[n];
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>l[i]>>r[i];
        int x=r[i]-l[i]+1;
        ans+=x;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
(defn input []
  (->> (clojure.string/split (read-line) #"\s")
    (map #(Integer/parseInt %))))

(defn RFN [[D N]]
  (-> (filter #(and (zero? (rem % (Math/pow 100 D)))
                 ((complement zero?) (rem % (Math/pow 100 (inc D)))))
        (range))
    (nth (dec N))))

(-> (input)
  RFN
  println)

Measured memory_bytes: 107748
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A

from sys import stdin
input = lambda: stdin.readline().rstrip()

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

f = True
i = 0
cnt = 0
while f:
    f = False
    for j in reversed(range(1+i, N)):
        if A[j] < A[j-1]:
            w = A[j]
            A[j] = A[j-1]
            A[j-1] = w
            f = True
            cnt = cnt+1
    i = i+1

print(' '.join(map(str, A)))
print(cnt)


Measured memory_bytes: 5596
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;

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


        BigDecimal a,b;
        a=sc.nextBigDecimal();
        b=sc.nextBigDecimal();
        BigDecimal ans=a.multiply(b);



        System.out.println(ans.setScale(0, BigDecimal.ROUND_DOWN));
    }
}


Measured memory_bytes: 37628
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

count1 = [A1[0]] * N
count2 = [A2[-1]] * N
for i in range(1, N):
    count1[i] = count1[i-1] + A1[i]
    count2[N-1-i] = count2[N-i] + A2[N-1-i]

candy = 0
for i in range(0, N):
    candy = max(candy, count1[i] + count2[i])

print(candy)

Measured memory_bytes: 3064
/*
* @Author: Kabid
* @Date:   2020-04-29 14:50:32
* @Last Modified by:   Kabid
* @Last Modified time: 2020-05-13 15:08:18
*/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define  in(x) scanf("%d",&x);
#define out(x) printf("%d",x);
#define  ins(x)  scanf("%s",x);
#define outs(x) printf("%s",x);
#define lin puts("");
#define _ putchar(' ');

int t;       //test cases
int i, j;	 //iterators
int   n, a, b, m, l;
ll c; //variables
string s;
char h;

int main() {
	cin >> s;
	n=s.size();
	if (s.size() % 2) {
		for (i = 0; i < n; i++) {
			if (s[i] != s[n - 1 - i]) {
				j = 1;
				puts("No");
				break;
			}
		}
		if (j == 1) goto A;

		for (i = 0; i < (n - 1) / 2; i++) {
			if (s[i] != s[((n - 1) / 2) - 1 - i]) {
				j = 1;
				puts("No");
				break;
			}
		}
		if (j == 1) goto A;
		for(i=((n+3)/2)-1;i<n;i++){
			if(s[i]!=s[n-1-i]){
				j=1;
				puts("No");
			}
		}
	}
	else {
		j = 1;
		puts("No");
	}
	A: if(j==0){
		puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::str::FromStr;

// abc-of-abc.rs --- abc of ABC
// author: Seong Yong-ju <sei40kr@gmail.com>

#[allow(unused_macros)]
macro_rules! get {
  ($t:ty) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      line.trim().parse::<$t>().unwrap()
    }
  };
  ($($t:ty),*) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      let mut iter = line.split_whitespace();
      (
        $(iter.next().unwrap().parse::<$t>().unwrap(),)*
      )
    }
  };
  ($t:ty; $n:expr) => {
    (0..$n).map(|_|
                get!($t)
    ).collect::<Vec<_>>()
  };
  ($($t:ty),*; $n:expr) => {
    (0..$n).map(|_|
                get!($($t),*)
    ).collect::<Vec<_>>()
  };
  ($t:ty ;;) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      line.split_whitespace()
        .map(|t| t.parse::<$t>().unwrap())
        .collect::<Vec<_>>()
    }
  };
  ($t:ty ;; $n:expr) => {
    (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
  };
}

#[allow(unused_macros)]
macro_rules! debug {
  ($($a:expr),*) => {
    println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
  }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("Failed to parse token")
}

#[allow(dead_code)]
fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer);
}

fn main() {
    let s = get!(String);
    let mut cs = s.chars().collect::<Vec<_>>();
    cs.sort();
    let ans = cs.into_iter().collect::<String>() == "abc";
    with_bufwriter(|mut out| writeln!(out, "{}", if ans { "Yes" } else { "No" }).unwrap());
}


Measured memory_bytes: 4352