akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

void division(ll N, vector<vector<ll>> &v, vector<pll> &vv, int i) {
    ll cnt2 = 0, cnt5 = 0;
    while (N % 2 == 0) {
        N /= 2;
        cnt2++;
    }
    while (N % 5 == 0) {
        N /= 5;
        cnt5++;
    }
    v[cnt2][cnt5]++;
    vv[i] = {cnt2, cnt5};
}

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

    int N;
    cin >> N;
    vector<ll> A(N);
    vector<vector<ll>> div(60, vector<ll>(60, 0));
    vector<pll> vv(N);
    rep(i, N) {
        string a;
        cin >> a;
        ll ss = 0, exp = 1, cnt = 0;
        bool judge = 1;
        for (int i = a.size() - 1; i > -1; i--) {
            if (a[i] == '.') {
                judge = 0;
                continue;
            } else if (judge)
                cnt++;
            ss += exp * (a[i] - '0');
            exp *= 10;
        }

        if (judge)
            ss *= pow(10, 9);
        else
            ss *= (ll)pow(10, 9 - cnt);

        A[i] = ss;
        division(A[i], div, vv, i);
    }

    ll ans = 0;
    rep(i, N) {
        ll need2 = max(0LL, 18 - vv[i].first),
           need5 = max(0LL, 18 - vv[i].second);
        for (int i = need2; i < 60; i++) {
            for (int j = need5; j < 60; j++) {
                ans += div[i][j];
            }
        }
        if (need2 <= vv[i].first && need5 <= vv[i].second) // 自分を引く
            ans--;
    }

    ans /= 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7936
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        String a = sc.next();
        String s = sc.next();
        String c = sc.next();

        sc.close();

        System.out.println("A" + s.charAt(0) + "C");

    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(0);
	
	int N, K; cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	for (int i = K; i < N; i++) {
		if (A[i - K] < A[i]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3984
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using ul = unsigned long long;
using ld = long double;

int main() {
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
	ll n, k, s, inf = 1e9;
    cin >> n >> k >> s;
    ll r = (s == inf ? 1 : inf);
    rep(i, n)
        cout << (i < k ? s : r) << ' ';
}



Measured memory_bytes: 1280
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define line cout << "----------" << endl;


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
void Yay(bool condition){

    if(condition){
        p("Yay!");
    }else{
        p(":(");
    }
    return;
}

//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,ans,a,b,c,d,e,g,h,w,i,j,k,q;
ll x[500005],y[500005],z[500005];
ll sum[500005],lsum[500005];
char s[500005],t[500005];
bool dame;



int main(){
	cin >> n;
	P table[500005];
	for(i=0;i<n;i++){
		cin >> a >> b;
		table[i].first = b;
		table[i].second = a;
	}
	sort(table,table + n);
	bool dame = false;
	ll time = 0;
	for(i=0;i<n;i++){
		time += table[i].second;
		//pe(time);p(table[i].first);
		if(time > table[i].first){
			dame = true;
			break;
		}

	}
	Yes(!dame);
	return 0;
}


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

int N, Q;
string S;

int main(){
  cin >> N >> Q;
  cin >> S;
  vector<int> L(Q);
  vector<int> R(Q);

  vector<int> A(N+1, 0);

  for(int i =0; i<N; i++){
    if(S[i] == 'A'){
      if(S[i+1] == 'C'){
        A[i+1] += A[i] +1;
      }else{
        A[i+1] = A[i];
      }
    }else{
      A[i+1] = A[i];
    }
  }



  for(int i = 0; i< Q; i++){
    cin >> L.at(i) >> R.at(i);
  }

  for(int i = 0; i< Q; i++){
    cout << A[R.at(i)-1] - A[L.at(i)-1] << endl;
  }

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









  return 0;

}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

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

using namespace std;
typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        vector<int> v(n);
        rep(i,n) cin >> v[i];

        string s;
        cin >> s;

        rep(i,s.size()) {
            int j = i%n;
            for(int k=v[j];k>0;k--) {
                if(s[i] == 'a') s[i] = 'Z';
                else if(s[i] == 'A') s[i] = 'z';
                else s[i]--;
            }
        }

        cout << s << endl;
    }

    return 0;
}

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

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    int sum = r * 100 + g * 10 + b;
    if (sum % 4 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3572
n = int(input())
li = list(map(int, input().split()))
cnt = 0

flag = True

while flag:
	flag = False
	for i in range(n-1,0,-1):
		if li[i] < li[i-1]:
			li[i], li[i-1] = li[i-1], li[i]
			flag = True
			cnt +=1

print(*li)
print(cnt)

Measured memory_bytes: 7700
N, K = list(map(int, input().split()))
B = [0]*N
for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for one in A:
        B[one-1]+=1
cnt = 0
for one in B:
    if one==0:
        cnt+=1
print(cnt)

Measured memory_bytes: 67620
#define errOut(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << std::endl; }

#include <bits/stdc++.h>

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;
#define errOut(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << std::endl; }

#include <bits/stdc++.h>

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

static std::string const YES = "Yes";
static std::string const NO = "No";

bool solve(int64_t  /*n*/, std::vector<std::vector<int64_t>> dss) {
  int cnt = 0;
  for (auto const& ds : dss) {
    if (ds[0] == ds[1]) {
      cnt++;
      if (cnt >= 3) {
        return true;
      }
    } else {
      cnt = 0;
    }
  }
  return false;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  std::vector<std::vector<int64_t>> dss(n, std::vector<int64_t>(2));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      std::cin >> dss[i][j];
    }
  }
  auto const res = solve(n, std::move(dss));
  std::cout << (res ? YES : NO) << std::endl;
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define int long
main(){
  int n,r=0;
  cin>>n;
  vector<int> a(n),b(n),c(n-1);
  for(auto& i:a)cin>>i;
  for(auto& i:b)cin>>i;
  for(auto& i:c)cin>>i;
  for(int i=0;i<n;++i){
    r+=b[a[i]-1]+(i&&a[i-1]+1==a[i]?c[a[i-1]-1]:0);
  }
  cout<<r;
}

Measured memory_bytes: 256
// AOJ 2117 Connect Line Segments
// 2018.3.18 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef struct { double x, y; } PP;

#define INF 1e16
int N;
PP pp[14][2];
double dis[14][2][14][2];
double dp[1 << 14][14][2];

double dist(PP p1, PP p2) { return hypot(p1.x - p2.x, p1.y - p2.y); }

double travellingSalesman(int n)
{
	int s, v, i, j, k, m, max;
	double x, ans;

	max = 1 << n;
	for (s = 0; s < max; s++) for (v = 0; v < n; v++) for (i = 0; i < 2; i++) dp[s][v][i] = INF;
	for (v = 0; v < n; v++) for (i = 0; i < 2; i++) dp[1 << v][v][i] = 0;

	for (s = 0; s < max; s++) for (v = 0; v < n; v++) if ((s >> v) & 1) {
		for (i = 0; i < 2; i++) {
			for (j = 0; j < n; j++) {
				if ((s >> j) & 1) continue;
				for (k = 0; k < 2; k++) {
					m = s | (1 << j);
					x = dp[s][v][i] + dis[v][i][j][k];
					if (dp[m][j][!k] > x) dp[m][j][!k] = x;
				}
			}
		}
	}
	ans = INF;
	for (v = 0; v < n; v++) for (i = 0; i < 2; i++) {
		if (ans > dp[max - 1][v][i]) ans = dp[max - 1][v][i];
	}
	return ans;
}

int main()
{
	int cno, i, j;
	double ans;

	cno = 0;
	while (scanf("%d", &N) && N) {
		for (i = 0; i < N; i++) {
			scanf("%lf%lf%lf%lf", &pp[i][0].x, &pp[i][0].y, &pp[i][1].x, &pp[i][1].y);
		}
		ans = 0;
		for (i = 0; i < N; i++) {
			ans += dist(pp[i][0], pp[i][1]);
			for (j = i + 1; j < N; j++) {
				dis[i][0][j][0] = dis[j][0][i][0] = dist(pp[i][0], pp[j][0]);
				dis[i][0][j][1] = dis[j][1][i][0] = dist(pp[i][0], pp[j][1]);
				dis[i][1][j][0] = dis[j][0][i][1] = dist(pp[i][1], pp[j][0]);
				dis[i][1][j][1] = dis[j][1][i][1] = dist(pp[i][1], pp[j][1]);
			}
		}
		ans += travellingSalesman(N);
		printf("Case %d: %.8lf\n", ++cno, ans);
	}
	return 0;
}


Measured memory_bytes: 5424
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        // String s = sc.next();
        // int cnt = 1;

        // for (int i = 0; i < n - 1; i++) {
        // if (s.charAt(i + 1) != s.charAt(i)) {
        // cnt++;
        // }
        // }
        System.out.println((n + 1) / 2);
        sc.close();
    }
}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(String.format("%d %d %f", a / b, a % b, (double)a / (double)b));
		}
	}
}



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

int main(){
  int S,W;
  cin>>S>>W;
  if(S>W){
    cout<<"safe"<<endl;
  }else{
    cout<<"unsafe"<<endl;
  }


}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int n;
	cin>>n;
	vi a(n);
	rep(i, n) cin>>a[i];
	if(n==1) {
		cout<<0<<endl;
		return 0;
	}
	if(n == 2){
		int ans = a[0] > a[1] ? 1: 0;
		cout<<ans<<endl;
		return 0;

	}
	map<int,int> m;
	rep(i, n) m[a[i]]++;
	int cnt = 1;
	for(auto&p:m) p.se = cnt++;
	rep(i, n) a[i] = m[a[i]];
	ll ans = 0LL;
	rep(i, n) if(abs(a[i] - i) % 2 == 0) ans ++;
	cout<<ans/2<<endl;
}

Measured memory_bytes: 5376
import java.io.*;

public class Main{

    public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String N_moji = br.readLine();
	int N = Integer.parseInt(N_moji);
	String S = br.readLine();
	int x_max = 0,i,x = 0;
	for(i = 0; i < N; i++){
	    if(S.charAt(i) == 'D'){
		x--;
	    }
	    else{
		x++;
		if(x_max <= x){
		    x_max = x;
		}
	    }
	}
	System.out.println(x_max);
    }
}
		
	    
	    
	    
	


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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define int long long

int r, d, x;

signed main()
{
	IOS;
	cin >> r >> d >> x;
	int cur = r * x - d;
	cout << cur << endl; 
	for (int i = 1; i < 10; i++) {
		cur = r * cur - d;
		cout << cur << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

int main() {
  unsigned long long N, M;
  std::cin >> N >> M;
  unsigned long long ans = M * 1900 + (N - M) * 100;
  for (unsigned i = 0; i < M; ++i) {
    ans *= 2;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 888
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());

            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);

            var flag = false;
            for(var i = a; i <= b; i++){
                flag = i % k == 0 ? true: false;

                if(flag){
                    break;
                }
            }

            Console.WriteLine(flag ? "OK" : "NG");
        }
    }
}


Measured memory_bytes: 27532
// 枝刈り有り
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

int n, q;
vector<int> A;

bool solve(int i, int m) {
    if (m == 0) return true;
    if(i >=n || m < 0) return false;
    return solve(i + 1, m) || solve(i + 1, m - A[i]);
}

int main() {
    cin >> n;
    A.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int m;
        cin >> m;
        bool ans = solve(0, m);
        if(ans) cout << "yes" << endl;
        else cout << "no" << endl;
    }

    return 0;
}




Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    if ( N*2 >= M) {
        cout << M/2 << endl;
        return 0;
    }

    cout << N + (M-N*2)/4 << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#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 all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen
class MF{//max flow
	public:
	int n;
	vector<vector<edge> >G;//[MAX];
	vector<bool>used;//[MAX];
	MF(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int from, int to, int cap){
		edge q={to,cap,int(G[to].size())};
		G[from].push_back(q);
		q={from,0,int(G[from].size()-1)};
		G[to].push_back(q);
	}
	int dfs(int v,int t, int f) {
		if(v==t)return f;
		used[v]=1;
		for(int i=0;i<G[v].size();i++){
			edge &e=G[v][i];
			if(used[e.to]||e.cap<=0) continue;
			int d =dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
		return 0;
	}
	int mf(int s,int t) {//from s to t,ford_fulkerson
		int flow=0,f;
		while(1){
			used=vector<bool>(n,false);
			f=dfs(s,t,inf);
			if(f==0)return flow;
			flow+=f;
		}
	}
};
int f(vi w){
	int n=w.size();
	MF mf(2*n+2);
	int s=2*n,t=s+1;
	rep(i,n)mf.add_edge(s,i,1);
	rep(i,n)mf.add_edge(n+i,t,1);
	rep(i,n)rep(j,n)if(i!=j&&w[i]%w[j]==0)
		mf.add_edge(i,n+j,1);
	return n-mf.mf(s,t);
}
int res;
vi out;
void F(vi w){
	if(w.size()==0)return;
	vi go;
	rep(i,w.size()-1)if(w[i+1]%w[0]&&w[0]%w[i+1])
		go.pb(w[i+1]);
	int flow=f(go);
//	cout<<" "<<flow<<endl;
//	rep(i,go.size())cout<<go[i]<<" ";cout<<endl;
	if(flow==res-1-out.size()){
		out.pb(w[0]);
		F(go);
	}else{
		w.erase(w.begin());
		F(w);
	}
}
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	map<int,int>ma;
	rep(i,n)ma[in[i]]=i+1;
	res=f(in);
	F(in);
	rep(i,out.size())cout<<ma[out[i]]<<(i==out.size()-1?"\n":" ");
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 int a[3][3];
 for(int i=0;i<3;i++)for(int j=0;j<3;j++)cin>>a[i][j];
 set<int> b;
 int n;
 cin>>n;
 for(int i=0;i<n;i++){
  int c;
  cin>>c;
  b.insert(c);
 }
 for(int i=0;i<3;i++)
  for(int j=0;j<3;j++)if(b.find(a[i][j]) != b.end() )a[i][j] = 0;
 
 int n1=0,n2=0;
 for(int i=0;i<3;i++){
  int t=0,y=0;
  n1+=a[i][i];
  n2+=a[i][2-i];
  for(int j=0;j<3;j++){
   t+=a[i][j];
   y+=a[j][i];
  }
  if(t*y==0){
   cout<<"Yes"<<endl;
   return 0;
  }
 }
 if( n1*n2==0 ){
  cout<<"Yes"<<endl;
  return 0;
 }
 cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int ans = n;
	rep(i, n + 1) {
		int cnt = 0;
		int tmp = i;
		while (tmp > 0) {
			cnt += tmp % 6; tmp /= 6;
		}
		tmp = n - i;
		while (tmp > 0) {
			cnt += tmp % 9; tmp /= 9;
		}
		chmin(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

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

	std::vector<int> mochi(101,0);
	int d;

	for (int i = 1; i <= N; i++)
	{
		cin >> d;
		if (mochi[d] == 0) mochi[d] = 1;
	}

	int sum =0 ;

	for (int i = 1; i <= 100 ; ++i)
	{
		sum += mochi[i];
	}

	cout << sum << endl; 

	return  0;

}

Measured memory_bytes: 256
import itertools
N=int(input())
A=tuple(map(int, input().split()))
B=tuple(map(int, input().split()))
#print(A,B)
S=list(range(1,N+1)) 
T=list(itertools.permutations(S))
#print(T)
X=T.index(A)
Y=T.index(B)
print(abs(X-Y))

Measured memory_bytes: 8052
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    
    int A[N],B[N],C[N];
    for(int i=1;i<=N;i++){
        cin >> A[i];
    }
    for(int i=1;i<=N;i++){
        cin >> B[i];
    }
    for(int i=1;i<=N-1;i++){
        cin >> C[i];
    }
    
    int ans = 0;
    for(int i=1;i<=N;i++){
        ans += B[A[i]];
        if(A[i+1]==A[i]+1){
            ans += C[A[i]];
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

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

happy = dict()
for i in range(N):
    happy[A[i]] = B[i]

ans = sum(B)
for i in range(1, N):
    if A[i] - A[i-1] == 1:
        ans += C[A[i-1]-1]

print(ans)


Measured memory_bytes: 3064
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong(); 
    long cap[] = new long[5]; // array
    for (int i=0; i<5; i++) {
      cap[i] = sc.nextLong();
    }
    Arrays.sort(cap);
    long num_iter = (long) Math.ceil(N/(double) cap[0]);
    System.out.println(num_iter + 4);
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<ll> sum(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        sum[i + 1] = sum[i] + a[i];
    }

    map<ll, int> mp;
    ll ans = 0;
    for (int i = 0; i < n + 1; ++i) {
        if (mp[sum[i]] > 0) ans += mp[sum[i]];
        ++mp[sum[i]];
    }

    cout << ans << endl;
}

Measured memory_bytes: 15872
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

llint f (llint n, llint x) {
	if (n == -1) {
		return 0;
	}
	return n/x + 1;
}

int main (void) {
	llint a, b,x; cin >> a >> b >> x;
	llint count = f(b, x) - f(a-1,x);
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define f first
#define s second

using namespace std;

typedef long long ll;

ostream& operator << (ostream &os, vector <ll> &v) {
    for (ll i : v)
        os << i << " ";
    os << "\n";
    return os;
}

const ll MAXN = 1001;
const ll M = 1e9 + 7;

ll dp[MAXN][MAXN];

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n, m;
    cin >> n >> m;
    vector <string> g(n);
    for (auto& i : g)
        cin >> i;
    dp[0][0] = 1;
    for (ll i = 0; i < n; ++i)
        for (ll j = 0; j < m; ++j) {
            if (i + 1 < n && g[i + 1][j] != '#')
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % M;
            if (j + 1 < m && g[i][j + 1] != '#')
                dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % M;
        }
    cout << dp[n - 1][m - 1] << "\n";
    return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pll A[55];
pll B[55];

int main()
{
    int N, M;
    cin >> N >> M;
    REP(i, N)
    {
        cin >> A[i].first >> A[i].second;
    }
    REP(i, M)
    {
        cin >> B[i].first >> B[i].second;
    }
    REP(i, N)
    {
        int t = 0;
        REP(j, M)
        {
            ll l0 = abs(A[i].first - B[j].first) + abs(A[i].second - B[j].second);
            ll l1 = abs(A[i].first - B[t].first) + abs(A[i].second - B[t].second);
            if (l0 < l1)
                t = j;
        }
        cout << t + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

static const int MAX_V = 1e3;

int V, match[MAX_V];
vector<int> G[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v){
	G[u].push_back(v);
	G[v].push_back(u);
}


bool dfs(int v) {
	used[v] = true;
	for (int i = 0; i < G[v].size(); ++i)
	{
		int u = G[v][i], w = match[u];
		if (w < 0 || (!used[w] && dfs(w)))
		{
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bipartite_matching() {
	int res = 0;
	fill(match, match+V, -1);
	for (int v = 0; v < V; ++v)
	{
		if (match[v] < 0)
		{
			fill(used, used+V, 0);
			if (dfs(v)) res++;
		}
	}
	return res;
}

int main(int argc, char const *argv[])
{
	int x, y, e;
	cin >> x >> y >> e;
	V = x+y;
	for (int i = 0; i < e; ++i)
	{
		int xi, yi;
		cin >> xi >> yi;
		yi+=x;
		add_edge(xi, yi);
	}
	cout << bipartite_matching() << endl;
	return 0;
}


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

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

	}

	vector<int>cost(n,0);
	cost[0]=0;
	cost[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++)
	{
		cost[i]=min(abs(arr[i]-arr[i-2])+cost[i-2],abs(arr[i]-arr[i-1])+cost[i-1]);
	}
	cout<<(cost[n-1])<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  ll MOD=1000000007;
  int n,k;
  cin>>n>>k;
  ll amari[k+1];
  for(int i=1;i<k+1;i++){
    amari[i]=modpow(i,n,MOD);
  }
  ll kosuu[k+1];
  ll ans=0;
  for(int i=k;i>=1;i--){
    kosuu[i]=amari[k/i];
    for(int j=2*i;j<=k;j+=i){
      kosuu[i]=mod(kosuu[i]-kosuu[j],MOD);
    }
    ans=mod(ans+kosuu[i]*i,MOD);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5104
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

bool is_all_even(std::vector<long long> vector)
{
    for (long long i : vector)
    {
        if (i % 2 != 0) { return false; }
    }
    return true;
}

int main()
{
    int N;
    long long a;
    std::cin >> N;
    std::vector<long long> vec;
    for (int i = 0; i < N; i++)
    {
        std::cin >> a;
        vec.push_back(a);
    }

    int ans = 0;
    while (is_all_even(vec))
    {
        ans++;
        for (int i = 0; i < vec.size(); i++) { vec[i] /= 2; }
    }

    std::cout << ans << std::endl;

    return 0;
}

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

int main(void) {
	int h, w;
	char c[101][101];

	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int t = 1; t <= w; t++) {
			cin >> c[i][t];
		}
	}
	
	for (int i = 1; i <= h; i++) {
		for (int u = 1; u <= 2; u++) {
			for (int t = 1; t <= w; t++) {
				cout << c[i][t];
			}
			cout << endl;
		}
	}
	return 0;
}

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

int main()
{
    int n;
    cin >> n ;
    int cost[n] , height[n];
    
    for (int i=0 ; i< n ;i++)
        cin >> height[i] ;
    cost[0]=0 , cost[1]=fabs(height[1]-height[0]);
    for (int i=2;i<n;i++)
        cost[i]=min(cost[i-1]+fabs(height[i]-height[i-1]),cost[i-2]+fabs(height[i]-height[i-2])) ;
    cout << cost[n-1];
    




}


Measured memory_bytes: 4312
using System;
namespace ConsoleApplication1
{
    class Program
    {
        private static int GCD(int num1, int num2)
        {
            int min = 0;
            int max = 0;
            int maxModMin = 0;
            min = Math.Min(num1, num2);
            max = Math.Max(num1, num2);
            maxModMin = max % min;
            return maxModMin > 0 ? GCD(min, maxModMin) : min;
        }

        private static int LCM(int num1, int num2)
        {
            return num1 / GCD(num1, num2) * num2;
        }

        static void Main(string[] args)
        {
            while (true)
            {
                string r = Console.ReadLine();
                if (r == null) break;
                int[] k0 = new int[2];
                for (int i = 0; i < 2; i++) k0[i] = int.Parse(r.Split(' ')[i]);
                Console.WriteLine(GCD(k0[0],k0[1]) + " " + LCM(k0[0],k0[1]));
            }
        }
    }
}

Measured memory_bytes: 8876
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

int main(int argc, char** argv)
{
	/*
	問題文
A, C, G, T からなる長さ N の文字列 S が与えられます。以下の Q 個の問いに答えてください。
問 
i (1≤i≤Q): 整数 li,ri (1≤li<ri≤N) が与えられる。
S の先頭から li 文字目から ri 文字目までの (両端含む) 部分文字列を考える。
この文字列に AC は部分文字列として何回現れるか。	*/

	/*
	制約
	2≤N≤10^5
	1≤Q≤10^5
	S は長さ Nの文字列である。
	S の各文字は A, C, G, T のいずれかである。
	1≤li<ri≤N
	*/

	
	// https://atcoder.jp/contests/abc122/tasks/abc122_c
	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	
	
	// d[i] = S の [0,i) までで AC が部分文字列として現れる数
	std::vector<int> d(N+1);
	for (int i = 1; i < N; i++) {
		if (S[i - 1] == 'A' && S[i] == 'C') {
			d[i+1] = d[i] + 1;
		}
		else {
			d[i+1] = d[i];
		}
	}
	// l ~ r の中に AC がいくつ入ってるかしりたい。
	// l ~ r の中の AC  = 0 ~ r までの AC  - 0 ~ (l-1) までの AC

	// [l,
	for (int i = 0; i < Q; i++) {
		int l, r;
		cin >> l >> r;
		int ans = d[r] - d[l];
		cout << ans << endl;
	}

	/*
	実行結果
	8 3
	ACACTACG
	3 7
	2
	
	2 3
	1
	
	1 8
	3
	*/
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,r;
	cin>>n>>r;
	if(n>=10)cout<<r;
	else{
		int i=10-n;
		cout<<r+i*100;
	} 
return 0;
}


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



int main() {
    string n;
    cin >> n;
    
    int ans = 0;
    rep(i,n.size()) {
        ans += n[i] - '0';
        ans %= 9;
    }
    
    if(ans % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    
    
    
    return 0;
}




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

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

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  --a;
  ll cd = lcm(c,d);
  ll div1 = a - a/c - a/d + a/cd;
  ll div2 = b - b/c - b/d + b/cd;

  ll ans = div2 - div1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[2005][2005];
int n,m,a[2005],b[2005];
int main()
{
	scanf("%d%d",&n,&m);
	int ans=max(n,m);
	for(int i=0;i<n;i++)scanf("%s",s[i]);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m-1;j++)if(i&&!(s[i-1][j+1]^s[i][j]^s[i-1][j]^s[i][j+1]))a[j]++;else a[j]=1;
		int t=0;
		for(int j=0;j<=m-1;j++)
		{
			while(t&&a[b[t-1]]>=a[j])
			{
				int x=b[--t];
				if(t==0)ans=max(ans,(j+1)*a[x]);else ans=max(ans,(j-b[t-1])*a[x]);
			}
			b[t++]=j;
		}
	}
	printf("%d\n",ans);
	return 0;
}
/////////////////////////////////////////////////////////////////////////////////

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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	ll n, m, x[114514], y[114514];
	cin>>n>>m;
	REP(i, n){
		cin>>x[i];
	}
	REP(i, m){
		cin>>y[i];
	}
	ll h=0;
	for(ll i=0; i<n-1; ++i){
		h=(h+(x[i+1]-x[i])*(n-i-1)%MOD*(i+1))%MOD;
	}
	ll w=0;
	for(ll i=0; i<m-1; ++i){
		w=(w+(y[i+1]-y[i])*(m-i-1)%MOD*(i+1))%MOD;
	}
	cout<<(w*h)%MOD<<'\n';
	return 0;
}


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

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

  int s,c; cin >> s >> c;

  int ans = 0;
  if(s > c/2){
    ans += c/2;
  }
  else {
    ans += s;
    c -= s*2;
    ans += c/4;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define getchar gc
inline char gc(){
	static char buf[1<<16],*p1=buf,*p2=buf;
	if(p1==p2){
		p2=(p1=buf)+fread(buf,1,1<<16,stdin);
		if(p2==p1) return EOF;
	}
	return *p1++;
}
#endif
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const double eps=1e-9;
const double pi=acos(-1);


struct point{
	double x,y;
	inline void read(){
		scanf("%lf%lf",&x,&y);
	}
	inline point operator + (const point &nt) const {
		return (point){x+nt.x,y+nt.y};
	}
	inline point operator - (const point &nt) const {
		return (point){x-nt.x,y-nt.y};
	}
	inline point operator * (const double &nt) const {
		return (point){x*nt,y*nt};
	}
}x,y,p;

double DJ(point x,point y){ //点积 
	return x.x*y.x+x.y*y.y;
}

double CJ(point x,point y){ //叉积 
	return x.x*y.y+x.y*y.x;
}

double distance(point x,point y){ //距离 
	return sqrt((y.x-x.x)*(y.x-x.x)+(y.y-x.y)*(y.y-x.y));
}

struct segment{
	point x,y;
	inline void read(){
		x.read();y.read();
	}
	inline double length(){ //线段长度 
		return distance(x,y);
	}
}seg;

point trpoint(segment x){ //将有向线段转成向量点 
	return x.y-x.x;
}

double prolen(point x,segment a){ //点在有向线段上的投影长度 
	return DJ(trpoint((segment){a.x,x}),trpoint(a))/a.length();
}

point propoint(point x,segment a){ //点在有向线段上的投影点 
	return a.x+trpoint(a)*(prolen(x,a)/a.length());
}

void doit(){
	p.read();
	point res=propoint(p,seg);
	printf("%.10lf %.10lf\n",res.x,res.y);
}

signed main(){
	x.read();y.read();
	seg=(segment){x,y};
	int t;
	read(t);
	while(t--) doit();
}


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

int main(){
  string s, t, u;

  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if(s == u){
    cout << a-1 << " " << b;
  }
  else if(t == u){
    cout << a << " " << b-1;
  }
}

Measured memory_bytes: 256
n = int(input())
H = [int(x) for x in input().split()]

pre = float('INF')
isOK = True
for i in range(n-1,-1,-1):
    if(pre >= H[i]):
        pre = H[i]
        continue
    if(pre == (H[i]-1)):
        H[i] -= 1
        pre = H[i]
        continue
    isOK = False
    break
    

if(isOK):
    print('Yes')
else:
    print('No')

    


Measured memory_bytes: 14252
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<tuple>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

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

struct edge{int to,cost;};

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

	int n;
	cin >> n;

	int a[n],b[n],c[n];
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<n;i++) cin >> b[i];
	for(int i=0;i<n;i++) cin >> c[i];

	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);

	int la[n],lec[n];
	int ida=0,idc=0;
	for(int i=0;i<n;i++){
		while(ida < n && a[ida] < b[i]) ida++;
		la[i]=ida;
		while(idc < n && c[idc] <= b[i]) idc++;
		lec[i]=idc;
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ans += 1LL*la[i]*(n-lec[i]);
	}
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long 
#define ull unsigned long long
#define li long long int

ul f(ul a,ul b) {
  ul ct=0;
  while (a|b) {
    a/=10;b/=10;
    ct++;
  }
  return ct;
}

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

  int ct=0;

  for (int i=0;i<1000;i++) {
    string cns=to_string(i);
    cns=((i<100) ? ((i<10)?"00":"0"):"") + cns;
    size_t sp[3];
    sp[0] = s.find_first_of(cns[0]);
    if (sp[0]!= string::npos)
    {
      sp[1] = s.find_first_of(cns[1], sp[0] + 1);
      if (sp[1] != string::npos)
      {
        sp[2] = s.find_first_of(cns[2], sp[1] + 1);
        if (sp[2] != string::npos)
        {
          //cout << cns << ", " << sp[0] << ", " << sp[1] << ", " << sp[2] << endl;
          ct++;
        }
      }
    }
  }

  cout << ct <<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>

void solve() {
    int n, k, t;
    std::cin >> n >> k >> t;

    std::vector<std::vector<int>> ls(n), rs(n);
    std::vector<int> xs(t + 2);
    xs[0] = 0;
    for (int i = 1; i <= t; ++i) {
        int l, r;
        std::cin >> l >> r >> xs[i];
        ls[--l].push_back(i);
        rs[--r].push_back(i);
    }
    xs[t + 1] = k + 1;

    std::set<int> ts{0, t + 1};
    int out = 1, ans = 0;
    for (int i = 0; i < n; ++i) {
        for (auto x : ls[i]) {
            auto it = ts.lower_bound(x);
            int nxt = *it;
            --it;
            int prev = *it;

            if (xs[nxt] - xs[prev] != 1) --out;
            if (xs[x] - xs[prev] != 1) ++out;
            if (xs[nxt] - xs[x] != 1) ++out;
            ts.insert(x);
        }

        if (out == 0) ++ans;

        for (auto x : rs[i]) {
            ts.erase(x);
            auto it = ts.lower_bound(x);
            int nxt = *it;
            --it;
            int prev = *it;

            if (xs[x] - xs[prev] != 1) --out;
            if (xs[nxt] - xs[x] != 1) --out;
            if (xs[nxt] - xs[prev] != 1) ++out;
        }
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}



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


using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;

const int N = 107;
const int WW = 200007;
const int INF = 2000000000;

LL dp[WW];
bool czy[WW];
int w[N], v[N];

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    int n, W;
    cin >> n >> W;
    int maks = 0;
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
        maks = max(maks, v[i]);
    }
    const int XX = maks*n;
    czy[0] = true;
    for(int i = XX; i > 0; i--){
        dp[i] = INF;
    }
    for(int i = 0; i < n; i++){
        for(int j = XX; j >= v[i]; j--){
            if(czy[j-v[i]] == true && dp[j-v[i]]+w[i] <= W){
                dp[j] = min(dp[j], dp[j-v[i]]+w[i]);
                czy[j] = true;
            }
        }
    }
    int res = 0;
    for(int i = 0; i <= XX; i++){
        if(czy[i]) res = i;
    }
    cout << res << '\n';
    
    return 0;
}

Measured memory_bytes: 1152
// Sの長さは変わらないんので26進数で加算して繰り上げていくみたいなのはダメ
// 上の桁からできるだけ小さくしていくことを考える
// ↑手元でためしたときにアルファベットと数値の対応がおかしくてバグらせてることに気づかず解説みるという最悪をした

package main
import (
	"fmt"
	"strings"
)
func main(){
	var S string
	var K int
	fmt.Scan(&S, &K)
	char := "a"
	T := make(map[string]int)
	T[char] = 0
	for i:=1; i<26; i++ {
		char = string(char[0] + 1)
		T[char] = 26-i
	}
	ans := make([]string, len(S))
	for i, c:= range []rune(S){
		if T[string(c)]<=K{
			K-=T[string(c)]
			ans[i] = "a"
		}else{
			ans[i] = string(c)
		}
	}

	if K>0{
		K%=26
		for i:=0; i<K; i++{
			ans[len(S)-1] = string(ans[len(S)-1][0]+1)
		}
	}
	fmt.Println(strings.Join(ans, ""))
}

Measured memory_bytes: 4804
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n; cin>>n;
	queue<string> q; q.push("a");
	int cnt = 1;
	while(cnt<n){
		int t = q.size();
		rep(i,t){
			string tmp = q.front(); q.pop();
			// char last = tmp[cnt-1];
			// string f,s; f = tmp+last;
			// last+=1; s=tmp+last;
			// q.push(f); q.push(s);
			char cmax = 'a';
			rep(i,cnt) chmax(cmax,tmp[i]);
			for(char i='a'; i<=cmax+1; i++){
				q.push(tmp+i);
			}
		}
		cnt++;
	}
	while(!q.empty()){
		cout << q.front() << endl;
		q.pop();
	}

  return 0;
}


Measured memory_bytes: 9728