akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*約数*/vector<ll>div(ll a){vector<ll>b;ll i;rep(i,1,a){if(!a%i)push(b,a);}return b;}
llfor;///////////////////////////////////////////////////////////
int main(){
 ll n;
 sc(n);
 char s[5000];
 sc(s);
 ll k,ans=0,r=0,g=0,b=0;
 rep(i,0,n){
  if(s[i]=='R')r++; 
  if(s[i]=='G')g++;
  if(s[i]=='B')b++;
 }
 ans=r*g*b;
 rep(i,0,n){
  rep(j,i+1,n){
   k=2*j-i;
   if(k>=n)continue;
   if(s[i]==s[k]||s[j]==s[k]||s[i]==s[j])continue;
   ans--;//cout<<i<<" "<<j<<endl;
  }
 }

 pr(ans);
return 0;}



Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define for1(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define clr(x) memset((x), 0, sizeof((x)));
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long i64;
typedef unsigned long long ull;

template<class T>
bool remin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool remax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

ll gcd(ll a, ll b) {
    a = abs(a);
    b = abs(b);
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

typedef ll ptdata;

struct pt {
    ptdata x, y;

    pt() {}

    pt(ptdata x, ptdata y) : x(x), y(y) {}

    inline pt operator-(const pt &r) const {
        return pt(x - r.x, y - r.y);
    }

    inline pt operator+(const pt &r) const {
        return pt(x + r.x, y + r.y);
    }

    inline pt operator*(const ld &r) const {
        return pt(x * r, y * r);
    }

    inline ptdata sqlen() const {
        return abs(x * x + y * y);
    }

    inline bool operator<(const pt &r) const {
        if (x != r.x) return x < r.x;
        return y < r.y;
    }

    inline bool operator==(const pt &r) const {
        return x == r.x && y == r.y;
    }
};

ostream &operator<<(ostream &os, const pt &p) {
    return os << "(" << p.x << "," << p.y << ")";
}

inline ptdata cross(const pt &l, const pt &r) {
    return l.x * r.y - l.y * r.x;
}

inline ptdata dot(const pt &l, const pt &r) {
    return l.x * r.x + l.y * r.y;
}


ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

template<typename T>
inline T sqr(T x) {
    return x * x;
}


void solve() {
    string s;
    cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4) << "\n";
}

void prepare() {

}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    prepare();

    int t = 1;
    //t = nxt();
    forn(i, t) {
        solve();
    }

    //cerr << "Time " << clock() / (double) CLOCKS_PER_SEC << endl;
    return 0;
}


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

#define int long long
#define INF (int)0x3f3f3f3f*(int)0x3f3f3f3f

int n,m;
int ans = INF;

signed main()
{
	cin >> n >> m;
	if(n <= 9 && m <= 9) cout<<n*m;
	else cout<<-1;
	return 0;
}

Measured memory_bytes: 384
class Dice
  def initialize(faces)
    @top = faces.shift
    @front = faces.shift
    @right = faces.shift
    @left = faces.shift
    @back = faces.shift
    @bottom = faces.shift
  end

  def turn_to_n
    old_top = @top
    @top = @front
    @front = @bottom
    @bottom = @back
    @back = old_top
  end

  def turn_to_e
    old_top = @top
    @top = @left
    @left = @bottom
    @bottom = @right
    @right = old_top
  end

  def turn_to_w
    old_top = @top
    @top = @right
    @right = @bottom
    @bottom = @left
    @left = old_top
  end

  def turn_to_s
    old_top = @top
    @top = @back
    @back = @bottom
    @bottom = @front
    @front = old_top
  end

  def rotate
    old_front = @front
    @front = @right
    @right = @back
    @back = @left
    @left = old_front
  end

  def right_when_top_and_front_are(top, front)
    set_top_to(top)
    keep_top_and_set_front_to(front)
    @right
  end

  def ==(other)
    return true if is_same?(other)
    4.times {
      other.rotate
      return true if is_same?(other)
    }
    3.times {
      turn_to_e
      4.times {
        other.rotate
        return true if is_same?(other)
      }
    }
    turn_to_e
    turn_to_n
    4.times {
      other.rotate
      return true if is_same?(other)
    }
    turn_to_s
    turn_to_s
    4.times {
      other.rotate
      return true if is_same?(other)
    }
    false
  end

  def is_same?(other)
    @top == other.top && @front == other.front && @right == other.right \
      && @left == other.left && @back == other.back && @bottom == other.bottom
  end

  attr_reader :top, :front, :right, :left, :back, :bottom

  private

  def set_top_to(top)
    return if @top == top
    case top
      when @front then turn_to_n
      when @left then turn_to_e
      when @right then turn_to_w
      when @back then turn_to_s
      else turn_to_s; turn_to_s
    end
  end

  def keep_top_and_set_front_to(front)
    return if @front == front
    case front
      when @left then turn_to_e; turn_to_s; turn_to_w
      when @right then turn_to_w; turn_to_s; turn_to_e
      when @back then turn_to_e; turn_to_s; turn_to_s; turn_to_w
    end
  end
end

n = gets.to_i
dices = (1..n).map {Dice.new gets.split(" ").map(&:to_i)}
count = 0
(0...n).each {|i|
  (0...n).each {|j|
    if i != j && dices[i] == dices[j] then
      count += 1
    end
  }
}
puts count == 0 ? "Yes" : "No"

Measured memory_bytes: 8744
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
b=sorted(a,reverse=True)

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


Measured memory_bytes: 19008
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    int N, K;
    cin >> N >> K;
    int p[N];
    REP (i, N) {
        cin >> p[i];
    }

    int sum[N+1];
    REP (i, N+1) {
        if (i == 0) {
            sum[0] = 0;
        }
        sum[i] = sum[i-1] + p[i-1];
    }
    int max_sum = 0, place;
    REP (i, N-K+1) {
        int tmp = sum[i+K] - sum[i];
        if (tmp > max_sum) {
            max_sum = tmp;
            place = i;
        }
    }
    ld ans = 0;
    for (int i = place; i < place+K; i++) {
        ans += (ld)(p[i]+1) / 2;
    }

    cout << fixed << setprecision(8) << ans << endl;
}

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

int main(){
	string s;
	cin >> s;
	int n = s.size();
	int ans(0);
	rep(i,n/2){
		if(s[i] != s[n-1-i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a;
int main()
{
	int ok=0,n,m;
	getline(cin,a);
	for(int i=0;i<a.size();i++){
		if(a[i]=='C')ok=1;
		if(a[i]=='F'&&ok==1){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define DR(i,a,b) for (int i=(b); i-->(a);)
#define D(i,n) DR(i,0,n)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream &operator<<(ostream &os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i];
    return os;
}
const bool debug = 1;

typedef long double ld;
int s(int n) {
    if (n == 0) return 0;
    return n%10 + s(n/10);
}
ld r(int n) {
    return (ld)s(n)/n;
}

int rup(int a, int d) {
    return (a+d-1)/d;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    /*double best = 0;
    D(i,10000000) {
        double r = (double)s(i)/i;
        if (r >= best) {
            H(i)
            best = r;
        }
    }*/
    int k; cin>>k;
    int p = 1, cur = 2;
    while (k) {
        int x = cur*p - 1;
        int y = rup(cur, 10)*p*10 - 1;
        if (r(y) > r(x)) {
            cur = rup(cur, 10);
            p *= 10;
        } else {
            cout<<x<<"\n";
            k--;
            cur += 1;
        }
    }
}

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

#define double long double
#define int long long
#define ALL(x) x.begin(),x.end()
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define eb emplace_back
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 998244353 
#define F(i, a, n) for(i=a;i<n;i++)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

const int N = 1e6 + 5;
int a[N];

int32_t main(void)
{
    FASTER;
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j;
    int n;
    SI(n);
    vi muow;
    F(i, 0, n)
    {
    	int x;
    	SI(x);
    	if(!a[x])
    		muow.pb(x);
    	a[x]++;
    }
    bool ok[N];
	fill(ok, ok + N, true);
	sort(muow.begin(), muow.end());
    for(auto x: muow)
    {
    	for(j = 2*x; j < N; j += x)
    		ok[j] = false;
    }
    int ans = 0;
    F(i, 0, N)
    {
    	if(ok[i] && a[i] == 1)
    		++ans;
    }
    SO(ans);
    
    
    
    #ifdef LOCAL
    	cout<<endl<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 13668
#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 K;
string S;
int N;

const ll mo=1000000007;	

ll comb(ll N_, ll C_) {
	const int NUM_=2400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
ll hcomb(int P_,int Q_) { return (P_==0&&Q_==0)?1:comb(P_+Q_-1,Q_);}

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


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K>>S;
	N=S.size();
	
	ll ret=0;
	FOR(i,K+1) {
		ret+=modpow(26,i)*modpow(25,K-i)%mo*hcomb(N,K-i)%mo;
	}
	cout<<ret%mo<<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: 60488
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int x = int.Parse(input[0]);
            int a = int.Parse(input[1]);

            if (x < a)
                Console.WriteLine(0);
            else
                Console.WriteLine(10);
        }
    }

Measured memory_bytes: 11092
N, M = map(int, input().split())

order_list = [list(map(int, input().split())) for _ in range(M)]

for x in range(10**N):
    if len(str(x)) == N:
        for o in order_list:
            if str(x)[o[0]-1] != str(o[1]):
                break
        else:
            print(x)
            exit()

print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(20)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  string S; cin >> S;
  if(S=="SUN") cout << 7 << endl;
  else if(S=="SAT") cout << 1 << endl;
  else if(S=="FRI") cout << 2 << endl;
  else if(S=="THU") cout << 3 << endl;
  else if(S=="WED") cout << 4 << endl;
  else if(S=="TUE") cout << 5 << endl;
  else cout << 6 << endl;
}

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

int main() {
    string s;
    cin >> s;
    
    string d = "";
    
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '0') {
            d.insert(d.size(), "0");
        } else if (s[i] == '1') {
            d.insert(d.size(), "1");
        } else if (s[i] == 'B') {
            if (0 < d.size()) {
                d.erase(d.size() - 1);
            }
        }
    }
    
    cout << d << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  int n;
  cin>>n;
  vector<int> t(n-1);
  REP(i,n-1) cin>>t[i];
  vector<int> dpa(n+2,100000000);
  vector<int> dpb(n+2,100000000);
  dpa[1] = 0;
  REP(i,n-1) {
    vector<int> tmpa(n,1000000000);
    vector<int> tmpb(n,1000000000);
    REP(j,n/2+1) {
      tmpa[j+1] = min(tmpa[j+1], dpa[j]);
      tmpa[j+1] = min(tmpa[j+1], dpb[j]+t[i]);
      tmpb[j] = min(tmpb[j], dpb[j]);
      tmpb[j] = min(tmpb[j], dpa[j]+t[i]);
    }
    swap(tmpa,dpa);
    swap(tmpb,dpb);
  }
  cout << min(dpa[n/2], dpb[n/2]) << endl;
  return 0;
}

Measured memory_bytes: 1352
N = int(input())
W = list(map(int, input().split()))
Sum = sum(W)
Half = Sum / 2

s2 = 0
min_d = Sum
for w in W:
    if s2 + w >= Half:
        min_d = min(abs(Sum - s2 * 2), abs(Sum - (s2 + w) * 2))
        break
    s2 += w

print (min_d)


Measured memory_bytes: 3060
#include <iostream>

int main(void)
{
    int x, y, W, H, r;
    std::cin >> W >> H >> x >> y >> r;
    if((r <= x && x <= W-r) && (r <= y && y <= H-r)) {
	std::cout << "Yes" << std::endl;
    } else {
	std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1156
def checkWays(n,x)
  count = 0
  catch(:stop) do
    n.downto(1) do |n1|
      (n1-1).downto(1) do |n2|
        n3 = x - n1 - n2
        count += 1 if (n3 < n2) && (n3 > 0)
        throw :stop if (n3 > n1)
        break if (n3 > n2)
      end
    end
  end
  puts count
end

while ((n,x = gets.split(" ").map(&:to_i)) != [0,0]) do
  checkWays(n,x)
end

Measured memory_bytes: 8600
O = input()
E = input()
P = ""
for i in range(min(len(O),len(E))):
  if O[i] == "":
    break
  else:
    P = P+O[i]
  if E[i] == "":
    break
  else:
    P = P+E[i]
if len(O)-len(E) == 1:
  P = P+O[-1]
elif len(E)-len(O) == 1:
  P = P+E[-1]
else:
  P = P
print(P)

Measured memory_bytes: 3064
N = int(input())
S = str(input())

ans = 0

for i in range(0, 10):
    a = S.find(str(i))
    if a == -1:
        continue
    for j in range(0, 10):
        b = S.find(str(j), a + 1)
        if b == -1:
            continue
        for k in range(0, 10):
            c = S.find(str(k), b + 1)
            if c == -1:
                continue
            ans += 1
print(ans)


Measured memory_bytes: 62796
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <complex>
#include <cmath>
//#include <cstdlib>
using namespace std;

#define FOR(i,x) for(int i=0;i<x;i++)

const double EPS = 1e-7;
typedef complex<double> P; /* _ */
struct L { P p, q; L(P p, P q) : p(p), q(q) {} }; /* üª */

// complexÉå¬ÖWªKvÈê
namespace std{
	bool operator < (const P &a, const P &b){ return make_pair(real(a),imag(a)) < make_pair(real(b),imag(b)); }
}

// àÏEOÏEpx(xNga,bÌZ)
double dot(P a, P b) { return real(conj(a)*b); }
double cross(P a, P b) { return imag(conj(a)*b); }
double angle(P a, P b) { return arg(conj(a)*b); }

// _p©ç¼ülÉºëµ½üÌ«
P footPerp(L l, P p) {
	return l.p + (l.q-l.p)*( dot(l.q-l.p, p-l.p) / (abs(l.q-l.p)*abs(l.q-l.p)));
}

// ¼ülÉÎ·é_pÌ
P lineShadow(L l, P p) {
	return footPerp(l, p)+footPerp(l, p)-p;
}

int main(){
	string in;
	while(cin>>in){
		double x1,y1,x2,y2,xq,yq;
		sscanf(in.c_str(), "%lf,%lf,%lf,%lf,%lf,%lf", &x1,&y1,&x2,&y2,&xq,&yq);
		/*
		double x1 = atof(in.substr(0, in.find(',')).c_str());
		in = in.substr(in.find(',')+1);
		double y1 = atof(in.substr(0, in.find(',')).c_str());
		in = in.substr(in.find(',')+1);
		double x2 = atof(in.substr(0, in.find(',')).c_str());
		in = in.substr(in.find(',')+1);
		double y2 = atof(in.substr(0, in.find(',')).c_str());
		in = in.substr(in.find(',')+1);
		double xq = atof(in.substr(0, in.find(',')).c_str());
		in = in.substr(in.find(',')+1);
		double yq = atof(in.substr(0, in.find(',')).c_str());
		in = in.substr(in.find(',')+1);*/

		L l = L(P(x1,y1), P(x2,y2));
		P q = P(xq, yq);

		P r = lineShadow(l, q);

		printf("%.7f %.7f\n", real(r), imag(r));
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ll N, M, X, Y; cin >> N >> M >> X >> Y;
    ll xi[N];
    ll yi[M];
    ll miny = 100;
    ll maxx = -100;

    for(int i = 0; i < N; i++)
    {
        cin >> xi[i];
        maxx = max(maxx, xi[i]);
    }

    for(int i = 0; i < M; i++)
    {
        cin >> yi[i];
        miny = min(miny, yi[i]);
    }

    /*if(miny > maxx)
    {
        if(X < miny && miny <= Y)
        {
            for(int i = 0; i < N; i++)
            {
                if(miny < xi[i])
                {
                    cout << "War" << endl;
                    return 0;
                }
            }
        }

        else
        {
            cout << "War" << endl;
            return 0;
        }
    }

    else
    {
        if(X < maxx && maxx <= Y)
        {
            for(int i = 0; i < M; i++)
            {
                if(maxx < yi[i])
                {
                    cout << "War" << endl;
                    return 0;
                }
            }
        }

        else
        {
            cout << "War" << endl;
            return 0;
        }
    }

    cout << "No War" << endl;*/

    if(max(X, maxx) < min(Y, miny))
    {
        cout << "No War" << endl;
    }

    else
    {
        cout << "War" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fi first
#define se second
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
   ll a,b,i;
   cin>>a>>b;
   if(a<b)
   {
       cout<<0;
   }
   else
   {
       cout<<10;
   }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(){
    
    int n,cnt=0,f=0;
    cin>>n;
    long long a[n],ans=1;
    //long double ans=1.0,tmp=1;
 /*
    for(int i=0;i<n;i++){
        cin>>a;
        tmp=a;
        while(tmp>10){
            tmp=tmp/10;
            cnt++;
        }
        if(cnt>=18){
            ans=-1;
            f=1;
            cout<<-1<<"\n";
            cnt=0;
            break;
        }
        ans=ans*tmp;
    }
    for(int i=0;i<cnt;i++){
        ans=ans*10;
        if(ans>1000000000000000000){
            cout<<-1<<"\n";
            f=1;
        }
        //return 0;
    }
    if(f==0){
        cout<<(long long)ans<<"\n";
    }
    */
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<"\n";
            return 0;
        }
    }
    
    for(int i=0;i<n;i++){
        if(a[i]<=1000000000000000000/ans){
            ans=ans*a[i];
        }else{
            cout<<-1<<"\n";
            return 0;
        }
    }
    cout<<ans<<"\n";
    
    return 0;
}

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

int main(){
    int n, m, t, i, j = 0, k;
    long long s = 0;
    cin >> n >> m;
    int a[n+1] = {};
    pair<int, int> p[m];
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    for(i=0; i<m; i++){
        cin >> p[i].second >> p[i].first;
    }
    sort(p, p+m);
    for(i=m-1; i>=0; i--){
        k = 0;
        while(k < p[i].second && j < n){
            if(a[j] < p[i].first){
                a[j] = p[i].first;
                k++;
                j++;
            }else{
                break;
            }
        }
        if(a[j] > p[i].first){
            break;
        }
    }
    for(i=0; i<n; i++){
        s += (long long)a[i];
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main(){

    int i, n;
    scanf("%d", &n);
    int a[n];
    for (i=0;i<n;i++) scanf("%d", &a[i]);
    printf("%d", a[n-1]);
    for (i=2;i<n+1;i++) printf(" %d", a[n-i]);
    printf("\n");

    return 0;

}



Measured memory_bytes: 2032
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ull unsigned long long
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

int main() {
	int N,i,b=0,r=0;
	string str;
	cin >> N >> str;
	char c;
	REP(i, N) {
		if (str[i] == 'R')
			r++;
		else
			b++;
	}
	if (r > b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

int main() {
    int n; string s, t; cin >> n >> s >> t;
    string ans = "";
    for (int i = 0; i < n; ++i) {
        ans += s[i]; ans += t[i];
    }
    cout << ans;


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int m;
  std::vector<int> v;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &m);
    v.push_back(m);
  }
  std::sort(v.begin(), v.end());
  long long int ans = 0;
  int i;
  for (i = 0; i < n; ++i) {
    if (v[i] < 0) {
      if (i % 2 == 0) {
        if (i + 1 < n) {
          if (v[i + 1] >= 0) {
            if (-v[i] > v[i + 1]) {
              ans += -v[i] - 2 * v[i + 1];
            } else {
              ans += v[i];
            }
          } else {
            ans += -v[i];
          }
        } else {
          ans += v[i];
        }
      } else {
        ans += -v[i];
      }
    } else {
      ans += v[i];
    }
  }

  printf("%lld\n", ans);

  return 0;
}


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

int main() {
  int n, a, b, c, d;
  cin >> n;
  
  a = n / 1000;
  b = (n - a * 1000) / 100;
  c = (n - a * 1000 - b * 100) / 10;
  d = n - a * 1000 - b * 100 - c * 10;
  
  if (a == b && b == c || b == c && c == d) {
    cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
/**
 * snuke code
**/
fn main() {
    input! {
            h:usize,
            w:usize,
            k:usize,
        s:[Chars;h],
    }
    dbg!(&s);
    let mut ans = INF;
    // 横に切る方法を全探索
    for div in 0..(1usize << (h - 1)) {
        let mut g: usize = 0;
        let mut id = vec![0usize; h + 1];
        for i in 0..h {
            id[i] = g;
            if (((div >> i) & 1) == 1) {
                g += 1;
            }
        }
        // dbg!(div);
        g += 1;
        let mut c = vec![vec![0usize; w]; g];
        // groupにmapping
        for i in 0..h {
            for j in 0..w {
                c[id[i]][j] += (s[i][j] as u8 - b'0') as usize;
            }
        }

        // dbg!(&c);
        let mut num: usize = g - 1;
        // 各グループで何個のホワイトチョコがあるか
        let mut now = vec![0usize; g];
        for j in 0..w {
            // dbg!(j);
            if !add(&mut now, j, g, k, &c) {
                num += 1;
                now = vec![0usize; g];
                if !add(&mut now, j, g, k, &c) {
                    num = INF;
                    break;
                }
            }
            // dbg!(&now);
            // dbg!(num);
        }
        dbg!(div, num);
        ans = min(ans, num);
    }
    println!("{}", ans);
}
// j列目をnowに加算
fn add(now: &mut Vec<usize>, j: usize, g: usize, k: usize, c: &Vec<Vec<usize>>) -> bool {
    for i in 0..g {
        now[i] += c[i][j];
    }
    for i in 0..g {
        if now[i] > k {
            return false;
        }
    }
    return true;
}
const INF: usize = 1 << 62;

pub fn charconv(c: char, base: char) -> usize {
    return (c as u8 - base as u8) as usize;
}


Measured memory_bytes: 2300
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<iterator>
#include<iostream>
#include<sstream>
#include<cctype>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<stack>
#include<functional>
#include<utility>
#include<numeric>
#include<bitset>
#include<iterator>
#define INF (int)1e9
#define MOD 1000000007
#define tr(c, it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define debug(x) cout<<#x" = "<<(x)<<endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz size
#define ll long long
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MEM(a, b) memset(a, (b), sizeof(a))
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?"\n":" ")
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?"\n":" ")
#define PRE(i, m, n, in) for(int (i)=(m);(i)<(n);i+=in)
#define RFOR(i, n) for(int i=n ; i>=0 ; i--)
#define RPRE(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define ERS(A, P) A.erase(A.begin() + P)
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<int>())
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define countv(v,a) count(v.begin(),v.end(),a)
#define toint(a) atoi(a.c_str())
using namespace std;
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
typedef vector <int> VI;
typedef vector <ll> VL;
typedef vector<string> VS;
typedef vector <VS> VSS;
typedef vector <II> VII;
typedef vector <LL> VLL;
typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VII> VVII;
typedef vector <VLL> VVLL;
typedef map<int,int> MPII;
typedef map<ll,ll> MPLL;
typedef map<string, int>MPSI;
typedef map<string, ll>MPSL;
typedef map<int, string>MPIS;
typedef map<ll, string> MPLS;
typedef map<string, string> MPSS;
typedef set<int> SETI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    int n; cin >> n; VI v(n); VI c(n);
    FOR(i, n) {
      cin >> v[i];
    }
    int max_global = 0;
    FOR(i, n) {
      cin >> c[i];
      if(v[i] - c[i] > 0) {
        max_global += (v[i] - c[i]);
      }
    }
    std::cout << max_global << '\n';
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000000)

def dfs(x):
  if x == N:
    return 1
  if x > N:
    return 0
  if memo[x] >= 0:
    return memo[x]
  memo[x] = dfs(x+1) + dfs(x+2)
  return memo[x]

N, M = map(lambda x: int(x), input().split())
a = [int(input()) for i in range(M)]
#print(N)
#print(M)
#print(a)
memo = [-1]*(N+1)
for ai in a:
  memo[ai] = 0
count = dfs(0)
print(count%1000000007) 



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

#define NIL -2
#define INF 1000000001
#define EPS 1e-10
#define equals(a,b) (fabs((a) - (b)) < EPS)

using namespace std;
class Point{
    public:
    double x,y;

    Point(double x = 0,double y = 0): x(x), y(y) {}

    Point operator + (Point p){ return Point(x+p.x, y+p.y); }
    Point operator - (Point p){ return Point(x-p.x, y-p.y); }
    Point operator * (double k){ return Point(x*k,y*k);      }
    Point operator / (double k){ return Point(x/k,y/k);      }

    double norm(){ return x*x + y*y;}
    double abs(){ return sqrt(norm());}
    double dot(Point p){
        return x*p.x + y*p.y;
    }

    bool operator < (Point &p){
        return x != p.x ? x < p.x : y < p.y;
    }
    bool operator == (Point &p){
        return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
  
};
typedef Point Vector;

int main(){
    double x1,y1,x2,y2;
    double x,y;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    Point p1(x1,y1);
    Point p2(x2,y2);
    Vector p12 = p2-p1;
    p12 = p12 / p12.abs();

    int q;
    scanf("%d",&q);
    for(int i = 0;i < q;i++){
        scanf("%lf %lf",&x,&y);
        Point p(x,y);
        p = p - p1;
        Point ans;
        double inner_prod = p12.dot(p);
        ans = p1 + p12 * inner_prod;
        printf("%.9lf %.9lf\n",ans.x,ans.y);
    }
    return 0;
}


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

typedef long long ll;

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

const long double PI = 4 * atanl(1);

int main()
{
	int x1,y1,x2,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	bool revX = false;
	bool revY = false;
	if(x1 > x2){
		revX = true;
		x1 = 1e8 - x1;
		x2 = 1e8 - x2;
	}
	if(y1 > y2){
		revY = true;
		y1 = 1e8 - y1;
		y2 = 1e8 - y2;
	}
	vector<pii> fountain;
	int n;
	cin >> n;
	FOR(i,0,n){
		int X,Y;
		cin >> X >> Y;
		if(revX)X = 1e8 - X;
		if(revY)Y = 1e8 - Y;
		if(min(x1, x2) <= X && X <= max(x1,x2) && min(y1,y2) <= Y && Y <= max(y1,y2)){
			fountain.pb(mp(X,Y));
		}
	}
	sort(ALL(fountain));
	vector<int> dp(fountain.size()+1,INF);
	FOR(i,0,(int)fountain.size()){
		*(lower_bound(ALL(dp), fountain[i].second)) = fountain[i].second;
	}
	int cnt = lower_bound(ALL(dp), INF) - dp.begin();
	int tyoksuin = 0;
	if(cnt == min(x2-x1, y2-y1)+1){
		tyoksuin = 1;
	}
	long double ans = (x2-x1 + (ll)(y2-y1)) * 100ll + (long double)cnt * (5 * PI - 20) + tyoksuin * 5 * PI;
	printf("%.15lf\n", (double)ans);
	return 0;
}


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

using namespace std;

int main(){
    int X, Y, a, b;
    bool flag = 0;

    cin >> X >> Y;

    //  a + b = X
    //  2a + 4b = Y

    for(int i = 0; i <= 100; i ++){
        for(int j = 0; j <= 100; j ++){
            if((i + j == X) && (2 * i + 4 * j == Y))flag = 1;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3688
#include <stdio.h>

int main(){
    double a,b,c,d,e,f;
    double x,y;
    
    while (scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF) {
        x=(double)((c*e-b*f)/(a*e-b*d));
        y=(double)((c*d-a*f)/(b*d-a*e));
        if(-0.0005<x && x<=0)
            x=0;
        if(-0.0005<y && y<=0)
            y=0;
        printf("%.3f %.3f\n",x,y);
    }
    
    return 0;
}

Measured memory_bytes: 2616
#include <bits/stdc++.h>
#include <unistd.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int n, q;
string s;
vector<char> t;
vector<char> d;

// x の場所のゴーレムが落ちるか？
bool ok( int x ){
	bool flag = true;
	for( int i = 0; i < q; ++i ){
		if( s[x] == t[i] ){
			if( d[i] == 'L' ) --x; else ++x;
			if( x < 0 || n <= x ){
				flag = false;
				break;
			}
		}
	}
	return flag;
}

// x の場所のゴーレムがどっちに落ちるか？
char ok2( int x ){
	bool flag = true;
	for( int i = 0; i < q; ++i ){
		if( s[x] == t[i] ){
			if( d[i] == 'L' ) --x; else ++x;
			if( x < 0 || n <= x ){
				flag = false;
				break;
			}
		}
	}
	if( flag ) return 'T';
	else{
		if( x < 0 ) return 'L';
		else return 'R';
	} 
}

int main(){
	cin >> n >> q;
	cin >> s;
	for( int i = 0; i < q; ++i ){
		char tmp0, tmp1;
		cin >> tmp0 >> tmp1;
		t.push_back(tmp0);
		d.push_back(tmp1);
	}
	bool a = ok(0), b = ok(n-1);
	// cout << a << " " << b << endl;
	if( a && b ){
		cout << n << endl;
		return 0;
	}
	int ans;
	if( a && !b ){
		// cout << "a && !b" << endl;
		int l = 0, r = n-1, mid;
		while( r-l > 1 ){
			mid = (l+r)/2;
			// cout << mid << ": " << ok(mid) << endl;
			if( ok(mid) ){
				l = mid;
			} else {
				r = mid;
			}
		}
		ans = (n-l-1);
	} else if( !a && b ){
		// cout << "!a && b" << endl;
		int l = 0, r = n-1, mid;
		while( r-l > 1 ){
			mid = (l+r)/2;
			if( ok(mid) ){
				r = mid;
			} else {
				l = mid;
			}
		}
		ans = n-l-1;
	} else{
		// cout << "!a && !b" << endl;
		int k = -1;
		int l_ = 0, r_ = n-1, mid_;
		bool fla = false;
		while( r_-l_ > 1 ){
			mid_ = (l_+r_)/2;
			if( ok2(mid_) == 'T' ){
				k = mid_;
				fla = true;
				break;
			} else if( ok2(mid_) == 'L' ){
				l_ = mid_;
			} else {
				r_ = mid_;
			}
			/*
			cout << mid_ << ": " << ok2(mid_) << endl;
			sleep(1);
			*/
		}
		if( k == -1 ){
			cout << 0 << endl;
			return 0;
		}
		{
		int l = 0, r = k, mid;
		while( r-l > 1 ){
			mid = (l+r)/2;
			if( ok(mid) ){
				r = mid;
			} else {
				l = mid;
			}
		}
		// cout << (l+1) << endl;
		ans += (l+1);
		}
		
		// かぶる場合は OK ?
		{
		int l = k, r = n-1, mid;
		while( r-l > 1 ){
			mid = (l+r)/2;
			if( ok(mid) ){
				l = mid;
			} else {
				r = mid;
			}
		}
		// cout << (n-l-1) << endl;
		ans += (n-l-1);
		}
		
		ans = n - ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

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

    for (int i = 0; i < n; i++) {
        cout << vec[i] << '\n';
    }

    return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    int ga,sa,ba;
    int gb,sb,bb;
    Scd(N);
    Scd3(ga,sa,ba);
    Scd3(gb,sb,bb);

    vl dp(N+1,N);

    Rep(ni,N+1){
        if( ni+ga <= N )
        dp[ni+ga] = max( dp[ni+ga], dp[ni] + gb-ga );
        if( ni+sa <= N )
        dp[ni+sa] = max( dp[ni+sa], dp[ni] + sb-sa );
        if( ni+ba <= N )
        dp[ni+ba] = max( dp[ni+ba], dp[ni] + bb-ba );
    }

    ll M = 0;
    Rep(i,N+1) M = max( M, dp[i] );

    swap(ga,gb);
    swap(sa,sb);
    swap(ba,bb);
    dp.assign(M+1,M);
    Rep(ni,M+1){
        if( ni+ga <= M )
        dp[ni+ga] = max( dp[ni+ga], dp[ni] + gb-ga );
        if( ni+sa <= M )
        dp[ni+sa] = max( dp[ni+sa], dp[ni] + sb-sa );
        if( ni+ba <= M )
        dp[ni+ba] = max( dp[ni+ba], dp[ni] + bb-ba );
    }
    ll ans = 0;

    Rep(i,M+1) ans = max( ans, dp[i] );

    printf ("%lld\n", ans );

    return 0;
}



Measured memory_bytes: 195584
n=int(input())
a=[]
ans=0

for i in range(n):
  _=int(input())
  dic={}
  for j in range(_):
    x,y=map(int,input().split())
    dic[x]=y
  a.append(dic.copy())
  

for i in range(2 ** n):#bit全探索
    b=[]
    for j in range(n):
      if i>>j & 1:
        b.append(j)
    summ=0
    jdg=[-1]*n
    flgg=0
    for j in range(len(b)):
      if jdg[b[j]]==-1:
        jdg[b[j]]=1
      elif jdg[b[j]]!=1:
        flgg=1
        break
      dic=a[b[j]]
      key=list(dic.keys())
      flg=0
      for k in range(len(key)):
        if jdg[key[k]-1]==-1:
          jdg[key[k]-1]=dic[key[k]]
        elif jdg[key[k]-1]==dic[key[k]]:
          jdg[key[k]-1]=dic[key[k]]
        else:
          flg=1
          flgg=1
          break
      if flg==1:
        flgg=1
        jdg=[-2]*n
        break
    
    sumi=0
    if flgg==0:
      for j in range(len(jdg)):
        if jdg[j]==1:
          sumi+=1
    if sumi==len(b):
      summ=sumi
    ans=max(ans,summ)
print(ans)

Measured memory_bytes: 49772
#include <stdio.h>

int main(void)
{
  int y, m;
  scanf("%2d%2d", &y, &m);
  if (y == 0) {
    if (1 <= m && m <= 12) {
      puts("YYMM");
    } else {
      puts("NA");
    }
  } else if (m == 0) {
    if (1 <= y && y <= 12) {
      puts("MMYY");
    } else {
      puts("NA");
    }
  } else if (y > 12 && m > 12) {
    puts("NA");
  } else if (y > 12 && m <= 12) {
    puts("YYMM");
  } else if (y <= 12 && m > 12) {
    puts("MMYY");
  } else {
    puts("AMBIGUOUS");
  }
}


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

bool dp[200005] = {0};
vector<int> edge[200005];
int n, mdis = 0;

int bfs(int x);
bool solve();

int main() {
  cin >> n;
  for(int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  bfs(bfs(0));
  if(solve())
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}

int bfs(int x) {
  int ans = 0, num = x;
  vector<int> dis;
  queue<int> qu;
  dis.assign(n, n + 1);
  qu.push(x);
  dis[x] = 0;
  while(qu.size() > 0) {
    int now = qu.front();
    qu.pop();
    for(int i = 0; i < edge[now].size(); ++i) {
      int nextp = edge[now][i];
      if(dis[nextp] <= dis[now] + 1) continue;
      dis[nextp] = dis[now] + 1;
      if(ans < dis[nextp]) {
        ans = dis[nextp];
        num = nextp;
      }
      qu.push(nextp);
    }
  }
  mdis = ans;
  return num;
}

bool solve() {
  dp[1] = 1;
  dp[2] = 0;
  for(int i = 3; i <= mdis + 1; ++i)
    dp[i] = (!dp[i - 1]) | (!dp[i - 2]);
  return dp[mdis + 1];
}

Measured memory_bytes: 13556
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    a, b = ns()

    g = fractions.gcd(a, b)

    def search(n):
        i = 2
        so = []
        while not(n == 1 or i * i > n):
            while n % i == 0:
                n //= i
                so.append(i)
            i += 1
        if n != 1:
            so.append(n)

        return so

    ans = set(search(g))
    print(len(ans) + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5116
import java.util.*;

public class Main {


    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        String line = sc.next();

        int[] arr = new int[n+1];
        for(int i = 0;i < n;i++){
            if(i+2 < n){
                if(line.charAt(i) == '.' && line.charAt(i+1) == '.' && line.charAt(i+2) == '.'){
                    arr[i+1] = 1;
                }
            }
            if(i + 1 < n){
                if(line.charAt(i) == '#' && line.charAt(i+1) == '#'){
                    arr[i+1] = -1;
                }
            }
        }

        boolean ans  = true;
        for(int i = a;i < c;i++){
            if(arr[i] == -1) {
                ans = false;
                break;
            }
        }

        for(int i = b;i < d;i++){
            if(arr[i] == -1) {
                ans = false;
                break;
            }
        }

        if(d < c){
            boolean jump = false;
            for(int i = b-1;i < d;i++){
                if(arr[i] == 1) {
                    jump = true;
                    break;
                }
            }
            ans = ans && jump;
        }
        System.out.println(ans ? "Yes" : "No");
    }
}

Measured memory_bytes: 28588
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 505;
const int INF = 3000;
char arr[N][N];
char SYM[] = "RYGB";
int n, m, d;

int main()
{                                                     
	ios_base::sync_with_stdio(0);
	
	cin >> n >> m >> d;

	if (d % 2 == 1) {
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				arr[i][j] = SYM[(i + j) % 4];
	}
	else {
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++) {
				int new_x, new_y;
				if ((i + j) % 2 == 0) {
					new_x = (i + j + INF) / 2;
					new_y = (i - j + INF) / 2;
				}
				else {
					new_x = (i + j + 1 + INF) / 2;
					new_y = (i - j + 1 + INF) / 2;
				}
				int new_d = d / 2;

				int x_sqr = new_x / new_d;
				int y_sqr = new_y / new_d;

				if (x_sqr % 2 == 0)
					arr[i][j] = SYM[y_sqr % 4];
				else 
					arr[i][j] = SYM[(y_sqr + 2) % 4];
			}
	}


	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cout << arr[i][j];
		}
		cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 768
l,r = map(int,input().split())
if (r - l ) >= 2019 :
  print(0)
else:
  ans = 2020
  for i in range(l,r+1):
    for j in range(l,r+1):
      if i != j:
        ans = min(ans, (i*j) % 2019 )
  print(ans)


Measured memory_bytes: 2940