akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# coding: utf-8
#


def main(input_str):
    x, y = list(map(int, input_str.split(' ')))
    if 0 == x % y:
        print(-1)
        return
    
    
    max_num = 1e18
    num = x
    while num <= max_num:
        if 0 != num % y:
            print('{}'.format(num))
            return
        num += x
    print(-1)
    
if '__main__' == __name__:
    try:
        while True:
            main(input().strip())
    except EOFError:
        pass



Measured memory_bytes: 3060
const MAX: usize = 1e18 as usize;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    if a.contains(&0) {
        println!("0");
        return;
    }

    let mut p = 1;
    for i in 0..n {
        if p > MAX / a[i] {
            println!("-1");
            return;
        }
        p *= a[i];
        if p > MAX {
            println!("-1");
            return;
        }
    }

    println!("{}", p);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2808
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
vector <int> G[MAXN];
int dfs(int pos)
{
	vector <int> temp;
	for (int i = 0; i < G[pos].size(); ++i)
	{
		temp.push_back(dfs(G[pos][i]));
	}
	sort(temp.rbegin(), temp.rend());
	int ans = 0;
	for (int i = 0; i < temp.size(); ++i)
	{
		ans = max(ans, temp[i] + i + 1);
	}
	return ans;
}
int main()
{
	int n;
	cin>>n;
	for (int i = 2; i <= n; ++i)
	{
		int x;
		cin>>x;
		G[x].push_back(i);
	}
	cout<<dfs(1)<<"\n";
	return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    int maxt = 0;
    rep(i, N)rep(j, N){
        if(i != j){
            tmp = abs(A[i] - A[j]);
            maxt = max(tmp, maxt);
        }
    }
    cout << maxt << endl;
    return 0;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();

		if(N == M) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

		scan.close();

	}
}


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
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...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll x;cin>>x;
  bitset<100001>y=0;
  y[0]=1;
  rep(i,100,106){
    rep(j,0,1005){
      y|=(y<<i);
    }
  }
  ans(y[x],1,0);
  return 0;
}

Measured memory_bytes: 256
N = int(input())
h_list = list(map(int, input().split()))
from itertools import accumulate

h_max = list(accumulate(h_list, max))
ans = 0
for i in range(N):
    tmp = h_max[i]
    h = h_list[i]
    if tmp <= h:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
    map < string , int > mp;

int main(){
    int n, i, j,k;
    cin >> n;
    string s;
    vector < string  > v;
    for(int i = 0 ; i < n ; i++)
    cin >> s, v.push_back(s);
    
    mp[v[0]]++;
    for(i = 1; i < n; i++){
        if(v[i][0] != v[i-1].back() || mp[v[i]])return cout << "No",0;
        mp[v[i]]++;
    }
    cout << "Yes\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int x;
  cin >> x;

  if (x == 0) {
    cout << 1 << endl;
  } else if (x == 1){
    cout << 0 << endl;
  }
  return 0;
}


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

int n,m,q,ans,x[12],a[52],b[52],c[52],d[52];

void dfs(int now,int lst)
{
    if(now==n)
    {
        int tmp=0;
        for(int i=0;i<q;i++)
            if(x[b[i]-1]-x[a[i]-1]==c[i]) 
                tmp+=d[i];
        ans=max(ans,tmp);
        return;
    }
    for(int i=lst;i<=m;i++)
        x[now]=i,dfs(now+1,i);
}

int main()
{
    scanf("%d%d%d",&n,&m,&q);
    for(int i=0;i<q;i++) scanf("%d%d%d%d",a+i,b+i,c+i,d+i);
    dfs(0,1);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 3760
import java.lang.StringBuilder
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    println(problem136d(s))
}

fun problem136d(s: String): String {
    val s = s + "R"
    val list = IntArray(s.length - 1)
    var current = s[0]
    var count = 0
    for (i in 0 until s.length) {
        val si = s[i]
        if (current != si) {
            if (current == 'R') {
                if (count % 2 == 0) {
                    list[i] += count / 2
                    list[i - 1] += count / 2
                } else {
                    list[i] += count / 2
                    list[i - 1] += count / 2 + 1
                }
            } else {
                if (count % 2 == 0) {
                    list[i - count - 1] += count / 2
                    list[i - count] += count / 2
                } else {
                    list[i - count - 1] += count / 2
                    list[i - count] += count / 2 + 1
                }
            }
            if (i != s.length) {
                current = s[i]
            }
            count = 1
            continue
        }
        count++
        current = s[i]
    }
    val sb = StringBuilder()
    list.forEach {
        sb.append("$it ")
    }

    return sb.toString()
}

Measured memory_bytes: 40848
// She is Pretty pretty!
// DAG上dp
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

const int N = 1e6+100;
int n , m , x , y ,dp[N], deg[N];
vector<int > G[N];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n >> m;
    for(int i = 0; i < m ; i++){
        cin >> x >> y;
        deg[y]++;G[x].pb(y);
    }
    queue<int > q ;
    for(int i = 1; i <= n; i++){
        if(!deg[i])q.push(i);
    }
    while(!q.empty()){
        int now = q.front();
        q.pop();
        // cout << "now === " << now << endl;
        /*for(int it = 0; it < G[now].size(); it++){
            dp[G[now][it]] = max(dp[now]+1, dp[G[now][it]]);
            deg[G[now][it]]--;
            if(!deg[G[now][it]])q.push(G[now][it]);
            // cout << "it ==" <<  it << endl;
        }*/
        for(auto it : G[now]){
            dp[it] = max(dp[it] , dp[now]+1);
            deg[it] --;
            if(!deg[it])q.push(it);
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(dp[i], ans);
    }cout << ans << endl;
    return 0;
}

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

long long n;
long long ans = 0;
long long a[200010], b[200010];
priority_queue<pair<long long, long long>> q;

int main()
{
    cin >> n;
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long i = 0; i < n; i++)
    {
        cin >> b[i];
        if (a[i] < b[i])
        {
            q.push(make_pair(b[i], i));
        }
        else if (a[i] > b[i])
        {
            cout << -1 << endl;
            return 0;
        }
    }
    while (!q.empty())
    {
        pair<long long, long long> m = q.top(); q.pop();
        long long i = m.second;
        long long pi = i - 1;
        long long ni = i + 1;
        if (pi == -1) pi = n - 1;
        if (ni == n) ni = 0;
        long long x = b[pi] + b[ni];
        long long y = max(b[pi], b[ni]);
        long long cnt = min((b[i] - a[i]) / x, (b[i] - y) / x + 1);
        if (!cnt)
        {
            cout << -1 << endl;
            return 0;
        }
        ans += cnt;
        b[i] -= cnt * x;
        if (b[i] > a[i])
            q.push(make_pair(b[i], i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9072
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vi2;
typedef vector<vi2> vi3;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vll> vll2;
typedef vector<vll2> vll3;
typedef vector<bool> vb;

#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define uset unordered_set
#define vec vector
#define loop(a) for (auto &x : a)
#define all(a) a.begin(), a.end()
#define mp make_pair

int n, m;
vec<vec<pii>> adj;
vll edge_mask;
ll ans = 0;

void dfs(int which, ll mask, int in_ex) {
#ifdef LOCAL
    // cout << "which:" << which << " mask:" << mask << " bits:" << __builtin_popcountll(mask) << el;
#endif
    if (which == m) {
        int edge_left = n - 1 - __builtin_popcountll(mask);
#ifdef LOCAL
        assert(edge_left >= 0);
        // cout << "edge_left=" << edge_left << el;
#endif
        ans += (ll)in_ex * (1LL << edge_left);
        return;
    }
    dfs(which + 1, mask, in_ex);
    dfs(which + 1, mask | edge_mask[which], -in_ex);
}

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

    cin >> n;
    adj = vec<vec<pii>>(n);
    rep(i, 0, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].emplace_back(b, i);
        adj[b].emplace_back(a, i);
    }
    cin >> m;
    edge_mask = vll(m);
    rep(i, 0, m) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        queue<int> q;
        vii from(n, {-1, -1});
        q.push(u);
        from[u] = {u, -1};
        while (!q.empty()) {
            int h = q.front();
            q.pop();
            if (h == v) {
                break;
            }
            loop(adj[h]) {
                if (from[x.first].first == -1) {
                    from[x.first] = {h, x.second};
                    q.push(x.first);
                }
            }
        }
        set<int> edges;
        int work = v;
        while (work != u) {
            edges.insert(from[work].second);
            work = from[work].first;
        }
#ifdef LOCAL
        cout << "edges for " << i << ":";
        loop(edges) {
            cout << x << ' ';
        }
        cout << el;
#endif
        loop(edges) {
            edge_mask[i] += 1LL << x;
        }
#ifdef LOCAL
        cout << "edge_mask for " << i << ":" << edge_mask[i] << el;
#endif
    }
    dfs(0, 0, 1);
    cout << ans << el;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define fi first
#define se second
#define pb push_back
#define read(type, ...)type __VA_ARGS__; macro_scan(__VA_ARGS__);

using namespace std;

template<typename T> void macro_scan(T& t){cin>>t;};
template<typename F, typename ...R>void macro_scan(F& f , R& ...r){
  cin>>f;macro_scan(r...);
}

void deb(){
    cerr<<endl;
}
template<typename T , typename... t>
void deb(T a , t...b){
    cerr<<a<<" ";
    deb(b...);
}
template<typename T>
void dev(vector<T>v){
    int c = 0;
    for(auto i : v){
        cerr<<i<<" ";
        c++;
    }
    cerr<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    read(int, a);
    int dg = (int)log10(a) + 1;
    int cnt = 0;
    if(dg%2==1)cnt = a - (int)pow(10  , dg) + 1;
    for(int i = 0; i < (int)dg; ++i){
        int x = 0;
        if(i%2==0)x = (int)pow(10 , i + 1) - (int)pow(10 , i);
        cnt += x;

    }
    cout<<cnt<<"\n";
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <functional>
#include<math.h>
using namespace std;
vector<long long> code(26, 0);


int main() {
	long long X, A, B;
	cin >> X >> A >> B;
	if (B-A <= 0) {

		cout << "delicious" << endl;
	}
	else if (B-A <= X) {

		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const int MAX_N = 1e6 + 10;
bool used[MAX_N];

int ok(vector<int> ans) {
    int curr = -1;
    for(int i = 0; i < ans.size(); i ++) {
        int now = ans[i];
        for(int j = i - 1; j >= 0; j --) {
            now ^= ans[j];
            if(ans[j] == ans[i]) {
                if(curr == -1) {
                    curr = now;
                } else if(curr != now) {
                    return -1;
                }
                break;
            }
        }
    }
    return curr;
}

int pref[MAX_N];

void solve() {
    int n, k;
    cin >> n >> k;
    if(n == 0) {
        if(k == 0) {
            cout << 0 << " " << 0 << endl;
        } else {
            cout << -1 << endl;
        }
    } else if(n == 1) {
        if(k < 1) {
            cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
        } else {
            cout << -1 << endl;
        }
    } else if(n == 2) {
        if(k >= (1 << n)) {
            cout << -1 << endl;
            return;
        }
        vector<int> ans;
        for(int i = 0; i < (1 << n); i ++) {
            ans.push_back(i);
            ans.push_back(i);
        }
        do {
            int now = ok(ans);
            if(now == k) {
                for(auto it : ans) {
                    cout << it << " ";
                }
                cout << endl;
                return;
            }
        } while(next_permutation(ans.begin(), ans.end()));
    } else {
        if(k >= (1 << n)) {
            cout << -1 << endl;
            return;
        }
        int mask = 1 << n;
        for(int i = 0; i < mask; i ++) {
            if(i == k) {continue;}
            cout << i << " ";
        }
        cout << k << " ";
        for(int i = mask - 1; i >= 0; i --) {
            if(i == k) {continue;}
            cout << i << " ";
        }
        cout << k << endl;
    }
}

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);++i)
#define rep(i,n) REP(i, 0, n)
 
typedef pair<int, int> state;
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    const int INF = 1.0e9;
    for(int N, M; cin >> N >> M && N;) {
        vector<vector<tuple<int, int, int>>> G(N);
        rep(i, M) {
            int u, v, d, c;
            cin >> u >> v >> d >> c;
            --u; --v;
            G[u].emplace_back(v, d, c);
            G[v].emplace_back(u, d, c);
        }
        vector<int> mdist(N, INF), preEcos(N, INF);
        mdist[0] = preEcos[0] = 0;
        priority_queue<state, vector<state>, greater<state>> que;
        que.emplace(0, 0);
        while(!que.empty()) {
            int dis, cur;
            tie(dis, cur) = que.top(); que.pop();
            if(mdist[cur] < dis) continue;
            for(const auto& e : G[cur]) {
                int nv, ndis, ncos;
                tie(nv, ndis, ncos) = e;
                if(mdist[nv] > dis + ndis) {
                    mdist[nv] = dis + ndis;
                    preEcos[nv] = ncos;
                    que.emplace(mdist[nv], nv);
                } else if(mdist[nv] == dis + ndis && preEcos[nv] > ncos)
                  preEcos[nv] = ncos;
            }
        }
        cout << accumulate(preEcos.begin(), preEcos.end(), 0) << endl;
    }
    return 0;
}

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

int main() {
	string S;
	cin >> S;

	int ans = 1;
	if(S == "RRR") ans = 3;
	else if(S == "RRS" || S == "SRR") ans = 2;
	else if(S == "SSS") ans = 0;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,sum,j,p,d;
  cin >> n;
  j = n/500;
  p = n%500;
  d = p/5;
  sum = 1000*j + d*5;
  cout<<fixed<<sum;
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>    
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define int long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define fone for(i=0;i<n;i++)
#define endl "\n"
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N          = 5000*100+1;
const ll N2      = 1000*1000+5;
const ld PI  = 3.14159265;
const ll R   = 250;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ return (a.second < b.second); }


signed main ()
{
  fastio();
  int a,b;
  cin>>a>>b;
  cout<<(a*b)<<endl;
  



 
  return 0;
  
}

Measured memory_bytes: 3648
import math
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p=[1,2,3,math.inf]
p1=0
p2=0
p3=0
p4=0
 
#p=1
for i in range(n):
    p1+=(abs(a[i]-b[i]))
print("{:10f}".format(p1))
 
#p=2
q=0
for i in range(n):
    q+=((abs(a[i]-b[i]))**2)
    p2=math.sqrt(q)
print("{:10f}".format(p2))
 
#3
q=0
for i in range(n):
    q+=((abs(a[i]-b[i]))**3)
    p3=q**(1/3)
print("{:10f}".format(p3))
 
#inf
q=0
for i in range(n):
    q=(abs(a[i]-b[i]))
    if q>p4:
        p4=q 
print("{:10f}".format(p4))


Measured memory_bytes: 5732
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct edge {
	long long to, cap, rev;
};
vector<edge>x[309]; bool used[309];

void add_edge(int u, int v, long long c) {
	x[u].push_back(edge{ v,c,(long long)x[v].size() });
	x[v].push_back(edge{ u,0LL,(long long)x[u].size() - 1 });
}
long long dfs(int u, int v, long long f) {
	if (u == v) return f;
	used[u] = true;
	for (int i = 0; i < x[u].size(); i++) {
		if (x[u][i].cap == 0 || used[x[u][i].to] == true) continue;
		long long G = dfs(x[u][i].to, v, min(f, x[u][i].cap));
		if (G == 0) continue;
		x[u][i].cap -= G;
		x[x[u][i].to][x[u][i].rev].cap += G;
		return G;
	}
	return 0;
}
long long max_flow(int u, int v) {
	long long F = 0;
	while (true) {
		for (int i = 1; i <= 300; i++) used[i] = false;
		long long FF = dfs(u, v, (1LL << 60));
		if (FF == 0) break;
		F += FF;
	}
	return F;
}

long long a[109], n, sum;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) { cin >> a[i]; sum += max(0LL, a[i]); }
	for (int i = 1; i <= n; i++) {
		for (int j = 2 * i; j <= n; j += i) add_edge(i, j, (1LL << 50));
		if (a[i] <= 0) add_edge(n + 1, i, -a[i]);
		if (a[i] >= 1) add_edge(i, n + 2, a[i]);
	}
	cout << sum - max_flow(n + 1, n + 2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	int b = 0;
	rep(i, n) cin >> a[i];
	rep(i, n - 1) {
		b = max(b, a[i + 1] - a[i]);
	}
	b = max(b, k - a[n - 1] + a[0]);
	cout << k - b << endl;
}

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

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    ll a, b;
    cin>>a>>b;
    cout<<max(0ll, a - 2*b)<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(),A.end());
    ll ans = 0;
    map<int,int> mp,mp2;
    rep(i,N){
        mp2[A[i]]++;
    }
    rep(i,N){
        int num = A[i];
        if(mp[A[i]]!=0){
            continue;
        }
        for(int j=2;j*A[i]<=A[N-1];j++){
            mp[A[i]*j]++;
        }
    }
    rep(i,N){
        if(mp2[A[i]]>1) continue;
        if(mp[A[i]]!=0) continue;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 57808
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
#define fcout cout<<fixed<<setprecision(10)
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
//template<typename T>void pp(T x){cout<<x<<endl;}

using namespace std;
template<typename T> void test(vector<T> v){for(int i=0;i<v.size();i++){if(i)cout<<" ";cout<<v[i];}cout<<endl;}

typedef struct buhin{
    int a,b,c;
    int judge;

    void init(){
        a--; b--; c--;
    }
}B;
int main(){
    int a,b,c;
    while(cin>>a>>b>>c&&a&&b&&c){
        vector<int> ans(a+b+c,2);
        int n; cin>>n;
        vector<B> v(n);
        rep(i,0,n){
            cin>>v[i].a>>v[i].b>>v[i].c>>v[i].judge;
            v[i].init();
        }

        rep(i,0,n){ //先に正常な部品をチェック
            if(v[i].judge==1){
                ans[v[i].a]=1;
                ans[v[i].b]=1;
                ans[v[i].c]=1;
            }
        }

        rep(i,0,n){
            if(v[i].judge==0){
                if(ans[v[i].a]==1&&ans[v[i].b]==1)ans[v[i].c]=0;
                if(ans[v[i].b]==1&&ans[v[i].c]==1)ans[v[i].a]=0;
                if(ans[v[i].c]==1&&ans[v[i].a]==1)ans[v[i].b]=0;
            }
        }

        rep(i,0,a+b+c){
            cout<<ans[i]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3028
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	H := make([]int, N)
	for i := 0; i < N; i++ {
		H[i] = sc.nextInt()
	}
	max := 0
	current := 0
	before := H[0]
	for i := 1; i < N; i++ {
		if before >= H[i] {
			current++
		} else {
			if current > max {
				max = current
			}
			current = 0
		}
		before = H[i]
	}
	if current > max {
		max = current
	}
	fmt.Println(max)
}


Measured memory_bytes: 3072
from copy import deepcopy
from collections import Counter, defaultdict, deque
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
def maze_solve(S_1,S_2,maze_list):
    d = deque()
    dist[S_1][S_2] = 0
    d.append([S_1,S_2])
    dx = [0,0,1,-1]
    dy = [1,-1,0,0]
    while d:
        v = d.popleft()
        x = v[0]
        y = v[1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if nx < 0 or nx >= h or ny < 0 or ny >= w:
                continue
            if dist[nx][ny] == -1:
                dist[nx][ny] = dist[x][y] + 1
                d.append([nx,ny])
    return max(list(map(lambda x: max(x), dist)))
h,w = MI()
ans = 0
maze = [list(input()) for _ in range(h)]
dist = [[-1]*w for _ in range(h)]
start_list = []
for i in range(h):
    for j in range(w):
        if maze[i][j] == "#":
          dist[i][j] = 0
        else:
          start_list.append([i,j])
dist_copy = deepcopy(dist)
for k in start_list:
  dist = deepcopy(dist_copy)
  ans = max(ans,maze_solve(k[0],k[1],maze))
print(ans)

Measured memory_bytes: 9544
#include <stdio.h>
#include <iostream>
#include <string>


int main() {
	int S,W;
	std::cin >> S;
	std::cin >> W;
	if (S > W) {
		std::cout << "safe" << std::endl;
	}
	else {
		std::cout << "unsafe" << std::endl;
	}

	return 0;

}

Measured memory_bytes: 3624
import sys
H, W = map(int, input().split())
s = [input() for i in range(H)]
S = []
S.append('.' * (W + 2))
for i in range(H):
    S.append('.' + s[i] + '.')
S.append('.' * (W + 2))
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if S[i][j] == '#':
            if S[i + 1][j] == '#' or S[i - 1][j] == '#' or S[i][j + 1] == '#' or S[i][j - 1] == '#':
                continue
            else:
                print('No')
                sys.exit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(n,0);

    ll ans = 1;
    ll MOD  = 1e9 + 7;

    rep(i,n){
        cnt[a[i]]++;
        if(a[i] != 0){
            ans *= (cnt[a[i] - 1] - cnt[a[i]] + 1);
        }
        else{
            ans *= (4 - cnt[0]);
        }
        ans = (ans+MOD)%MOD;
    }

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

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  string S;
  cin >> S;

  long first = (S[0] - '0') * 10 + S[1] - '0';
  long second = (S[2] - '0') * 10 + S[3] - '0';

  // YYMM
  // MMYY

  bool YYMM = true;
  if (second > 12 or second == 0) YYMM = false;

  bool MMYY = true;
  if (first > 12 or first == 0) MMYY = false;

  if (YYMM and MMYY) cout << "AMBIGUOUS" << endl;
  else if (YYMM) cout << "YYMM" << endl;
  else if (MMYY) cout << "MMYY" << endl;
  else cout << "NA" << endl;

  return 0;
}


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

int main(){
        int n,m,i,p,cnt_p=0,cnt_a=0;
        string s;
        cin >> n >> m;
        vector<int> pen(n);
        vector<bool> done(n);
        for(i=0;i<m;++i){
                cin >> p >> s;
                --p;
                if(done.at(p)) continue;
                if(s=="WA") ++pen.at(p);
                else{
                        cnt_p += pen.at(p);
                        ++cnt_a;
                        done.at(p) = true;
                }
        }
        cout << cnt_a << " " << cnt_p << endl;
        return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <cmath>
using namespace std;
typedef unsigned long long ULL;

inline ULL GCD(ULL a,ULL b)
{
    ULL res=0;
    if(a != b)
    {
        if(a > b) 
        {
            if(a % b == 0)
            {
                return b;
            }
            else
            {
                GCD(b,(a % b));
            }

        }
        else 
        {
            if(b % a == 0)
            {
                return a;
            }
            else
            {
                GCD(a,(b % a));
            }

        }
    }
    else
    {
        return a;
    }
}
inline ULL LCM(ULL a,ULL b)
{
    ULL l  = GCD(a,b);
    ULL l1 = a / l;
    ULL l2 = b / l;
    return l * l1 * l2;
}
int main()
{
    ULL a,b;
    while(cin >> a >> b)
    {
        cout << GCD(a,b) << " " << LCM(a,b) << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n,m;
	int su[1001];
	cin >> n >> m;
	if(n==0 && m == 0) break;
	REP(i,n) cin >> su[i];
	int me[1000];
	REP(i,m) cin >> me[i];
	int pos = 0;
	int ans = 0;
	REP(i,m){
	    pos += me[i];
	    if(pos+1 >= n){
		ans = i + 1;
		break;
	    }
	    pos += su[pos];
	    if(pos+1 >= n){
		ans = i + 1;
		break;
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

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

using namespace std;
int main() {
	map<string,bool>mapa;
int n;
string a,b;
cin>>n;
while(n--){
	cin>>a>>b;
	if(a[0]=='i'){
		mapa[b]=true;
	}else {
		if(mapa[b]){
			cout<<"yes\n";
		}else{
			cout<<"no\n";
		}
	}
}
	return 0;
}


Measured memory_bytes: 52608
//## MohK
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int h[n];
    for(int i = 0; i < n; i++){
       cin>>h[i] ;
    }
    int ans = 0 ;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            ans+=h[i]*h[j];
        }
    }
    cout << ans << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  int temp;
  for(int i = 0; i < n; ++i){
    if(s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T') continue;
    temp = 1;
    for(int j = i + 1; j < n; ++j){
      if(s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] =='T') temp++; 
      else break;
    }
    ans = max(ans, temp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))
A = []

for i in range(N):
    if i == 0:
        A.append(B[0])
    elif i == N-1:
        A.append(B[i-1])
    else:
        A.append(min(B[i-1], B[i]))

print(sum(A))

Measured memory_bytes: 9064
#include <cstdio>
#include <cstring>

struct data{
	int par,left,right;
};

int n;
int a[41],b[41],c[41];
data dat[41];
int cnt;

void dfs(int v){
	if(dat[v].left>0)dfs(dat[v].left);
	if(dat[v].right>0)dfs(dat[v].right);
	printf("%d%c",v,cnt==n-1?'\n':' ');
	cnt++;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
		c[b[i]]=i;
	}
	c[0]=n;
	for(int i=1;i<=n;i++){
		dat[i].par=-1;
		dat[i].left=-1;
		dat[i].right=-1;
	}
	dat[a[0]].par=0;
	int p=a[0];
	int mostr=c[a[0]];
	for(int i=1;i<n;i++){
		for(int j=c[a[i]]-1;j>=0;j--){
			if(dat[b[j]].par!=-1 && dat[b[j]].right==-1){
				dat[b[j]].right=a[i];
				dat[a[i]].par=b[j];
				break;
			}
			if(dat[b[j]].par!=-1)break;
		}
		for(int j=c[a[i]]+1;j<n;j++){
			if(dat[b[j]].par!=-1 && dat[b[j]].left==-1){
				dat[b[j]].left=a[i];
				dat[a[i]].par=b[j];
				break;
			}
			if(dat[b[j]].par!=-1)break;
		}
	}
	dfs(a[0]);
	return 0;
}

Measured memory_bytes: 1028
so=input()

s=""

N=len(so)
i=0
while i<N:
    if so[i]=="A":
        s=s+"A"
        i+=1
    elif so[i:i+2]=="BC":
        s=s+"B"
        i+=2
    elif so[i]=="C" or so[i]=="B":
        s=s+"D"
        i+=1

L=len(s)
f=False
cnt=0
a=0
for i in range(L):
    if s[i]=="A":
        f=True
        a+=1
    elif f and s[i]=="B":
        cnt+=a
    elif s[i]=="D":
        f=False
        a=0
print(cnt)


Measured memory_bytes: 3500
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)

ll sq(ll x){
	return x*x;
}

int main(void){
	int ans,n,k,i;
	cin >> n >> k;
	ans = k;
	k--;
	for(i=1; i<n; ++i){
		ans *= k;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a<b && a<=c){
    if(b<=c)printf("%d %d %d\n",a,b,c);
    else printf("%d %d %d\n",a,c,b);
  }
  if(b<=a && b<c){
    if(a<=c)printf("%d %d %d\n",b,a,c);
    else printf("%d %d %d\n",b,c,a);
  }
  if(c<a && c<=b){
    if(b<=a)printf("%d %d %d\n",c,b,a);
    else printf("%d %d %d\n",c,a,b);
  }
  return 0;
}

Measured memory_bytes: 596
package main

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

func main() {
	a := getInt()
	b := getInt()

	if (a+b)%2 == 1 {
		fmt.Println("IMPOSSIBLE")
		return
	}
	fmt.Println((a + b) / 2)
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>A>>B;
    if(A == 1 && B == 1) {
        cout<<1<<endl;
    }else if(min(A,B) == 1){
            cout<<max(0LL, max(A,B) - 2)<<endl;
    }else{
        cout<<(A-2)*(B-2)<<endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class ABC171
{
    static void Main()
    {
        string[] sarr = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
        long num_N = long.Parse(sarr[0]);
        long num_K = long.Parse(sarr[1]);

        long[] parr = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        Array.Sort(parr);

        long ans = 0;
        for(int i=0; i<num_K; i++)
        {
            ans += parr[i];
        }
        Console.WriteLine(ans);
        System.Diagnostics.Debug.WriteLine(ans);
    }
}

Measured memory_bytes: 28588
#include <bits/stdc++.h>
using namespace std;
long long dp[101][100003];
int main()
{
	long long n,W,v[105],w[105];
	cin>>n>>W;
	for(int i=1;i<=n;i++)
	{
		cin>>w[i]>>v[i];
	}
	for(int i=0;i<=100;i++)
	{
		for(int j=0;j<=100000;j++)
		{
			dp[i][j]=1000000000000000LL;
		}
	}
	dp[0][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=100000;j++)
		{
			if(j>= v[i])
			{
				dp[i][j]=min(dp[i-1][j],w[i]+dp[i-1][j-v[i]]);
			}
			else
			{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	long long int ans=0;
	for(long long int i=1;i<=100000;i++)
	{
		if(dp[n][i]<=W)
		{
			ans=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,ans;
  int t=1;
  cin >> N;
  vector<int> a(N);

  for (int i =0 ; i < N ; i++){
    cin >> a.at(i);
  }
  //ここまで入力

  for (int i = 0; i <N; i++){
      t = a.at(t-1);
      ans++;
      if(t==2){
          break;
        }
    }
if (ans < N){
    cout << ans << endl;
}else{
    cout << -1 << endl;
}

}


Measured memory_bytes: 3804
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
  int N,K;cin>>N>>K;
  int a[N+10];for(int i=0;i<N;i++)cin>>a[i];
  double ans=(((double)N)-1)/(((double)K)-1);
  cout<<(int)ceil(ans)<<endl;
}

Measured memory_bytes: 640
def findSumOfDigits(n):
    sum = 0
    while (n > 0):
        sum += n % 10
        n //= 10
    return sum

ans = 0
n = int(input())
total = findSumOfDigits(n)
if n % total == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define mod 1000000007
#define ull unsigned ll
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi acos(-1)
#define nui 100
#define INF 100000000000
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define F(i,a,n) for(ll i=a;i<n;i++)
#define B(i,a,n) for(ll i=n-1;i>=a;i--)
#define tc int t;cin>>t;while(t--)
#define tcf int t;cin>>t;for(int w=1;w<=t;w++)
#define pfn cout<<"-1\n"
#define pfp cout<<"1\n";



using namespace std;


ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}

ll fermat_inv(ll y) {return binpow(y, mod - 2);}



int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ld d, t, s;
    cin >> d >> t >> s;
    if (s >= (d / t))
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }




    return 0;

}

Measured memory_bytes: 3728
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long k = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();

        long biscuits = 1;
        if (k <= a || a + 2 > b) {
            biscuits += k;
        } else {
            if ((k - a) % 2 == 0) {
                biscuits = b + (k - a - 1) / 2 * (b - a) + 1;
            } else {
                biscuits = b + (k - a - 1) / 2 * (b - a);
            }
        }
        System.out.println(biscuits);
    }

}


Measured memory_bytes: 21844
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    int n;
    cin>>n;
    vector<int> x(n);
    rep(i,n) cin>>x.at(i);
    int ans=100100100;
    
    for(int p=1;p<=100;p++){
        int temp=0;
        for(auto a:x){
            temp+=(a-p)*(a-p);
        }
        ans=min(ans,temp);
    }
    
    dunk(ans);
    return 0;
}



Measured memory_bytes: 256
def main(n, a):
    a.sort()
    ans = 0

    for i in range(n):
        if i % 2 == 0:
            ans += a.pop()
        else:
            ans -= a.pop()

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << ' ' << X << ' ' << Y << endl;
    return 0;
}

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

#define int long long

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

int N;
int A[100000];
int odd = 0, even = 0;

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] % 2 == 0) {
            even++;
        } else {
            odd++;
        }
    }
    if (odd % 2 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

int main(){
  for(int i = 0; i < 5; i++){
    int x;
    cin >> x;
    if(x == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, k = map(int, input().split())

aa = [1]*n

for i in range(k):

    d = int(input())
    a = list( map(int, input().split()))
    for a_ in a:
        aa[a_-1]=0

print(sum(aa))

Measured memory_bytes: 9188
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}


//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	for(var i = 0; i < 1000; i++){
		if(i * 1000 >= N){
			myout((i * 1000) - N);
			return;
		}
	}
}


Measured memory_bytes: 30160