akhauriyash/Code-Regression huggingface dataset:
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<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;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, y;
  cin >> x >> y;
  REP(int, i, 100)
  {
    REP(int, j, 100-i+1)
    {
      if (y == 2*i+4*j && x == i+j)
      {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;



public class Main {

	public static void main(String[] args) {
		 FastScanner sc =new FastScanner();
		 int n=10000007;
		 
		 long k=sc.nextLong();
		long val=7%k;
		 for(int i=1;i<=n;i++) {
			
			 if(val==0) {
				 System.out.println(i);
				 return;
			 }
			 val=(val*10+7)%k;
		 }
		 
		
		   System.out.println("-1");
		 
		  
		
		
		    	
		    }
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}

		    
		}

Measured memory_bytes: 32796
a,b=map(int,input().split())
k=list(map(int,input().split()))

ans=0

for i in range(0,a-1):
    now=k[i]+k[i+1]
    if now > b:
        c=now-b
        if k[i+1]<c:
            k[i+1]=0
        else:
            k[i+1]-=c
        ans+=c
#print(k)
print(ans)       

Measured memory_bytes: 14160
import re

A = input().split()

stack = []

for s in A:
    if re.match("[0-9]+", s):
        stack.append(int(s))
    elif re.match("\+", s):
        stack.append(stack.pop(-2) + stack.pop(-1))
    elif re.match("-", s):
        stack.append(stack.pop(-2) - stack.pop(-1))
    elif re.match("\*", s):
        stack.append(stack.pop(-2) * stack.pop(-1))

print(stack[0])


Measured memory_bytes: 6548
n = int(input())
a = list(map(int, input().split()))
t = 1
cand1 = 0
tmp = 0
for ai in a:
    if (tmp + ai) * t <= 0:
        cand1 += abs(tmp + ai - t)
        tmp = t
    else:
        tmp += ai
    t *= -1
t = -1
cand2 = 0
tmp = 0
for ai in a:
    if (tmp + ai) * t <= 0:
        cand2 += abs(tmp + ai - t)
        tmp = t
    else:
        tmp += ai
    t *= -1

print(min(cand1, cand2))

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

class Dice{
public:
  int value[6];
  void roll(char _order) {
    switch(_order) {
    case 'N':
      swap(value[4], value[0]);
      swap(value[0], value[1]);
      swap(value[1], value[5]);
      break;
    case 'E':
      swap(value[2], value[0]);
      swap(value[0], value[3]);
      swap(value[3], value[5]);
      break;
    case 'S':
      swap(value[1], value[0]);
      swap(value[0], value[4]);
      swap(value[4], value[5]);
      break;
    case 'W':
      swap(value[0], value[2]);
      swap(value[2], value[5]);
      swap(value[5], value[3]);
      break;
    }
  }
  int right(int top, int front) {
    int top_idx, front_idx;
    for (int i=0;i<6;i++)
      for (int j=0;j<6;j++)
        if (i != j && value[i] == top && value[j] == front) {
          top_idx = i;
          front_idx = j;
        }
    switch (top_idx) {
    case 0:
      switch (front_idx) {
      case 1: return value[2]; break;
      case 2: return value[4]; break;
      case 4: return value[3]; break;
      case 3: return value[1]; break;
      }
      break;
    case 1:
      switch (front_idx) {
      case 0: return value[3]; break;
      case 3: return value[5]; break;
      case 5: return value[2]; break;
      case 2: return value[0]; break;
      }
      break;
    case 2:
      switch (front_idx) {
      case 0: return value[1]; break;
      case 1: return value[5]; break;
      case 5: return value[4]; break;
      case 4: return value[0]; break;
      }
      break;
    case 3:
      switch (front_idx) {
      case 0: return value[4]; break;
      case 4: return value[5]; break;
      case 5: return value[1]; break;
      case 1: return value[0]; break;
      }
      break;
    case 4:
      switch (front_idx) {
      case 0: return value[2]; break;
      case 2: return value[5]; break;
      case 5: return value[3]; break;
      case 3: return value[0]; break;
      }
      break;
    case 5:
      switch (front_idx) {
      case 1: return value[3]; break;
      case 3: return value[4]; break;
      case 4: return value[2]; break;
      case 2: return value[1]; break;
      }
      break;
  }
  }
};

int main() {
  Dice dice;
  int q;
  for (int i=0;i<6;i++)
    cin >> dice.value[i];
  cin >> q;
  for (int i=0;i<q;i++) {
    int top, front;
    cin >> top >> front;
    cout << dice.right(top, front) << endl;
  }
}



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

//?????????
#define FOR(i, a, b) for(int i = (a); i < (b), i++)
#define REP(i, n) FOR(i, 0, n);
#define ALL(a) (a).begin(),(a).end()

// 0-1???????????¶????????????
// dp???????????????
// dp[i][j] : i??????(-1??????????????????)?????§?????????????????????????????????????¶????????????????????????????????????????????????????????????§???

// ??¶?´? 1 <= n <= 100
// weight[i], value[i]?????´??°
// 1 <= weight[i], value[i] <= 1000
// 1 <= W <= 10000


int main(){
    
    //??\???
    int n, w; cin >> n >> w;
    vector<int> weight(n);
    vector<int> value(n);
    vector<vector<int> > dp(n, vector<int> (w + 1, 0));
    for(int i = 0; i < n; i++) cin >> value[i] >> weight[i];

    //dp
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            if(i == 0){
                if(j >= weight[i]) dp[i][j] = value[i];
            }else{
                if(j >= weight[i]) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weight[i]] + value[i]);
                else dp[i][j] = dp[i - 1][j];
            }
        }
    }

    /*for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/

    cout << dp[n - 1][w] << endl;

    return 0;
}

Measured memory_bytes: 6772
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n, h;cin>>n>>h;
  vector<int> b(n);
  int a=-1;
  rep(i, n){
    int t;
  	cin>>t>>b[i];
    a=max(a, t);
  }
  sort(b.begin(), b.end(), greater<int>());
  int ans=0, sum=0;
  rep(i, n){
    if(b[i]<a)break;
  	sum+=b[i];ans++;
    if(sum>=h)break;
  }
  if(sum<h){
  	ans+=(h-sum)/a;
    if((h-sum)%a!=0)ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

void solve(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        a[tmp-1] = i+1;
    }

    for(int i = 0; i < n; i++){
        cout << a[i] << " ";
    }
    cout << endl;

}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <memory>
#include <string>
#include <vector>

struct node {
  int key;
  std::weak_ptr<node> parent;
  std::shared_ptr<node> left;
  std::shared_ptr<node> right;
  node(int k) : key(k), left(nullptr), right(nullptr) {};
};

class bst {
private:
  std::shared_ptr<node> root;
  void r_inorder(std::shared_ptr<node> n);
  void r_preorder(std::shared_ptr<node> n);
public:
  bst() : root(nullptr) {};
  void insert(int v);
  bool find(int k);
  void delete_(int k);
  void print();
};

void bst::insert(int k) {
  std::shared_ptr<node> y = nullptr;
  std::shared_ptr<node> x = root;
  std::shared_ptr<node> z(new node(k));
  while (x != nullptr) {
    y = x;
    if (z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;
  if (y == nullptr)
    root = z;
  else if (z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

bool bst::find(int k) {
  std::shared_ptr<node> n = root;
  while (n != nullptr) {
    if (n->key == k)
      return true;
    if (n->key > k)
      n = n->left;
    else
      n = n->right;
  }
  return false;
}

void bst::delete_(int k) {
  std::shared_ptr<node> n = root;
  while (n != nullptr) {
    if (n->key == k)
      break;
    if (n->key > k)
      n = n->left;
    else
      n = n->right;
  }
  if (n == nullptr)
    return;
  if (n->left == nullptr && n->right == nullptr) {
    auto p = n->parent.lock();
    if (p->left != nullptr && p->left->key == k) {
      p->left = nullptr;
    } else {
      p->right = nullptr;
    }
  }
  else if(n->left != nullptr && n->right != nullptr) {
    auto next = n->right;
    while (next->left != nullptr)
      next = next->left;
    int tmp = next->key;
    delete_(tmp);
    n->key = tmp;
  }
  else {
    auto p = n->parent.lock();
     if (p->left != nullptr && p->left->key == k) {
       p->left = (n->left != nullptr) ? n->left : n->right;
       p->left->parent = p;
    } else {
       p->right = (n->left != nullptr) ? n->left : n->right;
       p->right->parent = p;
    }
  }
}

void bst::r_inorder(std::shared_ptr<node> n) {
  if (n == nullptr)
    return;
  r_inorder(n->left);
  std::cout << " " << n->key;
  r_inorder(n->right);
}

void bst::r_preorder(std::shared_ptr<node> n) {
  if (n == nullptr)
    return;
  std::cout << " " << n->key;
  r_preorder(n->left);
  r_preorder(n->right);
}

void bst::print() {
  r_inorder(root);
  std::cout << std::endl;
  r_preorder(root);
  std::cout << std::endl;
}

int main() {
  int n;
  std::cin >> n;
  bst tree;
  for (int i = 0; i < n; ++i) {
    std::string str;
    std::cin >> str;
    int k;
    switch (str[0]) {
    case 'i':
      std::cin >> k;
      tree.insert(k);
      break;
    case 'f':
      std::cin >> k;
      std::cout << (tree.find(k) ? "yes" : "no") << std::endl;
      break;
    case 'd':
      std::cin >> k;
      tree.delete_(k);
      break;
    case 'p':
      tree.print();
      break;
    default:
      break;
    }
  }
}

Measured memory_bytes: 40528
#include <stdio.h>
int main(void)
{
    int A,B,C,D;
    int flag=0;
    scanf("%d%d%d%d",&A,&B,&C,&D);
    
    while(1){
        C-=B;
        if(C<=0){
            flag=1;
            break;
        }
        
        A-=D;
        if(A<=0){
            flag=2;
            break;
        }
    }
    
    if(flag==1)
        printf("Yes\n");
    else
        printf("No\n");
        
    
    return 0;
}

Measured memory_bytes: 1560
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
int main(){
ll n;
string s;
cin >>n>>s;
ll max=0;
for(ll i=1;i<n-1;i++){
ll a[26],b[26];
for(ll x=0;x<26;x++){
a[x]=0;
b[x]=0;
}
for(ll j=0;j<i;j++){
a[s[j]-'a']=1;
}
for(ll j=i;j<n;j++){
b[s[j]-'a']=1;
}
ll count=0;
for(ll x=0;x<26;x++){
if(a[x]==1&&b[x]==1)
count++;
}
if(max<count)
max=count;

}
cout<<max;
return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import sys
from math import ceil

_HO = 10**12 + 1

def binary_search(lo=0,ho=_HO):
    if ho-lo==1: return lo

    mid = lo + (ho-lo-1)//2
    if check(mid):
        return binary_search(lo=lo,ho=mid+1)
    else:
        return binary_search(lo=mid+1,ho=ho)

def check(x):
    global k, a, f

    s = 0
    for ai, fi in zip(a,f):
        af = ai * fi
        if af<=x: continue
        s += ceil((af-x)/fi)
        if s>k: return False
    #
    return True

n,k = [ int(x) for x in sys.stdin.readline().strip().split() ]
a = [ int(x) for x in sys.stdin.readline().strip().split() ]
f = [ int(x) for x in sys.stdin.readline().strip().split() ]

a.sort()
f.sort(reverse=True)

print(binary_search())


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

using namespace std;

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

  for (int i = 0; i < N; i++) {
    cout << A[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 1152
import numpy as np

def check4adjacent(N, a):
    a = np.array(map(int, a))
    count_4multiples = len(np.where(a % 4 == 0)[0])
    count_2multiples = len(np.where((a % 2 == 0) & (a % 4 != 0))[0])
    count_else = N - (count_4multiples + count_2multiples)
    if count_2multiples % 2 == 0:
        flag = 1
    else:
        flag = 0

    if (count_4multiples + flag >= count_else ):
        return "Yes"
    else:
        return "No"



if __name__ == "__main__":
    N = int(raw_input())
    a = raw_input().split()
    print(check4adjacent(N, a))

Measured memory_bytes: 20324
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
typedef pair<int,int> iP;
int power(int x,int y){
    int res=1;
    x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        x=(x*x)%mod;
        y/=2;
    }
    return res;
}
int mulmod(int a,int b){ 
    int res=0;
    a=a%mod; 
    while(b>0){
        if(b%2==1) 
        res=(res+a)%mod; 
        a=(a*2)%mod; 
        b/=2;
    } 
    return res%mod; 
}
vector<int> pr;
void sieve() { 
    bool prime[1000000+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p<=1000000; p++) {
        if (prime[p] == true) {  
        pr.push_back(p);
            for (int i=p*p; i<=1000000; i += p) 
                prime[i] = false; 
        } 
    }
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;
    int n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;
    string str;
    cin>>str;
    string tmp;
    int sc=0;
    for(int i=0;i<k;i++){
        if(str[i]=='r')sc+=p;
        if(str[i]=='s')sc+=r;
        if(str[i]=='p')sc+=s;
        tmp.push_back(str[i]);
    }
    for(int i=k;i<n;i++){
        if(str[i]==tmp[i%k])
        tmp[i%k]='z';
        else{
            tmp[i%k]=str[i];
        if(str[i]=='r')sc+=p;
        if(str[i]=='s')sc+=r;
        if(str[i]=='p')sc+=s;
        }
    }
    cout<<sc;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int k; cin >> k;
    int now=7%k;
    int ans=1;
    map<int,int> res;
    for(;;){
        if(res[now]!=0){
            cout << -1 << endl;
            return 0;
        }
        if(now==0){
            cout << ans << endl;
            return 0;
        }
        ans++;
        res[now]++;
        now=(10*now+7)%k;
    }
return 0;
}

Measured memory_bytes: 50412
#include<iostream>
using namespace std;
int main() {
  string S;
  cin >> S;
  
  if (S == "hi") {
    cout << "Yes" << endl;
  }
  
  else if (S == "hihi") {
    cout << "Yes" << endl;
  }
  
  else if (S == "hihihi") {
    cout << "Yes" << endl;
  }
  
  else if (S == "hihihihi") {
    cout << "Yes" << endl;
  }
  
  else if (S == "hihihihihi") {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  

}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
int main() {
	int N;
	cin >> N;
	int now_t = 0, now_x = 0, now_y = 0;
	for (int i = 0; i < N; i++) {
		int nxt_t, nxt_x, nxt_y;
		cin >> nxt_t >> nxt_x >> nxt_y;
		int d = abs(now_x - nxt_x) + abs(now_y - nxt_y);
		if (d > nxt_t - now_t || (nxt_t - now_t - d) % 2) {
			cout << "No" << endl;;
			return 0;
		}
		now_t = nxt_t;
		now_x = nxt_x;
		now_y = nxt_y;
	}
	cout << "Yes" << endl;
}

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

#define REP(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(x) begin(x), end(x)
vector<string> field,squ;
int check(int x,int y){
  for(int i =0 ;i < 2;i++){
	for(int j = 0;j < 2;j++){
	  if(field[y+i][x+j] != squ[i][j])return 0;
	}
  }
  return 1;
}
int main(){
  int n,m;
  cin >> m >> n;
  field = vector<string>(m);
  for(int i = 0;i < m;i++){
	cin >> field[i];
  }
  squ = vector<string>(2);
  for(int i = 0;i < 2;i++){
	cin >> squ[i];
  }
  vector<vector<int> > cnt(m,vector<int>(n,0));
  int sum = 0;
  for(int i = 0;i < m-1;i++){
	for(int j = 0;j < n-1;j++){
	  if(check(j,i)){
		cnt[i][j] = 1;
		sum++;
	  }
	}
  }

  int ans = sum;
  string str = "JOI";
  int dx[] = {-1,1,1,-1};
  int dy[] = {-1,-1,1,1};
  int dxx[] = {-1,0,0,-1};
  int dyy[] = {-1,-1,0,0};
  for(int i = 0;i < m;i++){
	for(int j = 0;j < n;j++){
	  char keep = field[i][j];
	  for(int l = 0;l < str.size();l++){
		field[i][j] = str[l];
		int tmp = 0;
		for(int k = 0;k < 4;k++){
		  if(i+dy[k] >= m || i+dy[k] < 0 || j+dx[k] >= n || j+dx[k] < 0)continue;
		  int res = check(j+dxx[k],i+dyy[k]);
		  tmp+=res - cnt[i+dyy[k]][j+dxx[k]];
		}
		ans = max(ans,tmp+sum);
	  }
	  field[i][j] = keep;
	}
  }
  cout << ans << endl;
  return 0;
}

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

void seqm(int K, vector<int>& V)
{
  int N = (int)V.size()-1;
  while(!V[N]) --N; 
  V[N]--; if(V[N] == 0) return;
  for(int i=N+1; i<(int)V.size(); ++i)
    V[i] = K;
  return;
}
int main()
{
  int K, N; scanf("%d%d", &K, &N);
  if(K==1)
  {
    for(int i=0; i<(N+1)/2; ++i)
      printf("1 ");
    puts("");
    return 0;
  }
  if(K%2==0)
  {
    printf("%d", K/2);
    for(int i=0; i<N-1; ++i) printf(" %d", K);
    puts("");
    return 0;
  }
  vector<int> seq(N, (K+1)/2);
  for(int i=0; i<N/2; ++i) seqm(K, seq);
  for(auto x: seq)
  {
    if(!x)
    {
      puts(""); return 0;
    }
    printf("%d ", x);
  }
  puts("");
  return 0;
}

Measured memory_bytes: 3456
mod = 10**9+7
N, M = map(int, input().split())
A_ = [int(input()) for _ in range(M)]
A = [0] * (N+1)
for a in A_:
    A[a] = 1
dp = [0] * (N+3)
dp[0] = 1
for i in range(1, N+1):
    if A[i-1] == 0:
        dp[i] += dp[i-1]
    if A[i-2] == 0:
        dp[i] += dp[i-2]
    dp[i] %= mod
print(dp[N])


Measured memory_bytes: 9612
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int N = s.length();
    int cIdx = -1;
    for (int i = 0; i < N; i++) {
      if (s.charAt(i) == 'C') {
        cIdx = i;
        break;
      }
    }
    if (cIdx == -1) {
      System.out.println("No");
      return;
    }
    for (int i = cIdx; i < N; i++) {
      if (s.charAt(i) == 'F') {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 21844
N,K = map(int, input().split())
lis = list(map(int, input().split()))
lis_cost = [-1]*N
lis_root = [1]

s = 1
cost = -1
while True:
    g = lis[s-1]
    cost += 1
    if lis_cost[s-1] == -1:
        lis_cost[s-1] = cost
        s = g
        lis_root.append(g)
    else:
        break
    #print(lis_cost)
    
#print(cost,s) # cost回目のジャンプでs番目に着いた

cost_loop = cost-lis_cost[s-1]
cost_prev = lis_cost[s-1]
lis_root_loop = lis_root[cost_prev:-1]
lis_root_prev = lis_root[:cost_prev]
#print(cost_loop,cost_prev,lis_root_prev)

if cost_prev <= K:
    q = (K-cost_prev+1)%len(lis_root_loop)
    print(lis_root_loop[q-1])
else:
    print(lis_root_prev[K])

Measured memory_bytes: 32368
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std ;

int countFreq(string &pat, string &txt)
{
    int M = pat.length();
    int N = txt.length();
    int res = 0;

    /* A loop to slide pat[] one by one */
    for (int i = 0; i <= N - M; i++)
    {
        /* For current index i, check for
           pattern match */
        int j;
        for (j = 0; j < M; j++)
            if (txt[i+j] != pat[j])
                break;

        // if pat[0...M-1] = txt[i, i+1, ...i+M-1]
        if (j == M)
        {
           res++;
           j = 0;
        }
    }
    return res;
}

int main() {
    int n ; scanf("%d", &n) ;
    string s , pat = "ABC" ; cin >> s ;
    printf("%d\n", countFreq(pat, s)) ;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =  998244353;
const int INV2 = (MOD+1)/2;
vector<pair<int,pair<int,int>>> hen[10];
int x[10]={},m,n;
int dfs(int a){
  if(a>=n)return 0;
  int ans=0,ans2=0;
  for(auto&& i:hen[a]){
    if(x[a]-x[i.first]==i.second.first)ans+=i.second.second;
  }
  if(a==n-1)return ans;
  for(int i=x[a];i<=m;i++){
    x[a+1]=i;
    ans2=max(ans2,dfs(a+1));
  }
  return ans+ans2;
}


     signed main(){
       
       int q,ans=0;
       cin>>n>>m>>q;
       int a,b,c,d;
       for(int i=0;i<q;i++){
         cin>>a>>b>>c>>d;a--;b--;
        hen[b].push_back(make_pair(a,make_pair(c,d)));
       }
       x[0]=1;
       cout<<dfs(0)<<endl;




        





}


        


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<int> L(n);
    rep(i,n) cin >> L[i];
    int ans=0;
    sort(L.begin(),L.end());
    rep(b,n)rep(a,b){
        int ab = L[a] + L[b];
        int r = lower_bound(L.begin(),L.end(),ab) - L.begin();
        int l = b+1;
        ans += r-l;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>A(N);
    vector<int>B(N);
    vector<int>C(N-1);
    for(int i;i<N;i++){
        cin>>A[i];
        --A[i]; //1<N<20
    }
    for(int j;j<N;j++){
        cin>>B[j];
    }
    for(int k;k<N;k++){
        cin>>C[k];
}
int ans =0;
for (int i=0;i<N;i++){
    ans +=B[A[i]];
    if(0<i&&A[i]==A[i-1]+1){
        ans +=C[A[i-1]];
    }
}
cout<<ans<<endl;
}

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 998244353 
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_backP
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;

	int n,k = inf,ans = 0;
	cin>>n;

	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
		k = min(arr[i],k);

		if(arr[i]<=k)
			ans++;
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 1024
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  
  ll lcm_me=c*d/__gcd(c,d);
  ll ac=(a-1)/c;
  ll ad=(a-1)/d;
  ll alcm=(a-1)/lcm_me;
  ll bc=b/c;
  ll bd=b/d;
  ll blcm=b/lcm_me;

  
  cout<<(b-a+1)-(bc-ac)-(bd-ad)+(blcm-alcm)<<endl;
}


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

int main(){
	string s;
	for(;getline(cin,s),s!="END OF INPUT";){
		int n=0,i;
		for(i=0;i<s.size();i++){
			(i==s.size()-1)?
				cout<<n+1<<endl,0
			:
				(s[i]==' ')?
					(cout<<n),n=0
				:
					n++;
		}
	}
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main (){
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    for(int j=i+1;j<s.size();j++){
      if(s[i]==s[j]){
        cout << "no" << endl;
        i=s.size();
        break;
      }
    }
  if(i==s.size()-1) cout << "yes" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[4][4],n;
	bool m[4][4];
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			cin>>a[i][j];
			m[i][j]=false;
		}
	}
	cin>>n;
	int f[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>f[i];
	}
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			for(int k=1;k<=n;k++)
			{
				if(a[i][j]==f[k])
				{
					m[i][j]=true;
					break;
				}
			}
		}
	}
	for(int i=1;i<=3;i++)
	{
		if(m[i][1]&&m[i][2]&&m[i][3])
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		else if(m[1][i]&&m[2][i]&&m[3][i])
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	if(m[1][1]&&m[2][2]&&m[3][3])
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	else if(m[1][3]&&m[2][2]&&m[3][1])
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
#include <stdlib.h>
#include <math.h>
#include <string.h>
long long max(long long, long long);
int main(){
	long long N, A, B, C, D;
	int t=0;
	scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);
	long long n=N-1;
	long long s=max(A-B, B-A);
	double a;
	double s1, n1, c1, d1, p, q;
	s1=s;
	n1=n;
	c1=C;
	d1=D;
	p=(s1+n1*c1)/(c1+d1);
	q=(s1+n1*d1)/(c1+d1);
	for(a=0;a<=n;a++){
		if(a>=p&&a<=q) t=1;
	}
	if(t==0) printf("NO");
	if(t==1) printf("YES");
	return 0;
}
long long max(long long a, long long b){
	if(a>=b) return a;
	return b;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef struct pair<int,int> P;
typedef long long ll;

ll n,k,l;

int dp1[16002][3]={};
int dp2[16002][3]={};
ll c[200001]={};
int main() {
	string s;
	cin>>s;
	int x,y;
	cin>>x>>y;
	queue<P> que1,que2;
	que1.push(P(0,1));
	int flgd=0;//0=x,1=y
	bool flgx=false;
	bool flgy=false;

	for(int i=0;i<s.length();++i){
		if((s[i]=='F')&&(flgd==0)){
			while(que1.size()){
				P p1=que1.front();que1.pop();
				int pos=p1.first;
				int d1=p1.second;
				if(dp1[pos+8000][d1+1]>=(i+1))continue;
				dp1[pos+8000][d1+1]=i+1;
				que2.push(P(pos+d1,d1));
			}
			while(que2.size()){
				P p2=que2.front();que2.pop();
				que1.push(p2);
			}
		}
		if(s[i]=='T'){
			if(flgd==1){
				flgd=0;
				while(que1.size()){
					P p1=que1.front();que1.pop();
					int pos=p1.first;
					int d1=p1.second;
					if(dp1[pos+8000][d1+1]>=(i+1))continue;
					dp1[pos+8000][d1+1]=i+1;
					que2.push(P(pos,1));
					que2.push(P(pos,-1));
				}
				while(que2.size()){
					P p2=que2.front();que2.pop();
					que1.push(p2);
				}
			}else{
				flgd=1;
			}
		}
	}
	while(que1.size()){
		P p1=que1.front();que1.pop();
		int pos=p1.first;
		if(pos==x)flgx=true;
	}
	if(flgx==false){
		cout<<"No"<<endl;
		return 0;
	}

	que1.push(P(0,1));
	flgd=0;
	for(int i=0;i<s.size();++i){
		if((s[i]=='F')&&(flgd==1)){
			while(que1.size()){
				P p1=que1.front();que1.pop();
				int pos=p1.first;
				int d1=p1.second;
				if(dp2[pos+8000][d1+1]>=i+1)continue;
				dp2[pos+8000][d1+1]=i+1;
				que2.push(P(pos+d1,d1));
			}
			while(que2.size()){
				P p2=que2.front();que2.pop();
				que1.push(p2);
			}
		}
		if(s[i]=='T'){
			if(flgd==0){
				flgd=1;
				while(que1.size()){
					P p1=que1.front();que1.pop();
					int pos=p1.first;
					int d1=p1.second;
					if(dp2[pos+8000][d1+1]>=i+1)continue;
					dp2[pos+8000][d1+1]=i+1;
					que2.push(P(pos,1));
					que2.push(P(pos,-1));
				}
				while(que2.size()){
					P p2=que2.front();que2.pop();
					que1.push(p2);
				}
			}else{
				flgd=0;
			}
		}
	}

	while(que1.size()){
		P p1=que1.front();que1.pop();
		int pos=p1.first;
		if(pos==y)flgy=true;
	}
	if(flgy==false){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
int main(){
	int n;
	string s;
	int k;
	cin>>n>>s>>k;
	for(int i=0;i<n;i++){
		if(s[i]!=s[k-1]){
			cout<<"*";
		}else{
			cout<<s[i];
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
s = list(map(int, input().split()))
kekka = 0

for i in range(N):
    if s[i]%2 == 0:
        if s[i]%3 != 0 and s[i]%5 != 0:
            kekka =1

if kekka == 0:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

const int INF = 100000000;

int
main(int argc, char **argv)
{
	const int c[8] = { 4, 1, 4, 1, 2, 1, 2, 1};
	int i, j;

	while (true)
	{
		int p[8];
		for (i = 0; i < 8; ++i)
		{
			if (scanf("%d", &p[i]) == EOF)
				goto l_end;
		}

		int min = INF;
		int vmin = INF;
		for (i = 0; i < 8; ++i)
		{
			int t = 0;
			for (j = 0; j < 8; ++j)
			{
				if (p[j] > c[(j + i) % 8])
					t += p[j] - c[(j + i) % 8];
			}

			if (t <= min)
			{
				int v = 0;
				for (j = 0; j < 8; ++j)
					v = 10 * v + c[(j + i) % 8];

				if (t < min || v < vmin)
				{
					min = t;
					vmin = v;
				}
			}
		}

		int ans[8];
		for (i = 7; i >= 0; --i)
		{
			ans[i] = vmin % 10;
			vmin /= 10;
		}

		for (i = 0; i < 8; ++i)
			printf("%d%c", ans[i], i < 7 ? ' ' : '\n');
	}

l_end:
	return 0;
}

Measured memory_bytes: 600
# -*- coding: utf-8 -*-
"""
A - Christmas Eve Eve Eve
https://atcoder.jp/contests/abc115/tasks/abc115_a

"""
import sys


def solve(D):
    ans = ['Christmas'] + ['Eve'] * (25-D)
    return ' '.join(ans)


def main(args):
    D = int(input())
    ans = solve(D)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<map>
#include<set>
#include<queue>
#include <algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
#define forz(i,a,b) for(int i=(a);i<=(b);i++)
#define forf(i,a,b) for(int i=(a);i>=(b);i--)
#define mems(x,v) memset(x,v,sizeof(x))
using namespace std;
int n,i,j,q,f,F,x,numb,numc;
char a[105000],b[205000],c[205000],t;
int main()
{
scanf("%s",a);
scanf("%d",&q);
F=1;
numb=numc=0;
while(q--)
{
    scanf("%d",&f);
    if(f==1)F=F*-1;
    else
    {
        scanf("%d %c",&x,&t);
        if(x==2)x=-1;
        if(x*F==1)
        {
            numb++;
            b[numb]=t;
        }
        else
        {
            numc++;
            c[numc]=t;
        }
    }
}
if(F==1)
{
    for(i=numb;i>=1;i--)printf("%c",b[i]);
    printf("%s",a);
    for(i=1;i<=numc;i++)printf("%c",c[i]);
}
else
{
    for(i=numc;i>=1;i--)printf("%c",c[i]);
    for(i=strlen(a)-1;i>=0;i--)printf("%c",a[i]);
    for(i=1;i<=numb;i++)printf("%c",b[i]);
}
return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;



int main() {
	int N, W, H; cin >> N >> W >> H;
	vector<int>ys(H+1);
	vector<int>xs(W+1);
	for (int i = 0; i < N; ++i) {
		int x, y, w; cin >> x >> y >> w;
		ys[max(0, y - w)]++;
		ys[min(H, y + w)]--;
		xs[max(0, x - w)]++;
		xs[min(W, x + w)]--;

	}
	int sum = 0;
	bool ok = true;
	for (int i = 0; i < W; ++i) {
		sum += xs[i];
		if (!sum) {
			ok = false;
			break;
		}
	}
	if (!ok) {
		ok = true;
		sum = 0;
		for (int i = 0; i < H; ++i) {
			sum += ys[i];
			if (!sum) {
				ok = false;
				break;
			}
		}
	}
	
	if (ok) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct BIT {
  vector<vector<int>> data;
  int h, w;
  BIT(int h, int w):data(h+1, vector<int>(w+1)), h(h), w(w){}
  void add(int y, int x, int a) {
    for(int i = y; i <= h; i += i & -i) {
      for(int j = x; j <= w; j += j & -j) {
	data[i][j] += a;
      }
    }
  }
  int sum(int y, int x) {
    int res = 0;
    for(int i = y; i > 0; i -= i & -i) {
      for(int j = x; j > 0; j -= j & -j) {
	res += data[i][j];
      }
    }
    return res;
  }
  int sum(int sy, int sx, int ty, int tx) {
    if(sy > ty || sx > tx) return 0;
    return sum(ty, tx) - sum(sy-1, tx) - sum(ty, sx-1) + sum(sy-1, sx-1);
  }
};


signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, k;
  cin >> n >> k;
  vint x(n), y(n);
  vector<char> c(n);
  rep(i, n) {
    cin >> x[i] >> y[i] >> c[i];
  }
  int k2 = 2*k;
  vector<BIT> bit(2, BIT(k2, k2));
  rep(i, n) {
    bit[c[i]=='W'].add(y[i]%k2+1, x[i]%k2+1, 1);
  }
  int ans = 0;
  reps(i, 1, k+1) {
    reps(j, 1, k+1) {
      int w = bit[0].sum(1, 1, k2, k2);
      int d = bit[0].sum(1, 1, i-1, j-1);
      int e = bit[0].sum(i, j, i+k-1, j+k-1);
      int f = bit[0].sum(i+k, j+k, k2, k2);
      int g = bit[0].sum(i+k, 1, k2, j-1);
      int h = bit[0].sum(1, j+k, i-1, k2);
      int W = d+e+f+g+h;

      int b = bit[1].sum(1, 1, k2, k2);
      int D = bit[1].sum(1, 1, i-1, j-1);
      int E = bit[1].sum(i, j, i+k-1, j+k-1);
      int F = bit[1].sum(i+k, j+k, k2, k2);
      int G = bit[1].sum(i+k, 1, k2, j-1);
      int H = bit[1].sum(1, j+k, i-1, k2);
      int B = D+E+F+G+H;

      chmax(ans, max(W+b-B, w-W+B));
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 96000
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int k;
    cin >> k;
    rep(_,k) cout << "ACL";
    cout << endl;
    return 0;
}




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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  (s[2] == s[3] && s[4] == s[5]) ? cout << "Yes\n" : cout << "No\n";
return 0;
}


Measured memory_bytes: 256
-- Try AtCoder
-- author: Leonardone @ NEETSDKASU

main = print . solve =<< getLine

solve xs = solveX 0 0 xs where
    solveX tc sc ('S':ss) = solveX tc (sc + 1) ss
    solveX tc  0 ('T':ss) = solveX (tc + 1) 0 ss
    solveX tc sc ('T':ss) = solveX tc (sc - 1) ss
    solveX tc sc [] = tc + sc

Measured memory_bytes: 9468
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll,ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int m,k; cin >> m >> k;
    int f=(int)pow(2,m)-1;
    if(f<k){
        cout << -1 << endl;
        return 0;
    }
    if(m==1 && k==1){
        cout << -1 << endl;
        return 0;
    }
    int f2=f;
    f++;
    f*=2;
    if(k==0){
        rep(i,f2+1){
            printf("%d ",i);
            printf("%d ",i);
        }
        return 0;
    }

    int now=0;
    rep(i,f/2){
        if(k!=now){
            printf("%d ",now);
            now++;
            continue;
        }
        now++;
    }
    now--;
    printf("%d ",k);
    rep(i,f/2){
        if(k!=now){
            printf("%d ",now);
            now--;
            continue;
        }
        now--;
    }
    printf("%d ",k);
return 0;
}



Measured memory_bytes: 1792
def main():
    r, g, b, n = map(int, input().split())

    cnt = 0
    for i in range(int(n//r)+1):
        r_num = r * i
        for j in range(int((n - r_num)//g)+1):
            g_num = g * j
            b_num = (n - r_num - g_num)
            if b_num >= 0 and b_num % b == 0:
                cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

int main() {
    int N;
    std::cin >> N;
    std::vector<char> Sn;
    for (int i = 0; i < N; ++i) {
        char S;
        std::cin >> S;
        Sn.push_back(S);
    }
    std::sort(Sn.begin(), Sn.end());
    Sn.erase(std::unique(Sn.begin(), Sn.end()), Sn.end());
    std::cout << (Sn.size() == 4 ? "Four" : "Three") << std::endl;
    return 0;
}


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,h) for(int i=0;i<h;i++)
 
int main(void) {
  long long int h,n,tmp;
  cin >> h >> n;
  
  vector<long long int> data;
  
  rep(i,h){
    cin >> tmp;
    data.push_back(tmp);
  }
  
  sort(data.begin(), data.end());
  
  long long int total = 0;
  for(int i=0;i<h-n;i++){
    total = total + data[i];
  }
    
  cout << total << endl;
  
  return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

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

using namespace std;

typedef long long int lli;

int main () {
    string S;
    cin >> S;
    int c[26] = {0};
    REP (i, 0, S.size()) {
        c[S[i] - 'a']++;
    }
    int ans = 1000;
    REP (i, 0, 26) {
        string s = S;
        if (c[i] == s.size()) {
            ans = 0;
            break;
        }
        if (c[i]) {
            int temp = 0;
            REP (t, 0, 110) {
                string ss = "";
                REP (j, 0, s.size() - 1) {
                    if (s[j] == 'a' + i || s[j + 1] == 'a' + i) {
                        ss += 'a' + i;
                    } else {
                        ss += '?';
                    }
                }
                s = ss;
                bool run = true;
                REP (k, 0, ss.size()) {
                    if (ss[k] != ('a' + i)) run = false;
                }
                if (run) {
                    temp = t + 1;
                    break;
                }
            }
            ans = min(ans, temp);
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const ll INF = (ll) 1e16 + 7;

int main(int argc, char *argv[])
{
	ll a, b, n;
	sf("%lld %lld %lld", &a, &b, &n);

	ll l = 0, r = n;
	ll ans = LONG_MIN;
	while (l <= r) {
		ll mid = (l + r) / 2;
		ll x = (a * mid) / b - a * (mid / b);
		if (x >= ans) {
			ans = x;
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}

	printf("%lld", ans);

	return 0;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, c, k;
  cin >> n >> c >> k;
  vector<int> t(n);
  rep(i, n) cin >> t.at(i);
  sort(t.begin(), t.end());
  int res = 0;
  int cur = 0;
  while (cur < n) {
    int next = cur + 1;
    for (int i = 1; i < c && (cur + i < n); i++) {
      if (t.at(cur + i) <= t.at(cur) + k) {
        next++;
        continue;
      }
    }
    res++;
    cur = next;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3788
#include <stdio.h>
int main(void) {

	int N, K, Q;
	int A[100000];
	int B[100000];
	int a = 0;
	scanf("%d%d%d", &N, &K, &Q);
	for (int i = 0;i < N;i++) {
		B[i] = K;
	}
	for (int i = 0;i < Q;i++) {
		scanf("%d", &A[i]);
		a = A[i];
		B[a-1] += 1;
	}

	for (int i = 0;i < N;i++) {
		B[i] -= Q;
		
	}
	


for (int i = 0;i < N;i++) {
		if (B[i] <= 0) {
			printf("No\n");
		}
		else {
			printf("Yes\n");
		}
	}
	





	return 0;
}

Measured memory_bytes: 1280
int main()
{
	long n;
	long cnt = 0;
	

	scanf("%ld", &n);

	//printf("%ld\n",n);
	if (n % 2 == 1) {
		cnt = 0;
	}
	else {
		if (n > 0) {
			cnt += n / 10;
			n /= 10;
		}

		while (n > 0) {
			
			cnt += n / 5;
			n /= 5;
		}
	}
	

	printf("%ld", cnt);
	
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 1000000001
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

bool paircomp(const P& a, const P& b){
  return (a.first < b.first);
}

int main(){
  int N, Q, S,T,X,si,ti,di;
  cin >> N >> Q;
  vector<P> sv(N+1);
  vector<P> tv(N+1);
  vector<int> dv(Q);
  set<int> st;
  REP(i,N){
    cin >> S >> T >> X;
    sv[i] = make_pair(S-X,X);
    tv[i] = make_pair(T-X,X);
  }
  sv[N] = make_pair(INF,INF);
  tv[N] = make_pair(INF,INF);
  REP(i,Q){
    cin >> dv[i];
  }
  
  sort(sv.begin(),sv.end(),paircomp);
  sort(tv.begin(),tv.end(),paircomp);
  si = ti = di = 0;
  bool sf,tf,df;
  sf = tf = df = true;
  REP(i,2*N+Q){
    if((sv[si].first < tv[ti].first) && (sv[si].first <= dv[di]) && (si < N)){
      st.insert(sv[si].second);
      si++;
    }
    else if((tv[ti].first <= dv[di]) && (ti < N)){
      st.erase(tv[ti].second);
      ti++;
    }
    else if(di < Q){
      if(st.empty()) cout << -1 << endl;
      else cout << *(st.lower_bound(0)) << endl;
      di++;
    }
  }

  return 0;
}

Measured memory_bytes: 14592
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Long n = sc.nextLong();
		Long kaijo = 1L;
		long p = 1000000007;
		for(int i=2; i<=n; i++){
			kaijo *= i;
          	kaijo = kaijo % p;
		}
		System.out.println(kaijo);
	}
}

Measured memory_bytes: 25300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC129_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string[] s = a.Split();
            int P = int.Parse(s[0]);
            int Q = int.Parse(s[1]);
            int R = int.Parse(s[2]);
            int X = P + Q;
            int Y = P + R;
            int Z = Q + R;
            if (X <= Y && X <= Z)
                Console.WriteLine(X);
            else if (Y <= X && Y <= Z)
                Console.WriteLine(Y);
            else
                Console.WriteLine(Z);
        }
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int a,b,c;
int main()
{
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    if (a == b && b != c) CO("Yes");
    else if  (b == c && c != a) CO("Yes");
    else if  (c == a && a != b) CO("Yes");
    else CO("No");
    return 0;
}

Measured memory_bytes: 256
import sys
import heapq


input = sys.stdin.readline

T = int(input())

def solve():
    N = int(input())
    ls = []
    rs = []
    heapq.heapify(ls)
    heapq.heapify(rs)
    for _ in range(N):
        k, l, r = map(int, input().split())
        if l - r >= 0:
            heapq.heappush(ls, (k, l, r))
        else:
            heapq.heappush(rs, (N-k, l, r))
    ans = 0
    ls_l = []
    heapq.heapify(ls_l)
    while len(ls) != 0:
        k, l, r = heapq.heappop(ls)
        heapq.heappush(ls_l, (l-r))
        ans += r
        while len(ls_l) > k:
            heapq.heappop(ls_l)
    rs_r = []
    heapq.heapify(rs_r)
    while len(rs) != 0:
        k, l, r = heapq.heappop(rs)
        heapq.heappush(rs_r, (r-l))
        ans += l
        while len(rs_r) > k:
            heapq.heappop(rs_r)
    while len(ls_l) != 0:
        ans += heapq.heappop(ls_l)
    while len(rs_r) != 0:
        ans += heapq.heappop(rs_r)
    print(ans)


for _ in range(T):
    solve()


Measured memory_bytes: 115872