akhauriyash/Code-Regression huggingface dataset:
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANNOT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795

 #define ll long long
 #define int long long
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
#define MAXN 402
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}

void solve()
{
    ll n;cin>>n;
    n = n%10;
    if(n==4 ||n==2 ||n==5 ||n==7||n==9)
        cout<<"hon"<<endl;
    else if(n==3)cout<<"bon"<<Endl;
    else cout<<"pon"<<endl;
}

signed main()
{
 
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//   }
   
    solve();
    return 0;
}


Measured memory_bytes: 3600
// Problem : D - Non-decreasing
// Contest : AtCoder Regular Contest 086
// URL : https://atcoder.jp/contests/arc086/tasks/arc086_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define temptts template <class T, class... Ts>

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

int n, mn = inf, mx = -inf, pmn, pmx, a[N];
vector<pair<int, int>> ans;

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (mn > a[i]) {
			mn = a[i];
			pmn = i;
		}
		if (mx < a[i]) {
			mx = a[i];
			pmx = i;
		}
	}
	if (mx >= 0 && mn <= 0) {
		if (mx >= -mn) for (int i = 1; i <= n; i++) {
			if (i != pmx) {
				a[i] += mx;
				ans.push_back({pmx, i});
			}
		} else for (int i = 1; i <= n; i++) {
			if (i != pmn) {
				a[i] += mn;
				ans.push_back({pmn, i});
			}
		}
	}
	mn = inf, mx = -inf;
	for (int i = 1; i <= n; i++) {
		if (mn > a[i]) {
			mn = a[i];
			pmn = i;
		}
		if (mx < a[i]) {
			mx = a[i];
			pmx = i;
		}
	}
	if (mn >= 0) {
		for (int i = 2; i <= n; i++) {
			ans.push_back({i - 1, i});
		}
	} else {
		for (int i = n - 1; i >= 1; i--) {
			ans.push_back({i + 1, i});
		}
	}
	cout << size(ans) << '\n';
	for (auto& x : ans) {
		cout << x.first << ' ' << x.second << '\n';
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 //~ #define int ll
int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
int sub(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=10001;

void solve(){
	int a,b;
	cin>>a>>b;
	if((a+b)&1)cout<<"IMPOSSIBLE";
	else cout<<(a+b)/2;
	
	
	
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<int> VI;

int main(){
    int N;
    cin >> N;
    VI V(N);

    REP(i,N) {
        cin >> V[i];
    }

    VI dp(N);
    dp[0] = 0;
    dp[1] = abs(V[1]-V[0]);

    for(int i = 2; i < N; i++){
        dp[i] = min(abs(V[i]-V[i-1])+dp[i-1],abs(V[i]-V[i-2])+dp[i-2]);
    }
    cout << dp[N-1]<<endl;  
    return 0;
}
   


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int n;
    cin >> n;

    cout << ((n * 800) - (int(n / 15) * 200)) << endl;

    return 0;
}


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

using namespace std;

struct point
{
	int x, y, id;
} p[100005];

vector< pair<int, pair<int, int> > > q;

bool cmpx(point a, point b)
{
	if (a.x != b.x) return a.x > b.x;
	else return a.y > b.y;
}

bool cmpy(point a, point b)
{
	if (a.y != b.y) return a.y > b.y;
	else return a.x > b.x;
}

int up[100005];

void makesets()
{
	for (int i = 0; i < 100001; i++)
	{
		up[i] = -1;
	}
}

int Find(int x)
{
	if (up[x] < 0) return x;
	int root = Find(up[x]);
	up[x] = root;
	return root;
}

void Union(int x, int y)
{
	if (Find(x) == Find(y)) return;
	if (up[x] < up[y])
	{
		up[x] += up[y];
		up[y] = x;
	}
	else
	{
		up[y] += up[x];
		up[x] = y;
	}
}

int n;

signed main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d%d", &p[i].x, &p[i].y);
		p[i].id = i;
	}
	sort(p+1, p+1+n, cmpx);
	for (int i = 1; i < n; i++)
	{
		q.push_back(make_pair(p[i].x - p[i+1].x, make_pair(p[i].id, p[i+1].id)));
	}
	sort(p+1, p+1+n, cmpy);
	for (int i = 1; i < n; i++)
	{
		q.push_back(make_pair(p[i].y - p[i+1].y, make_pair(p[i].id, p[i+1].id)));
	}
	sort(q.begin(), q.end());
	makesets();
	long long res = 0;
	for (int i = 0; i < q.size(); i++)
	{
		int u = q[i].second.first, v = q[i].second.second;
		if (Find(u) != Find(v))
		{
			Union(Find(u), Find(v));
			res += q[i].first;
		}
	}
	printf("%lld", res);
}

Measured memory_bytes: 6132
#include <stdio.h>
#include <string.h>
int main(){

  char s[100];
  int i;
  for(i=0;i<100;i++){
    scanf("%c",&s[i]);
  }
  int f=0,d=1;
  for(i=0;i<100;i++){
  	if( d%2 ==0 && s[i] == 'R'){
  		printf("No\n");
      	f=1;
        break;
  	}else if(d%2 == 1 && s[i] == 'L'){
        printf("No\n");
        f=1;
        break;
  	}
    d++;
  }
  
  if(f == 0) printf("Yes\n");
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    ll n;
    cin >> n;

    string ans;
    while(n) {
        n--;
        ans += 'a'+n%26;
        n /= 26;
    }
    reverse(all(ans));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(void)
{
	int a, b, x;
	cin >> x >> a >> b;
	if (abs(x - a) > abs(x - b)) {
		cout << "B" << endl;
	}
	else {
		cout << "A" << endl;
	}

	return (0);

}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> as(n), bs(n), cs(n);
    for(int i = 0; i < n; i++){ cin >> as[i]; }
    for(int i = 0; i < n; i++){ cin >> bs[i]; }
    for(int i = 0; i < n; i++){ cin >> cs[i]; }
    sort(as.begin(), as.end());
    sort(bs.begin(), bs.end());
    sort(cs.begin(), cs.end());
    prints(as, bs, cs);
    vector<ll> b2;
    for(int i = 0; i < n; i++){
        int b = bs[i];
        b2.push_back(cs.end() - upper_bound(cs.begin(), cs.end(), b));
    }
    prints(b2);
    for(int i = n - 2; i >= 0; i--){
        b2[i] += b2[i + 1];
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        int a = as[i];
        int bi = upper_bound(bs.begin(), bs.end(), a) - bs.begin();
        prints(bi);
        if(bi < n){
            ans += b2[bi];
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 2552
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define endl "\n"
    #define sz(x) (int)(x).size()
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    ll mod =(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) return 1;
    	if (p == 2 || (p & 1)) return mult(x, binpow(x, p - 1));
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    // bool check(ll x){}
    ll binsearch(ll l,ll r)
    {
        while(l<r)
        {
            ll mid=(l+r)/2;
            // if(check(mid))r=mid;
            // else l=mid+1;
        }
        return l;
    }
    const ll man=(ll)1005;
    vector<ll>adj[man];
    bool vis[man][man];
    ll d[man],depth[man],par[man];
    void addedge(ll u,ll v){adj[u].pb(v);adj[v].pb(u);}
    ll dx[4]={1,-1,0,0};ll dy[4]={0,0,1,-1};
/*........................................................................................................................*/

signed main()/*Check flow...question galat mat padhna */
{
    fast;  
    ll n;
    cin>>n;
    ll x=0;
    ll a[n];
    For(i,n)
    {
        cin>>a[i];
        x^=a[i];
    }
    For(i,n)
    {
        cout<<(x^a[i])<<endl;
    }
}      


Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    map<int,int> m;
    for(int i=0;i<n;i++){
        m[A[i]]++;
    }
    for(int i=0;i<n;i++){
        A[i]++;
        m[A[i]]++;
    }
    for(int i=0;i<n;i++){
        A[i] -= 2;
        m[A[i]] ++;
    }
    int ans = 0;
    for(auto x:m){
        ans = max(ans,x.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define  ll  long long
ll a[105];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,n,m,l,r,s=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<(a[n-1]-a[0])<<"\n";
    return 0;
}



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

int bva[2005][2005], be1[2005][2005], be2[2005][2005];
int va[2005][2005], e1[2005][2005], e2[2005][2005], r, c, q;
char buf[2005][2005];

void upd(int bit[2005], int x, int v)
{
	for (;x < 2005;x+=x&-x) bit[x] += v;
}

void upd(int bit[2005][2005], int x, int y, int v)
{
	for (;x < 2005;x+=x&-x) upd(bit[x], y, v);
}

int qu(int bit[2005], int x)
{
	int v = 0;
	for (;x;x-=x&-x) v += bit[x];
	return v;
}

int qu(int bit[2005][2005], int x, int y)
{
	int v = 0;
	for (;x;x-=x&-x) v += qu(bit[x], y);
	return v;
}

int qu(int bit[2005][2005], int r1, int c1, int r2, int c2)
{
	return qu(bit, r2, c2)-qu(bit, r1-1, c2)-qu(bit, r2, c1-1)+qu(bit, r1-1, c1-1);
}

int main()
{
	scanf("%d%d%d", &r, &c, &q);
	for (int i = 1;i <= r;i++) scanf("%s", buf[i]+1);
	for (int i = 1;i <= r;i++) for (int j = 1;j <= c;j++)
	{
		va[i][j] = buf[i][j]-'0';
		e1[i][j] = va[i][j]&va[i-1][j];
		e2[i][j] = va[i][j]&va[i][j-1];
		upd(bva, i, j, va[i][j]);
		upd(be1, i, j, e1[i][j]);
		upd(be2, i, j, e2[i][j]);
	}
	while (q--)
	{
		int r1, c1, r2, c2; scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
		int ans = qu(bva, r1, c1, r2, c2) - qu(be1, r1+1, c1, r2, c2) - qu(be2, r1, c1+1, r2, c2);
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 99968
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	static Integer dp[][];

	static int maxhappiness(int n, int prev, int a[], int b[], int c[])
	{
		if(n==0)
			return 0;

		if(dp[n][prev]!=null)
			return dp[n][prev];

		int max = -1;
		if(prev==1)
		{
			int temp = Math.max(b[n-1]+maxhappiness(n-1, 2, a, b, c), c[n-1]+maxhappiness(n-1, 3, a, b, c));
			max = Math.max(max, temp);
		}
		if(prev==2)
		{
			int temp = Math.max(a[n-1]+maxhappiness(n-1, 1, a, b, c), c[n-1]+maxhappiness(n-1, 3, a, b, c));
			max = Math.max(max, temp);
		}
		if(prev==3)
		{
			int temp = Math.max(a[n-1]+maxhappiness(n-1, 1, a, b, c), b[n-1]+maxhappiness(n-1, 2, a, b, c));
			max = Math.max(max, temp);
		}
		if(prev==0)
		{
			int temp = Math.max(a[n-1]+maxhappiness(n-1, 1, a, b, c), c[n-1]+maxhappiness(n-1, 3, a, b, c));
			temp = Math.max(temp, b[n-1]+maxhappiness(n-1, 2, a, b, c));
			max = Math.max(max, temp);
		}
		return dp[n][prev]=max;
	}

	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int a[]=new int[n];
		int b[]=new int[n];
		int c[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=scan.nextInt();
			b[i]=scan.nextInt();
			c[i]=scan.nextInt();
		}

		dp=new Integer[n+1][4];

		int ans = maxhappiness(n, 0, a, b, c);
		System.out.println(ans);
	}
}

Measured memory_bytes: 124388
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		while(true){
			String[] array = br.readLine().split(" ");
	        int x = Integer.parseInt(array[0]);
	        int y = Integer.parseInt(array[1]);
	        if(x==0&&y==0){
	        	break;
	        }else if(x>y){
	        	sb.append(y+" "+x+"\n");
	        }else{
	        	sb.append(x+" "+y+"\n");
	        }
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 25000
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 入力数字の数 */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			Map<Integer, Integer> map = new HashMap<>();
			IntStream.range(0, N).forEach(i -> {
				int a = scanner.nextInt();
				map.put(a, map.getOrDefault(a, 0) + 1);
			});
			System.out
					.println(map.entrySet().stream().filter(entry -> entry.getValue() == 1).findFirst().get().getKey());
		}
	}
}


Measured memory_bytes: 36160
program main
      implicit none
      integer :: h1, m1, h2, m2, k
      integer :: str, fin, ans

      read *, h1, m1, h2, m2, k
      
      str = h1*60+m1
      fin = h2*60+m2

      ans = fin-str-k
      print *, ans

end program main



Measured memory_bytes: 2856
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (long) 1e9 + 7;

int main(){
    
    int n;
    vector<int> v(3,0);
    cin >> n >> v[0] >> v[1] >> v[2];
    
    vector<int> fi(n,0), se(n,0), ans(n,0);
    
    rep(i,n){
        string s;
        cin >> s;
        fi[i] = s[0] - 'A';
        se[i] = s[1] - 'A';
    }
    
    rep(i,n){
        
        if(v[fi[i]] > v[se[i]]){
            v[fi[i]]--;
            v[se[i]]++;
            ans[i] = se[i];
        } else if(v[fi[i]] < v[se[i]]){
            v[fi[i]]++;
            v[se[i]]--;
            ans[i] = fi[i];
        } else if(v[fi[i]] == 0){
            cout << "No" << "\n";
            return 0;
        } else if(i == n - 1){
            v[fi[i]]++;
            v[se[i]]--;
            ans[i] = fi[i];
        } else if(fi[i] == fi[i + 1] || fi[i] == se[i + 1]){
            v[fi[i]]++;
            v[se[i]]--;
            ans[i] = fi[i];
        } else {
            v[fi[i]]--;
            v[se[i]]++;
            ans[i] = se[i];
        }
    }
    
    cout << "Yes" << "\n";
    
    rep(i,n) printf("%c\n",'A' + ans[i]);
    
    return 0;
}


Measured memory_bytes: 3892
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

const int I_MAX = 26;

void calc_point(int& d, VI& c, VI2D& s, VI& t) {
	int point = 0;
	VI last(I_MAX + 1, 0);
	REP(i, d) {
		point += s[i][t[i]];
		last[t[i]] = i + 1;
		int down = 0;
		REP(j, I_MAX) { down += c[j] * ((i + 1) - last[j]); }
		point -= down;
		cout << point << endl;
	}
}

int main() {
	int d;
	cin >> d;
	VI c(I_MAX);
	REP(i, I_MAX) { cin >> c[i]; }
	VI2D s(d, VI(I_MAX));
	REP(i, d) {
		REP(j, I_MAX) { cin >> s[i][j]; }
	}
	VI t(d);
	REP(i, d) {
		int tmp;
		cin >> tmp;
		t[i] = tmp - 1;
	}
	calc_point(d, c, s, t);
	return 0;
}


Measured memory_bytes: 3644
i=3;main(n,j){for(scanf("%d",&n);j=n-i+1&~1,n>3&5000<j;i+=3);for(i=n-j;i;printf(n<4?i=0,"2 3 25":"%d ",2*i--))for(;j;printf("%d ",6*j---3));}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
C, A = list(map(lambda x: x[0], A)), list(map(lambda x: x[1:], A))
ans = 10**18
for i in range(2**n):
    M = [0]*m
    cost = 0
    for j in range(n):
        if (i>>j)&1:
            cost += C[j]
            for k in range(m):
                M[k] += A[j][k]
                
    
    if all([mm >= x for mm in M]): ans = min(ans, cost)
print(ans if ans!=10**18 else '-1')


Measured memory_bytes: 9224
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    A, B, C = Scanner.map_int()
    if A == B == C and A % 2 == B % 2 == C % 2 == 0:
        print(-1)
        return
    ans = 0
    while A % 2 == B % 2 == C % 2 == 0:
        a, b, c = A//2, B//2, C//2
        A, B, C = b+c, c+a, a+b
        ans += 1
    print(ans)
    return


if __name__ == "__main__":
    main()


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

# import sys
# import math
# sys.setrecursionlimit(10**8)
# INF = float('inf')
# PI = math.pi()
# from functools import lru_cache
# @lru_cache(maxsize=None)
t = input()
# a, b = map(int, input().split())
# c = list(map(int, input().split()))
# s = [list(map(int,list(input()))) for i in range(h)]

tt = t.replace('?','D')
print(tt)


Measured memory_bytes: 9500
#include<bits/stdc++.h>
using namespace std;
long long p=1000000007ll;
long long n,k,dp[10001];
long long quickpow(long long a,long long b)
{
	if(b<0) return 1;
	if(b==0&&n>1) return 1;
	if(b==0&&n==1) return 0;
	if(b==1) return a%p;
	if(b%2==0)
	{
		long long t=quickpow(a,b/2);
		return t*t%p;
	}
	else
	{
		long long t=quickpow(a,b/2);
		t=t*t%p;
		return t*a%p;
	}
}

int main(){
    cin>>n>>k;
    dp[0]=1;
    for(int i=1;i<n;i++)
	{
		for(int j=i;j>0;j--)
			dp[j]=(dp[j+1]+dp[j-1])%p;
		dp[0]=dp[1];
	}
	cout<<(long long)(dp[n-k]*quickpow(2,n-k-1)%p)<<endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars
    }
    let mut r = 0;
    let mut b = 0;
    for c in s {
        if c == '0' {
            r += 1;
        } else {
            b += 1;
        }
    }
    println!("{}", std::cmp::min(r, b) * 2);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
    int w, h, x, y, r;
    
    cin >> w >> h >> x >> y >> r;
    if (x<w && x<h && y<w && y<h && x+r<=w && y+r<=h && x-r>=0 && y-r>=0)
     cout << "Yes" << endl;
    else
      cout << "No"<< endl;
   
    return 0;
}


Measured memory_bytes: 3116
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

H, W = MAP()
M = [input().rstrip() for _ in range(H)]

for h in range(H):
	for w in range(W):
		if M[h][w] == '#':
			# print(h, w)
			cnt = 0
			for dh, dw in [[-1,0],[0,1],[1,0],[0,-1]]:
				nh = h+dh
				nw = w+dw
				if nh < H and nh >= 0 and nw < W and nw >= 0:
					cnt += 1
					if M[nh][nw] == '.':
						cnt -= 1
			if cnt == 0:
				print('No')
				sys.exit()

print('Yes')

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

const int mod = 1000000007; 

int main() {
  int s;
  cin >> s;
  vector<ll> dp(s+1);
  // dp[n] = number of sequences whose terms are all integers 
  // greater than or equal to 3 and whose sum is equal to n

  dp[0] = 1;  // there is only one way to get sum 0: take nothing
  for (int sum = 3; sum <= s; sum++) {
    for (int elmt = 3; elmt <= sum; elmt++) {
      dp[sum] += dp[sum-elmt];
      dp[sum] %= mod;
    }
  }
  cout << dp[s];
}

/*
*****Another approach*****
For example, dp[0] to dp[9] will be:
dp[0] -> {9}
dp[1] -> {}
dp[2] -> {}
dp[3] -> {3}
dp[4] -> {4}
dp[5] -> {5}
dp[6] -> {6},{3,3}
dp[7] -> {7},{3,4},{4,3}
dp[8] -> {8},{3,5},{4,4},{5,3}
dp[9] -> {9},{3,6},{4,5},{5,4},{6,3},{3,3,3}

By adding number into each sequence to dp[6] that makes the sum of a sequence to be 9,
one can see that all sequences of dp[9] appears in dp[0] to dp[6]
dp[0] -> {9}
dp[3] -> {3,6}
dp[4] -> {4,5}
dp[5] -> {5,4}
dp[6] -> {6,3},{3,3,3}

Therefore,
dp[9] = dp[0] + dp[1] + ... + dp[6]
Generalize above,
dp[n] = dp[0] + dp[1] + ... + dp[n-3] --- (1)
Moreover,
dp[n+1] = dp[0] + dp[1] + ... + dp[n-3] + dp[n-2]
        = dp[n] + dp[n-2]
Thus,
dp[n] = d[n-1] + dp[n-3] --- (2)

Use (1) or (2)

'''
dp[0] = 1; dp[1] = 0; dp[2] = 0;
for (int i = 3; i <= s; i++) {
  dp[i] = dp[i-1] + dp[i-3];  // (2)
  dp[i] %= mod;
}
'''
*/


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
using ll=long long;
using ld=long double;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "agc033F"
int n, m;
bitset <2000> f[2000];
vector <int> g[2000];
queue <pair <int, int>> q;
bitset <2000> sub[2000];
bitset <2000> head[2000];
bitset <2000> full;
int lca[2000][2000];
vector <int> ch[2000];
bool reach[2000];
int branch[2000][2000];
void dfs(int u){
    reach[u]=1;
    ch[u].pb(u);
    lca[u][u]=u;
    for(int v: g[u]) if(!reach[v]){
        head[v]=head[u];
        head[v][u]=1;
        dfs(v);
        for(int x: ch[u]) for(int y: ch[v]) lca[x][y]=lca[y][x]=u;
        for(int y: ch[v]){
            branch[u][y]=v;
            ch[u].pb(y);
        }
    }
    for(int x: ch[u]) sub[u][x]=1;
}
int main(){
    #ifdef Aria
        if(fopen(taskname".in", "r"))
            freopen(taskname".in", "r", stdin);
    #endif // Aria
    read(n);
    read(m);
    FFOR(i, 0, n) full[i]=1;
    FFOR(i, 1, n){
        int a, b;
        read(a);
        read(b);
        a--;
        b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    FOR(i, 1, m){
        int a, b;
        read(a);
        read(b);
        a--;
        b--;
        f[a][b]=1;
        f[b][a]=1;
        q.push(mp(a, b));
    }
    FFOR(i, 0, n) f[i][i]=1;
    dfs(0);
    while(!q.empty()){
        auto a=q.front().first;
        auto b=q.front().second;
        q.pop();
//        cerr<<a<<' '<<b<<'\n';
        bitset <2000> now;
        if(lca[a][b]==b) swap(a, b);
        if(lca[a][b]==a) now=(full^sub[branch[a][b]])|sub[b]|head[b];
        else{
            now=sub[a]|sub[b]|(head[a]^head[b]);
            now[lca[a][b]]=1;
        }
//        for(int i=0; i<n; i++) cerr<<now[i]<<" \n"[i+1==n];
        bitset <2000> nx=(now&f[a])&(full^f[b]);
        for(int c=nx._Find_first(); c<2000; c=nx._Find_next(c)){
            f[b][c]=1;
            f[c][b]=1;
            q.push(mp(b, c));
        }
                      nx=(now&f[b])&(full^f[a]);
        for(int c=nx._Find_first(); c<2000; c=nx._Find_next(c)){
            f[a][c]=1;
            f[c][a]=1;
            q.push(mp(a, c));
        }
    }
    int ans=0;
    FFOR(i, 0, n) ans+=f[i].count()-1;
    writeln(ans/2);
}

Measured memory_bytes: 60212
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n, r;
    cin >> n >> r;
    int inner;
    if (n >= 10) inner = r;
    else inner = r + 100*(10-n);
    cout << inner << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


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

int main(){
  int n; cin >> n;
  int a[2][n];
rep(i,2){rep(j,n){
cin >> a[i][j];
}}
if(n==1){
cout << a[0][0]+a[1][0] << endl;
return 0;}
int dp[2][n];
dp[0][0]=a[0][0];
dp[1][0]=dp[0][0]+a[1][0];
for(int i=1;i<n;i++){
dp[0][i]=dp[0][i-1]+a[0][i];
dp[1][i]=max(dp[1][i-1],dp[0][i]) + a[1][i];}
cout << dp[1][n-1] << endl;}


  

Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 21:06:58
*/

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


int main(){
    int a;
    cin >> a;
    if(a==1) printf("Hello World\n");
    else{
        int i,j;
        cin >> i >> j;
        printf("%d\n",i+j);         
    }
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int S, a, b;
    cin >> S;
    a = S / 100;
    b = S % 100;
    if (a == 0 || a > 12)
    {
        if (b == 0 || b > 12)
        {
            cout << "NA" << endl;
        }
        else
        {
            cout << "YYMM" << endl;
        }
    }
    else
    {
        if (b == 0 || b > 12)
        {
            cout << "MMYY" << endl;
        }
        else
        {
            cout << "AMBIGUOUS" << endl;
        }
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int a = in.nextInt();
		int r = a + a * a + a * a * a;
		System.out.println(r);
	}
}

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

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

    set<int> se; // 3200 以下で登場する色の種類数
    int over_num = 0; // 3200 以上の人数
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (a >= 3200) ++over_num;
        else se.insert(a/400);
    }
        
    int Max = (int)se.size() + over_num;
    int Min = 0;
    if (se.size() == 0) Min = 1;
    else Min = (int)se.size();
        
    cout << Min << " " << Max << endl;
}
//setで解く方法

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef ONLINE_JUDGE
const int N = 1e6+10;
#else
const int N = 111;
#endif


int n, x, a[N];
ll ans;
ll dp[22][53][3333];

void DP(int m) {
	int s = 0, cur = 0;
	memset(dp[cur],0,sizeof dp[0]);
	dp[0][0][0] = 1;
	REP(i,1,n) { 
		cur ^= 1;
		memcpy(dp[cur],dp[!cur],sizeof dp[0]);
		REP(j,0,m) REP(k,0,s) {
			dp[cur][j+1][k+a[i]]+=dp[!cur][j][k];
		}
		s += a[i];
	}
	ans += dp[cur][m][m*x];
}

int main() {
	cin>>n>>x;
	REP(i,1,n) cin>>a[i];
	REP(k,1,n) DP(k);
	printf("%lld\n", ans);
}









Measured memory_bytes: 4352
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        int x = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();
        String cnt;
        
        if(b - a <= 0)cnt = "delicious";
        else if(b - a > 0 && b - a <= x)cnt = "safe";
        else cnt = "dangerous";
        
        System.out.println(cnt);
	  }
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

vec eratosthenes(ll n) {
    vector<bool> sieve(n+1, true);
    vector<ll> table;
    sieve[0] = sieve[1] = false;
    for (ll i = 2; i <= n; i++) {
        if (sieve[i]) {
            table.push_back(i);
            for (ll j = 2; i * j <= n; j++) {
                sieve[i * j] = false;
            }
        }
    }

    return table;
}

template <typename T>
struct PrimeFact {
    vector<T> spf;
    PrimeFact(T N) { init(N); }
    void init(T N) { // 前処理。spf を求める
        spf.assign(N + 1, 0);
        for (T i = 0; i <= N; i++) spf[i] = i;
        for (T i = 2; i * i <= N; i++) {
            if (spf[i] == i) {
                for (T j = i * i; j <= N; j += i) {
                    if (spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }
    map<T, T> get(T n) { // nの素因数分解を求める
        map<T, T> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        return m;
    }
};

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

    ll N;
    cin >> N;

    vec table = eratosthenes(1e4);
    // cout << table.size() << "\n";
    ll ans = 0;

    PrimeFact<ll> pf(1e7+1);

    for (ll i = 1; i <= N; i++) {
        map<ll, ll> cnt = pf.get(i);

        ll now = 1;
        for (auto e : cnt) {
            now *= e.second + 1;
        }

        ans += i * now;
    }

    cout << ans << endl;


}

Measured memory_bytes: 81340
cards = [[False for i in range(13)] for j in range(4)]
mark = ["S", "H", "C", "D"]

n = int(input())
for i in range(n):
    m, x = input().split()
    x = int(x)
    cards[mark.index(m)][x-1] = True
    
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(mark[i], j+1)


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> a(M,0);
    vector<ll> b(M,0);
    for(ll i=0;i<M;i++){
        cin>>a[i]>>b[i]
    ;}
    ll ans=0;
    for(ll i=0;i<M;i++){
        //1からいけるかどうか
        vector<bool> check(N+1,0);
        check[1]=1;
        for(ll k=0;k<N;k++){
        for(ll j=0;j<M;j++){
            if(j==i)continue;
            if(check[a[j]]==1||check[b[j]]==1){
                check[a[j]]=1;check[b[j]]=1;
            }
        ;}}
        bool notok=0;
        for(ll j=1;j<=N;j++){
            if(!check[j]){notok=1;break;}
        ;}
        if(notok){ans++;}
    ;}
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S,T;
    cin >> S >> T;

int a = 0;
if(S.at(0) == T.at(0)){
    a++;
}

if(S.at(1) == T.at(1)){
    a++;
}

if(S.at(2) == T.at(2)){
    a++;
}
cout << a << endl;
}


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

// 插入此處
const int MAXN = 2e5 + 2;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    vector<int> A(MAXN);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    int ma = A[0];
    LL ans = 0;
    for (int i = 1; i < N; ++i) {
        ans += max(0, ma - A[i]);
        ma = max(ma, A[i]);
    }
    cout << ans << endl;
    return 0;
}


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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		// 解説見た後

		// 標準入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		ArrayList<Integer> nums = new ArrayList<Integer>();

		int so = 7;

		for (int i = 0; i < n; i++) {
			while (true) {
				so++;
				boolean sosuflag = true;
				for (int j = 2; j < so; j++) {
					if (so % j == 0) {
						sosuflag = false;
						break;
					}
				}
				if (sosuflag && so % 5 == 1) {
					nums.add(so);
					break;
				}
			}

		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(nums.get(i) + " ");
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb);

	}

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define db double
#define inf 0x3f3f3f3f
using namespace std;

const int N=5e5+10,mod=1e9+7;


ll fac[N],inv[N];
ll ksm(ll a,ll n){
	ll ans=1;
	while(n){
		if(n&1) ans=ans*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans;
}
ll C(int m,int n){
	return fac[m]*inv[m-n]%mod*inv[n]%mod;
}
ll A(int m,int n){
	return fac[m]*inv[m-n]%mod;
}


int main(){
	int n,m;
	cin>>n>>m;
	fac[0]=1;
	for(int i=1;i<=m;i++) fac[i]=fac[i-1]*i%mod;
	inv[m]=ksm(fac[m],mod-2);
	for(int i=m-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	ll ans=0;
	for(int i=0;i<=n;i++) ans+=C(n,i)*((i&1)?-1:1)*A(m-i,n-i)%mod;
	ans=(ans%mod+mod)%mod;
	ans=(ans*A(m,n)%mod);
	cout<<ans<<endl;	
}
 

Measured memory_bytes: 11448
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<int,int>
#define mp make_pair
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    ii R =mp(1,n);
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        R.fr = max(R.fr , x);
        R.sc = min(R.sc , y);
    }
    if(R.fr <= R.sc)
    {
        cout<<R.sc-R.fr+1<<endl;
    }
    else
        cout<<0<<endl;
    return 0;
}


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

Measured memory_bytes: 1676
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		if(s.length % 2 ==1) {
			System.out.println("No");
			return;
		}
		for(int i = 0;i <s.length;i++) {
			if(i %2 == 1) {
				if(!s[i].equals("i")) {
					System.out.println("No");
					return;
				}
			}else {
				if(!s[i].equals("h")) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 5e5 + 10;
const ll mod = 1e9 + 7;
int n, m;
int sx, sy, tx, ty;
char mz[1010][1010];
int leg(int x, int y) {
	return x >= 1 && x <= n && y >= 1 && y <= m && mz[x][y] == '.';
}
int dx[]{ 0,0,-1,1 };
int dy[]{ -1,1,0,0 };
typedef pair<int, int>pii;
typedef pair<int, pii>ppii;
deque<ppii>q;
int d[1010][1010];
int bfs() {
	q.push_back({ 0,{sx,sy} });
	memset(d, 0x3f, sizeof(d));
	d[sx][sy] = 0;
	while (!q.empty()) {
		ppii tp = q.front(); q.pop_front();
		int x = tp.second.first, y = tp.second.second, di = tp.first;
		if (di > d[x][y])continue;
		if (x == tx && y == ty)return di;
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				if (!leg(i + x, j + y))continue;
				if (d[i + x][j + y] > di + 1) {
					d[i + x][j + y] = di + 1;
					q.push_back({ d[i + x][j + y],{i + x,j + y} });
				}
			}
		}
		for (int i = 0; i < 4; i++) {
			int nx = dx[i] + x, ny = dy[i] + y;
			if (leg(nx, ny) && d[nx][ny] > di) {
				d[nx][ny] = di;
				q.push_front({ d[nx][ny],{nx,ny} });
			}
		}
	}
	return -1;
}
int main() {
	scanf("%d%d", &n, &m);
	scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
	for (int i = 1; i <= n; i++)scanf("%s", mz[i] + 1);
	printf("%d\n", bfs());
	return 0;
}

Measured memory_bytes: 8840
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    vector<pair<size_t, size_t>> a{};
    a.reserve(n);
    for (size_t i = 0; i < n; ++i) {
        size_t j;
        cin >> j;
        a.emplace_back(j, i + 1);
    }
    sort(begin(a), end(a));
    for (size_t i = 0; i < n; ++i) {
        if (i > 0)
            cout << ' ';
        cout << a[i].second;
    }
    cout << endl;
    return 0;
}

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

int A[100]={0};
int l,n,r;

int solve();

int main(){
  int i,j,k,ans=0;
  while(1){
    cin >> n >> l >> r;
    if(n+l+r==0)break;
    ans = 0;
    for(i=0;i<n;i++)cin >> A[i];
    ans = solve();
    cout << ans << endl;
  }
  return 0;
}

int solve(){
  int i,j,now,countn=0;
  for(i=l;i<=r;i++){
    now = i;
    for(j=0;j<n;j++){
      if(j%2==0&&now%A[j]==0){
	countn++;
	break;
      }
      else if(j%2==1&&now%A[j]==0)break;
      if(j==n-1){
	if(n%2==0)countn++;
      }
    }
  }
  return countn;
}



Measured memory_bytes: 2996