akhauriyash/Code-Regression huggingface dataset:
bool DBG = false;
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
using ld = long double;
//using i128 = __int128_t;
//using bint = boost::multiprecision::cpp_int
//using d1024 = boost::multiprecision::number<mp::cpp_dec_float<1024>>;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
#define fs first
#define sd second
#define couts(x) cout << (x) << (" ")
#define coutn(x) cout << (x) << ("\n")
#define endl "\n"
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define dcouts(x) if(DBG) couts(x)
#define dcoutn(x) if(DBG) coutn(x);
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T1, typename T2> std::istream &operator>>(std::istream &is, std::pair<T1,T2> &p){is >> p.first >> p.second; return is; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::deque<T> &vec){ os << "deque["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;
template<class T> using V3 = V<V2<T>>;



void solve(){
  int n; cin >> n;
  V<int> a(n);
  cin >> a;
  V<int> b = a;
  sort(ALL(b));
  FOR(i,0,n) coutn( ((a[i]==b[n-1])?(b[n-2]):(b[n-1])) );
}

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll h, m, hh, mm, k;
	cin >> h >> m >> hh >> mm >> k;

	ll mi = m;
	ll ho = h;
	ll ans = 0;
	while (true)
	{
		if (ho == hh && mi == mm)
		{
			break;
		}
		mi++;
		ho += mi / 60;
		mi %= 60;
		ans++;
	}

	cout << ans - k << endl;

	debug;
	return 0;
}

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

int main() {
	long long a, b, c, x, y; cin >> a >> b >> c >> x >> y;
	c *= 2;
	long long ans = 1e10;
	for (long long i = 0; i <= max(x, y); i++) {
		ans = min(ans, c * i + max(0LL, x - i) * a + max(0LL, y - i) * b);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
    public static void main(String args[])
    {
        @SuppressWarnings("resource")
		Scanner cin = new Scanner(System.in);
        int n, a, b;
        n = cin.nextInt();
        a = cin.nextInt();
        b = cin.nextInt();
        char[] students = null;
        cin.nextLine();
        if(cin.hasNextLine()){
        	String s = cin.nextLine();
        	students = s.toCharArray();
        }
        int sum = a + b;
        for(char s : students){
        	switch(s){
        	case 'c':System.out.println("No");break;
        	case 'b':
        		if(b > 0 && sum > 0){
        			b--;
        			sum--;
        			System.out.println("Yes");
        		}
        		else{
        			System.out.println("No");
        		}
        		break;
        	case 'a':
        		if(sum > 0){
        			sum--;
        			System.out.println("Yes");
        		}
        		else{
        			System.out.println("No");
        		}
        		break;
        	default:break;
        	}
        }
    }
}

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

int main() {
  int H, N;
  cin >> H >> N;
  int a;
  for(int i = 0; i < N; ++i) {
    cin >> a;
    H -= a;
  }
  if(H > 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

N = int(input())
A = [[]] + [list(map(int, input().split()))[::-1] for _ in range(N)]

pair = [[0 for _ in range(N + 1)] for _ in range(N + 1)]

stack = []
for i in range(1, N + 1):
  a = A[i].pop()
  pair[i][a] += 1
  if pair[i][a] == pair[a][i] == 1:
    stack.append(i)
    stack.append(a)

r = []
answer = 1
while stack:
  while stack:
    i = stack.pop()
    if A[i]:
      a = A[i].pop()
      pair[i][a] += 1
      if pair[i][a] == pair[a][i] == 1:
        r.append(i)
        r.append(a)
  stack = r
  if r:
    answer += 1
  r = []
  
flag = 1
for i in range(1, N + 1):
  if A[i]:
    flag = 0
    break
if flag:
  print(answer)
else:
  print(-1)

Measured memory_bytes: 65244
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MAX3(a, b, c) ((a) > (MAX(b, c)) ? (a) : (MAX(b, c)))
#define MIN3(a, b, c) ((a) < (MIN(b, c)) ? (a) : (MIN(b, c)))

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int m = max(a, max(b, c));
    cout << m * 10 + (a + b + c) - m << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		String ans = "No";

		if (c>a) {
			if (c-a<=d) {
				ans = "Yes";
			} else if ((b>a) && (b<c) && (b-a<=d) && (c-b<=d)) {
				ans = "Yes";
			}
		} else if (a>c) {
			if (a-c<=d) {
				ans = "Yes";
			} else if ((b>c) && (b<a) && (b-c<=d) && (a-b<=d)) {
				ans = "Yes";
			}
		} else if (a == c) {
			ans = "Yes";
		}

		System.out.println(ans);

		scan.close();

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>

using namespace std;

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

    long long p[n+1], t[n+1];
    p[0] = t[0] = 1;
    for (int i = 1; i <= n; i++) {
        p[i] = 2 * p[i-1] + 1;
        t[i] = 2 * t[i-1] + 3;
    }

    long long ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (x >= 2 * t[i] + 3) {
            ans += 2 * p[i] + 1;
            x -= 2 * t[i] + 3;
        } else if (x >= 2 * t[i] + 2) {
            ans += 2 * p[i] + 1;
            x -= 2 * t[i] + 2;
        } else if (x >= t[i] + 2) {
            ans += p[i] + 1;
            x -= t[i] + 2;
        } else if (x >= t[i] + 1) {
            ans += p[i];
            x -= t[i] + 1;
        } else if (x >= 1) {
            x -= 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <math.h>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;

const int MAX_N = 200005;

int a[MAX_N];

bool ok(int l, int N, int K) {
   ll cuts = 0;
   for (int i = 0; i < N; i++) {
      cuts += (a[i] - 1) / l;
      if (cuts > K) {
         break;
      }
   }
   return cuts <= K;
}

int solve(int N, int K) {
   int lmax = a[0];
   for (int i = 1; i < N; i++) {
      lmax = max(lmax, a[i]);
   }

   int lo = 1, hi = lmax;
   int mid = -1;
   while (lo < hi) {
      mid = (lo + hi) / 2;
      if (ok(mid, N, K)) {
         hi = mid;
      } else {
         lo = mid + 1;
      }
   }
   return lo;
}

int main() {

   int N, K;
   scanf("%d %d", &N, &K);
   for (int i = 0; i < N; i++) {
      scanf("%d", &a[i]);
   }

   int ans = solve(N, K);
   printf("%d\n", ans);

   return 0;
}

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

int main() {
	int n, d;
    scanf("%d %d", &n, &d);
	int result = 0;
	for (int i = 0; i < n; i++) {
		long long x, y;
		// cin >> x >> y;
        scanf("%lld %lld", &x, &y);
		if (x * x + y * y <= (long long)d * d)
			result++;
	}
	cout << result;
}


Measured memory_bytes: 3720
object Main extends App {
	val S = scala.io.StdIn.readLine.toList.toArray
	val lngth = S.size

	val T1 = S.take((lngth - 1)/2)
	val T2 = S.drop((lngth + 1)/2)

	val flg1 = S.zip(S.reverse).map{case (a, b) => a==b}.map{case true => 0; case false => 1}.sum == 0
	val flg2 = T1.zip(T1.reverse).map{case (a, b) => a==b}.map{case true => 0; case false => 1}.sum == 0
	val flg3 = T2.zip(T2.reverse).map{case (a, b) => a==b}.map{case true => 0; case false => 1}.sum == 0

	if( flg1 && flg2 && flg3 ) println("Yes")
	else println("No")
}

Measured memory_bytes: 25664
N,X=map(int,input().split())
P=sorted(list(map(int,input().split())))
P=[abs(i-X) for i in P]

def gcd_list(L):
    b=min(L)
    for i in L:
        while True:
            if i%b==0:
                break
            c=b
            b=i%b
            i=c
    return(b)

print(gcd_list(P))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

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

  if(n == 0) cout << 0 << endl;
  else{
  string ans = "";
  while(n != 0){
    if(n % -2 == 0){
      ans = "0" + ans;
    }
    else {
      ans = "1" + ans;
      n -= 1;
    }
    n /= -2;
  }
  cout << ans << endl;}
  return 0;
}


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

struct Card {char suit, value; };

void bubble(struct Card A[], int N){
  for(int i = 0; i < N; i++){
    for(int j = N - 1; j >= i; j--){
      if(A[j].value < A[j - 1].value){
        Card t = A[j];
        A[j] = A[j - 1];
        A[j - 1] = t;
      }
    }
  }
}

void selection(struct Card A[], int N){
  for(int i = 0; i < N; i++){
    int minj = i;
    for(int j = i; j < N; j++){
      if(A[j].value < A[minj].value)
        minj = j;
    }
    Card t = A[i];
    A[i] = A[minj];
    A[minj] = t;
  }
}

void print(struct Card A[], int N){
  for(int i = 0; i < N; i++){
    if(i > 0)
      cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
  for(int i = 0; i < N; i++){
    if(C1[i].suit != C2[i].suit)
      return false;
  }
  return true;
}

int main(){
  Card C1[100], C2[100];
  int N;
  char ch;

  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> C1[i].suit >> C1[i].value;
  }

  for(int i = 0; i < N; i++)
    C2[i] = C1[i];

  bubble(C1, N);
  selection(C2, N);

  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if(isStable(C1, C2, N)){
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;

int binary_search(int *v2,int size,int n)
{
    int high,mid,low;
    low=0;
    high=size-1;
    while(low<=high){
        mid=(low+high)/2;
        if(v2[mid]==n){
            return 1;
        }
        else if(n>v2[mid]) low=mid+1;
        else if(n<v2[mid]) high=mid-1;
    }
    return -1;
}



int arr[g_size];
int ara[g_size],ara2[g_size];


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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k,a,b;

	bool flag;

	string s1,s2;

	char s[100000];



    cin>>n>>m;

    pii p[m];

//    f(i,0,m-1){
//        cin>>p[i].fi>>p[i].se;
//    }
//
//    sort(p,p+m);

//    f(i,0,m-1){
//        if(p[i].fi==1){
//            f(j,i+1,m-1){
//                if(p[i].se==p[j].fi  && p[j].se==n){
//                    cout<<"POSSIBLE"<<endl,exit(0);
//                }
//            }
//        }
//    }

    int size1=0;
    int size2=0;

    vi v1,v2;
    f(i,0,m-1){
        cin>>a>>b;

        if(a==1){
            ara[size1]=b;
            size1++;
        }
        else if(b==n){
            ara2[size2]=a;
            size2++;
        }
    }

    sort(ara2,ara2+size2);

    f(i,0,size1-1)
    {
        k=ara[i];
        if(binary_search(ara2,size2,k)==1){
            cout<<"POSSIBLE"<<endl,exit(0);
        }
    }

    cout<<"IMPOSSIBLE"<<endl;

}


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

int main() {
    int n;
    cin >> n;
    
    vector<int> a(n);
    
    for (int i = 0; i < n; i++) cin >> a.at(i);
    
    int ac = 0, bc = 0;
    
    for (int i = 0; i < n; i++) {
        
        int max = 0;
        
        for (int j = 0; j < n; j++) {
            if (a.at(j) > max) max = a.at(j);
        }
        
        for (int j = 0; j < n; j++) {
            if (a.at(j) == max) {
                a.at(j) = 0;
                break;
            }
        }
        
        if (i % 2 == 0) ac += max;
        else bc += max;
    }
    
    cout << ac - bc << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
   int n,l;
   cin >> n >> l;
   vector<string> s(n);
   rep(i,n)cin >> s[i];
   sort(ALL(s));
   rep(i,n)cout<<s[i];
   cout<<endl;
   return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int K = sc.nextInt();
      int score = 0;
      while(K > 0){
        if(A > 0){
          A--;
          K--;
          score++;
        }
        else if(B > 0){
          B--;
          K--;
        }
        else if(C > 0){
          C--;
          K--;
          score--;
        }
      }
      System.out.println(score);
	
	}
}

Measured memory_bytes: 35608
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    ll n;
    cin >> n;

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

    vector<vector<ll>> a(33,vector<ll> (2));
    a[0][0] = 1;
    a[0][1] = 0;

    ll m = 1;

    for(int i=1;i<33;i++){
        m*=-2;
        if(m>0){
            a[i][0] = a[i-1][0] + m;
            a[i][1] = a[i-1][1];
        }else{
            a[i][1] = a[i-1][1] + m;
            a[i][0] = a[i-1][0];
        }
    }
    ll tmp = n;
    vector<int> ans(33,0);
    for(int i=32;i>0;i--){
        if(tmp>0){
            if(a[i][0]>=tmp&&tmp>a[i-1][0]){
                ans[i] = 1;
                tmp = tmp - m;
            }else{
                ans[i] = 0;
            }
        }else{
            if(a[i][1]<=tmp&&tmp<a[i-1][1]){
                ans[i] = 1;
                tmp = tmp - m;
            }else{
                ans[i] = 0;
            }
        }
        m /= (-2);
    }
    if(tmp == 1){
        ans[0] = 1; 
    }else{
        ans[0] = 0;
    }

    bool flag = false;

    for(int i=32; i >= 0; i--){
        if(!flag){
            if(ans[i]==1){
                cout << ans[i];
                flag = true;
            }
        }else{
            cout << ans[i];
        }
    }


    return 0;
}

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

long long int N, a, an = 1, i, j;
long long int p[168] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};

int main(){
    scanf("%lld", &N);
    for(i = 0; i < 168 && p[i] <= N; ++i, a = 0){
        for(j = p[i]; j <= N; j *= p[i]){
            a += N / j;
        }
        an *= a + 1;
        an %= 1000000007;
    }
    cout << an << endl;
    return 0;
}


Measured memory_bytes: 256
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

const MOD: usize = 1000000007;

fn main() {
   input! {
      _k: String,
      d: usize,
   }

   let k: Vec<usize> = _k.as_bytes().iter().map(|&b| (b - b'0') as usize).collect();
   let n = k.len();

   let mut dp = vec![vec![vec![0; 2]; d]; n + 1];
   dp[0][0][1] = 1;
   for i in 0..n {
      for j in 0..d {
         for l in 0..10 {
            dp[i + 1][(j + l) % d][0] += dp[i][j % d][0];
            if l < k[i] {
               dp[i + 1][(j + l) % d][0] += dp[i][j][1];
            } else if l == k[i] {
               dp[i + 1][(j + l) % d][1] += dp[i][j][1];
            }
            dp[i + 1][(j + l) % d][0] %= MOD;
            dp[i + 1][(j + l) % d][1] %= MOD;
         }
      }
   }
   let mut ans = dp[n][0][0] + dp[n][0][1] + MOD - 1;
   ans %= MOD;
   println!("{}", ans);
}


Measured memory_bytes: 45308
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
#    S = [list(map(int, input(_).split())) for _ in range(M)]
    #LIST = [1] * N
    LIST = [ 1 for _ in range(N)]
    for _ in range(M):
        A, B = map(int, input().split())
        if H[A-1] >= H[B-1]: LIST[B-1] = 0
        if H[A-1] <= H[B-1]: LIST[A-1] = 0
    print(sum(LIST))

main()

Measured memory_bytes: 20052
program takoyaki_festival_2019
    implicit none
    integer(4):: n
    integer(4), allocatable:: d(:)
    integer(4):: ans=0
    
    read*, n
    allocate(d(n))
    read*, d(:)
    block; integer(4):: i,j
        do i=1, n-1
            do j=i+1,n
                ans = ans + d(i)*d(j)
            end do
        end do
    end block

    print*, ans
end program takoyaki_festival_2019

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	int a;
	scanf("%d",&a);
	
	int count = 0;
	for(int i=1;i<=a;i++)
	{
		int b;
		scanf("%d",&b);
		if(i%2==1&&b%2==1) count++;
	}
	printf("%d",count);
}

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

typedef long long ll;

const int Maxn = 52;
const int Maxm = Maxn * Maxn;
const int mod = 1000000007;

int n, k;
int dp[Maxn][Maxn][Maxm];

int main()
{
    scanf("%d %d", &n, &k);
    if (k % 2) { printf("0\n"); return 0; }
    else k /= 2;
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++)
        for (int a = i; a >= 0; a--)
            for (int b = i; b >= 0; b--)
                for (int s = 0; s < Maxm; s++) if (dp[a][b][s]) {
                    int ways = dp[a][b][s]; dp[a][b][s] = 0;
                    if (a > b) {
                        dp[a][b][s] = ll(ways) * (a - b) % mod;
                        dp[a][b + 1][s - (n - i - 1)] = (dp[a][b + 1][s - (n - i - 1)] + ll(ways) * (a - b) % mod * (a - b)) % mod;
                    }
                    dp[a + 1][b][s + (n - i - 1)] = (dp[a + 1][b][s + (n - i - 1)] + ways) % mod;
                    dp[a + 1][b + 1][s] = (dp[a + 1][b + 1][s] + ll(ways) * (a + 1 - b)) % mod;
                }
    int res = 0;
    for (int i = 0; i <= n; i++)
        res = (res + dp[i][i][k]) % mod;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 25600
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
int a[100005];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n; 
	cin>>n ;
	int sum = 0;
	int ans = 0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]>a[i-1]){
			sum = 0;
			ans = max(ans,sum);
		}
		else{
			sum++;
			ans = max(ans,sum);
		}
	}
	cout<<ans<<endl;
	return 0;
}



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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){

  ll h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h)cin >> s[i];

  vector<vector<ll>> L(h,vector<ll>(w));
  vector<vector<ll>> R(h,vector<ll>(w));
  vector<vector<ll>> U(h,vector<ll>(w));
  vector<vector<ll>> D(h,vector<ll>(w));

  rep(i,h)rep(j,w){
    if(s[i][j]=='#'){
      L[i][j]=0;
    }else if(j==0){
      L[i][j]=1;
    }else{
      L[i][j]=L[i][j-1]+1;
    }
  }

  rep(i,h){
    for(ll j = w-1; j >= 0;j--){
      if(s[i][j]=='#'){
        R[i][j]=0;
      }else if(j==w-1){
        R[i][j]=1;
      }else{
        R[i][j]=R[i][j+1]+1;
      }
    }
  }

  for(ll j = 0; j < w; j++){
    for(ll i = 0; i < h; i++){
      if(s[i][j]=='#'){
        U[i][j] = 0;
      }else if(i==0){
        U[i][j] = 1;
      }else{
        U[i][j] = U[i-1][j] +1;
      }
    }
  }

  for(ll j = 0; j < w; j++){
    for(ll i = h-1; i >= 0; i--){
      if(s[i][j]=='#'){
        D[i][j] = 0;
      }else if(i==h-1){
        D[i][j] = 1;
      }else{
        D[i][j] = D[i+1][j] +1;
      }
    }
  }

  ll ans = 0;
  rep(i,h)rep(j,w){
    ans = max(L[i][j]+R[i][j]+U[i][j]+D[i][j]-3, ans);
  }
  cout << ans << endl;


  // rep(i,h){
  //   rep(j,w){
  //     cout << U[i][j]<< " ";
  //   }
  //   cout << endl;
  // }


  return 0;
}

Measured memory_bytes: 131712
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define LL long long
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

int main(void) {
	int N;
	cin >> N;
	map<string, int> profit_dict;

	for (int i = 0; i < N; i++)
	{
		string tmp;
		cin >> tmp;
		profit_dict[tmp]++;
	}

	int M;
	cin >> M;
	map<string, int> loss_dict;
	for (int i = 0; i < M; i++)
	{
		string tmp;
		cin >> tmp;
		loss_dict[tmp]--;
	}

	int max = 0;
	for (auto &kv:profit_dict) {
		chmax(max, kv.second + loss_dict[kv.first]);
	}

	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;



/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}
public class Main {

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		Reader.init(System.in);
		int n = Reader.nextInt();
		String s1 = Reader.next();
		String s2 = Reader.next();
		
		if(n == 1) {
			System.out.println(3);
		}else {
			String d;
			int i = 1;
			long a = 1;
			if(s1.charAt(0)== s2.charAt(0)) {
				d = "single";
				a = 3;
			}else {
				d = "double";
				i = 2;
				a = 6;
			}
			while(i<n) {
				if(s1.charAt(i) != s2.charAt(i)) {
					if(d.compareTo("single") == 0) {
						a = ((a%1000000007)*2)%1000000007;
					}else {
						a = ((a%1000000007)*3)%1000000007;
					}
					i+=2;
					d = "double";
				}else {
					if(d.compareTo("single") == 0) {
						a = ((a%1000000007)*2)%1000000007;
					}
					d = "single";
					i++;
				}
			}
			System.out.println(a);
		}
		
		

	}

}


Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define log(i,n) log(n)/log(i);
using namespace std;
typedef long long ll;


int main()
{
	ll n,m;
	cin >> n >> m;
	vector<ll>l(m), r(m);
	rep(i, m)cin >> l[i] >> r[i];
	cout << min(n,max(0LL,*min_element(r.begin(), r.end()) - *max_element(l.begin(), l.end()) + 1)) << endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1000000;
#include <map>
#include <math.h>

using ll = long long;
using namespace std;

int main(){
    int c[3][3];
    rep(i, 3){
        rep(j, 3){
            cin >> c[i][j];
        }
    }

    int x[3], y[3];
    x[0] = 0;

    rep(i, 3) y[i] = c[0][i] - x[0];
    reps(i,1, 3) x[i] = c[i][0] - y[0];

    rep(i, 3){
        rep(j, 3){
            if((x[i]+y[j])!=c[i][j]){
                cout << "No" << endl;
            return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[2005][2005];
int main() {
	int n;
	cin >> n;
	vector< pair< ll , ll > > a(n + 1);
	for(int i = 1 ; i <= n ; i++){
		int x;
		cin >> x;
		a[i] = {x , i};
	}
	for(int i = 0 ; i <= n ; i++){
		for(int j = 0 ; j <= n ; j++)
			dp[i][j] = -1;
	}
	dp[0][0] = 0;
	sort(a.begin() + 1 , a.end());
	reverse(a.begin() + 1 , a.end());
	for(int i = 0 ; i <= n ; i++){
		for(int j = 0 ; i + j < n ; j++){
				//if(dp[i][j] == -1) continue;
				ll x = i + j + 1;
				ll ith = i + 1;
				ll jth = n - j;
				dp[i+1][j] = max(dp[i+1][j], dp[i][j] + abs(a[x].second - ith)*a[x].first);
				dp[i][j+1] = max(dp[i][j+1] , dp[i][j] + abs(a[x].second - jth)*a[x].first);
		}
		
	}
	ll ans = 0;
	for(int i = 0 ; i <= n ; i++){
		ans = max(ans, dp[i][n-i]);
	}
	cout << ans << endl;
	return 0;
	
}


Measured memory_bytes: 34984
#include <stdio.h>

char m[25][25];
int cou;

void dfs(int i,int j){
  //printf("%d %d\n",i,j);///
  m[i][j]='#';
  if(m[i+1][j]=='.'){
    cou++;    
    dfs(i+1,j);
  }
  if(m[i][j+1]=='.'){
    cou++;
    dfs(i,j+1);  
  }
  if(m[i-1][j]=='.'){
    cou++;
    dfs(i-1,j);
  }
  if(m[i][j-1]=='.'){
    cou++;
    dfs(i,j-1);
  }
}

int main(){
  int a,b,i,j;
  char o;
  while(1){
    cou=0;
    scanf("%d %d%c",&a,&b,&o);
    if(a==0&&b==0)break;
    for(i=1;i<b+1;i++){
      for(j=1;j<=a+1;j++){
	scanf("%c",&m[i][j]);
      }
    }
    for(i=1;i<b+1;i++){
      for(j=1;j<=a+1;j++){
	if(m[i][j]=='@')dfs(i,j);
      }
    }
    printf("%d\n",cou+1);
    for(i=1;i<b+1;i++){
      for(j=1;j<=a+1;j++){
	m[i][j]='0';
      }
    }
  }
return 0;
}

Measured memory_bytes: 1056
#!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()
n, x, y = [int(x) for x in input().split()]
ans = [0 for k in range(n)]
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        ans[min(abs(i - j), abs(x - i) + 1 + abs(y - j), abs(y - i) + 1 + abs(x - j))] += 1
print(*(ans[1:]), sep='\n')


Measured memory_bytes: 46684
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 200005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


int s[N], d[N];

map<int, int> ss, dd;

void solve(){
    int n; cin>>n;
    For(i, 1, n+1){
        int a; cin>>a;
        s[i]=i+a;
        d[i]=i-a;
        dd[d[i]]++;
    }
    int ans = 0;
    For(i, 1, n+1){
        ans += dd[s[i]];
    }
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}





Measured memory_bytes: 29416
#include<stdio.h>

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b){
    printf("0\n");
    }
    else{
    if(b/a>c){
    printf("%d\n",c);
    }
    else{
    printf("%d\n",b/a);
    }


    }




return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.io.IOException;
import java.io.InputStream;

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

    static class CDistinctOrNot {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int n = ni();
            HashSet<Integer> hset = new HashSet<>();
            for (int i = 0; i < n; i++)
                hset.add(ni());
            pn(hset.size() == n ? "YES" : "NO");
        }

        int ni() {
            return in.nextInt();
        }

        void pn(String zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 52672
A,B,C=map(int,input().split())

count=0
while True:
  if A==B and B==C:
    if A%2 == 0:
      count=-1
    break
  elif A%2==1 or B%2==1 or C%2==1:
    break
  else:
    A,B,C=(B+C)//2,(A+C)//2,(A+B)//2
    count+=1
  pass
print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define x first 
#define y second
typedef std::pair<int,int> pii;
typedef std::pair<pii,int> edg;
typedef std::pair<int,pii> kkk;
const int N=101000;
edg s[N];
kkk t[N<<1];
int n,m;
bool com(edg a,edg b){return a.x.y==b.x.y?a.x.x<b.x.x:a.x.y<b.x.y;}
int calc(int i,int j){return std::min(std::abs(s[i].x.x-s[j].x.x),std::abs(s[i].x.y-s[j].x.y));}
int q[N];
void init(){for(int i=1;i<=n;i++)q[i]=i;}
int ask(int p){return q[p]==p?p:q[p]=ask(q[p]);}
bool uni(int u,int v){return ask(u)==ask(v);}
void link(int u,int v){q[ask(u)]=ask(v);} 
int mt()
{
	int ret=0;
	init();
	std::sort(t+1,t+m+1);
	for(int i=1;i<=m;i++)
	{
		int x=t[i].y.x,y=t[i].y.y;
		if(uni(x,y))continue;
		link(x,y);
		ret+=t[i].x;
	}
	return ret;
}
int main()
{
	scanf("%d",&n);
	for(int i=1,x,y;i<=n;i++)
		scanf("%d%d",&x,&y),s[i]=edg(pii(x,y),i);
	std::sort(s+1,s+n+1);
	m=0;
	for(int i=1;i<n;i++)
		t[++m]=kkk(calc(i,i+1),pii(s[i].y,s[i+1].y));
	std::sort(s+1,s+n+1,com);
	for(int i=1;i<n;i++)
		t[++m]=kkk(calc(i,i+1),pii(s[i].y,s[i+1].y));
	printf("%d\n",mt());
	return 0;
}


Measured memory_bytes: 4096
import math
def bsearch_int(init_ng, init_ok, cond):
    ng = init_ng
    ok = init_ok
    while(abs(ok - ng) > 1):
        mid = math.floor(abs(ok + ng)/2)
        if cond(mid):
            ok = mid
        else:
            ng = mid
    return ok

def condition(cnt, N, A, B, hs):
    basedmg = B*cnt
    diff = A - B
    diffcnt = 0
    for h in hs:
        if h < basedmg:
            break
        else:
            diffcnt += math.ceil((h-basedmg)/diff)
    if diffcnt > cnt:
        return False
    else:
        return True

import functools
def resolve():
    N, A, B = list(map(int, input().split(" ")))
    hs = [int(input()) for i in range(N)]
    hs.sort(reverse=True)
    print(bsearch_int(0, math.ceil(hs[0]/B), functools.partial(condition, N=N, A=A, B=B, hs=hs)))


if __name__ == '__main__':
    resolve()

Measured memory_bytes: 51544
words = lambda t : list(map(t, input().split()))
n = int(input())
a = words(int)
b = [0] * n

for i in reversed(range(n)):
    t = i+1
    if t*2 > n:
        b[i] = a[i]
    else:
        #print(i, b[i], i*2+1, a[i*2+1])
        b[i] = a[i*2+1]
        j = i + (t*2)
        #print(j,b[i])
        #print(b)
        while j < n:
            b[i] += b[j]
            #print(j, b[j], b[i])
            j += t*2
        b[i] = b[i] % 2
        #print(a[i], b[i])
        if b[i] == a[i]:
            b[i] = 0
        else:
            b[i] = 1

#print(b)
ans = []
for i in range(len(b)):
    if b[i] == 1:
        ans.append(str(i+1))
print(len(ans))
if len(ans) > 0:
    print(" ".join(ans))


Measured memory_bytes: 76400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define maxi INT_MAX
#define mini INT_MIN
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};

vector<vector<int>> g;
vector<int> parent, depth, subsize;

ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // cout<<fixed;
    // cout<<setprecision(18);
    int n, m, sum = 0;
    cin>>n>>m;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i], sum+=a[i];
    sort(a.begin(), a.end(), greater<int>());
    int temp = (sum/(4*m));
    if(sum%(4*m) != 0)
        temp++;
    int count = 0;
    for(int i=0;i<m;i++)
    {
        if(a[i]>=temp)
        count++;
    }
    if(count == m)
    cout<<"Yes";
    else
    cout<<"No";
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll maxh = 5e4 + 10;
const ll maxn = 1010;
ll p[maxn], c[maxn];
ll dp[maxh];

int main()
{
    ll n, h;
    cin>>h>>n;
    for(ll i = 0; i < n; i++) cin>>p[i]>>c[i];
    fill(dp, dp +  maxh, INF);
    dp[0] = 0;
    for(ll i = 0; i < n; i++) {
        for(ll j = 0; j <= h; j++) {
            dp[j + p[i]] = min(dp[j + p[i]], dp[j] + c[i]);
        }
    }
    ll mins = INF;
    for (ll i = h; i < maxh; i++) mins = min(mins, dp[i]);
    cout<<mins;
    return 0;
}

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

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

  vector<int> p(n);
  rep(i,n) cin >> p[i];

  int ans = 0;
  for(int i = 1;i<n-1;i++){
    bool isSecond = (((p[i] - p[i-1]) * (p[i] - p[i+1])) <= -1);
    if(isSecond) ans += 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

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")
}

fn main() {
    let s: String = read();
    let n = s.len();

    let mut prv = "".to_owned();
    let mut i = 0;
    let mut ans = 0;
    while i < n {
        let mut k = i + 1;
        while k <= n {
            if s[i..k] != prv {
                break;
            }
            k += 1;
        }

        if k > n {
            // 最後がやばいので1つ前のにくっつけるしかない
            break;
        }

        prv = s[i..k].to_owned();
        i = k;
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#coding:utf-8
#1_5_B
def merge(array, left, mid, right):
    global cnt
    L = array[left:mid]  + [sentinel]
    R = array[mid:right] + [sentinel]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            array[k] = L[i]
            i += 1
        else:
            array[k] = R[j]
            j += 1
    cnt += right - left

def merge_sort(array, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(array, left, mid)
        merge_sort(array, mid, right)
        merge(array, left, mid, right)


n = int(input())
S = list(map(int, input().split()))
cnt = 0
sentinel = 10 ** 9 + 1
merge_sort(S, 0, len(S))
print(*S)
print(cnt)

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

typedef long long int llint;

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

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

  llint m = 0;
  for(int i = 0; i < 63; i++) if(i % 2 == 0) m |= (llint)1 << i;

  llint sa = m - n;
  for(int i = 0; i < 63; i++) {
    if(sa & ((llint)1 << i)) {
      m ^= (llint)1 << i;
    }
  }

  bool flg = true;
  for(int i = 62; i >= 0; i--) {
    if(m & ((llint)1 << i)) flg = false;
    if(flg) continue;
    cout<< (bool)(m & ((llint)1 << i));
  }
  cout<<endl;

  
  return 0;
}


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

int main(){
  int N,M;
  int ans;
  cin >> N >> M;
  if ( (N >= 1) && (N <= 9) && (M >= 1) && (M <= 9)){
    ans = N * M;
  } else {
    ans = -1;
  }
  
  cout << ans << endl;  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

typedef pair <int, int> PII;
typedef vector<PII> VPII;
typedef vector<VPII> VVPII;
bool U[2000];
int L[1001];

int main( void )
{
    int N, M;
    while ( cin >> N >> M && N && M ) {
        VVPII T( 10001 );
        memset( L, -1, sizeof(L) );
        int r, q;
        int t, n, m, s, ts, te;
        cin >> r;
        for ( int i = 0; i < r; i++ ) {
            cin >> t >> n >> m >> s;
            if ( s ) {
                L[n] = t;
            } else {
                T[m].push_back( PII( L[n], t ) );
                L[n] = -1;
            }
        }
        cin >> q;
        for ( int i = 0; i < q; i++ ) {
            memset( U, false, sizeof(U) );
            int answer = 0;
            cin >> ts >> te >> m;
            for ( VPII ::iterator it = T[m].begin(); it != T[m].end(); it++ ) {
                PII r = *it;
                for ( int j = r.first; j < r.second; j++ ) U[j] = true;
            }
            for ( int j = ts; j < te; j++ ) if ( U[j] ) answer++;
            cout << answer << endl;
        }
    }
    return 0;
}

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

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

    vector<string> vs(h);
    for (int i = 0; i < h; i++) {
        cin >> vs[i];
    }

    for (int i = 0; i < w+2; i++) {
        cout << "#";
    }
    cout << endl;

    for (int i = 0; i < h; i++) {
        cout << "#" << vs[i] << "#" << endl;
    }

    for (int i = 0; i < w+2; i++) {
        cout << "#";
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M := getInt(), getInt()

	if N > M/2 {
		out(M / 2)
		return
	}

	M -= N * 2
	ans := N + M/4
	out(ans)
}


Measured memory_bytes: 640