akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,p,bp=1;
  int flag = 0;
  int cnt=0;
  cin >> n;
  vector<int> buttons(n);
  for(int i=0;i<n;i++) cin >> buttons.at(i);
  while(flag == 0){
    p = buttons.at(bp-1);
    buttons.at(bp-1) = 0;
    if(buttons.at(p-1) == 0) flag = -1;
    else if(p == 2) flag = 1;
    bp = p;
    cnt++;
  }
  if(flag == 1) cout << cnt << endl;
  else cout << "-1" << endl;
}

Measured memory_bytes: 640
from collections import deque
n,m = map(int,input().split())
e1 = [[] for i in range(n)]
e2 = [[] for i in range(n)]
l = []
for i in range(m):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    e1[a].append(b)
    e2[b].append(a)
    l.append([a,b,c])

def search(x,e):
    dis = [0]*n
    dis[x] = 1
    q = deque([])
    q.append(x)
    while q:
        now = q.popleft()
        for nex in e[now]:
            if dis[nex] == 0:
                dis[nex] = 1
                q.append(nex)

    return dis

dis1 = search(0,e1)
dis2 = search(n-1,e2)
dis = [0]*n
for i in range(n):
    if dis1[i] == 1 and dis2[i] == 1:
        dis[i] = 1

li = []
for i in range(m):
    a,b,c = l[i]
    if dis[a] == 1 and dis[b] == 1:
        li.append(l[i])

ans = [-float("INF")]*n
ans[0] = 0

for i in range(2*n):

    check = False
    for i,j,k in li:
        if ans[i]+k > ans[j]:
            ans[j] = ans[i]+k
            check = True
    
    if not check:
        print(ans[-1])
        exit()
print("inf")

Measured memory_bytes: 48744
while True:
    try:
        a, b, c, d, e, f = map(float, input().split())
        z = a * e - b * d
        x = (c * e - b * f) / z
        y = (a * f - c * d) / z
        print("{:.3f} {:.3f}".format(x + 0, y + 0))
    except:
        break

Measured memory_bytes: 6744
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(usize);
    let vs = scan!(i64;;);

    let mut m = HashMap::new();
    for &v in vs.iter() {
        let n = if v >= 3200 { 8 } else { v / 400 };
        let val = m.entry(n).or_insert(0);
        *val += 1
    }

    let s = m.len();
    if m.contains_key(&8) {
        let &w = m.get(&8).unwrap();
        if n == w {
            println!("1 {}", w)
        } else {
            println!("{} {}", s - 1, s + w - 1)
        }
    } else {
        println!("{} {}", s, s)
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	int C,N,M;
	cin >> N >> M >> C;
	vector<int> B(M);
	rep(i,M) cin >> B[i];
	vector<vector<int>> A(N,vector<int>(M));
	rep(i,N) rep(j,M) cin >> A[i][j];
	int ans = 0;
	rep(i,N) {
		int sum = 0;
		rep(j,M) sum += A[i][j] * B[j];
		sum += C;
		if(sum > 0) ans++;
	} 
	cout << ans << endl;


  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

ll n, m, k;
vector <vector <ll>> vec;
vector <vector <ll>> dp;
vector <ll> height;

const ll INF = 1e9;

int main() {
	cout << fixed << setprecision(15);
	cin >> n;
	ld res = 0;
	for (int i = 0; i < n; ++i) {
		ld x;
		cin >> x;
		res += 1 / x;
	}
	cout << 1 / res;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	m := make(map[rune]int)
	for _, v := range s {
		m[v]++
	}
	ok := true
	for _, v := range m {
		if v%2 != 0 {
			ok = false
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <climits>
using namespace std;

typedef long long ll;

const int N = (int)2e5+77;

int n,m,x;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    int two = 0, four = 0, other = 0;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (x % 4 == 0) four++;
        else if (x % 2 == 0) two++;
        else other++;
    }

    if (!two) {
        if (other > four + 1) return cout << "No\n", 0;
    } else {
        if (other > four) return cout << "No\n", 0;
    }

    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
def knapsack(n, w, info):
    sum_v = 0
    for i in range(n):
        value = info[i][0]
        sum_v += value

    # dp[i][j] := i番目までの品物の中から価値の総和がjとなるように選んだときの、
    #             重さの総和の最小値
    dp = [[float("inf")]*(sum_v + 1) for i in range(n + 1)]
    dp[0][0] = 0

    for i in range(n):
        for j in range(sum_v + 1):
            weight = info[i][1]
            value = info[i][0]
            if j < value:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = min(dp[i][j], dp[i][j - value] + weight)
    ans = 0
    for j in range(sum_v + 1):
        if dp[n][j] <= w:
            ans = j
    return ans


n, w = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]
print(knapsack(n, w, info))



Measured memory_bytes: 13888
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template <typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}
template<class T> bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1;}
    return 0;
}
template<class T> bool chmin(T & a, const T & b) { if (a > b) { a = b; return 1;}
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    double ans = 1 - (N / 2) / (double)N;
    printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string S,T;
  bool ans=false;
  cin>>S>>T;
  for(int i=0;i<S.size();i++){
    S=S.back()+S;
    S.pop_back();
    if(S==T){
      cout<<"Yes"<<endl;
      ans=true;
      break;
    }
  }
  if(ans==false){
    cout<<"No"<<endl;
  }
  return 0;

}


Measured memory_bytes: 256
// Problem : D - Widespread
// Contest : AtCoder - AtCoder Beginner Contest 063
// URL : https://atcoder.jp/contests/abc063/tasks/arc075_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}
bool check(int x,vi &v,int a,int b)
{
	vi vt;
	vt=v;
	for(int &i:vt)
	i-=x*b;
	int cnt=0;
	for(int i=0;i<size(vt);i++)
	{
		if(vt[i]>0)
		{
			int xtra=(vt[i]+(a-b)-1)/(a-b);
			cnt+=xtra;
		}
	}
	if(cnt<=x)return true;
	return false;
}
void solve()
{
int n,a,b;cin>>n>>a>>b;
vi v(n);cin>>v;
int worst=0;
for(int i:v)
worst+=(i+b-1)/b;
int l=0,h=worst;
int ans=worst;
while(l<=h)
{
	int mid=(l+h)/2;
	if(check(mid,v,a,b))
	{
		ans=mid;
		h=mid-1;
	}
	else
	l=mid+1;
}
cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin >> N;
  int pre = -1, cnt = 0;
  for(int i = 0; i < N; ++i){
    int x; cin >> x;
    if(x == pre){
      cnt++;
      x = -1;
    }
    pre = x;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
int n,s;
while(cin>>n>>s,n||s){
bool in[10]={0};
rep(i,n)in[i]=1;
sort(in,in+10);
int co=0;
do{
int sum=0;
rep(i,10)if(in[i])sum+=i;
if(sum==s)co++;
}while(next_permutation(in,in+10));
cout<<co<<endl;
}
}

Measured memory_bytes: 1176
#include<stdio.h>

int main(void){
	  int A;
	  int B;
	  scanf("%d%d", &A, &B);
	  int count = 0;
	  int total = 1;
	  while(total < B){
		total -= 1;
	        total += A;
		count++;
		
	  }
	  printf("%d\n",count);
	  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+99;
int n,s[N][21];
ll ans;
bool count(int l,int r)
{
	for(int j=0;j<20;j++)
	if(s[r][j]-s[l-1][j]>=2)return 1;
	return 0;
}
int main()
{
	cin>>n;
	for(int i=1,x;i<=n;i++)
	{
		scanf("%d",&x);
		for(int j=0;j<20;j++)
		if(x&(1<<j))s[i][j]=s[i-1][j]+1;
		else s[i][j]=s[i-1][j];
	}
	for(int l=1,r=1;r<=n;r++)
	{
		while(l<=r&&count(l,r))l++;
		ans+=r-l+1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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 int MAX = 1000010;
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;
}


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

	int x, y;
	cin >> x >> y;
	if((x + y) % 3 != 0) {
		cout << 0 << endl;
		return 0;
	}

	int m, n;
	n = ((2 * y - x) / 3) % MOD;
	m = ((2 * x - y) / 3) % MOD;

	if(m < 0 || n < 0) {
		cout << 0 << endl;
	} else {
		COMinit();
		cout << COM(n + m, n) << endl;
	}
	//cout << comb(x, y) << endl;
	return 0;
}


Measured memory_bytes: 23808
import sys
input = sys.stdin.readline
import math
a = math.sqrt(3) * 0.5
def koch(d, p1, p2):
    if d == 0:
        return
    else:
        s = [(2*p1[0]+p2[0])/3, (2*p1[1]+p2[1])/3]
        t = [(p1[0]+2*p2[0])/3, (p1[1]+2*p2[1])/3]
        u = [(t[0]-s[0])*0.5-(t[1]-s[1])*a+s[0], (t[0]-s[0])*a+(t[1]-s[1])*0.5+s[1]]
        koch(d-1, p1, s)
        print(s[0], s[1])
        koch(d-1, s, u)
        print(u[0], u[1])
        koch(d-1, u, t)
        print(t[0], t[1])
        koch(d-1, t, p2)

def main():
    n = int(input())
    p1 = [0, 0]
    p2 = [100, 0]
    print(p1[0], p1[1])
    koch(n, p1, p2)
    print(p2[0], p2[1])


if __name__ == '__main__': main()


Measured memory_bytes: 5756
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,z,w;
    cin>>n>>z>>w;
    vector<ll> a(n);
    REP(i,n) cin>>a[i];
    if(n==1) cout<<abs(a[0]-w)<<endl;
    else cout<<max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]))<<endl;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll A, B, N;
	cin >> A >> B >> N;

	ll ans = 0;
	if (N >= B){
		ans = (A * (B-1)) / B;
	} else {
		ans = (A * N) / B;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
/* ---------------------- ここから ---------------------- */

namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

ll n,q;
string s;
int main() {
    INIT();

    cin >> n;
    unordered_map<int, int> a(n + 1);
    for(ll i = 0; i < n; i++) {
        int tmpA;
        cin >> tmpA;
        if(a.count(tmpA) == 0) {
            a[tmpA] = 0;
        }
        a[tmpA]++;
    }
    Bint r = 0;
    for(auto&& [key, value] : a) {
        r += key * value;
    }
    cin >> q;
    while(q--) {
        int b,c;
        cin >> b >> c;
        a[c] += a[b];
        r += (c - b) * a[b];
        a.erase(b);
        cout << r << endl;
    }
}

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


const int inf = 1<<20;
const int N = 311;
int n,src,snk,m;
int c[N][N],vis[N],pa[N];
vector<int> adj[N];

int get_path(){
    memset(vis,-1,sizeof vis); // vis[u] = min capacity on the way to u
    memset(pa,-1,sizeof pa); // pa[u] = parent[u] in BFS
    queue<int> q;
    q.push(src);
    vis[src] =  inf;
    while(q.size()){
        int u = q.front(); q.pop();
        if(u == snk) return vis[u];
        for(int v : adj[u]){
            if(vis[v] == -1 && c[u][v] > 0){
                vis[v] = min(vis[u],c[u][v]);
                pa[v] = u;
                q.push(v);
            }
        }
    }
    return 0;
}

void augment(int f){
    int u = snk;
    while(pa[u]!=-1){
        c[pa[u]][u] -= f;
        c[u][pa[u]] += f;
        u = pa[u];
    }
}

int maxflow(){
    int mf = 0,f;
    while(f = get_path()){
        mf += f;
        augment(f);
    }
    return mf;
}

void init(){
    for(int i=0;i<N;i++) adj[i].clear();
    memset(c,0,sizeof c);
}

int main(){
init();
int n , m ;
char a[300][300];
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++)scanf("%s",a+i);
src=0;
snk=n+m+1;
for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){

            if( a[i][j]=='o' ){
                c[i+1][n+j+1]=1;
                c[n+j+1][i+1]=1;
                adj[i+1].push_back(n+j+1);
                adj[n+j+1].push_back(i+1);
            }
            if( a[i][j]=='S' ){
                c[src][n+j+1]=inf;
                c[src][i+1]=inf;
                c[n+j+1][src]=inf;
                c[i+1][src]=inf;
                adj[src].push_back(n+j+1);
                adj[n+j+1].push_back(src);
                adj[src].push_back(i+1);
                adj[i+1].push_back(src);
            }
            if( a[i][j]=='T' ){
                c[n+j+1][snk]=inf;
                c[i+1][snk]=inf;
                c[snk][n+j+1]=inf;
                c[snk][i+1]=inf;
                adj[snk].push_back(n+j+1);
                adj[n+j+1].push_back(snk);
                adj[snk].push_back(i+1);
                adj[i+1].push_back(snk);
            }

        }

int ans = maxflow();
if( ans >= inf )ans=-1;
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long int
#define st string
#define be begin
#define en end
#define sr sort
#define sz size
#define lt length
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(b<=(a+1)/2)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int in_num = 1;
    int scan_num = 0;

    while(true) {
      scan_num = stdIn.nextInt();
      if (scan_num == 0) {
        break;
      }
      System.out.println("Case "+ in_num + ": " + scan_num);
      in_num++;
    }
  }
}

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

int main()
{
    string steps, result;
    cin >> steps;

    int mask = 1;
    bool ok = true;
    for (int i=0; i<steps.size(); i++) {
        if (ok == false) {
            break;
        }

        if (mask == 1) {
            if ((steps[i] == 'R') || (steps[i] == 'U') || (steps[i] == 'D')) {
                ok = true;
            }
            else {
                ok = false;
            }
        }
        else {
            if ((steps[i] == 'L') || (steps[i] == 'U') || (steps[i] == 'D')) {
                ok = true;
            }
            else {
                ok = false;
            }
        }
        mask += 1;
        mask &= 0x01;
    }

    if (ok == true) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

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

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

  int res = 0;
  for (int a = 1; a <= k; ++a) {
    for (int b = 1; b <= k; ++b) {
      for (int c = 1; c <= k; ++c) {
        res += gcd(gcd(a, b), c);
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int M = sc.nextInt();
            int[] D = new int[M];
            long[] C = new long[M];
            for (int i = 0; i < M; i++) {
                D[i] = sc.nextInt();
                C[i] = sc.nextLong();
            }

            long ans = 0;
            long x = 0;
            for (int i = 0; i < M; i++) {
                ans += C[i];

                x += D[i] * C[i];
                ans += (x - 1) / 9;
                x = (x - 1) % 9 + 1;
            }

            ans = ans - 1;

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 102516
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  cin>>n>>m;
  int MOD=1000000007;

  if(n==1||(m+1)<(n-1)){
    cout<<(m+1)%MOD<<endl;
    return 0;
  }
  
  int ans=0;
  int p=((m+1)/(n-1))%MOD,k=((m+1)%(n-1))%MOD;
  //cout<<p<<" "<<k<<endl;
  ans=p*(p-1)%MOD;
  ans*=(n-1);
  ans%=MOD;
  ans+=(p*k*2)%MOD;
  ans%=MOD;
  ans+=(m+1);
  ans%=MOD;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3080
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,X,M; cin>>N>>X>>M;
  
  ll s,roop;
  vector<ll> list(M,-1); list[X]=0;
  vector<ll> vec(1,X);
  for(int i=1;;i++){
    ll A=vec[i-1]*vec[i-1]%M;
    if(list[A]>-1) {s=list[A]; roop=i-s; break;}
    else{
      list[A]=i;
      vec.push_back(A);
    }
  }
  
  //rep(i,vec.size()) {if(i!=0) cout<<" "; cout<<vec.at(i);} cout<<'\n';
  
  ll sz=vec.size();
  ll ans=0;
  ll sum=0;
  for(int i=s;i<s+roop;i++) sum+=vec[i];
  rep(i,s) ans+=vec[i];
  N-=s;
  ans+=N/roop*sum;
  N%=roop;
  for(int i=s;i<s+N;i++) ans+=vec[i];
  
  cout<<ans<<'\n';
    
  
  return 0;
}


Measured memory_bytes: 4592
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char p[10010], q[5010], res[5010];
int n, K, C[10100];
int main() {
	int i, j;
	scanf("%d%d", &n, &K);
	scanf("%s", p+1);
	char Mn = 'z';
	for (i = 1; i <= n; i++) {
		if (Mn > p[i])Mn = p[i];
	}
	if (K >= 15) {
		for (i = 1; i <= n; i++)printf("%c", Mn);
		puts("");
		return 0;
	}
	for (i = 1; i <= n; i++)p[n + n + 1 - i] = p[i];
	if (K == 1) {
		for (i = 0; i < n; i++)res[i] = 'z';
		for (i = 1; i <= n; i++) {
			for (j = 0; j < n; j++)q[j] = p[i + j];
			if (strcmp(q, res) < 0) {
				for (j = 0; j < n; j++)res[j] = q[j];
			}
		}
		printf("%s\n", res);
		return 0;
	}
	int Mx = -1;
	for (i = 1; i <= n + n; i++) {
		C[i] = C[i - 1] + 1;
		if (p[i] != Mn)C[i] = 0;
		Mx = max(Mx, C[i]);
	}
	for (i = 0; i < n; i++)res[i] = 'z';
	for (i = n; i <= n + n; i++) {
		if (Mx == C[i]) {
			int c = 0;
			for (j = i; j >= i - n + 1; j--) {
				q[c++] = p[j];
			}
			if (strcmp(q, res) < 0) {
				for (j = 0; j < n; j++)res[j] = q[j];
			}
		}
	}
	for (i = 1; i < K; i++) {
		Mx = min(Mx * 2, n);
	}
	for (i = 0; i < Mx; i++)printf("%c", Mn);
	if (Mx < n) {
		for (i = 0; res[i] == Mn; i++);
		int t = i;
		for (i = 0; i < n - Mx; i++)printf("%c", res[t + i]);
	}
	puts("");
}

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

int main(){
	long long w, h;
	long long w1,w2,h1,h2;
	cin >> w >> h;	
	
	
	if(h==1 || w==1){
		cout << 1 << "\n";	
	}else{
		w1 = (w%2) ? (w/2)+1 : (w/2);
		w2 = w-w1;
		h1 = (h%2) ? (h/2)+1 : (h/2);
		h2 = h-h1;
		
		cout << (w1*h1)+(w2*h2) << "\n";
	}
}



Measured memory_bytes: 3568
# Aizu Problem 0010: Circumscribed Circle of a Triangle
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def circumscribed_circle(x1, y1, x2, y2, x3, y3):
    d = 2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
    px = ( (x1**2 + y1**2) * (y2 - y3) + (x2**2 + y2**2) * (y3 - y1) + (x3**2 + y3**2) * (y1 - y2) ) / d
    py = ( (x1**2 + y1**2) * (x3 - x2) + (x2**2 + y2**2) * (x1 - x3) + (x3**2 + y3**2) * (x2 - x1) ) / d
    a = math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
    b = math.sqrt((x1 - x3)**2 + (y1 - y3)**2)
    c = math.sqrt((x2 - x3)**2 + (y2 - y3)**2)
    s = (a + b + c) / 2
    A = math.sqrt(s * (s - a) * (s - b) * (s - c))
    r = a * b * c / (4 * A)
    return px, py, r

          
N = int(input())
for k in range(N):
    x1, y1, x2, y2, x3, y3 = [float(_) for _ in input().split()]
    px, py, r = circumscribed_circle(x1, y1, x2, y2, x3, y3)
    print("%.3f %.3f %.3f" % (px, py, r))

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

using namespace std;

int main() {
    long long n;
    cin >> n;
    string str = "";
    while (n) {
        int id = n % 26;
        n /= 26;
        if (!id) id = 26, n--;
        str = (char)(id + 'a' - 1) + str;
    }
    cout << str;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 998244353;


void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    cin >> a[i];
    ll x = 1000;
    for (int i = 1; i < n; ++i) {
        if (a[i] > a[i - 1]) {
            ll q = x / a[i - 1];
            x = x % a[i - 1];
            x += q * a[i];
        }
    }
    cout << x << endl;
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, deque<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int N, M, Q;
deque<int> a;

bool solve() {
    vector<int> b(M);
    for (int i = 0; i < M; ++i) b[i] = i;
    map<int,int> id;
    int iter = 0;
    for (int i = 0; i < a.size(); ++i) {
        if (id.count(a[i])) continue;
        id[a[i]] = iter++;
    }
    for (int i = 0; i < b.size(); ++i) {
        if (id.count(b[i])) continue;
        id[b[i]] = iter++;
    }
    for (int i = 0; i < a.size(); ++i) a[i] = id[a[i]];
    for (int i = 0; i < b.size(); ++i) b[i] = id[b[i]];

    vector<int> con(id.size(), 0);
    for (int i = 0; i < a.size(); ++i) {
        if (a[i] == 0) con[a[i]]++;
        else if (con[a[i]] + 1 <= con[a[i]-1]) con[a[i]]++;
    }
    for (int i = 0; i < b.size(); ++i) {
        if (b[i] == 0) chmax(con[b[i]], N);
        else chmax(con[b[i]], con[b[i]-1]);
    }
    bool ok = true;
    for (int i = 0; i < con.size(); ++i) {
        if (con[i] < N) ok = false;
    }

    //COUT(a); COUT(id); COUT(a); COUT(con);
    
    return ok;
}

int main() {
    while (cin >> N >> M >> Q) {
        a.resize(Q);
        for (int i = 0; i < Q; ++i) cin >> a[i], --a[i];
        reverse(a.begin(), a.end());
        if (a.empty() || solve()) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 6144
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n , m , a[N];

int main(){
  cin >> n >> m;
  vi odd , even;
  rep(i,0,m) {
    cin >> a[i];
    (a[i] & 1 ? odd : even).pb(a[i]);
  }
  if(sz(odd) > 2) cout << "Impossible" << endl;
  else {
    vi A , B;
    if(sz(odd)>=1) A.pb(odd[0]);
    for(auto e : even) A.pb(e);
    if(sz(odd)==2) A.pb(odd[1]);
    B = A;
    if(sz(B) == 1) B[0]--,B.pb(1);
    else {
      B[0]--;
      B[sz(B)-1]++;
    }
    vi C;
    for(auto e : B) if(e) C.pb(e);
    B = C;
    rep(i,0,sz(A)) cout << A[i] << " \n"[i+1==sz(A)];
    cout << sz(B) << endl;
    rep(i,0,sz(B)) cout << B[i] << " \n"[i+1==sz(B)];
  }
  return 0;
}


Measured memory_bytes: 384
N = int(input())
s = [input() for _ in range(N)]

result = {}
for word in set(s):
  result[word] = s.count(word)
    
M = int(input())
for _ in range(M):
  w = input()
  if w in set(s):
    result[w]-=1

print(max(max(result.values()),0))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

const ll mod = 1e9 + 7;

void solve() {
    ll p[100001], i, j;
    fo(i,100)p[i]=0;
    Fo(i,100,106)p[i]=1;
    Fo(i,106,100001)Fo(j,100,106)if(p[i-j]==1)p[i]=1;
    ll k;cin>>k;
    cout<<p[k];
}

int main()
{
    fastIO;ll t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n, i;
    cin >> n >> i;

    int ans = n - i + 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
template<typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val){ //usage: int dp[10][10]; Fill(dp,INF);
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
/*const int MAXN = 100001;

struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};*/

//-----Template---------
int n;
int l[210];

int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin>>n;
    for (int i = 0; i < n*2; ++i) {
        cin>>l[i];
    }
    int res=0;
    sort(l,l+2*n,std::greater<int>());
    for (int i = 1; i < 2*n; i+=2) {
        res+=l[i];
    }

    cout<<res<<endl;
}

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

int main() {
  int N,K,a;
  cin >> N >>K;
  a=1;

  for (int i=0; i<N; i++){
      if (a<K)
        a+=a;
      else
        a+=K;
    if  (i==N-1)
      cout << a << endl;
  }
}


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

using namespace std;

using i64 = long long;


struct BitVector{
    vector<uint64_t> v;
    vector<int> r;
    BitVector(){}
    void build(){
        r.assign(v.size() + 1, 0);
        for(int i = 0; i < v.size(); ++i)
            r[i + 1] = r[i] + __builtin_popcountll(v[i]);
    }
    bool access(int x){
        return (v[x >> 6] >> (x & 63)) & 1;
    }
    // [0, x)の1の出現回数
    int rank(int x){
        return r[x >> 6] + __builtin_popcountll(v[x >> 6] & ((1uLL << (x & 63)) - 1));
    }
    int rank(int x, bool fl){
        return fl ? rank(x) : x - rank(x);
    }
};

template <typename T, int W>
struct WaveletMatrix{

    array<BitVector, W> bv;
    array<int, W> zero_cnt;

    WaveletMatrix(vector<T>& a){
        int n = a.size();
        vector<T> v(a);
        for(int i = W - 1; i >= 0; --i){
            vector<uint64_t> b((n >> 6) + 1, 0);
            vector<T> v1, v2;
            for(int j = 0; j < n; ++j){
                ((v[j] >> i) & 1 ? v2 : v1).push_back(v[j]);
                b[j >> 6] |= uint64_t((v[j] >> i) & 1) << (j & 63);
            }
            for(int j = 0; j < v.size(); ++j)
                v[j] = (j < v1.size() ? v1[j] : v2[j - v1.size()]);
            bv[i].v = move(b);
            bv[i].build();
            zero_cnt[i] = bv[i].rank(n, 0);
        }
    }

    // [l, r)内のxの数
    int count(int l, int r, T x){
        for(int i = W - 1; i >= 0; --i){
            bool fl = (x >> i) & 1;
            int st = bv[i].rank(l, fl);
            int en = bv[i].rank(r, fl);
            l = (fl ? zero_cnt[i] : 0) + st;
            r = (fl ? zero_cnt[i] : 0) + en;
        }
        return r - l;
    }

    // [l, r)内で[0, x)を満たす値の数
    int count_lower(int l, int r, T x){
        int cnt = 0;
        for(int i = W - 1; i >= 0; --i){
            bool fl = (x >> i) & 1;
            int st = bv[i].rank(l, fl);
            int en = bv[i].rank(r, fl);
            if(fl){
                st += zero_cnt[i];
                en += zero_cnt[i];
                cnt += (bv[i].rank(r, 0) - bv[i].rank(l, 0));
            }
            l = st, r = en;
        }
        return cnt;
    }

    // [l, r)内で[x, y)を満たす値の数
    int count_range(int l, int r, T x, T y){
        return count_lower(l, r, y) - count_lower(l, r, x);
    }
};


signed main(){

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    WaveletMatrix<int, 31> w(a);

    for(int i = 0; i < q; ++i){
        int l, r;
        cin >> l >> r;
        cout << w.count_range(0, n, l, r + 1) << endl;
    }
}



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

int main(){

  int a,b,k;
  cin>>a>>b>>k;

  for(int i=a;i<=b;i++){
    if(i-a+1<=k){
      cout<<i<<endl;
    }else if(b-i+1<=k){
      cout<<i<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool prime[10000001];
int main() {
    for(long long int i=3;i<3162;i++)if(!prime[i])for(int j=i*2;j<10000001;j+=i)prime[j]=1;
    int n;
    while(cin>>n,n){
        if(n%2==0)n--;
        for(;;n-=2){
            if(!prime[n]&&!prime[n-2]&&!prime[n-6]&&!prime[n-8]){
                cout<<n<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 10924
#include <iostream>
#include <string>

using namespace std;

int main() {
	int a,b;
	string num;
	
	cin >> a >> b;
	
	int count = 0;
	for (int i = a; i <= b; i++) {
		num = to_string(i);
		if (num[0]==num[4] && num[1]==num[3]) {
			count++;
		}
	}
	
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int d[n][2];
	for(int i=0;i<n;i++)
		cin>>d[i][0]>>d[i][1];
	bool ima=0;
	for(int i=0;i<n-2;i++){
		if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1])
			ima=1;
	}
	if(ima)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int N; cin >> N;
    
    map<string, int> count;
    string str;
    int max = 0;
    for(int i = 0; i < N; i ++) {
        cin >> str;
        count[str] += 1;
        if(max < count[str]) max = count[str];
    }

    for(auto it = count.begin(); it != count.end(); it++) {
        if(max == it->second) cout << it->first << endl;
    }

    return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>

const ll mod = 1000000007 ;
const ll N=5e5+5;

ld dp[1005][1005];
int main()
{
    FAST
    ll tc,i,j;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
      char ch;
      cin>>ch;
      if(ch-'a'>=0 && ch-'a'<26)
        cout<<"a"<<"\n";
      else
        cout<<"A"<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3608
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
      
        int[] list = new int[n + 1];
      
        for(int i = 0; i < m; i++) {
          list[sc.nextInt()]++;
        }
      
        int index = x;
        int ans1 = 0;
        while(index != n) {
          ans1 += list[index];
          index++;
        }
      
        index = x;
        int ans2 = 0;
        while(index != 0) {
          ans2 += list[index];
          index--;
        }
    
		// 出力
		System.out.println(Math.min(ans1, ans2));
	}
}


Measured memory_bytes: 23124
#include <stdio.h>

#define MAX 100000

int depth(int);
int hei(int,int);
int deg(int);

typedef struct{
  int le,ri,pa;
}data;

data Da[MAX];
int De[MAX];

int main(){
  int n,id,bufi,le,ri,chk=0;
  int i,j;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++) Da[i].pa=Da[i].le=Da[i].ri=-1;
  for(i=0;i<n;i++){
    scanf("%d",&id);    
    for(j=0;j<2;j++){
      scanf("%d",&bufi);      
      if(j==0)Da[id].le=bufi;
      else Da[id].ri=bufi;      
      le=bufi;      
      if(le>=0)Da[bufi].pa=id;     
    }
  }
  
  for(i=0;i<n;i++){    
    printf("node %d: ",i);
    printf("parent = %d, ",Da[i].pa);

    if(Da[i].pa==-1) printf("sibling = -1, ");
    else {
      if(Da[Da[i].pa].le!=i&&Da[Da[i].pa].le!=-1) printf("sibling = %d, ",Da[Da[i].pa].le);//sibling
      else if(Da[Da[i].pa].ri!=i&&Da[Da[i].pa].ri!=-1)printf("sibling = %d, ",Da[Da[i].pa].ri);
      else printf("sibling = -1, ");
    }
    
    printf("degree = %d, ",deg(i));//degree
    
    printf("depth = %d, ", depth(i));

    printf("height = %d, ",hei(i,0));
    
    if(Da[i].pa==-1) printf("root");
    else if(Da[i].le==-1&&Da[i].ri==-1) printf("leaf");
    else printf("internal node");
    printf("\n");
  }
  
  return 0;
}

int depth(int a){
  int count = 0;

  while(Da[a].pa!=-1){
    count++;
    a=Da[a].pa;
  }

  return count;
}

int hei(int i,int cnt){
  int a,b;
  if(deg(i)==2){
    cnt++;
    a=hei(Da[i].ri,cnt);
    b=hei(Da[i].le,cnt);

    if(a>=b) return a;
    else return b;
  }

  else if(deg(i)==1){
    cnt++;
    if(Da[i].ri!=-1) return hei(Da[i].ri,cnt);
    if(Da[i].le!=-1) return hei(Da[i].le,cnt);
    return cnt;
  }
  else return cnt;
}

int deg(int i){
  int chk=0;                        
  if(Da[i].ri!=-1) chk++;
  if(Da[i].le!=-1) chk++;
  return chk;
}




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

int main() {
  int N, n1, n2, n3, n4;
  cin >> N;
  n1 = N / 1000;
  n2 = (N - n1 * 1000) / 100;
  n3 = (N - n1 * 1000 - n2 * 100) / 10;
  n4 = (N - n1 * 1000 - n2 * 100 - n3 * 10);
  if (n1 == n2 && n2 == n3)
    cout << "Yes" << endl;
  else if (n2 == n3 && n3 == n4)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
  int a;
  int b;
  int c;
  int d;
  	cin >> a >> b >> c >> d;
      if(a + b > c + d){
        cout << "Left" << endl;
      }
  		else if(a + b == c + d){
          cout << "Balanced" << endl;
        }
  		else if(a + b < c + d){
          cout << "Right" << endl;
        }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	ll N;cin>>N;
	string S,T;cin>>S>>T;

	// 解法
	
	string ans = "";
	REP(i,N){
		ans += S.substr(i,1);
		ans += T.substr(i,1);
	}

	//出力
	printf("%s\n", ans.c_str()); // stringをprint
}


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

int main(){
    int nums[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> nums[i][j];
        }
    }
    int a[3];
    for(a[0] = 0; a[0] <= 100; a[0]++){
        for(a[1] = 0; a[1] <= 100; a[1]++){
            for(a[2] = 0; a[2] <= 100; a[2]++){
                int b_pattern[3][3];
                for(int i = 0; i < 3; i++){
                    for(int j = 0; j < 3; j++){
                        b_pattern[i][j] = nums[i][j] - a[i];
                    }
                }
                bool if_ok = true;
                for(int i = 0; i < 3; i++){
                    if_ok &= (b_pattern[0][i] == b_pattern[1][i] && b_pattern[1][i] == b_pattern[2][i]);
                }
                if(if_ok){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())
l = input().split(" ")
l = [int(x) for x in l]

l.sort(reverse = True)
s= 0
for i in range(0, n):
  a = i * 2
  b = i * 2 + 1
  m = min(l[a], l[b])
  s += m
print(s)

Measured memory_bytes: 38384
#include <iostream>
#include <stdio.h>
using namespace std;


int main(void){
    // Your code here!
    int N, i = 0, c, tmp;
    bool found = false;
    
    scanf("%d", &N);
    int bricks[N+1];
    
    while(cin>>tmp){
        bricks[i] = tmp;
        // cout << bricks[i];
        i++;
    }
    
    c = 1;
    for(i = 0; i < N; i++){
      if (c == bricks[i]){
        // printf("t\n");
        c++;
        found = true;
      }
    }
    
    int ans;
    if (!found) ans = -1;
    else ans = N - c + 1;
    
    printf("%d\n", ans);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  vector<vector<int>> unko(3,vector<int>(3));
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      cin>>unko.at(i).at(j);
  cin>>n;
  vector<int> b(n);
  for(int i=0;i<n;i++)
    cin>>b[i];
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<n;k++){
        if(b[k]==unko[i][j])
          unko[i][j]=-1;
      }
  if((unko[0][0]==-1&&unko[0][1]==-1&&unko[0][2]==-1)||(unko[1][0]==-1&&unko[1][1]==-1&&unko[1][2]==-1)||(unko[2][0]==-1&&unko[2][1]==-1&&unko[2][2]==-1)||(unko[0][0]==-1&&unko[1][0]==-1&&unko[2][0]==-1)||(unko[0][1]==-1&&unko[1][1]==-1&&unko[2][1]==-1)||(unko[0][2]==-1&&unko[1][2]==-1&&unko[2][2]==-1)||(unko[0][0]==-1&&unko[1][1]==-1&&unko[2][2]==-1)||(unko[0][2]==-1&&unko[1][1]==-1&&unko[2][0]==-1))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}
  


Measured memory_bytes: 256