akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    ll k,q; cin >> k >> q;
    vector<ll> d(k);
    REP(i,k){
        cin >> d[i];
    }

    vector<ll> ans(q);
    REP(i,q){
        ll n,x,m; cin >> n >> x >> m;
        x %= m;
        vector<ll> dmod(k), ruiseki(k+1,0),zeros(k+1,0);
        //ll ruiseki = 0;
        //ll zeros = 0;
        REP(j,k){
            dmod[j] = d[j] % m;
            //cout << dmod[j] << " ";
            ruiseki[j+1] =ruiseki[j] + dmod[j];
            if(ruiseki[j+1] == ruiseki[j]){
                zeros[j+1] = zeros[j] + 1;   // a1 = a0 + d0 で、d0 = 0 の場合
            }
            else zeros[j+1] = zeros[j];
        }
        //cout << endl;
        ll shou = (n-1) / k;
        ll amari = (n-1) % k;
        ll sum = 0;
        ll zero = 0;
        sum = x + shou * ruiseki[k] + ruiseki[amari];
        zero = zeros[k] * shou + zeros[amari];
        ans[i] = (n - 1) - sum / m - zero;
        
    }
    REP(i,q){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3700
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int64_t H,W;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);
    in >> H >> W;
    if (H > W) {
        std::swap(H, W);
    }
    if (H == 1) {
        out << 1 << endl;
        return 0;
    }

    out << ((W + 1) / 2) * ((H + 1) / 2) + (W / 2) * (H / 2) << endl;


    return 0;
}
#endif


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
typedef pair<ll,ll>pi;
#define ff first
#define ss second
vector<pi>v;
#define inf 8e18
ll n,k;
const ll N=100;
bool comp(pi a,pi b)
{
    return a.ff<b.ff;
}
ll x[N+4],y[N+4],a[N+5],b[N+6];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    for(ll i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        a[i]=x[i],b[i]=y[i];
    }
    ll ans=inf;
    sort(x,x+n);
    sort(y,y+n);
    for(ll lx=0;lx<n;lx++)
        for(ll rx=lx+1;rx<n;rx++)
            for(ll by=0;by<n;by++)
                {
                    for(ll uy=by+1;uy<n;uy++)
                    {
                        ll cnt=0;
                        for(ll i=0;i<n;i++)
                        {
//                            cout<<x[rx]<<" "<<x[lx]<<"   "<<y[uy]<<" "<<y[by]<<endl;
//                            cout<<a[i]<<" "<<b[i]<<endl;
                            if(a[i]<=x[rx]&&a[i]>=x[lx]&&b[i]>=y[by]&&b[i]<=y[uy])cnt++;
                        }
                        if(cnt>=k)
                        {
                            ans=min(ans,(x[rx]-x[lx])*(y[uy]-y[by]));
                        }
                    }
                }
    cout<<ans<<endl;
}
/*
3999999996000000001
*/


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

using namespace std;

int main(){
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	int sum=0;
	for(int i=1;i<=k;i++){
		sum+=a[i];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3652
/* ex7_1
   moka223711 */

#include <stdio.h>

typedef struct point{ // 点を表す構造体
    int x_elem;
    int y_elem;
}point;

// vtx1を中心にvtx2を90度回転させた座標を返す関数 point_shift()
point shift_point(point vtx1, point vtx2){
    point vtx;
    /* 複素数平面上で考える。
     * 複素数 z1 を中心に複素数 z2 を90°回転させた複素数 z は
     *   z = (z2 - z1)i + z1  と表される。
     * z1 = x1 + iy1, z2 = x2 + iy2 とすると
     *
     * z = {x2 + iy2 - (x1 + iy1)}i + x1 + iy1
     *   = {x2 - x1 + i(y2 - y1)}i + x1 + iy1
     *   = -(y2 - y1) + i(x2 - x1) + x1 + iy1
     *   = x1 + y1 - y2 + i(-x1 + x2 + y1)
     * 
     * よって、z = x + iy とすると、
     * x = x1 + y1 - y2, y = -x1 + x2 + y1
     */
    vtx.x_elem = vtx1.x_elem + vtx1.y_elem - vtx2.y_elem;
    vtx.y_elem = - vtx1.x_elem + vtx2.x_elem + vtx1.y_elem;
    return vtx;
}

int main(void){
    point vtx1, vtx2, vtx3, vtx4;
    scanf("%d%d%d%d", &vtx1.x_elem, &vtx1.y_elem, &vtx2.x_elem, &vtx2.y_elem);
    
    // vtx1, vtx2, vtx3, vtx4 は反時計回りに並んでいる
    vtx4 = shift_point(vtx1, vtx2); // vtx4はvtx1を中心にvtx2を90°回転させた座標にある。
    vtx3 = shift_point(vtx4, vtx1); // vtx3はvtx4を中心にvtx1を90°回転させた座標にある。
  
    printf("%d %d %d %d\n", vtx3.x_elem, vtx3.y_elem, vtx4.x_elem, vtx4.y_elem);
    return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
typedef long long LL;

LL A,B,C,D;

LL f(LL a,LL  b)
{
    LL  num=a*b;
    LL  c=a%b;
    while(c!=0)
    {
        a=b;
        b=c;
        c=a%b;
    }
    return num/b;
}
int main()
{
    while(cin>>A>>B>>C>>D)
    {
        if(C==1||D==1)
        {
            cout<<0<<endl;
            continue;
        }
        LL g=f(C,D);
        LL a=(A-1)/C+(A-1)/D-(A-1)/g;
        LL b=B/C+B/D-B/g;
        cout<<B-A+1-(b-a)<<endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] ab = scanner.nextLine().split(" ", 2);
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        String[] line = scanner.nextLine().split(" ", n);

        int firstCnt = 0;
        int secondCnt = 0;
        int thirdCnt = 0;
        for (int i = 0; i < n; i++) {
            int p = Integer.parseInt(line[i]);
            if (p <= a) {
                firstCnt++;
            } else if (a + 1 <= p && p <= b) {
                secondCnt++;
            } else if (b + 1 <= p) {
                thirdCnt++;
            }
        }
        System.out.println(Math.min(firstCnt, Math.min(secondCnt, thirdCnt)));
    }
}


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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int X; 
  cin >> X;
  int count =0;
  for(int i=0; i<=A; i++){
    for(int j=0; j<=B; j++){
      if(C>=(X-500*i-100*j)/50 && 0<=X-500*i-100*j)
        count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,x,cnt,ans=1;
int main()
{
	cin>>n>>x;
	for(int i=0;i<n;i++)
	{
		int y;
		cin>>y;
		cnt+=y;
		if(cnt<=x)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    int ans = 0;
    vector<int> cans;
    int MAX = 1e5;
    int a = 1, b = 1;
    cans.push_back(a);
    while (a <= MAX) {
        a *= 6;
        cans.push_back(a);
    }

    while (b <= MAX) {
        b *= 9;
        cans.push_back(b);
    }

    sort(all(cans));

    vector<ll> dp(MAX + 10, INF);
    dp[N] = 0;
    // 値がiの時の操作の最小値
    for (int i = N; i >= 0; i--) {
        rep(j, cans.size()) {
            if (i >= cans[j])
                dp[i - cans[j]] = min(dp[i - cans[j]], dp[i] + 1);
        }
    }

    cout << dp[0] << endl;
}

Measured memory_bytes: 1024
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

string s;

int p[300];

int main() {
	cin >> s;
	REP(i, (int)s.size()) p[s[i]]++;
	REP(i, 300) if (p[i] > 0) p[i] = 1;
	if ((p['W'] ^ p['E']) || (p['S'] ^ p['N'])) puts("No");
	else puts("Yes");
	return 0;
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May  3 21:14:43 JST 2020
 **/

signed main() {
    Int n, K;
    std::cin >> n >> K;
    std::vector<Int> no(n, 1);
    REP(i, K) {
        Int d;
        std::cin >> d;
        REP(_, d) {
            Int a;
            std::cin >> a;
            no[a - 1] = 0;
        }
    }
    std::cout << std::accumulate(no.begin(), no.end(), 0LL) << std::endl;
}


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

int main(){
    string S, T;
    cin >> S >> T;
    int ans = T.size();
    for(int i = 0; i <= S.size()-T.size(); ++i){
        int buf = 0;
        for(int j = 0; j < T.size(); ++j){
            if(S[i+j] != T[j]) ++buf; 
        }
        ans = min(ans, buf);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3488
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int a, b, t;
    char op;
    for(t = 1;t > 0;t++)
    {
        scanf("%d %c %d", &a, &op, &b);
        if(op =='+')
        {
            printf("%d\n",a + b);
        }
        else if(op =='-')
        {
            printf("%d\n",a - b);
        }
        else if(op =='*')
        {
            printf("%d\n",a * b);
        }
        else if(op =='/')
        {
            printf("%d\n",a / b);
        }
        else if(op =='?')
        {
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  vector<pair<int, bool>> a(9);
  REP(i, 9) {
    scanf("%d", &(a.at(i).first));
    a.at(i).second = false;
  }
  int n;
  scanf("%d", &n);
  vector<int> b(n);
  int val;
  REP(i, n) {
    scanf("%d", &val);
    REP(j, 9) {
      if (a.at(j).first == val) {
        a.at(j).second = true;
      }
    }
  }

  // check
  bool bingo = false;
  int lines[8][3] = {
    {0, 1, 2},
    {3, 4, 5},
    {6, 7, 8},
    {0, 3, 6},
    {1, 4, 7},
    {2, 5, 8},
    {0, 4, 8},
    {2, 4, 6}
  };

  for(int* line : lines) {
    if (a.at(line[0]).second && a.at(line[1]).second && a.at(line[2]).second) {
      bingo = true;
      break;
    }
  }

  printf("%s\n", bingo ? "Yes" : "No");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n;
    string s;
    cin >> n >> s;
    int r = 0, g = 0, b = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'R') ++r;
        else if(s[i] == 'G')    ++g;
        else    ++b;
    }
    ll ans = (ll) r * g * b;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            if(s[i] == s[j])    continue;
            int len = j - i;
            if(j + len >= n)    break;
            int k = j + len;
            if(s[k] != s[i] && s[k] != s[j])    --ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
"16時57分開始"
N, Q = map(int, input().split())  # 長さNの文字列, Q個の問い
S = str(input())

ac_counter = [0]
for i in range(1, N):
    if S[i] == 'C' and S[i-1] == 'A':
        ac_counter.append(ac_counter[-1]+1)
    else:
        ac_counter.append(ac_counter[-1])

# print(ac_counter)

for i in range(Q):
    l, r = map(int, input().split())
    print(ac_counter[r-1] - ac_counter[l-1])


Measured memory_bytes: 6100
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll A, B;
  cin >> A >> B;
  REP(i, 1, 1001) {
    if (floor(0.08 * i) == A && floor(0.1 * i) == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<long long> a(n);
  long long sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
    sum%= (long long)1e9+7;
  vector<long long> ans;
  for(int i=0;i<n-1;i++){
      sum+=(long long)1e9+7-a[i];
	  sum%=(long long)1e9+7;
      ans.push_back(a[i]*sum);
  }
  long long res=0;
  for(auto x:ans){
    res+=x;
    res%=(long long)1e9+7;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 6776
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int dist[100010];

int main(){
  string S;
  cin>>S;
  int N=S.size();

  int lastr=-1;
  for(int i=0;i<N;i++){
    if(S[i]=='R') lastr=i;
    else dist[i]=lastr;
  }

  int lastl=N;
  for(int i=N-1;i>=0;i--){
    if(S[i]=='L') lastl=i;
    else dist[i]=lastl;
  }

  vector<int> ans(N+1,0);
  for(int i=0;i<N;i++){
    if(S[i]=='R'){
      int d=dist[i]-i;
      d--;
      if(d%2) ans[dist[i]]++;
      else ans[dist[i]-1]++;
    }else{
      int d=i-dist[i];
      d--;
      if(d%2) ans[dist[i]]++;
      else ans[dist[i]+1]++;
    }
  }

  for(int i=0;i<N;i++) cout<<ans[i]<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
  vector<char> s(4);
  for(int i=0;i < 4;i++)
  {
    cin>>s.at(i);
  }
  sort(s.begin(),s.end());

  if(s.at(0)==s.at(1) && s[2]==s[3] && s[1]!=s[2]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL X, Y, Z, K; cin >> X >> Y >> Z >> K;
	vector<LL> a(X);

	for (int i = 0; i < X; i++) {
		cin >> a[i];
	}

	vector<LL> b(Y);

	for (int i = 0; i < Y; i++) {
		cin >> b[i];
	}

	vector<LL> c(Z);

	for (int i = 0; i < Z; i++) {
		cin >> c[i];
	}

	vector<LL> tb;

	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			tb.push_back(a[i] + b[j]);
		}
	}

	sort(tb.rbegin(), tb.rend());

	sort(c.rbegin(), c.rend());

	vector<LL> ans;

	LL L = min((LL)tb.size(), K);

	for (int i = 0; i < L; i++) {
			for (int j = 0; j < Z; j++) {
				ans.push_back(tb[i] + c[j]);
			}
	}

	sort(ans.rbegin(), ans.rend());

	for (int i = 0; i < K; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 43112
#include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;

void solve(){
 int n;
  long long a[30] = {1,2,4};
  loop(i,3,30)a[i] = a[i-1] + a[i-2] + a[i-3];
  while(cin>>n,n)
    cout<<1+a[n-1]/3650<<endl;
}
int main(void){
  solve();
  return 0;
}

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

using namespace std;

using ll = long long;

int main(){
    ll n, odd = 0, evendiv = 0, even = 0;
    cin >> n;
    for(ll i = 0; i < n; ++i){
        ll tmp; cin >> tmp;
        if(tmp % 2 != 0)odd++;
        else if(tmp % 4 == 0)evendiv++;
        else even++;
    }
    if(even == 0){
        if(evendiv >= odd - 1){
            cout << "Yes";
        }else cout << "No";
    }
    else if(evendiv >= odd){
        cout << "Yes";
    }
    else cout << "No";
    return 0;
}


Measured memory_bytes: 384
from math import sqrt

N, M = [int(_) for _ in input().split()]

p = []
m = M
max_x = 1
for i in range(2, int(sqrt(m)) + 1):
    if m % i == 0:
        cnt = 0
        while m % i == 0:
            cnt += 1
            m //= i
        p.append((i, cnt))
        if cnt > max_x:
            max_x = cnt
if m > 1:
    p.append((m, 1))

kaijo = [0] * (max_x + 1 + N)
gyaku = [0] * (max_x + 1 + N)
kaijo[0] = kaijo[1] = 1
gyaku[0] = gyaku[1] = 1

MOD = 10 ** 9 + 7
for i in range(2, len(kaijo)):
    kaijo[i] = (kaijo[i - 1] * i) % MOD
for i in range(2, len(gyaku)):
    gyaku[i] = pow(kaijo[i], MOD - 2, MOD)
# print(kaijo)
# print(gyaku)
ans = 1
for x, y in p:
    a = y + (N - 1)
    b = (N - 1)
    spam = (kaijo[a] * gyaku[a - b] * gyaku[b]) % MOD
    ans = (ans * spam) % MOD
print(ans)


Measured memory_bytes: 10968
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

ll a[2001],dp[2001];
int main(){
    ll n,x,ai;
    cin>>n>>x;
    ll sum=1000100010001000;
    rep(i,n){
        cin>>ai;
        dp[i]=a[i]=ai;
    }
    rep(i,n){
        ll s=0;
        rep(j,n){
            dp[j]=min(dp[j],a[(j-i+n)%n]);
            s+=dp[j];
        }
        sum=min(sum,s+i*x);
    }
    cout<<sum<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

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

	int n;
	cin >> n;
	vector<P> v(n);
	map<P, int> mp;
	for (int i = 0; i < n; i++)
	{
		int x, y, w;
		cin >> x >> y >> w;
		v[i] = P(x, y);
		mp[v[i]] = w;
	}
	int ma = 0;
	for (int i = 0; i < n; i++)
	{
		int x = v[i].first, y = v[i].second;
		for (int j = 0; j < 8; j += 2)
		{
			int sum = mp[P(x, y)] + mp[P(x + dx[j], y + dy[j])] + mp[P(x + dx[(j + 1) % 8], y + dy[(j + 1) % 8])] + mp[P(x + dx[(j + 2) % 8], y + dy[(j + 2) % 8])];
			ma = max(ma, sum);
		}
	}
	cout << ma << " / 1" << endl;
}



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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int h, w, c;
string s;

int main() {
	cin >> h >> w;
	rep(i,h) {
		cin >> s;
		rep(j,w) c += (s[j]=='#');
	}
	if (c==h+w-1) cout << "Possible" << ln;
	else cout << "Impossible" << ln;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        d: usize,
        c: [i64;26],
        s: [[i64;26];d],
    }
    let mut t=vec![0;d];
    let mut last=[0;26];
    for (i,t) in t.iter_mut().enumerate() {
        let mut m=std::i64::MIN;
        let mut k=0;
        for j in 0..26 {
            let p=last[j];
            let mut v=0;
            v+=s[i][j];
            last[j]=i+1;
            for (&c,&last) in c.iter().zip(last.iter()) {
                v-=c*(i+1-last)as i64;
            }
            if m<v {
                m=v;
                k=j;
            }
            last[j]=p;
        }
        last[k]=i+1;
        *t=k;
    }
    for t in t {
        println!("{}",t+1);
    }
}

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

int main(){
  int n,s;
  
  while(cin>>n && n!=0){
    int sum=0;
    int largest=0;
    int smallest=1000;
    
    for(int i=1;i<=n;i++){
      cin>>s;
      sum+=s;
      if(largest<s)  largest=s;
      if(smallest>s) smallest=s;
    }
    int result=sum-largest-smallest;

    cout<<(int)(result/(n-2))<<endl;
}

}

Measured memory_bytes: 3044
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	mx := 0
	m := make(map[string]int)
	var s string
	for i := 0; i < n; i++ {
		fmt.Scan(&s)
		m[s]++
		if mx < m[s] {
			mx = m[s]
		}
	}

	ss := make([]string, 0)
	for s, c := range m {
		if c == mx {
			ss = append(ss, s)
		}
	}
	sort.Strings(ss)

	for _, s := range ss {
		fmt.Println(s)
	}
}


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

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

	int N;
	int i,j;
	int tmp;
	int counter=0;
	double ave;
	string answer;
	vector<int> given;

	cin >> N;

	N=N%10;

	if(N==3){
		answer="bon";
	}else if(N==0 |N==1 |N==6 |N==8){
		answer="pon";
	}else{
		answer="hon";
	}
	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 3452
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    let A = parseInt(arg[0].split(" ")[0]);
    let B = parseInt(arg[0].split(" ")[1]);
    let C = parseInt(arg[0].split(" ")[2]);
    const K = parseInt(arg[0].split(" ")[3]);
    
    // 1 0 -1の順で優先してとる
    const one = A >= K ? K : A;
    
    const zero = Math.max(K - A, 0);
    
    const minusOne = Math.max(K - (A + B), 0);
    
    console.log((1 * one) + (0 * zero) + (-1 * minusOne));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29808
using System;
using System.Linq;

namespace AtCoder.BeginnersSelections
{
    class Test{

        static void Main(string[] args)
        {
            string[] st = Console.ReadLine().Split(' ');
            int N = int.Parse(st[0]);
            int K = int.Parse(st[1]);

            int[] L = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Array.Sort(L);
            Array.Reverse(L);

            int ans = 0;

            for (int i = 0; i < K; i++)
                ans += L[i];
            Console.WriteLine(ans);            
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;


void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


/* 注意 

    1LL<<60 * N とかのオーバーフローに気を付けろ
    制約がヒントになる、ちゃんと全ての制約を見ろ

*/



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

    int n; cin >> n;
    vector<int> s(n), l(n), p(n);
    rep(i, n) cin >> s[i] >> l[i] >> p[i];

    vector<vector<int>> dp(400, vector<int>(400, -1));
    rep(i, n+1) dp[i][0] = 0;

    rep(i, n) rep(j, 400) {
        chmax(dp[i+1][j], dp[i][j]);
        for(int k=max(0, j-l[i]); k<=j-s[i]; ++k) chmax(dp[i+1][j], dp[i+1][k]+p[i]);
    }

    int m; cin >> m;
    bool ng = false;
    vector<int> ans(m);
    rep(i, m) {
        int w; cin >> w;
        if (dp[n][w] == -1) { ng = true; break; }
        ans[i] = dp[n][w];
    }

    if (ng) { cout << -1 << endl; return 0; }
    rep(i, m) cout << ans[i] << endl;

    return 0;
}



Measured memory_bytes: 3664
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	cin>>S;
	rrep(i,0,SZ(S))
	{
		if(S[i]=='?')S[i]='D';
	}

	cout<<S<<endl;
	
	return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
 
int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k % 2 == 0) cout << a - b << endl;
    else cout << b - a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int const NMAX = 1e5;
int const KMAX = 100;
int const INF = 1e9;

int nStones;
int hopLim;
int ans;
int dp[1+NMAX][1+KMAX];
int heights[1+NMAX];

int costOfHop(int from, int to) {
  return abs(heights[from]-heights[to]);
}

int main() {
  cin >> nStones >> hopLim;
  for(int i=1; i<=nStones; i++) {
    cin >> heights[i];  
  }

  //We make the following notation = dp[i][0] = min(dp[i][1], dp[i][2], .. dp[i][hopLim])
  for(int i=1; i<=nStones; i++){
    dp[i][0] = INF;
  }

  //solve 1st problem
  dp[1][0] = 0;

  //solve 2nd problem
  dp[2][0] = costOfHop(1, 2);

  for(int i=3; i<=nStones; i++) { 
    int lim = min(hopLim, i-1); 
    for(int j=1; j<=lim; j++) {       
        dp[i][j] = dp[i-j][0] + costOfHop(i-j, i);
        dp[i][0] = min(dp[i][0], dp[i][j]);
    }
  }
  
  cout << dp[nStones][0];
  return 0;
}

Measured memory_bytes: 40064
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string A, B, C;
	cin >> A >> B >> C;
	if (A.back() == B.front() && B.back() == C.front()) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
map<ll,ll> mp;
const ll mod=1000000007;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}
int main(){
   int n,p;
   cin>>n>>p;
   vector<int> a(n);
   ll cnt=0;
   for(int i=0;i<n;i++){
       cin>>a.at(i);
       if(a.at(i)%2==1)cnt++;
   }
if(cnt==0&&p==1)cout<<0<<endl;
else if(cnt==0)cout<<modpow(2,n)<<endl;
else cout<<modpow(2,n-1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/


int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int n, w; cin >> n >> w;
    ll sum = 0;
    vector <int> weights(n+1), values(n+1);
    for (int i = 1; i <= n; ++i) {
        cin >> weights[i] >> values[i];
        sum += values[i];
    }

    //dp[i][j] => using elements [1...i], minimum weights required to get the value= 'j'
    //to do so I have create the recurrence relation
    //dp[i][j] = min(dp[i-1][j], weight[i] + dp[i-1][j - values[i]])
    vector <vector<ll>> dp(n+1, vector <ll>(sum+1, 1e18));
    dp[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= sum; ++j) {
            dp[i][j] = dp[i-1][j]; //don't use the current element
            if (j - values[i] >= 0)
                dp[i][j] = min(dp[i][j], weights[i] + dp[i-1][j-values[i]]);
        }
    }

    ll ans = 0;
    for (int i = sum; i >= 0; --i) {
        if (dp[n][i] <= w) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, x; cin >> n >> x;
	vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i];
	long long ans = 0;
	for(int i = 0; i < n - 1; i++){
		int has = a[i] + a[i + 1];
		int pick = max(has - x, 0);
		int pl = min(pick, a[i + 1]);
		pick -= pl;
		a[i + 1] -= pl;
		ans += pl;
		a[i] -= pick;
		ans += pick;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
fn main() {
    proconio::input! {
        n: usize,
        mut ab: [(i64,i64);n],
    }
    let mut p = vec![1;n+1];
    for i in 0..n {
        p[i+1] = p[i]*2%MOD;
    }
    let mut m = std::collections::BTreeMap::new();
    let mut z = 0;
    for (mut a, mut b) in ab {
        if a==0 && b==0 {
            z+=1;
            continue;
        }
        if b==0 {
            a=1;
        }
        else if a==0 {
            b=1;
        }
        else {
            if b<0 {
                a=-a;
                b=-b;
            }
            let g = num::integer::gcd(a.abs(),b.abs());
            if g!=0 {
                a/=g;
                b/=g;
            }
        }
        *m.entry((a,b)).or_insert(0) += 1usize;
    }
    let mut t=1;
    let s: Vec<_> = m.keys().cloned().collect();
    for (a,b) in s { if m.contains_key(&(a,b)) {
        let x = m.remove(&(a,b)).unwrap_or(0) + m.remove(&(-a,-b)).unwrap_or(0);
        let y = m.remove(&(-b,a)).unwrap_or(0) + m.remove(&(b,-a)).unwrap_or(0);
        t = t*(p[x]+p[y]-1)%MOD;
    }}
    t=(t+z+MOD-1)%MOD;
    println!("{}",t);
}
const MOD: i64=1000000007;

Measured memory_bytes: 22156
def abc144c_walk_on_multiplication_table():
    def divisor(n):
        """ nの約数列挙 """
        ret = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                ret.append(i)
                if i ** 2 == n:
                    continue
                ret.append(n // i)
        return ret  # sortされていない
    ans = float('inf')
    n = int(input())
    a = divisor(n)
    for item in a:
        ans = min(ans, item-1+n//item-1)
    print(ans)
abc144c_walk_on_multiplication_table()

Measured memory_bytes: 66276
/* 2017.3.18 Celicath */
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stdint.h>
#include <queue>

int main()
{
	int X;
	scanf("%d", &X);

	unsigned int min = 0;
	unsigned int max = 50000;
	while (min < max)
	{
		unsigned int mid = (min + max) / 2;
		unsigned int c = mid * (mid + 1) / 2;
		if (c > X)
			max = mid;
		else if (c < X)
			min = mid + 1;
		else min = max = mid;
	}

	printf("%d\n", max);
	return -0;
}


Measured memory_bytes: 128
def ii():return int(input())
def iim():return map(int,input().split())
def ism():return map(str,input().split())
def iil():return list(map(int,input().split()))
s,t=ism()
a,b=iim()
u=input()

if u == s:
    print(a-1,b)
else:
    print(a,b-1)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
char s[N];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  vector<int> qS(n + 1), aS(n + 1), cS(n + 1);
  for (int i = 0; i < n; ++i) {
    qS[i + 1] = qS[i] + (s[i] == '?');
    aS[i + 1] = aS[i] + (s[i] == 'A');
    cS[i + 1] = cS[i] + (s[i] == 'C');
  }
  vector<int64> p3(n + 1);
  p3[0] = 1;
  for (int i = 1; i <= n; ++i) {
    p3[i] = p3[i - 1] * 3 % MOD;
  }
  int ret = 0;
  for (int i = 1; i < n - 1; ++i) {
    if (s[i] == 'A' || s[i] == 'C') continue;
    int cnt = qS[i];
    int64 L = aS[i] * p3[cnt] % MOD;
    if (cnt) {
      L = (L + p3[cnt - 1] * cnt) % MOD;
    }
    // trace(i, cnt, L);
    cnt = qS[n] - qS[i + 1];
    int64 R = (cS[n] - cS[i + 1]) * p3[cnt];
    if (cnt) {
      R = (R + p3[cnt - 1] * cnt) % MOD;
    }
    // trace(i, cnt, R);
    ret += L * R % MOD;
    ret %= MOD;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 2304
#include<iostream>
using namespace std;
int main(void){
    char c1, c2, c3;
    int pri = 700;
    cin >> c1 >> c2 >> c3;
    if(c1 == 'o'){
        pri += 100;
    }
    if(c2 == 'o'){
        pri += 100;
    }
    if(c3 == 'o'){
        pri += 100;
    }
    cout << pri <<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import collections

n = int(input())
a =np.array([int(x) for x in input().split()])
q = int(input())
bc = [map(int, input().split()) for _ in range(q)]
b, c = [list(i) for i in zip(*bc)]

count_dict = collections.Counter(a)
ans = np.sum(a)
for i in range(q):
    if count_dict[b[i]] > 0:
        ans += count_dict[b[i]]*(c[i]-b[i])
        count_dict[c[i]] += count_dict[b[i]]
        count_dict[b[i]] = 0
    print(ans)

Measured memory_bytes: 86276
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int func(vector<string> &S, int K, vector<int> x) {
  int W = S[0].size();
  int N = x.size() - 1;  // num bins

  int ans = N - 1;
  
  vector<int> c(N);
  vector<int> d(N);
  for (int j = 0; j < W; ++j) {
    for (int k = 0; k < N; ++k) {
      d[k] = c[k];
      for (int i = x[k]; i < x[k + 1]; ++i) {
	if (S[i][j] == '1') d[k] += 1;
      }
    }
    if (*max_element(d.begin(), d.end()) > K) {
      ++ans;
      for (int k = 0; k < N; ++k) {
	d[k] -= c[k];
      }
      if (*max_element(d.begin(), d.end()) > K) {
      	return -1;
      }
    }
    swap(c, d);
  }
  
  return ans;
}

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  for (int i = 0; i < H; ++i) {
    cin >> S[i];
  }

  int ans = (H - 1) + (W - 1);
  for (int b = 0; b < 1<<(H - 1); ++b) {
    vector<int> x;
    x.push_back(0);
    for (int i = 0; i < H - 1; ++i) {
      if (b>>i & 1) {
	x.push_back(i + 1);
      }
    }
    x.push_back(H);
    int ret = func(S, K, x);
    if (ret != -1) {
      ans = min(ans, ret);
    }
  }

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


Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())
s=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if x==500*i+100*j+50*k:
        s=s+1

print(s)        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, m;
string a[55], b[55];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	FOR(i, n) cin >> a[i];
	FOR(i, m) cin >> b[i];
	if (n == m) {
		bool ok = true;
		FOR(i, n) {
			FOR(j, n) {
				if (a[i][j] != b[i][j]) ok = false;
			}
		}
		cout << (ok ? "Yes" : "No") << endl;
		return 0;
	}
	FOR(i, n-m) {
		FOR(j, n-m) {
			bool ok = true;
			FOR(x, m) {
				FOR(y, m) {
					if (a[i+x][j+y] != b[x][y]) ok = false;
				}
			}
			if (ok) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	string s;
	cin>>s;
	int a = s[0] - '0';
	int b = s[1] - '0';
	int c = s[2] - '0';
	int d = s[3] - '0';
	if(a + b + c + d == 7){
		cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7\n";
		exit(0);
	}
	if(a + b + c - d == 7){
		cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7\n";
		exit(0);
	}
	if(a + b - c + d == 7){
		cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7\n";
		exit(0);
	}
	if(a - b + c + d == 7){
		cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7\n";
		exit(0);
	}
	if(a + b - c - d == 7){
		cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7\n";
		exit(0);
	}
	if(a - b + c - d == 7){
		cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7\n";
		exit(0);
	}
	if(a - b - c + d == 7){
		cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7\n";
		exit(0);
	}
	if(a - b - c - d == 7){
		cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7\n";
		exit(0);
	}

	return 0;
}

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


char b;
map<char,char> m;

int main(){
    cin >> b;
    m['A'] = 'T';
    m['T'] = 'A';
    m['G'] = 'C';
    m['C'] = 'G';

    cout << m[b] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

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

int f(int a){
  int count = 0;
  int flag = 0;
  for(int i = 1; i <= pow(a,0.5); ++i){
    if(a % i == 0) count ++;
    if(i*i == a)flag = 1;
  }
  count *= 2;
  if(flag == 1) --count;
  return count;
}


int main(){

  int n;
  scanf("%d",&n);

  char s[n+1];
  scanf("%s",s);

  char num[4];
  int ans = 0;
  for(int i = 0; i < 1000; ++i){
      int tmp = i;
      int index = 0;
    for(int j = 2; j >= 0; --j){
      num[j] =  tmp % 10;
      tmp /= 10;
    }
    for(int j = 0; j < n; ++j){
      if(num[index] == (s[j] - '0')) index++;
      if(index == 3){
        ans ++;
        break;
      }
    }
  }

  printf("%d",ans);

  return 0;
}


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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

map<int, int> s;

int main () {
	//std::ios::sync_with_stdio(false);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	int n;
	cin >> n;
	forn(i, n) {
	 	int a;
	 	cin >> a;
	 	s[a]++;
	}
	ll ans = 0;
	for (auto pa: s) {
	 	if (pa.fs <= pa.sc) {
	 	 	ans += pa.sc - pa.fs;
	 	} else {
	 	 	ans += pa.sc;
	 	}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

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

    long long ans = 0;
    vector<long long> vec(N,0);
    for(int i=0; i<N; i++){
        cin >> vec[i];
    }
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            ans+=vec[i]*vec[j];
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
k = int(input())

t = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
s = t.split(',')

print(s[k-1].strip())

Measured memory_bytes: 2940