akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define nmax 100005
using namespace std;
long long n,k,i,r[nmax],g[nmax],l[nmax],a,ok,b,c,x,y,xx,yy;
long long maxx,s,tot,j,i1,i2,sol[nmax*3];

bool comp(int a,int b)
{
    return a>b;}
int main()
{

cin>>x>>y>>a>>b>>c;
for(i=1;i<=a;i++)
    cin>>r[i];
for(i=1;i<=b;i++)
    cin>>g[i];
    for(i=1;i<=c;i++)
    cin>>l[i];
sort(r+1,r+a+1,comp);
sort(g+1,g+b+1,comp);
sort(l+1,l+c+1,comp);

for(i=1;i<=x;i++)
    sol[i]=r[i];
for(i=1;i<=y;i++)
    sol[x+i]=g[i];
for(i=1;i<=c;i++)
    sol[x+y+i]=l[i];
sort(sol+1,sol+1+x+y+c,comp);

for(i=1;i<=x+y;i++)
    s+=sol[i];
cout<<s;


       return 0;
}


Measured memory_bytes: 4992
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int a,b;
  cin >> a >> b;

  cout << max(0LL,a-2*b) << endl;

  return 0;
}

Measured memory_bytes: 256
# 宿泊数
N = int(input())
# 通常料金期間
K = int(input())
# 通常料金X
X = int(input())
# 割引料金Y
Y = int(input())

if N>K:
	print(K*X + (N-K)*Y)
else:
	print(N*X)

Measured memory_bytes: 3064
import math
number_list = [input() for _ in range(5)]
last_digit = [int(n[-1]) if int(n[-1]) != 0 else 1000 for n in number_list]
min_last_digit_index = last_digit.index(min(last_digit))
print(sum([int(n) if i == min_last_digit_index else math.ceil(int(n) / 10) * 10
           for i, n in enumerate(number_list)]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main () {
  long A, B, C;
  cin >> A >> B >> C;
  long aa, bb, cc, ans = 0, flag = 0;
  while(A % 2 != 1 && B % 2 != 1 && C % 2 != 1){
    if(A == B && B == C){
      flag = 1;
      break;
    }
    aa = B / 2 + C / 2;
    bb = A / 2 + C / 2;
    cc = C / 2 + A / 2;
    A = aa;
    B = bb;
    C = cc;
    ans++;
  }
  cout << (flag?-1:ans) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
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; }
#define all(a)  (a).begin(),(a).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vll vector<ll>
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
const ll INF =1LL << 62;
int main(){
  string S; cin >> S;
  int ans=0;
  int ans1=0;
  for(int i=0;i<S.size();i+=2){
    if(S[i] !=S[0]) ans ++;
  }
  for(int i=1;i<S.size();i+=2){
    if(S[i] ==S[0]) ans ++;
  }
  
  for(int i=0;i<S.size();i+=2){
    if(S[i] ==S[0]) ans1 ++;
  }
  for(int i=1;i<S.size();i+=2){
    if(S[i] !=S[0]) ans1 ++;
  }
  ans=min(ans,ans1);
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<bitset>
#include<iomanip>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

bool judge(long long a){
  if(a == 2)return true;
  if(a < 2 || a%2 == 0)return false;
  for(long long i = 3; i <= sqrt(a); i += 2){
    if(a%i == 0)return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  long long ans = 0, a;
  for(int i=0; i < n; i++){
    cin >> a;
    if(judge(a))ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  string S;
  cin >> S;
  string ans = "yes";
  for (int i = 0; i < S.size() - 1; i++) {
    for (int j = i + 1; j < S.size(); j++) {
      if (S.at(i) == S.at(j)) ans = "no";
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,C = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    for a in range(1,B+1):
        _ = (a*A)%B
        if _ == C:
            TF = 'YES'
            break
    else:
        TF = 'NO'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)


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

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int min_num = n;
    vector<int> c;
    int count = 1;
    int num = 0;
    for(int i = 0; i < n - 1; i++){
        if(s.at(i) == s.at(i + 1)) count++;
        else{
            c.emplace_back(count);
            count = 1;
        }
    }
    c.emplace_back(count);
    //先頭が白のとき
    if(s.at(0) == '.'){
        //全部白にする場合
        num = 0;
        for(int i = 1; i < c.size(); i += 2){
            num += c.at(i);
        }
        if(num < min_num) min_num = num;
        //全部黒にする場合
        num = 0;
        for(int i = 0; i < c.size(); i += 2){
            num += c.at(i);
        }        
        if(num < min_num) min_num = num;
        //それ以外
        for(int i = 1; i < c.size(); i += 2){
            //境界以降を黒にする数
            num -= c.at(i - 1);
            //境界より前を白にする数
            if(i > 2) num += c.at(i - 2);
            if(num < min_num) min_num = num;
        }
    //先頭が黒のとき
    }else{
        //全部白にする場合
        num = 0;
        for(int i = 0; i < c.size(); i += 2){
            num += c.at(i);
        }
        if(num < min_num) min_num = num;
        //全部黒にする場合
        num = 0;
        for(int i = 1; i < c.size(); i += 2){
            num += c.at(i);
        }
        if(num < min_num) min_num = num;
        //その他
        for(int i = 2; i < c.size(); i += 2){
            //境界より後を黒にする数
            num -= c.at(i - 1);
            //境界より前を白にする数
            num += c.at(i - 2);            
            if(num < min_num) min_num = num;
        }
    }
    cout << min_num << endl;
}

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

int main(){
  int n; cin >> n;
  int x;
  ll ans = 0;
  for(int i = 0; i <  n; ++i){
    cin >> x;
    ans += (ll)(x - 1);
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
bool cmp(long long int x,long long int y)
{
   return x>y;
}
int main(void)
{
   long long int k,a,b,c;
   vector<long long int> v,v1,v2;
   vector< pair <long long int,long long int> >p,p1,p2;
   set<long long int> st;
   priority_queue<long long int> pq;
   priority_queue< long long int,vector<long long int>,greater<long long int> > lpq;
   priority_queue< pair<long long int,long long int>,vector< pair<long long int,long long int> >,greater< pair <long long int,long long int> > > plpq;
   string s;
   //cin>>t;
   //while(t--)
   //{
      cin>>a>>b>>c>>k;
      while(k!=0)
      {
         if(b>a)
            break;
         b=b*2;
         k--;
      }
      //cout<<k<<a<<b;
      while(k!=0)
      {
         if(c>b)
            break;
         c=c*2;
         k--;
      }
      //cout<<k;
      //cout<<a<<b<<c;
      if(a<b && b<c)
         cout<<"Yes"<<endl;
      else
         cout<<"No"<<endl;
   //}
   return 0;
}


Measured memory_bytes: 3628
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long N; cin >> N;
	long A[100009]; for (int i = 1; i <= N; i++) cin >> A[i];
	A[0] = 0; A[N + 1] = 0;
	long S = 0; for (int i = 1; i <= N + 1; i++) S += abs(A[i] - A[i - 1]);

	for (int i = 1; i <= N; i++) cout << S - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]) << endl;
}

Measured memory_bytes: 2048
use strict;
use warnings;

my $line = <>;
chomp($line);
my(@in) = split(//,$line);
my $cnt = 0;
my ($prev, $now) = ('', '');

for my $i (0 ... $#in){
	$now .= $in[$i];
	if($prev ne $now){
		$cnt++;
		$prev = $now;
		$now = '';
	}
}
print $cnt;


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

int main(){
    int n, r, temp;
    cin >> n >> r;
    temp = 100*(10-n);
    if(n >= 10) cout << r << endl; /*check*/
    else        cout << r + temp << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ulli unsigned long long int
#define ld long double  
#define endl "\n"
using namespace std; 


void solve() {
    int s;
    cin >> s;

    unordered_map<int, int> nums;

    nums[s] = 1;
    int n = s;
    int i = 1;
    while (true) {
        n = (n & 1) ? 3 * n + 1: n / 2;
        if (nums[n] == 0) {
            nums[n] = i;
        } else {
            //cout << "n: " << n << " nums: " << nums[n] << endl;
            cout << i+1 << endl;
            break;
        }
        i++;
    }
}

int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
  
    int t = 1; 
    //cin >> t; 
    while (t--) { 
        solve(); 
    } 
  
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
    return 0; 
} 


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

int N;
vector<vector<int>> tree;
vector<ll> cnt;

void dfs(int u, int p){
    for(int v : tree[u]){
        if(v == p) continue;
        cnt[v] += cnt[u];
        dfs(v, u);
    }
}

int main(){
    int Q;
    cin >> N >> Q;
    tree.resize(N, vector<int>());
    for(int i=0; i<N-1; i++){
        int a, b;  cin >> a >> b;
        a--;  b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    cnt.resize(N, 0);
    for(int i=0; i<Q; i++){
        ll p, x;  cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    dfs(0, -1);

    for(ll c : cnt){
        cout << c << " ";
    }cout << endl;
}


Measured memory_bytes: 24320
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  string input;
  cin >> input;
  
  int len_input = input.size();
  int counter_n = -1;
  int counter_s = -1;
  int counter_w = -1;
  int counter_e = -1;
  for(int i = 0; i < len_input; i++){
    if(input[i] == 'N' && counter_n == -1){
      counter_n = 1;
    } else if(input[i] == 'E' && counter_e == -1){
      counter_e = 1;
    } else if(input[i] == 'S' && counter_s == -1){
      counter_s = 1;
    } else if(input[i] == 'W' && counter_w == -1){
      counter_w = 1;
    } // else if(input[i] == 'N' && counter_n == 0){
    //   counter_n = 1;
    // } else if(input[i] == 'E' && counter_e == 0){
    //   counter_e = 1;
    // } else if(input[i] == 'S' && counter_s == 0){
    //   counter_s = 1;
    // } else if(input[i] == 'W' && counter_w == 0){
    //   counter_w = 1;
    // } else {
      
    // }
  }

  if(counter_e * counter_w < 0 || counter_n * counter_s < 0){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int long long
typedef pair<int,int> P;
typedef pair<int,P> PP;

int p,q,a,n;
int b[7];
int dfs(int x=0,int B=1,int pn=1){
  int res=0;
  if(x>0){
    int sum=0;
    for(int i=0;i<x;i++)sum+=B/b[i];
    /*
    for(int i=0;i<x;i++){
	 cout<<b[i]<<" ";
    }cout<<endl;
    */
    if(p*B==q*sum)return 1;
    if(p*B<q*sum)return 0;
  }
  if(x==n)return 0;
  for(int i=pn;i*B<=a;i++){
    b[x]=i;
    res+=dfs(x+1,i*B,i);
  }
  return res;
}

signed main(){
  while(1){
    cin>>p>>q>>a>>n;
    if(q==0)break;
    cout<<dfs()<<endl;
  }
  return 0;
}



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> p(N);
    rep (i, N) {
        cin >> p[i];
        p[i]--;
    }

    ll ans = 0;
    rep (i, N-1) {
        if (i == p[i]) {
            swap(p[i], p[i+1]);
            ans++;
        }
    }

    if (N-1 == p[N-1]) {
        ans++;
    }

    cout << ans << endl;
    return 0;
}

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

ll solve(ll h,ll w){
    
	ll res = h * w;
	for(ll i = 1; i < h; i++){
		ll a = i * w;           //上
        ll b = (h-i) * w;       //下
		ll c = (i/2) * w;       //真ん中
		ll d = i * (w/2);       //width半分
		res = min(res, max({b, c, a-c}) - min({b, c, a-c})); //上中下
		res = min(res, max({b, d, a-d}) - min({b, d, a-d})); //左上、右上、下
	}
	return res;
}

int main(){

	ll h, w;
    cin >> h >> w;
	
    cout << min(solve(h,w), solve(w,h)) << endl;
	
    return 0;
}


Measured memory_bytes: 256
n = int(input())
lets = [chr(i) for i in range(ord("a"), ord("a") + n)]
d = {e: i for i, e in enumerate(lets)}

s = ["a"]
for i in range(1, n):
    nxt = []
    for e in s:
        mx = 0
        for l in e:
            mx = max(mx, d[l])
        for j in range(mx + 2):
            nxt.append(e + lets[j])
    s = nxt

print(*s, sep="\n")


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

string S;
int dp[110000][13];

signed main() {
    cin >> S;
    int r = 5;
    int n = 0;
    dp[0][0] = 1;
    int mod = 1e9 + 7;
    for (int i = 0; i < S.length(); i++) {
        int x = i % 3;
        int y = 1;
        for (int j = 0; j < x; j++)y *= 10;
        int c = S.length() - i - 1;
        if (S[c] == '?') {
            if (i % 6 < 3) {
                for (int j = 0; j < 13; j++) {
                    for (int k = 0; k < 10; k++) {
                        (dp[n + 1][(j + k * y) % 13] += dp[n][j]) %= mod;
                    }
                }
            } else {
                for (int j = 0; j < 13; j++) {
                    for (int k = 0; k < 10; k++) {
                        (dp[n + 1][(j - k * y + 13000) % 13] += dp[n][j]) %= mod;
                    }
                }
            }
            n++;
        } else {
            if (i % 6 < 3)(r -= (S[c] - '0' - 13) * y) %= 13;
            else (r += (S[c] - '0') * y) %= 13;
        }
    }
    cout << dp[n][r] << endl;
}

Measured memory_bytes: 10752
fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let s: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    let a: u64 = read();
    let b: u64 = read();
    let c: u64 = read();
    let mut vec = vec![a, b, c];

    if vec.iter().fold(1, |sum, &x| sum * x) % 2 == 1 {
        vec.sort();
        let ans = vec[1] * vec[0];
        println!("{}", ans);
    } else {
        println!("0");
    }
}

#[test]
fn ki_su_test() {
    assert!(is_ki_su(vec![3]));
    assert!(is_ki_su(vec![3, 5]));
    assert!(!is_ki_su(vec![2]));
    assert!(!is_ki_su(vec![2, 3]));
    assert!(is_ki_su(vec![3, 3]));
}
fn is_ki_su(vec: Vec<u64>) -> bool {
    vec.iter().fold(1, |sum, &x| sum * x) % 2 == 1
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))

int main(){
	ll l,r,mo=2019;
	cin >> l >> r;
	ll ans = 199999999;
	if(r-l>2019){
		ans = 0;
	}else{
		FOR(i,l,r+1){
			FOR(j,i+1,r+1){
				ans = min(ans,i*j%mo);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node{int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int u){
	if(u==NIL) return;
	printf(" %d",u);
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u){
	if(u==NIL)return;
	inParse (T[u].l);
	printf(" %d",u);
	inParse(T[u].r);
}

void postParse(int u){
	if(u==NIL)return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d",u);
}

int main(void){
	int i,v,l,r,root;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		T[i].p=NIL;
	}
	
	for(i=0;i<n;i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].l=l;
		T[v].r=r;
		if(l !=NIL)T[l].p=v;
		if(r!=NIL)T[r].p=v;
	}
		
	for(i=0;i<n;i++)if(T[i].p==NIL)root=i;
	
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	
	return 0;
	}



Measured memory_bytes: 2064
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
ans = []
for i in range(n):
    mm = 10 ** 9
    nn = 0
    for j in range(m):
        if mm > abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1]):
            mm = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1])
            nn = j + 1
    ans.append(nn)
for i in range(n):
    print(ans[i])


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

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/floor.hpp
#ifndef FLOOR_HPP
#define FLOOR_HPP


/*
usage:

tools::floor(5, 3) // => 1 (i.e., floor(5 / 3))
*/

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

int main() {
  std::int_fast64_t n, y;
  std::cin >> n >> y;

  const std::int_fast64_t m = tools::ceil<std::int_fast64_t>(y - 1000 * n, 4500);
  if ((y - 1000 * n) % 1000 == 0 && m <= std::min(tools::floor<std::int_fast64_t>(y - 1000 * n, 4000), tools::floor<std::int_fast64_t>(y, 5000))) {
    const std::int_fast64_t a = ((y - 1000 * n) - 4000 * m) / 1000;
    const std::int_fast64_t b = (9000 * m - 2 * (y - 1000 * n)) / 1000;
    const std::int_fast64_t c = n - a - b;
    std::cout << a << ' ' << b << ' ' << c << std::endl;
  } else {
    std::cout << "-1 -1 -1" << std::endl;
  }
  return 0;
}

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

int N;
vec<string> ans;
vec<string> P,Q;

void dfs(string s) {
    if (s.size() == N) {
        ans.push_back(s);
        return;
    }

    for(int i=1;i<=N;++i) {
        bool flag = true;
        for (auto e : s)
            if (e == (i + '0')) flag = false;
        if (!flag) continue;
        s += to_string(i);
        dfs(s);
        s.pop_back();
    }
};


int main() {
    cin >> N;
    P.resize(N);
    Q.resize(N);
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];

    string Ps = "";
    string Qs = "";
    for(auto e:P) Ps+=e;
    for(auto e:Q) Qs+=e;

    dfs("");
    sort(all(ans));

    int ansP,ansQ;
    rep(i,ans.size()){
        if(ans[i]==Ps) ansP=i+1;
        if(ans[i]==Qs) ansQ=i+1;
    }
    cout << abs(ansP-ansQ) << endl;

}

Measured memory_bytes: 2424
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {

	ll N;
	cin >> N;

	vector<ll> L(N + 1);

	L[0] = 2;
	L[1] = 1;

	for (int i = 2; i <= N; i++) {
		L[i] = L[i - 1] + L[i - 2];
	}

	cout << L[N];
	system("PAUSE");

	

}


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

int main(){
    int X,Y;
    cin >> X >> Y;
    if(X == 1 && Y == 1) {
        cout << 1000000 << endl;
        return 0;
    }
    int ans = 0;
    if(X == 1) ans+=300000;
    if(X == 2) ans+=200000;
    if(X == 3) ans+=100000;
    if(Y == 1) ans+=300000;
    if(Y == 2) ans+=200000;
    if(Y == 3) ans+=100000;
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-18 03:46:52
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int64 q, h, s, d; cin >> q >> h >> s >> d;

  int64 n; cin >> n;
  int64 ans = 0;

  int64 mn = min({4LL * q, 2LL * h, s});

  if (2LL * mn < d) {
    cout << n * mn << endl;
  } else {
    ans += n / 2 * d;
    ans += (n % 2) * mn;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
from collections import deque
N = int(input())
graph = [[] * N for _ in range(N)]

for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    graph[u].append([v, w])
    graph[v].append([u, w])

dist = [-1 for _ in range(N)]
que = deque()
dist[0] = 0
que.append(0)

while que:
    v = que[0]
    que.popleft()
    for i in range(len(graph[v])):
        nv = graph[v][i][0]
        d = graph[v][i][1]
        if dist[nv] != -1:
            continue
        dist[nv] = dist[v] + d
        que.append(nv)

for i in range(N):
    if dist[i] % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 49356
#include<iostream>
#include<map>
#include<cstdio>
using namespace std;
int n;long long s[101000];int tot=0;
long long prime[101000];bool Prime[101000];
void init()
{
	for(int i=2;i<=2155;i++)
	{
		if(!Prime[i])prime[++tot]=i;
		for(int j=1;j<=tot&&i*prime[j]<=2155;j++)
		{
			Prime[i*prime[j]]=1;
			if(i%prime[j]==0)break;
		}
	}
}
map<long long,int> mp1;
map<long long,int> mp2;
long long s1[101000],s2[101000];
long long Sqrt(long long x)
{
	long long l=1,r=1e10;
	while(l<r){long long mid=l+r>>1;if(mid*mid>=x)r=mid;else l=mid+1;}
	return r;
}
int main()
{
	scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%lld",&s[i]);
	init();int ans=0,ok=0;
	for(int i=1;i<=n;i++)
	{
		long long x=s[i],b=1,c=1;
		for(int j=1;j<=tot;j++)
		{
			int tt=0;
			while(x%prime[j]==0)x/=prime[j],tt++;
			tt%=3;
			if(tt==1)b*=prime[j],c*=prime[j]*prime[j];
			if(tt==2)b*=prime[j]*prime[j],c*=prime[j];
		}
		long long k=Sqrt(x);
		if(k*k==x)c*=k,b*=k*k;
		else if(x<=1e5)c*=x*x,b*=x;
		else {s1[i]=-1;ans++;continue;}
		mp1[b]++;s1[i]=b;s2[i]=c;
	}
	for(int i=1;i<=n;i++)
	{
		if(s1[i]==-1)continue; 
		if(s1[i]==1){ok=1;continue;}
		ans+=max(mp1[s1[i]],mp1[s2[i]]),mp1[s1[i]]=mp1[s2[i]]=0;
	}
	printf("%d",ans+ok);return 0;
}

Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	string s;
	cin >> s;
	int n = sz(s);
	string r(n, 'x');
	cout << r << endl;
	return 0;
}



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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//実行部
void Main()
{
  ll R; cin >> R;
  fin(R * 2. * PI);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

bool isPrime(int x){
    if(x<=1)return false;
    if(x == 2)return true;
    for(int i=2;i*i<=x;i++){
        if(x%i==0)return false;
    }
    return true;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int x;
    cin >> x;
    for(int i=x;i<=1e6;i++){
        if(isPrime(i)){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
n, k, q = map(int, input().split())
a_list = [int(input()) for i in range(q)]

point_dic = []
for i in range(n):
    point_dic.append(k-q)

for a in a_list:
    point_dic[a-1] = point_dic[a-1] + 1


for point in point_dic:
    if point > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 11776
#include <iostream>
#include <vector>
#include <stack>
#include <functional>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<class T> class SWAG{
private:
    struct node{
        T val,sum;
        node(const T& val, const T& sum):val(val),sum(sum){}
    };

    using F = function<T(T,T)>;
    stack<node> front_stack,back_stack;
    F op;
public:
    SWAG(const F op):op(op),front_stack(),back_stack(){};

    void push(const T& x){
        if(back_stack.empty()) back_stack.emplace(x,x);
        else{
            T s{op(back_stack.top().sum,x)};
            back_stack.emplace(x,s);
        }
    }

    void pop(){
        if(front_stack.empty()){
            front_stack.emplace(back_stack.top().val,back_stack.top().val);
            back_stack.pop();
            while(!back_stack.empty()){
                T s{op(back_stack.top().val,front_stack.top().sum)};
                front_stack.emplace(back_stack.top().val,s);
                back_stack.pop();
            }
        }
        front_stack.pop();
    }

    T result(){
        if(front_stack.empty()) return back_stack.top().sum;
        else if(back_stack.empty()) return front_stack.top().sum;
        else return op(front_stack.top().sum,back_stack.top().sum);
    }
};

int main(){
    int N,L;
    cin >> N >> L;
    SWAG<int> S([](int a,int b){return min(a,b);});
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        S.push(a);
        if(L-1<=i){
            cout << S.result() << (i!=N-1? " ":"\n");
            S.pop();
        }
    }  
}


Measured memory_bytes: 3588
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
//#define ll long long
#define P pair<ll,ll>

string s;

int main(){
	cin>>s;
	int ans=s.size()/2;
	int mid=ans;
	char t=s[mid];
	
	if(s.size()%2){
	rep(i,s.size()){
		if(s[mid+i]!=t||s[mid-i]!=t)break;
		ans++;
	}
	}
	else{
		int mid2=mid-1;
		rep(i,s.size()){
			if(s[mid+i]!=t||s[mid2-i]!=t)break;
			ans++;
		}
	}	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define w cout
#define e '\n'
#define int long long
#define all(v) (begin(v) , end(v))
#define pb push_back
using namespace std;
const int N = 1e5 + 10 , MOD = 1e9 + 7;

int  dd[N] , temp[N];

signed main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n , m ; cin >> n >> m;
	int a[n + 1] , b[m + 1];
	for(int i = 0 ; i < n; i ++ )  cin >> a[i];
	for(int j = 0 ; j < m ; j ++)  cin >> b[j];
	int sum = 0;
	for(int i = n - 1 ; i >= 0 ; i -- ) {
		sum = 0;
		for(int j = m - 1 ; j >=0  ; j -- ) {
			if(a[i] == b[j]) {
				dd[j] += sum + 1;
				dd[j] %= MOD;
			}
			sum += temp[j];
			sum %= MOD;
		}
		for(int j = 0 ; j < m ; j ++ ) {
			temp[j] = dd[j] % MOD;
		}
	}
	int ans = 0;
	for(int i = 0;  i < m ;i ++ ) {
		ans += dd[i];
		ans = ans % MOD;
	}
	w << (ans + 1) % MOD;
				
}


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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

bool prime[101001];

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    
    for(int i = 2; i < 101000; i++){
        prime[i+1] = IsPrime(i);
    }
    while(!prime[n+1]){
        n++;
    }
    cout << n;
}


Measured memory_bytes: 384
#include <cstdio>

int main(){
    int x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    for(int i = 1;; i++){
        if(y * i + z * (i + 1) > x){
            printf("%d\n",i - 1);
            break;
        }
    }

    return 0;
}

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

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

	int cnt = 0;
	rep(x, k + 1) {
		rep(y, k + 1) {
			int z = s - x - y;
			if (z >= 0 && z <= k) cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
class P
{
    static void Main()
    {
        int r = int.Parse(Console.ReadLine());
        if (r < 1200)
        {
            Console.WriteLine("ABC");
            return;
        }
        if (r < 2800)
        {
            Console.WriteLine("ARC");
            return;
        }
        Console.WriteLine("AGC");
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
template <typename T = int>
T in() {
    T temp; cin >> temp; return temp;
}

template <typename VType = int>
list<VType> const LR(VType start, VType end) {
    list<VType> ret; for (VType i = start; i < end; i++) ret.push_back(i); return move(ret);
}


int main() {
   int A, B;
   cin >> A>> B;

   int count = 0;

    if (B > 1) {
        count = 1;
        if (B > A) {
            B -= A;
            A--;
            
            while (B > 0) {
                B -= A;
                count++;
            };
        }
    }
   cout << count << endl;
   return 0;
}




Measured memory_bytes: 256
require 'prime'
n=gets.chomp.to_i
i = 0
count = 0
if n == 1
else
    a = Prime.prime_division(n)
    for i in 0..a.size-1
        k = 1
        while(true)
            if a[i][1] - k >= 0
                a[i][1] -= k
                count += 1
            else
                break
            end
            k += 1
        end
    end        
end
print count


Measured memory_bytes: 14468
#include <stdio.h>
int main(void)
{
	int n, a, b, c, d, xgoukei, ygoukei;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	if(n % a == 0){
		xgoukei = n / a;
	}
	else{
		xgoukei = (n / a) + 1;
	}
	if(n % c == 0){
		ygoukei = n / c;
	}
	else{
		ygoukei = (n / c) + 1;
	}
	if(xgoukei * b <= ygoukei * d){
		printf("%d\n", xgoukei * b);
	}
	else
	{
		printf("%d\n", ygoukei * d);
	}
	return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;

    ll vsqrt = sqrt(n) + 10;

    ll vmin = 1e18;
    reps(i, 1, vsqrt){
        if(n % i == 0){
            vmin = min(vmin, i + n/i - 2);
        }
    }

    cout << vmin << endl;

    // vector<ll> vec;
    // ll vsqrt = sqrt(n) + 10;
    // ll i = 2;
    // while(true){
    //     if(n % i == 0){
    //         n /= i;
    //         vec.push_back(i);
    //     }
    //     else{
    //         i++;
    //         if(i >= vsqrt){
    //             break;
    //         }
    //     }

    //     if(n == 1){
    //         break;
    //     }
    // }

    // // rep(i, vec.size()){
    // //     cout << vec[i] << endl;
    // // }

    

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	s := nextStr()
	t := nextStr()

	run := 0
	for i := 0; i < n; i++ {
		s1 := s[n-i-1:]
		t1 := t[:i+1]
		if s1 == t1 {
			run = i + 1
		}
	}

	fmt.Println(2*(n-run) + run)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include <iostream>
using namespace std;
 
bool primes[100000000];
 
void Sieve(){
    for(int i= 2; i < 10000000; i++){
        primes[i] = true;
    }
    primes[1] = false;    
    for(int i = 2; i < 10000; i++){
        if(primes[i] == true)
            for(int j=i; j*i < 100000000;j++){
                primes[j*i] = false;
            }
    }     
}
bool IsPrime(int x){
    return primes[x];
}
 
int main(void){
    Sieve();
    int n, c;
    for(int k = 1; k > 0; k++){
        cin >> n;
        if(n == 0) break;
        c = 0;
        for(int i = n + 1; i <= 2 * n; i++){
        if(IsPrime(i)==true)
            c++;
        }
        cout << c << endl;
    }
    return 0;
}


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



int main(){
    string s;cin >> s;
    string f,e;
    bool is_front = true;
    int Q;cin >> Q;
    while(Q--){
        int T;cin >> T;
        if(T == 1){
            is_front = !is_front;
        }else{
            int F;cin >> F;
            char c;cin >> c;
            if(F == 1){
                if(is_front){
                    f.push_back(c);
                }else{
                    e.push_back(c);
                }
            }else{
                if(is_front){
                    e.push_back(c);
                }else{
                    f.push_back(c);
                }
            }
        }
    }
    //cout<<is_front<<endl;
    if(is_front){
        reverse(f.begin(), f.end());
        cout<<f;
        cout<<s;
        cout<<e<<endl;
    }else{
        reverse(e.begin(), e.end());
        cout<<e;
        reverse(s.begin(), s.end());
        cout<<s;
        cout<<f<<endl;
    }
    return 0;
}


Measured memory_bytes: 1088
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <stdio.h>
#include <stack>
#include<queue>
#include <map>
#include <cmath>
#include<cstring>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << P.first << " " << P.second;
}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    for(auto v : V) os << v << "\n ";
    return cout << "";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    for(auto s:S) os<<s<<" ";
    return cout << "";
}
const ll mod=998244353;
#define inf 9999999999999

ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}

ll gcd(ll a,ll b){ if (b==0) return a;return gcd(b,a%b);}

ll pwr(ll a, ll b) {a %= mod; ll res = 1;while (b > 0) {if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1;}return res;}
//Template ends
bool overlap(pll a,pll b){
    if(a.ss<b.ff)return false;
    else return true;
}
ll fac[300010];
ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = ((ll)y)>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n,ll p)
{
    return power(n, p-2, p);
}
ll nCrModPFermat(ll n, ll r,ll p)
{
    if(r>n)return 0;
   if (r==0)
      return 1;
    ll x=((fac[n]* modInverse(fac[r], p)) % p * modInverse(fac[n-r], p)) % p ;
    return x;
}
int main(){
    fio;
    ll n;
    cin>>n;
    for(int i=0;i<n;i++)cout<<"ACL";
}



Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  int n;
  cin >> n;
  erep(i, 0, n/4) {
    erep(j, 0, n/7) {
      if(i*4 + j*7 == n) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
}


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    a = NI()
    print(a + a*a + a*a*a)

if __name__ == '__main__':
    main()

Measured memory_bytes: 74408
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  for(i<-1 to readInt) {
    val Array(x1,y1,x2,y2,x3,y3,x4,y4) = readLine.split(" ") map { _.toDouble }
    val p = (x2-x1)*(y4-y3) - (x4-x3)*(y2-y1)
    if(p< 1e-10 && p > -(1e-10)) println("YES") else println("NO")
  }
}

Measured memory_bytes: 44252
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<typename T>
T gcd(T a, T b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main(){
    int N;
    ll X;
    cin >> N >> X;
    vector<ll> x(N);
    for(int i = 0; i < N; i++) cin >> x[i];
    for(int i = 0; i < N; i++){
        x[i] = abs(X - x[i]);
    }
    ll min_n = x[0];
    for(int i = 1; i < N; i++) min_n = gcd(min_n, x[i]);
    cout << min_n << endl;

}

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

typedef long long int ll;
const int N = 1e6+6;

int main()
{
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll p = b+c,q = a+c,r = a+b;
    if( k&1 )
    {
        if( abs(p-q)>1e18 )cout<< "unfair\n";
        else cout<<p-q<< "\n";
    }
    else
    {
        if( abs(a-b)>1e18 )cout<< "unfair\n";
        else cout<<a-b<< "\n";
    }


    return 0;
}


Measured memory_bytes: 256