akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
void print(double p[]){
	printf("%lf %lf\n",p[0],p[1]);
}

void kock(int n, double p1[],double p2[]){
double s[2],t[2],u[2];
	s[0]=(p2[0]-p1[0])/3+p1[0];
	s[1]=(p2[1]-p1[1])/3+p1[1];
	t[0]=2*(p2[0]-p1[0])/3+p1[0];
	t[1]=2*(p2[1]-p1[1])/3+p1[1];
	u[0]=(t[0]-s[0])/2-sqrt(3)/2*(t[1]-s[1])+s[0];
	u[1]=(t[1]-s[1])/2+sqrt(3)/2*(t[0]-s[0])+s[1];
	if(n==0) return;
	kock(n-1,p1,s);
	print(s);
	kock(n-1,s,u);
	print(u);
	kock(n-1,u,t);
	print(t);
	kock(n-1,t,p2);
}


int main(){
	int n;
	double p1[2],p2[2];
	p1[0]=p1[1]=p2[1]=0;
p2[0]=100;
	
	scanf("%d",&n);
	print(p1);
	kock(n,p1,p2);
	print(p2);
	
	return 0;
}
		

Measured memory_bytes: 636
#include<cstdio>
#include<algorithm>
#include<bitset>
using namespace std;
int main(){
	bitset<5000005> dp;
	int n;
	scanf("%d",&n);
	int sum=0;
	dp[0]=1;
	for (int i=1; i<=n; i++) {
		int x;
		scanf("%d",&x);
		dp|=dp<<x;
		sum+=x;
	}
	for (int i=(sum+1)/2; i; i++)
		if (dp[i]) {
			printf("%d",i);
			return 0;
		}
}

Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

vector<ll> P, E;

void Enu(ll x)
{
	for (int i = 0; i < 3; i++) {
		ll tmp = x * 10;
		if (i == 0) tmp += 3;
		else if (i == 1) tmp += 5;
		else if (i == 2) tmp += 7;
		if (tmp < 1000000000) {
			P.push_back(tmp);
			Enu(tmp);
		}
	}
}
int main()
{
	ll N; cin >> N;
	int count[10] = { 0 };
	Enu(0);
	bool c3 = false, c5 = false, c7 = false;
	for (int i = 0; i < P.size(); i++) {
		c3 = false, c5 = false, c7 = false;
		ll tmp = P[i];
		while (tmp > 0) {
			if (tmp % 10 == 3) c3 = true;
			else if (tmp % 10 == 5) c5 = true;
			else if (tmp % 10 == 7) c7 = true;
			tmp /= 10;
		}
		if (c3 && c5 && c7) {
			E.push_back(P[i]);
		}
	}
	sort(E.begin(), E.end());
	int i = 0, ans = 0;
	while (N >= E[i]) {
		ans++;
		i++;
		if (i == E.size()) break;
	}
	cout << ans << endl;
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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;
}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll N; cin >> N;
    REP(h, 1, 3501){
        REP(w, 1, 3501){
            //cout << h << " " << w << endl;
            if( (4 * h * w - N * w - N * h) > 0 &&  ((N * h * w) % (4 * h * w - N * w - N * h) ) == 0){
                cout << (N * h * w) / (4 * h * w - N * w - N * h) << " " << h << " " << w;
                return 0;
            }
        }
    }
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define For(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
// const ll MOD=1000000007ll;
const ll MOD=998244353ll;
const int MAX=510000;


int main(){
    int x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
while True:
    n,x=map(int,input().split(" "))
    if n==0 and x==0:
        break
    count=0
    ans_list=[]

    for i in range(1,n+1):
        for j in range(1,n+1):
            k=x-i-j
            if i==j or j==k or k==i:
                pass
            elif k<=0:
                pass
            elif k>n:
                pass
            elif i+j==x-k:
                count+=1
                ans_list.append([i,j,k])
            else:
                pass
    
    for item in ans_list:
        item.sort()
    ans_list.sort()
    
    dup=0
    for i in range(len(ans_list)):
        if i==0:
            pass
        elif ans_list[i]==ans_list[i-1]:
            dup+=1
    
    ans=len(ans_list)-dup
    print(ans)



Measured memory_bytes: 6244
#include <stdio.h>
#include <limits.h>
#define MAX_H 2000000
int H;

int parent(int i) {return i / 2;}
int left(int i) {return 2 * i;}
int right(int i) {return 2 * i + 1;}


void MaxHeapif(int A[], int i) {
	int l, r, largest, tmp;
	l = left(i);
	r = right(i);
	
	if (l <= H && A[l] > A[i]) {
		largest = l;
	} else {
		largest = i;
	}

	if (r <= H && A[r] > A[largest]) {
		largest = r;
	}

	if (largest != i) {
		tmp = A[i];
		A[i] = A[largest];
		A[largest] = tmp;
		MaxHeapif(A, largest);
	}
}

void buildMaxHeap(int A[]) {
	int i;
	for (i = H/2; i > 0; --i) {
		MaxHeapif(A, i);
	}
	return;
}

void heapIncreaseKey(int A[], int i, int key) {
	int tmp;
	if (key < A[i]) return;
	A[i] = key;

	while (i > 1 && A[parent(i)] < A[i]) {
		tmp = A[i];
		A[i] = A[parent(i)];
		A[parent(i)] = tmp;
		i = parent(i);
	}
	
	return;
}

void insert(int A[], int key) {
	H++;
	A[H] = INT_MIN;
	heapIncreaseKey(A, H, key);
}

int heapExtractMax(int A[]) {
	int max;
	
	if (H < 1) return 0;

	max = A[1];
	A[1] = A[H];
	H--;
	MaxHeapif(A, 1);

	return max;
		
}

int main(void) {
	int key, A[MAX_H+1] = {0};
	char com[20] = {0};
	H = 0;

	

	while (1) {
		scanf("%s", com);
		if (com[0] == 'i') {
			scanf("%d", &key);
			insert(A, key);
		} else if (com[0] == 'e' && com[1] == 'x') {
			key = heapExtractMax(A);
			printf("%d\n", key);
		} else {
			break;
		}
	}
	

	return 0;
}

Measured memory_bytes: 8424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, p = 1e9 + 7;
  string s;
  cin >> n >> s;

  vll cnt(26, 1);
  for (ll i = 0; i < n; i++) {
    cnt[s[i] - 'a']++;
  }

  ll ans = 1;
  for (ll i = 0; i < 26; i++) {
    ans *= cnt[i];
    ans %= p;
  }
  ans--;
  if (ans < 0) ans += p;
  cout << ans << endl;
}

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

const int maxn(5005);
const int mod(1e9 + 7);

inline void Inc(int &x, const int y) {
    x = x + y >= mod ? x + y - mod : x + y;
}

inline void Dec(int &x, const int y) {
    x = x - y < 0 ? x - y + mod : x - y;
}

inline int Add(int x, const int y) {
    return x + y >= mod ? x + y - mod : x + y;
}

inline int Sub(int x, const int y) {
    return x - y < 0 ? x - y + mod : x - y;
}

inline int Pow(ll x, int y) {
    ll ret = 1;
    for (; y; y >>= 1, x = x * x % mod)
        if (y & 1) ret = ret * x % mod;
    return ret;
}

int c[maxn][maxn], f[maxn][maxn], n, size[maxn], fac[maxn], tmp[maxn], pw[maxn];
vector <int> edge[maxn];

inline void AddEdge(int u, int v) {
	edge[u].push_back(v), edge[v].push_back(u);
}

void Dfs(int u, int ff) {
	int i, j;
	size[u] = f[u][1] = 1;
	for (int v : edge[u])
		if (v ^ ff) {
			Dfs(v, u);
			for (i = size[u]; ~i; --i) tmp[i] = f[u][i], f[u][i] = 0;
			for (i = 0; i <= size[u]; ++i)
				for (j = 0; j <= size[v]; ++j)
					if (j) Inc(f[u][i + j], (ll)f[v][j] * tmp[i] % mod);
					else Dec(f[u][i + j], (ll)f[v][j] * tmp[i] % mod);
			size[u] += size[v];
		}
	for (i = 2; i <= size[u]; i += 2) {
		j = i >> 1;
		Inc(f[u][0], (ll)f[u][i] * c[i][j] % mod * c[i - j][j] % mod * fac[j] % mod * pw[j] % mod);
	}
}

int main() {
	int i, j, u, v;
	scanf("%d", &n);
	for (i = 1; i < n; ++i) scanf("%d%d", &u, &v), AddEdge(u, v);
	for (fac[0] = i = 1; i <= n; ++i) fac[i] = (ll)fac[i - 1] * i % mod;
	for (c[0][0] = i = 1; i <= n; ++i)
		for (c[i][0] = j = 1; j <= i; ++j) c[i][j] = Add(c[i - 1][j - 1], c[i - 1][j]);
	pw[0] = 1, pw[1] = (mod + 1) >> 1;
	for (i = 2; i <= n; ++i) pw[i] = (ll)pw[i - 1] * pw[1] % mod;
	Dfs(1, 0), printf("%d\n", f[1][0]);
    return 0;
}

Measured memory_bytes: 195968
//A.cpp
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  int N;
  cin >> N;
  int a;
  map<int,int> chk;
  for(int i = 0; i < N; i++){
    cin >> a;
    ++chk[a];
  }

  long long Ans = 0;

  for(auto x: chk){
    if(x.first < x.second) Ans += x.second-x.first;
    else if(x.first > x.second) Ans += x.second;
  }

  printf("%lld\n",Ans);
  return 0;
}


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

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

Measured memory_bytes: 256
#include  <stdio.h>
 
int main(){
    long long int a,b=1,c,d=1000000000000000000;
    scanf("%lld",&a);
    
    for(int i=0;i<a;i++)
    {
        scanf("%lld",&c);
        if(c==0)
        {
            printf("0");
            return 0;
        }
        
        b = b * c;
        if(c>d)
        {
            b=-1;
        }
            
        d = d / c;
    }
    
    printf("%lld",b);
    return 0;
}

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


int main() {
    int A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;

    int as = 0;
    int aw = 100 * A;
    for(int i=0; 100*A*i<=F; i++){
        for(int j=0; 100*A*i + 100*B*j<=F; j++){
            for(int k=0; 100*A*i + 100*B*j + C*k<=F; k++){
                for(int l=0; 100*A*i + 100*B*j + C*k + D*l<=F; l++){
                    int s = C*k + D*l;
                    int w = 100*A*i + 100*B*j;
                    if(100 * s > E * w) continue;
                    if(w + s == 0) continue;
                    if((aw + as) * s > (w + s) * as){
                        as = s;
                        aw = w;
                    }
                }
            }
        }
    }
    cout << aw + as << " " << as << endl;
    return 0;
    
}


Measured memory_bytes: 384
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());
    
    int[][] val = new int[M][3];
    for(int i = 0; i < M; i++){
      int a = Integer.parseInt(sc.next());
      int b = Integer.parseInt(sc.next());
      val[i][0] = a;
      val[i][1] = b;
      val[i][2] = i;
    }
    Arrays.sort(val, (a, b) -> Integer.compare(a[1], b[1]));
    
    String[] ans = new String[M];
    int[] count = new int[N+1];
    for(int i = 0; i < M; i++){
      int a = val[i][0];
      count[a]++;
      String S = String.format("%06d%06d", a, count[a]);
      ans[val[i][2]] = S;
    }
    
    for(int i = 0; i < M; i++){
     System.out.println(ans[i]); 
    }
  }
}

Measured memory_bytes: 110544
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}


pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: i64 = 1_000_000_007;
const INF: i64 = std::i64::MAX/3;

fn solve() {
	let n = read!(usize);
	let mut a = read!([i64]);
	let mut cum = vec![0;n+2];
	for i in 0..n+1 {
		cum[i+1] = cum[i]+a[i];
	}
	let mut prev = 1;
	let mut ans = 0;
	for i in 0..n+1 {
		let mut ma = prev*2-a[i];
		if i==0 {
			ma = 1-a[i];
		}
		ma = min(ma, cum[n+1]-cum[i+1]);
		if ma < 0 {
			println!("-1");
			return;
		}
		ans += ma+a[i];
		prev = ma;
	}
	println!("{}",ans);
}

fn run() {
    solve();
}


Measured memory_bytes: 2996
#include <stdio.h>

int main(void)
{
	int A;
	int B;
	
	scanf("%d",&A);
	scanf("%d",&B);
	
	if(A>=0&&A<=8&&B>=0&&B<=8)
	{
	    printf("Yay!\n");
	}
	else 
	{
	    printf(":(\n");
    }

    return 0;
}

Measured memory_bytes: 128
// Try AtCoder
// author: Leonarone @ NEETSDKASU
package main

import "fmt"

func main() {
    var ar [27]int
    for i := 0; i < len(ar); i++ {
        ar[i] = -1
    }
    var n int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        var s string
        fmt.Scan(&s)
        var xs [27]int
        for _, r := range s {
            xs[int(r - 'a')]++
        }
        for j := 0; j < 27; j++ {
            if ar[j] < 0 || xs[j] < ar[j] {
                ar[j] = xs[j]
            }
        }
    }
    for i, e := range ar {
        if e >= 0 {
            s := string(rune(i + 'a'))
            for j := 0; j < e; j++ {
                fmt.Print(s)
            }
        }
    }
    fmt.Println()
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <cstring>
#include <set>
#include <bitset>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;
const unsigned gen_seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);

#define all(c) (c).begin(),(c).end()
#define forn(i, a, b) for(int i = a; i < b; i++)
#define read(x) scanf("%d", &x)
#define readv(x, n) vll x(n); forn(i,0,n) scanf("%lld", &x[i])

#define pb push_back
#define mp make_pair

vvi nb;
vi has;
vi ntop;
int ans = 0;
int s = 0;
void dfs(int v, int p) {
    int b = 0;
    int g = 0;
    for(auto u : nb[v]) {
        if(u==p) continue;
        dfs(u,v);
        if(!has[u]) {
            b++;
        }
        else has[v] = 1, g++;
    }
//    cout<<"WENT "<<v<<endl;
//    cout<<b<< " BAD CHILDREN\n";
    if(b>1) {
        ans += (b-1);
        has[v] = 1;
    }
    if(v==s) {
        if(g==1 && b<=1) ans++;
    }
//    cout<<v << " IS " << has[v]<<endl;
}

int main()
{
    int n;
    scanf("%d", &n);
    nb.resize(n);
    has = vi(n,0);
    ntop = vi(n,0);
    forn(i,0,n-1) {
        int u,v;
        scanf("%d %d", &u, &v);
        nb[u].pb(v);
        nb[v].pb(u);
    }
    
    if(n==2) {
        cout<<1;
        return 0;
    }
    while(nb[s].size() < 2) s++;
    dfs(s,-1);
    cout<<ans;
    
    
}


Measured memory_bytes: 15744
n,z,w = map(int,input().split())
a = list(map(int,input().split()))
ans = abs(w-a[-1])

if n == 1:
  print(ans)
  exit()
  
l = len(a)
for i in range(l-1):
  chk = 10**9
  for j in range(i+1,l):
    if j == l-1:
      chk = min(chk,abs(a[i]-a[j]))
    else:
      chk = min(chk,abs(a[l-1]-a[j]))
  ans = max(ans,chk)
  
print(ans)

Measured memory_bytes: 67980
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	long N;
	cin >> N;
	vector<long> A(N), M(N, 0);
	for (auto i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	int sign = 1;
	for (const auto& a : A)
	{
		M[0] += sign * a;
		sign = -1 * sign;
	}
	cout << M[0] << " ";
	for (auto i = 0; i < N - 1; ++i)
	{
		M[i + 1] = 2 * A[i] - M[i];
		if (i + 1 < N - 1)
		{
			cout << M[i + 1] << " ";
		}
		else
		{
			cout << M[i + 1] << endl;
		}
	}
	return 0;
}


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

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int m,n;
    m=min(a,b);
    n=min(c,d);
    cout<<m+n;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[20];
    int x[20][20];
    int y[20][20];
    for(int i=0; i<n; ++i){
        cin >> a[i];
        for(int j=0; j<a[i]; ++j){
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans;
    ans=0;
    int ansans=0;
    for(int i=0; i<(1<<n); ++i){
        bool b;
        b=true;
        int count;
        count =0;
        for(int k=0; k<n; ++k){
            if(!(i & (1 << k))) continue;
            for(int j=0; j<a[k]; ++j){
                if(((i>>(x[k][j]-1))&1)==y[k][j]){}
                else{
                    b=false;
                    break;
                }
            }
        }
        if(b){
        int countc; 
        countc=0;
        for(int j=0; j<n; ++j){
             if((i>>j)&1){
                 countc +=1;
             }
        }
        if(ansans<countc){
            ansans=countc;
        }  
        }  
    }
    cout << ansans << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  
  for(int i = 0;i < N;i++){
    cin >> A[i];
    --A[i];
  }
  for(int i = 0;i < N;i++){
    cin >> B[i];
  }
  for(int i = 0;i < N-1;i++){
    cin >> C[i];
  }
  int ans = 0;
  
  for (int i = 0; i < N; ++i) {
    ans += B[A[i]];
    
      if (i > 0 && A[i] == A[i-1]+1) {
        ans += C[A[i-1]];
      }
  }
  
  cout << ans << endl;
   
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int H, W;
    cin >> H >> W;
    string b[101];
    rep(i, H) cin >> b[i];
    map<char, int> mp;
    rep(r, H) rep(c, W) mp[b[r][c]]++;
    if (H%2 == 0 and W%2 == 0) {
        bool ok = true;
        for (auto& m : mp) {
            if (m.second%4 != 0) {
                ok = false;
                break;
            }
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
    else if (H%2 and W%2) {
        bool ok = true;
        int a, b, c; a=b=c=0;
        int tmp = H+W-2;
        for (auto& m : mp) {
            if (m.second%2) {
                if (a == 0) a = 1;
                else {
                    ok = false;
                }
                m.second--;
            }
            if (m.second > 0) {
                int num = m.second/4;
                b += num;
                m.second -= num*4;
                c += m.second/2;
            }
        }
        int tmp2 = H*W-1-tmp;
        if (b < tmp2/4) ok = false;
        else b -= tmp2/4;
        c += (b*4)/2;
        if (c != tmp/2) ok = false;
        cout << (ok ? "Yes" : "No") << endl;
    }
    else {
        bool ok = true;
        int a, b; a = b = 0;
        int tmp = (H%2 ? W : H);
        for (auto& m : mp) {
            if (m.second%2) ok = false;
            else {
                int num = m.second/4;
                a += num;
                m.second -= num*4;
                b += m.second/2;
            }
        }
        int tmp2 = H*W-tmp;
        if (a < tmp2/4) ok = false;
        else a -= tmp2/4;
        b += (a*4)/2;
        if (b != tmp/2) ok = false;
        cout << (ok ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cstring>
#include<map>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<time.h>
#include<limits.h>
#include<unordered_map>
#include<set>
#include<queue>
#include<stack>
#include <iomanip>

using namespace std;
#define inf LLONG_MAX
const int N = 201;
#define int long long


void solve() {
    int N;cin>>N;
    int ans=0;
    int pr = -1;
    for (int i = 0; i < N; i ++) {
        int x;
        cin >> x;
        if (x < pr) ans += pr - x;
        pr = max(pr, x);
    }
    cout << ans << endl;

}


int32_t main() {
    solve();
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n, k;
    cin >> n >> k;

    double res = 0;
    for (int i=1; i<=n; ++i) {
        int cnt = 0;
        int cur = i;
        while (cur < k) {
            ++cnt;
            cur *= 2;
        }
        res += 1.0 / pow(2, cnt);
    }

    cout << res / n << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=200005,MOD=1000000007,INV2=(MOD+1)>>1;
int qmi(int x,int y)
{
	int ans=1;
	for(;y;y>>=1,x=1ll*x*x%MOD)
		if(y&1)ans=1ll*ans*x%MOD;
	return ans;
}
inline int dmy(int x){return x>=MOD?x-MOD:x;}

int n,a[MAXN],b[MAXN],p[MAXN],las[MAXN],nxt[MAXN],invp[MAXN];
struct Fenwick
{
	int c[MAXN];
	void add(int x,int d){for(;x<=n;x+=(x&-x))c[x]=dmy(c[x]+d);}
	int query(int x){int s=0;for(;x;x-=(x&-x))s=dmy(s+c[x]);return s;}
}c0,c1,c2;

int main()
{
	#ifndef ONLINE_JUDGE
//	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	int sum=INV2,ans=0;
	readint(n);
	for(int i=1;i<=n;++i)readint(b[i]),++a[b[i]];
	for(int i=n;i;--i)a[i]+=a[i+1];
	p[0]=1;
	for(int i=1;i<=n;++i)
	{
		a[i]-=(n-i);
		if(a[i]<=0)return 0*printf("0\n");
		if(p[i-1])p[i]=1ll*p[i-1]*(a[i]-1)%MOD*qmi(a[i],MOD-2)%MOD;
		else p[i]=1ll*(a[i]-1)*qmi(a[i],MOD-2)%MOD;
		if(a[i]==1)las[i]=i;
		else las[i]=las[i-1];
		invp[i]=qmi(p[i],MOD-2);
		sum=1ll*sum*a[i]%MOD;
	}
	nxt[n+1]=n+1;
	for(int i=n;i;--i)
		if(a[i]==1)nxt[i]=i;
		else nxt[i]=nxt[i+1];
//for(int i=1;i<=n;++i)cerr<<a[i]<<" "<<p[i]<<" "<<invp[i]<<" "<<las[i]<<endl;
	for(int i=1;i<=n;++i)
	{
		ans=(ans+1ll*(c0.query(b[i])-c0.query(las[b[i]])+MOD)*sum%MOD*p[b[i]])%MOD;
		ans=(ans+1ll*(c2.query(b[i])-c2.query(nxt[b[i]]-1)+MOD)*sum%MOD*invp[b[i]])%MOD;
		ans=(ans+2ll*(c1.query(n)-c1.query(b[i])+MOD)%MOD*sum)%MOD;
		c0.add(b[i],invp[b[i]]);
		c1.add(b[i],1);
		c2.add(b[i],p[b[i]]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7296
#include <stdio.h>

int main(void)
{
	int n;
	int a, b, c, d;
	int cnt = 0;
	
	while (scanf("%d", &n) != EOF){
		cnt = 0;
		for (a = 0; a <= 9; a++){
			for (b = 0; b <= 9; b++){
				for (c = 0; c <= 9; c++){
					for (d = 0; d <= 9; d++){
						if (a + b + c + d == n){
							cnt++;
						}
					}
				}
			}
		}
		printf("%d\n", cnt);
	}
	
	return (0);
}

Measured memory_bytes: 596
n = gets.to_i
x = gets.split(' ').map(&:to_i)

x_sort = x.sort
x.each do |i|
  if i <= x_sort[n / 2 - 1]
    puts x_sort[n / 2]
  else
    puts x_sort[n / 2 - 1]
  end
end


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

using namespace std;

int main() {

  int l[10], v[2];
  double total, point, now;

  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v[0], &v[1]) + 1) {

    total = 0;
    now = 0;

    for(int i = 0; i < 10; ++i) total += l[i];

    point = total * v[0] / (v[0] + v[1]);
    
    for(int i = 0; i < 10; ++i) {
      now += l[i];
      if(now >= point) {
	cout << i + 1 << endl;
	break;
      }
    }

    //cout << total << " " <<  point << endl;

  }

}

Measured memory_bytes: 1208
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int k = sc.nextInt();
		int x = sc.nextInt();
		println(k * 500 >= x ? "Yes" : "No");
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i, 0, x) cin >> a[i];
    rep(i, 0, y) cin >> b[i];
    rep(i, 0, z) cin >> c[i];

    sort(all(a), greater<ll>());
    sort(all(b), greater<ll>());
    sort(all(c), greater<ll>());

    vector<ll> ans;
    rep(i, 0, x) {
        rep(j, 0, y) {
            if ((i + 1) * (j + 1) > k) break;
            rep(l, 0, z) {
                if ((i + 1) * (j + 1) * (l + 1) > k) break;
                ans.push_back(a[i] + b[j] + c[l]);
            }
        }
    }

    sort(all(ans), greater<ll>());

    rep(i, 0, k) cout << ans[i] << endl;
    return 0;
}


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

int top, S[1000];

void push(int);
int pop();
int isempty(void);
int isfull(void);

int main(){
  int x;
  int a, b;
  char s[100];

  top = 0;

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a + b);
    } else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b - a);

    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a * b);
    } else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",S[top]);

  return 0;
}









void push(int x){

  if(isfull() == 1){
    S[++top] = x;
  }

}

int pop(){

  if(isempty() == 1){
    top--;
    return S[top+1];
  }
  
}

int isempty(){

  if(top == 0){
    return 0;
  }
  else return 1;

}

int isfull(){

  if(top == 100){
    return 0;
  }
  else return 1;

}

Measured memory_bytes: 548
s = input()
t = input()
l = len(s)
cs = [0]*26
ct = [0]*26
for i in range(l):
    cs[ord(s[i])-ord('a')] += 1
    ct[ord(t[i])-ord('a')] += 1
cs.sort()
ct.sort()
if cs==ct:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9296
chomp($n=<>);
($a,$b,$c,$x,$y)=split/ /,$n;
if($x<=$y){
    $min=$x;
    $max=$y;
    $tasi=$b;
}else{
    $min=$y;
    $max=$x;
    $tasi=$a;
}
$sa=$max-$min;

if($c*2>=$a+$b){
    $sum+=$a*$min+$b*$min;
}else{
    $sum+=$c*2*$min;
}
if($tasi>=$c*2){
    $sum+=$c*2*$sa;
}else{
    $sum+=$sa*$tasi;
}
print $sum;

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

int main()
{
	int h, w;
	bool tate[100] = {}, yoko[100] = {};
	cin >> h >> w;
	string s[100];
	for (int i = 0; i < h; ++i)
	{
		cin >> s[i];
	}
	for (int i = 0; i < h; ++i)
	{
		int way = 0;
		for (int j = 0; j < w; ++j)
		{
			way += (s[i][j] == '.');
		}
		if (way == w)
		{
			yoko[i] = 1;
		}
	}
	for (int i = 0; i < w; ++i)
	{
		int way = 0;
		for (int j = 0; j < h; ++j)
		{
			way += (s[j][i] == '.');
		}
		if (way == h)
		{
			tate[i] = 1;
		}
	}
	for (int i = 0; i < h; ++i)
	{
		if (!yoko[i])
		{
			for (int j = 0; j < w; ++j)
			{
				if(!tate[j])
				{
					cout << s[i][j];
				}
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<Pi,int> Pii;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll n;
	ll c[501],s[501],f[501];

	cin>>n;

	for(ll i=1; i<n; i++){
		cin>>c[i]>>s[i]>>f[i];
	}
	int total=0;
	for(ll i=1; i<n-1; i++){
		total=s[i]+c[i];
		for(ll j=i+1; j<n; j++){
			if(total<=s[j]){
				total=s[j]+c[j];
			}else{
				ll r=s[j];
				for(ll k=0; k<100000001; k++){
					r+=f[j];
					if(total<=r){
						total=r+c[j];
						break;
					}
				}
			}

		}
		cout<<total<<endl;
		total=0;
	}
	cout<<s[n-1]+c[n-1]<<endl;
	cout<<"0"<<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;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m), p(m);
  vector<vector<int>> s(m);
  rep(i, m) {
    cin >> k[i];
    s[i] = vector<int>(k[i]);
    rep(j, k[i]) {
      cin >> s[i][j];
      --s[i][j];
    }
  }
  rep(i, m) cin >> p[i];

  int ans = 0;
  rep(bit, 1<<n) {
    vector<int> is_on(n, 0), num_on(m, 0);
    rep(i, n) if (1<<i & bit) is_on[i] = 1;
    bool all_on = true;
    rep(i, m) {
      rep(j, k[i]) if (is_on[s[i][j]]) ++num_on[i];
      if (num_on[i] % 2 != p[i]) all_on = false;
    }
    if (all_on) {
      ++ans;
      // printf("bit = %d\n", bit);
      // rep(i, n) printf("is_on[%d] = %d, ", i, is_on[i]);
      // printf("\n");
      // rep(i, m) printf("num_on[%d] = %d, ", i, num_on[i]);
      // printf("\n");
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <math.h>

using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1) {
		int N;
		vector<int> box_x;
		vector<int> box_y;
		cin >> N;
		if( N == 0 ) break;

		box_x.push_back(0);
		box_y.push_back(0);

		for(int i = 0; i < N - 1; i++) {
			int tmp, dir;
			int dx, dy;
			cin >> tmp >> dir;
			switch(dir) {
				case 0:
					dx = -1;
					dy = 0;
					break;
				case 1:
					dx = 0;
					dy = 1;
					break;
				case 2:
					dx = 1;
					dy = 0;
					break;
				case 3:
					dx = 0;
					dy = -1;
					break;
			}
			box_x.push_back(box_x.at(tmp) + dx);
			box_y.push_back(box_y.at(tmp) + dy);
		}

		int xmin = 0, xmax = 0;
		for(int i = 0; i < box_x.size(); i++) {
			if( xmin > box_x.at(i) ) xmin = box_x.at(i);
			if( xmax < box_x.at(i) ) xmax = box_x.at(i);
		}
		int ymin = 0, ymax = 0;
		for(int i = 0; i < box_y.size(); i++) {
			if( ymin > box_y.at(i) ) ymin = box_y.at(i);
			if( ymax < box_y.at(i) ) ymax = box_y.at(i);
		}
		cout << xmax - xmin + 1 << " " << ymax - ymin + 1 << endl;

	}

	
	//while(1){}
	return 0;
}

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

int main() {
  int n;
  long long int t;
  cin >> n >> t;
  long long int a[n];
  int trash;
  cin >> trash;
  for(int i=1;i<n;i++) cin >> a[i];
  a[0] = 0;

  long long x = 0;
  for(int i=0;i<n;i++) {
    long long int num;
    num = a[i+1] - a[i];
    if(num >= t) x += t;
    else x += num;
  }
  cout << x << endl;
}


Measured memory_bytes: 1792
//
//  main.cpp
//  E
//
//  Created by Charles on 2017/12/24.
//  Copyright © 2017年 Charles. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn=2e5+5;
typedef long long ll;
int c[maxn],len,cnt[26],p[maxn],last[26],vis[maxn];
char s[maxn];
int lowbit(int x){
    return x&-x;
}
void update(int pos){
    while(pos<maxn){
        c[pos]++;
        pos+=lowbit(pos);
    }
}
int query(int pos){
    int ans=0;
    while(pos){
        ans+=c[pos];
        pos-=lowbit(pos);
    }
    return ans;
}
int main(int argc, const char * argv[]) {
    while(~scanf("%s",s+1)){
        len=(int)strlen(s+1);
        for(int i=1;i<=len;++i){
            int t=s[i]-'a';
            cnt[t]++;
            p[i]=last[t];
            last[t]=i;
        }
        int count=0;
        for(int i=0;i<26;++i) count+=(cnt[i]&1);
        if(count>len%2) {
            puts("-1");
            continue;
        }
        ll ans=0,n=len,prenum=0;
        for(int i=1;i<=len;++i){
            if(!vis[i]){
                int t=s[i]-'a';
                int la=last[t];
                if(i>=la){
                    n--;
                    ans+=n/2;
                }
                else{
                    vis[la]=1;
                    ans+=n-(la-prenum-query(la));
                    update(la);
                    n-=2;
                    last[t]=p[la];
                }
                prenum++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 2048
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));

    long x = sc.nextInt();
    long n = sc.nextInt();
    TreeSet<Long> longs = new TreeSet<>();

    for (long i = 0; i < n; i++) {
      long p = sc.nextLong();
      longs.add(p);
    }

    ArrayList<Long> ans = new ArrayList<>();
    long target = x;
    for (long i = 0; i < 100; i++) {
      long upper = target + i;
      long lower = target - i;
      if (!longs.contains(upper)) {
        ans.add(upper);
      }
      if (!longs.contains(lower)) {
        ans.add(lower);
      }
      if (ans.size() > 0) {
        break;
      }
    }

    long pans;
    if (ans.size() > 1) {
      pans = Math.min(ans.get(0), ans.get(1));
    } else {
      pans = ans.get(0);
    }
    out.println(pans);
    out.close();
  }

  /*
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {

    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 34048
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int R;
	cin >> R;
	if (R < 1200) cout << "ABC\n";
	else if (R < 2800) cout << "ARC\n";
	else cout << "AGC\n";

	return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)

int main(void) {
  int n; cin >> n;
  int dp[n];
  dp[0] = dp[1] = 1;
  FOR(i, 2, n + 1) {
    dp[i] = dp[i - 1] + dp[i - 2];
  }
  cout << dp[n] <<endl;
  return 0;
}

Measured memory_bytes: 3096
using System;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long totaly = 0,totalb = 0;

            for (int i = 0; i < N; i++)
            {
                string[] s = Console.ReadLine().Split(' ');

                if (s[1].Equals("JPY"))
                    totaly += long.Parse(s[0]);
                else
                {
                    totalb += long.Parse(s[0].Replace(".", ""));
                }
            }
            totalb = totalb * 38;
            totaly += totalb / 10000;
            totalb = totalb % 10000;

            Console.Write(totaly.ToString());
            Console.Write(".");
            Console.WriteLine(totalb.ToString("0000"));

        }
    }
}


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

int main() {
	int n, T,cost=1001,time,a,b,j=0;
	cin >> n >> T;
	
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (b > T) {
			continue;
		}
		if (a < cost) {
			cost = a;
		}
	}
	if (cost == 1001) {
		cout << "TLE" << endl;
		return 0;
	}
	cout << cost << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int N, L;
int s[MAX_N];

void solve()
{
  for (int i = 0; i < N; i++) {
    s[i] = L + (i + 1) - 1;
  }
  int idx;
  int m = 1000;
  for (int i = 0; i < N; i++) {
    if (abs(s[i]) < m) {
      m = abs(s[i]);
      idx = i;
    }
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += s[i];
  }
  sum -= s[idx];
  printf("%d\n", sum);
}

int main(void)
{
  cin >> N >> L;
  solve();
  return 0;
}


Measured memory_bytes: 888
/* ex5_3
    fmuacshai */

#include<stdio.h>
#include<math.h>
int main(void){
    int height,wide,i,j;
    scanf("%d",&height);
    scanf("%d",&wide);
    char squeres[height][wide];
    for(i=0;i<height;i++){
        for(j=0;j<wide;j++){
            scanf(" %c",&squeres[i][j]);
        }
    }
    int sensorh[height],sensorw[wide];
    for(i=0;i<height;i++){
        sensorh[i]=0;
    }
    for(j=0;j<wide;j++){
        sensorw[j]=0;
    }
    for(i=0;i<height;i++){
        for(j=0;j<wide;j++){
            if(squeres[i][j]=='#'){
                sensorh[i]=1;
                sensorw[j]=1;
            }
        }
    }
    for(i=0;i<height;i++){
        for(j=0;j<wide;j++){
            if(sensorh[i]==1 && sensorw[j]==1){
                printf("%c",squeres[i][j]);
            }
        }
        if(sensorh[i]==1){
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(){
  int n,i,count=0,a[10000],flag,j;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&a[i]);
  }
  for(i = 0; i < n; i++){
    flag = 1;
    for(j = 2; j*j <= a[i]; j++){
      if(a[i]%j == 0) flag = 0;
    }
    if(flag)count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 628
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            int ans = Math.min(a * n, b);
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22740
input_line = input().split()

N = int(input_line[0])
X = int(input_line[1])

L = list(map(int, input().split()))

resultArray = []

for i in range(1, N+2):
  if i == 1:
    resultArray.append(0)
    continue
  D = resultArray[i-2] + L[i-2]
  resultArray.append(D)

result = [n for n in resultArray if n <= X]

print(len(result))


Measured memory_bytes: 3060
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>

using namespace std;

int main(void)
{
	set <int> s;
	int n, t;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> t;
		s.insert(t);
	}

	cout << s.size() << '\n';
	return 0;

}

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

int main(){
  int n,m; cin>>n>>m;
  vector<int> s(n),l(n),c(n);
  for(int i=0;i<n;i++){
    cin>>s[i]>>l[i]>>c[i];
  }
  vector<int> tt(200010,0),sm(200010,0);
  for(int i=1;i<=m;i++){
    for(int j=0;j<200010;j++) tt[j]=0;
    for(int j=0;j<n;j++){
      if(i==c[j]){
        tt[s[j]*2-1]++; tt[l[j]*2]--;
      }
    }
    for(int j=1;j<200010;j++) tt[j]+=tt[j-1];
    for(int j=0;j<200010;j++) if(tt[j]>0) sm[j]++;
  }
  int ans=0;
  for(int i=0;i<200010;i++) if(sm[i]>ans) ans=sm[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int b[300001],w[300001],n;
char s[300001];
int B(int x,int y){return b[y]-b[x-1];}
int W(int x,int y){return w[y]-w[x-1];}
int main()
{
	cin>>n>>(s+1);
	for(int i=1;i<=n;i++)b[i]=b[i-1]+(s[i]=='#'),w[i]=w[i-1]+(s[i]=='.');
	int ans=n;
	for(int i=0;i<=n;i++)ans=min(ans,B(1,i)+W(i+1,n));
	cout<<ans<<'\n';
}


Measured memory_bytes: 2048
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
	int N,A,B;
	scanf("%d %d %d",&N,&A,&B);
	int s=N*A;
	if(s==B)	printf("%d\n",s);
	if(s<B)		printf("%d\n",s);
	if(s>B)		printf("%d\n",B);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <cstdlib>
#define PI acos(-1.0)
#define ll long long int
#define db double
#define ull unsigned long long int
#define Fill(x,y) memset(x,y,sizeof(x))
#define bug printf("!!!!!!\n");
#define fi first
#define se second
using namespace std;
const db eps = 1e-6;
const int inf = 0x3f3f3f3f; //用这个可以直接mem
const ll INF = 1e18;
const int mod = 1e9+7;
const int maxn = 1e5+5;
int cas=1;
int a[15][15];
void f()
{
    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
            }
        }
    }
}
void solve()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++) {
            scanf("%d",&a[i][j]);
        }
    }
    f(); int ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) {
            int u; scanf("%d",&u);
            if(u == -1 || u == 1) continue;
            ans += a[u][1];
        }
    }
    cout << ans << endl;
}
int main()
{
    // freopen("in.txt","r",stdin);
    //  freopen("out.txt","w",stdout);
    int t = 1 ;
    //scanf("%d",&t);
    while(t--){
       // printf("Case %d: ", cas++);
        solve();
        //printf("\n");
    }
}









Measured memory_bytes: 256
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

gcd_v = 0
max_a = 0
a.each do |a_v|
  max_a = [max_a, a_v].max
  gcd_v = a_v.gcd(gcd_v)
end

if max_a >= k && k % gcd_v == 0
  puts 'POSSIBLE'
else
  puts 'IMPOSSIBLE'
end


Measured memory_bytes: 20732