akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[N]; int[] b = new int[N];
		int[] c = new int[M]; int[] d = new int[M];
		for (int i=0; i<N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for (int i=0; i<M; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		for (int i=0; i<N; i++) {
			int res = 1;
			int md = Math.abs(a[i] - c[0]) + Math.abs(b[i] - d[0]);
			for (int j=0; j<M; j++) {
				int cd = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
				if (md > cd) {
					md = cd;
					res = j+1;
				}
			}
			System.out.println(res);
		}
	}
}


Measured memory_bytes: 20812
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int con = 0;
		int flag = 0;
		int i = 0;
		int num[];
		int ans = 0;
		num = new int[10];
		for(i = 0; i < 10; i++){
			num[i] = con;
			con = con + 111;
		}
		
		i = 0;
		while(i < 9 && flag == 0){
			if(num[i] < n && n <= num[i + 1]){
				ans = num[i + 1];
				flag = 1;
			}
			i++;
		}
		
		
		
		System.out.println(ans);
	}
}


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

int enc(char c){
    if(islower(c))  return c-'a';
    else            return 26 + c - 'A';
}

char dec(int i){
    if(i <= 25) return 'a'+i;
    else        return 'A' + i-26;
}

int main(){
    int n;
    while(cin >> n, n){
        int key[n];
        for(int i = 0; i < n; i++)  cin >> key[i];
        string s;
        cin >> s;
        for(int i = 0; i < s.length(); i++){
            cout << dec((enc(s[i])+52-key[i%n])%52);
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3212
N,T = map(int,input().split())
a_list = list(map(int,input().split()))

profit_list = []

min_a = 10**9+1
for a in a_list:
    profit_list.append(a-min_a)
    if a<min_a:
        min_a = a

profit_list.sort()

max_profit = profit_list[-1]

cnt = 0
for p in profit_list:
    if p == max_profit:
        cnt += 1

print(cnt)

Measured memory_bytes: 64404
//https://atcoder.jp/contests/abc122/tasks/abc122_a
#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)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S;
    cin >> S;
    cout << ( S == "A" ? "T" : S == "T" ? "A" : S == "G" ? "C" : "G" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
using int64 = long long;

int main() {
  char a, b;
  cin >> a >> b;
  if ((a == 'H' & b == 'H') || (a == 'D' & b == 'D')) {
    cout << 'H' << endl;
  } else {
    cout << 'D' << endl;
  }
  return 0;
}

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


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define Rep(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

int n, m , x;
vector<vector<int>> sank;

const int INF = 10000000;

int calc(vvi sank, int bit){

    int cost = 0;
    vi a(m, 0);

    rep(i, n){
        if(bit & (1 << i)){
            rep(j, m) a[j] += sank[i][j+1];
            cost += sank[i][0];
        }
    }

    bool flag = true;
    rep(j, m) if(a[j] < x) flag = false;

    if(flag) return cost;
    else return INF;
    return 0;
}

int main(){
    cin >> n >> m >> x;
    sank.assign(n, vector<int>(m+1));
    rep(i, n) rep(j, m+1) cin >> sank[i][j];

    int ans = INF;

    rep(bit, (1 << n)){
        int cost = calc(sank, bit);

        ans = min(ans, cost);
    }


    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll a,b,k;
	scanf("%lld%lld%*d%lld",&a,&b,&k);
	printf("%lld\n",k%2?b-a:a-b);
}

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

int main(){
  int x, y;
  for (int i = 1; i < 3001; i++){
    cin >> x >> y;
    if (x == 0 && y == 0){
      break;
    }
    else if (x > y){
      swap(x, y);
      cout << x << " " << y << endl;
    }
    else{
      cout << x << " " << y << endl;
    }
  }
}



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

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

using namespace std;

string s;

bool ch(int pos)
{
	if(s[pos] == s[pos+1]) {
		cout << pos+1 << " " << pos+2 << endl;
	} else if (s[pos] == s[pos+2]) {
		cout << pos+1 << " " << pos+3 << endl;
	}
	return s[pos] == s[pos+1] || s[pos] == s[pos+2];	
}

int main()
{
	cin >> s;
	s = s + "????";
	rep(i, s.length()-4) {
		if (ch(i)) return 0;
	}
	cout << "-1 -1" << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  string s[301];
  cin >> n;
  rep(i, 0, n) {
    cin >> s[i];
  }
  int ans = 0;
  rep(i, 0, n) {
    bool f = 0;
    rep(j, 0, n) {
      rep(k, 0, n) {
        if(s[(j + i) % n][k] != s[(k + i) % n][j]) f = 1;
      }
    }
    if(!f) ans += n - i;
  }

  rep(i, 1, n) {
    bool f = 0;
    rep(j, 0, n) {
      rep(k, 0, n) {
        if(s[j][(k + i) % n] != s[k][(j + i) % n]) f = 1;
      }
    }
    if(!f) ans += n - i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

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

constexpr ll MOD = 1e9 + 7;

int n;
vector<int> v[112345];
ll memo[112345][2];

ll dfs(int par, int cur, int color)
{
    if (memo[cur][color] != -1)
        return memo[cur][color];

    ll res = 1;

    for (int i : v[cur])
    {
        if (i == par)
            continue;
        ll tmp = dfs(cur, i, 0);
        if (color == 0)
            tmp += dfs(cur, i, 1);
        (res *= tmp % MOD) %= MOD;
    }

    return memo[cur][color] = res;
}

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

    memset(memo, -1, sizeof(memo));

    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    cout << (dfs(-1, 1, 0) + dfs(-1, 1, 1)) % MOD << endl;

    return 0;
}


Measured memory_bytes: 16128
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long long
#define ll long long
#define ld long double


int main()
{
  int x,y,z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);

  cout << x << " " << y << " " << z <<endl;

      return 0;
}


Measured memory_bytes: 256
from math import floor


def calc(x):
    global a
    global b
    e1 = floor(a * x / b)
    e2 = a * floor(x / b)
    return e1 - e2


a, b, n = map(int, input().split())
if n >= b - 1:
    print(calc(b - 1))
else:
    print(calc(n))


Measured memory_bytes: 9168
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define FOR(i,a,b) for(long long int i=a;i<b;i++)
#define sz(s) (long long int)(s).size()
#define pb push_back
#define mp make_pair
const ll inf = 1000000000;
const ll MOD = 1000000007;

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    cout.tie(NULL);
    register ll i,j,k,x,y,m,n,t,q,temp,sum=0,count=0,f=1;
    cin>>n;
    double p[n];
    for(i=0;i<n;i++){
    	cin>>p[i];
    }
    double dp[n+1][n+1];
    
    for(i=0;i<=n;i++){
    	for(j=0;j<=n;j++){    		
    		dp[i][j] = 0;
    	}     	
    }
    dp[0][0] = 1;
    for(i=1;i<=n;i++){    	
    	dp[i][0] = dp[i-1][0]*(1- p[i-1]);
    }
    for(i=1;i<=n;i++){
    	for(j=1;j<=i;j++){
    		dp[i][j] = dp[i-1][j]*(1-p[i-1]) + dp[i-1][j-1]*p[i-1];
    	}
    }
    // for(i=0;i<=n;i++){
    // 	for(j=0;j<=n;j++){
    // 		cout<<dp[i][j]<<" ";
    // 	} 
    // 	cout<<"\n";
    // }
    double ans = 0;
    for(i=(n+1)/2;i<=n;i++){
    	ans += dp[n][i];
    }
    cout<<setprecision(11)<<ans;

}    
    

Measured memory_bytes: 70656
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {
  string s = in;
  string a = "CODEFESTIVAL2016";
  int cnt = 0;
  rep(i, size(s)) {
    if (a[i] != s[i])cnt++;
  }
  cout << (cnt) << endl;

}


Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define read(x) scanf("%d",&x)
int a;
string s;
int main(){
	ios::sync_with_stdio(false);
	cin>>a>>s;
	if (a>=3200) cout<<s;
	else cout<<"red";
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
//#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
//#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
//#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
//template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
//template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
//
//using Graph = vector<vector<int>>;
//using P = pair<int, int>;
//using Tuple = tuple<int, int, int>;

//ll dp[200005][2][3];

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

    vector<vector<ll>> dp(n, vector<ll>(2, -1e17));
    dp[0][0] = 0;
    dp[0][1] = a[0];
    dp[1][0] = max(a[0], a[1]);
    dp[1][1] = max(a[0], a[1]);

    for(int i=2; i<n; i++) {
        // iを選んで, i/2の状態
        dp[i][0] = max(dp[i][0], dp[i-2][0] + a[i]);
        // iをえらばず, i/2の状態
        dp[i][0] = max(dp[i][0], dp[i-1][1]);

        if(i%2==0) {
            // iを選んで, (i+1)/2個選ばれてる状態
            dp[i][1] = max(dp[i][1], dp[i-2][1] + a[i]);
        } else {
            // iを選んで, (i+1)/2個選ばれてる状態(偶数個の場合はi/2の状態と同じ)
            dp[i][1] = max(dp[i][1], dp[i][0]);
        }
        // iを選ばず, (i+1)/2個選ばれてる状態(ありえないはず)
//        cout << dp[i][0] << endl;
//        cout << dp[i][1] << endl;
    }

    if(n%2==0) {
        cout << dp[n-1][0] << endl;
    } else {
        cout << dp[n-1][0] << endl;
    }

    return 0;
}

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

int A = 500;
int B = 100;
int C = 50;

int count(int a, int b, int c, int x){
    int counter = 0;
    for (int ai=0; ai<=a; ai++) {
        for (int bi=0; bi<=b; bi++) {
            for (int ci=0; ci<=c; ci++) {
                int total = A * ai + B * bi + C * ci;
                if (total == x) counter++;
            }
        }
    }
    return counter;
}

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    cout << count(a, b, c, x) << endl;
}



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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}

int t(int k){
	int c=0;
	for(int i=1;i<10;++i){
		if(k>=i) {k-=i;c++;}
		else break;
	}
	return c;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	ll n;cin>>n;// vl a(n); repi(i,n) cin>>a[i];
	int c=0,ans=0;
	for(ll i=2;i*i<=n;++i){
	
		if(n%i==0){
			c=0;
			while(n%i==0) {
				c++;n/=i;
			}
			ans+=t(c);
		}
	}
	if(n>1) ans++;
	db(ans);
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int, int> mp;
    rep(i,n){
        for(int j = -1; j < 2; j++) mp[a[i]+j]++;
    }
    int ans = 0;
    for(auto m: mp) ans = max(ans, m.second);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8056
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

long long word[6];
long long ans;

int main(void) {
    string s;
    int n;
    cin >> n;
    while(n--) {
        cin >> s;
        if (s[0] == 'M') {
            word[0] += 1;
        } else if (s[0] == 'A') {
            word[1] += 1;
        } else if (s[0] == 'R') {
            word[2] += 1;
        } else if (s[0] == 'C') {
            word[3] += 1;
        } else if (s[0] == 'H') {
            word[4] += 1;
        }
    }
    ans += word[0] * word[1] * word[2];
    ans += word[0] * word[1] * word[3];
    ans += word[0] * word[1] * word[4];
    ans += word[0] * word[3] * word[2];
    ans += word[0] * word[3] * word[4];
    ans += word[0] * word[2] * word[4];

    ans += word[1] * word[2] * word[3];
    ans += word[1] * word[3] * word[4];
    ans += word[1] * word[2] * word[4];

    ans += word[2] * word[3] * word[4];

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


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

typedef long long ll;
typedef vector<ll> vll;

int main(){
        ios::sync_with_stdio(0); 
        cin.tie(0); 
        cout.tie(0);
        ll num; 
        cin >> num;
        vll b(num);
        map<ll,ll>mp;
        rep(i,num)
        {
            cin >> b[i];
            mp[b[i]]++;
        }
        ll res = 0;
        for(auto y: mp)
        {
            ll ans  = y.second;
            res+=(ans*(ans-1)/2);
        }
        rep(i,num)
        {
            cout<<res-mp[b[i]]+1<<"\n";
        }


return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int sum = 0;
		for (int i = 0; i < N.length(); i++) {
			sum += N.charAt(i)-'0';
		}
		if (sum % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 40368
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;
 
void testCase() {
    int n, m;
    cin >> n >> m;
    ll sum = 0;
    int cnt = 0;
    ll val[n+1];
    for (int i=0; i<n; i++) {
        cin >> val[i];
        sum += val[i];
    }
    for (int i=0; i<n; i++) {
        ll take = val[i]*4*m;
        if (take >= sum)
            cnt++;
    }
    if (cnt >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T> inline void chmin(T & a, T const & b) { a = min(a, b); }

struct union_find_tree {
    vector<int> data;
    union_find_tree() = default;
    explicit union_find_tree(size_t n) : data(n, -1) {}
    bool is_root(int i) { return data[i] < 0; }
    int find_root(int i) { return is_root(i) ? i : (data[i] = find_root(data[i])); }
    int tree_size(int i) { return - data[find_root(i)]; }
    int unite_trees(int i, int j) {
        i = find_root(i); j = find_root(j);
        if (i != j) {
            if (tree_size(i) < tree_size(j)) swap(i,j);
            data[i] += data[j];
            data[j] = i;
        }
        return i;
    }
    bool is_same(int i, int j) { return find_root(i) == find_root(j); }
};

ll solve(int n, int m, vector<ll> const & a, vector<ll> const & b, vector<vector<int> > const & g) {
    vector<ll> c(n);
    REP (i, n) {
        c[i] = max(a[i] - b[i], 0ll);
    }
    vector<int> order(n);
    iota(ALL(order), 0);
    sort(ALL(order), [&](int i, int j) { return c[i] < c[j]; });

    union_find_tree uft(n);
    vector<ll> dp(n, -1);
    vector<ll> sum_b = b;
    for (int i : order) {
        vector<int> roots;
        for (int j : g[i]) {
            j = uft.find_root(j);
            if (dp[j] != -1) {
                roots.push_back(j);
            }
        }
        sort(ALL(roots));
        roots.erase(unique(ALL(roots)), roots.end());
        for (int j : roots) {
            sum_b[i] += sum_b[j];
        }
        dp[i] = c[i] + sum_b[i];
        for (int j : roots) {
            chmin(dp[i], max(c[i], dp[j]) + sum_b[i] - sum_b[j]);
        }
        for (int j : roots) {
            uft.unite_trees(i, j);
        }
        int root = uft.find_root(i);
        dp[root] = dp[i];
        sum_b[root] = sum_b[i];
    }

    return dp[uft.find_root(0)];
}

int main() {
    // input
    int n, m; cin >> n >> m;
    vector<ll> a(n), b(n);
    REP (i, n) cin >> a[i] >> b[i];
    vector<vector<int> > g(n);
    REP (j, m) {
        int u, v; cin >> u >> v;
        -- u; -- v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    // solve
    ll w = solve(n, m, a, b, g);

    // output
    cout << w << endl;
    return 0;
}


Measured memory_bytes: 11004
import sys,math
input=sys.stdin.readline
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(10000):
    x=math.cos(2*math.pi*i/10000)
    y=math.sin(2*math.pi*i/10000)
    ax=0
    ay=0
    for dx,dy in xy:
        if x*dx+y*dy>=0:
            ax+=dx
            ay+=dy
    ans=max(ans,(ax**2+ay**2)**0.5)
print(ans)


Measured memory_bytes: 41836
from bisect import bisect
from bisect import bisect_right
from bisect import bisect_left
from bisect import insort
from bisect import insort_right
from bisect import insort_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
#print(L)

cnt = 0
for i in range(N):
  for j in range(i+1, N):
    s = L[i] + L[j]
    x = bisect_left(L, s)
    #print((L[i], L[j]), s, x)
    cnt += max(x - j - 1, 0)
print(cnt)

Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MOD = 1000 * 1000 * 1000 + 7;

const int MAX = 111;

int A[333];

int main()
{
    int n;
    scanf("%d", &n);
    int s = 0;
    LL ans = 0;
    bool f = 0;
    FOR(i, 0, n)
    {
        int x;
        scanf("%d", &x);
        if (!x)
        {
            f = 0;
            continue;
        }
        if (f)x++;
        ans += x/2;
        f = (x%2 == 1);
    }
 
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)
#define vi vector<long long>
#define vs  vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
/*bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
*/
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int main()
{
    ll a,b,c,t,n,k,p,q,r,y,yy,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    set<ll>st;
    char ch;
    map<ll,ll>mp;
    vector<ll>v,vv,vz;

      cin>>a>>b>>c;
      if(a+b==c || a+c==b || b+c==a) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
}





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

long double dp[3000][3000];

int main(){
    int n;
    cin >> n;
    vector<long double> head(n+1);
    for(int i=1;i<=n;i++){
        cin >> head[i];
    }
    dp[1][0]= 1-head[1];
    dp[1][1]= head[1];
    for(int i=2;i<=n;i++){
        for(int h=0;h<=i;h++)
        {
            if(h!=0)
            dp[i][h]= dp[i-1][h-1]*head[i];
            dp[i][h]+= dp[i-1][h]*(1-head[i]);
        }
    }
    long double ans=0;
    for(int i=0;i<=n;i++){
        int h=i;
        int t= n-i;
        if(h>t)
            ans+= dp[n][h];
    }
    cout << fixed << setprecision(10) <<  ans;
}

Measured memory_bytes: 139136
n,m,q=[int(i) for i in input().split()]
abcd=[]

import itertools

A=itertools.combinations_with_replacement(range(1,m+1),n)
A=list(A)


for i in range(q):
    abcd.append([int(i) for i in input().split()])
ans=0

for listA in A:
    count=0
    for kumi in abcd:
        a,b,c,d=kumi
        
        if listA[b-1]-listA[a-1]==c:
            count+=d
    ans=max(ans,count)
print(ans) 

Measured memory_bytes: 21724
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind tree(N);
  vector<int> v[100000];
  vector<int> block[100000];
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    v[a].push_back(b);
    v[b].push_back(a);
    tree.unite(a, b);
  }
  rep(i, K) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    block[a].push_back(b);
    block[b].push_back(a);
  }

  int count[100000] = {0};
  rep(i, N) {
    count[tree.root(i)]++;
  }

  int ans[100000] = {0};
  rep(i, N) {
    ans[i] = count[tree.root(i)] - v[i].size() - 1;
    rep(j, block[i].size()) {
      if(tree.same(i, block[i][j])) {
        ans[i] -= 1;
      }
    }
  }
  
  rep(i, N) {
    cout << ans[i];
    if(i != N-1) cout << " ";
    else cout << endl;
  }
  return 0;
}

Measured memory_bytes: 16352
x1=list(map(int,input().split()))
x2=list(map(int,input().split()))
x3=list(map(int,input().split()))
n=int(input())
for _ in range(n):
  m=int(input())
  x1 =[0 if m==x else x for x in x1]
  x2 =[0 if m==x else x for x in x2]
  x3 =[0 if m==x else x for x in x3]

if sum(x1)*sum(x2)*sum(x3) ==0 or x1[0]+x2[0]+x3[0]==0 or x1[1]+x2[1]+x3[1]==0 or x1[2]+x2[2]+x3[2]==0 or x1[0]+x2[1]+x3[2]==0 or x1[2]+x2[1]+x3[0]==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<stdio.h>
#define Max 100
int main()
{
  
  int i,j,x,count=0,N,flag;
  int A[Max];

  scanf("%d",&N);
  
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  
  flag = 1;

  while(flag){
    flag = 0;
    for(j=N-1;j>=1;j--){
      if(A[j]<A[j-1]){
	x = A[j];
	A[j] = A[j-1];
	A[j-1] = x;
	flag = 1;
	count++;
      }
    }
  }
  
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i != N-1) printf(" ");   
  }
  
  printf("\n");
  
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 604
N = int(input())
H = list(map(int, input().split()))
count = 0
max_count = 0
for i in range(1, N):
    if H[i-1] >= H[i]:
        count += 1
    else:
        max_count = max(max_count, count)
        count = 0
max_count = max(max_count, count)
print(max_count)

Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(void) {
	string s;
	int num, k = 1, i, j, l, r;
	ll ans = 1, ansr = 1;
	cin >> num >> s;
	vector<int> d(s.size() + 1, 0);
	l = 0;
	r = 0;
	for (i = 0; i < num * 2; i++) {
		if (s[i] == 'B') {
			if (d[i] & 1) {
				d[i + 1] = d[i] - 1;
				ans *= l - r;
				r++;
			}
			else {
				d[i + 1] = d[i] + 1;
				l++;
			}
		}
		else {
			if (d[i] & 1) {
				d[i + 1] = d[i] + 1;
				l++;
			}
			else {
				if (d[i] == 0) {
					ans = 0;
					break;
				}
				d[i + 1] = d[i] - 1;
				ans *= l - r;
				r++;
			}
		}
		if (l > num || r > num) {
			ans *= 0;
			break;
		}
		ans %= MOD;
	}
	for (i = 2; i <= num; i++) {
		ans *= i;
		ans %= MOD;
	}
	cout << ans << "\n";
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    deque<char> que;
    for (char c: s) que.push_back(c);
    bool flip = false;
    int q;
    cin >> q;
    int t, f;
    char c;
    rep(qi, q){
        cin >> t;
        if (t == 1) {
            flip = !flip;
        }else{
            cin >> f >> c;
            if (flip) f = 3 - f;
            if (f == 1) {
                que.push_front(c);
            } else {
                que.push_back(c);
            }
        }
    }
    if (flip) reverse(que.begin(), que.end());
    string ans;
    for (char c : que) ans += c;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1412
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,d,a;

int main(){
  ll ans=0;
  cin >> n >> d>>a;
  vi x(n),h(n),hh(n);
  REP(i,n){
    cin>>x[i]>>h[i];
    hh[i]=h[i]/a+(h[i]%a!=0);
  }


vector<pair<ll, ll>> p(n);
REP(i,n){
  p[i].first=x[i];
  p[i].second=hh[i];
}
sort(p.begin(),p.end());//, compare_by_b
REP(i,n){
  x[i]=p[i].first;
  hh[i]=p[i].second;
}

vi y(n,-1);
vi cnum(n+1);





  d=d*2;
  REP(i,n){
    cnum[i+1]=cnum[i]+0;
    if (y[i]!=-1){
      hh[i]-=cnum[i]-cnum[y[i]];
    }
    
    auto Iter2 = lower_bound(x.begin(),x.end(), x[i]+d+1);//1,2,3・・のときl=3なら2が返る
    ll k=(Iter2-x.begin()-1);

    
    if (k<n){
      if (y[k]==-1)
        y[k]=i;
    }
      
    k--;
    for(;k>=0;k--){
      if (y[k]==-1){
        y[k]=i;
      }else{
        break;
      }
    }

    //cout<<hh[i]<<endl;
    if (hh[i]<=0){
      continue;
    }
    cnum[i+1]=cnum[i]+hh[i];
    ll dmg=hh[i];
    ans+=dmg;

  }

/*
  cout<<endl;
  REP(i,6){
    cout<<cnum[i]<<endl;
  }
*/


  cout<<ans<<endl;
  return 0;
}
/*
5 1 1
1 1
4 4
5 5
2 2
3 3
*/

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    string s = string(n, 'a');
    for (int i = 0; i < m; i++) {
        int id, c;
        cin >> id >> c;
        --id;
        if (s[id] != 'a' && (s[id] - '0') != c) {
            cout << -1 << endl;
            return 0;
        }
        if (n > 1 && id == 0 && c == 0) {
            cout << -1 << endl;
            return 0;
        }
        s[id] = '0' + c;
    }
    for (int i = 0; i < n; i++) {
        if (s[i] == 'a') {
            if (n > 1 && i == 0) {
                s[i] = '1';
            } else {
                s[i] = '0';
            }
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define REP(i, n)  for(int i=0;i<(int)(n);++i)
#define FOR(i, b, n)  for(int i=b;i<(n);++i)
#define ALL(c) (c).begin(),(c).end()
#define PB(c) push_back(c)
#define SS size()
#define ST first
#define ND second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
    int n; cin >> n;
    bool _ = true;
    REP(i,n) {
        char c;
        cin >> c;
        if (c=='Y') _= false;
    }
    cout << (_?"Three":"Four") << endl;
}

Measured memory_bytes: 256
/**
*   @Author : MeGA
*   @InitTime :05/04/20 22:35:03
*   @Idea : 
*
*
*
*
*
*
*
**/
#include <bits/stdc++.h>
using namespace std;

const int MOD=1e9+7;

int cnt[(int)1e5+7];
int main(){
#ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
#endif

     ios::sync_with_stdio(false);
     cin.tie(0);
     int n;
     cin>>n;
     set<int>s;
     for(int i=0;i<n;i++){
         s.insert(abs(i-(n-i-1)));
     }
     bool bad=false;
     
     for(int i=0;i<n;i++){
        int a;
        cin>>a;
        cnt[a]++;
        if(!s.count(a)){
          bad=1;
        }
     }
     if(bad){
      cout<<"0"<<endl;
      return 0;
     }
     long long re=1;
     for(auto c:s){
   //  	cerr<<c<<" "<<cnt[c]<<endl;
       if(c==0&&cnt[c]>1){
         cout<<"0";
         return 0;
       }else if(c!=0&&cnt[c]!=2){
         cout<<"0";
         return 0;
       } else{
        re*=cnt[c];
        re%=MOD;
       }
     }
     cout<<re<<endl;
  


}

Measured memory_bytes: 2944
#include<iostream>
#include <cmath> 
#include <iomanip> 
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){

    int n;
    cin>>n;
    int arr[n];
    
    for(int i=0;i<n;i++){
      cin>>arr[i];
    }
  ll a[n];
  a[0]=0;
  for(int i=1;i<n;i++){
int k=2;
ll c=INT_MAX,b=INT_MAX;
  
     c= a[i-1] + abs(arr[i-1]-arr[i]);
      if(i-2 >=0 ){
        b =a[i-2] + abs(arr[i-2]-arr[i]);
      }

    
    a[i]= min(c,b);
  }
  cout<<a[n-1];
 
return 0;
}

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

int main(int argc, char *argv[]) {
	int N = 0;
	std::cin >> N;

	int answer = 0;
	for (int i = 1; i <= N; i++) {
		int divisor = 0;
		if (i % 2 == 1) {
			for (int j = 1; j <= N; j++) {
				if (i % j == 0) {
					divisor++;	
				}
			} 
			if (divisor == 8) {
				answer++;
			}
		}
	}

	std::cout << answer << std::endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())

isok = True
x_now = 0
y_now = 0
t_now = 0
for i in range(N):
    t,x,y = map(int,input().split())
    c = t-t_now
    l = abs(x-x_now)+abs(y-y_now)
    if c%2!=l%2 or c<l:
        isok=False
    x_now = x
    y_now = y
    t_now = t
    
if isok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
'''
Name: Devansh
Username: singhdevansh
Github: https://github.com/Devansh3712
'''

import os
import sys
import math
from itertools import *
from io import BytesIO, IOBase
from collections import *

#<fast I/O>
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
#</fast I/O>

#<template>
mod=(10**9)+7
pi=3.14159265358979323846264338327950

def i1():	#int(input())
	return int(sys.stdin.readline())

def sf():	#input()
	return sys.stdin.readline()

def mi():	#map(int(input()))
	return map(int,sys.stdin.readline().split())

def arr():	#list(map(int,input().split()))
	return list(map(int,sys.stdin.readline().split()))

def pf(ans): #print(x)
	return sys.stdout.write(str(ans)+"\n")

def gcd(a,b):
	if a==0:
		return b
	elif b==0:
		return a
	if a>b:
		return gcd(a%b,b)
	else:
		return gcd(a,b%a)

def lcm(a,b):
	return (a*b)//gcd(a,b)
#</template>


#<solve>
def solve():
	s=input()
	if s[-1]=='s':
		print(s+'es')
	else:
		print(s+'s')
solve()
#</solve>

#<solution>
# tc=i1()
# for t in range (tc):
# 	solve()
#<solution>

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

int main(){
  int ans=0;
  for(int i=0;i<3;i++){
    char s;
    cin >> s;
    if(s=='a') ans+=100;
    else if(s=='b') ans+=10;
    else ans++;
  }
  if(ans==111) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


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

cnt = 0
for i in a:
    if i % 2 == 0:
        if (i % 3 == 0) | (i % 5 == 0):
            pass
        else:
            cnt = 1

if cnt == 1:
    print('DENIED')
else:
    print('APPROVED')


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


using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"

const ll maxn=5e5;

const ll maxx=1e13;
const ll mod=1000000007;
const ll mod1=998244353;

ll a[maxn];
map<ll,ll> mp;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    //   freopen("GREEDY.INP", "r", stdin);
    //  freopen("GREEDY.OUT", "w", stdout);
   ll n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    ll ans=0;
    for (int i=1;i<=n;i++)
    {
        ll t= a[i]-i;
        ans+=mp[t];
        mp[-(a[i]+i)]++;
    }
    cout <<ans;



}


Measured memory_bytes: 27912
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        System.out.println(solve(a, b, c));

        sc.close();
    }

    static int solve(int a, int b, int c) {
        return a + b + c - IntStream.of(a, b, c).max().getAsInt();
    }
}

Measured memory_bytes: 28244
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long int
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
}
void printMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printVec(vector<int>v)
{
for(int i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void printVec2(vector<int>v[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
 set<pair<int,int>> primeset;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primeset.insert(mkp(p,1));
}
int32_t main()
{
fastio;
int n;in n;
vector<pair<int,int>> task;
rep(i,n){
  int a;in a;int b;in b;
  task.pb(mkp(b,a));
}
sort(task.begin(),task.end());
int sum=0;
bool ans=true;
for(int i=0;i<task.size();i++){
  sum+=task[i].ss;
  if(sum>task[i].first){
    ans=false;
    break;
  }
}
if(ans)
    cout<<"Yes";
else
  out "No";
    return 0;
}


Measured memory_bytes: 6256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

vector<int> height;

int main() {
	for (int i = 0; i < 10; i++) {
		int input;
		cin >> input;
		height.push_back(input);
	}

	sort(height.begin(), height.end());

	for (int i = 9; i >= 7; i--) {
		cout << height[i] << endl;
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

Measured memory_bytes: 1216
#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++)A
#define mp make_pair
#define deb(x) cout<<#x<<"-->"<<x<<endl;
#define deb1a(v) for(auto it:v) {cout<<it<<" ";} cout<<endl;
#define deb2a(v) for(auto it:v){for(auto it1:it) {cout<<it1<<" ";}cout<<endl;}
int32_t main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
string s1,s2;
cin>>s1>>s2;
int count=0;
fo(i,3)
if(s1[i]==s2[i])
   {
       //sdeb(s1[i]);deb(s2[i]);
   count++;}
cout<<count;

}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

c = sorted(a,reverse = True)

for i in range(n):
    if c[0] == a[i]:
        b = c[1]
    else:
        b = c[0]
    print(b)

Measured memory_bytes: 14132
#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 int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
ll sub[200005];
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, d, b, i, prev = 0, ans = 0;
    cin>>n>>d>>b;
    vector<ll> a(n);
    vector<pair<ll, ll>> v(n);
    for(i=0; i<n; i++) {
    	cin>>v[i].ff>>v[i].ss;
    	a[i] = v[i].ff;
    }
    sort(all(v));
    sort(all(a));
    for(i=0; i<n; i++) {
    	prev -= sub[i];
    	v[i].ss = v[i].ss - prev;
    	if(v[i].ss <= 0) {
    		continue;
    	}
    	ll dec = v[i].ss / b;
    	if(v[i].ss % b != 0) {
    		dec++;
    	}
    	ans += dec;
    	dec = dec * b;
    	ll f = v[i].ff + 2*d + 1;
    	ll ind = lower_bound(all(a), f) - a.begin();
    	// cout<<ind<<"\n";	
    	sub[ind] += dec;
    	prev += dec;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 6528
#include<stdio.h>
 int main(void){
 	int W,H,x,y,r,a,b,c,d;
 	 	scanf("%d %d %d %d %d" ,&W,&H,&x,&y,&r); 
 	a=x+r;
 	b=x-r;
 	c=y+r;
 	d=y-r;
 	if((a<=W)&&(c<=H)&&(b>=0)&&(d>=0))
 	printf("Yes\n");
    else
printf("No\n");
 	
 	return 0;
 	}
 	
 

Measured memory_bytes: 584
//nikkei2019_b.cpp
//Sun Jan 27 20:54:06 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n;
	cin >> n;
	string a,b,c;
	cin >> a >> b >> c;

	int ans = 0;
	for (int i=0;i<n;i++){
		int eq = 0;
		if (a[i]==b[i]){
			eq++;
		}
		if (a[i]==c[i]){
			eq++;
		}
		if (b[i]==c[i]){
			eq++;
		}
		if (eq == 1){
			ans = ans + 1;
		}else if (eq == 0){
			ans = ans + 2;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

string s;

long long dfs(int pos, long long now, long long ans)
{
	if (pos == s.size()) return ans * (now == 0);
	return dfs(pos + 1, now * 10 + s[pos] - '0', ans) + dfs(pos + 1, 0, ans + now * 10 + s[pos] - '0');
}

int main()
{
	cin >> s;
	cout << dfs(0, 0, 0) << endl; 
	return 0;
}

Measured memory_bytes: 3628
n = int(input())
stations = []

for _ in range(n-1):
    c,s,f = map(int,input().split())
    stations.append((c,s,f))

def solve(t,i,stations):
    if i == n-1:
        return t
    c,s,f = stations[i]
    t = max(int((t-0.1)//f + 1)*f,s)
    return solve(t+c,i+1,stations)

for i in range(n):
    print(solve(0,i,stations))


Measured memory_bytes: 3444
/**
 *    author:  Mohamad Milhem
 *    created: 2020-04-04-18.04.41
**/

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(5)


int main(){

    FAST;
    long long n,m;
    cin >> n >> m;

    n%=m;

    long long first = n;
    long long second = abs(n - m);

    cout << min(first ,second) << endl;

    return 0;
}


Measured memory_bytes: 256