akhauriyash/Code-Regression huggingface dataset:
s = [list(input()) for _ in range(3)]

n_row = 0

dic = {0:"A",1:"B",2:"C"}
s_fix = {"a":0,"b":1,"c":2}

while len(s[n_row]):    
    n_row = s_fix[s[n_row].pop(0)] 

print(dic[n_row])

Measured memory_bytes: 8944
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>

typedef long ELEM;      //???????????????????´???????
#define STACK_SIZE 100  //?????????????????§??????

void error(char *s);
void init();
void push(ELEM x);
ELEM pop();
int empty();

ELEM stack[STACK_SIZE]; //?????????????????????
int n;                  //???????????????????????????

int main(void)
{
    int c;
    long x, a, b;

    init();
    while ((c = getchar()) != EOF) {
        if (isdigit(c)) {
            ungetc(c, stdin);
            scanf("%ld", &x);
            push(x);
        } else {
            switch (c) {
                case '+':
                    b = pop();
                    a = pop();
                    push(a+b);
                    break;
                case '-':
                    b = pop();
                    a = pop();
                    push(a-b);
                    break;
                case '*':
                    b = pop();
                    a = pop();
                    push(a*b);
                    break;
                case '/':
                    b = pop();
                    a = pop();
                    push(a/b);
                    break;
                case '\n':
                    if (! empty()) {
                        //printf("?????????%ld??§??????\n", pop());
                        printf("%ld\n", pop());
                        return 0;
                    }
                    init();
                    break;
                case ' ':
                case '\t':
                    break;
                default:
                    printf("?????£??????????????????????????????\n");
                    printf("??\?????????????????????????????????\n");
                    while ((c=getchar()) != EOF && c != '\n')
                        ;
                    break;
            }
        }
    }
}

void error(char *s)
{
    fprintf(stderr, s);
    exit(1);
}

void init()
{
    n = 0;
}

void push(ELEM x)
{
    if (n >= STACK_SIZE)
        error("stack overflow\n");
    stack[n++] = x;
}

ELEM pop()
{
    if (n <= 0)
        error("stack underflow\n");
    return stack[--n];
}

int empty()
{
    return n==0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
#include <iostream>
typedef long long ll;
using namespace std;
#define maxn 200005
char a[8];
int main()
{
    ll n,k,mau=0,mad=0,mal=0,mar=0,d=0,l=0,r=0,u=0,m=0,i,j,ans=0,t;
    scanf("%lld",&n);
    if(n>=500)
    {
        t=n%500;
        ans+=n/500*1000;
        n=n%500;
        if(n>=5)
        {
            t=n%5;
            ans+=n/5*5;
        }
    }
    else
    {
        if(n>=5)
        {
            t=n%5;
            ans+=n/5*5;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#Educational DP Contest
#D-Knapsack1

#n = int(input())
N,W = map(int,input().split())
#lst1 = list(map(int,input().split()))

#dp table
#内側が重さw,外側がその品物をいれるかどうかのループを作る
#いきなりループに入れるように、内外共に0配列を余分に用意する
dp = [[0]*(W+1) for _ in range(N+1)]

#process1
for i in range(1,N+1):
    w,v = map(int,input().split())
    for j in range(1,W+1):
        if w > j: #入らないなら
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v)


#output process
print(dp[-1][-1])

Measured memory_bytes: 119916
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;

int main() {
  ll X, Y;
  cin >> X >> Y;
  ll result = 1;
  ll num = X;
  while (true) {
    num *= 2;
    if (num <= Y) {
      ++result;
    } else {
      break;
    }
  }
  cout << result << endl;
}

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

const int MAXN = 100 + 10, MAXK = 1e5 + 10, P = 1e9 + 7;

int n, k, a[MAXN], f[MAXN][MAXK], suf[MAXN][MAXK];

int sub(int a, int b) { return (a - b) < 0 ? a - b + P : a - b; }
int add(int a, int b) { return (a + b) > P ? a + b - P : a + b; }

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    f[0][0] = suf[0][0] = 1;
    for (int i = 1; i <= k; ++i) suf[0][i] = 1;
    for (int i = 1; i <= n; ++i) {
        f[i][0] = 1;
        for (int j = 1; j <= k; ++j) {
            if (j > a[i]) f[i][j] = sub(suf[i - 1][j], suf[i - 1][j - a[i] - 1]);
            else f[i][j] = suf[i - 1][j];
        }
        suf[i][0] = 1;
        for (int j = 1; j <= k; ++j) {
            suf[i][j] = add(suf[i][j - 1], f[i][j]);
        }
    }
    printf("%d", f[n][k]);
    return 0;
}

Measured memory_bytes: 84224
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;




int main(){
	int n,m;
	cin>>n>>m;
	P stu[n];
	rep(i,0,n){
		int a,b;
		cin>>a>>b;
		stu[i]=make_pair(a,b);
	} 
	P che[m];
	int next[n];
	rep(i,0,m){
		int c,d;
		cin>>c>>d;
		che[i]=make_pair(c,d);
	}

	rep(i,0,n){
		ll M=1e9;
		int nex=0;
		rep(k,0,m){
			ll man=abs(stu[i].first-che[k].first)+abs(stu[i].second-che[k].second);
			if(M>man){
				M=man;
				nex=k+1;
			}
		}
		next[i]=nex;
	}

	rep(i,0,n){
		cout<<next[i]<<endl;
	}
}


Measured memory_bytes: 256
class Main {
    public static void main(String[] args) {
    	int[] x = {1,2,3,4,5,6,7,8,9},y = {1,2,3,4,5,6,7,8,9};
    	
    	for(int i=0; i<9; i++) {
    		for(int j=0; j<9; j++) {
    			int ans = x[i] * y[j];
    			System.out.println(x[i] + "x" + y[j] + "=" + ans);
    		}
    	}
    }
}

Measured memory_bytes: 9324
//shara's here
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
int main(){
    int x,y;
    cin>>x>>y;
    if(x>9||y>9){cout<<-1;}
    else cout<<x*y;



















return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

std::vector<ll> fac(510000, 1), finv(510000, 1), inv(510000, 1);

void c4_init(ll m) {
    for (ll i = 2; i < 510000; i++) {
        fac[i] = fac[i - 1] * i % m;
        inv[i] = m - inv[m%i] * (m / i) % m;
        finv[i] = finv[i - 1] * inv[i] % m;
    }
}

ll c4(ll n, ll k, ll m) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % m) % m;
}

signed main() {
  ll p;
  cin>>p;
  vector<ll> a(p-1);
  rep(i,p)
    cin>>a[i];
  c4_init(p);
  vector<ll> b(p-1,0);
  rep(i,p){
    if (a[i] == 0)
      continue;
    (b[0] += 1) %= p;
    ll pw = 1;
    for (ll j=p-1; j>=0; j--) {
      (b[j] += p*p - pw * c4(p-1, j, p)) %= p;
      (pw *= p-i) %= p;
    }
  }
  rep(i,p){
    cout<<b[i]<<(i!=p-1 ? " ":"");
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

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

    int mini=p[0];
    int cnt=1;
    for(int i=1; i<n; i++){
        if(mini>p[i]){
            cnt++;
            mini=p[i];
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.matches("[A-Z]")){
            System.out.println("A");
        }else{
            System.out.println("a");
        }
    }
}

Measured memory_bytes: 35592
#include <iostream>
#include <map>
#include <cstring>
using namespace std;

const int size = 300;
int G[size][size];
int C[size];
map <int, int> M;
int M_index;
bool flag;

void set_index( int a ) 
{
  if ( M.find( a ) != M.end() ) return;
  M[a] = M_index; 
  M_index++;
}

void init()
{
  memset( G, 0, sizeof(G) );
  memset( C, 0, sizeof(C) );
  M.clear();
  flag = false;
}

int main( void ) 
{
  int a, b;
  flag = true;
  while ( cin >> a >> b ) {
    if ( a == 0 && b == 0 ) {
      for ( int i = 0; i < size; i++ ) {
        for ( int j = 0; j < size; j++ ) {
          if ( G[i][j] > 0 ) C[i] += G[i][j];
        }
      }
      bool ok = true;
      int start = M[1], goal = M[2];
      for ( int i = 0; i < size; i++ ) {
        if ( !C[i] ) continue;
        if ( i == start || i == goal ) {
          if ( C[i] % 2 == 0 ) ok = false;
        } else {
          if ( C[i] % 2 != 0 ) ok = false;
        }
      }
      // output
      cout << ( ok ? "OK" : "NG" ) << endl;
      flag = true;
    } else {
      if ( flag ) {
        init();
      }
      set_index( a );
      set_index( b );
      int index_a = M[a], index_b = M[b];
      G[index_a][index_b]++;
      G[index_b][index_a]++;
    }
  }
  return 0;
}

Measured memory_bytes: 0
n = input().split()
a = int(n[0])
b = int(n[1])
c = int(n[2])
if a > b:
	bf = a
	a = b
	b = bf
if b > c:
	bf = b
	b = c
	c = bf
if a > b:
	bf = a
	a = b
	b = bf
print(str(a) + " " + str(b) + " " + str(c))

Measured memory_bytes: 7668
#include <bits/stdc++.h>
#define MAX 1000000
#define INF 999999999
#define EPS 1e-9
#define pb push_back
#define mp make_pair
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
using namespace std;
 typedef  long long  int ll;
 typedef pair<int,int> ii;
 typedef vector<ii> vii;
 typedef vector <ll > vi;

int arr[100005];

int main()
{
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str;
  cin>>str;
  int f,len;
  for(int i=str.size()-2;i>=0;i--)
  {
   // cout<<i<<endl;
    if((i)%2==1)
      continue;
     len=(i)/2;
    f=0;
    for(int j=0;j<len;j++)
    {
      //cout<<str[j]<<" "<<str[len+j]<<endl;
      if(str[j]!=str[len+j])
        f=1;
    }
    if(f!=1)
    {
      cout<<i<<endl;
      return 0;   
     }
  }


return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define WA cout<<"char134217728";exit(0)
#define RE throw
#define TLE sleep(1000)
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int H, W, h, w;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> H >> W >> h >> w;
  cout << (H-h) * (W-w) << endl;
}

Measured memory_bytes: 256
def dic_counter(dic, num):
    if num in dic:
        dic[num] += 1
    else:
        dic[num] = 1

_ = int(input())
dic = {}
for i in input().split():
    dic_counter(dic, int(i)-1)
    dic_counter(dic, int(i))
    dic_counter(dic, int(i)+1)
print(sorted(dic.values(), key=lambda x: -x)[0])

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

int main(){
   int n;
   cin >> n;
   for(int i=1;i<=50000;i++){
     if(floor(i*1.08)==n){
     	cout << i;
       	return 0;
     }
   }
  cout << ":(";
  return 0;
}

Measured memory_bytes: 256
// Author : heyuhhh
// Created Time : 2020/09/13 20:00:48
#include<bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;
void run() {
    int x;
    cin >> x;
    if (x) {
        cout << 0 << '\n';
    } else {
        cout << 1 << '\n';
    }
}
int main() {
#ifdef Local
    freopen("input.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 3600
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
v = sorted([(key, value) for key, value in c.items() if value != 1],
           key=lambda x: x[0],
           reverse=True)
# print(v)
if len(v) <= 0:
    print(0)
    exit()
if len(v) == 1:
    if v[0][1] >= 4:
        print(v[0][0] * v[0][0])
    else:
        print(0)
    exit()
if v[0][1] >= 4:
    print(v[0][0] * v[0][0])
else:
    print(v[0][0] * v[1][0])


Measured memory_bytes: 18600
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;

int main() {
  vector<vector<ll>> C(100, vector<ll>(100, 0));
  C[0][0] = 1;
  C[1][0] = 1;
  for (int i = 1; i < 100; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
    }
  }
  ll n, a, b;
  cin >> n >> a >> b;
  vector<ll> v(n);
  map<ll, ll> mp;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    mp[v[i]]++;
  }
  sort(all(v), greater<ll>());
  double mean = 0;
  for (int i = 0; i < a; i++) {
    mean += v[i];
  }
  cout << fixed << setprecision(12) << mean / a << endl;
  if (v[0] == v[a - 1]) {
    for (int i = a; i <= b; i++) {
      ans += C[mp[v[0]]][i];
    }
  } else {
    int k = 0;
    for (int i = 0; i < a; i++) {
      k += v[i] == v[a - 1];
    }
    ans += C[mp[v[a - 1]]][k];
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long int
using namespace std;
void solve() {
    int n;
    cin >> n;
    int a[n];
//    set <int> s;
    unordered_map <int, int> mp;
    for(int i=0;i<n;i++) {
        cin >> a[i];
        mp[a[i]]++;
//        s.insert(a[i]);
    }
    int count1 = 0;
    for(auto it : mp) {
        if(it.second > it.first)
            count1 += it.second - it.first;
        else if(it.second < it.first)
            count1 += it.second;
    }
    cout << count1 << '\n';
    return ;
} 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 5028
N = int(input())
h = list(map(int,input().split()))
dp = [0]*N
dp[0]= 0
dp[1] = abs(h[1]-h[0])
for i in range(1,N-1):
  dp[i+1] = min(dp[i-1] + abs(h[i+1]-h[i-1]),dp[i] + abs(h[i+1]-h[i]))
  
print(dp[-1])


Measured memory_bytes: 13980
import java.util.*;
import java.io.*;

public class Main {
	
	static int N;

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		N = Integer.parseInt(br.readLine());
		String[] P = br.readLine().split(" ") ; 
		String[] Q = br.readLine().split(" ") ; 
		
		String Pmoto = "";
		String Qmoto = "";
		for(int n=0; n<N; n++) {
			Pmoto += P[n];
			Qmoto += Q[n];
		}
		
		int countP = 0;
		int countQ = 0;
		
		ArrayList<String> zenbu = new ArrayList<String>();
		new Main().jisyo("", zenbu);
		
		for(int a=0; a<zenbu.size(); a++) {
			if(zenbu.get(a).equals(Pmoto)) {
				countP = a+1;
			}
			if(zenbu.get(a).equals(Qmoto)) {
				countQ = a+1;
			}
		}
		
		System.out.println(Math.abs(countP-countQ));	
		
	}
	
	//辞書
	private void jisyo(String s, ArrayList<String> zenbu) {
		if(s.length() == N) {
			zenbu.add(s);
		}
		digit: 
		for(int i=1; i<=N; i++) {
			for(int j=0; j<s.length(); j++) {
				if(Character.getNumericValue(s.charAt(j)) == i) {
					continue digit;
				}
			}
			jisyo(s + Integer.toString(i),zenbu);
		}
	}
}

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

int main()
{
  int N;
  int p[51];
  int diff=0;
  cin >> N;
  rep(i,N) cin >> p[i];

  rep(i,N){
    diff += (i+1!=p[i]);
  }
  if(diff==0 || diff==2) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

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

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main()
{
    int N;
    cin >> N;
    vector<P> red, blue;
    REP(i, N)
    {   
        int x, y;
        cin >> x >> y;
        P p(x, y);
        red.push_back(p);
    }
    REP(i, N)
    {   
        int x, y;
        cin >> x >> y;
        P p(x, y);
        blue.push_back(p);
    }

    // x座標でソート
    sort(blue.begin(), blue.end());
    int ans = 0;
    bool isUsed[N] = {false};
    REP(i, N)
    {
        int c, d;
        c = blue[i].first;
        d = blue[i].second;
        int maxY = -1;
        int maxYIndex = -1;
        REP(j, N)
        {
            if (!isUsed[j])
            {
                int a, b;
                a = red[j].first;
                b = red[j].second;
                if (a < c && b < d)
                {
                    if (b > maxY)
                    {
                        maxY = b;
                        maxYIndex = j;
                    }
                }
            }
        }
        if (maxYIndex != -1)
        {
            ans++;
            isUsed[maxYIndex] = true;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
(function(input) {
    var p = input.replace(/\n$/, '').split('\n').map(Number);
    for (var i = 0; i < p.length; i++) {
        var n = p[i];
        console.log(count(n));
    }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function count(n) {
    var count = 0;
    for (var i = 2; i <= n; i++) {
        if (isPrimeNumber(i)) {
            count++;
        }
    }
    return count;
}

function isPrimeNumber(x) {
    if (x === 2) {
        return true;
    } else if (x % 2 === 0) {
        return false;
    }
    var n = 3;
    while (n <= Math.sqrt(x)) {
        if (x % n === 0) {
            return false;
        }
        n += 2;
    }
    return true;
}

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

using namespace std;

const int N = 52;

int ans;
int tin[N], anc[N], TIME;
vector<int> g[N];

void dfs(int v, int pv) {
  tin[v] = anc[v] = ++TIME;
  fprintf(stderr, "%d %d %d\n", v, tin[v], anc[v]);
  for (int u : g[v]) {
    if (tin[u] == 0) {
      dfs(u, v);
      anc[v] = min(anc[v], anc[u]);
    } else if (pv != u) {
      anc[v] = min(anc[v], tin[u]);
    }
    if (tin[v] < anc[u]) {
      ans++;
    }
  }
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  while (m--) {
    int x, y;
    scanf("%d %d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, -1);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n,c[501],s[501],f[501];
int path(int p,int i){
	int ans=s[i+1];
	p+=c[i];
	if(!ans){return p;}
	for(int j=0;;j++){
		if(p<=ans){break;}
		ans+=f[i+1];
	}
	return path(ans,i+1);
}
int main(void){
	int i;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d%d%d",&c[i],&s[i],&f[i]);
	}
	for(i=1;i<=n;i++){
		printf(" %d\n",path(s[i],i));
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int a[10];
    for(int i=0;i<9;i++){
        cin>>a[i];
    }
    if(a[0]-a[1]==a[3]-a[4] && a[3]-a[4]==a[6]-a[7] && a[0]-a[3]==a[1]-a[4] && a[1]-a[4]==a[2]-a[5] && a[1]-a[2]==a[4]-a[5] && a[4]-a[5]==a[7]-a[8] && a[3]-a[6]==a[4]-a[7] && a[4]-a[7]==a[5]-a[8]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
from collections import Counter
n, k = map(int, input().split())
A = list(map(int, input().split()))
c = Counter(A)
cnt = 0
ans = 0
m = len(c)-k
if m < 0:
    m = 0
for k, v in sorted(c.items(), key=lambda x: x[1]):
    if cnt == m:
        break
    ans += v
    cnt += 1

print(ans)


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

typedef pair<string, int> PSI;

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

#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define fst first
#define snd second

int main(void) {
    int n, p;
    string s;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<pair<PSI, int>> vec(n);
    REP(i, n) {
        cin >> s >> p;
        vec[i] = MP(PSI(s, -p), i);
    }

    sort(ALL(vec));
    REP(i, n) {
        cout << vec[i].snd + 1 << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
int main() {

    ll n,m,l;
    cin >> n>>m>>l;
    pair<ll,ll> mi[n][n];

    rep(i, n) {
        rep(j, n) {
            mi[i][j].first = MOD;
            mi[i][j].second = MOD;
        }
    }

    rep(i,m){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        if(c>l)continue;
        mi[a][b] = {0,c};
        mi[b][a] = {0,c};
    }

    rep(i,n)mi[i][i] = {0,0};

    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                pair<ll,ll> p1 = mi[i][k];
                pair<ll,ll> p2 = mi[j][k];
               if(p1.second+p2.second<=l){
                   min_update(mi[i][j],{0,p1.second+p2.second});

               }
//                    if(mi[i][j].first>p1.first+p2.first){
//                        mi[i][j] = {0,p1.second+p2.second};
//                    }else{
//
//                    }
//                }

            }
        }
    }

    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                pair<ll,ll> p1 = mi[i][k];
                pair<ll,ll> p2 = mi[j][k];
                min_update(mi[i][j],{p1.first+p2.first+1,p2.second});
//                if(p1.first+p2.first<mi[i][j].first){
//                  mi[i][j] = {p1.first+p2.first+1,mi[j][k].second};
//                }

            }
        }
    }
    int q;
    cin>>q;
    rep(i,q){
        int s,t;
        cin>>s>>t;
        if(mi[s-1][t-1].first==MOD){
            cout<<-1<<endl;
        }else{
            cout<<mi[s-1][t-1].first<<endl;
        }
    }





    return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<iomanip>
#include<vector>
//#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;


int main() {
	ll n, a[100010], sum = 0,c=0;
	bool f;

	cin >> n;
	for (int i = 0; i < (n); i++)cin >> a[i];

	for (int i = 0; i < n; i++)if (a[i] < 0)c++;


	if (c % 2)f = true;
	else f = false;
	for (int i = 0; i < (n); i++) {
		sum += abs(a[i]);
		a[i] = abs(a[i]);
	}
	
	sort(a, a + n);
	if (f)sum -= 2*abs(a[0]);
	cout << sum << endl;

}

Measured memory_bytes: 1024
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
//#include <cstdio>
//#include <cstdlib>
//#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(void){

	int a, b, c;
	// char ;

	cin >> a >> b >> c;
	
	if(a < b && b < c) cout << "Yes" <<endl;
	else cout << "No"<<endl;

	return 0;
}

/*
for(i=0;i<N;i++){
	cin >> X[i];
}


for(i=0;i<N;i++){
	for(j=0;j<N;j++){
		cin >> X[i][j];
	}
}
*/

Measured memory_bytes: 1156
// In the name of god
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <bitset>
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
using namespace std;
 
template <typename T>
T next_int() {
    T x = 0, p = 1;
    char ch;
    do { ch = getchar(); } while(ch <= ' ');
    if(ch == '-') {
        p = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9') {
        x = x * 10 + (ch - '0');
        ch = getchar();
    }
    return p * x;
}
 
string next_token() {
    char ch;
    string ans = "";
    do { ch = getchar(); } while(ch <= ' ');
    while(ch > ' ') {
        ans += ch;
        ch = getchar();
    }
    return ans;
}
 
const long long INF = (long long)1e18;
const int INFINT = (int)1e9 + 227 + 1;
const int MAXN = (int)1e6 + 227 + 1;    
const int MOD = (int)1e9 + 7;
const long double EPS = 1e-9;
 
long long bin_pow(long long a, long long b) {
    if(!b) return 1;
    long long ans = bin_pow(a, b / 2);
    ans = ans * ans % MOD;
    if(b % 2) ans = ans * a % MOD;
    return ans;
}

int main() {
    // freopen(".in", "r", stdin);

    int n; cin >> n;

    vector<int> a(n);

    for(int i = 0; i < n; i++)
        a[i] = next_int<int>();

    sort(all(a));

    for(int i = 0; i < n; i++)
        if(a[i] != a[0] && a[i] != a.back()) {
            puts("No");
            return 0;
        }

    if(a.back() == a[0]) {
        if(a.back() == n - 1 || a.back() * 2 <= n) {
            puts("Yes");
        } else {
            puts("No");
        }

        return 0;
    }

    int k[2] = {0, 0};
    for(int i = 0; i < n; i++)
        k[a.back() == a[i]]++;

    int kek = a.back() - k[0];

    if(kek * 2 <= k[1] && kek > 0 && abs(a.back() - a[0]) == 1) {
        puts("Yes");
    } else {
        puts("No");
    }
}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
K = INT()
sum = 0
 
for n in range(K):
  for m in range(K):
    for l in range(K):
      sum += gcd(n+1, gcd(m+1, l+1))
 
print(sum)

Measured memory_bytes: 69212
//2017-10-13
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define N (100000+5)

int ra[N], a[N];

int main(){
	int n;
	scanf("%d", &n);
	For(i, 1, n) scanf("%d", &ra[i]), a[i] = ra[i];
	
	int ans = 0;

	sort(ra+1, ra+n+1);
	For(i, 1, n){
		a[i] = lower_bound(ra+1, ra+n+1, a[i]) - ra;
		if((i&1) ^ (a[i]&1)) ++ans;
	}

//	printf("ans = %d\n", ans);
	printf("%d\n", ans >> 1);
	
	return 0;
}

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

int main() {
    int a,b,c,d,e = 0;
    cin >> a >> b >> c;
    for(int i = a; i <= b; i++){
        d = c % i;
        if(d == 0)e += 1;
    }
    cout << e << endl;
}


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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
typedef long long ll;

int h,w,n;



bool f( vector<string> board){
  vector<vector<bool>> ok(h,vector<bool>(w,false));
  rep(i,h){
    rep(j,w-n+1){
      if(board[i][j] == '.') continue;
      set<char> st;
      for(int k=j; k < j+n; k++){
        st.insert(board[i][k]);
        if(st.size() == 2) break;
        if(k == j+n-1){
          for(int l=j; l < j+n; l++) ok[i][l] = true;
        }
      }
    }
  }

  rep(j,w){
    rep(i,h-n+1){
      if(board[i][j] == '.') continue;
      set<char> st;
      for(int k=i; k < i+n; k++){
        st.insert(board[k][j]);
        if(st.size() == 2) break;
        if(k == i+n-1){
          for(int l=i; l < i+n; l++) ok[l][j] = true;
        }
      }
    }
  }

  // 落下処理
  vector<string> newBoard(h);

  rep(j,w){
    int hi = 0;
    int low = h-1;
    for(int i = h-1; i >= 0; i--){
      if(ok[i][j]){
        newBoard[hi].push_back('.');
        hi++;
      }else{
        newBoard[low].push_back(board[i][j]);
        low--;
      }
    }
  }

  bool combFlag = false;
  bool okFlag = true;
  rep(i,h){
    rep(j,w){
      if(ok[i][j] == 1) combFlag = true;
      if(newBoard[i][j] != '.') okFlag = false;
    }
  }

  if(okFlag) return true;
  else if(combFlag) return f(newBoard);
  else return false;
}

bool init(vector<string> board){
  vector<string> newBoard(h);
  rep(j,w){
    int hi = 0;
    int low = h-1;
    for(int i = h-1; i >= 0; i--){
      if(board[i][j] == '.'){
        newBoard[hi].push_back('.');
        hi++;
      }else{
        newBoard[low].push_back(board[i][j]);
        low--;
      }
    }
  }

  return f(newBoard);
}

int main(){

  cin >> h >> w >> n;
  vector<string> board(h);
  rep(i,h) cin >> board[i];
  rep(i,h){
    rep(j,w-1){
      if(board[i][j] != '.' || board[i][j+1] != '.'){
        char tmp = board[i][j];
        board[i][j] = board[i][j+1];
        board[i][j+1] = tmp;
        if(init(board)){
          cout << "YES" << "\n";
          return 0;
        }
        board[i][j+1] = board[i][j];
        board[i][j] = tmp;
      }
    }
  }

  
  cout << "NO" << "\n";
}



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

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

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    ll a, b, n;
    cin >> a >> b >> n;

    ll ans = 0;
    ll tmp = (b <= n ? b-1 : n);
    ans = ((a*tmp)/b);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int n;
int m =0;
int *a;

void bubble_sort()
{
	bool flag = true;
	while (flag)
	{
		flag =false;  
		for (int i=n-1; i>0; i--)
		{
			int ai = a[i];
			if(ai < a[i-1]) 
			{
				a[i] = a[i-1];
				a[i-1] = ai;
				flag = true;
				m++;
			}
		}
	}
}

int main()
{
	cin >> n;
	a = new int[n];
	for (int i = 0; i < n;	i++)
	{
		cin >> a[i];
	}
	
	bubble_sort();
	
	for (int i=0; i<n;	i++)
	{
		if (i) cout << ' ';
		cout << a[i];
	}
	
	cout << endl;
	cout << m << endl;
	
	return 0;
}

Measured memory_bytes: 1188
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n;
LL a[100111];
int main()
{
	get1(n);
	for(int i=1;i<=n;i++)get1(a[i]);sort(a+1,a+n+1);
	int ans=n;
	for(int i=1;i<=n;i++)
	{
		if(a[i-1]*2<a[i])ans=n-i+1;
		a[i]+=a[i-1];
	}
	printendl(ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int val[15]={0,14},a,b;
	for(int i=2;i<=13;++i) val[i]=i;
	cin>>a>>b;
	cout<<(val[a]!=val[b]?val[a]>val[b]?"Alice":"Bob":"Draw");
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

pub fn count_ones(i: usize) -> usize {
    let i = i - ((i >> 1) & 0x5555555555555555);
    let i = (i & 0x3333333333333333) + ((i >> 2) & 0x3333333333333333);
    let r = (((i + (i >> 4)) & 0xF0F0F0F0F0F0F0F) * 0x101010101010101) >> 56;
    r as usize
}

fn main() {
    input! {
        n: usize,
        a: [[usize; n]; n],
    }
    let mut dp = vec![vec![0; 1 << n]; n + 1];
    dp[0][0] = 1;

    for i in 0..n {
        for j in 0..(1 << n) {
            if count_ones(j) != i {
                continue;
            }
            for k in 0..n {
                if j & (1 << k) == 0 && a[i][k] == 1 {
                    dp[i + 1][j | (1 << k)] += dp[i][j];
                    dp[i + 1][j | (1 << k)] %= 1_000_000_007;
                }
            }
        }
    }
    println!("{}", dp[n][(1 << n) - 1]);
}


Measured memory_bytes: 184572
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >>a>>b;
  if(a==2){
    if(b==2) cout <<"Yes\n";
    else cout <<"No\n";
  }
  else{
    if(a==4||a==6||a==9||a==11){
      if(b==4||b==6||b==9||b==11) cout <<"Yes\n";
      else cout <<"No\n";
    }
    else{
      if(a!=2){
	if(b==1||b==3||b==5||b==7||b==8||b==10||b==12) cout <<"Yes\n";
	else cout <<"No\n";
      }
      else cout <<"No\n";
    }
  }
  return 0;
}


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

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

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  ll ans = 0;

  int right = 0;
  int sum = 0;
  for (int left = 0; left < n; left++) {
    while(right < n && (sum ^ a[right]) == (sum + a[right])) {
      sum += a[right];
      right++;
    }

    ans += (right - left);
    if(right == left) right++;
    else sum -= a[left];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int N;
vector<int> A;

ll solve(){
    vector<int> alt;
    rep(i,N) alt.push_back(A[i]);
    sort(all(alt));
    rep(i,N){
        int it=lower_bound(all(alt),A[i])-alt.begin();
        A[i]=it;
    }
    vector<int> nums(N,0);
    for(int i=1;i<N;i+=2) nums[i]++,nums[A[i]]++;
    int res=0;
    for(int i=1;i<N;i+=2) if(nums[i]==2) res++;
    return N/2-res;
}

int main(){
    cin>>N;
    A.resize(N);
    rep(i,N) cin>>A[i];
    cout<<solve()<<endl;
}

Measured memory_bytes: 1528
n,d=map(int,input().split())
a=[[0]*d for ii in range(n)]
for ii in range(n):
  a[ii][:]=map(int,input().split())
r=0
for ii in range(n):
  for jj in range(n):
    if ii!=jj:
      d2=0
      for kk in range(d):
        d2+=(a[ii][kk]-a[jj][kk])**2
      d2=d2**0.5
      #print(d2)
      if int(d2)==d2:
        r+=1
print(r//2)


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int func(long long n, long long k, std::vector<long long> h) {
    // cout << fixed << setprecision(8);
    sort(all(h));

    ll ans = INF;
    for (int i = 0; i + (k - 1) < n; i++) {
        ans = min(ans, h[i + (k - 1)] - h[i]);
    }
    cout << ans << endl;

    return 0;
}

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

    func(N, K, std::move(h));

    return 0;
}


Measured memory_bytes: 1024
n,x,m=map(int,input().split())
A=[[0]*2 for i in range(m)]
A[x]=[1,x]
a=x
f=-1
for i in range(10**5+100):
  if i==n-1:
    f=0
    break
  x=x**2%m
  a=a+x
  if A[x][0]!=0:
    f=1
    break
  A[x]=[i+2,a]
if f==0:
  print(a)
elif f==1:
  ans=A[x][1]+(a-A[x][1])*((n-A[x][0])//(i+2-A[x][0]))
  for i in range((n-A[x][0])%(i+2-A[x][0])):
    x=x**2%m
    ans=ans+x
  print(ans)

Measured memory_bytes: 86916
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int n; string s;
    cin>>n>>s;
    int ans=0;
    for(int i=1;i<s.size()-1;i++){
        string l,r;
        l=s.substr(0,i);
        r=s.substr(i,s.size()-i);
        vector<bool> lkind(26,false);
        vector<bool> rkind(26,false);
        int p=0;
        while(p!=l.size()){
            lkind[l[p]-'a']=true;
            p++;
        }
        p=0;
        while(p!=r.size()){
            rkind[r[p]-'a']=true;
            p++;
        }
        int t=0;
        rep(i,26)if(lkind[i]&&rkind[i])t++;
        chmax(ans,t);
    }
    cout<<ans<<endl;
    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 ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> ans;
	rep(i,n) cin >> v[i];
	while (!v.empty()) {
		int k = 0;
		rep(i,v.size()) {
			if (i + 1 == v[i]) {
				k = i + 1;
			}
		}
		if (k) {
			ans.push_back(k);
			v.erase(v.begin() + k - 1);
		} else {
			cout << -1 << endl;
			return;
		}
	}
	for (int i = n - 1; i >= 0; i--) {
		cout << ans[i] << endl;
	}
}

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

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

using namespace std;

#define int long long
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

//ll fact[mxn];
//ll in_fact[mxn];
//fact[0] = 1;
//for(ll i = 1; i < mxn; i++) {
	//fact[i] = (i*fact[i-1])%mod;
//}
//in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
//for(ll i = mxn-2; i >= 0; i--) {
	//in_fact[i] = (in_fact[i+1] * (i+1))%mod;
//}
//ll c(ll n,ll r) {
	//ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	//return ans;
//}


signed main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        string s;
        int ans = 0;
        cin>>s;
        int n = (int)s.size();
        for(int i = 0; i < n; i++) {
			ans += s[i]-'0';
		}
		if(ans%9) cout<<"No\n";
		else cout<<"Yes\n";
        
        
    }



return 0;
}


Measured memory_bytes: 3604
from collections import deque
from itertools import accumulate
import sys
sys.setrecursionlimit(10**6)

mo=10**9+7
#n=int(input())
l,r=map(int,input().split())
r=min(l+2019+10,r)

ans=2018
for i in range(l,r):
    for j in range(l+1,r+1):
        ans=min(ans,(i*j)%2019)
        #print(i,j,(i*j)%2019,ans)


print(ans)



Measured memory_bytes: 40428
/*
ID: ramil-p1
PROG: sprime
LANG: C++11
*/
#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5 + 100, inf = 2e9 + 100;

int sx, sy, tx, ty;

int main(){
    ios::sync_with_stdio(0);
    cin >> sx >> sy >> tx >> ty;
    for (int i = 0; i < tx - sx; i++)
        cout << 'R';
    for (int i = 0; i < ty - sy; i++)
        cout << 'U';
    for (int i = 0; i < tx - sx; i++)
        cout << 'L';
    for (int i = 0; i < ty - sy; i++)
        cout << 'D';
    cout << 'L';
    for (int i = 0; i <= ty - sy; i++)
        cout << 'U';
    for (int i = 0; i <= tx - sx; i++)
        cout << 'R';
    cout << 'D';
    cout << 'R';
    for (int i = 0; i <= ty - sy; i++)
        cout << 'D';
    for (int i = 0; i <= tx - sx; i++)
        cout << 'L';
    cout << 'U';
}


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

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[2 * n];
        for (int i = 0; i < 2 * n; ++i) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int res = 0;
        for (int i = 0; i < 2 * n; i += 2) {
            res += arr[i];
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 22996
(function(input) {
    var lines = input.split('\n');
    for (var i = 0; i < lines.length; i++) {
        var l = lines[i];
        if (l.match(/\?/)) {
            break;
        }
        var r = Math.floor(eval(l));
        console.log(r);
    }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

//Moonlight Farm
public class Main{

	class R implements Comparable<R>{
		String r;
		double E;
		public R(String r, double e) {
			this.r = r;
			E = e;
		}
		public int compareTo(R o) {
			return Math.abs(E-o.E)<1e-8?r.compareTo(o.r):(int)Math.signum(o.E-E);
		}
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			R[] r = new R[n];
			for(int i=0;i<n;i++){
				String t = sc.next();
				int p = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt(), e = sc.nextInt(),
				f = sc.nextInt(), s = sc.nextInt(), m = sc.nextInt();
				int S = s*f*m-p, T = a+b+c+m*(d+e);
				r[i] = new R(t, S*1.0/T);
			}
			Arrays.sort(r);
			for(R v:r)System.out.println(v.r);
			System.out.println("#");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000