akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k; cin >> n >> k;
    vector<int> vec(n);
    int d, a;
    rep(i,k){
        cin >> d;
        rep(j,d){
            cin >> a;
            a--;
            vec[a]++;
        }
    }
    int cnt = 0;
    rep(i,n){
        if (vec[i] == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3668
while True:
    try:
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))

        hit = 0
        blow = 0

        for i in range(4):
            if a[i] == b[i]:
                hit += 1
            elif a[i] in b:
                blow += 1

        print(hit,blow)

    except EOFError:
        break

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

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define debug(a) cerr << #a << ": " << a << endl
#define umii unordered_map<int64_t,int64_t>
#define ftt int t;cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end());
#define Sort(v) sort(v.begin(),v.end());
#define mem(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define pq priority_queue<int>
#define dbg cout<<"\nhi\n"
#define sayy cout<<"YES\n"
#define sayn cout<<"NO\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define vi vector<int>
#define eb emplace_back
#define nl cout<<"\n"
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define sp <<" "<<
#define int long long
#define double long double
#define se second
#define fi first

const int MOD = 1000000007;
const double PI = 3.1415926535898;
const int LIM = 100005;

using namespace std;

int fpow( int x,int y) {
    int temp;
    if(y == 0)
        return 1;
    temp = fpow(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;}

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

void sieve(int n) {
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
     for (int p=2; p*p<=n; p++)
          if (prime[p] == true)
               for (int i=p*p; i<=n; i += p)
                    prime[i] = false;
     prime[1]=0;}

inline int read(){
    int p=1,ans=0;
    char ch=getchar();
    while(ch<48||ch>57)
    {
        if(ch=='-')p=-1;
        ch=getchar();
    }
    while(ch>=48&&ch<=57)
    {
        ans=(ans<<3)+(ans<<1)+ch-48;
        ch=getchar();
    }
    return ans*p;
}

int fun(int n)
{
    if(n % 2 != 0)
        return n;
    while(n % 2 == 0)
        n /= 2;
    return n;
}

/*int cnt, sum = 0, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;*/

//*************************************************************************************************************************


int32_t main()
{    fio;

     int n, k;
     cin>>n>>k;
     vi v(n);
     for(int &x : v)
        cin>>x;
    Sort(v);
    int ans = accumulate(v.begin(),v.begin()+k,0);
    cout<<ans;
     return 0;
}





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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

template <ll mod> class modint
{
private:
    ll x;

public:
    modint(ll x = 0) : x(x >= 0 ? x % mod : (x % mod) + mod) {}
    modint &operator+=(const modint rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator-=(const modint rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator*=(const modint rhs) {
        (x *= rhs.x) %= mod;
        return *this;
    }
    modint &operator/=(const modint rhs) {
        *this *= rhs.inv();
        return *this;
    }
    modint operator+(const modint rhs) const { return modint(*this) += rhs; }
    modint operator-(const modint rhs) const { return modint(*this) -= rhs; }
    modint operator*(const modint rhs) const { return modint(*this) *= rhs; }
    modint operator/(const modint rhs) const { return modint(*this) /= rhs; }

    modint operator-() const { return modint(-x); }

    modint pow(ll n) const {
        modint e = *this, ret = modint(1);
        while (n) {
            if (n & 1) ret *= e;
            e *= e, n >>= 1;
        }
        return ret;
    }

    modint inv() const { return pow(mod - 2); }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m.x;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }
};
using mint = modint<1000000007>;

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

    int n, m; cin >> n >> m;
    if (n < m) swap(n, m);
    
    if (n - m > 1) {
        cout << 0 << endl;
        return 0;
    }

    mint fact = 1;
    for (int i = 1; i <= m; i++) fact *= i;
    
    mint ans;
    if (n == m) ans = fact * fact * 2;
    else ans = fact * (fact * n);

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


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

from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    red = [False] * n
    red[0] = True
    balls = [1] * n
    ans = 1
    for _ in range(m):
        x, y = map(int, input().split())
        if red[x - 1]:
            if balls[x - 1] == 1:
                red[x - 1] = False
                ans -= 1
            if not red[y - 1]:
                red[y - 1] = True
                ans += 1
        balls[x - 1] -= 1
        balls[y - 1] += 1
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 75072
(n,m)=gets.split.map(&:to_i)
ab=(0...m).map{gets.split.map{|s| s.to_i - 1 }}

room=(0...n).map{[]}

ab.each{|a,b|
    room[a]<< b
    room[b]<< a
}

room_tree=[0]

queue = room[0].map{|x| [x,0] }

loop do
    break if queue == []
    (from,to)=queue.shift
    if room_tree[from] == nil
        room_tree[from] = to
        room[from].each{|x|
            queue << [x,from] if room_tree[x] == nil
        }
    end
end



if room_tree.include?(nil)
    print "No"
else
    print "Yes\n"
    room_tree[1...room_tree.size].each{|x| 
        print x+1,"\n"
    }
end

Measured memory_bytes: 62180
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int max = 0;
    Set<String> st1 = new HashSet<String>();
    Set<String> st2 = new HashSet<String>();
    for(int i = 1;i<n;i++){
      for(int j = 0;j<i;j++){
        st1.add(s.substring(j,j+1));
      }
      List<String> li = new ArrayList<String>(st1);
      for(int j = i;j<n;j++){
        st2.add(s.substring(j,j+1));
      }
      int count = 0;
      for(int j = 0;j<li.size();j++){
        if(st2.contains(li.get(j))){
          count++;
        }
      }
      max = Math.max(max,count);
      st1.clear();
      st2.clear();
      li.clear();
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 37584
n,m=map(int,input().split())
l1 = [0]*n
l2 = [0]*n
for i in range(m):
        p,s=map(str,input().split())
        p= int(p)
        if s == 'AC':
                l2[p-1] +=1
        else:
                if l2[p-1] == 0:
                        l1[p-1] +=1
cntac = 0
cntwa = 0
for i in range(n):
        if l2[i] != 0:
                cntac +=1
                cntwa += l1[i]

                
                
print(cntac,cntwa)

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

int h, w, pref[905][905];

long long sum = 0;

char a[905][905], b[905][905];

bool check(int x, int y) {
    if(x >= 1 && x <= h && y >= 1 && y <= w && a[x][y] == '#') return 1;
    return 0;
}

void solve() {
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            pref[i][j] = 0;
            if(a[i][j] == '#')
                pref[i][j] = 1;
        }
    }
    for(int i = 1; i <= 3 * h; i++) {
        for(int j = 1; j <= 3 * w; j++) {
            if(i > h || j > w)
                pref[i][j] = 0;
            pref[i][j] += pref[i - 1][j - 1];
        }
    }
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            if(a[i][j] == '.') continue;
            for(int range = 1; range <= max(h, w); range++) {
                if(check(i + range, j + range))
                    sum = sum + pref[i + 2 * range - 1][j - 1] - pref[i + range - 1][max(j - range - 1, 0)];
            }
        }
    }
}

void rot() {
    for(int j = 1; j <= w; j++) {
        int cnt = 1;
        for(int i = h; i >= 1; i--) {
            b[j][cnt] = a[i][j];
            cnt++;
        }
    }
    swap(w, h);
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++)
            a[i][j] = b[i][j];
    }
}

int main() {
    scanf("%d%d", &h, &w);
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++)
            scanf(" %c", &a[i][j]);
    }
    solve();
    rot(); solve();
    rot(); solve();
    rot(); solve();
    printf("%lld", sum);
}


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

int main(){
	
	int a,b;
	cin >> a >> b;
	if(a > b) swap(a,b);
	
	int mid = (b-a)/2;
	
	if((b-a)%2 == 0){
		cout << b-mid << endl;
	}
	else{
		cout << "IMPOSSIBLE" << endl;
	}
	
	return 0;
}

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

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}
ll count(ll x){
    ll a=0;
    while(x%2==0){
        a++;
        x=x/2;
    }
    return a;
}

int main(){
    ll n;cin>>n;
    ll ans=0;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
        ans+=count(a[i]);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    ll x;
    cin >> x;
    ll ans = (x / 11) * 2;
    if (0 < x % 11)
        ans++;
    if (6 < x % 11)
        ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var A, B, K int
	fmt.Scan(&A, &B, &K)
	bp := B + 1

	n := (float64(B) - float64(A)) / 2

	if n >= float64(K) {
		for i := A; i < A+K; i++ {
			fmt.Println(i)
		}
		for i := B - K + 1; i < bp; i++ {
			fmt.Println(i)
		}
		return
	}
	for i := A; i < bp; i++ {
		fmt.Println(i)
	}
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

#define endl '\n'
#define hoise cerr<<"hoise - "<<__LINE__<<"\n";
#define tham getchar();
#define FASTIO ios::sync_with_stdio(false);cin.tie(nullptr);

using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
using vl = vector <ll>;

const int MXN = (int)2e5+6;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int INF = 1e9;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

//inline int Set(int N, int pos){return N=N | (1<<pos);}
//inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
//inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }


template <typename T> using orderedSet = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using orderedSet1 = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*--------------------------------------------------------------------------------------------------------------------------*/


vector <int> adj[MXN];
multiset <int> Set;
int n, a[MXN], ans[MXN];
	
void dfs (int u, int parent = 0) {
	Set.insert (a[u]);
	
	int x = -1;
	
	auto it = Set.lower_bound (a[u]);
	
	if (++it != Set.end()) {
		x = *it;
		Set.erase (it);
	}
	
	ans[u] = Set.size();
	
	for (auto& child : adj[u]) {
		if (child != parent) {
			dfs (child, u);
		}
	}
	if (x != -1) {
		Set.insert (x);
	}
	Set.erase (Set.find (a[u]));
}


int main(){
	FASTIO
	
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	
	for (int i = 1; i < n; ++i) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back (v);
		adj[v].push_back (u);
	}
	
	dfs (1);
	
	
	for (int i = 1; i <= n; ++i) {
		cout << ans[i] << endl;
	}
	
    return 0;	
}

/*

*/


Measured memory_bytes: 30540
#include<cstdio>
#define MAX(x,y) ((x>y)? x:y)

int n;
int a[5005];
long long int def;
long long int answer=-1000000000;

int main()
{
	while(true)
	{
		answer=-1000000000;
		scanf("%d",&n);
		for(int i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			def=0;
			for(int j=i;j<n;j++)
			{
				def+=a[j];
				answer=MAX(answer,def);
			}
		}
		printf("%lld\n",answer);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
long long a,b;
char x;
int main()
{
      cin>>a>>x>>b;
      if(x=='+')
      {
      	cout<<a+b<<endl;
      }
      if(x=='-')
      {
      	cout<<a-b<<endl;
      }
      if(x=='*')
      {
      	cout<<a*b<<endl;
      }
      if(x=='/')
      {
      	cout<<a/b<<endl;
      }
    return 0;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,l,r) for(int i=(l);i<(r);i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

// g++ -std=c++11 prac.cpp 

int main(){
    ll x=0,y=0,z=0,n,m=0,k,ans=0,h,w,sum=0,Max=-1e9-1,cnt=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> n >> m;
    VB b(n);
    VL c(n);
    rep(i,n){
        b[i] = false;
    }

    rep(i,m){
        cin >> x >> s;

        if(b[x-1] == false && s == "AC"){
            ans++;
            cnt += c[x-1];
            b[x-1] = true;
        }
        else if(b[x-1] == false && s == "WA"){
            c[x-1]++;
        }
    }    
   
    cout << ans << " " <<  cnt << endl;
    return 0;
}


 

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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()

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

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

typedef long long int lli;
typedef long double ld;

const int INF = INT_MAX/3;
const double EPS = 1e-14;
const int dx[4] = {0, 1, 0, -1}; // {-1,  0,  1, -1, 1, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0}; // {-1, -1, -1,  0, 0,  1, 1, 1};
typedef pair<double,string> P;

int N;

int main() {
  cout << fixed << setprecision(10);

  while (cin >> N and N) {
    vector<P> fruits;
    REP(i, N) {
      string l;
      lli p, a, b, c, d, e, f, s, m;
      cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
      int year = a + b + c + m * (d + e);
      int gain = m * f * s;
      double perf = (gain - p) * 1.0 / year;
      fruits.push_back(P(-perf, l));
    }
    sort(ALL(fruits));
    for (P f:fruits) {
      cout << f.second << endl;
    }
    cout << "#" << endl;
  }
  return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N, K;
	cin >> N >> K;
	llong now = 1, ans = 1;
	N--;
	while(true){
		llong next = now/K + (now%K>0);
		if(N < next)
			break;
		now += next;
		N -= next;
		ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int n, m;
struct place {
	int sum;
	int number;
	bool operator<(const place &c) const {
		return c.sum < sum;
	}
};

int main() {
	while(1) {
		scanf(" %d %d", &n, &m);
		if(n == 0 && m == 0) break;
		vector<place> v(m);
		rep(i,m) {
			v[i].number = i + 1;
		}
		rep(i,n) {
			rep(j,m) {
				int t;
				scanf(" %d", &t);
				if(t == 1) v[j].sum++;
			}
		}
		stable_sort(v.begin(), v.end());
		printf("%d", v[0].number);
		for(int i = 1; i < m; i++)
			printf(" %d", v[i].number);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 0
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sqr(x) (x) * (x)

using namespace std;
using namespace __gnu_pbds;

mt19937_64 gen(time(0));

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const ll mod = 1e9 + 7;

//const int inf = 1e9;

const int maxn = 2e6 + 66;

ll bpw (ll a, ll n)
{
	if (n == 0)
		return 1;
	if (n % 2 == 1)
		return (bpw(a, n - 1) * a) % mod;
	else
    {
		ll b = bpw (a, n / 2);
		return (b * b) % mod;
	}
}

ll f[maxn];

signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
//#ifdef LOCAL
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#else
//
//#endif
    int k;
    string s;
    cin >> k >> s;
//    s = "0" + s + "0";
    int n = int(s.size());
    f[0] = 1;
    for(ll i = 1; i < maxn; ++i)
        f[i] = (f[i - 1] * i) % mod;


    ll ans = 0;
    for(int i = 0; i <= k; ++i)
    {
        ll cur = (1ll * bpw(25, k - i) * bpw(26, i)) % mod;
//        cur *= bpw(k - i + 1, i);
//        cur %= mod;
//        if (i >= 0)
        {
            cur *= f[k + n - i - 1];
//            cerr << f[d + i - 1] << endl;
            cur %= mod;
            cur *= bpw(f[n - 1], mod - 2);
            cur %= mod;
            cur *= bpw(f[k - i], mod - 2);
            cur %= mod;
        }

        ans += cur;
        ans %= mod;
    }
    cout << ans;
    return 0;
}


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

ll t[200010];
ll s[200010];
int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,200020){
        
    }
    rep(i,n){
        cin >> a[i];
        t[a[i]]++;
    }
    ll ans=0;
    rep(i,200010){
        if(t[i]){
            s[i]=t[i]*(t[i]-1)/2;
            t[i]=(t[i]-1)*(t[i]-2)/2;
            ans+=s[i];
        }
    }
    rep(i,n){
        cout << ans+t[a[i]]-s[a[i]] << endl;
    }

}

Measured memory_bytes: 5504
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int stack[128];
int size;

void push(int x)
{
    stack[size] = x;
    size++;
}

int top(void)
{
    return (stack[size - 1]);
}

void pop(void)
{
    size--;
}

int main(void)
{
    char s[128];
    int a, b;
    int tmp;

    while (scanf("%s", s) != EOF){
        if (isdigit(s[0])){
            tmp = atoi(s);
        }
        else {
            b = top();
            pop();
            a = top();
            pop();
            switch (s[0]){
                case '+': tmp = a + b; break;
                case '-': tmp = a - b; break;
                case '*': tmp = a * b; break;
            }
        }
        push(tmp);
    }

    printf("%d\n", top());

    return (0);
}

Measured memory_bytes: 548
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
# 配列入力の受け取り
arrH = list(map(int,input().split()))

i = 0
temp = 0
ans = 0
while i < n:
    if i == n-1:
        ans = max(ans,temp)
        break
    elif arrH[i] >= arrH[i+1]:
        temp += 1
        i += 1
    else:
        ans = max(ans,temp)
        temp = 0
        i +=1

print(ans)
# print("{:.10f}".format(ans))


Measured memory_bytes: 14252
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int N; cin >> N;
    unordered_set<string> words;
    string prev; cin >> prev;
    words.insert(prev);

    rep(i, 1, N) {
        string word; cin >> word;
        auto insertRes = words.insert(word);
        if (prev[prev.size()-1] != word[0] or !insertRes.second) {
            cout << "No" << endl;
            return 0;
        }
        prev = word;
    }

    cout << "Yes" << endl;
}


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

int skip(string &str,int i){
  if(str[i]!='(')return i;
  string res;
  int cnt=1;i++;
  while(1) {
    if(str[i]=='(')cnt++;
    if(str[i]==')')cnt--;
    if(!cnt)break;
    res+=str[i++];
  }
  return i;
}


int num[1<<8];
vector <S> mem;
map <string,int> M;
void calc(char ch,S a,S b, S &res){
  S::iterator i,j;
  for(i=a.begin();i!=a.end();i++)
    for(j=b.begin();j!=b.end();j++){
      int I=*i,J=*j,c=0;
      if(ch=='+') c=I+J;
      else if(ch=='-') c=I-J;
      else if(ch=='*') c=I*J;
      else if(ch=='/'){
	if(!J)continue;
	c=I/J;
      }
      res.insert(c);
    }
}

S solve(string str){
  S res;
  if(str.size()==1){res.insert(num[str[0]]);return res;}
  if(M.count(str))return mem[M[str]];
  if(skip(str,0)==str.size()-1)return solve(str.substr(1,str.size()-2));

  string A,B;
  for(int i=0;(i=skip(str,i))<str.size()-1;i+=2){
    string A=str.substr(0,i+1),B=str.substr(i+2,str.size()-i-2);
    calc(str[i+1],solve(A),solve(B),res);
  }
  M[str]=mem.size();
  mem.push_back(res); 
  return mem[M[str]];
}

int main(){
  while(1){
    string str;
    cin>>str;
    if(str=="#")break;
    mem.clear(),M.clear();
    string siki;
    char ch='A';
    for(int i=0;i<(int)str.size();){
      int b=0;
      while('0'<=str[i]&&str[i]<='9') b=b*10+str[i++]-'0';
      if(b) num[ch]=b,siki+=ch++;
      else siki+=str[i++];
    }
    cout <<solve(siki).size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1376
//24
#include<iostream>

using namespace std;

int main(){
  int dp[300]={1};
  for(int i=1;i<=17;i++){
    int s=i*i;
    for(int j=s;j<300;j++){
      dp[j]+=dp[j-s];
    }
  }
  for(int n;cin>>n,n;){
    cout<<dp[n]<<endl;
  }
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int N0=N;
  int count=0;
  while(N0>0){
    count+=N0%10;
    N0=N0/10;
  }
  if(N%count==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		long count = 10000000000L;
		long tmp = y - x;
		if (tmp >= 0) {
			count = Math.min(tmp, count);
		}
		tmp = y - x * -1 + 1;
		if (tmp >= 0) {
			count = Math.min(tmp, count);
		}
		tmp = y * -1 - x + 1;
		if (tmp >= 0) {
			count = Math.min(tmp, count);
		}
		tmp = y * -1 - x * -1 + 2;
		if (tmp >= 0) {
			count = Math.min(tmp, count);
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23252
import java.util.Scanner


object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val cubes = sc.next()
    cubes
  }

  // Stackは非推奨。Listを使うことが推奨されている。
  def step(stack: List[Char], cube: Char): List[Char] = {
    if(stack.isEmpty){
      List(cube)
    }else{
      val stackTop = stack.head
      if(stackTop != cube){
        stack.tail
      }else{
        cube::stack
      }
    }
  }


  def solve(cubes: String): Int = {
    val stack = cubes.foldLeft[List[Char]](List.empty)(step)
    cubes.length - stack.length
  }


  def main(args: Array[String]): Unit = {
    val cubes = read()
    println(solve(cubes))
  }
}

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

const ll mod = 1000000007;
const ll INF = 1001001001;

int main(){
    int n; cin >> n;
    int tmp = 0;
    vector<int> a(n), ans(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        tmp ^= a[i];
    }
    for(int i = 0; i < n; i++){
        ans[i] = tmp ^ a[i];
    }
    for(int i = 0; i < n; i++) cout << ans[i] << " ";
}


Measured memory_bytes: 4772
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




















class RollingHash {
private:
    using ull = unsigned long long;
    const ull base1;
    const ull base2;
    const ull mod1;
    const ull mod2;
    vector<ull> hash1;
    vector<ull> hash2;
    vector<ull> pow1;
    vector<ull> pow2;
    
    string s;
    
public:
    RollingHash(string &s) : s(s), base1(1009), base2(2009), mod1(1000000007), mod2(1000000009),
                             hash1(s.size() + 1), hash2(s.size() + 1), pow1(s.size() + 1, 1), pow2(s.size() + 1, 1) {
        for(int i = 0; i < s.size(); i++){
            hash1[i + 1] = (hash1[i] * base1 + s[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + s[i]) % mod2;
            pow1[i + 1] = (pow1[i] * base1) % mod1;
            pow2[i + 1] = (pow2[i] * base2) % mod2;
        }
    }
    
    // s の [l, r) のハッシュ値を返す
    ull get(int l, int r){
        return (hash1[r] - ((hash1[l] * pow1[r - l]) % mod1) + mod1) % mod1;
    }
    
    ull get(){
        return get(0, s.size());
    }
    
    ull operator () (){
        return get(0, s.size());
    }
    
    ull operator () (int l, int r){
        return get(l, r);
    }
};

int main(){
    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    string ss;
    ll tmp = ((m % n == 0)? m / n : m / n + 1);
    REP(i, tmp * 2){
        ss += s;
    }
    RollingHash roli1(ss), roli2(t);
    vector<bool> match(n);
    REP(i, n){
        if(roli1(i, i + m) == roli2()){
            match[i] = true;
        }
    }
    vector<ll> d(n);
    set<ll> st;
    auto f = [dfs = [&](auto &&dfs, ll now) -> ll {
        if(st.find(now) != st.end()){
            cout << -1 << endl;
            exit(0);
        }
        if(d[now] != 0){
            return d[now];
        }
        st.insert(now);
        if(match[now]){
            d[now] = dfs(dfs, (now + m) % n) + 1;
        }
        st.erase(now);
        return d[now];
    }](ll start){ dfs(dfs, start); };
    REP(i, n){
        f(i);
    }
    cout << *max_element(d.begin(), d.end()) << endl;
}

Measured memory_bytes: 130760
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long int llint;
int main() {
	llint a, b, k;
	cin >> a >> b >> k;
	for (int i = 0;i < k;i++) {
		if (i % 2 == 0) {
			b += a / 2;
			a /= 2;
		}
		else {
			a += b / 2;
			b /= 2;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	var n = Number(input.trim());
	var a = 0;
	if(n < 4 || n == 5 || n == 6){
		console.log('No');
		return;
	} else if(n%4 == 0 || n%7 == 0) {
		console.log('Yes');
		return;
	} else {
		for(var i = 0; n>i*4; i++){
			a = n - i*4;
			if(a%7 == 0){
				console.log('Yes');
				return;
			}
		}
	}
	console.log('No');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>

using namespace std;
struct node {
    node() : value {}, left {nullptr}, right {nullptr} {};
    node(int v) : value {v}, left {nullptr}, right {nullptr} {};
    int value;
    node* left;
    node* right;
};

struct bst {
    bst() : root {nullptr} {};
    node* root;
    void insert(int v){
        node** ptr = &root;
        while(*ptr){
            if(v < (*ptr)->value){
                ptr = &((*ptr)->left);
            } else {
                ptr = &((*ptr)->right);
            }
        }
        *ptr = new node(v);
    };
    bool find(int v){
        auto ptr = root;
        while(ptr){
            if(ptr->value == v){
                return true;
            }
            if(v < ptr->value){
                ptr = ptr->left;
            } else {
                ptr = ptr->right;
            }
        }
        return false;
    };
    void inorder_print(node* ptr){
        if(!ptr){
            return;
        }
        inorder_print(ptr->left);
        cout << ' ' << ptr->value;
        inorder_print(ptr->right);
    };
    void preorder_print(node* ptr){
        if(!ptr){
            return;
        }
        cout << ' ' << ptr->value;
        preorder_print(ptr->left);
        preorder_print(ptr->right);
    };
    void print(){
        inorder_print(root);
        cout << endl;
        preorder_print(root);
        cout << endl;
    };
};


int main(){
    int n;
    cin >> n;
    char com[10];
    int v;
    auto tree = bst();
    for(int i = 0; i < n; ++i){
        scanf("%s", com);
        if(com[0] == 'i'){
            scanf("%d", &v);
            tree.insert(v);
        } else if(com[0] == 'f'){
            scanf("%d", &v);
            cout << (tree.find(v) ? "yes" : "no") << endl;
        } else {
            tree.print();
        }
    }
}

Measured memory_bytes: 13748
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

int dfs(int v, vector<vector<int>> A, vector<int> visit, int &count)
{
    bool all_flag = 1;

    for (int i = 0; i < visit.size(); i++)
    {

        if (visit[i] == 0)
        {
            all_flag = 0;
        }
    }

    if (all_flag == 1)
    {
        count++;
        //eturn 1;
    }

    int mas=0;

    for (int w : A[v])
    {
        if (visit[w] == 0)
        {
      
            visit[w] = 1;
            dfs(w, A, visit, count);
            visit[w] = 0;
        }
    }

    return mas;
}

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

    vector<vector<int>> A(N, vector<int>(0));

    for (int i = 0; i < M; i++)
    {

        int a, b;
        cin >> a >> b;

        A[a - 1].push_back(b - 1);
        A[b - 1].push_back(a - 1);
    }

    vector<int> visit(N, 0);

    visit[0] = 1;

    int count = 0;
    dfs(0, A, visit, count);

    cout << count << endl;
    return 0;
}


// const int nmax=8;
// bool graph[nmax][nmax];

//  int dfs(int v,int N,bool visited[nmax]){

//  bool all_visited=true;

//  for(int i=0;i<N;++i){
//  if(visited[i]==false)
//  all_visited=false;
//  }

//  if(all_visited){
//  return 1;
//  }


//  int ret=0;

//  for(int i=0;i<N;++i){
//  if(graph[v][i]==false) continue;
//  if(visited[i]) continue;

//  visited[i]=true;
//  ret+=dfs(i,N,visited);
//  visited[i]=false;
//  }

//  return ret;
//  }

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

//  for(int i=0;i<M;++i){
//  int A,B;
//  cin >> A >> B;
//  graph[A-1][B-1]=graph[B-1][A-1]=true;
//  }

//  bool visited[nmax];
//  for(int i=0;i<N;++i){
//  visited[i]=false;
//  }

//  visited[0]=true;
//  cout << dfs(0,N,visited) << endl;
//  return 0;
//  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

int main() {
    char s[nax];
    scanf("%s", s);
    int n =  strlen(s);
    int res = 0;
    for (int i = 0 ; i < n ; ++ i) {
        res += s[i] - '0';
    }

    puts(res % 9 == 0 ? "Yes" : "No");
}



Measured memory_bytes: 3852
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    int a,b;
    cin >> a >> b;
    cout << a * b << endl;
}


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

int main(){
    long long n,m,a;
    long long sum = 0;
    cin >> n >> m;
    for(int i = 0;i < m;i++){
        cin >> a;
        sum += a;
    }
    if(sum > n){
        cout << -1 << endl;
    }
    else{
        cout << n - sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    a, b, c, k = map(int, input().split())
    if k <= a:
        print(k)
    elif k <= a + b:
        print(a)
    else:
        print(a - (k - a - b))
resolve()

Measured memory_bytes: 61684
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) cerr << #x << " = " << (x) << " " << endl;
#else
const bool test = false;
#define dump(x) 
#define dumpl(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}
 
template<typename T>
T gcd(T a, T b)
{
  T c;
  while (a != 0) {
    c = a; a = b%a;  b = c;
  }
  return b;
}
 
void solve();
 
class Solver {
  public:
    int A, B, C, D;

  string ans()  {
    int L = A + B;
    int R = C + D;
    if (L > R) return "Left";
    if (L < R) return "Right";
    return "Balanced";
  }

  void solve() {
    cin >> A >> B >> C >> D;
    cout << ans() << endl;
  }
};
 
signed main()
{
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {    
  //     auto ptr = new Solver();
  //     ptr->solve();
  //     delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <set>
#include <map>
#include <cstdio>
using namespace std;
using ll = long long;


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


int dat[200007];

int main() {

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

    //rep(i, N)cin >>dat[i];

    cin >> N;
    int count = 0;
    rep(i, N) {
        int a, b;
        cin >> a>> b;
        if (a == b)count++;
        else count = 0;
        if (count >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    while(true){
      int a=sc.nextInt();
      String op=sc.next();
      int b=sc.nextInt();
      int ans=0;
      if(op.equals("?")){
        break;
      }
      switch(op){
        case "+":
          ans=a+b;
          break;
        case "-":
          ans=a-b;
          break;
        case "*":
          ans=a*b;
          break;
        case "/":
          ans=a/b;
          break;
      }
      System.out.println(ans);
    }
  }
}


Measured memory_bytes: 26448
#include <iostream>
#include <map>
#include <algorithm>
#include <string>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;

lli mod197 = 1000000007LL;

lli barely[100010] = {};
lli margin[100010] = {};

// a + b = a xor b が成り立つのは a and b = 0

int main(void) {

	string L;
	cin >> L;

	barely[0] = 1;

	//
	for (int i = 0; i < L.size(); i++) {
		if (L[i] == '0') {
			barely[i + 1] = barely[i];
			margin[i + 1] = margin[i] * 3;
		}
		else {
			barely[i + 1] = barely[i] * 2;
			margin[i + 1] = margin[i] * 3 + barely[i];
		}
		barely[i + 1] %= mod197;
		margin[i + 1] %= mod197;
	}

	COUT((barely[L.size()] + margin[L.size()]) % mod197);

	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int MOD = 1000000007;

const int MAX_N = 2000010;
long long fac[MAX_N + 1], finv[MAX_N + 1];

struct init_fac {
    long long mod_inv(long long a, long long m) {   // gcd(a, m) = 1
        long long b = m, x = 1, y = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(x -= t * y, y);
        }
        x = (x % m + m) % m;
        return x;
    }

    init_fac() {
        fac[0] = 1;
        for (int i = 1; i <= MAX_N; ++i) fac[i] = i * fac[i - 1] % MOD;
        finv[MAX_N] = mod_inv(fac[MAX_N], MOD);
        for (int i = MAX_N - 1; i >= 0; --i) finv[i] = (i + 1) * finv[i + 1] % MOD;
    }
} init_fac;

long long nPk(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
}

long long nCk(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return nPk(n, k) * finv[k] % MOD;
}

long long nHk(int n, int k) {
    if (n < 0 || k < 0) return 0;
    return nCk(n + k - 1, k);
}

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

    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r2++; c2++;
    int ans = 0;
    (ans += nCk(r2 + c2, c2)) %= MOD;
    (ans += MOD - nCk(r2 + c1, c1)) %= MOD;
    (ans += MOD - nCk(r1 + c2, c2)) %= MOD;
    (ans += nCk(r1 + c1, c1)) %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 31488
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

a = p[:X]
b = q[:Y]
a.extend(b)
a.extend(r)
a.sort(reverse=True)
print(sum(a[:X+Y]))


Measured memory_bytes: 109676
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);
            int iT = int.Parse(sS[2]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            for (int i = iA; i <= iT; i += iA)
            {
                iOut += iB;                
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
import java.io.*;
import java.util.*;

public class Main
{
	
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int ans = 0;
		for(int i = 0; i< n ; i++){
			int now = Integer.parseInt(br.readLine());
			if(now != 1){
				boolean isPrime = true;
				for(int j = 2 ; j*j <= now; j++)
				{
					if(now != j && now % j == 0){
						isPrime = false;
						break;
					}
				}
				if(isPrime) ans++ ;
			}
		}
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 28204
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
a = [I() for i in range(M)]

dp = [0]*(N+1)
dp[0] = 1

for i in a:
  dp[i] = -1

for i in range(N+1):
  if dp[i] == -1:
    continue
  if i+1 <= N:
     if dp[i+1] != -1:
      dp[i+1] += dp[i]
  if i+2 <= N:
    if dp[i+2] != -1:
      dp[i+2] += dp[i]
      
print(dp[N]%mod)

Measured memory_bytes: 471684