akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  int *A,*B;

  int C[VMAX+1];
  int n,i,j;
  scanf("%d",&n);

  A=malloc(sizeof(int)*n+1);
  B=malloc(sizeof(int)*n+1);

  for(i=0;i<=VMAX;i++) C[i]=0;

  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++) C[i]=C[i]+C[i-1];

  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }


  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 16276
N, M = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]
L.sort()

A = []
B = []
for i in range(N):
	A.append(L[i][0])
	B.append(L[i][1])
num = 0
cost = 0
i = 0
while num < M:
	cost = cost + A[i]*min(B[i], M - num)
	num = num + min(B[i], M - num)
	i = i + 1

print(cost)

Measured memory_bytes: 29664
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>

#include <fstream>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, b, a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979

typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;

const int INF = 1000000000;
const int MAX = 107;
const int MAX2 = 507;
const int MAXD = 20;
const int BASE = 1000000007;
const int MOD = 1000000007;

int main()
{
    //freopen("in.txt", "r" , stdin);

    int n;
    cin >> n;

    Int A = 1;
    Int B = 1;

    FOR(i,0,n)
    {
        int a , b;
        cin >> a >> b;

        Int k = max((A + a - 1) / a , (B + b - 1) / b);

        A = k * a;
        B = k * b;
    }

    cout << A + B << endl;

    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "bitset"

using namespace std;

//const long long int MOD = 998244353;
const long long int MOD = 1000000007;
const long double EPS = 1e-7;

long long int N, M, K, H, W, L, R;

unsigned int dp[6001][3001][2];

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

	cin >> N >> M;
	M *= 2;
	for (int i = 1; i <= N; i++) dp[0][i][0] = 1;
	dp[0][0][1] = 1;
	for (int i = 1; i <= M; i++) {
		for (int j = 0; j <= N; j++) {
			if (i % 2) {
				if (j) {
					if (j == N) continue;
					dp[i][j][0] += dp[i - 1][j + 1][0];
					dp[i][j][1] += dp[i - 1][j + 1][1];
					dp[i][j][0] += dp[i - 1][j][0];
					dp[i][j][1] += dp[i - 1][j][1];
					dp[i][j][0] %= MOD;
					dp[i][j][1] %= MOD;
				}
				else {
					dp[i][j][1] += dp[i - 1][j][1];
					dp[i][j][1] += dp[i - 1][j + 1][1];
					dp[i][j][1] += dp[i - 1][j + 1][0];
					dp[i][j][0] %= MOD;
					dp[i][j][1] %= MOD;
				}
			}
			else {
				if (j) {
					dp[i][j][0] += dp[i - 1][j - 1][0];
					dp[i][j][0] += dp[i - 1][j][0];
					dp[i][j][1] += dp[i - 1][j - 1][1];
					dp[i][j][1] += dp[i - 1][j][1];
					dp[i][j][0] %= MOD;
					dp[i][j][1] %= MOD;
				}
				else {
					dp[i][j][1] += dp[i - 1][j][1];
					dp[i][j][0] %= MOD;
					dp[i][j][1] %= MOD;
				}
			}
		}
	}
	long long int ans = 0;
	for (int i = 0; i <= N; i++)ans += dp[M][i][1];
	ans %= MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 140928
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    int64_t n, a, b;
    cin >> n >> a >> b;
    if (a > b || (n == 1 && a != b)) {
        cout << 0 << endl;
    } else if (a == b) {
        cout << 1 << endl;
    } else {
        int64_t min = a * (n - 1) + b;
        int64_t max = b * (n - 1) + a;
        cout << max - min + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <ctype.h>
using namespace std;

int main(){
	char ch;
	int counter[26] = {0};

	while( cin >> ch ){
		ch = tolower( ch );
		int num = ch - 'a';
		counter[num]++;
	}

	for( int i = 0; i < 26; i++ ){
		cout << ( char )( 'a' + i ) << " : " << counter[i] << "\n";
	}
	return 0;
}

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

int h[100010];
ll cost[100010];

int main() {
  ll n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> h[i];

  for (int i = 0; i < n; i++) cost[i] = 10000000000;
  cost[0] = 0;

  for (int i = 1; i < n; i++) {
    for (int j = i-1; (i - j <= k) && 0 <= j; j--) {
      cost[i] = min(cost[i], cost[j] + abs(h[i] - h[j]));
    }
  }

  cout << cost[n - 1] << endl;
}


Measured memory_bytes: 1408
import sys

inf = 1 << 60

def solve():
    N, M = map(int, input().split())
    edges = [None] * M

    for i in range(M):
        a, b, c = map(int, sys.stdin.readline().split())
        a, b = a-1, b-1
        edges[i] = (a, b, -c)

    ans = BellmanFord(N, M, edges)
    if ans is None:
        print('inf')
    else:
        print(-ans)

def BellmanFord(N, M, edges):
    d = [inf] * N
    d[0] = 0

    for i in range(N-1):
        for (u, v, c) in edges:
            if d[u] + c < d[v]:
                d[v] = d[u] + c

    #for i in range(N):
    for (u, v, c) in edges:
        if d[u] + c < d[v]:
            if v == N-1:
                return None
            
            d[v] = d[u] + c
    return d[N-1]

if __name__ == '__main__':
    solve()
        


Measured memory_bytes: 40368
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	int n;
	int a[100100]={0};
	cin>>n;
		 ll ans=0;
	REP(i,n)
	{
		int b;
		cin>>b;
		if(b>100000)ans++;
		else 
		a[b]++;
	 } 
	 REP(i,100100)
	 {
	 	if(a[i]<i)ans+=a[i];
	 	if(a[i]>i)ans+=a[i]-i;
	  } 
	  cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 640
#define TEST_SNO	1
#define TEST_ENO	2

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

FILE *in, *ans;
int t;
int v[5];
int k;

int
out(const char *s)
{
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int
outi(int i)
{
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int
getint()
{
	int i;
	fscanf(in, "%d", &i);
	return i;
}

int
getstr(char *s)
{
	fscanf(in, "%s", s);
	return 0;
}

int
sortfnc(const void *v1, const void *v2)
{
	int *i1 = (int *)v1;
	int *i2 = (int *)v2;

	if (*i1 > *i2) {
		return 1;
	}
	else if (*i1 < *i2) {
		return -1;
	}

	return 0;
}

int
chk()
{
	int i, j;
	for (i = 0; i < 4; i++) {
		for (j = i + 1; j < 5; j++) {
			if (v[j] - v[i] > k) {
				return -1;
			}
		}
	}
	return 0;
}

int
fnc()
{
	for (int i = 0; i < 5; i++) {
		v[i] = getint();
	}
	k = getint();
	int r = chk();
	if (r == 0) {
		out("Yay!\n");
	}
	else {
		out(":(\n");
	}

	return 0;
}

int
main()
{
#ifdef TEST
	for (t = TEST_SNO; t <= TEST_ENO; t++) {
		char str[128];
		sprintf(str, "test%d.txt", t);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", t);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


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



int32_t main()
{
    int n,i;
    cin>>n;
    string s[n],x;
    int t[n];
    for(i=0;i<n;i++)
    {
        cin>>s[i]>>t[i];
    }
    cin>>x;

    int sum=0;
    for(i=0;i<n;i++)
    {
        if(s[i]==x)break;
    }
    for(i=i+1;i<n;i++)sum+=t[i];
    cout<<sum<<"\n";
    
    return 0;
}

Measured memory_bytes: 256
//いまだに厳密なところは考察できてない
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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

	int N = getint();
	ll LR[100000];
	rep(i, N) LR[i] = getint() + ((ll)getint() << 32);
	pakuri_sort(N, LR);

	int r1[100000];
	int r2 = 1e9;
	const int m = (1 << 31) - 1;

	r1[0] = LR[0] >> 32;
	rep1(i, N - 1) r1[i] = min(r1[i - 1], (int)(LR[i] >> 32));
	int kotae = (LR[N - 1] >> 32) - (LR[N - 1] & m) + max(-1, r1[N - 2] - (int)(LR[N - 2] & m));

	int lm = (int)(LR[N - 1] & m);
	for (int i = N - 2; i >= 1; i--) {
		chmin(r2, (int)(LR[i + 1] >> 32));
		chmax(kotae, (int)((LR[i] >> 32) - (LR[i] & m) + max(-1, min(r1[i - 1], r2) - lm)));
		chmax(kotae, max(-1, r1[i] - (int)(LR[i] & m)) + max(-1, (int)(r2 - lm)));
	}
	chmin(r2, (int)(LR[1] >> 32));
	chmax(kotae, (int)((LR[0] >> 32) - (LR[0] & m) + max(-1, r2 - lm)));
	chmax(kotae, max(-1, r1[0] - (int)(LR[0] & m)) + max(-1, (int)(r2 - lm)));

	printf("%d", kotae + 2);

	Would you please return 0;
}

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

int main(){
        int a,b,c,x;
        cin>>a>>b>>c;

        x=c;
        for(int i=0; i<10; i++) {
                x=a*x-b;
                cout<<x<<endl;
        }
}


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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int H, W, h, w;
  cin >> H >> W >> h >> w;

  int white = H * W;
  int black = (W * h) + (H * w) - h * w;
  cout << white - black << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int h, w;
bool ba[10][10];

struct Rect {
  int y,x,d;
  Rect(int y, int x, int d) :
    y(y),x(x),d(d) {}
};
vector<Rect> rs;
bool covered[100][10][10];

bool contain(const Rect &a, const Rect &b) {
  if (a.y<=b.y && a.x<=b.x &&
      b.y+b.d<=a.y+a.d && b.x+b.d<=a.x+a.d) return 1;
  return 0;
}
int ans;

void dfs(int cnt, int num) {
  // cout << cnt << " " << num << endl;
  // REP(i,h) {
  //   REP(j,w) cout << ba[i][j] << " ";
  //   cout << endl;
  // }
  if (ans <= num) return;
  if (cnt == rs.size()) {
    REP(i,h)REP(j,w) {
      if (ba[i][j]) return;
    }
    ans = num;
    return;
  }
  int tmp[h][w];
  REP(i,h)REP(j,w)tmp[i][j]=ba[i][j];
  if (ba[rs[cnt].y][rs[cnt].x] == 0) {   
    dfs(cnt+1, num);
  }
  REP(i,rs[cnt].d) REP(j,rs[cnt].d)
    ba[i+rs[cnt].y][j+rs[cnt].x] = 0;

  dfs(cnt+1,num+1);

  REP(i,rs[cnt].d) REP(j,rs[cnt].d) {
    int y = i+rs[cnt].y;
    int x = j+rs[cnt].x;
    ba[y][x] = tmp[y][x];
  }
}

int main() {
  while(cin>>w>>h,h||w) {
    REP(i,h)REP(j,w)cin>>ba[i][j];
    vector<Rect> v;
    REP(y,h)REP(x,w) {
      for (int d=1; y+d<=h&&x+d<=w; ++d) {
        bool ok = 1;
        for (int yy=y; yy<y+d; ++yy) {
          for (int xx=x; xx<x+d; ++xx) {
            if (ba[yy][xx] == 0) ok = 0;
          }
        }
        if (ok) v.push_back(Rect(y,x,d));
      }
    }
    vector<Rect> trs;
    REP(i,v.size()) {
      bool ok = 1;
      REP(j,v.size()) {
        if (i == j) continue;
        if (contain(v[j], v[i])) ok = 0;
      }
      if (ok) trs.push_back(v[i]);
    }
    int cnt[10][10] = {};
    FOR(it, trs) {
      for (int y=it->y; y<it->y+it->d; ++y)
        for (int x=it->x; x<it->x+it->d; ++x)
          cnt[y][x]++;
    }
    rs.clear();
    int base = 0;
    FOR(it, trs) {
      bool flag = 0;
      for (int y=it->y; y<it->y+it->d; ++y)
        for (int x=it->x; x<it->x+it->d; ++x)
          if (cnt[y][x] == 1) {
            flag = 1;
          }
      if (flag) {
        for (int y=it->y; y<it->y+it->d; ++y)
          for (int x=it->x; x<it->x+it->d; ++x)
            ba[y][x] = 0;
        base++;
      } else {
        rs.push_back(*it);
      }
    }
    // cout << base << endl;
    // cout << rs.size() << endl;
    // FOR(it, rs) {
    //   cout << it->y << " " << it->x << " " << it->d << endl;
    // }
    
    ans = INF;
    dfs(0,0);
    cout << ans+base << endl;
  }
}

Measured memory_bytes: 1236
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    let mut next = || { iter.next().unwrap() };
    input_inner!{next, $($r)*}
  };
  ($($r:tt)*) => {
    let stdin = std::io::stdin();
    let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
    let mut next = move || -> String{
      bytes
        .by_ref()
        .map(|r|r.unwrap() as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect()
    };
    input_inner!{next, $($r)*}
  };
}
macro_rules! input_inner {
  ($next:expr) => {};
  ($next:expr, ) => {};

  ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($next, $t);
    input_inner!{$next $($r)*}
  };
}
macro_rules! read_value {
  ($next:expr, ( $($t:tt),* )) => {
    ( $(read_value!($next, $t)),* )
  };

  ($next:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
  };

  ($next:expr, chars) => {
    read_value!($next, String).chars().collect::<Vec<char>>()
  };

  ($next:expr, usize1) => {
    read_value!($next, usize) - 1
  };

  ($next:expr, $t:ty) => {
    $next().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input!{
    N: chars,
  }

  let mut ans = false;
  for c in N {
    if c == '7' {
      ans = true;
    }
  }
  println!("{}", if ans {"Yes"} else {"No"});
}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int ar[105];

int32_t main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	int mn = 1e15;
	for(int i=-100;i<=100;i++){
		int cur = 0;
		for(int j=1;j<=n;j++){
			cur += (ar[j]-i)*(ar[j]-i);
		}
		mn = min(cur,mn);
	}
	cout<<mn;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;
const double pi = 3.1415926535;
/*
https://codeforces.com/contest/1106/problems
https://codeforces.com/contest/1106/submit
*/
const ll mod = 1e9+7;
//快速幂 (a^b)%mod
//如果求逆元，则b = mod-2;
ll pow_quick(ll a,ll b){
    ll r = 1,base = a;
    while(b){
        if(b & 1){
            r *= base;
            r %= mod;
        }
        base *= base;
        base %= mod;
        b >>= 1;
    }
    return r;
}

char a[1000000];
int main(){
    int h,w;
    s(h) s(w)
    gc
    for(int i = 0; i < h; i ++){
        ss(a) gc
        puts(a);
        puts(a);
    }
	return 0;
 }/*
int t[100000];
int main(){
    int n = 0;
    s(n)
    for(int i = 0; i < n ;i ++){
        s(t[i])
    }
    int m;
    s(m)


	return 0;
 }
*/


Measured memory_bytes: 256
const main = (inputs) => {

  var array1 = inputs[0].split(" ");
  var array2 = inputs[1].split(" ");
  var array3 = inputs[2].split(" ");
  var card = array1.concat(array2).concat(array3);
  var bingo = [];
  var answer = 'No';

  for (var i = 3; i < inputs.length; i++) {
    card = card.map(x => {
      if (Number(x) == Number(inputs[i].split(" ")))
        return 'O';
      else
        return x;
    });
  }
  if (card[0] === 'O' && card[1] === 'O' && card[2] === 'O') {
    answer = 'Yes';
  } else if (card[3] === 'O' && card[4] === 'O' && card[5] === 'O') {
    answer = 'Yes';
  } else if (card[6] === 'O' && card[7] === 'O' && card[8] === 'O') {
    answer = 'Yes';
  } else if (card[0] === 'O' && card[3] === 'O' && card[6] === 'O') {
    answer = 'Yes';
  } else if (card[1] === 'O' && card[4] === 'O' && card[7] === 'O') {
    answer = 'Yes';
  } else if (card[2] === 'O' && card[5] === 'O' && card[8] === 'O') {
    answer = 'Yes';
  } else if (card[0] === 'O' && card[4] === 'O' && card[8] === 'O') {
    answer = 'Yes';
  } else if (card[2] === 'O' && card[4] === 'O' && card[6] === 'O') {
    answer = 'Yes';
  }
  console.log(answer);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));

Measured memory_bytes: 21064
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def yn(f) return (f)? "Yes": "No" end
def ynb(f) return (f)? "YES": "NO" end
def ap(a) a.each{|u| p u} end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n = inp[0]
t = []
ans = []
n.times do |i|
  t.push(inps+[i+1])
  t[i][1] = t[i][1].to_i
end
t.sort_by!{|u|u[1]}
t.reverse!
i = 0
t.sort_by!{|u|[u[0],i+=1]}
n.times do |i|
 p t[i][2]
end
=begin

=end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> findnge(vector<int> &ar)
{
	int n = ar.size();
	vector<int> res(n);
	stack<int> st;
	for(int i =0 ;i<n; i++)
	{
		while(st.size() && ar[st.top()] > ar[i])
		{
			res[st.top()] = i;
			st.pop();
		}
		st.push(i);
	}
	while(st.size())
	{
		res[st.top()] = n;
		st.pop();
	}
	return res;
}
int32_t main(){
	int n ;
	cin >> n ;
	vector<int> ar(n);
	for(int i =0 ; i <n ;i++)
	{
		cin >> ar[i];
	}
	vector<int> nge = findnge(ar);
	vector<int> dp( n + 1);
	int sum =0;
	for(int i = n-1 ; ~i ; i--)
	{
		dp[i] = (nge[i] - i) * ar[i] + dp[nge[i]];
		sum += dp[i];
	}
	cout<< sum <<endl;

}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
/**
 * 全てのAを試せる
 */
i32 n,m,q;
vec<i32> a,b,c,d;
i32 A[15];
i32 a_max = -1;
void rec(i32 depth, i32 past_val) {
    if(depth == n) {
        i32 tmp = 0;
        for(i32 i = 0; i < q; ++i) {
            if(A[b[i]] - A[a[i]] == c[i]) tmp += d[i];
        }
        chmax(a_max, tmp);
        return;
    }
    for(i32 p = past_val; p <= m; ++p) {
        A[depth] = p;
        rec(depth+1, p);
    }
}


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i], --b[i];
    }

    rec(0, 1);

    cout << a_max << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,(n)-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,(n)-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int x;

    cin >> x;

    if(x >= 30)puts("Yes");
    else puts("No");

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
long long ans=0;
bool judge(long long s){
    long long cnt3=0, cnt5=0, cnt7=0, tmp=s;
    while(tmp>0){
        if(tmp%10==3) cnt3++;
        else if(tmp%10==5) cnt5++;
        else if(tmp%10==7) cnt7++;
        else return false;
        tmp=tmp/10;
    }
    if(cnt3>0 && cnt5>0 && cnt7>0) return true;
    else return false;
}
int dfs(long long s, long long n){
    bool check;
    check=judge(s);
    if(s<=n && check) ans++;
    if(s>n) return 0;
    long long a=s*10+3, b=s*10+5, c=s*10+7;
    dfs(a, n);
    dfs(b, n);
    dfs(c, n);
}
int main(){
    long long n , s=0;
    cin >>n;
    dfs(s, n);
    cout << ans <<endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for (int i=s;i<=t;i++)
#define pi acos(-1)
#define FOR(i,s,t) for (int i = s; i < t; i++)
typedef long long LL;
typedef long double LD;
typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef pair<PII, PII> PPP;
typedef pair<PII, int> PPI;
typedef pair<LL, PII> PLP;
typedef pair<double, PII> PDP;
#define repp(i,s,t) for (int i=s;i>=t;i--)
template<class T> T sqr(T x) {return x*x;}
#define debug(x) cerr<<#x"="<<(x)<<endl;
#define pb(x) push_back(x);
#define ori(x) x-'a'
#define y0 AERGAEWFAWERAw
#define y1 ASDFAEWRWERWERW
#define x0 gggsdfsfsfdf
#define x1 SAFREWRREWR
int main() {
	LL a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k & 1) cout << b - a << endl;
	else cout << a - b << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

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

  int x;
  double ans;
  if (N % 2 == 0) {
    ans = 0.5;
  } else {
    ans = (double)(N / 2 + 1) / N;
  }

  printf("%.10f\n", ans);

  return 0;
}


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

int main() {
    int N, Z, W;
    cin >> N >> Z >> W;
    vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    long long ans;
    if(N>=2){
        ans = max(abs(W - a[N - 1]), abs(a[N - 1] - a[N - 2]));
    }else{
        ans = abs(W - a[0]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import heapq
import itertools
def main():
    n,k=map(int, input().split())
    v=[int(i) for i in input().split()]
    #k回Vの両端から取り出したり詰めたりして持ってるものの価値の最大化をする
    v_1 = v[::-1]
    #左から取る回数をA、右から取る回数をBとしたとき、価値が負の宝石を捨てる操作は（k-(A+B)）回できる
    #これを利用して全探索
    res = 0
    for i in range(k+1):
        j = 0
        while(i+j<=min(n,k)):

            q = []
            tmp = 0
            if(i>0):
                for l in range(i):
                    if(v[l]<0):
                        heapq.heappush(q,v[l])
                    tmp += v[l]
            if(j>0):
                for l in range(j):
                    if(v_1[l]<0):
                        heapq.heappush(q,v_1[l])
                    tmp += v_1[l]
            for l in range(k-(i+j)):
                if(len(q)>0):
                    z = heapq.heappop(q)
                    tmp -= z
            j+=1
            res = max(res,tmp)

    print(res)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9264
#define DEBUG 0

/**
 * File    : E.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-4-21 10:41:20
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

const int MAX_SIZE = 1000010;
bool isprime[MAX_SIZE];
vector<int> prime_num;

void init()
{
  fill(isprime, isprime + MAX_SIZE, true);
  isprime[0] = isprime[1] = false;
  for (auto i = 2; i < MAX_SIZE; i++)
  {
    if (isprime[i])
    {
      prime_num.push_back(i);
      for (auto j = 2; i * j < MAX_SIZE; j++)
      {
        isprime[i * j] = false;
      }
    }
  }
}

vector<long long> make_factors(long long x)
{ // 2 \leq x \leq MAX_SIZE^2
  vector<long long> ans;
  auto it = prime_num.begin();
  while (it != prime_num.end())
  {
    if (x == 1)
    {
      break;
    }
    while (x % *it == 0)
    {
      ans.push_back(*it);
      x /= *it;
    }
    it++;
  }
  if (x != 1)
  {
    ans.push_back(x);
  }
  return ans;
}

ll N;
ll a[100010];
set<ll> S;
vector<ll> ans;

void make_primes()
{
  for (auto it = prime_num.begin(); it != prime_num.end(); it++)
  {
    if (*it <= N)
    {
      S.insert(*it);
#if DEBUG == 1
      cerr << "S.insert(" << *it << ")" << endl;
#endif
    }
    else
    {
      break;
    }
  }
  auto W = make_factors(abs(a[N]));
  for (auto x : W)
  {
#if DEBUG == 1
    cerr << "W inclues " << x << endl;
#endif
    S.insert(x);
  }
}

void flush()
{
  if (ans.empty())
  {
    cout << endl;
    return;
  }
  sort(ans.begin(), ans.end());
  for (auto x : ans)
  {
    cout << x << endl;
  }
}

void check_prime(ll p)
{
  vector<ll> A(min(p, N + 1), 0);
  A[0] = a[0];
  for (auto i = 1; i <= N; i++)
  {
    ll t = i % (p - 1);
    if (t == 0)
    {
      t = p - 1;
    }
    A[t] += a[i];
  }
  bool ok = true;
  for (auto x : A)
  {
    if (x % p != 0)
    {
      ok = false;
      break;
    }
  }
  if (ok)
  {
    ans.push_back(p);
  }
}

int main()
{
  init();
  cin >> N;
  for (auto i = 0; i <= N; i++)
  {
    cin >> a[i];
  }
  reverse(a, a + N + 1);
  make_primes();
  for (auto x : S)
  {
    check_prime(x);
  }
  flush();
}

Measured memory_bytes: 1916
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int N, M;
vector<vector<PII>> E;
vector<int> D;

bool dfs(int on){
    bool res = true;
    for(PII &e:E[on]){
        int to = e.fs;
        int d = e.sc;
        if(D[to]!=1<<30 && D[to]!=D[on]+d) return false;
        if(D[to]==1<<30){
            D[to] = D[on] + d;
            res &= dfs(to);
        }
    }
    return res;
}




int main() {
    cin >> N >> M;
    E.resize(N);
    D.resize(N, 1<<30);
    for(int i=0; i<M; i++){
        int l, r, d; cin >> l >> r >> d;
        l--;
        r--;
        E[l].push_back({r, d});
        E[r].push_back({l, -d});
    }
    
    
    for(int i=0; i<N; i++){
        if(D[i]==1<<30){
            D[i] = 0;
            if(!dfs(i)){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

const ll MOD = 1e9+7;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    ll H,W,D,Q;
    cin >>H>>W>>D;
    vector<vll> A(H+1,vll(W+1));
    vpii HW(H*W+1);
    vll kyo(H*W+1,0);
    FOR(h,1,H){
        FOR(w,1,W){
            cin >>A[h][w];
            HW[A[h][w]]=mp(h,w);
        }
    }
    FOR(i,1+D,H*W){
        kyo[i]=kyo[i-D]+abs(HW[i].fi-HW[i-D].fi)+abs(HW[i].se-HW[i-D].se);
    }
    cin >>Q;
    ll L,R;
    FOR(i,1,Q){
        cin >>L>>R;
        cout <<(kyo[R]-kyo[L])<<endl;
    }

    return 0;
}

Measured memory_bytes: 3200
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VL a(n);
  REP(i, 0, n) cin >> a[i];
  REP(i, 0, n) {
    if (a[i] > i) {
      cout << -1 << endl;
      return 0;
    }
    if (i >= 1) {
      if (a[i] - a[i - 1] > 1) {
	cout << -1 << endl;
	return 0;
      }
    }
  }
  ll tot = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (i == n - 1 || a[i + 1] - a[i] != 1) {
      // create a mountain
      tot += a[i];
    }
  }
  cout << tot << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>

using namespace std;

typedef long long ll;


int kaizyou(int n,ll sum);

int n;
ll ans=1;

int main(){
	while(cin >> n){
		ans = 1;
		kaizyou(n,ans);
		cout << ans << endl;
	}
}

int kaizyou(int n,ll sum){
	if(n > 1){
		ans = sum * n;
		kaizyou(n - 1,ans);
	}

}

Measured memory_bytes: 3076
#include <stdio.h>
#include <set>

using namespace std;

int n,tmp;
set<int> s;

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&tmp);
    if(s.find(tmp)!=s.end()){
      s.erase(tmp);
    }else{
      s.insert(tmp);
    }
  }
  printf("%lu\n", s.size());
}


Measured memory_bytes: 4864
#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;
typedef long double ld;
ld dp[505][105][105]={};
    
int main(){
    int h,n,p,m,K;
    cin >> h >> n >> p >> m >> K;
    vector<int>v(h+1,-1);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        v[a] = b;
    }
    dp[h+1][0][p] = 1.0;
    for(int i=h;i>=1;i--){
        for(int j=0;j<=K;j++){
            for(int k=1;k<=n;k++){
                if(v[i]==-1){
                    dp[i][j][k] =dp[i+1][j][k];
                    if(j>=1){
                        if(k==1||k==n){
                            dp[i][j][k] += dp[i+1][j-1][k]*(ld)(n-2);
                        }else{
                            dp[i][j][k] += dp[i+1][j-1][k]*(ld)(n-3);
                        }
                        if(k!=1){
                            dp[i][j][k] += dp[i+1][j-1][k-1];
                        }
                        if(k!=n){
                            dp[i][j][k] += dp[i+1][j-1][k+1];
                        }
                    }
                }else{
                    if(k==v[i]){
                        dp[i][j][k] = dp[i+1][j][k+1];
                    }else if(k==v[i]+1){
                        dp[i][j][k] = dp[i+1][j][k-1];
                    }else{
                        dp[i][j][k] = dp[i+1][j][k];
                    }
                }
            }
        }
    }
    ld sm = 0.0;
    for(int i=1;i<=n;i++){
        sm += dp[1][K][i];
    }
    ld mx = 0.0;
    for(int i=1;i<=n;i++){
        mx = max(mx,dp[1][K][i]/sm);
    }
    cout << fixed << setprecision(15) << mx << endl;
    return 0;
}


Measured memory_bytes: 88064
#include <stdio.h>

int A[100000+2];

void temp(int A[], int i, int j) {
	int t;
	t = A[i];
	A[i] = A[j];
	A[j] = t;
}

int partition(int A[], int p, int r) {
	int x,i,j,t;
	x = A[r];
	i=p;
	for(j=p;j<r;j++) {
		if(A[j] <= x) {
			temp(A, i, j);
			i++;
		}
	}
	
	temp(A, i, r);
	return i;
}

int main(void) {
	int n,i,t;
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%d", &A[i]);
	}
	
	t = partition(A, 0, n-1);
	for(i=0;i<n;i++) {
		if(t == i) { printf("[%d]", A[i]); }
		else { printf("%d", A[i]); }
		
		if(i<n-1) { printf(" "); }
		else { printf("\n"); }
	}
	
	return 0;
}



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

	bool is_prime[10000000];
int main()
{	
	is_prime[0]=is_prime[1]=false;
	for(int i=2; i<10000000; i++){
		is_prime[i]=true;
	}
	
	for(int i=2; i*i<10000000; i++){
		if(is_prime[i]){
			for(int j=i*i; j<10000000; j+=i){
				is_prime[j]=false;
			}
		}
	}
	
	while(true){
		int n;
		cin>>n;
		
		if(n==0)
			break;
		
		while(true){
			while(!is_prime[n]){
				n--;
			}	
		
			if(is_prime[n-2] && is_prime[n-6] && is_prime[n-8])
				break;
			else n--;
		}
			cout<<n<<endl;
	}
}
		

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

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

	int count;
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) {
			b[i] = a[i];
			count++;
			c[i] = a[i];
			count++;
		}
		else if (a[i] == b[i] && b[i] != c[i] && c[i] != a[i]) {
			c[i] = a[i];
			count++;
		}
		else if (a[i] != b[i] && b[i] == c[i] && c[i] != a[i]) {
			a[i] = b[i];
			count++;
		}
		else if (a[i] != b[i] && b[i] != c[i] && c[i] == a[i]) {
			b[i] = c[i];
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

char f[61][31];
vector<pair<int,int>> g[4000];
int d[4000];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int w,h;
	while(cin >> w >> h,h){
		for(int i=0;i<4000;i++){
			g[i].clear();
			d[i]=1e9;
		}
		int s=2*h*w,t=2*h*w+1;
		int a=h*w;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> f[i][j];
				if(f[i][j]=='S'){
					g[s].push_back({i*w+j,0});
					g[s].push_back({a+(i*w+j),0});
				}
				if(f[i][j]=='T'){
					g[i*w+j].push_back({t,0});
					g[a+(i*w+j)].push_back({t,0});
				}
			}
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				for(int k=1;k<=3;k++){
					for(int l=-(3-k);l<=(3-k);l++){
						int x=i+l,y=j+k;
						if(0<=x&&x<h&&0<=y&&y<w){
							if(f[x][y]!='X'){
								if(f[x][y]=='S'||f[x][y]=='T'){
									g[i*w+j].push_back({a+(x*w+y),0});
								}
								else{
									g[i*w+j].push_back({a+(x*w+y),f[x][y]-'0'});
								}
							}
						}
						x=i+l,y=j-k;
						if(0<=x&&x<h&&0<=y&&y<w){
							if(f[x][y]!='X'){
								if(f[x][y]=='S'||f[x][y]=='T'){
									g[a+(i*w+j)].push_back({(x*w+y),0});
								}
								else{
									g[a+(i*w+j)].push_back({(x*w+y),f[x][y]-'0'});
								}
							}
						}
					}
				}
			}
		}
		priority_queue<pair<int,int>> q;
		q.push(make_pair(0,s));
		d[s]=0;
		while(q.size()){
			auto p=q.top(); q.pop();
			if(-p.first!=d[p.second])continue;
			for(auto to:g[p.second]){
				if(d[to.first]>d[p.second]+to.second){
					d[to.first]=d[p.second]+to.second;
					q.push(make_pair(-d[to.first],to.first));
				}
			}
		}
		if(d[t]==1e9){
			printf("-1\n");
		}
		else{
			printf("%d\n",d[t]);
		}
	}
}


Measured memory_bytes: 3788
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();
		int[] A=new int[N+1];
		
		for(int i=0;i<N+1;i++) {
			A[i]=0;
		}
		
		for(int i=1;i<K+1;i++) {
			int d=sc.nextInt();
			for(int j=0;j<d;j++) {
				int l=sc.nextInt();
				A[l]++;
			}
		}
		
		int count=0;
		
		for(int k=1;k<N+1;k++) {
			if(A[k]==0) {
				count++;
			}
		}
		
		System.out.println(count);
		
	}
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int t = 1900 * M + 100 * (N - M);
  int ans = t * pow(2, M);
  cout << ans << "\n";
  return 0;
}

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

int n,m;
vector<vector<int>> edge(10);

int main(){
    cin >> n >> m;
    rep(i,m){
        int a,b; cin >> a >> b;
        --a;--b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> root;
    rep(i,n) root.push_back(i);
    int cnt = 0;
    do{
        bool flag = true;
        rep(i,n-1){
            vector<int> s = edge[root[i]];
            if(find(ALL(s),root[i+1]) == s.end()) flag = false;
            if(root[0] != 0) flag = false;
        }
        if(flag) cnt++;
    }while(next_permutation(ALL(root)));
    cout << cnt << endl;
}

Measured memory_bytes: 256
n=int(input())
s=[]
t=[]
for _ in range(n):
    s.append(input())
    
m=int(input())

for _ in range(m):
    t.append(input())
    
point=[None]*100

max_point=0

for i in range(len(s)):
    point_s=s.count(s[i])
    point_t=-1*t.count(s[i])
    point_sum=point_s+point_t
    max_point=max(max_point,point_sum)
    
print(max_point)

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

#define REP(i,n) for(ll i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

using namespace std;
typedef long long ll;
int main(){
  vector<int> A={0,0,0};
  cin >> A[0] >>A[1] >>A[2];
  sort(A.begin(),A.end());
  cout << A[0]+A[1] << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n , x; cin >> n;
    deque<int> Q;
    cin >> x;
    Q.pb(x);
    int length = 1;
    for(int i = 0 ;i < n-1 ; i++){
        cin >> x;
        if(x <= Q[0]){
            Q.push_front(x);
            length++;
        }
        else if(x > Q[length-1])
            Q[length-1] = x;
        else{
            int l = 0 , r = length-1 , ans = -1;
            while(l <= r){
                int mid = (l+r)/2;
                if(Q[mid] <  x){
                    ans = mid;
                     l = mid+1;
                }
                else    
                    r = mid-1;
            }
            Q[ans] = x;
        }        
    }
    cout << length << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline void chmin(T &a, T b){if(a>=b)a=b;}
template<class T> inline void chmax(T &a, T b){if(a<=b)a=b;}
typedef long long ll;
const int INF = 1e9;

int N;
int H[30];

int main(){
    cin >> N;
    REP(i,N) cin >> H[i];

    int t = H[0];
    int ans = 1;
    for(int i = 1; i < N; ++i){
        if(t <= H[i]){
            ++ans;
            t = H[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256