akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string s;
int n;

int main()
{
	cin >> s;
	n = s.size();

	string t;

	for (int i = 0;i < n;i++) {
		if (s[i] != 'x') {
			t = t + s[i];
		}
	}

	int m = t.size();
	for (int i = 0;i < m / 2;i++) {
		if (t[i] != t[m - 1 - i]) {
			cout << "-1" << endl;
			return 0;
		}
	}

	int left = 0, right = n-1;
	int ans = 0;

	while (left < right) {
		if (s[left] == s[right]) {
			left++;
			right--;
		}
		else if (s[left] == 'x') {
			ans++;
			left++;
		}
		else if (s[right] == 'x') {
			ans++;
			right--;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

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

    int dig1 = N % 10;
    int dig2 = N / 10;
    bool has9 = dig1 == 9 || dig2 == 9;

    cout << (has9 ? "Yes" : "No") << endl;

    return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  int c[10][10];
  for ( int i = 0; i < 10; i++ ) {
    for ( int j = 0; j < 10; j++ ) {
      cin >> c[i][j];
    }
  }

  for ( int k = 0; k < 10; k++ ) {
    for ( int i = 0; i < 10; i++ ) {
      for ( int j = 0; j < 10; j++ ) {
        c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
      }
    }
  }

  long long ans = 0;
  for ( int i = 0; i < h*w; i++ ) {
    int n;
    cin >> n;
    if ( n != -1 ) { ans += c[n][1]; }
  }

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


Measured memory_bytes: 3644
n=int(input())
s=input()
W=0 ; E=s[1:].count("E")
ans=float("inf")
for i in range(n):
    ans=min(ans, W+E)
    if i==n-1:print(ans);exit()
    if s[i]=="W":
        W+=1
    if s[i+1]=="E":
        E-=1

Measured memory_bytes: 9716
import sys

# sys.stdin = open('d1.in')

n, W = map(int, input().split())
g = {}
w1 = 0
for i in range(n):
    w, v = map(int, input().split())
    if i == 0:
        w1 = w
        for x in range(w, w + 4):
            g[x] = []
    g[w].append(v)
for w, values in g.items():
    values.sort(reverse=True)

res = 0
for a in range(len(g[w1]) + 1):
    for b in range(len(g[w1 + 1]) + 1):
        for c in range(len(g[w1 + 2]) + 1):
            for d in range(len(g[w1 + 3]) + 1):
                total_w = w1 * a + (w1 + 1) * b + (w1 + 2) * c + (w1 + 3) * d
                if total_w > W:
                    continue

                total_v = 0
                for i in range(a):
                    total_v += g[w1][i]
                for i in range(b):
                    total_v += g[w1 + 1][i]
                for i in range(c):
                    total_v += g[w1 + 2][i]
                for i in range(d):
                    total_v += g[w1 + 3][i]
                if total_v > res:
                    res = total_v
print(res)


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

using namespace std;

#define MAX 10
#define INF 1e9
typedef pair<int,int> pii;
typedef pair<pii,int> piii;

int H,W,sx,sy,gx,gy;
int field[MAX][MAX];
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

bool inField(int x,int y){
  return 0 <= x && x < W && 0 <= y && y < H;
}

int bfs(){
  queue<piii> Q;
  Q.push(piii(pii(sx,sy),6));
  int d[MAX][MAX][7];
  fill(d[0][0],d[0][0]+MAX*MAX*7,INF);
  d[sy][sx][6] = 0;
  
  while(!Q.empty()){
    piii p = Q.front(); Q.pop();
    int x = p.first.first, y = p.first.second;
    int life = p.second;

    if(x == gx && y == gy){
      return d[y][x][life];
    }                                        
    if(life == 1) continue;
    for(int i = 0 ; i < 4 ; i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(!inField(nx,ny)) continue;
      if(field[ny][nx] == 0) continue;
      if(field[ny][nx] == 4){
        if(d[y][x][life] + 1 < d[ny][nx][6]){
          d[ny][nx][6] = d[y][x][life] + 1;
          Q.push(piii(pii(nx,ny),6));
        }
      }else{
        if(d[y][x][life] + 1 < d[ny][nx][life-1]){
          d[ny][nx][life-1] = d[y][x][life] + 1;
          Q.push(piii(pii(nx,ny),life-1));
        }
      }
    }    
  }
  return -1;
}

int main(){
  while(cin >> W >> H, W){
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
        cin >> field[i][j];
        if(field[i][j] == 2){
          sx = j; sy = i;
        }else if(field[i][j] == 3){
          gx = j; gy = i;
        }
      }
    }
    cout << bfs() << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
import java.lang.StringBuilder
import java.math.BigDecimal

fun main(){
    val N = readLine()!!.toLong()
    val E = 26L

    var digit = 0
    var n = N
    var e = E
    while (n > 0){
        digit++
        n -= e
        e *= 26
    }

    e /= 26
    n += e
    n--
    val s = StringBuilder()
    do {
        val rem = (n % E).toInt()
        s.append('a' + rem)
        n /= E
    }while (n > 0)
    while (s.length < digit){
        s.append("a")
    }
    println(s.toString().reversed())
}

Measured memory_bytes: 35748
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  COMinit();
  ll n,k;
  cin >> n >> k;
  ll ans=0;
  rep(i,min(k+1,n)){
    ll res=COM(n,i)*COM(n-1,n-i-1)%MOD;
    ans+=res;
    ans%=MOD;
  }
  cout << ans << endl;
  return 0;     
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  string s;
  cin >> s;
  short a[200002] = {0};
  int count[2020] = {0}, ans = 0, num = 0, r = 0;
  for (int i = 0; i < s.size(); ++i) {
    a[i] = s[i] - '0';
  }
  int mod10 = 1;
  for (int i = s.size() - 1; i >= 0; --i) {
    num += a[i] * mod10;
    r = num % 2019;
    if (a[i] != 0) count[r]++;
    mod10 *= 10;
    mod10 %= 2019;
  }
  ans += count[0];
  for (int i = 0; i < 2019; ++i) {
    if (count[i] >= 2) ans += count[i] * (count[i] - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

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

typedef pair<int, int> P;

int main()
{
	int n, m, a, b, cost;
	while (cin >> n >> m, n || m) {
		vector< queue< P > > bridge(n);
		vector<int> group(n,0);
		for (int i = 0; i < m; i++) {
			cin >> a >> b >> cost;
			bridge[a].push(P(-cost,-b));
			bridge[b].push(P(-cost,-a));
		}
		group[0] = 1;
		priority_queue< P > pq;
		int ncost = 0;
		while (!bridge[0].empty()) {
			pq.push(bridge[0].front());
			bridge[0].pop();
		}
		for (int i = 1; i < n; i++) {
			while (group[-pq.top().second]) {
				pq.pop();
			}
			P tmp = pq.top();
			pq.pop();
			group[-tmp.second] = 1;
			ncost -= tmp.first;
			while (!bridge[-tmp.second].empty()) {
				pq.push(bridge[-tmp.second].front());
				bridge[-tmp.second].pop();
			}
		}
		cout << ncost << endl;
	}
	return 0;
}

Measured memory_bytes: 3064
import math

N, D = map(int,input().split())
x = []
for _ in range(N):
    x.append(list(map(int,input().split())))
cnt = 0
for i in range(N-1):
    for j in range(i+1,N):
        dist =0
        ist = [x[i][k] - x[j][k] for k in range(D)]
        for n in ist:
            dist += n ** 2
        if math.sqrt(dist) == int(math.sqrt(dist)):
            cnt +=1
print(cnt)

Measured memory_bytes: 3064
public class Main {


  private static void solve() {
    int h = ni();
    int w = ni();
    int a = ni();
    int b = ni();
    
    System.out.println(h * w - a * w - b * h  + a * b);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep (i, n) cin >> h[i];

    vector<int> dp(n, 0);
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = dp[i-1] + abs(h[i-1] - h[i]);
        for (int j = 0; j <= k; j++) {
            if (j > i) break;
            dp[i] = min(
                dp[i],
                dp[i-j] + abs(h[i-j] - h[i])
            );
        }
    }

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4004
S = input()
g = 0
p = 0
win = 0
lose = 0
for s in S:
  if(s == "g"):
    if(p < g):
      p += 1
      win += 1
    elif(p == g):
      g += 1
  else:
    if(p < g):
      p += 1
    elif(p == g):
      g += 1
      lose += 1
print(win-lose)

Measured memory_bytes: 3316
MOD = 10 ** 9 + 7

N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))

T_d = [1] * N
T_d[0] = T[0]
for i in range(1, N):
    if T[i - 1] < T[i]:
        T_d[i] = T[i]

A_d = [1] * N
A_d[-1] = A[-1]
for i in range(N - 2, -1, -1):
    if A[i] > A[i + 1]:
        A_d[i] = A[i]

# print (T)
# print (T_d)
# print ()
# print (A)
# print (A_d)

ans = 1
for i in range(N):
    tmp = max(0, min(A[i], T[i]) - max(A_d[i], T_d[i]) + 1)
    ans *= tmp
    ans %= MOD

print (ans)

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

int n, m, deg[51];
int main() {
  cin >> n >> m;
  for(int i = 0, u, v; i < m; i++) {
    cin >> u >> v;
    deg[u]++;
    deg[v]++;
  }
  for(int i = 1; i <= n; i++) cout << deg[i] << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

from_1 = set(b for a, b in AB if a == 1)
to_N = set(a for a, b in AB if b == N)
print('POSSIBLE' if from_1 & to_N else 'IMPOSSIBLE')


Measured memory_bytes: 59512
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> enum_div(ll n){
	vector<ll> ret;
	for(ll i=1;i*i<=n;++i){
		if(n%i==0){
			ret.push_back(i);
			if(i*i!=n){
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

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

	ll N=in<ll>();
	auto E=enum_div(N);
	ll sum = 0;
	for(auto& x:E){
		if(x>1 && N/(x-1)==N%(x-1)) sum += x-1;
	}
	out(sum);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <limits.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int main(void) {
  int N, L;
  scanf("%d %d", &N, &L);
  int minT = INT_MAX;
  int minL = INT_MAX;
  int SUM = 0;
  for(int i = 0; i < N; i++) {
    int T = L + i;
    SUM += T;
    int tmp = ABS(T);
    if(minT > tmp) { 
      minT = tmp;
      minL = T;
    }
  }
  printf("%d\n", SUM-minL);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
    int a,b,fee;
    scanf("%d %d",&a,&b);
    if(a>=13){
        fee = b;
    }else if(12>=a&&a>=6){
        fee = b/2;
    }else{
        fee = 0;
    }
    printf("%d\n",fee);
    return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int grid[52][52];
bool visited[52][52];

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

void init(){
    rep(i, 52) rep(j, 52) {grid[i][j] = 0; visited[i][j] = false;}
}

void dfs(int px, int py, int sx, int sy){
    visited[sx][sy] = true;
    rep(i, 8){
        int nx = sx+dx[i];
        int ny = sy+dy[i];
        if(grid[nx][ny] == 1 && !visited[nx][ny]){
            dfs(sx, sy, nx, ny);
        }
    }
}

int main(void){
    while(true){
        int res = 0;
        init();
        int W, H; cin >> W >> H;
        if(W == 0) break;
        rep(i, H){
            rep(j, W){
                cin >> grid[i+1][j+1];
            }
        }
        for(int i = 1; i <= H; i++){
            for(int j = 1; j <= W; j++){
                if(grid[i][j] == 1 && !visited[i][j]){
                    dfs(-1, -1, i, j);
                    res++;
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i)  
#else
  #define DUMP(i)  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const int EPS = 1e-9;

string s;
bool check(int cnt){
  DUMP(s[cnt]);
  if(s[cnt] - '0' < 0 ||  s[cnt] - '0' > 9)return false;
  return true;
}

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char x,y;
  while(cin >> x >> y){
    string ans;
    if(x - y > 0)ans = ">";
    else if(x - y == 0) ans = "=";
    else ans = "<";
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define MD 100007
#define MX 444

using namespace std;

typedef unsigned long long ull;

template <typename T> void read(T& x)
{
	x = 0; char c = getchar();
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
}

struct HASH
{
	int fst[MD], nxt[MX*4], hnum;
	ull key[MX*4], val[MX*4];
	ull rehash(ull *a) {return (a[0]) | (a[1]<<10) | (a[2]<<20) | (a[3]<<30);}
	void insert(ull k, ull x)
	{
		int p = k % MD;
		for(int i=fst[p]; i; i=nxt[i])
			if(key[i] == k)
			{
				val[i] += x;
				return;
			}
		nxt[++hnum] = fst[p];
		fst[p] = hnum;
		key[hnum] = k;
		val[hnum] = x;
	}
	ull query(ull k)
	{
		for(int i=fst[k%MD]; i; i=nxt[i])
			if(key[i] == k)
				return val[i];
		return 0;
	}
} H;

ull col[MX][4];
int N;

void rotate(ull* t, ull* x)
{
	ull a = x[0];
	t[0] = x[1], t[1] = x[2], t[2] = x[3], t[3] = a;
}

void comb(ull* t, const ull* x, const ull* y, int p)
{
	t[0] = x[p&3], t[1] = y[(3-p)&3], t[2] = y[(2-p)&3], t[3] = x[(p+1)&3];
}

void input()
{
	read(N);
	for(int i=1; i<=N; i++)
	{
		read(col[i][0]);
		read(col[i][1]);
		read(col[i][2]);
		read(col[i][3]);
	}
}

void add(ull* f, ull x)
{
	for(int i=0; i<4; i++) rotate(f, f), H.insert(H.rehash(f), x);
}

void work()
{
	for(int i=1; i<=N; i++) add(col[i], +1);
	ull ans = 0;
	ull f[6][4], n[6];
	memset(f, 0, sizeof(f)), memset(n, 0, sizeof(n));
	for(int i=1; i<=N; i++)
	{
		memmove(f[0], col[i], sizeof(f[0])), add(f[0], -1);
		for(int j=i+1; j<=N; j++)
		{
			memmove(f[1], col[j], sizeof(f[1])), add(f[1], -1);
			for(int k=0; k<4; k++)
			{
				bool ok = 1;
				rotate(f[1], f[1]);
				for(int p=2; p<6; p++) comb(f[p], f[0], f[1], p-2);
				for(int p=2; p<6; p++)
				{
					n[p] = H.query(H.rehash(f[p]));
					if(!n[p]) ok = 0;
					if(n[p]) add(f[p], -1);
				}
				for(int p=2; p<6; p++) if(n[p]) add(f[p], +1);
				if(ok) ans += n[2] * n[3] * n[4] * n[5];
			}
			add(f[1], +1);
		}
		add(f[0], +1);
	}
	printf("%llu\n", ans/3);
}

int main()
{
	input();
	work();
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10;
int cnt[M],a[M];
main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i],cnt[a[i]]++;
	sort(cnt+1,cnt+n+1);
	int ans=0;
	for(int i=n;i>=n-k+1;i--)
	{
		ans+=cnt[i];
	}
	cout<<n-ans;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
 
using ll = long long;
using weight = ll;
using P = pair<ll, ll>;
 
int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    for(int i=0; i<N; ++i) {
        cin >> A[i];
        sum += A[i];
    }
    ll cnt = sum*2/N/(N+1);
    if(sum != N*(N+1)/2*cnt) {
        cout << "NO" << endl;
        return 0;
    }
    bool ok = true;
    for(int i=0; i<N; ++i) {
        ll t = A[(i+1)%N] - A[i] - cnt;
        ok &= t <= 0 && abs(t) % N == 0;
    }
    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

int main(){
    int H,W;
    cin >> H >> W;
    while(H!=0 && W !=0){
        for(int i=0; i<H;i++){
            for(int j=0;j<W;j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
    return 0;
}


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

const int maxn = 1e5;

int n, a[maxn];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  long long l = 2, r = 2;
  for (int i = n - 1; i >= 0; --i) {
    long long min_x = (l + a[i] - 1) / a[i] * a[i];
    long long max_x = r / a[i] * a[i];
    if (min_x > max_x) {
      puts("-1");
      return 0;
    }
    l = min_x;
    r = max_x + a[i] - 1;
  }
  printf("%lld %lld\n", l, r);
  return 0;
}


Measured memory_bytes: 512
import bisect
from itertools import accumulate

N , M , K = map(int , input().split())
a = list(map(int , input().split()))
b = list(map(int , input().split()))
a = list(accumulate(a))
b = list(accumulate(b))
a.insert(0,0)

ans = 0
for i in range(N + 1):
    if a[i] > K:
        break
    ans = max(ans , i + bisect.bisect_right(b, K - a[i]))
print(ans)


Measured memory_bytes: 41016
function Main(input){
  var inp = input.split('\n');
  var A = parseInt(inp[0].trim());
  var B = parseInt(inp[1].trim());
  var C = parseInt(inp[2].trim());
  var D = parseInt(inp[3].trim());

  var max1 = Math.min(A, B);
  var max2 = Math.min(C, D);
  console.log(max1+max2); 
  
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
T inf = numeric_limits<T>::max();

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

  ll X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> p(A), q(B), r(C);
  vector<ll> mix;
  repr(i, A, 0) cin >> p[i];
  repr(i, B, 0) cin >> q[i];
  repr(i, C, 0) cin >> r[i];

  sortd(p); sortd(q); sortd(r);
  
  for (int i = 0; i < X; ++i) mix.push_back(p[i]);
  for (int i = 0; i < Y; ++i) mix.push_back(q[i]);
  sorti(mix);
  for (int i = 0; i < min<int>(mix.size(), C); ++i) {
    if (mix[i] < r[i]) {
      mix[i] = r[i];
    } else {
      break;
    }
  }

  ll ans = 0;
  for (auto itr : mix) {
    ans += itr;
  }

  cout << ans << endl;
}


Measured memory_bytes: 7684
import java.math.*;
import java.util.*;
public class Main
{
        public static void main(String[] args)
        {
            Scanner cin = new Scanner(System.in);
            int tt;
            tt = cin.nextInt();
            BigInteger t = new BigInteger("1000000000000000000");
            BigInteger ans = BigInteger.valueOf(1);
            for(int i = 1;i <= tt;i ++)
            {
                int f;
                BigInteger m = cin.nextBigInteger();
                int s = m.compareTo(BigInteger.valueOf(0));
                if (s == 0)
                {
                    ans = BigInteger.valueOf(0);
                }
                f = ans.compareTo(t);
                if(s != 0 && f <= 0)
                ans = ans.multiply(m);
            }
            int kk = ans.compareTo(t);
            if(kk <= 0)
                System.out.println(ans);
            else System.out.println("-1\n");
        }
}

Measured memory_bytes: 59180
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC161C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long N = long.Parse(input[0]);
            long K = long.Parse(input[1]);
            if (N < K)
            {
                if (N < K - N)
                {
                    Console.WriteLine(N);
                }
                else
                {
                    Console.WriteLine(K - N);
                }
            }
            else if (N == K)
            {
                Console.WriteLine(0);
            }
            else
            {
                N = N % K;
                if (N < K - N)
                {
                    Console.WriteLine(N);
                }
                else
                {
                    Console.WriteLine(K - N);
                }
            }
        }
    }
}


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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define uset unordered_set
#define umap unordered_map

#define endl "\n"

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define all(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.first << ", " << p.second << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    int n, m, p;
    string s;
    cin >> n >> m;
    vi pens(n + 1);
    uset<int> solved;
    long long tot_pens = 0;
    for (int i = 1; i <= m; i++) {
        cin >> p >> s;
        if (s == "AC") {
            if (!solved.count(p)) {
                tot_pens += pens[p];
            }
            solved.insert(p);
        } else {
            pens[p]++;
        }
    }
    cout << solved.size() << " " << tot_pens;
}


Measured memory_bytes: 7656
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=305,mod=998244353;
ll dp[N][N][N][2];
ll par[N][N][N];
int32_t main(){
    ll n,k1;
    string s;
    cin >> s >> k1;
    k1=min(k1,N-1);
    n=s.size();
    for (int i=0;i<=k1;i++){
        for (int j=0;j<=i;j++){
            dp[0][0][i][0]=1;
            dp[0][0][i][1]=1;
            par[0][j][i]=1;
        }
    }
    for (int i=1;i<=n;i++){
        if (s[i-1]=='1'){
            for (int j=0;j<N;j++){
                for (int k=j;k<N;k++){
                    dp[i][j][k][0]=dp[i-1][j][k][0];
                    dp[i][j][k][1]=dp[i-1][j+1][k+1][1]+dp[i-1][j][k][0];
                    dp[i][j][k][0]%=mod;
                    dp[i][j][k][1]%=mod;
                }
            }
        }
        else{
            for (int j=0;j<N;j++){
                for (int k=j;k<N;k++){
                    if (j>0){
                    dp[i][j][k][0]+=par[i-1][j-1][k];
                    dp[i][j][k][1]+=par[i-1][j-1][k];
                    }
                    ll z=0;
                    for (int t=1;t<=j;t++){
                        z+=dp[i-1][j-t][k][0];
                        //dp[i][j][k][1]+=dp[i-1][j-t][k][0];
                    }

                    dp[i][j][k][0]+=dp[i-1][j][k][1];
                    dp[i][j][k][1]+=dp[i-1][j][k][1];
                    dp[i][j][k][0]%=mod;
                    dp[i][j][k][1]%=mod;
                }
            }
        }
        for (int j=0;j<N;j++){
            for (int k=0;k<N;k++){
                par[i][j][k]=dp[i][j][k][0];
                if (j>0) par[i][j][k]+=par[i][j-1][k];
                par[i][j][k]%=mod;

            }
        }
        /*
        for (int j=0;j<=2;j++){
            for (int k=0;k<=4;k++){
                cout << dp[i][j][k][0] << " " << dp[i][j][k][1] << " " ;
            }
            cout << "        ";
        }
        cout << endl;
        */
    }
    ll ans=dp[n][0][0][1];
    cout << ans%mod << endl;
}


Measured memory_bytes: 652340
N, M = map(int, input().split())
lst = [[] for _ in range(M)]
for i in range(M):
    lst[i] = list(map(int, input().split()))

p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
    for j in range(M):
        bitmask = 0b0
        for sw in lst[j][1::]:
            bitmask += 2**(sw-1)
        on_count = bin(bitmask & i).count("1")
        
        if p[j] != on_count % 2:
            break

    else:
        ans += 1

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }
#define ll long long
#define ld long double

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, ans = 2000000000;
	cin >> n;
	int x[n];
	cina(x, n);
	for (int i = 1; i <= 100; ++i) {
		int sum = 0;
		for (int j = 0; j < n; ++j) {
			sum += (i-x[j])*(i-x[j]);
		}
		ans = min(ans, sum);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int ans;
int main(){
  string s;
  cin >> s;
  for (int i = 0; i < s.size()/2;i++){
    if (s[i] != s[s.size()-i-1])
      ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,Q;
string S;
int l[100000];
int r[100000];
int L[100001];

int main(){
    cin>>N>>Q>>S;
    rep(i,Q) cin>>l[i]>>r[i];

    int sumL=0;
    rep(i,N-1){
        if(S[i]=='A' && S[i+1]=='C'){
            sumL++;
        }
        L[i+2]=sumL;
    }

    /*for(int i=0;i<=N;i++) cout<<L[i]<<' ';
    cout<<endl;*/

    rep(i,Q){
        int ans=L[r[i]]-L[l[i]-1];
        if(L[l[i]-1]!=L[l[i]]) ans--;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
#define sort(v) sort(v.begin(), v.end())
#define sortr(v) sort(v.rbegin(), v.rend())
void chmin(int &a, int b) {if(a > b) a = b;}
void chmax(int &a, int b) {if(a < b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};


int main(){
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    rep(i,0,n) cin >> a[i];
    while(q--){
        ll x;
        cin >> x;
        ll ans = 0;
        int right = 0;
        ll sum = 0;
        for(int left = 0 ; left < n ; left++){
            while(right < n && sum + a[right] <= x){
                sum += a[right];
                right++;
            }
            ans += right - left;

            if(right == left) right++;
            else sum -= a[left];

        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3152
# A, B = map(int, input().split())
# l = list(range(A,B))
# l += [B]
# l = [list("{:0>42}".format(format(i, 'b'))) for i in l]

# import numpy as np
# l = np.array(l)

# ans = ''
# for i in range(42):
#     if np.sum(l[:, i] == '1') % 2 == 1:
#         ans += '1'
#     else:
#         ans += '0'
# print(int(str(ans), 2))

A, B = map(int, input().split())
def xor(x):
    mod = x % 4
    if mod == 0:
        return x
    elif mod == 1:
        return 1
    elif mod == 2:
        return x ^ 1
    elif mod == 3:
        return 0
print(xor(A-1) ^ xor(B))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    String s = scan.next();
    
    if(s.equals("ABC")) {
      System.out.println("ARC");  
    } else {
      System.out.println("ABC");
    }
    
  }

}

Measured memory_bytes: 35632
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  int K, T;
  scanf("%d %d", &K, &T);
  int maks = 0;
  REP(i, T) {
    int x;
    scanf("%d", &x);
    maks = max(maks, x);
  }

  printf("%d\n", max(0, maks - (K - maks) - 1));
  return 0;
}


Measured memory_bytes: 256
//Lion's Sin Escanor 

#include<bits/stdc++.h>
using namespace std;
     
     
//#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)
#define moder 1000000007
#define forn(i,n) for(int i = 0; i < n ; i++)

ll moding( ll x , ll y ){
   
    ll ans = x % y;

    if(ans < 0)ans = ans + y ;

    return ans ;

}


bool isprime(ll n){
    if(n==2) return true;
    if(n==3) return true;
    if(n%2 == 0) return false;
    if(n%3 == 0) return false;

    ll i = 5,w=2;

    while(i*i <= n){
        if(n%i == 0)return false;

        i += w;
        w = 6 - w;
    }

    return true;
}

ll cmp(string s1 , string s2){
    // 1 for diff
    // 0 for same 

    int n = s1.size();
    int m = s2.size();

    if(n!=m)return 1;

    forn(i,n)
        if(s1[i] != s2[i])return 1;


    return 0; // SAME
}




int main(){

    int n ; cin >> n;

    int arr[n];

    forn(i,n){
        sd(arr[i]);
    }

    int num = 1;
    int ans = 0;
    bool flag = false;

    forn(i,n){
        if(arr[i] == num){
            flag = true;
            num++;
        }
        else ans++;
    }

    if( flag)cout << ans << endl;
    else cout << -1 << endl;


           
     
     
        
    return 0;
}
      
       

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
const int MAX = 10000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    COMinit();

    int r1,c1,r2,c2;
    cin >> r1 >> c1 >> r2 >> c2;

    ll ans = 0;
    for(int i = 0;i <= r2;i++){
        ans += COM(c2+i+1,c2);
        ans %= MOD;
    }

    for(int i = 0;i <= r1-1;i++){
        ans += COM(c1+i,c1-1);
        ans %= MOD;
    }

    ll minus = 0;
    for(int i = 0;i <= r1-1;i++){
        minus += COM(c2+i+1,c2);
        minus %= MOD;
    }


    for(int i = 0;i <= r2;i++){
        minus += COM(c1+i,c1-1);
        minus %= MOD;
    }

    cout << (ans - minus + MOD) % MOD << endl;
}


Measured memory_bytes: 234624
n = gets.to_i
s = gets.chomp

x = s.chars.group_by(&:itself).map{|k, v| [k, v.size]}.to_h.map {|_, num| num == 1 ? 2 : num + 1}.inject(:*) - 1
puts (x % (1000000000 + 7)).to_i


Measured memory_bytes: 8060
def main():
    """
    n=30
     3 6 9 12 13 15 18 21 23 24 27 30
    """
    n = int(input())
    for i in range(1, n + 1):
        x = i
        if x % 3 == 0:
            print("", i, end="")
            continue

        while x > 0:
            if x % 10 == 3:
                print("", i, end="")
                break

            x //= 10

    print("")

if __name__ == "__main__":
    main()

Measured memory_bytes: 6176
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(){
	int N,i;
	long long int A[100001]={},B[100001]={};
	long long int count=0;
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		scanf("%d%d",&A[i],&B[i]);
	}
	for(i=N;i>=1;i--){
		if((A[i]+count)%B[i]!=0) count+=(B[i]-(A[i]+count)%B[i]);
	}
	printf("%lld\n",count);
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,m,t,fl;
int flag=0;
//bool f[41][41];
int minn=1e9;
void dfs(int x,int y,int sum)
{
    if(sum>minn) return;
    if(x<1||x>n||y<1||y>m) return;
    if(x==n&&y==m) minn=min(minn,sum);
    dfs(x+1,y,sum+1);
    dfs(x,y+1,sum+1);
}
int main()
{
	//ios::sync_with_stdio(false);
	int i,j;
	cin>>t;
    while(t--)
    {
        cin>>fl>>n>>m;
        if(n+m>fl) 
        {
            flag=1;
            break;
        }
        if((fl-n-m)%2==1) 
        {
            flag=1;
            break;
        }
    }
    if(flag) cout<<"No";
    else cout<<"Yes";
	//dfs(1,1,a[1][1]);
	//cout<<maxx;
    system("pause");
	return 0;
}

Measured memory_bytes: 504
/** @xigua */
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cstring>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <climits>
#include <bitset>
#include <ctime>
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
const int INF = 1e8 + 5;
const ll inf = 1e15 + 5;
const db eps = 1e-8;
const ll hp = 2333;
const ll base = 1e9+13;

void solve() {
    char s[10];
    int va[10];

    while (cin >> s) {
        for (int i = 0; i < 4; i++) va[i] = s[i] - '0';
        for (int st = 0; st < (1<<3); st++) {
            int val = va[0];
            for (int i = 0; i < 3; i++) {
                if ((1<<i)&st) {
                    val += va[i+1];
                }
                else val -= va[i+1];
            }
            if (val == 7) {
                for (int i = 0; i < 3; i++) {
                    cout << va[i];
                    if ((1<<i)&st) cout << "+";
                    else cout << "-";
                }
                cout << va[3] << "=7" <<endl;
                break;
            }
        }
    }
}

int main() {
    int t = 1, cas = 1;
   //memset(dp, 0, sizeof(dp));
  // freopen("in.txt", "r", stdin);
   // freopen("out.txt", "w", stdout);
   // scanf("%d", &t);
    while(t--) {
        solve();
    }
    return 0;
}


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

int main() {
  double W, H, x, y;
  double S;
  cin >> W >> H >> x >> y;
  S = W * H / 2;
  int second = 0;
  if (x == W / 2 && y == H / 2) {
    second = 1;
  }
  cout << S << " " << second << endl;
  
  return 0;
}


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
 
#define ff first
#define ss second
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define mem(a) memset(a , 0 ,sizeof a)
#define rep(i,a,b) for(int i=a ; i<b ; ++i)
#define deb(x) cout << #x << " - " << x << "\n";
#define deb2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define D2(x) { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define clz(x) __builtin_clzll(x)
#define bit(x) __builtin_popcount(x)
//(a / b) + ((a % b) != 0);
 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 10000000000000000;
const ll MAX_N = 1e5 + 7;

int main() {
    IOS;
    int n,m,x; cin>>n>>m>>x;
    int range = (1<<n);
    vector<int>adj[n+1];
    for(int i=1;i<=n;i++){
        int price; cin>>price;
        adj[i].pb(price);
        for(int j=0;j<m;j++){
            int l; cin>>l;
            adj[i].pb(l);
        }    
    }
    map<int,int>mp;
    int res = INT_MAX;
    for(int i=1;i<range;i++){
        mp.clear();
        int num = i, j = 1,sum = 0;
        while(num!=0&&j<=n){
            if(num&1){
                sum += adj[j][0];
                for(int g=1;g<adj[j].size();g++) mp[g] += adj[j][g];
            }
            j++ , num>>=1;
        }
        bool flag = true;
        for(auto f:mp){
            if(mp[f.first]<x){
                flag = false; break;
            }
        }
        if(flag) res = min(res,sum);
    }
    if(res == INT_MAX) cout<<"-1";
    else cout<<res;
    return 0;
}

Measured memory_bytes: 3664
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn main() {
    input! { n, a: [usize; n] };
    let mut ans = a[0] - 1;
    let mut k = 2;
    for i in 1..n {
        if a[i] == k {
            k += 1;
        } else if a[i] > k {
            ans += (a[i] - 1) / k;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans;
int n,m;


signed main(){
	
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	rep(i,ty-sy)cout<<"U";
	rep(i,tx-sx)cout<<"R";
	rep(i,ty-sy)cout<<"D";
	rep(i,tx-sx)cout<<"L";
	
	cout<<"L";
	rep(i,ty-sy+1)cout<<"U";
	rep(i,tx-sx+1)cout<<"R";
	cout<<"D";
	cout<<"R";
	rep(i,ty-sy+1)cout<<"D";
	rep(i,tx-sx+1)cout<<"L";
	cout<<"U"<<endl;

	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc=  new Scanner(System.in);

        int num = sc.nextInt();

        float f = num/1000f;

        int l = (int)(Math.ceil(f));
        System.out.println(l*1000-num);
    }
}


Measured memory_bytes: 35708
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
long long N;

int ketawa(ll P){
  int keta = 0;
  while(P>0){
    keta+=P%10; P/=10;
  }
  return keta;
}

int main(){
  int K; cin >> K; ll ans = 1, mae=0;
  while(K>0){
    rep(i, 17){
      ll A = (ll)pow(10, i);
      ll ans = pow(10, i);
      rep(j, i){
        ans+=9*(ll)pow(10, j);
      }
      while(ketawa(ans)*(ll)pow(10, i)>=ans){
        if(ans<=mae){
          ans+=A; continue;
        }
        cout << ans << endl;
        mae = ans;
        K--;
        ans+=A;
        if(K==0) break;
      }
      if(K==0) break;
    }
  }
}
    

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int partition (int array[], int l, int r) {
    int pivot = array[r];
    int i = (l - 1);

    for (int j = l; j <= r - 1; j++) {
        if (array[j] <= pivot) {
            i++;
            swap(&array[i], &array[j]);
        }
    }
    swap(&array[i + 1], &array[r]);
    return (i + 1);
}

void quickSort(int array[], int l, int r) {
    if (l < r) {
        int pivot = partition(array, l, r);
        quickSort(array, l, pivot - 1);
        quickSort(array, pivot + 1, r);
    }
}

int main()
{
    int n;
    cin >> n ;
    int w[n]={0};
    rep(i,n) cin >> w[i];
    
    
    //quickSort( w, 0, n-1 );

    int sum=0;
    rep(i,n) sum += w[i];
    int min=10000;
    int sum2=0;
    rep(i,n-1){
        sum2 += w[i];
        int tmp = abs( sum2 - (sum-sum2) );
        if( tmp < min ) min = tmp;
    }

    cout << min << endl;

    return 0;
}


Measured memory_bytes: 256