akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 998244353ll;
const ll MAXN = (ll) 1e2 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;


ll dp[MAXN][100010];
ll w[MAXN], v[MAXN];

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//memset(dp, 31 , sizeof dp);
	ll n, W;
	cin >> n >> W;
	for(int i = 1;i<=n;i++) cin >> w[i] >> v[i];
	
	dp[0][0] = 0;
	for(int i = 1;i<=n;i++){
		for(int j = 0;j<=W;j++){
			dp[i][j] = dp[i-1][j];
			if(j >= w[i]){
				dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
			}
		}
	}
	ll ans = 0;
	for(int i = 0;i<=W;i++) ans = max(ans, dp[n][i]);
	cout << ans;
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


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

int main(){
	int s; cin>>s;
	int a=s/100,b=s%100;
	string ans;
	if(a>=1&&a<=12){
		if(b>=1&&b<=12)ans="AMBIGUOUS";
		else ans="MMYY"s;
	}else{
		if(b>=1&&b<=12)ans="YYMM"s;
		else ans="NA"s;
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long 
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define N ((ll)(2e6+100))
#define MAX ((ll)(1e16+100))
#define ARRS ((ll)(3e5+100))
#define MOD ((ll)(1e9+7))
#define M1 ((ll)(1001783))
#define M2 ((ll)(1001941))
#define M3 ((ll)(1002073))
#define pb push_back


ll n,m;
ll a[ARRS];
string s;

int main(){
	cin>>n>>m;
	if(n%m)
		cout<<n;
	else cout<<-1;
}
 


Measured memory_bytes: 256
using System;

class Program
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var baseNumbers = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
		var sortedNumbers = baseNumbers.Clone() as int[];
		Array.Sort(sortedNumbers);

		var centerIndex = (n + 1) / 2;
		var frontCenterValue = sortedNumbers[n / 2 - 1];
		var backCenterValue = sortedNumbers[n / 2];
		for (var i = 0; i < n; ++i) {
			if (baseNumbers[i] <= frontCenterValue) {
				Console.WriteLine(backCenterValue);
			} else {
				Console.WriteLine(frontCenterValue);
			}
		}

		Console.ReadKey();
	}
}


Measured memory_bytes: 35932
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int H, W; cin >> H >> W;
	char A[1010][1010];
	queue <pair<pii,int>>Q;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> A[i][j];
			if (A[i][j] == '#') {
				Q.push({ {i,j},0 });
			}
		}
	}
	int ans = 0;
	while (!Q.empty()) {
		auto key = Q.front();
		ans = max(ans, key.second);
		Q.pop();
		for (int i = 0; i < 4; ++i) {
			int ny = key.first.first + dy[i];
			int nx = key.first.second + dx[i];
			if (ny < 0 || ny >= H || nx < 0 || nx >= W||A[ny][nx]=='#') {
				continue;
			}
			else {
				A[ny][nx] = '#';
				Q.push({ { ny,nx }, key.second + 1 });
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 13456
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = gcd(a, b);
		int count = 1;
		for (long i = 2; i * i <= x; i++) {
			if (x % i == 0) {
				count++;
				while (x % i == 0) {
					x /= i;
				}
			}
		}
		if (x > 1) {
			count++;
		}
		System.out.println(count);
	}
	
	static long gcd(long a, long b) {
		if (a % b == 0) {
			return b;
		} else {
			return gcd(b, a % b);
		}
	}
}


Measured memory_bytes: 23760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static ArrayList<String> s = new ArrayList<String>();
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n= in.nextInt();
		int k= in.nextInt();
		int [] a= new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i]= in.nextInt();
		}
		Arrays.sort(a);
		int best= 0;
		for (int i = n-k; i < a.length; i++) {
			best+=a[i];
		}
		System.out.println(best);
		
	}
	public static void combinations(String suffix,String prefix){
        if(prefix.length()<0)return;
        s.add(suffix);
        for(int i=0;i<prefix.length();i++)
         combinations(suffix+prefix.charAt(i),prefix.substring(i+1,prefix.length()));
    }
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}



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

int main(){
    int x,a,b;
    cin>>x>>a>>b;
    if(b-a<=0) cout<<"delicious"<<endl;
    else if(b-a<=x) cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
    return 0;
}

Measured memory_bytes: 256
//上書き禁止にすれば、塗りつぶしに用いる「残り移動距離」の配列を使いまわせる。
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;

int n, m;
vector<int> et[100000];
int q;
int v[100000], d[100000], c[100000];
int dp[100000];	//dp[v] = 頂点vでの「残り距離」のmax (遷移条件で使用. 初期値は-1.)
int ans[100000];

void bfs(int queryId) {
	int color = c[queryId];
	
	queue<P> que;	//(dist, vertex)
	if (dp[v[queryId]] >= d[queryId]) return;
	
	que.push(P(d[queryId], v[queryId]));
	dp[v[queryId]] = d[queryId];
	if (ans[v[queryId]] == 0) {
		//cout << "fill(" << v[queryId] << ", " << color << ")" << endl;
		ans[v[queryId]] = color;
	}
	
	while (!que.empty()) {
		P now = que.front(); que.pop();
		int dist = now.first;
		int pos = now.second;
		for (int i = 0; i < et[pos].size(); i++) {
			int npos = et[pos][i];
			int ndist = dist - 1;
			if (ndist > dp[npos]) {
				dp[npos] = ndist;
				if (ans[npos] == 0) {
					ans[npos] = color;
					//cout << "fill(" << npos << ", " << color << ")" << endl;
				}
				que.push(P(ndist, npos));
			}
		}
	}
}

int main() {
	int i;
	
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		int a, b; cin >> a >> b; a--; b--;
		et[a].push_back(b); et[b].push_back(a);
	}
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> v[i] >> d[i] >> c[i];
		v[i]--;
	}
	for (i = 0; i < n; i++) dp[i] = -1;
	
	for (i = q - 1; i >= 0; i--) {
		bfs(i);
	}
	for (i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 8912
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[101];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];
    sort(a,a+n,greater<int>());
    int al=0,bo=0;
    rep(i,n){
        if(i%2==0) al+=a[i];
        else bo+=a[i];
    }
    cout<<al-bo<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int n, m;
ll h[100001];
int a[100001], b[100001];
int isGood[100001];

int main(int argc, char const *argv[]) {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
    }

    for (int i = 1; i <= n; i++) {
        isGood[i] = true;
    }
    for (int i = 0; i < m; i++) {
        if (h[a[i]] == h[b[i]]) {
            isGood[a[i]] = false;
            isGood[b[i]] = false;
        } else if (h[a[i]] < h[b[i]]) {
            isGood[a[i]] = false;
        } else {
            isGood[b[i]] = false;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (isGood[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int n,t,a,i;
  double near = 1000000.0;
  int h[1000];
  int ans;
  
  scanf("%d", &n);
  scanf("%d %d", &t, &a);
  
  for (i = 0; i < n; i++){
    scanf("%d ", &h[i]);
    if (fabs(a-(t-(h[i]*0.006))) <= near){
      near = fabs(a-(t-(h[i]*0.006)));
      ans = i + 1;
    }
  }
  
  printf("%d", ans);
  
  return 0;
}

Measured memory_bytes: 128
//author : Yogi79

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

string s,t;

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin>>s>>t;

   long long c=0;

   for(int i=0;i<s.length();i++)
   {
      if(s[i] == t[i])
      	c++;
   }
   cout<<c;
}

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

int main(){
  int n;cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++)cin>>d[i];
  sort(d.begin(),d.end());
  cout<<d[n/2]-d[n/2-1]<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2e5+2;

int main()
{
    fastio;
    ll i, j, k, n, m, t;

    cin>>n>>m;
    if(m%2==0)
    {
        if(m>=2*n && m<=4*n)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;
    }
    else
        cout<<"No"<<endl;
    
        
    return 0;
}

Measured memory_bytes: 3548
#include<stdio.h>

int main()
{
    int n,i,t=0;
    scanf("%d",&n);
    int a[n],b[n],c[n-1];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        }
    for(i=0;i<n;i++){
        scanf("%d",&b[i]);
        }
    for(i=0;i<n-1;i++){
        scanf("%d",&c[i]);
        }
    for(i=0;i<n;i++){
        if(a[i-1]==a[i]-1&&i!=0){
            t=t+b[a[i]-1]+c[a[i]-2];
        }
        else{
                t=t+b[a[i]-1];
        }
        }
        printf("%d",t);

    }



Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
int gcd(int a,int b)
{
    int r;
    r = a % b;
    if (r == 0)
        return b;
    else
        return gcd(b,r);
}
 
int main()
{
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include <random>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

// Segment tree (RMQ type)
struct seg {
  typedef vi TT;
  vector<TT> d; int x2;
  seg(){}
  seg(int mx) {
    x2 = 1; while(x2 < mx) x2 <<= 1;
    d.resize(x2<<1);
  }
  void add(int a, int b, int i=1, int l=0, int r=-1){
    if (r == -1) r = x2;
    if(a <= l && r <= b) {
      d[i].pb(a);
      return;
    }
    int c = (l+r)>>1;
    if(a < c) add(a,b,i<<1,l,c);
    if(c < b) add(a,b,i<<1|1,c,r);
  }
  void init() {
    rep(i,sz(d)) sort(rng(d[i]));
  }
  int get(int i, int x){
    int res = 0;
    for(i+=x2;i;i>>=1) {
      res += sz(d[i])-(upper_bound(rng(d[i]),x)-d[i].begin());
    }
    return res;
  }
};
//



int main() {
  int n, m;
  scanf("%d%d",&m,&n);
  seg t(n+5);
  rep(i,m) {
    int l, r;
    scanf("%d%d",&l,&r);
    t.add(l,r+1);
  }
  t.init();
  rrep(i,n) {
    int ans = 0;
    for (int j = i; j <= n; j += i) {
      int r = t.get(j,j-i);
      ans += r;
    }
    printf("%d\n",ans);
  }
  return 0;
}































Measured memory_bytes: 32684
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int n,m;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    int q;
    cin>>q;
    rep(i,q){
        int b,m,c;
        cin>>b>>m>>c;
        vi w=v;
        for(int i=0;i<c-b;i++){
            w[b+((i+(c-m))%(c-b))]=v[b+i];
        }
        v=w;

    }
    rep(j,n){
        if(!j)cout<<v[0];
        else cout<<" "<<v[j];
    }cout<<endl;
}




Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll n, t;
	cin >> n >> t;
	vector<vll> v(n, vll(2));
	for (ll i = 0; i < n; i++) cin >> v[i][0] >> v[i][1];
	sort(all(v));
	ll x = 0;
	while (x < n && v[x][1] > t) x++;
	if (x < n) cout << v[x][0] << endl;
	else cout << "TLE" << endl;
}


Measured memory_bytes: 256
s=list(input())
p=[chr(ord("a")+i)for i in range(26)]
q=100
if len(list(set(s)))==1:
    print(0)
else:
    for i in range(26):
        t=p[i]
        d=s[:]
        c=0
        while len(d)>0:
            c+=1
            for j in range(len(d)-1):
                if d[j]==t or d[j+1]==t:
                    d[j]=t
            else:
                d.pop(-1)
                if len(list(set(d)))==1 and d[0]==t:
                    break
        q=min(q,c)
    print(q)

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

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v;
  int h;
  while (cin >> h) {
    v.push_back(h);
  }
  sort(v.begin(), v.end());
  int s = v.size();
  cout << v[s-1] << endl << v[s-2] << endl << v[s-3] << endl;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){ 
    int a,b;
    cin >> a >> b;
    int ans =  max(a+b,a-b);
    cout << max(ans,a*b)<< endl;
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
int n,k,x,y;
scanf("%d",&n);
scanf("%d",&k);
scanf("%d",&x);
scanf("%d",&y);
if(n<=k){printf("%d\n",n*x);}
else {printf("%d\n",k*x+(n-k)*y);}
 
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 405;
const int inf = 5e7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, ma, mb;
	cin>>n>>ma>>mb;
	vector<vector<int> > dp[n + 1];
	for(int i = 0; i <= n; i++){
		dp[i] = vector<vector<int> >(N, vector<int>(N, inf));
	}
	dp[0][0][0] = 0;
	for(int i = 1; i <= n; i++){
		int a, b, c;
		cin>>a>>b>>c;
		for(int sa = 0; sa < N; sa++){
			for(int sb = 0; sb < N; sb++){
				dp[i][sa][sb] = min(dp[i][sa][sb], dp[i - 1][sa][sb]);
				if(sa + a < N && sb + b < N){
					dp[i][sa + a][sb + b] = min(dp[i][sa + a][sb + b], dp[i - 1][sa][sb] + c);
				}
			}
		}
	}
	int ans = inf;
	for(int k = 1; k*ma < N && k*mb < N; k++){
		ans = min(ans, dp[n][ma*k][mb*k]);
	}
	if(ans < inf)cout<<ans<<'\n';
	else cout<<-1<<'\n';


	return 0;
}

Measured memory_bytes: 27136
using System;
using static System.Console;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(ReadLine());
            int[] A = { 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 };
            WriteLine(A[K - 1]);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define int long long // 簡略化のため longlong を int に
const long long MOD = 1e9+7;

int fact[150000], revfact[150000]; // fact[i]はiまでの階乗、revfact[i]はiまでの階乗の逆元
queue<int> prime_count;

int powmod(int a, int p){
    int res = 1, tmp = a;
    while(p != 0){
        if(p % 2) res = (res*tmp) % MOD;
        tmp = (tmp*tmp) % MOD;
        p /= 2;
    }
    return res;
}

void factmod(){
    fact[0] = revfact[0] = 1;
    for(int i = 1; i < 150000; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        revfact[i] = (revfact[i-1] * powmod(i, MOD-2)) % MOD;
    }
}

int nCrmod(int n, int r){ // nCr % MOD
    return (((fact[n] * revfact[r]) % MOD) * revfact[n-r]) % MOD;
}

signed main(){ // ここの signed を int にするとCEします
    int N, M; cin >> N >> M;

    for(int i = 2; i <= sqrt(M); i++){ // 素因数分解して指数を queue に突っ込む
        if(M % i == 0){
            int cnt = 0;
            while(M % i == 0){
                M /= i;
                cnt++;
            }
            prime_count.push(cnt);
        }
        if(M == 1) break;
    }
    if(M != 1) prime_count.push(1); // Mが素数の場合はqueueに1だけが入ることになります

    factmod();

    int ans = 1;
    while(!prime_count.empty()){
        int bi = prime_count.front();
        ans *= nCrmod(N+bi-1, bi); ans %= MOD;
        prime_count.pop();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

//Trapezoids
public class Main{

	int h;
	char[][] map;
	int[] move = {-1,0,1};

	void run(){
		Scanner sc = new Scanner(System.in);
		boolean f = true;
		while(true){
			h = sc.nextInt();
			if(h==0)break;
			if(!f)System.out.println("----------");
			f = false;
			Map<Integer, Integer> ans = new HashMap<Integer, Integer>();
			map = new char[h][];
			sc.nextLine();
			for(int i=0;i<h;i++)map[i]=sc.nextLine().toCharArray();
			for(int i=0;i<h;i++){
				for(int j=0;j<map[i].length;j++){
					if(map[i][j]!='*')continue;
					int a = 1;
					map[i][j] = ' ';
					int k = j+1;
					while(k<map[i].length&&map[i][k]=='*'){
						map[i][k++] = ' ';
						a++;
					}
					k--;
					int height = 1;
					int b = 1;
					for(int d=0;d<3;d++){
						int w = j+move[d];
						if(0<=w&&w<map[i+1].length&&map[i+1][w]=='*'){
							int y = i+1;
							while(y<h&&0<=w&&w<map[y].length&&map[y][w]=='*'){
								height++;
								map[y][w] = ' ';
								y++;
								w += move[d];
							}
							y--;
							w-=move[d];
							w++;
							while(w<map[y].length&&map[y][w]=='*'){
								b++;
								map[y][w] = ' ';
								w++;
							}
							w--;
							int dir = w<k?0:w==k?1:2;
							y = i+1;
							w = k + move[dir];
							while(w<map[y].length&&y<h&&map[y][w]=='*'){
								map[y][w] = ' ';
								y++;
								w+=move[dir];
							}
							break;
						}
					}
					int area = (a+b)*height/2;
					if(ans.containsKey(area)){
						ans.put(area, ans.get(area)+1);
					}
					else{
						ans.put(area, 1);
					}
				}
			}
			PriorityQueue<Integer> q = new PriorityQueue<Integer>();
			for(Integer i:ans.keySet())q.add(i);
			while(!q.isEmpty()){
				int area = q.poll();
				System.out.println(area+" "+ans.get(area));
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back


void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main(){
  string s;
  cin>>s;
  int a[3]={};
  rep(i,s.size()){
    a[s[i]-'a']++;
  }

  sort(a,a+3);

  if(a[2]-a[0]<=1){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }

}



Measured memory_bytes: 512
# 全部試す
# 1つあたりO(M)
# O(M^2) = 10^6くらい
from scipy.sparse.csgraph import dijkstra
N,M = map(int,input().split())
edge = [[int(x) for x in input().split()] for _ in range(M)]

graph = [[0]*(N+1) for _ in range(N+1)]
for a,b in edge:
  graph[a][b] = 1

answer = 0
INF = 10 ** 9
for a,b in edge:
  graph[a][b] = INF
  dist = dijkstra(graph, indices = a, directed = False)
  if dist[b] >= INF:
    answer += 1
  graph[a][b] = 1

print(answer)

Measured memory_bytes: 17476
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(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 bool 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 = "";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+" ";
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
constexpr const ll INF = 1e15;
constexpr const ll MOD = 1000000007;
constexpr const ll MAX = 1e9;
constexpr ll nx[4] = {1,0,-1,0};
constexpr ll ny[4] = {0,1,0,-1};
typedef pair<ll,ll> P;
int main(){
    int n,m;
    cin >> n >> m;
    ll l = 1,r = n;
    if (n%2){
        rep(i,m){
            cout << l << " " << r << endl;
            l++;
            r--;
        }
    }
    else{
        int c = ((n-1)/2+1)/2;
        rep(i,min(c,m)){
            cout << l << " " << r << endl;
            l++;
            r--;
        }
        r--;
        rep(i,m-c){
            cout << l << " " << r << endl;
            l++;
            r--;
        }
    }
}


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

int main()
{
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++)
  {
    if(int(i * 1.08) == n)
    {
      cout << i;
      return 0;
    }
  }
  cout << ":(";
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func main() {
	var X, Y, Z, K int
	fmt.Scan(&X, &Y, &Z, &K)

	A := make([]int, X)
	for i := 0; i < X; i++ {
		fmt.Scan(&A[i])
	}
	B := make([]int, Y)
	for i := 0; i < Y; i++ {
		fmt.Scan(&B[i])
	}
	C := make([]int, Z)
	for i := 0; i < Z; i++ {
		fmt.Scan(&C[i])
	}

	D := make([]int, 0)
	for i := 0; i < X; i++ {
		for j := 0; j < Y; j++ {
			D = append(D, A[i]+B[j])
		}
	}

	sort.Sort(sort.Reverse(sort.IntSlice(D)))

	E := make([]int, 0)
	for i := 0; i < Min(K, len(D)); i++ {
		for j := 0; j < Min(K, len(C)); j++ {
			E = append(E, D[i]+C[j])
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(E)))

	for i := 0; i < K; i++ {
		fmt.Println(E[i])
	}
}


Measured memory_bytes: 110208
def main():
  I=lambda:list(map(int,input().split()))
  n,m=I()
  e=[(I()[0],[1<<n-i for i in I()])for _ in'_'*m]
  I=9**9
  dp=[I]*2**n
  dp[0]=0
  for i,d in enumerate(dp):
    if d==I:continue
    for a,c in e:
      b,x=i,d+a
      for j in c:b|=j
      if dp[b]>x:dp[b]=x
  print(-(dp[-1]==I)or dp[-1])
main()

Measured memory_bytes: 3436
#include<iostream>
#include<algorithm>
#include<vector>
//#include<cmath>
using namespace std;

int ans;

void gcd(int a, int b)
{
	if (a%b == 0) {
		ans = b;
		return;
	}
	else
		gcd(b, a%b);
}

int main(void)
{
	int a, b;
	cin >> a >> b;
	if (a > b)
		gcd(a, b);
	else
		gcd(b, a);
	cout << ans << endl;
	return 0;
}


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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, k;
	cin >> n >> k;

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

	sort(all(a));

	int sum = 0;

	for(int i = n-1; k > 0; k--, i--)
		sum += a[i];

	cout << sum << endl;
	return 0;	
}

Measured memory_bytes: 256
N=int(input())
S=[input()for _ in'_'*N]
z=0
for k in range(-N,0):
	for t in range(N*N):
		i=t//N
		j=t%N
		if S[i][j+k]!=S[j][i+k]:
			break
	else:
		z+=N
print(z)


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

//#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e9 + 7;
const int N = 2e6 + 7;
const int M = 26;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll n,k;
ll f[N];
string s;

ll bnp( ll x , ll y )
{
    if( y == 0 )return 1ll;
    if( (y & 1) ){
        return x * bnp( x , y - 1 ) % mod;
    }else{
        ll b = bnp( x , y / 2 );
        return b * b % mod;
    }
}

ll C( ll x , ll y )
{
    return f[x] * bnp( f[x - y] * f[y] % mod , mod - 2 ) % mod;
}

void solve1()
{
    cin >> k >> s;
    n = (int)s.size();
    ll ans = 0;
    f[0] = 1;
    for( int i = 1; i < N; i++ ){
        f[i] = f[i - 1] * i % mod;
    }
    for( int i = 0; i <= k; i++ ){
        int z = k - i;
        ans += C( z + n - 1 , n - 1 ) * bnp( 25 , z ) % mod * bnp( 26 , i ) % mod;
        ans %= mod;
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 19836
import copy
import bisect

N = int(input())
L = sorted(list(map(int, input().split())))

triangles = 0

for i in range(N - 2):
    P = L[i]
    for j in range(i + 1, N - 1):
        Q = L[j]
        if P + Q <= L[j + 1]:
            continue
        maxR = P + Q - 1
        triangles += bisect.bisect_right(L, maxR) - (j + 1)

print(triangles)


Measured memory_bytes: 3700
def dp(n):
    d=[0]*(n+1)
    if n==1:
        return 1
    else:
         d[0]=1
         if a[1]==0:
            d[1]=1
         else:
            d[1]=0
         for i in range(2,n+1):
            if a[i]==0:
                d[i]=(d[i-1]+d[i-2])%1000000007
            else:
                d[i]=0
         return d[n]

n,m=map(int, input().split())
a=[0]*(n+1)
for i in range(0,m):
    k=int(input())
    a[k]=1
print(dp(n))

Measured memory_bytes: 7668
import math
a, b, h, m = [int(i) for i in input().split()]
theta = math.radians(h / 12 * 360 - m / 60 * 360 + m / 60 / 12 * 360)
print(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(theta)))

Measured memory_bytes: 9420
from collections import deque
h,w=map(int,input().split())
s=[input() for _ in range(h)]
def bfs(i,j):
  seen=[[-1]*w for _ in range(h)]
  todo=deque([(i,j)])
  seen[i][j]=0
  while len(todo)>0:
    (i,j)=todo.popleft()
    if i>0 and seen[i-1][j]==-1 and s[i-1][j]=='.':
      seen[i-1][j]=seen[i][j]+1
      todo.append((i-1,j))
    if i>0 and seen[i-1][j]==-1 and s[i-1][j]=='#':
      seen[i-1][j]=0
    if i<h-1 and seen[i+1][j]==-1 and s[i+1][j]=='.':
      seen[i+1][j]=seen[i][j]+1
      todo.append((i+1,j))
    if i<h-1 and seen[i+1][j]==-1 and s[i+1][j]=='#':
      seen[i+1][j]=0
    if j>0 and seen[i][j-1]==-1 and s[i][j-1]=='.':
      seen[i][j-1]=seen[i][j]+1
      todo.append((i,j-1))
    if j>0 and seen[i][j-1]==-1 and s[i][j-1]=='#':
      seen[i][j-1]=0
    if j<w-1 and seen[i][j+1]==-1 and s[i][j+1]=='.':
      seen[i][j+1]=seen[i][j]+1
      todo.append((i,j+1))
    if j<w-1 and seen[i][j+1]==-1 and s[i][j+1]=='#':
      seen[i][j+1]=0
  return seen[-1][-1]
b=bfs(0,0)
if b==-1:
  print(-1)
  exit()
c=0
for si in s:
  c+=si.count('.')
print(c-b-1)



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

int main(){
    ll a,b, k;
    cin >> a >> b >> k;

    if(a>=k){
        cout << a-k << " " << b << endl;
    }
    else if(a<k and k<=a+b){
        cout << 0  << " " << a+b-k << endl;
    }
    else{
        cout << 0 << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
char s[30];
int main()
{
    int n;
    double total , val;
    scanf("%d" , &n);
    for(int i = 1; i <= n ; i ++)
    {
        scanf("%lf " , &val);
        scanf("%s" , s);
        if(s[0] == 'B')
        {
            total += val * 380000.0;
        }
        else
            total += val ;
    }
    printf("%lf" , total);
}


Measured memory_bytes: 128
#include<stdio.h>
 
int main(){
  int x,i,max,min;
  long sum=0;

  scanf("%d",&x);
  int a[x];
  for(i=0;i<x;i++){
    scanf("%d ",&a[i]);
    sum = sum+a[i];
    if(i==0){
      max=a[i];
      min=a[i];
    }
    if(max<a[i])max=a[i];
    if(min>a[i])min=a[i];
  }
  printf("%d %d %ld\n",min,max,sum);
  return 0;
}


Measured memory_bytes: 2748
S = int(input())
X1 = 0
Y1 = 0
if S <= 10**9:
    X2 = S
    Y2 = 0
    X3 = 0
    Y3 = 1
elif 10**9 < S < 10**18:
    T = S % 10**9
    X2 = 10**9
    Y3 = (S // 10**9) + 1
    X3 = 10**9 - T 
    Y2 = 1
else:
  X2 = 0
  Y2 = 10**9
  X3 = 10**9
  Y3 = 0
print(X1,Y1,X2,Y2,X3,Y3)

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

using namespace std; 

int main(){
	
	int n; 
	
	vector<int> container(101);
	
	cin >> n;
	
	int cont = 0 , ans = 0; 
	
	for(int i=0; i< n; i++){
		cin >> container[i];
		cont+= container[i];
	}
	
	while(1){
		bool ok = false;
		for(int i=0;i<n;i++){
			if(container[i]>0){
				container[i]--;
				cont--;
				ok = true;
			}else{
				if(ok){
					ans+=1;
					ok = false; 
					break;
				}
			}
		}
		
		if(ok) ans+=1;
		
		if(cont == 0) break;
		
	}
	
	cout << ans << endl;
	
	
    return 0;
}


Measured memory_bytes: 256
from collections import deque
H, W = list(map(int, input().split(' ')))
FIELD = list()
for _ in range(H):
    FIELD.append(input())
WHITE_CELL_NUM = 0
for h in range(H):
    for w in range(W):
        if FIELD[h][w] == '.':
            WHITE_CELL_NUM += 1
sh, sw = 0, 0  # start
gh, gw = H - 1, W - 1  # goal
# We can get the maximum score
# when we change colors of cells which are not on the shortest path.
frontier = deque()
ch, cw = sh, sw
frontier.append((ch, cw))
steps = [[-1 for _ in range(W)] for _ in range(H)]
steps[ch][cw] = 0
while len(frontier) > 0:
    ch, cw = frontier.popleft()  # current
    if ch == gh and cw == gw:  # reach goal
        break
    for dh, dw in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
        nh, nw = ch + dh, cw + dw  # next
        if (nh < 0) or (H - 1 < nh) or (nw < 0) or (W - 1 < nw):
            continue
        if FIELD[nh][nw] == '#':
            continue
        if steps[nh][nw] >= 0:
            continue
        steps[nh][nw] = steps[ch][cw] + 1
        frontier.append((nh, nw))
if ch != gh and cw != gw:
    print(-1)
    exit(0)
shortest_path_length = steps[gh][gw] + 1
print(WHITE_CELL_NUM - shortest_path_length)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int H,W,K,dp[110][110],i,j,k,m,M=1e9+7;
int main(){
  cin>>H>>W>>K;
  dp[0][1]=1;
  for(i=1;i<=H;++i)for(k=0;k<1<<(W-1);++k)if(!(k&k/2))for(m=k<<1,j=1;j<=W;++j)(dp[i][j]+=dp[i-1][m>>j&1?j+1:m>>(j-1)&1?j-1:j])%=M;
  cout<<dp[H][K]<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int inf = 1000000000;
int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.rbegin(),a.rend());
    int t = n-1;
    ll ans = 0;
    rep(i,n){
        int lim = 2;
        if(i == 0) lim = 1;
        rep(j,lim){
            if(t > 0){
                ans += a[i];
                t--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const ll MOD = 1000000007;

const int N_MAX = pow(10,5)*2;
const int MM_MAX = pow(10,5);

vector<bool> isp(MM_MAX, true);

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=MM_MAX; i++) {
    if (isp[i]) for(int j=2; i*j<=MM_MAX; j++) isp[i*j] = false;
  }
}

// factorial(階乗)の計算

ll fac[N_MAX+1] ={};

ll c_fac(int n) {
  if (fac[n]!=0) return fac[n];
  if (n==0) return fac[n]=1;
  return fac[n] = (c_fac(n-1)*n)%MOD;
}

// inverse(逆元)の計算

ll inv(ll a,ll m) {
  ll b = m, x = 1, y = 0;
  while (b!=0) {
    ll d = a/b;
    a -= b*d; swap(a, b);
    x -= y*d; swap(x, y);
  }
  return x>=0 ? x : x+m;
}

// combinataionの計算

ll nck(ll n, ll k) { 
  if (n<k) return 0;
  ll nume = fac[n];
  ll deno = ( inv(fac[n-k],MOD) * inv(fac[k],MOD) ) % MOD;
  return ( nume * deno ) % MOD;
}

int main() {
  int N, M; cin >> N >> M;

  sieve(); c_fac(N_MAX);
  int i = 2;
  ll result = 1;
  while (i*i<=M) {
    if (isp[i]) {
      int num = 0;
      while (M%i==0) { num++; M/=i; }
      // cout << i << " " << num << " " << M << endl;
      result *= nck(N-1+num, num);
      result %= MOD;
    }
    i++;
  }
  if (M!=1) {result*=N; result%=MOD;}
  cout << result << endl;
  return 0;
}


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

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

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

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

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

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

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  vector<int> a(N), b(N), c(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  vector<vector<int>> dp(N, vector<int>(3));
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for (int i = 1; i < N; i++) {
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
  }
  cout << max(max(dp[N - 1][0], dp[N - 1][1]), dp[N - 1][2]) << endl;
  return 0;
}

Measured memory_bytes: 6912
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int divisor_num(int x){
  int num = 0;
  int save_val = x;
  for(int i = 1; i * i <= x; i++){
    if(x % i == 0){
      if(i * i == x) num++;
      else num += 2;
    } 
  }
  return num;
}

int main()
{
  int n;
  cin >> n;
  int sum = 0;
  for(int i = 1; i < n; i++){
    sum += divisor_num(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string a, b;
    cin >> a >> b;
    a += b;
    int num = stoi(a);

    bool res = false;
    rep(i, 500) {
        if(i*i == num) {
            res = true;
            break;
        }
    }

    if(res) cout << "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}

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


int main(){
  int n,k;cin >> n >>k;
  vector<vector<int>> vec(n);
  for(int i = 1; i < n; ++i){
    vec[0].push_back(i);
    vec[i].push_back(0);
  }
  int m = n - 1;
  int x = (pow(n-1,2)-n+1)/2;

  int p1 = 1,p2 = 2;
  while(x > k){
    vec[p1].push_back(p2);
    vec[p2].push_back(p1);
    p2++;
    if(p2 >= n){p1++;p2=p1+1;}
    if(p1 >= n){
      p1++;
      p2=p1+1;
      if(p2 >= 0)break;
    }
    m++;
    x--;
  }

  if(x != k){cout << -1 << endl;return 0;}
  cout << m << endl;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < vec[i].size(); ++j){
      if(i < vec[i][j])
	cout << i + 1 << ' ' << vec[i][j] + 1 << endl;
    }
  }
  cout << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int half = n / 2;
    string sub = s.substr(0, half);
    string check = sub + sub;
    if (check == s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
X,Y,A,B,C=map(int,input().split())
P=sorted([int(x) for x in input().split()])
Q=sorted([int(x) for x in input().split()])
R=sorted([int(x) for x in input().split()])

final=sorted(P[A-X:]+Q[B-Y:]+R,reverse=True)

print(sum(final[:X+Y]))

Measured memory_bytes: 23200
//在 POJ 和小白菜中，该库禁用！
//在 USACO中请用文件。
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#define inf 1000000001

using namespace std;
typedef long long ll;

struct e{
	int to,cst;
	e(int x=0,int y=0){
		to=x;cst=y;
	}
};
vector <e> adj[100005];
bool vis[100005],b;
int n,m,l,r,d,dis[100005];
void dfs(int x,int cur_dis){
	vis[x] = true;
	dis[x] = cur_dis;
//	bool f = true;
	for(int i=0;i<adj[x].size();i++){
		if(!vis[adj[x][i].to])
		dfs(adj[x][i].to,cur_dis+adj[x][i].cst);
		else{
			int ndis = cur_dis+adj[x][i].cst;
			if(ndis != dis[adj[x][i].to]) b = 0;
		}
	}
	return;
}
int main(){
//	ios::sync_with_stdio(false);
//	cin.tie(0);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&l,&r,&d);
		adj[l].push_back(e(r,d));
		adj[r].push_back(e(l,-d));
	}
	
	b = true;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			memset(dis,-1,sizeof(dis));
			dfs(i,0);
		}
		if(!b){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
  return 0;
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

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

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template<typename T, typename U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}
template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        print(a);
    }
    cout << endl;
}


int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> b(n);
    rep(i,n) cin >> b[i];

    ll ans = INF;
    rep(i,(1LL << n)){
        vector<Pll> odd, even;
        rep(j,n){
            if((i >> j) & 1){
                if(j & 1)odd.emplace_back(a[j],j);
                else odd.emplace_back(b[j],j);
            }
            else {
                if(j & 1)even.emplace_back(b[j],j);
                else even.emplace_back(a[j],j);
            }
        }
        if(odd.size() != n/2 && even.size() != (n+2-1)/2)continue;
        sort(all(even));
        sort(all(odd));
        vector<Pll> vec;
        rep(i,even.size()){
            vec.emplace_back(even[i]);
            if(i < odd.size())vec.emplace_back(odd[i]);
        }
        bool ok = true;
        rep(i,n-1)if(vec[i].first > vec[i+1].first){ok = false;continue;}
        if(!ok)continue;

        ll t = 0;
        rep(i,n)rep(j,n){
            if(i >= j)continue;
            if(vec[i].second > vec[j].second)++t;
        }
        // if(chmin(ans,t)){
        //     debug(i);
        //     print(odd);
        //     print(even);
        //     print(vec);
        // }
        chmin(ans,t);
    }

    cout << (ans == INF ? -1 : ans) << endl;
}

Measured memory_bytes: 256