akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Collections;
import java.util.Arrays;
import java.lang.Math;

public class Main {
    static int gcd(int a, int b) {return b>0?gcd(b, a%b):a;}

	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int N = reader.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++) {
		    A[i] = reader.nextInt();
		}
		
		solver(N, A);
	}
	
	public static void solver(int N, int[] A) {
		// write logic
		int[] Lgcd = new int[N];
		int[] Rgcd = new int[N];
		Lgcd[0]   = A[0];
		Rgcd[N-1] = A[N-1];
		for(int i=1; i<N-1; i++) {
		    Lgcd[i]     = gcd(Lgcd[i-1], A[i]);
		    Rgcd[N-1-i] = gcd(Rgcd[N-i], A[N-1-i]);
		}

		int ans = Math.max(Lgcd[N-2], Rgcd[1]);
		for(int i=1; i<N-1; i++) {
		    ans = Math.max(ans, gcd(Lgcd[i-1], Rgcd[i+1]));
		}
		System.out.println(ans);
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


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

using namespace std;

typedef long long ll;

using V = vector<int>;
using Q = queue<int>;
using Graph = vector<vector<int>>;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl
#define err(x) cerr<<(x)<<endl
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define deg(_rad) (((_rad)/2/M_PI)*360)
#define rad(_deg) (((_deg)/360)*2*M_PI)
#define mid(min, max) ((min + max) / 2)

int main() {
	ll a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v <= w) {
		out("NO");
		return 0;
	}
	if (abs(a - b) / (double)(v - w) <= t) {
		out("YES");
		return 0;
	}
		out("NO");
    return 0;
}


Measured memory_bytes: 3632
import scala.io.StdIn
import scala.annotation.tailrec
import scala.collection.mutable.ListBuffer

object Main{
  def main(args: Array[String]){
    StdIn.readLine()
    val line = StdIn.readLine().split(" ").toList.map(_.toInt)

    println(line.sorted.mkString(" "))
    println(sSort(List(), line, 0))
  }

  @tailrec
  def sSort(sorted: List[Int], unsorted: List[Int], n: Int): Int={
    if(unsorted.length == 0) n
    else if(unsorted.sorted == unsorted) n
    else {
      val pos = unsorted.indexWhere(_ == unsorted.min)
      val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)

      if(pos == 0) sSort(sorted :+ unsorted.min, swapped.tail, n)
      else sSort(sorted :+ unsorted.min, swapped.tail, n+1)
    }
  }
}

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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 1; i < n; i++) {
		string t = s.substr(0, i);
		string u = s.substr(i, n - i);
		set<char> st;
		rep(j, i) {
			rep(k, n - i) {
				if (t[j] == u[k]) st.insert(t[j]);
			}
		}
		ans = max(ans, (int)st.size());
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
 
int main() {
    int h,w;
  cin>>h>>w;
  vector<string> s(h);
  rep(i,h) cin>>s[i];
  int ans=0;
  vector<vector<int>> dist(h,vector<int>(w,INF));
  queue<P> q;
  auto update=[&](int i,int j,int x){
    if(dist[i][j]!=INF) return;
    dist[i][j]=x;
    q.push(P(i,j));// .emplace(i,j)
  };
  update(0,0,0);
  while(!q.empty()){
    int i=q.front().first;
    int j=q.front().second; q.pop();
    rep(dir,4){
      int ni=i+di[dir], nj=j+dj[dir];
      if(ni<0||ni>=h||nj<0||nj>=w) continue;
      if(s[ni][nj]=='#') continue;
      update(ni,nj,dist[i][j]+1);
    }
  }
  ans=dist[h-1][w-1];
  if(dist[h-1][w-1]==INF){
    cout<<-1<<endl;
    return 0;
  }
  ans++;
  int sum=0;
  rep(i,h)rep(j,w){
    if(s[i][j]=='.') sum++;
  }
  cout<<sum-ans<<endl;
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli a,b;
    cin2(a,b);
    if (a - b*2 < 0)
        cout << 0 << endl;
    else
        cout << a-b*2 << endl;

}


Measured memory_bytes: 256
s = input()

if s[0] != 'A' :
  print("WA")
elif s[2:-1].count('C') !=1:
  print("WA")
else:
  s = ''.join([i for i in s if i not in 'AC'])
  if s.islower() :
    print('AC')
  else  :
    print('WA')

Measured memory_bytes: 3060
n = int(input())
S = input()
rs = [s=="R" for s in S]
gs = [s=="G" for s in S]
bs = [s=="B" for s in S]

ind_r = [i for i,s in enumerate(rs) if s == 1]
ind_g = [i for i,s in enumerate(gs) if s == 1]
ind_b = [i for i,s in enumerate(bs) if s == 1]

ans = 0
ng = sum(gs)
for i in ind_r:
    for j in ind_b:
        # print(i,j)
        kM = max(i,j) + abs(i-j)
        km = min(i,j) - abs(i-j)
        ans += ng
        if (max(i,j) - min(i,j))%2==0:
            # print("aaa",(max(i,j)+min(i,j))//2)
            ans -= gs[(max(i,j)+min(i,j))//2]
        if kM < n:
            ans -= gs[kM]
        if 0 <= km:
            ans -= gs[km]
print(ans)

Measured memory_bytes: 74656
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
public:
    input()
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var) { return std::cin >> var, *this; }
    template <class T>
    inline input& operator,(T& var) { return *this >> var; }

    template <class T>
    inline T read()
    {
        T var;
        std::cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            std::cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            std::cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            std::cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
        cout << '\n';
    }
};

void prog()
{
    input in;
    output out;
    int a, b;
    in >> a, b;
    int res = 0;
    auto f = [](int& a, int& b) {
        if (a > b) {
            --a;
            return a + 1;
        } else {
            --b;
            return b + 1;
        }
    };
    res += f(a, b);
    res += f(a, b);
    out(res);
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll const mod=1e+9+7;
int main(){
  ll N;
  cin>>N;
  vector<ll>data(N);
  for(ll i=0;i<N;i++)cin>>data[i];
  ll res=0;
  for(ll d=0;d<60;d++){
    ll one=0,zero=0;
    for(ll i=0;i<N;i++){
      if((data[i]>>d)&1){
        one++;
      }else{
        zero++;
      }
    }
    ll tmp=one*zero%mod;
    ll n=(1ll<<d)%mod;
    ll num=tmp*n%mod;
    res=(res+num)%mod;
  }
  res=res%mod;
  cout<<res<<endl;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n,m;
	while(cin>>n>>m,n){
	    vi a(n);
	    int ans=-1;
		rep(i,n){
		    cin>>a[i];
		}
		rep(i,n)rep(j,i){
		    if(a[i]+a[j]<=m){
		        ans=max(ans,a[i]+a[j]);
		    }
		}
		if(ans==-1)cout<<"NONE"<<endl;
		else cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mk make_pair
#define N 5010
#define M 210
int n, m, b[N][M], L[N], R[N];
ll a[N], f[N][N], ans = 0;

pii stk[N]; int top;
inline void init() {
	for (int j = 1; j <= m; ++ j) {
		top = 0;
		for (int i = 1; i <= n; ++ i) {
			while (top > 0 && b[i][j] > stk[top].fi) {
				R[stk[top].se] = i - 1;
				-- top;
			}
			stk[++ top] = mk(b[i][j], i);
		}
		while (top > 0) {
			R[stk[top].se] = n;
			-- top;
		}
		for (int i = n; i >= 1; -- i) {
			while (top > 0 && b[i][j] >= stk[top].fi) {
				L[stk[top].se] = i + 1;
				-- top;
			}
			stk[++ top] = mk(b[i][j], i);
		}
		while (top > 0) {
			L[stk[top].se] = 1;
			-- top;
		}
		for (int i = 1; i <= n; ++ i) {
			// x : [L, i] , y : [i, R]
//			printf("i = %d, L %d, R %d\n", i, L[i], R[i]);
//			for (int x = L[i]; x <= i; ++ x)
//				for (int y = i; y <= R[i]; ++ y) f[x][y] += b[i][j];
			f[L[i]][i] += b[i][j];
			f[i + 1][R[i] + 1] += b[i][j];
			f[L[i]][R[i] + 1] -= b[i][j];
			f[i + 1][i] -= b[i][j];
		}
	}
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j <= n; ++ j) f[i][j] += f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];
}
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i < n; ++ i) {
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j <= m; ++ j) {
			cin >> b[i][j];
		}
	init();
	for (int l = 1; l <= n; ++ l)
		for (int r = l; r <= n; ++ r) {
			ans = max(ans, f[l][r] - (a[r] - a[l]));
//			printf("f[%d][%d] = %lld, dist = %lld\n", l, r, f[l][r], a[r] - a[l]);
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 200576
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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 long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int N;cin >> N;
    vector<int> retu(N);
    int ans = 0;
    for(int i = 0;i<N;i++)cin >> retu.at(i);
    for(int i = 0;i<N;i++){
        int to = retu.at(retu.at(i)-1);
        int from = i+1;
        if(from == to) ans++;
    }
    cout << ans / 2 << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int Q;
ll A,M;

ll ext_gcd(ll p,ll q,ll& x, ll& y) { // get px+qy=gcd(p,q)
	if(q==0) return x=1,y=0,p;
	ll g=ext_gcd(q,p%q,y,x);
	y-=p/q*x;
	return g;
}

pair<ll,ll> crt(ll a1,ll mo1,ll a2,ll mo2) { // return (x,y) y=lcm(a1,a2),x%mo1=a1,x%mo2=a2
	ll g,x,y,z;
	g=ext_gcd(mo1,mo2,x,y);
	a1=(a1%mo1+mo1)%mo1;a2=(a2%mo2+mo2)%mo2;
	if(a1%g != a2%g) return pair<ll,ll>(-1,0); // N/A
	__int128_t lcm=mo1*(mo2/g);
	if(lcm<mo1) return pair<ll,ll>(-2,0); // overflow
	
	__int128_t v=a1+((a2-a1)%lcm+lcm)*x%lcm*(mo1/g);
	return make_pair(((v%lcm)+lcm) % lcm,lcm);
}

ll modpow(ll a, ll n,ll mo) {
	ll r=1; a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

int phi(int p) {
	int op=p;
	for(int x=2;x*x<=p;x++) if(p%x==0) {
		op=op/x*(x-1);
		while(p%x==0) p/=x;
	}
	if(p>1) op=op/p*(p-1);
	return op;
}

ll hoge(ll A,ll M) {
	if(M==1) return 30;
	if(A==0) return M;
	if(A==1) return 1;
	
	ll mm=phi(M);
	ll mv=hoge(A,mm);
	if(mv==-1) return -1;
	ll v=modpow(A,mv,M);
	auto p=crt(v,M,mv,mm);
	if(p.first<0) return -1;
	
	while(p.first<30) p.first+=p.second;
	return p.first;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	
	cin>>Q;
	while(Q--) {
		cin>>A>>M;
		ll v=hoge(A,M);
		assert(v%M==modpow(A,v,M));
		cout<<v<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;



int main(){
    INIT;
    int x, a; cin >> x >> a;
    if(x < a) cout << 0;
    else cout << 10;
}

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

const int N = 1e6+10;
char s[N];

int sig(int n) {
    return n > 0? 1: -1;
}

// -x +y

struct Node {

    // b>=0 
    // -b +a+b
    int a, b;
    Node() {}
    Node(int a, int b):a(a), b(b) {}
    bool operator < (const Node& rh) const {
        if (sig(a) != sig(rh.a)) {
            return sig(a) > sig(rh.a);
        }
        if (sig(a) == 1) {
            return b < rh.b;
        } else {
            return a+b > rh.a+rh.b;
        }
    }
};

void solve() {

    int n;
    scanf("%d", &n);

    vector<Node> vec;
    vector<Node> vec2;
    for (int i = 0; i < n; i++) {
        scanf("%s", s);
        int a = 0, b = N;
        for (int j = 0; s[j]; j++) {
            if (s[j] == '(') a++;
            else a--;
            b = min(b, a);
        }
        vec.push_back(Node(a, max(0, -b)));
    }

    sort(vec.begin(), vec.end());
    /*
    for (auto i: vec) {
        printf("%d %d\n", i.a, i.b);
    }
    */

    int t = 0;
    for (auto i: vec) {
        if (t < i.b) {
            printf("No\n");
            return ;
        }
        t += i.a;
    }

    if (t == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

}

int main(){

    solve();
	return 0;
}


Measured memory_bytes: 11676
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
//自作関数
template<class T> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}

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

int n;
int INF = 1<<30;
int main(){
    int h,w;
    cin>>h>>w;
    int dix[]={0,1,0,-1};
    int diy[]={1,0,-1,0};
    string s[h];
    rep(i,h)cin>>s[i];

    using p = pair<int,int>;
    int ans=0;
    rep(si,h)rep(sj,w){
    vector<vector<int>> dist(h,vector<int>(w,INF));
    queue<p> q;
        auto update=[&](int x,int y,int nv){
            if(dist[x][y]==INF){
                dist[x][y]=nv;
                q.emplace(x,y);
            }
        };
        if(s[si][sj]=='#')continue;
            update(si,sj,0);
        while(!q.empty()){
            int iv=q.front().first;
            int jv=q.front().second;
            q.pop();
        for(int k=0;k<4;k++){
           int ni=iv+dix[k];
           int nj=jv+diy[k];
           if(ni>=0&&ni<h&&nj>=0&&nj<w){
               if(s[ni][nj]=='.'){
                  update(ni,nj,dist[iv][jv]+1);
               }
           }
        }
        }
        rep(i,h)rep(j,w){
            if(dist[i][j]==INF)continue;
            chmax(ans,dist[i][j]);
        }
    }
    cout<<ans<<endl;
    return 0;
}




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

int main() {
  int n;
  cin >> n;
  
  if(n % 1000 == 0){
    cout << 0 << endl;
  }
  else{
    cout << 1000 - (n % 1000) << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 1e4 + 4;
const int mod = (int) 1e9 + 7;

int n;
ll a[N];
unordered_map<int, int> lcm;

struct mul {
	ll operator()(const ll &n1, const ll &n2) const {
		return (n1 * n2) % mod;
	}
};

ll identity_element(const mul& m) {
	return 1LL;
}

ll modInv(ll num) {
	return power(num, mod - 2, mul());
}

void factorize(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) {
			int c = 0;
			while (x % i == 0) {
				x /= i;
				c++;
			}
			lcm[i] = max(lcm[i], c);
		}
	}
	if (x > 1) {
		lcm[x] = max(lcm[x], 1);
	}
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		factorize(a[i]);
	}
	ll L = 1, res = 0;
	for (auto p : lcm) {
		(L *= power(p.first, p.second, mul())) %= mod;
	}
	for (int i = 0; i < n; i++) {
		(res += L * modInv(a[i]) % mod) %= mod;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<math.h>
typedef struct{
double x,y;
} Pointer;

int koch(int d,Pointer p1,Pointer p2){
  Pointer s,t,u;

  double r =M_PI*60/180;//度からラジアンへ60度固定
 if(d==0)return 0;
   s.x=(2*p1.x+1*p2.x)/3;
   s.y=(2*p1.y+1*p2.y)/3;
   t.x=(1*p1.x+2*p2.x)/3;
   t.y=(1*p1.y+2*p2.y)/3;
   u.x=(t.x-s.x)*cos(r)-(t.y-s.y)*sin(r)+s.x;
   u.y=(t.x-s.x)*sin(r)+(t.y-s.y)*cos(r)+s.y;//それぞれの座標
   koch(d-1,p1,s);
   printf("%.8f %.8f\n",s.x,s.y);
   koch(d-1,s,u);
   printf("%.8f %.8f\n",u.x,u.y);
   koch(d-1,u,t);
   printf("%.8f %.8f\n",t.x,t.y);
   koch(d-1,t,p2);
 }


int main(){
  Pointer p1,p2;
  int n;
  scanf("%d",&n);
  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;
  printf("%.8f %.8f\n",p1.x,p1.y);
  koch(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);
  return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>

#define mod 1e9+7
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << w*h/double(2) << " ";
    if(2*x==w&&2*y==h) cout << 1;
    else cout << 0;
}


Measured memory_bytes: 256
/*
[abc135] F - Strings of Eternity
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_S = 5e5;
const int MAX_T = 5e5;

const int MAX_TXT = 2 * MAX_S + MAX_T;
const int MAX_PAT = MAX_T;

string txt, pat;
int table[MAX_PAT + 1];
bool matched[MAX_TXT];

void kmp() {
    int n = txt.length(), m = pat.length();

    table[0] = -1;
    for (int i = 0, j = -1; i < m; i++) {
        while (j >= 0 && pat[i] != pat[j]) {
            j = table[j];
        }
        table[i + 1] = ++j;
    }

    for (int i = 0, j = 0; i < n; i++) {
        while (j >= 0 && txt[i] != pat[j]) {
            j = table[j];
        }
        if (++j >= m) {
            matched[i - m + 1] = true;
            j = table[j];
        }
    }
}

string s, t;
int dep[MAX_S];
bool looped;

int dfs(int v, int h = 0) {
    if (h > (int)s.length()) {
        looped = true;
        return 0;
    }
    if (dep[v] >= 0) {
        return dep[v];
    }
    if (matched[v]) {
        return (dep[v] = 1 + dfs((v + t.length()) % s.length(), h + 1));
    }
    return (dep[v] = 0);
}

ll solve() {
    pat = t;
    while (txt.length() < s.length() + t.length()) {
        txt += s;
    }
    kmp();

    memset(dep, -1, sizeof(dep));
    int ans = 0;
    for (int i = 0; i < (int)s.length(); i++) {
        ans = max(ans, dfs(i));
        if (looped) {
            return -1;
        }
    }

    return ans;
}

int main() {
    cin >> s;
    cin >> t;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 16328
from collections import deque

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

F=[[] for _ in range(N)]
B=[[] for _ in range(N)]


for i in range(M):
    a,b=map(int,input().split())
    F[a-1].append(b-1)
    F[b-1].append(a-1)

for i in range(K):
    a,b=map(int,input().split())
    B[a-1].append(b-1)
    B[b-1].append(a-1)

q=deque([])
G=[]
visited=[0]*N
group=[-1]*N
idx=0
for i in range(N):
    if visited[i]==1:continue
    visited[i]=1
    group[i]=idx
    q.append([i,[i]])
    while q:
        n,c=q.pop()
        for j in F[n]:
            if visited[j]==0:
                c.append(j)
                visited[j]=1
                group[j]=idx
                q.append([j,c])
    G.append(c)
    idx+=1

cnt=[0]*N
for g in G:
    for i in g:
        for b in B[i]:
            if  group[i]==group[b]:
                cnt[i]+=1

ans=[0]*N

for g in G:
    for i in g:
        ans[i]=len(g)-len(F[i])-cnt[i]-1

for i in ans:
    print(str(i),end=" ")


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

int main() {
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  vector<int> xP(n),yP(m);
  for(int i = 0;i < n;i++){
    cin >> xP.at(i);
  }
  for(int i = 0;i < m;i++){
    cin >> yP.at(i);
  }
  sort(xP.begin(),xP.end());
  sort(yP.begin(),yP.end());
  
  int N = n-1; int J = 0;
  for(int i = x+1;i <= y;i++){
    if(i > xP.at(N) && i <= yP.at(0)){
      J++;
    }
  }
  
  if(J != 0){
    cout << "No War" << endl;
   }else{
    cout << "War" << endl;
  }


  return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vector<pair<ll, ll> > ends;
    for(ll i=0;i<n;i++){
        ll x, l; cin >> x >> l;
        // t, s
        ends.push_back(make_pair(x + l, x - l));
    }
    sort(ends.begin(), ends.end());
    ll prev_t = -1e10;
    ll ans = 0;
    for(pair<ll, ll> end: ends){
        ll t = end.first;
        ll s = end.second;

        if(prev_t <= s){
            ans++;
            prev_t = t;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
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;
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

  vector<long long> X(N),Y(N);
  vector<long long> x(0),y(0);
  for(int i = 0;i < N;i++) {
    cin >> X[i] >> Y[i];
    x.push_back(X[i]+Y[i]);
    y.push_back(X[i]-Y[i]);
  }

  sort(x.begin(),x.end());
  sort(y.begin(),y.end());

  cout << max(x[N-1]-x[0],y[N-1]-y[0]) << endl;


}


Measured memory_bytes: 9780
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        long[] xy = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var x = xy[0];
        var y = xy[1];

        long ans = 0;
        //xyが正数の場合
        if (0 <= x && 0 <= y)
        {
            if (x <= y)
            {
                ans += y - x;
            }
            else
            {
                x *= -1;
                ans++;

                ans += Math.Abs(Math.Abs(y) - Math.Abs(x));

                if (y != 0)
                {
                    x *= -1;
                    ans++;
                }
            }
        }
        //xyが負数の場合
        else if (x < 0 && y < 0)
        {
            if (x <= y)
            {
                ans += Math.Abs(Math.Abs(y) - Math.Abs(x));
            }
            else
            {
                x *= -1;
                ans++;

                ans += Math.Abs(Math.Abs(y) - Math.Abs(x));
                x += Math.Abs(Math.Abs(y) - Math.Abs(x));

                x *= -1;
                ans++;
            }
        }
        //yだけが負数の場合
        else if (0 <= x && y < 0)
        {
            if (Math.Abs(x) == Math.Abs(y))
            {
                x *= -1;
                ans++;
            }
            else if (Math.Abs(x) < Math.Abs(y))
            {
                ans += Math.Abs(Math.Abs(y) - Math.Abs(x));
                x += Math.Abs(Math.Abs(y) - Math.Abs(x));

                x *= -1;
                ans++;
            }
            else
            {
                x *= -1;
                ans++;

                ans += Math.Abs(Math.Abs(y) - Math.Abs(x));
                x += Math.Abs(Math.Abs(y) - Math.Abs(x));
            }
        }
        //xだけが負数の場合
        else if (x < 0 && 0 <= y)
        {
            if (Math.Abs(x) == Math.Abs(y))
            {
                x *= -1;
                ans++;
            }
            else if (Math.Abs(x) < Math.Abs(y))
            {
                x *= -1;
                ans++;

                ans += Math.Abs(Math.Abs(y) - Math.Abs(x));
                x += Math.Abs(Math.Abs(y) - Math.Abs(x));
            }
            else
            {
                ans += Math.Abs(Math.Abs(y) - Math.Abs(x));
                x += Math.Abs(Math.Abs(y) - Math.Abs(x));

                if (y != 0)
                {
                    x *= -1;
                    ans++;
                }
            }
        }


        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
#include <iostream>

using namespace std;

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  int range_sum[N][N];
  int ans[N][N];
  for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) range_sum[i][j] = 0;

  for (int i = 0; i < M; i++) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    range_sum[l][r] += 1;
  }

  for (int i = 0; i < N; i++) {
    int sum = 0;
    for (int j = 0; j < N; j++) {
      sum += range_sum[i][j];
      range_sum[i][j] = sum;
    }
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      int sum = 0;
      for (int k = i; k <= j; k++) {
        sum += range_sum[k][j];
      }
      ans[i][j] = sum;
    }
  }

  for (int i = 0; i < Q; i++) {
    int p, q;
    cin >> p >> q;
    p--, q--;
    cout << ans[p][q] << endl;
  }

/*
  for (int i = 0; i < Q; i++) {
    int p, q;
    cin >> p >> q;
    p--, q--;
    int sum = 0;
    for (int j = p; j <= q; j++) {
      sum += range_sum[j][q];
    }
    cout << sum << endl;
  }
*/
}


Measured memory_bytes: 2816
#include <algorithm>
#include <iostream>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>

using std::set;
using std::multiset;
using std::tuple;
using std::vector;
using std::unordered_map;

int solve(int N, int K, const vector<int> &P)
{
	vector<int> memo(N);
	for (int i = 1; i < N; ++i)
	{
		if (P[i] > P[i - 1]) { memo[i] = memo[i - 1] + 1; }
	}
	int cnt = 1;
	set<int> set;
	for (int i = 0; i < K; ++i) { set.emplace(P[i]); }
	bool flag = (memo[K - 1] - memo[0] == K - 1);
	for (int i = 1; i + K <= N; ++i)
	{
		bool L = (P[i - 1] == *set.cbegin());
		set.erase(P[i - 1]);
		set.emplace(P[i + K - 1]);
		bool R = (P[i + K - 1] == *set.crbegin());
		if (memo[i + K - 1] - memo[i] == K - 1)
		{
			if (!flag) { ++cnt; }
			flag = true;
		}
		else
		{
			if (!L || !R) { ++cnt; }
		}
	}
	return cnt;
}

int main(int argc, char *argv[])
{
	int	N, K;
	std::cin >> N >> K;
	vector<int> P(N);
	for (int i = 0; i < N; ++i)
	{
		std::cin >> P[i];
	}
	std::cout << solve(N, K, P) << std::endl;
	return 0;
}


Measured memory_bytes: 11136
#!/usr/bin/env python3
import sys


def solve(R: int, G: int, B: int, N: int):
    ans = 0
    for i in range(0, N+1, R):
        for j in range(0, N+1, G):
            x = N - i - j
            if(0 <= x and x%B == 0):
                ans += 1

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(R, G, B, N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
using System;
using System.Linq;
public class c
{
  public static void Main()
  {
    int N=int.Parse(Console.ReadLine());
    int A=int.Parse(Console.ReadLine());
    string Ans="No";
    if(N%500<=A)Ans="Yes";
    Console.WriteLine(Ans);
  }
}


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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
   cin.tie(nullptr);
   ios_base::sync_with_stdio(false);

   int n, a, b;
   cin >> n >> a >> b;
   int ab;

   ab = a + b;
   if (a == 0)
   {
      cout << 0 << '\n';
   }
   else if (a >= n)
   {
      cout << n << '\n';
   }
   else if (ab >= n)
   {
      cout << a << '\n';
   }
   else if (n % ab == 0)
   {
      cout << (n / ab) * a << '\n';
   }
   else
   {
      if (n % ab >= a)
      {
         cout << (n / ab) * a + a << '\n';
      }
      else
      {
         cout << (n / ab) * a + (n % ab) << '\n';
      }
   }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    char s[205];
    ll n,ans=0;
    scanf("%s",s);
    n=strlen(s);
    rrep(i,n-3,1){
        if(ans!=0) break;
        // printf("%lld\n",i);
        rep(j,0,i/2+1){
            // printf("%c %c\n",s[j],s[(i/2+1)+j]);
            if(s[j]!=s[(i/2+1)+j]) break;
            if(j==i/2) ans=i+1;
        }
        i--;
    }

    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
   cin>>a>>b>>c>>d;
    e=(min(d,a));
    d=d-e;
    f=min(d,b);
    d=d-f;
    f=0;
    g=min(d,c);
    d=d-g;
    g=g*(-1);
    cout<<e+f+g<<endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int n, m;
	cin >> n >> m;
	vector<int> foods(m+1);
	for (int i = 0; i < n; i++){
		int k;
		cin >> k;
		for (int j = 0; j < k; j++){
			int a;
			cin >> a;
			foods[a]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= m; i++){
		if (foods[i] == n) ans++;
	}
	cout << ans << endl;
 	return 0;
 }

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

using namespace std;


int main(){
    int n,r,g,b;
    cin>>r>>g>>b>>n;


    int ans=0;

    vector <int> num(3);
    num[0] = r;
    num[1] = g;
    num[2] = b;
    sort(num.begin(),num.end());
    for (int i = 0; i*num[0] <=n ; i++)
    {
        for (int j = 0; i*num[0]+j*num[1] <= n; j++)
        {
            if((n-i*num[0]-j*num[1])%num[2]==0){
                ans++;
            }
        }
        
    }
    
    
    cout << ans <<endl;
    return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	
	printf("%d\n", std::max(0, c - (a - b)));
	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 a = sc.nextInt(), b = sc.nextInt(), t = sc.nextInt();
		sc.close();
		int ans = t / a;
		ans *= b;
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    vector<ll> C(N);
    vector<ll> S(N);
    vector<ll> F(N);
    rep1(i,N-1){
        cin>>C[i]>>S[i]>>F[i];
    }
    
    // 1  2  3 4 ...    N
    //  C1 C2  ... C_N-1
    
    //S_i S_i+F_1...
    //S_i/F_i=tmp
    //F_i*(tmp,tmp+1,...)
    
    rep1(i,N){
        ll now=0;
        
        //駅jについて
        FOR(j,i,N){
            ll tmp=S[j]/F[j];
            now = F[j] * max((now+F[j]-1)/F[j],tmp) + C[j];
        }
        
        cout<<now<<endl;
    }
}



Measured memory_bytes: 3600
import sys
def input():
	return sys.stdin.readline()[:-1]

INF = 10**30

class Rmin():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1
		while self.n < size:
			self.n *= 2
		self.node = [INF] * (2*self.n-1)

	def Access(self, x):
		return self.node[x+self.n-1]

	def Update(self, x, val):
		x += self.n-1
		self.node[x] = min(val, self.node[x])
		while x > 0:
			x = (x-1)//2
			self.node[x] = min(self.node[2*x+1], self.node[2*x+2])
		return

	#[l, r)
	def Get(self, l, r):
		L, R = l+self.n, r+self.n
		s = INF
		while L<R:
			if R & 1:
				R -= 1
				s = min(s, self.node[R-1])
			if L & 1:
				s = min(s, self.node[L-1])
				L += 1
			L >>= 1
			R >>= 1
		return s

n, m = map(int, input().split())
seg = []
for _ in range(m):
	l, r, c = map(int, input().split())
	seg.append([l-1, r-1, c])

seg.sort(reverse=True)
ans = [INF for _ in range(n)]
ans[0] = 0
tree = Rmin(n)

for i in range(1, n):
	while seg and seg[-1][0] == i-1:
		l, r, c = seg.pop()
		tree.Update(r, c + ans[l])
	ans[i] = tree.Get(i, n)

if ans[n-1] > 10**29:
	print(-1)
else:
	print(ans[n-1])

Measured memory_bytes: 90204
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste
// #include "UnionFind.h"
// #include "power.h"

signed main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << min({A * B * (C % 2 == 1), B * C * (A % 2 == 1), C * A * (B % 2 == 1)}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans1 = b * d;
    ll ans2 = a * c;
    ll ans3 = a * d;
    ll ans4 = b * c;

    ll ans = max({ans1, ans2, ans3, ans4});
    cout << ans << endl;

}

Measured memory_bytes: 3632
def main():
    N, M = map(int, input().split())
    if abs(N - M) > 1:
        print(0)
        exit()
    v = 10 ** 9 + 7
    ans = 1
    for n in range(1, N+1):
        ans = (ans * n) % v
    for m in range(1, M+1):
        ans = (ans * m) % v
    if N == M:
        ans = (ans * 2) % v
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63248