akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int x;
    cin>>x;
    REP(i,-200,200){
        REP(j,-200,200){
            if(i*i*i*i*i-j*j*j*j*j==x){
                cout<<i<<sp<<j<<endl;
                return;
            }
        }
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	string a;
	for (int i=1;i<=n;i++)
		cin>>a[i];
	for (int i=1;i<=n;i++)
	{
		if (i==k)
			cout<<char(a[i]+32);
		else
			cout<<a[i];
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char ** argv)
{
  std::string s;
  std::cin >> s;

  int ans = 0;
  const int len = s.size();
  for (int i = 0; i < len / 2; ++i) {
    if (s.at(i) != s.at(len - 1 - i)) {
      ans++;
    }
  }
  std::printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  static int N;
  static int[][] A, dp;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    A = new int[N][3];
    dp = new int[N][4];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 3; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    System.out.println(f(0,3));
  }
  static int f(int index, int prev) {
    if (index == N) return 0;
    if (dp[index][prev] > 0) return dp[index][prev];
  	int max = 0;
    for (int i = 0; i < 3; i++) {
      if (i != prev) {
      	max = Math.max(max,A[index][i] + f(index + 1, i));
      }
    }
    return dp[index][prev] = max;
  }
}

Measured memory_bytes: 113220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		pl(Math.min(B/A,C));
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  vll csum(n + 1, 0);
  rep(i, n) {
    ll a;
    cin >> a;
    csum[i + 1] = csum[i] + a;
  }

  ll tachib = INF;
  repLRE(i, 1, n - 1) chmin(tachib, abs(2*csum[i] - csum[n]));

  cout << tachib << endl;

  return 0;
}


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  if(C-(A-B)>0){
    cout << C-(A-B) << endl;
  }
  else{
    cout << 0 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  var lines = chunk.split("\n");
  var n = lines[0] * 1;
  var name = lines[1];
  var i, iLen, j, jLen, d, dLen,
      cnt=0;
  
  iLen = n+2;
  for (i=2; i<iLen; i++) {
    var board = lines[i], able = false;
    jLen = board.length;
    for (j=0; j<jLen; j++) {
      var d, dLen;
      dLen = board.length; 
      for (d=1; d<=dLen; d++) {
        var idx = j;
        var str = '';
        while(board[idx]) {
          str += board[idx];
          if (str == name) {
            able = true;
          }
          if (able) { break; }
          idx += d;
        }
        if (able) { break; }
      }
      if (able) { break; }
    }
    if (able) {
      cnt++;
    }
  }
  console.log(cnt);
});

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

void fnInput(int &rnElmCnt, vector<int> &rvnElm, int &rnTrgCnt , vector<int> &rvnTrg )
{
  cin >> rnElmCnt;

  rvnElm.resize(rnElmCnt);
  for (int i = 0; i < rnElmCnt; i++)
    cin >> rvnElm[i];

  cin >> rnTrgCnt;

  rvnTrg.resize(rnTrgCnt);
  for (int i = 0; i < rnTrgCnt; i++)
    cin >> rvnTrg[i];
}

int fnRcsSch(int nPos, int nTrg, const vector<int> &cnrvnElm, vector<vector<int>> &rvvnOK)
{
  if (!nTrg)                    return 1;
  if (nTrg < 0)                 return 0;
  if (nPos == cnrvnElm.size())  return 0;
  if (rvvnOK[nPos][nTrg] != -1) return rvvnOK[nPos][nTrg];

  if (fnRcsSch(nPos + 1, nTrg, cnrvnElm, rvvnOK))
    rvvnOK[nPos][nTrg] = 1;
  else if (fnRcsSch(nPos + 1, nTrg - cnrvnElm[nPos], cnrvnElm, rvvnOK))
    rvvnOK[nPos][nTrg] = 1;
  else
    rvvnOK[nPos][nTrg] = 0;

  return rvvnOK[nPos][nTrg];
}

void fnExhSch(const vector<int> &cnrvnElm, const vector<int> &cnrvnTrg)
{
  vector<vector<int>> vvnOK(21, vector<int>(2001, -1));
  
  for (int i = 0; i < cnrvnTrg.size(); i++)
  {
    int nTrg = cnrvnTrg[i];
    int nRtn;

    if (nRtn = fnRcsSch(0, nTrg, cnrvnElm, vvnOK))
      cout << "yes" << endl;
    else
      cout << "no" << endl;

    vvnOK[0][nTrg] = nRtn;
  }
}

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

  int nElmCnt, nTrgCnt;
  vector<int> vnElm, vnTrg;

  fnInput(nElmCnt, vnElm, nTrgCnt, vnTrg);
  fnExhSch(vnElm, vnTrg);

  return 0;
}

Measured memory_bytes: 1340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N1,N2,W;
	cin >> N1 >> W;
	N2 = N1/2;
	N1 -= N2;
	vector<ll> v1,v2,w1,w2;
	vector<P> ans1,ans2;

	FOR(i,0,N1){
		ll v,w;
		cin >> v >> w;
		v1.push_back(v);
		w1.push_back(w);
	}
	FOR(i,0,N2){
		ll v,w;
		cin >> v >> w;
		v2.push_back(v);
		w2.push_back(w);
	}

	ans1.push_back({0,0});
	FOR(i,0,N1){
		vector<P> anst;
		for(P x:ans1){
			anst.push_back(x);
			anst.push_back({x.first+w1[i],x.second+v1[i]});
		}
		ans1 = anst;
	}
	SORT(ans1);
	vector<P> anst;
	set<ll> s;
	FORR(i,0,ans1.size()){
		if(s.count(ans1[i].first)==0){
			s.insert(ans1[i].first);
			anst.push_back(ans1[i]);
		}
	}
	ans1 = anst;
	REV(ans1);
	anst.clear();
	ll mv=-1;
	FOR(i,0,ans1.size()){
		if(ans1[i].second>mv){
			mv = ans1[i].second;
			anst.push_back(ans1[i]);
		}
	}
	ans1 = anst;



	ans2.push_back({0,0});
	FOR(i,0,N2){
		anst.clear();
		for(P x:ans2){
			anst.push_back(x);
			anst.push_back({x.first+w2[i],x.second+v2[i]});
		}
		ans2 = anst;
	}
	SORT(ans2);
	anst.clear();
	s.clear();
	FORR(i,0,ans2.size()){
		if(s.count(ans2[i].first)==0){
			s.insert(ans2[i].first);
			anst.push_back(ans2[i]);
		}
	}
	ans2 = anst;
	REV(ans2);
	anst.clear();
	mv = -1;
	FOR(i,0,ans2.size()){
		if(ans2[i].second>mv){
			mv = ans2[i].second;
			anst.push_back(ans2[i]);
		}
	}
	ans2 = anst;


	ll ans = 0;
	FOR(i,0,ans1.size()){
		ll v1i = ans1[i].second;
		ll w1i = ans1[i].first;
		P x1i = ans1[i];
		if(w1i>W)continue;
		P search = {W-w1i+1,0};
		ll i2 = POSL(ans2,search);
		P zero={0,0};
		if(ans2[i2]==zero)i2++;
		ans = max(ans,v1i+ans2[i2-1].second);
	}
	cout << ans << endl;
}



Measured memory_bytes: 117484
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
answer = set(range(1, M+1))
for _ in range(N):
    k, *A = lr()
    s = set(A)
    answer &= s

print(len(answer))


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=1;i<=9;i++){
    if(n%i==0 and n/i<10){
      cout<<"Yes\n";
      return 0;
    }
  }
  cout<<"No\n";
  return 0;
}
       

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

int main() {
    int n, a,b, s[200005];
    cin >> n;
    vector<int> vec(n);
    for(int i=0; i<n; i++) {
        cin >> vec.at(i);
        s[i]=vec.at(i);
    }
    sort(vec.begin(), vec.end());
    a=vec.at(n-1);
    b=vec.at(n-2);
    for(int i=0; i<n; i++) {
        if(s[i] != a) cout << a << endl;
        else cout << b << endl;
    }
}

Measured memory_bytes: 3200
// Contest: AtCoder Beginner Contest 145 (https://atcoder.jp/contests/abc145)
// Problem: F: Laminate (https://atcoder.jp/contests/abc145/tasks/abc145_f)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

template <class T, size_t... Is> struct arr_helper;
template <class T> struct arr_helper<T> { using type = T; };
template <class T, size_t I, size_t... Is>
struct arr_helper<T, I, Is...> { using type = array<typename arr_helper<T, Is...>::type, I>; };
template <class T, size_t... Is> using arr = typename arr_helper<T, Is...>::type;

arr<ll, 305, 305> dp{};

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

    int n, k; cin >> n >> k;
    vi h(n);
    trav(hi, h) cin >> hi;

    if (n == k)
        cout << "0\n", exit(0);

    trav(row, dp) row.fill(INFL);
    dp[0][1] = h[0];

    reps(i, 1, n) {
        dp[i][1] = h[i];
        reps(j, 2, n - k + 1)
            rep(x, i)
                dp[i][j] = min(dp[i][j], dp[x][j - 1] + max(0, h[i] - h[x]));
    }

    ll mn = INFL;
    rep(i, n)
        mn = min(mn, dp[i][n - k]);
    cout << mn << '\n';

    return 0;
}

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

int main() {

  int N, D; cin >> N >> D;
  if (N % (2 * D + 1) == 0) {
    cout << N / (2 * D + 1) << endl;
  }
  else {
    cout << N / (2 * D + 1) + 1 << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) //std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int mod = 998244353;
int k, n;
vll answers;

void print_ans() {
  FOR (i, 2, 2*k+1) {
    printf("%lld\n", answers[i]);
  }
}

int main() {
  scanf("%d %d", &k, &n);
  vvll table(k+1, vll(n+1, 0LL));
  rep (i, n+1) {
    table[1][i] = 1;
  }
  FOR (i, 1, k+1) {
    table[i][0] = 1;
  }
  FOR (i, 2, k+1) {
    FOR (j, 1, n+1) {
      table[i][j] = table[i][j-1] + table[i-1][j];
      table[i][j] %= mod;
    }
  }
  vvll comb(k+1, vll(k+1, 0LL));
  comb[0][0] = comb[1][0] = comb[1][1] = 1;
  FOR (i, 2, k+1) {
    comb[i][0] = 1;
    comb[i][i] = 1;
    FOR (j, 1, i) {
      comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % mod;
    }
  }
  vll po2(k+1, 1LL);
  FOR (i, 1, k+1) {
    po2[i] = po2[i-1] * 2 % mod;
  }
  /*
  debug(table);
  debug(comb);
  */

  answers.assign(2*k+1, 0LL);

  FOR (i, 2, 2*k+1) {
    debug(i);
    ll ans = 0;
    int ma = min(i-1, k);
    int mi = i - ma;
    int p = (ma - mi + 1) / 2;
    int q = (i-1)%2; // if i is even dice must have i/2
    int r = k - (ma - mi + 1);
    debug(p); debug(q); debug(r);
    rep (ip, p+1) {
      debug(ip);
      ll select = comb[p][ip] * po2[ip] % mod;
      debug(select);
      int n2 = n - ip;
      ll add;
      if (n2 < 0) {
        add = 0;
      } else {
        add = select * table[ip+r][n2] % mod;
      }
      ll add2 = 0;
      if (q == 1) {
        int n3 = n - ip - 1;
        if (n3 >= 0) {
          add2 = select * table[ip+r][n3] % mod;
        }
      }
      debug(add);
      debug(add2);
      ans = (ans + add + add2) % mod;
    }

    answers[i] = ans;
  }
  debug(answers);

  print_ans();

  return 0;
}


Measured memory_bytes: 63224
#include <bits/stdc++.h>
typedef long long ll;

inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }

int main() {
	char s[10];
    std::cin >> s;
    if (s[1] == 'B') puts("ARC");
    else puts("ABC");
	return 0;
}










Measured memory_bytes: 3596
n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
i = int(p**(1/n))+1
if i%2 == 0:
    i -= 1
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 1
print(c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int solver (vector<int> c, vector<vector<int>> s, vector<int> t){
    vector<int> last(26);
    ll st = 0, los = 0;
    REP(i, 365){
        st += s[i][t[i]-1];
        last[t[i]-1] = i+1;
        //cout << st << endl;   //満足度の低下を考えない場合
        REP(j, 365){
            los += c[j]*(i+1 - last[j]);
        }
        //cout << st << endl;
    }
    return st - los;
}

int main(){
    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> s (D, vector<int>(26));    

    /// 入力部分 ///
    REP(i, 26){
        cin >> c[i];
    }
    REP(i, D){
        REP(j, 26){
            cin >> s[i][j];
        }
    }
    /// 入力部終わり ///

    random_device rnd;
    mt19937 mt(rnd());
    uniform_real_distribution<> rand(1, 27);

    vector<int> t(365);
    vector<int> best(365);
    ll st = 0, st_temp;
    int iii = 0;
    while (iii < 15e+2){
        for (int i = 0; i < 365; ++i) {
            t[i] = int(rand(mt));
            //cout << t[i] << endl;
        }

        st_temp = solver(c, s, t);
        //cout << st_temp << endl;
        if(st < st_temp){
            st = st_temp;
            best = t;
        }
        iii++;
    }
    REP(i, D){
        cout << best[i] << endl;
    }
}


Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

template<class T> class rollinghash {
	const ull mask30 = (1LL << 30) - 1;
	const ull mask31 = (1LL << 31) - 1;
	const ull mod61 = (1LL << 61) - 1;
	const ull base = 10000001;
	vector<ull> hashvalue, basepower;
	int length;
	ull modulo(ull a) {
		ull au = a >> 61; ull ad = a & mod61;
		ull res = au + ad; if (res >= mod61) res -= mod61;
		return res;
	}
  	ull multiply(ull a, ull b) {
		ull au = a >> 31; ull ad = a & mask31;
		ull bu = b >> 31; ull bd = b & mask31;
		ull mid = ad * bu + au * bd;
		ull midu = mid >> 30; ull midd = mid & mask30;
		return au * bu * 2 + midu + (midd << 31) + ad * bd;
	}
public:
	rollinghash(T s) {
		length = s.size();
		hashvalue = vector<ull>(length + 1);
		for (int i = 0; i < length; i++) {
			hashvalue[i + 1] = modulo(multiply(hashvalue[i], base) + s[i] + 1);
		}
		basepower = vector<ull>(length + 1);
		basepower[0] = 1;
		for (int i = 1; i <= length; i++) {
			basepower[i] = modulo(multiply(basepower[i - 1], base));
		}
	}
	ull hash(ll l, ll r) { // hash of [l, r)
		assert(l < r && 0 <= l && l < length && 0 < r && r <= length);
		return modulo(hashvalue[r] + mod61 * 3 - modulo(multiply(hashvalue[l], basepower[r - l])));
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	string s;
	cin >> s;
	rollinghash<string> rol(s);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			while (i + ans < j && j + ans < n) {
				if (rol.hash(i, i + ans + 1) != rol.hash(j, j + ans + 1)) break;
				ans++;
			}
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 384
#include <stdio.h>

int main() {
  int H, W;
  int h, w;
  scanf("%d %d", &H, &W);
  while(H != 0 || W != 0) {
    for(h = 0; h < H; h++) {
      for(w = 0; w < W; w++) {
        if(h == 0 || h == H - 1 || w == 0 || w == W - 1) {
          printf("#");
        } else {
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d %d", &H, &W);
  }
  return 0;
}

Measured memory_bytes: 2632
// 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 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,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,ko;
    ll x,y,w;
    char hoge,fuga;
    cin>>str>>stra;
    if(str[0]==stra[2]&&str[1]==stra[1]&&str[2]==stra[0])YES;
    else NO;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    double ans=0.0;

    for(int i=0; i<N; i++){
        double a;
        string s;
        cin >> a >> s;
        if(s=="JPY"){
            ans = ans + a;
        }
        else{
            ans = ans + 380000.0 * a;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(void){
    while(1){
        int h, w;
        cin >> h >> w;
        if(h == 0) break;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++) cout << '#';
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
/*
Date: 2020/1/19.
Name: AtCoder ABC152 D "Handstand 2".
*/
#include<iostream>
#include<vector>
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;

int main(){
	int n;
	cin>>n;
	
	vvi cnt(10,vi(10,0));//point.
	int hoge=1;
	for(int i=1;i<=n;++i){
		if(i>=10*hoge) hoge*=10;
		cnt[i/hoge][i%10]++;
	}
	
	llong ans=0;
	for(int i=1;i<=9;++i)for(int j=1;j<=9;++j){
		ans+=(llong)cnt[i][j]*cnt[j][i];//point.
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	for i := 1; i <= 9; i++ {
		if N%i == 0 && N/i <= 9 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
//  cd Desktop/Prog_Contest
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define rep(i,n) for(i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

int main(){
    int n,a[200]={},i,ans=0;
    scanf("%d",&n);
    rep(i,n) scanf("%d",&a[i]);
    for(i=0;i<n;i+=2) if(a[i]%2==1) ans++;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,q,ans,a[52],b[52],c[52],d[52],f[52];
inline void dfs(re int x){
	if(x>n){
		re int sum=0;
		for(re int i=1;i<=q;++i){
			if(f[b[i]]-f[a[i]]==c[i])sum+=d[i];
		}
		ans=max(ans,sum);
		return;
	}
	for(re int i=f[x-1];i<=m;++i){
		f[x]=i;
		dfs(x+1);
	}
}
signed main(){
	n=read(),m=read(),q=read();
	for(re int i=1;i<=q;++i){
		a[i]=read();
		b[i]=read();
		c[i]=read();
		d[i]=read();
	}
	f[0]=1;
	dfs(1);
	printf("%d",ans);
}


Measured memory_bytes: 3768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		x -= a;
		while(x - b >= 0)
			x -= b;
		System.out.println(x);
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,D,A;
    cin >> N >> D >> A;
    vec<ll> X(N),H(N);
    map<ll,ll> mp;
    for(int i=0;i<N;i++){
        cin >> X[i] >> H[i];
        mp[X[i]] += H[i];
    }

    set<P<ll,ll>> s;
    ll ans = 0,now = 0;
    for(auto p:mp){
        ll x = p.first,h = p.second;
        set<P<ll,ll>>::iterator it = s.begin();
        while(it!=s.end()){
            if((*it).first>=x) break;
            now -= (*it).second;
            it = s.erase(it);
        }
        if(now<h){
            ll c = (h-now+A-1)/A;
            ans += c;
            s.insert({x+2*D,c*A});
            now += c*A;
        }
        it = s.begin();
        while(it!=s.end()){
            if((*it).first>x) break;
            now -= (*it).second;
            it = s.erase(it);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 22144
main :: IO ()
main = do
    (n, k) <- getPair :: IO (Pair Int)
    ds     <- filter (/= ' ') <$> getLine
    print $ solve n ds

type Pair a = (a, a)
getPair = (\(x:y:_) -> (x, y)) . map read . words <$> getLine :: Read a => IO (Pair a)

solve :: Int -> [Char] -> Int
solve n ds
  | all (`notElem` ds) $ show n = n
  | otherwise                   = solve (succ n) ds


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

template <typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n = 0) : n(n), d(n + 1) {}
  void add(int i, T x = 1) {
    for (i++; i <= n; i += i & -i) d[i] += x;
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i & -i) x += d[i];  // 最下位bitの加算
    return x;
  }
  T sum(int l, int r) { return sum(r - 1) - sum(l - 1); }
};

int main() {
  ll n, d, a, ans = 0;
  cin >> n >> d >> a;
  vector<P> p(n);

  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());

  BIT<ll> bit(n + 1);

  rep(i, n) {
    ll x = p[i].first;
    ll h = p[i].second;
    h -= bit.sum(i);
    if (h <= 0) continue;
    ll num = (h + a - 1) / a;
    ans += num;
    ll da = num * a;
    bit.add(i, da);
    bit.add(upper_bound(p.begin(), p.end(), P(x + d * 2 + 1, 0)) - p.begin(),
            -da);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7960
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

typedef long long int ll;

const ll MOD = 1000000007;

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

  int N;
  cin >> N;
  vector<double> A(N);
  for (auto &x: A) cin >> x;

  double divisor = 0.0;

  for (auto &x: A) divisor += 1.0 / x;

  double ans = 1.0 / divisor;

  cout << setprecision(16) << ans << endl;

  return 0;
}


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

int main() {
	int n;
	int max;
	while(1) {
		cin >> n;
		if(n == 0) break;
		int a[5010];
		for(int i = 0; i < n; i++) {
			cin >> a[i];
		}
		max = a[0];
		for(int i = 0; i < n; i++) {
			int temp = 0;
			for(int j = i; j < n; j++) {
				temp += a[j];
				if(temp > max) max = temp;
			}
		}
		cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
def solve(s):
    import collections
    l = collections.deque()

    cnt = 0
    for x in map(int,s):
        if len(l) == 0:
            l.append(x)
            continue
        y = l[-1]
        if x + y == 1:
            l.pop()
            cnt += 2
        else:
            l.append(x)

    return cnt


print(solve(input()))

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

int main() {
  char S;
  int bill=0;

  for(int i=0; i<3; i++){
    cin >> S;
    if(S=='o'){
      bill++;
    }
  }  

  cout << 700+(bill*100) << endl;

return 0;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int              //cout<<fixed<<setprecision(9)<<double value; 
#define INF 1000000000000000007
#define pb emplace_back 
#define md 1000000007
#define all(s) s.begin(),s.end()
typedef vector<int> vi;
ll ans=0;
int gh[101];
int d;
ll dp[101][4][2];
ll getsum(int idx,int n,int k,bool flag){
	if(idx>n)return (k==0);
	if(k==0){
		return 1;
	}
	if(dp[idx][k][flag]!=-1)return dp[idx][k][flag];
	int limit=9;
	if(!flag)limit=gh[idx];
	ll res=0;
	for(int i=0;i<=limit;i++){
		if(i<limit||flag){
			if(i>0)
			res+=getsum(idx+1,n,k-1,true);
			else
			res+=getsum(idx+1,n,k,true);
		}
		else{
			if(i>0)
			res+=getsum(idx+1,n,k-1,false);
			else
			res+=getsum(idx+1,n,k,false);
		}
	}
	return dp[idx][k][flag]=res;
}
void solve(){
	string b;
	cin>>b;
	cin>>d;
	for(int i=0;i<b.size();i++){
		gh[i+1]=b[i]-'0';
	}
	memset(dp,-1,sizeof dp);
    ll r=getsum(1,b.size(),d,0);
   cout<<r<<"\n";
}
int main(){
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
   int t=1;
  // cin>>t;
     while(t--){
     	solve();
	 }
     return 0;
}

Measured memory_bytes: 3668
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var answer = 0;
            for (int i = 0; i < S.Length - 2; i++)
            {
                if(S[i + 0] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
                {
                    answer++;
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2*N-1], dneg[2*N-1], X[N][N];

void initialize(){
  for(int i = 0; i < N; i++){
    row[i] = FREE;
    col[i] = FREE;
  }
  for(int i = 0; i < 2*N-1; i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}

void printBoard(){
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(X[i][j] == 1){
	if(row[i] != j)return;
      }
    }
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  if(i == N){
    printBoard();
    return;
  }

  for(int j = 0; j < N; j++){
    //
    if(NOT_FREE == col[j] ||
       NOT_FREE == dpos[i+j] ||
       NOT_FREE == dneg[i-j+N-1])continue;
    //
    row[i] = j; col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    //
    recursive(i+1);
    //
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
  //
}

int main(){
  initialize();

  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      X[i][j] = -1;
    }
  }

  int k;
  scanf("%d",&k);
  for(int i = 0; i < k; i++){
    int r, c;
    scanf("%d%d",&r,&c);
    X[r][c] = 1;
  }

  recursive(0);

  return 0;
}



Measured memory_bytes: 2112
def check(s,l):
	for i in s:
		if i in l:
			return False
	return True

n,k = map(int,input().split())
l = "".join(input().split())

for s in [str(i) for i in range(n,100000)]:
	if check(s,l):
		print(s)
		break



Measured memory_bytes: 16228
n = int(input())
a = list(map(int,input().split()))

cnt2 = 0
cnt4 = 0
cnt = 0

for i in a:
    if i%4==0:
        cnt4 += 1
    elif i%2==0:
        cnt2 += 1
    else:
        cnt += 1
ans = 0
if (cnt - cnt4 == 1 and cnt2 == 0) or (cnt4>=cnt):
    ans = 1
print("Yes" if ans==1 else "No")

Measured memory_bytes: 20020
#include<stdio.h>

int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
		if(x+r<=W && y+r<=H && x-r>=0 && y-r>=0){
			printf("Yes\n");
}	else {
		printf("No\n");
}	return 0;
}


Measured memory_bytes: 2092
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
	string s;
	cin >> s;
	int n = s.size();
	if(s[n - 1] == 's'){
		cout << s << "es\n";
		return 0;
		}
	cout << s << "s\n";
		}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;
  
  
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L == R) {
    cout << "Balanced" << endl;
  }
  else if (L < R) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(lambda x:int(x), input().split()))
q = int(input())

numdic = {}
#print(a)
s = 0
for i in a:
  s += i
  #print(i)
  if i in numdic:
    numdic[i] += 1
  else:
    numdic[i] = 1
#print(numdic)

#operation = []
for i in range(q):
  bc = list(map(lambda x:int(x), input().split()))
  #operation.append((bc[0],bc[1]))
  if bc[0] in numdic:
    s = s + bc[1]*numdic[bc[0]] - bc[0]*numdic[bc[0]]
    if bc[1] in numdic:
      numdic[bc[1]] += numdic[bc[0]]
      numdic[bc[0]] = 0
    else:
      numdic[bc[1]] = numdic[bc[0]]
      numdic[bc[0]] = 0
  print(s)
  
#print(operation)
#print(numdic)


Measured memory_bytes: 20888
n = int(input())
b = list(map(int, input().split()))

a = []

for i in range(n):
    if i == 0:
        a.append(b[0])
    elif i == n-1:
        a.append(b[-1])    
    else:
        a.append(min(b[i-1], b[i]))

print(sum(a))

Measured memory_bytes: 61976
import java.util.Scanner;

//Planning Rolling Blackouts
public class Main{

	int h, w, s, S;
	int[][] a, sum;
	int[][][][] group, rest;
	
	int get(int i, int j, int k, int l){
		return sum[k][l]-sum[i-1][l]-sum[k][j-1]+sum[i-1][j-1];
	}
	
	void dfs(int i, int j, int k, int l){
		if(group[i][j][k][l]!=-1)return;
		if(s<S-get(i, j, k, l))return;
		if(group[i][j][k][l]<1){
			group[i][j][k][l] = 1;
			rest[i][j][k][l] = s-S+get(i, j, k, l);
		}
		else if(group[i][j][k][l]==1){
			rest[i][j][k][l] = Math.max(rest[i][j][k][l], 0);
		}
		for(int ni=i;ni<k;ni++){
			dfs(i, j, ni, l); dfs(ni+1, j, k, l);
			if(group[i][j][ni][l]==-1||group[ni+1][j][k][l]==-1)continue;
			if(group[i][j][k][l]<group[i][j][ni][l]+group[ni+1][j][k][l]){
				group[i][j][k][l] = group[i][j][ni][l]+group[ni+1][j][k][l];
				rest[i][j][k][l] = Math.min(rest[i][j][ni][l], rest[ni+1][j][k][l]);
			}
			else if(group[i][j][k][l]==group[i][j][ni][l]+group[ni+1][j][k][l])
				rest[i][j][k][l]=Math.max(rest[i][j][k][l], Math.min(rest[i][j][ni][l], rest[ni+1][j][k][l]));
		}
		for(int nj=j;nj<l;nj++){
			dfs(i, j, k, nj); dfs(i, nj+1, k, l);
			if(group[i][j][k][nj]==-1||group[i][nj+1][k][l]==-1)continue;
			if(group[i][j][k][l]<group[i][j][k][nj]+group[i][nj+1][k][l]){
				group[i][j][k][l] = group[i][j][k][nj]+group[i][nj+1][k][l];
				rest[i][j][k][l] = Math.min(rest[i][j][k][nj], rest[i][nj+1][k][l]);
			}
			else if(group[i][j][k][l]==group[i][j][k][nj]+group[i][nj+1][k][l])
				rest[i][j][k][l]=Math.max(rest[i][j][k][l], Math.min(rest[i][j][k][nj], rest[i][nj+1][k][l]));
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			h = sc.nextInt(); w = sc.nextInt(); s = sc.nextInt();
			if((h|w|s)==0)break;
			a = new int[h+1][w+1]; sum = new int[h+1][w+1];
			for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
				a[i][j] = sc.nextInt();
				sum[i][j] = sum[i-1][j] + sum[i][j-1] + a[i][j] - sum[i-1][j-1];
			}
			group = new int[h+1][w+1][h+1][w+1]; rest = new int[h+1][w+1][h+1][w+1];
			for(int i=0;i<=h;i++)for(int j=0;j<=w;j++)for(int k=0;k<=h;k++)for(int l=0;l<=w;l++)group[i][j][k][l]=rest[i][j][k][l]=-1;
			S = get(1, 1, h, w);
			dfs(1,1,h,w);
			System.out.println(group[1][1][h][w]+" "+rest[1][1][h][w]);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 33000
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
 
 
using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif	
}
int tc;
const int N=3e5+5,M=3e5+5,MOD=1e9+7,OO=1e9;

int n,m,p;
std::vector<int> g[N];
bool vis[N];
void dfs(int u){
	if(vis[u])return;
	vis[u]=1;
	for(auto v : g[u])dfs(v);
}

int main()
{	
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	//file();
 	
 	scanf("%d %d %d",&n,&m,&p);
 	std::vector<ll> dist(n+1,-1e18);
 	vector<pair<pair<int,int>,int>>edge(m);
 	for(int i=0,u,v;i<m;i++){
 		scanf("%d %d %d",&edge[i].first.first,&edge[i].first.second,&edge[i].second);
 		u = edge[i].first.first;
 		v = edge[i].first.second;
 		g[u].pb(v);
 		edge[i].second-=p;
 	}
 	dist[1]=0;
 	for(int i=1;i<n;i++){
 		for(auto p : edge){
 			int u = p.first.first , v = p.first.second;
 			int w = p.second;
 			if(dist[u]>-1e18)
 				dist[v]=max(dist[v],dist[u]+w);
 		}
 	}

 	for(auto p : edge){
 		int u = p.first.first , v = p.first.second;
 		int w = p.second;
 		if(dist[u]>-1e18)
 		if(dist[v]<dist[u]+w){
 			dist[v]=dist[u]+w;
 			dfs(v);
 			if(vis[n] || vis[1])return !printf("-1\n");
 			for(int i=1;i<=n;i++)vis[i]=0;
 		}
 	}
 	printf("%lld\n",max(dist[n],0LL));
 	
}

Measured memory_bytes: 7552
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<math.h>
#define Rad(C) C*M_PI/180.0

int main() {
	double x[100],y[100],*px,*py,max=-1,s1,s2,s3,tmp;
	int i, n;
	scanf("%d", &n);
	px = x; py = y;
	s1 = s2 = s3 = 0;
	for (i = 0; i < n; i++)scanf("%lf", &*(px+i));
	for (i = 0; i < n; i++)scanf("%lf", &*(py+i));
	for (i = 0; i < n; i++) {
		tmp = fabs(*(px++) - *(py++));
		if (tmp > max) max = tmp;
		s1 += tmp;
		s2 += tmp*tmp;
		s3 += tmp*tmp*tmp;
	}
	printf("%lf\n%lf\n%lf\n%lf\n", s1, sqrt(s2), pow(s3,1/3.0), max);
	return 0;
}

Measured memory_bytes: 696
#include<iostream>
#include<string>
#define WIN_POINT 3
#define DRAW_POINT 1
using namespace std;

int main(){
	string p1_str, p2_str;
	int p1_score=0, p2_score=0, battle_num;
	cin >> battle_num;
	while(battle_num--){
		cin >> p1_str >> p2_str;
		if(p1_str < p2_str){
			p2_score += WIN_POINT;
		}else if(p1_str > p2_str){
			p1_score += WIN_POINT;
		}else if(p1_str == p2_str){
			p1_score += DRAW_POINT;
			p2_score += DRAW_POINT;
		}
	}
	cout << p1_score << ' ' << p2_score << endl;
	return 0;
}

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

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void) {
    int N, M;
    cin >> N >> M;
    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      
      // お菓子持ってない人をカウント
      boolean[] okashi = new boolean[N];
      for(int i = 0; i < N; i++){
        okashi[i] = false;
      }
      
      for(int i = 0; i < K; i++){
        int person = sc.nextInt();
        for(int j = 0; j < person; j++){
          int index = sc.nextInt()-1;
          okashi[index] = true;
        }
      }
      
      int count = 0;
      for(int i = 0; i < N; i++){
        if(!okashi[i]){
          count++;
        }
      }
      
      // 出力
      System.out.println(count);
    }

}

Measured memory_bytes: 46444
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

const ULL B[] = { 999999937ULL,1000000007ULL };

//aはbに含まれているか?
bool contain(string a, string b) {
	int al = a.length(), bl = b.length();
	if (al > bl)return false;

	//Bのal乗を計算
	ULL t[] = { 1 ,1 };
	for (int i = 0; i < al; i++)t[0] *= B[0];
	for (int i = 0; i < al; i++)t[1] *= B[1];

	//aとbの最初のal文字に関するハッシュ値を計算
	ULL ah[] = { 0 ,0 }, bh[] = { 0 ,0 };
	for (int i = 0; i < al; i++)ah[0] = ah[0] * B[0] + a[i];
	for (int i = 0; i < al; i++)bh[0] = bh[0] * B[0] + b[i];
	for (int i = 0; i < al; i++)ah[1] = ah[1] * B[1] + a[i];
	for (int i = 0; i < al; i++)bh[1] = bh[1] * B[1] + b[i];

	//bの場所を1つずつ進めながらハッシュ値をチェック
	for (int i = 0; i + al <= bl; i++) {
		if (ah[0] == bh[0] && ah[1] == bh[1]) {
			cout << i << endl;
		}
		if (i + al < bl) {
			bh[0] = bh[0] * B[0] + b[i + al] - b[i] * t[0];
			bh[1] = bh[1] * B[1] + b[i + al] - b[i] * t[1];
		}
	}
	return false;//一致する文字列がない
}
string s, t;

int main() {
	cin >> s >> t;
	contain(t, s);
}


Measured memory_bytes: 5036
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

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

const int N = 3*100000;

int n;
P data[N];

bool check(int k){
  if(k == 0) return true;
  priority_queue<P, vector<P> > que;
  lli sum = 0;
  for(int i=0;i<k-1;i++){
    sum += data[i].second;
    que.push(P(data[i].second, data[i].first));
  }
  for(int i=k-1;i<n;i++){
    if((lli)sum <= (lli)k * data[i].first - data[i].second) return true;
    sum += data[i].second;
    que.push(P(data[i].second, data[i].first));
    sum -= que.top().first;
    que.pop();
  }
  return false;
}

main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> data[i].second >> data[i].first;
  sort(data, data+n, greater<P>() );
  int l = 0, r = n+1;
  while(r - l > 1){
    int m = (l + r) / 2;
    if(check(m)) l = m;
    else r = m;
  }
  cout << l << endl;
}

Measured memory_bytes: 11192