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

int main() {
  int n,m;
  cin>>n;
  vector<int> a(n);

  for(int i=0;i<n;i++){
    int b;
    cin>>b;
    a[i]=b;
  }
  int tmp=1;
  for(int i=0;i<n+1;i++){
    if(tmp==2){
      cout<<i<<endl;
      break;
    }else if(i==n){
      cout<<-1<<endl;
    }
    tmp=a[tmp-1];
  }
}

Measured memory_bytes: 640
#include <stdio.h>
#define MAX 100000

int partition(int a,int b);
int K[MAX],kazu;

int main()
{
int i,j;
scanf("%d",&kazu);
for(i=0;i<kazu;i++)scanf("%d",&K[i]);

j=partition(0,kazu-1);
for(i=0;i<kazu;i++)
{
  if(i)printf(" ");
  if(i==j)printf("[");
  printf("%d",K[i]);
  if(i==j)printf("]");
}
printf("\n");
return 0;
}

int partition(int a,int b)
{
int l,i,j,s;
l=K[b];
i=a-1;
for(j=a;j<b;j++)
{
  if(K[j]<=l){
    i++;
    s=K[i];K[i]=K[j];K[j]=s;
  }
}
s=K[i+1];K[i+1]=K[b];K[b]=s;
return i+1;
}



Measured memory_bytes: 2148
// D - 756
#include <bits/stdc++.h>
using namespace std;

vector<int> P(97+1);// max prime 97 (<=100)

int f(int x){
	x--;
	int c = 0;
	for(int pc:P) if(pc>=x) c++;
	return c;
}

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

	for(int i=2; i<=N; ++i)
		for(int n=i, p=2; p<=i; ++p)
			for(;n%p==0; n/=p) P[p]++;

	int ans = f(75); // {f(75)}_C_{1}
	ans += f(25) * (f(3)-1); // {f(25)}_C_{1} * {f(3)-1}_C_{1}
	ans += f(15) * (f(5)-1); // {f(15)}_C_{1} * {f(5)-1}_C_{1}
	ans += f(5)*(f(5)-1)/2 * (f(3)-2); // {f(5)}_C_{2} * {f(3)-2}_C_{1}
	cout << ans <<endl;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int n,l=0;
    cin>>n;
    vector<int> a(10000),b(10000);
    for (int i=1;i*i<=n;i++){
      if (n%i==0){
          a[l] = i;
          b[l]= n/i;
          l++;
      }
    }
    int ans=1000;
    for (int i=0;i<l;i++){
        string s1=to_string(a[i]);
        string s2=to_string(b[i]);
        int l= max(sz(s1),sz(s2));
        ans = min(ans,l);
    }
    cout << ans << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  int N; cin >> N;
  int h[N]; rep(i,N) cin >> h[i];

  vector<ll> dp(100010, INF);
  dp[0] = 0;
  rep(i,N){
    chmin(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
    chmin(dp[i+2], dp[i]+abs(h[i+2]-h[i]));
  }
  cout << dp[N-1] << endl; 
  

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4232
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 1e9;
const int MB = 30;
const int MOD = 1e9 + 7;
const double PI = atan2(0, -1);


void solve() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        sum += x;
    }
    cout << (sum > n ? -1 : n - sum);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    //cin >> t;
    int t = 1;
    //srand(time(0));
    cout.precision(12);
    cout << fixed;
    while (t--) solve();
}

Measured memory_bytes: 3656
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
long const M=1e9+7;
const long mxN =1e5+2 ;
void solve(){
  ll a,b,c,k ; cin >> a >> b >> c >> k ;
  if(k<=a){
    cout << k ;
  }
  else if(k<=a+b){
    cout << a ;
  }
  else {
    cout << a-(k-b-a);
  }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 3640
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;

using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
#define rep(x, y, a) for (ll x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

typedef vector<int> vi;
typedef vector<pii> vpii;
namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    set<int> a2(all(a));
    map<int, int> cnt;
    rep(i, 0, n) ++cnt[a[i]];
    vi res(n, 1);
    rep(i, 0, n) {
        if (cnt[a[i]] > 1 || cnt[1] > 0 && a[i] != 1) res[i] = 0;
        for (int j = 2; j * j <= a[i] && res[i]; ++j) {
            if (a[i] % j == 0) {
                if (a2.count(j) || a2.count(a[i] / j)) res[i] = 0;
            }
        }
    }
    put(count(all(res), 1));
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;
    while (q--) solve();
}





Measured memory_bytes: 23524
from math import sqrt, ceil


def main():
    n = int(input())

    pairs = [(i, n // i) for i in range(1, ceil(sqrt(n)) + 1) if n % i == 0]

    least_distance = min(map(lambda x: x[0] + x[1], pairs))

    print(least_distance - 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
#include<stdio.h>
int main()
{
	int t,h,s;
	int r;
	while(1){
		scanf("%d%d%d",&t,&h,&s);
		if(t==-1&&h==-1&&s==-1){
			break;
		}
		r = 7200 - t*3600 - h*60 - s;
		printf("%02d:%02d:%02d\n",r/3600,(r%3600)/60,r%60);
		printf("%02d:%02d:%02d\n",3*r/3600,(3*r%3600)/60,3*r%60);
	}
	return 0;
}

Measured memory_bytes: 2716
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll count = 0;
  rep(i, n - 2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      count++;
    }
  }
  print(count);
}

Measured memory_bytes: 256
# エラトステネスの篩, 累積和
def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(2, int(n ** 0.5) + 1):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


max_lr = 10 ** 5

prime_table = make_prime_table(max_lr)

cs = [0] * (max_lr + 1)
for i in range(3, max_lr + 1, 2):
    j = (i + 1) // 2
    if prime_table[i] == i and prime_table[j] == j:
        cs[i] = 1
for i in range(1, max_lr + 1):
    cs[i] += cs[i - 1]

Q = int(input())
result = []
for _ in range(Q):
    l, r = map(int, input().split())
    result.append(cs[r] - cs[l - 1])
print('\n'.join(str(i) for i in result))
#print(*result, sep='\n')


Measured memory_bytes: 24648
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};

//スタート点,頂点数、辺を渡して、最短経路の配列を返す
std::vector<LL> dijkstra(int s,int N,vector<vector<Edge>> Edges){
    vector<LL> d;
    priority_queue<pair<int,int> ,vector<pair<int,int>>,greater<pair<int,int>> > que;
    REP(a,N+10){
        d.push_back(LINF);
    }
    d[s]=0;
    que.push(make_pair(0,s));
    while(!que.empty()){
        pair<int,int> p = que.top();que.pop();
        int v = p.second;
        if(d[v]<p.first)continue;
        for(int  i = 0;i < Edges.at(v).size();i++){
            Edge e = Edges.at(v).at(i);
            if(d.at(e.to)>d.at(v)+e.value){
                d.at(e.to)=d.at(v)+e.value;
                que.push(make_pair(d.at(e.to),e.to));
            }
        }
    }
    return d;
}
int main(){
    CIN(N);
    vector<vector<Edge>> edges(N+10);
    REP(a,N-1){
        CIN(b);CIN(w);CIN(y);
        Edge e(b,w,y);
        Edge r(w,b,y);
        edges.at(e.from).push_back(e);
        edges.at(r.from).push_back(r);
    }

    CIN(Q);CIN(K);
    vector<LL> vec1 = dijkstra(K,N,edges);
    REP(a,Q){
        CIN(x);CIN(y);
        COUT(vec1.at(x)+vec1.at(y));
    }
    rt 0;
}


Measured memory_bytes: 16052
#include<bits/stdc++.h>
#define Mx 1000000000005 
#define ll long long  
#define pi 3.141592653
#define vi vector<ll>
#define Mo 1000000007
#define mp make_pair
#define M map<ll,ll>
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define vii vector<pair<ll,ll> > 
#define fi first
#define se second
#define pb push_back
#define ld long double
#define fill(a,x) memset(a,x,sizeof(a))
using namespace std;
bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
  return a.second<b.second;
}
/*vi b=v;
   sort(b.begin(), b.end());
  b.resize(unique(b.begin(), b.end()) - b.begin());
  ll t; cin>>t; fr(f,0,t){ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 */
ll func(ll n, ll wt[], ll W, ll v[])
{
  if(n==0 || W==0) return 0;
  
  if(W<wt[n-1]) return func(n-1, wt, W, v); 

  return max(v[n-1]+func(n-1, wt, W-wt[n-1], v), func(n-1, wt, W, v));
}
int main()
{
  ll n,W; cin>>n>>W;
  ll wt[n],v[n];
  fr(i,0,n)
    cin>>wt[i]>>v[i];

  ll dp[n+1][W+1];
  fill(dp,0);

  fr(i,1,n+1)
  {
    fr(j,1,W+1)
    {
      dp[i][j]=dp[i-1][j];
      if(j>=wt[i-1])
        dp[i][j]=max(dp[i][j],v[i-1]+dp[i-1][j-wt[i-1]]);
    }
  }

  cout<<dp[n][W];

}

Measured memory_bytes: 82532
// AOJ 1019
#include<cstdio>
#define rep( i, a ) for( int i = 0; i != (a); ++i )

int N, K;
int S[100];
int B[100][100];

int main()
{
	while( scanf( "%d%d", &N, &K ), N|K )
	{
		rep( i, K )
			scanf( "%d", S+i );
		rep( i, N )
			rep( j, K )
				scanf( "%d", &B[i][j] );

		bool fl = true;
		rep( i, K )
		{
			int sum = 0;
			rep( j, N )
				sum += B[j][i];
			if( sum > S[i] ) { fl = false; break; }
		}

		puts( fl ? "Yes" : "No" );
	}

	return 0;
}

Measured memory_bytes: 1052
import sys


def solve(inp):
    N = int(inp.readline().strip())
    S = inp.readline().strip()

    r = 0
    for i in range(N - 2):
        if S[i:i + 3] == "ABC":
            r += 1

    return str(r)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import static java.lang.Math.PI;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double r = scanner.nextDouble();
        double length = 2 * Math.PI * r;
        double area = PI * r * r;
        System.out.printf ("%.6f %.6f\n",area,length); 
        scanner.close();
    }
}


Measured memory_bytes: 28060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#define P pair<char, char>

using namespace std;
int n;
P p[109], q[109], r[109];

void printArray(P a[]){
  for(int i=0;i<n;i++){
    cout << a[i].first << a[i].second << (i<n-1?' ': '\n');
  }
}

void bubbleSort(){
  for(int i=0;i<n;i++){
    for(int j=n-1;j>=i+1;j--){
      if(q[j].second < q[j-1].second){
        swap(q[j], q[j-1]);
      }
    }
  }
}

void selectionSort(){
  for(int i=0;i<n;i++){
    int mni = i;
    for(int j=i;j<n;j++){
      if(r[j].second <r[mni].second){
        mni=j;
      }
    }
    if(mni!=i)swap(r[i], r[mni]);
  }
}

int main(){
  cin >> n;
  string s;
  for(int i=0;i<n;i++){
    cin >> s;
    p[i] = P(s[0], s[1]);
  }
  copy(p, p+n, q);
  copy(p, p+n, r);
  bubbleSort();
  printArray(q);
  cout << "Stable" << endl;
  selectionSort();
  printArray(r);
  bool check_stable=true;
  for(int i=0;i<n;i++){
    if(q[i] != r[i])check_stable=false;
  }
  cout << (check_stable?"Stable": "Not stable") << endl;
}


Measured memory_bytes: 3128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	class Pair{
		public String S;
		public int P, Idx;
		public Pair(String s, int p, int idx){
			S = s; P = p; Idx = idx;
		}
	}
	public void Solve(){
		
		Pair[] L = new Pair[N];
		for(int i=0;i<N;i++) L[i] = new Pair(S[i], P[i], i + 1);
		
		Array.Sort(L, (p,q) => p.S.CompareTo(q.S) == 0 ? -1 *(p.P.CompareTo(q.P)) : p.S.CompareTo(q.S));
		Console.WriteLine(String.Join("\n",L.Select(p => p.Idx)));
		
		
		
	}
	int N;
	String[] S;
	int[] P;
	public Sol(){
		N = ri();
		S = new String[N];
		P = new int[N];
		for(int i=0;i<N;i++){
			var ss = rsa();
			S[i] = ss[0]; P[i] = int.Parse(ss[1]);
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13536
import java.io.*;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        long N = Long.parseLong(br.readLine());
        long[] arr = new long[5];
        long min = Long.MAX_VALUE;
        for(int i=0;i<5;++i)
        {
            arr[i] = Long.parseLong(br.readLine());
            if(min>arr[i]) min = arr[i];
        }
        long ans = N/min + (N%min==0?0:1);

        bw.write((ans+4)+"");
        bw.close();
    }
}


Measured memory_bytes: 21204
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

bool pss(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)
			return false;
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////

int n;
struct ac{
	int x,y,z;
}a[100010];
int bcj[100010];

int cmp(ac v,ac r){
	return v.x<r.x;
}

int cmp2(ac v,ac r){
	return v.y<r.y;
}

vector<pair<int,pii> > v;

int father(int b){
	if(bcj[b]==b)
		return b;
	bcj[b]=father(bcj[b]);
	return bcj[b];
}

int main(){
	//my name is Veex
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].x>>a[i].y;
		a[i].z=i;
		bcj[i]=i;
	}
	
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<n;i++)
		v.pb(mer(a[i+1].x-a[i].x,mer(a[i].z,a[i+1].z)));
	
	sort(a+1,a+n+1,cmp2);
	for(int i=1;i<n;i++)
		v.pb(mer(a[i+1].y-a[i].y,mer(a[i].z,a[i+1].z)));
	
	sort(v.begin(),v.end());
	int sum=0;
	for(int i=0;i<v.size();i++){
		if(father(v[i].se.fi)==father(v[i].se.se))
			continue;
		sum+=v[i].fi;
		bcj[father(v[i].se.fi)]=father(v[i].se.se);
	}
	cout<<sum;
	return 0;
}
/*
6
8 3
4 9
12 19
18 1
13 5
7 6
*/

Measured memory_bytes: 6516
from collections import defaultdict

N, M = map(int, input().split())
route = defaultdict(lambda: False)
for i in range(M):
    ai, bi = map(int, input().split())
    route[(ai, bi)] = True

possible = False
for i in range(2, N):
    if route[(1, i)] and route[(i, N)]:
        possible = True
print('POSSIBLE' if possible else 'IMPOSSIBLE')


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

int main(void)
{
    int x;
    cin >> x;
    int i, j;
    int maxa = 1;

    for(i = 2; i*i <= x; ++i)
    {
        int sum = i*i;
        while(1)
        {
            if(sum > x)
                break;
            if(sum > maxa)
                maxa = sum;
            sum*= i;
        }
    }
    cout << maxa <<endl;
    return 0;
}


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

Measured memory_bytes: 256
a,b,c,k = gets.split.map(&:to_i)

cnt = 0
if k > a
  k -= a
  cnt += a
else
  cnt += k
  p cnt
  exit
end

if k > b
  k -= b
else
  p cnt
  exit
end

if k > c
  k -= c
  cnt -= 1
else
  cnt -= k
  p cnt
  exit
end
p cnt

Measured memory_bytes: 14312
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn match_2(a: u32, b: u32, c: u32) -> String {
    let ans = if a == b && b != c {
        "Yes"
    } else if b == c && c != a {
        "Yes"
    } else if c == a && a != b {
        "Yes"
    } else {
        "No"
    };
    ans.to_string()
}

fn main() {
    input! {a: u32, b: u32, c: u32}
    println!("{}", match_2(a, b, c));
}

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

int main(void){
  int n, ary[100];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> ary[i];
  }
  for(int i=n-1; i>=0; i--){
    printf("%d", ary[i]);
    if(i!=0){
      printf(" ");
    }else{
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 3136
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Queue;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        Queue<Integer> queue = new ArrayDeque<>();
        
        int n = sc.nextInt();
        int q = sc.nextInt();
        String name[] = new String[n];
        int time[] = new int[n];
        for(int i = 0; i < n; i++){
            name[i] = sc.next();
            time[i] = sc.nextInt();
            queue.add(i);
        }
        
        int x = 0;
        while(!queue.isEmpty()){
            int y = queue.poll();
            if(time[y] <= q){
                x += time[y];
                System.out.println(name[y]+" "+x);
            }else{
                x += q;
                time[y] -= q;
                queue.add(y);
            }
        }
    }
}


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

int cntDivisor( int a )
{
    int cnt = 0;
    for( int i = 1; i <= a; i++ )
        if( a % i == 0 )
            cnt++;
    return cnt;
}

int main()
{
    int n;

    cin >> n;

    for( int i = n; i <= 1024; i++ )
    {
        if( n == cntDivisor( i ) )
        {
            cout << i << endl;
            break;
        }        
    }

    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;

int  main()
{
	int x, n; cin >> x >> n;
	vector <int> p(n);
	set <int> st;
	rep(i, n)
	{
		cin >> p[i];
		st.insert(p[i]);
	}
	int ans = INT_MAX;
	for (int i = -1; i <= 101; i++)
	{
		if(!st.count(i))
			ans = min(ans, abs(i - x));
	}
	for (int i= -1; i <= 101; i++)
	{
		if (!st.count(i))
		{
			if (ans == abs(i - x))
			{
				cout << i << endl;
				return 0;
			}
		}
	}
	return (0);
}

Measured memory_bytes: 3600
import java.util.*;
import java.io.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                Map hs = new HashMap();
                PrintWriter ou = new PrintWriter(System.out);
                int n = Integer.parseInt(sc.next());
                int[] l = new int[n];
                for(int i = 0 ; i < n ; i++){
                        l[i] = Integer.parseInt(sc.next());
                }
                sc.close();
                Arrays.sort(l);
                for(int i = 0 ; i < n - 1 ; i++){
                        l[n - 1] -= l[i];
                }
                if(l[n - 1] >= 0) ou.print("No\n");
                else ou.print("Yes\n");
                ou.flush();
        }
}

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

int main(){
   int n;
   cin >> n;
   auto v = vector<int>(n,0);
   for (int i = 0; i < n; i++)
   {
       cin >> v[i];
   }
 
   auto _max = *max_element(v.begin(),v.end());

   auto sum = accumulate(v.begin(),v.end(),0);

   if(sum>2*_max)
   {
       cout << "Yes";
   }
    else
   {
       cout << "No";
   }
   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a % b);
}


int main(void){
    int k;
    cin >> k;

    int ans = 0;
    for(int a=1; a<=k; a++){
        for(int b=1; b<=k; b++){
            int gcd_ab = gcd(a, b);
            for(int c=1; c<=k; c++){
                ans += gcd(gcd_ab, c);
            }
        }
    }

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

Measured memory_bytes: 3688
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int Q = sc.nextInt();
        var prime = GeneratePrimeList(100000);
        var cnt = 0;
        var arr = new int[100001];
        for (int i = 0; i <= 100000; i++) {
            if (prime[i] && prime[(i+1) / 2]) {
                cnt++;
            }
            arr[i] = cnt;
        }

        for (int i = 0; i < Q; i++) {
            var l = sc.nextInt();
            var r = sc.nextInt();
            WriteLine(arr[r] - arr[l-1]);
        }
    }

    bool[] GeneratePrimeList(int n) {
        n++;
        var isPrime = new bool[n];
        for (int i = 2; i < n; i++) isPrime[i] = true;
        var sqrt = (int)Math.Sqrt(n);
        for (int i = 2; i <= sqrt; i++) {
            if (isPrime[i]) {
                var j = i + i;
                while (j < n) {
                    isPrime[j] = false;
                    j += i;
                }
            }
        }
        return isPrime;
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


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



int main(){
   string s;
   cin >> s;
   
   int cntb1 = 0, cntb2 = 0;
   int cntw1 = 0, cntw2 =0;
   for(int i = 0; i < s.size();i+=2){
       if(s[i]=='0') cntb1++;
       else cntw1++;
       
   }
   for(int i = 1; i< s.size(); i+=2){
       if(s[i]=='0') cntb2++;
       else cntw2++;
   }
  int ans = min(cntb1,cntb2)+ min(cntw1,cntw2);
  cout << ans << endl;
   }


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

int main() {
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    double area = w * h;
    double ans1 = area/2;
    int ans2;
    if(x == w/2 && y == h/2){
        ans2 = 1;
    }else ans2 = 0;
    cout << fixed << ans1;
    cout << " " << ans2 << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_c

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<vector<int> > v(n+1,vector<int>(4,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=3;j++) cin>>v[i][j];
    }

    vector<vector<int> > dp(n+1,vector<int>(4,0));
    for(int d=1;d<=n;d++){
        dp[d][1] = v[d][1] + max(dp[d-1][2],dp[d-1][3]);
        dp[d][2] = v[d][2] + max(dp[d-1][1],dp[d-1][3]);
        dp[d][3] = v[d][3] + max(dp[d-1][1],dp[d-1][2]);
    }

    cout<<max(dp[n][1], max(dp[n][2],dp[n][3]))<<"\n";

    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cmath>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	double n;
	cin >> n;
	cout << fixed << setprecision(8) << 2*n*3.14159265358979323846;
	return 0;
}

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

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll s;
	cin >> s;
	ll a[100000];
	ll i=0;
	a[0]=s;
	while(1){
		if(s%2) s=3*s+1;
		else s/=2;
		i++;
		a[i]=s;
		//cout << a[i] << "\n";
		for(ll j=0; j<i; j++){
			if(a[j]==s){
				cout << i+1;
				return 0;
			}
		}
	}
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n)
	{
		int count = 0;
		for(int a = 0; a < 10; ++a)
		{
			for(int b = 0; b < 10; ++b)
			{
				for(int c = 0; c < 10; ++c)
				{
					for(int d = 0; d < 10; ++d)
					{
						if(n == a + b + c + d)
						{
							count++;
						}
					}
				}
			}
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(long long N, long long M, long long K, std::vector<long long> A, std::vector<long long> B){
  vector<ll>An(N+1),Bn(M+1);
  for (int i = 0; i < N+1; i++) {
    An[i] = (i == 0 ? 0:A[i-1] + An[i-1]);
  }
  for (int i = 0; i < M+1; i++) {
    Bn[i] = (i == 0 ? 0:B[i-1] + Bn[i-1]);
  }
  ll best = M , ans = 0;
  for (ll i = 0,l; i < N+1; i++) {
    bool done = false;
    ll x = K-An[i];
    if(x < 0)break;
    for (l = best; l >= 0; l--) {
      if(Bn[l] <= x){
        done = true;
        break;
      }
    }
    if(done){
      best = l;
      ans = max(ans,(i+l));
    }
  }
  cout << ans << endl;
}

int main(){
    long long N;
				scanf("%lld",&N);
				long long M;
				scanf("%lld",&M);
				long long K;
				scanf("%lld",&K);
				std::vector<long long> A(N);
				for(int i = 0 ; i < N ; i++){
								scanf("%lld",&A[i]);
				}
				std::vector<long long> B(M);
				for(int i = 0 ; i < M ; i++){
								scanf("%lld",&B[i]);
				}
    solve(N, M, K, std::move(A), std::move(B));
    return 0;
}


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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n;
vector<int> v;

main() {
    rep(i,4) cin >> n,v.pb(n)
    sort(all(v));
    if (v[0]==1 && v[1]==4 && v[2]==7 && v[3]==9) ct("YES")
    else ct("NO")

}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>

int main(void){
	int cnt, i;
	double x1, y1, x2, y2, x3, y3, xp, yp, r;
	double a, b, c, d, e, f;

	scanf("%d", &cnt);
	for (i = 0; i < cnt; i++) {
		scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
			if (x1 < -100 || x1 > 100) {
				printf("Error!\n");
				continue;
			} else if (y1 < -100 || y1 > 100) {
				printf("Error!\n");
				continue;
			} else if (x2 < -100 || x2 > 100) {
				printf("Error!\n");
				continue;
			} else if (y2 < -100 || y2 > 100) {
				printf("Error!\n");
				continue;
			} else if (x3 < -100 || x3 > 100) {
				printf("Error!\n");
				continue;
			} else if (y3 < -100 || y3 > 100) {
				printf("Error!\n");	
				continue;
			} else {
				a = 2 * (x1 - x2);
				b = 2 * (y1 - y2);
				c = (x1 + x2) * (x1 - x2) + (y1 + y2) * (y1 - y2);
				d = 2 * (x1 - x3);
				e = 2 * (y1 - y3);
				f = (x1 + x3) * (x1 - x3) + (y1 + y3) * (y1 - y3);
				
				if (((a*e) - (b*d)) == 0) {
					printf("Error!\n");
					continue;
				} else {
					xp = ((c*e) - (b*f)) / ((a*e) - (b*d));
					yp = ((a*f) - (c*d)) / ((a*e) - (b*d));
					r = sqrt(pow((x1 - xp), 2.0) + pow((y1 - yp), 2.0));
					printf("%.3f %.3f %.3f\n", xp, yp, r);
				}
			}
	}
	return 0;
}

Measured memory_bytes: 0
def main():
    from collections import deque
    H, W = map(int, input().split())
    grid = [["#"] * (W + 2)] + [list("#" + input() + "#")
                                for i in range(H)] + [["#"]*(W+2)]
    # print(grid)
    stack = deque()
    for h in range(1, H+1):
        for w in range(1, W+1):
            # 黒ならスタックにpush
            if grid[h][w] == "#":
                stack.append([h, w])

    for i in range(h + w + 3):
        tmp = deque()
        while stack:
            h, w = stack.pop()
            for dh, dw in ([0, 1], [0, -1], [1, 0], [-1, 0]):
                if grid[h + dh][w + dw] == ".":
                    grid[h + dh][w + dw] = "#"
                    tmp.append([h + dh, w + dw])
        stack = tmp
        if not stack:
            print(i)
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 169052
#include<iostream>
#include<string.h>
using namespace std;
const int N=110;
int match[N];
bool vis[N],flag[N][N];
struct node {
	int x,y;
}r[N],b[N];//红色和蓝色的点 
int n;
bool find(int x)
{
	for(int i=1;i<=n;i++)
	{
		if(!vis[i]&&flag[x][i])
		{
			vis[i]=1;
			if(match[i]==0||find(match[i]))
			{
				match[i]=x;
				return 1;
			}
		}
	}
	return 0;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>r[i].x>>r[i].y;
	for(int i=1;i<=n;i++) cin>>b[i].x>>b[i].y;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(r[i].x<b[j].x&&r[i].y<b[j].y)
			{
				flag[i][j]=1;//两者可以配对 
			}
		}
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{   
                memset(vis,0,sizeof(vis));
		if(find(i))//最大匹配 
		{
			ans++;
		}
	 } 
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int qmin(int a, int b){
	return (a < b) ? a : b;
}

int n;
int a[200200], b[200200];
int this_bit[1000100];
int z[1000100];
vector<int> v[200200], g[200200];

void z_box(){
	int l = 0, r = 0;
	for(int i = 1; i <= n+n+n; i++){
		z[i] = 0;
		if(r >= i){
			z[i] = qmin(z[i-l], r-i+1);
		}
		while(i+z[i] <= n+n+n && this_bit[i+z[i]] == this_bit[z[i]]) z[i]++;
		if(i+z[i]-1 > r){
			l = i;
			r = i+z[i]-1; 
		}
	}
}

int main(){
	scanf("%d", &n);
	rep(i, n) scanf("%d", &a[i]);
	rep(i, n) scanf("%d", &b[i]);
	this_bit[n] = 20200223;
	rep(bit, 30){
		rep(i, n) this_bit[i] = (b[i] >> bit) & 1;
		rep(x, 2){
			rep(i, n){
				this_bit[n+i+1] = this_bit[n+n+i+1] = ((a[i] >> bit) & 1) ^ x;
			}
			z_box();
			for(int i = n+1; i <= n+n; i++){
				if(z[i] >= n){
					int len = i-n-1;
					if(bit == 0) v[len].push_back(x << bit);
					else {
						rep(j, g[len].size()) v[len].push_back((x << bit) + g[len][j]);
					}
				}
			}
		}
		rep(i, n){
			g[i] = v[i];
			v[i].clear();
		}
	}
	rep(i, n){
		sort(g[i].begin(), g[i].end());
		rep(j, g[i].size()){
			cout << i << " " << g[i][j] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 34688
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,p;
    cin >> s;
    string S = s + s;
    cin >> p;
    if ( S.find(p)!= std::string::npos ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int k, a, b; cin >> k >> a >> b;
    bool t = false;
    repp(i,b+1,a){
        if (i % k == 0){
            t = true;
            break;
        }
    }
    if (t) cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3648
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())


N = int(input())
lines = []

for i in range(N):
	lines.append(inpl())

ans = 0
for s in range(N):
	for t in range(s+1,N):
		c = lines[s][t]
		ans += c
		for mid in range(N):
			if mid == s or mid == t:
				continue
			a = lines[s][mid]
			b = lines[mid][t]
			if a+b < c:
				print(-1)
				sys.exit()
			elif a+b == c:
				ans -= c
				break
print(ans)

Measured memory_bytes: 54104
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

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

	std::string s;
	std::cin >> s;
	FOR(i, SZ(s)) if(s[i] == '?') s[i] = 'D';

	std::cout << s;

	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;

  if(a == b) {
    cout << "a == b" << endl;
  } else if(a < b) {
    cout << "a < b" << endl;
  } else {
    cout << "a > b" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3120
N ,M = map(int, input().split())

s = [0] * M
c = [0] * M

for i in range(M):
    s[i], c[i] = map(int, input().split())

for i in range(1000):
    x = str(i)
    count = 0
    if len(x) != N:
        continue
    for j in range(M):
        if x[s[j]-1] == str(c[j]):
            count += 1
    if count == M:
        print(x)
        break
else: 
    print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define sc cout<<"success"<<endl

int main()
{
    //cin>>tc;for(int t=1;t<=tc;t++){ }
    int n;
    cin>>n;
    int a[n];
    int maxvalue=INT_MIN,maxindex=-1,secmax=INT_MIN,smaxindex=-1;
    cin>>a[0]>>a[1];

    maxvalue=a[0];
    maxindex=0;
    secmax=a[1];
    smaxindex=1;
    if(maxvalue<secmax)
    {
        swap(maxvalue,secmax);
        swap(maxindex,smaxindex);

    }
    //cout<<"maxvalue"<<maxvalue<<endl;
    for(int i=2;i<n;i++)
    {
        cin>>a[i];
        if(maxvalue<=a[i])
        {
            secmax=maxvalue;
            smaxindex=maxindex;
            maxvalue=a[i];
            maxindex=i;
        }
        if(secmax<=a[i] && i!= maxindex)
        {
            secmax=a[i];
            smaxindex=i;
        }
    }
    //cout<<maxvalue<<" "<<secmax<<endl;
    //cout<<maxindex<<" "<<smaxindex<<endl;

    for(int i=0;i<n;i++)
    {
        if(i==maxindex)
            cout<<secmax<<endl;
        else
            cout<<maxvalue<<endl;
    }
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 10000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector

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

string S; cin >> S;
int N = S.size();

VVI cnt(N, VI(13, 0));
if (S[0] == '?')
    for (int i = 0; i < 10; i++) cnt[0][i] = 1;
else
    cnt[0][S[0] - '0'] = 1;

for (int k = 0; k < N - 1; k++) 
    if (S[k + 1] == '?')  // 次の文字が自由に決められる
        for (int i = 0; i < 13; i++) 
            for (int j = 0; j < 10; j++)  // 全ての文字を試す
                (cnt[k + 1][(i * 10 % 13 + j) % 13] += cnt[k][i]) %= MOD;
    else  // 次の文字が指定されている
        for (int i = 0; i < 13; i++)
            (cnt[k + 1][(i * 10 % 13 + (S[k + 1] - '0')) % 13] += cnt[k][i]) %= MOD;

cout << cnt[N-1][5] << endl;

}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 13648