akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pii pair<int, int>
#define fir first
#define sec second
#define ll long long
using namespace std;
const int MAXN = 2e5 + 7;
inline int lowbit(int x) {return x & -x;}
int len, c[MAXN];
void update(int x, int v) {for (; x <= len; x += lowbit(x)) c[x] += v;}
int query(int x, int res = 0) {for (; x; x -= lowbit(x)) res += c[x]; return res;}
int id[MAXN], pos[MAXN], cnt[2], lst[26];
char s[MAXN];
vector<int>vec[26];
int main() 
{
    scanf(" %s", s + 1); len = strlen(s + 1);
    for (int i = 1; i <= len; i++) vec[s[i] - 'a'].push_back(i);
    for (int c = 0; c < 26; c++) cnt[vec[c].size() % 2]++, lst[c] = (int)vec[c].size() - 1;
    if ((len & 1) && cnt[1] > 1) {puts("-1"); return 0;}
    if (!(len & 1) && cnt[1] > 0) {puts("-1"); return 0;}
    int v = 0;
    for (int i = 1, c; i <= len; i++)
    {
        c = s[i] - 'a';
        if (id[i]) continue;
        int j = vec[c][lst[c]--];
        if (i == j) id[i] = len / 2 + 1;
        else id[i] = ++v, id[j] = len + 1 - v; 
    }
    assert(v <= len / 2);
    // for (int i = 1; i <= len; i++) printf("%d%c", id[i], " \n"[i == len]);
    for (int i = 1; i <= len; i++) pos[id[i]] = i;
    ll ans = 0;
    for (int i = len; i >= 1; i--)
    {
        ans += query(pos[i]);
        update(pos[i], 1);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3832
import numpy as np

def tmp(n,k):
    l = len(str(n))-1
    num = 0
    if(k == 1):
        num = 9 * l
        p = n // 10**l
        num += p
    elif(k == 2):
        for i in range(1,l):
            num += i * 81
        p = n // 10**l
        r = n % 10**l
        t = (n-r-1) % 10**(l)
        num += (p-1) * tmp(t,1) + tmp(r,1)
    elif(k == 3):
        for i in range(2,l):
            num += i * (i-1) / 2 * 729
        p = n // 10**l
        r = n % 10**l
        t = (n-r-1) % 10**(l)
        num += (p-1) * tmp(t,2) + tmp(r,2)
    return(num)



N = int(input())
K = int(input())


print(int(tmp(N,K)))

Measured memory_bytes: 12500
#include <stdio.h>

int main(void) {
	int S, h, m, s, r;
	scanf("%d", &S);
	h = S/3600;
	r = S%3600;
	m = r/60;
	r = r%60;
	s = r;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	string x="",y="";
	for(int i=0;i<n;i++)
		x=x+(char)(m+'0');
	for(int i=0;i<m;i++)
		y=y+(char)(n+'0');
	if(x>=y)
		cout<<y;
	else
		cout<<x;
	return 0;
} 

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

int main() {
	int N, Y;
	cin >> N >> Y;
	int P;
	P = Y / 1000 - N;
	int a, b;
	b=0;
	while((P - 4*b)%9!=0 && P>=4*b)
	{
	    ++b;
	}
	a=(P - 4*b)/9;
	if(P >= 4*b && a+b<=N) cout << a << " " << b <<  " " << N-(a+b) << endl;
	else cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

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

#define ll long long
#define ld double
#define oo 2e18
#define OS tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

const int N = 1e5 + 5;
int n, a[N], n1[N], n2[N];

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int mx1 = 0, mx2 = 0, mxx1 = 0, mxx2 = 0, p1 = -1, p2 = -1, pp1 = -1, pp2 = -1;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            ++n1[a[i]];
            if(mx1 < n1[a[i]]) {
                if(a[i] != p1) {
                    mx2 = mx1;
                    p2 = p1;
                }
                mx1 = max(mx1, n1[a[i]]);
                p1 = a[i];
            }
            else if(mx2 < n1[a[i]]) {
                mx2 = max(mx2, n1[a[i]]);
                p2 = a[i];
            }
        }
        else if(i % 2) {
            ++n2[a[i]];
            if(mxx1 < n2[a[i]]) {
                if(a[i] != pp1) {
                    mxx2 = mxx1;
                    pp2 = pp1;
                }
                mxx1 = max(mxx1, n2[a[i]]);
                pp1 = a[i];
            }
            else if(mxx2 < n2[a[i]]) {
                mxx2 = max(mxx2, n2[a[i]]);
                pp2 = a[i];
            }
        }
    }
    if(p1 == pp1) {
        if(mxx1 + mx2 >= mx1 + mxx2 && p2 > 0) {
            mx1 = mx2;
        }
        else if(mx1 + mxx2 > mxx1 + mx2 && pp2 > 0) {
            mxx1 = mxx2;
        }
        else {
            mx1 = 0;
        }
        cout << n - mx1 - mxx1 << "\n";
        return 0;
    }
    cout << n - mx1 - mxx1 << "\n";
    return 0;
}

Measured memory_bytes: 1408
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int n;

vector<int> g[100000+5];
const int INF = 1e9;
int dist[100000+5][3];

int main(void) {
  int m;
  scanf("%d%d", &n, &m);
  REP(i, m) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u-1].push_back(v-1);
  }
  int s, t;
  scanf("%d%d", &s, &t);
  --s;
  --t;
  REP(i, n) REP(j, 3) {
    dist[i][j] = INF;
  }
  queue<pair<int,int> > q;
  q.push(make_pair(s, 0));
  dist[s][0] = 0;
  while(!q.empty()) {
    auto cur = q.front(); q.pop();
    int u = cur.first;
    int mod = cur.second;
    REP(i, g[u].size()) {
      int v = g[u][i];
      if(dist[v][(mod+1)%3] == INF) {
        dist[v][(mod+1)%3] = dist[u][mod] + 1;
        q.push(make_pair(v, (mod+1)%3));
      }
    }
  }
  int res = dist[t][0];
  cout << (res == INF ? -1 : res/3) << endl;
  
  return 0;
}


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

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

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

	bool tf = true;

	for (int j = 0; j < n; j++) {
		if (num[j] % 2 == 0) {
			if (num[j] % 3 != 0 && num[j] % 5 != 0) {
				tf = false;
				break;
			}
		}
	}

	if (tf) {
		cout << "APPROVED" << endl;
	}

	else {
		cout << "DENIED" << endl;
	}
}

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

int main() {
int N; 
  int K;
  cin>>N>>K;
  int L=0;
  vector<int> S(N);
  for(int i=0; i<N; i++){
    cin>>S.at(i);
    if(S.at(i)>=K)
      L++;
    else continue;
  }
  cout<<L<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}

int main(){
	init();
	ll N;cin>>N;
	vector<ll>v(N+1);
	for(int i=1;i<=N;i++)cin>>v[i];
	v.push_back(-1);
	ll ans=0;
	for(int i=1;i<=N;i++){
		if(v[i]==i && v[i+1]==i+1){
			ans++;
			i++;
			continue;
		}
		if(v[i]==i)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		Set<Integer> set = new HashSet<>();

		for (int i = 0; i < n; i++) {

			int in = sc.nextInt();

			set.add(in);
		}

		System.out.println(set.size());


		sc.close();

	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
typedef long long llong;

int main() {

	int D;

	cin >> D;

	if (D == 22)cout << "Christmas Eve Eve Eve\n";
	else if (D == 23)cout << "Christmas Eve Eve\n";
	else if (D == 24)cout << "Christmas Eve\n";
	else cout << "Christmas\n";
	
	
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ll a , b , t;
    cin >> a >> b >> t;
    int ans = 0;
    for(int i = a; i < t+1; i += a){
        ans += b;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc131/tasks/abc131_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int c, int d) { return c / gcd(c, d) * d; }

void solve() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int lcm_v = lcm(C, D);
    int minv = (A - 1) / C + (A - 1) / D - (A - 1) / lcm_v;
    int maxv = B / C + B / D - B / lcm_v;
    cout << (B - A + 1) - (maxv - minv) << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

#define l 	long
#define ll 	long long
#define vll vector<ll> 
#define vi 	vector<int>
#define pb push_back

// #define rep(j,n,s)  for(long i=j;i<=n;i+=s)
#define forn(j,n,s) for(long i=j; i<n; i+=s)
#define rep(i,n,s) 	for(		; i<n; i+=s)

#define read(k)		ll k; cin>>k;
#define range(v)	begin(v), end(v)
#define X first
#define Y second

void solve() 
{
    //Answer here.
    read(k);	string s;	cin>>s;

    if(s.size()<=k)	cout<<s<<endl;
    else	cout<<s.substr(0,k) + "..."<<endl;
    

}

int main(){

	#ifndef ONLINE_JUDGE
			freopen("input", "r", stdin);
			freopen("output","w",stdout);
	#endif

	ios_base::sync_with_stdio(0);	cin.tie(NULL);	cout.tie(0);
    int t=1;  //cin>>t;
    while(t--)  solve();

    return 0;
}


Measured memory_bytes: 3652
import java.util.*;
import java.awt.geom.*;

public class Main {
	double EPS = 1.0e-08;
	
	public class Circle{
		Point2D p;
		double r;
		public Circle(Point2D p, double r) {
			this.p = p; this.r = r;
		}
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			Circle [] clist = new Circle[n];
			for(int i = 0; i < n; i++){
				String [] s = sc.next().split(",");
				Point2D p = new Point2D.Double(Double.parseDouble(s[0]), Double.parseDouble(s[1]));
				clist[i] = new Circle(p, 1.0);
			}
			
			int res = 1;
			for(int i = 0; i < n; i++){
				for(int j = i + 1; j < n; j++){
					Point2D [] interp = intersectPtCC(clist[i], clist[j]);
					if(interp == null){
						continue;
					}
					for(int k = 0; k < interp.length; k++){
						int result = count(clist, interp[k]);
						res = Math.max(res, result);
					}
				}
			}
			System.out.println(res);
		}
	}
	
	private int count(Circle[] clist, Point2D p) {
		int count = 0;
		for(int i = 0; i < clist.length; i++){
			if(clist[i].p.distance(p) - 1.0 <= EPS){
				count++;
			}
		}
		return count;
	}

	Point2D [] intersectPtCC(Circle a,Circle b) {
		double dis = a.p.distance(b.p);
		if(dis > a.r + b.r)return null;
		Point2D v = sub(b.p, a.p);
		double rc = (dis * dis + a.r * a.r - b.r * b.r) / (2 * dis);
		double rate = rc / dis;
		v = mul(v, rate);
		Point2D c = add(v, a.p);
		double disC2c = c.distance(b.p);
		double disqc = Math.sqrt(b.r * b.r - disC2c * disC2c);
		Point2D v2 = sub(b.p, c);
		v2 = mul(v2, disqc / disC2c);
		Point2D [] res = new Point2D[2];
		res[0] = add(normalVector1(v2), c);
		res[1] = add(normalVector2(v2), c);
		return res;
	}
	
	private Point2D sub(Point2D p2, Point2D p1) {
		double x = p2.getX() - p1.getX();
		double y = p2.getY() - p1.getY();
		return new Point2D.Double(x, y);
	}
	
	private Point2D add(Point2D p1, Point2D p2) {
		double x = p2.getX() + p1.getX();
		double y = p2.getY() + p1.getY();
		return new Point2D.Double(x, y);
	}
	
	private Point2D mul(Point2D p,double value) {
		return new Point2D.Double(p.getX() * value, p.getY() * value);
	}
	
	private Point2D normalVector1(Point2D p) {
		return new Point2D.Double(-p.getY(), p.getX());
	}
	
	private Point2D normalVector2(Point2D p) {
		return new Point2D.Double(p.getY(), -p.getX());
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

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

int find(vector<int> &parent, int cur) {
	if (cur == parent[cur]) return cur;
	else return find(parent, parent[cur]);
}

void solve() {

	int n;
	cin >> n;

	// coordinate, vertex
	vector<pii> x_coord(n), y_coord(n);
	// x, y coordinate combo
	vector<pii> vertexes(n);

	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		x_coord[i] = mp(x, i);
		y_coord[i] = mp(y, i);
		vertexes[i] = mp(x, y);
	}

	sort(x_coord.begin(), x_coord.end());
	sort(y_coord.begin(), y_coord.end());

	vector< pair<int, pii> > edges;

	// x coordinates
	for (int i = 1; i < n; i++) {
		int u = x_coord[i - 1].ss;
		int v = x_coord[i].ss;
		int weight = x_coord[i].ff - x_coord[i - 1].ff;
		edges.pb(mp(weight, mp(u, v)));
	}

	// y coordinates
	for (int i = 1; i < n; i++) {
		int u = y_coord[i - 1].ss;
		int v = y_coord[i].ss;
		int weight = y_coord[i].ff - y_coord[i - 1].ff;
		edges.pb(mp(weight, mp(u, v)));
	}
	sort(edges.begin(), edges.end());


	// disjoint union set
	vector<int> parent(n), rank(n);
	for (int i = 0; i < n; i++) parent[i] = i;

	int ans = 0;

	for (const auto &edge : edges) {

		int weight = edge.ff;
		int u = edge.ss.ff;
		int v = edge.ss.ss;

		// cout << u << ' ' << v << " : " << weight << endl;

		int up = find(parent, u);
		int vp = find(parent, v);

		// disjoint
		if (up != vp) {
			if (rank[up] > rank[vp]) {
				parent[vp] = up;
			} else if (rank[vp] > rank[up]) {
				parent[up] = vp;
			} else {
				parent[up] = vp;
				rank[vp]++;
			}
			ans += weight;
		}

	}
	cout << ans;
}

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

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();
}

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

int main() {
  long long x;
  cin >> x;
  for(long long a = 0ll; a <= 9839ll; a++){
    for(long long b = 0ll; b <= 9839ll; b++){
      if(x == a*a*a*a*a - b*b*b*b*b){
        cout << a << " " << b << endl;
        return 0;
      }else if(x == a*a*a*a*a + b*b*b*b*b){
        cout << a << " " << b * -1 << endl;
        return 0;
      }else if(x == b*b*b*b*b - a*a*a*a*a){
        cout << a * -1 << " " << b * -1 << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

void Main(){
	int n, q; cin >> n >> q;
	fenwick_tree<ll> fw(n);
	rep(i,n){
		int a; cin >> a;
		fw.add(i, a);
	}
	Rep(q){
		int c; cin >> c;
		if(c == 0){
			int p; ll x; cin >> p >> x;
			fw.add(p, x);
		}else{
			int l, r; cin >> l >> r;
			cout << fw.sum(l, r) << endl;
		}
	}
}


Measured memory_bytes: 8248
#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 n;
	cin >> n;
	vector<int> ns(n+100);
    rep(i, n+100) ns.at(i) = -1;
	int max = 0;
    int nk = n/100;
    if(n < 100){
      for(int i=0; i<n; i++){
          int a;
          cin >> a;
          rep(j, n){
              if(max < j) max = j;
              if(ns.at(j) < a){
                ns.at(j) = a;
                break;
              }
          }
      }
    }else{
      for(int i=0; i<n; i++){
          int a;
          cin >> a;
      	  int l = 0;
      	  for(int k=0; k<=nk+1; k++){
          	if(ns.at(k*100) < a){
              l = k;
              break;
            }
          }
          for(int j=100*l-100; j<=100*l; j++){
            if(j >= 0){
              if(max < j) max = j;
              if(ns.at(j) < a){
                ns.at(j) = a;
                break;
              }
            }
          }
      }
    }
    cout << max+1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N;
    cin >> N;
    vec prime;
    loop(i, 55556)
    {
        if (primejudge(i + 1))
            prime.push_back(i + 1);
    }
    ll siz = prime.size();
    ll count = 0;
    loop(i, 10000)
    {
        if (prime[i] % 5 != 1)
            continue;
        cout << prime[i];
        count++;
        if (count != N)
            cout << " ";
        else
            putout("");
        if (count == N)
            break;
    }
    return 0;
}


Measured memory_bytes: 3796
r,c = [int(x) for x in input().split()]
s_row = [0 for x in range(c+1)]
for i in range(r):
    row = [int(x) for x in input().split()]
    row.append(sum(row))
    print(" ".join([str(x) for x in row]))
    s_row = [x+y for x,y in zip(s_row,row)]
print(" ".join([str(x) for x in s_row]))


Measured memory_bytes: 5620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
ll dp[200][100050]={};
ll max(int a,int b){
  if(a>b)return a;
  return b;
}
int main(){
  int n,W;
  cin>>n>>W;
  vector<int> v(n);
  vector<int> w(n);
  for(int i=0;i<n;i++){
    cin>>w[i]>>v[i];
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=W;j++){
      if(j>=w[i-1]){
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
	}
      else dp[i][j]=dp[i-1][j];
    }
  }
  ll max=0;
  for(int i=1;i<=W;i++){
    if(max<dp[n][i])max=dp[n][i];
  }
  cout<<max<<endl;
  return 0;
}


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

int main(){
	map<int,int> mapa;
	int l=1,r=399;
	int n,sz=0,rat;
	cin >> n;
	for(int i = 0;i<n;i++){
		l = 1,r=399;
		bool f = 0;
		cin >> rat;
		for(int j = 1;j<=8;j++){
			
			if(rat>=l and rat <=r){
				f = 1;
				mapa[j]=1;
				
				break;
			}
			l = 400*j;
			r =l+399;
		}

		if(!f)
			sz++;
	
	}
	
	cout<<max(1,(int)mapa.size())<<" "<<mapa.size()+sz;
}

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

int f(int a) {
    int ret = 0;
    for (; a > 0; a /= 10) {
        ret += a % 10;
    }
    return ret;
}

int main() {
    int n, ret = 100000000;
    std::cin >> n;
    for (auto a = 1; a <= n / 2; a++) {
        ret = std::min(ret, f(a) + f(n - a));
    }
    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000009
#define int signed long long int 
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int pow(int p,int r){
	int ans=1;
	while(r>0){
     if(r&1){
		 ans=((ans%mod)*(p%mod))%mod;
	 }
	 r=r>>1;
     p=((p%mod)*(p%mod))%mod;
	}
}
signed main() {
garou;
int n;
cin>>n;
int x=1;
int y=1000000000000000000;
int a[n],z=0;
for(int i=0;i<n;i++){
	cin>>a[i];
	if(a[i]==0)
    z++;
}
if(z>0)
cout<<0;
else{
for(int i=0;i<n;i++){
	if(a[i]<=y/x){
		x*=a[i];
	}
	else{
		x=-1;
		break;
	}
	
}
cout<<x;
}
}

Measured memory_bytes: 4376
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

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

        System.out.println(price(A, B));
    }

    private static int price(int age, int price) {
        if (age <= 5) return 0;
        if (6 <= age && age <= 12) return price / 2;
        return price;
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int dice(int a, int b){
		int count = 0;
		string tpat[3];
		tpat[0] = "12651";
		tpat[1] = "23542";
		tpat[2] = "13641";
		int ret[3];
		ret[0] = 3;
		ret[1] = 1;
		ret[2] = 5;
		for(int i = 0; i < 3; i++){
				for(int j = 0; j < 4; j++){
						if(tpat[i][j] - '0' == a && tpat[i][j+1] - '0' == b){
								return ret[i];
						}
				}
		}
		tpat[0] = "15621";
		tpat[1] = "24532";
		tpat[2] = "14631";
		for(int i = 0; i < 3; i++){
				for(int j = 0; j < 4; j++){
						if(tpat[i][j] - '0' == a && tpat[i][j+1] - '0' == b){
								return 7 - ret[i];
						}
				}
		}
		return 1;

}

int main(int argc, char const* argv[])
{
	int d[6];
	for(int i = 0; i < 6; i++){
			cin >> d[i];
	}
	int e[6];
	for(int i = 0; i < 6; i++){
			cin >> e[i];
	}
	int a1 = 0;
	int a2 = 1;
	while(d[a1] == d[a2] && a2 < 7)a2++;
	int b1[6];
	int b2[6];
	int c1 = 0;
	int c2 = 0;
	for(int i = 0; i < 6; i++){
			if(d[a1] == e[i])b1[c1++] = i;
			if(d[a2] == e[i])b2[c2++] = i;
	}
	for(int i = 0; i < c1; i++){
			for(int j = 0; j < c2; j++){
					if(d[dice(a1+1, a2+1)-1] == e[dice(b1[i]+1, b2[j]+1)-1] && d[5-a1] == e[5-b1[i]] && d[5-a2] == e[5-b2[j]]){
						cout << "Yes" << endl;
						return 0;
					}
			}
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double pi=acos(-1);
double a,b,c,d;
double C;
//c^2=a^2+b^2-2abcosC
int main(){
	cin>>a>>b>>c>>d;
	double C=abs(c/12*2*pi+d/60*pi/6-d/60*2*pi);
	//注意10点40时时针不在10上
	printf("%.10lf\n",sqrt(a*a+b*b-2*a*b*cos(C)));
	return 0;
}




Measured memory_bytes: 4240
main(a,b,c){
    scanf("%d%d%d",&a,&b,&c);
    if(a>b)a+=b,b=a-b,a-=b;
    if(b>c)b+=c,c=b-c,b-=c;
    if(a>b)a+=b,b=a-b,a-=b;
    printf("%d %d %d\n",a,b,c);
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

ll MAX_V = 3000; //頂点数
struct edge {
    ll to;
    ll cost;
};
ll n;

vector<vector<struct edge>> G(MAX_V); //隣接リスト
vector<ll> d(MAX_V); //各頂点への最短距離
bool bellmanford(ll s){
  fill(ALL(d), INF);
  d[s]=0;
  for(ll i=0;i<MAX_V;i++){
    for(ll j=0;j<G.size();j++){
      for(ll k=0;k<G[j].size();k++){
        struct edge e=G[j][k];
        if(d[e.to]>d[j]+e.cost){
          d[e.to]=d[j]+e.cost;
          if(e.to==n-1&&i==MAX_V-1){
            return false;
          }
        }
      }
    }
  }
  return true;
}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll m;cin>>n>>m;
  vector<ll> u(m),v(m),a(m);
  for(i=0;i<m;i++){
    cin>>u[i]>>v[i]>>a[i];
    struct edge e ={v[i]-1,(-1)*a[i]};
    G[u[i]-1].push_back(e);
  }
  if(bellmanford(0))
  cout<<d[n-1]*(-1)<<endl;
  else
  cout<<"inf"<<endl;
  

  return 0;
}

Measured memory_bytes: 384
#include <iostream>

struct vector3 {
    double x, y, z;
    vector3(double x, double y, double z): x(x), y(y), z(z) {}
};

vector3 cross_product(const vector3 &v1, const vector3 &v2)
{
    return vector3(v1.y*v2.z-v1.z*v2.y,v1.z*v2.x-v1.x*v2.z,v1.x*v2.y-v1.y*v2.x);
}

int main()
{
    while (true) {
        double x1, y1, x2, y2, x3, y3, xp, yp;
        std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;
        if (std::cin.eof()) break;

        vector3 p1(xp - x1, yp - y1, 0.0), p2(xp - x2, yp - y2, 0.0), p3(xp - x3, yp - y3, 0.0);
        vector3 cp1 = cross_product(p1, p2), cp2 = cross_product(p2, p3), cp3 = cross_product(p3, p1);
        if (cp1.z < 0.0 && cp2.z < 0.0 && cp3.z < 0.0) std::cout << "YES" << std::endl;
        else if (cp1.z > 0.0 && cp2.z > 0.0 && cp3.z > 0.0) std::cout << "YES" << std::endl;
        else std::cout << "NO" << std::endl;
    }
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int H, W;
char S[400][400];
bool visit[400][400];
int black, white;
int dy[4] = {0, 1, 0, -1};
int dx[4] = {-1, 0, 1, 0};

void dfs(int y, int x)
{
  visit[y][x] = true;
  if (S[y][x] == '#')
    black++;
  else
    white++;
  REP(i, 4)
  {
    int ny = y + dy[i];
    int nx = x + dx[i];
    if (0 <= ny && ny < H && 0 <= nx && nx < W && !visit[ny][nx] && S[y][x] != S[ny][nx])
      dfs(ny, nx);
  }
}

int main()
{
  cin >> H >> W;
  REP(i, H)
  REP(j, W)
  cin >> S[i][j];
  REP(i, H)
  REP(j, W)
  visit[i][j] = false;
  ll ans = 0;
  REP(i, H)
  REP(j, W)
  {
    if (!visit[i][j])
    {
      black = 0;
      white = 0;
      dfs(i, j);
      ans += (ll)black * white;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N, ans = 0;
  cin >> N;
  vector<int> V(N), C(N);
  for(int i = 0; i < N; i++) cin >> V.at(i);
  for(int i = 0; i < N; i++) cin >> C.at(i);
  for(int i = 0; i < N; i++){
    if(V.at(i) - C.at(i) > 0) ans += V.at(i) - C.at(i);
  }
  cout << ans;
}

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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

using namespace std;

int main ()
{
  double L;
  
  cin >> L;

  printf("%.12lf\n",pow(L/3.0,3.0));
  return 0;
}

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

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string input;
            while((input = Console.ReadLine()) != null) {
                double[] data = input.Split(',').Select(q => double.Parse(q)).ToArray();
                if((data[1] / Math.Pow(data[2], 2)) >= 25) {
                    Console.WriteLine((int)data[0]);
                }
            }
        }
    }
}

Measured memory_bytes: 6088
package main

import (
	"fmt"
)

func main() {
	var a int
	var b int
	fmt.Scanf("%d %d", &a, &b)

	var count int
	for i := a; i <= b; i++ {
		if isPalindromic(i) {
			count++
		}
	}
	fmt.Println(count)
}

func isPalindromic(n int) bool {
	var reversed int
	original := n
	for n > 0{
		digit := n % 10
		reversed = reversed * 10 + digit
		n /= 10
	}
	return reversed == original
}

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

using namespace std;

int s;
bool Find;
vector<int> vl,cu;
vector< vector<int> > el;

void dfs(int v, int nov) {
	if (nov > 0 && v == s) {
		cout << nov << endl;
		for (int i = 0; i < nov; ++i) {
			cout << vl[i]+1 << endl;
		}
		Find = true;
		return;
	}
	if (!Find) {
		bool ca = true;
		for (int i = 0; i < el[v].size(); ++i) {
			if (cu[el[v][i]] == 1) {
				cu[el[v][i]] = -v;
			}
			else if (cu[el[v][i]] > 1) {
				for (int j = 0; j < nov; ++j) {
					if (vl[j] == el[v][i]) {
						cout << nov-j << endl;
						for (int k = j; k < nov; ++k) {
							cout << vl[k]+1 << endl;
						}
						Find = true;
						return;
					}
				}
			}
		}
		for (int i = 0; i < el[v].size(); ++i) {
			if (cu[el[v][i]] == -v) {
				cu[el[v][i]] = 2;
				vl[nov] = el[v][i];
				dfs(vl[nov],nov+1);
				cu[el[v][i]] = -v;
			}
		}
		for (int i = 0; i < el[v].size(); ++i) {
			if (cu[el[v][i]] == -v) {
				cu[el[v][i]] = 1;
			}
		}
	}
	return;
}

int main(void) {
	int u,v,N,M;
	cin >> N >> M;
	el = vector< vector<int> >(N);
	for (int i = 0; i < M; ++i) {
		cin >> u >> v;
		el[u-1].push_back(v-1);
	}
	s = 0;
	cu = vector<int>(N,1);
	vl = vector<int>(N,-1);
	Find = false;
	while (!Find && s < N) {
		dfs(s,0);
		++s;
	}
	if (!Find) {
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll i,j=100,N,ans=0;
  cin>>N;
  while(j<N){
    j+=j/100;
    ans++;
  }
  print(ans);
  // }return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <algorithm>

using namespace std;

using int64 = long long;

template<class T> inline void fastin(T &num) {
  T c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

constexpr int64 INF = 1e18;

int main() {
  int n; int64 x; fastin(n); fastin(x);
  int64 a[n];
  for (int i = 0; i < n; ++i) fastin(a[i]);

  int64 dp[n][n]; fill(dp[0], dp[n], INF);

  for (int i = 0; i < n; ++i) {
    for (int move = 0; move < n; ++move) {
      int pos = (i + move) % n;
      dp[i][move] = min(dp[i][(move + n - 1) % n], a[pos]);
    }
  }

  int64 ans = INF;

  for (int move = 0; move < n; ++move) {
    int64 sum = 0;
    for (int j = 0; j < n; ++j) {
      sum += dp[j][move];
    }
    sum += move * static_cast<int64>(x);
    ans = min(ans, sum);
  }

  printf("%lld\n", ans);

  return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll ans = 0,n,x;
    cin >> n;
    vector<ll> b(n);
    for(int i = 0;i < n;i ++){
        int ai;
        cin >> ai;
        b[i] = ai - (i+1);
    }
    sort(b.begin(),b.end());
    if(n%2) x = b[(n-1)/2];
    else x = round((b[(n/2)]+b[n/2-1])/2);
    for(int i = 0;i < n;i ++){
        ans += abs(b[i] - x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
def segfunc(x,y):
    return x|y

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
n=int(input())
S=input()
Q=int(input())

num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

alphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
alphabet={key:alphabetlist.index(key)  for key in alphabetlist}

data=[0 for i in range(0,n)]
for i in range(0,n):
    data[i]=2**(alphabet[S[i]])

init(data)

ans=[]
for i in range(0,Q):
    q,a,b=input().split()
    if q=='1':
        update(int(a)-1,2**(alphabet[b]))
    else:
        a=int(a)
        b=int(b)
        ans.append(query(a-1,b))

for i in range(len(ans)):
    x=ans[i]
    print(bin(x).count('1'))


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct BipartiteMatching {
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;

  BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}

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

  bool dfs(int idx) {
    used[idx] = timestamp;
    for(auto &to : graph[idx]) {
      int to_match = match[to];
      if(alive[to] == 0) continue;
      if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
        match[idx] = to;
        match[to] = idx;
        return true;
      }
    }
    return false;
  }

  int bipartite_matching() {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      if(i < match[i]) {
        cout << i << "-" << match[i] << endl;
      }
    }
  }
};


signed main()
{
  gearup;
  int n; cin >> n;
  vpii r,b;
  rep(i,n){
    int x,y; cin >> x >> y;
    x--;y--;
    r.push_back({x,y});
  }
  rep(i,n){
    int x,y; cin >> x >> y;
    x--;y--;
    b.push_back({x,y});
  }
  //sort(all(r));
  //sort(all(b));
  
  BipartiteMatching bm(n + n);
  rep(i,n){
    rep(j,n){
      if(r[i].first < b[j].first && r[i].second < b[j].second) bm.add_edge(i,n+j);
    }
  }
  
  out(bm.bipartite_matching());
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  printf("%d\n",(a + b) % 24);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N],d[N],f[N],t;

void visit(int r){
  color[r] = GRAY;
  d[r] = ++t;
  for(int v=0;v<n;v++){
    if(M[r][v] == 0) continue;
    if(color[v] == WHITE) visit(v);
  }
  color[r] = BLACK;
  f[r] = ++t;
}


void dfs(){
  for(int u=0;u<n;u++) color[u] = WHITE;
  t = 0;

  for(int u=0;u<n;u++){
    if(color[u] == WHITE) visit(u);
  }

  for(int u=0;u<n;u++){
    cout << u+1 << " " << d[u] << " " << f[u] << endl;
  }
}

int main(){
  int u,v,k;

  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) M[i][j] = 0;
  }

  for(int i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(int j =0;j<k;j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  dfs();
  
  return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
using namespace std;

bool func (int p[], int N){
	for(int k = 0; k < N; k++){
		if(k+1 != p[k]) {
			return false;
		}
	}
	return true;
}

int main() {
	int N;
	int p[55];
	bool can = false;
	int flag = 0;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> p[i];

	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			swap(p[i],p[j]);
			can = func(p, N);
			if(can == true) flag = 1;
			swap(p[i],p[j]);
		}
	}

	if(flag == 1) cout << "YES" << endl;
	else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,X,s;
  s=0;
  cin >> N >> X;
  vector<int> m(N);
  for(int i=0;i<N;i++){
    cin >> m.at(i);
  }
   for(int i=0;i<N;i++){
    s+=m.at(i);
  }
  sort(m.begin(), m.end());
  cout << N+(X-s)/m.at(0) << endl;
}

Measured memory_bytes: 256
N, M, L = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
B = [list(map(int, input().split())) for i in range(M)]
C = [[0] * L for i in range(N)]

for n in range(N):
    for l in range(L):
        for m in range(M):
            C[n][l] += A[n][m] * B[m][l]
for row in C:
    print(*row)


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

int main() {
  
  int K, X; cin >> K >> X; K--;
  
  for (int i = X - K; i <= X + K; i++) {
    cout << i;
    if (i != X + K) cout << " ";
  }
  
  cout << endl;  
  
}

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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	vector<int> v(4);
	cin >> v[0] >> v[1] >> v[2] >> v[3];
	sort(v.begin(), v.end());
	do{
		if(v[0]*1000 + v[1]*100 + v[2]*10 + v[3] == 1974){
			cout << "YES" << endl;
			return 0;
		}
	}while(next_permutation(v.begin(), v.end()));

	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<int> sum(n+1,0);
	rep(i,m){
		int l,r;
		cin>>l>>r;
		sum[l-1]++;
		sum[r]--;
	}
	rep(i,n+1){
		sum[i+1]+=sum[i];
	}
	int ans=0;
	rep(i,n+1){
		if(sum[i]==m) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A= sc.nextInt();
		int B = sc.nextInt();
		int C= sc.nextInt();
		int X= sc.nextInt();
		int count =0;
		for (int i=0;i*500<=X&&i<=A;i++) {
			int total = i*500;
			for (int j=0;j*100<=X-total&&j<=B;j++) {
				if ((X-total-j*100)/50<=C) {
					count ++;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35732
#include <bits/stdc++.h>
#define MAX (ll)(1e6 + 7)
#define INF (ll)(1e17 + 7)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false);
#define LOG 22

using namespace std;
using ll = long long;

int main () {
	string st;
	cin >> st;
	if (st[2] == st[3] && st[4] == st[5]) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  sort(A.begin(), A.end(), greater<ll>());
  ll ans = 0;
  for(int i=0;i<N-1;++i) {
    if(i==0) ans += A[0];
    else {
      ans += A[(i+1)/2];
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4800
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
    if((a+b)%2==0){
        cout << (a+b)/2 << endl;
    }
    else{
        cout << (a+b)/2+1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
ac, wa, tle, re = 0, 0, 0, 0
n = int(input())
for _ in range(n):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    else:
        re += 1

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))


Measured memory_bytes: 9044