akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
vector<int>v[100010];
int n,m,color[100010];
bool dfs(int x,int c){
	color[x]=c;
	for(int p:v[x]){
		if(color[p]==c)return false;
		if(color[p]==0&&!dfs(p,-c))return false;
	}
	return true;
}
bool is_bipartite(){
	rep(i,n){
		if(color[i]==0){
			if(!dfs(i,1)){
				return false;
			}
		}
	}
	return true;
}
signed main(){
	cin>>n>>m;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	if(is_bipartite()){
		int b=0,w=0;
		rep(i,n){
			if(color[i]==1)b++;
			else w++;
		}
		cout<<b*w-m<<endl;
	}
	else{
		cout<<n*(n-1)/2-m<<endl;
	}
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int x[n], y[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    

    int ans = 50;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            int p = x[i] - x[j];
            int q = y[i] - y[j];
            bool check[n];
            for (int k = 0; k < n; k++) check[k] = false;
            int cnt = 0;
            for (int k = 0; k < n; k++) {
                if (check[k]) continue;
                cnt++;
                check[k] = true;
                queue<int> que;
                que.push(k);
                while (que.size() > 0) {
                    int h = que.front();
                    que.pop();
                    for (int nh = 0; nh < n; nh++) {
                        if (check[nh]) continue;
                        if (x[nh] - x[h] == p && y[nh] - y[h] == q || x[h] - x[nh] == p && y[h] - y[nh] == q) {
                            check[nh] = true;
                            que.push(nh);
                        }
                    }
                }
            }
            ans = min(ans, cnt);
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,d,x; cin >> n >> d >> x;
    int A[n+1];
    for (int i=0; i<n; i++) cin >> A[i];
    int ans = x;
    
    for (int i=0; i<n; i++){
        int j=1;
        while (j<=d) {ans++; j += A[i];}
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: i32,
        a: i32,
        b:i32,
    }
    let mut ans = 0;

    for t in 1..=n {
        let mut i = t;
        let mut dsum = 0;
        while i > 0 {
            dsum += i % 10;
            i /= 10
        }
        if a <= dsum && dsum <= b {
            ans += t
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 2132
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;

    priority_queue<pair<int, int>> pq;
    for (int i = 0; i < A; i++) {
        int a; cin >> a;
        pq.push(make_pair(a, 0));
    }
    for (int i = 0; i < B; i++) {
        int a; cin >> a;
        pq.push(make_pair(a, 1));
    }
    for (int i = 0; i < C; i++) {
        int a; cin >> a;
        pq.push(make_pair(a, 2));
    }

    int x = 0, y = 0, sum = 0;
    long long ans = 0;
    while (sum < X+Y) {
        pair<int, int> p = pq.top();
        pq.pop();
        if (p.second == 0) {
            x++;
            if (x > X) continue;
        }
        if (p.second == 1) {
            y++;
            if (y > Y) continue;
        }
        ans += p.first;
        sum++;
        //cout << p.first << " " << x << " " << y << " " << sum << endl;
    }

    cout << ans << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    if(n<m)
    {
        for(i=0;i<m;i++)
        {
            cout<<n;
        }
    }
    else
    {
        for(i=0;i<n;i++)
        {
            cout<<m;
        }
    }
    return 0;
}



Measured memory_bytes: 3652
#include <iostream>

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    std::cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    std::cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  std::cout << std::endl;
}

int main()
{
    int n;
    std::cin >> n;
    
    call(n);
    
    return 0;
}


Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			long a = sc.nextLong();
			long b = sc.nextLong();

			// 出力(整数)
			System.out.println((a * (a - 1) / 2) + (b * (b - 1) / 2));
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}

Measured memory_bytes: 21716
//PRIME NUMBERS

#include<iostream>
#include<cmath>
using namespace std;

bool prime(long int num){
	
	if(num==2){return true;}

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

int main(){
	long int count=0, n, num;
	cin >> n;
	for(long int i=0; i<n; ++i){
		cin >> num;
		if(prime(num)){++count;}
	}

	cout << count << endl;

	return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define int long long
#define rint register int
using namespace std;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
int n;
vector<int> g[233333];

inline int dfs(int u, int fat) {
  int now = 0;
  for (int v : g[u])
    if (v != fat)
      now ^= 1 + dfs(v, u);
  return now;
}

main(void) {
  read(n);
  for (int i = 2; i <= n; i ++) {
    int x, y; read(x); read(y);
    g[x].push_back(y); g[y].push_back(x);
  }
  puts( dfs(1, 0) ? "Alice" : "Bob" );
}


Measured memory_bytes: 12288
#include<bits/stdc++.h>
using namespace std;
long long n,m,x[100005],v[100005],s[100005],r[100005],ans;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	cin>>x[i]>>v[i];
	for(int i=1;i<=n;i++)
	s[i]=s[i-1]+v[i];
	for(int i=n;i>=0;i--)
	r[i]=r[i+1]+v[i];
	for(int i=1;i<=n;i++)
	{
		s[i]=max(0LL,s[i]-x[i]);
		s[i]=max(s[i],s[i-1]);
	}
	for(int i=n;i;i--)
	{
		r[i]=max(0LL,(r[i]-m+x[i]));
		r[i]=max(r[i],r[i+1]);
	}
	for(int i=1;i<=n;i++)
	ans=max(ans,s[i]+max(0LL,r[i+1]-x[i]));
	for(int i=n;i;i--)
	ans=max(ans,r[i]+max(0LL,s[i-1]-(m-x[i])));
	cout<<ans;
	return 0;
}

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

using namespace std;

const int N = 1e3+7;

int k;
int n[3];
long long a[3][N];
map<int, int> vis;

struct Node
{
    int id[3];
    long long sum;
    Node(int i0, int i1, int i2, long long s) : sum(s) {
        id[0] = i0; id[1] = i1; id[2] = i2;
    }
    bool operator < (const Node &nex) const { return sum < nex.sum; }
};

priority_queue<Node> q;

inline int my_hash(Node &x)
{
    return x.id[0]*1000000+x.id[1]*1000+x.id[2];
}

int main()
{
    for (int i = 0; i < 3; ++i) cin >> n[i];
    cin >> k;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < n[i]; ++j)
            cin >> a[i][j];
        sort(a[i], a[i]+n[i]);
        reverse(a[i], a[i]+n[i]);
    }
    int cnt = 0;
    q.push(Node(0, 0, 0, a[0][0]+a[1][0]+a[2][0]));
    while (q.size() && cnt < k) {
        Node cur = q.top();
        q.pop();
        cout << cur.sum << endl;
        ++cnt;

        for (int i = 0; i < 3; ++i) {
            if (cur.id[i]+1 >= n[i]) continue;
            cur.sum -= a[i][cur.id[i]];
            ++cur.id[i];
            cur.sum += a[i][cur.id[i]];
            if (!vis.count(my_hash(cur))) {
                vis.insert({my_hash(cur), 1});
                q.push(cur);
            }
            cur.sum -= a[i][cur.id[i]];
            --cur.id[i];
            cur.sum += a[i][cur.id[i]];
        }
    }
    return 0;
}

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


multiset<int> ms;

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);
    string s;
    cin >> s;
    cout << s.substr(0, s.length() - 8);
    return 0;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, A, N);
    ll ans = INF;
    FOR(a, A)
    {
        ll k = 0;
        while (a % 2 == 0)
        {
            a /= 2;
            ++k;
        }
        CH(min, ans, k);
    }
    OUT(ans);
}


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

int main(void){
    string s;
    cin >> s;
    string t = s;
    reverse(s.begin(),s.end());

    int count = 0;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=t[i]) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#pragma region template 2.3
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, K);
    OUT(min(N % K, abs(K - N % K)));
}

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

int main(){
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  int cnt=1;
  int cntmax=1;
  int temp=1;
  int flag=0;
  queue<int>Q;
  if(S.at(0)=='0'){
    flag=0;
    K--;
  }
  else {
    flag=1;
  }

  for(int i=1;i<N;i++){
    //cout<<"flag"<<flag<<"temp"<<temp<<"cnt"<<cnt<<endl;
    if(flag==0 && S.at(i)=='0'){
      cnt++;
      temp++;
      cntmax=max(cntmax,cnt);
       continue;
    }
    if(flag==0 && S.at(i)=='1'){
      Q.push(temp);
      flag=1;
      cnt++;
      temp=1;
      cntmax=max(cntmax,cnt);
      continue;
    }
    
    if(flag==1 && S.at(i)=='1'){
      cnt++;
      temp++;
      cntmax=max(cntmax,cnt);
       continue;
    }    
    if(flag==1 && S.at(i)=='0'){
      K--;
      flag=0;
      if(K<0){
        cnt-=Q.front();
        Q.pop();
      }
      cnt++;  
      temp++;
      cntmax=max(cntmax,cnt);
    }
  }
  
  cout<<cntmax<<endl;
  
  return 0;
}


Measured memory_bytes: 3784
#define ffor(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--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

	int X;
	cin >> X;

	//t秒後の和がXを越えれば良い.
	int t=0;
	while(t<X){
		t++;
		if((t*(t+1))/2 >= X) break;
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int w = sc.nextInt();
        int h = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if(x-r < 0 || x+r > w){
            System.out.println("No");
        }else{
            if(y-r < 0 || y+r > h){
                System.out.println("No");
            }else{
                System.out.println("Yes");
            }
        }
    }
}


Measured memory_bytes: 26408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int k;
    cin >> k;
    priority_queue<ll, vector<ll>, greater<ll>> que;
    for(int i = 1; i < 10; ++i) que.push(i);
    while(k > 0){
        ll x = que.top();
        que.pop();
        if(--k == 0){
            cout << x << endl;
            return 0;
        }
        int d = x % 10;
        x *= 10;
        for(int i = max(0, d - 1); i <= min(9, d + 1); ++i){
            que.push(x + i);
        }
    }
}

Measured memory_bytes: 5296
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int N;  cin >> N;
  vector<double> v(N);
  REP(i, N) cin >> v[i];
  sort(ALL(v));
  double ans = v[0];
  REPS(i, N-1) ans = (ans + v[i]) / 2.0;
  printf("%.10lf\n", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
using namespace std;
typedef pair< double , int > P;
typedef pair< int , P > Pii;
#define reps(i,b,n) for(int i = b ; i < n ; ++i )
#define rep(i,n) reps(i,0,n)
#define INF 10000000
#define fr first
#define sc second
#define EPS (1e-10)
double getdis(int x1,int y1,int x2,int y2){return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));}

int n,s,g;
double d[5001],dis;
int prev[5001];
struct edge{
  int to;
  double cost;
  edge(){}
  edge(int to,double cost):to(to),cost(cost){};
};
vector< vector< edge > > info;
vector<int> dijkstra(){
  vector<int> ans;
  fill_n(d,5001,INF),fill_n(prev,5001,-1);
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(0.0,s));
  d[s] = 0.0;
  while(!que.empty()){
    P p = que.top();
    que.pop();
    double dis = p.fr;
    int now = p.sc;
    if(now == g){
      ans.push_back(g);
      int furuwara = g;
      while(furuwara != s){
        furuwara = prev[furuwara];
        ans.push_back(furuwara);
      }
      break;
    }
    rep(i,info[now].size()){
      edge e = info[now][i];
      if(d[now] + e.cost < d[e.to]){
        d[e.to] = d[now] + e.cost;
        que.push(P(d[e.to],e.to));
        prev[e.to] = now;
      }
    }
  }
  return ans;
}
int main(){
  while(cin >> n , n){
    int id[n],x[n],y[n],m;
    rep(i,n) cin >> id[i] >> x[i] >> y[i];
    info.resize(n + 1);
    rep(i,n) rep(j,n){
      if((dis = getdis(x[i],y[i],x[j],y[j])) <= 50.0){
        info[id[i]].push_back(edge(id[j],dis));
      }
    }
    cin >> m;
    while(m--){
      cin >> s >> g;
      vector<int> ans = dijkstra();
      if(ans.empty()) cout << "NA";
      else rep(i,ans.size()) cout << ( i ? " " : "" ) << ans[ans.size()-1-i];
      cout << endl;
    }
    info.clear();
  }
}

Measured memory_bytes: 1292
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t,n,a[1000];
	cin>>n>>t;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int sum =0;
	sort(a,a+n);
	for(int i=0;i<t;i++){
		sum+=a[i];
	}
	
	cout<<sum<<"\n";

}

Measured memory_bytes: 3640
def main():
    list_length = int(input())
    num_list = list(map(int, input().split(" ")))
    answer = -float("inf")
    for i in range(list_length):
        for j in range(i, list_length):
            answer = max(answer, abs(num_list[i] - num_list[j]))
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0;i < N;i++)cin >> A[i];
    ll cnt = 1,sub = 1;
    for(int i = 0;i < N;i++){
        if(A[i] & 1){
            cnt *= 3;
        }else{
            cnt *= 3;
            sub *= 2;
        }
    }
    cout << cnt - sub << endl;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize
    }
    let m : i64 = 1000000007;
    let mut p10 = 1;
    let mut p9 = 1;
    let mut p8 = 1;
    for _ in 0..n {
        p10 = 10 * p10 % m;
        p9 = 9 * p9 % m;
        p8 = 8 * p8 % m;
    }
    println!("{}", (p10 + 2*(m-p9) + p8)%m);
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
vector<int> graph[NUM];
bool visited[NUM];
int comp = 0;
void dfs(int node){
    visited[node] = 1;
    comp++;
    for(auto x:graph[node])
        if(!visited[x])
            dfs(x);
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n,m; cin >> n >> m;
        map<pair<int,int>,bool> mapit;
        FOR(i,0,m){
            int x,y; cin >> x >> y;
            if(mapit[{x,y}] or mapit[{y,x}]) continue;
            graph[x].pb(y);
            graph[y].pb(x);
            mapit[{x,y}] = 1;
            mapit[{y,x}] = 1;
        }
        int groups = 0;
        FOR(i,1,n+1){
            if(!visited[i]){
                comp = 0;
                dfs(i);
                groups = max(groups,comp);
            }
        }
        cout << groups ;
    }    
}

Measured memory_bytes: 45992
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e10;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    Yes(s == t.substr(0,s.length()));
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    long long s[n];
    cin>>s[0];
    for(int i=0;i<n-1;i++){
        long long t;
        cin>>t;
        s[i+1]=s[i]+t;
    }
    sort(s,s+n);
  //for (int i=0;i<n;i++) cout<<s[i]<<" ";
 // cout<<endl;
    long long ans=0;
    long long tmp=1;
    long long prev=s[0];
    
    for (int i=1;i<n;i++){
       //out<<s[i]<<endl;
        if (s[i]==prev){
            tmp++;
        }else{
           //cout<<"add"<<tmp<<endl;
            prev=s[i];
            ans+=tmp*(tmp-1)/2;
            tmp=1;
           
        }
    }
    ans+=tmp*(tmp-1)/2;
    for (int i=0;i<n;i++){
        if (s[i]==0)ans++;}

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

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{     int c=0;
      string s,t;
      cin>>s>>t;
      for (int i = 0 ; i < s.size() ; i++)
{
if (s[i] != t[i])
    {
    c++;

    }

}
  if (c>=1)
    {
        cout<<"No";
    }
    else{


        cout<<"Yes";
    }

    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
using namespace std;
int n, a[200010], b[200010], ans;

bool check(int x) {
	for(int i = 1; i < 2 * n; i++)
		if(a[i] >= x) b[i] = 1;
			else b[i] = 0;
	for(int i = 1; i < n; i++) {
		if(!(b[n + i] ^ b[n + i - 1])) return b[n + i];
		if(!(b[n - i] ^ b[n - i + 1])) return b[n - i];
	}
	return b[1];
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i < 2 * n; i++) scanf("%d", &a[i]);
	int l = 1, r = 2 * n;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(check(mid)) l = mid + 1, ans = mid;
			else r = mid - 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1920
#pragma GCC optimize ("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>

using namespace std;
using Int = long long; using uint = unsigned int; using uInt = unsigned long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 998244353;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rer(i,l,r) for(int i=(l); i<=(r); ++i)
#define gnr(i,l,r) for(int i=(r); i>=(l); --i)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
#define priend(a) {cout<<(a)<<'\n'; return 0;}
#define fil(a,v) memset((a),v,sizeof(a))
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

template<class T>
struct BIT{
  V(T)data;
  int n;

  BIT(int size){
    n=size+1;
    data.assign(n,0);
  }

  T sum(int k){
    T res=0;
    for(++k; k>0; k-=k&-k)res+=data[k];
    return res;
  }

  void add(int i,int x){
    for(++i; i<n; i+=i&-i)data[i]+=x;
  }
};

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  cin>>n>>m; int a[n]; V(Int)sum(n+1),b; sum[0]=0;
  rep(i,n){cin>>x; a[i]=x-m; sum[i+1]=sum[i]+a[i];} b=sum;
  sort(ALL(b)); b.erase(unique(ALL(b)),b.end());
  unordered_map<Int,int>p;
  rep(i,b.size())p[b[i]]=i;
  BIT<int> bi(n+1);
  rep(i,n+1)bi.add(p[sum[i]],1);
  Int ans=0;
  rep(i,n+1){
    bi.add(p[sum[i]],-1);
    ans+=n-i-bi.sum(p[sum[i]]-1);
  }
  END
}

Measured memory_bytes: 13256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

ll binary_pow(ll a, ll N) {
  ll ans = 1;
  ll tmp = a;
  while(N > 0) {
    if(N % 2 == 1) {
      ans *= tmp;
      ans %= mod;
    }
    N /= 2;
    tmp *= tmp;
    tmp %= mod;
  }
  return ans;
}
ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}

int main() {
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  map<pair<ll, ll>, ll> mp;
  ll cnt00 = 0, cntA0 = 0, cnt0B = 0;
  rep(i, N) {
    cin >> A[i] >> B[i];
    if(A[i] == 0 && B[i] == 0) {
      cnt00++;
    } else if(B[i] == 0) {
      cntA0++;
    } else if(A[i] == 0) {
      cnt0B++;
    } else {
      ll G = gcd(abs(A[i]), abs(B[i]));
      if(A[i] < 0 && B[i] < 0) mp[make_pair(-A[i]/G, -B[i]/G)]++;
      else if(A[i] < 0)        mp[make_pair(A[i]/G, B[i]/G)]++;
      else if(B[i] < 0)        mp[make_pair(-A[i]/G, -B[i]/G)]++;
      else                     mp[make_pair(A[i]/G, B[i]/G)]++;
    }
  }
  set<pair<ll, ll>> done;
  ll ans = 1;
  if(cntA0 && cnt0B) {
    (ans *= (binary_pow(2, cntA0) + binary_pow(2, cnt0B) - 1 + mod) % mod) %= mod;
  } else if(cntA0) {
    (ans *= binary_pow(2, cntA0)) %= mod;
  } else if(cnt0B) {
    (ans *= binary_pow(2, cnt0B)) %= mod;
  }
  for(auto m: mp) {
    auto val = m.first;
    pair<ll, ll> val2;
    if(val.first < 0) val2 = make_pair(val.second, -val.first);
    else              val2 = make_pair(-val.second, val.first);
    if(done.count(val2)) continue;
    if(mp.count(val2)) {
      (ans *= (binary_pow(2, m.second) + binary_pow(2, mp[val2]) - 1 + mod) % mod) %= mod;
    } else {
      (ans *= binary_pow(2, m.second)) %= mod;
    }
    done.insert(val);
  }
  cout << (ans+mod-1+cnt00)%mod << endl;
  return 0;
}


Measured memory_bytes: 31508
#include<queue>
#include<cstdio>

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

using namespace std;

const int INF=1<<29;

struct edge{ int v,cost; };

struct state{
	int u1,u2,vis;
	state(int u1,int u2,int vis):u1(u1),u2(u2),vis(vis){}
	bool operator<(const state &S)const{ return true; } // dummy
};

int main(){
	for(int n,m;scanf("%d%d",&n,&m),n;){
		int fee[50],h[50];
		fee[0]=fee[n-1]=h[0]=0;
		h[n-1]=1000;
		for(int i=1;i<n-1;i++) scanf("%d%d",fee+i,h+i);

		vector<edge> G[50],R[50]; // グラフ, 逆グラフ
		rep(i,m){
			int u,v,cost; scanf("%d%d%d",&u,&v,&cost); u--; v--;
			G[u].push_back((edge){v,cost});
			R[v].push_back((edge){u,cost});
		}

		int W[50]; // W[u] := ( 高さ h[u] の町の中で u は何番目か )
		int h_cnt[1001]={};
		rep(u,n) W[u]=h_cnt[h[u]]++;

		// d[u1][u2][S] := 行きのパスで u1 にいて, 帰りのパスで u2 にいて,
		//                 u1 と u2 の低いほうの町を v とすると, v と同じ高さにあるすでに訪れた町の集合が S である状態へ達するための最小コスト
		static int d[50][50][1024];
		rep(u1,n) rep(u2,n) rep(S,1024) d[u1][u2][S]=INF;
		d[0][0][1<<W[0]]=0;
		priority_queue< pair<int,state> > Q;
		Q.push(make_pair(0,state(0,0,1<<W[0])));
		while(!Q.empty()){
			int d_now=-Q.top().first,u1=Q.top().second.u1,u2=Q.top().second.u2,vis=Q.top().second.vis; Q.pop();

			if(d[u1][u2][vis]<d_now) continue;

			if(h[u1]<=h[u2]){ // 行きを進める
				rep(i,G[u1].size()){
					int v=G[u1][i].v,cost=G[u1][i].cost;
					if(h[u1]>h[v]) continue;

					int vis_next;
					if(h[v]<h[u2]){
						vis_next=1<<W[v];
						if(h[v]==h[u1]) vis_next|=vis;
					}
					else if(h[v]==h[u2]){
						vis_next=1<<W[v]|1<<W[u2];
						if(h[v]==h[u1]) vis_next|=vis;
					}
					else{ // h[v]>h[u2]
						vis_next=1<<W[u2];
						if(h[u1]==h[u2]) vis_next|=vis;
					}

					int d_next=d_now+cost;
					if(!(h[v]==h[u1] && vis>>W[v]&1) && v!=u2) d_next+=fee[v];

					if(d[v][u2][vis_next]>d_next){
						d[v][u2][vis_next]=d_next;
						Q.push(make_pair(-d_next,state(v,u2,vis_next)));
					}
				}
			}
			else{ // 帰りを進める
				rep(i,R[u2].size()){
					int v=R[u2][i].v,cost=R[u2][i].cost;
					if(h[u2]>h[v]) continue;

					int vis_next;
					if(h[v]<h[u1]){
						vis_next=1<<W[v];
						if(h[v]==h[u2]) vis_next|=vis;
					}
					else if(h[v]==h[u1]){
						vis_next=1<<W[v]|1<<W[u1];
						if(h[v]==h[u2]) vis_next|=vis;
					}
					else{ // h[v]>h[u1]
						vis_next=1<<W[u1];
						if(h[u2]==h[u1]) vis_next|=vis;
					}

					int d_next=d_now+cost;
					if(!(h[v]==h[u2] && vis>>W[v]&1) && v!=u1) d_next+=fee[v];

					if(d[u1][v][vis_next]>d_next){
						d[u1][v][vis_next]=d_next;
						Q.push(make_pair(-d_next,state(u1,v,vis_next)));
					}
				}
			}
		}

		int ans=INF;
		rep(S,1024) ans=min(ans,d[n-1][n-1][S]);
		printf("%d\n",ans<INF?ans:-1);
	}

	return 0;
}

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

long long dp[105][100005];//品物がiまでで重さがj以下の価値の最大値
//dp[i+1][j]=max(dp[i][j], dp[i][j-weight[i]]+value[i])
//

int main(){
  int n,w;
  long long weight[101], value[101];
  cin >> n >> w;
  for(int i=0;i<n;i++)cin >> weight[i] >> value[i];
  
  // for(int i=0;i<n;i++){
  //   for(int j=0;j<=w;j++){
  //     if(j<weight[i])dp[i+1][j]=dp[i][j];
  //     else dp[i+1][j]=max(dp[i][j], dp[i][j-weight[i]]+value[i]);
  //   }
  // }

  for(int j=0;j<=w;j++){
    for(int i=0;i<n;i++){
      if(j<weight[i])dp[i+1][j]=dp[i][j];
      else dp[i+1][j]=max(dp[i][j], dp[i][j-weight[i]]+value[i]);
    }
  }

  // for(int i=0;i<=n;i++){
  //   for(int j=0;j<=w;j++){
  //     printf("%3d", dp[i][j]);
  //   }
  //   cout << endl;
  // }

  cout << dp[n][w] << endl;


  return 0;
}

Measured memory_bytes: 79360
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var N = input[0];
        var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var days = N - A.Sum();

        Console.WriteLine(days >= 0 ? days : -1);
    }
}


Measured memory_bytes: 29108
using System;

namespace abc164A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            if (A > B)
                Console.WriteLine("safe");
            else
                Console.WriteLine("unsafe");
        }
    }
}


Measured memory_bytes: 27420
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){

	int a,b,d,r;
	double f;
	

	cin >> a >> b;

	d = a / b;
	r = a%b;
	f = (double) a / b;

	

	cout << d <<" "<< r <<" ";
	printf("%.8lf\n", f);



	return 0;
}

Measured memory_bytes: 1240
from collections import deque

n=int(input())
a = []

for i in range(n):
    a.append(int(input()))

a.sort()

a=deque(a)

mid = a[(n-1)//2]
midi = abs(a[(n-1)//2-1] - mid)
mida = abs(a[(n-1)//2+1] - mid)

rev = False
omi = a[0]
oma = a[-1]

ans = abs(oma - omi)
for i in range(len(a)//2):
    mi = a.popleft()
    ma = a.pop()

    if rev:
        q = mi
        mi = ma
        ma = q

    ans+=abs(mi - omi)+abs(ma - oma)

    omi = mi
    oma = ma
    rev = not rev

if len(a)==1:
    ans+=max(midi,mida)

print(ans)

Measured memory_bytes: 8244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
const int maxn=20;
const int inf=1e9+7;
const int mod=1e9+7;
int a[maxn];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(n<m) swap(n,m);
    int s=m;
    for(int i=1;i<n;i++)
        s=s*10+m;
    printf("%d\n",s);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
#define pb(x) push_back(x);
typedef long long  int ll;
ll mod = 998244353;
ll hmaxii=0;
vector<ll>values[2*100000+1];
ll MAXN = 2*100000+1;
ll spf[2*100000+1];
//vector<ll>values[];
ll diff,x,y,z;
ll flag=1;ll price[1001][1001];

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }



void solution(){
    ll n;
    //cin>>n;
    ll ans=0;
    string ss;
    cin>>ss;
    n=ss.length();
    ll right[n+1];
    int temp=0;
    ll left[n+1];
    left[0]=0;
    for(int i=0;i<n;i++){
        if(ss[i]=='<'){
            temp++;
        }
        else{
            temp=0;
        }
        left[i+1]=temp;
    }
    right[n]=0;temp=0;
    for(int i=n-1;i>=0;i--){
        if(ss[i]=='>'){
            temp++;
        }
        else{
            temp=0;
        }
        right[i]=temp;
    }
    for(int i=0;i<=n;i++){
        ans+=max(right[i],left[i]);
    }
    cout<<ans<<endl;
}


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //sieve();
    /*ll powe[64];
    powe[0]=1;
    ll i=1;
    while(i<64){
        powe[i] = powe[i-1]*2;
        i++;
    }*/
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solution();
    }
    return 0;
}


Measured memory_bytes: 14620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, sum = 0;
	cin >> n;
	int x = n;
	while (x > 0) {
		sum += x % 10;
		x /= 10;
	}
	if (n%sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
# coding: utf-8


def bpow(x, y, z):
    a = 1
    for b in format(y, 'b'):
        a = (a*a) % z
        if b == '1':
            a = (a*x) % z
    return a


def solve(*args: str) -> str:
    n, m, k = map(int, args[0].split())
    mod = 998244353

    if m == 1 and n-1 == k:
        return str(1)

    ncr = 1
    p = m*bpow(m-1, n-1, mod) % mod
    ret = p
    inv = bpow(m-1, mod-2, mod)
    for i in range(1, k+1):
        ncr = (ncr * (n-i)*bpow(i, mod-2, mod)) % mod
        p = (p*inv) % mod
        ret += p*ncr % mod

    return str(ret % mod)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 9240
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N, W = map(int, input().split())
    value, weight = [0] * N, [0] * N
    for i in range(N):
        value[i],weight[i] = map(int, input().split())


    # この前段階で、荷物の数N、ウェイトの上限W、
    # weightの表weightとvalueの表valueは用意しておく。
    def knapsack(N, W, weight, value):
        dp = [[0] * (W + 1) for _ in range(N + 1)]

        for i in range(N):
            for w in range(W + 1):
                if w >= weight[i]:  # 荷物が加わる可能性がある
                    # max関数の第一引数だと、既存の荷物の方がましな場合。
                    # 第二引数だと、新入りを加えた方が良い場合。
                    dp[i + 1][w] = max(dp[i][w], dp[i][w - weight[i]] + value[i])
                else:  # 加わる可能性はない
                    dp[i + 1][w] = dp[i][w]

        return dp[N][W]

    print(knapsack(N, W, weight, value))



resolve()


Measured memory_bytes: 25500
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int N;
	cin >> N;
	N--;
	cout << A[N] << endl;

	return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
const int nmax=100005;
vector<vector<int>> ad(nmax);
vector<bool> vis(nmax);
vector<int> q(nmax),par(nmax);
int m;
void dfs(int s){
  stack<int> st;
  st.push(s);
  vis[s]=true;
  q[s]=m-1;
  while(!st.empty()){
    int p=st.top();
    st.pop();
    int cnt=0;
    for(int i=0;i<ad[p].size();i++){
      if(!vis[ad[p][i]]){
        cnt++;
        q[ad[p][i]]=(q[p]+cnt)%m;
        par[ad[p][i]]=p;
        vis[ad[p][i]]=true;
        st.push(ad[p][i]);
      }
    }
  }
}
int main(){
  int n;cin >> n;
  vector<int> a(n-1),b(n-1),c(n);
  for(int i=0;i<n-1;i++){
    cin >> a[i] >> b[i];
    a[i]--,b[i]--;
    ad[a[i]].push_back(b[i]);
    ad[b[i]].push_back(a[i]);
    c[a[i]]++;
    c[b[i]]++;
  }
  m=0;
  int t;
  for(int i=0;i<n;i++){
    if(m<c[i]){
      m=c[i];
      t=i;
    }
  }
  cout << m << endl;
  dfs(t);
  for(int i=0;i<n-1;i++){
    if(par[a[i]]==b[i]){
      cout << q[a[i]]+1 << endl;
    }
    else{
      cout << q[b[i]]+1 << endl;
    }
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n,u,v;
    cin>>n>>u>>v;
    VV g(n);
    u--;
    v--;
    rep(i,n-1){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    Vec par(n,-1);
    queue<Pi> q;
    q.push(mp(v,0));

    Vec distv(n,0);
    //vからの距離求める

    //uにげる
    //vおう

    while(!q.empty()){
        Pi &now = q.front();
        q.pop();
        Each(next,g[now.fi]){
            if(next==v)continue;
            if(distv[next]!=0)continue;
            distv[next] = now.se+1;
            par[next] = now.fi;
            q.push(mp(next,now.se+1));
        }
    }

    Vec distu(n,0);
    q.push(mp(u,0));

    while(!q.empty()){
        Pi &now = q.front();
        q.pop();
        Each(next,g[now.fi]){
            if(next==u)continue;
            if(distu[next]!=0)continue;
            distu[next] = now.se+1;
            q.push(mp(next,now.se+1));
        }
    }

    ll ans=0;
    //はじっこはダメ
    //parにないとダメ

    sort(ALL(par));
    rep(i,n){
        if(distv[i]>distu[i]){
           chmax(ans,distv[i]);
        }
    }



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


Measured memory_bytes: 8832
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


void ReadInput(long *input)
{
    //printf("Enter the money which you want to get: \n");
    scanf("%ld", input);
}

void CountYears(long * input)
{
    long basicMoney = 100;
    int years = 0;
    
    while(basicMoney < *input)
    {
        years++;
        basicMoney *= 1.01;
        
    }
    
    printf("%d \n", years);
    
}

int main(int argc, const char * argv[])
{
    long  *input = malloc(32 * sizeof(long));
    ReadInput(input);
    CountYears(input);
    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,d,x,day;
    cin>>n>>d>>x;

    int count=n;

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

    for (int i=0;i<n;i++) {
        for (int j=1;j<=100;j++) {
            day=j*a[i]+1;
            if(day>d){
                break;
            }
            count++;
        }
    }
   cout<<x+count<<endl;
}

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

using namespace std;
#define li long long int
#define FOR(i, a, b) for (int i = a ; i < b ; ++i)
#define REP(i, n) for (int i = 0 ; i < n ; ++i)

// ユークリッドの互除法
li gcd(li a,li b) {
    return a % b == 0 ? b : gcd(b, a % b);
}

// 素数判定
bool isPrime(li n) {
    for(li i = 0; i * i < n ; i++) {
        if (n % i == 0) return false;
    }
    return n != 1; // 1は例外
}

// 素因数分解
map<li, li> prime_factor(li n) {
    map<li, li> res;
    FOR(i, 0, sqrt(n)) {
        while(n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}
 
int main(void) {
    li T, X;
    cin >> T >> X;

    double t = double(T) / double(X);    
    cout << t << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <tuple>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
const long long INF = 1LL<<60; //仮想的な無限大の値


int main(){
	int N,K;
	cin >> N >> K;
	int x = 1;
	rep(i,N){
		if(x >= K) x += K;
		else x*= 2;
	}
	cout << x << endl;
}

Measured memory_bytes: 256