akhauriyash/Code-Regression huggingface dataset:
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < (int)n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
#endif

int main() {
	string s;
	cin >> s;
	s[5] = s[13] = ' ';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.nio.CharBuffer;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        char[] s = scanner.next().toCharArray();
        Arrays.sort(s);
        if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
            writer.println("Yes");
        else
            writer.println("No");

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

ll BASE_NUM = 998244353;

ll my_pow(ll x,ll y){
    if (y == 0){
        return 1LL;
    }else if(y == 1){
        return x;
    }else{
        return (my_pow(x,y/2) % BASE_NUM) * (my_pow(x,(y+1)/2) % BASE_NUM) % BASE_NUM;
    }
}

int main()
{
    // 整数の入力
    ll N;
    vector<ll> D;
    map<ll, ll> D_Counts;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        ll d;
        cin >> d;
        D.push_back(d);
        D_Counts[d]++;
    }
    if (D[0] != 0)
    {
        cout << 0 << endl;
    }
    else if (D_Counts[0] > 1)
    {
        cout << 0 << endl;
    }
    else
    {
        ll total = 1;
        for(int i = 1;i<D_Counts.size();i++){
            if (D_Counts[i] == 0){
                total = 0;
            }else{
                total = total * my_pow(D_Counts[i-1],D_Counts[i]) % BASE_NUM;
            }
            // cout << i << ":" << total << endl;
        }
        cout << total <<endl;
    }
    return 0;
}

Measured memory_bytes: 7284
import java.io.*;
import java.util.*;
public class Main {
	static int[] dx= {0,0,-1,1},dy= {1,-1,0,0};
	static char[][]in;
	static boolean isValid(int i,int j) {
		return i>=0 && j>=0 && i<in.length && j<in[0].length && in[i][j]!='#';
	}
	static int ans;
	static void bfs(int i,int j) {
		LinkedList<int[]>q=new LinkedList<int[]>();
		q.add(new int[]{i,j,0});
		boolean[][]vis=new boolean[in.length][in[0].length];
		vis[i][j]=true;
		while(!q.isEmpty()) {
			int[]cur=q.poll();
			ans=Math.max(ans, cur[2]);
			for(int o=0;o<4;o++) {
				int ii=cur[0]+dx[o],jj=cur[1]+dy[o];
				if(isValid(ii, jj) && !vis[ii][jj]) {
					vis[ii][jj]=true;
					q.add(new int[] {ii,jj,cur[2]+1});
				}
			}
		}
	}
	public static void main(String[] args) throws Exception {
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int n=sc.nextInt(),m=sc.nextInt();
		in=new char[n][m];
		for(int i=0;i<n;i++)in[i]=sc.nextLine().toCharArray();
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(in[i][j]!='#') {
					bfs(i, j);
				}
			}
		}
		pw.println(ans);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 28620
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;


int main(){
    ll a,b,c,d; cin >> a >> b >> c >> d;
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

void err() {
	puts(-1);
	exit(0);
}
class UnionFind {
public:
	vector<int> r, p;

	UnionFind() {}
	UnionFind(int size) {
		r.resize(size, 0);
		p.resize(size, 0);
		rep(i, 0, size)makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		r[x] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (r[x] > r[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (x == y) {
				r[y]++;
			}
		}
	}


	int findSet(int x) {
		if (x == p[x]) {
			return x;
		}
		else {
			return p[x] = findSet(p[x]);
		}
	}
};

vector<int>edgetree[101010];
vector<pair<int, int>>ans;
vector<int>cnt;

void dfs(int now, int p) {
	fore(x, edgetree[now]) {
		if (x != p) {
			dfs(x, now);
		}
	}
	if (now != 0) {
		if (cnt[now] % 2) {
			ans.pb({now+1,p+1});
			cnt[now]++;
		}
		else {
			ans.pb({ p+1,now+1 });
			cnt[p]++;
		}
	}
}

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

	int N, M;
	cin >> N >> M;
	if (M % 2)err();
	cnt.resize(N);

	UnionFind un = UnionFind(N);

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		if (un.same(a, b)) {
			ans.pb({a+1,b+1});
			cnt[a]++;
		}
		else {
			un.unite(a, b);
			edgetree[a].pb(b);
			edgetree[b].pb(a);
		}
	}

	dfs(0, -1);
	fore(x, ans)cout << x.first << " " << x.second << endl;

	return 0;
}


Measured memory_bytes: 14324
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
map< ll , ll > mp;
int main()
{
	ll n , k;
	cin >> n >> k;
	for(int i = 0 ; i < n ; i++){
		ll a , b;
		cin >> a >> b;
		mp[a] += b;
	}
	ll ans = 0;
	for(auto it : mp){
		ans += it.second;
		if(ans >= k){
			cout << it.first << endl;
			return 0;
		}
	}
	return 0;
} 




Measured memory_bytes: 4224
n = int(input())
h = list(map(int, input().split()))
dp = [5e9] * (n + 2)
dp[0] = 0
for i in range(n):
    if i + 1 < n:
        dp[i + 1] = min([dp[i + 1], dp[i] + abs(h[i] - h[i + 1])])
    if i + 2 < n:
        dp[i + 2] = min([dp[i + 2], dp[i] + abs(h[i] - h[i + 2])])

print(dp[n - 1])


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

// 0-indexed
template <class T, class E>
struct SegmentTreeLaze {
  // a,b:T c,d:E e:E(unit)
  // g(f(a,b),c) = f(g(a,c),g(b,c))
  // g(g(a,c),d) = g(a,h(c,d))
  // g(a,e) = a
  typedef function<T(T, T)> F;
  typedef function<T(T, E)> G;
  typedef function<E(E, E)> H;
  int n, height;
  F f;
  G g;
  H h;
  T tunit;
  E eunit;
  vector<T> dat;
  vector<E> laz;
  SegmentTreeLaze(){};
  SegmentTreeLaze(int newn, F f, G g, H h, T nt, E ne)
      : f(f), g(g), h(h), tunit(nt), eunit(ne) {
    init(newn);
  }
  SegmentTreeLaze(const vector<T> &v, F f, G g, H h, T nt,
                  E ne)
      : f(f), g(g), h(h), tunit(nt), eunit(ne) {
    int _n = v.size();
    init(v.size());
    for(int i = 0; i < _n; ++i) dat[n + i] = v[i];
    for(int i = n - 1; i; --i)
      dat[i] = f(dat[i << 1], dat[(i << 1) | 1]);
  }
  void init(int newn) {
    n = 1, height = 0;
    while(n < newn) n <<= 1, ++height;
    dat.assign(n << 1, tunit);
    laz.assign(n << 1, eunit);
  }

  inline T reflect(int k) {
    return laz[k] == eunit ? dat[k] : g(dat[k], laz[k]);
  }

  inline void eval(int k) {
    if(laz[k] == eunit) return;
    laz[k << 1] = h(laz[k << 1], laz[k]);
    laz[(k << 1) | 1] = h(laz[(k << 1) | 1], laz[k]);
    dat[k] = reflect(k);
    laz[k] = eunit;
  }

  inline void thrust(int k) {
    for(int i = height; i; --i) eval(k >> i);
  }

  void recalc(int k) {
    while(k >>= 1)
      dat[k] = f(reflect(k << 1), reflect((k << 1) | 1));
  }
  // [a,b)
  void update(int a, int b, E newdata) {
    thrust(a += n);
    thrust(b += n - 1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l], newdata), l++;
      if(r & 1) --r, laz[r] = h(laz[r], newdata);
    }
    recalc(a);
    recalc(b);
  }

  void set_val(int k, T newdata) {
    thrust(k += n);
    dat[k] = newdata;
    laz[k] = eunit;
    recalc(k);
  }

  // [a,b)
  T query(int a, int b) {
    thrust(a += n);
    thrust(b += n - 1);
    T vl = tunit, vr = tunit;
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) vl = f(vl, reflect(l++));
      if(r & 1) vr = f(reflect(--r), vr);
    }
    return f(vl, vr);
  }
};
#define fi first
#define se second
#define MOD 998244353
using P = pair<long long, long long>;

long long n, q;
vector<P> v;

int main() {
  cin >> n >> q;
  v.resize(n, {0, 1});
  for(int i = 0; i < n; ++i) cin >> v[i].fi;

  auto f = [](P l, P r) {
    return make_pair((l.fi + r.fi) % MOD, l.se + r.se);
  };
  auto g = [](P l, P r) {
    return make_pair(
        (l.fi * r.fi % MOD + l.se * r.se % MOD) % MOD,
        l.se);
  };
  auto h = [](P l, P r) {
    return make_pair(r.fi * l.fi % MOD,
                     ((r.fi * l.se) % MOD + r.se) % MOD);
  };
  SegmentTreeLaze<P, P> seg(v, f, g, h, {0, 1}, {1, 0});
  while(q--) {
    int t, l, r;
    cin >> t >> l >> r;
    if(t)
      cout << seg.query(l, r).fi << endl;
    else {
      long long b, c;
      cin >> b >> c;
      seg.update(l, r, {b, c});
    }
  }
  return 0;
}

Measured memory_bytes: 43836
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


    using namespace std;
 
    int main(){
      int a,b;
      cin >> a >> b;
      cout << (a+b)%24 << endl;
      return 0;}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool given_number_has_eight_factors(int x) {
    int counter = 0;
    for (int i = 1; i <= x; ++i) {
        if (x % i == 0) counter++;
    }

    return (counter == 8);
}

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

    int ans = 0;
    for (int i = 1; i <= N; i+=2) {
        if (given_number_has_eight_factors(i)) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String s = sc.next();
    int b = sc.nextInt();
    int ans = 0;
    if(s.equals("+")) {
      ans = a + b;
    } else {
      ans = a - b;
    }
    System.out.println(ans);
  }
}

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



#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef map<int, int> mii;

void solve(ll test_case)
{
  string s;
  cin>>s;
  if(s[s.size()-1] =='s' )
        s+="es";
  else{
        //if()
        s+="s";
    }
  cout<<s;
}

int main()
{

//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1, t1 = 0;
  //  cin >> t;
    while (t1 < t)
    {
        solve(t1 + 1);
        t1++;
    }
 return 0;
}


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

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

    if(a<3200)
    {
        cout<<"red"<<endl;
    }
    else
    {
        cout<<s<<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(' ')))

A.sort()
C.sort()

import bisect

ret = 0
for b in B:
    i = bisect.bisect_left(A, b)
    j = bisect.bisect_right(C, b)

    ret += i * (N - j)
    # print(i, (N - j))

print(ret)



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    string s, ans;
    cin >> s;

    rep(i, s.size()){
        if(s[i] == 'B' && !ans.empty()){
            ans.erase(ans.end()-1, ans.end());
        }

        if(s[i] == '1' || s[i] == '0'){
            ans.push_back(s[i]);
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s, t;
    cin >> n >> s >> t;
    V temp;
    rep(i, n)
    {
        if (i != n - 1)
        {
            if (s[i] == s[i + 1])
            {
                temp.push_back(1);
                i++;
                continue;
            }
        }
        temp.push_back(0);
    }
    ll res;
    if (temp[0] == 1)
    {
        res = 6;
    }
    else
    {
        res = 3;
    }
    rep(i, temp.size() - 1)
    {
        if (temp[i] == 1 && temp[i + 1] == 1)
        {
            res *= 3;
        }
        if ((temp[i] == 0 && temp[i + 1] == 0) || (temp[i] == 0 && temp[i + 1] == 1))
        {
            res *= 2;
        }
        res %= MOD;
    }
    cout << res << endl;
}


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

int main() {
  long long a;
  string b;
  cin >> a;
  cin >> b;
  long long bx100 = stoll(b.replace(b.find("."), 1, ""));
  cout << a * bx100 / 100 << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
typedef int fuko[yuzu|10];
fuko a,b,c;
int main(){
int i,n=read();
for (i=1;i<=n;++i) a[i]=read();
for (i=1;i<=n;++i) b[i]=read();
for (i=1;i<=n;++i) c[i]=read();
sort(a+1,a+n+1),sort(b+1,b+n+1),sort(c+1,c+n+1);
ll llx=0;
#define lb lower_bound
#define ub upper_bound
for (i=1;i<=n;++i){
  int p1=lb(a+1,a+n+1,b[i])-a-1,p2=n-(ub(c+1,c+n+1,b[i])-c)+1;
  llx+=1ll*p1*p2;
  }write(llx);
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>

using namespace std;
int main(){
    int k,s; cin>>k>>s;
    int ans=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(k>=s-i-j && s-i-j>=0)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

drawRectangle :: [Int] -> IO ()
drawRectangle [h, w] = replicateM_ h (putStrLn $ replicate w '#')

parser :: IO()
parser = do
    args <- (map (read :: String -> Int) . words) <$> getLine
    if (args == [0, 0])
    then return ()
    else do
        drawRectangle args
        putStrLn ""
        parser

main = parser

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

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

}


Measured memory_bytes: 256
function getLines(input){
	return input.split("\n").map((s)=>s.trim())
}
function parseLine(line){
	return line.split(" ").map((s)=>s.trim());
}
function parseLineToInt(line){
	return line.split(" ").map((s)=>parseInt(s.trim()));
}
// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.	
	input = getLines(input).map(parseLineToInt);
	var K = input[0][0];
	var N = input[0][1];
	var a = input[1];
	var ans = -1;
	for (var i = 0; i < N; i++) {
		if(ans==-1)
			ans = a[N-1]-a[0];
		else
			ans = Math.min(ans,K-a[i]+a[i-1]);
	}
	console.log(ans);
}
// Don't edit this line!
//Main(require("fs").readFileSync(__dirname+'/in.txt', "utf8"));
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 36156
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;



int main()
{
	int n,m;
	cin>>n>>m;
	stack<int> *toList = new stack<int>[n];
	int *h = new int[n];
	rep(i,n) cin>>h[i];
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a = a - 1;
		b = b - 1;
		toList[a].push(b);
		toList[b].push(a);
	}
	int ans = 0;
	rep(i,n){
		bool amIheighest = true;
		while(toList[i].empty() != true){
			int b = toList[i].top();
			toList[i].pop();
			//cout<<"h[i]:"<<h[i]<<" h[b]:"<<h[b]<<endl;
			if( h[i] <= h[b]){
				amIheighest = false;
				break;
			}
		}
		if(amIheighest == true) ans++;
		//cout<<i<<":"<<amIheighest<<endl;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 71496
function Main(input){ 
    let arr = input.split(' ').map(Number);
    let min1 = arr[0] * 60 + arr[1];
    let min2 = arr[2] * 60 + arr[3];
    console.log(min2-min1- arr[4]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define M 1000000007
typedef pair<int,int> P;

priority_queue<P,vector<P>,greater<P> > Que;
vector<int> rin[100000],rin2[100000] ; //隣接   数値　 場所
int v,e,r; //　グラフGの　頂点の数　辺の数　　　スタート
int s,t,d;//  i番目の辺が結ぶ２つの頂点   i 番目の辺の重み
int leng[100000];
int q;
int i,j;

int main(void){
	
	cin>>v>>e>>r;
	for(i=0;i<e;i++){
		cin>>s>>t>>d;
		rin[s].push_back(d);
		rin2[s].push_back(t);
	}
	
	for(i=0;i<v;i++) leng[i]=M;
	
	//rin 確認
	/*cout<<endl;
	cout<<"rin"<<endl;
	for(i=0;i<e;i++){
		for(j=0;j<rin[i].size();j++) cout<<rin[i][j]<<" ";
		cout<<endl;
	}*/
	
	//rin2 確認
	/*cout<<"rin2"<<endl;
	for(i=0;i<e;i++){
		for(j=0;j<rin2[i].size();j++) cout<<rin2[i][j]<<" ";
		cout<<endl;
	}*/
			
	
	leng[r]=0;
	Que.push(P(0,r)); // 数値　 場所
	while(!Que.empty()){
		
		/*for(i=0;i<v;i++) cout<<leng[i]<<" ";
		cout<<endl;*/
		
		P q=Que.top(); Que.pop();
		
		if(leng[q.second]>q.first) continue;
		
		for(i=0;i<rin[q.second].size();i++){
			if(leng[rin2[q.second][i]]>q.first+rin[q.second][i]){
				leng[rin2[q.second][i]]=q.first+rin[q.second][i];
				Que.push(P(leng[rin2[q.second][i]],rin2[q.second][i]));
			}
		}
	}
	
	for(i=0;i<v;i++){
		if(leng[i]==M) cout<<"INF"<<endl;
		else cout<<leng[i]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 17200
n = int(input())
a = list(map(int,input().split()))
t = 0
for c in a: 
  if c < 0: t = 1 - t
if t:
  t = abs(a[0])
  s = 0
  for c in a:
    t = min(t, abs(c))
    s += abs(c)
  print(s - t - t)
else:
  s = 0
  for c in a:
    s += abs(c)
  print(s)

Measured memory_bytes: 64880
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    int N, M, Q;
    cin >> N >> M >> Q;
    int imos[N + 1][N + 1];
    memset(imos, 0, sizeof(imos));
    rep(i, 0, M) {
        int l, r;
        cin >> l >> r;
        imos[l][r]++;
    }

    rep(y, 1, N + 1) rep(x, 1, N + 1) imos[y][x] += imos[y][x - 1];
    rep(y, 1, N + 1) rep(x, 1, N + 1) imos[y][x] += imos[y - 1][x];

    vector<int> rsl;
    rep(i, 0, Q) {
        int p, q;
        cin >> p >> q;
        int tmp = imos[q][q] - imos[q][p - 1] - imos[p - 1][q] + imos[p - 1][p - 1];
        rsl.push_back(tmp);
    }

    rep(i, 0, rsl.size()) cout << rsl[i] << endl;
}


Measured memory_bytes: 2424
from collections import defaultdict
from bisect import bisect_right
S=input()
T=input()
ls=len(S); lt=len(T)
S_dict=defaultdict(list)
for i,s in enumerate(S):
    S_dict[s].append(i+1)
T_list=[[] for _ in range(lt)]
for i,t in enumerate(T):
    if not S_dict[t]:
        print(-1)
        exit()
    T_list[i]=S_dict[t]
#print(T_list)
ans=T_list[0][0]
prev=T_list[0][0]
cycles=0
#print(ans)
for i in range(1,lt):
    idx=bisect_right(T_list[i],prev)
    if idx==len(T_list[i]):
        cycles+=1
        prev=T_list[i][0]
    else:
        prev=T_list[i][idx]
    ans=prev+(cycles*ls)
    #print(prev,cycles,ans)
print(ans)

Measured memory_bytes: 52912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

ll N;

int f(ll x, bool a, bool b, bool c) {
  int y = 0;
  if (x > N) return y;
  if (a && b && c) y = 1;
  return y + f(x*10 + 7,true,b,c) + f(x*10 + 5,a,true,c) + f(x*10 + 3,a,b,true);
}
int main() {
  cin >> N;
  int count = f(0,false,false,false);
  cout << count << endl;
}

Measured memory_bytes: 256
# coding: utf-8


def solve(*args: str) -> str:
    A = []
    for i in range(3):
        A.extend(map(int, args[i].split()))

    n = int(args[3])
    B = map(int, args[4:])

    M = [False]*9
    for b in B:
        for j in range(9):
            M[j] |= A[j] == b

    bingo = False

    for y in range(3):
        bingo |= all(M[y*3:y*3+3])

    for x in range(3):
        bingo |= all([M[x], M[x+3], M[x+6]])

    bingo |= all([M[0], M[4], M[8]])
    bingo |= all([M[2], M[4], M[6]])

    return 'Yes' if bingo else 'No'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

int main() {
  int N;
  int h[100002];
  int dp[100002];
  cin >> N;
  for (int i=0;i<N;i++ ) {
    cin >> h[i];
    dp[i] = 0;
  }
  dp[1] = abs(h[1] - h[0]);
  for (int i=2;i<N;++i){
    dp[i] = min( dp[i-1]+abs(h[i] - h[i-1]), dp[i-2]+abs(h[i]-h[i-2]) );
  }
  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#include <cmath>
#include <iostream>

using namespace std;

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

  int table[n][3];
  for (int i = 0; i < n; i++) { cin >> table[i][0] >> table[i][1] >> table[i][2]; }

  long dp[n][3];
  dp[0][0] = table[0][0];
  dp[0][1] = table[0][1];
  dp[0][2] = table[0][2];
  for (int i = 1; i < n; i++) {
    dp[i][0] = table[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][1] = table[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
    dp[i][2] = table[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
  }
  cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}



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

constexpr int INF = 1 << 30;

void solve() {
    int h, w;
    std::cin >> h >> w;

    std::set<int> s;
    for (int x = 0; x < w; ++x) s.insert(x);
    std::vector<int> ds(w, 0);

    std::multiset<int> dss;
    for (auto d : ds) dss.insert(d);

    for (int i = 1; i <= h; ++i) {
        int l, r;
        std::cin >> l >> r;
        --l;

        auto it = s.lower_bound(l);
        int min = INF;
        while (it != s.end() && *it <= r) {
            int x = *it;
            it = s.erase(it);

            dss.erase(dss.find(ds[x]));
            min = std::min(min, ds[x] + r - x);
            ds[x] = INF;
        }

        if (r < w && min < INF) {
            ds[r] = std::min(ds[r], min);
            s.insert(r);
            dss.insert(ds[r]);
        }

        if (dss.empty()) {
            std::cout << -1 << "\n";
        } else {
            int d = *dss.begin();
            std::cout << d + i << "\n";
        }
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 22652
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

def dfs(index, a, b, c):
    if index == N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a, b, c) > 0 else float('inf')
    
    val1 = dfs(index+1, a, b, c)
    val2 = dfs(index+1, a+l[index], b, c) + 10
    val3 = dfs(index+1, a, b+l[index], c) + 10
    val4 = dfs(index+1, a, b, c+l[index]) + 10
    return min(val1, val2, val3, val4)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int x1,x2,a;
	scanf("%d %d",&x1,&x2);
	if(x1>=x2){
	a=x1-x2;
	}
	if(x1<=x2){
	a=x2-x1;
	}
	printf("%d\n",a);
	return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ll long long
int main()
{
    int n;
    cin>>n;
    int i,t;
    vector<int> a;
    for(i=0;i<n;i++)
    {
        cin>>t;
        a.pb(t);
    }
    sort(a.begin(),a.end());
    int ans=1;
    for(int i=1;i<n;i++)
    {
        if(a[i]>a[i-1])
        {
            ans++;
        }
    }
    cout<<ans;
    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> v(M,0);
  
  for (int i = 0; i < N; i++) {
    int L;
    cin >> L;
    for (int j = 0; j < L; j++) {
      int P;
      cin >> P;
      v[P-1] += 1;
    }
  }
  int count = 0;
  for (int i = 0; i < M; i++) {
    if (v[i] == N) count += 1;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int arr[] = new int[N];
		int sum = 0;
		for(int n=0;n<N;n++){
			arr[n] = sc.nextInt();
			sum += arr[n];
		}

		System.out.println(sum-N);
	}
}

Measured memory_bytes: 26064
program tenquestionthree
    implicit none
    integer n, i, x
    integer,allocatable,dimension(:) ::A
    x=30
    read(*,*) n
    allocate(A(n))
     read(*,*) A                                !横に読ます時これでいいらしい
     do i=1,n
      do while ((mod(A(i),2**x)).ne.0)          !do while文．論理が真ならループを繰り返す．最も2の成分が少ないA(i)を探してる
      x=x-1
      end do
    end do
    write(*,*) x
end program

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  if(N<10) cout<<N<<endl;
  else if(N<100) cout<<9<<endl;
  else if(N<1000) cout<<9+N-100+1<<endl;
  else if(N<10000) cout<<909<<endl;
  else if(N<100000) cout<<909+N-10000+1<<endl;
  else cout<<90909<<endl;
}

Measured memory_bytes: 3532
import java.util.*;
import java.math.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		int ans=0;
		for(int i=0; i<n-2; i++){
			if(s.substring(i,i+3).equals("ABC")){
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int a = stdin.nextInt();
		int b = stdin.nextInt();
		int c = stdin.nextInt();
		int d = stdin.nextInt();
		if(a+b>c+d) {
			System.out.println("Left");
		}else if(a+b==c+d) {
			System.out.println("Balanced");

		}else {
			System.out.println("Right");

		}


		// TODO 自動生成されたメソッド・スタブ

	}

}


Measured memory_bytes: 23252
'use strict'
 
function main(n) {
  let num = n.split("\n")[0]*1;
  let ans = "No"
  for(let s = 0; s<=100; s++ ){
  	for(let f = 0; f<=100; f++){
    	if(7*s + 4*f === num){
          ans = "Yes";
        }
    }
  }
  
  
  console.log(ans);
  
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 100005
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int cnt[100005] ;

int main()
{
    int i , j , k , n ;

    scanf("%d",&n) ;

    for(i=1 ; i<=n ; i++)
    {
        int a ;
        scanf("%d",&a) ;
        cnt[a]++ ; cnt[a+1]++ ; cnt[a+2]++ ;
    }

    int mx = 0 ;

    for(i=0 ; i<=100001 ; i++) mx = max(mx,cnt[i]) ;

    printf("%d\n",mx) ;

    return 0 ;
}


Measured memory_bytes: 640
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

//char rbuf[]; int rbufl;
//#define getchar() rbuf[rbufl++]
#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void printint(int32_t x){ if(x<0){x=-x; putchar('-');}else if(x==0){putchar('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar(s[i]); putchar('\n'); }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

class union_find{
	public:
	int *prev, *rank, *size_a;
	int root(int x){ return prev[x]==x?x:(prev[x]=root(prev[x])); }
	int size(int x){ return size_a[root(x)]; }
	void join(int x, int y){
		x=root(x), y=root(y); if(x==y) return;
		if(rank[x]<rank[y]){
			prev[x]=y; size_a[y]+=size_a[x];
		}else if(rank[x]>rank[y]){
			prev[y]=x; size_a[x]+=size_a[y];
		}else{
			prev[x]=y; rank[y]++; size_a[y]+=size_a[x];
		}
	}
	union_find(int n){
		prev = (int*) malloc(n*sizeof(int));
		rank = (int*) malloc(n*sizeof(int));
		size_a = (int*) malloc(n*sizeof(int));
		for(int i=0; i<n; i++){ prev[i]=i; rank[i]=1; size_a[i]=1; }
	}
	~union_find(void){
		free(prev);
		free(rank);
		free(size_a);
	}
};


union_find f(200001);

int main(void){
	int n=nextint();
	int m=nextint();
	for(int i=0; i<m; i++){
		int a=nextint();
		int b=nextint();
		f.join(a, b);
	}
	int ans=0;
	for(int i=1; i<=n; i++){
		int now = f.size(i);
		if(now>ans) ans=now;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 5460
S = input()
l = len(S)
while l > 0:
  if S[l-5:l] == 'erase' or S[l-5:l] == 'dream':
    l -= 5
  elif S[l-6:l] == 'eraser':
    l -= 6
  elif S[l-7:l] == 'dreamer':
    l -= 7
  else:
    l = -10
    
if l == 0:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3188
#各配点の問題について、全て解くor全く解かないを決める
#点数に満たない場合は、配点のうち最も高いものを足りない分解く

d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
ans = float('inf')

#まずはbitの列挙、一つずつ探索する
for bit in range(1<<d):
    count = 0
    sum = 0
    #残った配点を列挙するためにsetを用意しておく
    nokori = set(range(1,d+1))

    for i in range(d):
        #各bitが1の場合は解く, i=0は一桁目=1問目を見ている
        if (bit>>i)&1 == 1 :
            sum += pc[i][0] * (100*(i+1)) + pc[i][1]
            count += pc[i][0]
            #set.discard('x')で集合から'x'を削除する
            #i=0 -> 1桁目 -> discard(i+1), set(1, ..., d)
            nokori.discard(i+1)

    #合計sumが求めるgに達していない場合の処理をする
    #足すのは最大のものだけ、それ以外の場合は他のbitで処理
    #sumがgに足りないときはansに入れない
    if sum < g:
        #用いるのは、nokori集合の配点が最大のもの
        use = max(nokori)
        #解く問題数nを設定する
        #(g-sum): 必要な点数、use*100: 1問あたりの点数、切り上げて求める。最大はpi
        n = min(pc[use-1][0], -(-(g-sum)//(use*100)))
        count += n
        sum += n * use * 100
    #sumがgを超えた場合だけ、ansと比較する
    if sum >= g:
        ans = min(ans, count)

print(ans)



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const long long N = 200100;
long long n, a[N], b[N], ans;
priority_queue <pair<long long, long long>  > pq;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	for(long long i = 0; i < n; i++)
		cin >> a[i];

	for(long long i = 0; i < n; i++) {
		cin >> b[i];
		if(b[i] != a[i])
			pq.push({b[i], i});
	}

	while(!pq.empty()) {
		auto p = pq.top();
		pq.pop();
		long long nxt = max({a[p.nd], b[(n + p.nd - 1) % n] + b[(p.nd + 1) % n]});
		// dbg(p);
		long long dif = p.st - nxt;
		dif /= (b[(n + p.nd - 1) % n] + b[(p.nd + 1) % n]);
		dif = max(dif, 1LL);
		ans += dif;
		p.st -= dif * (b[(n + p.nd - 1) % n] + b[(p.nd + 1) % n]);
		if(p.st != a[p.nd])
			pq.push(p);
		
		if(p.st < a[p.nd]) return cout << "-1\n", 0;
		b[p.nd] = p.st;
	}
	cout << ans << '\n';
}	


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

lint A[55];

int main(){
    int N; cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    lint ans = 0, cnt = 1;
    while(cnt){
        cnt = 0;
        for(int i=0;i<N;i++) cnt += A[i] / N;
        for(int i=0;i<N;i++) A[i] -= A[i] / N * N - (cnt-A[i]/N);
        ans += cnt;
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
    int N , K;
    cin >> N >> K;
    if(N % 2 == 0){
        if(N / 2 >= K){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    else{
        if(N / 2 + 1 >= K){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define PI 3.14159265359
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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;}
template <class T> using V=vector<T>;
const int INF = 1e9;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,x,y; cin >> a >> b >> c >> x >>y;
    ll res = 0;
    if (x<y) {
        res = min(min(max(x,y)*2*c, x*2*c+abs(x-y)*b), a*x+b*y);
    } else {
        res = min(min(max(x,y)*2*c,y*2*c+abs(x-y)*a), a*x+b*y);
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
n = int(input())
arr = [int(i) for i in list(input().split())]
def helper(arr):
	if len(arr) <= 1:
		return 0
	if len(arr) == 2:
		return abs(arr[1] - arr[0])
	way1 = abs(arr[-1] - arr[-2]) + helper(arr[:-1])
	way2 = abs(arr[-1] - arr[-3]) + helper(arr[:-2])
	return min(way1, way2 )

if n == 1:
	print(0)
elif n == 2:
	print(abs(arr[1] - arr[0]))
else:
	dp = [0]*n
	dp[0] = 0
	dp[1] = abs(arr[1] - arr[0])
	for i in range(2,len(arr)):
		dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] + abs(arr[i] - arr[i-2]))
	print(dp[n-1])
# print(helper(arr))

Measured memory_bytes: 20028
n=int(input())
#a,b,x=map(int,input().split())
pl=list(map(str,input().split()))
ql=list(map(str,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

l=[str(i) for i in range(1,n+1)]

import itertools
p=("".join(pl))
q="".join(ql)

per=[]

for tup in itertools.permutations(l):
    per.append("".join(list(tup)))

per.sort()

print(abs(per.index(p)-per.index(q)))

Measured memory_bytes: 6040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define rep(i,a,n) for(ll i = a ; i <=n;++i)
#define sf(n) scanf("%lld",&n)
#define pf(n) printf("%lld\n",n)
#define bug printf("bug\n")
int main(){

ll n ; sf(n);
ll a[n+2];
ll ans = 0;
ll boo = 1000000;
rep(i,0,n-1) sf(a[i]);
rep(i,0,n-2){

if(a[i] == a[i+1]){

    a[i+1] = boo;
    ++boo;
    ++ans;


}


}
pf(ans);
return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>=1 && a<=13 && b>=1 && b<=13)
	if(a==b)
	cout<<"Draw";
	else 
	if(a==1 || (a>b && b>1) )
	cout<<"Alice";
	else
	cout<<"Bob";
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
N = (int)(input())
edges = []
for _ in range(N-1):
    edges.append((list)(map(int, input().split())))

Q, K = (list)(map(int, input().split()))
querys = []
for _ in range(Q):
    querys.append((list)(map(int, input().split())))

'''
 N:num of nodes
 Q: num of query
 K: node must passed in query

'''
dist = [[] for _ in range(N+1)]
for e in edges:
    dist[e[0]].append([e[1], e[2]])
    dist[e[1]].append([e[0], e[2]])

dist_from_k = [-1]*(N+1)


def dfs(v, cost):
    if dist_from_k[v] != -1:
        return

    dist_from_k[v] = cost
    for e in dist[v]:
        dfs(e[0], cost+e[1])


dfs(K, 0)

for q in querys:
    print(dist_from_k[q[0]] + dist_from_k[q[1]])


Measured memory_bytes: 173276
from collections import defaultdict
from bisect import bisect_left, bisect, insort_left, insort
def solve():
    S = input()
    T = input()
    if not set(T) <= set(S):
        return -1
    len_s = len(S)
    m = defaultdict(list)
    for i, s in enumerate(S):
        m[s].append(i)
    for k, v in m.items():
        m[k].append(m[k][0] + len_s)
    last = S.index(T[0])
    ans = last + 1
    for t in T[1:]:
        num = bisect(m[t], last)
        ans += m[t][num] - last
        last = m[t][num] % len_s
    return ans
print(solve())


Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std;
const int MAX=3000;
int n;
vector<ld> p(MAX);
vector<vector<ld>> dp(MAX,vector<ld>(MAX));
ld calc(int i,int t){
    if(i==n){
        if(t>(n-1)/2){
            return 0;
        }
        return 1;
    }
    if(dp[i][t]!=-1){
        return dp[i][t];
    }
    ld ans;
    if(t>(n-1)/2){
        ans=0;
    }
    else{
        ans=p[i]*calc(i+1,t)+(1-p[i])*calc(i+1,t+1);    
    }
    return dp[i][t]=ans;
}
void solve(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p[i];
        dp[i].assign(n,-1);
    }
    ld result=calc(0,0);
    cout<<fixed<<setprecision(10)<<result<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

using namespace std;

const int N = 3e3 + 5;
const double Pi = acos( -1.0 );
int _w;

int n , T[N] , L;
double ansx , ansy , theta;

int main( void ) {
  _w = scanf("%d%d",&n,&L);
  for( int i = 1 ; i <= n ; ++i )
    _w = scanf("%d",T+i);
  for( int i = 1 ; i <= n ; ++i )
    for( int j = i + 1 ; j <= n ; ++j ) {
      theta = Pi * ( (double)T[i] + T[j] ) / L;
      ansx += cos( theta ) * ( n - j + i - 1 );
      ansy += sin( theta ) * ( n - j + i - 1 );
      ansx += cos( theta + Pi ) * ( j - i - 1 );
      ansy += sin( theta + Pi ) * ( j - i - 1 );
    }
  ansx /= 1.0 * n * ( n - 1 ) * ( n - 2 ) / 6;
  ansy /= 1.0 * n * ( n - 1 ) * ( n - 2 ) / 6;
  printf("%.10f %.10f\n",ansx,ansy);
  return 0;
}


Measured memory_bytes: 640