akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,n;
	cin>>a>>b>>n;
	if (n<b)
	{
		long long ans=a*n/b;
		cout<<ans;
	} else {
		if (n%b==0)
		{
			long long s1=a*(n-1)/b;
			long long s2=(n-1)/b;
			cout<<s1-a*s2;
		} else {
			long long x=((int)(n/b))*b-1;
			long long s1=a*x/b;
			long long s2=x/b;
			cout<<s1-a*s2;
		}
	}
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>


using namespace std;


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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }

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

    mean /= n;
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] <= mean) {
        count++;
      }
    }

    cout << count << endl;
    

  }
  
  

  return 0;
}


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

int main(){
  
  string s;
  cin>>s;
  
  if(s=="ARC"){
    cout<<"ABC"<<endl;
  }
  else{
    cout<<"ARC"<<endl;
  }
  
  return 0;
}
  
  

Measured memory_bytes: 3636
import sys


def gcd(a, b):
    """Euclidean Algorithm"""
    while b != 0:
        a, b = b, a % b
    return a


def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    A = sorted(A)

    if N == 2:
        return A[1]

    g0 = A[1]
    for i in range(1, N):
        g0 = gcd(g0, A[i])

    g = A[0]
    B = []
    for a in A:
        g = gcd(a, g)
        B.append(g)

    i = B.index(g)
    A.pop(i)

    g = A[0]
    for a in A:
        g = gcd(g, a)

    return max(g, g0)


if __name__ == '__main__':
    print(main())


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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


int main(void){

	int N; cin >> N;
	string P, Q;

	REP(i,N){
		char s; cin >> s;
		P += s;
	} 
	REP(i,N){
		char s; cin >> s;
		Q += s;
	} 
	
	string tmp;
	REP(i,N){
		tmp += (char)(i + '1');
	}

	int a;
	int b;
	int idx = 1;

	do{
		if(tmp == P) a = idx;
		if(tmp == Q) b = idx;
		idx++;
	}while(next_permutation(tmp.begin(), tmp.end()));

	cout << abs(a-b) << endl;

	return 0;

}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T &a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;

    vector<lint> a(n);
    lint sum = 0, osum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
        if(i % 2 == 1){
            osum += a[i];
        }
    }

    vector<lint> ans(n);
    ans[0] = sum - 2LL * osum;
    rep(i, n - 1){
        ans[i + 1] = 2LL * a[i] - ans[i];
    }

    rep(i, n){
        if(i) cout << ' ';
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

struct BIT {
  vector<vector<ll> > array;
  int n, m;
  BIT(int _n, int _m)
  : array(_n + 1, vector<ll>(_m + 1)), n(_n), m(_m) {}
  // [1, 1]から[x, y]までの累積和
  ll sum(int x, int y) {
    ll s = 0;
    for (int i = x; i > 0; i -= i & -i) {
      for (int j = y; j > 0; j -= j & -j) {
        s += array[i][j];
      }
    }
    return s;
  }
  ll sum(int x1, int y1, int x2, int y2) {
    return sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) + sum(x1 - 1, y1 - 1);
  }
  void add(int x, int y, ll k) {
    for (int i = x; i <= n; i += i & -i) {
      for (int j = y; j <= m; j += j & -j) {
        array[i][j] += k;
      }
    }
  }
  void out() {
    rep(i, n + 1) { rep(j, m + 1) cout << array[i][j] << " "; cout << endl; }
  }
};

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  cin >> a;
  vector<int> b(m);
  cin >> b;

  BIT bit(n, m);
  // bit.out();
  rep(i, n) rep(j, m) {
    if (a[i] != b[j]) continue;
    // cout << i << " " << j << endl;
    // 10^9 * 10^3 * 10^3 = 10^15
    bit.add(i + 1, j + 1, (bit.sum(i, j) + 1) % mod);
  }
  // bit.out();
  cout << (bit.sum(n, m) + 1) % mod << endl;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
int n,ls[30],mx1,mx2,x;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        mx1=-1;
        for(int j=1;j<=26;j++)
        {
            scanf("%d",&x);
            if(x>mx1)mx1=x,mx2=j;
            else if(x==mx1)if(ls[j]<ls[mx2])mx2=j;
        }
        ls[mx2]=i;
        printf("%d\n",mx2);
    }
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
#define MAX 100000
class art_point{
public:
    vector<bool>visited;
    vector<int>prenum;
    vector<int>parent;
    vector<int>lowest;
    int timer;
    int v;
    int N;
    map<int,int>Mp;
    vector<vector<int>>edge;
    art_point(int V,vector<vector<int>>&E){
        prenum.resize(V);
        parent.resize(V);
        lowest.resize(V);
        timer=0;
        visited.resize(V);
        rep(i,V)visited[i]=false;
        edge=E;
        N=v=V;
    }
    void dfs(int current,int prev){
        prenum[current]=lowest[current]=timer;
        timer++;
        visited[current]=true;
        int  next;
        for(int i=0;i<edge[current].size();i++){
            next=edge[current][i];
            if(!visited[next]){
                parent[next]=current;
                dfs(next,current);
                lowest[current]=min(lowest[current],lowest[next]);
            }else if(next != prev){
                lowest[current] = min(lowest[current],prenum[next]);
            }
        }
    }
    void _art_point(){
        timer=1;
        dfs(0,-1);
        int np=0;
        for(int i=1;i<N;i++){
            int p=parent[i];
            if(p==0)np++;
            else if(prenum[p]<=lowest[i])Mp[p]++;
            if(np>1)Mp[0]++;
        }
    }
    void get_art_point(){
        for(auto itr:Mp)cout<<itr.first<<endl;
    }
};
signed main(){
    int v,e; cin>>v>>e;
    vector<vector<int>>edge(v);
    rep(i,e){
        int a,b;cin>>a>>b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    art_point temp(v,edge);
    temp._art_point();
    temp.get_art_point();
}



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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);

	int n, l;
	vector<string> str;
	cin >> n >> l;

	for(int i=0; i<n; i++){
		string t;
		cin >> t;
		str.push_back(t);
	}
	
	sort(str.begin(), str.end());

	for(int i=0; i<n; i++){
		cout << str[i];
	}
	puts("");

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
using namespace std;

int main() {
  stack<int> s1;
  stack<pair<int,int>> s2;
  char ch;
  int sum = 0;

  for(int i = 0; cin >> ch; i++) {
    if(ch == '\\') s1.push(i);
    else if(ch == '/' && s1.size() > 0) {
      int j = s1.top(); s1.pop();
      sum += i - j;
      int a = i - j;

      while(s2.size() > 0 && s2.top().first > j) {
        a += s2.top().second; s2.pop();
      }

      s2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  int t = 0;
  while(s2.size() > 0) {
    ans.push_back(s2.top().second);
    s2.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for(auto v : ans) {
    cout << " ";
    t += v;
    cout << v;
  }
  cout << endl;
}



Measured memory_bytes: 3240
#include <cstdio>
#include <map>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

const int MX = 100500;

#define pii pair<int,int>


int a[MX];
int b[MX];
int c[MX];
long long ra[MX];
long long rb[MX];
long long rc[MX];

int main(int argc, char** argv)
{
    //freopen("/Users/ozzy/Documents/in.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0 ; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0 ; i < n; i++){
        cin >> b[i];
    }
    for(int i = 0 ; i < n; i++){
        cin >> c[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    for(int i = 0; i < n; i++){
        ra[i] = 1;
    }

    a[n] = b[n] = 1e9 + 10;
    int pos = -1;
    for(int i = 0; i < n; i++){
        if(i) rb[i] = rb[i - 1];
        while(b[i] > a[pos + 1]){
            pos++;
            rb[i] += ra[pos];
        }
    }

    pos = -1;
    long long ans = 0;
    for(int i = 0; i < n; i++){
        if(i) rc[i] = rc[i - 1];
        while(c[i] > b[pos + 1]){
            pos++;
            rc[i] += rb[pos];
        }
        ans += rc[i];
    }
    cout << ans << endl;

    return 0;
}

// 1 4 9 6 5 6


Measured memory_bytes: 3840
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from math import gcd
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

mod=10**9+7

print("ACL"*I())


Measured memory_bytes: 76528
#include<stdio.h>
int n, m, P[101000], C[101000], cnt;
int main(){
    int i, a, b;
    scanf("%d%d",&n,&m);
    P[1]=1;
    for(i=1;i<=n;i++)C[i]=1;
    for(i=1;i<=m;i++){
        scanf("%d%d",&a,&b);
        if(P[a])P[b]=1;
        C[a]--,C[b]++;
        if(!C[a])P[a]=0;
    }
    for(i=1;i<=n;i++)if(P[i])cnt++;
    printf("%d\n",cnt);
}


Measured memory_bytes: 896
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	int n,a[200001];
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	int r=n/2,l=n/2;
	int b[200001];
	for(int i=0;i<n;++i){
		if(i%2==0){
			b[r]=a[i];
			l--;
		}
		if(i%2==1){
			b[l]=a[i];
			r++;
		}
	}
	if(n%2==0){
		for(int i=0;i<n-1;++i){
			cout<<b[i]<<" ";
		}
		cout<<b[n-1]<<endl;
	}else{
		for(int i=n-1;i>0;--i)cout<<b[i]<<" ";
		cout<<b[0]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		int tmp = Math.max(a * b, a + b);
		int max = Math.max(tmp, a - b);

		System.out.println(max);

	}
}

Measured memory_bytes: 21844
use proconio::input;

fn main() {
    input! {n: i32, x: i32, t: i32};
    // 20 12 6
    let mut ans = 0;
    let mut c = 0;
    loop {
        c = c + x;
        ans = ans + t;
        if c >= n {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S, T;
    cin >> S >> T;
    REP( i, (int)S.size() )
    {
        S = S[ (int)S.size() - 1 ] + S.substr( 0, S.size() - 1 );
        if( S == T )
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
// written by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>

// DELETE the debugging information!
#define debug(x) std::cerr << #x << " = " << (x) << std::endl

const int N_MAX = 103;
char s[N_MAX];
bool col[N_MAX][N_MAX];
int dp[N_MAX][N_MAX];

int main() {
  int H, W;
  scanf("%d%d", &H, &W);
  for (int i = 1; i <= H; ++i) {
    scanf("%s", s + 1);
    for (int j = 1; j <= W; ++j)
      col[i][j] = s[j] == '#';
  }
  for (int i = 2; i <= H; ++i)
    dp[i][0] = i;
  for (int j = 2; j <= W; ++j)
    dp[0][j] = j;
  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j)
      dp[i][j] = std::min(dp[i - 1][j] + (col[i][j] > col[i - 1][j]),
                          dp[i][j - 1] + (col[i][j] > col[i][j - 1]));
  printf("%d\n", dp[H][W]);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    int n;
    cin >> n;
    map<ll,ll> m;
    rep(i,0,n){
	ll a;
	cin >> a;
	m[a]++;
    }

    if(sz(m) == 1 && m[0] == n){
	Yes;
    }else if(sz(m) == 2 && m[0] == n/3){
	Yes;
    }else if(sz(m) == 3){
	ll b[3];
	int i = 0;
	for(auto aa:m){
	    if(aa.sd == n/3)b[i++] = aa.ft;
	    else {
		No;
		ret 0;
	    }
	}
	if((b[0] ^ b[1] ^ b[2]) == 0)Yes;
	else No;
    }else{
	No;
    }
    
    
    return  0;
}


Measured memory_bytes: 5120
#include<stdio.h>

main(void){
    int a, b;
    char op;
while(1){
scanf("%d %c %d",&a ,&op, &b);
if(op == '+')
printf("%d\n",a + b);
else if(op == '-')
printf("%d\n",a - b);
else if(op == '*')
printf("%d\n",a * b);
else if(op == '/')
printf("%d\n",a / b);
else
break;
}

return 0;
}


Measured memory_bytes: 1976
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    long long x,y;
    int res=0;
    scanf("%lld%lld",&x,&y);
    while(x<=y)
    {
        x*=2;
        res++;
    }
    printf("%d",res);
    return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<iterator>
#include<algorithm>
#include<bitset>

#define Filein(N) freopen("N", "r", stdin);
#define Fileout(N) freopen("N", "w", stdout);
#define sci(x) scanf("%d", &x)
#define sci2(x,y) scanf("%d%d", &x,&y)
#define scll2(x,y) scanf("%lld%lld",&x,&y)
#define scll(x) scanf("%lld",&x)
#define scd(x) scanf("%lf", &x)
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", x)
#define pfll(x) printf("%lld", x)
#define pfd(x) printf("%f", x)
#define pfstr(x) printf("%s", x)
#define ps printf(" ")
#define pn printf("\n")
#define pfdt printf("..")

#define For(var,start,end) for(int var=start; var<=end;i++)
#define rFor(var,start,end) for(int var=start; var>=end; i--)
#define TestCase int testcase, cs=1; cin>>testcase;while(testcase--)

#define mkp make_pair
#define pb push_back
#define fi first
#define se second

#define px(x) cout<<"X -> "<<x<<endl;
#define py(x) cout<<"Y = "<<x<<endl;
#define pz(x) cout<<"Z >> "<<x<<endl;
#define pstr(x) printf("%s\n",x);

using namespace std;
using ll = long long;
using vi = vector <int>;
using mpii = map<int,int>;
using si = set<int>;
using sll = set<ll>;
using vll= vector<ll>;

#define INF 1000000000
#define LINF 4000000000000000000
#define pi  (2*acos(0))
#define Mod 1000000007

 int main(){
 ll n;
 scll(n);
 vi vc;
 while(n){
    ll d = n%26;
    if(d==0) { d=26; n--;}

    d += 96;
    vc.pb(d);

    n/=26;

 }

 for(int i=vc.size()-1;i>=0;i--){
    printf("%c",vc[i]);
 }pn;





    return 0;
}







Measured memory_bytes: 3656
#!/usr/bin/env python3
import sys


def solve(K: int, N: int, A: "List[int]"):    
    return K - max(a2 - a1 for a1, a2 in zip(A, A[1:]+[K+A[0]]))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(K, N, A))

if __name__ == '__main__':
    main()


Measured memory_bytes: 29300
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin>>n;
  x=n%10;
  if(x==2||x==4||x==5||x==7||x==9)
  cout<<"hon";
  else if(x==0||x==1||x==6||x==8)
  cout<<"pon";
  else 
  cout<<"bon";
  cout<<"\n";}


Measured memory_bytes: 3556
l,r = map(int,input().split())
ans = 10**20
if r-l>=2019:
    print(0)
    exit()
elif r-l<2019:
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans = min(ans,i*j%2019)
            if i*j%2019 == 0:
                break
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  int n;
  cin >> n;
  for (int z = 0; z < n; z++) {
    int x, y, b, p;
    cin >> x >> y >> b >> p;
    if (b >= 5 and p >= 2) {
      cout << 0.8 * (x * b + y * p) << endl;
    } else {
      cout << min(x * b + y * p, 4 * (x * max(b, 5) + y * max(p, 2)) / 5) << endl;
    }
  }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

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

int t[110];
int n,a;
ll dp[110][110][3000]={};

int main(){
	cin>>n>>a;
	REP(i,n){
		cin>>t[i];
	}
	dp[0][0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=50;j++){
			for(int k=0;k<3000;k++){
				if(dp[i][j][k]){
				dp[i+1][j+1][k+t[i]]+=dp[i][j][k];
				dp[i+1][j][k]+=dp[i][j][k];
				}
			}
		}
	}
	ll ans=0;

	for(int i=1;i<=n;i++)
		ans+=dp[n][i][i*a];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 123136
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


class CombTools(object):
    def __init__(self, cap: int, mod: int):
        self.cap = cap
        self.mod = mod
        self.inv = self._calc_inv()
        self.fac = self._calc_fac()
        self.fac_inv = self._calc_fac_inv()

    def _calc_inv(self):
        inv = [0, 1]
        for i in range(2, self.cap+1):
            inv.append((self.mod - (self.mod // i) * inv[self.mod % i]) % self.mod)

        return inv

    def _calc_fac(self):
        fac = [1]
        for i in range(1, self.cap+1):
            fac.append((i * fac[-1]) % self.mod)

        return fac

    def _calc_fac_inv(self):
        fac_inv = [1]
        for i in range(1, self.cap+1):
            fac_inv.append((self.inv[i] * fac_inv[-1]) % self.mod)

        return fac_inv

    def nCr(self, n: int, r: int):
        # validation
        if r > n:
            raise ValueError("n must be larger than r (n={}, r={})".format(n, r))

        # calculation
        return self.fac[n] * self.fac_inv[n-r] * self.fac_inv[r] % self.mod

    def nPr(self, n: int, r: int):
        # validation
        if r > n:
            raise ValueError("n must be larger than r (n={}, r={})".format(n, r))

        # calculation
        return self.fac[n] * self.fac_inv[n-r] % self.mod

    def nHr(self, n: int, r: int):
        return self.nCr(n+r-1, n)


n, k = li()

CAP = 10**5
MOD = 10**9 + 7
ct = CombTools(CAP, MOD)

for i in range(1, k+1):
    if n-k-i+1 < 0:
        print(0)
    else:
        ans = ct.nHr(n-k-i+1, i+1) * ct.nHr(k-i, i)
        print(ans % MOD)

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

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)

using namespace std;
using ll = long long;
using pos = pair<ll, ll>;

ll a,b;

void solve();

int main() {

   solve();
   return 0;

}

void solve() {

    cin >>a>>b;
    cout << ((a%3)*(b%3)*((a+b)%3)?"Impossible":"Possible") << endl;

}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){
int N;
cin>>N;
map<ll,ll> ans;
for(ll x=1;x*x<=2*N;x++){
    for(ll y=1;y*y<=2*N;y++){
        for(ll z=1;z*z<=2*N;z++){
            ans[(x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x)]++;
        }
    }
}
rep3(i,N){
    cout<<ans[2*i]<<endl;
}
return 0;
}

Measured memory_bytes: 8632
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

static const int MAX = 15;

int A[MAX][MAX];
int n;

int counter(int x){
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

void solve(){
    int ans = 0;
    
    for (int bits = 1; bits < (1 << n); bits++){
        bool ok = true;
        for (int i = 0; i < n; i++){
            if (!(bits & (1 << i))) continue;
            for (int j = 0; j < n; j++){
                if (A[i][j] == -1) continue;
                if (((bits >> j) & 1) ^ A[i][j]) ok = false;
            }
        }
        if (ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return;
}

int main(){
    int a, x, y;
    cin >> n;

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

    for (int i = 0; i < n; i++){
        cin >> a;
        for (int j = 0; j < a; j++){
            cin >> x >> y;
            x--;
            A[i][x] = y;
        }
    }

    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 5;
int main() {
	int n;
	cin >> n;
	vector<int> dp(n,inf);
	vector<int> h(n);
	for(int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	dp[0] = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j <= i + 2 && j < n; ++j) {
			dp[j] = min(dp[j], dp[i] + abs(h[j] - h [i])); 
		}
	}
	cout << dp[n-1];
}



Measured memory_bytes: 1024
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

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

int main() {
	ll N, M;
	cin >> N >> M;
	ll INF = numeric_limits<int>::max();
	auto graph = make_vec_nd(INF, N, N);
	vector<pair<ll, ll>> edges;
	rep(i,0,M) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		graph[a][b] = c;
		graph[b][a] = c;
		edges.push_back({a, b});
	}
	auto dist = graph;
	rep(i,0,N) {
		dist[i][i] = 0;
	}
	rep(k,0,N) {
		rep(i,0,N) {
			rep(j,0,N) {
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
			}
		}
	}
	ll cnt = 0;
	rep(m,0,M) {
		ll i = edges[m].first;
		ll j = edges[m].second;
		if (graph[i][j] > dist[i][j]) {
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 888
s = list(input())
t = list(input())
dics = {}
dic2 = {}
for i in range(len(s)):
    if s[i] in dics:
        if dics[s[i]] != t[i]:
            print("No")
            exit()
    else:
        dics[s[i]] = t[i]
    if t[i] in dic2:
        if dic2[t[i]] != s[i]:
            print("No")
            exit()
    else:
        dic2[t[i]] = s[i]
    
print("Yes")

Measured memory_bytes: 6704
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a) (a).begin(), (a).end()

const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T &r, T &l)
{
    T tmp = r;
    r = l;
    l = tmp;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
    return is;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> h(n);
    cin >> h;




    ll ans = 0;
    ll nh = h[0];
    ll tmp = 0;
    for (ll i = 1; i < n; i++){
        if (nh >= h[i]){
            tmp++;
            nh = h[i];
        }else{
            if ( ans < tmp)ans = tmp;
            nh = h[i];
            tmp = 0;
        }
    }

    if ( ans < tmp)ans = tmp;
    


    cout<< ans;

}


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

int main(){
  int n;
  cin >>n;
  vector <int> x(n+1);
  for(int i =0;i<n;i++) cin >> x.at(i+1);
  ll sum =0;
  ll ans =0;
  for(int i =1;i<=100;i++){
    sum =0;
    for(int j =1;j<=n;j++){
      sum +=(((x.at(j))-i)*((x.at(j))-i));
    }
    if(i == 1){
      ans = sum;
    }
    ans =min(sum,ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>

#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
#define Mabs(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define Abs(a) (a)>0?(a):(-(a))
template <typename QvQ> inline QvQ Min2(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max2(QvQ a,QvQ b){if(a>b) return a;return b;}
template <typename QvQ> inline QvQ Abs2(QvQ a){if(a>0) return a;return -a;}

#define n1kw 10000000
#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f
#define lldinf 0x3f3f3f3f3f3f3f3f

#define ll long long
#define rei register int
#define inv inline void
#define inb inline bool
#define ini inline int

#define bl putchar(' ')
#define ed putchar('\n')
#define test std::cout<<"this:"
#define card system("pause")

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

//char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)

template <typename QvQ>inv read(QvQ &x)
{
    x=0;int f=1;
    char c=getchar();
    for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
    x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
    if(x<0) x=-x,putchar('-');
    if(x>9) write(x/10);
    putchar(x%10+48);
}
using namespace std;
int r;
int main()
{
    read(r);
    write(r*r*3);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a==b)printf("%d\n",a+b);
	else if(a>b)printf("%d\n",a+a-1);
	else if(a<b)printf("%d\n",b+b-1);
	
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'



int main() {
     int n, k;
     cin >> n >> k;
     map<int,int> cnt;
     for (int i = 0; i < n; ++i) {
          int x;
          cin >> x;
          cnt[x]++;
     }
     vector<int> res;
     for (auto el : cnt) {
          res.push_back(el.second);
     }
     sort(res.begin(), res.end());
     int ans = 0;
     for (int i = 0; i < (int)res.size() - k; ++i) {
          ans += res[i];
     }
     cout << ans;
}


Measured memory_bytes: 10748
n = int(input())
x = input()
one = x.count("1")
base1 = 0
base2 = 0
if one == 1:
  idx = n - x.index("1") - 1
  base = pow(2,idx,2)
  for k,v in enumerate(x):
    now = base
    if v == "0":
      now += pow(2,n-k-1,2)
      if now % 2:
        print(2)
      else:
        print(1)
    else:
      print(0)
  exit()
for k,v in enumerate(x[::-1]):
  if v == "1":
    base1 += pow(2,k,one+1)
    base2 += pow(2,k,one-1)
base1 %= one+1
base2 %= one-1

for k,v in enumerate(x):
  ans = 1
  if v == "0":
    now = base1 + pow(2,n-k-1,one+1)
    now %= one+1
  else:
    now = base2 - pow(2,n-k-1,one-1)
    now %= one-1
  while now > 0:
    popcount = bin(now).count("1")
    now %= popcount
    ans += 1
  print(ans)

Measured memory_bytes: 82644
def main():
  s=input()
  if s==s[::-1]:
    t=s[:(len(s)-1)//2]
    if t==t[::-1]:
      t=s[(len(s)+3)//2-1:]
      if t==t[::-1]:
        return 'Yes'
  return 'No'
if __name__ == '__main__':
  print(main())

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string s;
    cin >> s;

    int ans = 0;
    int cnt = 0;
    REP(i, s.size()) {
        if (s[i] == 'R') {
            cnt++;
            ans = max(ans, cnt);
        } else {
            cnt = 0;
        }
    }

    print(ans);
}


Measured memory_bytes: 3580
#define MAX 100
#define INF 168435450

typedef struct node{
 int flg;
 int cost;
}node;



int min(int a,int b){
if(a < b)return a;
return b;
}


int min_idx(node N[],int n){
int idx;
int i;
int mini=268435450;

for(i=0;i<n;i++){
 if(N[i].flg==0 && N[i].cost<mini){
   mini=N[i].cost;
   idx=i;
 }
}

return idx;
}



int main(){
int n,x,y,d;
int i,j,k,u;
int Dis[MAX][MAX];
node N[MAX];

scanf("%d",&n);

for(i=0;i<n;i++){N[i].flg=0;N[i].cost=INF;
 for(j=0;j<n;j++){
  Dis[i][j]=INF;
  if(i==j)Dis[i][j]=0;
 }
}



for(i=0;i<n;i++){
 scanf("%d %d",&x,&k);
 for(j=0;j<k;j++){
  scanf("%d %d",&y,&d);
  Dis[x][y]=d;
 }
}


N[0].cost=0;

for(i=0;i<n;i++){
 u=min_idx(N,n);


 if(N[u].flg==0){
    N[u].flg=1;
    for(j=0;j<n;j++){
     if(Dis[u][j]!=INF){
      N[j].cost=min(N[j].cost,N[u].cost+Dis[u][j]);
     }
    }
 }

}









for(i=0;i<n;i++)
 printf("%d %d\n",i,N[i].cost);


return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <string>
#include <cstring>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <unordered_set>
#include <stack>
#include <vector>
#include <tuple>

using namespace std;
mt19937_64 rng(58);

typedef __int128 ll;
const int maxn = 100000;
ll np[maxn + 1];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    long long xx; // find a^5 - b^5 = x
    cin >> xx;
    ll x = xx;
    unordered_set<ll> nn;
    for (ll i = 1; i <= maxn; i++) {
        ll sq = i * i;
        np[i] = sq * sq * i;
        nn.insert(np[i]);
        nn.insert(-np[i]);
    }
    if (nn.find(x) != nn.end()) {
        for (int i = 1; i <= maxn; i++) {
            if (np[i] == x) {
                cout << i << " " << 0 << endl;
                return 0;
            }
        }
    }
    for (int i = 1; i <= maxn; i++) {
        if (nn.find(np[i] - x) != nn.end()) {
            for (int j = 0; j <= maxn; j++) {
                if (np[j] == np[i] - x) {
                    cout << i << " " << j << endl;
                    return 0;
                } else if (-np[j] == np[i] - x) {
                    cout << i << " " << -j << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 15504
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(Math.min(a, b) + " " + Math.max(0, a+b-n));
    }
}

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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int>v(m);int a=0;
  for(int i=0;i<m;i++){
    cin>>v.at(i);a+=v.at(i);
  }
  cout<<max(n-a,-1)<<endl;
}


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

double a, b, c, d, e, f, pi=3.14159265358979;

int main() {
    cin >> a >> b >> c;
    d = a * b / 2 * sin(c/180*pi);
    e = a + b + sqrt(a*a + b*b - 2*a*b*cos(c/180*pi));
    f = d / a * 2;
    cout << fixed << setprecision(9);
    cout << d <<endl << e << endl << f << endl;
}


Measured memory_bytes: 3540
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for ai in A:
    s = C
    for a, b in zip(ai, B):
        s += a * b
    if s > 0:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nummax 110000
using namespace std;

int gcd(int a, int b)
{
	int x;
	while (1)
	{
		x = a % b;
		if (x == 0)
			return b;
		else
		{
			a = b;
			b = x;
		}
	}
}

int main() {
	int i, iout = 0, N, A[nummax], ans, gcdL[nummax], gcdR[nummax], gcdtmp, gcdmax = 0, imax;
	cin >> N;
	for (i = 1; i <= N; i++)
	{
		cin >> A[i];
	}
	gcdL[1] = A[1];
	gcdR[N] = A[N];
	for (i = 2; i <= N; i++)
	{
		gcdL[i] = gcd(gcdL[i - 1], A[i]);
	}
	for (i = N - 1; i >= 1; i--)
	{
		gcdR[i] = gcd(gcdR[i + 1], A[i]);
	}
	for (i = 1; i <= N; i++)
	{
		if (i == 1)
			gcdtmp = gcdR[2];
		else if (i == N)
			gcdtmp = gcdL[N - 1];
		else gcdtmp = gcd(gcdL[i - 1], gcdR[i + 1]);
		if (gcdtmp > gcdmax)
		{
			gcdmax = gcdtmp;
			imax = i;
		}
	}
	if (imax == 1)
		ans = A[2];
	else ans = A[1];
	for (i = 2; i <= N; i++)
	{
		if (i != imax)
			ans = gcd(ans, A[i]);
	}
	cout << ans << endl;
}

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

using ll  = long long;
const int mod = 998244353;

#define f(i,a,b) for (int i = a; i < b; i++)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n; cin>>n;
  int a[n];
  f(i,0,n) cin>>a[i];
  sort(a+1,a+n);
  map<int,int> freq;
  f(i,0,n) freq[a[i]]++;
  
  ll ans = 1;
  if (freq[0] != 1) ans = 0;
  f(i,1,n) {
  	ans = (ans*freq[a[i]-1])%mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, X, T;
    cin >> N >> X >> T;
    printf("%lld\n", ((N-1)/X + 1) * T);
}

Measured memory_bytes: 3756
h, w, n = map(int, input().split())
li = []
l = [w] * h
for _ in range(n):
    x, y = map(int, input().split())
    li.append((x - 1, y - 1))
li.sort()
cnt = 0
ans = h
for x, y in li:
    if x - cnt == y:
        cnt += 1
    elif x - cnt > y:
        ans = min(ans, x)
print(ans)



Measured memory_bytes: 67672
#include <iostream>
#include <string>
#include<iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include<queue>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include <map>
#include<string.h>
#include<sstream>
#include<stack>
#include <iostream>
#define ll long long
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 2e5 + 5, inf = 1e9 + 7;
const double ep = 0.0000000001;
const double pi = 3.14159265359;
const int MAXN = 1000007;
ll k, arr[10004];
ll count1[1000005];//3ddddd
int spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (ll i = 2; i < MAXN; i++)
		spf[i] = i;
	for (ll i = 4; i < MAXN; i += 2)
		spf[i] = 2;
	for (ll i = 3; i*i < MAXN; i++)
	{
		if (spf[i] == i)
		{
			for (ll j = i * i; j < MAXN; j += i)
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}
void primefactor(ll x)
{
map<ll, ll>count2;
	while (x != 1)
	{
		count2[spf[x]] += 1;
		if (count1[spf[x]] < count2[spf[x]])
			count1[spf[x]] = count2[spf[x]];
		x = x / spf[x];
	}

}
long long fp(long long b, long long p) {
	if (p == 0) {
		return 1;
	}
	long long ans = fp(b, p / 2);
	if (p % 2 == 0) {
		return ans * ans;
	}
	else {
		return b * ans*ans;
	}

}
ll d, x, y;
void extendedEuclid(ll A, ll B) {
	if (B == 0) {
		d = A;
		x = 1;
		y = 0;
	}
	else {
		extendedEuclid(B, A%B);
		int temp = x;
		x = y;
		y = temp - (A / B)*y;
	}
}
ll modInverse(ll A, ll M)
{
	extendedEuclid(A, M);
	return (x%M + M) % M;
}
int main() {
	sieve();
	cin >> k;
	vector <ll>ans;
	set<ll>st;
	ll sum = 0;
	for (int i = 0; i < k; ++i) {
		cin >> arr[i];
		st.insert(arr[i]);
	}
	for (auto x : st) {
		primefactor(x);
	}
	for (int i = 0; i < 1000001; ++i) {
		if (count1[i] != 0) {
			ans.push_back(fp(i, count1[i]));
		}
	}
	ll lc = 1;
	for (int i = 0; i < ans.size(); ++i) {
		lc = ((lc%inf)*(ans[i] % inf)) % inf;
	}
	for (int i = 0; i < k; i++) {
		ll o1 = (lc*(modInverse(arr[i], inf) % inf)) % inf;
		sum = (sum%inf + o1) % inf;
	}
	cout << sum;
	return 0;

}

	

Measured memory_bytes: 11392
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  long long a,b;
  cin>>a>>b;
  long long g;
  g = gcd_(a,b);
  
  vector<int> primes;
  for(int i = 1; i<=100'000; i++){
    if(prime_(i)){
      primes.push_back(i);
    }
  }
  
  long long temp = g;
  int s = primes.size();
  int cnt[s] = {};
  int acnt = 0;
  for(int i = 0; i<s; i++){
    while(temp%(long long)primes[i] == 0){
      temp /= (long long)primes[i];
      cnt[i]++;
    }
  }
  if(temp != 1){
    acnt++;
    for(long long i = 100'000LL; i<=1000'000LL;i++){
      while(temp%i==0 && temp != i){
        temp /= i;
        acnt++;
      }
    }
  }
  
  int ans = 1;
  REP(i,s){
    if(cnt[i] != 0){
      ans++;
    }
  }
  ans += acnt;
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 384