akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> pil;
#define ls i << 1
#define rs i << 1 | 1
class RangeUpdateSegmentTree {
   private:
    struct node {
        int l, r;
        ll adt = 0;
        ll x = 0;
    };
    vector<node> a;
    void push(int i) {
        if (a[i].adt) {
            a[ls].adt += a[i].adt, a[rs].adt += a[i].adt;
            //a[ls].x += a[i].adt, a[rs].x += a[i].adt;
            a[i].adt = 0;
        }
    }
    void pull(int i) {
        a[i].x = max(a[ls].x + a[ls].adt, a[rs].x + a[rs].adt);
    }
    void build(int l, int r, int i) {
        a[i].l = l, a[i].r = r;
        if (l == r) return;
        int mid = (l + r) >> 1;
        build(l, mid, ls), build(mid + 1, r, rs);
    }
   public:
    RangeUpdateSegmentTree(int n) : a(n << 2) {
        build(0, n, 1);
    }
    void add(int l, int r, ll val, int i = 1) {
        if (a[i].l >= l && a[i].r <= r) {
            a[i].adt += val;
            return;
        }
        push(i);
        int mid = (a[i].l + a[i].r) >> 1;
        if (l <= mid) add(l, r, val, ls);
        if (r > mid) add(l, r, val, rs);
        pull(i);
    }
    ll maxx(int l, int r, int i = 1) {
        if (l <= a[i].l && a[i].r <= r) return a[i].x + a[i].adt;
        push(i);
        ll ret = -9e18;
        int mid = (a[i].l + a[i].r) >> 1;
        if (l <= mid) ret = max(ret, maxx(l, r, ls));
        if (r > mid) ret = max(ret, maxx(l, r, rs));
        pull(i);
        return ret;
    }
};

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<ll> add(n + 1);
	vector<vector<pil>> del(n + 1);
	for (int i = 0; i < m; i++) {
		int l, r; ll a;
		cin >> l >> r >> a;
		add[l] += a;
		del[r].push_back(pil(l, a));
	}
	RangeUpdateSegmentTree ST(n + 1);
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ST.add(0, i - 1, add[i]);
		ll tmp = ST.maxx(0, i - 1);
		ans = max(ans, tmp);
		ST.add(i, i, tmp);
		for (pil p : del[i])
			ST.add(0, p.first - 1, -p.second);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
int a, b;
vector <bool> v;
int main () {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> a >> b;
	if(a == 1 && b == 2 || a == 2 && b == 1) {
		cout << 3;
	}
	if(a == 2 && b == 3 || a == 3 && b == 2) {
		cout << 1;
	}
	if(a == 1 && b == 3 || a == 3 && b == 1) {
		cout << 2;
	}
	return 0;
}

Measured memory_bytes: 256
s = [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]

k = gets.to_i

puts s[k - 1]


Measured memory_bytes: 3836
#!/usr/bin/env python
import sys

input = sys.stdin

def tax(pct8, pct10):
    pct8low_x10 = pct8 * 125
    if pct8low_x10 % 10 == 0:
        pct8low = pct8low_x10 // 10
    else:
        pct8low = pct8low_x10 // 10 + 1

    pct8high_x10 = (pct8 + 1) * 125

    if pct8high_x10 % 10 == 0:
        pct8high = pct8high_x10 // 10 - 1
    else:
        pct8high = pct8high_x10 // 10

    pct10low = pct10 * 10
    pct10high = (pct10 + 1) * 10 - 1

    if pct8high < pct10low or pct10high < pct8low:
        return -1
    else:
        return max(pct8low, pct10low)

#def test():
#    for i in range(1, 100+1):
#        for j in range(1, 100+1):
#            price = tax(i, j)
#            if price > 0:
#                if int(price *.08) != i or int(price * .1) != j:
#                    print(f"Wrong! tax({i},{j}) -> {price} but price*0.8={int(price*0.08)} and price*0.1={int(price*0.1)}")

pct8, pct10 = map(int, input.readline().split(" "))
print(tax(pct8, pct10))
#test()


Measured memory_bytes: 3064
N = int(input())
c = str(input())

Rcount = 0
Wcount = 0
for i in range(len(c)):
    if c[i] == 'R':
        Rcount += 1
for i in range(Rcount):
    if c[i] == 'W':
        Wcount += 1

print(Wcount)


Measured memory_bytes: 66296
package main

import (
	"fmt"
	"sort"
)

type ByRune []rune

func (r ByRune) Len() int           { return len(r) }
func (r ByRune) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
func (r ByRune) Less(i, j int) bool { return r[i] < r[j] }

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func SortStringByCharacter(s string) string {
	var r ByRune = StringToRuneSlice(s)
	sort.Sort(r)
	return string(r)
}

func count(ss []string) int64 {
	var cnt int64
	cnt = 1
	var ans int64
	sort.Strings(ss)
	n := len(ss)
	// fmt.Println(ss)
	for i := 0; i < n-1; i++ {
		s1 := ss[i]
		s2 := ss[i+1]
		if s1 == s2 {
			cnt++
		} else {
			ans += (cnt * (cnt - 1)) / 2
			// fmt.Println(ss[i], cnt, ans)
			cnt = 1
		}
	}
	if cnt > 1 {
		// fmt.Println(ss[n-1], cnt)
		ans += (cnt * (cnt - 1)) / 2
	}
	return ans
}

func main() {
	var n int
	fmt.Scan(&n)
	ss := make([]string, n)

	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		s = SortStringByCharacter(s)
		ss[i] = s
	}
	fmt.Println(count(ss))
}


Measured memory_bytes: 6528
// atcoder/abc139/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<lli> v(n);
    cin >> v;

    int mx = 0;
    int cnt = 0;
    for (int i = 1; i < v.size(); ++i) {
      if (v[i - 1] >= v[i]) {
        ++cnt;
      } else {
        cnt = 0;
      }
      setmax(mx, cnt);
    }
    cout << mx << endl;
  }

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  set<char> st;
  rep(i, n) st.insert(s[i]);
  for(auto c : t) if(st.find(c) == st.end()) {
    cout << -1 << endl;
    return 0;
  }
  map<char, set<int>> mp;
  rep(i, n) mp[s[i]].insert(i+1);

  ll loop = 0;
  int i = 0;
  for(auto c : t) {
    auto it = mp[c].upper_bound(i);
    if(it != mp[c].end()) i = *it;
    else {
      ++loop;
      i = *mp[c].begin();
    }
  }
  ll ans = (ll)n * loop + i;
  cout << ans << endl;
}


Measured memory_bytes: 5120
#include <stdio.h>
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",(a*b*c)/(gcd(a,b)*gcd(a,b)));
}


Measured memory_bytes: 2724
#include <iostream>
    #include <vector>
    #include <map>
     
    using namespace std;
     
    #define rep(i,n) for(int i=0; i<n; i++)
     
    int main() {
    int n,k;
    cin >> n >> k;
     
    vector<vector<int> > boat(k);
    vector<int> isbad(n+1);
    rep(i,k) {
    int m;
    cin >> m;
    rep(j,m) {
    int bunny;
    cin >> bunny;
    boat[i].push_back(bunny);
    }
    }
     
    map<pair<int, int>, int> table;
    int r;
    cin >> r;
    rep(i,r) {
    int a,b;
    cin >> a >> b;
    table[make_pair(a,b)] = 1;
    table[make_pair(b,a)] = 1;
    }
     
    rep(i,k) {
    rep(j,boat[i].size()) {
    for (int k=j+1; k<boat[i].size(); k++) {
    if (table[make_pair(boat[i][j],boat[i][k])] == 1) {
    isbad[boat[i][j]] = 1;
    isbad[boat[i][k]] = 1;
    }
    }
    }
    }
    int ans = 0;
    rep(i,n+1) {
    if (isbad[i]) {
    ans++;
    }
    }
    cout << ans << endl;
    return 0;
    }

Measured memory_bytes: 1368
#include <vector>
#include <string>
#include <set>
#include <iterator>
#include <unordered_map>
#include <iomanip>
#include <cmath>
#include <limits>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <unordered_set>
#include <fstream>

#define Fill(a, b) memset(a, b, sizeof(a))
typedef long long LL;
const LL inf = 1LL << 61;
const LL mod = 1000000007;

#ifndef DEBUG
#define DEBUG
#endif

#ifdef DEBUG
#define Debug(x) cout << #x << "=" << (x) << endl;
#else
#define Debug(x) ;
#endif

using namespace std;


int main() {
    
    std::ios::sync_with_stdio(false);
    
    bool ok = true;
    int w, h;
    cin >> h >> w;
    vector<string> a(h, "");
    
    unordered_map<char, int> m;
    
    for (int i = 0; i < h; i++) {
        cin >> a[i];
        for (auto c : a[i]) {
            m[c]+=1;
        }
    }
    
    vector<int> cnt(4, 0);
    for (auto &p : m) {
        p.second %= 4;
        cnt[p.second]+=1;
    }
    

    if (w > h) swap(w, h);
    //w <= h
    if (1 == w) {
        if (0 == h%2 && (cnt[1] > 0 || cnt[3] > 0)) {
            ok = false;
        }
        if (1 == h%2 && 1!=(cnt[1] + cnt[3]) ) {
            ok = false;
        }
    } else if (0 == w % 2) {
        if (1 == h%2) {
            if (cnt[1] > 0 || cnt[3] > 0) ok = false;
            if (cnt[2] * 2 > w) ok = false;
        } else {
            if (cnt[1] > 0 || cnt[2] > 0 || cnt[3] > 0) ok = false;
        }
    } else if (1 == w % 2) {
        if (0 == h%2) {
            if (cnt[1] > 0 || cnt[3] > 0) ok = false;
            if (cnt[2] * 2 > h) ok = false;
        } else {
            int t2 = cnt[2] + cnt[3];
            int t1 = cnt[1] + cnt[3];
            if (t1 != 1) ok = false;
            if (t2 * 2 > w+h-2) ok = false;
        }
    }

    
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
   
    public static void main(String args[])throws IOException
    {
       Scanner sc=new Scanner(System.in);
       int a=sc.nextInt();
       int b=sc.nextInt();
       long p=a*b;
      System.out.println((int)p);
    }
}


Measured memory_bytes: 35768
#include <stdio.h>

int main() {
	int n, d, x, a;
	int chocolate = 0;
	scanf("%d %d %d", &n, &d, &x);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &a);
		for(int j = 1; j <= d; j += a, chocolate++)
			;
	}
	printf("%d\n", chocolate + x);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int n, W;
int w[110], v[110];

int main() {
    cin >> n >> W;
    rep(i, n) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n+1, vector<ll>(W+1, 0));
    rep(i, n) {
        repr(j, W) {
            if (j-w[i] >= 0)
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
            else
                dp[i+1][j] = dp[i][j];
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
long long A[200][2][4] = {};

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

    A[0][0][0] = 1;
    for(int i=0; i<N.size(); ++i) {
        for(int j=0; j<2; ++j) {
            for(int k=0; k<4; ++k) {
                int n = (int)(N[i] - '0');
                A[i + 1][j | (n > 0)][k] += A[i][j][k];
                if(k == 3) continue;
                for(int c=1; c<=(j?9:n); ++c) {
                    A[i + 1][j | (n > c)][k + 1] += A[i][j][k];
                }
            }
        }
    }
    cout << A[N.size()][0][K] + A[N.size()][1][K] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int d;
    int t;
    int s;
    scanf("%d %d %d", &d, &t, &s);
    int ans = s * t;
    if (d <= ans) {
        printf ("Yes\n");
    } else {
        printf ("No\n");
    }
}


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

typedef long long ll;

const ll MAX = 5000000;
const ll MOD = 1000000007;
ll fac[MAX + 1], facinv[MAX + 1];
// fac[i] = i!;
// facinv[i] = (i!)^-1 (mod MOD)

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

ll modinv(ll a, ll m) {
  // Need: gcd(a, m) = 1;
  // a^-1(mod. m)は
  // ax+my=gcd(a, m)=1;
  // を満たすxである。(それはそう,両辺をmodを法としてmodを考えてみよう)
  ll x, y;
  extgcd(a, m, x, y);
  return (x % m + m) % m;
}

void COMInit() {
  // O(MAX log MOD)
  fac[0] = 1;
  for (int i = 1; i <= MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
  }
  facinv[MAX] = modinv(fac[MAX], MOD);
  for (int i = MAX - 1; i >= 0; i--) {
    facinv[i] = facinv[i + 1] * (i + 1) % MOD;
  }
}

ll comb(ll n, ll r) {
  //           n!
  // nCr = -----------
  //        r!*(n-r)!
  return (fac[n] * facinv[r]) % MOD * facinv[n - r] % MOD;
}

int main() {
  COMInit();
  ll x, y;
  cin >> x >> y;
  if ((2 * x - y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  if ((2 * y - x) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll a = (2 * x - y) / 3;
  ll b = (2 * y - x) / 3;
  if (a < 0 || b < 0) {
    cout << 0 << endl;
    return 0;
  }
  a %= MOD;
  b %= MOD;
  cout << comb((a + b) % MOD, a) << endl;
}


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

typedef struct {
    int ind;
    int count;
} pair_t;

bool less_pair(pair_t a, pair_t b){
    return a.count > b.count;
}

constexpr long N = 100000;
pair_t obin[N];
pair_t ebin[N];

int main(void){
    for(long i=0; i<N; i++){
        obin[i].ind=i;
        ebin[i].ind=i;
    }
    long n;
    cin >> n;
    vector<long> v(n), o(n/2), e(n/2);
    for(long i=0; i<n; i++){
        cin >> v[i];
    }
    for(long i=0; i<n; i++){
        if(i%2==0){
            o[i/2] = v[i];
            obin[v[i]].count++;
        }else{
            e[i/2] = v[i];
            ebin[v[i]].count++;
        }
    }
    sort(obin, obin+N, less_pair);
    sort(ebin, ebin+N, less_pair);
    /*
       for(long i=0; i<100000; i++){
       if(obin[i].count!=0){
       cout << obin[i].ind << " " << obin[i].count << endl;
       }
       }
       cout << endl;
       for(long i=0; i<100000; i++){
       if(ebin[i].count!=0){
       cout << ebin[i].ind << " " << ebin[i].count << endl;
       }
       }
       */
    if(obin[0].ind != ebin[0].ind){
        cout << n-(obin[0].count+ebin[0].count) << endl;
    }else{
        int co = n/2-obin[0].count;
        int ce = n/2-ebin[0].count;
        int cco = n/2-obin[1].count;
        int cce = n/2-ebin[1].count;
        if(co+cce<=cco+ce){
            cout << co+cce << endl;
        }else{
            cout << cco+ce << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<cstring>
#include<string>

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

int di[4] = {1, 0, -1, 0};
int dj[4] = {0, 1, 0, -1};
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
    int n;
    vector<pair<double, string> > rank;
    while(cin >> n && n!=0){
        rank.clear();
        REP(i,n){
            string l;
            double p, a, b, c, d, e, f, s, m;
            cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            double eff = - (f * s * m - p) / (a + b + c + (d + e) * m );
            rank.push_back(make_pair(eff, l));
        }
        sort(rank.begin(), rank.end());
        REP(i,n) cout << rank[i].second << endl;
        cout << '#' << endl;
    }
    return 0;
}

Measured memory_bytes: 1252
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n;
  cin>>n;
  ll f=0;
  vector<ll>v(n,0);
  set<ll>st;
  multiset<ll>s;
  for(ll i=0;i<n;i++){
    cin>>v[i];
    st.insert(v[i]);
    s.insert(v[i]);
  }
  if(n==3){
    ll ff=0;
    for(ll i=0;i<3;i++){
      if((v[i]^v[(i+1)%3])!=v[(i+2)%3]) ff=1;
    }
    if(ff==0)f=1;
  }
  else{
    if(st.size()==1&&v[0]==0){
      f=1;
    }
    if((n%3)==0){
      if(st.size()==3){
        ll ff=0;
        vector<ll>vv(3,0);
        auto itr=st.begin();
        for(ll j=0;j<3;j++){
          vv[j]=*itr;
          itr++;
        }
        for(ll i=0;i<3;i++){
          if((vv[i]^vv[(i+1)%3])!=vv[(i+2)%3]) ff=1;
        }
        if(ff==0){
          ll fff=0;
          for(ll j=0;j<3;j++){
            if(ll(s.count(v[j]))!=(n/3))fff=1;
          }
          if(fff==0)f=1;
        }
      }
      else if(st.size()==2){
        if(*st.begin()==0){
          if(ll(s.count(*st.begin()))==(n/3))f=1;
        }
      }
    }
  }
  if(f==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 8064
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < S.length(); ++i)
    if (S[i] != T[i]) ++ans;
  cout << ans << '\n';
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
int main (){
  int a,sa=0,d=0;
  cin >>a;
  vector <int> qw(a);
    for (int s=0; s<a;s++){
    cin >>qw.at(s);
    }
  sort(qw.begin(),qw.end());
  reverse(qw.begin(),qw.end());
  for (int s=0; s<a; s+=2){
  sa+=qw.at(s);
  }
  for (int s=1;s<a; s+=2){
  d+=qw.at(s);
  }
  sa-=d;
  cout << sa << endl;
}

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

int main(){
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++)
    cin >> a[i];
  sort(a,a+N);
  cout << a[N-1] - a[0] << endl;
}  

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

#define M_PI       3.14159265358979323846   // pi

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

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

const ull mod = 1000000007;

int main(void)
{
	ll h, w;
	cin >> h >> w;
	vector<vector<ll>> r(h, vector<ll>(w));
	vector<vector<ll>> b(h, vector<ll>(w));
	vector<vector<ll>> diff(h, vector<ll>(w));
	rep(i, h) {
		rep(j, w) cin >> r[i][j];
	}
	rep(i, h) {
		rep(j, w) cin >> b[i][j];
	}
	rep(i, h) {
		rep(j, w) diff[i][j] = abs(r[i][j] - b[i][j]);
	}
	vector<vector<vector<int>>> visit(h,vector<vector<int>>(w,vector<int>(12800, 0)));
	visit[0][0][diff[0][0]] = true;
	for (int y = 1; y < h;y++) {
		for (int k = 0; k < 12800; k++) {
			auto e = visit[y-1][0][k];
			if (e) {
				visit[y][0][k + diff[y][0]] = true;
				visit[y][0][abs(k - diff[y][0])] = true;
			}
		}
	}
	for (int x = 1; x < w; x++) {
		for (int k = 0; k < 12800;k++) {
			auto e = visit[0][x - 1][k];
			if(e){
				visit[0][x][k + diff[0][x]] = true;
				visit[0][x][abs(k - diff[0][x])] = true;
			}
		}
	}
	for (int y = 1; y < h; y++) {
		for (int x = 1; x < w; x++) {
			for (int k = 0; k < 12800; k++) {
				auto e = visit[y][x - 1][k];
				if (e) {
					visit[y][x][k + diff[y][x]] = true;
					visit[y][x][abs(k - diff[y][x])] = true;
				}
			}
			for (int k = 0; k < 12800; k++) {
				auto e = visit[y - 1][x][k];
				if (e) {
					visit[y][x][k + diff[y][x]] = true;
					visit[y][x][abs(k - diff[y][x])] = true;
				}
			}
		}
	}
	for (int k = 0; k < 12800; k++) {
		auto e = visit[h - 1][w - 1][k];
		if(e){
			cout << k << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 324736
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 2019;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
  

   
 void solve() {
	   string s;
	   cin>>s;
	   int len=sz(s);
	   mi mp;
	   int cur=0;
	   mp[0]=1;
	   rep(i,0,len) {
		      cur*=10;
		      cur%=mod;
		      cur+=s[i]-'0';
		      int val=po(10,len-i+1)*cur%mod;
		      mp[val]++; 
		      
		   }
		   int sm=0;
		   for(auto to:mp) 
		     sm+=(to.se*(to.se-1))/2;
		     cout<<sm<<endl;
	   
	   		
						   
 }

    
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


Measured memory_bytes: 3776
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int a=sc.nextInt();
		int b=sc.nextInt();
		int h=sc.nextInt();
		int m=sc.nextInt();

		double angle= Math.abs((double)h/12+((double)m/60)/12.0 -(double)m/60.0)*2*Math.PI;
		double res= (double)a*a +(double)b*b -(double) 2*a*b*Math.cos(angle);
		res =Math.sqrt(res);

        System.out.printf("%.20f",res);
	}

}


Measured memory_bytes: 35948
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<stack>
#include<vector>
#define maxn 10000
#define INF 10000000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;



int main()
{
	ull n,m;
	scanf("%llu%llu",&n,&m);
	if(n == 1|| m ==1)
	{
		printf("1");	
	}else if(n%2 == 0)
	{
		printf("%llu",n/2*m);
	}else{
		printf("%llu",(n+1)/2*m-m/2);
	}
	return 0;
}

Measured memory_bytes: 256
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        Console.WriteLine(Max(0, a - 2 * b));
    }
}


Measured memory_bytes: 11092
#include<stdio.h>

int main()
{
    char c;
    while(1) {
        scanf("%c", &c);

        if(c == '\n') break;

        if('a' <= c && c <= 'z') printf("%c", c - 'a' + 'A');
        else if('A' <= c && c <= 'Z') printf("%c", c - 'A' + 'a');
        else printf("%c", c);
    }
    printf("\n");
}



Measured memory_bytes: 2040
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int n, m; cin >> n >> m;
	vector<vector<int>> v(n);
	rep(i, m){
		int a, b; cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	rep(i, n) cout << v[i].size() << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<lint> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
vvi G;
vi color;
bool dfs(int u, int col)
{
    color[u] = col;
    rep(i, G[u].size())
    {
        int v = G[u][i];
        if (color[v] == col)
        {
            return false;
        }
        if (color[v] == 0 && !dfs(v, -col))
        {
            return false;
        }
    }
    return true;
}
int main()
{
    lint n, m;
    cin >> n >> m;
    G.resize(n);
    color.resize(n);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if (dfs(0, 1))
    {
        lint black = 0;
        lint white = 0;
        rep(i, n)
        {
            if (color[i] == 1)
            {
                black++;
            }
            if (color[i] == -1)
            {
                white++;
            }
        }
        cout << black * white - m << endl;
    }
    else
    {
        cout << (n * (n - 1)) / 2 - m << endl;
    }
    return 0;
}

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

int main()
{
	int x,y;
	while (true) {
		cin >> x >>y;
		if (x == 0 && y == 0) {
			break;
		}
		else if (x <= y) {
			cout << x << " " << y << endl;
		}
		else if(y<x){
			cout << y << " " << x << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int n,m,a,b,dp[3]={-1,-1,-1},ans;
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;
        if(dp[a]!=-1&&dp[a]!=b){
            cout<<-1<<endl;
            return 0;
        }
        dp[a]=b;
    }
    if(dp[0]==0&&n>=2){
        cout<<-1<<endl;
        return 0;
    }
    if(dp[0]==0&&n==1){
        cout<<0<<endl;
        return 0;
    }
    if(dp[0]==-1&&n==1){
        cout<<0<<endl;
        return 0;
    }
    if(dp[0]==-1&&n>=2){
        dp[0]=1;
    }
    for(int i=1;i<=n;i++){
        if(dp[i-1]==-1)dp[i-1]=0;
        if(n-i==0)ans+=dp[i-1];
        if(n-i==1)ans+=dp[i-1]*10;
        if(n-i==2)ans+=dp[i-1]*100;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int f[200005];
int main()
{
    int n,m;
    cin >> n >> m;
    for(int i = 0;i < m;i++)
    {
        int a,b;
        cin >> a >> b;
        if(a == 1&&b == n){cout << "POSSIBLE";return 0;}
        if(a == 1)f[b]+=1;
        if(b == n)f[a]+=300000;
    }
    for(int i = 1;i <= 200000;i++)
    {
        if(f[i]>=300000&&f[i]%300000>0){cout << "POSSIBLE";return 0;}
    }
    cout << "IMPOSSIBLE";
    return 0;
}




Measured memory_bytes: 1024
#pragma GCC optimize ("-O2")
#include <iostream>
#include <bits/stdc++.h>
#include <queue>
#include <stack>
#include <vector>
#define loop(n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef int ll;
const ll Mxn = 21;
const ll md = 1e9 + 7;
const ll Mxd = (1 << 21) + 2;

ll matrix[Mxn];
ll dp[Mxn][Mxd];


ll count(ll m,ll n,ll bitmask)
{
	if(m == n)
		return (__builtin_popcount(bitmask) == n);
	
	if(dp[m][bitmask] != -1)
	{
		return dp[m][bitmask];
	}
		
	ll res = 0;
	for(ll i=0;i<n;i++)
	{
		if(((1 << i) & matrix[m]) && !(bitmask & (1<<i)))
		{
			
			res = (res +  count(m+1,n,bitmask | (1<<i)))%md;
			
			
		}
		
	}
	dp[m][bitmask] = res;
	return res;
}



int main()
{
    //fastio;
    memset(dp,-1,sizeof(dp));
    
    ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		matrix[i] = 0;
		for(ll j=0;j<n;j++)
		{
			int x;
			cin>>x;
			
			if(x)
			{
				matrix[i] |= (1LL << j);
			}
		}
		
	}
		
	
	
	ll res = count(0,n,0);
	cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 175664
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    REP(i,n){
        ll ma = a + i * d - (n - 1 - i) * c;
        ll mi = a + i * c - (n - 1 - i) * d;
        if(mi <= b && b <= ma){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >>  b;
  int s[n];
  int c=0,d=0,e=0;
  for(int i=0;i<n;i++)
    cin >> s[i];
  for(int i=0;i<n;i++){
    if(s[i]<a+1)
      c++;
    else if(s[i]>b)
      e++;
    else
      d++;
  }
  cout << min(min(c,d),e) << endl;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  
  cout << '#';
  for (int i = 0; i < w; i++)
	cout << '#';
  cout << '#' << endl;
  
  for (int j = 0; j < h; j++) {
	string pic;
    cin >> pic;
    cout << '#' << pic << '#' << endl;
  }
  
  cout << '#';
  for (int i = 0; i < w; i++)
	cout << '#';
  cout << '#' << endl;
}



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

int main(){
	ll n,s=0;
  string str;
	cin>>str;
	
	for(int i=0;i<str.size();i++){
		int j=str[i]-48;
		s+=j;
	}
	
//	s=0;
//	
//	while(n!=0){
//		s+=n%10;
//		n/=10;
//	}
//	
	if(s%9==0)
    cout<<"Yes";
    
    else cout<<"No";
    
	

}

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

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  rep(i, 10){
    cout << r*x-D<< endl;
    x = r*x-D;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
using namespace std;
typedef pair<int,int> P;

int main(){
    int n,i;
    cin>>n;
    if(n<1000) cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;
    return 0;
}

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

const int N = 200005;
const int MOD = 998244353;

int n, m, k;
int fact[N];
int ifact[N];

int C(int n, int k) {
  return 1LL * fact[n] * ifact[k] % MOD * ifact[n-k] % MOD;
}

int power(int x, int y) {
  int ret = 1;
  for (; y; y >>= 1) {
    if (y & 1) ret = 1LL * ret * x % MOD;
    x = 1LL * x * x % MOD;
  }
  return ret;
}

int main() {
  scanf("%d %d %d", &n, &m, &k);

  fact[0] = 1;
  for (int i = 1; i <= n; ++i) fact[i] = 1LL * fact[i-1] * i % MOD;
  ifact[n] = power(fact[n], MOD-2);
  for (int i = n-1; i >= 0; --i) ifact[i] = 1LL* ifact[i+1] * (i+1) % MOD;

  int ans = 0;
  for (int i = n-1-k; i < n; ++i) {
    ans = (1LL * C(n-1, i) * m % MOD * power(m-1, i) + ans) % MOD;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 5304
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

struct edge { int to, cost;};
int V;
vector<edge> G[100005];
int d[100005];

void dijkstra(int s){
  priority_queue< pii, vector<pii>, greater<pii> > q;
  fill(d,d+V,INF);
  d[s]=0;
  q.push(pii(0,s));
    
  while(!q.empty()){
    pii p=q.top();q.pop();
    int v=p.second;
    if(d[v]<p.first)continue; //更新されていたら何もしない
    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
	d[e.to]=d[v]+e.cost;
	q.push(pii(d[e.to],e.to));
      }
    }
  }
}


int main(void) {
  int i,j;
  int n;
  cin>>n;
  V=n;
  rep(i,n){
    edge e;
    e.to=((i+1)%n);
    e.cost=1;
    G[i].push_back(e);
    e.to=(10*i)%n;
    e.cost=0;
    G[i].push_back(e);
  }
  dijkstra(1);
  cout<<d[0]+1<<endl;
}


Measured memory_bytes: 6780
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000
#define MAX 200001
#define MOD 1000000007
ll fac[MAX], finv[MAX], inv[MAX];
const int MX = 1000005;

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n;
    cin >> n;
    vector<int> v;
    int cnt_negative = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >>x;
        if (x < 0)
            cnt_negative++;
        v.push_back(abs(x));
    }
    int sum = accumulate(v.begin(), v.end(), 0LL);
    if (cnt_negative % 2 == 0) {
        cout << sum << "\n";
        return 0;
    }
    else {
        sum -= *min_element(v.begin(), v.end()) * 2;
    }
    cout << sum << "\n";
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	if(x == 2){
		cout << 2;
		return 0;
	}

	while(1){
		label:

		if(x % 2 == 0){
			x++;
			continue;
		}

		int n = (int)sqrt(x);

		int i;
		for(i = 3; i <= n; i += 2){
			if(x % i == 0){
				x++;
				goto label;
			}
		}

		break;
	}

	cout << x;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

long k;
long a[50];

int main() {
    scanf("%ld", &k);
    for (int i = 0; i < 50; i++) a[i] = 50 + k / 50;
    for (int i = k % 50; i < 50; i++) a[i] -= (k % 50 + 1);

    printf("50\n");
    for (int i = 0; i < 49; i++) printf("%ld ", a[i]);
    printf("%ld\n", a[49]);

    return 0;
}


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

int main(){
	string sa;
	
	while(getline(cin,sa)){
		
		for(int j=0;j<26;j++){
			int a=sa.size();
		for(int i=0;i<a;i++){
			if(sa[i]>='a'&&sa[i]<='z'){
				sa[i]+=1;
				if(sa[i]>'z'){
					sa[i]-=26;
					}
				}
			}	
			size_t z=sa.find("this");
			size_t za=sa.find("that");
			size_t zb=sa.find("the");
			if(z!=string::npos){break;}
			else if(za!=string::npos){break;}
			else if(zb!=string::npos){break;}
			}
			cout<<sa<<endl;
			
		}
		return 0;
	}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
 
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
 
static const int INF = 1145141919;
const long long INFL = 1LL<<60;
 
int main()
{
	int n, k;
	cin >> n >> k;
	long long int h[110000];
	for (int i = 0; i < n; ++i)
	{
		cin >> h[i];
	}
	long long int dp[110000];
	for (int i = 0; i < 110000; ++i)
	{
		dp[i] = INFL;
	}
	dp[0] = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 1; j <= k; ++j)
		{
			chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1920
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long X){
  if(X>=2000){
    cout << "1" << endl;
    return;
  }
  vi dp(2001);
  dp[0] = 1;
  rep(i,6){
    ll val = 100+i;
    rep(j,2001){
      if(j-val>=0) dp[j] |= (dp[j-val]);
    }
  }
  if(dp[X]) cout << "1" << endl;
  else cout << "0" << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long X;
  scanf("%lld",&X);
  solve(X);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int count = 0;
        for(int i = 1; i < n + 1; i += 2){
            int count2 = 1;
            for(int j = n / 2; j > 0; j--){
                if(i % j == 0){
                    count2++;
                }
            }
            if(count2 == 8){
                count++;
            }
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 25172
#include <iostream>
#include <string>
using namespace std;
int n, a;
bool b[16];


bool pos( int s ) {
    for ( ;s ; s/= 10 ) {
        int d = s%10;
        if ( b[d] ) { return 0; }
    }
    return 1;
}

int main () {
    cin >> a >> n;
    for ( int i = 0 ; i < n ; i ++ ) {
        int c;
        cin >> c;
        b[c] = 1;
    }
    bool canL = 0;

    for ( int ans = a; ; ans ++ ) {
        if ( pos ( ans ) ) { cout << ans << "\n"; return 0; }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int n,a[222222];
ll b[222222];
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)b[i+1]=a[i]+b[i];
	ll x=0,y=2,ans=LLONG_MAX;
	for(int i=2;i<n-1;i++){
		while(b[x+1]<b[i]-b[x+1])x++;
		while(b[y+1]-b[i]<b[n]-b[y+1])y++;
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)
				ans=min(ans,abs(max({b[x+j],b[i]-b[x+j],b[y+k]-b[i],b[n]-b[y+k]})-min({b[x+j],b[i]-b[x+j],b[y+k]-b[i],b[n]-b[y+k]})));
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 2560
A, B, C, X, Y = map(int, input().split())

min_price = A * X + B * Y

if A + B > 2 * C:
    while X > 0 and Y > 0:
        X = X - 1
        Y = Y - 1
        min_price -= A + B - 2 * C

if X > 0 and A > 2 * C:
    while X > 0:
        X = X - 1
        min_price -= A - 2 * C

if Y > 0 and B > 2 * C:
    while Y > 0:
        Y = Y - 1
        min_price -= B - 2 * C

print(min_price)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int n;
long long f[87];
int main()
{
    cin>>n;
    f[0]=2;
    f[1]=1;
    for(int i=2;i<=n;i++)
        f[i]=f[i-1]+f[i-2];
    cout<<f[n]<<endl;
    return 0;
}

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

#define RED 'R'
#define WHITE 'W'

char stone_int_array[200000];

int main()
{
    int n, exchange_num = 0;
    char not_stone;
    char scan_stone;
    int left_counter, right_counter;

    scanf("%d", &n);

    scanf("%c", &not_stone);

    for (int i = 0; i<n; i++)
    {
        scanf("%c", &stone_int_array[i]);

    }

    left_counter = 0;
    right_counter = n-1;

    while (left_counter < right_counter)
    {
        for (; stone_int_array[left_counter] == RED; left_counter++)
        { }

        for (; stone_int_array[right_counter] == WHITE; right_counter--)
        { }

        if (left_counter < right_counter)
        {
            exchange_num ++;
            left_counter ++;
            right_counter --;
        }
    }
    


    printf("%d", exchange_num);

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    string ans;
    if(n == 0){
        ans = "0";
    }else{
        while(n != 0){
            int r = n % (-2);
            n /= (-2);
            if(r < 0) n++;
            ans.push_back('0' + ((r + 2) % 2));
        }
    }
    reverse(begin(ans), end(ans));
    cout << ans << endl;
    return 0;
}

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

signed main() {
  int x, y, z;
  cin >> x >> y >> z;

  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << '\n';
}

Measured memory_bytes: 3580
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

/*
int cost,n;
int V[3000],C[3000];
int dp[1100][1100];
int therock=0;
int tt=0;


int rec(int a,int b){
  int res=0;
  if(a == n){
 if(tt<=res){
      cout << "tt  = " << b+C[a] << endl;
therock=b+C[a];
      tt=res;
    }


return 0;
}
  if(dp[a][b] != -1){
 if(tt<=res){
      cout << "tt  = " << b+C[a] << endl;
therock=b+C[a];
      tt=res;
    }

return dp[a][b];
  }
  
  // cout << "rest =" << therock << endl;
  if(cost<b+C[a]){
 if(tt<=res){
      cout << "tt  = " << b+C[a] << endl;
therock=b+C[a];
      tt=res;
    }

    return 0;
  }
  else{
    res = max(rec(a+1,b),rec(a+1,b+C[a])+V[a]);
    if(tt<=res){
      cout << "tt  = " << b+C[a] << endl;
therock=b+C[a];
      tt=res;
    }
  }
  
  return dp[a][b]= res;

}



int main(){
  int g=1;

  while(1){
    cin >> cost;
    if(cost == 0)break;
    cin >> n;

    for(int i=0;i<n;i++){
      scanf("%d,%d",&V[i],&C[i]);
    }
    memset(dp,-1,sizeof(dp));
    cout << "Case " << g << ":" << endl;
    cout << rec(0,0) << endl;
       
    for(int i=0;i<n;i++){
      for(int j=0;j<cost;j++){
	cout << dp[i][j] << " ";
      }
      cout << endl;
    }

      cout << therock << endl;
    g++;
    therock=0;
  }




}
*/
int n,m;
int V[1100],C[1100];
int dp[1100][1100];
int cc=0;
void solve(){
  for(int i=0;i<m;i++){
    for(int j=0;j<=n;j++){
      if(j<C[i]){
	dp[i+1][j]=dp[i][j];
      }else{
	dp[i+1][j]=max(dp[i][j],dp[i][j-C[i]]+V[i]);
      }
    }
  }
  cout << dp[m][n] << endl;
  for(int i=0;i<=n;i++){
    if(dp[m][i] == dp[m][n]){
      cout << i << endl;
      break;
    }
  }
  


}


int main(){

  int ghc=1;
  while(1){
    cin >> n ;
    if(n == 0)break;
    cin >> m;

    for(int i=0;i<m;i++)scanf("%d,%d",&V[i],&C[i]);
    memset(dp,0,sizeof(dp));
    cout << "Case " << ghc << ":" << endl;
    solve();
    ghc++;
  }


}

Measured memory_bytes: 0