akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)

template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }


///////////////

#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])

template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;

ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }

ld area2(CR<G> g) {
	ld s = 0;
	REP(i, g.size()) s += cross(g[i], NEXT(g, i));
	return s;
}

//////////////

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);

	ll i = 1;
	while (true) {
		ll n;
		cin >> n;
		if (n == 0) break;
		G g;
		REP(i, n) {
			ld x, y; cin >> x >> y;
			g.push_back({ x, y });
		}
		cout << fixed << setprecision(1);
		cout << i << " " << abs(area2(g)) / 2 << endl;
		++i;
	}

	return 0;
}

Measured memory_bytes: 3256
#include <iostream>
#include <vector>
#include <algorithm>
/*
int main(){
    using namespace std;
    long n, sum{0};
    cin >> n;
    vector<int> ai(n);
    for(int i{0}; i < n; i++) {cin >> ai[i]; sum = sum + ai[i];}  
    cout << *min_element(ai.begin(), ai.end()) << " "
    << *max_element(ai.begin(), ai.end()) << " " << sum <<endl;

}
*/

int main(){
    using namespace std;
    int n, a{-1000000}, b{1000000}, c;
    long sum{0};
    cin >> n;
    for(int i{0}; i<n; i++){
        cin >> c;
        if(a<c) a=c;
        if(b>c) b=c;
        sum = sum + c;
    }
    cout << b << " " << a << " " << sum << endl;
}





Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> Pair;
using namespace std;

ll gcd(ll x,ll y)
{
    ll r;
    if(x < y){
        swap(x,y);
    }
    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
    ll N,M;
    cin >> N >> M;
    string s,t;
    cin >> s >> t;
    bool can = true;
    ll x = N * M / gcd(N,M);
    ll y = gcd(N,M);
    ll n = N / gcd(N,M);
    ll m = M / gcd(N,M);
    for(int i = 0; i < y; i++){
        if(s[i*n] != t[i*m]){
            can = false;
        }
    }
    if(can) cout << x << endl;
    else cout << -1 << endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    vector<string> S(H);
    for (int i=0;i<H;++i) cin >> S[i];
    vector<vector<int>> diff(H-1,vector<int>(W));
    for (int i=0;i<H-1;++i){
        for (int j=0;j<W;++j){
            diff[i][j]=(S[i][j]!=S[i+1][j]);
        }
    }
    for (int i=0;i<H-1;++i){
        int now=0;
        while(now<W){
            int r=0;
            while(r<W&&diff[i][now+r]==diff[i][now]) ++r;
            for (int j=0;j<r;++j) diff[i][now+j]=r-j;
            now+=r;
        }
    }
    int ans=W;
    for (int j=0;j<W;++j){
        stack<int> stl,str;
        vector<int> L(H-1),R(H-1);
        for (int i=0;i<H-1;++i){
            while(!stl.empty()&&diff[stl.top()][j]>=diff[i][j]){
                stl.pop();
            }
            L[i]=(stl.empty()?0:stl.top()+1);
            stl.emplace(i);
        }
        for (int i=H-2;i>=0;--i){
            while(!str.empty()&&diff[str.top()][j]>=diff[i][j]){
                str.pop();
            }
            R[i]=(str.empty()?H-1:str.top());
            str.emplace(i);
        }
        for (int i=0;i<H-1;++i){
            ans=max(ans,diff[i][j]*(R[i]-L[i]+1));
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 22280
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long

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

  int T[N], sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
    sum += T[i];
  }

  int M;
  cin >> M;

  queue<pair<int, int> > que;
  int p, x;
  for (int i = 0; i < M; i++) {
    cin >> p >> x;
    que.push(make_pair(p, x));
  }

  pair<int, int> u;
  while (!que.empty()) {
    u = que.front();
    que.pop();
    cout << sum + (u.second - T[u.first - 1]) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer i;
  for(i=nil;i->next!=nil;i=i->next){
  	if(i->next->key==key){
  		return i->next;
  		}
  }
  	return NULL;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  t->next->prev=t->prev;
  t->prev->next=t->next;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer i;
  i=nil->prev;
  deleteNode(i);
}

void delete(int key){
  /* your code */
  NodePointer i; 
  i=listSearch(key);
  if(i!=NULL)deleteNode(i);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 32976
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);	
		int N = sc.nextInt();
		int[] A;
		A = new int[N];

		for(int i = 0; i < N; i++){
		 	A[i]= sc.nextInt();
		}

		int count = 0;
		int flag = 1;
		while(flag == 1){
			flag = 0;
			for(int j = N - 1; j > 0; j--){
				if(A[j] < A[j-1]){
					int temp = A[j];
					A[j] = A[j-1];
					A[j-1] = temp;
					flag = 1; 
					count ++;
				}
			}
		}
		for(int k = 0; k < N; k++){
			System.out.printf("%d",A[k]);
			if(k != N - 1){
				System.out.printf(" ");
			}	
		}
		System.out.printf("\n%d\n",count);

	}
}


Measured memory_bytes: 26656
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    LL n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;

    n--;
    cout << 5LL + max({n / a, n / b, n / c, n / d, n / e}) << endl;
}

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

using namespace std;

typedef long long int lli;

lli i,j,k,l,m,n,t,a,b,c,d,x,y,p,q,sum=0,total=0;

#define read(in) freopen("Input.txt","r",stdin)

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    //read(in);

    cin>>n>>k;

    map<lli,lli>mp;

    if(k==1 || n==0)
        cout<<"0\n";
    else
    {
        a=n%k;
        b=abs(a-k);
        n=min(a,b);
        cout<<n<<"\n";
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}


const int dy[4] = {-1, 0, 1, 0};
const int dx[4] = {0, -1, 0, 1};
typedef pair<int, int> P;
const int INF = 100100100;
int main(){//
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for(int i=0; i<(int)s.size(); i++) cin >> s[i];
    //for(int i=0; i<H; i++) cin >> s[i];
    //BFSして最短経路を見つけ，　
    //そのあと，黒く塗れるマスを数える
    vector<vector<int>> grid(H, vector<int>(W, INF));
    grid[0][0] = 0;
    queue<P> q;
    q.push(P(0, 0));
    while(!q.empty()){
        int y = q.front().first;
        int x = q.front().second;
        q.pop();

        for(int dir=0; dir<4; dir++){
            int next_y = y + dy[dir];
            int next_x = x + dx[dir];
            if(next_y < 0 || H <= next_y) continue;
            if(next_x < 0 || W <= next_x) continue;
            if(s[next_y][next_x] == '#') continue;
            if(grid[next_y][next_x] != INF) continue;
            grid[next_y][next_x] = grid[y][x] + 1;
            q.push(P(next_y, next_x));
        }
    }

    //cout << " BFS is completed ! " << endl;
    int ans = 0;
    if(grid[H-1][W-1] == INF){
        ans = -1;
        cout << ans << endl;
        return 0;
    }
    int min_step = grid[H-1][W-1];
    //gridの中に同じ値が入っていたら数える為のフラグ
    vector<bool> is_double(min_step+5, false); 
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(grid[i][j] > min_step && s[i][j] == '.'){
                ans++;
                continue;
            }
            if(s[i][j] == '#') continue;
            if(is_double[grid[i][j]] == true){
                ans++;
                continue;
            }
            is_double[grid[i][j]] = true;

        }
    }

    cout << ans << endl;



}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <vector>
int main() {
    int n, m, q;
    std::vector<int> v, w;
    std::cin >> n;
    while (n-- > 0) {
        std::cin >> m;
        v.push_back(m);
    }
    std::cin >> q;
    while (std::cin >> m) {
        w.push_back(m);
    }
    int c = 0;
    for (auto&& e: w) {
        if (std::binary_search(v.begin(), v.end(), e)) {
            ++c;
        }
    }
    std::cout << c << std::endl;
}



Measured memory_bytes: 3492
///*****************************************************///
///*.......................Faiyaj Bin Amin............................*///
///*...................................................................*///
///*.........................KUET CSE 2K17......................*///
///*...................................................*///
///*****************************************************///

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define fastio      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define ret return
#define rep(q, i, n) for(int q=i; q<n; q++)
#define forn(i, n) for(int i=0; i<n; i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pdd pair<double, double>

#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define seecontent(v) for(auto x : v) { cout << x << " ";} cout << "\n\n";

#define PI 2*acos(0.0)
#define lcm(a, b)  ((a / __gcd(a, b) ) * b)

#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)

#define mx 100005
#define INF 1e18
#define MOD 1000000007
#define MIN 0

//template <typename T>  using orderedSet =
//    tree<T, null_type, less_equal<T>,
//    rb_tree_tag, tree_order_statistics_node_update>; //find_by_order, order_of_key


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0}; // Directional
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

/**------------------------------------BITMASK------------------------------------------**/
//int Change(int N, int pos){return N= N^(1<<pos);}
//bool Check(int N, int pos){return (bool)(N &(1<<pos));}  /// check bit 0 or 1
/**-----------------------------------------------------------------------------------------------**/

//using namespace __gnu_pbds;
using namespace std;

int main()
{
    fastio;

    ll n;
    cin>>n;

    ll b[n-1], a[n]= {0};

    forn(i, n-1)
    {
        cin >> b[i];
    }

    a[0]=b[0];
    a[1]=b[0];
    for(int i=1; i<n-1; i++)
    {
        a[i+1]=b[i];
        if(b[i]<a[i])
            a[i]=b[i];
    }


    ll cnt=0;
    forn(i, n)
    {
        cnt += a[i];
    }
    cout<< cnt << "\n";

    return 0;
}

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

int main(){
 int N; cin >> N;
  vector<double> x(N); vector<double> y(N);
  for(int i = 0; i < N; i++){ cin >> x[i] >> y[i];}
  
  vector<int> per(N);
  for(int i = 0; i < N; i++){ per[i] = i;}
  
  long double ans = 0.0;
  int cnt = 0;
  do{
    long double res = 0.0;
    for(int i = 0; i < N-1; i++){
      res += sqrt(pow((x[per[i+1]]-x[per[i]]),2)+pow((y[per[i+1]]-y[per[i]]),2));
      
    }
      ans += res;
    
    cnt++;
       
  }while(next_permutation(per.begin(),per.end()));
  
  
  cout << fixed << setprecision(10) << ans/cnt << endl; return 0;
}
      
      
     

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

int M;
int a[7];
int s, g;
int N[301];

bool isChecked[301];
vector<int> milestone[301];  //そのマスで出せばゴールにたどり着ける目を格納する

int iabs(int x){ return x >= 0 ? x : -x; }

bool search(int now){
	if (isChecked[now]) return false;
	else if (now == g)  return true;

	isChecked[now] = true;
	for (int dice = 1; dice <= 6; dice++){
		if (now + a[dice] <= M && search(now + a[dice] + N[now + a[dice]])){
			milestone[now].push_back(a[dice]);
		}
		if (now - a[dice] >= 1 && search(now - a[dice] + N[now - a[dice]])){
			milestone[now].push_back(-a[dice]);
		}
	}

	return milestone[now].size() > 0 ? true : false;
}

int main(){
	cin >> M;
	for (int i = 1; i <= 6; i++){
		cin >> a[i];
	}
	cin >> s >> g;
	for (int i = 1; i <= M; i++){
		cin >> N[i];
	}
	bool canGoal = search(s);

	int now = s; //自分が今いるマスの番号
	for (;;){
		int dice;
		cin >> dice;

		bool found = false;
		for (vector<int>::iterator it = milestone[now].begin(); it != milestone[now].end(); it++){
			if (iabs(*it) == a[dice]){
				if (*it > 0){
					now = now + a[dice] + N[now + a[dice]];
					cout << 1 << endl;
				}
				else{
					now = now - a[dice] + N[now - a[dice]];
					cout << -1 << endl;
				}
				found = true;
				break;
			}
		}
		if(!found) cout << 0 << endl;
		//cout.flush();

		if (now == g) return 0;
	}
	
	return 0;
}

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

int main(){
    while (1){
        int h,w; cin>>h>>w;
        if(h+w==0)
            break;
        bool came[h][w]={},loop=0;
        string in[h];
        for(int i=0; i<h; i++){
            cin>>in[i];
        }
        int x=0,y=0;
        while (in[y][x]!='.'){
            if(came[y][x]){
                loop=1;
                break;
            }
            came[y][x]=1;
            switch (in[y][x]){
                case '>':
                    x++;
                    break;
                case '<':
                    x--;
                    break;
                case '^':
                    y--;
                    break;
                case 'v':
                    y++;
                    break;
            }
        }
        if(loop)
            cout<<"LOOP\n";
        else
            cout<<x<<" "<<y<<endl;
//      cout<<in[y][x]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3164
#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>;

// #define NDEBUG
#include<assert.h>
const int INF = 1001001001;

ll n,k;
vector<ll>a;
ll eps=1e-9;
int check(double mid){
	ll cnt=0;
	rep(i,n){
		if(a[i]<=mid)continue;
		cnt+=(a[i]+mid-0.01)/mid-1;
	}
	if(cnt<=k)return 1;
	return 0;
}
ll solve(){
   double l=0,r=1e9;
   for(int i=0;i<100;i++){
		double mid=l+ (r-l)/2.0;
		if(check(mid))r=mid;
		else l=mid;
   }
   return ceil(l);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	a.resize(n);
	rep(i,n)cin>>a[i];
	cout<<solve()<<endl;
	return 0;
}

Measured memory_bytes: 4680
N = int(input())
X = [int(i) for i in input().split()]
X_sorted = sorted(X)
a = X_sorted[len(X_sorted)//2]
b = X_sorted[len(X_sorted)//2-1]
for i in X:
  if i <= b:
    print(a)
  elif i >= a:
    print(b)

  

Measured memory_bytes: 25556
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n=in.nextInt();
            int[] heights=new int[n];
            for(int i=0;i<n;i++){
                heights[i]=in.nextInt();
            }
            int[] dp =new int[n];
            dp[0]=0;
            dp[1]=Math.abs(heights[0]-heights[1]);
            for(int i=2;i<n;i++){
                dp[i]=Math.min(dp[i-1]+Math.abs(heights[i]-heights[i-1]), dp[i-2]+Math.abs(heights[i]-heights[i-2]));
            }
            out.println(dp[n-1]);
        }
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 31724
s = input()
sl = list(s)
for i in range(len(sl)):
    if (i + 1) % 2 == 1:
        if sl[i] == 'L':
            print('No')
            break
        else:
            continue
    else:
        if sl[i] == 'R':
            print('No')
            break
        else:
            continue
else:
    print('Yes')

Measured memory_bytes: 61672
def submit():
    n = int(input())
    s1 = input()
    s2 = input()
    modp = 1000000007

    curr = 0
    ans = 1
    prev = 0 # 縦向きなら1, 横向きなら2
    while curr < n:
        if s1[curr] == s2[curr]:
            # 縦向き
            if prev == 0:
                ans = 3
            elif prev == 1:
                ans *= 2
                ans %= modp
            prev = 1
            curr += 1
        else:
            if prev == 0:
                ans = 6
            elif prev == 1:
                ans *= 2
                ans %= modp
            else:
                ans *= 3
                ans %= modp
            prev = 2
            curr += 2
    print(ans)


submit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
/******************************define**********************************/

/*****************************functions********************************/

/****************************main function*****************************/
int main(void){
    int n;cin >> n;
    vector<int> a(n);
  	int cnt = 0;
    rep(n){cin >> a[i]; a[i]--;}
    if(a[0] == 0){swap(a[0],a[1]);cnt++;}
    if(a[n-1] == n-1){swap(a[n-1],a[n-2]);cnt++;}
    for(int i = 1;i < n-1;i++){
        if(a[i]!=i) continue;
        else if(a[i+1]==i+1){swap(a[i],a[i+1]);cnt++;}
        else if(a[i+1]!=i){swap(a[i],a[i+1]);cnt++;}
        else{swap(a[i],a[i-1]);cnt++;}
    }
    //rep(n) printf("%d ",*(a.begin()+i) + 1);
  	cout << cnt << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, m;
  cin >> n >> m;

  map<ll, ll> suki;

  rep(i, n) {
    ll k;
    cin >> k;
    rep(j, k) {
      ll a;
      cin >> a;
      suki[a]++;
    }
  }

  ll ans = 0;
  FORm(it, suki) {
    if (it->second == n) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

# dp[i][j][k] = 寿司が3つの皿がi個、2つの皿がj個、1つの皿がk個からの操作回数の期待値
# dp[0][0][0] = 0で正しいので、ここから順に埋めていけばよい。

N = int(readline())
A = list(map(int,readline().split()))

cnt = [0] * 4

for a in A:
  cnt[a] += 1

dp = [[[0 for k in range(N + 2)] for j in range(N + 2)] for i in range(N + 2)]

for i in range(N + 1):
  for j in range(N + 1):
    for k in range(N + 1):
      nonzero = i + j + k
      if nonzero == 0:
        continue
      dp[i][j][k] = N / nonzero
      if i - 1 >= 0:
        dp[i][j][k] += dp[i - 1][j + 1][k] * i / nonzero
      if j - 1 >= 0:
        dp[i][j][k] += dp[i][j - 1][k + 1] * j / nonzero
      if k - 1 >= 0:
        dp[i][j][k] += dp[i][j][k - 1] * k / nonzero

print(dp[cnt[3]][cnt[2]][cnt[1]])


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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

bool data[50][50];
int n,m;
vector<pii> vp;
int ans = 0;
bool reach[50];
//pからqへいけるか？
bool check(int p, int now, int q){
	//cout << "now " << now << endl;
	if(p != now && now == q){
		// cout << "p now q" << p << " " << now << " " << q << endl;
		return true;
	} 
	bool res = false;
	REP(i,n){
		if(reach[i] == false && data[i][now]){
			if(i == p && now == q) continue;
			if(i == q && now == p) continue;
			reach[i] = true;
			if(check(p, i, q)) res = true;
		}
	}
	return res;
}
int main(){
	REP(i,50) REP(j,50) data[i][j] = false;
	cin >> n >> m;
	REP(i,m){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		data[a][b] = true;
		data[b][a] = true;
		vp.pb(mp(a,b));
	}
	REP(i,m){
		REP(j,50) reach[j] = false;
		pii edge = vp[i];
		bool ok = check(edge.first, edge.first, edge.second);
		if(ok == false) ans++;
	}
	// REP(j,50) reach[j] = false;
	// cout << check(0,0,2);
	//cout << check(3,3,5);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int n;cin>>n;
    vector<ll> avec(n+1);
    vector<ll> bvec(n);
    for(ll i=0;i<=n;i++) cin >> avec[i];
    rep(i,n) cin >> bvec[i];
    ll ans=0;
    rep(i,n){
        if (avec[i]>=bvec[i]){
            ans += bvec[i];
        }else{
            ans += avec[i];
            bvec[i] -=avec[i];
            if (bvec[i]<=avec[i+1]){
                ans += bvec[i];
                avec[i+1] -= bvec[i];
            }else{
                ans += avec[i+1];
                avec[i+1] = 0;
            }
        }
    }
    cout << ans << endl;
    
}

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

typedef long long ll;

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

    vector<ll> a(n+1);
    a[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

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

    int cnt = 0;
    for(int i = 1; i <= n; i++){
        ll body = a[i];
        int pos = i;
        bool ok = false;
        
        while(pos != n){
            body = sum[pos];
            auto next = upper_bound(a.begin(), a.end(), 2*body);
            int nextpos = --next - a.begin();
            if(pos == nextpos)  break;
            else                pos = nextpos;
        }

        if(pos == n)  cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  int n,u,adj[110][110],k,v[100],i,j;
  scanf("%d",&n);
  for(i=0;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v[j]);
      adj[u-1][v[j]-1]=1;
    }
  }

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


  return 0;

}

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

#define vd vector<double>
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#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 rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    int n;
    cin >> n;
    vl h(n);
    rep(i,n){
        cin >> h[i];
    }
    int max = 0;
    int count = 0;
    rep(i,n-1){
        if(h[i] >= h[i+1]){
            count++;
        }
        else{
            if(count > max){
                max = count;
            }
            count = 0;
        }
    }
    if(count > max){
        max = count;
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 1024
object Main extends App {
  val line = io.Source.stdin.getLines.toIndexedSeq.tail
  .map(_.split(' ').map(_.toInt).toArray)
  val T=line(0)(0)
  val A=line(0)(1)*1000
  //println(T,A)
  val H=line(1)
  val temps=H.map(h => T*1000 - h*6).toIndexedSeq
  //println(temps)
  
  var closest=Int.MaxValue
  var index=0
  var i=0
  temps.foreach{t =>
    val abs = Math.abs(t-A)
    if( abs < closest){
      closest = abs
      index = i
    }
    i+=1
  }
  println(index+1)
}
	

Measured memory_bytes: 27164
// Beginner160.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <bits/stdc++.h>
#include <iostream>

using  namespace std;
typedef long long ll;

int main()
{

	//A
	/*string s;
	cin >> s;
	cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << '\n';*/

	//B
	/*int x;
	cin >> x;

	int y500 = x / 500;
	x -= y500 * 500;
	int y5 = x / 5;

	ll resut = y500 * 1000 + y5 * 5;

	cout << resut  << '\n';*/


	//C
	/*int k, n;
	cin >> k >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];


	ll result = 0;
	int max_dist = -1;
	int max_dist_i = -1;
	for (int i =0; i < n-1; ++i)
	{
		int dist = a[i + 1] - a[i];
		if (dist > max_dist)
		{
			max_dist = dist;
			max_dist_i = i;
		}
	}

	int last_dist = k - a[n - 1] + a[0];
	if (last_dist > max_dist)
	{
		max_dist = last_dist;
		max_dist_i = n - 1;
	}

	for (int i = 0; i < n; ++i)
	{
		if (i == max_dist_i) continue;
		if (i == n - 1) result += last_dist;
		else result += a[i + 1] - a[i];
	}

	cout << result << '\n';*/

	//D
	/*int n, x, y;
	cin >> n >> x >> y;

	map<int, map<int, int>> distances;
	for (int i = 1; i <=n; ++i)
	{
		for (int j = 1; j <=n; ++j)
		{
			distances[i][j] = abs(i - j);
		}
	}

	distances[x][y] = 1;
	distances[y][x] = 1;

	int min_x_y = min(x, y);
	int max_x_y = max(x, y);
	
	for (int i = 1; i <=n; ++i)
	{
		for (int j = i+1; j<=n; ++j)
		{
			if (i==j) continue;
			if (i <= min_x_y && j <= min_x_y || i > max_x_y && j > max_x_y) continue;
			if (i <= min_x_y && j >= max_x_y) distances[i][j] = distances[i][min_x_y] + 1 + distances[max_x_y][j];
			else distances[i][j] = min(distances[i][j], distances[i][min_x_y] + 1 + distances[max_x_y][j]);
		}
	}

	
	vector<int> result(n +1);
	for (int i = 1; i <=n;++i)
	{
		for (int j = i + 1; j <=n;++j)
		{
			int res = distances[i][j];
			result[res]++;
		}
	}

	for (int k = 1; k < n; ++k)
	{
		cout << result[k] << '\n';
	}*/

		//E
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	
	vector<int> p(a);
	vector<int> q(b);
	vector<int> r(c);
	for (int i = 0; i < a; ++i)
	{
		cin >> p[i];
	}
	for (int i = 0; i < b; ++i)
	{
		cin >> q[i];
	}
	for (int i = 0; i < c; ++i)
	{
		cin >> r[i];
	}

	sort(p.begin(), p.end(), greater<int>());
	sort(q.begin(), q.end(), greater<int>());
	sort(r.begin(), r.end(), greater<int>());

	ll sum = 0;
	vector<int> apples;
	for (int i = 0; i < x; ++i)
	{
		apples.push_back(p[i]);
	}

	for (int i = 0; i < y; ++i)
	{
		apples.push_back(q[i]);
	}

	for (int i = 0; i < min(x + y, c); ++i)
	{
		apples.push_back(r[i]);
	}

	sort(apples.begin(), apples.end(), greater<int>());

	for (int i = 0 ;i < x + y; ++i)
	{
		sum += apples[i];
	}

	cout << sum;
	
}



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

using namespace std;

int64_t INF = 1'000'000'000'000'000;

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

    vector<int64_t> H(N);
    for(int i=0;i<N;i++)    cin >> H[i];

    sort(H.begin(), H.end());

    int64_t section = K-1;
    int64_t ans = INF;
    for(int i=0;i<N-section;i++){
        ans = min(ans, H[i+section] - H[i]);
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n;
    
    while (scanf("%d", &n) && n){
        bitset<128> p[128];
        bitset<128> q;
        
        for (int i = 0; i < n; i++){
            int m;
            scanf("%d", &m);
            p[i] = 0;
            for (int j = 0; j < m; j++){
                int x;
                scanf("%d", &x);
                p[i][x] = 1;
            }
        }
        int m;
        scanf("%d", &m);
        for (int j = 0; j < m; j++){
            int x;
            scanf("%d", &x);
            q[x] = 1;
        }
        
        int ret = -1;
        int cnt = 0;
        for (int i = 0; i < n; i++){
            if ((p[i] & q) == q){
                ret = i + 1;
                cnt++;
            }
        }
        
        printf("%d\n", cnt == 1 ? ret : -1);
    }
    
    return (0);
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, M, K, f;
	cin >> N >> M;
	int a[M] = {0};
	REP(i, 0, N){
		cin >> K;
		REP(j, 0, K){
			cin >> f;
			++a[f-1];
		}
	}
	int ans = 0;
	REP(i, 0, M) ans += (a[i] == N?1:0);
	cout << ans;

}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int s, e;
    cin >> s >> e;
    sum += e - s + 1;
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::string S, T;

  std::cin >> S >> T;

  int c = 0;

  for (int i = 0, size = S.size(); i < size; i ++)
    if (S[i] != T[i])
      c ++;

  std::cout << c << std::endl;

  return 0;
}


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

int main(){
    int64_t x,t=0,m=100;
    cin >>x;
    while(m<x){
        t++;
        int64_t c = m*0.01;
        m+=c;
        if(m>=x){
            cout << t << endl;
            return 0;
        }
    }
}


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

int main() {
  ll l, r;
  cin >> l >> r;
  r = min(r, l+4038);
  int ans = 2018;
  for (ll i = l; i <= r; ++i) {
    for (ll j = i+1; j <= r; ++j) {
      int x = i*j%2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

bool check(int a, int b) {
	return a > b;

}

int main() {
	int n;
	cin >> n;
	int cnt;
	int min = n;
	int tmp;
	rep(i, n + 1) {
		cnt = 0;
		tmp = i;
		while (tmp > 0) {
			cnt += tmp % 6;
			tmp /= 6;
		}
		tmp = n - i;
		while (tmp > 0) {
			cnt += tmp % 9;
			tmp /= 9;
		}
		if (min > cnt) {
			min = cnt;
		}
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){//popcount%2
	return __builtin_parity(x);
}



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

const ll INF=1e15;

const ll mod=1e9+7;


int main(){
    ll n;
    cin >> n;
    vector<vector<ll>> a(n,vector<ll>(n-1));
    rep(i,n)rep(j,n-1){
        cin >> a[i][j];
        a[i][j]--;
    }
    rep(i,n){
        reverse(a[i].begin(),a[i].end());
    }
    vector<pii> q;
    auto check=[&](ll i){
        if(a[i].size()==0){
            return ;
        }
        ll j=a[i].back();
        if(a[j].back()!=i){
            return ;
        }
        if(i>j) swap(i,j);
        pii P=make_pair(i,j);
        q.push_back(P);
    };
    rep(i,n){
        check(i);
    }
    ll day=0;
    while(q.size()){
        day++;
        sort(q.begin(),q.end());
        q.erase(unique(q.begin(),q.end()),q.end());
        vector<pii> preQ;
        swap(preQ,q);
        for(pii x:preQ){
            ll i=x.first;
            ll j=x.second;
            a[i].pop_back();
            a[j].pop_back();
        }
        for(pii x:preQ){
            ll i=x.first;
            ll j=x.second;
            check(i);
            check(j);
        }
    }
    rep(i,n){
        if(a[i].size()){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << day << endl;
    return 0;
}

Measured memory_bytes: 11128
#include <bits/stdc++.h>
using namespace std;
#define P pair<int, int>
#define hi cout<<"hi"<<endl;
#define INF 0x3f3f3f3f
#define LL long long
typedef long long ll;

const int maxn = 1005;

struct Edge {
    int v, next, cap, flow;
}e[maxn*maxn]; //注意边数
int head[maxn];
int cur[maxn], d[maxn];//当前弧下标 结点到汇点距离下界
int p[maxn], gap[maxn]; //可增广路上的一条弧 gap优化 比dinic多的两个数组
int tot;
void init()
{
    tot = 0;
    memset(head, -1, sizeof head);
}
void addedge(int u, int v, int w, int rw = 0)
{
    e[tot].v = v; e[tot].cap = w; e[tot].flow = 0;
    e[tot].next = head[u]; head[u] = tot++;
    e[tot].v = u; e[tot].cap = rw; e[tot].flow = 0;
    e[tot].next = head[v]; head[v] = tot++;
}

int sap(int s, int t, int N) //N 结点总数(包括源点汇点)
{
    memset(gap, 0, sizeof(gap));
    memset(d, 0, sizeof(d));
    memcpy(cur, head, sizeof(head));
    int u = s;
    p[u] = -1;
    gap[0] = N;
    int ans = 0;
    while (d[s] < N)
    {
        if (u == t)
        {
            int Min = INF;
            for (int i = p[u]; ~i; i = p[e[i^1].v])
                if (Min > e[i].cap - e[i].flow)
                    Min = e[i].cap - e[i].flow;
            for (int i = p[u]; ~i; i = p[e[i^1].v])
            {
                e[i].flow += Min;
                e[i^1].flow -= Min;
            }
            u = s;
            ans += Min;
            continue;
        }
        int v;
        bool ok = false;
        for (int i = cur[u]; ~i; i = e[i].next)
        {

            v = e[i].v;
            if (e[i].cap - e[i].flow && d[v] + 1 == d[u])
            {
                ok = true;
                cur[u] = p[v] = i;
                break;
            }
        }
        if (ok)
        {
            u = v;
            continue;
        }
        int Min = N;
        for (int i = head[u]; ~i; i = e[i].next)
        {

            if (e[i].cap - e[i].flow && d[e[i].v] < Min)
            {
                Min = d[e[i].v];
                cur[u] = i;
            }
        }
        gap[d[u]]--;
        if (!gap[d[u]]) return ans;
        d[u] = Min + 1;
        gap[d[u]]++;
        if (u != s) u = e[p[u]^1].v;
    }

    return ans;
}
int l[maxn], r[maxn];
int main()
{
    int n = 31, m;
    ios::sync_with_stdio(0);
    cin  >> m;

    init();
    int s = 0, t = m + n + 1;

    for (int i = 1; i <= m; i++)
    {
        cin >> l[i] >> r[i];
        //r[i] = l[i] + r[i] - 1;

    }
    for (int i = 1; i <= m; i++)
    {
        addedge(s, i, 1);
    }
    for (int i = 1; i <= m; i++)
    {
        for (int j = l[i]; j <= r[i]; j++)
        {
            addedge(i, j + m, 1);
        }
    }
    for (int i = m + 1; i <= m + n; i++)
    {
        addedge(i, t, 1);
    }
    int k = sap(s, t, t + 1);

    cout << 50 * 31 + k * 50 << endl;

    return 0;
}



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

int main()
{
	int n;
	cin >> n;
	int P[8], Q[8], moto[8];
	for (int i = 0; i < n; ++i)
	{
		moto[i] = i + 1;
		cin >> P[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin >> Q[i];
	}
	int count = 1, pc = 0, qc = 0;
	bool ok;
	do
	{
		ok = 1;
		for (int i = 0; i < n; ++i)
		{
			ok *= (P[i] == moto[i]);
		}
		pc = (ok?count:pc);
		ok = 1;
		for (int i = 0; i < n; ++i)
		{
			ok *= (Q[i] == moto[i]);
		}
		qc = (ok?count:qc);
		++count;
	} while (next_permutation(moto, moto + n));
	cout << abs(pc - qc) << endl;
	return 0;
}

Measured memory_bytes: 256
n, m, x, y = gets.split.map(&:to_i)
x_arr = gets.split.map(&:to_i)
y_arr = gets.split.map(&:to_i)
x_arr.concat([x])
y_arr.concat([y])
puts x_arr.max < y_arr.min ? 'No War
' : 'War'


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main()
{
	long long int n, k, x, y;
  	cin >> n >> k;
  	if (k % 2){
      	x = n / k;
    	cout << x * x * x;
    } else {
    	x = n / k;
      	y = (n + k / 2) / k;
      	cout << x * x * x + y * y * y; 
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<long double> f(n + 1);
  f[0] = 1;
  for(int i = 0; i < n; i++){
    long double p0; cin >> p0;
    for(int j = n - 1; j >= 0; j--){
      f[j + 1] += p0 * f[j];
      f[j] *= (1 - p0);
    }
  }
  long double pr = 0;
  for(int i = (n + 1)/2; i <= n; i++) pr += f[i];
  cout << fixed << setprecision(12) << pr << endl;
  return 0;
}
  


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <utility>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define pill pair<int, int>
#define ft first
#define sd second
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int qq = 1e5 + 10;
const int MOD = 1e9 + 7;
LL num[60];

int main(){
	LL k;	scanf("%lld", &k);
	int cnt = 0;
	LL tmp = k / 50;
	for(int i = 49; i >= 0; --i) {
		num[cnt] = i;
		num[cnt] += tmp;
		cnt++;
	}
	k = k % 50;
	for(int i = 0; i < 50 && k > 0; ++i, --k) {
		num[i]++;
	}
	printf("50\n");
	for(int i = 0; i < 49; ++i) {
		printf("%lld ", num[i]);
	}
	printf("%lld\n", num[49]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 1e18
#define common cout << "Case #" << w+1 << ": "  


int main()
{
    int x;
    cin >> x;
    if(x==0)
        cout << "1" << endl;
    else
        cout << "0" << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define dbg(x) cerr<<#x" = "<<x<<endl
#define rep(i,a,b) for(register int i=(a),i##_end=(b);i<=i##_end;++i)
#define per(i,a,b) for(register int i=(a),i##_st=(b);i>=i##_st;--i)
#define rpg(i,x) for(register int i=fir[x];i;i=e[i].nxt)
#define ull unsigned long long
#define fi first
#define se second
#define pb push_back
#define bin(i) (1<<i)
#define cla(x) memset(x,0,sizeof x)
#define meminf(x) memset(x,127,sizeof x)
typedef pair<int,int> pa;
typedef long long LL;
const int INF = 0x7fffffff;
const int oo = 0x3f3f3f3f;
inline char nc()
{
    static char buf[100000],*p1=buf,*p2=buf;
    if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
    return *p1++;
}
//#define  getchar() nc()
inline int rd()
{
    int x = 0 , f = 1; char CH = getchar();
    while(CH<'0'||CH>'9') {if(CH=='-')f=0;CH=getchar();}
    while(CH>='0'&&CH<='9') {x=(x<<3)+(x<<1)+(CH-48);CH=getchar();}
    return f ? x : -x;
}
int a;
inline bool work(int x) {
	int s[10],cnt=0,flag=0;
	while(x) {
		s[cnt++]=x%10;
		x/=10;
	}
	if(s[1]==s[2]&&s[2]==s[3]) return true;
	if(s[0]==s[1]&&s[1]==s[2]) return true;
	return false;
}
int main()
{
#ifdef	iloi
	freopen("test.txt","r",stdin);
#endif
	a=rd();
	if(work(a)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Map;
import java.util.Map.Entry;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;

class Main {
    
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<String, Integer> map = new HashMap<>();
        for(int i=0; i<n; i++){
            String str = scanner.next();
            if(map.containsKey(str)){
                map.put(str, map.get(str)+1);
            }else{
                map.put(str, 1);
            }
        }
        scanner.close();
        List<Entry<String, Integer>> list = new ArrayList<>(map.entrySet());
        Collections.sort(list, new Comparator<Entry<String, Integer>>() {
            public int compare(Entry<String, Integer> obj1, Entry<String, Integer> obj2){
                return obj1.getValue().compareTo(obj2.getValue());
            }
        });
        List<String> resultList = new ArrayList<>();
        // resultList.add(list.get(list.size()-1).getKey());
        for(int i=list.size()-1; i>=0; i--){
            if(list.get(i).getValue()==list.get(list.size()-1).getValue()){
                resultList.add(list.get(i).getKey());
            }
        }
        Collections.sort(resultList);
        for (String string : resultList) {
            System.out.println(string);
        }
    }

    
}

Measured memory_bytes: 82084