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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s, t; cin >> s >> t;

  vector<int> f(26, -1), sec(26, -1);
  
  rep(i, s.size()) {
    int a = s[i]-'a';
    int b = t[i]-'a';

    if(f[a] != -1 || sec[b] != -1) {
      if(f[a] != b || sec[b] != a) {
	cout << "No" << endl;
	return 0;
      }
    }
    
    f[a] = b;
    sec[b] = a;
  }	
  cout << "Yes" << endl;
}


Measured memory_bytes: 916
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s, int v, vector<int>& d, whei(edge)& G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size(); i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}


int main() {
	int n;
	cin >> n;
	hei(int) a(n);
	llint ans = 0;
	rep(i, 0, n) {
		cin >> a[i];
	}
	int i = 1;
	while (i != 2) {
		ans++;
		i = a[i - 1];
		if (ans == 1000000) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    cin >> k;
    cin >> a >> b;
    n = a / k;
    c = a % k;
    if (a % k == 0 || b % k == 0) {
        cout << "OK";
    }
    else if (a < (a - c + k) && (a - c + k) < b) {
        cout << "OK";
    }
    else {
        cout << "NG";
    }

}

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
int d[100000];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&d[i]);
    std::sort(d,d+n);
    printf("%d\n",d[n/2]-d[n/2-1]);
    return 0;
}

Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}



use std::cmp;
use std::ascii::AsciiExt;
use std::iter::Iterator;

fn main() {
    input! {
        n:usize,
        k:usize,
        s:chars
    }

    let mut ss = s;
    ss[k -1] = ss[k-1].to_ascii_lowercase();


    let mut sss = "".to_string();

    for elem in ss {
        sss.push(elem);
    }
    println!("{}",  sss);

}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;
#define int long long
signed main(){
    int n;
    cin >> n;
    vector<int> v(n+1, 0);
    int prime;
    for (int i = 2; i <= n; i++)
    {
        prime = 2;
        int copy = i;
        while (prime * prime <= copy){
            if(copy%prime==0){
                v[prime]++;
                copy /= prime;
            }
            else
                prime++;
        }
        v[copy]++;
    }
  /*  for (int i = 0; i <=n; i++)
    {
        cerr << v[i] << " ";
    }
    cerr << "\n";
    */
    int cnt2 = 0;
    int cnt4 = 0;
    int cnt14 = 0;
    int cnt24 = 0;
    int cnt74 = 0;
    for (int i = 0; i <= n; i++)
    {
        if(v[i]>=2)
            cnt2++;
        if (v[i]>=4)
            cnt4++;
        if(v[i]>=14)
            cnt14++;
        if(v[i]>=24)
            cnt24++;
        if(v[i]>=74)
            cnt74++;

    }
   // cerr << cnt2 << cnt4 << cnt14 << cnt24 << cnt74 << endl;
    cout <<cnt74+ cnt24*(cnt2-1)+cnt14*(cnt4-1)+(cnt4-1)*cnt4/2*(cnt2-2)<< endl;

    return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N, K; cin >> N >> K;
    vi A(N); REP(i, N) cin >> A[i];
    cout << ((N-1)+(K-1)-1) / (K-1) << endl;
}
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int x1,x2,d;
	scanf("%d %d",&x1,&x2);
	d=x1-x2;
	if(d<0)	d=-d;
	printf("%d\n",d);
	return 0;
}


Measured memory_bytes: 2724
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
L=get_i
ans=0
(N-2).times do|i|
    (i+1).upto(N-2) do|j|
        next if L[i]==L[j]
        (j+1).upto(N-1) do|k|
            next if L[j]==L[k] or L[i]==L[k]
            ans+=1  if L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j]
        end
    end
end
puts ans

Measured memory_bytes: 14356
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int r,g,b;
  cin >> r >> g >> b;
  int N;
  N = 100*r+10*g+b;
  if(N%4==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int find(int x);
int same(int x,int y);
void unite(int x,int y);
int qfind(int x);
int qsame(int x,int y);
void qunite(int x,int y);
int p[200009];
int q[200009];
map<int,int>mp[200009];

int main(){
  int n,k,l;
  cin>>n>>k>>l;
  for(int i=0;i<=n;i++){
    p[i]=i;
    q[i]=i;
  }
  for(int i=0;i<k;i++){
    int a,b;
    cin>>a>>b;
    if(!same(a,b)){
      unite(a,b);
    }
  }
  for(int i=0;i<l;i++){
    int a,b;
    cin>>a>>b;
    if(!qsame(a,b)){
      qunite(a,b);
    }
  }
  for(int i=1;i<=n;i++){
    mp[find(i)][qfind(i)]++;
  }
  for(int i=1;i<=n;i++){
    cout<<mp[find(i)][qfind(i)];
    if(i==n)cout<<endl;
    else cout<<' ';
  }
  return(0);
}

int find(int x){
  if(p[x]==x)return x;
  return p[x]=find(p[x]);
}

int same(int x,int y){
  if(find(x)==find(y))return 1;
  return 0;
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  p[x]=y;
}

int qfind(int x){
  if(q[x]==x)return x;
  return q[x]=qfind(q[x]);
}

int qsame(int x,int y){
  if(qfind(x)==qfind(y))return 1;
  return 0;
}

void qunite(int x,int y){
  x=qfind(x);
  y=qfind(y);
  q[x]=y;
}


Measured memory_bytes: 20096
factors :: Int -> [Int]
factors n = [x | x <- [1..n], n `mod` x == 0]

has8Factors :: Int -> Bool
has8Factors n
  | even n   = False
  | n < 105  = False
  | n == 105 = True
  | otherwise = (== 8) $ length $ factors n

solve :: Int -> Int
solve n = length $ filter has8Factors [1..n]

main :: IO ()
main = do
  n <- readLn
  print $ solve n

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

#define pb push_back
#define int ll

using ll=long long;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;
using vi=vector<int>;
using vvi=vector<vi>;

void greedy(const string& s, const int kmax, const int c, vi& posl) {
  const int n = s.size();
  posl = vi(n, -1);
  int k = 0;
  int i = 0;
  while (i < n && k < kmax) {
    for (; i < n && s[i] != 'o'; ++i);
    if (i >= n)
      break;
    posl[i] = k++;
    i += 1 + c;
  }
  assert(k == kmax);
}

signed main() {
  ios_base::sync_with_stdio(false);

  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  assert(s.size() == n);

  vi lr;
  greedy(s, k, c, lr);

  vi rl;
  reverse(s.begin(), s.end());
  greedy(s, k, c, rl);
  reverse(rl.begin(), rl.end());
  for (int i=0; i<n; ++i) {
    if (rl[i] >= 0)
      rl[i] = k - 1 - rl[i];
  }

  for (int i=0; i<n; ++i) {
    if (lr[i] != -1 && lr[i] == rl[i])
      cout << i+1 << "\n";
  }
}


Measured memory_bytes: 5012
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	string s;
	cin>>s;
	for(int i=0;i<s.size;i++)
	{
			if(i==s.size-1 && s[i]=='?')
			{
				if(s[i-1]=='P')
				{
					s[i]='D';
				}
				else
				{
					s[i]='D';
				}
			}
		else if(s[i]=='?')
		{
			if(s[i-1]=='P')
			{
				s[i]='D';
			}
			else
			{
				s[i]='D';
			}
		}
	}
	cout<<s<<endl;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>     
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)1e5 + 100;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
 
int n, dp[maxn][4], k;
int a[maxn][4];
main () {
	cin >> n;
	forn(i, 1, n)
		forn(j, 0, 2){
			cin >> a[i][j];
			if(i == 1) dp[i][j] = a[i][j];
		}
	forn(i, 2, n){
		forn(t1, 0, 2)
			forn(t2, 0, 2)
				if(t1 != t2)
					dp[i][t1] = max(dp[i][t1], dp[i - 1][t2] + a[i][t1]);
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}

Measured memory_bytes: 6528
#include<iostream>
#include <climits>
#include <vector>
using namespace std;

int Vacation(vector<vector<int> > input, int n){

	int dp[n][3];

	for(int i = 0; i < 3; i++){
		dp[0][i] = input[0][i];
	}
	
	for(int i = 1; i < n; i++){
		dp[i][0] = input[i][0] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = input[i][1] + max(dp[i-1][2], dp[i-1][0]);
		dp[i][2] = input[i][2] + max(dp[i-1][1], dp[i-1][0]);
	}

	return max(dp[n-1][1], max(dp[n-1][2], dp[n-1][0]));

}


int main(){



	int n;
	cin>>n;
	vector<vector<int> > input(n, vector<int>(3));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			cin>>input[i][j];
		}
	}
	cout<<Vacation(input, n)<<'\n';

	return 0;
}

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

int func(int x) {
    if(x%2) return (3*x+1);
    else return x/2;
}

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

    vector<int> a;
    a.push_back(s);
    int m = 2;
    while(m <= 10000000) {
        int temp = func(a[a.size()-1]);
        rep(i, a.size()) {
            //cout << a[i] << " ";
            if(a[i] == temp) {
                    cout << m << endl;
                    return 0;
            }
        }
        //cout << endl;
        a.push_back(temp);
        m++;
    }


    return 0;
}

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

int main(void) {
    int a, b, len;
    char num[8];

    while (scanf("%d %d", &a, &b) != EOF) {
        snprintf(num, 8, "%d", a + b);
        len = strlen(num);
        printf("%d\n", len);
    }

    return 0;
}



Measured memory_bytes: 2124
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
int n;
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
int main(){
    LL k , n, cnt=0;
    cin >> n >> k;
   VL h(n);
   REP(i, n){
       cin >> h[i];
   }
   sort(h.rbegin(), h.rend());
   if(n <= k) cout << 0 << endl;
   else {
       FOR(i, k, n){
           cnt += h[i];
       }
       cout << cnt << endl;
   }
   
   
}

    



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

BA = []

for _ in range(N):
    a, b = list(map(int, input().split()))
    BA.append([b, a])

BA.sort()

a = 0

flg = False
for ba in BA:
    b = ba[0]
    a += ba[1]
    if b < a:
        flg = True
        break

if flg:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 76824
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=1e6+5,M=5e3+5,INF=1e9,mod=924844033;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
char s[N];int n,k,a[N];
void gao(){
	int now=1,dir=1;
	while(now>=1&&now<=n){
		if(s[now]=='A')dir*=-1;
		if(s[now]=='A')s[now]='B';else s[now]='A';
		now+=dir;
	}
	printf("%s\n",s+1);
}
int typ=0,l,r;
void rua(){
	if((typ^a[l])==1)a[l]^=1;else{
		l++;r++;
		typ^=1;a[r]=1^typ;
	}
}
int main(){
	read(n,k);
	scanf("%s",s+1);
	rep(i,1,n)a[i]=s[i]=='A';
	/*n=20;rep(i,1,n)s[i]=rand()&1?'A':'B';
	rep(i,1,20)gao();*/
	r=n;l=1;
	rep(i,1,n+n){
		rua();
		k--;if(!k)break;
	}
	if(k&1)rua();
	rep(i,l,r)printf("%c",(a[i]^typ)?'A':'B');
}

Measured memory_bytes: 4480
// wavelate tree/persistance segment tree number of unique element in a range


#include <bits/stdc++.h>
using namespace std;
// S=sorted list
// tree=wavelet tree
// L=বামে এখন পর্যন্ত কয়টা গেছে
// ls বামের যোগফল 
// SL=Sum left
const int mx=500010;
int arr[mx],n;
const int sqr=20;
int s[mx],tree[sqr][mx],L[sqr][mx];
long long ls[sqr][mx],SL;
void build(int l, int r, int d)
{
	if (l == r)return;
	int mid = (l + r) >> 1, cnt = 0, lc = l, rc = mid + 1, ec = 0;
	for (int i = l; i <= r; i++) if (tree[d][i] < s[mid])cnt++;
	for (int i = l; i <= r; i++)
	{
		if ((tree[d][i] < s[mid]) || (tree[d][i] == s[mid] && ec < (mid - l + 1 - cnt)))
		{
			tree[d + 1][lc++] = tree[d][i];
			ls[d][i] = ls[d][i - 1] + tree[d][i];
			if (tree[d][i] == s[mid])ec++;
		}
		else
		{
			tree[d + 1][rc++] = tree[d][i];
			ls[d][i] = ls[d][i - 1];
		}
		L[d][i] = L[d][l - 1] + lc - l; //বামে এখন পর্যন্ত কয়টা গেছে
	}
	build(l, mid, d + 1);
	build(mid + 1, r, d + 1);
}
void init(int *arr, int n)
{
	for (int i = 1; i <= n; i++)
	{
		tree[0][i] = arr[i];
		s[i] = tree[0][i];
	}
	sort(s + 1, s + n + 1);
	build(1, n, 0);
}
//kth smallest element in [x, y]
// SL= sum of first kth smallest elemnt in [x,y]
int kth(int l, int r, int d, int x, int y, int k)
{	//1,n,0,x,y,k
	if (l == r) {
		SL += tree[d][l];
		return tree[d][l];
	}
	int cnt = L[d][y] - L[d][x - 1];
	int mid = (l + r) >> 1;
	if (cnt >= k)
	{
		int newx = L[d][x - 1] - L[d][l - 1];
		int newy = L[d][y] - L[d][l - 1];
		return kth(l, mid, d + 1, l + newx, l + newy - 1, k);
	}
	else
	{
		int newx = x - l - (L[d][x - 1] - L[d][l - 1]);
		int newy = y - l + 1 - (L[d][y] - L[d][l - 1]);
		SL += ls[d][y] - ls[d][x - 1];
		return kth(mid + 1, r, d + 1, mid + 1 + newx, mid + newy, k - cnt);
	}
}
//count of nos in [l, r] Less than or equal to k
//SL= sum of element less than or equal to k in [l,r]
int LTE(int l, int r, int d, int x, int y, int k)
{	//1,n,0,x,y,k
	if (l == r) {
		if(l>y || l<x)return 0;
		SL += tree[d][l] * (tree[d][l] <= k);
		return tree[d][l] <= k;
	}
	int cnt = L[d][y] - L[d][x - 1], mid = (l + r) >> 1;
	if (s[mid] <= k)
	{
		int newx = x - l - (L[d][x - 1] - L[d][l - 1]);
		int newy = y - l + 1 - (L[d][y] - L[d][l - 1]);
		SL += ls[d][y] - ls[d][x - 1];
		return cnt + LTE(mid + 1, r, d + 1, mid + 1 + newx, mid + newy, k);
	}
	else
	{
		int newx = L[d][x - 1] - L[d][l - 1];
		int newy = L[d][y] - L[d][l - 1];
		return LTE(l, mid, d + 1, l + newx, l + newy - 1, k);
	}
}

int age[500010];
int main(int argc, char const *argv[])
{
	memset(age,5,sizeof age);
	// cout<<age[0]<<endl;
	int q;
	scanf("%d %d",&n,&q);
	for(int i=1;i<=n;i++){
		scanf("%d",&arr[i]);
	}
	for(int i=n;i>0;i--){
		int a=arr[i];
		arr[i]=age[a];
		age[a]=i;
	}
	init(arr,n);
	while(q--){
		int l,r;
		scanf("%d %d",&l,&r);
		printf("%d\n", (r-l+1)-LTE(1,n,0,l,r,r));
	}
	return 0;
}

Measured memory_bytes: 160328
var s,n,i,j,t:Longint;
l:Array[1..200]of Longint;
begin
read(n);
for i:=1 to 2*n do begin
read(l[i]);
for j:=i-1 downto 1 do if l[j]<l[j+1]then begin
t:=l[j];l[j]:=l[j+1];l[j+1]:=t;
end;
end;
for i:=1 to n do inc(s,l[i*2]);
writeln(s);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int k;
long long ans;
inline int gcd(int x,int y){return !y?x:gcd(y,x%y);}
int main(){
	scanf("%d",&k);
	for(int i=1;i<=k;++i)
		for(int j=1;j<=k;++j)
			for(int l=1;l<=k;++l)
				ans+=gcd(gcd(i,j),l);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3764
s = gets.chomp.chars
k = gets.to_i

str = s[0,k].join
last = nil
s.size.times do |i|
  tmp = s[i, k].join
  if tmp.length < k
    last = s[i, k].join
    break
  end
  str = tmp < str ? tmp : str
end

def create_cands(str)
  cands = []
  chars = str.chars
  while first = chars.shift
    cands << first
    chars.size.times do |i|
      if cands[-1]
        cands << cands[-1] + chars[i]
      else
        cands << chars[i]
      end
    end
  end
  cands.uniq!
  cands.sort
end

if last && last < str
  if a = create_cands(last)[k-1]
    ans = a
  else
    ans = create_cands(str)[k-1]
  end
else
  ans = create_cands(str)[k-1]
end

puts ans

Measured memory_bytes: 4732
using System;

class FivehundredCoins
{
    static void Main(string[] args)
    {

        var input = Console.ReadLine().Split(' ');
        var number = int.Parse(input[0]);
        var money = int.Parse(input[1]);

        var ans = "No";

        if(number * 500 >= money)
        {
            ans = "Yes";
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#ABC071

s = sorted(set(input()))
l = "abcdefghijklmnopqrstuvwxyz"
for i in l:
    
    if i not in s:
        print(i)
        break
        
else:
    print("None")
    
    
## if i in s == False はうまくいかない
##in/not inを使う

Measured memory_bytes: 3188
#include <iostream>
#include <vector>

struct Edge {
  int source, target;
  Edge(int source, int target): source(source), target(target) {}
};

struct Node {
  std::vector<Edge> edges;
  void addEdge(Edge edge) {
    edges.push_back(edge);
  }
};

class Graph {
private:
  std::vector<Node> nodes;
  int size;
public:
  Graph(int size): size(size) {
    nodes.resize(size);
  }
  void addEdge(int source, int target) {
    nodes[source].addEdge(Edge(source, target));
  }
  void printAdjacencyList() {
    for(Node node: nodes) {
      std::vector<int> hasEdgeTo(size);
      for(Edge edge: node.edges) {
        hasEdgeTo[edge.target] = 1;
      }
      for(int i = 0; i < size; i++) {
        if(i == size - 1) {
          std::cout << hasEdgeTo[i] << std::endl;
        }else {
          std::cout << hasEdgeTo[i] << ' ';
        }
      }

    }
  }
};

int main() {
  int n;
  std::cin >> n;
  Graph graph(n);
  for(int i = 0; i < n; i++) {
    int u, k;
    std::cin >> u >> k;
    for(int j = 0; j < k; j++) {
      int v;
      std::cin >> v;
      graph.addEdge(u - 1, v - 1);
    }
  }
  graph.printAdjacencyList();
}

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

int main(){
  int N;
  bool b = 1;
  cin >> N;
  set<string> s;
  rep(i,N){
    string W;
    char c;
    cin >> W;
    if(i==0){
      s.insert(W);
      c = W.at(W.size()-1);
    }else{
      if(s.count(W)||c!=W.at(0)){
        cout << "No" << endl;
        b = 0; break;
      }else{
        s.insert(W);
        c = W.at(W.size()-1);
      }
    }
  }
  if(b){
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#define N -1
#define W 0
#define B 1
static const int MAX = 500;
static const int INF = (1<<21);

int main(void){
  int i, j, k, n, u, v, c;
  int minv;
  int M[MAX][MAX];
  int check[MAX];
  int p[MAX];
  int key[MAX];

  scanf("%d", &n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j] = INF;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d", &u, &k);
    for(j=0;j<k;j++){
      scanf("%d %d", &v, &c); 
      M[u][v]=c;
    }
  }

  for(i=0;i<n;i++){
    key[i]=INF;
    p[i]=N;
    check[i]=W;
  }

  key[0]=0;

  while(1){
    u=N;
    minv=INF;
    for(i=0;i<n;i++){
      if(key[i]<minv && check[i] == W){
	u=i;
	minv=key[i];
      }
    }

    if(u==N) break;

    check[u]=B;

    for(v=0;v<n;v++){
      if(check[v] == W && key[v]>key[u] + M[u][v]){
	key[v] = key[u]+M[u][v];
	p[v]=u;
      }
    }
  }

  for(i=0;i<n;i++){
    printf("%d %d\n", i, (key[i] == INF? 0:key[i]));
  }

  return 0;
}

Measured memory_bytes: 808
#include<bits/stdc++.h>
#define mx 100005
using namespace std;

int n, m, x[mx], dif[mx], wi;

int main(){
  scanf("%d%d", &n, &m);
  for(int i = 0; i < m; i++) {
    scanf("%d", x+i);
  }
  sort(x, x+m);
  wi = x[m-1] - x[0];
  for(int i = 1; i < m; i++) {
    dif[i-1] = x[i] - x[i-1];
  }
  sort(dif, dif+m-1, greater<int>());
  for(int i = 0; i < n-1; i++) {
    wi -= dif[i];
  }
  printf("%d\n", wi);
}

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

#define N 255

int main(){
    
    int n, list[N];
    cin >> n;
    
    for(int i = 1; i <= n; i++){
        cin >> list[i];
    }
    
    for (int i = 1; i <= n; i++){
        cout << "node " << i << ": key = " << list[i] << ", ";
        if ( i != 1 ) cout << "parent key = " << list[i/2] << ", ";
        if ( 2 * i <= n ) cout << "left key = " << list[2*i] <<", ";
        if ( 2 * i + 1 <= n ) cout << "right key = " << list[2*i+1] << ", ";
        cout << endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 3096
#include <iostream>
 
int N;
long long K;
long long data[100005];
int main(){
  std::cin>>N>>K;
  int temp1,temp2;
  for(int i=0;i<N;++i){
    std::cin>>temp1>>temp2;
    data[temp1]+=temp2;
  }
 
  for(int i=1;i<=100000;++i){
    if(K<=data[i]){
      std::cout<<i<<std::endl;
      break;
    }
    K-=data[i];
  }
  
  return 0;
}

Measured memory_bytes: 1024
def GCD(a, b):
    a, b = max(a, b), min(a, b)
    while a%b>0:
        a, b = b, a%b
    return b

N, M = map(int, input().split())
S = input()
T = input()
GCD = GCD(N, M)
LCM = N * M // GCD
sm, tm = N//GCD, M//GCD
for i in range(GCD):
    if S[i*sm] != T[i*tm]:
        print(-1)
        break
else:
    print(LCM)


Measured memory_bytes: 3316
# base -k representation of n
def f(n, k):
    if n == 0:
        return []
    r = n % k
    return f(-(n - r) // k, k) + [r]

N = int(input())
l = f(N, 2)
if l:
    print("".join(map(str, l)))
else:
    print(0)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String str;
		long num[] = new long[2];
		while((str = in.readLine()) != null){
			num[0] = Long.parseLong(str.substring(0, str.indexOf(" ")));
			num[1] = Long.parseLong(str.substring(str.indexOf(" ")+1, str.length()));
			System.out.println(gcd(num[0], num[1]) + " " + lcm(num[0], num[1]));

		}

	}
	static long gcd(long a, long b){
		return b == 0 ? a : gcd(b, a%b);
	}
	static long lcm(long a, long b){
		return b*a/gcd(a,b);
	}

}

Measured memory_bytes: 17020
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
struct ee{
	int fi,se;
}p[524290];
int n,a[524290],N,ans;
void f(int x,int y)
{
	if(x==p[y].fi||x==p[y].se) return;
	if(a[x]>a[p[y].fi]) p[y].se=p[y].fi,p[y].fi=x;
	else if(a[x]>a[p[y].se]) p[y].se=x;
}
int main()
{
	scanf("%d",&n);
	N=1<<n;
	for(int i=0;i<N;i++) scanf("%d",&a[i]),p[i].fi=i,p[i].se=N;
	for(int i=1,j,g;i<N;i++)
	{
		for(int j=1;j<=i;(j<<=1))
		{
			if(i&j)
			{
				int k=i^j;
				f(p[k].fi,i);
				f(p[k].se,i);
			}
		}
	}
	for(int i=1;i<N;i++)
	{
		ans=max(ans,a[p[i].fi]+a[p[i].se]);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  ull p, q, r;
  cin >> p >> q >> r;

  vector<ull> res;
  res.push(p + q);
  res.push(p + r);
  res.push(q + r);

  cout << min_value(res) << endl;

  return 0;
}


Measured memory_bytes: 256
N,M = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
judge = sum(A)/(4 * M)
result = N
for i in range(N):
    if A[i] < judge:
        result -= 1
    if result < M:
        break
if result >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
      ll a,b; cin >> a >> b;
     if((b-1)%(a-1)!=0) cout << (b-1)/(a-1)+1 << endl;
     else cout << (b-1)/(a-1) << endl;
	   
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b){
        cout << c << endl;
    }else if(b == c){
        cout << a << endl;
    }else{
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

xx = sorted(list(map(int, input().split())))

yy = [abs(xx[i]-xx[i+1]) for i in range(m-1)]

sy = sorted(yy)

if n > 1:
  print(sum(sy[:-n+1]))
else:
  print(xx[-1] - xx[0])

Measured memory_bytes: 20476
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int X;

signed main(){
	cin >> X;
	for(int i=1; i<=INT_MAX; i++){
		if(i*X % 360 == 0){
			cout << i << endl;
			return 0;
		}
	}
}

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

int main() {
  int L,R,d;
  cin >> L >> R >> d;
  
  int count =0;
  for(int i=L; i<R+1; i++){
    if (i % d == 0) count ++;
  }
  
  cout << count << endl;

}

Measured memory_bytes: 3628
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B, C, D, E, F = LI()

    # 水と砂糖の用意できるパターンを列挙
    w = set()
    for i in range(F // (100 * A) + 1):
        for j in range((F - i * 100 * A) // (100 * B) + 1):
            if i != 0 and i != 0:
                w.add(i * A + j * B)
    # print(w)

    s = set()
    for i in range(F // C + 1):
        for j in range((F - i * C) // D + 1):
            s.add(i * C + j * D)
    # print(s)

    # 全探索で間にあう(2分探索不要)
    # 初期値として水100Aの0%砂糖水を設定
    ans = [A, 0]
    for i, j in itertools.product(w, s):
        if 100 * i + j <= F and j <= i * E:
            # 100j/(100i+j) > 100ans[1]/(100ans[0]+ans[1])
            if j * (100 * ans[0] + ans[1]) > ans[1] * (100 * i + j):
                ans[0] = i
                ans[1] = j

    print(ans[0] * 100 + ans[1], ans[1])

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10192
# coding: utf-8
# Your# coding: utf-8
# Your code here!
N = int(input())
S = str(input())
K = int(input())
#rint(N,S,K)
 
WRITE = list(S)
CHARA = S[K-1]
#print(CHARA)
 
for i in range(N):
    if S[i] != CHARA:
        S = S[:i] + '*' + S[i+1:]
 
print(S) 


Measured memory_bytes: 2940
#include<bits/stdc++.h>
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int n,a[100007];
bool chk(){
	int c0=0;
	for(int i=0;i<n;++i)c0+=~a[i]&1;
	if(~n&1)return c0&1;
	if(c0&1)return 1;
	if(c0==n-1){
		int p,g=0;
		for(int i=0;i<n;++i)if(a[i]&1)p=i;
		if(a[p]==1)return 0;
		--a[p];
		for(int i=0;i<n;++i)g=gcd(a[i],g);
		if(g==1)return 0;
		for(int i=0;i<n;++i)a[i]/=g;
		return !chk();
	}
	return 0;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i)scanf("%d",a+i);
	puts(chk()?"First":"Second");
	return 0;
}

Measured memory_bytes: 640
l, r = map(int, input().split())
n = r-l+1
ans1 = 0
ans2 = 0
min1 = 1000000000
min2 = 10000000000


for i in range(min(n, 2024)):
   # print(l+i)
    if (l+i) % 2019 == 0:
        print(0)
        break
else:
    ans = 10000000000
    for i in range(min(n, 2019)):
        for j in range(i+1, min(n, 2020)):
            # print(l+i, l+j)
            if ((l+i)*(l+j)) % 2019 < ans:
                ans = ((l+i)*(l+j)) % 2019
                # print(ans, l+i, l+j)
    print(ans)


Measured memory_bytes: 9172
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int>v(N + 2, 0);
    for (int i = 0; i < M; i++) {
        int L, R;
        cin >> L >> R;
        v[L]++; v[R + 1]--;
    }

    for (int i = 1; i <= N; i++)v[i] += v[i - 1];

    cout << count(v.begin(), v.end(), M) << endl;

}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input();
    vector< int > A(N);
    cin >> A;
    
    auto dp = make_vector(5, 3, -infll);
    dp[1][0] = dp[2][0] = 0;
    
    range(i, 0, N) {
        rrange(j, 1, 5) dp[j] = dp[j - 1];
        dp[0] = vector< i64 >(3, -infll);
        range(s, 0, 3) range(k, 0, s + 1) {
            chmax(dp[0][s], dp[2 + k][s - k] + A[i]);
        }
    }
    
    int m = (N & 1 ? 2 : 1);
    cout << max(dp[0][m], dp[1][m - 1]) << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3988
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool isprime(int p){
  if(p==1) return false;
  for(int i=2; i<p; i++){
    if(!(p%i)) return false;
  }
  return true;
}

signed main(){
  int n; cin>>n;
  cout << 11 << ' '; n--;
  for(int i=31; i<=55555; i+=5){
    if(isprime(i)) cout << i << ' ', n--;
    if(!n) break;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
struct edge
{
	ll start;
	ll end;
	ll lenth;
	void operator=(edge ee)
	{
		start=ee.start;
		end=ee.end;
		lenth=ee.lenth;
	}
	bool operator<(edge ee)
	{
		return lenth<ee.lenth;
	}
} tot[90000];
ll g[300][300];
int main()
{
	ll n,i,j,t=0,flag,ans=0;
	scanf("%lld",&n);
	for(i=0;i<n;++i)
	{
		for(j=0;j<n;++j)
		{
			scanf("%lld",g[i]+j);
			tot[t++]=(edge){i,j,g[i][j]};
		}
	}
	sort(tot,tot+t);
	for(i=0;i<t;++i)
	{
		flag=0;
		for(j=0;j<n;++j)
		{
			if(j==tot[i].start||j==tot[i].end)
				continue;
			if(g[tot[i].start][j]+g[j][tot[i].end]==tot[i].lenth)
				flag=1;
			else if(g[tot[i].start][j]+g[j][tot[i].end]<tot[i].lenth)
			{
				puts("-1");
				return 0;
			}
		}
		if(flag==0)
			ans+=tot[i].lenth;
	}
	printf("%lld",ans>>1);
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) << endl;
  return 0;

}


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

int aidx,ah,bidx,bh;
vector<int> pile[105];
int m;

void put_floor(int x){
  
  for(int i=0;i<m;i++)
    if(!pile[i].size()){
      pile[i].push_back(x);
      return;
    }
  
}

void get_place_a(int x){
  
  for(int i=0;i<m;i++){
    for(int j=0;j<pile[i].size();j++){
      
      if(pile[i][j]==x){
	
	aidx=i;
	ah=j;
	return;
      }
      
    }
  }
  
}

void get_place_b(int x){
  
  for(int i=0;i<m;i++){
    for(int j=0;j<pile[i].size();j++){
      
      if(pile[i][j]==x){
	
	bidx=i;
	bh=j;
	return;
      }
    }
  }
  
}


int main(){

  while(1){

    cin>>m;
    if(!m)break;

    for(int i=0;i<m;i++)pile[i].clear();
    
    for(int i=0;i<m;i++) pile[i].push_back(i+1);
    
    while(1){
      
      int a,b;
      
      cin>>a>>b;
      if(!a)break;
      
      if(!b){
	
	get_place_a(a);
	
	if(ah==0)continue;
	
	for(int i=pile[aidx].size()-1;i>=ah;i--){
	  
	  put_floor(pile[aidx][i]);
	  
	  pile[aidx].erase(pile[aidx].end()-1);
	  
	}
	
      }else{
	
	get_place_a(a);
	
	get_place_b(b);
	
	if(aidx==bidx&&ah>=bh)continue;

	for(int i=pile[aidx].size()-1;i>ah;i--){
	  
	  put_floor(pile[aidx][i]);
	  
	  pile[aidx].erase(pile[aidx].end()-1);
	  
	}
	
	pile[aidx].erase( pile[aidx].begin()+ah );
	
	get_place_b(b);
	
	pile[bidx].push_back(a);
	
      }
      
    }

    vector<int> ans;
    
    for(int i=0;i<m;i++) ans.push_back(pile[i].size());
    
    sort(ans.begin(),ans.end());
    
    for(int i=0;i<m;i++){
      if(ans[i]==0)continue;
      cout<<ans[i]<<endl;
    }
    cout<<"end"<<endl;
    
  }
  
  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    ll n, k;
    cin >> n >> k;

    ll ans = k;
    for (int i = 0; i < n - 1; i++)
        ans *= (k - 1);

    OP(ans);

    return 0;
}

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

using namespace std;
typedef long long ll;

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

	vector<int> nums(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}

	auto it = max_element(nums.begin(), nums.end());
	int tar = *it;
	int op_cnt = 0;
	for (int i = 1; i <= tar; i++) {

		int j = 0;
		while (nums[j] < i) j++;

		int last = 0;
		for (; j < n; j++) {
			if (nums[j]< i && last >= i) op_cnt++;
			last = nums[j];
		}

		if (last >= i) op_cnt++;
	}

	cout << op_cnt;

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int A[] = new int[N];
		int S = 0;
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextInt();
			S += A[i];
		}
		int th = (S + 4 * M - 1) / (4 * M);
		int k = 0;
		for(int i = 0 ; i < N ; ++i){
			if(A[i] >= th){
				++k;
			}
		}
		if(k >= M){
			System.out.println("Yes");
		}else{
			System.out.println("No");			
		}
	}
}


Measured memory_bytes: 21844