akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
	PrintWriter out;
    StringTokenizer st;
    BufferedReader br;
 	
 	class Pair implements Comparable<Pair>
	{
	    int f;
	    int s;
 
	    Pair(int t, int r) {
	       f = t;
	       s = r;
	    }
	    public int compareTo(Pair p)
	    {
	    	if(this.f!=p.f)
	    		return this.f-p.f;
 
	    	return this.s-p.s;
	    }
 	}
 	class Sort implements Comparator<Integer> 
	{ 
	    public int compare(Integer a, Integer b) 
	    { 
	    	if(a < 0)
	    		a *= -1;
	    	if(b < 0)
	    		b *= -1;
	    	return a.compareTo(b);
	    } 
	}
 
	String ns() {
        while (st == null || !st.hasMoreElements()) {
 
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }
 
    int nextInt() {
        return Integer.parseInt(ns());
    }
 
    long nextLong() {
        return Long.parseLong(ns());
    }
 
    double nextDouble() {
        return Double.parseDouble(ns());
    }
	
	int upperBound(long a[],long key)
	{
		int l=0,r=a.length-1;
		int i=-1;
 
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid]<key)
				l=mid+1;
 
			else{
				i=mid;	
				r=mid-1;
			}
			
		}
		return i;
	}
	int lowerBound(Pair[] a , long key)
	{
		int l = 0, r = a.length- 1;
		int i = -1;
 	
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid].f<key)
			{
				i=mid;
				l=mid+1;	
			}
 
			else
				r=mid-1;
			
		}
		return i;
	}
 
	long power(long x,long y)
	{
	    long ans=1;
	    
	    while(y!=0)
	    {
	        if(y%2==1) ans=(ans*x)%mod;
	        x=(x*x)%mod;
	        y/=2;
	    }
	    return ans%mod;
	}
	
 
	int mod= 1000000007;
	long gcd(long x ,long y)
	{
		if(y==0)
			return x;
		return gcd(y,x%y);
	}
 
	// ArrayList a[];
	// int vis[],cnt=0;
	// void dfs(int ver)
	// {
	// 	ArrayList<Integer> l=a[ver];
	// 	if(l.size()==1)
	// 		cnt++;
	// 	for(int v:l)
	// 	{
	// 		if(vis[v]==0){
	// 			vis[v]=vis[ver]+1;
	// 			dfs(v);
	// 		}
	// 	}
	// }
 
 	int countSetBits(long n) 
    { 
        int count = 0; 
        while (n > 0) { 
            n &= (n - 1); 
            count++; 
        } 
        return count; 
    }

	void solve() throws IOException{
		int n = nextInt();
		int a[] = new int[n];
		int cnt = 0;
		
		for(int i = 0; i < n; i++)
			a[i] = nextInt();
		
		for(int i = 0; i < n; i += 2)
		{
			if(a[i] % 2 == 1)
				cnt++;
		}
		out.println(cnt);
	}
 	
    void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
		solve();
		out.flush();
 
		out.close();
	}
 
	public static void main(String args[]) throws IOException {
		new Main().run();
	}		
}
 

Measured memory_bytes: 32920
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)



int main(){
    int n; cin>>n;
    vector<ll> a(n);
    rep(i,0,n) cin>>a[i];
    vector<ll> b1(n);
    vector<ll> b2(n);
    rep(i,0,n){
        if (a[i]+i<n) b1[a[i]+i]++;
        if (0<=i-a[i]&&i-a[i]<n) b2[i-a[i]]++;
    }
    ll ans = 0;
    rep(i,0,n){
        ans += b1[i]*b2[i];
    }
    cout<<ans<<endl;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

int main() {
    string s, t;
    cin >> s >> t;
    Int res = INF;
    for (Int i = 0; i < (Int)s.size(); i++) {
        bool check = true;
        Int cnt = 0;
        for (Int j = 0; j < (Int)t.size(); j++) {
            if (i + j < (Int)s.size()) {
                if (s[i + j] != t[j]) {
                    cnt++;
                }
            } else {
                check = false;
                break;
            }
        }
        if (check) {
            res = min(res, cnt);
        }
    }
    print(res);
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}

const int mod = 1000000007;
const int max_n = 200005;
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
    int n;cin >> n;
    vector<mint> dp(n+1);
    dp[0]=1;
    mint cum=0;
    rep(i,n+1){
        if(i-3>=0)cum+=dp[i-3];
        dp[i]+=cum;
    }
    cout << dp[n] <<endl;
}  

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	int N;
	cin>>N;
	vl A(N);
	int order=0;
	rep(i,0,N){
		cin>>A[i];
		if(A[i]==0){
			cout<<0<<endl;
			return 0;
		}
		rep(j,2,20){
			if(A[i]<pow(10,j)){
				order+=j-1;
				break;
			}
		}
	}
//	if(order>18){
	//	cout<<-1<<endl;
		//return 0;
//	}
	DBG("","","","");
	ll ans;
	ans=A[0];
	rep(i,1,N){
		ll check;
		check=INF/ans;
		if(INF%ans) check++;
		if(check<A[i]){
			ans=-1;
			break;
		}
		else{
			ans*=A[i];
		}
	}
	if(ans>INF) ans=-1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4088
t=4
v = []
while t>=0:
    v.append(int(input()))
    t = t-1

k = int(input())
n = 4
l = False
while n>=0:
    for i in range(n-1):   
        soma = v[n] - v[i]
        if soma > k:
            print(":(") 
            l = True
            break
    if l:
        n = -2
    else: 
        n = n-1
if n == -1:  
    print("Yay!")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
ll mpow(ll x, ll y, ll m) {
    if(y == 0) {
        return 1;
    } else {
        ll z = mpow(x, y / 2, m);
        return z * z % m * (y % 2 ? x % m : 1) % m;
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    sort(a.begin(), a.end());
    bool valid = n % 2 ? a[0] == 0 : true;
    for(int i = n % 2, j = (n % 2 ? 2 : 1); i + 1 < n and valid; i += 2, j += 2) {
        valid &= a[i] == j and a[i + 1] == j;
    }
    cout << (valid ? mpow(2, n / 2, 1'000'000'007) : 0) << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,n,arr[105];
    cin>>x>>n;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }

    int ans=0,flag=0;
    int k=0,a=0,b=0;
    while(flag==0)
    {
        a=x+k;
        b=x-k;
        int d=0,e=0;
        for(int i=0;i<n;i++)
        {
            if(a==b)
            {
                if(arr[i]==a)
                {
                    d=1;
                    e=1;
                }
            }
            else if(arr[i]==a)
            {
                d=1;
            }
            else if(arr[i]==b)
            {
                e=1;
            }
        }
        if(d==0&&e==0)
        {
            ans=min(a,b);
            flag=1;
        }
        else if(d==0)
        {
            ans=a;
            flag=1;
        }
        else if(e==0)
        {
            ans=b;
            flag=1;
        }
        k++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
n, a, b, c, d = gets.split.map(&:to_i)
ss = gets.chomp

ac = ss[a - 1..c]
bd = ss[b - 1..d]

valid = true
if c < d
  valid = false if ac.include?("##") || bd.include?("##")
elsif c > d
  valid = false if !ss[b - 2..d].include?("...")
end

puts valid ? "Yes" : "No"


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

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

    long long sum = 0;

    for (long long i = 1; i <= N; i++){
        if (i % 3 == 0 || i % 5 == 0){
            sum += 0;
        }
        else {
            sum += i;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3624
n = int(input())
s = input()

x = 0
xmax = 0

for i in range(n):
    if s[i] == "I":
        x += 1
        xmax = max(xmax, x)
    elif s[i] == "D":
        x -= 1
        xmax = max(xmax, x)

print(xmax)

Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
a.insert(0,0)   #最初に0
a.insert(n+1,0) #最後に0

res = sum([abs(a[i]-a[i+1]) for i in range(n+1)]) #階差の和

for i in range(1,n+1):
    tmp = res + abs(a[i-1]-a[i+1]) - (abs(a[i-1]-a[i]) + abs(a[i]-a[i+1]))
    print(tmp)

Measured memory_bytes: 65132
from collections import defaultdict

N, M = map(int, input().split())

A = defaultdict(list)
for i in range(M):
    P, Y = map(int, input().split())
    A[P].append((Y, i))

ans = [''] * M
for p, grp in A.items():
    for j, (_, i) in enumerate(sorted(grp), start=1):
        ans[i] = '%06d%06d' % (p, j)
print(*ans, sep='\n')



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

using ll=long long;

const ll inf =1LL << 62;
const ll mod=1000000007LL;

inline ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
inline ll ADD(const ll &a, const ll &b,const ll &mod) { return a+b<mod?a+b:a+b-mod;}
inline ll SUB(const ll &a, const ll &b,const ll &mod) { return a-b>=0?a-b:a-b+mod;}
inline ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
inline ll INV(ll a,ll mod){ll x,y;extgcd(a,mod,x,y);return (x%mod+mod)%mod;}
inline ll DIV(const ll &a, const ll &b,const ll &mod) {return MUL(a,INV(b,mod),mod);}
inline ll POW(ll a,ll n,ll mod){ll b=1LL;for(a%=mod;n;a=MUL(a,a,mod),n>>=1)if(n&1) b=MUL(b,a,mod); return b;}

ll a[410],b[410];
ll coef[410][410];
ll sum[410][410];

int n,c;

ll rec(ll i,ll res){
	if(i==n) return res==0;

	ll &ret=coef[i][res];
	if(ret!=-1) return ret;

	ret=0LL;
	rrep(nxt,res+1){
		const ll d=res-nxt;
		ll cur=SUB(sum[b[i]][d],sum[a[i]-1][d],mod);
		ll tar=MUL(cur,rec(i+1,nxt),mod);
		ret=ADD(ret,tar,mod);
	}
	return ret;
}

int main(void){
	rep(i,401) rep(d,401){
		if(i-1>=0) sum[i][d]=sum[i-1][d];
		sum[i][d]=ADD(sum[i][d],POW(i,d,mod),mod);
	}

	cin >> n >> c;
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];

	rep(i,n)rep(j,c+1) coef[i][j]=-1;
	cout << rec(0,c) << endl;
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
//#ifdef LOCAL
//#include "uj.h"
//#endif
void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...


	
int N;
void test_case(){
	cin >> N;
	vector<int> v(N);
	for(int & x  : v)
		cin >> x;

	ll ans = 0;
	for(int i = 0;i<N-1;++i){
		if(v[i] > v[i+1]) ans += (v[i] - v[i+1]),v[i+1] = v[i];
	}
	cout << ans;
	
}
	

	





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

using namespace std;

template<class T> inline T sqr(const T& a) {
  return a * a;
}

template<class T> inline int len(const T &c) {
  return static_cast<int>(c.size());
}

template<class T> inline bool maximize(T &r, const T c) {
  if (r < c) {
    r = c;
    return true;
  }
  return false;
}

template<class T> inline bool minimize(T &r, const T c) {
  if (r > c) {
    r = c;
    return true;
  }
  return false;
}

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const ld EPS = 1e-9;
const ld PI = 2 * acos(0.0);
const int N = 100;

int main() {
  int n;
  scanf("%d", &n);
  vector<li> s(n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &s[i]);
  }
  sort(s.begin(), s.end());
  vector<li> pres(n);
  pres[0] = s[0];
  for (int i = 1; i < n; ++i) {
    pres[i] = pres[i - 1] + s[i];
  }
  int lf = n - 1;
  while (lf - 1 >= 0 && pres[lf - 1] * 2 >= s[lf]) {
    --lf;
  }
  printf("%d\n", n - lf);
  return 0;
}


Measured memory_bytes: 1792
int i,n,d=11328;main(c,v){for(;;){for(v=c=i=0;i-5;++i){scanf("%d",&n);n?:exit(0);v|=n<<i*2;c|=1<<n;}for(n=d>>c&3,i=0;i-5;++i){printf("%d\n",(v>>i*2&3)-n?(n?2:3):1);}}}

Measured memory_bytes: 600
#include<bits/stdc++.h> 
#define ll                 long long                            
#define ra                 return a;                                          
#define pb                 push_back                                                     
#define sti                stack<ll>
#define spi                stack<pair<ll,ll>>
#define S                  second
#define msi                map<string,ll >
#define msi                map<string,ll >
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z)        { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define mis                map<ll , string>
#define rep(i,a,b)         for(ll  i=a;i<b;i++)
#define mpi                map<pair<ll ,ll >,ll >                                                
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define F                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define pqi                priority_queue<ll>
#define si                 set <ll>
#define vs                 vector<string>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define bs                 binary_search
#define mp                 make_pair
#define qi                 queue<ll>
#define qs                 queue<string>
#define qpi                queue<pair<ll,ll>>
#define qps                queue<pair<ll,string>> 
#define inf                1e18L+1
#define endl               '\n' 
#define itr(a,it)          for(typeof(a.begin()) it=a.begin();it!=a.end();it++)// This will produce const_iterator for const object and normal iterator for non-const object
#define ss                 set<string>
using namespace std;
#define N  3005
long double dp[N][N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
//    cin>>t;
    while(t--)
{
    ll n;
    cin>>n;
    double p[n+1];
    rep(i,1,n+1)cin>>p[i];
    	dp[1][0]=1-p[1];
    	dp[1][1]=p[1];
    	rep(i,2,n+1)
    	{
    		rep(j,0,i+1)
    		{
    			dp[i][j]=dp[i-1][j]*(1-p[i]);
    			if(j)dp[i][j]+=dp[i-1][j-1]*(p[i]);
    		}
    	}
    	long double ans=0;
    	rep(i,(n+1)/2,n+1)
    	ans+=dp[n][i];
    	cout<<setprecision(15)<<ans;
    
}
    return 0;
}

Measured memory_bytes: 139264
#include <bits/stdc++.h>
#define N 1000500
using namespace std;
int n,x,a[N];
inline int rd() {int r;scanf("%d",&r);return r;}
int main() {
	n = rd(), x = rd();
	for (int i=1;i<=n;i++) a[i] = rd();
	sort(a+1,a+n+1);
	
	int ans = 0;
	for (int i=1;i<=n;i++) if (x-a[i] >= 0) {
		ans++;
		x -= a[i];
	}
	if (ans == n && x != 0) ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// finish date: 2018/01/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    string S;
    cin >> S;
    string str;
    rep(i, S.length()) if (i % 2 == 0) str += S[i];
    
    cout << str << endl;
    return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  ll n,k;
  cin>>n>>k;
  ll ans=0;
  if(k%2==1) ans=(n/k)*(n/k)*(n/k);
  else{
    ans=(n/k)*(n/k)*(n/k);
    ll cnt=0;
    for(ll i=k/2; i<=n; i+=k){
      cnt++;
    }
    ans+=cnt*cnt*cnt;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int N, A;

  scanf("%d", &N);
  scanf("%d", &A);

  N %= 500;

  if( N <= A ){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
from collections import defaultdict,deque,Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
xx = inpl()


ans = INF
for a in range(102):
    tmp = 0
    for x in xx:
        tmp += (a-x)**2
    ans = min(ans,tmp)

print(ans)


Measured memory_bytes: 4076
function Main(input) {
    var five = (input.match(/5/g) || []).length;
    var seven = (input.match(/7/g) || []).length;
    ( five == 2 && seven == 1) ? console.log("YES") : console.log("NO");
}

var character = "";
process.stdin.on('data', function(char){character += char});
process.stdin.on('end', function(){ Main(character); });
process.on('SIGINT', function() { Main(character); process.exit(0); });

Measured memory_bytes: 29796
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int a,b;
  cin>>a>>b;
  int c = a+b;
  dump(c);
  if (c%2==0){
    cout << c/2 << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{ 
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int cnt=0;
			while(sc.hasNext()) {
				int val = sc.nextInt();
				if(val==0)break;
				if(cnt>0) {
					System.out.println();
				}
				cnt++;
				int a = sc.nextInt();int b= sc.nextInt();
				int c = sc.nextInt(); int d = sc.nextInt();
				
				int min = 9999999;
				int ansa = 0;int ansb = 0;
				int ansc = 0;int ansd =0;
				for(int i=0;i<=a;i++) {
					for(int j=0;j<=b;j++) {
						for(int k=0;k<=c;k++) {
							for(int l=0;l<=d;l++) {
								int mon = 10*i+50*j+100*k+500*l-val;
								if(mon<0)continue;
								if(i==(mon%50/10) && i!=0)continue;
								if(j==(mon%100/50) && j!=0)continue;
								if(k==(mon%500/100) && k!=0)continue;
								if(l==(mon/500) && l!=0)continue;
								
								if(min>a-i+b-j+c-k+d-l+mon/500+mon%500/100+mon%100/50+mon%50/10) {
									min = a-i+b-j+c-k+d-l+mon/500+mon%500/100+mon%100/50+mon%50/10;
									ansa = i;
									ansb = j;
									ansc = k;
									ansd = l;
								}
							}
						}
					}
				}
				if(ansa!=0)
				System.out.println("10 "+ansa);
				if(ansb!=0)
				System.out.println("50 "+ansb);
				if(ansc!=0)
				System.out.println("100 "+ansc);
				if(ansd!=0)
				System.out.println("500 "+ansd);
				
			}
		}
	}
}



Measured memory_bytes: 43232
#include <iostream>
#include <cstdio>
#include <cmath>
#define eps 0.0000001
using namespace std;
struct po{int x,y,z,r; long long l;};
struct popo{int x,y,z;};

double mk_dis(popo a,popo b){
  return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));
}

int main(){
  int n,q;
  cin >>n>>q;
  po ball[51];
  for(int i=0;i<n;i++)cin>>ball[i].x>>ball[i].y>>ball[i].z>>ball[i].r>>ball[i].l;
  
  for(int i=0;i<q;i++){
    int a1,a2,b1,b2,c1,c2;
    double dis[3];
    cin >>a1>>b1>>c1>>a2>>b2>>c2;
    dis[0] = mk_dis((popo){a1,b1,c1},(popo){a2,b2,c2});
    long long ans=0;
    for(int j=0;j<n;j++){
      dis[1] = mk_dis((popo){a1,b1,c1},(popo){ball[j].x,ball[j].y,ball[j].z});
      dis[2] = mk_dis((popo){a2,b2,c2},(popo){ball[j].x,ball[j].y,ball[j].z});
      double s = (dis[0]+dis[1]+dis[2])/2.0;
      double S = sqrt(s*(s-dis[0])*(s-dis[1])*(s-dis[2]));
      double h = (2*S)/dis[0];
      
      if(dis[1]-ball[j].r<=eps ||dis[2]-ball[j].r<=eps) {
	ans+=ball[j].l;
	continue;
      }

      if(fabs(sqrt(dis[1]*dis[1]-h*h)+sqrt(dis[2]*dis[2]-h*h)-dis[0]) > eps)continue;
      if(h-ball[j].r<=eps) ans+=ball[j].l;
    }
    cout << ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<float> vfloat;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main(void){
    int n, k;
    cin >> n >> k;
    vint x(n);
    rep(i, n) cin >> x[i];
    int ans = 0;
    rep(i, n) ans += min(abs(k-x[i]), x[i]);
    cout << ans*2 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vl a(n), b(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        sum += a[i];
    }
    bool ok  = true;
    ll ret   = 0;
    ll gezan = INF;
    for (int i = 0; i < n; ++i) {
        if (a[i] != b[i])
            ok = false;
        if (a[i] > b[i]) {
            chmin(gezan, b[i]);
        }
    }
    if (ok)
        cout << 0 << "\n";
    else
        cout << sum - gezan << "\n";
    return 0;
}

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

int main(void){
    ll n, ans = 0;
    string s;
    vector<int> r, g;
    int b[4010], rn = 0, bn = 0, gn = 0;
    for(int i = 0; i < 4010; i++) b[i] = 0;
    cin >> n >> s;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') {r.push_back(i); rn++;}
        else if(s[i] == 'G') {g.push_back(i); gn++;}
        else {b[i]++; bn++;}
    }
    for(int i = 0; i < rn; i++){
        for(int j = 0; j < gn; j++){
            int minn = min(r[i], g[j]);
            int maxn = max(r[i], g[j]);
            int l = maxn - minn;
            int l2 = minn + maxn;
            int add = bn;
            if(minn-l >= 0 && b[minn-l] > 0){
                add--;
            } 
            if(l%2==0 && b[l2/2] > 0){
                add--;
            } 
            if(maxn+l < n && b[maxn+l] > 0){
                add--;
            }
            ans += add;
        }
    }
    cout << ans << endl;
    return 0;
}


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


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

#define mod 1000000007

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}



signed main(void){
	double a,b;
	cin >>a>>b;
	double mina = ceil(a / 0.08);
	double maxa = (a + 1) / 0.08;
	double minb = ceil(b / 0.10);
	double maxb = (b + 1) / 0.10;
	if (maxb <= mina || maxa <= minb) {
		print(-1);
		return 0;
	}
	else {
		print(max(mina, minb));
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i, k, n, q, m, l, r, S[100000], T[100000];
  k = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &S[i]);

  scanf("%d", &q);
  for(i = 0; i < q; i++) scanf("%d", &T[i]);

  for(i = 0; i< q; i++){
    l = 0;
    r = n;
    while(l < r){
    m = (l + r)/2;
    if(T[i] == S[m]){
      k++;
      break;
    }
    else if(T[i] < S[m]) r = m;
    else if(T[i] > S[m]) l = m + 1;
    }
  }

  printf("%d\n", k);
  
  return 0;
}

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

int main() {
    int A, B, C, D;
    std::cin >> A >> B >> C >> D;

    int sec = 0;
    for (int i = A; i < B; ++i) {
        if (C <= i && i < D) {
            ++sec;
        }
    }

    std::cout << sec << std::endl;

    return 0;
}


Measured memory_bytes: 256
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
string to_string(char c) { return string(1,c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
template<class A> string to_string(complex<A> c) { 
	stringstream ss; ss << c; return ss.str(); }
string to_string(vector<bool> v) { 
	string res = "{"; for(int i = 0; i < (int)v.size(); i++) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> string to_string(bitset<SZ> b) {
	string res = ""; for(size_t i = 0; i < SZ; i++) res += char('0'+b[i]);
	return res; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) { // containers with begin(), end()
	bool fst = 1; string res = "{";
	for (const auto& x: v) {
		if (!fst) res += ", ";
		fst = 0; res += to_string(x);
	}
	res += "}"; return res;
}
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define wis(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
#else
#define wis(...) 0
#endif
typedef long long ll;
const int MOD = 1e9 + 7, INF = 1e9 + 5;
const ll LONG_INF = 1e18 + 10;
inline ll powmod(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)res=res*a%MOD;return res;}
inline ll power(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a)if(b&1)res=res*a;return res;}

const int MAXN = 2e5 + 10;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	long double d;
	int ans = 0;
	cin >> n >> d;
	for(int i = 0; i < n; i++){
		long double x, y;
		cin >> x >> y;
		if(sqrt((x * x) + (y * y)) <= d)
			ans++;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3788
'use strict'

function main(input) {
  input = input
    .trim()
    .split(' ')
    .map(Number)

  const A = input[0]
  const B = input[1]
  const ans = A % 2 === 0 || B % 2 === 0 ? 'Even' : 'Odd'
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

#define Fi first
#define Se second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)
typedef tuple<int, int, int> t3;

int n, u, v;
vector <int> E[100010];
int dis[2][100010];

int main() {
	scanf("%d%d%d", &n, &u, &v);
	rep(i, n-1) {
		int x, y;
		scanf("%d%d", &x, &y);
		E[x].pb(y);
		E[y].pb(x);
	}
	rep(a, 2) {
		int st = (a ? v : u);
		vector <int> q;
		q.pb(st);
		auto& D = dis[a];
		memset(D, -1, sizeof D);
		D[st] = 0;
		rep(i, szz(q)) {
			int t = q[i];
			for(int e : E[t]) if(D[e] == -1) {
				D[e] = D[t] + 1;
				q.pb(e);
			}
		}
	}
	int ans = 0;
	if(dis[0][v] % 2 == 0) ans = dis[0][v] / 2;
	for(int i=1;i<=n;i++) if(dis[0][i] < dis[1][i]) {
		int r = dis[1][i] - 1;
		ans = max(ans, r);
	}
	printf("%d\n", ans);
	return 0;
}


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

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }

    int ans = 0;
    int tmp = 0;


    for(int i = 1;i < n; i++) {
        if(h[i-1] >= h[i]) {
            tmp++;
            ans=max(ans,tmp);
        } else {
            tmp=0;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {

  int a, b;
  cin >> a >> b;
  if (a > b) {
      cout << "a > b" << endl;
  }
  else if (a == b) {
      cout << "a == b" << endl;
  }
  else {
      cout << "a < b" << endl;
  }

}



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

typedef long long LL;
const LL mod = 1e9+7;
LL dp[1000003];
int main()
{
    LL n, sum=0;
    scanf("%lld",&n);
    dp[1] = n;
    dp[2] = (n*n)%mod;
    for(int i=3; i<=n; ++i)
    {
        sum = (sum + dp[i-3])%mod;
        dp[i] = (dp[i-1] + sum + (n-1)*(n-1)%mod + n-i+2)%mod;
    }
    printf("%lld\n",dp[n]);
    return 0;
}


Measured memory_bytes: 8064
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 L, R;
  std::cin >> L >> R;

  if (L % 2019 == 0 || R % 2019 == 0 || L / 2019 < R / 2019) {
    std::cout << 0 << std::endl;
  } else {
    L %= 2019;
    R %= 2019;
    i64 answer = std::numeric_limits<i64>::max();
    for (i64 i = L; i < R; ++i) {
      for (i64 j = i + 1; j <= R; ++j) {
        answer = std::min(answer, (i * j) % 2019);
      }
    }
    std::cout << answer << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
def find_gcd(a: int, b: int) -> int:
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return find_gcd(b, a % b)


if __name__ == "__main__":
    a, b = list(map(lambda x: int(x), input().split()))
    print(f"{find_gcd(a, b)}")



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
ll x; cin >> x;
ll now = 100;
int day=0;
while (now < x) {
  day++;
  now += now / 100;
}
cout << day << endl;
 return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int n, a[4];
int main() {
	int maxn = 199999;
	cin >> n >> a[0] >> a[1] >> a[2] >> a[3];
	for (int i = 1; i <= n; i++) {
		int x[4], y[4];
		for (int j = 0; j < 4; j++) {
			x[j] = (a[j] - 1) % i;
			y[j] = (a[j] - 1) / i;
		}
		int m1 = abs(x[0] - x[1]) + abs(y[0] - y[1]);
		int m2 = abs(x[2] - x[3]) + abs(y[2] - y[3]);
		maxn = min(maxn, m1 + m2);
	}
	cout << maxn << endl;
	return 0;
}

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

typedef complex<double> P;
const double eps = 1e-10;
const double inf = 1e10;

bool equals(double a, double b) {
  return abs(a-b) < eps;
}

namespace std {
  bool operator < (const P &a, const P &b) {
    if(a.real() != b.real()) return a.real() < b.real();
    return a.imag() < b.imag();
  }
}

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}

P project(P s1, P s2, P p) {
  P base = s2 - s1;
  double t = dot(p - s1, base)/norm(base);
  return s1 + base*t;
}

P reflect(P s1, P s2, P p) {
  return p + (project(s1, s2, p) - p)*2.0;
}

int ccw(P p, P a, P b) {
  a -= p;
  b -= p;
  if(cross(a,b) > eps) return 1;
  if(cross(a,b) < -eps) return -1;
  if(dot(a,b) < -eps) return 2;
  if(norm(b)-norm(a) > eps) return -2;
  return 0;
}

int main() {
  int N;
  P s;
  vector<P> g;
  while(cin >> N && N) {
    g.resize(N);
    cin >> s.real() >> s.imag();
    for(int i = 0; i < N; ++i) {
      cin >> g[i].real() >> g[i].imag();
    }

    vector<pair<P,P> > seg;
    for(int i = 0; i < N; ++i) {
      seg.push_back(make_pair(g[i], g[(i+1)%N]));
    }
    sort(seg.begin(), seg.end());
    int res = 0;
    do {
      try {
        vector<pair<P,P> > t = seg;
        for(int i = 0; i < N; ++i) {
          for(int j = i+1; j < N; ++j) {
            P p = reflect(t[i].first, t[i].second, t[j].first);
            P q = reflect(t[i].first, t[i].second, t[j].second);
            t[j] = make_pair(p, q);
          }
        }

        P A, B;
        for(int i = 0; i < N; ++i) {
          P a = t[i].first;
          P b = t[i].second;
          if(ccw(s,a,b) == -1) swap(a, b);
          if(i == 0) {
            A = a;
            B = b;
          } else {
            if(ccw(s,A,a) ==  1) A = a;
            if(ccw(s,B,b) == -1) B = b;
            if(!(cross(A-s,B-s) > eps)) throw 0; // important
          }
        }
        if(cross(A-s,B-s) > eps) ++res;
      } catch(...) {}
    } while(next_permutation(seg.begin(), seg.end()));
    cout << res << endl;
  }
  return 0;
}

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


int main(){
	string s;
	cin >> s;
	bool ok = false;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'C'){
			ok = true;
		}
		if (s[i] == 'F'&&ok){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#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>;

double dist(P a, P b){
    return sqrt(pow(a.first - b.first, 2) + pow(a.second - b.second, 2));
}

int main(){
    int N; cin >> N;
    vector<P> vec;
    rep(i,N){
        int x,y; cin >> x >> y;
        vec.push_back(P(x,y));
    }
    sort(vec.begin(), vec.end());
    double ans;
    int i = 0;
    do{
        double total = 0;
        rep(i,N-1) total += dist(vec[i], vec[i+1]);
        ans = (ans*i + total)/(i+1);
        ++i;
    }while(next_permutation(vec.begin(), vec.end()));
    printf("%.10f\n", ans);
}


Measured memory_bytes: 3780
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;
int n, m, vis[N];
vector<int> g[N], v;

void dfs(int x) {
	for (int y:g[x]) if (!vis[y]) {
		vis[y] = 1;
		v.pb(y);
		return dfs(y);
	}
}

int main() {
	scanf("%d%d", &n,&m);
	REP(i,1,m) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].pb(v),g[v].pb(u);
	}
	v.pb(1),vis[1]=1;
	dfs(1);
	reverse(v.begin(),v.end());
	dfs(1);
	printf("%d\n", (int)v.size());
	for (int t:v) printf("%d ", t);hr;
}








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

int main(){
	double a,b,c,d,e,f,x,y;

	while(cin >> a >> b >> c >> d >> e >> f){
	x=(int)((c*e-b*f)/(a*e-b*d)*1000) / 1000.0;
	y=(int)((a*f-c*d)/(a*e-b*d)*1000) / 1000.0;
	printf("%.3f %.3f\n", x,y);
}
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

template <class T>
T gcd(T n, T m) {
    if (n < m) swap(n, m);
    while (m != 0) {
        T r = n % m;
        n = m;
        m = r;
    }
    return n;
}

struct V {
    bool operator!=(const V &v) const {
        return a != v.a || b != v.b;
    }
    bool operator<(const V &v) const {
        return a != v.a ? a < v.a : b < v.b;
    }
    ll a, b;
    int t;
};

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

    int n;
    cin >> n;

    vector<int> p2(n + 1);
    p2[0] = 1;
    for (int i = 0; i < n; i++) {
        p2[i + 1] = p2[i] * 2 % P;
    }

    int m = 0;
    vector<V> v;

    for (int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;

        if (a == 0 && b == 0) {
            m++;

        } else {
            ll c = gcd(abs(a), abs(b));
            if (b < 0 || (b == 0 && a < 0)) c *= -1;
            a /= c;
            b /= c;

            int t = 0;
            if (a <= 0) {
                ll x = a;
                a = b;
                b = -x;
                t = 1;
            }
            v.push_back({ a, b, t });
        }
    }
    sort(v.begin(), v.end());

    n = v.size();

    ll r = 1;
    V v0 = { 0, 0, 0 };
    int k[2];

    for (int i = 0; i <= n; i++) {
        if (i == n || v[i] != v0) {
            if (i != 0) {
                r *= p2[k[0]] + p2[k[1]] - 1;
                r %= P;
            }
            if (i == n) break;
            v0 = v[i];
            k[0] = k[1] = 0;
        }
        k[v[i].t]++;
    }

    r += m;
    r--;
    r %= P;
    if (r < 0) r += P;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 10304
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

n = I()
t = [0]
x = [0]
y = [0]
for _ in range(n):
    tmp = LI()
    t.append(tmp.pop(0))
    x.append(tmp.pop(0))
    y.append(tmp.pop(0))

for i in range(1,n+1):
    dist = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])
    dt = abs(t[i]-t[i-1])
    if dt<dist:
        print('No')
        exit()
    else:
        if (dt-dist)%2:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 11844