akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let W: usize = sc.get();
    let mut val = Vec::new();
    let mut weight = Vec::new();
    for _ in 0..N {
        let vi: usize = sc.get();
        let wi: usize = sc.get();
        val.push(vi);
        weight.push(wi);
    }
    let mut dp = vec![0; W+1];
    for w in 0..W+1 {
        for i in 0..N {
            if w >= weight[i] {
                dp[w] = max(dp[w], dp[w - weight[i]] + val[i]);
            }
        }
    }
    let mut ans = 0;
    for w in 0..W+1 {
        ans = max(ans, dp[w]);
    }
    println!("{}", ans);
}



Measured memory_bytes: 5036
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<functional>
#include<tuple>

using namespace std;
typedef tuple<double, int, int> td2i;

struct edge {
	int to, cost;
	edge(int x, int y) { to = x, cost = y; }
};

int n, m, p, a, b;

double d[30][1 << 8];
int baken[8];
vector<vector<edge>> E;

void djkstra(int start) {
	priority_queue<td2i, vector<td2i>, greater<td2i>> pq;
	d[start][0] = 0;
	pq.push(make_tuple(0, start, 0));

	while (pq.size()) {
		auto NOW = pq.top(); pq.pop();
		int nowp = get<1>(NOW);
		int bitjoutai = get<2>(NOW);

		if (d[nowp][bitjoutai] < get<0>(NOW))continue;

		for (int i = 0; i < E[nowp].size(); i++) {
			for (int j = 0; j < n; j++) {
				int next = E[nowp][i].to;
				int cost = E[nowp][i].cost;
				if (!(bitjoutai & (1 << j))) {
					//j番目の馬券を使う
					if (d[next][bitjoutai + (1 << j)] > d[nowp][bitjoutai] + ((double)cost / (double)baken[j])) {
						d[next][bitjoutai + (1 << j)] = d[nowp][bitjoutai] + ((double)cost / (double)baken[j]);
						pq.push(make_tuple(d[next][bitjoutai + (1 << j)], next, bitjoutai + (1 << j)));
					}
				}
			}
		}
	}
	
}

int main() {

	while (1) {
		cin >> n >> m >> p >> a >> b;
		if (n + m + p + a + b == 0)break;
		a--, b--;

		E.resize(m);

		for (int i = 0; i < n; i++) {
			cin >> baken[i];
		}
		for (int i = 0; i < p; i++) {
			int A, B, C;
			cin >> A >> B >> C;
			A--, B--;
			E[A].push_back(edge(B, C));
			E[B].push_back(edge(A, C));
		}

		for (int i = 0; i < 30; i++)for (int j = 0; j < (1 << 8); j++)d[i][j] = 99999999;

		djkstra(a);

		double ans = 99999999;
		for (int i = 0; i < (1 << 8); i++)ans = min(ans, d[b][i]);

		if (ans == 99999999)cout << "Impossible" << endl;
		else cout << ans << endl;

		E.clear();

	}

	return 0;
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

int gcd(int a, int b){
  if(a == 0) return b;
  else return gcd(b%a, a);
}

int32_t main(){
  DESYNC;
  int r;
  cin >> r;
  cout << 3*r*r << endl;
}



Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.array;

int read_number() {return readln.chomp.to!(int);}

bool is_correct(int[][] lot, int start, int finish) {
  uint curr = start;
  foreach(col; lot) {
    // writeln(col, " ", curr);
    if (col[curr - 1] == 1) curr--;
    else if (col[curr] == 1) curr++;
  }
  return curr == finish;
}

void main() {
  while(true) {
    int width = (read_number - 1);
    if (width == -1) break;
    int start = read_number;
    int finish = read_number;
    int height = read_number;
    int[][] lot = [];
    int[][] empty = [];           // [[i, j], ...]
    foreach(int i; 0..height) {
      lot ~= [0] ~ readln.chomp.dup.map!((x) => to!(int)(x - '0')).array ~ [0];
      foreach(int j; 0..width) {
        if (lot[i][j + 1] == 0 && lot[i][j + 2] == 0 && lot[i][j] == 0)
          empty ~= [i, j + 1];
      }
    }
    if (is_correct(lot, start, finish)) writeln(0);
    else {
      int[] ans = [];
      foreach(data; empty) {
        lot[data[0]][data[1]] = 1;
        if (is_correct(lot, start, finish)) {ans = data; break;}
        else {
          lot[data[0]][data[1]] = 0;
        }
      }
      if (ans == []) writeln(1);
      else writefln("%d %d", ans[0] + 1, ans[1]);
    }
  }
}

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

int main()
{
  int N,M,i,max_,min_,result=0;
  int L[100000],R[100000];
  cin >> N >> M;
  for( i = 0; i < M; i++ )
  {
    cin >> L[i] >> R[i];
  }
  max_ = L[0];
  min_ = R[0];
  for( i = 1; i < M; i++ )
  {
    if( max_ < L[i] ){
      max_ = L[i];
    }
    if( min_ > R[i] ){
      min_ = R[i];
    }
  }
  result = min_ - max_ + 1;
  if( result >= 0 ){
    cout << result << endl;
  }else{
    cout << 0 << endl;
  }
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 106
#define mo 1000000007
using namespace std;
int n,m,ans,f[N][N*N];
inline int read()
{
	int x=0,c=getchar(),f=1;while(c<'0'||c>'9')f=(c=='-'?-f:f),c=getchar();
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+c-48,c=getchar();return f>0?x:-x;
}
void print(int x)
{
	if(x>9LL)print(x/10LL);putchar(x%10+48);
}
int wk(int x)
{
	if(x%10==0)return 0;else return x;
}
int main()
{
	n=read();f[0][0]=1;
	for(int i=1;i<=n;i++){
		m=read();
		for(int j=0;j<=10000;j++)f[i][j]=f[i-1][j]|(j>=m?f[i-1][j-m]:0);
	}
	for(int i=1;i<=10000;i++)if(f[n][i])ans=max(ans,wk(i));
	printf("%d\n",ans);
}

Measured memory_bytes: 4608
N = int(input())
print(0)
s = input()
if s=="Vacant":
    exit()
left=0
right=N
l_state = r_state = s
while True:
    center = (left+right)//2
    print(center)
    s = input()
    if s == "Vacant":
        exit()
    if ((center-left)%2) ^ (s!=l_state):
        right = center
        r_state = s
    else:
        left = center
        l_state = s


Measured memory_bytes: 3660
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,res;
    cin>>a>>b;
    res=a*b;
    if(res%2==0)
    {
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn main() {
    let mut stdin = std::io::stdin();
    let mut buf = String::new();
    stdin.read_to_string(&mut buf).unwrap();
    let mut lines = buf.lines();
    let mid: usize = lines.next().unwrap().parse::<usize>().unwrap() / 2;
    let mut d: Vec<i32> = lines.next().unwrap().split_whitespace().map(|x|x.parse().unwrap()).collect();

    d.sort();
    println!("{}", d[mid] - d[mid-1]);
}


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

int main(){
  int con = 0, con2 = 0;
  string s;

  cin>>s;

  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'S'){
      con++;
    } else {
      if(con <= 0){
	con2++;
	con = 1;
      }
      con--;
    }
  }

  cout<<con2*2<<endl;
  
  return 0;
}


Measured memory_bytes: 640
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

ll LCM(ll x , ll y){
	return (x*y) / __gcd(x,y) ;
}

ll NumOfDiv(ll a , ll b , ll k){
	return b/k - a/k + (a%k == 0) ;
}
void start(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int numofdig(int n){
    int i = 0 ;
    while (n!=0)
    {
        n/=10;
        i++;
    }
    return i%2 == 1;
    
}

int main()
{
	start();
	int n ; 
    cin >> n ;
    int c = 0 ;
    for (int i = 1; i <= n; i++)
    {
        if (numofdig(i))
        {
            c++;
        }
        
    }
    cout << c << endl;
	return 0 ;
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/abc157/tasks/abc157_b

a=[]
for _ in range(3):
    num_a=list(map(int,input().split()))
    for i in range(3):
        a.append(num_a[i])
n=int(input())
res=[-1 for i in range(9)]
for i in range(n):
    b=int(input())
    if b in a:
        num_index=a.index(b)
        res[num_index]=1

for i in range(3):
    if (res[i]==res[i+3])&(res[i+3]==res[i+6])&(res[i]==1):
        print("Yes")
        exit()
for i in range(3):
    if (res[3*i]==res[3*i+1])&(res[3*i+1]==res[3*i+2])&(res[3*i]==1):
        print("Yes")
        exit()
if ((res[0]==res[4])&(res[4]==res[8])&(res[0]==1))|((res[2]==res[4])&(res[4]==res[6])&(res[2]==1)):
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 38384
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
sa = sum(a)
sa2 = sum(a[::2]) * 2
a.append(a[0])
ans[0] = sa2 - sa

for i in range(1, n):
    ans[i] = a[i - 1] * 2 - ans[i - 1]

print(' '.join(map(str, ans)))


Measured memory_bytes: 19096
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define inf (int) 2e15
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end()
#define ll long long 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

signed main () {
	start_routine;
	
	int a[3];
	cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	cout << a[2] - a[0] << endl;
	end_routine;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
using lint = long long;
int main() {
	int A, B;
	cin >> A >> B;
	rep(i, 10001) {
		if ((int)(i * 0.08) == A && (int)(i * 0.1) == B) {
			cou(i);
			exit(0);
		}
	}
	cou(-1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int n;
    cin>>n;
    int a[n],x;
    cin>>a[0];
    x=a[0];
    for(int i=1;i<n;i++)
    {
        cin>>a[i];
        x=x^a[i];
    }
    for(int i=0;i<n;i++)
    {
        int k=x^a[i];
        cout<<k<<" ";
    }
    cout<<endl;

}
































Measured memory_bytes: 4432
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define alpha_size 26
const int maxn = 2e5 + 10;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr); 
    int n; cin >> n;
    int ret = n / 500;
    ret *= 1000;
    int curr = n - (ret / 2);
    curr /= 5, curr *= 5;
    cout << curr + ret << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int a, b, c; cin >> a >> b >> c;
    cout << ((a+b==c or b+c==a or a+c==b) ? "Yes" : "No") << endl;
}


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

int main() {
  int x;

  cin >> x;
  if (x % 7 == 1) cout << "fri" << endl;
  else if (x % 7 == 2) cout << "sat" << endl;
  else if (x % 7 == 3) cout << "sun" << endl;
  else if (x % 7 == 4) cout << "mon" << endl;
  else if (x % 7 == 5) cout << "tue" << endl;
  else if (x % 7 == 6) cout << "wed" << endl;
  else if (x % 7 == 0) cout << "thu" << endl;
}

Measured memory_bytes: 3112
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int dp[3002][3002][4];
int32_t main()
{
    IOS;
    int r,c,k;
    cin>>r>>c>>k;
    int val[r][c];
    rep(i,0,r)
    {
        rep(j,0,c)
        val[i][j]=0;
    }
    for(int i=0;i<k;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        val[a][b]=c;
    }
    dp[0][0][0]=0;
    if(val[0][0]>0)
    dp[0][0][1]=val[0][0];
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            for(int z=0;z<=3;z++)
            {
                if(j<(c-1))
                {
                    if(z<3&&val[i][j+1]>0)
                    dp[i][j+1][z+1]=max(dp[i][j+1][z+1], dp[i][j][z]+val[i][j+1]);
                    dp[i][j+1][z]=max(dp[i][j+1][z], dp[i][j][z]);
                }
                if(i<(r-1))
                {
                    if(val[i+1][j]>0)
                    dp[i+1][j][1]=max(dp[i+1][j][1], dp[i][j][z]+val[i+1][j]);
                    dp[i+1][j][0]=max(dp[i+1][j][0], dp[i][j][z]);
                }
            }
        }
    }
    cout<<max({dp[r-1][c-1][0], dp[r-1][c-1][1], dp[r-1][c-1][2], dp[r-1][c-1][3]});
}

Measured memory_bytes: 355200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void) {
  ll N; cin >> N;
  ll ans = 0;
  ll sum = 0;
  for (ll i = 0; i < N; i++) {
    ll a; cin >> a;
    if (a == 0) {
      ans += sum/2;
      sum = 0;
    }
    else sum += a;
  }
  ans += sum/2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

typedef long long LL;

const int N=200005;

int n,a[N];

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		if (a[i]>=i) {puts("-1");return 0;}
	LL ans=0;int tag=-n;
	for (int i=n;i>=1;i--)
	{
		int now=std::max(0,tag+i);
		if (now>a[i]) {puts("-1");return 0;}
		if (now==a[i]) continue;
		ans+=a[i];tag=a[i]-i;
	}
	printf("%lld",ans);
	return 0;
}

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

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

int main(){
    int N;
    cin >> N;
    vector<ll> sum(N),mi(N);
    rep(i,N){
        ll a,b;
        cin >> a >> b;
        sum[i] = a+b;
        mi[i] = a -b;
    }
    sort(all(sum));
    sort(all(mi));
    cout << max(sum[N-1] - sum[0],mi[N-1] - mi[0]) << endl;
}

Measured memory_bytes: 6348
#include<iostream>

using namespace std;

int main()
{
	char S[4];
	int sum=0;

	cin >> S;

	for(int i=0;i<4;i++){
		if(S[i]=='+'){
			sum++;
		}
		else{
			sum--;
		}
	}

	cout << sum << endl;

	return 0;
}


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

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;



int main() {

	int N, M;
	cin >> N >> M;

	string ans = "Yes";

	Graph G(N+1);

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	// BFS のためのデータ構造
	vector<int> flag(N+1, -1); // 全頂点を「未訪問」に初期化
	queue<int> que;

	// 初期条件 (頂点 0 を初期ノードとする)
	flag[1] = 0;
	que.push(1); // 0 を橙色頂点にする

				 // BFS 開始 (キューが空になるまで探索を行う)
	while (!que.empty()) {
		int v = que.front(); // キューから先頭頂点を取り出す
		que.pop();

		// v から辿れる頂点をすべて調べる
		for (int nv : G[v]) {
			if (flag[nv] != -1) continue; // すでに発見済みの頂点は探索しない

										  // 新たな白色頂点 nv について距離情報を更新してキューに追加する
			flag[nv] = v;
			que.push(nv);
		}
	}



	cout << ans << endl;

	for (int i = 2; i < N+1; i++) {
		cout << flag[i] << endl;
	}

	cin >> ans;

	return 0;


}

Measured memory_bytes: 10152
#include<iostream>
#include<stdio.h>
using namespace std;
using ll=long long;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using P=pair<int,int>;
const int mod=1000000007;


int main(){
  int n;
  int a[100];
cin>>n;
rep(i,n)cin>>a[i];
bool ok=true;
rep(i,n){
  if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0){
    ok=false;
  }
}
if(ok)cout<<"APPROVED"<<endl;
else cout<<"DENIED"<<endl;
return 0;
}

Measured memory_bytes: 3128
#include <stdio.h>
int main ()
{
	int A, B;
	scanf ("%d %d", &A, &B);
	if (B % A == 0){
		printf ("%d", A + B);
	} else if ( B % A != 0){
		printf ("%d", B - A);
	}
return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int n=1e6;
vector<int> linep;
vector<bool> is_prime(n+1, 1);
void era(){
    for (int p=2; p<=n; p++) {
        if (!is_prime[p]) continue;
        for (int k=2*p; k<=n; k += p) is_prime[k] = false;
        linep.push_back(p);
    }
}
int main(){
	int x; cin >> x;
    era();
    cout << *lower_bound(linep.begin(),linep.end(),x) << endl;
}

Measured memory_bytes: 1020
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello{
    public static void Main(){
        foreach (var c in Console.ReadLine().ToCharArray()) {
            if (c == '7'){
                Console.WriteLine("Yes");
                return;
            }
        }
        
        System.Console.WriteLine("No");
    }
}


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

int c;
int dx[]={1,3,4,5};

class Board
{
public:
	int size, v[20];
	Board(int size, int vt[20])
	:size(size)
	{
		for(int i=0; i<20; i++)
			v[i]=vt[i];
	}
	
	void Remove(int p1, int p2)
	{
		v[p1]=-1; v[p2]=-1;
		
		for(int i=p2; i<19; i++)
			swap(v[i], v[i+1]);
		
		for(int i=p1; i<19; i++)
			swap(v[i], v[i+1]);
		
		size-=2;
	}
};

void dfs(Board b)
{
	for(int j=0; j<b.size; j++)
	for(int i=0; i<4; i++)
	{
		if(i==1&&j%4==0) continue;
		if(i==0&&j%4==3) continue;
		if(i==3&&j%4==3) continue;
		
		int pr=j+dx[i];
		if(pr>=20) continue;
		if(b.v[pr]!=b.v[j]) continue;
		
		Board t=b;
		t.Remove(j,pr);
		dfs(t);
	}		
	
	if(b.size < c) c=b.size;
}

int main()
{
	int N;
	scanf("%d", &N);
	while(N--)
	{
		int v[20];
		for(int i=0; i<20; i++)
			scanf("%d", &v[i]);
			
		c=20;
		dfs(Board(20,v));
		printf("%d\n", c);
	}
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<ll,ll>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll n,m,a[200010],b[200010],c[200010],h[100010];
ll s[100010];
vector<ll> g[100010];
vector<P> pos[100010];
set<ll> pot;
vector<ll> vec;
queue<ll> qu;
bool used[100010]={};

int main(){
	cin >> n >> m;
	REP(i,0,m){
		cin >> a[i] >> b[i] >> c[i]; a[i]--; b[i]--;
		pot.insert(a[i]); pot.insert(b[i]);
		g[a[i]].push_back(b[i]);
		pos[a[i]].push_back({b[i], c[i]});
		h[b[i]]++;
	}
	
	stack<int> st;
	for(auto e:pot) if(!h[e]) st.push(e),s[e]=1;
	while(!st.empty()){
		auto p = st.top(); st.pop();
		
		vec.push_back(p);
		for(auto e:g[p]){
			h[e]--;
			if(!h[e]) st.push(e);
		}
	}
	
	if(!m){cout << "Yes" << endl; return 0;}
	if(!vec.size()){cout << "No" << endl; return 0;}
	REP(i,0,vec.size()){
		for(auto e:pos[vec[i]]){
			if(!s[vec[i]] and !s[e.first]) continue;
			if(s[e.first] and s[vec[i]] and s[vec[i]] + e.second != s[e.first]){cout << "No" << endl; return 0;}
			if(s[vec[i]]) s[e.first] = s[vec[i]] + e.second;
			else if(s[e.first]) s[vec[i]] = s[e.first] - e.second;
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 25468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P ,ll> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int m, k, b;
    cin >> m >> k;
    b = int(pow(2,m));
    if(k >= b || (m == 1 && k == 1)){
        cout << -1 << endl;
    }
    else{
        if(k == 0){
            REP(i, b){
                cout << i << " " << i << " \n"[i==b-1];
            }
        }
        else{
            deque<int> que;
            que.push_back(k);
            REP(i,b){
                if(i == k) continue;
                que.push_back(i);
                que.push_front(i);
            }
            que.push_back(k);
            int cnt = 0;
            for(auto i : que){
                cout << i << " \n"[cnt==int(que.size())-1];
                cnt++;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using int64=long long;
const int INF=1145141919,MOD=1e9+7;
const int64 LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int h,w,n; cin>>h>>w>>n;
    int sy,sx; cin>>sy>>sx;
    string s,t; cin>>s>>t;
    int y1=sy,y2=sy;
    int x1=sx,x2=sx;
    string ans="YES";
    for(int i=0;i<n;i++){
        if(s[i]=='L') x1--;
        if(s[i]=='R') x2++;
        if(x1<1||w<x2) ans="NO";
        if(t[i]=='L') x2=max(1,x2-1);
        if(t[i]=='R') x1=min(w,x1+1);
        //
        if(s[i]=='U') y1--;
        if(s[i]=='D') y2++;
        if(y1<1||h<y2) ans="NO";
        if(t[i]=='U') y2=max(1,y2-1);
        if(t[i]=='D') y1=min(h,y1+1);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 776
import sys

def check_ans(s,x):
  res=[0]
  for i in s:
    res = set([x + i for x in res]) | set([x - i for x in res])
  return x in res

S = sys.stdin.readline().strip()
X,Y=map(int,input().split())
d=1
while S and S[0]=='F':
  S=S[1:]
  X-=1
if len(S)==0:
  if X==0 and Y==0:
    print("Yes")
  else:
    print("No")
  sys.exit()

nx=[]
ny=[]
X=abs(X)
Y=abs(Y)

while S:
  step=0
  while S and S[0]=='T':
    d*=-1
    S=S[1:]
  while S and S[0]=='F':
    step+=1
    S=S[1:]
  if step==0:
    break
  if d==1:
    nx.append(step)
  else:
    ny.append(step)

if check_ans(nx,X) and check_ans(ny,Y):
  print("Yes")
else:
  print("No")

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	ll ans = 0;
	while(true){
		sort(a.rbegin(), a.rend());
		if(a[0] < n) break;
		ll sub = a[0] / n;
		a[0] -= sub * n;
		for(int i = 1; i < n; ++i) a[i] += sub;
		ans += sub;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

typedef long long lint;
const lint N = 330, INF = 1e17+7;

lint n, m, l, dist[N][N], fuel[N][N], ans[N][N];


int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif
	scanf("%lld %lld %lld", &n, &m, &l);

	for (int i = 0; i < N; i++){
		for (int j = 0; j < N; j++){
			if (i==j)
				continue;
			dist[i][j] = INF;
			fuel[i][j] = INF;
		}
	}

	for (lint i = 0; i < m; i++){
		lint a, b, c;
		scanf("%lld %lld %lld", &a, &b, &c);
		dist[a][b] = dist[b][a] = c;
	}


	for (int k = 1; k <= n; k++){
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				if (i == j)
					continue;
				if (dist[i][k] + dist[k][j] < dist[i][j]){
					dist[i][j] = dist[i][k] + dist[k][j];
				}
			}
		}
	}

	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			if (i == j)
				continue;
			if (dist[i][j] <= l)
				fuel[i][j] = 1;
		}
	}

	for (int k = 1; k <= n; k++){
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				if (fuel[i][k] + fuel[k][j] < fuel[i][j])
					fuel[i][j] = fuel[i][k] + fuel[k][j];
			}
		}

	}

	lint q;

	scanf("%lld", &q);

	while (q--){
		lint s, t;
		scanf("%lld %lld", &s, &t);
		
		if (fuel[s][t] < INF)
			printf("%lld\n", fuel[s][t] - 1);
		else
			printf("-1\n");

	}

	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    int N, temp;
    std::cin >> N;
    
    std::vector<int> cards;
    for (int i=0; i<N; ++i) {
        std::cin >> temp;
        cards.push_back(temp);
    }
    
    std::sort(cards.begin(), cards.end(), [](int a, int b){return a > b;});
   
    int alice(0), bob(0);
    for (auto itr=cards.begin(); itr!=cards.end(); itr++) {
        if (std::distance(cards.begin(), itr) % 2 == 0) {
            alice += *itr;
        } else {
            bob += *itr;
        }
    }
    std::cout << (alice - bob) << std::endl;
}

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

vector<int> d[4]={{-1,0},{1,0},{0,-1},{0,1}};

int main(){
  int H,W; cin >> H >> W;
  string S[20];
  for(int i=0; i<H; i++) cin >> S[i];
  
  queue<vector<int>> startlist;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(S[i][j]=='.') startlist.push({i,j});
    }
  }
  
  int result=0;
  while(!startlist.empty()){
    int field[20][20];
    for(int i=0; i<20; i++){
      for(int j=0; j<20; j++){
        field[i][j]=-1;
      }
    }
    field[startlist.front()[0]][startlist.front()[1]]=0;
    queue<vector<int>> tmp;
    tmp.push(startlist.front());
    
    while(!tmp.empty()){
      for(int i=0; i<4; i++){
        if(0<=tmp.front()[0]+d[i][0]&&tmp.front()[0]+d[i][0]<H&&
           0<=tmp.front()[1]+d[i][1]&&tmp.front()[1]+d[i][1]<W&&
           S[tmp.front()[0]+d[i][0]][tmp.front()[1]+d[i][1]]=='.'&&
           field[tmp.front()[0]+d[i][0]][tmp.front()[1]+d[i][1]]<0){
          field[tmp.front()[0]+d[i][0]][tmp.front()[1]+d[i][1]]=field[tmp.front()[0]][tmp.front()[1]]+1;
          result=max(result,field[tmp.front()[0]+d[i][0]][tmp.front()[1]+d[i][1]]);
          tmp.push({tmp.front()[0]+d[i][0],tmp.front()[1]+d[i][1]});
        }
      }
      tmp.pop();
    }
    startlist.pop();
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<sstream>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	char x;
	cin >> x;
	if (x == 'A')
		cout << 'T' << endl;
	else if (x == 'T')
		cout << 'A' << endl;
	else if (x == 'C')
		cout << 'G' << endl;
	else if (x == 'G')
		cout << 'C' << endl;
}

Measured memory_bytes: 256
const main = args => {
  const [n, y] = args.split(' ').map(arg => +arg);
  let ans = [-1, -1, -1];

  [...Array(n + 1)].forEach((_, i) => {
    [...Array(n - i + 1)].forEach((_, j) => {
      const k = n - i - j;
      if (10000 * i + 5000 * j + 1000 * k === y) ans = [i, j, k];
    });
  });

  console.log(ans.join(' '));
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 34892
import sys
import numpy as np
import bisect
s = input()
t = input()



count = 0
s_len = len(s)
s_list = np.zeros(len(s))
t_list = []*len(t)
indexes = []

for i in range(26):
  
  indexes.append([j for j, x in enumerate(s) if x == chr(i + ord('a')) ])
  


for i,k in enumerate(t):

  index = indexes[ord(k)-ord('a')]
  
  if len(index) == 0:
    print(-1)
    sys.exit(0)
  else:
    t_list.insert(i,index)
    


pre = -1
for i in range(len(t)):
  
  #high = [j  for j in t_list[i] if j > pre]
  high = bisect.bisect_left(t_list[i], pre+1) 

  if high >= len(t_list[i]):
    
    count += s_len - pre  + t_list[i][0]
    pre = t_list[i][0] 
  else:
    
    count += t_list[i][high] - pre 
    pre = t_list[i][high]

print(count)

Measured memory_bytes: 19396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M=1e9+7;
ll grid[105][105];
ll memo[22][ll(1<<22)];

ll solve(int idx,ll mask,int n)
{
    if(idx==n) return 1;
    
    if(memo[idx][mask]!=-1) return memo[idx][mask];
    ll ret=0;
    for(int i=0;i<n;i++)
    {
        if(grid[idx][i]==1 && !(mask&(1<<i)) )
        {
            ret=(ret%M+(solve(idx+1,mask|(1<<i),n) )%M)%M;
        }
    }
    
    return memo[idx][mask]=ret%M;
}
int main()
{
    memset(memo,-1,sizeof(memo));
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>grid[i][j];
        }
    }
    
    ll ans=solve(0,0,n);
    cout<<ans<<"\n";
}

Measured memory_bytes: 721152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=j;i<(int)n;i++)
#define rrep(i,j,n) for(int i=j;i>(int)n;i++)
#define ll long long
int main(){
  int A,B;
  cin>>A>>B;
  if((A+B)%2!=0){
    cout << "IMPOSSIBLE" << endl;
  }else{
    cout << abs((A+B)/2)<< endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, M;
int A[112345], B[112345], C[112345];

int main() {
	cin >> N >> M;
	
	REP(i, N) scanf("%d", A + i);
	REP(i, M) scanf("%d %d", B + i, C + i);
	
	vector<pii> v(M);
	REP(i, M) v[i] = pii(C[i], B[i]);
	sort(ALL(v), greater<pii>());
	
	priority_queue<int, vector<int>, greater<int> > pq;
	REP(i, N) pq.push(A[i]);
	
	for (pii cur : v) {
		REP(i, cur.se) {
			int m = pq.top();
			if (m < cur.fi) {
				pq.pop();
				pq.push(cur.fi);
			}
			else break;
		}
	}
	
	ll ans = 0;
	while (!pq.empty()) {
		ans += pq.top(); pq.pop();
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2812
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
        char str[10];
        int num[10][10], i, j;

        while ( scanf( "%s", str ) == 1 ) {
                for ( i = 0 ; i < 10 ; i++ ) {
                        num[0][i] = str[i] - 48;
                }

                for ( j = 1 ; j < 10 ; j++ ) {
                        for ( i = 0 ; i < 10 - j ; i++ ) {
                                num[j][i] = ( num[j-1][i] + num[j-1][i+1] ) % 10;
                        }
                }
                printf( "%d\n", num[j-1][0] );
        }

        return 0;
}



Measured memory_bytes: 2140
def LCM(x,y):
    return x*y//GCD(x,y)

def GCD(x,y):
    x,y=max(x,y),min(x,y)
    if x%y==0:
        return y
    else:
        return GCD(y,x%y)

N=int(input())
ans=1
for i in range(N):
    ans=LCM(ans,int(input()))

print(ans)

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

//テストケースはあんまり見ないほうが良い。デバッグする能力が必要.
int main(){
    int n,ans;
  	cin >> n;
    vector<int> p(n), q(n);
    ans =0;
    rep(i,n)cin >> p[i];
	rep(i,n)q[i] = p[i];
    sort(p.begin(), p.end());
    rep(i,n){
        if(p[i] != q[i])++ans;
    }
    if(ans>2)cout<<"NO" <<endl;
    else cout<<"YES" << endl;
    return 0;

}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
dp = [0 for _ in range(K+1)]
for i in range(K+1):
    if i<A[0]:
        dp[i] = 0
    else:
        dp[i] = not dp[i-A[0]]
        for j in range(1,N):
            if i>=A[j]:
                dp[i] = dp[i] or not dp[i-A[j]]
if dp[K]==True:
    print("First")
else:
    print("Second")

Measured memory_bytes: 47344
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;

ll GCD(ll a,ll b){

    if(a>b){

        return GCD(b,a);

    }

    else{

    ll r=b%a;

    while(r!=0){

        b=a;

        a=r;

        r=b%a;

    }

    return a;

    }

}

int main(){
    
    ll N,M;cin>>N>>M;
    string s,t;cin>>s>>t;
    ll gcd=GCD(N,M);
    ll lcm=N*M/gcd;
    if(gcd==1&&s.at(0)!=t.at(0)){
        cout<<-1<<endl;
        return 0;
    }
    else{
        int ok=1;
        rep(i,0,gcd){
            if(s.at(i*(N/gcd))!=t.at(i*(M/gcd)))ok=0;
        }
        if(ok==0){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<lcm<<endl;
}






Measured memory_bytes: 512
N, K = map(int, input().split())
ans = N - K + 1
for i in range(1, K + 1):
    if i > N - K + 1:
        ans = 0
    print(ans % 1000000007)
    ans = ans * (N - K + 1 - i) * (K - i)
    ans = ans // ((i + 1) * i)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    cin >> N;
    int S = 0;
    vector<int> W(N);
    for(int i = 0; i < N; i++) {
        cin >> W[i];
        S += W[i];
    }
    int ans = 1e7;
    int s = 0;
    for(int i = 0; i < N; i++) {
        s += W[i];
        ans = min(ans, abs(S - 2 * s));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let res: Vec<usize> = (0..5).map(|_| sc.read::<usize>()).collect();
    let k = sc.read();
    if (res[4] - res[0]) <= k {
        println!("Yay!");
    } else {
        println!(":(");
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
#include<stdio.h>

int main(void){
	int num, money;
	scanf("%d%d", &num, &money);
	int eq = 1;
	for(int i = 0; i <= num; i++){
		for(int j = 0; j <= num - i; j++){
			for(int z = 0; z <= num - i - j; z++){
				int tmp = money;
				tmp -= 10000*i+5000*j+1000*z;
				if(tmp == 0 && eq == 1 && (i+j+z) == num){
					printf("%d %d %d", i, j, z);
					eq = 0;
				}
			}
		}
	}
	if(eq)puts("-1 -1 -1");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
using namespace std;

//***********************************************************************

// hash struct for unordered_map
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************
int n;

dl dp[301][301][301];
dl finddpvalue(int x,int y, int z)
{
    //cout << "x : " <<x  << " y : " << y << " z : " << z << endl;
    if(x==0 && y==0 && z==0)
    {
        return 0.0;
    }
    if(dp[x][y][z]!=-1.0)
    return dp[x][y][z];

    dl ans=1.0;
    if(x>0)
    ans+=x*finddpvalue(x-1,y,z)/n;
    if(y>0)
    ans+=y*finddpvalue(x+1,y-1,z)/n;
    if(z>0)
    ans+=z*finddpvalue(x,y+1,z-1)/n;
    ans=n*ans/(x+y+z);
    return dp[x][y][z]=ans;
}


void solve()
{
    cin >> n;
    int n1=0,n2=0,n3=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        if(x==1)
        n1++;
        if(x==2)
        n2++;
        if(x==3)
        n3++;
    } 
    for(int i=0;i<301;i++)
    {
        for(int j=0;j<301;j++)
        {
            for(int k=0;k<301;k++)
            dp[i][j][k]=-1.0;
        }
    }
    //cout << "c0" << endl;
    dl ans=finddpvalue(n1,n2,n3);
    //cout << "c1" << endl;
    cout << setprecision(12) << fixed << ans << endl;
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 213376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    // int A, B;
    // cin >> A >> B;
    // cout << A+B;
    // cout << (1 + 100) * 100 / 2 << endl;
 
    int H,W;
    cin >> H >> W;
    for(int i=0; i<W+2; i++){
        cout << "#";
    }
  	cout << endl;
  
    string str;
    for(int i=0; i<H; i++){
        cin >> str ;
        cout << "#" << str << "#" << endl;
    }
  
  
    for(int i=0; i<W+2; i++){
        cout << "#";
    }
}

Measured memory_bytes: 256
n=gets.to_i
l=[]
n.times do
  l << []
end
(n-1).times do
  u,v,w=gets.split.map(&:to_i)
  l[u-1] << [v-1,w]
  l[v-1] << [u-1,w]
end
c=[0]+[nil]*(n-1)
n-=1
s=[[0,0]]
while n>0
  z=[]
  s.each do |ss,sc|
    l[ss].each do |lss,w|
      if c[lss]==nil
        c[lss]=(sc+w)%2
        z << [lss,sc+w]
        n-=1
      end
    end
  end
  s=z.dup
end
puts c


Measured memory_bytes: 29308
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC079.C
{
    class Program
    {
        static void Main ()
        {
            string s1 = Console.ReadLine ();
            string s2 = Console.ReadLine ();
            string s3 = Console.ReadLine ();
            Console.WriteLine ($"{ s1[0] }{ s2[1] }{ s3[2] }");
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
    while(true)
    {
        int n;cin>>n;if(n==0){break;}double ave=0;
        vector<double >a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];ave+=a[i];
        }
        ave/=(double)n;
        double buns;
        buns=0;
        for(int i=0;i<n;i++){
            buns+=(ave-a[i])*(ave-a[i]);
        }
        buns/=n;
        cout<<sqrt(buns)<<endl;
    }
    return 0;
}


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

using namespace std;

template <class T>
struct Edge {
  using w_type = T;
  Edge(int u, int v, w_type w): u(u), v(v), w(w) { }
  int u, v;
  w_type w;
  bool operator<(const Edge<T> & rhs) const {
    if (w != rhs.w) { return w < rhs.w; }
    if (u != rhs.u) { return u < rhs.u; }
    return v < rhs.v;
  }
};

template <class Edge>
decltype(auto) AllPairsShortestPaths(const vector<Edge> & edges,
                 typename vector<Edge>::size_type node_num) {
  using size_type = typename vector<Edge>::size_type;
  using w_type = typename Edge::w_type;
  const w_type kInf = numeric_limits<int>::max();

  vector<vector<w_type>> adjacency_matrix(node_num, vector<w_type>(node_num, kInf));
  for (const auto & e: edges) {
    adjacency_matrix[e.u][e.v] = e.w;
  }
  for (unsigned i = 0; i < node_num; ++i) {
    adjacency_matrix[i][i] = 0;
  }

  unsigned m = 1;
  auto dist_m = adjacency_matrix;
  while (m < 2 * (node_num - 1)) {
    vector<vector<w_type>> dist_2m(node_num, vector<w_type>(node_num, kInf));
    for (unsigned i = 0; i < node_num; ++i) {
      for (unsigned j = 0; j < node_num; ++j) {
        for (unsigned k = 0; k < node_num; ++k) {
          if (dist_m[i][k] == kInf || dist_m[k][j] == kInf) { continue; }
          dist_2m[i][j] = min(dist_2m[i][j], dist_m[i][k] + dist_m[k][j]);
        }
      }
    }
    if (m >= node_num - 1 && dist_m != dist_2m) {
      return make_pair(false, dist_m);
    }
    dist_m = dist_2m;
    m *= 2;
  }

  return make_pair(true, dist_m);
}

int main(int argc, char const *argv[]) {
  using w_type = int;
  const w_type kInf = numeric_limits<w_type>::max();
  vector<Edge<w_type>> edges;
  unsigned V, E;
  cin >> V >> E;
  for (unsigned i = 0; i < E; ++i) {
    unsigned u, v;
    w_type w;
    cin >> u >> v >> w;
    edges.emplace_back(u, v, w);
  }

  auto ans = AllPairsShortestPaths(edges, V);
  auto have_neg_cycle = ans.first;
  auto dist = ans.second;
  if (!have_neg_cycle) {
    cout << "NEGATIVE CYCLE\n";
  } else {
    for (unsigned i = 0; i < V; ++i) {
      for (unsigned j = 0; j < V; ++j) {
        if (dist[i][j] == kInf) {
          cout << "INF";
        } else {
          cout << dist[i][j];
        }
        if (j == V - 1) {
          cout << "\n";
        } else {
          cout << " ";
        }
      }
    }
  }

  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(b==1) puts("0");
    else cout << a-b << endl;;

    return 0;
}

Measured memory_bytes: 256