akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n; cin >> n;
    string s[51];
    string alphabet = "abcdefghijklmnopqrstuvwxyz";
    map<char, int> res;
    for (auto c:alphabet) {
        res[c] = 1000;
    }
    REP(i, n) {
        string tmp; cin >> tmp;
        map<char, int> tm;
        for (auto c:alphabet) {
            tm[c] = 0;
        }
        REP(j, tmp.size()) {
            tm[tmp[j]] += 1;
        }
        for (auto c:alphabet) {
            res[c] = min(res[c], tm[c]);
        }
    }
    for (auto c:alphabet) {
        REP(i, res[c]) {
            cout << c;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#define MAX 25
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/

typedef struct Node_struct Node;

Node T[MAX];
int D[MAX];
int H[MAX];
int De[MAX];
int S[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", u,T[u].p,S[u],De[u],D[u],H[u]);

  if(T[u].p == NIL) printf("root");
  else if(T[u].l == NIL && T[u].r == NIL) printf("leaf");
  else printf("internal node");
  printf("\n");
}

void calcDepth(int u, int p){
  D[u] = p;
  
  if(T[u].l != NIL) calcDepth(T[u].l, p+1);
  if(T[u].r != NIL) calcDepth(T[u].r, p+1);
}

int calcHeight(int u){
  int r,l;
  r = l = 0;
  
  if(T[u].l == NIL && T[u].r == NIL) {
    H[u] = 0;
    return 0;
  }
  
  if(T[u].r != NIL) 
    r = calcHeight(T[u].r) + 1;
  if(T[u].l != NIL)
    l = calcHeight(T[u].l) + 1;
  
  if(l > r) {
    H[u] = l;
    return l;
  }
  else {
    H[u] = r;
    return r;
  } 
}

void calcDegree(int u){
  if(T[u].r != NIL) {
    De[u]++;
    calcDegree(T[u].r);
  }
  if(T[u].l != NIL) {
    De[u]++;
    calcDegree(T[u].l);
  }
}

void calcSibling(int u){ 
    S[T[u].r] = T[u].l;
    S[T[u].l] = T[u].r;
}

void preorder(int u) {
  if(u == NIL)
    return;

  printf(" %d",u);
  preorder(T[u].l);
  preorder(T[u].r);
}

void inorder(int u) {
  if(u == NIL)
    return;
 
  inorder(T[u].l);
  printf(" %d",u);
  inorder(T[u].r);
}

void postorder(int u) {
  if(u == NIL)
    return;
 
  postorder(T[u].l);
  postorder(T[u].r);
  printf(" %d",u);
}
  
int main(){
  int i, j;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) {
    T[i].p = T[i].l = T[i].r = NIL;
    S[i] = NIL; 
  }
  
  for(i=0; i<n; i++){
    scanf("%d",&id);

    for(j = 0; j<2; j++){ //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else {
	T[id].r = child;
	calcSibling(id);
      }  
     
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == NIL ) root = i;
  }
  
  //それぞれのノードの深さを求める (find depth of each node)
  printf("Preorder\n");
  preorder(root);
  printf("\n");

  printf("Inorder\n");
  inorder(root);
  printf("\n");

  printf("Postorder\n");
  postorder(root);
  printf("\n");


  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm> // sort
#include <map>       // pair
#include <vector>
using namespace std;

#define REP(a,b) for(int i =(a);i < (b);i++)
#define FOR(n) for(ll i = 0; i<(n); i++)
#define COUT(c)  cout<<(c)<<endl


const int INF = 100100100;
const int MOD = (int)1e9 +7;
const double EPS = 1e-9; 

typedef long long int ll;

//char in[120];
//ex. pair
//pair<pair<string,int>,int> p[110];

int main(){
    string a,b;
    cin >> a >> b;
    int cnt=0;
    for(int i =0;i<3;i++){
        if(a[i] == b[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;    
}

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

using namespace std;

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

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

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

	int n;
	cin >> n;

	string s = to_string(n);

	int v = 0;
	for (auto c : s) {
		v += c - '0';
	}

	cout << (n % v == 0 ? "Yes" : "No") << endl;
	return 0;
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    std::string str;
    int a,b;
    b=0;
    std::cin>>a>>str;
    b=str.size();
    if(a>=b){
        std::cout<<str<<std::endl;
    }else{
        for(int i=0;i<a;i++){
            std::cout<<str.at(i);
        }
        std::cout<<"..."<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3640
import Control.Monad

main :: IO ()
main = do
  num <- readLn
  if (num == 0)
    then (return ())
    else do
      is <- replicateM (num+1) readLn
      let ans = counter (init is) (last is)
            where
              counter :: [Int] -> Int -> Int
              counter ls k = counter' (tpl ls) k 0
                where
                  counter' :: ([Int],[Int],Int) -> Int -> Int -> Int
                  counter' (l,h,m) k c
                    | m == 0 = c
                    | m == k = c + 1
                    | m > k = counter' (tpl l) k (c + 1)
                    | m < k = counter' (tpl h) k (c + 1)
                  tpl :: [Int] -> ([Int],[Int],Int)
                  tpl [] = ([],[],0)
                  tpl xs = tpl' [] xs
                    where
                      length :: [Int] -> Int
                      length [] = 0
                      length (_:xs) = (length xs) + 1

                      tpl' l1 [] = ((init l1),[],(last l1))
                      tpl' l1 (x:xs)
                        | (length l1) >= (length (x:xs)) = ((init l1),(x:xs),(last l1))
                        | otherwise = tpl' (l1 ++ [x]) xs
      print ans
      main

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

int main() {
	ll m,n,mx=0,i,s,x=1;
	cin>>m>>n;
	vector <ll> vi;
	for(i=1;i<sqrt(n);i++){
	    if(n%i==0){
	        vi.push_back(i);
	        vi.push_back(n/i);
	    }
	    
	}
	sort(vi.begin(),vi.end());
	for(i=0;i<vi.size();i++){
	    if(m<=n/vi[i]){
	        x=vi[i];
	    }
	}
	cout<<x;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}

int main() {
  ll n;
  cin >> n;
  vector<double> a(n);
  double sum = 0;
  rep(i,n) {
    cin >> a[i];
    sum += a[i];
  }
  sum /= (double)n;
  double mini = -1;
  int pos = -1;
  rep(i,n) {
    if( mini == -1 ) {
      mini = a[i];
      pos = 0;
    } else {
      if( LT(abs(sum-a[i]),abs(sum-mini)) ) {
	mini = a[i];
	pos = i;
      }
    }
  }
  cout << pos << endl;
  compute();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n;
	while(cin >> n, n){
		int m, sum = 0;
		cin >> m;
		rep(i, m){
			int A, B;
			cin >> A >> B;
			sum += abs(A-B);
		}
		if(sum >= n){
			cout << "OK" << endl;
		}else{
			cout << abs(n-sum) << endl;
		}
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1164
#include <stdio.h>

int main()
{
  int a, b, c, i = 0;

  scanf("%d %d %d", &a, &b, &c);

  for( ; a <= b ; a++ )
  {
    if( c % a == 0 )
      i++;
  }

  printf("%d\n", i);
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll OO = 1e18+7;
const int MOD = 1e9+7;
const int N = 3e3+7;
int n;
ll mem[2][N][N];
ll a[N];

ll dp(bool p,int l,int r)
{
    ll &ret = mem[p][l][r];
    if (ret != -1) return ret;
    if (l > r) return 0;
    if (!p)
    {
        ret = max(dp(!p,l+1,r)+a[l],dp(!p,l,r-1)+a[r]);
    }
    else
    {
        ret = min(dp(!p,l+1,r)-a[l],dp(!p,l,r-1)-a[r]);
    }
    return ret;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);
    memset(mem,-1,sizeof mem);
    cin >> n;
    REP(i,0,n-1) cin >> a[i];

    cout << dp(0,0,n-1) << endl;

    return 0;
}


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

using namespace std;

int n, a[200005], x, d[1000010], sol;

int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a, a+n);
    for(int i=0;i<n;i++){
        x=a[i];
        if(d[x]!=0){
            d[x]++;
            continue;
        }
        for(int j=x;j<=a[n-1];j+=x){
            d[j]++;
        }
    }
    for(int i=0;i<n;i++){
        if(d[a[i]]==1){
            //cout<<a[i]<<" ";
            sol++;
        }
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 8248
n = input();
n = int(n);
a = input().rstrip('\n')
a = a.split(" ");
a.append(a[n-1]);
state = int(a[1]) - int(a[0]);
ans = 1;
for i in range(2,n) :
	if int(a[i]) - int(a[i-1]) > 0 and state < 0 :
		ans = ans + 1;
		state = int(a[i+1]) - int(a[i]);
	elif int(a[i]) - int(a[i-1]) < 0 and state > 0 :
		ans = ans + 1;
		state = int(a[i+1]) - int(a[i]);
	elif state == 0 :
		state = int(a[i+1]) - int(a[i]);
print(ans);

Measured memory_bytes: 11480
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<int> A;
map<int, int> deg;
int main() {
  cin >> N;
  A.resize(N);
  for (auto &val : A){
    cin >> val;
    deg[val]++;
  }
  sort(A.begin(), A.end());
  priority_queue<pii, vector<pii>, greater<pii> > que;
  set<int> tmp;
  for (const auto &val : deg){
    tmp.emplace(val.first);
    if (val.second > 1){
      que.emplace(mp(val.second - 1, val.first));
    }
  }
  int sum = N;
  while (que.size() >= 2){
    pii a = que.top();
    que.pop();
    a.first--;
    pii b = que.top();
    que.pop();
    b.first--;
    sum -= 2;
    if (a.first > 0){
      que.emplace(a);
    }
    if (b.first > 0){
      que.emplace(b);
    }
  }
  if (que.size() == 1){
    pii a = que.top();
    que.pop();
    while (a.first >= 2){
      a.first -= 2;
      sum -= 2;
    }
    if (a.first > 0){
      sum -= 2;
    }
  }
  cout << max(1, sum) << endl;
  return 0;
}


Measured memory_bytes: 9984
#include <stdio.h>
#include <algorithm>
int main(void){
    int a[3];
    int k,x;
    scanf("%d%d%d%d",&a[0],&a[1],&a[2],&k);
    std::sort(a,a+3);
    for(int i=0;i<k;i++){
        x=a[2];
        a[2]=2*x;
    }
    printf("%d\n",a[0]+a[1]+a[2]);
}

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

class Program {
    static void Main(string[] args) {
        int a = cin.ni();
        int b = cin.ni();
        int h = cin.ni();

        Console.WriteLine((a + b) * h / 2);

    }
}


public class cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public static int ni() {
        return int.Parse(next());
    }

    public static long nextLong() {
        return long.Parse(next());
    }

    public static double nextDouble() {
        return double.Parse(next());
    }

}


Measured memory_bytes: 2776
#include<bits/stdc++.h>
using namespace std;
//解説-解法2
int main (){
    int X;
    cin >> X;
    bool ans = false;
    if(X >= 2000){
        ans = true;
    }else{
        for(int i=0;i<=20;i++){
            for(int j=0;j<=20;j++){
                for(int k=0;k<=20;k++){
                    for(int l=0;l<=20;l++){
                        for(int m=0;m<=20;m++){
                            for(int n=0;n<=20;n++){
                                if(X == 100*i + 101*j + 102*k + 103*l + 104*m + 105*n){
                                    ans = true;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if(ans){
        cout << '1' << endl;
    }else{
        cout << '0' << endl;
    }
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);

    int leftc = m / 2 + m % 2;
    int rightc = m / 2;

    int l = 1, r = leftc * 2;
    rep(i, leftc) {
        cout << l << " " << r << endl;
        l++; r--;
    }

    l = leftc*2 + 1, r = m * 2 + 1;
    rep(i, rightc) {
        cout << l << " " << r << endl;
        l++; r--;
    }

    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(ll i = a; i < (ll)b; ++i)

typedef long long ll;

const int Inf = 1e9 + 7;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m, n;  cin >> m >> n;
    ll ans = 1;
    if (abs(m - n) >= 2) {
      ans = 0;
    } else {
      FOR (i, 1, m + 1) {
        ans = (ans * i) % Inf;
      }
      FOR (i, 1, n + 1) {
        ans = (ans * i) % Inf;
      }
      if (n == m) ans = (ans * 2) % Inf;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
program contrast
  implicit none
  integer :: n, m = 0, i
  integer, allocatable :: a(:), b(:), c(:), d(:)
  read(*,*) n
  allocate(a(n), b(n), c(0:n), d(0:n))
  read(*,*) a
  read(*,*) b
  do i = 1, n
    c(a(i)) = c(a(i)) + 1
    d(b(i)) = d(b(i)) + 1
  end do
  if (any(c + d > n)) then
    write(*,'(a)') 'No'
    stop
  end if
  do i = 1, n
    c(i) = c(i) + c(i - 1)
    d(i) = d(i) + d(i - 1)
    m = max(m, c(i) - d(i - 1))
  end do
  m = n - m
  write(*,'(a)') 'Yes'
  write(*,'(i0)',advance='no') b(merge(m + 1 - n, m + 1, m + 1 > n))
  do i = 2, n
    write(*,'(x,i0)',advance='no') b(merge(m + i - n, m + i, m + i > n))
  end do
  write(*,*)
end program contrast

Measured memory_bytes: 6212
/*  (: ///////|||||| BEGINS |||||||\\\\ :) */
/* REMEMBER
Deletes all characters except first one     Deletes 4 characters from index number 1
    str.erase(1);                               str.erase(1,4);
Deletes character at position 4
 str.erase(str.begin() + 4);
bool compare(const pair<int, int>&a, const pair<int, int>&b)
{
   return a.second<b.second;
}
maxn = max_element(mp.begin(), mp.end(), compare)->second;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second < b.second);
}
priority_queue <int, vector<int>, greater<int>> gquiz; // to create min heap
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
const int inf=0x3f3f3f3f;
#define mod  1000000007
#define fo(i,n) for(int i=1;i<=n;i++)
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define three_max(n1,n2,n3) (n1 > n2)?(n1>n3?n1:n3):(n2>n3?n2:n3)
#define lb lower_bound
#define ub upper_bound
#define tr(it, a) for(auto it = a.begin();it!=a.end();it++)
#define gcd(a,b) __gcd(a,b)
#define pq priority_queue 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long isprime(long long n)
{
    for(long long i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)return 0;
    }
    return 1;
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll k;
cin>>k;
ll total=0;
for(ll i=1;i<=1e6;i++)
{

total=(total*10+7)%k;
if(total==0)
{
    cout<<i<<endl;
    return 0;
}
}
cout<<-1<<endl;
return 0;
}

Measured memory_bytes: 3656
S=int(input())
ans=0

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 3000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
i=1
while S>=3*i:
  s=S-3*i
  ans+=cmb(s+(i-1),i-1,mod)
  i+=1
print(ans%mod)

Measured memory_bytes: 9416
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#endif

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cini(n);
	vector<pair<string, int>> data(n);
	for (int i = 0; i < n; i++) {
		cin >> data[i].first >> data[i].second;
	}
	cins(x);

	bool seen = false;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (seen)
			ans += data[i].second;

		if (x == data[i].first)
			seen = true;
	}
	cout << ans << endl;
}

int main() {
	cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	solve();
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        char array[] = s.toCharArray();

        if(array[0]==array[1] || array[1]==array[2] || array[2]==array[3]){
            System.out.println("Bad");
        }else{
            System.out.println("Good");
        }

    }
}

Measured memory_bytes: 23764
#!/usr/bin/env python3
S = input()
# 奇数文字目にLがあるとだめ
# 偶数文字目にRがあるとだめ
ng = ["L", "R"]
for i in range(0, len(S)):
  if S[i] == ng[i%2]:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(),v.end()
#define sz(x) (int)sz.size()
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define what(x) cout<<#x<<" is "<<x<<endl;
using namespace std;

#ifdef LOCAL//ONLINE_JUDGE
#include "D:\c_c++\template.h"
#else
#define debug(...) 42
#endif

ll powmod(ll a,ll b,ll mod) {
    ll res=1;a%=mod;
    //assert(b>=0);
    for(;b;b>>=1){
        
      if(b&1)res=res*a%mod;
			a=a*a%mod;
    }
    return res;
}

void solve(){
	ll x;
	cin>>x;
	debug("hahah");
	cout<<(!x)<<'\n';
	debug("bhai bhai");
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
//    #ifdef LOCAL
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
    int tc=1;
    // cin>>tc;
    while(tc--)solve();
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
#define int long long
#pragma region alias
#define inf LONG_MAX
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repr(i,n) for(int i=(int)(n-1);i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define sz(v) ((int)(v).size())
#define rz resize
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vec vector
using vi=vec<int>;
using vs=vec<string>;
using ii=pair<int,int>;
#pragma endregion

// define variables here
int n;
int sum;
void solve(){
  // write code here
  cin>>n;
  for(int i=1;i<=n;++i){
    if(i%3!=0&&i%5!=0)sum+=i;
  }
  cout<<sum<<endl;
}

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

Measured memory_bytes: 3652
#include <string>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main() {
    int n, num;
    cin >> n;
    map<int, int> map1;
    for (int i = 0; i < n; i++) {
        cin >> num;
        if (map1.find(num) == map1.end())
            map1[num] = 1;
        else {
            map1[num]++;
            
        }
        

    }
    n = 0;

    map<int, int>::iterator it;
    it = map1.begin();
    while (it != map1.end()) {
        if (it->second % 2 != 0)
            n++;
        it++;
    }
    cout << n;
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
typedef long long ll;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

#define fail return puts("-1"),0;
const int N=1e5+5,inf=1e9;
const char ch[]="BW";
int n,m,d[N],num=1,head[N],w[N<<1],col[N],fa[N];
struct edge{int to,next,vis;} e[N<<2];
inline void add(int u,int v){
    e[++num]=(edge){v,head[u]},head[u]=num;
    e[++num]=(edge){u,head[v]},head[v]=num;
}

inline void dfs(int u){
    for(int i=head[u];i;i=e[i].next){
	int v=e[i].to;if(!e[i].vis||~col[v])continue;
	col[v]=1-col[u];dfs(v);
    }
}

int main(){
    //freopen("in.in","r",stdin);
//什么zz题，说好了输出int范围内即可结果大于1e9就爆炸？？？
    n=read(),m=read();
    REP(i,1,n)d[i]=read();
    REP(i,1,m)add(read(),read()),w[i]=inf;
    REP(u,1,n){
	if(!head[u])fail;
	int p=head[u];
	for(int i=e[p].next;i;i=e[i].next){
	    if(d[e[i].to]<d[e[p].to])p=i;
	    else if(d[e[i].to]==d[e[p].to]&&e[i].to<e[p].to)p=i;
	}
	if(d[e[p].to]>d[u])fail;
	e[p^1].vis=1;w[p>>1]=d[u];fa[u]=e[p].to;
    }
    memset(col,-1,sizeof col);
    REP(i,1,n)if(fa[fa[i]]==i&&!~col[i])col[i]=0,dfs(i);
    REP(i,1,n)putchar(ch[col[i]]);
    puts("");
    REP(i,1,m)printf("%d\n",w[i]);
    return 0;
}


Measured memory_bytes: 9472
import sys
import numpy as np
X, N = map(int, input().split())
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))

forbid = [True]*102

for i in range(len(p)):
    if forbid[p[i]]:
        forbid[p[i]] = False
        
pp = []

for i in range(len(forbid)):
    if forbid[i]:
        pp.append(i-X)

# num = pp[len(pp)-1]        
# for i in range(len(pp)-1,0,-1):
#     if abs(num) >= abs(pp[i]):
#         num = pp[i]
        
print(pp[np.argmin(np.abs(pp))]+X)


Measured memory_bytes: 27076
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int a;
	cin>>a;
	if(a<1200)cout<<"ABC"<<endl;
	else if(1200<=a&&a<2800)cout<<"ARC"<<endl;
	else if(2800<=a)cout<<"AGC"<<endl;
	
	return 0;
}

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

public class Main{

    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        int n=Integer.parseInt(sc.nextLine());
        sc.close();
        final int[] f = new int[n+1];
        System.out.println(f(n,f));


       

        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //    try{
        //         //int n= Integer.parseInt(br.readLine());
        //         //int[] array = Arrays.stream(sElementArray).mapToInt(Integer::parseInt).toArray();

                
                
        //     }catch(IOException e){e.printStackTrace();}
    }
    static int f(int n, int[] f){
        f[0]=1;
        if(n>=1){f[1]=1;}
        if(n>=2 && f[n]==0){f[n]=f(n-1,f)+f(n-2,f);}
        return f[n];
    }
}
    


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

inline bool chmax(ll&x,ll y);
ll dp[2001][2001]={};

int main(){
	int n; cin >> n;
	vector<pl> a(n);
	rep(i,n){
		cin >> a[i].first; a[i].second = i;
	}
	sort(a.rbegin(), a.rend());

	vector<vl> dp(n+1, (vl(n+1, 0)));
	ll ans = 0;
	for(int i = 0; i<=n; i++){
		for(int j = 0; i+j<=n; j++){
			if (!(i||j)) continue;
			if(i){
				int diff = a[i+j-1].second - i + 1;
				dp[i][j] = dp[i-1][j]+a[i+j-1].first*diff;
			} 
			if(j){
				int diff = (n-j) - a[i+j-1].second;
				dp[i][j] = max(dp[i][j], dp[i][j-1]+a[i+j-1].first*diff); 
			}

			if(i+j==n) ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 34676
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    h = map(int, input().split())

    p = 0
    for i in h:
        if i > p:
            p = i - 1
        elif i < p:
            print('No')
            return

    print('Yes')


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


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

vector<map<int, int>> graph;
map<int, int> depths;

bool dfs(int v, int p, int d)
{
	if (depths.find(v) != depths.end()) {
		return true;
	}
	depths[v] = d;

	for (auto n : graph[v]) {
		if (p == n.first) {
			continue;
		}
		int n_depth = d + n.second;
		if ((depths.find(n.first) != depths.end()) && (depths[n.first] != n_depth)) {
			return false;
		}
		bool result = dfs(n.first, v, n_depth);
		if (!result) {
			return false;
		}
	}
	return true;
}

int main(void)
{
	int N, M;
	cin >> N >> M;

	graph.resize(N);

	for (int i = 0; i < M; i++) {
		int L, R, D;
		cin >> L >> R >> D;
		graph[L - 1][R - 1] = D;
		graph[R - 1][L - 1] = -D;
	}

	for (int i = 0; i < N; i++) {
		if (!dfs(i, -1, 0)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 35840
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
#define Maxn 205
#define E 4000010
int rel[Maxn][Maxn];
int head[Maxn],v[E],nxt[E],tot=0;
inline void add_edge(int s,int e){
	tot++;v[tot]=e;nxt[tot]=head[s];head[s]=tot;
}
int col[Maxn],d[Maxn];
bool flag=true;
void dfs(int u,int c){
	if(!flag)return;
	col[u]=c;
	for(int i=head[u];i;i=nxt[i])
	    if(col[v[i]]==-1)dfs(v[i],c^1);
	    else{
	    	if(col[u]==col[v[i]]){
	    		flag=false;
	    		return;
			}
		}
}

int Q[Maxn],hd,tl;
int solve(int u){
	memset(d,-1,sizeof(d));
	d[u]=0;
	int res=1;
	hd=tl=0;
	Q[tl++]=u;
	while(hd<tl){
		int x=Q[hd];hd++;
		res=max(res,d[x]+1);
		for(int i=head[x];i;i=nxt[i])
		    if(d[v[i]]==-1){
		    	d[v[i]]=d[x]+1;
		    	Q[tl++]=v[i];
			}
	}
	return res;
}

char ch[Maxn][Maxn];

int main(){
	scanf("%d",&n);
	int x;
	for(register int i=1;i<=n;++i){
	    scanf("%s",ch[i]+1);
	    for(register int j=1;j<=n;++j){
			if(ch[i][j]=='1')add_edge(i,j);	
		}
	}
	memset(col,-1,sizeof(col));
	dfs(1,0);
	if(!flag){
		puts("-1");
		return 0;
	}
	int ans=0;
	for(register int i=1;i<=n;++i)ans=max(ans,solve(i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2432
// AtCoDeerくんと選挙速報
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long INT;

INT N,T[1000],A[1000];

int main(){
    cin>>N;
    for(INT i=0;i<N;i++){
        cin>>T[i]>>A[i];
    }
    for(INT i=1;i<N;i++){
        INT x=max((T[i-1]-1)/T[i]+1,(A[i-1]-1)/A[i]+1);
        T[i]*=x;
        A[i]*=x;
    }
    cout<<T[N-1]+A[N-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        int[] A = new int[N];
        int sum=0;
        for(int i=0; i<N; i++){
            A[i] = Integer.parseInt(sc.next());
            sum = sum + A[i];
        }
        sc.close();

        int count = 0;
        for(int i=0; i<N; i++){
            if(A[i] * 4 * M >= sum){
                count += 1;
            }
        }
        if(count >= M){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }




    }

}

       

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

int main()
{
	char a[55], b[55];
	
	scanf("%s%s", a, b);
	int x = strlen(a), y = strlen(b);
	for (int i = 0; i < x - 1; i++) {
		putchar(a[i]);
		putchar(b[i]);
	}
	putchar(a[x - 1]);
	if (x == y) {
		putchar(b[x - 1]);
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include<stdbool.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define swap(a,b) {ll tp=a;a=b;b=tp;}
const ll MOD = 1000000007;

int main(){
    char s[202];scanf("%s",s);
    char t[102],u[102];
    int n=strlen(s);
    ll ans=0;
    while(n--){
        if(n%2==1)continue;
        strncpy(t,s,n/2); t[n/2]=0;
        strncpy(u,s+n/2,n/2); u[n/2]=0;
        if(strcmp(t,u)==0){
            ans=n;
            break;
        }
    }
    
    printf("%lld\n", ans);
}


Measured memory_bytes: 1728
import sys

sys.setrecursionlimit(10 ** 6)


class UnionFind:
    def __init__(self, n_nodes):
        self.parent = [i for i in range(n_nodes)]
        self.rank = [0] * n_nodes
        self.size = [1] * n_nodes

    def find(self, x):
        if x == self.parent[x]:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] > self.rank[y]:
            self.parent[y] = x
            self.size[x] += self.size[y]
        else:
            self.parent[x] = y
            self.size[y] += self.size[x]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def check(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        return self.size[self.find(x)]


N, M, K = map(int, input().split())
tree = UnionFind(N)
exclusion = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    tree.unite(a, b)
    exclusion[a].append(b)
    exclusion[b].append(a)

for _ in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if not tree.check(c, d):
        continue
    exclusion[c].append(d)
    exclusion[d].append(c)

for i in range(N):
    # 同一グループで自分以外の人数
    n = tree.get_size(i) - 1
    ans = n - len(exclusion[i])
    print(ans, end=" ")


Measured memory_bytes: 56496
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

deque<int> ans;
vector<int> g[100100];
bool used[100100];

void dfs(int l, int r){
	int i;
	for(i=(g[l].l_ength()-1); i>=0; --i){
		if(used[g[l][i]]){
			continue;
		}
		used[g[l][i]] = true;
		ans.push_front(g[l][i]);
		dfs(g[l][i],r);
		return;
	}
	for(i=(g[r].l_ength()-1); i>=0; --i){
		if(used[g[r][i]]){
			continue;
		}
		used[g[r][i]] = true;
		ans.push_back(g[r][i]);
		dfs(l,g[r][i]);
		return;
	}
}

int main(void){
	int n,m,i,a,b;
	cin >> n >> m;
	for(i=0; i<m; ++i){
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	ans.push_back(1);
	used[1] = true; dfs(1,1);
	cout << ans.l_ength() << endl;
	for(i=0; i<ans.l_ength(); ++i){
		cout << ((i)?" ":"") << ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 6784
import math
n, k = map(int, input().split())
result = []
for i in range(k):
    okashi = int(input())
    hito = list(map(int, input().split()))
    for j in range(len(hito)):
        if (hito[j] not in result):
            result.append(hito[j])

print(n - len(result))

Measured memory_bytes: 67756
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion



int main(){
    ios;
    INT(n);
    STR(s);
    ll cnt = 0;
    ll rc = 0;
    REP(i, n) if(s[i] == 'R') rc++;
    REP(i, n-1)if(s[i] == 'W' and s[i + 1] == 'R') cnt++;
    fin(cnt == 0, 0);
    ll res = rc;
    REP(i, rc){
        if(s[i] == 'R') res--;
    }
    print(res);
}

Measured memory_bytes: 3960
using System;
using System.Collections.Generic;
using System.Linq;
namespace AOJ {
  public class AOJ {
    public static void Main(string[] args) {
      bool isContinue = true;
      while(isContinue) {
        string[] input = Console.ReadLine().Split(' ').ToArray();
        switch(input[1]) {
        case "+":
          Console.WriteLine(int.Parse(input[0]) + int.Parse(input[2]));
          break;
        case "-":
          Console.WriteLine(int.Parse(input[0]) - int.Parse(input[2]));
          break;
        case "*":
          Console.WriteLine(int.Parse(input[0]) * int.Parse(input[2]));
          break;
        case "/":
          Console.WriteLine(Math.Floor(double.Parse(input[0]) / double.Parse(input[2])));
          break;
        case "?":
          isContinue = false;
          break;
        }
      }
    }
  }
}

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

int main() {
	//cout<<"GfG!";
	long long int n, m, c = 0;
	float tot, sum = 0, a[100];
	cin>>n>>m;
	for (int i = 0; i < n; i++)
	{
	    cin>>a[i];
	    sum += a[i];
	}
	tot = sum / (4 * m);
	for (int i = 0; i < n; i++)
	{
	    if (a[i] >= tot)
	    {
	        c++;
	    }
	}
	if (c >= m)
	    cout<<"Yes";
	else
	    cout<<"No";
	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		//Scanner????????????????????????
		Scanner scan = new Scanner(System.in);
		//?????°???????????????
		int n = scan.nextInt();

		ArrayList<Integer> sList = new ArrayList<Integer>();
		ArrayList<Integer> hList = new ArrayList<Integer>();
		ArrayList<Integer> cList = new ArrayList<Integer>();
		ArrayList<Integer> dList = new ArrayList<Integer>();
		int intCardVal = 13;
		int[] sAry = new int[intCardVal];
		int[] hAry = new int[intCardVal];
		int[] cAry = new int[intCardVal];
		int[] dAry = new int[intCardVal];
		for(int i = 0; i < intCardVal; i++){
			sAry[i] = 0;
			hAry[i] = 0;
			cAry[i] = 0;
			dAry[i] = 0;
		}

		int intCount = 0;

		while(scan.hasNextLine()){

			String strMark = scan.next();
			int intNum = scan.nextInt();

			if("S".equals(strMark)){

				sAry[intNum - 1] = intNum;

			}else if("H".equals(strMark)){

				hAry[intNum - 1] = intNum;
			}else if("C".equals(strMark)){

				cAry[intNum - 1] = intNum;
			}else if("D".equals(strMark)){

				dAry[intNum - 1] = intNum;
			}

			intCount++;
			if(intCount == n){
				scan.close();
				break;

			}
		}


		//????????????????????£???????????°?????????????????°??????list???????´?
		for(int i = 0; i < intCardVal; i++ ){

			if(sAry[i] == 0 ){

				sList.add( i + 1);
			}
			if(hAry[i] == 0){

				hList.add(i + 1);
			}
			if(cAry[i] == 0){

				cList.add(i + 1);
			}
			if(dAry[i] == 0){

				dList.add(i + 1);
			}
		}


		//??????????????????
		for(int i = 0; i < sList.size(); i++){

			System.out.print("S ");
			System.out.print(sList.get(i));
			System.out.println("");
		}

		//???????????????
		for(int i = 0; i < hList.size(); i++){

			System.out.print("H ");
			System.out.print(hList.get(i));
			System.out.println("");
		}

		//???????????????
		for(int i = 0; i < cList.size(); i++){

			System.out.print("C ");
			System.out.print(cList.get(i));
			System.out.println("");
		}

		//???????????????
		for(int i = 0; i < dList.size(); i++){

			System.out.print("D ");
			System.out.print(dList.get(i));
			System.out.println("");
		}

	}
}

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

for i in range(K):
    if A >= C:
        C *= 2
    elif A >= B:
        B *= 2
    elif B >= C:
        C *= 2
    if A < B and B < C:
        print("Yes")
        break
else:
    print("No")


Measured memory_bytes: 9168
def input_list():
  return list(map(int, input().split()))

def main():
  r, g, b, n = input_list()
  ans = 0
  for x in range(n//r+1):
    for y in range(n//g+1):
      rr = r*x
      gg = g*y
      if rr + gg > n:
        continue
      bb = (n - rr - gg)
      if bb % b != 0:
        continue
      ans += 1
  print(ans)

main()

Measured memory_bytes: 39536
import java.util.Scanner;

public class Main {
	public  static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] h = new int[N];
		int cnt = 0;

		for(int i = 0;i < N;i++) {
			h[i] = sc.nextInt();
			if(K <= h[i]) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 50732
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut iter = s.split_whitespace();

    let n: i32 = iter.next().unwrap().parse().unwrap();
    let d: i32 = iter.next().unwrap().parse().unwrap();

    let res;
    if n % (d * 2 + 1) != 0 {
        res = n / (d * 2 + 1) + 1;
    } else {
        res = n / (d * 2 + 1);
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


int main(){
    string s;cin >> s;
    ll k;cin >> k;
    ll cnt=0;
    ll n=s.size();
    bool same=true;
    rep(i,n-1)if(s[i]!=s[i+1])same=false;
    if(same){
        cout << k*s.size()/2 << endl;
        return 0;
    }
    rep(i,n-1){
        if(s[i]==s[i+1]){
            cnt++;
            i++;
        }
    }
    if(s[0]!=s[n-1])cout << cnt*k <<endl,exit(0);
    ll a=1,b=1;
    repl(i,1,n){
        if(s[i]==s[i-1])a++;
        else break;
    }
    reverse(all(s));
    repl(i,1,n){
        if(s[i]==s[i-1])b++;
        else break;
    }
    cout << cnt*k-(a/2+b/2-(a+b)/2)*(k-1) <<endl;
}

Measured memory_bytes: 3616
#複数行に一文字ずつの場合
a,b,c,k  = gets.chomp.split(" ").map(&:to_i);

ans = 0
if k >= a then
	ans += a * 1
	k = k - a
else
	ans += k
	puts ans
	exit
end

if k >= b then
	k = k - b
else
	puts ans
	exit
end

if k >= c then
	ans = ans - c
else
	ans = ans - k
end
puts ans


Measured memory_bytes: 14384