akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

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

    int x,k,d; cin >> x >> k >> d;

    x = abs(x);

    int times = x/d;

    if(times>=k){
        cout << x - d*k << "\n";
    } else {
        int ans = x%d;
        int extra = k - times;
        if(extra&1){
            ans = d - ans;
        }

        cout << ans << "\n";

    }


}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
long long n, a, b;

int main() {
	ios_base::sync_with_stdio(false);
  cin >> a >> b;
  if(abs(a - b) <= 1) cout << "Brown\n";
    else cout << "Alice\n";
}	

	

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int maxv = -2000000000;
    int minv = 2000000000;
    
    int x;
    while(cin >> x){
        maxv = max(maxv, x-minv);
        minv = min(minv, x);
    }
    cout << maxv << endl;

    return 0;
}
    


Measured memory_bytes: 3116
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b){
        cout << c << endl;
    }
    else if(b==c){
        cout << a << endl;
    }
    else {
        cout << b << endl;
    }
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let w = read_vec::<i64>();

    let mut s1 = w[0];
    let mut s2 = w.iter().skip(1).sum::<i64>();
    let mut ans = (s1 - s2).abs();
    for t in 1..n - 1 {
        s1 += w[t];
        s2 -= w[t];
        ans = min(ans, (s1 - s2).abs());
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2144
//BISMILLAHIR RAHMANIR RAHEEM
//ALLAH IS WATCHING ME
// Allah amader korona virus theke rokkha korun.Amin.

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp> //order_of_key return number of elements less than x, find_by_order return index (pointer use kora lgbe)

using namespace std;
using namespace __gnu_pbds;

#define ull    unsigned long long
#define ll    long long
#define ios    ios::sync_with_stdio(0);cin.tie(0);
#define ses   "\n"
#define all(x) (x).begin(), (x).end()
//#define INF   ((int)2e18)
#define ii pair<ll, ll>

string digit="0123456789";
string small="abcdefghijklmnopqrstuvwxyz";
string capital="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

const int N=1e6+5;
const ll M=1e18;

typedef tree< ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

struct Edge
{
    int u, vv;
    bool operator<(Edge const& other)
    {
        return vv > other.vv;
    }
}; // eta joss jinis.krsukal er jnno and sort 1 out of 3 or more er jnno better

/////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//main function is here.........
int main()
{
       //ios
ll x,ans;
cin>>x;
ll xx = x/500;
ll mod = x%500;
ans= xx*1000;
xx = mod/5;
xx*=5;
cout<<ans+xx<<ses;
}


/*
*/



//Alhamdulillah


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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "YES"
#define NO  "NO"
#define MOD 1000000000+7
#define forit(v) for(auto it = v.begin(); it != v.end(); ++it)

using namespace std;

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

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  // flag = true;

  int n; cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    if (s[i] == "Y") flag = true;
  }

  cout << (flag ? "Four" : "Three") << endl;

  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <cmath>

using namespace std;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,q,l,r;
  string s;
  int ans = 0;
  cin >> s;

  int tmp = 0;
  for (auto && c : s) {
    switch (c) {
    case 'A':
    case 'T':
    case 'G':
    case 'C':
      tmp++;
      break;
    default:
      ans = max(ans, tmp);
      tmp = 0;
      break;
    }
  }
  ans = max(ans, tmp);

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

class UnionFind{

    vector<int> par;
    vector<int> rank;
    vector<int> size;
public:
    UnionFind(int N) : par(N), rank(N), size(N){
        for(int i = 0; i < N; i++) {
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }

    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;

        par[rx] = ry;
        size[ry] += size[rx];
        size[rx] = 0;
    
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int getsize(int x){
        return size[root(x)];
    }
};

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

    long long N, M;
    cin >> N >> M;

    vector<long long> A(M);
    vector<long long> B(M);
    for(int i = 0; i < M; i++){
        cin >> A[i] >> B[i];
    }

    vector<long long> ans(M+1);

    for(int i = 0; i < M+1; i++){
        ans[i] = 0;
    }

    ans[M] = (long long)(N * (N-1) / 2);

    UnionFind union_tree(N);

    for(int i = M; i > 0; i--){

        if(!union_tree.same(A[i-1]-1, B[i-1]-1)){
            long long size_group_A = (long long)(union_tree.getsize(A[i-1]-1));
            long long size_group_B = (long long)(union_tree.getsize(B[i-1]-1));
            ans[i-1] = ans[i] - size_group_A * size_group_B;
            union_tree.unite(A[i-1]-1, B[i-1]-1);
        }
        else
        {
            ans[i-1] = ans[i];
        }
    }

    for(int i = 1; i < M+1; i++){
        cout << ans[i] << endl;
    }

    return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		String[] rc = br.readLine().split(" ");
		int r = Integer.parseInt(rc[0]);
		int c = Integer.parseInt(rc[1]);
		int sumOfRow, total = 0;
		int[] sumOfCol = new int[c];

		for(int i = 0; i < r; i++) {
			String row = br.readLine();
			String[] elem = row.split(" ");
			sumOfRow = 0;
			for(int j = 0; j < c; j++) {
				sumOfRow += Integer.parseInt(elem[j]);
				sumOfCol[j] += Integer.parseInt(elem[j]);
			}
			total += sumOfRow;
			sb.append(row + " " + sumOfRow + "\n");
		}

		for(int j = 0; j < c; j++) {
			sb.append(sumOfCol[j] + " ");
		}

		System.out.println(sb.append(total));

	}
}

Measured memory_bytes: 27932
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=2019;         
const int N=5e5+4;

int main()
{
	string s;

	cin>>s;

	int sum=0;

	int n=(int)s.size();

	int pwr[n];

	pwr[0]=1;

	rep(i,1,n)
	pwr[i]=(pwr[i-1]*10)%mod;

	vector<int> fa(mod,0);

	fa[0]=1;

	ll ans=0;

	int cur=n-1;

	rep(i,0,n)
	{
		sum=(sum+pwr[cur]*(s[i]-'0'))%mod;

		cur--;

		//int req=(2019-sum)%mod;

		//cout<<sum<<" "<<req<<" "<<fa[req]<<endl;

		ans+=fa[sum];

		fa[sum]++;
	}

	lpri(ans);

    return 0; 
}

Measured memory_bytes: 4632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> G(N);
	for (int i = 0; i < M; ++ i) {
		int u, v;
		cin >> u >> v;
		-- u; -- v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	vector<bool> visited(N);
	queue<int> Q;
	visited[0] = true;
	Q.push(0);
	vector<int> res(N);
	while (!Q.empty()) {
		int v = Q.front();
		Q.pop();
		for (auto x : G[v]) if (!visited[x]) {
			res[x] = v;
			visited[x] = true;
			Q.push(x);
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i < N; ++ i) cout << res[i]+1 << endl;
}


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

//問題文のように後ろから1文字以上消していく、とは視点を変えて考える
int main() {
  string S;
  cin >> S;
  int N = S.length();
  int ans = 0;
  for (int i=2;i<N;++i) {
    if (i % 2 == 0) {
      string A = S.substr(0, i / 2);//substr(開始位置, 取り出す長さ)
      string B = S.substr(i / 2, i / 2);
      if (A == B) {
          ans = max(ans, i);
      }
    }
  }
            cout << ans << endl;
}


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

int n,arr[100000];

int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",arr+i);

    sort(arr,arr+n);
    int ans=0;
    for(int i=0,j=0;i<n;i=j) {
        for(j=i;j<n && arr[i]==arr[j];j++);
        if(j-i>arr[i]) ans += j-i-arr[i];
        else if(j-i<arr[i]) ans += j-i;
    }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) max_element(x.begin(),x.end())
#define MIN(x) min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//fixed<<setprecision(15);
signed main(){
    int n,y; cin >> n >> y;
    for(int i=0; i<=y/10000; i++){
        for(int j=0; j<=(y-10000*i)/5000; j++){
            if((i*10000+j*5000+(n-i-j)*1000)==y){
                cout<<i<<' '<<j<<' '<<n-i-j<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
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>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#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)...);
}
using namespace std;
using int64 = long long;

int main() {
  string X;
  cin >> X;
  int X_size = X.size();
  int delete_num = 0;
  int S_left_num = 0;
  for (int i = 0; i < X_size; i++) {
    if (X[i] == 'S')
      S_left_num++;
    else {
      if (S_left_num) {
        S_left_num--;
        delete_num += 2;
      }
    }
  }
  cout << X_size - delete_num << endl;
  return 0;
}

Measured memory_bytes: 3680
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA(My_College_Sucks)
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli, lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005

#define binary_search bs
#define lower_bound lb
#define upper_bound ub

lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
lli f(lli a)
{
    if(a==1 or a==3 or a==5 or a==7 or a==8 or a==10 or a==12)
    {
        return 1;
    }
    if(a==2)
    {
        return 3;
    }
    return 2;
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli x,y;
    cin>>x>>y;
    lli a,b;
    a=f(x);
    b=f(y);
    if(a==b)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}


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

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName
#define INPUT_LLINT(valName) long long int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string& str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }

template <typename T> void insert(vector<T>& dest, const vector<T>& src) { copy(src.begin(), src.end(), back_inserter(dest)); }

template <long long int MOD> long long int mod_inv(long long int a) {
	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}

template <long long int MOD> long long int mod_add(long long int a, long long int b) {
	return (a + b) % MOD;
}

template <long long int MOD> long long int mod_sum(long long int a, long long int b) {
	return (a - b) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b) {
	return (a % MOD) * (b % MOD) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b, long long int c) {
	return mod_mul<MOD>(a, mod_mul<MOD>(b, c));
}

template <long long int MOD> long long int mod_div(long long int a, long long int b) {
	return (a % MOD) * mod_inv<MOD>(b) % MOD;
}


//------------------------------------------------------------------------------------------------------------------------------


int main() {
	
	// TODO: streamやめる

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

	INPUT_INT(N);

	bool f = false;

	for (int a = 1; a <= 9; ++a) {
		for (int b = 1; b <= 9; ++b) {
			if (a * b == N) {
				f = true;
				break;
			}
		}
		if (f) break;
	}

	if (f) {
		OUTPUT("Yes");
	} else {
		OUTPUT("No");
	}

	return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string a = Console.ReadLine(); //標準入力
        
        bool test = a == "1";

        if (test)
        {
            Console.WriteLine("{0}", 0);
        }
        else
        {
            Console.WriteLine("{0}", 1);
        }

       
    }

}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
const int mod = 1e9 + 7;

const ll MAX = 500010;
const ll MOD = 1e9 + 7;

ll fac[MAX], finv[MAX], inv[MAX];

void com_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
}

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

    com_init();

    ll tmp;
    ll sum = 0;
    for (int i = 1; i <= n; ++i) {
        tmp = (perm(m, n) * com(n, i) % MOD) * perm(m-i, n-i) % MOD;
        if (i % 2){
            sum += tmp;
            sum %= MOD;
        } else{
            sum -= tmp;
            sum += MOD;
            sum %= MOD;
        }
    }
    ll res = (perm(m, n) * perm(m, n) % MOD) - sum;
    res += MOD;
    res %= MOD;
    cout << res << endl;
}

Measured memory_bytes: 15288
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)


int main(){ FastIO;

int i,n;cin>>n;
int a[n];
int f=1;
for(i=0;i<n;i++) cin>>a[i];
a[0]--;
for(i=1;i<n;i++)
{
	if(a[i]>a[i-1]) a[i]--;
	if(a[i]<a[i-1]) {
		f=0;break;
	}
	
}
cout<<(f ? "Yes" : "No");


return 0;
}


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

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x - a) < abs(x - b)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}

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

def resolve():
    N = I()
    A = LI()

    ans = [0] * N

    for i in range(N):
        ans[0] += (-1) ** i * A[i]

    for i in range(N - 1):
        ans[i+1] = 2 * A[i] - ans[i]

    print(*ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 21908
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;


signed main() {
int S ,W;
cin >> S >> W;
string ans="safe";
if(W>=S){
    ans ="unsafe";
}
answer(ans);
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main(void)
{
  cout << fixed << setprecision(10);
    ll a;
    long double b;

  	cin >> a >> b;
 
    cout << (ll)floor(a*b) << endl;
   
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int n;
vector<set<int>> vec;
vector<int> val;

ll res[200005];
set<int> now;

void dfs(int node, int par) {
    int cc = -1, ff = -1;
    if(now.insert(val[node]).second) {
        auto it = now.find(val[node]);
        it++;
        if(it!=now.end()) {
            ff = *it;
            now.erase(it);
        }

        cc = val[node];
    }

    res[node] = now.size();

    for(auto& it : vec[node]) {
        if(par==it) continue;
        dfs(it, node);
    }
    
    if(cc!=-1) {
        now.erase(now.find(cc));
        if(ff!=-1)
            now.insert(ff);
    }
}

int32_t main() {
    fastio
    cin>>n;
    vec.assign(n, set<int>());
    val.assign(n, 0);
    for(auto& it : val) cin>>it;

    for(int i = 0; i<n-1; ++i) {
        int u, v;
        cin>>u>>v;
        u -= 1; v -= 1;
        vec[u].insert(v);
        vec[v].insert(u);
    }

    dfs(0, -1);

    for(int i = 0; i<n; ++i) 
        cout<<res[i]<<endl;
    cout<<endl;
}

Measured memory_bytes: 50920
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	string s;
	cin>>s;
	int x,ans=0;
	
	ans=s[0]-49;
	//cout<<ans<<endl;
	int f=1;
	FOR(i,1,s.size()){
		if(s[i]!='9')f=0;
		ans+=9;
	}
	if(f==1)ans++;
	cout<<ans<<endl;
	
	return 0;
}

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

int main() {

    int N, M;
    cin >> N >> M;

    vector<int> votes;
    int total_votes = 0;

    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        total_votes += A;
        votes.push_back(A);
    }

    int count = 0;

    for (int i = 0; i < votes.size(); i++) {
        if (votes[i] * (4 * M) >= total_votes) {
            count++;
        }
    }

    if (count >= M) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

const int N=1e5+5;
int n;
ll a[N];

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

        int used=0;
        for (int i=0; i<n; i++) {
                int end=i;
                while (end<n-1 && a[end+1] == a[i])
                        end++;

                if (end < n-1) {
                        if (a[end+1] > a[i]) {
                                while (end < n-1 && a[end+1] >= a[end])
                                        end++;
                        } else {
                                while (end < n-1 && a[end+1] <= a[end])
                                        end++;
                        }
                }

                used++;
                //cout << i << " to " << end << "\n";
                i = end;
        }

        cout << used << "\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int N = 1e+6;
int weight[N];
int v[N];

int n,w;

int32_t main()
{
	string s,t;
	cin>>s>>t;

	vector<vector<int> > dp(s.length()+1,vector<int>(t.length()+1,0));

	for(int i=0;i<s.length();i++)
	{
		for(int j=0;j<t.length();j++)
		{
			if(s[i]==t[j])
			{
				dp[i+1][j+1] = 1 + dp[i][j];
			}
			else
			{
				dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
			}
		}
	}
	string ans = "";

	int i = s.length();
	int j = t.length();

	while(i>0&&j>0)
	{
		if(s[i-1]==t[j-1])
		{
			ans+=s[i-1];
			i--;
			j--;
		}
		else
		{
			if(dp[i][j]==dp[i-1][j])
			{
				i--;
			}
			else
			{
				j--;
			}
		}
	}

	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}

Measured memory_bytes: 70784
#include <stdio.h>

int main(void){
   int n, i, j, m, x, y;

   scanf("%d", &n);

   int a[n];

   for(i = 0; i < n; i++) {
      scanf("%d", &a[i]);
   }

   x = a[1] - a[0];
   y = a[0];

   for(j = 1; j < n; j++) {
      if (a[j - 1] < y){
         y = a[j - 1];
      }
      if (a[j] >= y){
         m = a[j] - y;
         if (x < m){
            x = m;
         }
      }
   }

   printf("%d\n", x);

   return 0;
}


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

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
	int N; cin >> N;
	vector<ll> A(N);
	rep(i,N) cin >> A[i];
	sort(A.begin(),A.end());
	vector<ll> sum(N+1);
	rep(i,N) sum[i+1] = sum[i] + A[i];
	int ans = 1;
	for(int i = N-2; i >= 0; i--){
		if(sum[i+1]*2 >= A[i+1]) ans++;
		else break;
	}
	cout << ans << endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout <<(char)toupper(a[0]) <<(char)toupper(b[0]) << (char)toupper(c[0]) << endl;
    return 0;
}


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

priority_queue<ll> asmall;
priority_queue<ll, vector<ll>, greater<ll> > alarge;


int main(){
    int q;
    cin >> q;
    ll bsum = 0;
    ll amid = 0;
    ll n = 0;
    ll asmallsum = 0, alargesum = 0;

    for(int i = 0; i < q; i++){
        int x;
        cin >> x;
        if(x == 1){
            int a, b;
            cin >> a >> b;
            bsum += b;
            if(n == 0){
                amid = a;
            }
            else if(n % 2 == 0){
                if(asmall.top() > a){
                    amid = asmall.top();
                    asmallsum -= asmall.top();
                    asmallsum += a;
                    asmall.pop();
                    asmall.push(a);
                }
                else if(alarge.top() < a){
                    amid = alarge.top();
                    alargesum -= alarge.top();
                    alargesum += a;
                    alarge.pop();
                    alarge.push(a);
                }
                else{
                    amid = a;
                }
            }
            else{
                if(a > amid){
                    asmallsum += amid;
                    asmall.push(amid);
                    alargesum += a;
                    alarge.push(a);
                }
                else{
                    asmallsum += a;
                    asmall.push(a);
                    alargesum += amid;
                    alarge.push(amid);
                }
            }
            n++;
        }
        else{
            if(n == 0){
                cout << 0 << " " << 0 << endl;
            }
            else if(n % 2 == 0){
                ll y = asmall.top();
                ll ret = alargesum - asmallsum + bsum;
                cout << y << " " << ret << endl;
            }
            else{
                ll y = amid;
                ll ret = alargesum - asmallsum + bsum;
                cout << y << " " << ret << endl;
            }
        }
    }




    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b;
  string s;
  cin>>a>>b>>s;
  REP(i,a)if(!isdigit(s[i])){
    puts("No");return 0;
  }
  if(s[a]!='-'){
    puts("No");return 0;
  }
  FOR(i,a+1,a+b+1)if(!isdigit(s[i])){
    puts("No");return 0;
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 256
S = list(input())

c = 0
if S[0] == '0':
    for i in S[::2]:
        if i == '1':
            c += 1
    for j in S[1::2]:
        if j == '0':
            c += 1
        
d = 0
if S[0] == '1':
    for i in S[::2]:
        if i == '0':
            d += 1
    for j in S[1::2]:
        if j == '1':
            d += 1
            
print(max(c,d))

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

ll A[100001];
int main(){
    ll n;
    cin >> n;
    for(int i=0;i<n;i++) cin >> A[i];
    sort(A,A+n);

    ll large_side = 0, small_side = 0;
    for(int i=n-1;i>=1;i--){
        if(A[i]==A[i-1]){
            if(large_side==0){
                large_side = A[i];i--;
            }
            else{
                small_side = A[i]; break;
            }
        }
    }
    ll ans = large_side * small_side;
    cout << ans << endl;
    return 0;
}

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

int main(void) {
  long long L, R;
  cin >> L >> R;
  long long mi = LONG_LONG_MAX;
  if (R - L >= 2019) {
    mi = 0;
  } else {
    for (int i = L; i < R; i++) {
      for (int j = i + 1; j <= R; j++) {
        mi = min(mi, ((i % 2019LL) * (j % 2019LL) % 2019LL));
      }
    }
  }
  cout << mi << endl;
  return 0;
}

Measured memory_bytes: 256
main = do
  ss <- getContents
  mapM_ func $ map words $ lines ss

func s = do
  putStrLn $ era s

era s
  | i < [1868,9,8]    = "pre-meiji"
  | i < [1912,7,30]   = ("meiji " ++) $ unwords $ map show $ tra i 1867
  | i < [1926,12,25]  = ("taisho " ++) $ unwords $ map show $ tra i 1911
  | i < [1989,1,8]    = ("showa " ++) $ unwords $ map show $ tra i 1925
  | otherwise         = ("heisei " ++) $ unwords $ map show $ tra i 1988
  where i = map read s
        tra s num = ((head s) - num) : head (tail s) : tail (tail s)

Measured memory_bytes: 3728
def hole(query,n):
    dir=query[0]
    [a,b]=[int(x)-1 for x in query[1:]]
    if dir=="xy":
        ret=[b*n+a+z*n**2 for z in range(n)]
    elif dir=="xz":
        ret=[n**2*b+a+y*n for y in range(n)]
    else:
        ret=[n**2*b+a*n+x for x in range(n)]
    return ret


while(1):
    [n,h]=[int(x) for x in raw_input().split()]
    if n==0:
        break
    else:
        bad=[]
        for i in range(h):
            query=raw_input().split()
            bad+=hole(query,n)
        hset=set(bad)
        print n**3-len(hset)

Measured memory_bytes: 13600
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
using namespace std;
const int  INF=100000000;
int main(){
  string x,y,z;
  cin>>x>>y>>z;
  int t=x[0];
  x.erase(x.begin());
  for(;;){
    if(t=='a'){
      if(x.size()==0){
	cout<<'A'<<endl;
	break;
      }
      t=x[0];
      x.erase(x.begin());
    }else if(t=='b'){
      if(y.size()==0){
	cout<<'B'<<endl;
	break;
      }
      t=y[0];
      y.erase(y.begin());
    }else if(t=='c'){
      if(z.size()==0){
	cout<<'C'<<endl;
	break;
      }
      t=z[0];
      z.erase(z.begin());
    }
  }
      
  return 0;
}


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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

int main(){
	int n; scanf("%d", &n);
	FOR(i, 0, n)
		printf("%s", "ACL");
	puts("");
	return 0;
}


Measured memory_bytes: 3748
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("amusing.in", "r", stdin);
    //freopen("amusing.out", "w", stdout);
}

void solve() {
    ll n, x;
    cin >> n >> x;
    ll ans = n;
    ll a = x, b = n - x;
    if (a < b) swap(a, b);
    while (a > 0 && b > 0){
        ll k = a / b;
        if (a % b == 0) ans -= b;
        ans += 2 * k * b;
        a -= k * b;
        swap(a, b);
    }
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

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

    long long a[n];
    long long b[n];

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

    long long ans = 0;

    for(int i = n - 1; i >= 0; i--){
        ans += (ceil((double)(a[i] + ans) / b[i]) * b[i]) - a[i] - ans;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int nax = 405;
const ll INF = 1e18L + 5; // 10^18+5
ll dp[nax][nax];
// dp[i][j] - the minimum total cost of combining interval [i,j] into one vertex

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for(int& x : a) {
        scanf("%d", &x);
    }
    auto sum = [&](int L, int R) {
        ll s = 0;
        for(int i = L; i <= R; ++i) {
            s += a[i];
        }
        return s;
    };
    for(int L = n - 1; L >= 0; --L) {
        for(int R = L; R < n; ++R) {
            if(L == R) {
                dp[L][R] = 0;
            }
            else {
                dp[L][R] = INF;
                ll s = sum(L, R);
                for(int i = L; i <= R - 1; ++i) {
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + s);
                }
            }
        }
    }
    
    printf("%lld\n", dp[0][n-1]);
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  i64 N, K;
  cin >> N >> K;
  vi32 A(N);
  cin >> A;
  sort(all(A));
  i64 ok = 1e18 + 1, ng = -1e18 - 1;
  while (ok - ng > 1) {
    i64 m = (ok + ng) / 2;
    i64 cnt = 0;
    rep(i, N) {
      if (A[i] < 0) {
        int x = bis<int>(N, i, [&](int j) { return (i64) A[i] * A[j] <= m; });
        cnt += N - x;
      } else if (A[i] > 0) {
        int x = bis<int>(i, N, [&](int j) { return (i64) A[i] * A[j] <= m; });
        cnt += x - i;
      } else {
        if (m >= 0) {
          cnt += N - i - 1;
        }
      }
      if (cnt >= K) break;
    }
    (cnt >= K ? ok : ng) = m;
  }
  cout << ok << endl;
}


Measured memory_bytes: 1024
n = int(input())
A = [[int(i) for i in input().split()] for i in range(n-1)]

for i in range(n-1):
    time = 0
    for j in range(i, n-1):
        c, s, f = A[j]
        if time < s:
            time = s
        elif time % f != 0:
            time += (f - time % f)
        time += c
    print(time)
print(0)

Measured memory_bytes: 3188