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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

vector<bool> prime(100200);
void eratos ( int n){
	prime[2] = true; prime[0] = prime[1] = false;
	for(int i = 3; i <= n; i += 2) prime[i] = true, prime[i+1] = false;
	int limit = (int)sqrt((double)n) + 1;
	for(int i = 3; i <= limit; i += 2){
		if(!prime[i]) continue;
		for(int j = i * i, k = i * 2; j <= n; j += k) prime[j] = false;
	}
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int q;
	cin >>q;
	eratos(100100);
	
	VI oks;
	rep(i, 100080) if(prime[i] && prime[(i+1)/2]) oks.push_back(i);

	rep(i, q){
		int l, r;
		cin >>l>>r;
		int ans = upper_bound(all(oks), r) - lower_bound(all(oks), l);
		cout << ans <<"\n";
	}
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
const double pi = 3.1415926535898;

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double v = a * a * b;
    double ans;
    if(x * 2 > v){
        double m = v-x;
        m /= a;
        double l = m / a * 2;
        ans = atan(l/a);
    }
    else{
        x /= a;
        double l = x / b * 2;
        ans = atan(b/l);
    }
    ans *= 180;
    ans /= pi;
    printf("%.10lf",ans);
    cout << endl;
}

Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split())

dx = x1 - x2 #-4
dy = y1 - y2 #-3

x3,y3 = x2 + dy,y2 - dx
x4,y4 = x3 + dx,y3 + dy

print(x3,y3,x4,y4)


Measured memory_bytes: 9156
//
//  main.cpp
//  Shik_And_Stone
//
//  Created by Uttam Datta on 31/05/19.
//  Copyright © 2019 Uttam Datta. All rights reserved.
//

#include <iostream>
#include <vector>
using namespace std;

int rows,columns;

bool ans(string A[]){
    pair <int,int> d;
    for(int i = 0; i < rows-1; i++){
        for(int j = 0; j < columns-1; j++){
            if(A[i][j] = '#'){
                d = make_pair(i, j);
            if((A[i][j] == '#' && A[i+1][j] == '#' && A[i][j+1] == '#') || (d.second>j)){
                return false;
            }
                
            }
        }
    }
    return true;
}


int main(){
    cin >> rows >> columns;
    string A[rows];
    for(int i = 0; i < rows; i++){
        cin >> A[i];
    }
    bool res = ans(A);
    if(res){
        cout << "Possible" << endl;
    }
    else{
        cout << "Impossible" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())


dis = abs(a-b)
if a < b:
    a_mov = v*t + a
    b_mov = w*t + b
    # print(a_mov,b_mov)
    if b_mov <= a_mov:
        print("YES")
    else:
        print("NO")
else:
    a_mov = (-1*v)*t + a
    b_mov = (-1*w)*t + b
    # print(a_mov,b_mov)
    if b_mov >= a_mov:
        print("YES")
    else:
        print("NO")
        

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

#define ms(s,n) memset(s,n,sizeof(s))
#define all(a) a.begin(),a.end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mk make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;

const int MOD = (int) 1e9+7;
const int INF = (int) 1e9+1;
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int res=0;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])
					if(a[i]+a[j]>a[k])
						res++;
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


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

int main(){
   string s;
   bool a[30];
   cin>>s;
   for(int i=0;i<30;i++){
       a[i]=false;
   }
   for(int i=0;i<s.size();i++){
       a[s[i]-'a']=true;
   }
   for(int i=0;i<26;i++){
       if(!a[i]){
           cout<<char('a'+i)<<endl;
           return 0;
       }
   }
   cout<<"None"<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}



vector<int> edge[200000];

int ans[200000];
queue<int> q;
signed main(){
    int n,m;
    cin >> n >> m;
    REP(i,m){
        int a1,b1;
        cin >> a1 >> b1;
        edge[a1].pb(b1);
        edge[b1].pb(a1);
    }
    q.push(1);
    ans[1] = 1;
    while(q.size()>0){
        int na = q.front();
        q.pop();
        REP(i,edge[na].size()){
            if(ans[edge[na][i]]!=0) continue;
            ans[edge[na][i]] = na;
            q.push(edge[na][i]);
        }
    }
    cout << "Yes" << endl;
    REP(i,n){
        if(i==0) continue;
        cout << ans[i+1] << endl;
    }
    return 0;
}

Measured memory_bytes: 15276
use std::cmp;
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;
use std::string::String;

const MAX: i64 = 2147483647;

struct Segtree {
    node: Vec<i64>,
    size: usize,
}

impl Segtree {
    fn new(n: i32) -> Segtree {
        Segtree {
            size: {
                let mut tmp_size: usize = 1;
                while tmp_size < n as usize {
                    tmp_size *= 2;
                }
                tmp_size
            },
            node: {
                let mut tmp_size: usize = 1;
                while tmp_size < n as usize {
                    tmp_size *= 2;
                }
                vec![MAX; 2*tmp_size-1]
            }
        }
    }

    fn update(&mut self, mut k: usize, val: i64) {
        k += self.size - 1;
        self.node[k] = val;
        while k > 0 {
            k = (k - 1) / 2;
            self.node[k] = std::cmp::min(self.node[2*k+1], self.node[2*k+2]);
        }
    }

    fn get(&self, queryL: usize, queryR: usize) -> i64 {
        self._get(queryL, queryR, 0, self.size, 0)
    }

    fn _get(&self, queryL: usize, queryR: usize, nodeL: usize, nodeR: usize, k: usize) -> i64 {
        if nodeR <= queryL || queryR <= nodeL {return MAX;}
        if queryL <= nodeL && nodeR <= queryR {return self.node[k];}
        let nodeM: usize = (nodeL + nodeR) / 2;
        let vl: i64 = self._get(queryL, queryR, nodeL, nodeM, 2*k+1);
        let vr: i64 = self._get(queryL, queryR, nodeM, nodeR, 2*k+2);
        std::cmp::min(vl, vr)
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    /*
    let mut buf = String::new();
    std::io::stdin().read_line(& mut buf).ok();
    let buf = buf.trim();
    let n: i32 = buf.trim().parse().ok().unwrap();
    //println!{"{}", n};

    let mut buf = String::new();
    std::io::stdin().read_line(& mut buf).ok();
    let buf = buf.trim();
    let v: Vec<i32> = buf.split_whitespace().map(|x| x.parse().ok().unwrap()).collect();
    */
    let (n, q): (i32, i32) = (read(), read());
    let mut seg = Segtree::new(n);

    for _ in 0..q {
        let (com, x, y): (i32, usize, usize) = (read(), read(), read());
        if com == 0 {
            seg.update(x, y as i64);
        }
        else {
            println!{"{}", seg.get(x, y+1)};
        }
    }
    /*
    let mut seg = Segtree::new(4);
    println!{"{}", seg.node.len()};
    seg.update(0, 10);
    seg.update(1, 2);
    println!{"{}", seg.node[3]};
    println!{"{}", seg.node[4]};
    println!{"{}", seg.get(0, 1)};
    */
}



Measured memory_bytes: 7080
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let xs: Vec<usize> = (0..n).map(|_| sc.cin()).collect();
    let mut ans = 0;
    for i in 1..n-1 {
        let mut a = vec![xs[i-1],xs[i],xs[i+1]];
        a.sort();
        if a[1] == xs[i] {ans+=1;}
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>

using namespace std;

int n;
int x[3];
bool ans;

int main(){
	cin >> n;
	while (n--){
		cin >> x[0] >> x[1] >> x[2];
		sort(x, x + 3);
		(x[0] * x[0] + x[1] * x[1] == x[2] * x[2]) ? cout << "YES\n" : cout << "NO\n";
	}
}

Measured memory_bytes: 1136
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, A;
  cin>>N;
  bool ok = true;
  for(int i=0; i<N; i++){
    cin>>A;
    if(A%2==0 && (A%3!=0 && A%5!=0)){
      ok = false;
    }
  }
  cout<<(ok? "APPROVED\n": "DENIED\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define dbug printf("I am here\n");
    #define Fast ios_base::sync_with_stdio(false); cin.tie(0);
    #define vs            v.size()
    #define ss             s.size()
    #define be            v.begin(),v.end()
    #define pii             pair<int,int>
    #define ll               long long
    #define pb             push_back
    #define mpp            make_pair
    using namespace std;

    int main() {

    ll int a,b,c,d,n,k;
    int tst;
    cin>>a;
    vector<ll int>ar(a,0);
    for(int i = 1; i<=a; i++){
        for(int j = i; j <= a; j += i){//ei loop er maddame ami sob sokhar divisor berkori.onek ta seive er motokore kati.
            ar[j]++;
        }
    }
    ll int sum = 0;

    for(int i =1;i<=a; i++){
        sum += (ar[i]*i);
    }
    cout<<sum<<endl;

        return 0;
    }


Measured memory_bytes: 81380
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
int main() {FIN
	
	string s;
	cin >> s;
	for (int i = 0; i < (int)s.size(); i++) {
		if (s[i] == '7') {
			cout << "Yes\n";
		  return 0;
		}
	}
	  
	cout << "No\n";
	return 0;
}


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

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    int *A = new int[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    int *B = new int[N];
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    
    int *C = new int[N-1];
    for (int i = 0; i < N-1; i++) {
        cin >> C[i];
    }
    
    int ans = 0;
    int prev = -1;
    for (int i = 0; i < N; i++) {
        int idx = A[i] - 1;
        
        ans += B[idx];
        if (prev == idx - 1) {
            ans += C[prev];
        }
        
        prev = idx;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
# -*- coding: utf-8 -*-

n = input()
RATE = 380000.0
ans = 0.0
for i in range(n):
    inpt = map(str, raw_input().split())
    if inpt[1] == "JPY":
        ans += float(inpt[0])
    else:
        ans += float(inpt[0]) * RATE

print ans        




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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)


void func(long long N, std::string S){
    int ans = 0;
    int pos = S.find("ABC");
    while(pos != string::npos) {
        ans += 1;
        S = S.substr(pos+1);
        pos = S.find("ABC");
    }
    cout << ans << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    func(N, S);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
has = defaultdict(int)
arr = list(map(int, input().split(" "))) 
ans = 0
for a in arr :
    has[a] += 1
    ans += a

Q = int(input())
for i in range(Q) :
    b, c = map(int ,input().split(" "))
    ans -= has[b]*b
    ans += has[b]*c

    has[c] += has[b]
    has[b] = 0
    print(ans)


Measured memory_bytes: 24140
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, a[100008];
string str;

int main(){
	cin >> n;
	for(ll i = 1; i <= n; i++){cin >> a[i];}
	
	vector<ll> c;
	c.push_back(a[n]);
	ll amax = a[n];
	
	for(ll i = n-1; i >= 1; i--){
		if(a[i] >= amax){
			c.push_back(a[i]);
			amax = a[i];
		}
		else{
			ll lng = -1;
			ll rok = c.size()-1;
			while(rok-lng > 1){
				ll buf = (lng+rok)/2;
				if(a[i] < c[buf]){rok = buf;}
				else{lng = buf;}
			}
			//while(rok > 1 && c[rok] == c[rok-1]){rok--;}
			c[rok] = a[i];
			if(rok == c.size()-1){amax = a[i];}
		}
	}
	
	cout << c.size() << endl;
	return 0;
}

Measured memory_bytes: 2168
<?php

fscanf(STDIN, "%d %d %d %d %d", $a, $b, $c, $x, $y);

$min = min($x, $y);
$rest = max($x, $y) - $min;

$sum = 0;
if ($a + $b < 2 * $c) {
    $sum += ($a + $b) * $min;
} else {
    $sum += 2 * $c * $min;
}

if ($min === $y) {
    if ($a < 2 * $c) {
        $sum += $a * $rest;
    } else {
        $sum += 2 * $c * $rest;
    }
} else {
    if ($b < 2 * $c) {
        $sum += $b * $rest;
    } else {
        $sum += 2 * $c * $rest;
    }
}

echo $sum;


Measured memory_bytes: 4728
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;


int main(){
    int n;cin>>n;
    int s2=0,s4=0;
    for(int i=0;i<=n-1;i++){
        int k;cin>>k;
        if(k%4==0)s4++;
        else if(k%2==0)s2++;
    }
    bool flag;
    if(s2==0&&s4==0){
        flag=false;
    }else if(s2==0){
        if(s4*2+1>=n)flag=true;
        else flag=false;
    }else if(s4==0){
        if(s2>=n)flag=true;
        else flag=false;
    }else{
        if(s4*2+s2>=n)flag=true;
        else flag=false;
    }
    if(flag==true)printf("Yes");
    else printf("No");
    
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int read()
{
	char ch=getchar();int x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(int aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar('0'+aa%10);
	return;
}
int n;
int vis[100005];
int tot,head[100005],nx[200005],to[200005];
void jia(int aa,int bb)
{
	tot++;
	nx[tot]=head[aa];
	to[tot]=bb;
	head[aa]=tot;
	return;
}
void dfs(int rt,int fa)
{
	for(int i=head[rt];i;i=nx[i])
	{
		int yy=to[i];
		if(yy==fa) continue;
		dfs(yy,rt);
		if(!vis[yy]&&!vis[rt]) vis[yy]=1,vis[rt]=1;
	}
	return;
}
int main()
{
	n=read();
	for(int i=1;i<n;++i)
	{
		int x=read(),y=read();
		jia(x,y);jia(y,x);
	}
	dfs(1,1);
	for(int i=1;i<=n;++i) if(!vis[i]) {puts("First");return 0;}
	puts("Second");
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

const int N = 200010;

int a[N];
int n , m;

int main()
{
    cin >> n;
    for(int i = 1 ; i <= n ; i++)    cin >> a[i];
    
    long long s = 0;
    for(int i = 1 ; i < n ; i++)
    {
        int x = a[i + 1] - a[i];
        if(x < 0) a[i + 1] += -x;
        s += x < 0 ? -x : 0;
    }
    cout << s << endl;
    return 0;
}

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

char chess(int h, int w) {
    if((h+w)%2 == 0){
        return '#';
    }
    return '.';
}

int main(void)
{
    int H, W;
    while(true){
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cout << chess(i,j);
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<ll> x(2), y(2);
    cin >> x[0] >> x[1] >> y[0] >> y[1];
    if(x[0] <= 0 && x[1] >= 0) x.push_back(0);
    if(y[0] <= 0 && y[1] >= 0) y.push_back(0);
    ll ans = -1e18;
    for(ll a : x){
        for(ll b : y){
            ans = max(ans, a*b);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

long long int X, K, D;

int main(void) {


	cin >> X >> K >> D;

	if (X < 0) { X = -X; }

	long long int ans = X;
	if (X / D >= K) { ans = X - K*D; }
	else {
		long long int num = X / D;

		K -= num;  X = X - num*D;
		
		K = K % 2;
		
		if (K == 1) { X = X - D; }

		ans = abs(X);
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  int N,K,x,sum=0;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    cin >> x;
    if(x < K-x){
      sum += 2*x;
    }
    else{
      sum += 2*(K-x);
    }
  }
  cout << sum << endl;
}

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


int main(){
    int n;
    int a[105];
    int b[105]={0};
    cin>>n;
    int res=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i>=1)
        {
            if(a[i]==a[i-1]&&b[i-1]==0)
            {
                res++;
                b[i]=1;
            }
        }
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 256
//g++  7.4.0

#include <bits/stdc++.h>
using namespace std;

int main()
{
   int n,W;
    cin>>n>>W;
    int w[n];
    int val[n];
    for(int i =0;i<n;i++){
        cin>>w[i]>>val[i];
    }
  //int dp[W+1][n+1];
    long long int dp[W+1][n+1];
    for(int i=0;i<=W;i++)
        dp[i][0]=0;
    for(int i=0;i<=n;i++)
        dp[0][i]=0;
    for(int i=1; i<=W;i++)
   {
       for(int j=1;j<=n;j++){
           dp[i][j] = dp[i][j-1];
       if(i-w[j-1]>=0)
           dp[i][j] = dp[i][j-1] > dp[i-w[j-1]][j-1]+val[j-1]?dp[i][j-1]:(dp[i-w[j-1]][j-1]+val[j-1]);
       }
   }
    cout<<dp[W][n];
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int a, b, c;
  vector<int> x(3);
  cin >> x[0] >> x[1] >> x[2];
  sort(x.rbegin(), x.rend());
  int ans = 10 * x[0] + x[1] + x[2];
  cout << ans << endl;
  return 0;
}


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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0

int main ()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout.tie(NULL);

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> a(n);
    for(int& x : a) {
        scanf("%d", &x);
    }
    vector<bool> dp(k + 1);
    for(int stones = 0; stones <= k; ++stones) {
        for(int x : a) {
            if(stones >= x && !dp[stones-x]) {
                dp[stones] = true;
            }
        }
    }
    
    puts(dp[k] ? "First" : "Second");

    return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
S = list(map(int, list(input())[: -1]))
N = len(S)
P = 2019
rcs = [0] * (N + 1)
for i in range(N, 0, -1): rcs[i - 1] = (rcs[i] + S[i - 1] * pow(10, N - i, P)) % P
#print(rcs)
d = dd(list)
for i in range(N + 1):d[rcs[i]].append(i)
res = 0
if P == 2 or (P == 5):
  for i in range(N - 1, -1, -1):
    res += (S[i] % P == 0) * (i + 1)
  print(res)
  exit(0)
table = [0] * P
for i in range(N, -1, -1):
  x = rcs[i]
  res += table[x]
  table[x] += 1
print(res)


Measured memory_bytes: 89432
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define ld long double
#define pii pair <int,int>
#define pll pair <ll,ll>
#define pil pair <int,ll>
#define pli pair <ll,int>
#define ull unsigned long long
#define pdd pair <double,double>
#define pb push_back
#define mp make_pair
#define puu pair<ull,ull>
#define pvv pair<vector<int>, vector<int> >
#define _bp __builtin_popcount
#define ptt pair <Tree*,Tree*>
#define all(v) v.begin(),v.end()
#define en "\n"
//const long double pi = acos(-1);
void boos()
{
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}
void file()
{
   freopen("max.in","r",stdin);
   freopen("max.out","w",stdout);
}
const ll INF = 1e9 + 7;
const ll INF1 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTmx = (int)1e9;
const ld EPS = (ld)1e-9;
const int N = 3e5 + 100;
int main()
{
    //file();
    boos();
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0;i <= 2;i++)
    {
    	if(s[i] == t[i])ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
n=int(input())
for i in range(1,3501):
  for j in range(i,3501):
    if (4*i*j-n*(i+j))>0 and n*i*j%(4*i*j-n*(i+j))==0:
      k=n*i*j//(4*i*j-n*(i+j))
      break
  else:
    continue
  break
print(i,j,k)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
void Main(){
    int A = read(), B = read(), C = read();
    if ((A<C) ^ (B<C)) printf("Yes\n");
    else printf("No\n");
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
   long n,k,ans=0;
   cin >> n >> k;
   if(k==0){
       cout << n*n << endl;
       return 0;
   } 
   for(int b=k+1;b<=n;b++){
      ans += (n/b)*(b-k);
      if(k<=n%b) ans += n%b-k+1; 
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

vector<pair<int, double>> dices[10];
double hanchoE;
int ns[10], ms[10];
int t;

bool solve() {
  rep(i, t) {
    double E = 0.0;
    double sumr = 0.0;
    rep(k, ms[i]) {
      E += dices[i][k].first * dices[i][k].second;
      sumr += dices[i][k].second;
    }
    E /= sumr;
    if(E > hanchoE + 0.0000001) {
      return true;
    }
  }
  return false;
}

int main() {

  cin >> t;
  rep(ii, t) {
    cin >> ns[ii] >> ms[ii];
    rep(i, ms[ii]) {
      int v; double r; cin >> v >> r;
      dices[ii].emplace_back(v, r);
    }
  }

  int p, q; cin >> p >> q;
  double sumr = 0.0;
  rep(i, q) {
    int v; double r; cin >> v >> r;
    hanchoE += v * r;
    sumr += r;
  }

  hanchoE /= sumr;
  cout << (solve() ? "YES" : "NO") << endl;
  
  return 0;
}

Measured memory_bytes: 3300
n = int(input())
a = []
ans = 0
for i in range(n):
    k = list(map(int, input().split()))
    a.append(k)
flag = [[True for i in range(n)] for j in range(n)]
for i in range(n):
    for j in range(n):
        for k in range(n):
            if a[j][i] + a[i][k] < a[j][k]:
                print(-1)
                exit()
            elif a[j][i] + a[i][k] == a[j][k] and j != i and i != k:
                flag[j][k] = flag[k][j] = False
for i in range(n):
    for j in range(n):
        if flag[i][j]:
            ans += a[i][j]
print(ans//2)


Measured memory_bytes: 43996
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	int N, M; cin >> N >> M;
	vector<ll> A(N); rep(i, N)cin >> A[i];

	ll sum = 0; rep(i, N)sum += A[i];
	ll c = sum / (4 * M);

	ll cnt = 0;
	rep(i, N) if (A[i]*4 * M >=sum )cnt++;
	
	if (cnt >= M)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc130
{
    class A
    {
        static void Main(string[] args)
        {
            var input = Input.IntArray();
            int X = input[0];
            int A = input[1];

            if (X < A) {
                Console.WriteLine(0);
            } else {
                Console.WriteLine(10);  
            }

            
        }

        /** Input Class */
        internal static class Input
        {
            /** input int */
            public static int Int() => int.Parse(Console.ReadLine());

            /** input str */
            public static string Str() => Console.ReadLine();

            /** input array of int */
            public static int[] IntArray() => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            /** input array of string */
            public static string[] StrArray() => Input.Str().Split(' ');

            /** input array of char */
            public static char[] charArray() => Input.Str().ToCharArray();
        }

    }
}

Measured memory_bytes: 13396
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	int ans = 0;
	for (int i = 2; i < 10; i++)
	{
		for (int j = 2; j < 10; j++)
		{
			if (i * 10 + j > m) continue;
			if (i * j <= n) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int A, B, X;
	cin >> A >> B >> X;

	if (A <= X && X <= A + B){
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  map<string,int> mp;
  
  int n;
  int m;
  cin >> n;
  
  int res = 0;
  while (n--) {
    string s;
    cin >> s;
    mp[s]++;
  }
  
  cin >> m;
  
  while (m--) {
    string s;
    cin >> s;
    mp[s]--;
  }
  
  for (const auto &p: mp) {
    res = max(res, p.second);
  }
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  if(n/100==7){
    cout<<"Yes"<<endl;
  }else if(n%100/10==7){
     cout<<"Yes"<<endl;
  }else if(n%10==7){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>

int main()
{
    int n;

    std::cin >> n;

    int b,f,r,v;
    int res[4][3][10] = {};
    for (int i = 0; i < n; i++)
    {
        std::cin >> b >> f >> r >> v;

        res[b-1][f-1][r-1] += v;
    }

    for (int b = 0; b < 4; b++)
    {
        for (int f = 0; f < 3; f++)
        {
            std::cout << " ";
            for (int r = 0; r < 10; r++)
            {
                std::cout << res[b][f][r];

                if (r < 9) std::cout << " ";
                else       std::cout << std::endl;
            }
        }

        if (b < 3) std::cout << "####################" << std::endl;
    }
}


Measured memory_bytes: 3088
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li a, b, c;

int main () {
    fastIO;
    cin >> a >> b >> c;
    cout << max(c-a+b, (li)0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mpr make_pair
#define mt make_tuple
 
using namespace std;
 
const ll N = 200010;
const ll mod = 1e9 + 7;
ll power(ll x, ll   y, ll p){ ll res = 1; x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;} return res; }
ll n,val;
ll a[N], h[N], dp[N], segtree[4*N];

ll query(ll st, ll end, ll l, ll r, ll ind){
    ll m = (l+r)/2;
    if(l == st && r == end) return segtree[ind];
    if(st > m)  return query(st, end, m+1, r, 2*ind+2);
    else if(end <= m)   return query(st, end, l, m, 2*ind+1);
    return max(query(st,m,l,m,2*ind+1), query(m+1, end, m+1, r, 2*ind+2));
}

void update(ll height, ll val, ll l, ll r, ll ind){
    ll m = (l+r)/2;
    if(l == r && r == height){
        segtree[ind] = val;
        return ;
    }
    segtree[ind] = max(segtree[ind], val);
    if(height > m)  update(height, val, m+1, r, 2*ind+2);
    else    update(height, val, l, m, 2*ind+1);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    memset(segtree, 0, sizeof(segtree));
    for(int i=1;i<=n;i++)    cin>>h[i];
    for(int i=1;i<=n;i++)    cin>>a[i];
    dp[0] = 0;
    for(int i=1;i<=n;i++){
        val = a[i] + query(0, h[i]-1, 0, n, 0);
        update(h[i], val, 0, n, 0);
        dp[i] = max(dp[i-1], val);
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int n, k;
  cin >> n >> k;
  int x;
  int ans = 0;
  for (int i = 0; i < n; i++){
    cin >> x;
    ans += min(abs(x - k) * 2, abs(x - 0) * 2);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
x = int(input())

if 400 <= x < 600:
  print(8)
elif 600 <= x < 800:
  print(7)
elif 800 <= x < 1000:
  print(6)
elif 1000 <= x < 1200:
  print(5)
elif 1200 <= x < 1400:
  print(4)
elif 1400 <= x < 1600:
  print(3)
elif 1600 <= x < 1800:
  print(2)
elif 1800 <= x < 2000:
  print(1)

Measured memory_bytes: 9184
#include<stdio.h>

int main()
{
    long long int a, b, c, d;

    while(2==scanf("%lld %lld", &a, &b)){
        if(b>a){
            c=a;
            a=b;
            b=c;
        }

        while(a%b!=0){
            d=a%b;
            a=b;
            b=d;
        }
        printf("%lld\n", b);
    }

    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define loop while (true)

#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(), (a).end()
#define all(a) (a).begin(), (a).end()

#define PII pair<int, int>
#define pii pair<int, int>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VI vector<int>
#define VVI vector<vector<int>>

using namespace std;

typedef long long ll;
typedef unsigned long long ULL;

#define MAX 100001
bool ans[MAX];
bool kind[MAX];

bool check(bool a, bool b, int N)
{
    kind[0] = a;
    kind[1] = b;
    FOR(i, 2, N)
    {
        if (kind[i - 1]) {
            kind[i] = (ans[i - 1]) ? kind[i - 2] : (not kind[i - 2]);
        } else {
            kind[i] = (ans[i - 1]) ? (not kind[i - 2]) : kind[i - 2];
        }
    }
    if (kind[N - 1]) {
        bool f = (ans[N - 1] ? (kind[0] == kind[N - 2]) : (kind[0] != kind[N - 2]));
        if (f) {
            if (a) {
                return (ans[0]) ? (kind[1] == kind[N - 1]) : (kind[1] != kind[N - 1]);
            } else {
                return (ans[0]) ? (kind[1] != kind[N - 1]) : (kind[1] == kind[N - 1]);
            }
        } else {
            return f;
        }
    } else {
        bool f = (ans[N - 1] ? (kind[0] != kind[N - 2]) : (kind[0] == kind[N - 2]));
        if (f) {
            if (a) {
                return (ans[0]) ? (kind[1] == kind[N - 1]) : (kind[1] != kind[N - 1]);
            } else {
                return (ans[0]) ? (kind[1] != kind[N - 1]) : (kind[1] == kind[N - 1]);
            }
        } else {
            return f;
        }
    }
}

signed main()
{
    int N;
    cin >> N;
    char c;
    rep(i, N)
    {
        cin >> c;
        kind[i] = false;
        ans[i] = (c == 'o') ? true : false;
    }
    const bool flag = check(true, true, N) or check(true, false, N) or check(false, true, N) or check(false, false, N);
    if (flag) {
        rep(i, N)
        {
            cout << ((kind[i]) ? 'S' : 'W');
        }
        cout << endl;
    } else {
        cout << -1 << endl;
    }


    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main{
	Scanner sc = new Scanner(System.in);
	
	private void doit(){
		while(true){
			int n = sc.nextInt();
			if(n ==0)break;
			int [] data = new int[n];
			for(int i =0 ; i < n; i++){
				data[i] = sc.nextInt();
			}
			StringBuilder ans = new StringBuilder();
			int num = 32;
			int ind = 0;
			for(int i = 0;;i++){
				if(i % 2 == 0){
					int now = (num - 1) % 5;
					num -= now;
				}
				else{
					num -= data[ind % n];
					ind++;
				}
				if(num < 0) num = 0;
				ans.append(num + "\n");
				if(num == 0) break;
			}
			System.out.print(ans.toString());
		}
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 20860
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
// using namespace __gnu_pbds;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define fr(x,in,n,r) for(ll x=in;x<n;x+=r)
#define ifr(x,n) for(ll x=0;x<n;x++)
#define dfr(x,n) for(ll x=n-1;x>=0;x--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pof(a) pop_front(a)
#define pob(a) pop_back(a)
#define eb(a) emplace_back(a)
#define ef(a) emplace_front(a)
typedef long long ll;
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007

ll power(ll x,ll y){
	ll res=1;
	while(y>0){
		if(y&1)
			res=res*x;
		y=y>>1;
		x=x*x;
	}
	return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    ll x,y,r,p;
	cin>>x>>y;
	ld ans=0;
	fr(i,1,x+1,1){
		r=ceil((1.0*log((y*1.0)/i))/log(2));
		p=power(2,r);
		p*=x;
		// cout<<i<<" "<<p<<endl;
		ans+=(1.0/p);
	}
	cout<<setprecision(12)<<fixed;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  ll n;
  cin >> n;
  string ans="";
  while(n>0){
    --n;
    ans+=char('a'+n%26);
    n/=26;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    ll n;
    cin >> n;
    set<string> s;
    rep(i, n) {
        string t;
        cin >> t;
        s.insert(t);
    }

    print(s.size());
    return 0;
}


Measured memory_bytes: 19176
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, A[16], x[16][16], y[16][16], i, j, ans=0, sum, judge, tr[16];

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> A[i];

        for(j=1; j<=A[i]; j++){
            cin >> x[i][j] >> y[i][j];
        }
    }

    // {1, 2, ..., N} の部分集合の全探索(SとTに分ける)
    for (ll bit = 0; bit < (1<<N); bit++) {
        vector<ll> S, T;
        sum = 0;
        for (ll i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                // Sの末尾にiを追加する
                S.push_back(i+1); // 正直者
                tr[i+1]=1;
                sum++;
            }
            else{
                T.push_back(i+1); // 不親切
                tr[i+1]=0;
            }
        }

        judge = 1;

        for(i=1; i<=N; i++){ // 人i(正直者)の証言を確認
            for(j=1; j<=A[i]; j++){
                if(y[i][j]==1 && tr[i]==1){
                    if(tr[x[i][j]]==0){
                        judge = 0;
                    } 
                }
                else if(y[i][j]==0 && tr[i]==1){
                    if(tr[x[i][j]]==1){
                        judge = 0;
                    }
                }
            }
        }

        if(judge == 1){
            chmax(ans, sum);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int n, x;
	cin >> n >> x;
	while (n != 0 || x != 0) {
		int i, j, k;
		int ans = 0;
		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				for (k = j + 1; k <= n; k++) {
					if (i + j + k == x) ans++;
				}
			}
		}

		cout << ans << endl;

		cin >> n >> x;
	}


	return 0;
}



Measured memory_bytes: 3088
import java.util.*;
public class Main {
  public static void main(String... args) {
    Scanner input = new Scanner(System.in);
    
    int x = input.nextInt();
    int n = input.nextInt();
    
    Set<Integer> set = new HashSet<>();
    int[] a = new int[n];
    boolean notFound = true;
    for (int i = 0; i < n; i++) {
      set.add(input.nextInt());
    }

    int lower = x;
    int higher = x;
    
    while (set.contains(lower)) {
      lower--;
    }
    
    while (set.contains(higher)) {
      higher++;
    }
    
    System.out.println(x - lower <= higher - x ? lower : higher);
  }
}

Measured memory_bytes: 35940
#include <iostream>

using namespace std;

int main(){
    int W,H,x,y;
    cin >> W >> H >> x >> y;
    /* long long  ans = W * H / 2.0;
    int judge;
    if(x + x == W && y + y == H) {
        judge = 1;
    }
    else judge = 0;
    cout << ans << ' ' << judge << endl;*/
    printf("%lf %d\n", double(W)*double(H) / 2, x + x == W&&y + y == H);
}

Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc166/tasks/abc166_b
// implementation
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    int n, k;
    readf("%s %s\n", &n, &k);

    int[] snukes = new int[n+1];

    foreach(_; 0..k) {
        int t = readln.chomp.to!int;
        int[] a = readln.split.map!(to!int).array;

        foreach(item; a) {
            snukes[item] = 1;
        }
    }

    long answer = count!("a == 0")(snukes);
    answer -= 1;
    answer.writeln;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	vector<int> g[N];
	int a;
	rep(i,1,N){
		cin>>a; a--;
		g[a].push_back(i);
	}
	rep(i,0,N){
        cout<<g[i].size()<<endl;
    }
}

Measured memory_bytes: 14428
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
int scmpr(const void* a,const void* b){return strcmp(*(char**)b,*(char**)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}

int main(){
  LL i,ans=0;
  char S[105];
  scanf("%s",S);
  ans=strlen(S);
  FOR(i,0,ans)printf("x");

  //printf("%lld\n",A,B);
	return 0;
}


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

int main(){
	// input
	int N, M;
	cin >> N >> M;

	vector<vector<int>> S(M, vector<int>(N, 0));
	vector<int> P(M, 0);

	for (int m = 0; m < M; m++)
	{
		int K;
		cin >> K;
		for (int k = 0; k < K; k++)
		{
			int s;
			cin >> s;
			s--;
			S[m][s] = 1;
		}
	}

	for (int m = 0; m < M; m++)
	{
		cin >> P[m];
	}
	
	// solve
	int ans = 0;
	for (int i = 0; i < (1 << N); i++)
	{
		bool isok = true;
		for (int m = 0; m < M; m++)
		{
			int state = 0;
			for (int b = 0; b < N; b++)
			{
				if ( S[m][b] == 1 )
				{
					if ( (i & (1 << b)) != 0 )
					{
						state++;
					}
				}
			}
			state %= 2;
			if ( state != P[m] )
			{
				isok = false;
				break;
			}
		}
		if( isok ) ans++;
	}

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


Measured memory_bytes: 256