akhauriyash/Code-Regression huggingface dataset:
""" C
    https://atcoder.jp/contests/abc175/tasks/abc175_c
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

def _pattern(N):
    if N > 1:
        pa = _pattern(N-1)
        return [[0] + p for p in pa] + [[1] + p for p in pa]
    else:
        return [[0], [1]]

def main(X, K, D):
    if abs(X) > abs(D) * K:
        return abs(X) - abs(D) * K
    else:
        k = abs(X) // abs(D)
        if (K - k) % 2 == 0:
            return abs(X) - k * abs(D)
        else:
            return min(abs(abs(X) - (k+1) * abs(D)), abs(abs(X) - (k-1) * abs(D)))

if __name__ == "__main__":
    _X, _K, _D = readIntegerSet(3)

    print(main(_X, _K, _D))

Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a;
  cin >> a;
  
  cout << (a<=999?"ABC":"ABD") << endl;
}



Measured memory_bytes: 256
// Problem : A - Not
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define vp vector<pair<int,int>>
#define mod 1000000007
#define M_PI 3.14159265358979323846
#define pint pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,b,a) for(int i=b; i>=a ;--i)
#define mms(a,n) memset(a,n,sizeof(a))
#define fill(a,value) fill(a.begin(),a.end(),value)
#define all(a) a.begin(),a.end()
#define n_ones(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
#define see(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it){}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
template <typename T, typename U>inline void min_self(T &x, U y){if (y < x)x = y;}
template <typename T, typename U>inline void max_self(T &x, U y){if (x < y)x = y;}
template<class T1, class T2>ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class L, class R> ostream& operator<<(ostream& out, map<L, R> vec) { out<<"("; for (auto& v: vec) out<<"["<<v.first<<", "<<v.second<<"]"; return out<<")"; }
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
template <class Container>
void split(const std::string& str, Container& cont, char delim = ',')
{
    stringstream ss(str);
    string token;
    while (std::getline(ss, token, delim)) {
        cont.push_back(token);
    }
}

// cout << fixed << setprecision(10) << pi <<" "<<npi<<endl; 
// INT64_MAX
// transform(all(s), s.begin(), ::tolower);

int px[4] = {-1,0,1,0};
int py[4] = {0,-1,0,1};


void solve(){
    int n, res = 0;
    cin>>n ;
    res = 1-n;
    cout<<res<<'\n';
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3580
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
ll N;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	cout<<(N-1)/2<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a   = scan.nextInt();
        Integer b[] = new Integer[a];
        int alicesum = 0;
        int bobsum   = 0;

        for (int i = 0; i < a; i++) {
            b[i] = scan.nextInt();
        }

        Arrays.sort(b, Collections.reverseOrder());

        for (int i = 0; i < a; i = i+2) {
        	alicesum = alicesum + b[i];
        }

        for (int i = 1; i < a; i = i+2) {
        	bobsum = bobsum + b[i];
        }

        System.out.println(alicesum-bobsum);

    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int n; cin >> n;
    cout << (n/2) * (n - n/2) << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main () {
  long A, B;
  cin >> A >> B;
  long ans = 0;
  if(A % 2 == 0){
    if(B % 2 == 0){
      if(((B - A) / 2) % 2 == 0)ans = B;
      else ans = 1 ^ B;
    } else {
      if(((B - A + 1) / 2) % 2 == 0)ans = 0;
      else ans = 1;
    }
  } else {
    if(B % 2 == 0){
      if(((B - A - 1) / 2) % 2 == 0)ans = B ^ A ^ 0;
      else ans = 1 ^ B ^ A;
    } else {
      if(((B - A) / 2) % 2 == 0)ans = A;
      else ans = 1 ^ A;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007


/*nまでの素数を列挙して配列に保持*/
vector<int> Eratosthenes(int n,vector<int>& arr){

	for(int i = 0; i < n;i++){
		arr[i] = 1;
    }
    arr[0] = arr[1] = 0;

	for(int i = 2; i < sqrt(n); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) < n; j++){
				arr[i *(j + 2)] = 0;
			}
		}
    }
    return arr;
}


int main(){


    int n;
    int tmp = 50000;
    vector<int> arr(tmp+1);


    arr = Eratosthenes(tmp,arr);/*50000までの素数を列挙*/    
   
    while(cin >> n){
        int count = 0;
        for(int i = 1;i <= n;i++){
            if(arr[i] && arr[n-i+1]){
                count++;
            }
        }
        cout << count << endl;
    }  
    
    
    return 0;
}




Measured memory_bytes: 3180
//
//  golden_coins.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/03/31.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>

int main(int argc, const char* argv[]) {
    int x;
    std::cin >> x;
    int coin_500 = x / 500;
    int coin_5 = (x - coin_500*500) / 5;
    std::cout << coin_500*1000 + coin_5*5 << std::endl;
}
    




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[100001];
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    cout<<a[n]-a[1];
    return 0;
} 

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

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    bool can = true;
    rep(i, n) {
        if(a[i] % 2 == 0) {
            if(a[i] % 3 != 0 && a[i] % 5 != 0) can = false;
        }
    }

    cout << (can ? "APPROVED" : "DENIED") << endl;

    return 0;
}


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

int main()
{
    int N, X, T;
    cin >> N >> X >> T;
    if (N % X == 0)
    {
        cout << N / X * T << endl;
    }
    else
    {
        cout << N / X * T + T << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	int n;
	int a[100];

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];

	float sumReciprocal = 0.0f;

	for (int i = 0; i < n; i++)
	{
		sumReciprocal += (1.0f / (float)a[i]);
	}

	float answer = 1.0f / sumReciprocal;

	cout << answer;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, ma, mb; cin >> n >> ma >> mb;
  VI a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  vector<VVI> dp(n + 1, VVI(410, VI(410, 2e9)));
  dp[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    dp[i + 1] = dp[i];
    for (int j = 0; j < 410; j++) {
      for (int k = 0; k < 410; k++) {
        if (a[i] <= j and b[i] <= k) {
          dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j - a[i]][k - b[i]] + c[i]);
        }
      }
    }
  }
  int res = 2e9;
  for (int i = 1; i < 410; i++) {
    for (int j = 1; j < 410; j++) {
      if (i * mb == j * ma) {
        res = min(res, dp[n][i][j]);
      }
    }
  }
  cout << (res == 2e9 ? -1 : res) << '\n';
  return 0;
}

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

// infty
#define ULLINF (ULLONG_MAX)
#define LLINF  (LLONG_MAX)
#define IINF   (INT_MAX)
#define INF    (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();it++)

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

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// pair util
#define FST first
#define SND second

// range validator
#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss_; oss_ << a; return oss_.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

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

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


int FairField(int y,int m,int d)
{
  // adjust
  if(m <= 2) {
    y --;
    m += 12;
  }
  
  int U = y/4 - y/100 + y/400;
  return 365*y + U + 153*(m+1)/5 + d - 428;
}

int main() {
  int y1, m1, d1, y2, m2, d2;
  
  while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) {
    if(y1 == -1) break;
    
    cout << FairField(y2,m2,d2) - FairField(y1,m1,d1) << endl;
  }
  
  return 0;
}

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

using ll = long long;
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> hs(n);
  vector<bool> cs(n, true);
  rep(i, n) { cin >> hs[i]; }
  int a, b;
  rep(i, m) {
    cin >> a >> b;
    if (hs[a - 1] <= hs[b - 1]) {
      cs[a - 1] = false;
    }
    if (hs[b - 1] <= hs[a - 1]) {
      cs[b - 1] = false;
    }
  }
  int count = 0;
  rep(i, n) {
    if (cs[i]) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1001001001;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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 main(){
    int W,H,N; cin >> W >> H >> N;
    int xs=0;
    int xe=W;
    int ys=0;
    int ye=H;
    
    rep(i,N){
        int x,y,a; cin >> x >> y >> a;
        if (a==1) xs=max(xs,x);
        if (a==2) xe=min(xe,x);
        if (a==3) ys=max(ys,y);
        if (a==4) ye=min(ye,y);
    }
    if (xe>xs && ye>ys) cout << (ye-ys)*(xe-xs) << endl;
    else cout << 0 << endl;
}

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

const int INF = 1000000000;
int n;
vector<vector<pair<int,int>>> e;
vector<int> d;
vector<bool> t;
void dijkstra(int start) {
    d[start] = 0;
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;
    pq.push({d[start],start});
    while (not pq.empty()) {
    // rep(i, n) {
        // int min_d = INF, u = -1;
        // rep(j, n) {
        //     if (t[j] == false && d[j] < min_d) {
        //         min_d = d[j];
        //         u = j;
        //     }
        // }
        // if (u == -1) break;
        // t[u] = true;
        int u = pq.top().second;
        pq.pop();
        t[u] = true;
        rep(j, e[u].size()) {
            int v = e[u][j].first;
            if (t[v] == false) {
                if (d[u] + e[u][j].second < d[v]) {
                    d[v] = d[u] + e[u][j].second;
                    pq.push({d[v],v});
                }
            }
        }
    // }
    }
}

int main() {
    int m, r;
    cin >> n >> m >> r;
    e.resize(n);
    rep(i, m) {
        int s, t, d;
        cin >> s >> t >>d;
        e[s].push_back({t,d});
        // e[t].push_back({s,d});
    }
    d.resize(n,INF);
    t.resize(n,false);
    dijkstra(r);
    rep(i, n) {
        if (d[i] == INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
}


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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())

ll a,b;
signed main(){
	cin>>a>>b;
	if(a*b%2==0) cout<<"Even"<<endl;
	else cout<<"Odd"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
using namespace std;

int main() {
        string s;
        while (getline(cin, s)) {
                if (s == ".") break;
                stack<char> st;
                for (int i = 0; i < s.size(); i ++) {
                        if (s[i] != '(' && s[i] != ')' && s[i] != '[' && s[i] != ']') continue;
                        if (s[i] == '(') {
                                st.push('('); 
                        } else if (s[i] == '[') {
                                st.push('[');
                        } else if (s[i] == ')') {
                                if (st.empty() || st.top() != '(') {
                                        puts("no");
                                        goto end;
                                } else {
                                        st.pop();
                                }
                        } else {
                                if (st.empty() || st.top() != '[') {
                                        puts("no");
                                        goto end;
                                } else {
                                        st.pop();
                                }
                        }
                }
                if (st.empty()) puts("yes");
                else puts("no");
                end:;
        }
        return 0;
}

Measured memory_bytes: 3136
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H, W;
    while (true) {
      H = sc.nextInt();
      W = sc.nextInt();
      if (H == 0 && W == 0) break;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            System.out.print('#');
          } else {
            System.out.print('.');
          }
        }
        System.out.println();
      }
      System.out.println();
    }
  }
}


Measured memory_bytes: 36200
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> s(m);
	int k[m];
	int p[m];
	REP(i, m){
		cin >> k[i];
		REP(j, k[i]){
			int tmp;
			cin >> tmp;
			s[i].push_back(tmp);
		}
	}
	REP(i, m) cin >> p[i];
	ll ans = 0;
	for (int i = 0; i < pow(2, n); i++){
//		cout << "i = " << i << endl;
		int flag = 1;
		for (int j = 0; j < m; j++){
//			cout << "	j = " << j << endl;
			int cnt = 0;
			for (int l = 0; l < k[j]; l++){
				if (i & 1<<(s[j][l]-1)) cnt++;
			}
//			cout << "	cnt = " << cnt << endl;
			if (cnt % 2 != p[j]){
				flag = 0;
				break;
			}
		}
		if (flag){
//			cout << i << endl;
			ans++;
		}
	}

	cout << ans << endl;

		



}


Measured memory_bytes: 384
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    s = input()
    p = "CODEFESTIVAL2016"
    ans = 0

    for i in range(16):
        if s[i] != p[i]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
_, *a = map(str.split, open(0))
U, R, D, L = "URDL"
INF = float("inf")
d = {}
for *z, u in a:
  d.setdefault(u, []).append([*map(int, z)])
N = INF
for A, B, S in [(U, D, "x, y"), (R, L, "y, x"), 
                (R, U, "x+y, x-y"), (D, L, "x+y, x-y"), 
                (U, L, "x-y, x+y"), (R, D, "x-y, x+y")]:
  n = p = -INF
  L = eval(f"[({S}, Q) for P, Q in [(A, 1), (B, 0)] for x, y in d.get(P, [])]")
  for x, y, r in sorted(L):
    if r:n = x;p = y
    elif x==n :N = min(N, (y - p)*5)
print("SAFE" if N == INF else N)

Measured memory_bytes: 136500
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/




int main() {
  ll i, j, k;
  
  
  ll N, K;
  cin >> N >> K;
  
  if(N>=K) {
    if(N%K==0) pt(0);
    else {
      
      ll t=N/K;
      ll a=N-t*K;
      pt(min(a, K-a));
    }
  }else {
    ll ans=min(N, K-N);
    
    pt(ans);
    
  }
  
  
  
  
}




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

string swp(string s,const int&a,const int&b){swap(s[a],s[b]);return s;}

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

    string s = "01234567";

    queue<string> q;
    map<string, int> m;

    q.push(s);
    m[s] = 0;

    while (q.size()) {
        string t = q.front(); q.pop();
        int idx = t.find('0');
        string u;
        if (idx - 1 >= 0 && idx != 4) {
            u = swp(t, idx, idx - 1);
            if (m.find(u) == m.end()) {
                m[u] = m[t] + 1;
                q.push(u);
            }
        }
        if (idx + 1 < 8 && idx != 3) {
            u = swp(t, idx, idx + 1);
            if (m.find(u) == m.end()) {
                m[u] = m[t] + 1;
                q.push(u);
            }
        }
        if (idx - 4 >= 0) {
            u = swp(t, idx, idx - 4);
            if (m.find(u) == m.end()) {
                m[u] = m[t] + 1;
                q.push(u);
            }
        }
        if (idx + 4 < 8) {
            u = swp(t, idx, idx + 4);
            if (m.find(u) == m.end()) {
                m[u] = m[t] + 1;
                q.push(u);
            }
        }
    }

    string line; stringstream ss;
    while (getline(cin, line)) {
        ss << line;
        string t = "";
        for (int i = 0; i < 8; ++i) {char c;ss >> c;t += c;}
        cout << m[t] << endl;
    }
}

Measured memory_bytes: 5436
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,m,c,b[30],arr[30][30];
bool solve(int x){
    int cnt=0;
    for(int i=1;i<=m;i++){
        cnt+=arr[x][i]*b[i];
    }
    cnt+=c;
    if(cnt>0) return true;
    return false;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m>>c;
    for(int i=1;i<=m;i++){
        cin>>b[i];
    }
    for(int i=1;i<=n;i++){
        for(int  j=1;j<=m;j++){
            cin>>arr[i][j];
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(solve(i)) ans++;
    }
    cout<<ans<<endl;
}

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

long long int K, A, B;

int main(void) {
  cin >> K >> A >> B;
  int ans = 0; 
  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      ans++;
      break;
    } 
  }
  if (ans == 1) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a >> b;
	cout << (a - 1)*(b - 1) << "\n";
	
	std::cin >> e;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin, a, b;
    REP (i, 0, 100000) {
        int s = i * 0.08, t = i * 0.10;
        if (s == a && t == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

int main() {
  int A, B; cin >> A >> B;
  if ((A == 1 && B == 2) || (A == 2 && B == 1)) cout << 3 << endl;
  else if ((A == 2 && B == 3) || (A == 3 && B == 2)) cout << 1 << endl;
  else cout << 2 << endl;
}

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

#define ll long long
#define pb push_back
#define N 1000000007
#define nmax 200001
#define pll pair<ll,ll>
#define fill_nums(A,n) for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}

ll extended_gcd(ll a, ll b, ll &x, ll &y) {
	if(a==0) {
		x = 0;
		y = 1;
		return b;
	}

	ll x1,y1;
	ll gcd = extended_gcd(b%a,a,x1,y1);

	x = y1 - (b/a)*x1;
	y = x1;

	return gcd;
}

int main() {
    
    string s; 
    ll d;

    cin>>s>>d;
    vector<vector<ll>> dp(s.length(), vector<ll>(d,0));
    ll sp = 0;

    for(ll i=0;i<s.length();i++) {
    	if(i==0) {
    		int a = s[0]-'0';
    		for(int b=0;b<=a;b++)
    			dp[0][b%d]++;
    		sp = a%d;
    		continue;
    	}

    	for(ll j=0;j<d;j++) {
    		for(ll k=0;k<=9;k++)
    			dp[i][(j+k)%d] = (dp[i][(j+k)%d] + dp[i-1][j])%N;
    	}


    	for(ll k=s[i]-'0'+1;k<=9;k++)
    		dp[i][(sp+k)%d] = (dp[i][(sp+k)%d] - 1 + N)%N;
    	sp = (sp + s[i]-'0')%d;
    }

    cout<<(dp[s.length()-1][0]-1+N)%N<<endl;
   	 	
	return 0;
}



Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
 
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
 
static const int INF = 1145141919;
const long long INFL = 1LL<<60;
 
int main()
{
	int n, k;
	cin >> n >> k;
	long long int h[110000];
	for (int i = 0; i < n; ++i)
	{
		cin >> h[i];
	}
	long long int dp[110000];
	for (int i = 0; i < 110000; ++i)
	{
		dp[i] = INFL;
	}
	dp[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		for (int j = i - 1; j >= max(0, i - k); --j)
		{
			chmin(dp[i], dp[j]+abs(h[i]-h[j]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  bool ok = true;
  while(a >= b){
    k--;
    b *= 2;
    if(k < 0) ok = 0;
  }
  while(b >= c){
    k--;
    c *= 2;
    if(k < 0) ok = 0;
  }
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3648
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
 
 
public class Main {
 
	public static void main(String[] args) {
		execute13_1();
	}
 
	private static void execute13_2() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int ans = 0;
 
			System.out.println(ans);
		}
 
	}
 
	private static void execute13_1() {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			long b = sc.nextLong();
			long n = sc.nextLong();
 
			long x = Math.min(n, b - 1);
			long ans = a * x / b - a * (x / b);
 
			System.out.println(ans);
		}
 
	}
}

Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }



int main() {
    int n;
    cin >> n;
    vector<ll> a(n); // 累積でlong long
    rep(i, n) cin >> a[i];
    rep3(i, 1, n) a[i] += a[i - 1];
    // rep(i, n) cout << a[i] << " "; cout << endl;
    map<ll, int> mp;
    ll ans = 0;
    rep(i, n) mp[a[i]]++;
    mp[0]++;
    for (auto e : mp) {
        ans += 1LL * e.S * (e.S - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;
const int BIG = 998244353;

struct sigoto { int a; int b; };
bool sime(sigoto x, sigoto y){
	return x.b < y.b;
}

bool test(int N, vector<sigoto> s) {
	sort(s.begin(), s.end(), sime);

	int t = 0;

	for (int i = 0; i < N; i++) {
		t = t + s[i].a;
		if (t > s[i].b) { return false; }
	}

	return true;
}







int main() {

	int N;
	cin >> N;
	vector<sigoto> s(N);

	for (int i = 0; i < N; i++) {
		cin >> s[i].a >> s[i].b;
	}

	if (test(N, s)) { cout << "Yes"; }
	else { cout << "No"; }
	

	system("PAUSE");
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < n; ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= n; ++(i))
#define repU(i,bottom,ceiling) for(int (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(int (i) = (ceiling); (i) >= (bottom); --(i))
#define pub push_back
#define pob pop_back
#define prf printf
#define scf scanf
#define mkp make_pair
#define fir first
#define sec second
#define clr(a) memset((a),0,sizeof(a))

typedef long long ll;
typedef double db;

const vector<pair<int,int>> DIR = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = -1 + (1<<30);
const int MOD = (int)1e9 + 7;

template<typename T> inline T gcd(T a,T b){ if(a % b){ return gcd(b,a % b); }else{ return b; } }

template<typename T> inline T lcm(T a,T b){ return a / gcd(a,b) * b; }

inline long long Pow(const long long n,long long m,const int mod = MOD){
	long long res = 1,pow = n;
	while(m) {
		if(m & 1) res = (res * pow) % mod;
		pow = (pow * pow) % mod;
		m >>= 1;
	}
	return res;
}

inline vector<long long> Frac(const int range,const int mod = MOD){
	vector<long long> frac;
	frac.push_back(1);
	for(int i = 1; i <= range; ++i) frac.push_back((long long)frac.back() * i % mod);
	return frac;
}

inline long long Comb(const int n,const int m,const int mod = MOD){
	if(n < m || m < 0) return 0;
	vector<long long> frac(Frac(n,mod));
	long long rev = Pow((long long)frac[m] * frac[n-m] % mod,mod-2,mod);
	return rev * frac[n] % mod;
}

template<typename T> inline bool v_find(const vector<T> v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) { return true; }
	return false; 
}

template<typename T> inline bool v_erase(vector<T> &v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) {
		v.erase(itr);
		return true;
	}
	return false;	
}

template<class T,class U> inline auto LB(const T v,const U in){ return lower_bound(v.begin(),v.end(),in); }

template<class T,class U> inline auto UB(const T v,const U in){ return upper_bound(v.begin(),v.end(),in); }

inline unsigned long long next_subset(unsigned long long subset){
	unsigned long long tem = subset + (subset & -subset);
	unsigned long long btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

inline void solve(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	cout<<max(min(b,d)-max(a,c),0);
	return;
}

inline void input(){
	return;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	solve();
	return 0;
}





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

#define range 524289
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef  long long int ll;
typedef vector <ll> vi;
typedef vector<vi> vvi;
typedef pair <ll, ll> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;


vvi a;
vvi dp;
int n;

ll res;

ll cal(int i, int  mask){
    if(i==n){
        return (mask==((1<<n) - 1))?1:0;
    }
    if(dp[i][mask]!=-1) return dp[i][mask];
    ll cot = 0;
    for(int k=0;k<n;k++){
        if(a[k][i]){
            //cout<<(mask&(1<<k))<<endl;
            if((mask&(1<<k))==0){
                // cout<<"here as well"<<endl;
                cot = (cot + cal(i+1, mask|(1<<k)))%mod;
            }
        }
    }
    // cout<<cot<<" "<<i<<" "<<mask<<endl;
    return dp[i][mask] = cot;
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int t = 1;
	// cin>>t;
	while(t--){
        cin>>n;
        a = vvi(n, vi(n));
        for (int i = 0; i < n; ++i)
        {
            /* code */
            for(int j=0;j<n;j++){
                cin>>a[i][j];
            }
        }
        dp = vvi(n, vi(1<<22, -1));
        cout<<cal(0, 0)<<endl;





	}

    return 0;
}


Measured memory_bytes: 721280
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,m,a[10],b[10];
int main()
{
	while(scanf("%d%d",&n,&m),n){
		rep(i,n)scanf("%d",a+i);
		rep(i,m)scanf("%d",b+i);
		int ans=0;
		rep(i,n)rep(j,m)if(a[i]==b[j]){
			b[j]=0; break;
		}
		rep(i,n)ans+=a[i]; rep(i,m)ans+=b[i];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 50;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
 
struct edge{
    int from, to; ll cost;
};

// 偶数 + 偶数 = 偶数   奇数 + 奇数 = 偶数

int main(){
    int n;
    cin >> n;
    int count = 0;
    REP(i, n){
        int tmp;
        cin >> tmp;
        if(tmp % 2) count++;
    }
    if(count % 2 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

using namespace std;


int main(int argc, char const *argv[]) {
    vector<int> nums(3);
    cin >> nums[0] >> nums[1] >> nums[2];
    sort(nums.begin(), nums.end());

    if (nums[0] + nums[1] == nums[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n,a,b=list(map(int,input().split()))
p=min(a,b)
q=max(a,b)
sum=q-p
if(sum%2==0):
    print(int(sum//2))
else:
    k=n-q
    r=p-1
    s=min(k,r)
    t=q
    v=p
    ans=0
    ans=ans+s
    if(s==r):
        t=t-s
        if(t!=1):
            ans=ans+1
            t=t-1
            u=t-1
            ans=ans+u//2
    else:
        v=v+s
        if(v!=n):
            ans=ans+1
            v=v+1
            h=n-v
            ans=ans+h//2
    print(ans)

Measured memory_bytes: 3064
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib;

void main() {
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;

    auto R = new int[](N+1);
    auto G = new int[](N+1);
    auto B = new int[](N+1);

    foreach (i; 0..N) R[i+1] += R[i] + (S[i]=='R');
    foreach (i; 0..N) G[i+1] += G[i] + (S[i]=='G');
    foreach (i; 0..N) B[i+1] += B[i] + (S[i]=='B');

    long ans = 0;

    foreach (i; 0..N) foreach (k; i+2..N) if (S[i] != S[k]) {
        int par = (k - i + 1) % 2;
        int mid = (k + i) / 2;
        if ((S[i] == 'R' && S[k] == 'G') || (S[i] == 'G' && S[k] == 'R')) {
            ans += B[k+1] - B[i];
            if (par) ans -= S[mid] == 'B';
        } else if ((S[i] == 'R' && S[k] == 'B') || (S[i] == 'B' && S[k] == 'R')) {
            ans += G[k+1] - G[i];
            if (par) ans -= S[mid] == 'G';
        } else if ((S[i] == 'B' && S[k] == 'G') || (S[i] == 'G' && S[k] == 'B')) {
            ans += R[k+1] - R[i];
            if (par) ans -= S[mid] == 'R';
        }
    }

    ans.writeln;
}

Measured memory_bytes: 3244
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val xs = readLine()!!.split(' ').map { it.toInt() }
    var ans = Int.MAX_VALUE
    for (i in 0 until n - k + 1) {
        val l = xs[i]
        val r = xs[i + k - 1]
        if (r <= 0) {
            ans = Math.min(ans, -l)
            continue
        }
        if (l >= 0) {
            ans = Math.min(ans, r)
            continue
        }
        ans = Math.min(ans, -l + r + Math.min(-l, r))
    }
    println(ans)
}


Measured memory_bytes: 51768
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;
ll T, t[200002];

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

  cin >> N >> T;
  rep(i, N) cin >> t[i];
  ll ans = 0ll;
  rep(i, N){
    if (i==N-1){
      ans+=T;
      break;
    }
    if (t[i+1]-t[i]>T){
      ans+=T;
    }else{
      ans+=t[i+1]-t[i];
    }
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a*n, b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int vis[200005],pri[200005],tot;
int main()
{
    for(reg int i=2;i<=200000;++i)
        if(!vis[i])
        {
            pri[++tot]=i;
            for(reg int j=i+i;j<=200000;j+=i)
                vis[j]=1;
        }
    reg int x=read();reg int i;
    for(i=1;i<=tot;++i)
        if(pri[i]>=x){cout<<pri[i]<<"\n";break;}
	return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int main() {
    string s;
    cin >> s;
    int size =s.size();
    int count =0;
    if((s[0]=='R'&&s[1]=='R')&&s[2]=='R'){
        count =3;
    }
    else if((s[0]=='R'&&s[1]=='R')&&s[2]=='S'){
        count = 2;
    }
    else if((s[0]=='S'&&s[1]=='R')&&s[2]=='R'){
        count = 2;
    }
    else if((s[0]=='R'&&s[1]=='S')&&s[2]=='R'){
        count = 1;
    }
    else if((s[0]=='S'&&s[1]=='S')&&s[2]=='R'){
        count = 1;
    }
    else if((s[0]=='S'&&s[1]=='R')&&s[2]=='S'){
        count = 1;
    }
    else if((s[0]=='R'&&s[1]=='S')&&s[2]=='S'){
        count =  1;
    }
    else{
        count = 0;
    }
    cout << count << endl;

}

Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    for(int i=1; i<=9;++i){
        if(n%i!=0)continue;
        for(int j=1; j<=9; ++j){
            if(i*j==n){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No";
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll t = 0;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 0) {
            if (sum <= 0) {
                t += 1 - sum;
                sum = 1;
            }
        } else {
            if (sum >= 0) {
                t += sum + 1;
                sum = -1;
            }
        }
    }
    ll u = 0;
    sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 1) {
            if (sum <= 0) {
                u += 1 - sum;
                sum = 1;
            }
        } else {
            if (sum >= 0) {
                u += sum + 1;
                sum = -1;
            }
        }
    }
    cout << min(t, u) << endl;
}


Measured memory_bytes: 1024
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B, C, K = lr()
answer = min(A, K)
K -= min(A, K)
if K > 0:
    K -= min(B, K)
    if K > 0:
        answer -= min(C, K)
print(answer)

Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;


int main(void){
    long k;
    cin >> k;
    
    int sevens = 7;
    long counter = 1;
    
    while(sevens%k != 0){
        if(counter>=k+2){
            counter=-1;
            break;
        }
        counter++;
        sevens = (sevens%k)*10+7;
    }
    
    cout << counter << endl;
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

#define yes printf("Yes\n")
#define Yes printf("YES\n")
#define no printf("No\n")
#define No printf("NO\n")

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 3e18;
const string sp = " ";
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = max(a, b);
		return true;
	}
	return false;
}
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = min(a, b);
		return true;
	}
	return false;
}

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

int n;
int a, b;
signed main() {
	cin >> n;
	rep(i, n) {
		int c, d;
		cin >> c >> d;
		if (i == 0) {
			a = c, b = d;
		}
		else {
			a = max((a + c - 1) / c, (b + d - 1) / d) * c, b = max((a + c - 1) / c, (b + d - 1) / d) * d;
		}
	}
	cout << a + b << endl;
}

Measured memory_bytes: 256