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

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (stderr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 1e9, MOD = INF + 7;

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

const int N = 1e5 + 20;

int M, pre[N], suf[N];
int dp[N][2]; 
// dp[v][0] = ans for subtree v if v is black
// dp[v][1] = when v is black and none of nodes in subtree of v is black
vi g[N];

void dfs1(int v, int par = 0) {
	dp[v][0] = 1;
	for(int u : g[v]) if (u != par) {
		dfs1(u, v);
		dp[v][0] = (dp[v][0] * (1 + dp[u][0])) % M;
	}
}

void dfs2(int v, int par = 0) {
	vi childs;
	for(int u : g[v]) if (u != par) childs.push_back(u);
	pre[0] = 1;
	for(int i = 0; i < childs.size(); i++) pre[i + 1] = (pre[i] * (1 + dp[childs[i]][0])) % M;
	suf[childs.size()] = 1;
	for(int i = childs.size() - 1; i >= 0; i--) suf[i] = (suf[i + 1] * (1 + dp[childs[i]][0])) % M;
	for(int i = 0; i < childs.size(); i++) dp[childs[i]][1] = 1 + ((((pre[i] * suf[i + 1]) % M) * dp[v][1]) % M);
	for(int u : childs) dfs2(u, v);
}

int32_t main(){

    sync;

    int n; cin >> n >> M;
    for(int i = 0; i < n - 1; i++) {
    	int v, u; cin >> v >> u;
    	g[v].push_back(u);
    	g[u].push_back(v);
    }

    dfs1(1);
    dp[1][1] = 1;
    dfs2(1);

    for(int i = 1; i <= n; i++) cout << (dp[i][0] * dp[i][1]) % M << endl;

    return 0;
}

Measured memory_bytes: 17664
#include <stdio.h>
main(){
  int a[6];
  int ans[4];
  int i,n;
  int sum = 0;
  int max;
  // データ入力
  for(i=0;i<6;i++){
    scanf("%d",&a[i]);
  }
  // 解析
  for(i=0;i<3;i++){
    // 最大値取り出し
    max = 0;
    for(n=0;n<4;n++){
      if(a[n]>max){
        max=a[n];
      }
    }
    // 使用済みデータの削除
    for(n=0;n<4;n++){
      if(a[n]==max){
        a[n]=-1;
        break;
      }
    }
    // マックス値の追加
    ans[i]=max;
  }
  // 最後の値の選択
  if(a[4]>a[5]){
    ans[3]=a[4];
  }else{
    ans[3]=a[5];
  }
  // 合計値の算出
  for(n=0;n<4;n++){
    sum += ans[n];
  }
  // 結果表示
  printf("%d\n", sum);
}



Measured memory_bytes: 2056
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 310
int n, m;
int a[N][N];
int d[N], b[N];

bool f(int x){
	int s = 0;
	rep(i, m) s -= d[i];
	if(s == 0) return false;
	memset(b, 0, sizeof(b));
	rep(i, n) rep(j, m){
		if(d[a[i][j]]){
			b[a[i][j]]++;
			break;
		}
	}
	bool ok = true;
	rep(i, m){
		if(b[i]>x){
			ok = false;
			d[i] = 0;
		}
	}
	if(ok) return true;
	return f(x);
}

int main(){
	cin>>n>>m;
	rep(i, n) rep(j, m){
		cin>>a[i][j];
		a[i][j]--;
	}
	int lb = 0, ub = n; // (lb, ub]
	while(ub-lb>1){
		int md = (ub+lb+1)/2;
		memset(d, -1, sizeof(d));
		if(f(md)) ub = md;
		else lb = md;
	}
	cout<<ub<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#define MM	2000000000
using namespace std;
int dp[1001][1001];
void func(int,int);
int main(void)
{
	int n,m,i,j,c[1000],d[1000];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)	scanf("%d",&d[i]);
	for(i=0;i<m;i++)	scanf("%d",&c[i]);
	for(i=0;i<=m;i++)	{
		for(j=0;j<=n;j++)	{
			dp[i][j]=MM;
		}
	}
	dp[0][0]=0;
	for(i=0;i<m;i++)	{
		for(j=0;j<=n;j++)	{
			if(dp[i][j]!=MM)	{
				dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
				if(j+1<=n)
					dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+d[j]*c[i]);
			}
		}
	}
	printf("%d\n",dp[m][n]);
	return 0;
}


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

int binarySearch(int A[], int n, int key) {
  int left = 0, right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key) {
      return mid;
    } else if (key < A[mid]) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return -1;
}

int main() {
  int n; cin >> n;
  int A[100001];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  int q; cin >> q;
  int ans = 0;
  for (int i = 0; i < q; i++) {
    int t; cin >> t;
    if (binarySearch(A, n, t) != -1) ans++;
  }
  cout << ans << endl;
}


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

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

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int h,n;
    cin>>h>>n;

    int sum = 0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        sum += x;
    }

    if( sum >= h )
        cout<<"Yes";
    else
        cout<<"No";

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char X,Y;
    cin >> X >> Y;
    if(X<Y){
        cout << "<" << endl;
    }
    else if (X>Y){
        cout << ">" << endl;
    }
    else{
        cout << "=" << endl;
    }
}

Measured memory_bytes: 256
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q,l,r, x, y, u, v, n, m;
    string a,b;
    cin>>a>>b;
    n=a.size();
    m=b.size();

    ll dp[n+1][m+1];

    Ff(i,0,m+1)
    dp[0][i]=0;

    Ff(i,0,n+1)
    dp[i][0]=0;

    Ff(i,1,n+1)
    {
        Ff(j,1,m+1)
        {
            if(a[i-1]==b[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }

    i=n;
    j=m;
    string s="";
    while (i > 0 && j > 0) 
   { 
      if (a[i-1] == b[j-1]) 
      { 
          s+=a[i-1];  
          i--; j--;   
      } 
      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   } 

    reverse(all(s));
    cout<<s;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

typedef long long ll;
#define rep(i, n) for(ll i=0; i<n; i++)
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define sz(v) ll(v.size())

const long long MOD = 1000000007;

void solve(long long N, long long M, std::vector<long long> a){
    ll dp[N+2];
    dp[0] = 1;
    sort(a.begin(), a.end());
    bool flag[N+2];
    fill(flag, flag+N+1, false);
    rep(i, M) {
        flag[a[i]] = true;
    }
    FOR(i, 1, N+1) {
        if (flag[i]) {
            dp[i] = 0;
        } else {
            if (i >= 2) {
                dp[i] = (dp[i-1] + dp[i-2]) % MOD;
            } else {
                dp[i] = dp[i-1];
            }
        }
    }
    cout << dp[N] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, M, std::move(a));
    return 0;
}


Measured memory_bytes: 1920
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
import java.io.*;
public class Main
{
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		int n = Integer.parseInt(s);
		int w=0,x=0,y=0,z=0;
		for(int i=0; i<n; i++)
		{
		    s = br.readLine();
		    char l = s.charAt(0);
		    if(l == 'A')
		        w++;
		    else if(l == 'W')
		        x++;
		    else if(l == 'T')
		        y++;
		    else 
		        z++;
		}
		System.out.println("AC x "+ w);
		System.out.println("WA x "+ x);
		System.out.println("TLE x "+ y);
		System.out.println("RE x "+ z);
	}
}


Measured memory_bytes: 43380
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        int len = 0;
        StringBuilder sb = new StringBuilder();
        for(int i=0; i<s.length; i++) {
            if(s[i].equals("A") || s[i].equals("C") || s[i].equals("G") || s[i].equals("T")) {
                sb.append(s[i]);
                if(i == s.length-1) {
                    if(sb.length() > len) {
                        len = sb.length();
                    }
                }
            }else {
                if(sb.length() > len) {
                    len = sb.length();
                    sb = new StringBuilder();
                }
            }
        }
        
        System.out.println(len);
    }
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

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

    //-----------------------------------


    cout << ((N/10==9 || N%10==9) ? "Yes" : "No") <<endl;
    return (0);
}

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

int main()
{
    int N;
    cin >> N;
    int h[N][3];
    int dp[N][3];
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> h[i][j];
            dp[i][j] = 0;
            //cout << h[i][j] << " ";
        }
        // cout << "\n";
    }
    // cout << "\n";

    for (int i = 0; i < 3; i++)
        dp[0][i] = h[0][i];

    for (int i = 1; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (k!=j)
                {
                    dp[i][k] = max(dp[i][k], h[i][k] + dp[i-1][j]);
                }
            }
        }
    }
    cout << max({dp[N-1][0], dp[N-1][1], dp[N-1][2]});
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
#include <chrono>
#include <tuple>
#include <string>
#include <random>
#include <cstdio>
#define ll long long int
// #define endl '\n'
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
const int N = 100001;
vector<pair<ll, ll> > adj[N];

void solve() 
{
    ll n, W;
    cin>>n>>W;

    ll w, v;
    cin>>w>>v;

    ll low = w;

    // p.pb(mp(w, v));

    vector<ll> prices[4];

    prices[0].pb(v);

    rep(i, n-1)
    {
        int w, v;
        cin>>w>>v;

        if(w == low)
        {
            prices[0].pb(v);
        }
        else if(w == low + 1)
        {   
            prices[1].pb(v);
        }
        else if(w == low + 2)
        {
            prices[2].pb(v);
        }
        else
        {
            prices[3].pb(v);
        }
    }

    rep(i, 4)
    {
        sort(all(prices[i]));

        reverse(all(prices[i]));
    }

    rep(i, 4)
    {
        for(int j = 1; j < prices[i].size(); j++)
        {
            prices[i][j] += prices[i][j-1];
        }
    }

    ll ans = 0;

    // rep(i, 4)
    // {
    //     cout<<prices[i].size()<<endl;
    //     rep(j, prices[i].size())
    //     {
    //         cout<<prices[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    // cout<<prices[0].size()<<endl;
    for(int a = 0; a <= prices[0].size(); a++)
    {
        // cout<<"yes"<<endl;
        for(int b = 0; b <= prices[1].size(); b++)
        {
            for(int c = 0; c <= prices[2].size(); c++)
            {
                for(int d = 0; d <= prices[3].size(); d++)
                {
                    if(low*a + (low + 1)*b + (low + 2)*c + (low + 3)*d > W)
                    {
                        continue;
                    }

                    ll x1, x2, x3, x4;

                    if(a == 0) x1 = 0;
                    else x1 = prices[0][a-1];

                    if(b == 0) x2 = 0;
                    else x2 = prices[1][b-1];

                    if(c == 0) x3 = 0;
                    else x3 = prices[2][c-1];

                    if(d == 0) x4 = 0;
                    else x4 = prices[3][d-1];

                    ans = max(ans, x1+x2+x3+x4);

                }
            }
        }
    }

    cout<<ans<<endl;


}

int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 6196
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
struct M{
    ll a[4][4];
}f[33],g,ans;
int n,m,a[100005];
M mul(M &x,M &y){
    M ret;
    for(int i=1;i<=3;++i){
        for(int j=1;j<=3;++j){
            ret.a[i][j]=0;
            for(int k=1;k<=3;++k)ret.a[i][j]+=x.a[i][k]*y.a[k][j];
            ret.a[i][j]%=orz;
        }
    }
    return ret;
}
int main(){
    f[0].a[1][1]=1,f[0].a[1][2]=2,f[0].a[1][3]=1;
    f[0].a[2][1]=0,f[0].a[2][2]=1,f[0].a[2][3]=1;
    f[0].a[3][1]=1,f[0].a[3][2]=2,f[0].a[3][3]=2;
    g=f[0];
    g.a[3][1]=0,g.a[3][2]=0,g.a[3][3]=1;
    ans.a[1][1]=1;
    for(int i=0;i<30;++i)f[i+1]=mul(f[i],f[i]);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i)scanf("%d",a+i);
    a[0]=-1;
    a[m+1]=n;
    for(int i=1;i<=m+1;++i){
        for(int j=0;j<=30;++j)if((a[i]-a[i-1]-1)&(1<<j))ans=mul(ans,f[j]);
        if(i<=m)ans=mul(ans,g);
    }
    printf("%lld\n",ans.a[1][3]);
    //system("pause");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int N, K;
int c[26];

bool take(int k) {
  sort(c, c+26);
  for (int i=0; i<26; i++) {
    if (c[25-i] > 0) {
      c[25-i]--;
      k--;
      if (k == 0) return true;
    }
  }
  return false;
}

int main() {
  cin >> N >> K;
  for (int i=0; i<N; i++) {
    string p;
    cin >> p;
    c[(int)p[0]-(int)'A']++;
  }
  int ans = 0;
  while (true) {
    if (!take(K)) break;
    ans++;
  }
  cout << ans << "\n";
  return 0;
}



Measured memory_bytes: 256
main :: IO ()
main = do
  param <- reads2List :: IO [Int]
  let n = head param
  let a = param !! 1
  let b = last param
  print $ solve n a b

s2List :: Read a => String -> [a]
s2List = fmap read . words

reads2List :: Read a => IO [a]
reads2List = do
  s <- getLine
  return (s2List s)

solve :: Int -> Int -> Int -> Int
solve 1 a b = if a == b then 1 else 0
solve n a b | a > b = 0
            | otherwise = (sum maxi - sum mini) + 1 where
              mini = b : replicate (n - 1) a
              maxi = a : replicate (n - 1) b


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }


int r;
void solve() {
    cin >> r;
    cout << r * r << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
n,a,b = [int(i) for i in input().split()]

sum2 = 0

for x in range(n+1):
    sum1 = 0
    x2 = x
    while x > 0:
        sum1 += x % 10
        x = int(x/10)

    if sum1 >= a and sum1 <= b:
        sum2 += x2
print(sum2)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

char s[101];

int main(void){

	scanf("%s",s);

	for (int i = 0; i < strlen(s)-1; ++i)
	{
		if(s[i]=='C'){
			for (int j = i+1; j < strlen(s); ++j)
			{
				if(s[j]=='F'){
					printf("Yes\n");
					return 0;
				}
			}
		}
	}

	printf("No\n");					
	return 0;

}


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

int main(){
  long N;cin>>N;
  vector<long> A(5);
  for (auto&a : A)cin >> a;
  sort(A.begin(),A.end());
  cout << (N+A[0]-1)/A[0] -1 + 5 << endl;
  return 0;
}


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

const int N = 1e5 + 15;
const int mod = 1e9 + 7;

int n, f[2][N], s[2][N], g[2][N];
long long a[N], x[2];

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> x[0] >> x[1];
    for (int i = 1; i <= n; ++i) cin >> a[i];
    a[n + 1] = a[n] + max(x[0], x[1]);
    for (int i = 0; i <= 1; ++i) {
        for (int j = 1; j <= n; ++j) {
            g[i][j] = j;
            if (a[j] - a[j - 1] >= x[i]) {
                g[i][j] = g[i][j - 1];
            }
        }
    }
    s[0][0] = s[1][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= 1; ++j) {
            int tmp = lower_bound(a + 1, a + n + 2, a[i + 1] - x[j ^ 1] + 1) - a - 1;
            if (tmp == i) tmp--;
            if (g[j][i] - 1 <= tmp) {
                f[j][i] = s[j ^ 1][tmp];
                if (g[j][i] >= 2) {
                    f[j][i] = (f[j][i] - s[j ^ 1][g[j][i] - 2] + mod) % mod;
                }
            }
            s[j][i] = (s[j][i - 1] + f[j][i]) % mod;
            //cout << f[j][i] << ' ' << j << ' ' << i << '\n';
        }
    }
    cout << (f[0][n] + f[1][n]) % mod;
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b>> c >>d;
  int x = a+b;
  int y = c+d;
  if(x == y)cout << "Balanced" << endl;
  else if(x>y)cout <<"Left" << endl;
  else cout <<"Right" << endl;
  
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int k,t; cin >> k >> t;
  int mx = 0;
  vi a(t);
  rep(i,t){
    cin >> a[i];
    chmax(mx,a[i]);
  }
  if((k+1)/2 < mx){
    cout << (mx-(k+1)/2)*2-1;
  }else{
    cout << 0;
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3592
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize
    }
    let mut res = 0;
    let mut can = false;
    for i in 0..50000 {
        let x = (i as f64) * 1.08;
        if n == x as usize {
            can = true;
            res = i;
        }
    }
    if can {
        println!("{}", res);
    } else {
        println!(":(");
    }
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
const long long mod = 1000000007;
typedef long long ll;

ll n,h;
string s,t;

int main() {
  cin >> n;
  cout << n/11*2+(n%11+5)/6 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int num;
	int a[3];
	cin>>num;
	a[0] = num % 10;
	num /= 10;
	a[1] = num % 10;
	num /= 10;
	a[2] = num%10;
	if (a[2] == 1) cout << "9";
	else cout << "1";
	if (a[1] == 1) cout << "9";
	else cout << "1";
	if (a[0] == 1) cout << "9";
	else cout << "1";
}

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

def BellmanFord(graph: "List[List[int]]", s: int):
    """
    特定の始点から各点への最短距離を求めます。
    重みが負であっても動作します。
    ================
    s: 始点
    graph: 隣接リスト
    ----------------
    第一返り値: 負の閉路があるかいなか
    第二返り値: 最短距離のリスト
    """
    INF = 1e18
    n = len(graph)
    dist = [INF] * n
    dist[s] = 0
    for i in range(n):
        for v in range(n):
            for k in range(len(graph[v])):
                e  = graph[v][k]
                if dist[v] != INF and dist[e[0]] > dist[v] + e[1]:
                    dist[e[0]] = dist[v] + e[1]
                    if i == n-1 and e[0] == n-1:
                        return True, dist
    return False, dist

def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    G = [[] for _ in range(N)]
    for i in range(M):
        G[a[i]-1].append((b[i]-1, c[i]))
    flag, cost = BellmanFord(G, 0)
    if flag:
        print('inf')
    else:
        print(-cost[N-1])
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int n;
	cin >> n;
	vector<double> v(n);
	rep(i, n)
	{
		cin >> v[i];
	}

	sort(v.begin(), v.end());
	
	for (int i = 1; i < n; i++)
	{
		v[i] = (v[i-1] + v[i]) / 2;
		v[i-1] = 0;
		sort(v.begin(), v.end());

	}

	cout << v[n - 1] << endl;

}

Measured memory_bytes: 256
class CityData:
    def __init__(self, cityData):
        splitedData = cityData.split(" ")
        self.pref = int(splitedData[0])
        self.year = int(splitedData[1])

    def setRank(self, rank):
        self.rank = rank


firstLine = input().split(" ")
prefs = int(firstLine[0])
cities = int(firstLine[1])

cityDataArray = []
cityRankState = {}

for i in range(cities):
    inputData = input()
    cityDataArray.append(CityData(inputData))

sortedCityDataArray = sorted(cityDataArray, key=lambda x:x.year)

for i in sortedCityDataArray:
    try:
        rank = cityRankState[i.pref]
    except KeyError:
        rank = 0
    i.setRank(rank)
    rank += 1
    cityRankState[i.pref] = rank

for i in cityDataArray:
    print(str(i.pref).rjust(6, '0') + str(i.rank+1).rjust(6, '0'))


Measured memory_bytes: 36712
C, B, A = sorted([int(i) for i in input().split()])
ans = (A-B)//2+(A-C)//2
if (A-B) & 1 and (A-C) & 1:
    ans += 1
elif (A-B) & 1 or (A-C) & 1:
    ans += 2
print(ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int a, b;
	cin >> a >> b;
	string ans;
	if (a > 0 && b > 0)
		ans = "Positive";
	else if (a <= 0 && b >= 0)
		ans = "Zero";
	else if ((b-a)%2 == 0)
		ans = "Negative";
	else
		ans = "Positive";
	cout << ans << endl;
}



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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if (A == 1) {
    cout << "YES" << endl;
    return 0;
  }

  for (int i = A; i <= (A * B) * 2; i += A) {
    if (i % B == C) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=998244353;
int main(){
  int64_t N;cin>>N;
  vector<int64_t>a(N);
  int64_t sum=0;
  for(int i=0;i<N;i++){
    cin>>a.at(i);sum+=a.at(i);
  }
  vector<vector<int64_t>>dp(1+N,vector<int64_t>(1+sum,0));
  vector<vector<int64_t>>dp1(1+N,vector<int64_t>(1+sum,0));
  dp[0][0]=1;dp1[0][0]=1;
  for(int i=1;i<=N;i++)
    for(int j=0;j<=sum;j++){
    if(a.at(i-1)<=j){
      dp[i][j]=(2*dp[i-1][j]+dp[i-1][j-a.at(i-1)])%mod;
       dp1[i][j]=(dp1[i-1][j]+dp1[i-1][j-a.at(i-1)])%mod;
    }
      else{
        dp[i][j]=(2*dp[i-1][j])%mod;
         dp1[i][j]=dp1[i-1][j];
      }
    }int64_t ans=0;
if(sum%2==1){  for(int j=(sum+1)/2;j<=sum;j++)
    ans=(ans+dp[N][j])%mod;
            }else{
  for(int j=(sum+1)/2;j<=sum;j++)
    ans=(ans+dp[N][j])%mod;ans=(ans-dp1[N][sum/2]+mod)%mod;
}
  ans=(ans*3)%mod;
  int64_t b=1;
  for(int i=0;i<N;i++)
    b=(b*3)%mod;
  cout<<(b-ans+mod)%mod<<endl;
  return 0;
}

Measured memory_bytes: 426620
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using vpii = vector<pair<int, int>>;
using ll = long long;

int		main(void)
{
	int N, M;

	cin >> N >> M;
	cout << (N * (N - 1)) / 2 + (M * (M - 1)) / 2 << endl;
}


Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)
#define dl2(name,x,y) vector<vector< x > > name((y) , vector< x > (y) );
#define dl2d(name,x,a,b) vector<vector< x > > name( (a), vector< x >(b) );
#define dl3(name,x,y) vector<vector<vector< x > > > name( (y), vector<vector< x > >((y), vector< x >(y) ));
#define dl3d(name,x,a,b,c) vector<vector<vector< x > > > name( (a), vector<vector< x > >( (b), vector< x >(c) ));
#define dl4(name,x,y) vector<vector<vector<vector< x > > > > name( (y), vector<vector<vector < x > > >( (y), vector<vector< x > >((y), vector< x >(y))));
#define dl4d(name,x,a,b,c,d) vector<vector<vector<vector< x > > > > name( (a), vector<vector<vector < x > > >( (b), vector<vector< x > >( (c), vector< x >(d) )));


using namespace std;
 
typedef long long ll;
ll dp[4020][2020][2];
ll mod=924844033;
int main(){
    int N,K;
    cin>>N>>K;
    vector<ll> m;
    ll c=0,s=0;
    bool t[2001];
    for(int i=1;i<N+1;i++){
        if(!t[i]){
            s+=(N-i)/K;
            rp(j,0,(N-i)/K) m.push_back(c);
            c++;
            rp(j,0,(N-i)/K) m.push_back(c);
            c++;
            s+=(N-i)/K;
            for(int j=i;j<=N;j+=K){
                t[j]=true;
            }
        }
    }

    dp[0][0][0]=1;
    rp(i,0,s){
        rp(j,0,min(ll(2001),ll(i+1))){

            (dp[i+1][j+1][1]+=dp[i][j][0])%=mod;
            if(m[i]!=m[i-1]) (dp[i+1][j+1][1]+=dp[i][j][1])%=mod;
            (dp[i+1][j][0]+=(dp[i][j][0]+dp[i][j][1]))%=mod;
            }
    }


    ll per[2001];
    per[0]=1;
    rp(i,1,2001){
        per[i]=(per[i-1]*i)%mod;
    }





    ll sub=0;
    for(int i=1; i<=min(ll(s),ll(N)); ++i)
    {
        if(i%2==0) sub = (sub - ((dp[s][i][0]+dp[s][i][1])*per[N-i])%mod + mod)%mod;
        else sub = (sub + ((dp[s][i][0]+dp[s][i][1])*per[N-i])%mod)%mod;
    }

    ll ans=(per[N]-sub+mod)%mod;
    cout << ans << endl;
    return 0;

};




Measured memory_bytes: 102272
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	A, B := ReadInt(), ReadInt()
	ans := 0

	base := 1
	B += 1
	for i := 0; i < 41; i++ {
		c := B / (base * 2) * base
		if B%(base*2) >= base {
			c += B%(base*2) - base
		}
		if c%2 == 1 {
			ans ^= 1 << i
		}
		base <<= 1
	}

	base = 1
	x := A
	for i := 0; i < 41; i++ {
		c := x / (base * 2) * base
		if x%(base*2) >= base {
			c += x%(base*2) - base
		}
		if c%2 == 1 {
			ans ^= 1 << i
		}
		base <<= 1
	}

	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#include <stdio.h>
#include <bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
using namespace std;
int n;
char s[2][60];
int main()  
{  
	cin>>n>>s[0]>>s[1];
	ll ans=3;
	int k=0,j=1;
	if(s[0][0]==s[0][1]){
		k=1;j=2;
		ans=6; 
	}
	for(;j<n;j++){
		if(s[0][j]==s[0][j+1]){
			if(k==1) ans*=3;
			else ans*=2;
			k=1;j++;
		}else{
			if(k==0) ans*=2;
			k=0; 
		}
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;  
}  
/*
1 23
2 1 3 1
1 3 1 2 
2 1     
*/

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	var n, m uint
	fmt.Scan(&n)
	fmt.Scan(&m)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	s := make([][]uint, m)
	for i := uint(0); i < m; i++ {
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())

		for j := 0; j < k; j++ {
			scanner.Scan()
			sj, _ := strconv.Atoi(scanner.Text())
			s[i] = append(s[i], uint(sj))
		}
	}

	p := make([]int, m)
	for i := uint(0); i < m; i++ {
		scanner.Scan()
		p[i], _ = strconv.Atoi(scanner.Text())
	}

	max := int(math.Pow(2, float64(n)))
	var ret int
	for i := 0; i < max; i++ {
		on := make([]bool, n)
		for j := uint(0); j < n; j++ {
			on[j] = (i>>j)%2 == 1
		}
		var miss bool
		for j := uint(0); j < m; j++ {
			var num int
			for _, v := range s[j] {
				if on[v-1] {
					num++
				}
			}
			if num%2 != p[j] {
				miss = true
				break
			}
		}

		if !miss {
			ret++
		}
	}

	fmt.Println(ret)
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<pair<pair<int, int>, int>> Edges(M);
    for (int m = 0; m < M; ++m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        Edges[m] = {{a, b}, c};
    }
    
    vector<ll> Score(N, -INFLL);
    Score[0] = 0;
    int n = 0;
    ll ScoreTmp = 0;
    for (; n < 2*N; ++n) {
        bool bUpdate = false;
        for (auto e : Edges) {
            int from = e.first.first;
            int to = e.first.second;
            int cost = e.second;
            if (Score[from] != -INFLL && Score[to] < Score[from] + cost) {
                Score[to] = Score[from] + cost;
                bUpdate = true;
            }
        }
        if (!bUpdate) break;
        if (n == N-1) {
            ScoreTmp = Score[N-1];
        }
    }
    
    if (n == 2*N && ScoreTmp != Score[N-1]) {
        cout << "inf" << endl;
    } else {
        cout << Score[N-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
MOD = 998244353
N = int(input())
D = list(map(int, input().split()))

L = [0] * N

for d in D:
    L[d] += 1
if D[0] != 0:
    print(0)
    sys.exit()
total = 1
prev_l = 1
for i, l in enumerate(L):
    if i == 0:
        prev_l = l
        if l != 1:
            total = 0
            break
        continue
    total *= (prev_l**l)
    total %= MOD
    prev_l = l

print(total%MOD)


Measured memory_bytes: 53796
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n;
    double x,ans = 0;
    string u;
    cin >> n;
    rep(i, n){
        cin >> x >> u;
        if (u == "JPY") {
            ans += x;
        }else{
            ans += x * 380000;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
minA = min(A)
maxA = max(A)
ans = float("inf")
for i in range(minA, maxA + 1):
    cnt = 0
    for a in A:
        cnt += (i - a) ** 2
    ans = min(ans, cnt)
print(ans)

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	ll int n, t;
	ll int ans = 0;
	ll int oldend = 0;
	cin >> n >> t;
	REP(i,n){
		ll int tmp;
		cin >> tmp;
		if(oldend > tmp){
			ans += (tmp + t - oldend);
			//cout << tmp + t - oldend << endl;
		}else{
			ans += t;
			//cout << t << endl;
		}
		oldend = tmp + t;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()
i = 0
j = len(s)-1
count = 0
while i<j:
    if s[i] == 'R':
        i+=1
    elif s[j] == 'W':
        j-=1
    else:
        i+=1
        j-=1
        count+=1
print(count)

Measured memory_bytes: 67396
# Circle in a Rectangle

a = [int(i) for i in input().rstrip().split()]
rectangle = [a[0], a[1]]
circleCenter = [a[2], a[3]]
circleRadius = a[4]

if a[2] - a[4] >= 0 and a[2] + a[4] <= a[0]:
    if a[3] - a[4] >= 0 and a[3] + a[4] <= a[1]:
        print('Yes')
    else:
        print('No')
else:
    print('No')



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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



//#define int int64_t
signed main()
{
	int n; cin >> n;
	vector<int> h(n);
	for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> h[i];
	
	int max = h[0];
	int cnt = 1;
	for(int i = 1, i_len = (int)n; i < i_len; ++i){

		if(h[i]>=max){
			cnt++;
		}

		amax(max, h[i]);

	}
	cout << cnt << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 998244353;

ll DP[4000][8000][3];

int main(){
    ll N, S;
    cin >> N >> S;
    vector<ll> A(N);
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    DP[0][0][0] = 1;
    REP(i,N){
        ll a = A[i];
        REP(j,S+1){
            REP(k,3)
                DP[i+1][j][k] += DP[i][j][k];

            DP[i+1][j][1] += DP[i][j][0];
            DP[i+1][j][2] += DP[i][j][1];

            if(a + j > S) continue;
            DP[i+1][j+a][1] += DP[i][j][0];
            DP[i+1][j+a][1] += DP[i][j][1];

            DP[i+1][j+a][2] += DP[i][j][0];
            DP[i+1][j+a][2] += DP[i][j][1];
        }

        REP(j,S+1){
            REP(k,3){
                DP[i+1][j][k] %= MOD;
            }
        }
    }

    ll ans = DP[N][S][2];

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


Measured memory_bytes: 562176
n,m,x = map(int,input().split())
u = [list(map(int,input().split())) for i in range(n)]

import itertools
z = itertools.product([0,1],repeat=n)
t = []
s = []
for i in z:
    t = [0 for k in range(m)]
    cum=0
    for j in range(n):
        if i[j]==1:
            for k in range(m):
                t[k]+=u[j][k+1]
            cum+=u[j][0]
    for b in t:
        if b<x:
            break
    else:
        s.append(cum)
if len(s) !=0:
    print(min(s))
else:
    print(-1)

Measured memory_bytes: 68656
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int n, a, b,counta=0,countb=0,countc=0;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)
	{
		int op;
		cin >> op;
		if (op >= b + 1)
			countc++;
		if (op >= a + 1 && op <= b)
			countb++;
		else if (op <= a)
			counta++;
	}
	if (counta <= countb && counta <= countc) cout << counta << endl;
	else if (countb <= counta && countb <= countc) cout << countb << endl;
	else if (countc <= countb && countc <= counta) cout << countc << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

        if(y < 2 * x || 4 * x < y){
            System.out.println("No");
            return;
        }

        if(y % 2 == 1){
            System.out.println("No");
            return;
        }

        System.out.println("Yes");
    }
}


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

using namespace std;

#define MAX_V 101
#define MAX_E 10000
#define INF 1e9

int N, M, L;
struct edge{
  int to, dist, enemy;
  edge(int to, int dist, int enemy) : to(to), dist(dist), enemy(enemy) {}
};

struct State{
  int v, dist, l;
  State(int v, int dist, int l) : v(v), dist(dist), l(l) {}

  bool operator < (const State &s)const{
    return dist > s.dist;
  }
};

vector<edge> G[MAX_E];
int d[MAX_V][MAX_V];

int dijkstra(){
  int res = INF;
  priority_queue<State> Q;
  fill(d[0], d[N], INF);
  d[0][L] = 0;
  Q.push(State(0,0,L));

  while(!Q.empty()){
    State st = Q.top(); Q.pop();
    int v = st.v;

    if(v == N-1){
      res = min(res, st.dist);
      continue;
    }

    for(int i = 0 ; i < (int)G[v].size() ; i++){
      edge e = G[v][i];
      if(d[e.to][st.l] > d[v][st.l] + e.enemy){
        d[e.to][st.l] = d[v][st.l] + e.enemy;
        Q.push(State(e.to, d[e.to][st.l], st.l));
      }
    }
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      edge e = G[v][i];
      if(st.l - e.dist >= 0 && d[e.to][st.l-e.dist] > d[v][st.l]){
        d[e.to][st.l-e.dist] = d[v][st.l];
        Q.push(State(e.to, d[e.to][st.l-e.dist], st.l-e.dist));
      }
    }
  }

  return res;
}

int main(){
  int a, b, d, e;
  while(cin >> N >> M >> L, (N | M | L)){
    for(int i = 0 ; i < MAX_E ; i++){
      G[i].clear();
    }
    for(int i = 0 ; i < M ; i++){
      cin >> a >> b >> d >> e;
      a--, b--;
      G[a].push_back(edge(b,d,e));
      G[b].push_back(edge(a,d,e));
    }
    cout << dijkstra() << endl;
  }

  return 0;
}

Measured memory_bytes: 1968