akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

int X, A, B;

int main() {
  cin >> X >> A >> B;
  int ex = B - A;

  if (ex <= 0) {
    cout << "delicious";
  } else if (ex <= X) {
    cout << "safe";
  } else {
    cout << "dangerous";
  }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)


const ll INF = 10010001010;
const int inf = 1000034000;

typedef tuple<string, int, int> TUP;

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

int main()
{
    ll N;
    cin >> N;
    ll sum = 0;
    vector<ll> A(N);
    map<ll, ll> M;
    for (ll i = 0; i < N;i++)
    {
        cin >> A[i];
        sum += A[i];
        M[A[i]]++;
    }
    ll Q;
    cin >> Q;
    for (ll i = 0; i < Q;i++)
    {
        ll B, C;
        cin >> B >> C;
        sum -= M[B] * B;
        sum += M[B] * C;
        M[C] += M[B];
        M[B] = 0;
        cout << sum << endl;
    }
}


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

void solve(int m, vector<int>h){
  	vector<int>cost(m);
    cost[0] = 0;
    cost[1] = abs(h[0] - h[1]);
    for (int i=2; i<m; i++){
        cost[i] = min(
            (cost[i-1] + abs(h[i]-h[i-1])),
            (cost[i-2] + abs(h[i]-h[i-2]))
        );
    }
    cout << cost[m-1];
}

int main(){
  	int n; cin>>n;
  	vector<int>h(n); rep(i,n) cin>>h[i];
  	solve(n, h);
}

Measured memory_bytes: 4304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll po(ll k ,ll n,ll ans,ll temp,ll ans1){
    if(n==0)return ans;
    while(temp<=n){
        ans*=ans1;ans%=mod;ans1=ans1*ans1;ans1%=mod;n=n-temp;temp*=2;
    }
    return po(k,n,ans,1,k)%mod;
    //eg. po(2,78,1,1,2);
}
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //cin>>t;
    t=1;
    while(t--){
        
        dd d;
        cin>>d;
        cout.precision(20);
        cout<<(d/(dd)3)*(d/(dd)3)*(d/(dd)3);
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
 
using namespace std;
 
#define LL long long
const int N = 1e5 + 100;
 
int n,a[N],maxx,ans;
 
int main() {
    scanf("%d",&n);
    for(int i = 1 ; i <= n ; i++) 
        scanf("%d",&a[i]);
    for(int i = 2 ; i <= n ; i++) {
        if(a[i] <= a[i - 1]) {
            maxx ++;
            ans = max(maxx,ans);
        } else maxx = 0;
    }
    printf("%d",ans);
    //system("pause");
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cmath>
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int N;
  cin>>N;
  if(N>=65&&N<=90)
    cout<<"1"<<endl;
  else if(N>=97&&N<=122)
    cout<<"2"<<endl;
  else
    cout<<"0"<<endl;
  return 0;
}



Measured memory_bytes: 3108
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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[] a = new int[n];
            for (int i = 0; i < n; ++i) a[i] = in.nextInt();
            Arrays.sort(a);
            if (n % 3 != 0) {
                if (a[0] == 0 && a[n - 1] == 0) {
                    out.println("Yes");
                } else {
                    out.println("No");
                }
            } else {
                int p = n / 3;
                if (a[0] == a[p - 1] && a[p] == a[2 * p - 1] && a[2 * p] == a[3 * p - 1] && (a[0] ^ a[p] ^ a[2 * p]) == 0) {
                    out.println("Yes");
                } else {
                    out.println("No");
                }
            }
        }

    }

    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: 36056
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main(){
    string s;
    cin >> s;
    int sa = 999;
    for(int i = 0; i < (int)s.size()-2; i++){
        if(abs(753 - stoi(s.substr(i,3))) < sa){
            sa = abs(753 - stoi(s.substr(i,3)));
        }
    }
    cout << sa << endl;
}

Measured memory_bytes: 256
#include<bitset>
#include<cctype>
#include<cstdio>
const int N=100007,M=407;
int a[N],b[N],d[N];std::bitset<M>f[M];
int read(){int x=0,c=getchar();while(isspace(c))c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return x;}
int main()
{
    int n=read(),m=read(),ans=0;
    for(int i=1;i<=m;++i) a[i]=read(),b[i]=read();
    for(int i=1,j;i<=n;++i)
	for(f[i][i]=1,j=m;j;--j)
	{
	    if(f[i][a[j]]&&f[i][b[j]]) {d[i]=1;break;}
	    if(f[i][a[j]]&&!f[i][b[j]]) f[i][b[j]]=1;
	    else if(!f[i][a[j]]&&f[i][b[j]]) f[i][a[j]]=1;
	}
    for(int i=1;i<=n;++i) for(int j=i+1;j<=n;++j) if(!d[i]&&!d[j]&&(f[i]&f[j]).none()) ++ans;
    printf("%d",ans);
}


Measured memory_bytes: 1024
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H;
    cin >> H;
    ll h = H;
    ll ans = 0;
    ll mul = 1;
    while(h > 0){
        ans += mul;
        h /= 2;
        mul *= 2;
    }
    print(ans);

}

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

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

    vector<vector<int>> M(N, vector<int>(N, 0));

    int u, k, v;
    for (int i = 0; i < N; i++)
    {
        cin >> u >> k;
        u--; // 0オリジンへ変更
        for (int j = 0; j < k; j++)
        {
            cin >> v;
            v--; // 0オリジンへ変更
            M[u][v] = 1;
        }
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (j)
                cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3160
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;

typedef ll Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

pair<Weight, Edges> Kruskal(const Graph &g) {
	int n = g.size();
	UnionFind uf(n);
	priority_queue<Edge> Q;
	for (int u = 0; u < n; u++)
		for (__typeof(g[u].begin()) e = g[u].begin(); e != g[u].end(); e++)
			if (u < e->dst)
				Q.push(*e);

	Weight total = 0;
	Edges F;
	while (F.size() < n - 1 && !Q.empty()) {
		Edge e = Q.top();
		Q.pop();
		if (uf.unionSet(e.src, e.dst)) {
			F.push_back(e);
			total += e.weight;
		}
	}
	return pair<Weight, Edges>(total, F);
}

ll WarshallFloyd(const Matrix &g,Matrix &dist) {
    int n = (int)g.size();
    ll ret=0;
    dist = g;
    vector<vector<bool> >isused(n,vector<bool>(n,false));
    repeat(k, n) repeat(i, n) repeat(j, n) {
      if(k==i || k==j) continue;
        if(dist[i][k] == INF || dist[k][j] == INF) continue;
        if(!isused[i][j] && dist[i][j] == dist[i][k] + dist[k][j]){
          ret-=dist[i][j];
          isused[i][j] = true;
          isused[j][i] = true;
        }
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
          return -1;
        }
    }
    repeat(i,n){
      for(int j=i+1;j<n;j++){
        ret += dist[i][j];
      }
    }
    return ret;
}

int main() {
  int N;cin >> N;
  Matrix A(N,Array(N));
  Graph g(N);
  repeat(i,N){
    repeat(j,N){
      cin >> A[i][j];
      g[i].push_back({(int)i,(int)j,A[i][j]});
    }
  }

  Matrix dist;
  ll ans = WarshallFloyd(A,dist);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4096
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in(), k = in();
    string s; cin >> s;
    REP(i, n) {
        if (i + 1 == k) {
            cout << (char)(s[i] - 'A' + 'a');
        } else {
            cout << s[i];
        }
    }
    cout << endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

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

	int N, K;
	cin >> N >> K;
	vector<int> DP(K + 1, 0);

	int ans = 0;
	rrep(i, 1, K + 1)
	{
		DP[i] = modpow(K / i, N, MOD);
		int ti = i * 2;
		while (ti <= K)
		{
			DP[i] = (DP[i] - DP[ti] + MOD) % MOD;
			ti += i;
		}
		ans += DP[i] * i;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    if(n == 1) OUT("Hello World");
    else {
        int a,b; cin >> a >> b;
        OUT(a+b);
    }

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <set>

using namespace std;

int main()
{
    set<pair<int,int>> S;

    for (int i=0; i<2; i++)
    {
        int N;
        scanf("%d", &N);
        for (int j=0; j<N; j++)
        {
            int h, m;
            scanf("%d%d", &h, &m);
            S.insert(make_pair(h, m));
        }
    }

    const char *sep = "";
    for (auto s: S)
    {
        printf("%s%d:%02d", sep, s.first, s.second);
        sep = " ";
    }
    printf("\n");
}

Measured memory_bytes: 2720
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int D = sc.nextInt();
    int x = sc.nextInt();
    for(int i = 0;i < 10;i++){
      x = r*x-D;
      System.out.println(x);
    }
  }
}

Measured memory_bytes: 20180
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template <typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template <typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}



int main()
{
    int N;
    cin >> N;
    vi A(N);
    in(N,A);
    
    map<int,ll> B,C,D;
    rep(i,N) B[A[i]]++;
    
    
    ll ans = 0;
    
    for (auto p : B) {
        C[p.fi] = p.se*(p.se-1)/2;
        ans += C[p.fi];
        D[p.fi] = (p.se-1)*(p.se-2)/2;
    }
    
    rep(i,N){
        ll an = ans;
        an -= C[A[i]];
        an += D[A[i]];
        cout << an << endl;
    }

    
    
    
    

    return 0;
}


Measured memory_bytes: 28032
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace std;
#define int long long
#define double long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> new_data_set;
bool isprime(int n)
	{
    	if(n==1) return true;
    	for(int i = 2;i*i<=n;i++){
    		if(n%i==0) return false;
		}
		return true;
	}
int lcm(int a,int b){
	return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
    return 1; 
    return n * factorial(n - 1); 
} 
const int inf=1e17+7;
//const int N=2e5+5;
int dp[100001]={0};
vector<int> graph[100005];
string tranform(string s){
	for(int i=0;i<s.length();i++) {  
    if(s[i]>=65 && s[i]<=92){
		s[i]=s[i]+32;
    }
}
return s;
}
bool visited[100005]={false};
void dfs(int r){
	if(visited[r]){
		return;
	}
	else{
		visited[r]=true;
		for(int i=0;i<graph[r].size();i++){
			if(!visited[graph[r][i]]){
				dfs(graph[r][i]);
			}
			dp[r]=max(dp[r],1+dp[graph[r][i]]);
		}
	}
}
signed main(){
	FAST
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		graph[x].push_back(y);
	}
	for(int i=1;i<=n;i++){
		if(!visited[i]){
			//visited[i]=true;
			dfs(i);
		}
	}
	sort(dp,dp+100001);
	cout<<dp[100000];
	//cout<<ans;
}

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

using namespace std;

int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int count=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(i*500+j*100+k*50==x) count++;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import dijkstra
import numpy as np
n=int(input())
graph=np.zeros((2*n+2,2*n+2),dtype=np.int64)
start,goal=0,2*n+1
l=[[int(j)for j in input().split()]for i in range(n)]
for i in range(1,1+n):
    c,d=map(int,input().split())
    for j,(a,b) in enumerate(l,n+1):
        if a<c and b<d:
            graph[start,i]=1
            graph[i,j]=1
            graph[j,goal]=1
def max_flow(graph):
    flow=0
    while True:
        dist,pred=dijkstra(graph,indices=start,return_predecessors=True,unweighted=True)
        if dist[goal]==np.inf:
            return flow
        path=[]
        v=goal
        while True:
            path.append((pred[v],v))
            v=pred[v]
            if v==start:
                break
        add_flow=min(graph[x][y] for x,y in path)
        for x,y in path:
            graph[x][y]-=add_flow
            graph[y][x]+=add_flow
        flow+=add_flow
print(max_flow(graph))

Measured memory_bytes: 17436
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 100;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    

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



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

typedef long long ll;

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

    ll a,b,k;
    cin >> a >> b >> k;
    if(a-k>=0) cout << a-k << " " << b << endl;
    else if(b-(k-a)>0) cout << 0 << " " << b-(k-a) << endl;
    else cout << 0 << " " << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
var
  s1,s2:string;
  a,b:array['a'..'z']of longint;
  c:array[1..26]of boolean;
  f:boolean;
  i,j,k,p:longint;
begin
  readln(s1);
  read(s2);
  k:=length(s2);
  f:=true;
  if length(s1)<length(s2) then begin k:=length(s1); f:=false; end;
  for i:=1 to k-1 do
  begin
    inc(a[s1[i]]);
	inc(b[s2[i]]);
  end;
  if f then inc(b[s2[k]])
  else inc(a[s1[k]]);
  if f then p:=length(s1)
  else p:=length(s2);
  for i:=k to p do
  begin
  begin
     if f then inc(a[s1[i]])
	 else inc(b[s2[i]]);
  end;
  end;
  f:=true;
  for i:=1 to 26 do
  begin
     p:=a[chr(i+ord('a')-1)];
	 for j:=1 to 26 do
	 begin
	    if (c[j]=false)and(b[chr(j+ord('a')-1)]=p) then 
		begin
		   c[j]:=true;
		   break;
		end;
		if j=26 then f:=false;
     end;
	 if f=false then begin writeln('No'); halt; end;
  end;
  writeln('Yes');
end.


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int H, W;
	cin >> H >> W;

	vector<string> S(H);
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	int count;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '.') {
				count = 0;
				for (int k = 0; k <= 2; k++) {
					for (int l = 0; l <= 2; l++) {
						if (i - 1 + k >= 0 && i - 1 + k < H && j - 1 + l >= 0 && j - 1 + l < W) {
							if (!(k == 1 && l == 1) && S[i - 1 + k][j - 1 + l] == '#') {
								count++;
							}
						}

					}
				}
				S[i][j] = char(count + 48);
			}
			cout << S[i][j];
			if (j == W - 1) {
				cout << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
def Cal(A, B, op):
    if op == "+":
        return A + B
    else:
        return A - B

Num = input()
OP = ["---", "--+", "-+-", "-++", "+--", "+-+", "++-", "+++"]

for o in OP:
    Sum = Cal(int(Num[0]), int(Num[1]), o[0])
    Sum = Cal(Sum, int(Num[2]), o[1])
    Sum = Cal(Sum, int(Num[3]), o[2])
    if Sum == 7:
        print(Num[0]+o[0]+Num[1]+o[1]+Num[2]+o[2]+Num[3]+"=7")
        break

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
using namespace std;

int main(void) {
	int N, T;
	scanf("%d %d", &N, &T);
	int c[105], t[105];
	int min = 1001;
	bool flag = false;

	for (int i = 0; i < N; i++) {
		scanf("%d %d", &c[i], &t[i]);
		if (t[i] <= T && c[i] < min) {
			flag = true;
			min = c[i];
		}
	}
	if (flag) {
		printf("%d", min);
	} else {
		printf("TLE");
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b;
  c= (a * b) % 2;
  if ( c == 1 ) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" <<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int N, A, ans = 1, b = 1;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++)ans *= 3;
	for (int i = 1; i <= N; i++) {
		cin >> A;
		if (A % 2 == 0) {
			b *= 2;
		}
	}
	ans -= b;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int dp[3005][3005];
int N,S,T,A[3005],B[3005];

int dfs(int n, int t){
  if(n==N) return 0;
  int &res = dp[n][t];
  if(res >= 0) return res;
  int nt;
  if(t < S && S < t + B[n]) nt = S+B[n];
  else nt = t+B[n];

  if(nt <= T) res = max(res, dfs(n+1, nt)+A[n]);
  res = max(res, dfs(n+1, t));
  return res;
}

int main(){
  scanf("%d%d%d",&N,&T,&S);
  for(int i=0;i<N;i++) scanf("%d%d", &A[i], &B[i]);
  memset(dp, -1, sizeof dp);
  printf("%d\n", dfs(0, 0));
  return 0;
}

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

using namespace std;

int main() {
  int s, s1, s2, s3;
  cin >> s;

  s1 = ceil(s / 100);
  s2 = ceil((s - s1 * 100) / 10);
  s3 = ceil((s - s1 * 100 - s2 * 10));

  int answer = s1 + s2 + s3;

  cout << answer << endl;
}

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

string s;
string t;
bool ans = false;

void do_input(void){
    cin >> s;
    cin >> t;
}

void solve(void){
    for (unsigned int i = 0; i < s.size(); i++){
        s = s.back() + s.substr(0, s.size() -1);
        if(s == t) {
            ans = true;
            break;
        }
    }

    if(ans == true) cout << "Yes" << endl;
    else cout << "No" << endl;
}


int main(void){
    do_input();

    solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        char c = fs.next().charAt(0);
        System.out.println(Character.isUpperCase(c) ? 'A' : 'a');
    }

    static class FastScanner {
        BufferedReader br = null;
        StringTokenizer st;
    
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
    
        String next() {
            while(st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    
        double nextDouble() {
            return Double.parseDouble(next());
        }
    
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 32704
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int N = 4e5+10;
int a[N],b[N];
int n,k;
int main(){
    cin >> n >> k;
    for(int i=1;i<=n;++i){
        cin >> a[i];
        a[i]++;
        b[i] = a[i]%2;
        a[i]/=2;
    }
    pii csum,msum;
    for(int i=1;i<=k;++i){
        csum.first += a[i];
        csum.second += b[i];
        csum.first += csum.second/2;
        csum.second%=2;
    }
    msum = csum;
    for(int i=k+1;i<=n;++i){
        csum.first -= (a[i-k]);
        csum.second -= b[i-k];
        csum.first += a[i];
        csum.second += b[i];
        if(csum.second<0){
            csum.second +=2;
            csum.first--;
        }
        csum.first += csum.second/2;
        csum.second%=2;
        msum = max(csum,msum);
    }
    cout << msum.first;
    if(msum.second){
        cout << ".5";
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

vector<ll> tate; vector<ll> yoko;

void f(vector<vector<string>> chess, ll count){
    
    if(count == 8){
        bool flag = true;
        rep(i, tate.size()){
            if(chess[tate[i]][yoko[i]] != "Q") flag = false;
        }

        if(flag){
            rep(i, 8){
                rep(j, 8){
                    cout << chess[i][j];
                }
                br;
            }
        }
    }else{
        rep(j, 8){
            //縦
            bool tate_flag = true;
            for(ll k = count-1; k >= 0; k--){
                if(chess[k][j] == "Q") tate_flag = false;
            }  

            bool naname_flag = true;
            for(ll k = count, l = j; k >= 0 && l >= 0; k--, l--){
                if(chess[k][l] == "Q") naname_flag = false;
            }
            for(ll k = count, l = j; k >= 0 && l < 8; k--, l++){
                if(chess[k][l] == "Q") naname_flag = false;
            }
            for(ll k = count, l = j; k < 8 && l >= 0; k++, l--){
                if(chess[k][l] == "Q") naname_flag = false;
            }
            for(ll k = count, l = j; k < 0 && l < 0; k++, l++){
                if(chess[k][l] == "Q") naname_flag = false;
            }

            if(tate_flag && naname_flag){
                chess[count][j] = "Q";
                f(chess, count+1);
                chess[count][j] = ".";
            }
        }
    }
    
}


int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll k; cin >> k;
    
    rep(i, k){
        ll a, b;
        cin >> a >> b;
        tate.push_back(a); yoko.push_back(b);
    }

    vector<vector<string>> chess(8, vector<string>(8));
    rep(i, 8)rep(j, 8){
        chess[i][j] = ".";
    }

    rep(i, 8){
        chess[0][i] = "Q";
        f(chess, 1);
        chess[0][i] = ".";
    }

}


Measured memory_bytes: 3220
//coded b vishal mourya - the legendary coder
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define f(a,b) for(ll i = a ; i < b ; i++ )
#define fj(a,b) for(ll j = a ; j < b ; j++ )
#define fk(a,b) for(ll k = a ; k < b ; k++ )
#define fasthoja ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(void){
    fasthoja;
    ll n; cin >> n;
    string s; cin >> s;
    
    ll cnt = 0;
    ll limit = s.length();
    
    f( 0, limit) {
        if( s[i] == 'A' && ( i+1 < limit -1  ) && (i+2 <= limit - 1) ) {
            if( s[i+1] == 'B' && s[i+2] == 'C' )
                cnt++;
        }
    }
    
    cout << cnt << "\n";
 return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main() {
    map<string, int> dict;

    int n,ans=0; cin >> n; 
    for (string x; n--; dict[x]++) { 
        ans++;
        cin >> x; 
        if (dict[x]>=1)
        {
            ans--;
        }}
        
        cout<<ans<<endl;
        return 0;
}

Measured memory_bytes: 19176
#include <bits/stdc++.h>
    #define int long long
    #define endl '\n'
    ///Yeah, I am the backupguy!
    using namespace std;
    vector<int>master;
    void buildup(int n){
    if(n>4234566667)
    return;
    if(!n){
    for(int i=1;i<=9;i++){
    master.push_back(n+i);
    buildup(n+i);
    }
    }
    else{
    for(int i=max(n%10-1,(int)0);i<=min(n%10+1,(int)9);i++){
    master.push_back(n*10+i);
    buildup(n*10+i);
    }
    }
    }
    int32_t main()
    {
    iostream::sync_with_stdio(0);
    cin.tie(0);
    buildup(0);
    int n;
    cin>>n;
    sort(master.begin(),master.end());
    cout<<master[n-1];
    return 0;
}


Measured memory_bytes: 6384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	public static void main(String args[]) throws IOException{
		Scanner sc = new Scanner(System.in);
		
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//StringTokenizer st = new StringTokenizer(br.readLine());
		
		//StringBuilder sb = new StringBuilder();
		
		int n = sc.nextInt();
		
		int arr[] = new int[5];
		
		for(int i=0;i<n;i++){
			char c = sc.next().charAt(0);
			switch(c){
			case 'M':
				arr[0]++;
				break;
			case 'A':
				arr[1]++;
				break;
			case 'R':
				arr[2]++;
				break;
			case 'C':
				arr[3]++;
				break;
			case 'H':
				arr[4]++;
				break;
			}
		}
		
		long ans = 0;
		for(int i=0;i<5;i++){
			for(int j=i+1;j<5;j++){
				for(int k=j+1;k<5;k++){
					ans += (long)arr[i]*arr[j]*arr[k];
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 44236
let inf = 10101010101010

let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let ed = Array.init m (fun _ -> Scanf.scanf " %d %d %d" (fun a b c -> a-1,b-1,c)) in
  let g = Array.init n (fun _ -> Array.make n inf) in
  for i = 0 to n-1 do g.(i).(i) <- 0 done;
  ed |> Array.iter (fun (u, v, c) -> g.(u).(v) <- c; g.(v).(u) <- c; );

  for k = 0 to n-1 do
    for i = 0 to n-1 do
      for j = 0 to n-1 do
        g.(i).(j) <- min g.(i).(j) (g.(i).(k) + g.(k).(j))
  done done done;

  ed |> Array.fold_left (fun a (u,v,c) ->
    if g.(u).(v) < c then a+1 else a) 0
  |> Printf.printf "%d\n"

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int sign(int x) {
    return x < 0 ? -1 : x == 0 ? 0 : 1;
}

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

    int k, x, y;
    cin >> k >> x >> y;

    int d = abs(x) + abs(y);

    if (k % 2 == 0 && d % 2 != 0) {
        cout << -1 << endl;
        exit(0);
    }

    if (d == k) {
        cout << 1 << endl;
        cout << x << ' ' << y << endl;
        exit(0);
    }

    int s = d < k ? 2 : (d + k - 1) / k;
    if (k % 2 != 0 && (d % 2 == 0 ^ s % 2 == 0)) s++;

    cout << s << '\n';

    int a = 0, b = 0;
    for (int i = 0; i < s - 2; i++) {
        if (abs(x - a) > abs(y - b)) {
            a += k * sign(x - a);
        } else {
            b += k * sign(y - b);
        }
        cout << a << ' ' << b << '\n';
    }

    if (abs(x - a) > abs(y - b)) {
        int t = (abs(a - x) - (b - y)) / 2;
        a = x + t * sign(a - x);
        b = y + k - t;
    } else {
        int t = (abs(b - y) - (a - x)) / 2;
        b = y + t * sign(b - y);
        a = x + k - t;
    }

    cout << a << ' ' << b << '\n';

    cout << x << ' ' << y << '\n';

    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
map<int,int>mp;
int solve(int n)
{
	if(mp[n]==0){
	if(n==1){
		return mp[n]=1;
	}
	else{
		return mp[n]=(solve(n/2)+solve(n/2)+1);
	}
	}
	else{
		return mp[n];
	}
}
int32_t main()
{
	int n;
	cin >> n;
	cout<<solve(n);
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MAX_DIST 1LL<<50
#define NMAX 1003
#define MMAX 2003

ll dist[NMAX] = {0,};
bool negative[NMAX] = {false,};
ll a[MMAX];
ll b[MMAX];
ll c[MMAX];

void bellmanford(int start, int v, int e){
    for(int i = 0; i < NMAX; i++){
        dist[i] = MAX_DIST;
    }
    dist[start] = 0;

    for(int i = 0; i < v-1; i++){
        for(int j = 0; j < e; j++){
            if(dist[a[j]] == MAX_DIST){continue;}
            if(dist[b[j]] > dist[a[j]] + c[j]){
                dist[b[j]] = dist[a[j]] + c[j];
            }
        }
    }
    for(int i = 0; i < v; i++){
        for(int j = 0; j < e; j++){
            if(dist[a[j]] == MAX_DIST){continue;}
            if(dist[b[j]] > dist[a[j]] + c[j]){
                dist[b[j]] = dist[a[j]] + c[j];
                negative[b[j]] = true;
            }
            if(negative[a[j]]){
                negative[b[j]] = true;
            }
        }
    }
}

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

    for(int i = 0; i < m; i++){
        int at, bt ,ct;
        cin >> at >> bt >> ct;
        at--; bt--; ct = -ct;
        a[i] = at; b[i] = bt; c[i] = ct;
    }

    bellmanford(0, n, m);
    ll ans = -dist[n-1];
    if(negative[n-1]){cout << "inf" << endl;}
    else{cout << ans << endl;}

    return 0;
}


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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
#define ALL(a) (a).begin(),(a).end()
  
typedef pair<int,int> P;
typedef vector<int> vi;

int A,B,Q,INF=1e16;

signed main() {
    vi s,t,x;
    cin>>A>>B>>Q;
    s.pb(-INF); t.pb(-INF);
    rep(i,0,A) {
        int S; cin>>S;
        s.pb(S);
    }
    rep(i,0,B) {
        int T; cin>>T;
        t.pb(T);
    }
    rep(i,0,Q) {
        int X; cin>>X;
        x.pb(X);
    }

    s.pb(INF); t.pb(INF);

    rep(i,0,Q) {
        auto itr1=lower_bound(ALL(s),x[i]);
        auto itr2=lower_bound(ALL(t),x[i]);

        int d1=x[i]-s[itr1-s.begin()-1];
        int d2=s[itr1-s.begin()]-x[i];
        int d3=x[i]-t[itr2-t.begin()-1];
        int d4=t[itr2-t.begin()]-x[i];

        int ans1=max(d1,d3);
        int ans2=max(d2,d4);
        int ans3=min(2*d1+d4,2*d4+d1);
        int ans4=min(2*d2+d3,2*d3+d2);

        cout<<min(ans1,min(ans2,min(ans3,ans4)))<<endl;
        

        

       



    }
    return 0;
}


Measured memory_bytes: 3828
for(map~~<>,1..<>){
	($a,$b)=glob;
	$m=1e9;
	print+(grep{
		$c[$_-1]=~/ /;
		$m-=$-=$m-abs($`-$a)-abs$'-$b;
		$-
	}1..(@c=(@c,<>)))[-1],$/
}


Measured memory_bytes: 768
N, M =  map(int, (input().split(' ')))
A_B_list = []
money = 0
while len(A_B_list) < N:
    A, B =  map(int, (input().split(' ')))
    A_B_list.append([A, B])
A_B_list = sorted(A_B_list)
    

for A, B in A_B_list:
    if B < M:
        money += A * B
        M -= B
    else:
        money += A * M
        M = 0 
    if M == 0:
        print(money)
        exit()

Measured memory_bytes: 20880
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long[] a = new long[n];
		long[] b = new long[n];
		long[] c = new long[n];
		
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}
		for(int i=0;i<n;i++) {
			b[i] = in.nextInt();
		}
		for(int i=0;i<n;i++) {
			c[i] = in.nextInt();
		}
		
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);
		
		long[] sumB = new long[n];
		long nowB = b[0];
		int ptrA = 0;
		long count = 0;
		while(ptrA<n && a[ptrA]<nowB) {
			ptrA++;
			count++;
		}
		sumB[0] = count;
		for(int i=1;i<n;i++) {
			nowB = b[i];
			while(ptrA<n && a[ptrA]<nowB) {
				ptrA++;
				count++;
			}
			sumB[i] = count + sumB[i-1];
		}
		
		long sum = 0;
		int ptrB = 0;
		for(int i=0;i<n;i++) {
			long nowC = c[i];
			while(ptrB<n && b[ptrB]<nowC) {
				ptrB++;
			}
			if(ptrB>0) sum += sumB[ptrB-1];
		}
		
		System.out.println(sum);
		in.close();
		
		

	}

}


Measured memory_bytes: 100724
#include<cstdio>
#define MAX 45
int F[MAX];

int fibonacci(int F[], int n)
{
	if(F[n] != 0)
		return F[n];
	if(n == 0 || n == 1)
	{
		F[n] = 1;
		return F[n];
	}
	F[n] = fibonacci(F,n-1) + fibonacci(F,n-2);
	return F[n];
}

int main()
{
	int n;
	scanf("%d", &n);

	printf("%d\n", fibonacci(F,n));

	return 0;
}


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

int main(void){
    int h, n, sum = 0;
    cin >> h >> n;
    
    vector<int> a(n);
    rep(i, n){
        cin >> a.at(i);
        sum += a.at(i);
    }

    string s = "No";
    if(sum >= h){
        s = "Yes";
    }
    
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010
ll ans[1000000],n;
vvll v(1000000);
vll vis(1000000,0);
void dfs(ll x){
	vis[x]=1;
	rep(i,0,v[x].size()){
		if(!vis[v[x][i]]){
			ans[v[x][i]]+=ans[x];
			dfs(v[x][i]);
		}
		vis[v[x][i]]=1;
	}
}
int main(){
	IOS;
	ll q;cin>>n>>q;
	rep(i,0,n-1){
		ll a,b;cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	rep(i,0,q){
		int a;ll b;cin>>a>>b;
		ans[a]+=b;
	}
	dfs(1);
	rep(i,1,n+1)cout<<ans[i]<<" ";
	
	return 0;
}



Measured memory_bytes: 50816
N = input()

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

# left = []
left_count = 1
count = 0

for a in A:
    if a == left_count:
        left_count += 1
    else:
        count += 1
if left_count > 1:
    print(count)
else:
    print(-1)

Measured memory_bytes: 77516
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef map<string,int>M;
M shop[10];
string name[15];
int INF=0x3f3f3f3f,edge[11][11],n,q;
int minCost,minLength;
void F(int s)
{
	int i,j,k;
	int cost=0,tempCost;
	for(i=0;i<q;++i)
	{
		tempCost=INF;
		for(j=0;j<n;++j)
		{
			if(!(s&(1<<j)))continue;
			M::iterator ite=shop[j].find(name[i]);
			if(ite!=shop[j].end())
			{
				tempCost=min(tempCost,ite->second);
			}
		}
		if(tempCost==INF)return;
		cost+=tempCost;
	}
	if(minCost<cost)return;
	if(minCost>cost)
	{
		minCost=cost;
		minLength=INF;
	}

	s=(s<<1)+1;
	int dp[1<<11][11];
	memset(dp,INF,sizeof(dp));
	dp[1][0]=0;
	for(i=1;i<(1<<(n+1));++i)
	{
		if(i&~s)continue;
		for(j=0;j<n+1;++j)
		{
			for(k=0;k<n+1;++k)
			{
				int&r=dp[i|(1<<k)][k];
				r=min(r,dp[i][j]+edge[j][k]);
			}
		}
	}
	minLength=min(minLength,dp[s][0]);
}
int main()
{
	int i,j,k,v,m,a,b,d;
	char str[256];
	while(scanf("%d",&n),n)
	{
		memset(edge,INF,sizeof(edge));
		minCost=minLength=INF;
		for(i=0;i<n;++i)
		{
			shop[i].clear();
			for(scanf("%d",&k);k--;)scanf("%s%d",str,&v),shop[i][str]=v;
		}
		for(i=!scanf("%d",&q);i<q;++i)
		{
			scanf("%s",str);
			name[i]=str;
		}
		for(scanf("%d",&m);m--;)
		{
			scanf("%d%d%d",&a,&b,&d);
			edge[a][b]=edge[b][a]=d;
		}
		for(k=0;k<n+1;++k)for(i=0;i<n+1;++i)for(j=0;j<n+1;++j)edge[i][j]=min(edge[i][j],edge[i][k]+edge[k][j]);
		for(i=1;i<(1<<n);++i)F(i);
		if(minCost>=INF)puts("impossible");
		else printf("%d %d\n",minCost,minLength);
	}
	return 0;
}

Measured memory_bytes: 936
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=[]
s.append(0)
for i in range(n):
    s.append(s[i]+a[i])
s.sort()
a=Counter(s).most_common()
#print(a)
ans=0
for i in range(len(a)):
    ans += ((a[i][1]-1)*a[i][1])//2
print(ans)

Measured memory_bytes: 48752
#include<stdio.h>
int main()
{
    int a[100000];
    int i,l,m,n;
    long long s;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    s=0;
    for(i=0;i<n-1;i++)
    {
        if(a[i]+a[i+1]>m)
        {
            l=a[i]+a[i+1]-m;
            if(l>a[i+1])
            {
                s+=l;
                a[i+1]=0;
            }
            else
            {
                s+=l;
                a[i+1]=a[i+1]-l;
            }
        }
    }
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 640
using System.Collections.Generic;
using System;

public class hello
{
	public static void Main()
	{
		while (true)
		{
			var max = int.Parse(Console.ReadLine().Trim());
			if (max == 0) break;
			var n = int.Parse(Console.ReadLine().Trim());
			var s = new int[n + 2];
			for (int i = 0; i < n; i++)
				s[i + 1] = int.Parse(Console.ReadLine().Trim());
			var aa = setEdge(s, max, n);
			var dp = setDp(aa);
			goWarshall(dp);
			Console.WriteLine(getAns(dp) ? "OK" : "NG");
		}
	}
	static bool getAns(bool[,] dp)
	{
		var a = dp.GetLength(0);
		if (!dp[0, a - 1] ) return false;
		for (int i = 1; i < a - 1; i++)
			if (dp[0, i]  && !dp[i, a - 1] ) return false;
		return true;
	}
	static bool[,] setDp(List<int>[] aa)
	{
		var n = aa.Length;
		var dp = new bool[n + 1, n + 1];
		for (int i = 0; i < n; i++)
		{
			foreach (var x in aa[i])
				dp[i, x] = true;
		}
		for (int i = 0; i < n + 1; i++) dp[i, i] = true;
		return dp;
	}
	static List<int>[] setEdge(int[] s, int max, int n)
	{
		var aa = new List<int>[n + 1];
		for (int i = 0; i < n + 1; i++) aa[i] = new List<int>();
		for (int i = 0; i <= n; i++)
			for (int j = 1; j <= max; j++)
			{
				if (i + j <= n + 1)
				{
					var cmd = s[i + j];
					var np = i + j + cmd;
					if (np > n + 1) np = n + 1;
					if (np < 0) np = 0;
					if (!aa[i].Contains(np)) aa[i].Add(np);
				}
			}
		return aa;
	}
	public static void goWarshall(bool[,] dp)
	{
		var n = dp.GetLength(0);
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				for (int k = 0; k < n; k++)
					if (dp[j, i] && dp[i, k]) dp[j, k] = true;
	}
}



Measured memory_bytes: 22012
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v: Vec<usize> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();
    let mut r: Vec<usize> = vec![0; v[0]];
    for _ in 0..v[1] {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let u: Vec<usize> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();
        r[u[0]-1] += 1;
        r[u[1]-1] += 1;
    }
    for i in &r {
        println!("{}", *i);
    }
}



Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;


public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		//int k =sc.nextInt();
		long[][]a = input(n , 3 );
		long[][] dp = new long[n][3];
		for(int i =0 ; i < n ;i++) {
			long temp =(i>0 ? Math.max(dp[i-1][0] , dp[i-1][1]) :0) ; 
			dp[i][2] = temp+a[i][2];
			
			
			temp =(i>0 ? Math.max(dp[i-1][2] , dp[i-1][1]) :0) ; 
			dp[i][0] = temp+a[i][0];
			
			temp =(i>0 ? Math.max(dp[i-1][0] , dp[i-1][2]) :0) ; 
			dp[i][1] = temp+a[i][1];
		}
		long ans = Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2]));
		System.out.println(ans);
	}
	public static long[] input(int n) throws Exception {

		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		}
		return arr;
	}
	public static long[][] input(int n , int m ) throws Exception {

		long[][] arr = new long[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {

				arr[i][j] = sc.nextInt();
			}
		}
		return arr;
	}

}


Measured memory_bytes: 64728