akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin >> D;
  vector<int> c(26);
  for (int i = 0; i < 26; i++){
    cin >> c[i];
  }
  vector<vector<int>> s(D, vector<int>(26));
  for (int i = 0; i < D; i++){
    for (int j = 0; j < 26; j++){
      cin >> s[i][j];
    }
  }
  vector<int> last(26, -1);
  for (int i = 0; i < D; i++){
    vector<vector<int>> d(26, vector<int>(26, 0));
    for (int j = 0; j < 26; j++){
      for (int k = 0; k < 26; k++){
        d[j][k] += s[i][j];
        d[j][k] += c[j] * (i - last[j]) * 2;
        if (i < D - 1){
          if (j != k){
            d[j][k] += s[i + 1][k];
            d[j][k] += c[k] * (i - last[k] + 1);
          } else {
            d[j][k] += s[i + 1][k];
            d[j][k] += c[k];
          }
        }
        //cout << d[j][k] << ' ';
      }
      //cout << endl;
    }
    int a = 0, b = 0;
    if (i % 2 == 0){
      for (int j = 0; j < 26; j++){
        for (int k = 0; k < 26; k++){
          if (d[j][k] > d[a][b]){
            a = j;
            b = k;
          }
        }
      }
    } else {
      for (int j = 25; j >= 0; j--){
        for (int k = 25; k >= 0; k--){
          if (d[j][k] > d[a][b]){
            a = j;
            b = k;
          }
        }
      }
    }
    cout << a + 1 << endl;
    last[a] = i;
  }
}

Measured memory_bytes: 3676
A = list(map(int, input().split())) 
N = A[0]
K = A[1]
Q = A[2]
n = [K for _ in range(N)]
for i in range(N):
    n[i] -= Q
for _ in range(Q):
    ans = int(input()) - 1
    n[ans] += 1
for i in range(N):
    if(n[i] > 0):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 7844
#include <iostream>
#include <complex>
#include <cstdio>
#include <cmath>
using namespace std;

double area(const complex<double> &p0, const complex<double> &p1, const complex<double> &p2) {
    complex<double> _p0 (p0.real() - p1.real(), p0.imag() - p1.imag());
    complex<double> _p1 (p1.real() - p2.real(), p1.imag() - p2.imag());

    double a = (_p0.real() * _p1.imag() - _p0.imag() * _p1.real()) * 0.5;
    return (a > 0) ? a : -a;
}

double dist2(const complex<double> &p0, const complex<double> &p1) {
    return (p0.real() - p1.real()) * (p0.real() - p1.real())
        + (p0.imag() - p1.imag()) * (p0.imag() - p1.imag());
}

int main () {
    int n;
    cin >> n;
    while (n--) {
        complex<double> p[3];
        for (int i = 0; i < 3; i++) {
            double x, y;
            cin >> x >> y;
            p[i] = complex<double> (x, y);
        }

        double d2[3], d[3];
        for (int i = 0; i < 3; i++) {
            d2[i] = dist2(p[(i+1)%3], p[(i+2)%3]);
            d[i] = sqrt(d2[i]);
        }

        double s = area(p[0], p[1], p[2]);
        double ss = s * s * 16;

        double e[3];
        e[0] = d2[0] * (-d2[0] + d2[1] + d2[2]) / ss;
        e[1] = d2[1] * (d2[0] - d2[1] + d2[2]) / ss;
        e[2] = d2[2] * (d2[0] + d2[1] - d2[2]) / ss;

        double x = 0, y = 0;
        for (int i = 0; i < 3; i++) {
            x += e[i] * p[i].real();
            y += e[i] * p[i].imag();
        }
        double r = d[0] * d[1] * d[2] /
            sqrt((d[0]+d[1]+d[2]) * (-d[0]+d[1]+d[2]) * (d[0]-d[1]+d[2]) * (d[0]+d[1]-d[2]));

        printf("%.3f %.3f %.3f\n", x, y, r);
    }
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    string s; cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i, n-1) {
        if(s[i] != s[i+1]) ans++;
    }
    cout << ans;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;


struct SegmentTree {
private:
    int n;
    vector<bitset<26>> node;
    //int nとvector<int> nodeの2つを変数に持つ

public:
    //初期化処理
    SegmentTree(string v) {
        int sz = v.size(); //vは扱う配列の長さ
        n = 1; while(n < sz) n *= 2; //nはvの配列を入れるために必要なseg treeの葉の数
        node.resize(2*n-1, INF); //segtreeでは全部で2n-1の配列が必要
        for(int i=0; i<sz; i++) node[i+n-1] = (1 << (v.at(i) - 'a')); //segtreeの葉の部分に扱う配列を埋め込む
        for(int i=n-2; i>=0; i--) node[i] = node[2*i+1]|node[2*i+2]; //演算によって変える場所　segtreeを作る(注目しているnode iの子ノードを見て二項演算をして、node iの値を決定する)
    }

    void update(int x, char val) {
        x += (n - 1); //配列のx番目の要素を更新しようとするとき、segtreeで対応する要素はx+n-1番目である
        node[x] = 1 << (val - 'a'); //segtree上で値を更新
        while(x > 0) { //葉から根に向かってsegtreeの要素を更新していく
            x = (x - 1) / 2;
            node[x] = node[2*x+1]|node[2*x+2]; //演算によって変える
        }
    }

    int getor(int a, int b, int k=0, int l=0, int r=-1) {
        //求めたいのは区間[a,b)の中で演算しつづけた結果(たとえばこの区間の最小値)
        //自分がいるノードのindex(何階にいるか？)
        //ノードkは元の配列でいうとどの区間をカバーしているか？
        if(r < 0) r = n; //最初に呼び出す時はノードk=0はsegtreeの根なので区間は[0,n)を指す
        if(r <= a || b <= l) return 0; //今のノードが求める区間と無関係の場合は、最終的な答えに影響しない単位元(最小値を求めたい場合は単位元はINF)を返す 演算によって変える
        if(a <= l && r <= b) return ((int)(node[k].to_ullong())); //今見ている区間[l,r)が答えを求めたい区間[a,b)に完全に含まれるなら、この区間について演算し続けた結果(=node[k];例えば最小値)を返す

        //上記に当てはまらない場合
        //kの子ノードを見に行って、再帰的に処理を行う k=0の場合はノード1と2を見る
        int vl = getor(a, b, 2*k+1, l, (l+r)/2); //kの子ノード(left)の子孫のうち、求めたい区間に含まれる要素について演算し続けた結果を返す
        int vr = getor(a, b, 2*k+2, (l+r)/2, r); //kの子ノード(right)の子孫のうち、求めたい区間に含まれる要素について演算し続けた結果を返す
        bitset<26> bitvl(vl);
        bitset<26> bitvr(vr);
        bitset<26> vlorvr = bitvl|bitvr;
        return vlorvr.to_ullong(); //演算によって変える場所 子ノードの子孫のうち、演算しつづけた結果を返す
    }
};

int main(){
    ll N; cin >> N;
    string s; cin >> s;
    SegmentTree tree(s);
    ll Q; cin >> Q;
    rep(i,Q){
        ll type; cin >> type;
        if(type==1){
            ll first; cin >> first;
            first--;
            char second; cin >> second;
            tree.update(first,second);
        }else{
            ll first,second;
            cin >> first >> second;
            first--; 
            bitset<26> x(tree.getor(first,second));
            cout << x.count() << endl;
        }

    }
}

Measured memory_bytes: 9604
n = int(input())
s = input()

first = 0

for i in range (n-1):
    if s[i+1] == "E":
        first += 1
mini = first

for i in range(n-1):
    if s[i] == "W":
        first +=1
    if s[i+1] == "E":
        first -= 1
    mini = min(mini,first)

print(mini)

Measured memory_bytes: 3700
N = int(input())

pairs = []
for i in range(N):
    a, b = map(int, input().split())
    pairs.append((a, b))
pairs = pairs[::-1]

total = 0
for a, b in pairs:
    a_dash = a + total
    mod = a_dash % b
    if mod > 0:
        total += b - mod
print(total)

Measured memory_bytes: 17360
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let h = nextIntArray()
    let max = 0
    let curr = 0
    for (let i = 1; i < h.length; i++) {
        if (h[i] <= h[i - 1]) {
            curr++
        } else {
            max = Math.max(max, curr)
            curr = 0
        }
    }
    max = Math.max(max, curr)
    console.log(max)
}
Main()



Measured memory_bytes: 40064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string s;
  cin >> s;
  bool hasC = false,hasF = false;
  rep(i,sz(s)) {
    if(s[i] == 'C') {
      hasC = true;
    } else if(s[i] == 'F' && hasC) {
      hasF = true;
      break;
    }
  }
  if(hasF) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N=int(input())
alist=list(map(int,input().split()))

answer_dic={}
for a in alist:
  if a in answer_dic:
    answer_dic[a]+=1
  else:
    answer_dic[a]=1
#print(answer_dic)

for i in range(1,N+1):
  if i in answer_dic:
    print(answer_dic[i])
  else:
    print(0)

Measured memory_bytes: 33576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
typedef double db;
const int maxn = 5e5 + 5;
const int mod = 1e9 + 7;

ll a[maxn], dp[maxn][5];

int main(){
    int n;
    scanf("%d", &n);
    rep(i, 1, n)
        scanf("%lld", &a[i]);
    rep(i, 1, n){
        dp[i][0] = dp[i-1][0];
        rep(j, 1, 4)
            dp[i][j] = min(dp[i][j-1], dp[i-1][j]);
        dp[i][0] += a[i]; dp[i][4] += a[i];
        dp[i][1] += a[i] == 0 ? 2 : (a[i] & 1);
        dp[i][3] += a[i] == 0 ? 2 : (a[i] & 1);
        dp[i][2] += a[i] & 1 ^ 1;
    }
    ll ans = dp[n][0];
    rep(i, 1, 4)
        ans = min(ans, dp[n][i]);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 12544
#include<stdio.h>
int main()
{
    char s[3][11];
    int i;
    for (i = 0; i < 3; i++)
        scanf("%s", s[i]);
    for (i = 0; i < 3; i++)
        printf("%c", s[i][0] - 'a' + 'A');
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
W, H, N = map(int, input().split())

w_min, w_max = 0, W
h_min, h_max = 0, H

for _ in range(N) :
    x, y, a = map(int, input().split())
    
    if (a == 1):
        w_min = max(w_min, x)
    elif (a == 2):
        w_max = min(w_max, x)
    elif (a == 3):
        h_min = max(h_min, y)
    else:
        h_max = min(h_max, y)

# max > min が成立しない場合0
if (w_max < w_min or h_max < h_min):
    print(0)
else:
    area = (w_max - w_min) * (h_max - h_min)
    print(area)

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

int main() {
  int N, ans;
  cin >> N;
  for (int i = 1; i <= N; i++){
    int keta;
    keta = log10(i);
    if (keta % 2 == 0){
      ans++;
    }
    else continue;
  }
  cout << ans << endl;
}


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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000000000
const ll mod=1e9+7;

int main()
{
	int nT; nT=1; //cin>>nT;
	while(nT--)
	{
		ll a,b,c; cin>>a>>b>>c;
      	ll ans=0;
      	if(c>=b)
        {
          ans+=2*b;
          c-=b;
          if(a>=c) ans+=c;
          else ans+=a+1;
        }
        else
        {
          ans+=2*c;
          b-=c;
          ans+=b;
        }
      	cout<<ans;
    }
	return 0;
}
//2+

Measured memory_bytes: 256
class UnionFindWithSize
  def initialize(size)
    @rank = Array.new(size) { 0 }
    @parent = Array.new(size) { |id| id }
    @union_size = Array.new(size) { 1 }
  end

  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    ary = [@union_size[x_parent], @union_size[y_parent]]
    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
      @union_size[x_parent] += ary[1]
    else
      @parent[x_parent] = y_parent
      @union_size[y_parent] += ary[0]
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
    ary
  end

  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end
end

n, m = gets.split.map(&:to_i)
bridges = Array.new(m) { Array.new(2) }
uf = UnionFindWithSize.new(n)
m.times do |i|
  bridges[i] = gets.split.map {|j| j.to_i - 1 }
end
ans = []
curr_value = n * (n-1) / 2
ans << curr_value
bridges[1..-1].reverse_each do |u, v|
  if diff = uf.unite(u, v)
    curr_value -= diff[0] * diff[1]
  end
  ans << curr_value
end

puts ans.reverse

Measured memory_bytes: 20216
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    string s; int x, y; cin >> s >> x >> y;
    vector<int> X, Y;
    
    int turn = 0; int cnt = 0;
    for(char c: s){
        if(c == 'F') cnt++;
        else{
            if(turn%2==0){
                X.push_back(cnt);
            }else{
                Y.push_back(cnt);
            }
            cnt = 0;
            turn++;
        }
    }
    if(turn%2==0) X.push_back(cnt);
    else Y.push_back(cnt);

    int sx = X.size(), sy = Y.size();
    vector<vector<bool>> dx(sx+1, vector<bool>(8000*2+10));
    vector<vector<bool>> dy(sy+1, vector<bool>(8000*2+10));
    dx[0][8000] = true; dy[0][8000] = true;
    rep(i, sx){
        rep(j, 8000*2+10){
            if(dx[i][j]){
                dx[i+1][j+X[i]] = true;
                if(i>0) dx[i+1][j-X[i]] = true;
            }
        }
    }   
    rep(i, sy){
        rep(j, 8000*2+10){
            if(dy[i][j]){
                dy[i+1][j+Y[i]] = true;
                dy[i+1][j-Y[i]] = true;
            }
        }
    }    
    
    if(dx[sx][x+8000] && dy[sy][y+8000]) cout << "Yes" << ln;
    else cout << "No" << ln;
}


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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (x).size()


ll sum(int n);

void go(){
	int n;cin>>n;
	cout << pow(n,3);
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
   string s ;
   cin>>s;
   if(s=="Sunny"){
       cout<<"Cloudy";
   }
   else if(s=="Cloudy"){
       cout<<"Rainy";
   }
   else if(s=="Rainy"){
       cout<<"Sunny";
   }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = 10e9;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll N,M;
    cin>>N>>M;
    vector<vi> e(N, vi());
    REP(i,M){
        ll a,b;
        cin>>a>>b;
        e[a-1].push_back(b-1);
    }
    for(ll b:e[0]){
        if(find(e[b].begin(),e[b].end(),N-1)!=e[b].end()){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

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

#define MAX_V 100010
struct edge {int to, cost;};
int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
    priority_queue<p,vector<p>, greater<p> > que;
    fill(d,d+V, INF);
    d[s]=0;
    que.push(p(0,s));
    while(!que.empty()){
        p pi = que.top(); que.pop();
        int v = pi.second;
        if(d[v] < pi.first) continue;
        REP(i,G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(p(d[e.to],e.to));
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin >> V;
    vector<vector<ll> > A(V, vector<ll>(V));
    REP(i, V) REP(j, V) {
        cin >> A[i][j];
    }
    REP(i, V) if(A[i][i] != 0) {
        cout << -1 << endl;
        return 0;
    }
    REP(i, V) REP(j, V) if(A[i][j] != A[i][j]) {
        cout << -1 << endl;
        return 0;
    }
    vector<pair<int, pair<int, int> > > edges;
    REP(i, V) FOR(j, i, V) {
        edges.pb(make_pair(A[i][j], make_pair(i, j)));
    }
    sort(edges.begin(), edges.end());
    for(auto x: edges) {
        int cost = x.first;
        int start = x.second.first;
        int end = x.second.second;
        dijkstra(start);
        if (d[end] < cost) {
            cout << -1 << endl;
            return 0;
        } else if (d[end] > cost) {
            G[start].pb(edge{end,cost});
            G[end].pb(edge{start,cost});
        }
    }
    ll ans = 0;
    REP(i, V) {
        for(auto x: G[i]) {
            ans += x.cost;
        }
    }
    cout << ans / 2 << endl;
    
    return 0;
}


Measured memory_bytes: 4224
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
N = int(input())
A = list(map(int, input().split()))

f = False
cnt = 0
while (True) :
  for i in range(N) :
    if A[i] % 2 == 0 :
      A[i] /= 2
    else :
      f = True
  if f != True :
    cnt += 1
  else :
    break

print (cnt)
  
  
  



Measured memory_bytes: 38768
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)
def gcd(a,b,c):
    return  gcd_core((gcd_core(a,b)),c)

k = int(input())
al = {}
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            # tp = [i,j,l]
            # tp.sort()
            # ky = ",".join(map(str,tp))
            # if ky not in al:
            #     val = gcd(i,j,l)
            #     al[ky] = val
            #     ans += val
            # else:
            #     ans += al[ky]
            ans += gcd(i,j,l)

print(ans)

Measured memory_bytes: 77156
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	if(x<=0)return 0;
	LL res = 0;
	PER(i, 40){
		if(x&BIT(i)){
			if(i==0)res ^= x;
			else res ^= BIT(i+1) - 1;
		}
	}
}

int main(){
	int N;
	cin >> N;
	vector<int> line(N+1);
	for(int i=1;i<=N;++i)cin>>line[i];
	vector<int> ans(N+1, 0);
	for(int i=N;i;--i){
		int sum = 0;
		for(int j=i*2;j<=N;j+=i)sum += ans[j];
		if((sum&1)^line[i])ans[i]=1;
	}

	vector<int> al;
	REPA(i, N+1){
		if(ans[i])al.push_back(i);
	}
	bool flag = false;
	cout << al.size() << endl;
	foreach(i, al){
		if(flag)cout << " ";
		flag = true;
		cout << i;
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	string s; cin >> s;
	cout << (s[0] == s[1] || s[2] == s[1] || s[2] == s[3] ? "Bad" : "Good") << endl;
	
	return 0;
}

Measured memory_bytes: 256
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=2e5+10;

vector<int> v[N],clr[2],numbers[3];
vector<int> ans(N);

void dfs(int x,int p,int d)
{
    clr[d].pb(x);
    for(auto c:v[x])
    {
        if(c!=p)
            dfs(c,x,1-d);
    }
}

void solve()
{
    int n;
    cin>>n;

    int a,b;
    for(int i=0;i<n-1;++i)
    {
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }

    dfs(1,-1,0);

    for(int i=1;i<=n;++i)
        numbers[i%3].pb(i);

    if(clr[0].size()>clr[1].size())
        swap(clr[0],clr[1]);

//    show(clr[0]);
//    show(clr[1]);

    if(clr[0].size()>=numbers[1].size() && clr[1].size()>=numbers[2].size())
    {
        for(int i=0;i<2;++i)
        {
            for(auto c:clr[i])
            {
                if(numbers[i+1].size())
                {
                    ans[c]=numbers[i+1].back();
                    numbers[i+1].pop_back();
                }
                else
                {
                    ans[c]=numbers[0].back();
                    numbers[0].pop_back();
                }
            }
        }
    }
    else
    {
        for(int i=0;i<2;++i)
        {
            for(auto c:clr[i])
            {
                for(int j=0;j<3;++j)
                {
                    if(numbers[j].size())
                    {
                        ans[c]=numbers[j].back();
                        numbers[j].pop_back();
                        break;
                    }
                }
            }
        }
    }

    for(int i=1;i<=n;++i)
        cout<<ans[i]<<" ";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 24812
#include <iostream>

using namespace std;

int main() {
	int n, r;

	while (cin >> n >> r && (n > 0 && r > 0)) {
		int card[51];

		for (int i = 1; i <= n; i++) {
			card[i] = n - i + 1;
		}

		int p, c;
		for (int i = 0; i < r; i++) {
			cin >> p >> c;

			int temp[50];
			for (int j = 0; j < c; j++) {
				temp[j] = card[p + j];
			}

			for (int j = p - 1; j >= 1; j--) {
				card[j + c] = card[j];
			}

			for (int j = 0; j < c; j++) {
				card[j + 1] = temp[j];
			}
		}

		cout << card[1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;
public class Main {
	static final char APPLE_CHAR = '@';
	static final char KAKI_CHAR = '#';
	static final char ORANGE_CHAR = '*';
	static final char CHECKED = '0';
	char area[][];
	char fruit;
	void run(){
		Scanner scan = new Scanner(System.in);
		while(true){
			int h = scan.nextInt();
			int w = scan.nextInt();
			if(h == 0 && w == 0)break;
			area = new char[h][w];
			for(int i = 0;i < h;i++){
				String col = scan.next();
				for(int j = 0;j < w;j++){
					area[i][j] = col.charAt(j);
				}
			}
			int groupCnt = 0;
			for(int i = 0;i < h;i++){
				for(int j = 0;j < w;j++){
					//?????§???????????????????????????
					if(area[i][j] == CHECKED)continue;
					groupCnt++;
					fruit = area[i][j];
					checkArea(i,j);
				}
			}
			System.out.println(groupCnt);
		}
	}

	//??£?¶????????????????????????°?????§????????????
	void checkArea(int y,int x){
		//????????????NG
		if(y >= area.length)return;
		if(y < 0)return;
		if(x >= area[0].length)return;
		if(x < 0)return;
		if(area[y][x] == fruit){
			area[y][x] = CHECKED;
			checkArea(y + 1,x    );
			checkArea(y - 1,x    );
			checkArea(y    ,x + 1);
			checkArea(y    ,x - 1);
		}
	}

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

Measured memory_bytes: 30140
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	a := scanNums(n)

	printArray(answer(n, a))
}

func answer(n int, a *[]int) *[]int {
	res := make([]int, n)

	for k, v := range *a {
		res[v-1] = k+1
	}
	return &res
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("function min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func minArray(nums *[]int) int {
	res := (*nums)[0]
	for _, v := range *nums {
		res = int(math.Min(float64(res), float64(v)))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("function max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func maxArray(nums *[]int) int {
	res := (*nums)[0]
	for _, v := range *nums {
		res = int(math.Max(float64(res), float64(v)))
	}
	return res
}

func scanNums(len int) *[]int {
	var num int
	nums := make([]int, len)
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums[i] = num
	}
	return &nums
}

func printArray(nums *[]int) {
	len := len(*nums)
	for k, v := range *nums {
		fmt.Printf("%d", v)
		if k < len-1 {
			fmt.Printf(" ")
		}
	}
}

Measured memory_bytes: 7936
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int numo = 0;
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            if(a[i] % 2 == 1){
                numo++;
            }
        }
		sc.close();
        if(numo % 2 == 0){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        }
	}
}


Measured memory_bytes: 51632
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int h, w; cin >> h >> w;
    vector<string> grid(h);
    for (string &s: grid) cin >> s;
    vector<vector<int>> dist(h, vector<int>(w, -1));
    vector<pair<int, int>> que;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        if (grid[i][j] != '#') continue;
        que.emplace_back(i, j);
        dist[i][j] = 0;
    }
    for (int b = 0; b < que.size(); b++) {
        for (int di = -1; di <= 1; di++) {
            for (int dj = -1; dj <= 1; dj++) {
                if (di * di + dj * dj != 1) continue;
                int ni = que[b].first + di;
                int nj = que[b].second + dj;
                if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if (dist[ni][nj] != -1) continue;
                dist[ni][nj] = dist[que[b].first][que[b].second] + 1;
                que.emplace_back(ni, nj);
            }
        }
    }
    cout << dist[que.back().first][que.back().second] << endl;
    return 0;
}

Measured memory_bytes: 15468
#include<stdio.h>

#define MAX 100000
#define NIL -1

typedef struct{
  int right;
  int left;
  int parent;
} node;

node T[MAX];

void preorder(int);
void inorder(int);
void postorder(int);


int main(){
  int i,n,id,right,left,root;

  scanf("%d",&n);
  
  for(i=0;i<n;i++) T[i].parent=T[i].left=T[i].right=NIL;

  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&left,&right);
    T[id].left=left;
    T[id].right=right;
    if(left!=NIL) T[left].parent=id;
    if(right!=NIL) T[right].parent=id;
  }

  for(i=0;i<n;i++){
    if(T[i].parent==NIL) root=i;
  }

  printf("Preorder\n");
  preorder(root);
  printf("\n");

  printf("Inorder\n");
  inorder(root);
  printf("\n");

  printf("Postorder\n");
  postorder(root);
  printf("\n");
  
  return 0;
}

void preorder(int u){
  if(u==NIL) return;

  printf(" %d",u);
  preorder(T[u].left);
  preorder(T[u].right);
}

void inorder(int u){
  if(u==NIL) return;
  
  inorder(T[u].left);
  printf(" %d",u);
  inorder(T[u].right);
}

void postorder(int u){
  if(u==NIL)return;

  postorder(T[u].left);
  postorder(T[u].right);
  printf(" %d",u);
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	 int a,b,c;
  	cin>>a>>b>>c;
    int d = c-a-b;
    if( d>0 and d*d > 4*a*b)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(long[]);

    foreach (i ; 0 .. n) {
        a[i] = a[i] - (i + 1);
    }

    a.sort();

    long b = a[n / 2];

    debug {
        writeln(a);
        writeln(b);
    }

    long ans;

    foreach (i ; 0 .. n) {
        ans += abs(a[i] - b);
    }

    writeln(ans);
}









































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 11156
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <cinttypes>

#define fi first
#define se second

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll INF = 1e18 + 10;
const double EPS = 1e-9;

typedef pair<int, int> P;
inline P operator+(const P& p1, const P& p2) {
  return P(p1.first + p2.first, p1.second + p2.second);
}

int main() {
  int N;
  map<int, int> D;
  int M;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    D[d]++;
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    int t;
    cin >> t;
    if (D[t] <= 0) {
      cout << "NO" << endl;
      return 0;
    }
    D[t]--;
  }

  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 9600
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=3e5+5,inf=0x3f3f3f3f;
inline int max(R int x,R int y){return x>y?x:y;}
struct node;typedef node* ptr;
struct node{
	ptr lc,rc;int mx;
	inline void upd(){mx=max(lc->mx,rc->mx);}
}e[N<<3],*od,*ev,*pp=e;
void build(ptr &p,int l,int r,int d){
	p=++pp;if(l==r)return p->mx=d?-inf:0,void();
	int mid=(l+r)>>1;
	build(p->lc,l,mid,d),build(p->rc,mid+1,r,d);
	p->upd();
}
void update(ptr p,int l,int r,int x,int d){
	if(l==r)return p->mx=d,void();
	int mid=(l+r)>>1;
	x<=mid?update(p->lc,l,mid,x,d):update(p->rc,mid+1,r,x,d);
	p->upd();
}
int query(ptr p,int l,int r,int ql,int qr){
	if(ql<=l&&qr>=r)return p->mx;
	int mid=(l+r)>>1,res=-inf;
	if(ql<=mid)cmax(res,query(p->lc,l,mid,ql,qr));
	if(qr>mid)cmax(res,query(p->rc,mid+1,r,ql,qr));
	return res;
}
char s[N];int a[N],val[N],cnt[N],n;
inline bool ck(R int d,R int mx){
	if(mx<0)return false;
	return query(mx&1?od:ev,1,n,d,n)>=mx;
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n);
	for(R int i=1,mx=0;i<=n;++i){
		scanf("%d",&a[i]);
		val[i]=(cmax(mx,a[i])?2:1);
	}
	build(od,1,n,1),build(ev,1,n,0);
	fd(i,n,1){
		R int lo=query(od,1,n,a[i],n),le=query(ev,1,n,a[i],n);
		if(val[i]&1)update(ev,1,n,a[i],lo+val[i]),update(od,1,n,a[i],le+val[i]);
		else update(od,1,n,a[i],lo+val[i]),update(ev,1,n,a[i],le+val[i]);
	}
	fd(i,n,1)cnt[i]=cnt[i+1]+val[i]-1;
	int cx=0,cy=0,mx=0,my=0;
	fp(i,1,n){
		update(od,1,n,a[i],-inf),update(ev,1,n,a[i],0);
		if(ck(my,cx+cnt[i+1]-cy+(a[i]>mx))||ck(max(a[i],mx),cy+cnt[i+1]-cx-(a[i]>mx)))
			s[i]='0',cx+=cmax(mx,a[i]);
		else s[i]='1',cy+=cmax(my,a[i]); 
	}
	if(cx!=cy)return puts("-1"),0;
	printf("%s\n",s+1);
	return 0;
}

Measured memory_bytes: 24576
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, x = map(int, readline().split())
    a = list(map(int, readline().split()))
    ans = sum(a)
    prev = a[:]

    for cnt in range(1, n):
        score = cnt * x
        cur = [0] * n
        for i in range(n):
            cur[i] = min(prev[i], prev[(i - 1) % n])
        score += sum(cur)
        ans = min(ans, score)
        prev = cur

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74160
#include <bits/stdc++.h>
using namespace std;
int A[3];
map<vector<int>,int> mem; 
int pay2(vector<int> a)
{
    sort(a.begin(),a.end());
    int ret = 0;
    for(int i=0;i<3;++i) {
        ret += abs(A[i]-a[i]);
    }
    return ret;
}
int dfs(vector<int> vec)
{
    if(mem.count(vec)) {
        return mem[vec];
    }
    int n=vec.size();
    for(int i=0;i<n;++i)
    for(int j=i+1;j<n;++j)
    for(int k=j+1;k<n;++k)
    {
        int fee = pay2({vec[i],vec[j],vec[k]});
        if(!mem.count(vec) || fee<mem[vec]) {
            mem[vec] = fee;
        }
    }
    if(n>3)
    for(int i=0;i<vec.size();++i) {
        for(int j=i+1;j<vec.size();++j){
            vector<int> pp;
            for(int k=0;k<vec.size();++k) {
                if(k!=i&&k!=j)
                    pp.push_back(vec[k]);
            }
            pp.push_back(vec[i]+vec[j]);
            sort(pp.begin(),pp.end());
            mem[vec] = min(mem[vec], dfs(pp)+10);
        }
    }
    return mem[vec];
}


int main()
{
    int n;
    cin>>n>>A[0]>>A[1]>>A[2];
    sort(A,A+3);
    vector<int> bb(n,0);
    for(int i=0;i< n;++i)
    {
        cin>>bb[i];
    }
    sort(bb.begin(),bb.end());
    cout<<dfs(bb)<<endl;
}

Measured memory_bytes: 640
require 'prime'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times {|i|yield(i)}                    end
def repl(st,en,n=1);       n*= -1 if st>en;st.step(en,n){|i|yield(i)} end

n = gif
a,b = 1, 1
rep n do
  x,y = gi
  m = [(a+x-1)/x, (b+y-1)/y].max
  a = m * x
  b = m * y
end
puts (a + b)


Measured memory_bytes: 2300
def kitai(n):
  return (int(n)+1)/2

import numpy as np
n,k=map(int,input().split())

L=np.array([list(map(kitai, input().split()))]).reshape(-1)

from itertools import accumulate

acc = [0]+ list(accumulate(L)) # 0を忘れずに
ans = 0
for i in range(n-k+1):
  ans = max(ans,acc[i+k]-acc[i])
print(ans)


Measured memory_bytes: 32424
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	ll h,w;
	cin >> h >> w;
	ll ans=h*w;
	for(int k=0;k<2;k++){
		for(ll i=1;i<=h;i++){
			ll tmp;
			ll sa,sb,sc;
			ll sm,sM;
			sa=i*w;
			sb=(h-i)/2*w;
			sc=h*w-(sa+sb);
			sM=max({sa,sb,sc});
			sm=min({sa,sb,sc});
			tmp=sM-sm;
			sb=(h-i)*(w/2);
			sc=h*w-(sa+sb);
			sM=max({sa,sb,sc});
			sm=min({sa,sb,sc});
			tmp=min(tmp,sM-sm);
			ans=min(tmp,ans);
		}
		ll c=h;
		h=w;
		w=c;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

const double pi=3.1415;
ll absc(ll a,ll b){return (a-b>0?a-b:b-a);
}
ll mini(ll a,ll b){return (a>b?b:a);}
ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	return (a%b?gcd(a%b,b):b);
}
ll gojou(ll n){return pow(n,5);}
int main()
{
   ll a,b,c,k,ans=0;
   bool f=true;
   string s,t;
   cin>>a>>b>>c>>k;
   if(a<=k){ans+=a;k-=a;}
   else{cout<<k;return 0;}
   if(b<=k){k-=b;}
   else{cout<<ans;return 0;}
   if(k>0)ans-=k;
   else{cout<<ans-k;return 0;}
   cout<<ans;
}


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


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

    vector<int> s(n);
    rep(i,n) {
        cin >> s.at(i);
    }

    sort ( s.begin(), s.end());

    int first,second,third;
    int counter=0;

    rep (i,n-2) {

        first = s.at(i);

        for ( int j=i+1; j<n-1; j++) {
            second = s.at(j);

            for ( int k=j+1; k<n; k++ ) {
                third = s.at(k);

                if ( first + second > third) {
                    counter++;
                }
                else { break;}

            }

            
        }


    }

    cout << counter << endl;


    
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let s = get!(String);
    let mut t = Vec::new();
    for c in s.chars() {
        match c {
            '0' | '1' => {
                t.push(c);
            }
            _ => {
                if !t.is_empty() {
                    let idx = t.len() - 1;
                    t.remove(idx);
                }
            }
        }
    }
    println!("{}", t.into_iter().collect::<String>());
}

Measured memory_bytes: 4352
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
//#include <math>
using namespace std;
typedef long long ll;
int sum(int n){
  if(n==1) return 1;
  else return n+sum(n-1);
}
int main(){
  int n, m;

  cin >> n >> m;
  cout << sum(m-n)-m <<endl;


  
  return 0;
}

Measured memory_bytes: 256
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
int N,M;
char A[55][55],B[55][55];

int main()
{
    //std::ios::sync_with_stdio(false);
    scanf("%d%d", &N, &M);
    for(int i=0;i<N;i++) scanf("%s", &A[i]);
    for(int i=0;i<M;i++) scanf("%s", &B[i]);
    bool now = false;
    for(int i=0;i<N;i++)
    {
        int index = i,j=1, loc = strstr(A[index], B[0])-A[index];
        if(loc<0) continue;
        else now = true, index++;
        for(j;j<M;j++)
        {
            int cnt = strstr(A[index],B[j])-A[index];
            if(cnt>=0)
            {
                while(cnt!=loc && cnt<N && cnt>=0)
                {
                    cnt = strstr(A[index]+cnt+1, B[j]) - A[index];
                }
                if(cnt==loc) index++;
                else 
                {
                    now = false;
                    break;
                }
            }
            else
            {
                now = false;
                break; 
            }
        }
        if(j!=M) now = false;
        if(now) break;
    }
    if(now) puts("Yes");
    else puts("No");
    //system("pause");
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k; vector<int>rsp(4); string t;
	cin>>n>>k>>rsp['s'%7]>>rsp['p'%7]>>rsp['r'%7]>>t;
	int64_t ans=0;
	for(int i=0;i<n;++i){
		if(t[i]=='-')break;
		char prev='-';
		for(int j=i;j<n;j+=k){
			char&a=t[j];
			if(prev==a)prev='-';
			else{
				ans+=rsp[a%7];
				prev=a;
			}
			a='-';
		}
	}
	cout<<ans<<"\n"s;
}

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

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    if(n==1) {
        cout << "Hello World" << endl;
    } else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >> breads >>= print . solve 

solve :: [Int] -> Int 
solve  = sum . fmap mf . group . sort
    where
        mf xs@(x : _)
            | x > l = l
            | otherwise = l - x
            where
                l = length xs

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)

Measured memory_bytes: 16764
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n,a,b = myinput()

x = a + b

ans = (n//x) * a

if n%x <= a:
    ans += n%x
else:
    ans += a

print(ans)

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

int main()
{
	int a, b, c;
	
	scanf("%d%d%d", &a, &b, &c);
	if (a > b) {
		swap(a, b);
	}
	if (a > c) {
		swap(a, c);
	}
	if (b > c) {
		swap(b, c);
	}
	if (a == 5 && b == 5 && c == 7) {
		puts("YES");
	} else {
		puts("NO");
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;
#define INF 100000;

int main(void){

    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    int other = INF;
    int total = 0;
    for(int i = 0;i < n;i++) {
        cin >> m[i];
        total += m[i];
        other = min(other, m[i]);
    }

    x -= total;

    cout << n + x/other << endl;


    return 0;
}

Measured memory_bytes: 256