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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool is_prime (int x){
  if (x<=1) return false ;
  for (int i=2 ; i*i<=x ; i++){
    if (x%i==0) return false ;
  }
   return true;
}
int64_t solve( int64_t x){
  if ( x == 1){
    return 1;
  }else {
    return 2*solve(x/2)+1 ;
  }
}
 
/*CODE START HERE*/
int main() {
  int64_t x;
  cin >> x;
  cout << solve (x) << endl;
}

Measured memory_bytes: 3620
n, m = map(int, input().split())
AC = [0 for _ in range(n)]
PENA = [0 for _ in range(n)]
ac = 0
pena = 0
for _ in range(m):
    p, s = input().split()
    p = int(p)-1
    if(AC[p]):
        continue
    if(s == "AC"):
        AC[p] = 1
    else:
        PENA[p] += 1

for i in range(n):
    ac += AC[i]
    if(AC[i]):
        pena += PENA[i]
print(ac, pena)


Measured memory_bytes: 4760
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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

int N, A;
VI x(60);
vector<VVL> dp(60, VVL(60, VL(2600, 0)));
// dp[i][j][k] = x1からxiまでのうちj個選んで
// 合計をkにできるパターン数

void calcdp() {
  dp[0][0][0] = 1;

  NREP(i, N) {
    REP(j, N + 1) {
      REP(k, 2501) {

        dp[i][j][k] += dp[i - 1][j][k];
        if (k >= x[i] && j > 0) {
          dp[i][j][k] += dp[i - 1][j - 1][k - x[i]];
        }
      }
    }
  }

  return;
}

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

  cin >> N >> A;
  NREP(i, N) {
    cin >> x[i];
  }

  calcdp();

  ll ans = 0;

  NREP(j, N) {
    ans += dp[N][j][A * j];
  }

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

Measured memory_bytes: 74880
#include <iostream>

using namespace std;
long long MOD = 1e9+7;
int main()
{
     long long n,sum=0;
    cin>>n;
    long long Arr[n];
    long long pSa[n];
    for(long long i=0 ; i < n ; i++){
        
        cin>>Arr[i];
    }
    for (long long j=0 ;j<n;j++){
        if(j==0){
            pSa[0]=Arr[0];
        }
      else{
          pSa[j]=pSa[j-1]+Arr[j];
      }
    }
    for(long long k=0;k<n;k++){
        long long a = Arr[k]%MOD;
        long long b = (pSa[n-1] - pSa[k])%MOD;
        long long c = ((a%MOD)*(b%MOD))%MOD;
        sum += c%MOD;
    }
    cout<<sum%MOD<<endl;
   return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

ll mult(ll n) {
	vector<ll> vs;
	ll prev = 2;
	for (int i = 0; i < 64; i++) {
		vs.push_back(prev);
		prev = (prev * prev) % mod;
	}
	ll r = 1;
	for(int i = 0;i < 64;i++){
		if ((n >> i) & 1) {
			r *= vs[i];
			r %= mod;
		}
	}
	return r;
}

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

ll solve(ll n, ll a) {
	ll v = 1;
	ll u = 1;
	for (ll i = n, j = 1; i > n - a; i--, j++) {
		v *= i;
		v %= mod;
		v *= (inv_mod(j)) % mod;
		v %= mod;
	}
	return v;
}

int main(void)
{
	ll n,a,b;
	cin >> n >> a >> b;
	ll sum = mult(n) - 1;
	ll as = solve(n, a);
	ll bs = solve(n, b);
	ll m = (sum - as + mod - bs + mod) % mod;
	cout << m << endl;
	return 0;
}



Measured memory_bytes: 256
S = str(input())
for i in range(int(input())):
    L = input().split()
    o = L[0]
    a = int(L[1])
    b = int(L[2]) + 1
    if len(L) == 4:
        p = L[3]
    else:
        p = 0

    if o == "print":
        print(S[a:b])
    elif o == "reverse":
        S = S[:a]+S[a:b][::-1]+S[b:]
    elif o == "replace":
        S = S[:a]+p+S[b:]



Measured memory_bytes: 5612
ac = 0
wa = 0
tle = 0
re = 0

n = int(input())

s = ["a"]*n
for i in range(n):
    s[i] = input()

for j in range(n):
    if s[j]=="AC":
        ac += 1
    elif s[j]=="WA":
        wa += 1
    elif s[j]=="TLE":
        tle += 1
    elif s[j]=="RE":
        re += 1

print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b,k; cin >> a >> b >> k;
  if (a-k >= 0) cout << a-k << " " << b << endl;
  else {
    if (b+a-k >= 0) cout << 0 << " " << b+a-k << endl;
    else cout << 0 << " " << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const ll MOD = 998244353;
const int MAX_N = 200010;

struct Robot {
  int id;
  int x;
  int d;

  Robot(int id = -1, int x = -1, int d = -1) {
    this->id = id;
    this->x = x;
    this->d = d;
  }

  int range() {
    return x + d;
  }

  bool operator<(const Robot &n) const {
    return x < n.x;
  }
};

vector<Robot> robots;
vector<vector<int>> G(MAX_N);
ll cache[MAX_N];

ll dfs(int v) {
  if (cache[v] != -1) return cache[v];
  ll res = 1;

  for (int i = 0; i < G[v].size(); ++i) {
    int u = G[v][i];
    res = (res * dfs(u)) % MOD;
  }

  return cache[v] = res + 1;
}

int main() {
  memset(cache, -1, sizeof(cache));

  int N;
  cin >> N;

  int x, d;
  for (int i = 0; i < N; ++i) {
    cin >> x >> d;
    robots.push_back(Robot(i, x, d));
  }

  sort(robots.begin(), robots.end());
  stack<Robot> stk;
  vector<int> vs;

  for (int i = 0; i < N; ++i) {
    Robot robot = robots[i];

    while (!stk.empty() && stk.top().range() <= robot.x) {
      stk.pop();
    }

    if (stk.empty()) {
      vs.push_back(robot.id);
    } else {
      vs.push_back(stk.top().id);
      G[stk.top().id].push_back(robot.id);
    }

    stk.push(robot);
  }

  ll ans = 1;

  for (int v : vs) {
    if (cache[v] != -1) continue;

    ans = (ans * dfs(v)) % MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 28016
#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
#include<algorithm>
#define INF 0x3f3f3f3f
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
int a[N];
int main()
{
    string str;
   cin>>str;
    int len=str.length();
    int cnt=0;
    for(int i=1;i<len;i++)
    {
        if(str[i]!=str[i-1])
            a[++cnt]=max(i,len-i);
    }
    int res;
    res=len;
    for(int i=1;i<=cnt;i++)
    {
        res=min(res,a[i]);
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

int main() {
  int N;
  cin >> N;
  auto vec = set<int>();
  bool diff = true;
  REP(i, N) {
    ll A;
    cin >> A;
    if(vec.find(A) != vec.end()) {
      diff = false;
    }
    vec.insert(A);
  }
  if(diff) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

typedef long long int ll;

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n;
    cin>>n;
    ll arr[n+1];
    ll brr[n+1];

    for(ll i=0;i<n+1;i++)cin>>arr[i];
    for(ll i=0;i<n;i++)cin>>brr[i];

    ll ans = 0;

    for(ll i=0;i<n;i++){

        if(brr[i]>=arr[i]){
            ans += arr[i];
            brr[i]-=arr[i];
            arr[i] = 0;
        }
        else{
            ans += brr[i];
            arr[i]-=brr[i];
            brr[i] = 0;
        }
        if(brr[i]>=arr[i+1]){
            ans += arr[i+1];
            brr[i]-=arr[i+1];
            arr[i+1] = 0;
        }
        else{
            ans += brr[i];
            arr[i+1]-=brr[i];
            brr[i] = 0;
        }

    }

    cout<<ans<<endl;return 0;


}


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

using namespace std;

inline void quit(){ exit(0); }

typedef long long ll;

ll mpow(ll _x, ll _y, ll _mod){
    if(_y==0) return 1;
    if(_y==1) return _x%_mod;
    if(_y&1) return (mpow(_x, _y-1, _mod)*_x)%_mod;
    ll _tmp = mpow(_x, _y>>1, _mod);
    return (_tmp*_tmp)%_mod;
}

int n;
int arr[100002];
int ans;
int cnt;

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d", &arr[i]);
        if(arr[i-1] >= arr[i]){
            cnt++;
        }
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int a, b, c; cin >> a >> b >> c;
  if((a * 100 + b * 10 + c) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;

}


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

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

	if (N.size() == 1){
		cout << N << endl;
		return 0;
	}
	int ans = N.at(0) - 1 - '0' + 9 * (N.size() - 1);
	rep2(i, (int)(N.size()), 1, 1){
		if (N.at(i) != '9'){
			cout << ans << endl;
			return 0;
		}
	}
	cout << ans + 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
#define N 10000
#define Q 500
 
int main()
{
  int i, j, count=0,m,n;
  int S[N], T[Q];
   
  scanf("%d", &S[0]);
  for(i=1; i<S[0]+1; i++)
    {
      scanf("%d", &S[i]);
    }
  scanf("%d", &T[0]);
       for(j=1; j<T[0]+1; j++){
	 scanf("%d",&T[j]);
	 for(i=1; i<S[0]; i++){
	   if(S[i]==T[j]){
	     count++;
	     break;
	   }
	 }
       }
       printf("%d\n",count);
       return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

struct query{
  ll type;//0=empty, 1=add-sum ,2=set-max
  ll value;
  query(ll a=0,ll b=0):type(a),value(b) {}
};

ll INF=(1LL<<60);

struct segtree{
  ll SIZE;
  vector<query> s;
  vector<ll> t;// sum-add
  vector<ll> u;// max-set

  segtree(ll n=1){
    SIZE=1;
    while(SIZE<n)SIZE*=2;
    s.clear();
    t.clear();
    u.clear();
    s.resize(SIZE*2, query());
    t.resize(SIZE*2, 0);
    u.resize(SIZE*2, 0);
  }
  
  void func(ll k,ll l,ll r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(ll k,ll l,ll r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    ll m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(ll a,ll b,query x,ll k,ll l,ll r){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      ll m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=max(u[k*2+1],u[k*2+2]);
    }
  }

  ll Dfs(ll type,ll a,ll b,ll k,ll l,ll r){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return -INF; // max
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      ll m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return max(lv,rv); // max
    }
  }

  void Add(ll a,ll b,ll x){
    Update(a,b,query(1,x), 0,0,SIZE);
  }
  void Set(ll a,ll b,ll x){
    Update(a,b,query(2,x), 0,0,SIZE);
  }
  ll Getsum(ll a,ll b){
    return Dfs(1,a,b, 0,0,SIZE);
  }

  ll Getmax(ll a,ll b){
    return Dfs(2,a,b, 0,0,SIZE);
  }
  
};

int main() {
  ll n,m;
  cin >> n >> m;
  segtree T(n+1);
  T.Set(0,n+1,0);
  vector<vector<pll>> P(n+1);
  for(ll i=0;i<m;i++) {
    ll l,r,a;
    cin >> l >> r >> a;
    P[r].push_back(pll(l,a));
  }
  for(ll i=1;i<=n;i++) {
    T.Add(i,i+1,T.Getmax(0,i));
    for(auto p:P[i]) {
      ll l=p.first;
      ll a=p.second;
      T.Add(l,i+1,a);
    }
  }
  cout << T.Getmax(0,n+1) << endl;
}

Measured memory_bytes: 29568
#include <bits/stdc++.h>
using namespace std;
int n,k;
long long a[100009];
long long dp[100009];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=2;i<=n;i++){
		dp[i]=10000000009;
		for(int j=1;j<=k;j++){
			if(i-j<=0) break;
			dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
		}
	}
	cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
from collections import deque
import bisect
N,M,K = list(map(int, input().split()))
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

#if(sum(As) + sum(Bs) <= K):
#    print(N + M)
#    exit()


Asruisekiwa = []
Bsruisekiwa = []

Asruisekiwa.append(As[0])
Bsruisekiwa.append(Bs[0])

for i, j in enumerate(As[1:]):
    Asruisekiwa.append(Asruisekiwa[-1]+j)

for i, j in enumerate(Bs[1:]):
    Bsruisekiwa.append(Bsruisekiwa[-1] + j)

#print(Asruisekiwa)
#print(Bsruisekiwa)

ans = 0
#print(Asruisekiwa)
#print(Bsruisekiwa)

if(Asruisekiwa[0] >= Bsruisekiwa[0]):
    tmp = Asruisekiwa
    Asruisekiwa = Bsruisekiwa
    Bsruisekiwa = tmp

Asruisekiwa.insert(0,0)
Bsruisekiwa.insert(0,0)

#print(Asruisekiwa)
#print(Bsruisekiwa)


for index, i in enumerate(Asruisekiwa):

    if(i > K):
        break

    tmp = i
    maxcheck = K - i


    hoge = bisect.bisect_right(Bsruisekiwa, maxcheck)

    ans = max(ans, index-1 + hoge)

#    print(ans, tmp, hoge, maxcheck)

print(ans)

Measured memory_bytes: 49492
def solution():
    n = int(input())
    bon = [3]
    pon = [0, 1, 6, 8]
    last = n % 10
    if last in bon:
        return 'bon'
    elif last in pon:
        return 'pon'
    else:
        return 'hon' 
    
print(solution())

Measured memory_bytes: 9120
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;


int main(){
    int a,b,m;
    cin >> a >> b >> m;
    vector<int> as(a),bs(b);

    rep(i,a) cin >> as[i];
    rep(i,b) cin >> bs[i];
    int ans = 200100;
    rep(i,m){
        int x,y,c;
        cin >> x >> y >> c;
        x--;y--;
        ans = min(as[x] + bs[y] - c,ans);
    }
    SORT(as);
    SORT(bs);
    ans = min(ans,as[0]+bs[0]);
    cout << ans;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n, t; cin >> n >> t;
    vector<int> a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    vector<vector<int>> dp1(n + 1, vector<int>(t + 1, 0)), dp2(n + 1, vector<int>(t + 1, 0));
    rep(i, n) {
        for(int j = 0; j <= t; ++j) {
            if(j - a[i] < 0) dp1[i + 1][j] = dp1[i][j];
            else dp1[i + 1][j] = max(dp1[i][j], dp1[i][j - a[i]] + b[i]);
        }
    }
    per(i, n) {
        for(int j = 0; j <= t; ++j) {
            if(j - a[i] < 0) dp2[i][j] = dp2[i + 1][j];
            else dp2[i][j] = max(dp2[i + 1][j], dp2[i + 1][j - a[i]] + b[i]);
        }
    }
    int ans = 0;
    rep(i, n) {
        for(int j = 0; j <= t - 1; ++j) {
            ans = max(ans, b[i] + dp1[i][j] + dp2[i + 1][t - 1 - j]);
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 70912
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
    int Q;
    cin>>Q;
    vector <int>l(Q);
    vector <int>r(Q);
    for(int i=0 ; i<Q ; i++){
        cin>>l[i] ;
        cin>>r[i] ;
    }
    const int OFF=100000;
    vector <bool> t(OFF,false);
    vector <int> n(OFF,0);
    for(int i=2 ; i<=OFF ;i++){
        if(t[i]==false){
            for(int k=i+i ; k<=OFF ; k+=i){
                t[k]=true;
            }
        }
    }
    for(int i=3 ; i<=OFF ;i+=2){
        if(t[i]==false && t[(i+1)/2]==false)n[i]+=1;
    }
    for(int i=3 ; i<=OFF ;i++){
        n[i]+=n[i-1];
    }
    for(int i=0 ; i<Q ;i++){
        cout<<n[r[i]]-n[l[i]-1]<<endl;
    }
    return 0;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < long long > vll;
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef vector < int > vi;
typedef vector<vector<int>> vvi;
#define deb(x) cout << #x << " : " << x << endl
#define deb2(x , y) cout << #x << " : " << x << " , "<< #y << " : " << y << endl
#define debv(x) for(auto i=x.begin();i!=x.end();i++) cout<<*i<<' ';cout<<endl
#define debp(x) for(auto i=x.begin();i!=x.end();i++) cout<<i->first<<':'<<i->second<<' ';cout<<endl
#define debvv(x) for(auto j=x.begin();j!=x.end();j++) { for(auto i=(*j).begin();i!=(*j).end();i++) cout<<*i<<' ';cout<<endl;}cout<<endl
#define rsz(x,n) x.clear(); x.resize(n)
#define rrsz(x,a,n) x.clear(); x.resize(n,a)
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,a,n) for(int i = a; i < n; i++)
#define wt while(true)
#define all(x) x.begin(),x.end()
#define pb push_back
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define INF (1e9 + 7)
#define endl '\n'

vvi adj;
vi dist;

int dfs(int node){
	if(dist[node]!=-1){
		return dist[node];
	}
	dist[node]=0;
	for(int child:adj[node]){
		dist[node]=max(dist[node],dfs(child)+1);
	}
	return (dist[node]);
}
void solve() {
	int n,m;
	cin>>n>>m;
	adj.resize(n+1);
	dist.resize(n+1,-1);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		adj[a].pb(b);
	}
	int ans=0;
	reps(i,1,n+1){
		ans=max(ans,dfs(i));
	}
    cout<<ans<<endl;
}

int main() {
	csl;
	int testcase=1;
//	cin >> testcase;
	for (int i = 0; i < testcase; i++) {
		solve();
	}
	return 0;
}



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

int main(void) {
	long long int A,B,C,K ,ans = 0;
	cin >> A >> B >> C >>K;

	if (K % 2 == 0)
		ans = A - B;
	else
		ans = B - A;

	cout << ans << endl;


}


Measured memory_bytes: 256
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n=ni()
s=[_ for _ in input()]


mx=0

for i in range(n):
  sr =s[:i]
  sl = s[i:]
  r=set(sr)
  l=set(sl)

  nn=len(r & l)
  mx = max(nn,mx)

print(mx)



Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque

n,m = map(int,readline().split())
data = list(map(int,read().split()))
it = iter(data)

links = [[] for _ in range(n+1)]
for a,b in zip(it,it):
    links[a].append(b)
    links[b].append(a)

d = deque()
d.append(1)
parent = [-1] * (n+1)
parent[1] = 0

while(d):
    i = d.popleft()
    for j in links[i]:
        if(parent[j] == -1):
            parent[j] = i
            d.append(j)

ans = parent[2:]
if(min(ans) == -1):
    print('No')
else:
    print('Yes')
    print('\n'.join(map(str,ans)))

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

int main(){
    int H, W;
    cin >> H >> W;
    string map[2*H];
    int  mapH[2*H][2*W], mapW[2*H][2*W];
    int ans =0;
    int tmp = 1;

    for(int i=0; i<H; i++){
	cin >> map[i];

    }
    for(int i=0; i<H; i++){
	tmp = 1;
	for(int j=0; j<W; j++){
	    if(map[i][j] == '.'){
		mapW[i][j]=tmp;
		tmp ++;
	    }
	    else{
		tmp=1;
		mapW[i][j]=0;
	    }
	}
    }
    for(int i=0; i<H; i++){
	for(int j=W-1; j>0; j--){
	    if(mapW[i][j] > mapW[i][j-1] && mapW[i][j-1] != 0){
		mapW[i][j-1]= mapW[i][j];
	    }
	}
    }
    
    for(int i=0; i<W; i++){
	tmp = 1;
	for(int j=0; j<H; j++){
	    if(map[j][i] == '.'){
		mapH[j][i]=tmp;
		tmp ++;
	    }
	    else{
		tmp=1;
		mapH[j][i]=0;
	    }
	}
    }
    
    for(int i=0; i<W; i++){
	for(int j=H-1; j>0; j--){
	    if(mapH[j][i] > mapH[j-1][i] && mapH[j-1][i] != 0){
		mapH[j-1][i]= mapH[j][i];
	    }
	}
    }


    

    for(int i=0; i<H; i++){
	for(int j=0; j<W; j++){
	    ans = max(ans, mapW[i][j]+mapH[i][j]-1);
	}
    }

    cout << ans << endl;

    
    
}



Measured memory_bytes: 71040
MOD = 10**9+7


def end(b):
    num = 0
    for i in range(n, n-b, -1):
        num += i
    return num

n, k = map(int, input().split())
ans = 0
for i in range(k, n+2):
    s = (i-1) * i // 2
    e = (2*n-i+1) * i // 2
    #print(s, e)
    cnt = e-s+1
    ans = ans + cnt
    ans %= MOD
print(ans)

Measured memory_bytes: 63920
#include <bits/stdc++.h>
using namespace std;
struct point{double x;double y;};
int i,j,k,count1=0,count2=0;

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

Measured memory_bytes: 256
from collections import defaultdict

N=int(input())
S=[input() for _ in range(N)]

cnt=defaultdict(int)
for i in range(len(S[0])):
    cnt[S[0][i]]+=1

for i in range(1,N):
    tmp=defaultdict(int)
    for j in range(len(S[i])):
        tmp[S[i][j]]+=1
    for key,count in cnt.items():
        if count>tmp[key]:
            cnt[key]=tmp[key]

ans=[]
for key,count in cnt.items():
    for _ in range(count):
        ans.append(key)
ans.sort()
print("".join(ans))

Measured memory_bytes: 9456
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define UNVISITED -1

int cnt;
int tatami[20][20];

void solve(int r,int c,int now){
  int y=now/c,x=now%c;
  if ( r*c == now){
    rep(i,c)
      if (tatami[y-1][i]==UNVISITED)return;
    cnt++;
    return;
  }

  if( tatami[y][x]!=UNVISITED){
    solve(r,c,now+1);
    return;
  }

  if ( x==0 && y>0){
    rep(i,c)if ( tatami[y-1][i]==UNVISITED)return;
  }

  if (y != 0 && x>0){
    if ( tatami[y-1][x-1] != tatami[y-1][x] &&
	 tatami[y-1][x-1] != tatami[y][x-1])return;
  }

  if (y != r-1 ){
    tatami[y][x]=tatami[y+1][x]=now;
    solve(r,c,now+1);
    tatami[y][x]=tatami[y+1][x]=UNVISITED;
  }
  
  if ( x !=c-1 && tatami[y][x+1]==UNVISITED){
    tatami[y][x]=tatami[y][x+1]=now;
    solve(r,c,now+2);
    tatami[y][x]=tatami[y][x+1]=UNVISITED;
  }
  return;
}

main(){
  int r,c;
  while(cin>>r>>c && r){
    rep(i,r)rep(j,c)tatami[i][j]=-1;
    cnt=0;
    solve(r,c,0);
    cout << cnt << endl;
  }
}

Measured memory_bytes: 868
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    ll n, a, b;
    cin >> n >> a >> b;
    if (a > b)
    {
        cout << "0";
        return 0;
    }
    if (n == 1)
    {
        if (a == b)
            cout << "1";
        else
            cout << "0";
        return 0;
    }
    ll m = (n - 1) * a + b, M = (n - 1) * b + a;
    cout << M - m + 1;
    return 0;
}


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

int main()
{
	string s;
	cin >> s; 
	int n= s.size(); 		//s.sizeで要素数を取得
	int k;
	cin >> k;

	for(int i =0;i<n;i++)
	{
		if(i == n -1 ){
			s[i] = (s[i]-'a' + k)%26 + 'a';
		}else{
			if(s[i] == 'a') continue;
			
			if( 'z' - s[i] + 1 <= k ){
				k -= 'z' - s[i] + 1;
				s[i] = 'a';
			}
		}
	}
	cout << s << endl;

	return 0; 

}

Measured memory_bytes: 512
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()

for i in range(1, 10):
    for j in range(1, 10):
        if n == i * j:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 6732
import math
a,b,x=map(int,input().split())
if x>=(a**2)*b/2:
  y=a*b-x/a
  print(math.degrees(math.atan((y*2)/a**2)))
else:
  y=x/a
  print(math.degrees(math.atan(b**2/(y*2))))

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

const long long INF = 1LL << 60;
int MOD = 1000000007;
int PI = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define For(i,s,n) for (int i=s;i<(int)(n);i++)
#define vi vector<int>
#define vii vector< vector<int> >
#define vs vector<string>
#define All(c) (c).begin(), (c).end()
#define Print(x) cout<<(x)<<"\n"

int H, W;
vs S(2010);
int DURL[2010][2010][4];

int main() {

	cin >> H >> W;
	rep(i, H) cin >> S[i];

	rep(i, W) rep(j, H) {
		if (j == 0 && S[j][i] == '.') DURL[j][i][0] = 1;
		else if (S[j][i] == '.') DURL[j][i][0] = DURL[j - 1][i][0] + 1;
	}
	rep(i, W) rrep(j, H) {
		if (j == H - 1 && S[j][i] == '.') DURL[j][i][1] = 1;
		else if (S[j][i] == '.') DURL[j][i][1] = DURL[j + 1][i][1] + 1;
	}

	rep(i, H) rep(j, W) {
		if (j == 0 && S[i][j] == '.') DURL[i][j][2] = 1;
		else if (S[i][j] == '.') DURL[i][j][2] = DURL[i][j - 1][2] + 1;
	}
	rep(i, H) rrep(j, W) {
		if (j == W - 1 && S[i][j] == '.') DURL[i][j][3] = 1;
		else if (S[i][j] == '.') DURL[i][j][3] = DURL[i][j + 1][3] + 1;
	}

	int ans = 0;
	int cnt = 0;
	rep(i, H) rep(j, W) {
		cnt = DURL[i][j][0] + DURL[i][j][1] + DURL[i][j][2] + DURL[i][j][3] - 3;
		chmax(ans, cnt);
	}
	cout << ans << endl;


}

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

int main() {
  ll d,t,s;
  cin >> d >> t >> s;
  if(s*t >= d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 3624
from functools import reduce

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return (a * b) // gcd(a, b)

def lcm_list(n):
    return reduce(lcm, n)

n = int(input())
t = [int(input()) for i in range(n)]
print(lcm_list(t))

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
	int a,b;
	cin >> a >> b;
	if (a+b == 3) {
		cout << 3 << endl;
	} else if (a+b == 4) {
		cout << 2 << endl;
	} else if (a+b == 5) {
		cout << 1 << endl;
	}
	return 0;
}

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

int main(){
  int n,k;
  int ans=1;

  cin>>n>>k;

  for(int i=0;i<n;i++){
    if(ans<k){
      ans*=2;
    }else{
      ans+=k;
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  int n;
  cin>>n;
  ll a[n+1]={};
  ll p[n+1]={};
  p[0]=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    p[i]=p[i-1]+a[i];
  }
  ll ans=1e16;
  ll dif[4];
  int l=1,r=3;
  for(int i=2;i<=n-2;i++){
    while(l<i&&abs(p[l]-(p[i]-p[l]))>=abs(p[l+1]-(p[i]-p[l+1])))
    l++;
    while(r<n&&abs(p[r]-p[i]-(p[n]-p[r]))>=abs(p[r+1]-p[i]-(p[n]-p[r+1])))
    r++;
    dif[0]=p[l];dif[1]=p[i]-p[l];dif[2]=p[r]-p[i];dif[3]=p[n]-p[r];
    sort(dif,dif+4);
    ans=min(ans,dif[3]-dif[0]);
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

int main()
{
	int N , M;
	while(cin >> N >> M , N || M)
	{
		int a = 0 , b = 0 , c = 0 , d = 0;
		map<vector<int> , int>data;
		for(size_t i = 0; i < N; i++)
		{
			string S;
			cin >> S;
			int now = 0;
			while(now < S.size() && S[now] == '.')
			{
				now++;
			}
			int memo = 1;
			for(size_t i = 1; i < 20; i++)
			{
				if(a%i == 0 && b%i == 0 && c%i == 0 && now%i == 0)
				{
					memo = i;
				}
			}
			vector<int>memo2 = { a / memo,b / memo,c / memo };
			data[memo2] = now / memo;

			d = 0;
			while(now < S.size())
			{
				switch(S[now])
				{
					case '(':a++; break;
					case ')':a--; break;
					case '{':b++; break;
					case '}':b--; break;
					case '[':c++; break;
					case ']':c--; break;
					default:
						break;
				}
				now++;
			}
		}
		vector<vector<int>>candidate;
		for(int i = 1; i <= 20; i++)
		{
			for(int j = 1; j <= 20; j++)
			{
				for(int k = 1; k <= 20; k++)
				{
					bool f = 1;
					for(auto x : data)
					{
						if(x.first[0] * i + x.first[1] * j + x.first[2] * k != x.second)
						{
							f = 0;
							break;
						}
					}
					if(f)candidate.push_back(vector<int>{i - 1 , j - 1 , k - 1});
				}
			}
		}
		vector<set<int>>ans(M);
		for(size_t i = 0; i < M; i++)
		{
			string S;
			cin >> S;
			int now = 0;
			while(now < S.size() && S[now] == '.')
			{
				now++;
			}
			for(auto x : candidate)
			{
				ans[i].insert(( x[0] + 1 )*a + ( x[1] + 1 )*b + ( x[2] + 1 )*c);
			}

			d = 0;
			while(now < S.size())
			{
				switch(S[now])
				{
					case '(':a++; break;
					case ')':a--; break;
					case '{':b++; break;
					case '}':b--; break;
					case '[':c++; break;
					case ']':c--; break;
					default:
						break;
				}
				now++;
			}
		}
		for(size_t i = 0; i < M; i++)
		{
			if(ans[i].size() == 1)
			{
				for(auto x : ans[i])
				{
					cout << x;
				}
			} else
			{
				cout << -1;
			}
			cout << ( i == M - 1 ? "\n" : " " );
		}
	}
}

Measured memory_bytes: 1676
N, K = map(int,input().split())
q = list(map(int,input().split()))

# 何個捨てるか
ans = 0
for i in range(K):
    # 右から何個目まで取るか
    if K-i >= N:
        pick = q
        pick = sorted(pick)
        for m in range(i+1):
            ans = max(sum(pick[m:]),ans)        
    else:
        pick = q[:K-i]
        pick = sorted(pick)
        ans = max(sum(pick[i:]),ans)
        for j in range(min(N,K-i)):
            pick = []
            pick = q[:j]+q[-(K-i-j):]
            pick = sorted(pick)
            for m in range(i+1):
                ans = max(sum(pick[m:]),ans)        
print(ans)

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

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> vec(m);
  rep(i, m) {
    ll k;
    cin >> k;
    vec[i].resize(k);
    rep(j, k) {
      cin >> vec[i][j]; 
      // スイッチの番号を0オリジンに直す
      vec[i][j]--;
    }
  }
  vector<ll> p(m);
  rep(i,m) cin >> p[i];

  ll ans = 0;
  rep(i, 1 << n) {
    // スイッチのONのパターンでループ
    bool ok = true;
    rep(j, m) {
      ll c = 0;
      for (ll id : vec[j]) {
        //cout << "i: " << i << " j: " << j << " id: " << id << ", i>>id: " << (i >> id) <<endl;
        // この行の意味何?
        if ((i >> id) & 1) {
          c++;
        }
      }
      c %= 2;
      if (c != p[j]) {
        ok = false;
      }
    }
    if (ok) ++ans;
    
  }
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[100100][3];
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int N = S.size();
  // 0 -- A, 1 -- AB, 2 -- ABC
  int countVal=1;
  REPS(i,N){
    char si = S[i-1];
    REP(j,3){
      if ((si==('A'+j)) || (si=='?')){
        //増加分
        dp[i][j]+= (j==0? countVal : dp[i-1][j-1]);
        dp[i][j]%=MOD;
        REP(k,3){
          dp[i][k]+=dp[i-1][k];
          dp[i][k]%=MOD;
        }
      }
    }
    if (si=='?'){
      countVal*=3;
      countVal%=MOD;
    }
  }
  print(dp[N][2]);
  return 0;
}


Measured memory_bytes: 2768
iwi = gets.chomp
result = 0
if iwi.size.odd? then
  if iwi[iwi.size/2] =~ /[\)\(]/
    result += 1
  end
  iwi[iwi.size/2] = ''
end
front = iwi[0..iwi.size/2-1]
back  = iwi[iwi.size/2..-1].reverse
back.size.times do |i|
  if (back[i] == '(' and front[i] == '(') or
     (back[i] == ')' and front[i] == ')') then
    result += 1
    next
  end
  next if back[i] == front[i] or
          (back[i] == '(' and front[i] == ')') or
          (back[i] == ')' and front[i] == '(')
  result += 1
end

p result

Measured memory_bytes: 6116
import sys
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

l = make_divisors(N)
ll = [(v1 - 1) + (N / v1 - 1) for v1 in l]
print(int(min(ll)))



Measured memory_bytes: 3552
A = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
B = [int(input()) for _ in range(n)]

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j] = -1

for i in range(3):
    ans1, ans2 = 0, 0
    for j in range(3):
        if A[i][j] == -1:
            ans1 += 1
        if A[j][i] == -1:
            ans2 += 1
    if ans1 == 3 or ans2 == 3:
        print("Yes")
        exit()

if (A[0][0] == -1 and A[1][1] == -1 and A[2][2] == -1) or \
        (A[0][2] == -1 and A[1][1] == -1 and A[2][0] == -1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9144
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(int i=0;sc.hasNext();i++) {
			l = sc.next() + "="; p = 0; ov = false;
			P v = exp();
			if(ov) System.out.println("overflow");
			else {
				if( v.s == 0 ) System.out.println(v.f);
				else if(v.f == 0) System.out.println(v.s + "i");
				else System.out.println(v.f + (v.s<0? ""+v.s: "+"+v.s) + "i");
			}
		}

	}
	boolean ov;

	String l; int p;
	char next() {
		return l.charAt(p++);
	}

	P exp() {
		P v1 = term();
//		debug("", v1.f, v1.s);
		char c = next();
		if( c == '=' || c == ')' ) { p--; return v1;}

		do {
			P v2 = term();
			if (c == '+' ) v1 = v1.add(v2);
			else v1 = v1.sub(v2);
			c = next();
		}while( c != '=' && c != ')' );
		p--;
		return v1;
	}

	P term() {
		P v1 = facter();
//		debug("", v1.f, v1.s);
		char c = next();
		if( c == '=' || c == ')' || c == '+' || c == '-' ) { p--; return v1;}

		do {
			P v2 = facter();
			v1 = v1.mult(v2);
			c = next();
		}while( c != '=' && c != ')' && c != '+' && c != '-' );
		p--;
		return v1;
	}

	P facter() {
		char c = next();
//		debug(p, c);
		String v = "";
		if( c == '-' ) { v += '-'; c=next(); }
		if( c == '+' ) { c=next(); }
		if(c == 'i') {
			if(v.equals("-")) return new P(0, -1);
			return new P(0, 1);
		}
		if(c == '(' ) { P ret = exp(); p++; return ret; }
		if(c=='0') while(c=='0') c=next();
		if(c == '=' || c=='-' || c=='+' || c=='*' || c==')'){p--;return new P(0, 0);}
		while(c != '=' && c != '-' && c != '+' && c != '*' && c != ')') {
			v += c;
			c = next();
		}
		p--;
		if(v.length() > 8) {
			ov = true;
			return new P(0, 0);
		}
		return new P(Long.parseLong(v), 0);
	}

	long MAX = 10000;
	class P {
		long f, s;
		P(long f, long s) {
			this.f = f;
			this.s = s;
			ov |= max( abs(f), abs(s)) > MAX;
		}

		P add(P p) {
			return new P(f+p.f, s+p.s);
		}

		P sub(P p) {
			return new P(f-p.f, s-p.s);
		}

		P mult(P p) {
			return new P(f*p.f - s*p.s, f*p.s + p.f*s);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 26536
import sys
 
input = sys.stdin.readline
 
 
def main():
    n, q = [int(i) for i in input().split()]
    scores = [0] * (n + 1)
    lines = sorted([[int(i) for i in input().split()] for _ in range(n - 1)])
    counter = [[int(i) for i in input().split()] for _ in range(q)]
    for index, score in counter:
        scores[index] += score
 
    for a, b in lines:
        scores[b] += scores[a]
    print(*scores[1:])
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 90132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;

bool prime (int i) {
    if (i == 1) return false;
    for (int j = 2; j * j <= i; j++) {
        if (i % j == 0) return false;
    }
    return true;
}

signed main() {
    int n;
    cin >> n;
    vector<int> vec;
    for (int i = 2; vec.size() < n; i++) {
        if (prime (i) && i % 5 == 1) {
            vec.push_back (i);
        }
    }
    rep (i, 0, n) cout << vec[i] << " ";
    cout << "\n";
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  int A; cin>>A;
  string s; cin>>s;
  
  if(A>=3200) cout<<s<<endl;
  else cout<<"red"<<endl;
}
    
  
  

Measured memory_bytes: 256