akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;



int32_t main(){
    FAST;

    int n;  cin >> n;
    int a[n];   for(int x=0;x<n;x++)    cin >> a[x];
    int len = 0 , ans = 0;

    for(int x=0;x<n-1;x++){
        if(a[x] >= a[x+1] ){
            len++;
        }else{
            len = 0;
        }
        ans = max(ans, len);
    }

    cout << ans;
    

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };


/******************************************************************************************/


//BinaryIndexTree(siz):長さsizで初期化
//sum(k):区間[0,k]の和を求める
//add(k,x):要素kにxを加える

template<typename T>
struct BinaryIndexTree {

	int n;
	vector<T> data;
	
	BinaryIndexTree(int siz)
	{
		n = siz;
		//1-indexなので配列は1つ多めに用意する
		data.resize(siz + 1, 0);
	}


	T sum(int k) {

		//[0,k)までの和を計算
		T ret = 0;
		while (k > 0) {
			ret += data[k - 1];
			k -= k & -k;
		}
		return ret;
	}

	//0-index
	void add(int k, int x)
	{
		//a_kにxを加算する
		while (k <= n) {
			data[k - 1] += x;
			k += k & -k;
		}
	}


	// bitに入ってる中でx番目に小さい数を求める
	// 1番小さい数はx = 1;
	// bitに3を入れる→add(3, 1), 3を出す→add(3, -1)
	// return == nの場合x個も入っていない
	ll min_xth(int x) {
		int left = -1, right = n;
		while (left + 1 < right) {
			int mid = (left + right) / 2;
			int temp = sum(mid + 1);
			if (temp < x) {
				left = mid;
			}
			else {
				right = mid;
			}
		}
		return right;
	}


	// pを順番通りにするための交換回数
	ll bubble(vector<T> p) {
		int n = p.size();
		ll ans = 0;
		for (int j = 0; j < n; j++) {
			ans += (j - sum(p[j] + 1));
			add(p[j], 1);
		}
		return ans;
	}


};


int main() {

	int n;
	cin >> n;
	vector<int> a;
	a.push_back(0);

	ll sum = 0;

	for (int i = 0; i < n; i++)
	{
		int c;
		cin >> c;
		a.push_back(c);
	}

	

	a.push_back(0);
	for (int i = 0; i <= n; i++)
	{
		sum += abs(a[(i + 1) % (n+2)] - a[i]);
	}

	for (int i = 1; i <= n; i++)
	{
		cout << sum - abs(a[(i + 1) % (n+2)] - a[i]) - abs(a[i] - a[(i + n+2 - 1) % (n+2)]) + abs(a[(i + 1) % (n+2)] - a[(i + n+2 - 1) % (n+2)]) << endl;
	}


	return 0;
}


Measured memory_bytes: 1784
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int b[110000], l[110000], u[110000];
bool flag[110000] = {};

int main(){
    long long int N, X;
    cin >> N >> X;
    vector<P> v;
    long long int S = 0;
    for(int i = 0; i < N; i++){
        cin >> b[i] >> l[i] >> u[i];
        v.push_back(P(u[i] * (X - b[i]) + l[i] * b[i], i));
        S += l[i] * b[i];
    }
    sort(v.begin(), v.end());
    long long int ans = 0;
    for(int i = v.size() - 1; i >= 0; i--){
        if(S - v[i].first <= 0){
            long long int MS = X;
            for(int j = 0; j < N; j++){
                if(flag[j] == false){
                    if(S - l[j] * b[j] <= 0){
                        MS = min(MS, S / l[j] + (S % l[j] != 0));
                    }else{
                        long long int rem = S - l[j] * b[j];
                        MS = min(MS, b[j] + rem / u[j] + (rem % u[j] != 0));
                    }
                }
            }
            long long int ans1 = ans + MS;
            //cout << MS << endl;
            
            S -= v[i].first;
            //cout << S << endl;
            MS = X;
            for(int j = 0; j < N; j++){
                if(flag[j] == true){
                    long long int rem = u[j] * (X - b[j]) + l[j] * b[j] + S;
                    //cout << rem << endl;
                    //cout << b[j] << " " << l[j] << " " << u[j] << endl;
                    if(rem - l[j] * b[j] <= 0){
                        MS = min(MS, rem / l[j] + (rem % l[j] != 0));
                    }else{
                        rem = rem - l[j] * b[j];
                        MS = min(MS, b[j] + rem / u[j] + (rem % u[j] != 0));
                    }
                }
            }
            //cout << MS << endl;

            long long int ans2 = ans + MS;
            ans = min(ans1, ans2);
            break;
        }else{
            S -= v[i].first;
            ans += X;
            flag[v[i].second] = true;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4336
#include <stdio.h>

int now[9];
/* 9!=362880 */
int list_num;
int all_list[362880][9];

void tansaku(int pos,int rest) {
	int i;
	if(pos>=9) {
		for(i=0;i<9;i++)all_list[list_num][i]=now[i];
		list_num++;
	} else {
		for(i=0;i<9;i++) {
			if(rest & (1<<i)) {
				now[pos]=i;
				tansaku(pos+1,rest & ~(1<<i));
			}
		}
	}
}

int main(void) {
	int d_num,d_cur;
	int g_cards[9];
	int j_cards[9];
	int i,j;
	int now_g,now_j;
	int g_win,j_win;
	tansaku(0,0xffff);
	scanf("%d",&d_num);
	for(d_cur=0;d_cur<d_num;d_cur++) {
		for(i=0;i<9;i++)scanf("%d",&g_cards[i]);
		for(i=0;i<9;i++)scanf("%d",&j_cards[i]);
		g_win=j_win=0;
		for(i=0;i<list_num;i++) {
			now_g=now_j=0;
			for(j=0;j<9;j++) {
				if(g_cards[j]>j_cards[all_list[i][j]]) {
					now_g+=g_cards[j]+j_cards[all_list[i][j]];
				} else {
					now_j+=g_cards[j]+j_cards[all_list[i][j]];
				}
			}
			if(now_g>now_j)g_win++;
			else if(now_j>now_g)j_win++;
		}
		printf("%.15f %.15f\n",
			(double)g_win/list_num,(double)j_win/list_num);
	}
	return 0;
}

Measured memory_bytes: 12000
import Control.Arrow ((&&&))
import Data.List

isDream, isDreamer, isErase, isEraser :: String -> Bool
[(isDream, lenDream),
 (isDreamer, lenDreamer),
 (isErase, lenErase),
 (isEraser, lenEraser)] = map (isPrefixOf . reverse &&& length) ["dream", "dreamer", "erase", "eraser"]

exist :: String -> Bool
exist sna
  | null sna = True
  | isDream sna = exist $ drop lenDream sna
  | isDreamer sna = exist $ drop lenDreamer sna
  | isErase sna = exist $ drop lenErase sna
  | isEraser sna = exist $ drop lenEraser sna
  | otherwise = False

main :: IO ()
main = do
  ans <- getLine
  putStrLn $ if exist (reverse ans) then "YES" else "NO"


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    bool flg=false;
    for(int j=0;j<i;j++){
      if(a.at(j)>a.at(i)){
        flg=true;
      }
      if(flg){
        break;
      }
    }
    if(!flg){
      ans++;
    }else{
      flg=false;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static class Tree {
		public class Edge {
			int to, rev;

			public Edge(int to, int rev) {
				this.to = to;
				this.rev = rev;
			}
		}
		
		int V;
		ArrayList<ArrayList<Edge>> G;
		int root;
		int[] p;
		int[] mod;
		
		public Tree(int[] a, int[] b) {
			this.V = a.length+1;
			p = new int[V];
			mod = new int[V];
			
			G = new ArrayList<ArrayList<Edge>>();
			for(int i=0; i<V; i++) {
				G.add(new ArrayList<Edge>());
			}
			
			for(int i=0; i<V-1; i++) {
				G.get(a[i]).add(new Edge(b[i], G.get(b[i]).size()));
				G.get(b[i]).add(new Edge(a[i], G.get(a[i]).size()-1));
			}
			setRoot(0);
		}
		
		public void setRoot(int root) {
			this.root = root;
			setRoot(root, -1);
		}
		public void setRoot(int cur, int parent) {
			p[cur] = parent;
			for(int i=0; i<G.get(cur).size(); i++) {
				int next = G.get(cur).get(i).to;
				if(next!=parent) {
					setRoot(next, cur);
				}
			}
		}
		
		public void setGroup() {
			setMod(root, 1);
		}
		void setMod(int cur, int value) {
			mod[cur] = value;
			for(int i=0; i<G.get(cur).size(); i++) {
				int next = G.get(cur).get(i).to;
				if(next!=p[cur]) {
					setMod(next, 3-value);
				}
			}
		}
		public int[] getMod() {
			return mod;
		}
		
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] a = new int[N-1];
		int[] b = new int[N-1];

		for(int i=0; i<N-1; i++) {
			a[i] = sc.nextInt()-1;
			b[i] = sc.nextInt()-1;
		}
		Tree tree = new Tree(a, b);
		
		tree.setGroup();
		int[] m = tree.getMod();
		int[] count = new int[3];
		for(int i=0; i<N; i++)
			count[m[i]]++;
		if(count[1]<count[2]) {
			for(int i=0; i<N; i++)
				m[i] = 3-m[i];
			int temp = count[1];
			count[1] = count[2];
			count[2] = temp;
		}
		
		if(count[2]<(N+1)/3) {
			count = new int[3];
			for(int i=0; i<N; i++) {
				int v = m[i];
				if(m[i]==2) {
					v = 0;
				} else {
					if(count[1]<(N+2)/3) {
						v = 1;
					} else if(count[2]<(N+1)/3) {
						v = 2;
					} else {
						v = 0;
					}
				}
				m[i] = count[v]*3+(v==0 ? 3 : v);
				count[v]++;
			}
		} else {
			count = new int[3];
			for(int i=0; i<N; i++) {
				int v = m[i];
				if(count[m[i]]==(N+(3-m[i]))/3) {
					v = 0;
				}
				m[i] = count[v]*3+(v==0 ? 3 : v);
				count[v]++;
			}
		}
		
		for(int i=0; i<N; i++)
			System.out.print(m[i] + (i==N-1 ? "\n" : " "));
		sc.close();
	}
}


Measured memory_bytes: 134904
#include<stdio.h>
int main(){
	 char a[10]="ABC";
	 
     scanf("%s",a);
     
	 if(a[1]== 'B'){
        	
	 	printf("ARC");
	 }	else{
	 	a[1]=='R';
	 	printf("ABC",a);
	 }
	
	return 0;
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i = s; i < t ; ++i)
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define UNIQ(a) a.erase(unique(ALL(a)),a.end())
#define debug(a) cerr<<#a":="<<a<<endl;
#define SZ(a) (int)a.size()
using LL = long long; template<class T> using V = vector <T>; template <class T> using VV = V<V<T>>;


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

	int N, M, K; cin >> N >> M >> K;
	V<int>a(N), b(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	FOR(i, 0, N) {
		cin >> b[i];
	}
	LL ans = 0;
	FOR(state, 0, 1 << N) {
		if (__builtin_popcount(state) > K)continue;
		LL ret = 0;
		V<int>ord;
		FOR(i, 0, N) {
			if (state & 1 << i)
				ord.push_back(i);
		}
		do {
			LL sub = 0;
			int MM = M;
			FOR(i, 0, SZ(ord)) {// M個植えれる
				LL sz = min(MM, b[ord[i]]);
				MM -= sz;
				sub += sz * a[ord[i]];
			}
			sub += MM;
			ret = max(ret, sub);
		} while (next_permutation(ALL(ord)));

		ans = max(ans, ret);
	}
	
	cout << ans << endl;

	return 0;
}


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

int N;
string str;
set<int> st;

int dp[500010];


int main(){

  while(cin>>N){
    for(int i=0;i<N+10;i++)  dp[i]=0;
    st.clear();
    
    cin>>str;
    str="0"+str+"0";
    N=str.size();
  
    dp[N]=0;

    for(int i=0;i<N;i++){
      if(str[i]=='0')
        st.insert(i);
    }
    set<int> :: iterator it;  
    for(int i=N-1;i>=0;i--){
      dp[i]=max(dp[i],dp[i+1]);
      if(str[i]=='0')continue;
    
      it=st.lower_bound(i);
      int target=*it;
      if(target+1<N && str[target+1]=='1'){
        //      cout<<i<<' '<<target<<endl;
        dp[i]=max(dp[i],dp[target+2]+(target-i));
      }


      if(i+2<N&&str[i]=='1'&&str[i+1]=='0'&&str[i+2]=='1'){
        dp[i]=max(dp[i],dp[i+3]+1);
        int target=*st.upper_bound(i+1);
        dp[i]= max(dp[i], (target-i-2) + dp[target] );
        
        if(target-i-3>=0){
          dp[i]= max(dp[i], (target-i-3) + dp[target-1] );
        }
      }

    }
    /*
      for(int i=0;i<N;i++)  cout<<dp[i]<<' ';
      cout<<endl;
      for(int i=0;i<N;i++)  cout<<str[i]<<' ';
      cout<<endl;
    */
    cout<<dp[0]<<endl;
  }
  return 0;
}


Measured memory_bytes: 26136
s_arr = gets.chomp.split("").map{|c| c == "R" ? 0 : 1} + [0]

r_flag = true
tmp = 0
tmp_i = -1
count_arr = []
s_arr.each_cons(2).with_index do |(s1, s2), i|
  if r_flag then
    tmp += 1
    if s1 + s2 == 0 then
      count_arr[i] = 0
    else
      count_arr[i+1] = tmp / 2 + 1
      count_arr[i] = tmp - (tmp / 2)
      tmp = 0
      r_flag = false
      tmp_i = i
    end
  else
    if s1 + s2 == 2 then
      tmp += 1
      count_arr[i+1] = 0
    else
      count_arr[tmp_i+1] += tmp / 2
      count_arr[tmp_i] += tmp - (tmp / 2)
      r_flag = true
      tmp = 0
    end
  end
end

puts count_arr.join(" ")


Measured memory_bytes: 13636
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())

using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
int modpow(int a,int n,int p){if (n==0)return 1%p; if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位


class unionfind{
public:
	vector<int> table;
	void init(int size){
		table.resize(size);
		rep(i,size)table[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(19);
	string s;
	in(s);
	int a=0;
	int ans=0;
	rep(i,s.size()){
		if(s[i]=='R')a++;
		else a=0;
		chmax(ans,a);
	}
	out(ans);
	return 0;
}


Measured memory_bytes: 3652
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        long a = sc.nextLong();
        BigDecimal ba = BigDecimal.valueOf(a);
        String b = sc.next();
        BigDecimal bb = new BigDecimal(b);


        System.out.println(ba.multiply(bb).longValue());
    }
}

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

template<class T>
struct SegmentTree {
	using F = function<T(T, T)>;
	const T init;
	const F f;
	int sz;
	vector<T> seg;
	SegmentTree(int n, const T init, const F f) :
		init(init),
		f(f)
		{
			sz = 1;
			while(sz < n) sz <<= 1;
			seg.resize(sz << 1, init);
		}
	void update(int id) {
		while(id >>= 1) {
			seg[id] = f(seg[2 * id], seg[2 * id + 1]);
		}
	}
	void replace(int id, T x){
		id += sz;
		seg[id] = x;
		update(id);
	}
	void add(int id, T x){
		id += sz;
		seg[id] += x;
		update(id);
	}
	// [l,r)
	T get(int l, int r){
		T L = init, R = init;
		for(l += sz, r += sz; l < r; l >>= 1, r>>= 1) {
			if(l & 1) L = f(L, seg[l++]);
			if(r & 1) R = f(seg[--r], R);
		}
		return f(L, R);
	}
	void debug(){
		int i = 1;
		for(int r = 2; r <= 2 * sz; r <<= 1) {
			while(i < r) {
				cout << seg[i++] << " ";
			}
			cout << "\n";
		}
	}
};

int main() {
    int n, q; cin >> n >> q;
    SegmentTree<int> seg(n, 0, [](int a, int b){return a + b;});
    while(q--) {
        int com, x, y; cin >> com >> x >> y;
        if(com == 0) seg.replace(x, seg.get(x, x + 1) + y);
        else cout << seg.get(x, y + 1) << "\n";
    }
    return 0;
}


Measured memory_bytes: 3880
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
AGC028 B
"""

import itertools
from functools import reduce

n = int(input())
ali = list(map(int, input().split()))

cut = 10**9+7


def modInverse(a, b, divmod=divmod):
    r0, r1, s0, s1 = a, b, 1, 0
    while r1 != 0:
        q, rtmp = divmod(r0, r1)
        stmp = s0-q*s1
        r0, s0 = r1, s1
        r1, s1 = rtmp, stmp
    return s0 % cut


invlist = [modInverse(i, cut) for i in range(1, n+1)]
accuminv = list(itertools.accumulate(invlist, func=lambda x, y: x+y % cut))

ans = 0
nfact = reduce(lambda x, y: x*y % cut, range(1,n+1))
for i in range(n):
    sump = accuminv[i]+accuminv[n-1-i] - 1
    ans += ali[i]*sump % cut

ans = ans*nfact % cut
print(ans)




Measured memory_bytes: 16400
/*
[abc142] F - Pure
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 1000;
const int MAX_M = 2000;
const int INF = 1e9;

int N, M;
int A[MAX_M], B[MAX_M];
int dist[MAX_N], from[MAX_N];
vector<int> g[MAX_N], rg[MAX_N];

void bfs(int s) {
    queue<int> q;

    fill(dist, dist + N, INF);
    dist[s] = 0;
    q.push(s);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int to : g[v]) {
            if (dist[to] > dist[v] + 1) {
                dist[to] = dist[v] + 1;
                from[to] = v;
                q.push(to);
            }
        }
    }
}

void solve() {
    for (int i = 0; i < M; i++) {
        g[A[i]].push_back(B[i]);
        rg[B[i]].push_back(A[i]);
    }

    int ans_len = INF;
    vector<int> ans;
    for (int u = 0; u < N; u++) {
        bfs(u);
        for (int v : rg[u]) {
            if (ans_len > dist[v] + 1) {
                ans.clear();
                int w = v;
                while (dist[w] > 0) {
                    ans.push_back(w);
                    w = from[w];
                }
                ans.push_back(u);
                reverse(ALL(ans));
                ans_len = ans.size();
            }
        }
    }

    if (ans_len >= INF) {
        cout << -1 << endl;
        return;
    }

    cout << ans.size() << endl;
    for (int v : ans) {
        cout << v + 1 << endl;
    }
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
    }

    solve();

    return 0;
}


Measured memory_bytes: 384
n = int(input())
num =[]
for i in range(3):
  num.append(int(n%10))
  n /= 10
if(num[0] == 1):
  num[0] = 9
elif(num[0] == 9):
  num[0] = 1
if(num[1] == 1):
  num[1] = 9
elif(num[1] == 9):
  num[1] = 1
if(num[2] == 1):
  num[2] = 9
elif(num[2] == 9):
  num[2] = 1
print(num[0]+num[1]*10+num[2]*100)

Measured memory_bytes: 3064
#include<stdio.h>

void trace(int N, int A[]){
	for(int i=0;i<N;i++){
		if (i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

void insertionSort(int N,int A[]){
	int i,v,j;
	for(i=1;i<N;i++){
		v=A[i];
		j=i-1;
		while (j>=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		trace(N,A);
	}
}

int main(){
	int N, i, A[100];
	scanf("%d",&N);
	for (i=0;i<N;i++) scanf("%d",&A[i]);
	
	trace(N,A);
	insertionSort(N,A);
	
	return 0;
}



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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    int n;
    cin >> n;
    list<int> b;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        b.push_back(a);
    }

    vector<int> ret;
    reverse(b.begin(), b.end());

    for(int icount = 0; icount < n; icount++){
        int count = n - icount;
        for(auto itr = b.begin(); itr != b.end(); itr++){
            if(count == *itr){
                ret.push_back(*itr);
                b.erase(itr);
                break;
            }
            count--;
        }
        if(count < 1){
            cout << "-1" << endl;
            return 0;
        }
    }
    reverse(ret.begin(), ret.end());
    for(int i = 0; i < n; i++){
        cout << ret[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <assert.h>
#include <string>
#include <set>
#include <map>
using namespace std;
#define LL long long

map < string , vector < int > > mp;
int s[105];
int n;
int ans[105];

bool cmp( int a, int b ){
	return s[a] < s[b];
}

int main(){

	cin >> n;
	for ( int i = 1; i <= n; i++ ){
		string st;
		int sc;
		cin >> st >> sc;
		s[i] = sc;
		mp[st].push_back(i);
	}

	int idx = 0;
	for ( auto it : mp ){
		vector < int > v = it.second;
		sort(v.begin(),v.end(),cmp);
		while ( !v.empty() ){
			idx++;
			ans[idx] = v.back();
			v.pop_back();
		}
	}
	for ( int i = 1; i <= n; i++ ) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;
use std::collections::*;

pub fn read_from<T: FromStr, R: Read>(s: &mut R) -> T {
    let s = s.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    if !s.is_empty() {
        if let Ok(s) = s.parse::<T>() {
            s
        } else {
            panic!("faild to parse {}", s);
        }
    } else {
        if cfg!(local) {
            // eprintln!("reached to EOF");
        }
        std::process::exit(0)
    }
}

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    loop {
        let h: usize = read_from(&mut stdin);
        let w: usize = read_from(&mut stdin);
        let g: Vec<Vec<i32>> = (0..h).map(|_| (0..w).map(|_| {
            read_from(&mut stdin)
        }).collect()).collect();

        let mut route = vec![];
        let mut ans = String::new();
        let mut cnt = 0;

        for i in 0..h {
            let js: Vec<_> = if i % 2 == 0 { (0..w).collect() } else { (0..w).rev().collect() };
            for j in js {
                if g[i][j] % 2 == 1 {
                    route.push((i, j));
                    if route.len() >= 2 {
                        for pair in route[..].windows(2) {
                            let (fi, fj) = pair[0];
                            let (ti, tj) = pair[1];
                            ans += format!("{} {} {} {}\n", fi+1, fj+1, ti+1, tj+1).as_str();
                            cnt += 1;
                        }
                        route.clear();
                    }
                } else {
                    if !route.is_empty() {
                        route.push((i, j));
                    }
                }
            }
        }

        println!("{}", cnt);
        print!("{}", ans);
    }
}


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

#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1)
#define MAXS 1e(18)
#define MOD 1000000007
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;



int main()
{

    _fastIO;

    ll n;

    while(cin>>n){
        if(n&1){
            cout<<"0"<<endl;
        }
        else{
            ll s=0;
            for(ll i=5; i<i+1; i*=5){
                if(i>1000000000000000000 || i>n)break;
                ll x = n/i;
                s += (x/2);
        }
            cout<<s<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 384
n_d_list = input().split()
n, d = int(n_d_list[0]), int(n_d_list[1])

count = 0
d_2 = d**2

for i in range(n):
  x_y = input().split()
  x = int(x_y[0])
  y = int(x_y[1])
  if x**2 + y**2 <= d_2:
    count += 1

print(count)

Measured memory_bytes: 9104
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;

void solve()
{   
    ll n;
    lscn(n);

    vl div(n+1, 0);

    for(ll i=1; i<=n; i++) {
        for(ll j=i; j<=n; j+=i) {
            div[j] ++;
        }
    }
    
    ll sum = 0;

    for(ll i=1; i<=n; i++)
        sum += i * div[i];
    
    lprin(sum);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 81396
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
const int inf=1<<30;
int main(){
  int N,W,v[110],w[110];
  int dp[110][10010];
  cin>>N>>W;
  for(int i=0;i<N;i++)cin>>v[i]>>w[i];
  for(int i=0;i<=W;i++)dp[0][i]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(j>=w[i])dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  cout<<dp[N][W]<<endl;
  return 0;
}



Measured memory_bytes: 7044
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n,m;
vector<int> g[100005];
int main(){
  cin>>n>>m;
  REP(i,m){
    int a,b;scanf("%d%d",&a,&b);--a;--b;
    g[a].pb(b);
    g[b].pb(a);
  }
  bool res=true;
  REP(i,n) if(g[i].size()&1) res=false;
  puts(res?"YES":"NO");
  return 0;
}





Measured memory_bytes: 5376
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    k = int(input())
    a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

    print(a[k-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
using namespace std;

int main(){  
  string S;
  cin >> S;
  
  int c = 0;
  FOR(i, 0, 4) {
    if(S[i]=='+') c++;
    else c--;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();

      int num = 1;
      for(int i = 0; i < n; i++) {
        num = Math.min(num * 2, num + k);
      }
      System.out.println(num);
  }
}



Measured memory_bytes: 22612
N,x=map(int,input().split())
l=list(map(int,input().split()))
c=0
if l[0]>x:
  c+=(l[0]-x)
  l[0]=x
for i in range(len(l)-1):
  if l[i]+l[i+1]>x:
    c+=(l[i+1]+l[i]-x)
    l[i+1]=x-l[i]
print(c)

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

typedef pair<int, int> P;

int to_d(int x, int y, int R, int C)
{
    if (y == 0)
        return x;
    else if (x == R)
        return y + R;
    else if (y == C)
        return (R - x) + R + C;
    else
        return (C - y) + R + C + R;
}

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

    int R, C, N;
    cin >> R >> C >> N;

    vector<P> d;

    int x1, y1, x2, y2;
    for (int i = 0; i < N; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        if ((x1 == 0 || x1 == R || y1 == 0 || y1 == C)
                && (x2 == 0 || x2 == R || y2 == 0 || y2 == C)) {
            d.push_back(P(to_d(x1, y1, R, C), i));
            d.push_back(P(to_d(x2, y2, R, C), i));
        }
    }

    sort(begin(d), end(d));

    stack<int> s;
    for (P di : d) {
        int i = di.second;
        if (s.empty() || s.top() != i)
            s.push(i);
        else
            s.pop();
    }

    if (s.empty())
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<string>s(N);
  for(int i=0;i<N;i++){
    cin>>s[i];
  }
  map<char,int64_t>k;
  for(int i=0;i<N;i++){
    k[s[i][0]]++;
  }
  string t="MARCH";
  int64_t ans=0;
  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      for(int r=j+1;r<5;r++){
        ans+=k[t[i]]*k[t[j]]*k[t[r]]; 
      }
    }
  }    
  cout<<ans<<endl;
  return 0;  
}

Measured memory_bytes: 6244
//$g++ main.cpp - compile
//$./a.out - run
#include <iostream>
#include <string>
using namespace std;

int main(){
    int n, x, t, cnt, k = 0, size = 1000;
    int ans[size];
    for(int i = 0; i < size; i++){
       ans[i] = 0; 
    }
    do{
        cin >> n >> x;
        cnt = 0;
        for(int i = n; i > 0; i--){
            t = x;
            if(t - i >= 3){
                t -= i;
                for(int j = i - 1; j > 0; j--){
                    if(t - j >= 1 && t - j < j){
                        cnt++;
                    }
                }
            }
        }
        ans[k++] = cnt;
    }while(n != 0 || x != 0);
    for(int i = 0; i < k - 1; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 1164
N = int(input())
A = list(map(int, input().split()))
x = 1

if 0 in A:
  print('0')
  exit()

for i, v in enumerate(A):
  if i >= N:
    break
  x *= A[i]
  if x>10**18:
    print('-1')
    exit()

print(x)

Measured memory_bytes: 21624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n;
    cin >> n;
    rep(i, n){
        if (n < 7 * i){
            break;
        }else if ((n - 7 * i) % 4 == 0) {
            Yes;
            return 0;
        }
    }
    No;
    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
int dh[]={1,-1,0,0};
int dw[]={0,0,1,-1};


int main(){
      int ab,bc,ca;
      cin>>ab>>bc>>ca;
      cout<<(ab*bc)/2<<endl;
      return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair <int, int> P;

class LowLink {
    const vector<vector<int>> edge;
    vector <bool> used;
    vector <int> ord; // DFS木で訪れた順
    vector <int> low; // 後退辺を1度だけ通って辿れるordの最小値

public:
    vector <int> articulation; // 関節点
    vector <P> bridge; // 橋

    LowLink(const vector<vector<int>> &edge) : edge(edge) {}

    int dfs(int cur, int k, int par) {
        used[cur] = true;
        ord[cur] = k++;
        low[cur] = ord[cur];
        bool is_articulation = false;
        int children = 0;
        for (int to : edge[cur]) {
            if (!used[to]) {
                children++;
                k = dfs(to, k, cur);
                low[cur] = min(low[cur], low[to]);
                if (par >= 0) is_articulation |= low[to] >= ord[cur];
                if (low[to] > ord[cur]) bridge.push_back({cur, to});
            } else if (to != par) {
                low[cur] = min(low[cur], ord[to]);
            }
        }
        if (par == -1) is_articulation |= children > 1;
        if (is_articulation) articulation.push_back(cur);
        return k;
    }

    void build() {
        used.assign(edge.size(), false);
        ord.assign(edge.size(), 0);
        low.assign(edge.size(), 0);
        for (int i = 0; i < edge.size(); i++) {
            if (!used[i]) dfs(i, 0, -1);
        }
    }
};


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_A&lang=jp
void AOJ_GRL_3_A() {
    int V, E;
    cin >> V >> E;

    vector<vector<int>> edge(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        edge[s].push_back(t);
        edge[t].push_back(s);
    }

    LowLink lowlink(edge);
    lowlink.build();

    sort(lowlink.articulation.begin(), lowlink.articulation.end());
    for (int i : lowlink.articulation) cout << i << '\n';
}


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_B&lang=jp
void AOJ_GRL_3_B() {
    int V, E;
    cin >> V >> E;

    vector<vector<int>> edge(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        edge[s].push_back(t);
        edge[t].push_back(s);
    }

    LowLink lowlink(edge);
    lowlink.build();

    vector <P> bridge = lowlink.bridge;
    for (P &p : bridge) {
        if (p.first > p.second) swap(p.first, p.second);
    }

    sort(bridge.begin(), bridge.end());
    for (P p : bridge) cout << p.first << " " << p.second << '\n';
}

int main() {
    AOJ_GRL_3_A();
    // AOJ_GRL_3_B();
    return 0;
}


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

int main(void) {
  vector<int> v;
  for(int i = 0; i < 1000; ++i) {
    if(i == 0) v.push_back(i);
    else v.push_back(v[i - 1] + i);
  }
  int a,b;
  cin >> a >> b;
  cout << v[b - a] - b << endl;
  return 0;
}

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

using namespace std;

int main()
{
  int n,k,a,d;
  cin>>n>>k;
  int nums [101];
  memset(nums,0,sizeof(nums));
  while(k--){
    cin>>d;
    while(d--){
        cin>>a;
        nums[a]++;
    }
  }
  int cnt = 0;
  for(int i=1;i<=n;i++){
    if(nums[i]==0){
        cnt++;
    }
  }
  cout<<cnt;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int Maxn=1e2+10,Maxk=1e5+10,MOD=1e9+7;
int N,K;
vector<int> S(Maxk);
int Dp[Maxn][Maxk];
signed main()
{
	cin>>N>>K;
	Dp[0][0]=1;
	for(int i=1;i<=N;i++)
	{
		int A;
		cin>>A;
		for(int j=0;j<=K;j++)
		{
			S[j+1]=(S[j]+Dp[i-1][j])%MOD;
		}
		for(int j=0;j<=K;j++)
		{
			Dp[i][j]=(S[j+1]-S[max(0LL,j-A)]+MOD)%MOD;
		}
	}
	cout<<Dp[N][K]<<endl;
	return 0;
}

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

void ok(){
	cout << "Yes" << endl;
	exit(0);
}

void ng(){
	cout <<  "No" << endl;
	exit(0);
}

int p[324000], n;

int main(){
	cin >> n;
	for(int i  = 0;i < n;i++){
		cin >> p[i];
		if(i % 2 == p[i] % 2)ng();
	}

	for(int k = 0;k < 100;k++){
		for(int i = n-3;i >= 0;i--){
			int a = p[i], b = p[i+1], c = p[i+2];
			if(a > b && b > c){
				swap(p[i], p[i+2]);
			}
		}
	}
		for(int i = 1;i < n-1;i++){
		int a = p[i-1], b = p[i], c = p[i+1];
		if((a > c) && (a < b || b < c))ng();
	}

	for(int i = 0;i+3 < n;i++){
		int a = p[i], b = p[i+1], c = p[i+2], d = p[i+3];
		if(a > b && b > c && c > d)ng();
	}
	ok();
}

Measured memory_bytes: 1408
#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 PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
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=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	set<int> cnt;
	rep(i,3){
		int a;
		cin>>a;
		cnt.insert(a);
	}
	cout<<cnt.size()<<endl;
}

Measured memory_bytes: 640
n = int(input())
edges = [[] for _ in range(n)]
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    a, b = ab[i]
    for j in range(n):
        c, d = cd[j]
        if a < c and b < d:
            edges[i].append(j)
matched = [-1] * n
def dfs(v):
    for u in edges[v]:
        if visited[u]:
            continue
        visited[u] = True
        if matched[u] == -1 or dfs(matched[u]):
            matched[u] = v
            return True
    return False

ans = 0
for s in range(n):
    visited = [False] * n
    if dfs(s):
        ans += 1
print(ans)

Measured memory_bytes: 74004
#include <iostream>
using namespace std;
 
int main()
{
  int a,b,c,x,cnt=0;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> x;
  
  for (int i=0; i<=a; i++){
    for (int j=0; j<=b; j++){
      for (int k=0; k<=c; k++){
        if (500*i+100*j+50*k==x){
          cnt += 1;
        }
      }
    }
  }
  cout<< cnt <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main()
{
    char str[20];

    while(scanf("%s",str)==1)
    {
        for(int i=0; i<12; i++)
        {
            printf("%c",str[i]);

            if(i==3)
                printf(" ");
        }

        printf("\n");
    }

    return (0);
}


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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    string str = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
    for (auto &ch: str)
        if (ch == ',')
            ch = ' ';
    stringstream ss(str);
    vector<int> A;
    int a;
    while (ss >> a) {
        A.push_back(a);
    }
    // cout << "A: " << A << endl;
    int n;
    cin >> n;
    cout << A[n-1] << endl;
    return 0;
}


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

typedef long long ll;

const ll N = 55, inf = 1e17;

ll cost[N], n;

string str[N];


bool is_pallindrome(string s) {
	string t = s;
	reverse(t.begin(), t.end());
	return t == s;
}


ll dp[52][21][2][2][10001];




ll go(ll idx, ll len, ll pref, ll suff, ll dep) {
	if (len <= 1) {
		return 0;
	}
	if (pref && is_pallindrome(str[idx].substr(0, len))) {
		return 0;
	}
	if (suff && is_pallindrome(str[idx].substr(str[idx].size() - len, len))) {
		return 0;
	}
	if (dep > 10000) {
		return inf;
	}
	ll &ret = dp[idx][len][pref][suff][dep];
	if (~ret) {
		return ret;
	}
	ret = inf;
	for (ll i = 1; i <= n; i++) {
		if (pref) {
			ll k = min(len, (ll)str[i].size());
			if (is_pallindrome(str[i].substr(0, k) + str[idx].substr(len - k, k))) {
				if (k < (int) str[i].size()) {
					ret = min(ret, cost[i] + go(i, str[i].size() - k, 0, 1, dep + 1));
				} else {
					ret = min(ret, cost[i] + go(idx, len - k, 1, 0, dep + 1));
				}
			}
		} else {
			ll k = min(len, (ll)str[i].size()), pos = str[idx].size() - len;
			if (is_pallindrome(str[idx].substr(pos, k) + str[i].substr(str[i].size() - k, k))) {
				if (k < (int) str[i].size()) {
					ret = min(ret, cost[i] + go(i, str[i].size() - k, 1, 0, dep + 1));
				} else {
					ret = min(ret, cost[i] + go(idx, len - k, 0, 1, dep + 1));
				}
			}
		}
	}
	return ret;
}

int32_t main() {
	/*
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
	//*/

	cin >> n;
	ll ans = inf;
	for (ll i = 1; i <= n; i++) {
		cin >> str[i] >> cost[i];
		if (is_pallindrome(str[i])) {
			ans = min(ans, cost[i]);
		}
	}
	memset(dp, -1, sizeof dp);
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= n; j++) {
			ll n = str[i].size(), m = str[j].size();
			if (n <= m) {
				if (is_pallindrome(str[i] + str[j].substr(m - n, n))) {
					ans = min(ans, cost[i] + cost[j] + go(j, m - n, 1, 0, 1));
				}
			} else {
				if (is_pallindrome(str[i].substr(0, m) + str[j])) {
					ans = min(ans, cost[i] + cost[j] + go(i, n - m, 0, 1, 1));
				}
			}
		}
	}
	if (ans >= inf) ans = -1;
	cout << ans << endl;
}

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

void release(string &str)
{
    string().swap(str);
}

int main()
{
    string s, t;
    cin >> s >> t;

    vector<vector<string>> st(s.size() + 1, vector<string>(t.size() + 1, ""));

    for (int i = 1; i <= s.size(); i++)
    {
        for (int j = 1; j <= t.size(); j++)
        {
            if (st[i - 1][j].size() > st[i][j - 1].size())
            {
                st[i][j] = st[i - 1][j];
            }
            else
            {
                st[i][j] = st[i][j - 1];
            }

            if (s[i - 1] == t[j - 1] && (st[i - 1][j - 1].size() + 1) > st[i][j].size())
            {
                st[i][j] = st[i - 1][j - 1] + s[i - 1];
            }
            release(st[i - 1][j - 1]);
        }
    }

    cout << st.back().back() << endl;
}


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

int main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  int ans = 0;
  if (B <= C || D <= A) ans = 0;
  else ans = min(B, D)- max(A, C);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572