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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    vector<P_ii> v(N);
    REP(i, N){
        cin >> v[i].first;
        v[i].second = i + 1;
    }
    sort(all(v));

    REP(i, N) cout<< v[i].second << (i == N - 1 ? "" : " ");
    cout << endl;

    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int x; cin >> x;
  for(int k = 1;;++k) {
    if((k*x)%360==0) {
      cout << k << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3604
N=int(input())
A=sorted(list(map(int,input().split())))
A=[i//400 for i in A]

Colors=[0,0,0,0,0,0,0,0,0]
for i in A:
    if i>=8:
        Colors[8]+=1
    else:
        Colors[i]+=1

Count=0
for i in range(8):
    if Colors[i]>0:
        Count+=1

print(max(Count,1),Count+Colors[-1])

Measured memory_bytes: 3064
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;

int h, w, a[81][81], c[81][81];
const int base = 159 * 80, dx[] = {1, 0}, dy[] = {0, 1};
int check[2][81][base * 2 + 1];
struct piii{ int a, b, c; };
queue<piii> q;

void add(int x, int y, int val){
    if(check[(x + y) & 1][x][val + base] != x + y){
        check[(x + y) & 1][x][val + base] = x + y;
        q.push({x, y, val});
    }
}

int main(){
    scanf("%d %d", &h, &w);
    for(int i = 1; i <= h; i++) for(int j = 1; j <= w; j++) scanf("%d", &a[i][j]);
    for(int i = 1; i <= h; i++) for(int j = 1, b; j <= w; j++) scanf("%d", &b), c[i][j] = a[i][j] - b;

    int ans = 1e9;
    add(1, 1, -c[1][1]), add(1, 1, c[1][1]);
    while(!q.empty()){
        int x = q.front().a, y = q.front().b, val = q.front().c; q.pop();
        for(int d = 0; d < 2; d++){
            int nx = x + dx[d], ny = y + dy[d];
            if(nx > h || nx < 1 || ny > w || ny < 1) continue;
            add(nx, ny, val - c[nx][ny]), add(nx, ny, val + c[nx][ny]);
        }
        if(x == h && y == w) ans = min(ans, abs(val));
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 22148
#include <iostream>
#include <string>

using namespace std;

void LoopUtZeroIn(){
    int luziHoge=10;
    while(cin>>luziHoge&&luziHoge!=0);
}


int main(){
    int X,Y;
    cin>>X>>Y;
    cout<<X+(Y/2)<<endl;

    //LoopUtZeroIn();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int n;
struct point{
  double x;
  double y;
};
void print_point(struct point p){
  printf("%.8f %.8f\n",p.x,p.y);
}
void compute(int depth,double x1,double y1,double x2,double y2)
{
  double sin60 = sqrt(3.0)/2.0;
  double cos60 = 0.5;
  struct point s,t,u,v;
 
  s.x = (x1+x1+x2)/3.0;
  s.y = (y1+y1+y2)/3.0;
  t.x = (x1+x2+x2)/3.0;
  t.y = (y1+y2+y2)/3.0;
  v.x = t.x-s.x;
  v.y = t.y-s.y;
  u.x = s.x + cos60*v.x - sin60*v.y;
  u.y = s.y + sin60*v.x + cos60*v.y;
 
  if(depth>= n) return;
 
  compute(depth +1,x1,y1,s.x,s.y);
  printf("%.8f %.8f\n",s.x,s.y);
  compute(depth +1,s.x,s.y,u.x,u.y);
  printf("%.8f %.8f\n",u.x,u.y);
  compute(depth+1,u.x,u.y,t.x,t.y);
  printf("%.8f %.8f\n",t.x,t.y);
  compute(depth+1,t.x,t.y,x2,y2);
}
 
 
 
 
int main(void)
{
  scanf("%d",&n);
  printf("%.8f %.8f\n",0.0,0.0);
  compute(0,0.0,0.0,100.0,0.0);
  printf("%.8f %.8f\n",100.0,0.0);
  return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
if N%2==1:
    #print(A[0])
    #print(A[1:N//2])
    #print(A[N//2])
    print(A[0] + sum(A[1:N//2])*2 + A[N//2])
else:
    print(A[0] + sum(A[1:N//2])*2)

Measured memory_bytes: 94112
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
import java.util.HashSet;
import java.util.Iterator;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int K = sc.nextInt();
        final int Q = sc.nextInt();
        int[] p = new int[N];
        for(int i=0;i<Q;i++){
            p[sc.nextInt()-1]++;
        }
        for(int i=0;i<N;i++){
            if(K+p[i]-Q<=0){                
                System.out.println("No");
            }else{                                
                System.out.println("Yes");
            }
        }
        sc.close();
    }
}

Measured memory_bytes: 78864
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005
int n,k,arr[maxi],dp[maxi];
bool solve(int rem)
{
	if(dp[rem]!=-1)
		return dp[rem];
	bool ans=false;
	for(int i=0;i<n;i++)
		if(arr[i]<=rem)
			if(solve(rem-arr[i])==false)
			{
				dp[rem]=true;
				return true;
			}
	dp[rem]=false;
	return false;
}
int main()
{
    fastread;
    cin>>n>>k;
    for(int i=0;i<maxi;i++)
    	dp[i]=-1;
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    if(solve(k))
    	cout<<"First"<<endl;
    else
    	cout<<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main()
{
int A,B;
  
cin>>A>>B;

if(A >= 6){
    if(A >= 13){
        cout<<B<<"\n";
    }
    if(A <= 12){
        cout<<B/2<<"\n";
    }
}else{
        cout<<0<<"\n";
}

/*
if(13 <= A){
    cout<<B<<"\n";
}
if(6 <= A && A >= 12){
    if()
    cout<<B/2<<"\n";
}
if(5 >= A){
    cout<<0<<"\n";
} 
*/
return 0;
}

Measured memory_bytes: 256
def LCS(S, T):
    ls = len(S)
    lt = len(T)
    S = [-1] + [ord(s) for s in S]
    T = [-2] + [ord(t) for t in T]
    dp = [0]*((ls+1)*(lt+1))
    geta = ls + 1
    for j in range(1, lt+1):
        for i in range(1, ls+1):
            if S[i] == T[j]:
                dp[geta*j + i] = dp[geta*(j-1) + i-1] + 1
            else:
                dp[geta*j + i] = max(dp[geta*(j-1) + i], dp[geta*j + i-1])
    if not dp[-1]:
        return ''
    ans = [0]*dp[-1]
    i, j = ls, lt
    ctr = -1
    for _ in range(ls + lt):
        if i == 0 or j == 0:
            break
        if S[i] == T[j]:
            ans[ctr] = S[i]
            i -= 1
            j -= 1
            ctr -= 1
        elif dp[(j-1)*geta + i] >= dp[j*geta + i-1]:
            j -= 1
        else:
            i -= 1
    return ''.join([chr(a) for a in ans])
s = input().strip()
t = input().strip()
print(LCS(s, t))

Measured memory_bytes: 110832
#include <cstdio>
#include <algorithm>
using namespace std;
int n, z, w, a[2002];
int main() {
    scanf("%d %d %d", &n, &z, &w);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    if (n == 1) {
        printf("%d", abs(a[1]-w));
        return 0;
    }
    printf("%d", max(abs(a[n]-w), abs(a[n]-a[n-1])));
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    String ans = "";
    int d = 0;
    for (int i = 0; i < N; i++) {
      if (S.charAt(i) == '(') {
        ans = ans + "(";
        d++;
      } else {
        if (d > 0) {
          d--;
          ans = ans + ")";
        } else {
          ans = "(" + ans + ")";
        }
      }
    }
    while (d-- > 0) {
      ans = ans + ")";
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

int main() {
    int N; cin >> N;
    vector<int> A(N, INT_MAX), B(N - 1);
    rep(i, N - 1) cin >> B[i];
    rep(i, N - 1) {
        A[i] = min(A[i], B[i]);
        A[i + 1] = min(A[i + 1], B[i]);
    }
    int sum = 0;
    rep(i, N) sum += A[i];
    cout << sum << "\n";
}

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

#define int long long

signed main() {
	int n, m;
	cin >> n >> m;
	priority_queue<int> q;
	for(int i = 0; i < n; i++) {
		int t; cin >> t;
		q.push(t);
	}
	while(m--) {
		int x = q.top();
		q.pop();
		x /= 2;
		q.push(x);
	}
	int res = 0;
	while(!q.empty()) {
		res += q.top();
		q.pop();
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    string S;
    string T;
    cin >> S >> T;
    int ans = 0;
    for(int i=0;i<S.size(); i++){
        if(S[i] != T[i]) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3856
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_146A
{
    class Program
    {
        static void Main(string[] args)
        {
            String S;

            S = Console.ReadLine();

            if (S == "SUN")
            {
                Console.WriteLine("7");
            }

            else if (S == "MON")
            {
                Console.WriteLine("6");
            }

            else if (S == "TUE")
            {
                Console.WriteLine("5");
            }

            else if (S == "WED")
            {
                Console.WriteLine("4");
            }

            else if (S == "THU")
            {
                Console.WriteLine("3");
            }

            else if (S == "FRI")
            {
                Console.WriteLine("2");
            }

            else if (S == "SAT")
            {
                Console.WriteLine("1");
            }

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll quick(ll a,ll b){
	ll res =1;
	while(b){
		if(b&1){
			res=res*a%mod;
		}
		a=a*a%mod;
		b>>=1;
	}
	return res;
}
int main(){
	ll n;
	cin>>n;
	ll ans=((quick(10,n)-2*quick(9,n)+quick(8,n))%mod+mod)%mod;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3624
/*#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b));
} A*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,now,max=0;
	cin>>n;
	string s;
	cin>>s;
	bool sub[26][2];
	for(int i=0;i<n-1;i++)
	{
		memset(sub,false,sizeof(sub));
		now=0;
		for(int j=0;j<=i;j++)
		sub[s[j]-'a'][0]=true;
		for(int j=i+1;j<n;j++)
		sub[s[j]-'a'][1]=true;
		for(int i=0;i<26;i++)
		if(sub[i][0]==true&&sub[i][1]==true)now++;
		if(now>max) max=now;
	} 
	cout<<max;
}

Measured memory_bytes: 256
// KNOW NOTHING!
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(ll i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define sz(x) (int)x.size()
#define szs(x) (int)s.length()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef queue<int> qin;
typedef deque<ll> dqll;
typedef deque<int> dqint;
typedef priority_queue<ll> pqll;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}

int main()
{
/*
freopen ("input.txt","r","stdin");
freopen ("output.txt","w","stdout");
*/
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
ll x; cin>>x;
F (i,-120,120,1) {
	F (j,-120,120,1) {
		if (pwr (i,5) - pwr(j,5)==x) {cout<<i<<" "<<j; exit(0);}
	}
}
return 0;
}
/* What we know is a drop , but what we don't know is an ocean !*/

Measured memory_bytes: 3604
roman = {'I':1, 'V':5, 'X':10, 'L':50, 'C':100, 'D':500, 'M': 1000}
while(True):
    try:
        x = list(input())
    except:
        break
    
    ans = 0
    i = 0
    
    while i < len(x):
        if i+1 < len(x) and roman[x[i]] < roman[x[i+1]]:
            ans += roman[x[i+1]] - roman[x[i]]
            i += 1
        else: ans += roman[x[i]]
        i += 1
    print(ans)


Measured memory_bytes: 5564
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18;

int a[200010];
signed main(){
	int n;
	scanf("%lld", &n);
	for(int i = 0;i < n;i++)scanf("%lld", &a[i]);
	int sum = a[0];
	for(int i = 1;i < n;i++){
		sum += a[i];
		a[i] = a[i]+a[i-1];
	}
	int ans = INF;
	for(int i = 0;i < n-1;i++){
		int x = llabs(a[i]-(sum-a[i]));
		ans = min(ans, x);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m, a[20000] = {}, b, x, y, z, k, in[20000] = {}, ax[20000] = {}, d = 1, w, h, typ = 0;
	long long dp[200005] = {}, memo[200005] = {},res;
	string str, str2;
	cin >> n >> m >> b;
	cout << m * (b / n);
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N,M,K;
int A[20001]={};
const long long INF=100000000000000;
long long dp[20001]={};
int maxdp[20001][1001]={};
int mindp[20001][1001]={};

int maxD(int n2,int n3){
	int ans2=A[n2+n3];
	if(maxdp[n2][n3]>0)return maxdp[n2][n3];
	if(n3>1)ans2=max(maxD(n2,n3-1),A[n2+n3]);
	maxdp[n2][n3]=ans2;
	return ans2;
}
int minD(int n2,int n3){
	int ans2=A[n2+n3];
	if(mindp[n2][n3]>0)return mindp[n2][n3];
	if(n3>1)ans2=min(minD(n2,n3-1),A[n2+n3]);
	mindp[n2][n3]=ans2;
	return ans2;
}

long long calc(int n1){
	long long ans=INF;
	if(dp[n1]>-1)return dp[n1];
	for(int i=1;i<M+1&&i<n1+1;i++){
		ans=min(ans,calc(n1-i)+(long long)K+(long long)i*(long long)(maxD(n1-i,i)-minD(n1-i,i)));
	}
	dp[n1]=ans;
	return ans;
}
int main() {
	cin>>N>>M>>K;
	for(int i=1;i<N+1;i++)cin>>A[i];
	fill(dp,dp+20001,-1);
	dp[0]=0;
	cout<<calc(N)<<endl;
	return 0;
}



Measured memory_bytes: 160996
import sys

def comb(n, r, fact, revfac, mod):
    return (fact[n] * revfac[n-r] * revfac[r]) % mod

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    A.sort()
    B.sort()
    if len(A) > len(set(A)) or len(B) > len(set(B)):
        total = 0
    elif A[-1] != N * M or B[-1] != N * M:
        total = 0
    else:
        mod = 7 + 10 ** 9
        factorial = [1] * 1000001
        revfac = [1] * 1000001
        for i in range(1, 1000001):
            factorial[i] = (factorial[i-1] * i) % mod
        revfac[1000000] = pow(factorial[1000000], mod-2, mod)
        for i in reversed(range(1, 1000000)):
            revfac[i] = (revfac[i + 1] * (i + 1)) % mod
    
        total = 1
        row, line = 0, 0
        used = 0
        count = 0
    
        while row < M and line < N:
            #####debag#####
            #print(count, A[line], B[row], used)
            #####debag#####

            if A[line] < B[row]:
                if A[line] - used >= M - row:
                    ##
                    #print(A[line] - used, M - row)
                    ## 
                    total *= (factorial[M - row] * comb(A[line] - used - 1, M - row - 1, factorial, revfac, mod)) % mod
                    total %= mod
                    line += 1
                    used += M - row
                else:
                    total = 0
                    break
            elif A[line] > B[row]:
                if B[row] - used >= N - line:
                    ##
                    #print(B[row] - used, N - line)
                    ##
                    total *= (factorial[N - line] * comb(B[row] - used - 1, N - line - 1, factorial, revfac, mod)) % mod
                    total %= mod
                    row += 1
                    used += N - line
                else: 
                    total = 0
                    break
            else:
                if A[line] - used >= N - line + M - row - 1:
                    ##
                    #print(A[line]-used, N + M - line - row - 1)
                    ##
                    total *= (factorial[N - line + M - row - 2] * comb(A[line] - used - 1, N - line + M - row - 2, factorial, revfac, mod)) % mod
                    total %= mod
                    used += N - line + M - row - 1
                    line += 1
                    row += 1   
                else:
                    total = 0
                    break

            #####debag######
            #count += 1
            #print(total)
            #####debag######

    print(total)

    return

if __name__ == "__main__":
    solve()

Measured memory_bytes: 82292
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    map<string,ll> scount;
    rep(i, N)
    {
        string s;
        cin >> s;
        sort(s);
        ++scount[s];
    }
    //
    ll ans = 0;
    for (auto& s : scount)
    {
        ll c = s.second;
        ans += c* (c - 1) / 2;
    }
    cout << ans;
    //
    return 0;
}

Measured memory_bytes: 11448
N,K,L = map(int, input().split())


class UFT:
    def __init__(self, N):
        self.UFdata = [-1] * (N+1)
        self.rank   = [0]  * (N+1)

    def find(self,x):
        UFdata = self.UFdata
        while UFdata[x] != -1:
            x = UFdata[x]
        return x

    def unite(self,x,y):
        UFdata = self.UFdata
        rank = self.rank 
        find = self.find

        x = find(x)
        y = find(y)
        if x != y:
            if rank[x] < rank[y]:
                x,y = y,x
            if rank[x] == rank[y]:
                rank[x] += 1
            UFdata[y] = x       
            

UF1 = UFT(N)
UF2 = UFT(N)
ans = [1] * (N+1)
# MAP= [ [0] * (N+1) for _ in range(N+1)]
import sys
input = sys.stdin.readline
#PQ = [ [int(j) for j in input().split()] for _ in range(K)]
#RS = [ [int(j) for j in input().split()] for _ in range(L)]

for i in range(K):
    p,q = map(int,input().split())
    UF1.unite(p,q)
for i in range(L):
    p,q = map(int,input().split())#RS[i]
    UF2.unite(p, q)
counter=[]
from collections import defaultdict
cntdic =defaultdict(int)
for i in range(1,N+1):
  counter.append(UF1.find(i)+UF2.find(i)*10**6)
  cntdic[counter[-1]]+=1 

ans = [0]*(N+1)
for i in range(1,N+1):
    ans[i] = cntdic[counter[i-1]]

del ans[0]
# print(" ".join( map(lambda x: str(x), connected_num[1:])))
print(" ".join( map(lambda x: str(x), ans)))



Measured memory_bytes: 102876
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

char chest[1005][1005];
int dp[1005][1005];

signed main()
{
	int h,w;
	while(cin>>h>>w){
		getchar();
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++)
				cin>>chest[i][j];
			getchar();
		}
		
		/*for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++)
			cout<<chest[i][j];
			cout<<endl;
		}*/
				
		memset(dp,0,sizeof dp);
		dp[1][1]=1;//边界
		//从上向下，从左向右滚动到dp[h][w]
		for(int i=1;i<=h;i++)
			for(int j=1;j<=w;j++){
		 		if(chest[i][j]=='.'&&(i!=1||j!=1)){
		 			dp[i][j]=((dp[i-1][j]%mod)+(dp[i][j-1]%mod))%mod;
				}
			}
		 		
		cout<<dp[h][w]<<endl;
	}
	return 0;
}

Measured memory_bytes: 8504
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;

long long N, X[1009], Y[1009], H[1009]; vector<tuple<long long, long long, long long>>vec;

int main() {
	cin >> N; tuple<long long, long long, long long>G = make_tuple(-1, -1, -1);
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> Y[i] >> H[i];
		if (H[i] >= 1) G = make_tuple(X[i], Y[i], H[i]);
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			long long V = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j); V = max(V, 0LL); bool flag = true;
			for (int k = 1; k <= N; k++) {
				long long VV = V - abs(X[k] - i) - abs(Y[k] - j); VV = max(VV, 0LL);
				if (H[k] != VV) flag = false;
			}
			if (flag == true) vec.push_back(make_tuple(i, j, V));
		}
	}
	if (vec.size() == 1) {
		cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <set>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
 
using namespace std;
 
string s;
int n;
int cnt[26];
 
typedef struct node{
    int id;
    node* right;
    node* left;
    node(){right = nullptr,left = nullptr;}
} node;
 
int dfs(node* nd){
    if(nd->left){
        int le = dfs(nd->left);
        if(le < 0){
            return -1;
        }
        int ri = dfs(nd->right);
        if(ri < 0){
            return -1;
        }
        if(le == 0 && ri == 0){
            return -1;
        }
        if(le == 0){
            return ri-1;
        }else if(ri == 0){
            return le-1;
        }else{
            return -1;
        }
    }else{
        return cnt[nd->id];
    }
}
 
node* expr(int& pos);
node* factor(int& pos);
 
 
 
node* expr(int& pos)
{
    node* nw = new node;
    node* l = factor(pos);
    pos++;
    if(pos == (int)s.size()+1){
        return l;
    }
    node* r = factor(pos);
    nw->left = l;
    nw->right = r;
    return nw;
}
 
node* factor(int& pos){
    if(isalpha(s[pos])){
        node* nw = new node;
        n++;
        nw->id = s[pos]-'a';
        pos++;
        return nw;
    }
    pos++;
    node* res = expr(pos);
    pos++;
    return res;
}
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    n = 0;
    int pos = 0;
    node* root = expr(pos);
    rep(i,n){
        char c;
        int a;
        cin >> c >> a;
        cnt[c-'a'] = a;
    }
    int res = dfs(root);
    if(res != 0){
        cout << "No\n";
    }else{
        cout << "Yes\n";
    }
}



Measured memory_bytes: 3256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class E
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Scanner.Scan<int>();
            var inf = (int)1e9;
            var (zmin, zmax) = (inf, -inf);
            var (wmin, wmax) = (inf, -inf);
            for (var i = 0; i < N; i++)
            {
                var (x, y) = Scanner.Scan<int, int>();
                zmin = Math.Min(zmin, x + y);
                zmax = Math.Max(zmax, x + y);
                wmin = Math.Min(wmin, x - y);
                wmax = Math.Max(wmax, x - y);
            }
            Console.WriteLine(Math.Max(zmax - zmin, wmax - wmin));
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 41388
#include <stdio.h>
int main(){
	int N;
	scanf("%d",&N);
	int data;
	scanf("%d",&data);
	int max=-1000000000;
	int min=data;
	int i;
	for(i=1;i<N;i++){
		scanf("%d",&data);
		max=max>data-min?max:data-min;
		min=min<data?min:data;
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  
  if(A > B){
    cout << A + (A-1) << endl;
  }
  
  if(A < B){
    cout << B + (B-1) << endl;
  }
  
  if(A == B){
    cout << A + B << endl;
  }
  
}
  

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

int n,m;
bool c,vis[105],sk[105];
vector<int>G[105];

void dfs(int u) {
	if (c) return;
	vis[u]=sk[u]=1;
	for (int v:G[u]) {
		if (vis[v] && sk[v]) {
			c=1;
			return;
		}
		if (!vis[v]) dfs(v);
	}
	sk[u]=0;
}

int main() {
	cin>>n>>m;
	for (int i=0;i<m;i++) {
		int u,v; cin>>u>>v;
		G[u].pb(v);
	}
	for (int i=0;i<n;i++) {
		if (c) break;
		if (!vis[i]) dfs(i);
	}
	cout<<c<<'\n';
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> d(n);
  set<int> s;
  for(int i = 0; i < n; i++)
  {
    cin >> d[i];
    s.insert(d[i]);
  }
  cout << s.size() << endl;
}
  

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

signed main(){
	int X, Y, i, j;
	scanf("%d%d", &X, &Y);
	for(i = 0; i <= 100; i++){
		for(j = 0; j <= 100; j++){
			if(i + j == X && 2 * i +  4 * j == Y){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///

/*....................................Values................................................*/
#define inf 1<<30
#define p5 100007
#define p6 1000007
#define PI acos(-1)
#define M 1000000007

/*....................................Functions.............................................*/
#define sqr(x) x*x
#define sc scanf
#define pf printf
#define scin(x) sc("%d",&(x))
#define scin2(x,y) sc("d",&(x),&(y))
#define scin3(x,y,z) sc("d%d",&(x),&(y),&(z))
#define scln(x) sc("%lld",&(x))
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(), v.end()
#define ok cout << "ok" << endl
#define mem(x,y) memset(x,y,sizeof(x))
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

/*...................................Data_Types............................................*/
#define lli long long int
#define ull unsigned long long int
#define pii pair < int, int>
#define pll pair < ll, ll>
#define veci vector<int>
#define vecl vector<long long int>
#define vecp vector< pair<int,int> >
#define mapstrint map< string , int >
#define mapstrstr map< string , string >
#define mapint map< int, int >
#define uset unordered_set
#define umap unordered_map
#define pq priority_queue

#define pb push_back
#define mp make_pair
#define ss stringstream

/*.....................................Loops...............................................*/
#define rep( i , a , b ) for( i=a ; i<b ; i++)
#define rev( i , a , b ) for( i=a ; i>=b ; i--)
#define repx( i ,a,b, x) for( i=a ; i<b ; i+=x)

#define FastRead ios_base::sync_with_stdio(0);cin.tie(0)

//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//long power(long int x, long int y){ int temp; if( y == 0) return 1; temp = power(x, y/2); if (y%2 == 0) return temp*temp; else return x*temp*temp; }
/*lli gcd(lli x,lli y)
{
if(x==0) return y;
return gcd(y%x,x);
}*/
/*
int dx[5] = {1, -1, 0, 0 };
int dy[5] = {0, 0, 1, -1};
*/

using namespace std;

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

    int S = 1;
    for (int i = 0; i < D; i++)
        S *= 100;
    if (N <= 99)
    {
        cout << S * N << endl;
    }
    else
    {
        cout << S * 101 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
ll max(ll x, ll y) {
	return x > y ? x : y;
}
int main() {
	int k, a, b, yen = 0;
	scanf("%d%d%d", &k, &a, &b);
	ll ans = k + 1, num = 1;
	for (int i = 0; i < k; i++) {
		if (yen == 1) {
			num += b;
			yen--;
		} else if (num < a) {
			num++;
		} else {
			num -= a;
			yen++;
		}
	}
	if (yen == 1) {
		num += a + 1;
	}
	printf("%lld\n", max(ans, num));
	return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  REP(i,n){
    int a;
    cin >> a;
    ans += a;
  }
  ans -= n;
  
  cout << ans << endl;
  
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int n, m, ans=0;
    cin >> n >> m;
    vi s(m), c(m);
    vi v(n, -1);
    rep(i, m){
        cin >> s[i] >> c[i];
        if(s[i]==1&&c[i]==0&&n>1){
            cout<<-1<<endl;
            return 0;
        }
        if(v[s[i]-1]==-1||v[s[i]-1]==c[i]){
            v[s[i]-1]=c[i];
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    rep(i, n){
        if(v[i]==-1){
            if(i==0&&n>1){
                v[i]=1;
            }else{
                v[i]=0;
            }
        }
    }
    rep(i, n){
        ans+=v[i]*pow(10,n-i-1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
//package cf;
import java.io.*;
import java.util.*;
public class Main {
    static int p=1000000007;
    public static void main(String[] args) throws Exception{
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCII"), 512);
        FastReader sc=new FastReader();
        int n = sc.nextInt();
        int W = sc.nextInt();
        int w[]=new int[n];
        int v[]=new int[n];
        int sum=0;
        for(int i=0;i<n;i++)
        {
            w[i]=sc.nextInt();
            v[i]=sc.nextInt();
            sum+=v[i];
        }

        StringBuilder sb=new StringBuilder();
        long dp[][]=new long[n+1][sum+1];
        HashMap<Integer,Integer> h1=new HashMap<>();
        h1.put(0,0);
        long max=0;
        int in=0;

        for(int i=0;i<=n;i++) {
        dp[i][0]=0;
        }

        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=sum;j++)
            {

             if(j-v[i-1]>=0&&dp[i-1][j-v[i-1]]!=0||j-v[i-1]==0)
             {
                 dp[i][j]=Math.min(dp[i-1][j]==0?Long.MAX_VALUE:dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
             }
             else
             {
                 dp[i][j]=dp[i-1][j];

             }
             }
        }

        for(int i=1;i<=sum;i++)
        {
            for(int j=1;j<=n;j++)
            {
                if(dp[j][i]<=W&&dp[j][i]!=0)
                {
                    max=dp[j][i];
                    in=i;
                }
            }
        }
        sb.append(in);
        out.write(sb.toString());
        out.flush();
    }


static class pair
{
    long a,d;
    StringBuilder sb;

    public pair(long a, long d, StringBuilder sb) {
        this.a = a;
        this.d = d;
        this.sb = sb;
    }
}



    ///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }


}


Measured memory_bytes: 137668
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
  	if(a < 10 && b < 10){
    	console.log(a*b);
    }
  	else{console.log(-1);}
      
    

	//出力
//	console.log('%d %s',a+b+c,s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
N, M = map(int,input().split())
ls = []
for m in range(M):
    p, y = map(int,input().split())
    ls.append([p,y])
sorted_ls = sorted(ls,key=lambda x:x[1])
counter = [0 for i in range(N+1)]
d = {}
for p,y in sorted_ls:
    counter[p]+=1
    num = counter[p]
    d[y] = num
for p,y in ls:
    #print (p,d[y])
    print (str(p).zfill(6)+str(d[y]).zfill(6))



Measured memory_bytes: 33232
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
7
2 1
0 0
1 2
2 2
4 2
1 3
3 3

output:
5
0 0
2 1
4 2
3 3
1 3

The operator module functions allow multiple levels of sorting. For example, to sort by grade then by age:

sorted(student_tuples, key=itemgetter(1,2))
[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]

sorted(student_objects, key=attrgetter('grade', 'age'))
[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]
"""

import sys
from operator import attrgetter

EPS = 1e-9


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def check_ccw(p0, p1, p2):
    a, b = p1 - p0, p2 - p0
    if cross(a, b) > EPS:
        # print('COUNTER_CLOCKWISE')
        flag = 1
    elif cross(a, b) < -1 * EPS:
        # print('CLOCKWISE')
        flag = -1
    elif dot(a, b) < -1 * EPS:
        # print('ONLINE_BACK')
        flag = 2
    elif abs(a) < abs(b):
        # print('ONLINE_FRONT')
        flag = -2
    else:
        # print('ON_SEGMENT')
        flag = 0
    return flag


def convex_check_Andrew(_polygon):
    upper, lower = list(), list()
    _polygon.sort(key=attrgetter('real', 'imag'))

    upper.extend((_polygon[0], _polygon[1]))
    lower.extend((_polygon[-1], _polygon[-2]))

    for i in range(2, points):
        n1 = len(upper)
        while n1 >= 2 and check_ccw(upper[n1 - 2], upper[n1 - 1], _polygon[i]) == 1:
            n1 -= 1
            upper.pop()
        upper.append(_polygon[i])

    for j in range(points - 3, -1, -1):
        n2 = len(lower)
        while n2 >= 2 and check_ccw(lower[n2 - 2], lower[n2 - 1], _polygon[j]) == 1:
            n2 -= 1
            lower.pop()
        lower.append(_polygon[j])

    lower.reverse()
    lower_min = min(lower, key=attrgetter('imag', 'real'))
    min_index = lower.index(lower_min)
    lower_right = lower[min_index:]
    lower_left = lower[:min_index]

    for k in range(len(upper) - 2, 0, -1):
        lower_right.append(upper[k])
    return lower_right + lower_left


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    points = int(_input[0])
    p_info = map(lambda x: x.split(), _input[1:])

    polygon = [int(x) + int(y) * 1j for x, y in p_info]
    ans = convex_check_Andrew(polygon)
    print(len(ans))
    for ele in ans:
        print(int(ele.real), int(ele.imag))

Measured memory_bytes: 31028
#include<stdio.h>
int main(){
  char s[19];
 gets(s);
  for(int i=0;i<19;i++){
    if(s[i]==','){
      printf("%c",' ');
    }else{
      printf("%c",s[i]);
    }
  }
  printf("\n");
  
 return 0; 
}

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

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

  vector<int> a(100);

  for(int i = 0; i < n; i ++)
    cin >> a.at(i);

  int alice = 0, bob = 0;

  for(int i = 0; i < n; i ++){
    int max = *max_element(a.begin(), a.end());

    if(i%2) bob += max;
    else alice += max;
    
    for(int j = 0; j < n; j ++)
      if(a.at(j) == max){
        a.at(j) = 0;
        break;
      }
  }

  cout << alice - bob << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(15);
  int n;
  cin >> n;
  Vi a(n);
  rep(i,0,n) cin >> a[i];
  Vout(a);
  int now;
  rep(i,1,n){
    now=a[i];
    rep(j,0,i){
      if(a[j]>now) {
        //swap(a[i],a[j]);
        a.erase(a.begin()+i);  //  ←計算量に注意
        a.insert(a.begin()+j,now);
        break;
      }
    }
    Vout(a);
  }
  return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int P, N[6], cost[6] = {500, 100, 50, 10, 5, 1};

int check(int p){
  int cnt = 0;
  REP(i, 6){
    int n = min(N[i], p / cost[i]);
    cnt += n;
    p -= n * cost[i];
  }
  return p == 0 ? cnt : -1;
}

int f(int p){
  int res = 0;
  REP(i, 6){
    res += p / cost[i];
    p %= cost[i];
  }
  return res;
}

int main() {
  while(cin >>P && P){
    int sum = 0, ans = 1e9;
    REP(i, 6) { cin >>N[5 - i]; sum += N[5 - i] * cost[5 - i]; }
    FOR(i, P, sum + 1){
      int cnt = check(i);
      if(cnt != -1) ans = min(ans, cnt + f(i - P));
    }
    cout <<ans <<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
long long f[2000000],n[2000000];
long long p=1000000007;
long long mi(long long x,long long y)
{
	long long ans=1;
	while(y)
	{
		if(y&1) ans=ans*x%p;
		x=x*x%p;
		y>>=1;
	}
	return ans;
}
long long mo(int x,int y)
{
	if(x==y||y==0)
	{
		return 1;
	}
	return ((f[x]*n[y])%p*n[x-y]%p);
}
long long need(int x1,int y1,int x2,int y2)
{
	return mo(x2-x1+y2-y1,x2-x1);
}
int main(){
	int nn,m,a,b,ans=0;
	f[1]=1;
	for(int i=2;i<=200000;i++)
	{
		f[i]=(f[i-1]*i)%p;
	}
	n[200000]=mi(f[200000],p-2);
	for(int i=199999;i>=1;i--)
	{
		n[i]=(n[i+1]*(i+1))%p;
	}
	cin>>nn>>m>>a>>b;
	for(int i=1;i<=nn-a;i++)
	{
		ans+=(need(1,1,i,b)*need(i,b+1,nn,m))%p;
		ans%=p;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5888
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int a[101] = {0};
  int max = 0, n;

  while(cin >> n) ++a[n];  
  for(int i=1; i<=100; ++i) {
    if(a[i] > max) max = a[i];
  }
  for(int i=1; i<=100; ++i) {
    if(a[i] == max) cout << i << endl;;
  }

}




Measured memory_bytes: 2980
def main():
    N = int(input())
    for i in range(N):
        t,x,y = list(map(int,input().split()))
        if ((t%2)==(abs(x+y)%2)) and (abs(x+y)<=t):

            flag = True
        else:
            flag = False
            break
    if flag == True:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060