akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vector<vi> a(2, vi(n)), dp(2, vi(n));
	
	rep(i, 2) rep(j, n) cin >> a[i][j];
	dp[0][0] = a[0][0];
	//dbg(a);
	
	rep(i, 2) rep(j, n){
		if(i == 0) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i + 1][j]);
		if(j + 1 < n) dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + a[i][j + 1]);
	}
	cout << dp[1][n - 1] << endl;
	return 0;
}

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

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

int main(){
  int n;cin >> n;
  vector<ll> t(n);
  for(int i=0;i<n;i++)cin >> t[i];
  
  ll lcm=t[0];
  for(int i=1;i<n;i++){
    lcm = lcm/gcd(lcm,t[i])*t[i];
  }
  cout << lcm << endl;
} 

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

namespace myApp
{
    public class Reader
    {
        //
        public int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        //
        public int[] IntArray(char separator = ' ')
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Reader reader = new Reader();

            int[] abc = reader.IntArray();

            Console.WriteLine((abc[0] * abc[1]) / 2);
        }
    }
}


Measured memory_bytes: 13268
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    elif A[i]+A[i+1] > B[i]:
        ans += B[i]
        A[i+1] = A[i]+A[i+1] -B[i]
    else: #B[i]が大きいとき，A[i+1]を消費済みにする
        ans += A[i]+A[i+1]
        A[i+1] = 0
print(ans)

Measured memory_bytes: 18624
// ALDS_1_3_A.cpp
// Stack

#include <iostream>
#include <sstream>
#include <string>
#include <stack>
using namespace std;

int main()
{
    string str;
    stack<int> nums;
    while (cin >> str) {
        if (str[0] == '+') {
            int a = nums.top();
            nums.pop();
            int b = nums.top();
            nums.pop();
            nums.push(a + b);
        }
        else if (str[0] == '-') {
            int a = nums.top();
            nums.pop();
            int b = nums.top();
            nums.pop();
            nums.push(b - a);
        }
        else if (str[0] == '*') {
            int a = nums.top();
            nums.pop();
            int b = nums.top();
            nums.pop();
            nums.push(a * b);
        }
        else {
            int num;
            stringstream ss(str);
            ss >> num;
            nums.push(num);
        }
    }
    int res = nums.top();
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
long long n;
long long dp[26000000];
long long a[4],b[4];
long long m;
vector<int> ok;
void GoDP(long long ar1[4],long long ar2[4]){
	m=0;
	ok.clear();
	if(ar1[1]<ar2[1]) ok.push_back(1);
	if(ar1[2]<ar2[2]) ok.push_back(2);
	if(ar1[3]<ar2[3]) ok.push_back(3);
	for(int i=0;i<=n;i++) dp[i]=-1;
	dp[n]=0;
	for(int i=n;i>=1;i--){
		if(dp[i]==-1) continue;
		for(int j=0;j<ok.size();j++)
			if(i>=ar1[ok[j]])
				dp[i-ar1[ok[j]]]=max(dp[i-ar1[ok[j]]],dp[i]+ar2[ok[j]]);
		m=max(m,dp[i]+i);
	}
	m=max(m,dp[0]);
}
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=3;i++) cin>>a[i];
	for(int i=1;i<=3;i++) cin>>b[i];
	GoDP(a,b);
	n=m;
	GoDP(b,a);
	cout<<m<<endl;
	return 0;
}


Measured memory_bytes: 196864
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		//入力表示
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int C = scanner.nextInt();
		
		//3つの数字が同じ場合と３つの数字が違う場合Noと表示
		if (A == B && B == C && C ==A || A != B && B != C && C != A) { 
		System.out.println("No"); 
			} 
		else { 
		System.out.println("Yes"); 
		}

		scanner.close();
	}
}

Measured memory_bytes: 22996
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
using namespace std;
const int MOD = 1000000007;
const long long INF = 1000000000000000000;
typedef pair<int, int> P;
int main(){
	long long x, y;
	cin >> x >> y;
	if (x%y == 0) {
		cout << -1 << endl;
	}
	else{
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# WA

N, K = map(int, input().split())
S = list(input())

START = S[0]
prev = S[0]
ans = 0
for i in range(1, N):
    s = S[i]

    # 一緒だったら+1
    if prev == s:
        ans += 1

    # 最後の時だけ場合わけ
    if i == N - 1:
        if s == START and K > 0:
            if prev != s:
                ans += 2
        else:
            if K > 0:
                ans += 1

    # 最後以外
    else:
        # 前と異なる
        if prev != s:
            if s == START and K > 0:
                ans += 2
                K -= 1

            prev = s


print(ans)


Measured memory_bytes: 4084
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var a = int.Parse(ss[0]);
            var b = int.Parse(ss[1]);

            Console.WriteLine(Math.Ceiling((a + b) / 2.0));
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd              double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vll             vector<long long>
#define vdd             vector<double>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long,long long>>
#define vvi             vector<vector<int>>
#define vvl             vector<vector<long long>>
#define mii             map<int,int>
#define mll             map<long long,long long>
#define umii            unordered_map<int,int>
#define umll            unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep2(i,a,b)     for(int i=a;i<b;i++)
#define rev(i,n)        for(int i=n;i>=0;i--)
#define rev2(i,a,b)     for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fio             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
#define all(x)          x.begin(),x.end()
#define d0(x)           cout <<x<<" "
#define d1(x)           cout <<x<<endl
#define d2(x,y)         cout <<x<<" "<<y<<endl
#define d3(x,y,z)       cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)     cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define read2(x,y)      cin>>x>>y
#define read3(x,y,z)    cin>>x>>y>>z
#define read4(x,y,z,w)  cin>>x>>y>>z>>w
#define read5(x,y,z,w,a)cin>>x>>y>>z>>w>>a
#define sz(a)           (int)a.size()
const ll mod=1e9+7;
const double PI = 3.14159265359;
const ll MOD=998244353;
void i_o()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
}

ll mod_exp(ll a,ll ex){
   ll ans=1;
  //  if(ex==1) return a%MOD;
    if(ex==0) return 1;
   if(ex%2){
      ans*=a;
      ex--;
   }
   ans%=MOD;
   ll mul=mod_exp(a,ex/2);
   mul*=mul;
   mul%=MOD;
   ans=ans*mul;
   ans%=MOD;
   return ans;
}

int main() {
   fio
  // i_o();
   ll n,m,k;
   cin>>n>>m>>k;
   // d1("ok");
   vll m1(n+1,1);
   ll ini=1;
   for(ll i=1;i<=n;i++){
      ini*=(m-1);
      ini%=MOD;
      m1[i]=ini;
   }
   vll fac(n+1,1);
   ini=1;
   for(ll i=1;i<=n;i++){
      ini*=i;
      ini%=MOD;
      fac[i]=ini;
   }
   ll ans=0;
   for(ll i=n-k;i<=n;i++){
      ll ncr= fac[n-1]*(mod_exp(fac[i-1],MOD-2));
      ncr%=MOD;
     // d1(ncr);
      ncr*=mod_exp(fac[n-i],MOD-2);
      ncr%=MOD;
      ncr*=m;
      ncr%=MOD;
      ncr*=m1[i-1];
      ncr%=MOD;
      ans+=ncr;
      ans%=MOD;
   }
   d1(ans);
    return 0;
}



Measured memory_bytes: 6364
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n=sc.nextInt(),k=sc.nextInt();

        long ans=k;
        for(int i=1;i<n;i++){
            ans *= k-1;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    private static final PrintStream ps = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        char[] a = sc.next().toCharArray();
        
        int w = 0;
        int e = 0;
        for (int i = n-1; i >= 0; i--) {
            if (a[i] == 'W')
                w++;
            else
                e++;
        }
        int sum = e - (a[0] == 'E' ? 1 : 0);
        int min = sum;
        
        for (int i = 1; i < n; i++) {
            if (a[i-1] == 'W')
                sum ++;
            if (a[i] == 'E')
                sum--;
            min = Math.min(sum, min);
        }
        ps.println(min);
    }
}


Measured memory_bytes: 28124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
struct ConvexHullTrick{
	pair<long,long> Point[201000];
    int p;
    ConvexHullTrick(): p(0){}
    //aは単調増加でないといけない
    void Add(long a,long b){
        while(p >= 2 && !Need(Point[p-2],Point[p-1],{a,b})){
            p--;
        }
		Point[p] = {a,b};
        p++;
    }
    //1つはAddしていないといけない
    long Query(long x){
        return Calc(x,findMax(x));
    }
	//最初のクエリの前にpを減らす必要がある
	void Start(){
		p--;
	}
	//2分探索で探索
    int findMax(long x){
        int bf = 0;
        int bl = p-1;
        while(bf != bl){
            int bc = (bf+bl)/2;
            if(bc == p || Calc(x,bc) >= Calc(x,bc+1)){
                bl = bc;
            }
            else{
                bf = bc+1;
            }
        }
        return bf;
    }
    long Calc(long x,int i){
        return Point[i].first*x + Point[i].second;
    }
	//p1,p2,p3があるときp2は必要か
	bool Need(pair<long,long> p1,pair<long,long> p2,pair<long,long> p3){
        return (p2.first-p1.first)*(p2.second-p3.second) > (p3.first-p2.first)*(p1.second-p2.second);
    }
	void Free(){
		p = 0;
	}
};
long H[200000];
void Calc(){
	int N = rei();
	long C = rel();
	for(int i=0;i<N;i++){
		H[i] = rei();
	}
	ConvexHullTrick CHT;
	CHT.Add(2*H[0],-H[0]*H[0]-C);
	for(int i=1;i<N-1;i++){
		long t = H[i]*H[i]-CHT.Query(H[i]);
		CHT.Add(2*H[i],-t-C-H[i]*H[i]);
	}
	long ans = H[N-1]*H[N-1]-CHT.Query(H[N-1]);
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);

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

    for (int i = 0; i <= dia; ++i) {
        int k = max(i, dia - i);

        if (cnt[k] == 0) {
            cout << "Impossible" << endl;
            return 0;
        } else {
            cnt[k]--;
        }
    }

    for (int i = 1; i < dia; ++i) {
        int k = max(i, dia - i);

        cnt[k + 1] = 0;
    }

    for (int i = 0; i < cnt.size(); ++i) {
        if (cnt[i] > 0) {
            cout << "Impossible" << endl;
            return 0;
        }
    }

    cout << "Possible" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
 long long int a;
    
  cin >> a;
  
  for(int i=0;i<100000;i++){
    
    if(i*(i+1) >=2*a){
      
      cout << i << 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 n = sc.nextInt();
		// 文字列の入力
		String s = sc.next();
		String org = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		String con;
		String t = "";
		if ( n == 0 || n == 26 ) {
			// 出力
			System.out.println(s);
		} else {
			con = org.substring(n);
			con = con.concat(org.substring(0,n));
		// 
			for ( int i = 0 ; i < s.length() ; i++ ) {
				String c = String.valueOf(s.charAt(i));
				int ps = org.indexOf(c);
				t = t.concat(String.valueOf(con.charAt(ps)));
			}
			// 出力
			System.out.println(t);
		}
	}
}



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

class abc125_B
{
    static void Main(string[] args)
    {
        var QN = readInt();
        var QVs = readInts();
        var QCs = readInts();

        var result = QVs.Zip(QCs, (v, c) => v - c).Where(v => v > 0).OrderByDescending(v => v).Sum();
        Console.WriteLine(result);
    }

    static int readInt() {
        return int.Parse(Console.ReadLine());
    }

    static int[] readInts() {
        return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }
}

Measured memory_bytes: 11476
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int R,C,K;
vector<vector<ll>> V;
void input(){
    fast_io();
    cin >> R >> C >> K;
    V.assign(R,vector<ll>(C,0));
    for (int i = 0; i < K; i++)
    {
        int r,c;
        ll v;
        cin >> r >> c >> v;
        r--,c--;
        V[r][c] = v;
    }
}

void chmax(ll &a, ll b){if(a<b) a=b;}

int solve(){
    vector<vector<ll>> dp[5];
    dp[0].assign(R+1,vector<ll>(C+1,0));
    dp[1].assign(R+1,vector<ll>(C+1,0));
    dp[2].assign(R+1,vector<ll>(C+1,0));
    dp[3].assign(R+1,vector<ll>(C+1,0));

    dp[0][0][0] = 0;
    for (int i = 0; i < R; i++)
    {
        for (int j = 0; j < C; j++)
        {
            for (int k = 3; k >= 0; k--)
            {
                if(V[i][j]){
                    if(k+1<=3) chmax(dp[k+1][i][j], dp[k][i][j] + V[i][j]);
                }
            }
            for (int k = 0; k <= 3; k++)
            {

                for (int t = 0; t <= 3; t++)
                {
                    chmax(dp[t][i+1][j], dp[k][i][j]);
                }
                chmax(dp[k][i][j+1], dp[k][i][j]);
            }
        }
    }

    ll ans = 0;
    for (int k = 0; k <= 3; k++)
    {
        ans = max(ans, dp[k][R-1][C-1]);
    }
    cout << ans << endl;
    return 0;
}   

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

Measured memory_bytes: 355216
#include <stdio.h>

int main(void)
{
	int n;
	int i, j, k;
	int num[100];
	int sort;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d", &num[i]);
	}
	
	for (i = 0; i < n; i++){
		for (k = 0; k < n; k++){
			printf("%d", num[k]);
			if (k < n - 1){
				printf(" ");
			}
		}
		printf("\n");
		
		for (j = 0; j < i + 1; j++){
			if (num[i + 1] < num[j]){
				sort = num[j];
				num[j] = num[i + 1];
				num[i + 1] = sort;
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 604
/*
author: thanglong
*/
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
typedef pair<int, int> ii;
 
const int N = 3e3 + 5;
 
int n, mod, f[N][N], c[N][N], pw[N * N], pw2[N], dp[N], ans;
 
void calc() {
    //f[i][j]:the number of ways to "put" j guys in i bowl
    for(int i = 0; i <= N - 5; i++)
        f[i][0] = 1;
    for(int i = 1; i <= N - 5; i++) {
        for(int j = 1; j <= i; j++)
            f[i][j] = ((1ll * (j + 1) * f[i - 1][j]) % mod + f[i - 1][j - 1]) % mod;
    }
    c[0][0] = 1;
    for(int i = 1; i <= N - 5; i++) {
        c[i][0] = 1;
        for(int j = 1; j <= i; j++)
            c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
    }
    pw[0] = 1;
    for(int i = 1; i <= (N - 5) * (N - 5); i++)
        pw[i] = (1ll * pw[i - 1] * 2) % mod;
    pw2[0] = 2;
    for(int i = 1; i <= N - 5; i++)
        pw2[i] = (1ll * pw2[i - 1] * pw2[i - 1]) % mod;
    ans = pw2[n] - 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= i; j++) {
            //cout << f[i][j] << " " << i << " " << j << "\n";
            int val = (1ll * f[i][j] * pw[(n - i) * j]) % mod;
            if(j == 0)
                dp[i] += (1ll * val * (pw2[n - i] - 1)) % mod;
            else
                dp[i] += (1ll * val * pw2[n - i]) % mod;
            dp[i] %= mod;
        }
        if(i % 2 == 0)
            ans = (ans + (1ll * dp[i] * c[n][i]) % mod) % mod;
        else
            ans = (ans - (1ll * dp[i] * c[n][i]) % mod) % mod;
        ans = (ans + mod) % mod;
    }
    cout << ans;
    exit(0);
}
 
int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> mod;
    calc();
}

Measured memory_bytes: 106112
#include <bits/stdc++.h>
#define ll signed long long int
#define MAXX 1000005
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
 
ll a[MAXX], b[MAXX];
 
signed main()
{
	FAST;
	ll n;
	cin >> n;
	while(n > 0){
		if(n%10 == 7){
			cout << "Yes";
			return 0;
		}
		n /= 10;
	}
	cout << "No";
	
}

Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define each(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vd vector<double>
#define vvd vector<vd>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define out(x) rep(i, 0, (x).size()) cout << (x)[i] << ((i != (x).size() - 1) ? " " : "\n")
const double PI = 3.14159265;
const int MAXN = 1 << 15;
const ll LINF = 1LL << 60;
const int INF = 1 << 30;
#define Pr(a) (#a) << "=" << (a) << " "
#define pr(a) cout << Pr(a) << '\n'
///////////////////////////////////////////////////////
int main() {
  int n;
  cin >> n;
  vector<tuple<int, int, char, ll, string>> V(n);
  rep(i, 0, n) {
    int v;
    int w;
    char t;
    ll d;
    string s;
    cin >> v >> w >> t >> d >> s;
    V[i] = make_tuple(v, w, t, d, s);
  }

  sort(all(V));

  rep(i, 0, n) {
    cout << get<0>(V[i]) << " " << get<1>(V[i]) << " " << get<2>(V[i]) << " " << get<3>(V[i]) << " " << get<4>(V[i]) << endl;
  }

  return 0;
}


Measured memory_bytes: 12144
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

A, B = map(int, raw_input().split())

ans = 0
for i in range(50):
    cnt = 0
    num1 = A
    cnt -= num1 / (2 ** (i + 1)) * (2 ** i)
    cnt -= max(0, num1 % (2 ** (i + 1)) - 2 ** i)
    num1 = B + 1
    cnt += num1 / (2 ** (i + 1)) * (2 ** i)
    cnt += max(0, num1 % (2 ** (i + 1)) - 2 ** i)
    if cnt % 2:
        ans += 2 ** i
print ans


Measured memory_bytes: 2812
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#include<vector>
typedef long long ll;
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
int a[200010];
int main(){
	int i,n;
	ll h;
	ll ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(i==0){
			h=a[i];
		}else{
			if(a[i]>=h)h=a[i];
			else ans+=h-a[i];
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2516
/*
=============================================================

------------------Welcome To My Code-------------------------

---------Ankit Kumar || IIITBH || CSE || 2018-2022-----------

=============================================================
*/

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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
map<ll, ll>::iterator itr;
vector<ll>::iterator it, it1;
const double PI = 3.141592653589793238;

int main()
{
	FASTIO;


        ll i,j,k,x,y,z,m,n,a,b,c,c1=0,c2=0,flag=0,sum=0;
        string s,s1,str;
        cin>>n;
        ll arr[n];
        FOR(i,n)
            cin>>arr[i];

    for(i=0;i<n-2;i++)
    {
        for(j=i+1;j<n-1;j++)
        {
            a=arr[i];
            b=arr[j];

            for(k=j+1;k<n;k++)
            {
                c=arr[k];
                if(c!=a&&c!=b&&a!=b)
                {
                    if(a+b>c&&a+c>b&&b+c>a)
                        c1++;

                }
            }
        }
    }
    cout<<c1;


}


Measured memory_bytes: 3644
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int h, w;
int n;
int[] a;

void main() {
    scan(h, w);
    scan(n);
    a = readln.split.to!(int[]);

    auto ans = new int[](0);

    iota(n).each!(i => ans ~= repeat(i + 1, a[i]).array());

    foreach (i ; 0 .. h) {
        if (i & 1) {
            writefln("%(%s %)", ans[i*w .. i*w + w].retro());
        }
        else {
            writefln("%(%s %)", ans[i*w .. i*w + w]);
        }
    }
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main() {
	string  s;
	cin >> s;
	int min = 1000000;
	int max = -1000000;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			if (min > i) {
				min = i;
			}
		}
	}
	for (int j = 0; j < s.size(); j++) {
		if (s[j] == 'Z') {
			if (max < j) {
				max = j;
			}
		}
	}
	cout << max - min+1 << endl;
	return 0;
}



Measured memory_bytes: 640
n=int(input())
tc = 0
hc = 0
for _ in range(0,n):
    t,h = input().split()
    if t > h: tc = tc + 3
    if t < h: hc = hc + 3
    if t == h: 
        tc = tc + 1
        hc = hc + 1
print('{0} {1}'.format(tc, hc))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main (){
int x,a,b;
cin>>x>>a>>b;
  if (abs (x-a)<abs (x-b))
    {
    cout<<"A";
    }
  else if (abs (x-b)<abs (x-a))
    {
    cout<< "B";
    }
return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{
   
   
    string p;
    cin >> p;
    int r = 0;
    int a = 0;

    for (int i = 0; i < 3; i++) {
        if (p[i] == 'R')a++;
        else a = 0;
        r = max(r, a);
    }

    cout << r << endl;

    return 0;

}

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

int main() {
    int x ;
    cin >> x;
    if(x == 0){
        cout << 1 << endl;
        return 0;
    }
    else{
        cout << 0 << endl;
        return 0;
    }
}

Measured memory_bytes: 3632
#include <cstddef>
#include <iostream>
#include <vector>

class DisjointSet {
 private:
  class Node {
    friend DisjointSet;

    std::size_t parent;
    std::size_t size;

    Node(const std::size_t parent, const std::size_t size) : parent(parent), size(size) {}
  };

  std::vector<Node> nodes;

 public:
  DisjointSet(const std::size_t n) : nodes(n, Node(n, 1)) {}

  std::size_t size() const { return nodes.size(); }

  std::size_t size(const std::size_t x) { return nodes[root(x)].size; }

  std::size_t root(const std::size_t x) {
    if (nodes[x].parent == size()) return x;
    return nodes[x].parent = root(nodes[x].parent);
  }

  bool is_same(const std::size_t x, const std::size_t y) { return root(x) == root(y); }

  bool unite(const std::size_t x, const std::size_t y) {
    std::size_t rx = root(x), ry = root(y);
    if (rx == ry) return false;
    if (nodes[rx].size < nodes[ry].size) std::swap(rx, ry);
    nodes[rx].size += nodes[ry].size;
    nodes[ry].parent = rx;
    return true;
  }
};

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int N, Q;
  std::cin >> N >> Q;
  DisjointSet ds(N);
  for (int i = 0; i < Q; i++) {
    int t, u, v;
    std::cin >> t >> u >> v;
    switch (t) {
      case 0:
        ds.unite(u, v);
        break;
      case 1:
        if (ds.is_same(u, v)) {
          std::cout << 1 << '\n';
        } else {
          std::cout << 0 << '\n';
        }
        break;
    }
  }
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    double p[3003];
    for(int i = 1; i <= n; i++){
        cin >> p[i];
    }
    double dp[3003];
    fill(dp, dp + 3003, 0.0);
    dp[0] = 1.0;
    for(int i = 0; i <= n; i++){
        for(int j = n; j >= 0; j--){
            if(j == 0) dp[j] = dp[j] * (1.0 - p[i]);
            else dp[j] = dp[j] * (1.0 - p[i]) + dp[j - 1] * p[i];
        }
    }
    double ans = 0.0;
    for(int i = n / 2 + 1; i <= n; i++){
        ans += dp[i];
    }
    printf("%.15f\n", ans);
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int w[n], e[n];
    w[0] = e[n-1] = 0;
    for(int i = 1; i < n; i++){
        w[i] = (s[i-1] == 'W' ? w[i-1] + 1 : w[i-1]);
        e[n-i-1] = (s[n-i] == 'E' ? e[n-i] + 1 : e[n-i]);
    }
    int ans = 1e9;
    for(int i = 0; i < n; i++){
        ans = min(ans, w[i] + e[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  ll n;
  cin >> n;
  map<char,ll> s;
  for(ll i=0;i<n;i++) {
    string temp;
    cin >> temp;
    s[temp[0]]++;
  }
  vector<ll> count;
  for(auto p:s) {
    if(p.first=='M'||p.first=='A'||p.first=='R'||p.first=='C'||p.first=='H') {
      count.push_back(p.second);
    }
  }
  ll ans=0;
  for(ll i=0;i<count.size();i++) {
    for(ll j=i+1;j<count.size();j++) {
      for(ll k=j+1;k<count.size();k++) {
        ans+=count[i]*count[j]*count[k];
      } 
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
t = list(int (i) for i in input().split())
w=0
for i in range(len(t)-1):
    if t[i+1]-t[i]<=Y:
        w+=t[i+1]-t[i]
    else:
        w+=Y
w+=Y
print(w)

Measured memory_bytes: 26832
n, k = map(int, input().split())
a = list(map(int, input().split()))
low = 0
top = max(a) + 1

while top - low > 1:
  mid = (top + low) // 2
  cnt = 0
  for i in range(n):
    if a[i] % mid == 0:
      cnt += (a[i] // mid) - 1
    else:
      cnt += a[i] // mid
  if cnt <= k:
    top = mid
  else:
    low = mid
print(top)


Measured memory_bytes: 30836
a,b,k = map(int, input().split())
if a + k - 1 < b:
  min_ = a + k - 1
else:
  for i in range(a, b + 1):
    print(i)
  exit(0)
max_ = b - k + 1
if max_ <= min_:
  for i in range(a, b + 1):
    print(i)
  exit(0)
for i in range(a, min_ + 1):
    print(i)

for i in range(max_, b + 1):
    print(i)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NAB = Sarray();
            var N = NAB[0];
            var A = NAB[1];
            var B = NAB[2];
            var Xi = Sarray();
            var hirou = 0L;
            for(var i=1;i<N;++i)
                hirou += Min((Xi[i] - Xi[i - 1]) * A, B);
            WriteLine(hirou);
            //Out.Flush();
        }
    }
}

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

int main(){
  int n, kushi[210] = {0}, ans;
  
  cin >> n;
  for ( int i = 0; i < 2 * n; i++ ){
    cin >> kushi[i];
  }
  
  for ( int i = 0; i < 2 * n - 1; i++ ){
    for ( int j = 2 * n - 1; j > i; j-- ){
      if ( kushi[j] < kushi[j - 1] ){
        int k = kushi[j];
        kushi[j] = kushi[j - 1];
        kushi[j - 1] = k;
      }
    }
  }
  
  ans = 0;
  for ( int i = 0; i < 2 * n; i += 2 ){
    ans += kushi[i];
  }
  
  cout << ans << endl;
}

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

int arr[3] = {500 , 100 , 50};
int cnt[3];
long long dp[4][52][20001];
int X;

long long Do(int i , int n , int ammount)
{
	if(i==3){
		if(ammount == 0) return 1;
		return 0;
	}
	if(dp[i][n][ammount]!=-1) return dp[i][n][ammount];
	long long ret1 = 0 , ret2 = 0;
	if(n <= cnt[i] and  ammount - arr[i]>=0) ret1 = Do(i , n + 1 , ammount - arr[i]);
	ret2 = Do(i + 1 , 1 , ammount);
	return dp[i][n][ammount] = ret1 + ret2; 
}

int main()
{
	memset(dp , -1 , sizeof dp);
	int A , B , C;
	cin >> A >> B >> C;
	cnt[0] = A , cnt[1] = B , cnt[2] = C;
	cin >> X;
	cout << Do(0 , 1 , X) << endl;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll n;
    cin >> n;
    cout << (1000LL-n%1000LL)%1000LL << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<string> A={ "AC", "WA", "TLE", "RE" },B(N);
  
  for(int i=0;i<N;i++){
    cin >> B.at(i);
  }
  
  map<string, int> cnt={{"AC",0}, {"WA",0}, {"TLE",0}, {"RE",0}};
  for(string x : B){
    if(cnt.count(x)){
      cnt.at(x)++;
    } else 
      cnt[x] = 1;
  }
  for(int i=0;i<4;i++){
    cout << A.at(i) << " x " << cnt.at(A.at(i)) << endl;
  }
}

Measured memory_bytes: 6436
def countingSort(a, b, k)
  n = a.size
  c = Array.new(k+1){0}
  0.upto(n-1){|j|
    c[a[j]] += 1
  }
  1.upto(k){|i|
    c[i] += c[i-1]
  }
  (n-1).downto(0){|j|
    b[c[a[j]]-1] = a[j]
    c[a[j]] -= 1
  }
end

n = gets.to_i
arr = gets.split.map(&:to_i)
k = arr.max
ans = Array.new(n)

countingSort(arr, ans, k)
puts ans.join(" ")

Measured memory_bytes: 216100
N = int(input())
B = list(map(int, input().split()))

ans = 0

A = [0] * N
A[0] = B[0]
A[-1] = B[-1]

for i in range(1, N-1):
    min_B = min(B[i-1], B[i])
    A[i] = min_B

print(sum(A))


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            (long N, long K) = Slice2<long>();
            var dct = new Dictionary<long, long>();
            for (var i = 0; i < N; ++i)
            {
                (long a, long b) = Slice2<long>();
                if (!dct.ContainsKey(a)) dct[a] = 0;
                dct[a] += b;
            }
            var num = 0L;
            foreach (var d in dct.OrderBy(d => d.Key))
            {
                num += d.Value;
                if (K <= num)
                {
                    WriteLine(d.Key);
                    return;
                }
            }
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 45148
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<math.h>
#include<string>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;

int main()
{
	int n;
	std::cin >> n;
	int** arr = new int*[n];
	for (int i = 0; i < n; i++)
	{
		arr[i] = new int[3];
	}
	for (int i = 0; i<n; i++)
	{
		int a, b, c;
		std::cin >> a >> b >> c;
		arr[i][0] = a;
		arr[i][1] = b;
		arr[i][2] = c;
	}
	int** dp = new int* [n];
	for (int i = 0; i < n; i++)
	{
		dp[i] = new int[3];
	}
	dp[0] [0] = arr[0][0];
	dp[0][1] = arr[0][1];
	dp[0][2] = arr[0][2];
	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < 3; j++)
		{   int max=INT_MIN;

			for (int k = 0; k < 3; k++)
			{ 
				if (j == k)
				{
					continue;
				}
				int x = arr[i][j] + dp[i - 1][k];
				if (x > max)
				{
					max = x;
				}
			}
			dp[i][j] = max;
		}
	}
	int y = max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
	std::cout << y << endl;
	return 0;
}

Measured memory_bytes: 11448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second
#define vll vector <ll>

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

    ll n,m;
    cin>>n>>m;
    char c[n][m];
    for(ll i=0;i<n;i++)
        for(ll j=0;j<m;j++)
            cin>>c[i][j];
    ll dp[n][m];
    memset(dp,0,sizeof dp);
    for(ll i=0;i<n;i++)
        if(c[i][0]=='.')
        dp[i][0]=1;
        else
        break;
    for(ll i=0;i<m;i++)
        if(c[0][i]=='.')
        dp[0][i]=1;
        else
        break;
    for(ll i=1;i<n;i++)
    {
        for(ll j=1;j<m;j++)
        {
            if(c[i][j]=='#')
            {
                dp[i][j]=0;
                continue;
            }
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    cout<<dp[n-1][m-1]<<'\n';
}   


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

int main(){
    int N;
    cin >> N;
    int ans;
    ans = N %10;
    if(ans == 2 || ans == 4 || ans == 5 || ans == 7 || ans == 9){
        cout << "hon" << endl;
    }else if(ans == 0 || ans == 1 || ans == 6 || ans == 8){
        cout << "pon" << endl;
    }else{
        cout << "bon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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 main () {
  int n;
  cin >> n;
  vi a(n+1);
  rep(i,n) cin >> a[i+1];
  vi b(n+1);
  for (int i = n; i >= 1; --i) {
    int sum = 0;
    for (int j = i+i; j <= n; j += i) {
      sum ^= b[j];
    }
    b[i] = sum^a[i];
  }
  vi ans;
  for (int i = 1; i <= n; ++i) {
    if (b[i]) ans.pb(i);
  }
  cout << ans.size() << endl;
  rep(i,ans.size()) {
    printf("%d%c", ans[i], i+1==ans.size()?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 3064
#!/usr/bin/env python3

n, m = list(map(int, input().split()))

min_, max_ = 0, 10**5
for i in range(m):
    a, b = list(map(int, input().split()))

    min_ = max(min_, a)
    max_ = min(max_, b)

print(max(max_-min_+1, 0))


Measured memory_bytes: 3060
#include <stdio.h>
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a>b?b:a;}
int main(){
int a,b,n;
  scanf("%d%d%d",&n,&a,&b);
  printf("%d %d\n",min(a,b),max(0,a+b-n));
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; 
using namespace std;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " is " << (x) << endl
#define dbg(x)     cout << x << ' '
#define here cout << " Hey baitch!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld PI = 3.1415926535898;
int mod_exp(int base,int exp,int mod) {
    int ans =1;while(exp)   {
        if(exp%2)   ans = (ans%mod*base%mod)%mod;
        base=(base%mod*base%mod)%mod;exp/=2;ans%=mod;
    }return ans;
}
int inv_mod(int base,int mod) {
	return mod_exp(base,mod-2,mod);
}
int fact[N];
void pre_compute()
{
	fact[0] = 1;
	for(int i = 1;i<N;i++)
	{
		fact[i] = i*fact[i-1];
		fact[i]%=MOD;
	}
}
int nCr(int n, int r)
{
	if(r>=n or r==0)
		return 1;
	return ( (fact[n]%MOD * inv_mod(fact[r],MOD)%MOD) * inv_mod(fact[n-r],MOD))%MOD;
}
int32_t main()
{
	SYNC
	pre_compute();
	int n,m,k; cin >> n >> m >> k;
	int ans = 0;
	for(int i = 0; i <= k; i++) {
		ans += (m*mod_exp(m-1,n-i-1,MOD))%MOD * nCr(n-1,i);
		ans %= MOD;
	}
	cout << ans;
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for(int  i = (int)(s); i < (int)(e); ++i)
#define all(r) (r).begin(), (r).end()

typedef long long ll;
ll MOD = 1e9 + 7;

const int MAX_N = 55;

ll dp[MAX_N][2];

int main() {
  string a, b, c;
  while(cin >> a) {
    if(a == "0") break;
    cin >> b >> c;
    rep(i, MAX_N) rep(j, 2) dp[i][j] = 0;
    dp[0][0] = 1;
    reverse(all(a));
    reverse(all(b));  
    reverse(all(c));
    int n = a.size();
    rep(i, n) {
      rep(ai, 10) {
	if(i == n-1 && ai == 0) continue;
	if(a[i] != '?') {
	  if(a[i] != '0' + ai) continue;
	}
	rep(bi, 10) {
	  if( i == n-1 && bi == 0) continue;
	  if(b[i] != '?') {
	    if(b[i] != '0' + bi) continue;
	  }
	  {
	    int sum = ai + bi;
	    bool f = sum >= 10;
	    if(sum >= 10) sum -= 10;
	    if(i == n-1 && sum == 0) continue;
	    if(c[i] == '?' || c[i] == '0' + sum) (dp[i+1][f] += dp[i][0]) %= MOD;
	  }
	  {
	    int sum = ai + bi + 1;
	    bool f = sum >= 10;
	    if(sum >= 10) sum -= 10;
	    if(i == n-1 && sum == 0) continue; 
	    if(c[i] == '?' || c[i] == '0' + sum) (dp[i+1][f] += dp[i][1]) %= MOD;
	  }
	}
      }
      
    }
    cout << dp[n][0] << endl;
  }
  return 0;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline int rdi(){
	int x=0,f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	return f?-x:x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
int dp[100005][3],a[100005][3],n;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	int i,j,k;
	for(i=1;i<=n;++i) for(j=1;j<=3;++j) cin>>a[i][j];
	for(i=1;i<=n;++i) for(j=1;j<=3;++j) for(k=1;k<=3;++k) if(j!=k) dp[i][k]=max(dp[i][k],dp[i-1][j]+a[i][k]);
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;
	return 0;
}



Measured memory_bytes: 2560
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    let stdin = &mut stdin;
    let a: String = read(stdin).unwrap();
    let mut count = [0; 26];
    for i in a.chars() {
        let idx: i32 = i as i32 - 'a' as i32;
        let idx = idx as usize;
        count[idx] += 1;
    }
    let n = a.len();
    let n = n as i64;
    let mut ans: i64 = n * (n - 1) / 2;
    for i in count.iter() {
        let i = *i as i64;
        if i > 1 {
            ans -= i * (i - 1) / 2;
        }
    }

    println!("{}", ans + 1);
}


Measured memory_bytes: 4352