akhauriyash/Code-Regression huggingface dataset:
// Vicfred
// https://atcoder.jp/contests/abc164/tasks/abc164_d
// implementation
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    const int mod = 2019;

    vector<int> dp(mod);

    dp[0] += 1;

    int rem = 0;
    int base = 1;

    for(int i = 0; i < n; i++) {
        int d = s[n-i-1]-'0';
        rem = (rem + base * d)%mod;
        dp[rem] += 1;
        base *= 10;
        base %= mod;
    }

    long ans = 0LL;
    for(int i = 0; i < mod; i++) {
        ans += (dp[i]*(dp[i]-1))/2;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3700
K = gets.chomp.to_i

queue = []
1.upto(9) do |i|
  queue.push(i)
end

total = 0
while !queue.empty?
  n = queue.shift
  total += 1
  if total == K
    p n
    exit
  end
  last_s = n.to_s.split('').last
  ne = (n.to_s + last_s).to_i
  queue.push(ne - 1) if last_s != '0'
  queue.push(ne)
  queue.push(ne + 1) if last_s != '9'
end


Measured memory_bytes: 6012
def main():
    n = int(input())

    counter = 0
    ans = False
    for i in range(n):
        a,b = map(int, input().split())
        if a == b:
            counter += 1
        else:
            counter = 0
        if counter >= 3:
            ans = True
    if ans:
        print('Yes')
    else:
        print('No')
    

main()


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

  ll N;
  cin >> N;

  vl a(N, 0);
  vl b(N, 0);
  vl c(N, 0);

  vvl dp(N, vl(3, 0));

  FOR(i, 0, N){
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
  }

  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];

  FOR(i, 1, N){
    dp[i][0] = max(dp[i-1][1], dp[i-1][2])+a[i];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2])+b[i];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1])+c[i];
  }

  cout <<  max(max(dp[N-1][0], dp[N-1][1]),dp[N-1][2]) << endl;

}


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

namespace ProblemA
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = read[0];
            var A = read[1];
            var B = read[2];
            var C = read[3];
            var D = read[4];
            var S = Console.ReadLine();

            var existTwoConsRockBetweenACorBD = false;
            var CgeqD = C > D;
            var maxCD = Math.Max(C, D);
            var existThreeConsToSwitch = false;
            for (int i = 1; i < N; i++)
            {
                if(A <= i && i <= maxCD && i <= N - 1 && !existTwoConsRockBetweenACorBD)
                {
                    existTwoConsRockBetweenACorBD = S[i - 1] == '#' && S[i] == '#';
                }
                if(CgeqD && B <= i && i <= D && !existThreeConsToSwitch)
                {
                    existThreeConsToSwitch = S[i - 2] == '.' && S[i - 1] == '.' && S[i] == '.'; 
                }
            }
            var ret = existTwoConsRockBetweenACorBD || (CgeqD && !existThreeConsToSwitch) ? "No" : "Yes";
            Console.WriteLine(ret);
            
        }
    }
}


Measured memory_bytes: 11872
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(int argc, char** argv){
    int N;
    cin >> N;
    int count = 0;
    long a;
    for(int i=0; i < N; ++i){
        cin >> a; 
        while((a % 2) == 0){
            a /= 2;
            ++count;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace::std;
int main(){
    long N,i,score=0;
    cin>>N;
    long B[N],A[N];
    for(i=0;i<N-1;i++){
    cin>>B[i];
    }
for(i=0;i<N;i++){
    if(i==N-1){
        A[N-1]=B[N-2];
    }
    else if(i==0){
        A[i]=B[i];
    }
    else{
        if(B[i]<=B[i-1])
        A[i]=B[i];
        else 
        A[i]=B[i-1];
    }
    score+=A[i];
}
cout<<score;
    return 0;
}

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

using namespace std;

int main(){
	pair<int,int>  p1,p2,p3,p4;
	int a[4];
	int b[4];

	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]) != EOF){
		int hit = 0;
		int blow = 0;
		//scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);

		for(int i=0;i<4;i++){
			scanf("%d",&b[i]);
				if(a[i] == b[i]){
					hit++;
				}
				for(int j=0;j<4;j++){
						if(b[i] == a[j] and a[i] != b[i]){
							blow++;
						}
				}
		}
	cout << hit << " " << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <cstdio>
#include <algorithm>
#include <cstring>
#define int long long
const int INF = 0x3f3f3f3f3f3f;
const int maxn = 2005;
using namespace std;
struct E{
	int to, nxt;
}e[maxn << 1];
int head[maxn], tot = 0;
void addedge(int u, int v){
	e[++tot].to = v, e[tot].nxt = head[u];
	head[u] = tot;
}
int dep[maxn], sz[maxn], sdep[maxn], sum; char s[maxn];
void dfs1(int cur, int fa){
	dep[cur] = dep[fa] + 1;
	sum += (dep[cur] - 1) * (s[cur] == '1');
	for (int i = head[cur]; i; i = e[i].nxt){
		int v = e[i].to;
		if (v != fa){
			dfs1(v, cur);
			sz[cur] += sz[v] + (s[v] == '1');
			sdep[cur] += sdep[v] + sz[v] + (s[v] == '1');
		}
	}
}
void dfs2(int cur, int fa){
	int link = 0;
	for (int i = head[cur]; i; i = e[i].nxt){
		int v = e[i].to;
		if (v == fa) continue;
		if (sdep[v] + sz[v] + (s[v] == '1') > sdep[link] + sz[link] + (s[link] == '1') || link == 0) link = v;
	}
	if (link == 0) return;
	dfs2(link, cur); sdep[cur] = 0;
	for (int i = head[cur]; i; i = e[i].nxt)
		if (e[i].to != fa) sdep[cur] += sdep[e[i].to] + sz[e[i].to] + (s[e[i].to] == '1');
	if (2ll * (sdep[link] + sz[link] + (s[link] == '1')) > sdep[cur]) sdep[cur] = 2ll * (sdep[link] + sz[link] + (s[link] == '1')) - sdep[cur];
	else sdep[cur] = sdep[cur] & 1;
}
int n, ans = INF;
signed main(){
	scanf("%lld%s", &n, s + 1);
	for (int u, v, i = 1; i < n; i++){
		scanf("%lld%lld", &u, &v);
		addedge(u, v); addedge(v, u);
	}
	for (int rt = 1; rt <= n; rt++){
		memset(dep, 0, sizeof dep); memset(sz, 0, sizeof sz); sum = 0;
		memset(sdep, 0, sizeof sdep);
		dfs1(rt, 0); if (sum & 1) continue;
		dfs2(rt, 0);
		if (sdep[rt] == 0) ans = min(ans, sum >> 1);
	}
	if (ans == INF) ans = -1;
	printf("%lld\n", ans);
	return 0;
}

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

int main()
{
    int N,K;
    string S;
    
    cin>>N>>K;
    cin>>S;
    
    if(S[K-1]=='A')
    S[K-1]='a';
    
    if(S[K-1]=='B')
    S[K-1]='b';
    
    if(S[K-1]=='C')
    S[K-1]='c';
    
    cout<<S;
    return 0;
}

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

int main() {
 int a,b;
 cin >> a >> b;
  if((a+b)%2==0 ){
   cout << (a+b)/2 << endl;
  }
  else{
   cout << (a+b+1)/2 << endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll H,W,M;
    cin >>H>>W>>M;
    vector<Pi>HB(300005);
    vector<Pi>WB(300005);
    map<Pi,bool>m;
    rep(i,300005){
        HB[i].second=i;
        WB[i].second=i;
    }
    rep(i,M){
        ll h,w;
        cin>>h>>w;
        h--;w--;
        HB[h].first++;
        WB[w].first++;
        m[mp(h,w)]=1;
    }
    sort(all(HB));
    reverse(all(HB));
    sort(all(WB));
    reverse(all(WB));
    ll mx=HB[0].first+WB[0].first;
    rep(i,300005){
        rep(j,300005){
            if(WB[j].first<WB[0].first) break;
            if(HB[i].first+WB[j].first==mx){
                if(m[mp(HB[i].second,WB[j].second)]==0){
                    cout<<mx<<endl;
                    return 0;
                }
            }else if(HB[i].first<HB[0].first){
                cout<<mx-1<<endl;
                return 0;
            }
        }
    }



    return 0;
    

}

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

bool isev(ll ara[],ll n)
{
    for(ll i=0;i<n;i++)
    {
        if(ara[i]%2==1) return 0;
    }
    return 1;
}

int main()
{
    ll N,K=0,x,sum=0,c=0;
    cin>>N;
    ll ara[N];
    for(int i=0; i<N; i++)
    {
        cin>>ara[i];
        if(ara[i]%2==1)K=1;
    }
    if(K==1)
    {
        cout<<0<<endl;
        return 0;
    }
   while(isev(ara,N)==1)
   {
       c++;
       for(int i=0;i<N;i++)
       {
           ara[i]/=2;
       }
   }
   cout<<c<<endl;
}



Measured memory_bytes: 256
mod=10**9+7
s=list(input())
s=['-']+s
l=len(s)
dp=[[0 for j in range(4)] for i in range(l)]
dp[0][0]=1
for i in range(1,l):
    for j in range(4):
        dp[i][j]=dp[i-1][j]
        if s[i]=='?':
            dp[i][j]*=3;
        if j and (s[i]=='?' or 'ABC'[j-1]==s[i]):
            dp[i][j]+=dp[i-1][j-1]
        dp[i][j]%=mod
print(dp[-1][3])

Measured memory_bytes: 89976
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

char c;

int main(){
	cin>>c;
	if(c=='S') cout<<"Cloudy"<<endl;
	if(c=='C') cout<<"Rainy"<<endl;
	if(c=='R') cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2020/05/03.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i<(n); i++)
using namespace std;
using vec2div = vector<vector<long long>>;
using vec = vector<long long>;
using ll = long long;

int main(){
	char a,b,c;
	cin >> a >> b >> c;
	int ren=0;
	if(a=='R'||b=='R'||c=='R'){
		ren = 1;
	}
	
	
	if(a=='R'&&b=='R'){
		ren = 2;
	}
	if(c=='R'&&b=='R'){
		ren = 2;
	}
	if(a=='R'&&b=='R'&&c=='R'){
		ren = 3;
	}
	cout << ren << endl;
	
	
}

Measured memory_bytes: 3632
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int A, B, C; cin >> A >> B >> C;
    swap(B, A);
    swap(A, C);
    cout << A << " " << B << " " << C << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 896
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N = I()
A1 = LI()
A2 = LI()

answer = 0
for i in range(1, N+1):
    # i番目で下に行き、残りは右しか行かない場合
    result = sum([j for j in A1[0:i]])
    result += sum([j for j in A2[i-1:]])
    answer = max(result, answer)
print(answer)


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

using namespace std;
long long a[10];

int main()
{
	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);
	int n, m;
	int num = 0;
	int i, j;
	
	cin >> n >> m;
	
	for(i = 0;i <=n; i++)
	{
		for(j = 0; j <= n; j++)
		{
		
			if(i+j == n)
			{
			if(i*2 + j*4 == m)
			{
				cout << "Yes";
				return 0;
			}
		}
	}
}

printf("No");
	
	
}
		

Measured memory_bytes: 3708
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N >> K >> Q;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	priority_queue< pii, vector< pii >, greater< pii > > q;
	rep(i, N) q.push(pii(A[i], i));
	vector< bool > done(N + 1, false);
	done[N] = true;
	int ans = LINF;
	while (1) {
		priority_queue< int, vector< int >, greater< int > > q3;
		priority_queue< int, vector< int >, greater< int > > q2;
		rep(i, N + 1) {
			if (done[i]) {
				while (q2.size() >= K) {
					q3.push(q2.top());
					q2.pop();
				}
				q2 = priority_queue< int, vector< int >, greater< int > >();
			} else {
				q2.push(A[i]);
			}
		}
		int tmp = 0;
		int mina = LINF, maxa = 0;
		while (tmp < Q && !q3.empty()) {
			int a = q3.top();
			q3.pop();
			chmin(mina, a);
			chmax(maxa, a);
			++tmp;
		}
		//cout << maxa - mina << endl;
		if (tmp < Q)
			break;
		chmin(ans, maxa - mina);
		if (q.empty())
			break;
		int index = q.top().second;
		done[index] = true;
		q.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#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, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );

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

    ll N;
    cin>>N;
    vector<ll> A(N),B(N);
    ll a;
    FOR(i,0,N){
        cin>>a;
        A[i]=a;
        B[i]=a;
    }
    VSORTR(A);
    FOR(i,0,N){
        if(B[i]==A[0]) cout<<A[1]<<endl;
        else cout<<A[0]<<endl;
    }
    


}



Measured memory_bytes: 4736
import sys

def L(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())

def anser(prod):
    print(prod%(10**9+7))
    exit()

def solver(L,R,d):
    ans = 0

    for i in range(L,R+1):
        if i % d ==0:
            ans += 1

    print(ans)

def main():

    L,R,d = LI()

    solver(L,R,d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
a, b = map(int,input().split())
if a*b < 0:
    print(abs(a+b)+1)
elif a == 0:
    if b<0:
        print(abs(b)+1)
    else:
        print(b)
elif b == 0:
    if a >= 0:
        print(a+1)
    else:
        print(abs(a))
elif a<b:
    print(abs(b-a))
else:
    print(abs(a-b)+2)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define fl float
#define db double
#define ii pair<ll,ll>
#define pii pair<ii,ii>
#define ford(i,a,b) for(int i=a;i<=b;i++)
#define foru(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,a,b) for(int i=a;i<b;i++)
#define oo 10000000000001
#define ooo -1000000000001
double kc(double a,double b,double c,double d)
{
    return sqrt((c-a)*(c-a)+(d-b)*(d-b));
}
double w,h,a,b;
double res=0;
int main()
{
    cin>>w>>h>>a>>b;
    res=kc(0,0,w,0)*kc(w,0,w,h);
    res=res/2;
    cout<<fixed<<setprecision(6)<<res<<" ";
    if(a==w/2 && b==h/2)
        cout<<1;
    else
        cout<<0;
    return 0;
}


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

int main() {
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if(a==0) cout << 1 << endl;
    if(b==0) cout << 2 << endl;
    if(c==0) cout << 3 << endl;
    if(d==0) cout << 4 << endl;
    if(e==0) cout << 5 << endl;
}

Measured memory_bytes: 3568
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
using namespace std;

//14???????????¨??´???
int X, Y;
char sky[101][101];
int answer[100][100];

int main(){
	/*scanf("%s", &(sky[0]));*/

	scanf("%d %d", &Y, &X);
	for (int i = 0; i < Y; ++i){
		scanf("%s", &(sky[i]));
	}

	for (int y = 0; y < Y; ++y){
		for (int x = 0; x < X; ++x){
			if (sky[y][x] == 'c'){
				answer[y][x] = 0;
			}
			else if (sky[y][x] == '.'){
				if (x == 0){
					answer[y][x] = -1;
				}
				else if (answer[y][x - 1] == -1){
					answer[y][x] = -1;
				}
				else{
					answer[y][x] = answer[y][x - 1]+1;
				}
			}
			
			if (x == 0){
				printf("%d", answer[y][x]);
			}
			else{
				printf(" %d", answer[y][x]);
			}
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 2780
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin>>N;
  vector<long long>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  long long maximum=0;
  long long maximum2=0;
  for(int i=0;i<N;i++){
    maximum=max(maximum,A.at(i));
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(A.at(i)==maximum){
      if(count==0){
        count=count+1;
      }
      else{
        maximum2=maximum;
      }
    }
    else{
      maximum2=max(maximum2,A.at(i));
    }
  }
  for(int i=0;i<N;i++){
    if(maximum==A.at(i)){
      cout<<maximum2<<endl;
    }
    else{
      cout<<maximum<<endl;
    }
  }
}


Measured memory_bytes: 3200
#include<stdio.h>
#define N 10000
int main()
{
 int n,a[N],c=0,i;
  scanf("%d",&n);
   for(i=0;i<n;i++)
 {
     scanf("%d ",&a[i]);
     c=c+(a[i]-1);
 }
 printf("%d",c);
 return 0;
 }

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

using namespace std;

// x番目のゴーレムをk番目のマスに移動させられるか確認する
bool checkLeft(int x, int k, string &s, vector<char> &t, vector<char> &d)
{
	for(int i = 0; i < t.size(); ++i)
	{
		if(t[i] == s[x])
		{
			if(d[i] == 'L')
			{
				--x;
			}
			else
			{
				++x;
			}
		}

		if(s[x] == '_')
		{
			return x == k;
		}
	}

	return false;
}

int main()
{
	int n, q;
	string s;

	cin >> n >> q;
	cin >> s;

	s = "_" + s + "_";

	vector<char > t(q);
	vector<vector<char> > d(2, vector<char>(q));
	for(int i = 0; i < q; ++i)
	{
		cin >> t[i] >> d[0][i];
		d[1][i] = (d[0][i] == 'L' ? 'R' : 'L');
	}

	int golem = n;
	for(int i = 0; i < 2; ++i)
	{
		int lb = 0, m, ub = n + 1;
		while(ub - lb > 1)
		{
			m = (ub + lb) / 2;
			if(checkLeft(m, 0, s, t, d[i]))
			{
				lb = m;
			}
			else
			{
				ub = m;
			}
		}

		reverse(s.begin(), s.end());

		golem -= lb;
	}

	cout << golem << endl;
}

Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
//素因数分解

int main(void){
	int n,k,r,s,p;
	scanf("%d %d",&n,&k);
	scanf("%d %d %d",&r,&s,&p);
	char jk[100000];
	scanf("%s",jk);
	int score=0;
	char un='a';
	for(int m=0;m<n;m++){
		//unセット
		if(m-k>=0){
			un=jk[m-k];
		}

		if(jk[m]!=un){
			if(jk[m]=='r'){
				score+=p;
			}else if(jk[m]=='s'){
				score+=r;
			}else{
				score+=s;
			}
		}else{
			jk[m]='q';
		}
	}
	printf("%d",score);
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int n;
int happy[100100][5];
int dp[100100][5];

int solve(int now, int act){
	if(dp[now][act] != -1) return dp[now][act];
	if(now==n)return 0;
	else{
		int tmp = -1;
		for(int i=0; i<3; i++){
			if(i!=act){
				tmp=max(tmp,solve(now+1,i)+happy[now][i]);
			}
		}
		return dp[now][act]=tmp;
	}
}

int main(){
	cin >> n;
	dp[n][0] = dp[n][1] = dp[n][2] = -1;
	for(int i=0; i<n; i++){
		cin >> happy[i][0] >> happy[i][1] >> happy[i][2];
		dp[i][0] = dp[i][1] = dp[i][2] = -1;
	}
	cout << solve(0,5) << endl;

	return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int N;
    cin >> N;
    vector<vector<int>> a(N, vector<int>(3));
    rep(i,N){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    vector<vector<ll>> dp(100010, vector<ll>(3));
    rep(i,N){
        rep(j,3){
            rep(k,3){
                if(j!=k){
                    chmax(dp[i+1][k],dp[i][j]+a[i][k]);
                }
            }
        }
    }

    ll res=0;
    rep(i,3) {
        chmax(res, dp[N][i]);
    }
    cout << res << endl;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		char c[]=ob.next().toCharArray();
		int sum=0;
		for(int i=0;i<c.length;i++){
		sum=sum+Character.getNumericValue(c[i]);
		}
		if(sum%9==0){System.out.println("Yes");}
		else{System.out.println("No");}
	}
}


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

int main(){
    string S;
    cin >> S;
    int s=S.size();
    int ans=0;
    rep (i,s-1){
        if (S[i]!=S[i+1]&&i!=s-2){
            ans++;
        }
        else if (S[i]!=S[i+1]&&i==s-2){
            ans+=2;
        }
        else if (i!=s-2){
            ans+=2;
            i+=2;
            if (i==s-2){
                ans++;
            }
        }
        else {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  
  if(a < b)
  {
    if(b < c)
    {
      printf("Yes\n");
    }
    else
    {
      printf("No\n");
    }
  }
  else
  {
     printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define F first
#define S second
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

ll power(ll x,ll y){
    ll res = 1;
    while(y){
        if(y&1) res = (res*x)%mod;
        x = (x*x)%mod;
        y = y/2;
    }
    return res;
}

void  solve(){
    int n;
    cin>>n;
    vl a(n),pre(n);
    ll sum =0 ,ans =0;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll pro = 1;
    pre[0] = 1;
    for(int i=1;i<n;i++) {
        pro = (pro*i)%mod;
        pre[i] = power(i+1,mod-2);
        pre[i] = (pre[i]+pre[i-1])%mod;
    }
    for(int i=0; i<n-1;i++){
        ll pans;
        pans = ((a[i+1] - a[i])*pre[i])%mod;
        ans = (ans + pans)%mod;
    }
    ans = (ans*pro)%mod;
    cout<<ans;
}
        
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   // int n; cin>>n; for(int i=0;i<n;i++)
        solve();
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		int min = 10;
		int answer = 0;
		for(int i = 0; i < 5; i++){
			int a = sc.nextInt();
			if(a%10 == 0){
				answer += a;
			}else if(a%10 < min){
				min = a%10;
				answer += a/10*10+10;
			}else{
				answer += a/10*10+10;
			}
		}
		answer -= 10 - min;
		System.out.println(answer);
	}
}

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

using namespace std;

int main() {
	int ans = 0;
	string s;
	cin >> s;
	int conti = 0;
	for (int i = 0;i < s.length();i++) {
		if (s[i] == 'S') {
			ans = max(ans, conti);
			conti = 0;
		}
		else {
			conti++;
		}
	}
	ans = max(ans, conti);
	cout << ans << endl;
}

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

using namespace std;

int binary_search(vector<int> vec, int key);

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

    vector<int> s(n);
    for (int i = 0; i < n; ++i)
        cin >> s[i];

    int q;
    cin >> q;

    vector<int> t(q);
    for (int i = 0; i < q; ++i)
        cin >> t[i];

    int count = 0;
    for (int i = 0; i < q; ++i) {
        if (binary_search(s, t[i]) != -1)
            ++count;
    }

    cout << count << '\n';
}

int binary_search(vector<int> vec, int key)
{
    int left = 0;
    int right = vec.size() - 1;
    int mid = (left + right) / 2;

    while (left <= right) {
        mid = (left + right) / 2;

        if (vec[mid] == key)
            return mid;
        else if (vec[mid] < key)
            left = mid + 1;
        else
            right = mid - 1;
    }

    return -1;
}



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

char a[3000000];
int head = 1000001, tail;
int n;
bool fl = 0;

int main() {
	cin >> (a + 1000001) >> n;
	tail = strlen(a + 1000001) + 1000000;
	while(n--) {
		int opt;
		cin >> opt;
		if(opt == 1) fl = !fl;
		else {
			char ch;
			int pos;
			cin >> pos >> ch;
			if(pos == 1) {
				if(!fl) a[--head] = ch;
				else a[++tail] = ch;
			}
			else {
				if(!fl) a[++tail] = ch;
				else a[--head] = ch;
			}
		}
	}
	if(!fl)
		for(int i = head; i <= tail; ++i)
			putchar(a[i]);
	else
		for(int i = tail; i >= head; --i)
			putchar(a[i]);
	return 0;
}

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

//At Boss's Expense
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean[] prime = new boolean[1000001];
		Arrays.fill(prime, true);
		prime[1] = false;
		for(int i=2;i<1000001;i++){
			if(prime[i]){
				for(int j=i*2;j<1000001;j+=i)prime[j]=false;
			}
		}
		while(true){
			int n = sc.nextInt();
			int x = sc.nextInt();
			if((n|x)==0)break;
			int[] p = new int[n];
			boolean[] f = new boolean[x+1];
			f[0] = true;
			for(int i=0;i<n;i++){
				p[i]=sc.nextInt();
				for(int j=p[i];j<=x;j+=p[i])f[j]=true;
			}
			int max = 0;
			for(int i=1;i<=x;i++){
				if(!f[i]){
					for(int j=0;j<n;j++){
						if(i-p[j]>=0 && f[i-p[j]]){
							f[i] = true;
							break;
						}
					}
				}
				if(f[i] && prime[i])max = i;
			}
			System.out.println(max==0?"NA":max);
		}
	}
}

Measured memory_bytes: 15000
use std::io;
use std::cmp;


fn main() {
    let n = read_one::<usize>();
    let (a, b) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let mut pn = read::<usize>();
    pn.sort();
    let cnt_a = pn.iter().filter(|p| **p <= a).count();
    let cnt_c = pn.iter().filter(|p| **p > b).count();
    let cnt_b = n - cnt_a - cnt_c;
    println!("{}", cmp::min(cnt_a, cmp::min(cnt_b, cnt_c)));
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <vector>
#include <iostream>
#include <ctime>
#include <unistd.h>

using namespace std;

#define TRACE(x) cerr << #x <<  " = " << x << endl
#define _ << " " <<
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

#define X first
#define Y second

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

const int MAX = 105;

char s[MAX][MAX];
int brred, brstup;
int cnt[26];

int main()
{
  scanf("%d%d", &brred, &brstup);
  REP(i, brred) {
    scanf(" %s", s[i]);
    REP(j, brstup)
      cnt[s[i][j]-'a']++;
  }
 
  int cnt4 = (brred / 2) * (brstup / 2);
  int cnt2 = 0;
  if (brred % 2) cnt2 += brstup / 2;
  if (brstup % 2) cnt2 += brred / 2;
  int cnt1 = (brstup % 2) * (brred % 2);

  assert(cnt1 + 2*cnt2 + 4*cnt4 == brred*brstup);
  
  REP(i, 26)
    for (; cnt4 && cnt[i] >= 4; cnt[i]-=4, cnt4--);

  REP(i, 26)
    for (; cnt2 && cnt[i] >= 2; cnt[i]-=2, cnt2--);

  REP(i, 26)
    for (; cnt1 && cnt[i] >= 1; cnt[i]--, cnt1--);

  if (cnt1 == 0 && cnt2 == 0 && cnt4 == 0)
    printf("Yes\n");
  else
    printf("No\n");
   

  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		int x = scan.nextInt();
		int n = scan.nextInt();
		
		ArrayList<Integer> list = new ArrayList<Integer>();
		
		for(int i = 0; i < n; i++) {
			list.add(scan.nextInt());
		}
		
		for(int i = 0; i < 102; i++) {
			if(list.contains(x-i) != true) {
				System.out.print(x-i);
				return;
			}
			else if(list.contains(x+i) != true) {
				System.out.print(x+i);
				return;
			}
		}
		
	}
}

Measured memory_bytes: 35964
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

INF = 10**5
temp = INF

for i in range(N):
  t = T - H[i]*0.006
  if abs(t-A) <= temp:
    temp = abs(t-A)
    ans = i+1

print(ans)

Measured memory_bytes: 9176
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var M = sc.nextInt();
        var k = new int[M];
        var s = new int[M][];
        for (int i = 0; i < M; i++) {
            k[i] = sc.nextInt();
            var tmp = new int[k[i]];
            for (int j = 0; j < k[i]; j++) {
                tmp[j] = sc.nextInt();
            }
            s[i] = tmp;
        }
        var p = new int[M];
        for (int i = 0; i < M; i++) {
            p[i] = sc.nextInt();
        }

        var ans = new Dictionary<int, int>();
        var bit = N;
        for (int m = 0; m < M; m++) {
            for (int i = 0; i < (1 << bit); i++) {
                if (m == 0) ans.Add(i, 0);
                var cnt = 0;
                for (int j = 0; j < bit; j++) {
                    if ((1 & i >> j) == 1) {
                        if (s[m].Any(a => a == j + 1)) cnt++;
                    }
                }
                if (cnt % 2 == p[m]) ans[i]++;
            }
        }

        WriteLine(ans.Count(kvp => kvp.Value == M));
    }
}


class Scanner {
    string[] s;
    int i;

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

    public Scanner() {
        s = new string[0];
        i = 0;
    }

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

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

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

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

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

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 17560
N = int(input())

ans="Yes"
ta = xa = ya = 0
for i in range(N):
    tb, xb, yb = map(int, input().split())
    sa = tb-ta-(abs(xb-xa)+abs(yb-ya))
    if (sa>=0)&(sa%2==0):
        continue
    else:
        ans="No"
        break
    
print(ans)

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

int main(){
    int a,b,d,r ;
    double f;

    cin >> a >> b ;
    
    d = a/b ;
    r = a%b ;
    f = 1.0*a/b ;
    
    cout << d << "  " << r << " " << fixed << f << endl;
    return 0 ;
    }

Measured memory_bytes: 3292
n,m=map(int,input().split())

class UnionFind():
    def __init__(self,num):
        self.n = num         #class内変数nに、外部から入力した値numを代入
        self.parents = [-1 for i in range(self.n)]
          #parentsは要素の親(1こ上のやつ)番号0~n-1を格納、自分が最親なら-(要素数)を格納(初期値は-1)

    #xの最親は誰？
    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x]) #再帰して1番上までいってる
                #調べながらparentsの値を更新してる！（経路圧縮）
            return self.parents[x]

    #結合せよ
    #xの親とyの親をくっつける
    def union(self,x,y):
        xx=self.find(x)  #xxはxの最親
        yy=self.find(y)  #yyはyの最親
        if xx==yy:
            return     #同じ屋根の下にあった場合は何もしない
        else:
            size_xx=abs(self.parents[xx]) #xが含まれる木のサイズ
            size_yy=abs(self.parents[yy]) #yが含まれる木のサイズ
            if size_xx>size_yy:
                xx,yy=yy,xx  #yyの方が大きい木、ってことにする

            self.parents[yy]+=self.parents[xx] #大きい木のサイズ更新
            self.parents[xx]=yy   #サイズが小さい木を大きい木に接ぐ

    #xの属する木の大きさ（まあunionでも使ったけど）
    def size(self,x):
        xx=self.find(x)
        return abs(self.parents[xx])

    #xとyはこの空の続く場所にいますか　いつものように笑顔でいてくれますか　今はただそれを願い続ける
    def same(self,x,y):
        return 1 if self.find(x)==self.find(y) else 0

    #xと　同じ木にいる　メンバーは？
    def members(self,x):
        xx=self.find(x)
        return [i for i in range(self.n) if self.find(i)==xx]
             #ifの条件式に漏れたら無視

    #最親だけを並べあげる
    def roots(self):
        return [i for i,x in enumerate(self.parents) if x < 0]
        #いやこれは天才すぎる、basisのenumerate.py参照

    #すべての最親について、メンバーを辞書で
    def all_group_members(self):
        return {r:self.members(r) for r in self.roots()}

    #グループ分けどうなりましたか、２重リストで
    def state_grouping(self):
        return list(self.all_group_members().values())

uf=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    uf.union(a,b)

print(len(uf.roots())-1)

Measured memory_bytes: 74920
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  int32_t A, B, C;

  cin >> A >> B >> C;

  if ((A <= C) && (C <= B)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/// [Amberjack] CUT BEGIN
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define __GET_REP_MACRO(_1,_2,_3,NAME,...) NAME
#define __REP0(i,n) for(_loop_int i=0;i<(n);++i)
#define __REP1(i,a,b) for(_loop_int i=(a);i<(b);++i)
#define __REPR0(i,n) for(_loop_int i=(n)-1;i>=0;--i)
#define __REPR1(i,a,b) for(_loop_int i=(b)-1;i>=(a);--i)
#define REP(...) __GET_REP_MACRO(__VA_ARGS__,__REP1,__REP0)(__VA_ARGS__)
#define REPR(...) __GET_REP_MACRO(__VA_ARGS__,__REPR1,__REPR0)(__VA_ARGS__)

#ifdef BURI
#define __DEBUG0() "Hello"
#define __DEBUG1(x) #x"("<<(x)<<")"
#define __DEBUG2(x,...) #x"("<<(x)<<"), " __DEBUG1(__VA_ARGS__)
#define __DEBUG3(x,...) #x"("<<(x)<<"), " __DEBUG2(__VA_ARGS__)
#define __DEBUG4(x,...) #x"("<<(x)<<"), " __DEBUG3(__VA_ARGS__)
#define __DEBUG5(x,...) #x"("<<(x)<<"), " __DEBUG4(__VA_ARGS__)
#define __GET_DEBUG_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define __DEBUG(...) __GET_DEBUG_MACRO(__VA_ARGS__,__DEBUG5,__DEBUG4,__DEBUG3,__DEBUG2,__DEBUG1,__DEBUG0)(__VA_ARGS__)
#define DEBUG(...) cerr<<__DEBUG(__VA_ARGS__)<<endl
#else
#define DEBUG(...)
#endif

inline void getll(ll &x){
  int sgn=1;x=0;
  char c=getchar();
  while(c!='-'&&(c<'0'||c>'9'))c=getchar();
  if(c=='-') sgn=-1; else x=c-'0';
  c=getchar();
  while('0'<=c&&c<='9'){
    x*=10;
    x+=c-'0';
    c=getchar();
  }
  x*=sgn;
}
inline void read(ll &x){getll(x);}
inline void read(int &x){ll y;getll(y);x=y;}
inline void read(float &x){scanf("%f",&x);}
inline void read(double &x){scanf("%lf",&x);}
inline void read(long double &x){scanf("%Lf",&x);}
inline void read(char *s){scanf("%s",s);}
inline void read(string &s){int len=s.size();char *buf=(char*)malloc(len*sizeof(char));scanf("%s",buf);s=string(buf);free(buf);}
inline void read(char &c){char *buf=(char*)malloc(5*sizeof(char));scanf("%s",buf);c=buf[0];free(buf);}
inline void read(){}
template<typename S,typename ...T>
inline void read(S& first, T&... rest){
  read(first);
  read(rest...);
}
/// [/Amberjack] CUT END

int n;
int a[125252];
int main(){
  read(n);
  REP(i,n)read(a[i]);
  ll ans = 0;
  int ban = 0;
  REP(i,n){
    ll k = ban+1;
    if(a[i]==k){
      ban = k;
      continue;
    }
    ans += (a[i]-1)/k;
    if(ban==0)ban=1;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;
 

int main() {
    ll n;
    cin >> n;
    vector<ll> tests(n, 0);
    vector<ll> nontests(n, 0);
    for (ll i = 0; i < n; ++i) {
        ll a;
        cin >> a;
        tests[i] |= 1<<i;
        for (ll j = 0; j < a; ++j) {
            ll x, y;
            cin >> x >> y;
            --x;
            if (y == 1) {
                tests[i] |= 1<<x;
            } else {
                nontests[i] |= 1<<x;
            }
        }
    }

    //for (ll i = 0; i < n; ++i) {
    //    cerr << i << ":" << bitset<8>(tests[i]) << "  -" << bitset<8>(nontests[i]) << endl;
    //}

    ll ans = 0;
    ll mask = ((1<<n)-1);
    for (ll i = 1; i < 1<<n; ++i ) {
        ll cur = 0;
        //cerr << bitset<8>(i) << ": " << endl;;
        ll test = 0;
        ll nontest = 0;
        for (ll j = 0; j < n; ++j) {
            if (i & 1<<j) {
                ++cur;
                test |= tests[j];
                nontest |= nontests[j];
            }
        }
        //cerr << "  " << bitset<8>(test) << " " << bitset<8>(nontest) << endl;;
        if (i == test && ((i & nontest) == 0)) {
            ans = max(ans, cur);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
<?php
list($n,$m) = explode(" ",trim(fgets(STDIN)));

if($n > $m / 2){
$ans = floor($m / 2);
}else{
$ans = $n;
$m -= $n * 2;
$n = 0;
if($m >= 4){
$ans += floor($m / 4);
}
}

echo $ans ;
?>

Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{

	public static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

		var N = input[0];
		var M = input[1];

		var shopDic = new Dictionary<long, long>();
		for (int i = 0; i < N; i++)
		{
			input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			// 既にキーが追加されていたら値だけ追加
			if (shopDic.ContainsKey(input[0]))
			{
				shopDic[input[0]] += input[1];
			}
			else
			{
				shopDic.Add(input[0], input[1]);
			}
		}
		shopDic = shopDic.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value);

		long answer = 0;
		foreach (KeyValuePair<long, long> pair in shopDic)
		{
			// 次の店に行く必要がない場合
			if (M <= pair.Value)
			{
				answer += pair.Key * M;
				break;
			}
			else
			{
				answer += pair.Key * pair.Value;
				M -= pair.Value;
			}
		}

		Console.WriteLine(answer);
	}
}


Measured memory_bytes: 35508
N = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

A.append(10 ** 9 + 2)

ap = 0

Bnum = []

ans = 0

for i in range(N):

    b = B[i]

    while True:

        if A[ap] < b:

            ap += 1

        else:

            break

    if i == 0:
        Bnum.append(ap)

    else:
        Bnum.append(ap + Bnum[-1])

bp = 0
B.append(10 ** 9 + 2)

for i in range(N):

    c = C[i]

    while True:

        if B[bp] < c:

            bp += 1

        else:

            break

    if bp != 0:
        ans += Bnum[bp-1]

print (ans)



Measured memory_bytes: 108772