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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int n,d;
    cin>>n>>d;
    vector<double> v[n];
    ffor(i,0,n)
    {
        ffor(j,0,d)
        {
            float x;
            cin>>x;
            v[i].pb(x);
        }
    }
    int ans=0;
    ffor(i,0,n-1)
    {
        ffor(j,i+1,n)
        {
            float x=0;
            ffor(k,0,d)
            {
                x+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
            }
            x=sqrt(x);
            if(x==floor(x)) ans++;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ca = [[0 for _ in range(3)]]
for i in range(n):
  if(a[i] == ca[i][0]):
    ca.append([ca[i][0]+1,ca[i][1],ca[i][2]])
  elif(a[i] == ca[i][1]):
    ca.append([ca[i][0],ca[i][1]+1,ca[i][2]])
  else:
    ca.append([ca[i][0],ca[i][1],ca[i][2]+1])
ans = 1
for i in range(n):
  ans = (ans * ca[i].count(a[i])) % 1000000007
print(ans)

Measured memory_bytes: 26920
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

template<class Abel> struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<int> num_same;
	vector<Abel> diff_weight;

	UnionFind(int n = 1, Abel SUM_UNITY = 0) {
		init(n, SUM_UNITY);
	}

	void init(int n = 1, Abel SUM_UNITY = 0) {
		par.resize(n); rank.resize(n); num_same.resize(n); diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, num_same[i] = 1, diff_weight[i] = SUM_UNITY;
	}

	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}

	int calc_num_same(int x) {
		return num_same[root(x)];
	}

	Abel calc_weight(int x) {
		root(x);
		return diff_weight[x];
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y, Abel w) {
		w += calc_weight(x); w -= calc_weight(y);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		diff_weight[y] = w;
		num_same[x] += num_same[y];
		return true;
	}

	Abel diff(int x, int y) {
		return calc_weight(y) - calc_weight(x);
	}

	friend ostream& operator << (ostream& s, UnionFind uf) {
		map<int, vector<int> > res;
		for (int i = 0; i < uf.size_uf; ++i) {
			int r = uf.root(i);
			res[r].push_back(i);
		}
		for (map<int, vector<int> >::iterator it = res.begin(); it != res.end(); ++it) {
			s << endl;
			for (int j = 0; j < (int)it->second.size(); ++j) {
				s << it->second[j] << "(" << uf.calc_weight(it->second[j]) << "), ";
			}
		}
		return s << endl;
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	UnionFind<int> uf(N, 0);
	for (int i = 0; i < M; ++i) {
		int l, r, d;
		cin >> l >> r >> d;
		--l, --r;
		if (uf.issame(l, r)) {
			int diff = uf.diff(l, r);
			if (diff != d) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			uf.merge(l, r, d);
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (ll i = 0; i < n; ++i)
#define forn1(i, n) for (ll i = 1; i <= n; ++i)
#define pb push_back
#define fr first
#define sc second
//#define DEBUG
int main(){
  FastIO;
  #ifdef DEBUG
    freopen("input.txt", "r", stdin);
  #endif
  int a, b;
  cin >> a >> b;
  if (a <= 9 && a >= 1 && b <= 9 && b >= 1){
    cout << a * b << "\n";
    return 0;
  }
  cout << -1 << "\n";
  return 0;
}


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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int n;
string s;

int main() {
  cin>>n;
  REP(i,0,n){
    cin>>s;
    set<string> st;
    REP(k,1,s.size()){
      string train[4];
      train[0] = s.substr(0,k);
      train[1] = s.substr(k,s.size()-k);
      train[2]="", train[3]="";
      REP(j,0,train[0].size()) train[2] += train[0][train[0].size()-1-j];
      REP(j,0,train[1].size()) train[3] += train[1][train[1].size()-1-j];
      REP(ii,0,4){
        REP(jj,0,4){
            if(ii%2 != jj%2) st.insert(train[ii]+train[jj]);
        }
      }
    }
    cout<<st.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3232
n, k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())

ans = 0
for i in range(len(t)):
    tmp = t[i]
    if i >= k:
        if tmp == t[i-k]:
            t[i] = "c"
            continue
    if tmp == "r":
        ans += p
    elif tmp == "s":
        ans += r
    elif tmp == "p":
        ans += s
        
print(ans)

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

using namespace std;

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unite(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 same(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)];
    }
};

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> L(N);
    for (auto& v : L) {
        int K;
        cin >> K;
        v.resize(K);
        for (auto& x : v) {
            cin >> x;
            --x;
        }
    }

    UnionFind u(N);
    vector<vector<int>> v(M);
    for (int i = 0; i < N; ++i) {
        for (auto x : L[i]) {
            if (v[x].empty()) {
                v[x].push_back(i);
            }
            else {
                u.unite(v[x][0], i);
            }
        }
    }
    if (u.size(0) == N) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 8448
#include<set>
#include <unordered_set>
#include <unordered_map>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <string.h>

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%I64d",&x)
#define mod 1000000007
#define eps 1e-6
#define infi 1e9
#define infll 1e18
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

string a,b;

int main(){
    
    cin>>a>>b;
    if(sz(a) != sz(b)) {
        cout<<(sz(a) > sz(b) ?"GREATER":"LESS")<<endl;
        return 0;
    }
    
    lp(i, 0, sz(a)-1) if(a[i] != b[i]) {
        cout<<(a[i] > b[i] ?"GREATER":"LESS")<<endl;
        return 0;
    }
    
    cout<<"EQUAL\n";
    return 0;
}
/*
 abcda
 
 */

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;

signed main(){
    string s;
    cin >> s;
    if (s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3])
    {
        cout << "No" << endl;
        return 0;
    }   

    vi num(4,0);

    rep(i,4)
    {
        for(int j=i+1;j<4;j++)
        {
            num[i]=1;
            if(s[i]==s[j])
            {
                num[j]=1;
                if(num[0]&&num[1])
                {
                    if(s[2]==s[3])
                    {
                        cout << "Yes" << endl;
                        return 0;
                    }
                }
                if(num[1]&&num[2])
                {
                    
                    if(s[0]==s[3])
                    {
                        cout << "Yes" << endl;
                        return 0;
                    }
                }
                if(num[2]&&num[3])
                {
                    
                    if(s[1]==s[0])
                    {
                        cout << "Yes" << endl;
                        return 0;
                    }
                }
                if(num[3]&&num[0])
                {
                    
                    if(s[2]==s[1])
                    {
                        cout << "Yes" << endl;
                        return 0;
                    }
                }
                if(num[0]&&num[2])
                {
                    
                    if(s[1]==s[3])
                    {
                        cout << "Yes" << endl;
                        return 0;
                    }
                }
                if(num[1]&&num[3])
                {
                    
                    if(s[2]==s[0])
                    {
                        cout << "Yes" << endl;
                        return 0;
                    }
                }
                num[j]=0;
            }
            num[i]=0;
        }  
    }
    cout << "No" << endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;

int n;
pll x[200100];

ll mn[200200];
ll mx[200200];
ll mn1[200200];

int main(){
    cin>>n;
    for(int i=0 ; i<n ;i ++){
        scanf("%lld%lld",&x[i].fr,&x[i].sc);
        if(x[i].fr < x[i].sc)
            swap(x[i].fr,x[i].sc);
    }
    sort(x,x+n);
    reverse(x,x+n);
    mn[0] = x[0].sc;
    mx[0] = x[0].sc;
    for(int i=1;i <n ;i ++){
        mn[i] = min(mn[i-1],x[i].sc);
        mx[i] = max(mx[i-1],x[i].sc);
    }
    mn1[n-1] = x[n-1].sc;
    for(int i=n-2; i>=0 ; i--){
        mn1[i] = min(mn1[i+1],x[i].sc);
    }
    mn[n] = 1e18;
    ll r= (x[n-1].fr-x[0].fr)*(mn[n-1]-mx[n-1]);
    for(int i=1 ; i<n ;i ++){
        ll rmx2 = max(mx[i-1],x[i].fr);
        ll rmn2 = min(mn[i-1],mn1[i+1]);
        rmn2 = min(rmn2,x[i].fr);
        ll rmx1 = x[0].fr;
        ll rmn1 = min(x[n-1].fr,x[i].sc);
        r = min(r,(rmx2-rmn2)*(rmx1-rmn1));
    }
    for(int i=1 ; i<n ;i ++){
        ll rmx2 = max(mx[i-1],x[i].fr);
        ll rmn2 = min(mn[i-1],x[n-1].fr);
        ll rmx1 = x[0].fr;
        ll rmn1 = min(mn[n-1],x[i].sc);
        r = min(r,(rmx2-rmn2)*(rmx1-rmn1));
    }
    cout<<r<<endl;

    return 0;
}


Measured memory_bytes: 8064
#include <cstdio>
#include <cmath>
#include  <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
int n;
bool cmp(LL x, LL y){
	return x > y;
}
long long a[1000005], sum;
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= 3 * n; i++) scanf("%lld", &a[i]);
	sort(a + 1, a + 3 * n + 1, cmp);
	int ans = 2;
	for(int i = 1; i <= n; i++){
		sum += a[ans];
		ans += 2;
	}
	printf("%lld", sum);
}


Measured memory_bytes: 4224
yoko1 = gets.chomp.split(" ").map(&:to_i)
yoko2 = gets.chomp.split(" ").map(&:to_i)
yoko3 = gets.chomp.split(" ").map(&:to_i)
n = gets.chomp.to_i
list1 = Array.new()
n.times do
  list1 << gets.chomp.to_i
end
tate1 = [yoko1[0],yoko2[0],yoko3[0]]
tate2 = [yoko1[1],yoko2[1],yoko3[1]]
tate3 = [yoko1[2],yoko2[2],yoko3[2]]
naname1 = [yoko1[0],yoko2[1],yoko3[2]]
naname2 = [yoko1[2],yoko2[1],yoko3[0]]
def bingo_check(ary,lista)
  ary.all?{|elem| lista.include?(elem)}
end

if bingo_check(yoko1,list1) or bingo_check(yoko2,list1) or bingo_check(yoko3,list1) or bingo_check(tate1,list1) or bingo_check(tate2,list1) or bingo_check(tate3,list1) or bingo_check(naname1,list1) or bingo_check(naname2,list1)
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define POWT(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;


int main() {
	set<int> c;
	REP(i, 3) {
		int a;
		scanf("%d", &a);
		c.insert(a);
	}
	printf("%d\n", c.size());
	return 0;
}

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

int main()
{
    int x;
    int sum = 0;
    rep(i,5){
        cin >> x;
        sum += x;
    }
    cout << (15-sum) << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const int maxn = 2000 + 5;
const ll oo = 0x1000000000000000LL;
int N, M;
ll d1, d2;

int main()
{
	while (cin >> N >> M)
	{
		vector<int>a(M);
		vector<int>b(M);
		vector<ll>c(M);
		for (int i = 0; i < M; i++)
		{
			cin >> a[i] >> b[i] >> c[i];
			a[i]--,	b[i]--;
		}
		vector<ll>d(N, -oo);
		d[0] = 0LL;
		for (int i = 0; i < 2 * N; i++)
		{
			for (int j = 0; j < M; j++)
			{
				d[b[j]] = max(d[b[j]], d[a[j]] + c[j]);
			}
			if (i == N - 1)
				d1 = d[N - 1];
			if (i == 2 * N - 1)
				d2 = d[N - 1];
		}
		if (d1 == d2)
			cout << d1 << endl;
		else
			cout << "inf" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  vector<set<int>> X(26);
  rep(i,S.size()) X[S[i]-'a'].insert(i+1);
  int Q;
  cin>>Q;
  rep(qwe,Q){
    int M;
    cin>>M;
    if(M==1){
      int P;
      cin>>P;
      char C;
      cin>>C;
      X[S[P-1]-'a'].erase(P);
      S[P-1]=C;
      X[S[P-1]-'a'].insert(P);
    }else{
      int L,R;
      cin>>L>>R;
      int cnt=0;
      rep(i,26){
        if(X[i].size()==0) continue;
        auto itr=X[i].lb(L);
        if(itr!=X[i].end()) if(*itr<=R) cnt++;
      }
      cout<<cnt<<endl;
    }
  }
}

Measured memory_bytes: 24196
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
    cin>>n;
    int a[n],d=0;
    for(int i=0;i<n;i++)    cin>>a[i];
    sort(a,a+n);
    d=fabs(a[0]-a[n-1]);
    cout<<d<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

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


ull E = 1000000007;

int main() {
    int x = 0;
    int N;
    string S;
    cin >> N;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'I') {
            ++x;
        } else {
            --x;
        }
        ans = max(ans, x);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	
	public static final int MAX = 30000;
	public static final int SQRT = (int)(Math.ceil(Math.sqrt(MAX)));
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		boolean[] is_prime = new boolean[MAX + 1];
		int[] primes = new int[MAX];
		int prime_count = 0;
		Arrays.fill(is_prime, 2, MAX + 1, true);
		for(int i = 2; i <= MAX; i++){
			if(is_prime[i]){
				primes[prime_count] = i;
				prime_count++;
				
				for(int j = i * 2; j <= MAX; j += i){
					is_prime[j] = false;
				}			
			}
		}
		
		long[] count = new long[MAX + 1];
		for(int fst = 0; fst < prime_count; fst++){
			final int fst_num = primes[fst];
			for(int snd = fst; snd < prime_count; snd++){
				final int snd_num = primes[snd];
				if(fst_num + snd_num > MAX){ break; }
				
				for(int thd = snd; thd < prime_count; thd++){
					final int thd_num = primes[thd];
					if(fst_num + snd_num + thd_num > MAX){ break; }
					else if(thd_num >= snd_num + fst_num){ continue; }
					
					//System.out.println(fst_num + " " + snd_num + " " + thd_num);
					count[fst_num + snd_num + thd_num]++;
				}
			}
		}
		
		while (true) {

			final int T = sc.nextInt();
			
			if(T == 0){ break; }
			
			System.out.println(count[T]);
			
		}

	}
}

Measured memory_bytes: 23460
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    mat c(3, vec(3));
    rep(i, 3) rep(j, 3) cin >> c[i][j];

    bool f = false;

    for (int a1 = 0; a1 <= 100; a1++) {
        for (int a2 = 0; a2 <= 100; a2++) {
            for (int a3 = 0; a3 <= 100; a3++) {
                bool f2 = true;

                rep(j, 3) {
                    if (!(c[0][j] - a1 == c[1][j] - a2 && c[1][j] - a2 == c[2][j] - a3)) {
                        f2 = false;
                    }
                }

                if (f2) f = true;
            }
        }
    }

    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N, M;
	getval(N, M);

	LLONG K;
	getval(K);

	std::vector<LLONG> aiSum(N + 1, 0), biSum(M + 1, 0);
	for (int i = 1; i <= N; i++) {
		int ai;
		getval(ai);
		aiSum[i] = aiSum[i - 1] + ai;
	}
	for (int i = 1; i <= M; i++) {
		int bi;
		getval(bi);
		biSum[i] = biSum[i - 1] + bi;
	}

	int maxBook = 0;
	for (int i = 0; i <= N; i++) {
		if (aiSum[i] <= K) {
			maxBook = std::max(maxBook, i);

			LLONG targ = K - aiSum[i];
			auto bi = std::upper_bound(biSum.begin(), biSum.end(), targ);
			bi--;
			int bIdx = bi - biSum.begin();
			maxBook = std::max(maxBook, i + bIdx);
		}
	}
	printf("%d\n", maxBook);
}


Measured memory_bytes: 6404
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << "-->" << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
    #define mod 998244353
 
#define fi first
#define se second

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1, s2;
    cin >> s1 >> s2;
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    if(s==s1)
        a--;
        else
        {
            b--;
        }
        cout << a << " " << b;

}

Measured memory_bytes: 256
m,d=map(int,input().split())


cnt=0
for i in range(1,m+1):
    for j in range(22,d+1):
        dta=str(j)
        d1=int(dta[1])
        d10=int(dta[0])
        if d1>=2 and i==d1*d10:
            cnt=cnt+1

print(cnt)

Measured memory_bytes: 40048
from bisect import bisect_left
#from functools import lru_cache

#@lru_cache(maxsize=None)
def index(a, x):
    ''' Locate the leftmost value exactly equal to x
    http: // docs.python.jp / 3.5 / library / bisect.html
    '''
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    raise ValueError


if __name__ == '__main__':
    # ??????????????\???
    # S = [1, 2, 3, 4, 5]
    # T = [3, 4, 1]
    num = int(input())
    S = tuple(int(x) for x in input().split(' '))
    num = int(input())
    T = [int(x) for x in input().split(' ')]

    # ????´¢??????
    found = 0
    for t in T:
        try:
            index(S, t)
        except ValueError:
            pass
        else:
            found += 1

    # ???????????????
    print(found)

Measured memory_bytes: 19008
#include <stdio.h>
#include <math.h>
#define N_MAX 50021 /*50000æèå«¢Å¬Ìf*/

int main(void){
	/* eratosthenes */
	char a[N_MAX+1]; int i, j;
	a[0]=0, a[1]=0; for(i=2; i<=N_MAX; i++) a[i]=1;
	for(i=2; i<=(int)sqrt(N_MAX); i++)
		if(a[i]!=0) for(j=2*i; j<=N_MAX; j+=i) a[j]=0;
	
	while(scanf("%d",&i)==1){
		j=i;
		while(1)
			if(a[--i]==1){ printf("%d ",i); break; }
		while(1)
			if(a[++j]==1){ printf("%d\n",j); break; }
	}
	
	return 0;
}

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

int main() {
	int n,x;
	vector<int> h;
	while(cin >> n){
	vector<int>::iterator it=h.begin();
		if(n==0)
		break;
		n+=1;
		int ans=0;
		for(int i=0;i<n;i++){
		cin >> x;
		h.push_back(x);
		}
		for(it=h.begin();it!=h.end();it++){
			x=*it;
			it=h.erase(it);
			for(int j=2;j<n-1;j++){
				if(h[j]-h[j-1]!=h[j-1]-h[j-2])
				break;
				if(j==n-2)
				ans = x;
			}
			h.insert(it,x);
		}
		cout << ans << endl;
		h.clear();
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
 
using namespace std;
 
int solve(vector<int> &a)
{
    int N = a.size();
    const int p[] = {5, 7, 5, 7, 7};
    for (int i = 0; i < N; i++) {
        bool poss = 1;
        int q = i;
        for (int j = 0; j < 5; j++) {
            int sum = 0;
            for (; q < N; ) {
                sum += a[q++];
                if (sum >= p[j]) break;
            }
            if (sum != p[j]) {
                poss = 0;
                break;
            }               
        }
        if (poss) {
            return i + 1;
        }
    }
    return -1;
}
 
int main()
{
    int N;
    while (cin >> N, N) {
        vector<int> a(N);
        string s;
        for (int i = 0; i < N; i++) {
            cin >> s;
            a[i] = s.size();
        }
        cout << solve(a) << endl;
    }
    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
using namespace std;
int g[101][102],ch[101][2]={0},kh;

int dfs(int k,int n){
  ch[n][0]=k;
  //cout<<k<<n<<"<--"<<endl;/////////
  for(int i=1;i<=g[n][0];i++){
    if(ch[g[n][i]][0]==0){
      k=dfs(k+1,g[n][i]);
    }
  }
  ch[n][1]=k+1;
  kh=k+1;
  return k+1;
}

int main(){
  int a,b,c,d;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b>>c;
    g[b][0]=c;
    for(int j=1;j<=c;j++){
      cin>>d;
      g[b][j]=d;
    }
  }
  kh=0;
  for(int i=1;i<=a;i++){
    if(ch[i][0]==0){
      //cout<<i<<"<--"<<endl;////////
      dfs(kh+1,i);
    }
  }
  
  for(int i=1;i<=a;i++){
    cout<<i<<" "<<ch[i][0]<<" "<<ch[i][1]<<endl;
    
  }
  return 0;
}

Measured memory_bytes: 1204
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
{
	cout << *it << " = " << a;
	nl;
	err(++it, args...);
}
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
string s;
cin>>s;
if(n%2==1)
{
    cout<<"No";
    return ;
}
for(int i=0;i<n/2;i++)
{
    if(s[i]!=s[i+n/2])
    {
        cout<<"No";
        return ;
    }
}
cout<<"Yes";






return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int A, B;
    string S;
    cin >> A >> B >> S;
    bool f = true;
    for(int i=0; i<S.size(); ++i){
        if(i == A){
            if(S[i]!='-') f&=0;
        }
        else{
            if(!isdigit(S[i])) f&=0;
        }
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main() {
	int n, l; cin >> n >> l;
	vector<string> s(n);
	for (int i = 0; i < n; i++) cin >> s[i];
	sort(s.begin(), s.end());
	for (auto x : s) {
		cout << x;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		
		int[][] grid = new int[3][3];
		
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				grid[i][j] = scan.nextInt();
			}
		}
		
		int n = scan.nextInt();
		
		for (int nums = 0; nums < n; nums++) {
			int b = scan.nextInt();
			
			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < 3; j++) {
					if (grid[i][j] == b) {
						grid[i][j] = 0;
					}
				}
			}
		}
		
		boolean check = false;
		
		for (int i = 0; i < grid.length; i++) {
			int cnt = 0;
			int cntcol = 0;
			for (int j = 0; j < grid[0].length; j++) {
				if (grid[i][j] == 0) cnt++;
				if (grid[j][i] == 0) cntcol++;
			}
			if (cnt == 3) check = true;
			if (cntcol == 3) check = true;
		}
		
		if ((grid[0][0] == 0 && grid[1][1] == 0 && grid[2][2] == 0) || (grid[0][2] == 0 && grid[1][1] == 0 && grid[2][0] == 0)) {
			check = true;
		}
		
		if (check) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		
	}

}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

#define MAX_V 110
#define INF 1<<29

struct edge { int to, cap, rev; };

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, int cap) {
  G[from].push_back((edge){to, cap, (int)G[to].size()});
  G[to].push_back((edge){from, 0, (int)G[from].size()});
}

void bfs(int source) {
  memset(level, -1, sizeof(level));
  queue<int> que;
  que.push(source);
  level[source] = 0;
  while (!que.empty()) {
    int v = que.front(); que.pop();
    for (int i = 0; i < (int)G[v].size(); i++) {
      edge &e = G[v][i];
      if (e.cap > 0 && level[e.to] < 0) {
	level[e.to] = level[v] + 1;
	que.push(e.to);
      }
    }
  }
}

int dfs(int v, int sink, int flow) {
  if (v == sink) return flow;
  for (int &i = iter[v]; i < (int)G[v].size(); i++) {
    edge &e = G[v][i];
    if (e.cap > 0 && level[v] < level[e.to]) {
      int d = dfs(e.to, sink, min(e.cap, flow));
      if (d > 0) {
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

int dinic_max_flow(int source, int sink) {
  int flow = 0;
  while (true) {
    bfs(source);
    if (level[sink] < 0) return flow;
    memset(iter, 0, sizeof(iter));
    int f;
    while ((f = dfs(source, sink, INF)) > 0) {
      flow += f;
    }
  }
}


int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int V, E;
  cin >> V >> E;
  REP(i, E) {
    int u, v, c;
    cin >> u >> v >> c;
    add_edge(u, v, c);
  }
  cout << dinic_max_flow(0, V-1) << endl;  
  return 0;
}

Measured memory_bytes: 3256
n = gets.to_i
x, l = n.times.map{gets.split.map(&:to_i)}.transpose
count = 1
ary = n.times.map{|i| [x[i]-l[i], x[i]+l[i]]}.sort
(n-1).times do |i|
  if ary[i][1] <= ary[i+1][0]
    count+=1
  elsif ary[i][1] < ary[i+1][1]
    ary[i+1][1] = ary[i][1]
  end
end
puts count

Measured memory_bytes: 14896
#! cat input | python3 main.py
def debug():
    for X in field[size//2:] + field[:size//2]:
        print(X[size//2:], X[:size//2])

dice_data = [[],
        [4, 2, 3, 5],
        [4, 6, 3, 1],
        [6, 5, 1, 2],
        [1, 5, 6, 2],
        [4, 1, 3, 6],
        [4, 5, 3, 2],
        ]
def dice(t, f):
    i = dice_data[t].index(f)
    return [dice_data[t][x%4] for x in range(i, i + 4)]

size = 6
move = [[-1, 0], [0, 1], [1, 0], [0, -1]]

def drop(t, f, nowl, nowr):
    target = list(map(lambda x: x > 3, dice(t, f)))
    now = [nowl, nowr]
    
    now_field = field[now[0]][now[1]]
    for i, tg in enumerate(target):
        if tg:
            nb_field = field[now[0] + move[i][0]][now[1] + move[i][1]]
            if nb_field[1] >= now_field[1]:
                target[i] = False
    for i, v in sorted(enumerate(dice(t, f)), key=lambda x: x[1], reverse=True):
        if target[i]:
            if i == 0:
                f = t
            elif i == 2:
                f = 7 - t
            t = 7 - v
            drop(t, f, now[0] + move[i][0], now[1] + move[i][1])
            break
    else:
        change = field[now[0]][now[1]]
        change[0] = t
        change[1] += 1

while True:
    n = int(input())
    if not n: break
    field = [[[0, 0] for i in range(size)] for j in range(size)]

    tfs = [list(map(int, input().split())) for x in range(n)]
    for t, f in tfs:
        drop(t, f, 0, 0)
    cnt = [0 for x in range(7)]
    for row in field:
        for cell in row:
            cnt[cell[0]] += 1
    print(*cnt[1:])

Measured memory_bytes: 7844
import java.util.Scanner;

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


    if(A % 2 == B % 2){
      for(int K = 1;K<1000000000;K++){
        int a = Math.abs(A-K);
        int b = Math.abs(B-K);
        if(a == b){
          System.out.println(K);
          break;
        }
      }
    }else{
      System.out.println("IMPOSSIBLE");
    }
  }

}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
	int n, k;
	cin >> n >> k;
    ll ans = 0;
    for (int b = k+1; b <= n; b++) {
        ans += (ll)n/b*(b-k) + max(n%b-k+1, 0);
    }
    if (k==0) ans = (ll)n*n;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] v = new int[2][2 * N];
		for (int i = 0; i < 2 * N; ++i) {
			v[0][i] = i + 1;
		}
		int p = 1;
		for (int i = 0; i < M; ++i) {
			int q = sc.nextInt();
			if (q == 0) {
				for (int j = 0; j < N; ++j) {
					v[p][2 * j] = v[1 - p][j];
					v[p][2 * j + 1] = v[1 - p][N + j];
				}
			} else {
				for (int j = 0; j < 2 * N - q; ++j) {
					v[p][j] = v[1 - p][j + q];
				}
				for (int j = 0; j < q; ++j) {
					v[p][2 * N - q + j] = v[1 - p][j];
				}
			}
			p = 1 - p;
		}
		for (int i = 0; i < 2 * N; ++i) {
			System.out.println(v[1 - p][i]);
		}
	}
}

Measured memory_bytes: 12000
#include<stdio.h>

int main(void)

{
    int a,s;
    
    scanf("%d",&a);
    
    scanf("%d",&s);
    
    if(a<s){
        printf("a < b\n");
    }
    
    if(a>s){
        printf("a > b\n");
    }
    
    if(a==s){
        printf("a == b\n");
    }

    return 0;
}


Measured memory_bytes: 2060
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include <cstdio>

#include <algorithm>
#define ll long long
#define mx 9*1000000000LL*1000000000

using namespace std;
    int n,a,b;
int main(){
    cin>>n>>a>>b;	
    vector<ll> x(n);
    for(int i=0; i<n; i++)scanf("%lld", &x[i]);
    ll res=0;
    for(int i=1; i<n; i++){
	ll tmp = (x[i]-x[i-1])*a;
	if(tmp<b)res+=tmp; else res+=b;
    }
    cout<<res;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 200010

ll L;
vector<ll> A;

ll dp[MAX_N][5];

// i 番目を見ていて、現在の状態が state のときの最小値
// 0: 何もしない
// 1: 2 以上の偶数は 0
// 2: 奇数は 0
// 3: 2 以上の偶数は 0
// 4: 何もしない
ll dfs(ll i, ll state) {
    if(i >= L) { return 0; }

    ll& ret = dp[i][state];
    if(~ret) { return ret; }
    ret = LLINF;

    ll cost = 0;
    if(state == 0 || state == 4) {
        cost = A[i];
    }
    else if(state == 1 || state == 3) {
        if(A[i] == 0) { cost = 2; }
        else if(A[i] % 2 != 0) { cost = 1; }
    }
    else {
        if(A[i] % 2 == 0) { cost = 1; }
    }
    for(int j = 0; j + state < 5; ++j) {
        ret = min(ret, dfs(i + 1, state + j) + cost);
    }
    return ret;

}

ll solve() {
    MINUS(dp);
    return min({dfs(0, 0), dfs(0, 1), dfs(0, 2), dfs(0, 3), dfs(0, 4)});
}

signed main()
{
    cin >> L;
    A.resize(L);
    REP(i, L) { cin >> A[i]; }
    ll ans = solve();
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 18944
import math
import heapq

N, M = map(int, input().split())
tempA = list(map(int, input().split()))
A = []
for a in tempA:
    heapq.heappush(A, a * - 1)
for i in range(M):
    minNum = heapq.heappop(A)
    heapq.heappush(A, (minNum * -1 // 2) * - 1)
print(sum(A) * -1)


Measured memory_bytes: 14380
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int q;
    cin >> q;
    while (q--) {
        int b, m ,e;
        cin >> b >> m >> e;
        rotate(a.begin() + b, a.begin() + m, a.begin() + e);
    }
    rep(i, n) cout << a[i] << (i == n-1 ? '\n' : ' ');
}



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

using namespace std;

int main(){
    int n,k;int64_t ans = 0;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0;i < n;i++)cin >> h[i];
    sort(h.begin(),h.end(),greater<int>());
    for(int i = k;i < n;i++)ans += h[i];
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
flg = 0

for i in range(1, 10, 1):
  if flg==1:
    break
  for j in range(1, 10, 1):
    if i*j==N:
      print("Yes")
      flg= 1
      break
    
      
if flg==0:
  print("No")
      





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

int main ()
{
	long long a;
	long long b;
	long long c;
	cin >> a >> b >> c;
	if (a >= b && a >= c){
		if (a % 2 == 0) { 
			cout << '0';
		}
		else cout << b* c;
	}
	else if (b >= a && b >= c){
		if (b % 2 == 0) { 
			cout << '0';
		}
		else cout << a* c;
	}
	else if (c >= b && c >= a){
		if (c % 2 == 0) { 
			cout << '0';
		}
		else cout << b* a;
	}


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
  int N;
  cin >> N;
  
  pair<int,int> xy[50];

  for(int i=0; i<N; i++){
    cin >> xy[i].first >> xy[i].second;
  }

  map<pair<int,int>, int > m; // (p,q)
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(i==j)continue;

      pair<int,int> pq= make_pair(xy[i].first-xy[j].first, xy[i].second-xy[j].second);

      if(m.count(pq)==0){
	m[pq]=1;
      }else{
	m[pq]++;
      }
      
    }
  }

  int maximam=0;
  for(auto x : m){
    maximam=max(maximam,x.second);
  }

  cout<< N-maximam << endl;
  return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char>> hw(h, vector<char>(w));
    int reach_cnt[h][w];
    queue<pair<int, int>> que;
    rep(i, h) rep(j, w) {
        cin >> hw[i][j];
        reach_cnt[i][j] = -1;
        if ( hw[i][j] == '#' ) {
            que.push(make_pair(i, j));
            reach_cnt[i][j] = 0;
        }
    }
    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, 1, -1};
    int ans = 0;
    while(!que.empty()) {
        int size = que.size();
//        cout << "size " << size << endl;
        rep(rj, size) {
            pair<int, int> now_p = que.front();
            que.pop();
            rep(ri, 4) {
                int next_y = now_p.first + dy[ri];
                int next_x = now_p.second + dx[ri];
                if ( next_y >= h || next_y < 0 || next_x >= w || next_x < 0 ) {
                    continue;
                }
                if ( reach_cnt[next_y][next_x] != -1 ) {
                    continue;
                }
                reach_cnt[next_y][next_x] = reach_cnt[now_p.first][now_p.second] + 1;
//                cout << "test" << endl;
//                hw[next_y][next_x] = '#';
                que.push(make_pair(next_y, next_x));
                ans = max(ans, reach_cnt[next_y][next_x]);
            }
        }
//        bool end_flg = 1;
//        rep(i, h) {
//            rep(j, w) {
////                cout << hw[i][j];
////                cout << reach_flg[i][j] << " ";
//                if ( reach_cnt[i][j] == -1 ) {
//                    end_flg = 0;
//                }
//            }
//            cout << endl;
//        }
//        if ( end_flg ) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13328
#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX_N 100005

using namespace std;

int n;
int a[MAX_N];
int cnt[3];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(!(a[i]%4)) cnt[2]++;
		else if(!(a[i]&1)) cnt[1]++;
		else cnt[0]++;
	}
	int res=cnt[1] ? cnt[2] : cnt[2]+1;
	printf("%s\n",cnt[0]<=res ? "Yes" : "No");
}


Measured memory_bytes: 640
function Main(input){
	input = input.split("\n");
	var sum = 0;
	var now = 1;
	var arr = input[1].split(" ");
	arr.push("#");
	for(var i=1;i<arr.length;i++){
		if(arr[i]==arr[i-1]) now++;
		else{
			sum += Math.ceil((now-1)/2);
			now = 1;
		}
	}
	console.log(sum)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21064
def main():
    N = int(input())
    h = 0
    for _ in range(N - 1):
        u, v = map(int, input().split())
        if u > v:
            u, v = v, u
        h += u * (N + 1 - v)

    return N * (N + 1) * (N + 2) // 6 - h

print(main())


Measured memory_bytes: 9136
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#define ll long long
#define MOD(x) ((x)>=mod?(x)-mod:(x))
using namespace std;
const int maxn=5010, inf=1e9, mod=1e9+7;
struct edge{int too, pre;}e[maxn<<1];
int n, tot, x, y;
int last[maxn], size[maxn], f[maxn][maxn], g[maxn], tmp[maxn];

template<typename T>
inline void read(T &k)
{
	int f=1; k=0; char c=getchar();
	while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
	while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
	k*=f;
}

inline void add(int x, int y){e[++tot]=(edge){y, last[x]}; last[x]=tot;}

void dfs(int x, int fa)
{
	size[x]=1; f[x][1]=1;
	for(int i=last[x], too;i;i=e[i].pre)
	if((too=e[i].too)!=fa)
	{
		dfs(too, x);
		for(int j=1;j<=size[x]+size[too];j++) tmp[j]=0;
		for(int j=1;j<=size[x];j++)
		{
			for(int k=0;k<=size[too];k++)
			tmp[j+k]=(tmp[j+k]+1ll*f[x][j]*f[too][k])%mod;
		}
		for(int j=1;j<=size[x]+size[too];j++) f[x][j]=tmp[j];
		size[x]+=size[too];
	}
	for(int j=2;j<=size[x];j+=2)
	f[x][0]-=1ll*f[x][j]*g[j]%mod, f[x][0]=MOD(f[x][0]+mod);
}

int main()
{
	read(n);
	for(int i=1;i<n;i++) read(x), read(y), add(x, y), add(y, x);
	g[0]=1; for(int i=2;i<=n;i+=2) g[i]=1ll*g[i-2]*(i-1)%mod;
	dfs(1, 0);
	printf("%d\n", mod-f[1][0]);
}

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

int main() {
	int n, x, y;
	cin >> n;
	vector<pair<long long, long long> > a;
	for(int i = 0; i < n; i++) {
		cin >> x >> y;
		a.push_back({x, y});
	}
	sort(a.begin(), a.end());
	int ans = n;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			int dx = a[i].first - a[j].first;
			int dy = a[i].second - a[j].second;
			map<pair<long long, long long>, bool> mp;
			int cnt = 0;
			for(int k = 0; k < n; k++) {
				int px = a[k].first + dx;
				int py = a[k].second + dy;
				if(mp[{px, py}] == false || (dx == 0 && dy == 0)) {
					cnt++;
				}
				mp[a[k]] = true;
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int,input().split()))
a = [0] * m
b = [0] * m
for i in range(m):
    a[i],b[i] = map(int,input().split())
ans = [1]*n
for i in range(m):
    if h[a[i]-1]==h[b[i]-1]:
        ans[a[i]-1] = 0
        ans[b[i]-1] = 0
    elif h[a[i]-1]>h[b[i]-1]:
        ans[b[i]-1] = 0
    elif h[a[i]-1]<h[b[i]-1]:
        ans[a[i]-1] = 0
print(sum(ans))

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A;
  cin >> N ;
 
  for (int i = 0; i < N+1; i++) {
    cin >>  A;
    if (A%2==0 && A%6!=0 && A%10!=0){
      cout << "DENIED" << endl ;
      break ;
    }
    else if (i==N) {
      cout << "APPROVED" << endl ;
    }
    else if(A%2!=0) {
    }
    else if(A%2==0 && A%6 ==0){
    }
    else if (A%2==0 && A%10 == 0){
    }
    
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

void solve(string s, vector<char> t, ll i, ll sum)
{
    if (i == 4)
    {
        if (sum == 7)
        {
            cout << s[0] << t[0] << s[1] << t[1] << s[2] << t[2] << s[3] << "=7" << endl;
            exit(0);
        }
        else{
            return;
        }
    }

    t.push_back('+');
    solve(s, t, i + 1, sum + (s[i] - 48));
    t[i - 1] = '-';
    solve(s, t, i + 1, sum - (s[i] - 48));
}

int main(int argc, char const *argv[])
{
    string s;
    vector<char> t;
    cin >> s;
    solve(s, t, 1, s[0] - 48);
}


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

int main(){
    
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    int ans = 0;
    rep(i,n){
        ans = a[ans];
        if(ans==1){
            cout << i+1<< endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
    
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int d, n;
int main() {
   cin >> d >> n;
   if (d==2 && n==100) {cout << 1010000; return 0;}
   cout << (n!=100 ? n*pow(100, d) : 101*pow(100,d));  
}

Measured memory_bytes: 3884