akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


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

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  std::string S;

  std::cin >> N >> S;

  std::set<std::string> sets;

  std::map<char, int> map;

  for (int i = 0; i < N - 2; i ++)
    map[S[i]] ++;

  std::set<char> set;

  for (int i = N - 1; i >= 2; i --) {
    set.insert(S[i]);

    for (const auto& kv : map)
      for (const auto& c : set) {
        char s[4];

        s[0] = kv.first;
        s[1] = S[i - 1];
        s[2] = c;
        s[3] = '\0';

        sets.insert(s);
      }

    char c = S[i - 2];

    assert(map.count(c));

    if (-- map[c] == 0)
      map.erase(c);
  }

  std::cout << sets.size() << std::endl;;

  return 0;
}


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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

int main() {
    ios::sync_with_stdio(false);

    int p = 37;
    int k = p + 1;
    int n = p*p + p + 1;
    cout << n << " " << k << "\n";
    for (int i = 0; i < p; ++i) {
        for (int j = 0; j < p; ++j)
            cout << i*p + j + 1 << " ";
        cout << n << "\n";
    }
    for (int s = 0; s < p; ++s) {
        for (int i = 0; i < p; ++i) {
            for (int j = 0; j < p; ++j) {
                cout << j*p + (i + s*j) % p + 1 << " ";
            }
            cout << p*p + s + 1 << "\n";
        }
    }
    for (int i = 0; i <= p; ++i)
        cout << p*p + i + 1 << " ";
    cout << "\n";

    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

#define mod 1000000007
#define INF 1000000000
#define SIZE 100000
int check(int *p){
  for(int i=0;i<9-1;i++){
    if(p[i]!=p[i+1]) return false;
    if(p[i+21]!=p[i+22]) return false;
  }

  for(int i=0;i<2;i++){
    if(p[i+9]!=p[i+10]) return false;
    if(p[i+12]!=p[i+13]) return false;
    if(p[i+15]!=p[i+16]) return false;
    if(p[i+18]!=p[i+19]) return false;
  }

  return true;
}

void swap_p(int *p,int a,int b){
  swap(p[a-1],p[b-1]);
}

void rotate(int *p,int x){
  switch(x){
  case 0:
    swap_p(p,15,16);
    swap_p(p,1,28);
    swap_p(p,2,29);
    swap_p(p,3,30);
    swap_p(p,19,21);
    break;
  case 1:
    swap_p(p,13,18);
    swap_p(p,7,22);
    swap_p(p,8,23);
    swap_p(p,9,24);
    swap_p(p,10,12);
    break;
  case 2:
    swap_p(p,12,19);
    swap_p(p,3,22);
    swap_p(p,6,25);
    swap_p(p,9,28);
    swap_p(p,13,15);
    break;
  case 3:
    swap_p(p,10,21);
    swap_p(p,1,24);
    swap_p(p,4,27);
    swap_p(p,7,30);
    swap_p(p,16,18);
    break;
  }
}
  
int cc=0;

int dfs(int *p,int h=0){
  int p2[30],ret =INF;
  
  /*check*/
  if(check(p)) return h;
  if(h>8) return INF;

  for(int i=0;i<4;i++){
    for(int j=0;j<30;j++){
      p2[j] = p[j];
    }
    rotate(p2,i);

    ret = min(dfs(p2,h+1),ret);
  }
 
  return ret;
}

int main(){
  int n,p[30];

  scanf("%d",&n);
  
  for(int i=0;i<n;i++){
    for(int j=0;j<30;j++) scanf("%d",&p[j]);
    
    printf("%d\n",dfs(p));
  }
  
  return 0;
}

Measured memory_bytes: 1188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		long a = p[0];
		long b = p[1];
		if(a > b)
		{
			var c = a;
			a = b;
			b = c;
		}
		for (int i = 1; i <= a; i++)
		{
			if (b * i % a == 0)
			{
				Console.WriteLine(b*i);
				return;
			}
		}
		//Console.WriteLine(q);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13140
program abc126f
  implicit none
  integer :: m, k, i
  integer,allocatable :: b(:), c(:)

  read *, m, k
  if (m == 0) then
     if (k == 0) then
        print *, '0 0'
     else
        print *, '-1'
     end if
  else if (m == 1) then
     if (k == 0) then
        print *, '0 0 1 1'
     else
        print *, '-1'
     end if
  else if (k >= 2**m) then
     print *, '-1'
  else
     b = [(i,i=0,2**m-1)]
     b = pack(b,b/=k)
     c = [(i,i=2**m-1,0,-1)]
     c = pack(c,c/=k)
     print *, [b,k,c,k]
  end if
end program abc126f


Measured memory_bytes: 6524
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <unordered_map>
#include <array>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <random>
#include <numeric>

#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const int INFINT_LIM = (1LL << 31) - 1;              // 2.15x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62);  // 9.22x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const double PI = 3.141592653589793238462643383279;


const int MAX_N = 100000;
int N;
int A[MAX_N];

int main() {
  cin >> N;
  rep(i, N) cin >> A[i];

  sort(A, A+N);
  reverse(A, A+N);

  ll a = 0, b = 0;
  for (int i = 0; i < N-1; ++i) {
    if (a != 0 && b != 0) break;
    if (A[i] == A[i+1]) {
      if (a == 0) a = A[i];
      else b = A[i];
      ++i;
    }
  }

  cout << a*b << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long 
#define float long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

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__) << "] "
 
signed main(){
	IOS;
	int n ; 
	cin >> n; 
	map<string,int>mp;
	for(int i=0;i<n;i++){
		string s; 
		cin >> s; 
		mp[s]++;
	}
	string ans ="";
	int val = 0 ;
	for(auto ir : mp) val = max(val,ir.second);
	for(auto ir : mp){
		if(ir.second == val) ans+=ir.first+'\n';
	}
	debug() << imie(val) imie(range(mp.begin(),mp.end())) ;
	cout << ans ; 
	return 0;
}







Measured memory_bytes: 25732
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n[40];
int dp[40] = {0};

int input(){
    int i=0;
    while(1){
        int x;
        cin >> x;
        if(x == 0) break;
        n[i] = x;
        i++;
    }
    return i;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sz = input();
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 4;
    for(int i=1;i<31;i++){
        dp[i+3] = dp[i] + dp[i+1] + dp[i+2];
    }
    for(int i=0;i<sz;i++){
        cout << (dp[n[i]]%3650>0 ? dp[n[i]] / 3650 + 1 : dp[n[i]] / 3650) << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            var counter = 1;
            while (true)
            {
                var x = int.Parse(Console.ReadLine());
                if (x == 0)
                {
                    break;
                }
                Console.WriteLine("Case " + counter + ": " + x);
                counter++;
            }
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

int dp[100001][4];

void solve() {
  rep(i, 100001) rep(j, 4) dp[i][j] = -1e9;
  dp[0][0] = 0;
  int N;
  cin >> N;
  rep(i, N) {
    int a, b, c;
    cin >> a >> b >> c;
    amax(dp[i + 1][1], dp[i][0] + a);
    amax(dp[i + 1][1], dp[i][2] + a);
    amax(dp[i + 1][1], dp[i][3] + a);
    amax(dp[i + 1][2], dp[i][0] + b);
    amax(dp[i + 1][2], dp[i][3] + b);
    amax(dp[i + 1][2], dp[i][1] + b);
    amax(dp[i + 1][3], dp[i][0] + c);
    amax(dp[i + 1][3], dp[i][1] + c);
    amax(dp[i + 1][3], dp[i][2] + c);
  }
  int ans = -1e9;
  amax(ans, dp[N][1]);
  amax(ans, dp[N][2]);
  amax(ans, dp[N][3]);
  cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a == 0 && b == 0){break;}
			for(int i = 0; i < a; i++){
				String s = "";
				for(int k = 0; k < b; k++){
					if((i + k) % 2 == 0){
						s += "#";
					}else{
						s += ".";
					}
				}
				System.out.println(s);
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 55652
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;

int main(int argc,char const* argv[])
{
  int n,w;
  while(1)
    {
      vector<double> v(110,0.0);
      cin >> n >> w;
      if(!n) break;
      double vmax=0.0;
      double kukan=0.0;
      for(int i=0;i<n;i++)
	{
	  int tmp;
	  cin >> tmp;
	  if((tmp/w)+1>kukan)
	    {
	      kukan=tmp/w+1.0;
	    }
	  v[tmp/w]++;
	}
      kukan-=1.0;
      for(int i=0;i<105;i++)
	{
	  if(v[i]>vmax) vmax=v[i];
	}
      double ans=0.0;
      for(int i=0;i<=kukan;i++)
	{
	  ans+=((double)(kukan-i)/kukan)*(v[i]/vmax);
	}
      ans+=0.01;
      cout << fixed << setprecision(9) << ans << endl;
    }
  return 0;
}



Measured memory_bytes: 3196
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;
 
int n;
 
const int maxn = 1e6 + 5;
 
int trie[maxn][2];
char s[maxn];
long long L;
int tot;
bool vis[maxn];
void insert(char *str, int len){
    int cur = 0;
    for(int i = 0;i < len;i++){
        int ch = str[i] - '0'; 
        if(trie[cur][ch] == -1){
            trie[cur][ch] = ++tot;
            memset(trie[tot], -1, sizeof(trie[tot]));
        }
        cur = trie[cur][ch];
    }
    vis[tot] = true;
}
 
long long dfs(int u, long long depth){
    //cout << u << " " << depth << endl;
    if(u == -1){
        long long tmp = L + 1 - depth;
        return (tmp & (-tmp));
    }
    if(vis[u]){
        return 0;
    } 
    long long ans = 0;
    ans ^= dfs(trie[u][0], depth + 1);
    ans ^= dfs(trie[u][1], depth + 1);
    return ans;
}
 
 
int main(){
    cin >> n >> L;
    tot = 0;
    memset(trie[tot], -1, sizeof(trie[tot]));
    memset(vis, false, sizeof(vis));
    for(int i = 1;i <= n;i++){
        scanf("%s", s);
        int len = strlen(s);
        insert(s, len);
    }
    long long res = dfs(0, 0);
    if(res != 0){
        cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }
    return 0;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

struct Edge {
  int dst;
  long long cost;
  Edge() {}
  Edge(int x, long long y) : dst(x), cost(y) {}
};

std::vector<long long> dijkstra(int start_v, std::vector<std::vector<Edge>> &G, int L) {
  const long long LINF = 1000000000000000018LL;

  int n = (int)G.size();
  std::vector<std::pair<long long, long long>> dist(n, std::make_pair(LINF, 0));

  dist[start_v] = std::make_pair(0, 0);

  // ((補給回数, 消費燃料), 頂点)
  typedef std::pair<std::pair<long long, long long>, int> P;
  std::priority_queue<P, std::vector<P>, std::greater<P>> que;

  que.push(std::make_pair(std::make_pair(0LL, 0), start_v));

  while (!que.empty()) {
    P now = que.top();
    que.pop();

    int cur_vertex = now.second;
    long long num_charge = (now.first).first;
    long long use_charge = (now.first).second;

    if (now.first > dist[cur_vertex]) {
      continue;
    }

    for (int i = 0; i < (int)G[cur_vertex].size(); i++) {
      int nxt_vertex = G[cur_vertex][i].dst;
      long long cost = G[cur_vertex][i].cost;

      if (cost > L) {
        continue;
      }

      long long nxt_used = use_charge + cost;
      std::pair<long long, long long> nxt_p;
      if (nxt_used > L) {
        nxt_p = {num_charge + 1, cost};
      } else {
        nxt_p = {num_charge, nxt_used};
      }
      if (nxt_p < dist[nxt_vertex]) {
        dist[nxt_vertex] = nxt_p;
        que.push(std::make_pair(nxt_p, nxt_vertex));
      }
    }
  }

  std::vector<long long> res(n);
  for (int i = 0; i < n; i++) {
    res[i] = dist[i].first;
  }

  return res;
}

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

  const long long LINF = 1000000000000000018LL;

  int N, M, L;
  std::cin >> N >> M >> L;

  std::vector<std::vector<Edge>> Graph(N);

  for (int i = 0; i < M; i++) {
    int A, B, C;
    std::cin >> A >> B >> C;
    --A, --B;
    Graph[A].push_back(Edge(B, C));
    Graph[B].push_back(Edge(A, C));
  }

  std::vector<std::vector<long long>> ans(N, std::vector<long long>(N, LINF));

  for (int start_v = 0; start_v < N; start_v++) {
    auto dist = dijkstra(start_v, Graph, L);
    for (int i = 0; i < N; i++) {
      ans[start_v][i] = dist[i];
      ans[i][start_v] = dist[i];
    }
  }

  int Q;
  std::cin >> Q;

  while (Q--) {
    int s, t;
    std::cin >> s >> t;
    --s, --t;
    cout << (ans[s][t] == LINF ? -1 : ans[s][t]) << "\n";
  }

  return 0;
}

Measured memory_bytes: 7852
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define si scanf
#define so printf
#define N 100100
#define M 
#define INF  
template<typename TP>inline bool rd(TP& r)
{
	r=0;
	char tmp=getchar();
	while(tmp<'0'||tmp>'9')
	{
		if(tmp==EOF)
			return 0;
		tmp=getchar();
	}
	while('0'<=tmp&&tmp<='9')
	{
		r=(r<<3)+(r<<1)+tmp-'0';
		tmp=getchar();
	}
	return 1;
	
} 
int n;
long long L;
int ch[N][2],f[N],c[N],tot=1;
bool ed[N];
int s[N];
void trie()
{
	int now=1;
	for(int i=1;i<=s[0];++i)
	{
		if(ch[now][s[i]]==0)
		{
			ch[now][s[i]]=++tot;
			f[tot]=now;
			c[tot]=s[i];
		}
		now=ch[now][s[i]];
	}
	ed[now]=1;
}
long long ans=0;
long long calc(long long dp)
{
	int t=0;
	while((dp&1)==0)
	{
		++t;
		dp>>=1;
	}
	return 1<<t;
}
int d[N];
void dfs(int now)
{
	d[now]=d[f[now]]+1;
	if(ed[now])
		return;
	if(ch[now][0]==0)
		ans^=calc(L-d[now]+1);
	else
		dfs(ch[now][0]);
	if(ch[now][1]==0)
		ans^=calc(L-d[now]+1);
	else
		dfs(ch[now][1]);
}
int main()
{
	rd(n),rd(L);
	char in[N];
	int lth;
	for(int i=1;i<=n;++i)
	{
		si("%s\n",in+1);
		lth=strlen(in+1);
		for(int j=1;j<=lth;++j)
			s[j]=in[j]-'0';
		s[0]=lth;
		trie();
	}
	d[1]=0;
	dfs(1);
	if(ans)
		so("Alice\n");
	else
		so("Bob\n");
	return 0;
} 

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

const int MX = 1e5 + 5;

const int NINF = -1e9;
vector<vector<int>> arr;
int dp[MX][3];
int N;
int K = 3;

int solve(int x, int p1) {
    if (x >= N) return 0;
    if (p1 != -1 && dp[x][p1] != -1) return dp[x][p1]; 

    int res = NINF;
    for (int i = 0; i < K; i++) {
        if (p1 == i) continue;
        res = max(res, arr[i][x] + solve(x + 1, i));
    }

    if (p1 != -1) dp[x][p1] = res;
    return res;
}

int main() {
    memset(dp, -1, sizeof(dp));
    cin >> N;

    arr = vector<vector<int>>(K, vector<int>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < K; j++) {
            cin >> arr[j][i];
        }
    }
    
    cout << solve(0, -1) << "\n";
}



Measured memory_bytes: 10364
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

#define INFL (1LL << 60)

using namespace std;

typedef long long ll;

int main() {
    ll x, y, z, k;
    scanf("%lld%lld%lld%lld", &x, &y, &z, &k);
    vector<ll> a(x + 1), b(y + 1), c(z + 1), abc;
    abc.reserve(k);
    a.at(0) = (b.at(0) = (c.at(0) = INFL));
    for (ll i = 1; i <= x; ++i) scanf("%lld", a.begin() + i);
    for (ll i = 1; i <= y; ++i) scanf("%lld", b.begin() + i);
    for (ll i = 1; i <= z; ++i) scanf("%lld", c.begin() + i);
    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    sort(c.begin(), c.end(), greater<ll>());
    for (ll i = 1; i <= x; ++i) for (ll j = 1; i * j <= k && j <= y; ++j) for (ll h = 1; i * j * h <= k && h <= z; ++h) abc.push_back(a.at(i) + b.at(j) + c.at(h));
    sort(abc.begin(), abc.end(), greater<ll>());
    for (ll i = 0; i < k; ++i) printf("%lld\n", abc.at(i));
    return 0;
}


Measured memory_bytes: 1832
n = int(input())
V = list(map(int,input().split()))
De = {}
Do = {}
for i in range(n):
    x = V[i]
    if i%2==0:
        if x not in De:
            De[x] = 0
        De[x] += 1
    else:
        if x not in Do:
            Do[x] = 0
        Do[x] += 1
DeL = sorted(list(De.items()),key=lambda x:x[1],reverse=True)
DoL = sorted(list(Do.items()),key=lambda x:x[1],reverse=True)
y = DeL[0][0]
z = DoL[0][0]
if y!=z:
    n0 = n//2-De[y]
    n1 = n//2-Do[z]
elif y==z:
    if De[y]>Do[z]:
        z = DoL[1][0]
        n0 = n//2-De[y]
        n1 = n//2-Do[z]
    elif De[y]<Do[z]:
        y = DeL[1][0]
        n0 = n//2-De[y]
        n1 = n//2-Do[z]
    elif De[y]==Do[z]:
        if De[y]==n//2:
            n0 = 0
            n1 = n//2
        elif DeL[1][1]>=DoL[1][1]:
            y = DeL[1][0]
            n0 = n//2-De[y]
            n1 = n//2-Do[z]
        else:
            z = DoL[1][0]
            n0 = n//2-De[y]
            n1 = n//2-Do[z]
print(n0+n1)

Measured memory_bytes: 22368
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,n,maxi=0,f=0,mini=INF,sum=0;
    cin>>a>>b>>c;
    rep(i,100000001){
        sum+=a;
        if(sum%b==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    
    return 0;
}


Measured memory_bytes: 3656
from math import gcd

k = int(input())
sum_ = 0
for a in range(1, k + 1):
  for b in range(1, k + 1):
    gcd_ab = gcd(a, b)
    for c in range(1, k + 1):
      sum_ += gcd(c, gcd_ab)
print(sum_)

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

int n;
string s;

int main(){
	cin >> s;
	n = s.size();
	int ans = 0;
	rep(i, n){
		if(s[i] == s[i+1]){
			if(i == n-2){
				ans++;
				break;
			}
			else{
				ans += 2;
				i += 2;
			}
		} else {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
constexpr long double eps = 1e-9;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, m;
	scanf("%d%d", &n, &m);
	vector<pair<int, int>> ans;
	bool flag = false;
	int cnt = 0;
	for (int l = 1, r = n - 1; l < r; ++l, --r) {
		if (!flag and r - l <= n / 2 and n % 2 == 0)flag = true, --r;
		ans.emplace_back(l, r);
	}
	rep(i, m)printf("%d %d\n", ans[i].first, ans[i].second);

	Please AC;
}


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

#define MAXV 100
#define INF 100000000

int cost[MAXV][MAXV];
int mincost[MAXV];
bool used[MAXV];
int V;

int prim(){
	for(int i=0;i<V;++i){
		mincost[i]=INF;
		used[i]=false;
	}
	mincost[0]=0;
	int res=0;

	while(true){
		int v=-1;
		for(int u=0;u<V;u++){
			if(!used[u]&&(v==-1||mincost[u]<mincost[v])) v=u;
		}

		if(v==-1) break;
		used[v]=true;
		res+=mincost[v];

		for(int u=0;u<V;u++){
			mincost[u]=min(mincost[u],cost[v][u]);
		}
	}
	return res;
}

int main(){
     
	int m;
	int a,b,cot;

	while(1){
		 cin>>V>>m;
		 if(V==0&&m==0) break;
	
		  for(int i=0;i<V;i++){
			   for(int j=0;j<V;j++){
				   cost[i][j]=INF;
			   }
		   }

		   for(int i=0;i<m;i++){
			   cin>>a>>b>>cot;
			   cost[a][b]=cot;
			   cost[b][a]=cot;
		   }

		   cout<<prim()<<endl;
	  }

	 return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define intl long long int 

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	intl n,j,i;
	cin>>n>>j;
	vector<intl> ar(n);
	for(i=0;i<n;i++){
		cin>>ar[i];
	}
	sort(ar.begin(),ar.end());
	intl sum=0;
	for(i=0;i<n-j;i++){
		sum+=ar[i];
	}
	cout<<sum<<"\n";
}


Measured memory_bytes: 1792
h = int(input())
l = [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]
print(l[h-1])

Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int ans = 0;
        for(int i = 0; i < n.length(); i++) {
            if(n.charAt(i) == '2') ans++;
        }
        System.out.println(ans);
    } 
}

Measured memory_bytes: 21716
N=int(input())
from collections import defaultdict
d=defaultdict(list)
f=defaultdict(int)
for _ in range(N-1):
    a,b,c=map(int,input().split())
    d[a].append([b,c,a])
    d[b].append([a,c,b])
Q,K=map(int,input().split())

dist=defaultdict(int)
dist[K]=0
f[K]=1
que=d[K]
prev=defaultdict(int)
prev[K]=0
while len(que)>0:
    tmp=[]
    tmpd=defaultdict(int)
    for t,c,e in que:
        if f[t]==0:
            dist[t]=c+dist[e]
            tmpd[t]=c+dist[e]
            f[t]=1
            tmp+=d[t]
    prev=tmpd
    que=tmp

for _ in range(Q):
    x,y=map(int,input().split())
    print(dist[x]+dist[y])



Measured memory_bytes: 119256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;

	cin >> s;

	int ans = 0;

	rep(i, 0, 4) {
		if (s[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}

	cout << ans << endl;

}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	string s;
	cin>>s;
	
	ll sum = 0;
	for(char c : s) sum = (sum+c-'0') %9;
	
	cout<<(sum ? "No" : "Yes")<<endl;
	
	
	return 0;
}


Measured memory_bytes: 3740
# coding: utf-8
# Your code here!
def prime_factorize(N): #素因数分解
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization

SIZE=110000; MOD=10**9+7 #998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

#n = int(input())
#n,a = [int(i) for i in readline().split()]
n,m = [int(i) for i in readline().split()]

MOD = 10**9+7

ans = 1
L = prime_factorize(m)
for p,e in L:
    ans *= choose(n-1+e,e)
    ans %= MOD


print(ans)












Measured memory_bytes: 16116
#include <stdio.h>

int     main(void)
{
    int a;
    int b;
    int c;
    
    a = 0;
    b = 0;
    c = 0;
    scanf("%d %d %d",&a,&b,&c);
    if(a < b && b < c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return(0);
}


Measured memory_bytes: 2120
#include<iostream>
#include<string>
 using namespace std;
 
int main()
{
	string x;
	cin >> x;
	if(x[0]==x[1]&&x[2]==x[3]&&x[0]!=x[2]){
		cout<<"Yes";
	}
	else if(x[0]==x[2]&&x[1]==x[3]&&x[0]!=x[1]){
		cout<<"Yes";
	}
	else if(x[0]==x[3]&&x[1]==x[2]&&x[0]!=x[1]){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	
	REP(i,n+1) REP(j,m+1){
		if(m*i+n*j-2*i*j==k){
			puts("Yes");
			debug(i,j);
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
"""
X, K , D = map(int, input().split())

ans=1e+15

for i in range(K):
	init_X=X
	init_X+=i*D-(K-i)*D
	if abs(init_X)<ans:
		ans=abs(init_X)

print(ans)
"""
X, K , D = map(int, input().split())

left=X-K*D
right=X+K*D

if left<0<right:
	k=abs(X)//D
	X=abs(X)-D * k
	print(X if (K-k)%2==0 else abs(X-D))

elif right<=0:
	print(-right)
else:
	print(left)

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

int n;
ll a[MAX], b[MAX];

int main()
{
	cin >> n;
	for(int i = 1; i <= n+1; i++) scanf("%lld", &a[i]);
	for(int i = 1; i <= n; i++) scanf("%lld", &b[i]);
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		ll x = b[i], t = a[i];
		ans += min(x, a[i]+a[i+1]);
		a[i] -= min(a[i], x);
		if(x <= t) continue;
		x -= t;
		a[i+1] -= min(a[i+1], x);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    int mi = inf;
    rep(t,n){
        int s=0;
        int p = 0;
        for(int i=0;i<t;i++){
            s += a[i];
        }
        for(int j=t;j<n;j++){
            p += a[j];
        }
        mi = min(mi,abs(s-p));
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 888
# N, K <=200000
# As < N
from collections import Counter
N, K = [int(x) for x in input().split()]
As = [int(x) for x in input().split()]

counter = Counter()
for a in As:
    counter[a]+=1

B = sorted([(v, k) for k, v in counter.items()])

print(sum(v for v, k in B[:max(0, len(counter)-K)]))


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

int main(){
    int n;
    cin >> n;
    int cnt=1;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    bool flag=true,up;
    for(int i=0; i<n-1; i++){
        if(a[i]!=a[i+1]&&flag){
            if(a[i]<a[i+1])up=true;
            else up=false;
            flag=false;
        }else if(!flag){
            if(up&&a[i]>a[i+1]){
                cnt++;
                flag=true;
            }else if(!up&&a[i]<a[i+1]){
                cnt++;
                flag=true;
            }
        }
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int bp(int b, int p);

int main(void){
    int x;
    int b, p = 0;
    int max = 1;

    scanf("%d", &x);

    for(b = 2; b*b <= x; b++){
        while(bp(b, p) <= x){
            max = (max<bp(b, p)) ? bp(b, p) : max;
            p++;
        }
        p = 0;
    }
    printf("%d\n", max);

    return 0;
}

int bp(int b, int p){
    int k;
    int re = 1;

    for(k = 0; k < p; k++){
        re = re * b;
    }
    return re;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N;
  	cin>>N;
  	string s;
  	cin>>s;
  	int count =0;
  	for(int i =0; i<=(N-3);i++)
    {
      if(s[i]=='A' && s[i+1] == 'B' && s[i+2]=='C')
        count++;
    }
  cout<<count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

static const int N=101;
static const int W=10010;
int dp[N+1][W+1];

int main(){
  int n,c;
  cin>>n>>c;
  int v[N],w[N];
  for(int i=0;i<n;i++){
    cin>>v[i]>>w[i];
  }
  for(int i=0;i<=c;i++){
    dp[0][i]=0;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<=c;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]);
      }
    }
  }

  cout<<dp[n][c]<<endl;

  return 0;
}



Measured memory_bytes: 7044
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  string s;
  cin >> n >> m >> s;
  vector<int> sugoroku;
  bool yes = true;
  for(int i=0;i<n+1;i++) {
    if(s[i] == '0') sugoroku.emplace_back(i);
  }
  int si = sugoroku.size();
  vector<int> turn(si);
  for(int i=si-1;i>=0;i--) {
    if(i == si - 1) {
      turn[i] = 0;
      continue;
    }
    auto it = upper_bound(sugoroku.begin(), sugoroku.end(), sugoroku[i] + m);
    it = prev(it);
    int dist = distance(sugoroku.begin(), it);
    if(dist == i) {
      yes = false;
      break;
    }
    turn[i] = turn[dist] + 1;
  }
  if(!yes) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> ans;
  int pre = 0;
  int target = turn[0] - 1;
  for(int i=0;i<si;i++) {
    if(turn[i] != target) continue;
    else {
      target--;
      ans.emplace_back(sugoroku[i] - sugoroku[pre]);
      pre = i;
    }
  }
  for(auto& el : ans) cout << el << endl;
  return 0;
}


Measured memory_bytes: 1976
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int coudp[100001];

int main() {
	string s;
	cin >> s;
	int a = 0, b = 0;
	for (int i = 0;i < 3;++i) {
		if (s[0] == s[2 - i]) {
			++a;
		}
		if (s[3] == s[i + 1]) {
			++b;
		}
	}
	if (a > 2 || b > 2) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
tmp = M // N
ansMax = 0
y = []
for i in range(1, (int(M ** (0.5)) + 1)):
    if M % i == 0:
        y.append(i)
        if i != M // i:
            y.append(M // i)
y.sort()

for i in y:
    if i <= tmp:
        ansMax = i
    else:
        break
print(ansMax)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int power(int x, int y, int p = mod){ 
    int res = 1; 
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0) {  
        if (y & 1) res = (res*x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
} 
int modFact(int n, int p = mod) 
{ 
    if (n >= p) 
        return 0; 
  
    int result = 1; 
    for (int i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result; 
} 
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n - 1; ++i){
        cin >> arr[i];
    }
    vector<int> ans(n, INF);
    for(int i = 0; i < n - 1; ++i){
        ans[i] = min(ans[i], arr[i]);
        ans[i + 1] = min(arr[i], ans[i + 1]);
    }
    int res = 0;
    for(int x: ans) res += x;
    cout << res ;
}
// check indices of loop
// check for overflow


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

vector<string> button = {
  "",
  ".,!? ", "abc", "def",
  "ghi", "jkl", "mno",
  "pqrs", "tuv", "wxyz",
};

int main() {
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    int x = 0;
    int cnt = -1;
    string s; cin >> s;
    for (auto&& c : s) {
      int num = c - '0';
      if (num) {
        ++cnt;
      } else {
        if (x) cout << button[x][cnt % button[x].size()];
        cnt = -1;
      }
      x = num;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3196
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String S = scan.next();

        if(S.charAt(S.length()-1) == 's')
            os.println(S+"es");
        else
            os.println(S+'s');

    }
}

Measured memory_bytes: 26984
#include<iostream>
using namespace std;
#define MAXN 500

int N;
int C[MAXN],S[MAXN],F[MAXN];

int main(){
  cin>>N;
  for(int i=0;i<N-1;i++){
    cin>>C[i]>>S[i]>>F[i];
  }
  for(int i=0;i<N-1;i++){
    int cnt=i;
    int time=0;
    while(cnt<=N-2){
      if(time<=S[cnt]) time=S[cnt];
      else time=S[cnt]+((time-S[cnt]+F[cnt]-1)/F[cnt])*F[cnt];
      time+=C[cnt];
      cnt++;
    }
    cout<<time<<endl;
  }
  cout<<0<<endl;
  return 0;
}

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

int main(){
  int N,X; cin >> N >> X;
  
  int D = 0;
  int count = 0;
  for(int i = 0; i < N + 1; i++){
      int L; 
      cin >> L;
      if(D <= X) count++;
      D += L;
  }
  cout << count << endl;
}



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

typedef pair <int, int> pii;

const int MAXN = 5e4 + 5;
const int MAXM = 1e5 + 5;
const int SQRT = 450;

int N, M, T;
bitset <MAXN> state[MAXN];
int x[MAXM], y[MAXM];
vector <int> changes[SQRT][SQRT];
vector <pii> todo[MAXM];
bool adj[SQRT][SQRT];
char ans[MAXM];

void load() {
	scanf("%d%d%d", &N, &M, &T);
	for (int i = 0; i < M; i++) {
		scanf("%d%d", x + i, y + i);
		x[i]--;
		y[i]--;
	}
}

void reconstruct(int final) {
	vector <bool> curr(N, false);
	curr[final] = true;
	for (int i = M - 1; i >= 0; i--)
		if (!curr[x[i]]) {
			ans[i] = 'v';
			if (curr[y[i]])
				curr[x[i]] = true;
		}
		else {
			ans[i] = '^';
			if (curr[x[i]])
				curr[y[i]] = true;
		}
	puts(ans);
}

void uniforming() {
	for (int i = 0; i < N; i++)
		state[i].set(i);
	
	for (int i = M - 1; i >= 0; i--)
		state[x[i]] = state[y[i]] = state[x[i]] | state[y[i]];
	
	bitset <MAXN> all;
	all.set();
	for (int i = 0; i < N; i++)
		all &= state[i];
	
	for (int i = 0; i < N; i++)
		if (all.test(i)) {
			reconstruct(i);
			return;
		}
	
	puts("-1");
}

void finish(int u, int v) {
	for (int i = 0; i < M; i++) {
		bool flag = false;
		for (int j = 0; j < 2; j++) {
			if (!changes[u][v].empty() && changes[u][v].back() == i && (u == x[i] || u == y[i])) {
				ans[i] = u == x[i] ? 'v' : '^';
				u = x[i] ^ y[i] ^ u;
				flag = true;
				break;
			}
			swap(u, v);
		}
		if (!flag)
			ans[i] = x[i] == u || x[i] == v ? '^' : 'v';
		for (auto it : todo[i])
			changes[it.first][it.second].pop_back();
	}
	puts(ans);
}

void non_uniforming() {
	map <pii, int> bio;
	for (int i = 0; i < M; i++)
		bio[{x[i], y[i]}] = true;
	
	int sofar = 0;
	for (int i = 0; i < N && sofar <= M; i++)
		for (int j = i + 1; j < N && sofar <= M; j++) {
			if (!bio[{i, j}]) {
				finish(i, j);
				return;
			}
			sofar++;
		}
	
	assert(N < SQRT);	
	
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			adj[i][j] = i != j;

	for (int i = M - 1; i >= 0; i--) {
		adj[x[i]][y[i]] = adj[y[i]][x[i]] = false;
		for (int j = 0; j < N; j++) {
			if (adj[x[i]][j] && !adj[y[i]][j]) 
				todo[i].push_back({y[i], j});
			if (adj[y[i]][j] && !adj[x[i]][j])
				todo[i].push_back({x[i], j});
		}
		for (auto it : todo[i]) {
			adj[it.first][it.second] = adj[it.second][it.first] = true;
			changes[it.first][it.second].push_back(i);
		}
	}
		
	for (int i = 0; i < N; i++)
		for (int j = i + 1; j < N; j++)
			if (adj[i][j]) {
				finish(i, j);
				return;
			}
		
	puts("-1");
}

int main() {
	load();
	if (T == 1)
		uniforming();
	else
		non_uniforming();
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<ll> C(N - 1), S(N - 1), F(N - 1);
  REP(i, N - 1) cin >> C.at(i) >> S.at(i) >> F.at(i);

  vector<ll> ans(N);
  REP(i, N) {
    if(i == N - 1) {
      ans.at(i) = 0;
      break;
    }
    ans.at(i) = S.at(i);
  }

  REP(i, N) {
    for(int k = i; k < N - 1; ++k) {
      if(ans.at(i) < S.at(k)) {
        ans.at(i) = S.at(k);
      } else if(ans.at(i) % F.at(k) == 0) {

      } else {
        ans.at(i) = ans.at(i) + F.at(k) - (ans.at(i) % F.at(k));
      }
      ans.at(i) += C.at(k);
    }
  }

  REP(i, N) {
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 764