akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	return (n + 9) / 10 * 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int A, B,i=1,count=0,K;
	cin >> A >> B >> K;
	vector <int> div(A + B);
		REP(i, min(A, B)) {
		if (A % i == 0 && B % i == 0) {
			div[count] = i;
			count++;
		}
	}
	cout << div[count-K];
}

Measured memory_bytes: 256
#include <stdio.h>

int egara(char c){
  if(c=='S')return 0;
  if(c=='H')return 1;
  if(c=='C')return 2;
  if(c=='D')return 3;
  return 0;
}
char Egara(int n){
  if(n==0)return 'S';
  if(n==1)return 'H';
  if(n==2)return 'C';
  if(n==3)return 'D';
  return 'S';
}
int main(){
  int n,a[4][13],i,j,m;
  char c,d;
  for(i=0; i<4; i++){
    for(j=0; j<13; j++){
      a[i][j]=1;
    }
  }
  scanf("%d\n",&n);
  for(i=0; i<n; i++){
    scanf("%c %d\n",&c,&m);
    a[egara(c)][m-1]=0;
  }
for(i=0; i<4; i++){
    for(j=0;j<13; j++){
      if(a[i][j])
      printf("%c %d\n",Egara(i),j+1);
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main(){
	char a = '0', b;
	int n, ans = 0;
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> b;
		if(b!=a){
			ans++;
			a = b;
		}
	}
	cout << ans;
	return 0;
}

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

//cmdで g++ test.cpp とするとコンパイルできる

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> l(N);
  for(int i=0;i<N;i++){
    cin>>l.at(i);
  }
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int ans=0;
  for(int i=0;i<K;i++){
    ans+=l.at(i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string x,y;
    int cnt=0;
    cin>>x>>y;
    for(int i=0;i<x.length();i++){
        if(x[i]!=y[i])
            cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3796
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()
for i in range(25):
    for j in range(25):
        if i*7 + j*4 == n:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 63212
import java.util.Scanner;


public class Main {

	public static void main(String[] args)  {

		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int ans = 0;
		while(k > 0) {
			
			if(a >0) {
				a--;
				ans++;
			}else if(b > 0) {
				b--;
			}else {
				ans--;
			}
			
			k--;
		}
		
		
		System.out.println(ans);
	 }

}


Measured memory_bytes: 27160
#include<stdio.h>
int main()
{
	int s(int);
	int a[1000];
	int i=0,p,m,n,t,k;
	for(p=3;p<110000;p+=2)if(s(p)&&s(p/2+1)){
		a[i]=p;
		i++;
	}

	scanf("%d",&t);
	while(t--)
	{
		k=0;
		scanf("%d%d",&m,&n);
		for(i=0;a[i]<=n;i++)if(a[i]>=m)k++;
		printf("%d\n",k);
	}
	return 0;
}
int s(int p)
{
	int i;
	for(i=2;i*i<=p;i++)if(p%i==0)return 0;
	return 1;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<climits>
#define ll long long int
using namespace std;
int main(void) {
  int n;
  vector<int> a;
  vector<ll> sum(200001);
  ll ans=LLONG_MAX;
  sum[0]=0;
  cin>>n;
  for(int i=1; i<=n; i++) {
    int x;
    cin>>x;
    a.push_back(x);
    sum[i]=sum[i-1]+x;
  }
  ll all=sum[n];
  for(int i=1; i<n; i++) {
    ans=min(ans, abs(sum[i]-(all-sum[i])));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+7;
const ll inf_l = 1e18;
const int MAX = 1e7+10;

int dat[MAX];

void process() {
    for (int i = 1; i <= MAX; i++) {
        for (int j = i; j <= MAX; j += i) {
            dat[j]++;
        }
    }
}

int main() {
    int n; cin >> n;
    process();
    ll ans = 0;
    for (int k = 1; k <= n; k++) {
        ans += (ll)k * dat[k];
    }
    cout << ans << endl;
}

Measured memory_bytes: 42620
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int S;

int main(){
    cin >> S;
    int up2 = S/100;
    int down2 = S - up2*100;
    if (0 < up2 && up2 <=12) {
        if (0 < down2 && down2 <=12) {
            cout << "AMBIGUOUS" << endl;
        }
        else cout << "MMYY" << endl;
    }
    else {
        if (0 < down2 && down2 <=12) {
            cout << "YYMM" << endl;
        }
        else cout << "NA" << endl;
    }
    
    return 0;
}


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

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

    vector<int> A(n + 1);
    A[0] = A[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        A[i] = A[i - 2] + A[i - 1];
    }

    cout << A[n] << endl;

    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


// Morris-Pratt
// S から T を探し、その出現位置を T が始まる位置として 0-indexed で全列挙する O(|S|)
// 文字列ならば T は string, 整数列ならば T は vector<int> 等にする
template<typename T> 
struct MP {
    int n;
    T t;
    vector<int> a; // t[:i] (1-indexed) の suffix と prefix の共通部分の長さ（重複する位置があってはならない）
    MP() {};
    MP(T const & t) : t(t) {
        n = t.size();
        a = vector<int>(n+1);
        a[0] = -1;
        int j = -1;
        for(int i=0; i<n; ++i) {
            while(j != -1 && t[j] != t[i]) j = a[j];
            j++;
            a[i+1] = j;
        }
    }
    int operator[] (int i) { return a[i]; }
    vector<int> findAll(T const& s) {
        vector<int> res;
        int j = 0;
        for(int i=0; i<s.size(); ++i) {
            while(j != -1 && t[j] != s[i]) j = a[j];
            j++;
            if (j == n) {
                res.push_back(i-j+1);
                j = a[j];
            }
        }
        return res;
    }
};

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

    int N; cin >> N;
    vector<int> a(N), b(N), c(N), d(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    rep(i, N) {
        c[i] = a[i] ^ a[(i+1)%N];
        d[i] = b[i] ^ b[(i+1)%N];
    }
    c.insert(c.end(), c.begin(), c.end());
    MP<vector<int>> mp(d);
    auto res = mp.findAll(c);
    for(auto k: res) {
        if (k>=N) continue;
        cout << k << " " << (a[k]^b[0]) << endl;
    }
    
    return 0;
}


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

using namespace std;

int n;
string s;
int prefR[4010], prefG[4010], prefB[4010];

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

	cin >> n;
	cin >> s;

	for(int i = 1; i <= n; i++){
		if(s[i - 1] == 'B') prefB[i]++;
		else if (s[i - 1] == 'G') prefG[i]++;
		else prefR[i]++;

		prefR[i] += prefR[i - 1];
		prefG[i] += prefG[i - 1];
		prefB[i] += prefB[i - 1];
	}

	long long ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			if(s[i] != s[j]){
				bool r, g, b;

				r = g = b = false;

				if(s[i] == 'R') r = true;
				if(s[i] == 'G') g = true;
				if(s[i] == 'B') b = true;

				if(s[j] == 'R') r = true;
				if(s[j] == 'G') g = true;
				if(s[j] == 'B') b = true;

				if(!r){
					ans += prefR[n] - prefR[j];
				} else if (!g){
					ans += prefG[n] - prefG[j];
				} else {
					ans += prefB[n] - prefB[j];
				}

				if(2 * j - i < n && s[2 * j - i] != s[i] && s[2 * j - i] != s[j]) ans--;
			}
		}
	}

	cout << ans << "\n";
	
	return 0;
}

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

typedef long long int ll;

int main(){

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

    int n;
    cin>>n;

    vector<double>p(n+1);
    for(int i=1;i<=n;i++)cin>>p[i];

    vector<vector<double> >dp(n+1,vector<double>(n+1));

    dp[1][0] = 1 - p[1];
    dp[1][1] = p[1];

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

    for(int i=2;i<=n;i++){
        for(int j=1;j<=i;j++){

            dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1 - p[i]);

        }
    }

    double ans = 0;

    for(int i=n/2+1;i<=n;i++){
        ans+=dp[n][i];
        // cout<<dp[n][i]<<" ";
    }

    cout<<fixed<<setprecision(9)<<ans<<'\n';


    return 0;

}

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

namespace AGC003B_3{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var A = sr.Next<long>(N);
            var a = A.ToArray();

            var res = 0L;
            for(var i = 1; i < N; i++){
                res += a[i - 1] / 2;
                if(a[i - 1] % 2 == 1 && a[i] >= 1){
                    res++;
                    a[i]--;
                }
            }
            res += a[N - 1] / 2;

            Console.WriteLine(res);
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }
    }
}

Measured memory_bytes: 8640
package main

import (
	"fmt"
)

type graph struct {
	setuzoku []int
}
var sum int
var graphs []graph
var N int
func main() {
	var M int
	fmt.Scan(&N,&M)
	sum = 0
	graphs = make([]graph,N)
	for i:= 0; i<M; i++ {
		var a,b int
		fmt.Scan(&a,&b)
		graphs[a-1].setuzoku = append(graphs[a-1].setuzoku, b-1)
		graphs[b-1].setuzoku = append(graphs[b-1].setuzoku, a-1)
	}
	tansaku := map[int]bool{}
	tansaku[0] = true
	Dfs(graphs[0],tansaku,0)
	fmt.Println(sum)
}
func Dfs (me graph,tansaku map[int]bool, count int) {
	if count == N-1 {
		sum += 1
		// fmt.Println("確認",sum,count,me)
		return
	}
	// fmt.Println(count,me,N,tansaku,len(me.setuzoku))
	for i:=0; i <len(me.setuzoku); i ++ {
		check := me.setuzoku[i]
		// fmt.Println(tansaku[check])
		if ok := tansaku[check]; !ok {
			T := map[int]bool{}
			for j,value := range tansaku {
				T[j] = value
			}
			T[check] = true
			g := me.setuzoku[i]
			Dfs(graphs[g],T,count+1)
		}
	}
}


Measured memory_bytes: 2944
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int n, m, k; cin >> n >> m >> k;
  vector <ll> a(n);
  for(auto &x : a) cin >> x;
  vector <ll> b(m);
  for(auto &x : b) cin >> x;
  vector <ll> sum;
  ll cur = 0;
  for(auto x : a) {
    cur += x;
    sum.push_back(cur);
  }
  sum.push_back(1LL * 1e18);
  ll ans = 0;
  ll have = 0;
  for(int i = 0; i < m; i++) {
    have += b[i];
    if(have > k) break;
    int aro = lower_bound(sum.begin(), sum.end(), k - have) - sum.begin();
    if(sum[aro] > (k - have)) aro--;
    ans = max(ans, i + 1LL + aro + 1LL);
  }
  if(have <= k) ans = max(ans, m * 1LL);
  if(sum[n - 1] <= k) ans = max(ans, n * 1LL);
  print(ans);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}




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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 30;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int N; cin >> N;
  for(ll h = 0; h <= 3500; ++h) {
    for(ll n = 0; n <= 3500; ++n) {
      if(4*h*n-N*n-N*h > 0 && N*h*n % (4*h*n-N*n-N*h) == 0) {
        cout << h << " " << n << " " << N*h*n / (4*h*n-N*n-N*h) << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3636
N, C, K = map(int, input().split())
T = list(int(input()) for i in range(N))
T.sort()
bus = 1
passenger = 0
limit = T[0] + K
for i in range(N):
    if T[i] <= limit and passenger < C:
        passenger += 1
    else:
        bus += 1
        limit = T[i]+K
        passenger = 1
print(bus)

Measured memory_bytes: 13248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
ll r, g, b;
string S;

void solve() {
    cin >> N;
    cin >> S;
    for (int i = 0; i < N; ++i) {
        switch (S[i]) {
            case 'R':
                r++;
                break;
            case 'G':
                g++;
                break;
            case 'B':
                b++;
                break;
        }
    }
    ll ans = r * g * b;
    for (int i = 0; i < N; ++i) {
        for (int j = 1; i+j+j < N; ++j) {
            if ((S[i] ^ S[i+j] ^ S[i+j+j]) == ('R' ^ 'G' ^ 'B')) ans--;
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3648
import sys

input = sys.stdin.readline
n = int(input())
m = list(map(int, input().split()))

def solve(isPosi):
    ans = 0
    sm = 0
    
    for a in m:
        if isPosi:
            sm += a
            if sm >= 0:
                ans += (1+sm)
                sm = -1
            isPosi = False
        
        else:
            sm += a
            if sm <= 0:
                ans += (1-sm)
                sm = 1
            isPosi = True
    
    return ans

ans_p = solve(True)
ans_n = solve(False)

print(min(ans_p, ans_n))

Measured memory_bytes: 14332
import java.io.BufferedReader;
import java.io.InputStreamReader;

//public class Problem0012_APointInaTriangle {
public class Main {
	public static void main(String[] args) {
		try {
		//	Problem0012_APointInaTriangle test = new Problem0012_APointInaTriangle();
			Main test = new Main();
			
			
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String line;
			while((line = reader.readLine()) != null) {
				try {
					String[] textArray = line.split(" ");
					double[] numbers = new double[textArray.length];
					
					for(int i = 0; i < textArray.length; i++) {
						numbers[i] = Double.parseDouble(textArray[i]);
					}
					test.showAnswer(numbers);
				} catch(NumberFormatException e) {
					break;
				}
			}
			
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	//s() + t() = () (0<= s+t <= 1) ðzè(½¾µA()Í_Ì·Ùð\·xNg)
	void showAnswer(double[] array) {
		double[][] vector = getVector(array, 0, 2, 4);
		double[] position = {array[6] - array[0], array[7] - array[1]};
		if(vector[0][0] * vector[1][1] - vector[0][1] * vector[1][0] == 0) {
			vector = getVector(array, 2, 4, 0);
			position[0] = array[6] - array[2];
			position[1] = array[7] - array[3];
		}
		
	//	System.out.println("00:" + vector[0][0] + "\t01:" + vector[0][1]  + "\t10:" + vector[1][0] + "\t11:" + vector[1][1] + "\tA:" + position[0] + "\tB:" + position[1]);
		double s = (position[0] * vector[1][1] - position[1] * vector[1][0]) / (vector[0][0] * vector[1][1] - vector[0][1] * vector[1][0]);
	//	System.out.println("s:" + s);
		double t;
		if(vector[1][0] != 0) {
			t = (position[0] - vector[0][0] * s) / vector[1][0];
		} else if(vector[1][1] != 0) {	//¼û[Ì¯ê_  è¾È¢
			t = (position[1] - vector[0][1] * s) / vector[1][1];
		} else {
			System.out.println("NO");
			return;
		}
	//	System.out.println("t:" + t); 
		if(0 < s && 0 < t && s + t < 1) {	//1or0 Ì Ó¨æÑ¸_  è¾È¢
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
	double[][] getVector(double[] array, int origin, int first, int second) {
		double[][] result = new double[2][2];
		
		for(int i = 0; i < 2; i++) {
			result[0][i] = array[first + i] - array[origin + i];
			result[1][i] = array[second + i] - array[origin + i];
		}
		
		return result;
	}
}

Measured memory_bytes: 9736
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bitset>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 998244353;

ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll sq(ll x) {return (x * x) % MOD;}
ll modP(ll a, ll b) {return (!b ? 1 : (sq(modP(a, b / 2)) * (b % 2 ? a : 1)) % MOD);}

int d[maxN], cnt[maxN];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		cin >> d[i];
		cnt[d[i]]++;
	}
	if (cnt[0] != 1 || d[0] != 0){
		return cout << 0 << endl, 0;
	}
	ll ans = 1;
	for (int i = 1; i < n; i++){
		ans = (ans * cnt[d[i] - 1]) % MOD;
	}
	cout << ans << endl;
	return 0;
}
 



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  int64_t K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i]--;
  }
  vector<int> B(N, -1);
  int cur = 0, dist = 0;
  while (true) {
    if (B[cur] != -1 && K > N) {
      K %= dist - B[cur];
    }
    if (K == 0) {
      cout << cur + 1 << '\n';
      return 0;
    }
    B[cur] = dist++;
    cur = A[cur];
    K--;
  }
  return 0;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

int main(){
    ll k;
    cin >> k;
    if(k%2 == 0 || k%5 == 0){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 1, mod = 7, x=10;
    while(1){
        if(mod % k == 0)break;
        ans++;
        mod += x*7;
        mod %= k;
        x *= 10;
        x %= k;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
s = input()

no = []
for i, ss in enumerate(s):
    if ((i + 1) % 2 == 0 and ss in ('L','U','D')) or ((i + 1) % 2 != 0 and ss in ('R', 'U', 'D')):
        pass
    else:
        no.append(ss)

if len(no) == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n,m,k=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
cd=[list(map(int,input().split())) for i in range(k)]
frnd=[0]*n
for i in range(m):
    a,b=ab[i]
    frnd[a-1]+=1
    frnd[b-1]+=1
blck={}
for i in range(k):
    c,d=cd[i]
    if not c in blck:
        blck[c]=[d]
    else:
        blck[c].append(d)
    if not d in blck:
        blck[d]=[c]
    else:
        blck[d].append(c)

# print(frnd)
# print(blck)

class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.weight = [0] * (n+1)


    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

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

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]
uf = WeightedUnionFind(n)
for i in range(m):
    a,b=ab[i]
    uf.union(a,b,1)
for i in range(n):
    uf.find(i+1)

cnt=dict(Counter(uf.par))
# print(uf.par)

anslst=[0]*n
for i in range(n):
    anslst[i]=cnt[uf.find(i+1)]-frnd[i]-1
    if i+1 in blck:
        for j in blck[i+1]:
            if uf.same(i+1,j):
                anslst[i]-=1
# print(cnt)
# print(frnd)
print(*anslst)

Measured memory_bytes: 129508
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    ll x;
    cin >> x;

    ll t=1,n=1,e=1;
    for(int i=1;i<=x;i++){
        t= (t*10)%M;
        n= (n*9)%M;
        e= (e*8)%M;
    }

    ll ans=(t-2*n+e)%M;
    
    if(ans>=0){
        cout << ans << endl;
    }else{
        cout << ans+M << endl;
    }
}

Measured memory_bytes: 3608
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b = readline().decode().rstrip().split()

a = int(a)
b = int(b[0]) * 100 + int(b[2]) * 10 + int(b[3])

print(a*b//100)

Measured memory_bytes: 9240
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b)
    cout<<a-b<<endl;


}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
 
using namespace std;
 
const int MAX = 100001;
int n,w,bv,bw;
ll dp[MAX];
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  cin>>n>>w;
  
  while(n--){
    cin>>bw>>bv;
    for(int i=w;i>=bw;i--)dp[i]=max(dp[i],dp[i-bw]+bv);
  }
  
  cout<<dp[w]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
#define ar array 

void test_case() {
	string s;
	cin >> s;
	int count = 0 ;
	int best = 0;
	for(int i = 0 ; i < (int)s.size() ; i++)
		if(s[i]=='R')
			count++;
		else
			best = max(best,count) , count  = 0;
	best = max(best,count);
	cout<<best;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T = 1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
}


Measured memory_bytes: 3648
import sys
import math
import collections

def set_debug(debug_mode=False):
    if debug_mode:
        fin = open('input.txt', 'r')
        sys.stdin = fin


def int_input():
    return list(map(int, input().split()))


def get(s):
    return str(s % 9) + '9' * (s // 9)

if __name__ == '__main__':
    # set_debug(True)

    # t = int(input())
    t = 1

    for ti in range(1, t + 1):
        n = int(input())
        A = int_input()

        d = [0] * (10 ** 5 + 1)

        res = 0

        for x in A:
            res += x
            d[x] += 1

        q = int(input())

        for _ in range(q):
            b, c = int_input()

            res += (c - b) * d[b]
            d[c] += d[b]
            d[b] = 0

            print(res)


Measured memory_bytes: 21532
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

r=int(arr_data[0][0])

if r<1200:
    
    print("ABC")
    
elif r<2800:
    print("ARC")
    
else:
    
    print("AGC")

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i,m) cin >> a[i];
  
  // dp[i] : i段目にたどりつくまでの移動法の総数
  vector<int> dp(n+1);
  dp[0] = 1;
  int j = 0;
  rep(i,n+1){
    if(i<1) continue;
    if(j<m){
      if(a[j] == i){
        j++; continue;
      }
    }
    dp[i] = dp[i-1];
    if(i>1) dp[i] += dp[i-2];
    dp[i] %= mod;
  }
  
  //rep(i,n+1) cout << i << ":" << dp[i] << endl;
  
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[500010];
ll b[500010];
int main(void)
{
    ll i,n,sum=0;
    string s;
    cin >> s;
    s = '.' + s;
    for(i=1; i<s.size(); i++) {
        if(s[i]=='<')
            a[i]=a[i-1]+1;
    }
    for(i=s.size()-1; i>=1; i--) {
        if(s[i]=='>')
            b[i-1]=b[i]+1;
    }
    for(i=0;i<s.size();i++)
        sum+=max(a[i],b[i]);
    cout << sum;
    return 0;
}


Measured memory_bytes: 8728
import numpy as np
import sys
sys.setrecursionlimit(10 ** 7)

# 数え上げ

N, M, K = map(int, input().split())
ans = 0

MOD = 10 ** 9 + 7


def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv


U = N * M + 10
fact, fact_inv = make_fact(U, MOD)
fact, fact_inv = fact.tolist(), fact_inv.tolist()


def mod_comb_k(n, k, mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod


# X
for dx in range(1, N):
    pat = N - dx
    ans += dx * pat * M * M
    ans %= MOD

# Y
for dy in range(1, M):
    pat = M - dy
    ans += dy * pat * N * N
    ans %= MOD

ans *= mod_comb_k(N * M - 2, K-2, MOD)
ans %= MOD

print(ans)


Measured memory_bytes: 34124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,x;
  cin>>n>>d>>x;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    x+=d/a+(bool)(d%a);
  }
  cout<<x<<endl;
}


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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  long long ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    a[i] += ans;
    int rest = a[i] % b[i];
    if (rest > 0) ans += b[i] - rest;
    debug(ans);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4728
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main(void){
int A1,A2;
scanf("%d",&A1);
scanf("%d",&A2);
if(A1+A2<4){
	printf("3");
}
else if(A1+A2<5){
	printf("2");
}
else {
	printf("1");
}
}

Measured memory_bytes: 128
n,x,y = gets.chomp.split(" ").map(&:to_i)

hash = {}
(1).upto(n-1) do |i|
  (i+1).upto(n) do |j|
    diff = [j - i, (x - i).abs + 1 + (y - j).abs, (y - i).abs + 1 + (x - j).abs].min
    hash[diff] ||= 0
    hash[diff] += 1
  end
end

1.upto(n-1) do |i|
  puts hash[i].to_i
end

Measured memory_bytes: 14328
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string S;
    cin >> N >> S;

    int cnt = 0;
    for (int i = 0; i < N-2; i++)
    {
        if(S.substr(i, 3) == "ABC") cnt++;
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i,j;
  int n,m,x;
  cin>>n>>m>>x;
  int c[n];
  int a[n][m];
  for(i=0;i<n;i++){
    cin>>c[i];
    for(j=0;j<m;j++) cin>>a[i][j];
  }
  int ans=inf;
  for(i=0;i<(1<<n);i++){
    int p = 0;
    VI v(m,0);
    for(j=0;j<n;j++){
      if((i>>j)&1) {
        p += c[j];
        for(int k=0;k<m;k++) v[k]+=a[j][k];
      }
    }
    for(j=0;j<m;j++){
      if(v[j]<x) break;
      if(j==m-1) chmin(ans,p);
    }

  }
  if(ans == inf) ans = -1;
  cout<<ans<<endl;

}

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

using namespace std;

void Main() {
    string S;
    cin >> S;

    cout << (S == "ABC" ? "ARC" : "ABC") << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int q; cin>>q;
    while(q--){
        ll a, b; cin>>a>>b;
        if(a==b || abs(a-b)==1) cout << 2*(min(a, b)-1) << endl;
        else{
            ll c=sqrt(a*b);
            if(c*c==a*b) c--;
            if(c*(c+1)>=a*b) cout << 2*c-2 << endl;
            else cout << 2*c-1 << endl;
        }
    }
}

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

long long n;
vector<long long> v[2];

long long solve();

int main() {
  cin >> n;
  for(int t = 0; t < 2; ++t)
    for(int i = 0; i < n; ++i) {
      long long a;
      cin >> a;
      v[t].push_back(a);
    }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  int ans = 0;
  sort(v[1].begin(), v[1].end());
  for(int i = 0; i < 31; ++i) {
    vector<long long> nowv;
    for(int j = 0; j < n; ++j)
      nowv.push_back(v[1][j] % (1 << (i + 1)));
    sort(nowv.begin(), nowv.end());
    bool ch = 0;
    for(int j = 0; j < n; ++j) {
      long long now = v[0][j] % (1 << (i + 1)), l, r;
      r = (1LL << (i + 1)) - now;
      l = (1LL << i) - now;

      long long cnt =
          lower_bound(nowv.begin(), nowv.end(), r) -
          lower_bound(nowv.begin(), nowv.end(), l);
      ch ^= cnt % 2;
      l += 1LL << (i + 1);
      r += 1LL << (i + 1);
      cnt = lower_bound(nowv.begin(), nowv.end(), r) -
            lower_bound(nowv.begin(), nowv.end(), l);
      ch ^= cnt % 2;
    }
    if(ch) ans += 1LL << i;
  }
  return ans;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  while (a > 0 and c > 0) {
    c -= b;
    if (c > 0) {
      a -= d;
    } else {
      cout << "Yes" << endl;
      break;
    }
    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(){
  int N, K, i;
  cin >> N;
  char S[N], tmp;
  for(i=0; i<N; i++) cin >> S[i];
  cin >> K;
  tmp = S[K-1];
  for(i=0; i<N; i++){
    if(tmp != S[i]) S[i] = '*';
  }
  for(i=0; i<N; i++) cout << S[i];
  cout << endl;
  return 0;
}


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

using namespace std;

long long N;

void func(long long a, int flag, long long &counter){
    /*ベースケース */
    if(a > N) return;
    /*753フラグが立ってる時にcounter増やす */
    if(flag == 0b111) ++counter;

    /*7を付け足す */
    func(a * 10 + 7, flag | 0b001, counter);

    /*この時点で7スタートのカウントができてる */

    /*5を付け足す */
    func(a * 10 + 5, flag | 0b010, counter);

    /*この時点で以下略 */

    /*3を付け足す */
    func(a * 10 + 3, flag | 0b100, counter);

    /*値を返さないvoid関数だが、counterが答えに変わってる */
}

int main() {
    cin >> N;
    long long res = 0;
    func(0, 0, res);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{

  int i, j, n, x, y, A[100000];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

  x = A[n-1];
  i = -1;

  for(j = 0; j < n-1; j++){
    if(A[j] <= x){
      i = i + 1;
      y = A[i];
      A[i] = A[j];
      A[j] = y;
    }
  }
  y = A[i+1];
  A[i+1] = A[n-1];
  A[n-1] = y;

  for(j = 0; j < n-1; j++){
    if(j == i+1) printf("[%d] ", A[j]);
    else printf("%d ", A[j]);
  }

  printf("%d\n", A[n-1]);

  return 0;
}

Measured memory_bytes: 988
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#define rep(i, n) for (int i=0; i<n; ++i)
#define FOR(i, a, b) for (int i=a; i<b; ++i)
#define pb(x) push_back(x)
#define ll long long
#define ul unsigned long long
#define dbg(x) cout  << #x << " : " << (x) << endl
#define out(x) cout << (x)
#define outl(x) cout << (x) << endl
#define int(n); int n; cin >> n;
#define long(n); long long n; cin >> n;
#define dbl(f); double f; cin >> f;
#define s(s); string s; cin >> s;
#define into(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
using namespace std;

const int inf =1500000000;
char a[20][20];
int cnt; 
int w,h; 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1}; 
void dfs(int x, int y) {
  a[y][x] = '#';
  cnt++;
  rep(i, 4) {
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(nx<w&&ny<h&&nx>=0&&ny>=0&&a[ny][nx]=='.') dfs(nx, ny);
  }
}

int main () {
  while(true){
    cnt = 0;
    cin>>w>>h;
    if (w==0&& h==0) break;
    int x0,y0;
    rep(i, h) {
      rep(j, w) {
        cin>>a[i][j];
        if(a[i][j]=='@' ) {
          x0=j; y0=i;
          a[i][j]='.';
        }
      } 
    } 
    dfs(x0, y0);
    outl(cnt);
  }
  return 0;
}

Measured memory_bytes: 1168
// Problem : A - ABC Swap
// Contest : AtCoder Beginner Contest 161
// URL : https://atcoder.jp/contests/abc161/tasks/abc161_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
 
#define pb push_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << #x << "=" << x << endl;
#define see2(x, y) cout << #x << "=" << x << "\t" << #y << "=" << y << endl;
#define see3(x, y, z) cout << #x << "=" << x << "\t" << #y << "=" << y << "\t" << #z << "=" << z << endl;
#define INF 1e9+5
#define LL_MAX 1e18+5

using namespace std;

const ld PI = acos((ld)-1);
 
ll modmult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll modmultbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=modmultbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll modadd(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll modsub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = modmult(r,n,p); n = modmult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

int isPowerof2(ll x) { return (x && !(x & (x-1))); } 

ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
 
bool boundary(ll i,ll j,ll n, ll m){return (i>=0 && i<n && j>=0 &&  j<m);} //matrix boundary checking

ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
int lcm(int a, int b){return (a*b)/__gcd(a, b);}
 
string alpha="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

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

// cout << fixed for removing e notation
 
bool comp2(const pair<int, int>&a, const pair<int, int>&b)
{
    if(a.second < b.second)
        return true;
    else if(a.second == b.second)
    {
        if(a.fi > b.fi) return true;
        else return false;
    }
    else return false;
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
}

int main()
{
	int x, y, z;
	cin >> x >> y >> z;
	
	swap(x, y);
	swap(x, z);
	
	cout << x << " " << y << " " << z << "\n";
}






























































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
int x[2]={0,1};
int y[2]={1,0};
int main(){
	deque<pair<int,int>> q;
	int h,w;
	cin>>h>>w;
	q.push_back(make_pair(0,0));
	char s[h][w];
	int cost[h][w];
	rep(i,h)rep(j,w)cin>>s[i][j];
	rep(i,h)rep(j,w)cost[i][j]=1000000000;
	if(s[0][0]=='.')cost[0][0]=0;
	else cost[0][0]=1;
	pair<int,int> now;
	int newx,newy;
	while(1){
		now=q.front();
		q.pop_front();
		rep(i,2){
			newy=now.first+y[i];
			newx=now.second+x[i];
			if(0<=newy&&newy<h&&0<=newx&&newx<w){
				if(s[now.first][now.second]=='#'||s[newy][newx]=='.'){
						if(cost[newy][newx]>cost[now.first][now.second]){
							cost[newy][newx]=cost[now.first][now.second];
							q.push_front(make_pair(newy,newx));
						}
					}
					else{
						if(cost[newy][newx]>cost[now.first][now.second]+1){
							cost[newy][newx]=cost[now.first][now.second]+1;
							q.push_back(make_pair(newy,newx));
						}
					}
				}
			if(newy==h-1&&newx==w-1){
				cout<<cost[newy][newx];
				return 0;
			}
		}
	}		
	return 0;
}

Measured memory_bytes: 3652
n = int(input())
A = list(map(int, input().split()))

ans = 1
prev = A[0]
direction = 0
for a in A[1:]:
    if direction == 1:
        if prev > a:
            ans += 1
            direction = 0
            prev = a
            continue
    if direction == -1:
        if prev < a:
            ans += 1
            direction = 0
            prev = a
            continue
    if direction == 0:
        if prev < a:
            direction = 1
        elif prev > a:
            direction = -1
    prev = a
print(ans)

Measured memory_bytes: 15020