akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  string s, t;
  cin >> s >> t;
  if (s.substr(0, s.length()) == t.substr(0, t.length() - 1)) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
}


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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N, M;
    cin >> N >> M;
    vector<int> pj[M + 1];
    for (int i = 0; i < N; i ++) {
        int a, b;
        cin >> a >> b;
        if (a <= M) pj[a].push_back(b);
    }
    priority_queue<int> que;
    int ans = 0;
    for (int i = 1; i <= M; i++) {
        if(!pj[i].empty()) {
            for(int a : pj[i]) {
                que.push(a);
            }
        }
        if (!que.empty()) {
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
N =int(input())
D = [int(x) for x in input().split()]
cnt = [0]*(N)
if D[0]!=0:
  print(0)
  exit()
for i in range(N):
  cnt[D[i]]+=1
ans = 1
if cnt[0]!=1:
  print(0)
  exit()
a = 0
b = 0
for i in range(1,N-1):
  if cnt[i]==0 and a==0:
    a=i
    b+=1
  if a!=0 and cnt[i]!=0:
    print(0)
    exit()
  elif a!=0 and cnt[i]==0:
    b+=1
  ans*=cnt[i-1]**cnt[i]
  ans%=998244353
#print(cnt,a,b)
if N-a==b or a==b==0:
  print(ans)
else:
  print(0)


Measured memory_bytes: 53548
// finish date: 2018/01/10
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int fact(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans *= i;
    }
    return ans;
}

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << ((a + b) * h / 2) << endl;


    return 0;
}

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

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

auto input(size_t n) {
    return InputType2(n);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

int main() {
    size_t n = input();
    vector<size_t> a(n);
    map<size_t, size_t> m{};
    for (size_t i = 0; i < n; ++i) {
        a[i] = input();
        ++m[a[i]];
    }
    size_t b = 0;
    for (auto& e : m) {
        auto x = e.second;
        auto y = x * (x - 1) / 2;
        b += y;
    }
    for (auto e : a) {
        auto x = m[e];
        if (x < 2)
            cout << b << endl;
        else {
            auto y = x * (x - 1) / 2;
            auto z = b - y + (x - 1) * (x - 2) / 2;
            cout << z << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 11008
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

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

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[45], *outs=B+40, *outr=B+40;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 20010;
const int MAXK = 20;

int main()
{
	
	int n, k;
	cin >> n >> k;
	if (k == 1)
	{
		cout << 0 << endl;
	}
	else
	{
		int a = n-(k-1);
		cout << a-1 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll x;
    cin >> x;
    
    for(ll i = -1000; i <= 1000; ++i){
        for(ll j = -1000; j <= 1000; ++j){
            if(i*i*i*i*i - j*j*j*j*j == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3672
main :: IO ()
main = do
    [n, m] <- map read.words <$> getLine
    putStr.concatMap (\(x, y) -> shows x $ ' ' : shows y "\n" ) $ solve n m

solve :: Int -> Int -> [(Int, Int)]
solve n m =
    let r = div (n - 1) 2
        diffs = map (n -) [1,3..r] ++ reverse [2,4..r]
    in take m $ zipWith (\i d -> (i, i + d)) [1..] diffs


Measured memory_bytes: 9548
package main

import "fmt"

func main() {
	var k int
	var s string
	fmt.Scan(&k, &s)


	ss := split(s)
	if len(ss) <= k {
		fmt.Println(s)
		return
	}
	fmt.Print(s[0:k])
	fmt.Print("...")



}


func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}



Measured memory_bytes: 1828
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int sa[4100];
char in[40];
char ret[4100];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<=b){
		printf("Impossible\n");return 0;
	}
	int n=a+b;
	int at=-1;
	int sz=0;
	for(int i=0;i<n;i++){
		if(at==-1){
			sa[sz++]=i;
			at=i;
		}else{
			printf("? %d %d\n",at,i);
			fflush(stdout);
			scanf("%s",in);
			if(in[0]=='Y'){
				sa[sz++]=i;
				at=i;
			}else{
				sz--;
				if(sz==0)at=-1;
				else at=sa[sz-1];
			}
		}
	}
	for(int i=0;i<n;i++){
		printf("? %d %d\n",sa[sz-1],i);
		fflush(stdout);
		scanf("%s",in);
		if(in[0]=='Y'){
			ret[i]='1';
		}else ret[i]='0';
	}
	printf("! %s\n",ret);
}

Measured memory_bytes: 708
func gcd(_ a: Int, _ b: Int) -> Int {
    b == 0 ? abs(a) : gcd(b, a%b)
}

struct Fraction: Equatable, Hashable {
    let numerator, denominator: Int
    init (_ numerator: Int, _ denominator: Int) {
        switch (numerator, denominator) {
        case (0, 0):
            self.numerator = 0
            self.denominator = 0
        case (0, _):
            self.numerator = 0
            self.denominator = 1
        case (_, 0):
            self.numerator = 1
            self.denominator = 0
        default:
            let g = gcd(numerator, denominator)
            self.numerator = denominator.signum() * numerator / g
            self.denominator = abs(denominator) / g
        }
    }
    func perpendicular() -> Fraction {
        Fraction(-denominator, numerator)
    }
}

func pow(_ x: Int, _ n: Int, mod: Int) -> Int {
    precondition(n >= 0 && mod > 1)
    if n == 0 { return 1 }

    var u = pow(x, n/2, mod: mod)
    u = u*u % mod
    if n%2 == 1 { u = u*x % mod }
    return u
}
///////////////////////////////////////////////////////////////////////////////

let MOD = Int(1e9+7)

let N = Int(readLine()!)!
var cliques: [Fraction: Int] = [:]
var zeroes = 0
for _ in 1...N {
    let line = readLine()!.split(separator: " ").map { Int($0)! }
    let f = Fraction(line[0], line[1])
    if f == Fraction(0, 0) {
        zeroes += 1
    } else {
        cliques[f, default: 0] += 1
    }
}

var ways = 1
while let (k1, v1) = cliques.first {
    cliques.removeValue(forKey: k1)
    let k2 = k1.perpendicular()
    let v2 = cliques.removeValue(forKey: k2)

    ways *= pow(2, v1, mod: MOD) + (v2 != nil ? pow(2, v2!, mod: MOD) - 1 : 0)
    ways %= MOD
}
ways += MOD - 1
ways += zeroes
ways %= MOD
print(ways)


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pii pair<int, int>
#define vii vector<pii>
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vd vector<double>
#define vvi vector< vector<int> >
#define vvii vector< vector< pii > >
#define ld long double
#define mapii map<int, int>
#define mapsi map<string, int>
#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define INF  LLONG_MAX
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define pie  acos(-1)
#define mod(n,m) ((n % m + m) % m)
#define eps (1e-8)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'
#define output freopen("output.txt", "w", stdout)
#define mp(x, y, z) {x, {y, z}}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    deque<char> dq(n);
    rep(i, 0, n) cin >> dq[i];

    stack<char> st;
    rep(i, 0, sz(dq))
    {
        if (st.empty())
        {
            st.push(dq[i]);
        }
        else
        {
            if (st.top() == '(' && dq[i] == ')') st.pop();
            else st.push(dq[i]);
        }
    }

    while(!st.empty())
    {
        char c = st.top();
        st.pop();
        if (c == '(') dq.push_back(')');
        else dq.push_front('(');
    }
    rep(i, 0, sz(dq)) cout << dq[i];

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
int main(){
  char str1[4001], str2[4001];
  int i, j, k;
  while(scanf("%s %s", str1, str2) != EOF){
    int res = 0;
    for(i = 0;i < strlen(str1);i++){
      int x = 0;
      for(k = 0;i + k < strlen(str1) && k < strlen(str2);k++){
	if(str1[i + k] == str2[k])x++;
	else x = 0;
	res = max(res, x);
      }
    }

    for(i = 0;i < strlen(str2);i++){
      int x = 0;
      for(k = 0;k < strlen(str1) && i + k < strlen(str2);k++){
	if(str1[k] == str2[i + k])x++;
	else x = 0;
	res = max(res, x);
      }
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

typedef  long long ll;

using namespace std;

ll str_to_int(string s){
    ll res = 0;
    int digits = s.length();
    for(int i = 0; i < digits; i++)
    {
        res += (s[i] - '0') * pow(10, digits - 1 - i);
    }
    return res;
}

int main(){
    string s; cin >> s;

    int l = s.length() - 1;

    int n = 1 << l; //+の入れかた

    ll ans = 0;

    for(int flags = 0; flags < n; flags++){
        string tmp = "";
        for(int j = 0; j < l; j++){
            tmp += s[j];
            if((flags >> j & 1) == 1){
                ans += str_to_int(tmp);
                tmp = "";
            }
        }
        tmp += s[l];
        ans += str_to_int(tmp);
    }

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

Measured memory_bytes: 512
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007

using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

int main()
{
	fast();
	int a,b;
	cin>>a>>b;
	cout<<6-a-b;
}

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

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


Measured memory_bytes: 3092
/***********************************************************
*   Falling down is an accident, Staying down is a choice. *
************************************************************/
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#define ios std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) //Fast IO
#define PI acos(-1.0) //3.14159265358
#define EPS 1e-9 //epsilon, 10^-9, checking for equality 
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define isort(x) sort(x.begin(),x.end())
#define dsort(x) sort(x.rbegin(),x.rend())
const int inf=1e9+7; //10^9 +7
const int modc=998244353;
typedef long long int ll;typedef vector<int> vi;typedef vector<ll> vll;
typedef pair<int,int> ii;typedef map<int,int> mii;typedef complex<double> cd;
inline void rvi(vi &v, int n){int temp; rep(i,n){cin>>temp;v.pb(temp);}}
inline void rvll(vll &v, int n){ll temp;rep(i,n){cin>>temp;v.pb(temp);}}
inline void prvi(vi &a){rep(i,sz(a)){cout<<a[i]<<" ";}cout<<endl;}
inline void prvll(vll &a){rep(i,sz(a)){cout<<a[i]<<" ";}cout<<endl;}
inline vll prefixsum(vi &a){vll b;b.pb(a[0]);for(int i=1;i<sz(a);i++){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vi &a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];for(int i=sz(a)-2;i>=0;i--){b[i]=a[i]+b[i+1];}return b;}
inline vll prefixsum(vll &a){vll b;b.pb(a[0]);for(int i=1;i<sz(a);i++){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vll &a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];for(int i=sz(a)-2;i>=0;i--){b[i]=a[i]+b[i+1];}return b;}
void solve();int main(){ios;solve();return 0;}
/***************************************************************************************************************************/
void solve()
{
	int a,p;cin>>a>>p;
	cout<<(a*3+p)/2<<endl;
}

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

#define md 1000000007

long long dp[4400000];
int mk[4400000];
int data[25][25];

main()
{
  dp[0]=1;
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
    {
      scanf("%d",&data[i][j]);
    }
  }
  queue<pair<int,int> > q;
  q.push(make_pair(0,0));
  while(!q.empty())
  {
    int nw=q.front().first;
    int bf=q.front().second;
    q.pop();
    if(nw==n)
      continue;
    for(int i=0;i<n;i++)
    {
      if(data[nw][i]&&((bf&(1<<i))==0))
      {
        //if(nw==2)
        //printf("{%d %d %d %d}\n",bf,i,bf&(1<<i),nw);
        dp[(bf+(1<<i))]+=dp[bf];
        dp[(bf+(1<<i))]%=md;
        if(mk[(bf+(1<<i))]==0)
        {
          mk[(bf+(1<<i))]=1;
          q.push(make_pair(nw+1,(bf+(1<<i))));
        }
      }
    }
  }/*
  for (int i=0;i<=((1<<(n))-1);i++)
  {
    printf("{%d}\n",dp[i]);
  }*/
  printf("%d",dp[((1<<(n))-1)]);
}


Measured memory_bytes: 32128
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-x))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd()
{
	static uint seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());
	bool f(false);
	while(ch<48||ch>57) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();
	while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
Finline int read_str(char *s)
{
	char ch(getchar());
	while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;
	*tar=ch,ch=getchar();
	while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=305;
const int mod=998244353;
template<typename _Tp1,typename _Tp2>Finline void add(_Tp1 &a,_Tp2 b){(a+=b)>=mod&&(a-=mod);}
template<typename _Tp1,typename _Tp2>Finline void sub(_Tp1 &a,_Tp2 b){(a-=b)<0&&(a+=mod);}
int f[N][N],g[N][N];
char s[N];
int sum[N][N];
int main()
{
	int n=read_str(s+1),_;
	read(_);
	s[++n]='0';
	f[0][0]=1;
	for(int i=n;i>=1;--i)
	{
		memset(g,0,sizeof(g));
		memset(sum,0,sizeof(sum));
		int p=i;
		while(s[p-1]=='1') --p;
		for(int j=0;j<=n;++j)
		{
			for(int k=j;k<=n;++k)
			{
				add(g[j][k],f[j][k]);
				add(sum[0][k],f[j][k]);
				sub(sum[j][k],f[j][k]);
				for(int t=1;t<=i-p;++t) add(g[j+t][k+t],f[j][k]);
			}
		}
		for(int k=0;k<=n;++k)
		{
			for(int j=0;j<=k;++j)
			{
				if(j) add(sum[j][k],sum[j-1][k]);
				add(g[j][k],sum[j][k]);
			}
		}
		i=p;
		memcpy(f,g,sizeof(g));
	}
	int ans=0;
	for(int i=0;i<=n&&i<=_;++i) add(ans,f[0][i]);
	printf("%d\n",ans);
	return 0;
}


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

#define fo(i, x, y) for (int i = x; i <= y; ++i)
#define fd(i, x, y) for (int i = x; i >= y; --i)

typedef long long ll;

const int mod = 1e9 + 7;

int n;

int getint()
{
	char ch;
	int res = 0, p;
	while (!isdigit(ch = getchar()) && (ch ^ '-'));
	p = ch == '-'? ch = getchar(), -1 : 1;
	while (isdigit(ch))
		res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
	return res * p;
}

int main()
{
	n = getint();
	ll sum = 0, ans = 0;
	fo(i, 1, n)
	{
		ll x;
		x = getint();
		(ans += sum * x) %= mod;
		(sum += x) %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int len = scanner.nextInt();
        int choose = scanner.nextInt();
        int[] prices = new int[len];

        for(int index = 0; index < len; index++ ){
            prices[index] = scanner.nextInt();
        }

        Arrays.sort(prices);
        int sum = 0;
        for(int index = 0; index < choose; index++ ){
            sum += prices[index];
        }
        System.out.println(sum);
        scanner.close();
    }
}


Measured memory_bytes: 38512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            while (n-- > 0) {
                int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
                int s = a + b + c;
                System.out.println(a >= 100 || b >= 100 || c >= 100 || s >= 240 || a + b >= 180 ? "A" : s >= 210 || s >= 150 && (a >= 80 || b >= 80) ? "B" : "C");
            }
        }
    }
}


Measured memory_bytes: 37968
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int count=0;
  
  for(int i=1; i<=N; i++){
    if(i<=9){
      count++;
    }
    else if(100<=i&&i<=999){
      count++;
    }
    else if(10000<=i&&i<=99999){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
n, y = gets.split.map(&:to_i)
(0..n).each do |a|
(0..(n-a)).each do |b|
c = n - a - b
break if c < 0
if 10000 * a + 5000 * b + 1000 * c == y
puts "#{a} #{b} #{c}"
exit
end
end
end

puts "-1 -1 -1"

Measured memory_bytes: 1788
X=int(input())
l=[]
for i in range(300):
    a=i**5
    l.append(a)
    l.append(-a)
for j in l:
    for s in l:
        if j-s==X and j!=s:
            ans=[]
            for i in [j,s]:
                aaa=abs(i)**(1/5)
                if i>=0:
                    ans.append(int(aaa))
                else:
                    ans.append(int(-aaa))
            print(*ans)
            exit()

Measured memory_bytes: 9408
answer_list = [1, 1] + [None] * 43

def fib(num):
    ans = answer_list[num]
    if ans:
        return ans
    ans = fib(num - 1) + fib(num - 2)
    answer_list[num] = ans
    return ans


n = int(input())

print(fib(n))

Measured memory_bytes: 7748
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

template<typename T>
struct BIT{
  int n;
  vector<T> d;
  BIT(int n = 0):n(n),d(n+1){}
  void add(int i,T x=1){
    for(i++;i<=n;i += i&-i){
      d[i] += x;
    }
  }
  T sum(int i){
    T x = 0;
    for(i++;i>0;i -= i&-i){
      x += d[i];
    }
    return x;
  }
};

int main(){
  int n,m,q;cin >> n >> m >> q;
  vector<P> sche(m);
  vector<pair<P,int>> query(q);
  rep(i,m){
    int l,r;cin >> l >> r;
    sche[i] = make_pair(l,r);
  }
  sort(sche.rbegin(),sche.rend());
  vector<int> ans(q);
  rep(i,q){
    int p,q;cin >> p >> q;
    P temp = make_pair(p,q);
    query[i] = make_pair(temp,i);
  }
  sort(query.rbegin(),query.rend());
  int inds = 0;
  int indq = 0;
  BIT<int> tree(505);
  for(int x = n;x >= 0;x--){
    while(inds < m && sche[inds].first >= x) {
      tree.add(sche[inds].second,1);
      inds++;
    }

    while(indq < q && query[indq].first.first >= x){
      ans[query[indq].second] += tree.sum(query[indq].first.second);
      indq++;
    }
  }

  rep(i,q) cout << ans[i] << endl;
}

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

int main() {
   string a;
   cin >> a;
   int count = 700;
   if(a[0] == 'o'){
       count += 100;
   }
   if(a[1] == 'o'){
       count += 100;
   }
   if(a[2] == 'o'){
       count += 100;
   }
   cout << count << endl;
   
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
using namespace std;
enum Query
{
    insert = 0,
    dump = 1,
    splice = 2,
};
std::istream &operator>>(std::istream &is, Query &i)
{
    int tmp;
    if (is >> tmp)
        i = static_cast<Query>(tmp);
    return is;
} //オペレーターオーバーロード
void dump_list(list<int> L)
{
    //auto 具体的な型書かなくても右側で判別してくれる
    if (!L.empty())
    {
        cout << *L.begin();
        for (auto it = ++L.begin(); it != L.end(); it++)
        {
            cout << ' ' << *it;
        }
    }
    cout << endl;
}
int main()
{
    typedef list<int> ls;
    int n;
    cin >> n;

    vector<ls> L(n);

    int q;
    cin >> q;

    for (int i = 0; i < q; i++)
    {
        Query query;
        cin >> query;

        if (query == insert)
        {
            int t, x;
            cin >> t >> x;
            L.at(t).push_back(x);
        }
        if (query == dump)
        {
            int t;
            cin >> t;
            dump_list(L.at(t));
        }
        if (query == splice)
        {
            int s, t;
            cin >> s >> t;
            L.at(t).splice(L.at(t).end(), L.at(s));
        }
    }
}
//moveとは


Measured memory_bytes: 34360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    string S;
    cin >> S;

    if(S[2]==S[3]&&S[4]==S[5]){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(c <= b / a) cout << c << endl;
    else cout << b / a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int shar;
typedef double shara;
typedef string w;
int main(){
    shar x,y,z,a,b,c;
    cin>>a>>b>>c;
    x=a+b;
    y=b+c;
    z=a+c;
    if(x<=y&&x<=z){cout<<x;}
    else if(z<x&&z<y){cout<<z;}
    else if(z==x&&y==z&&x==y){cout<<a+b+c;}
    else if(y<=x&&y<=z){cout<<y;}






























  return 0;
}



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

ll gcd(ll a, ll b){
  return b ? gcd(b,a%b) : a;
}

int main(){
  int n;
  cin >> n;
  ll ans = 0;

  rep(i,1,n+1){
    rep(j,1,n+1){
      rep(k,1,n+1){
        if(i>j||j>k) continue;
        int a = gcd(i,j);
        int b = gcd(a,k);
        if(i==j&&j==k) ans += b;
        else if(i==j||j==k||i==k) ans += 3*b;
        else ans += 6*b;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  ll x, y;
  cin >> x >> y;

  ll tmp = y / x;
  ll cnt = 0;
  while (tmp > 0) {
    tmp /= 2;
    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 764
n,a=int(input()),list(map(int,input().split()));dp=[[None]*n for _ in range(n)]
for i in range(n):dp[i][i]=a[i]
for j in range(1,n):
  for i in range(n-j):dp[i][j+i]=max(a[i]-dp[i+1][j+i],a[j+i]-dp[i][j+i-1])
print(dp[0][-1])

Measured memory_bytes: 164744
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin>>N;
	vector<string> A(N);
	for(int i=0;i<N;++i){
		cin>>A[i];
	}

	int M;
	cin>>M;
	vector<string> B(M);
	for(int i=0;i<M;++i){
		cin>>B[i];
	}
	int ans = 0;
	for(int i=0;i<N;++i){
		int res = 0;
		string ter = A[i];
		for(int i=0;i<N;++i){
			if(A[i] == ter ){
				++res;
			}
		}
		for(int i=0;i<M;++i){
			if(B[i]==ter){
				--res;
			}
		}
		ans = max(ans,res);
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) begin(x),end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << " " <<
using namespace std;

const int MXN=1005;
const int MOD=1e9+7;
int add(int x,int y){return(x+=y)<MOD?x:x-MOD;}
int sub(int x,int y){return(x-=y)>= 0?x:x+MOD;}

int n,m;
int dp[MXN][MXN];
char mat[MXN][MXN];

int main(){
  scanf("%d%d",&n,&m);
  for(int i=0;i<n;++i)scanf("%s",mat[i]);
  dp[n-1][m]=1;
  for(int i=n-1;i>=0;--i){
    for(int j=m-1;j>=0;--j){
      if(mat[i][j]!='#'){
        dp[i][j]=add(dp[i+1][j],dp[i][j+1]);
      }
    }
  }
  printf("%d\n",dp[0][0]);
}


Measured memory_bytes: 5120
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef vector <int> vi;
typedef map <char,char> mapcc;
#define REP(i,n) for (int i=0; i<n; i++)
string A2Z="abcdefghijklmnopqrstuvwxyz";
struct affine_key{
	int a;
	int b;
};

string decode(mapcc &mp, string &msg){
	string s="";
	int i=0;
	while (msg[i]){
		char c = msg[i];
		if (islower(c)) c = mp[c];
		s += c;
		i++;
	}
	return s;
}

string affine(string &msg, int a=0, int b=0){
	
	mapcc mp;
	REP(i,26){
		int i1 = i*a+b;
		while (i1<0) i1 += 26;
		mp[A2Z[i]] = A2Z[i1 % 26];
	}
	return decode(mp, msg);
}

string rot(string &msg, int a){
	if (a==0) return msg;
	mapcc mp;
	while (a<0) a += 26;
	REP(i,26)
		mp[A2Z[i]] = A2Z[(i+a) % 26];
	return decode(mp, msg);
}

vi find(string &msg){
	char c0='t';
	vi key(2);
	int a,b;
	for (int i=1; i<26; i+=2){
		a = i;
		string x = affine(msg, a, 0);
		b = c0-x[0];
		if (b<0) b += 26;
		x = rot(x, b);
		if (x=="this" || x=="that"){
			key[0] = a;
			key[1] = b;
			return key;
		}
	}
	key[0] = -1;
	return key;
}

int main(void){
	int n;
	cin>>n;
	cin.ignore();
	REP(i,n){
		vi key;
		string msg, word;
		getline(cin, msg);
		istringstream is(msg);
		while(is>>word)
			if (word.size()==4){
				key = find(word);
				if (key[0] != -1) break;
			}
		cout<<affine(msg, key[0], key[1])<<endl;
	}
}

Measured memory_bytes: 1248
import numpy as np
N,K = map(int,input().split())
q = list(map(int,input().split()))
q = np.array(q)
 
p = (q + 1) /2
p = p.tolist()
a = sum(p[:K])
mx = a
 
for i in range(0,N-K):
    a = a - p[i] + p[i+K]
    if a > mx:
        mx = a
print(mx)

Measured memory_bytes: 33900
//include
//------------------------------------------
#include <iostream>
#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 <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>(b);i--)
#define REP(i,n)  FOR(i,0,n)

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
//-------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//typedef
//-------------------------------------------
typedef long long ll;

int memo[10001];
int isprime(int x) {
    if (x < 0 ) return 0;
    if (x == 2) return 1;
    if (x % 2 == 0) return 0;

    int l = (int)sqrt(x);
    for (int i = 3; i <= l; i += 2) {
        if (x % i == 0) return 0;
    }

    return 1;
}

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

    int m;
    while(1) {
        cin >> m;
        if (m == 0) break;
        FORR(j, m, 0) {
            if (isprime(j) && isprime(j - 2)) {
                cout << j - 2 << " " << j << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3008
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    ll H, W, N;
    cin >> H >> W >> N;
    map<ll, ll> mp;

    rep(i, 0, N) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        rep(k, 0, 3) rep(l, 0, 3) {
            if(0 <= a - k and a - k < H - 2 and 0 <= b - l and b - l < W - 2) {
                mp[(a - k) * W + b - l]++;
            }
        }
    }
    ll rsl[10];
    memset(rsl, 0, sizeof(rsl));
    for(auto it = mp.begin(); it != mp.end(); it++) {
        rsl[it->second]++;
    }

    ll cnt = 0;
    rep(i, 1, 10) {
        cnt += rsl[i];
    }
    rsl[0] = (H - 2) * (W - 2) - cnt;
    rep(i, 0, 10) cout << rsl[i] << endl;
}


Measured memory_bytes: 56576
#include <stdio.h>
 
long long mul(long long a, long long b, long long MOD){
    return(a*b)%MOD;
}

long long pow_MOD(long long x,long long n,long long MOD){
    long long ans = 1;
    while(n){
        if(n&1) ans=mul(ans,x,MOD);
        x=mul(x,x,MOD);
        n>>=1;
    }
    return ans;
}
 
int main(){
    long long MOD = 1000000007LL;
    int N,K;
    scanf("%d %d",&N,&K);
    long long ans=0;
    long long v[K];
    for(int i = K-1;i>=0;i--) {
        v[i] = pow_MOD(K/(i+1),N,MOD);
        for(int j = 2*(i+1); j <= K;j+=(i+1)) {
            v[i]-=v[j-1];
            if(v[i] < 0) v[i]+=MOD;
        }
    }
    for(int i = 0; i<K; i++) ans+=((v[i]*((i+1LL)%MOD))%MOD);
    printf("%lld\n",ans%MOD);
    return 0;
}

Measured memory_bytes: 2512
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int W,H,N;
    cin >> W >> H >> N;
    int minx = 0, miny = 0;

    forn(i,N){
        int x,y,a;
        cin >> x >> y >> a;
        if(a == 1){
            //el x solo actualiza el minimo
            if(x>W){
                W=minx;
            }else{
                if(x > minx){
                    minx = x;
                }
            }
        }else if(a == 2){
            if(x<minx){
                W=minx;
            }else{
                if(x < W){
                    W = x;
                }
            }
        }else if(a == 3){
            if(y>H){
                H = miny;
            }else{
                if(y > miny){
                    miny = y;
                }
            }
        }else{
            if(y < miny){
                H = miny;
            }else{
                if(y < H){
                    H = y;
                }
            }
        }
    }
    cout << (W-minx)*(H-miny);
    return 0;
}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]D - Dice in Line
            var line = ReadLine();
            int N = line[0];
            int K = line[1];
            var P = ReadLine();

            var dices = GetDices();
            double sum = 0;

            for(int i = 0; i < K; i++)
            {
                sum += dices[P[i]];
            }

            double max = sum;

            for(int i = 0; i < N - K; i++)
            {
                sum += dices[P[i + K]] - dices[P[i]];
                max = Math.Max(max, sum);
            }

            Console.WriteLine(max);
        }

        static double[] GetDices()
        {
            var dices = new double[1001];
            double sum = 0;

            for(int i = 1; i <= 1000; i++)
            {
                sum += (double)i;
                dices[i] = sum / i;
            }

            return dices;
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 30684
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let s = read::<String>();
    let vec_s: Vec<char> = s.chars().collect();

    let mut need_left = 0;
    let mut pointer = 0;
    for i in 0..n {
        if vec_s[i] == '(' {
            pointer += 1;
        } else {
            if pointer == 0 {
                need_left += 1;
            } else {
                pointer -= 1;
            }
        }
    }
    let need_right = pointer;

    let mut res = "".to_string();
    for _ in 0..need_left {
        res += &"(".to_string();
    }
    res += &s;
    for _ in 0..need_right {
        res += &")".to_string();
    }
    println!("{}", res);
}


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

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

int main()
{
	FASTIO;
	int a, b,x,y,s,h,m;
	cin>>a>>b>>x>>y>>s;
	if(b<=y)
    {
        m=y-b;
    }
    else
    {
        m=(60+y)-b;
        x--;
    }
        h=x-a;
        h=h*60;

    cout<<(h+m)-s<<"\n";
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,m,s;
    cin >> n >> m >> s;
    const ll INF = 1ll << 62;
    const ll silvermax = 50*n;
    vector<vector<pair<ll,pair<ll,ll>>>> graph(n);
    for(i = 0;i < m;++i){
        ll u,v,a,b;
        cin >> u >> v >> a >> b;
        --u;    --v;
        graph.at(u).emplace_back(v, make_pair(a,b));
        graph.at(v).emplace_back(u, make_pair(a,b));
    }
    vector<ll> c(n);
    vector<ll> d(n);
    vector<vector<ll>> cost(n, vector<ll>(silvermax+1, INF));
    for(i = 0;i < n;++i){
        cin >> c.at(i) >> d.at(i);
    }
    s = min(s, silvermax);
    cost.at(0).at(s) = 0;
    priority_queue<pair<ll,pair<ll,ll>>> pq;
    pq.emplace(0, make_pair(0,s));
    while(!pq.empty()){
        auto now = pq.top();
        pq.pop();
        ll nowcost = -now.first;
        ll nowsta = now.second.first;
        ll nowsilver = now.second.second;
        ll nextsilver = min(silvermax, nowsilver + c.at(nowsta));
        ll nextcost = nowcost + d.at(nowsta);
        if(nowsilver < silvermax && cost.at(nowsta).at(nextsilver) > nextcost){
            cost.at(nowsta).at(nextsilver) = nextcost;
            pq.emplace(-nextcost,make_pair(nowsta, nextsilver));
        }
        for(auto next:graph.at(nowsta)){
            ll nextsta = next.first;
            ll silvercost = next.second.first;
            ll minutecost = next.second.second;
            if(silvercost > nowsilver) continue;
            nextsilver = nowsilver - silvercost;
            nextcost = nowcost + minutecost;
            if(cost.at(nextsta).at(nextsilver) > nextcost){
                cost.at(nextsta).at(nextsilver) = nextcost;
                pq.emplace(-nextcost, make_pair(nextsta, nextsilver));
            }
        }
    }
    for(i = 1;i < n;++i){
        ll ans = INF;
        rep(j, silvermax+1){
            ans = min(ans, cost.at(i).at(j));
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 7332
#include<cstdio>
using namespace std;
long long ans[90];
int main(){
	int n;
	scanf("%d",&n);
	ans[0]=2,ans[1]=1;
	for(int i=2;i<=n;i++)
		ans[i]=ans[i-1]+ans[i-2];
	printf("%lld\n",ans[n]);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
        #pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize("unroll-loops")
         
        #include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define N 300010
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        const double eps = 1e-9;
         
        mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
        
 		signed main()
 		{
 			char c;
			 cin>>c;
			 if(c>='A' && c<='Z')
			 cout<<'A';
			 else
			 cout<<'a';	
		}

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

int func(int n, int k) {
  if ( n == 1 ) return 0;
  return (func(n-1, k)+k)%n;  
}

int main() {
  int n, k, m;
  while ( cin >> n >> k >> m, n ) {
    cout << (func(n-1, k)+m)%n+1 << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3412