akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=double;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vpll=vector<pll>;
using vvll=vector<vll>;
#define FOR(i,a,b) for(ll i=a;i<(ll)b;++i)
#define ROF(i,a,b) for(ll i=a;i>=(ll)b;--i)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define aa first
#define bb second
#define PB push_back
#define EQ(a,b) (fabs(a-b)<=(fabs(a+b)*EPS))


int main(){
  ios::sync_with_stdio(0);cout.tie(0);cin.tie(0);
  ll n, m;
  cin >> n >> m;
  vector<pair<ll,ll>> ev(2*m);
  F(m) {
    cin >> ev[2*i].aa;
    cin >> ev[2*i + 1].aa;

    ev[2*i].aa = ev[2*i].aa*2 + 1;
    ev[2*i + 1].aa = ev[2*i + 1].aa*2;

    ev[2*i].bb = i;
    ev[2*i + 1].bb = i;
  }
  sort(ev.begin(), ev.end());

  set<ll> open;
  set<ll> del;
  ll res = 0;
  F(2*m) {
    if (del.find(ev[i].bb) != del.end()) continue;
    if (open.find(ev[i].bb) != open.end()) { // must divide
      res ++;
      for (auto j = open.begin(); j != open.end(); ++ j) {
        del.insert(*j);
      }
      open.clear();
    } else {
      open.insert(ev[i].bb);
    }
  }
  cout << res << endl;



  return 0;
}


Measured memory_bytes: 9600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.util.*;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);
    private static final int[][] DIRS = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int a = sc.nextInt();
        String s = sc.next();
        String t = "ABC";
        int res = 0;

        for (int i = 0; i <= s.length() - 3; i++) {
            boolean isEqual = true;
            for (int j = 0; j < 3; j++) {
                if (t.charAt(j) != s.charAt(i + j)) {
                    isEqual = false;
                }
            }
            if (isEqual) { res++; }
        }

        print("" + res);
        System.exit(0);
    }

    static  private void print(String s) {
        System.out.println(s);
    }

    static private int log2(int x) {
        return (int)(Math.log(x) / Math.log(2));
    }

    static private long gcd(long m, long n) {
        if (m < n) { return gcd(n, m); }
        if (m % n == 0) { return n; }
        return gcd(n, m%n);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>

int main()
{
	using namespace std;
	long long a = 0, b = 0, c = 0, d = 0, e = 0, min = 0, ma = 0, ans = 0, count = 0, nagax = 0, nagay = 0, size = 0;
	int once[100020] = {}, info[100020] = {};
	std::string str[150], strs;

	bool okada = false, okada2 = true;
	cin >> a;
	for (int i = 1; i <= a; i++) {
		cin >> str[i];


	}
	for (int i = 2; i <= a; i++) {
		size = str[i - 1].size();
		if (str[i][0] != str[i - 1][size - 1]) {

			cout << "No" << endl;
			return 0;
		}

	}
	for (int i = 1; i <= a - 1; i++) {
		for (int j = i + 1; j <= a; j++) {

			if (str[i] == str[j]) {
				okada2 = false;
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;




}





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

using ll = long long;

using namespace std;

struct uftree {
    int n, *par, *rank, *size;
    uftree(int N) : n(N) {
        par = new int[(size_t)N];
        rank = new int[(size_t)N];
        size = new int[(size_t)N];
        for (int i = 0; i < N; i++) {
            par[i]  = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }
    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            int r         = root(par[x]);
            size[x]       = size[par[x]];
            return par[x] = r;
        }
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y])
            par[y] = x;
        else {
            par[x] = y;
            if (rank[x] == rank[y]) rank[y]++;
        }
        size[x] += size[y];
        size[y] = size[x];
    }
    int get_size(int x) {
        root(x);
        return size[x];
    }
    bool same(int x, int y) { return root(x) == root(y); }

    // 集合の数をカウントする関数
    // 1..nのつもりでやってる場合も0をカウントしちゃうので注意
    int count_sets() {
        int cnt = 0;
        bool used[n];
        fill(used, used+n, false);
        for (int i=0; i<n; i++) {
            if (used[root(i)]) continue;
            cnt++;
            used[root(i)] = true;
        }
        return cnt;
    }
};

using P = pair<int, int>;
#define fi first
#define se second

int main() {
    int n, q;
    long m;
    cin >> n >> m >> q;
    vector<P> multis;
    uftree uft(n);
    for (int i=0, a, b, c; i<q; i++) {
        cin >> a >> b >> c;
        if (c)
            multis.push_back(P{a, b});
        else if (!uft.same(a, b)) {
            uft.unite(a, b);
            m--;
        }
    }
    long s = (long)uft.count_sets();
    long lim = s * (s-1) / 2;
    cerr << s << ' ' << multis.size() << ' ' << lim << ' ' << m << '\n';
    if ((s <= 2 && multis.size() > 0) || lim < (long)m || s-1 > (long)m) {
        cout << "No" << '\n';
        return 0;
    }
    set<int> roots;
    for (auto &p:multis) {
        if (!uft.same(p.fi, p.se)) {
            roots.insert(uft.root(p.fi));
            roots.insert(uft.root(p.se));
        } else {
            cout << "No" << '\n';
            return 0;
        }
    }
    if (roots.size() > 0 && (long)m < s) {
        cout << "No" << '\n';
        return 0;
    }
    cout << "Yes" << '\n';
    return 0;
}

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

int main() {
  int M, N;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  for (int &a : A) {
    cin >> a;
    sum += a;
  }
  int pop = 0;
  double sumdiv = sum * 1.0 / (4 * M);
  for (int &a : A) {
    if (a < sumdiv) {
      continue;
    }
    pop += 1;
  }
  if (pop > M - 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

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

using namespace std;
typedef long long ll;
const ll N=6e5;

ll qz[N],least[N],dis,d[N];
int n,q;

inline ll read()
{
	ll o=0; char ch=' ';
	for(;ch<'0'||ch>'9';ch=getchar());
	for(;ch>='0'&&ch<='9';ch=getchar())o=o*10+ch-48;
	return o;
}

inline int readint()
{
	int o=0; char ch=' ';
	for(;ch<'0'||ch>'9';ch=getchar());
	for(;ch>='0'&&ch<='9';ch=getchar())o=o*10+ch-48;
	return o;
}

inline ll min(ll a,ll b)
{return a<b?a:b;}

inline ll ab(ll o)
{return o>=0?o:-o;}

int main()
{
	cin>>n>>dis;
	fo(i,1,n)d[i]=read();
	qz[0]=dis;
	fo(i,1,n)qz[i]=min(qz[i-1],ab(qz[i-1]-d[i]));
	least[n]=1;
	fd(i,n-1,1)if(-least[i+1]+d[i+1]>=least[i+1])least[i]=least[i+1];
	else least[i]=least[i+1]+d[i+1];
	cin>>q;
	fo(i,1,q){
		int wz=readint();
		if(least[wz]<=qz[wz-1])puts("YES");else puts("NO");
	}
}

Measured memory_bytes: 15232
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
	int r;
	cin >> r;
	cout << r*r*3 << endl;
	
	
	
	return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int n = ri();
	int a[n];
	int64_t sum = 0;
	for (int i = 0; i < n; i++) {
		a[i] = ri();
		sum += a[i];
	}
	int64_t res = 1000000000000000000;
	int64_t cur = 0;
	for (int i = 0; i < n; i++) {
		cur += a[i];
		res = std::min(res, std::abs(cur - (sum - cur)));
	}
	std::cout << res << std::endl;
	
	
	return 0;
}


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

int main() {
  int h,n;
  cin>>h>>n;
  vector<int> dp(h+1,100000005);
  dp[0] = 0;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    rep(j,h+1){
      int nj = min(h,j+a);
      dp[nj] = min(dp[j]+b,dp[nj]);
    }
    
  }
  cout << dp[h] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

ll anl(string s) {
	if (s.size() == 1)return s[0] - '0';
	rep(i, s.size()) {
		if (s[i] == '+') {
			return anl(s.substr(0,i)) + anl(s.substr(i+1));
		}
	}
	rep(i, s.size()) {
		if (s[i] == '*') {
			return anl(s.substr(0, i)) * anl(s.substr(i + 1));
		}
	}
}


bool mtest(string s, ll n) {
	ll ans = anl(s);
	return ans == n;

}

bool ltest(string s, ll n) {
	ll ans = 0;
	ans = s[0] - '0';
	int i = 1;
	range(i,1, s.size()) {
		if (s[i] == '+') {
			ans += s[i + 1]-'0';
		}
		else ans *= s[i + 1]-'0';
		i++;
	}
	return ans == n;
}

void solve(string s, ll n) {
	char c = 'U';
	bool m = mtest(s, n), l = ltest(s, n);
	if (m&&l)c = 'U';
	else if (m)c = 'M';
	else if (l)c = 'L';
	else c = 'I';
	cout << c << endl;
}


int main() {
	string s;
	ll n;
	while (cin >> s) {
		cin >> n;
		solve(s, n);
	}
}


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

vector<pair<long long, long long> > prime_factorize(long long N) {
  vector<pair<long long, long long> > res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0; // 指数

    // 割れる限り割り続ける
    while (N % a == 0) {
      ++ex;
      N /= a;
    }

    // その結果を push
    res.push_back({a, ex});
  }

  // 最後に残った数について
  if (N != 1) res.push_back({N, 1});
  return res;
}


// cout << "hogehoge" << '\n';  // "endl" executes flush in addition to line break.
int main() {
  cin.tie(nullptr);               // Do not flush "cout" when processing "cin".
  // ios::sync_with_stdio(false); // Be careful when using both "cin/cout" and "scanf/printf".

  int n;
  cin >> n;

  const int max = 1e6;

  // 1*1 = 1
  // 2*2 = 4
  // 3*3 = 9
  // 10*10 = 100
  // など、1000までの値を2乗した数をtrueとする
  // vector<int> is_dup(max+1, false);
  // for (int i = 1; i <= 1e3; i++) {
  //   is_dup.at(i*i) = true;
  // }

  vector<int> v(max+1);
  for (int i = 1; i <= max; i++) {
    // i=12 の場合
    //   { {2, 2}, {3, 1} }
    // i=1000 の場合
    //   { {2, 3}, {5, 3} }
    const auto &res = prime_factorize(i);
    int x = 1;
    for (auto p : res) {
      x = x * (p.second+1);
    }
    // // i=100 の場合 is_dup[100] は true である。
    // // そのため、10*10 のケースを考慮し-1する
    // //
    // // i=1 の場合は 1*1 の 1通りのため除かない
    // if (i !=1 && is_dup.at(i)) {
    //   x = x-1;
    // }
    // ある数の組み合わせの数を予め計算する
    v.at(i) = x;
  }

  int ans = 0;
  for (int i = 1; i < n; i++) {
    // cout << i << " : " << v.at(i) << endl;
    ans = ans + v.at(i);
  }
  cout << ans << endl;
  // for (int i = 1; i < n; i++) {
  //   cout << i << " : " << v.at(i) << endl;
  // }
  return 0;
}


Measured memory_bytes: 7124
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
#define ll long long
#define R register
map<int,int>m;
vector<int>v;
int main()
{
    int n,ans,x;
    cin>>n;
    for(R int i=1;i<=n;++i)
    {
        cin>>x;
        if(m[x]==0) v.push_back(x);
        ++m[x];
    }
    for(R int i=0;i<v.size();++i)if(m[v[i]]>=v[i])ans+=m[v[i]]-v[i];else ans+=m[v[i]];
    cout<<ans;
    return 0;
}

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

typedef long long ll;

ll gcd( ll x, ll y );
ll lcm( ll x, ll y );

int main()
{
    int s[10];
    int sum = 0;

    for ( int i = 0; i < 10; ++i ) {
        cin >> s[i];
        sum += s[i];
    }

    cout << sum << endl;

    return 0;
}

ll gcd( ll x, ll y )
{
    if ( y == 0 ) return x;
    return gcd( y, x % y );
}

ll lcm( ll x, ll y )
{
    return x / gcd( x, y ) * y;
}




Measured memory_bytes: 3084
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	string s; cin >> s;
	int res = 0;
	rep(i, 10)rep(j, 10)rep(k, 10)
	{
		int now = 0;
		vector<int> t(3);
		t = { i,j,k };
		for (char x : s)
		{
			if (x - '0' == t[now])++now;
			if (now == 3)
			{
				++res;
				break;
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<cmath>
using namespace std;

int main(){
  int p, q;
  std::cin >> p >> q;
  int gcd = __gcd(p, q), ans = 1;
  p /= gcd;
  q /= gcd;
  set<int> s;
  for (int i = 2; i*i <= q; i++) {
    while(q%i == 0)s.insert(i), q/=i;
  }
  s.insert(q);
  for (auto i: s) {
    ans *= i;
  }
  std::cout << ans << std::endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

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

  int n;cin>>n;
  std::vector<ll> v(n);
  ll sum=0;
  for(int i=0;i<n;i++){
      cin>>v[i];
  }
  ll res=0;
  for(int i=0;i<n;i++){
      sum+=v[i];
      if(i%2){
          if(sum>0) continue;
          res+=abs(1-sum);
          sum=1;
      }
      else{
          if(sum<0) continue;
          res+=abs(-1-sum);
          sum=-1;
      }
  }
  sum=0;
  ll tmp=0;
  for(int i=0;i<n;i++){
      sum+=v[i];
      if(i%2){
          if(sum<0) continue;
          tmp+=abs(-1-sum);
          sum=-1;
      }
      else{
          if(sum>0) continue;
          tmp+=abs(1-sum);
          sum=1;
      }
  }
  cout<<min(res,tmp)<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int t[1005], n[1005], m[1005], s[1005];
int ts[55], te[55], M1[55];
int ans[55];
int num[10005];
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int N, M, r, q;
        cin >> N >> M;
        if(N == 0) break;
        cin >> r;
        for(int i = 1; i <= M; i++) num[i] = 0;
        for(int i = 1; i <= r; i++) {
            cin >> t[i] >> n[i] >> m[i] >> s[i];
        }
        cin >> q;
        for(int i = 1; i <= q; i++) {
            cin >> ts[i] >> te[i] >> M1[i];
            ans[i] = 0;
        }
        for(int time = 540; time <= 1260; time++) {
            for(int i = 1; i <= r; i++) {
                if(t[i] != time) continue;
                if(s[i] == 1) num[m[i]]++;
                else num[m[i]]--;
            }
            for(int i = 1; i <= q; i++) {
                if(ts[i] > time || te[i] <= time) continue;
                if(num[M1[i]] > 0) ans[i]++;
            }
        }
        for(int i = 1; i <= q; i++) cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
n = int(input())
a = list(map(int, input().split()))
a.sort()
res = True
anse = list(i for i in range(1, n, 2))
anso = list(i for i in range(2, n, 2))
if n % 2 != 0:
  if a[0] != 0:
    res = False
    print(0)
  a = a[1:]
  for i in range(0, len(a), 2):
    if a[i] != anso[i//2] or a[i+1] != anso[i//2]:
        print(0)
        res = False
        break


if n % 2 == 0:
    for i in range(0, len(a), 2):
        if a[i] != anse[i//2] or a[i+1] != anse[i//2]:
            print(0)
            res = False
            break

p = 10**9 + 7
if res:
  print(pow(2, n//2, p))

Measured memory_bytes: 20620
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int a, p;

	while(scanf("%d%d", &a, &p)==2)
	{
		int ans=(a*3+p)/2;

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


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <cassert>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

vector<ll> find_all(const std::string str, const std::string subStr) {
    std::vector<ll> result;

    ll subStrSize = subStr.size();
    ll pos = str.find(subStr);

    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }

    return result;
}

int main(){
    string s; cin >> s;
    vector<ll> count(s.length(),0);
    vector<ll> lr = find_all(s, "LR");
    vector<ll> rl = find_all(s, "RL");
    assert(lr.size() + 1 ==rl.size());

    if(lr.size()== 0) {
        double ref = s.size()/2.0;
        if(rl[0]%2 ==0) {
            count[rl[0]] += ceil(ref);
            count[rl[0]+1] += ref;
        } else {
            count[rl[0]] += ref;
            count[rl[0]+1] += ceil(ref);
        }
    } else {
        for(ll i = 0; i <= lr.size(); i++) {
            if(i == 0) {
                ll diff = 0;
                double ref =  ((lr[i]+1-diff)/2.0);
                if ((rl[i])%2 !=0) {
                    count[rl[i]] += ref;
                    count[rl[i]+1] += ceil(ref);
                } else {
                    count[rl[i]] += ceil(ref);
                    count[rl[i]+1] += ref;
                }
            } else if (i == lr.size()){
                ll diff = s.size() - lr[i-1];
                double ref = (diff-1)/2.0;
                if((rl[i]-lr[i-1])%2==0) {
                    count[rl[i]] += ref;
                    count[rl[i]+1] += ceil(ref);
                } else {
                    count[rl[i]] += ceil(ref);
                    count[rl[i]+1] += ref;
                }
            } else {
                ll diff = lr[i] - lr[i-1];
                double ref = diff/2.0;
                if((rl[i]-lr[i-1])%2==0) {
                    count[rl[i]] += ref;
                    count[rl[i]+1] += ceil(ref);
                } else {
                    count[rl[i]] += ceil(ref);
                    count[rl[i]+1] += ref;
                }
            }
        }
    }
    for(ll i = 0; i < s.size(); i++){
        if(i != s.size()-1)
            cout << count[i] << " ";
        else
            cout << count[i] << endl;
    }
}


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

#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ld long double

#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)
#define Fit(i,v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define Fitd(i,v) for(__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))

using namespace std;

const int nm = 110;
const ll inf = 1e12;

string s;
ll nreps;
ll f[nm][30][30];
int n;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    cin >> s >> nreps;
    n = s.length();
    memset(f, 0x3f, sizeof(f));
    for (int i = 0; i < 26; ++i)
    	f[0][i][i] = (s[0] == i + 'a' ? 0 : 1);
    for (int i = 1; i < n; ++i) {
    	for (int j = 0; j < 26; ++j) {
    		for (int k = 0; k < 26; ++k) {
    			int tmp = (s[i] == k + 'a' ? 0 : 1);
    			for (int u = 0; u < 26; ++u) {
    				if (u != k)
    					f[i][j][k] = min(f[i][j][k], f[i - 1][j][u] + tmp);
    			}
    		}
    	}
    }
    ll res = inf;
    if (nreps == 1) {
    	for (int i = 0; i < 26; ++i)
    		for (int j = 0; j < 26; ++j)
    			res = min(res, f[n - 1][i][j]);
    	cout << res << "\n";
    	return 0;
    }
    if (nreps == 2) {
    	for (int i = 0; i < 26; ++i) {
    		for (int j = 0; j < 26; ++j) {
				for (int u = 0; u < 26; ++u) {
					if (j == u)
						continue;
					for (int v = 0; v < 26; ++v)
						res = min(res, f[n - 1][i][j] + f[n - 1][u][v]);
				}
    		}
    	}
		cout << res << "\n";
		return 0;
    }
    for (int i = 0; i < 26; ++i) {
    	for (int j = 0; j < 26; ++j) {
    		if (f[n - 1][i][j] > n)
    			continue;
    		for (int u = 0; u < 26; ++u) {
    			if (u == j)
    				continue;
    			for (int v = 0; v < 26; ++v) {
    				if (v == i)
    					continue;
    				if (f[n - 1][u][v] > n)
    					continue;
    				res = min(res, (nreps + 1) / 2 * f[n - 1][i][j] + nreps / 2 * f[n - 1][u][v]);
    			}
    		}
    	}
    }
    for (int i = 0; i < 26; ++i) {
    	for (int j = 0; j < 26; ++j) {
    		if (f[n - 1][i][j] > n)
    			continue;
    		for (int u = 0; u < 26; ++u) {
    			if (u == j || f[n - 1][u][j] > n)
    				continue;
    			for (int v = 0; v < 26; ++v) {
    				if (f[n - 1][u][v] > n)
    					continue;
    				res = min(res, f[n - 1][i][j] + (nreps - 2) * f[n - 1][u][j] + f[n - 1][u][v]);
    			}
    		}
    	}
    }
    cout << res << "\n";
#ifdef LOCAL
    cout << (double) clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
// #include "ext/pb_ds/assoc_container.hpp"
// #include "ext/pb_ds/tree_policy.hpp"
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 29996224275833
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s=="ABC")
        cout << "ARC";
    else
        cout << "ABC";

}
    


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

int main(){
    ll n; cin >> n;
    map<string,ll> m;
    //mapとは、連想配列を扱うためのライブラリの一つのこと。
    //map<キー型, 値型> 変数名;

    for(ll i=0;i<n;i++){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        m[s]++;
    }

    ll ans=0;
    for(auto p:m){
        ll x=p.second;
        ans+=x*(x-1)/2;
    }
    //for(auto p:m)は、変数mの配列の中からアルファベットが小さい順に参照している。
    //map<キー型, 値型> 変数名;
    //p.firstでキーを、p.secondで値を参照できる。

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

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, d, n);

  int cnt = 0;
  for (int i = 1;; ++i) {
    int x = i;
    int divnum = 0;
    while (x % 100 == 0) {
      x /= 100;
      divnum++;
    }
    if (divnum == d) cnt++;
    if (cnt == n) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N,K,i,j,ct=1,flag=1,max=-1,num;
  char S[100001];
  int flip[100001] = {0};
  scanf("%d %d",&N,&K);
  scanf("%s",S);
  for(i = 0;i < N;i++){
    if(S[i]-'0'!=flag){flip[ct] = i;ct++;flag = 1-flag;}
  }
  if(ct==1){max = N;}
  flip[ct] = N;
  for(i = 1;i < ct;i++){
    if(S[flip[i]]=='0'){
      num = flip[i+2*K > ct?ct:i+2*K]-flip[i-1];
      if(max < num){max = num;}
    }
  }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, mi = INF, ans;
int main() {
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		if (mi > a)ans++;
		mi = min(mi, a);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP=pair<P, int>;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			ans[i]++;
		}
	}
	if (n != 1) ans[n]++;
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}
int x, y, ans = inf;
signed main() {
	cin >> x >> y;
	rep(i, 4) {
		int cnt = 0;
		if (i < 2) {
			x *= -1;
			cnt++;
		}
		if (i & 1) {
			y *= -1;
			cnt++;
		}
		if (x <= y) {
			ans = min(ans, cnt + y - x);
		}
		if (i < 2) x *= -1;
		if (i & 1) y *= -1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

def mcm(sizes, memo, l, r):
    if l == r:
#        print('a:', l, r)
        return 0
    if memo[l][r] >= 0:
#        print('b:', l, r)
        return memo[l][r]
#    print('c:', l, r)
    m = sys.maxsize
    for k in range(l, r):
        m = min (m, mcm(sizes, memo, l, k) + mcm(sizes, memo, k+1, r) + sizes[l][0] * sizes[k][1] * sizes[r][1])
    memo[l][r] = m
    return memo[l][r]

if __name__ == '__main__':
    # Load input
    n = int(input())
    x = []
    for _ in range(n):
        y = tuple(map(int, input().split(' ')))
        x.append(y)
    
    # Create memo:
    memo = []
    for _ in range(n):
        memo.append([-1]*n)
#    print(x)
    print( mcm(sizes = x, memo=memo, l = 0, r = n-1) )

Measured memory_bytes: 7892
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 10005
#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

typedef tuple <ll,int,int> T;
struct edge{int to;ll cost;};
vector<edge> G[SIZE],M[SIZE];
bool used[SIZE];

//0_indexed
ll prim(){
  priority_queue<T,vector<T>,greater<T>> que;
  fill(used,used+SIZE,false);
  rep(i,0,SIZE) M[i].clear();
  ll res = 0;
  que.push(T(0,0,0));
  while(!que.empty()){
    T t = que.top();que.pop();
    ll l = get<0>(t);
    int v = get<1>(t);
    int from = get<2>(t);
    if(used[v])continue;
    res += l;
    used[v] = true;
    M[v].push_back((edge){from,l});
    M[from].push_back((edge){v,l});
    for(edge u : G[v]){
      if(!used[u.to])que.push(T(u.cost,u.to,v));
    }
  }
  return res;
}

void add_edge(int a,int b,ll c){
  G[a].push_back((edge){b,c});
  G[b].push_back((edge){a,c});
}

int V,E;

int main(){
  cin >> V >> E;
  rep(i,0,E){
    int s,t;
    ll w;
    cin >> s >> t >> w;
    add_edge(s,t,w);
  }

  cout << prim() << endl;

  return 0;
}



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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(int &a, int b){
  if(a > b)
    a = b;
}
void chmax(int &a, int b){
  if(a < b)
    a = b;
}

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int n;
  cin >> n;
  
  ll ans = 0;
  
  rep(i, 1, n+1){
    ll a = n/i;
    ans += a*(a+1)*i/2;
  }
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 3572
N=int(input())
ans=N
for i in range(N+1):
    count=0
    t=i#0
    while t>0:
        count+=t%6
        t//=6#last 0
    t=N-i#127
    while t>0:
        count+=t%9
        t//=9
    ans=min(ans,count)
print(ans)

Measured memory_bytes: 3060
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;

int main() {
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n-1; i++) {
		ans += i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  int h, w;cin>>h>>w;
  int dx[]={1, -1, 0, 0}, dy[]={0, 0, 1, -1};
  vector<vector<char>> field(h, vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>field[i][j];
    }
  }
  bool ans=true;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(field[i][j]=='#'){
        bool bad_cell=true;
      	for(int k=0;k<4;k++){
          int x=i+dx[k], y=j+dy[k];
          if((0<=x && x<h) && (0<=y && y<w)){
          	if(field[x][y]=='#'){bad_cell=false;break;}
          }
        }
        if(bad_cell){ans=false;break;}
      }
    }
    if(!ans)break;
  }
  cout<<(ans?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
# frozen_string_literal: true

# ABC 081 B - Shift Only

def judge(arr)
  arr.each do |item|
    return false if item.odd?
  end
  true
end

STDIN.gets
num_list = STDIN.gets.split.map(&:to_i)
count = 0

while judge(num_list)
  num_list = num_list.map do |item|
    item / 2
  end
  count += 1
end

puts count


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 70
int h1, m1, h2, m2, k;

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

    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int a = h1*60+m1, b=h2*60+m2;
    cout << (b-a)-k << "\n";

    return 0;
}


Measured memory_bytes: 3664
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    string s; cin >> s;
    Int K; cin >> K;

    set<string> substr;
    rep(len, 1, K+1) {
        rep(L, 0, s.size()+1-len) {
            substr.insert(s.substr(L, len));
        }
    }

    auto itr = substr.begin();
    rep(i, 0, K-1) ++itr;
    cout << *itr << endl;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[2000005];
ll b[2000005];
int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    for(ll i=1;i<=n;i++){
    	cin>>a[i];
    	a[i]+=a[i-1];
	}
	
    for(ll i=1;i<=m;i++){
    	cin>>b[i];
    	b[i]+=b[i-1];
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		if(a[i]>k){
			break;
		}
		else{
			ll su=k-a[i];
			ll indb=upper_bound(b+1,b+m+1,su)-b;
			indb--;
			ans=max(ans,i+indb);
		}
	}
	
		for(ll i=1;i<=m;i++){
		if(b[i]>k){
			break;
		}
		else{
			ll su=k-b[i];
			ll inda=upper_bound(a+1,a+n+1,su)-a;
			inda--;
			ans=max(ans,i+inda);
		}
	}
	cout<<ans;
	 
	
}
    


	
	
    



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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 998244353;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll n, s;
	cin>>n>>s;
	vector<ll> a(n);
	rep(i,n)cin>>a[i];

	vector<ll> dp(3030,0);
	ll ans=0;
	rep(i,n){
		repr(j,s,a[i]){
			if(j==a[i]){
				dp[j] += i+1;
				dp[j] %= mod;
			}else{
				dp[j] += dp[j-a[i]];
				dp[j] %= mod;
			}
		}
		ans += dp[s];
		ans %= mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int k;
  cin >> k;
  int t = 7%k;
  rep(i,k+5){
    if(t==0){
      cout << i+1 << endl;
      return 0;
    }
    t*=10;
    t+=7;
    t%=k;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3636
/*input
2
3 4

*/
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mod 998244353
#define int long long


signed main() {
	int k,a,b;
	cin>>k>>a>>b;
	int st = a/k;
	if(k*st<a ) st++;
	int end = b/k;
	if(st<=end) cout<<"OK"<<endl;
	else cout<<"NG"<<endl;
}

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

template<class T>
T knapsack(int N, int W, vector<T> v, vector<int> w) {
    vector<vector<T>> dp(N + 1, vector<T>(W + 1, 0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j < w[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            }
        }
    }
    return dp[N][W];
}

int main() {
    int N, W; cin >> N >> W;
    vector<int> v(N), w(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i] >> w[i];
    }
    cout << knapsack(N, W, v, w) << endl;
    return 0;
}


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

const int MN = 100010;

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

int N;
int A[MN];

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

    int sum = 0;
    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        sum ^= (A[i] - 1) & 1;
    }

    if(sum % 2) {
        printf("First");
        return 0;
    }
    if(N == 1) {
        printf("Second");
        return 0;
    }

    int turn = 1;
    while(1) {
        int cnt = 0;
        for(int i = 0; i < N; i++) {
            if(A[i] % 2) cnt++;
        }
        if(cnt > 1) {
            if(turn) printf("Second");
            else printf("First");
            return 0;
        }
        int g = 0;
        for(int i = 0; i < N; i++) {
            if(A[i] % 2) A[i]--;
            g = gcd(g, A[i]);
        }
        sum = 0;
        for(int i = 0; i < N; i++) {
            A[i] /= g;
            if(A[i] == 0) {
                sum = 1;
                break;
            }
            sum ^= (A[i] - 1) & 1;
        }
        if(sum % 2) {
            if(turn) printf("Second");
            else printf("First");
            return 0;
        }

        turn ^= 1;
    }
}


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

const long long MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> b(n, true);
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        b[a] = false;
    }

    vector<long long> dp(n + 1, 0);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        if (b[i + 1]) (dp[i + 1] += dp[i]) %= MOD;
        if (b[i + 2] && i < n - 1) (dp[i + 2] += dp[i]) %= MOD;
    }

    cout << dp[n] % MOD << endl;
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,m;
  cin >> n >> m;
  vector<vll> xyz(n, vll(3));
  REP(i, n){
    REP(j, 3)
    cin >> xyz[i][j];
  }

  ll ans = 0;
  REP(i, (1<<3)){
    vll sum(n, 0);
    REP(k, n){
      REP(j, 3){
        if((i>>j) & 1)
          sum[k] -= xyz[k][j];
        else
          sum[k] += xyz[k][j];
      }
    }

    sort(sum.begin(), sum.end(), greater<ll>());
    ll a = 0;
    REP(k, m)
      a += sum[k];
    ans = max(ans, a);
  }


  cout << ans << endl;
}


Measured memory_bytes: 384
I=N=9**9
P,*L='x+y,',
M,*R='x-y,',
U,*D=[],
for t in[*open(0)][1:]:*z,u=t.split();exec(u+'+=[*map(int,z)],')
for*A,S in(D,U,'x,y,'),(L,R,'y,x,'),(U,R,P+M),(L,D,P+M),(L,U,M+P),(D,R,M+P):
 n=p=-I
 for x,y,r in eval('sorted((%sQ)for Q,P in enumerate(A)for x,y in P)'%S):
  if r:n,p=x,y
  elif x==n:N=min(N,y-p)
print(N%I*5or'SAFE')

Measured memory_bytes: 72640
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [ list(map(int,input().split(" "))) for i in range(n)]
ans = 0
for i in range(n):
    k = 0
    for j in range(m):
        k += a[i][j] * b[j]
    k += c
    if k > 0:
        ans += 1
print(ans)


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

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;

    bool good = true;
    for (int i = 0; i < 3; i++)
    {
        if (S.at(i) == S.at(i + 1))
            good = false;
    }
    if (good == true)
        cout << "Good" << endl;
    else
        cout << "Bad" << endl;
    return 0;
}


Measured memory_bytes: 256
/*
	ID: sixathofpain
	TASK: friday
	LANG: C++   

*/


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
	
    // freopen("friday.in","r",stdin);
    // freopen("friday.out","w",stdout);

    string s;
    cin>>s;
    if(s.back()=='s')
    	s=s+"es";
    else
    	s=s+"s";
    cout<<s<<endl;

    return 0;
}

Measured memory_bytes: 3656
n = int(input())
ans = n
for i in range(n+1):
    cnt = 0
    t = i
    while t > 0:
        cnt += t % 6
        t //= 6
    t = n - i
    while t > 0:
        cnt += t % 9
        t //= 9
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<int>> a(h,vector<int>(w));
    rep(i,h) rep(j,w) cin >> a[i][j];
    
    vector<vector<int>> b(h,vector<int>(w));
    rep(i,h) rep(j,w) b[i][j] = a[i][j];

    int cnt = 0;
    rep(i,h)
        rep(j,w)
        {
            if(i==h-1 && j==w-1) continue;
            int ni = i<h-1 ? i+1 : i  ;
            int nj = i<h-1 ? j   : j+1;

            if(b[i][j]%2==1)
            {
                b[i][j]--;
                b[ni][nj]++;
                cnt++;
            }
        }

    cout << cnt << endl;
    rep(i,h) rep(j,w) b[i][j] = a[i][j];
    rep(i,h)
        rep(j,w)
        {
            if(i==h-1 && j==w-1) continue;
            int ni = i<h-1 ? i+1 : i  ;
            int nj = i<h-1 ? j   : j+1;

            if(b[i][j]%2==1)
            {
                b[i][j]--;
                b[ni][nj]++;
                cout << i+1 << " " << j+1 << " " << ni+1 << " " << nj+1 << endl;
            }
        }

    return 0;
}

Measured memory_bytes: 4096