akhauriyash/Code-Regression huggingface dataset:
<?php
fscanf(STDIN, "%d %d", $n, $p);
$a = explode(' ', trim(fgets(STDIN)));
$q = [0=>0, 1=>0];
foreach ($a as $b) $q[$b % 2]++;
$x = $y = 0;
if ($p) {
	for ($i = 1; $i <= $q[1]; $i += 2) {
		$x += ncr($q[1], $i);
	}
} else {
	for ($i = 0; $i <= $q[1]; $i += 2) {
		$x += ncr($q[1], $i);
	}
}
for ($i = 0; $i <= $q[0]; $i++) {
	$y += ncr($q[0], $i);
}
echo $x * $y;

function ncr($n, $r) {
	if ($r == 0) {
		return 1;
	}
	return ncr($n, $r - 1) * ($n - $r + 1) / $r;
}

Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
  read(x), read(y...);
}
const int N=1e3+10;
int H,W;
bool vis[N][N];
char s[N][N];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(H,W);
  queue<pair<int,int> > Q1,Q2;
  for(int i=1;i<=H;++i) {
    scanf("%s",s[i]+1);
    for(int j=1;j<=W;++j) {
      if(s[i][j]=='#') {
        vis[i][j]=true;
        Q1.push(mp(i,j));
      }
    }
  }
  int res=0;
  while(!Q1.empty()) {
    while(!Q1.empty()) {
      pair<int,int> A=Q1.front(); Q1.pop();
      int x=A.Fst,y=A.Snd;
      for(int i=0;i<4;++i) {
        int tx=x+dx[i],ty=y+dy[i];
        if(tx<1||ty<1||tx>H||ty>W||vis[tx][ty]) continue;
        vis[tx][ty]=true;
        Q2.push(mp(tx,ty));
      }
    }
    if(!Q2.empty()) ++res;
    while(!Q2.empty()) Q1.push(Q2.front()),Q2.pop();
  }
  printf("%d\n",res);
  return 0;
}


Measured memory_bytes: 10384
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    
    static int n;
    static Map<Integer, Map<Integer, Integer>> graph;
    static int[] d;
    static final int INF = Integer.MAX_VALUE / 10;
    static final int WHITE = 0;
    static final int GRAY = 1;
    static final int BLACK = 2;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        n = Integer.parseInt(sc.next());
        graph = new HashMap<>();
        for(int i = 0; i < n; i++){
            int u = Integer.parseInt(sc.next());
            graph.put(u, new HashMap<>());
            int k = Integer.parseInt(sc.next());
            for(int j = 0; j < k; j++){
                int v = Integer.parseInt(sc.next());
                int c = Integer.parseInt(sc.next());
                graph.get(u).put(v, c);
            }
        }
        
        dijkstra(0);
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(i).append(" ").append(d[i]).append(System.lineSeparator());
        }
        System.out.print(sb);
    }
    
    static void dijkstra(int s){
        
        int[] color = new int[n];
        d = new int[n];
        Arrays.fill(d, INF);
        d[s] = 0;
        
        PriorityQueue<Node> pq = new PriorityQueue<>();
        pq.add(new Node(s, 0));
        
        while(!pq.isEmpty()){
            Node u = pq.poll();
            
            color[u.id] = BLACK;
            
            if(d[u.id] < u.dist) continue;
            
            for (Integer v : graph.get(u.id).keySet()) {
                if(color[v] != BLACK){
                    if(d[u.id] + graph.get(u.id).get(v) < d[v]){
                        d[v] = d[u.id] + graph.get(u.id).get(v);
                        color[v] = GRAY;
                        pq.add(new Node(v, d[v]));
                    }
                }
            }
        }
    }
    
    static class Node implements Comparable<Node>{
        int id;
        int dist;

        public Node(int id, int dist) {
            this.id = id;
            this.dist = dist;
        }

        @Override
        public int compareTo(Node n) {
            return this.dist - n.dist;
        }
    }
}


Measured memory_bytes: 205536
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int[] count = new int [8];
		Arrays.fill(count, 0);
		int free = 0;
		int a ;
		for (int i = 0 ;i < n; ++i){
			a = Integer.parseInt(scan.next());
			if (a<=399)++count[0];
			else if (a<=799)++count[1];
			else if (a<=1199)++count[2];
			else if (a<=1599)++count[3];
			else if (a<=1999)++count[4];
			else if (a<=2399)++count[5];
			else if (a<=2799)++count[6];
			else if (a<=3199)++count[7];
			else free++;
		}

		int min=0;
		for(int i:count){
			if (i>0)++min;
		}
		if (min != 0){
			System.out.print(min+" "+(min+free));
		}else{
			System.out.print(1+" "+free);
		}





	}
}
//end


Measured memory_bytes: 21076
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 1100

int dxy[] = {1,-1,0,0};

int used[MAX][MAX];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int H, W;
	static string A[MAX];
	queue<pair<int,pair<int,int>>> Q;
	cin>>H>>W;
	int ans = 0;
	
	for(int i = 0; i < H; i++){
		cin>>A[i];
		for(int j = 0; j < W; j++){
			if(A[i][j] == '#')Q.push(make_pair(0,make_pair(i,j)));
			// used[i][j] = true;
		}
		
	}
	
	while(!Q.empty()){
		pair<int,pair<int,int>> p = Q.front();Q.pop();
		
		int y = p.second.first, x = p.second.second;
		
		if(used[y][x]) continue;
		
		used[y][x] = true;
		
		ans = max(ans, p.first);
		
		for(int i = 0; i < 4; i++){
			int ny = y + dxy[i], nx = x + dxy[3-i];
			
			if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
			
			// cout<<p.first+1<<endl;
			Q.push(make_pair(p.first+1,make_pair(ny,nx)));
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 107064
n = int(input())
ai = list(map(int,input().split()))
dic = {}
su = 0
for a in ai:
    dic[a] = 0
for a in ai:
    dic[a] += 1
for i , x in enumerate(dic):
    su += dic[x]*(dic[x]-1)/2
for a in ai:
    print(int(su-dic[a]+1))

Measured memory_bytes: 24748
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    string S;
    cin >> S;
    string out = "Good";
    rep(i,3){
        if(S[i]==S[i+1]) out = "Bad";
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


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

	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	deque<int> q;
	for(int i = 0; i < n; i++) {
		int p = lower_bound(q.begin(), q.end(), a[i]) - q.begin();
		if(p == 0) {
			q.push_front(a[i]);
		} else {
			q[p-1] = a[i];
		}
	}
	int ans = q.size();
	cout << ans << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define pb push_back
using namespace std;
const int N= 1e6 + 10;

int main(){ 
  fast;
  int n;
  cin >> n;
  if(n == 0)
    return cout << 2, 0;
  if(n == 1)
    return cout << 1, 0;
  ll cur = 1;
  ll prev = 2;
  ll temp;
  for(int i = 2; i <= n; i++){
    temp = cur;
    cur = cur + prev;
    prev= temp;
  }
  cout << cur;




  
  return 0;
}
    


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

ll dp[3010][3010][4];  // dp[i][j][k] : (i,j)にいてi行目でk個のアイテムを拾ったときの価値の合計の最大値
ll board[3010][3010];  // board[i][j] : (i,j)のアイテムの価値

int main() {
    ll h, w, n;
    cin >> h >> w >> n;

    rep(i, n) {
        ll x, y, v;
        cin >> x >> y >> v;
        board[x][y] = v;
    }

    if(board[1][1] > 0) {
        dp[1][1][1] = board[1][1];
    }
    exrep(i, 1, h) {
        exrep(j, 1, w) {
            exrep(k, 0, 3) {
                chmax(dp[i][j+1][k], dp[i][j][k]);
                chmax(dp[i+1][j][0], dp[i][j][k]);
                if(k < 3 && board[i][j+1] > 0) {
                    chmax(dp[i][j+1][k+1], dp[i][j][k] + board[i][j+1]);
                }
                if(board[i+1][j] > 0) {
                    chmax(dp[i+1][j][1], dp[i][j][k] + board[i+1][j]);
                }
            }
        }
    }
    
    ll ans = 0;
    exrep(k, 0, 3) {
        chmax(ans, dp[h][w][k]);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 356336
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}


int main(){
  ll a,b; cin >> a >> b;
  cout << max(a+b,max(2*a-1,2*b-1)) << endl;
}

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

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn is_dream(s: &str) -> bool {
    s.len() >= 5 && &s[..5] == "maerd"
}

fn is_dreamer(s: &str) -> bool {
    s.len() >= 7 && &s[..7] == "remaerd"
}

fn is_erase(s: &str) -> bool {
    s.len() >= 5 && &s[..5] == "esare"
}

fn is_eraser(s: &str) -> bool {
    s.len() >= 6 && &s[..6] == "resare"
}

fn is_good(s: &str) -> bool {
    let mut s: String = s.chars().rev().collect();

    while s.len() > 0 {
        if is_dream(&s) || is_erase(&s) {
            s = s[5..].to_string();
        } else if is_eraser(&s) {
            s = s[6..].to_string();
        } else if is_dreamer(&s) {
            s = s[7..].to_string();
        } else {
            return false;
        }
    }

    return true;
}

pub fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let s: String = read(&mut stdin).unwrap();

    if is_good(&s) {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4476
#include <iostream>
#include <iomanip>
#include <cmath>

struct point {
    double x, y;
};

point point1 = {0.0f, 0.0f}, point2 = {100.0f, 0.0f};
const long double pi = 3.141592653589793f;

void KochCurve(int depth, point point1, point point2) {
    if (depth==0) return;

    point A, B, C, dif;
    dif.x = point2.x - point1.x;
    dif.y = point2.y - point1.y;
    
    /*
                  A
                 /\
    point1 _____/  \_____point2
               B   C
    */
    
    /*
    When (x, y) -> (x', y'),
    x' = x*cos - y*sin
    y' = x*sin + y*cos
    */

    A.x = (dif.x*std::cos(pi/3) - dif.y*std::sin(pi/3))/3 + dif.x/3 + point1.x;
    A.y = (dif.x*std::sin(pi/3) + dif.y*std::cos(pi/3))/3 + dif.y/3 + point1.y;
    
    B.x = dif.x/3 + point1.x;
    B.y = dif.y/3 + point1.y;

    C.x = dif.x*2/3 + point1.x;
    C.y = dif.y*2/3 + point1.y;

    KochCurve(depth-1, point1, B);
    std::cout << std::fixed << std::setprecision(8) << B.x << " " << B.y << std::endl;
    KochCurve(depth-1, B, A);
    std::cout << std::fixed << std::setprecision(8) << A.x << " " << A.y << std::endl;
    KochCurve(depth-1, A, C);
    std::cout << std::fixed << std::setprecision(8) << C.x << " " << C.y << std::endl;
    KochCurve(depth-1, C, point2);
}

int main() {
    int depth;
    std::cin >> depth;

    std::cout << point1.x << " " << point1.y << std::endl;
    KochCurve(depth, point1, point2);
    std::cout << point2.x << " " << point2.y << std::endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;
    Vec a(n+2);
    a[0]=0;
    rep(i,n)cin>>a[i+1];
    a[n+1]=0;
    ll ans=0;
    Vec x(n+2);
    REP(i,1,n+2){
        ans += abs(a[i]-a[i-1]);
    }
    REP(i,1,n+1){
        ll out = ans + abs(a[i-1]-a[i+1]) - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]);
        cout<<out<<endl;

    }

    return  0;
}


Measured memory_bytes: 2816
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)
	
int main (){
	int x1,y1,x2,y2,x3,y3,x4,y4;
	cin  >> x1 >> y1 >> x2 >> y2;
	int vectorx,vectory;
	vectorx = x1 - x2;
	vectory = y1 - y2;
	x3  = x2 + vectory;
	y3  = y2 - vectorx;
	x4  = x3 + vectorx;
	y4  = y3 + vectory;

	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	return 0;
	
}


Measured memory_bytes: 256
import sys
from collections import deque, Counter
sys.setrecursionlimit(1000000)
N, K, L = map(int, input().split())
pq = [list(map(int, input().split())) for _ in range(K)]
rs = [list(map(int, input().split())) for _ in range(L)]

G_r = [[] for _ in range(N+1)]
for elem in pq:
    G_r[elem[0]].append(elem[1])
    G_r[elem[1]].append(elem[0])
G_t = [[] for _ in range(N+1)]
for elem in rs:
    G_t[elem[0]].append(elem[1])
    G_t[elem[1]].append(elem[0])


field_r = [None]*(N+1)


def dfs_r(i, idx):
    q = deque()
    q.append(i)
    field_r[i] = idx
    while q:
        tmp = q.pop()
        for pos in G_r[tmp]:
            if field_r[pos] is None:
                field_r[pos] = idx
                q.append(pos)
            else:
                continue
idx = 0
for i in range(1, N+1):
    if field_r[i] is None:
        dfs_r(i, idx)
        idx += 1


field_t = [None]*(N+1)


def dfs_t(i, idx):
    q = deque()
    q.append(i)
    field_t[i] = idx
    while q:
        tmp = q.pop()
        for pos in G_t[tmp]:
            if field_t[pos] is None:
                field_t[pos] = idx
                q.append(pos)
            else:
                continue
idx = 0
for i in range(1, N+1):
    if field_t[i] is None:
        dfs_t(i, idx)
        idx += 1

m = list(zip(field_r[1:], field_t[1:]))
cnt = Counter(m)
ans = []
for elem in list(m):
    ans.append(cnt[elem])
print(' '.join(map(str, ans)))


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

int main()
{
	int n;
	cin >> n;
	int p, m = 10e6;
	int ans = 0;
	while (n)
	{
		cin >> p;
		if (p <= m)
		{
			ans++;
			m = p;
		}
		n--;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
const int MaxN = 100;

struct xx
{
	int x;
	int y;
	int w;
}a[MaxN + 5];

struct xx b[MaxN + 5];

bool cmp(xx a,xx b)
{
	return a.w < b.w;
}

int vis[MaxN + 5];

int main()
{
	int n,m,ans,sum,biu,piu,piu1;
	while(~scanf("%d",&n))
	{
		ans = 0;
		for(int i = 1;i <= n;i++) 
		{
			scanf("%d %d",&a[i].x,&a[i].y);
			vis[i] = 0;
			a[i].w = 0;
			b[i].w = 0;
		}
		for(int i = 1;i <= n;i++) scanf("%d %d",&b[i].x,&b[i].y);
		for(int i = 1;i <= n;i++)
		{
			for(int j = 1;j <= n;j++)
			{
				if(a[i].x < b[j].x&&a[i].y < b[j].y) 
				{
					a[i].w++;
					b[j].w++;
				}
			}
		}
		sort(a+1,a+1+n,cmp);
		sort(b+1,b+1+n,cmp);
		for(int i = 1;i <= n;i++)
		{
			for(int j = 1;j <= n;j++)
			{
				if(a[i].x < b[j].x&&a[i].y <b[j].y&&vis[j]==0)
				{
					vis[j]=1;
					ans++;
					break;
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

using namespace std;
typedef pair<int, int> pii;
typedef pair<pii, string> piis;

int main(){
	while(true){
		int n, m;
		cin >> n >> m;
		if(n == 0 && m == 0){ break; }
		vector<piis> v(n);
		for(int i = 0; i < n; ++i){
			cin >> v[i].second >> v[i].first.second >> v[i].first.first;
		}
		sort(v.begin(), v.end());
		while(m--){
			int y;
			cin >> y;
			vector<piis>::iterator it =
				lower_bound(v.begin(), v.end(), piis(pii(y, 0), ""));
			if(it == v.end()){
				cout << "Unknown" << endl;
			}else{
				int jy = it->first.second - (it->first.first - y);
				if(jy <= 0){
					cout << "Unknown" << endl;
				}else{
					cout << it->second << " " << jy << endl;
				}
			}
		}
	}
	return 0;
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


int main() {
    ll n, k;
    cin >> n >> k;

    ll sum = 0;
    rep(i, k, n + 2) {
        sum = (sum + (i * (n + 1 - i) + 1)) % 1000000007;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <functional>
using namespace std;

int N, p[10009], sum;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) { cin >> p[i]; sum += p[i]; }
	sort(p, p + N);
	int s = p[N - 1] / 2;
	cout << sum - s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
using namespace std;
int h[3][300005] = {0};
int main()
{
	int n;
	char c;
	cin >>  n;
	for (int i = 1; i <= n; i++) {
		cin >> c;
		if (c == 'E') {
			h[1][i] = h[1][i - 1] + 1;
			h[2][i] = h[2][i - 1];
		}
		else {
			h[2][i] = h[2][i - 1] + 1;
			h[1][i] = h[1][i - 1];
		}

	}
//	h[1][n + 1] = h[1][n];
	for (int i = 1; i <= n; i++) {
		h[0][i] = h[2][i - 1] + h[1][n] - h[1][i];
	//	cout << h[1][i] <<h[2][i]<< h[0][i] << endl;
	}
	int ans = 100000000;
	for (int i = 1; i <= n; i++) {
		if (h[0][i] < ans)ans = h[0][i];
	}
	cout << ans << endl;

}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define MAX_SIZE 10000

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

const ll MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1.0);
const db ERR = 1e-8;
const int MAXN = 1e7;

int main(int argc, char const *argv[]){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
    return 0;
}


Measured memory_bytes: 256
/******************************************************************************

            EYENINE,THE ELDER_WAND!!!
            THE ROOT OVER MINUS EIGHTY ONE!!

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

#include<bits/stdc++.h>
#define vi vector<int>
#define ALL_UP_WITH return 0
using namespace std;
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vi p(n),q(n);
    for(int&i:p){
        cin>>i;
    }
    for(int&i:q){
        cin>>i;
    }
    vi x(n);
    for(int i=0;i<n;i++){
        x[i]=i+1;
    }
    int a=0,b=0,i=0;
    do{

        if(p==x)
            a=i;
        if(q==x)
        b=i;
        i++;
    }
    while(next_permutation((x).begin(),(x).end()));
    cout<<abs(a-b)<<endl;

    ALL_UP_WITH;
}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    dp = [[0] * 3 for _ in range(n)]
    for i in range(n):
        a, b, c = list(map(int, readline().split()))
        if i == 0:
            dp[i][0] = a
            dp[i][1] = b
            dp[i][2] = c
        else:
            dp[i][0] = max(dp[i-1][1] + a, dp[i-1][2] + a)
            dp[i][1] = max(dp[i-1][0] + b, dp[i-1][2] + b)
            dp[i][2] = max(dp[i-1][0] + c, dp[i-1][1] + c)
    print(max(dp[-1]))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 53996
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
ll T;
ll t[200000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>T;
    for(int i=0;i<n;i++) cin>>t[i];
    ll ans=0;
    ll outtime=T;
    if(n==1){
        cout<<T<<"\n";
        return 0;
    }

    for(int i=1;i<n;i++){
        if(outtime>=t[i]){
            ans+=t[i]-t[i-1];
            outtime=t[i]+T;
        }
        else{
            ans+=T;
            outtime=t[i]+T;
        }
        if(i==n-1){
            ans+=T;
        }
    }
    cout <<ans<< "\n";
}

Measured memory_bytes: 1792
import sys
n = int(input())
a = list(map(int, input().split()))


cnt = [0] * n
for x in a:
  cnt[x] += 1

ok = True
for i in range(0, n):
  if n % 2 == 1 and i % 2 == 0:
    if i == 0 and cnt[i] != 1 or i > 0 and cnt[i] != 2:
      ok = False
  elif n % 2 == 0 and i % 2 == 1:
    if cnt[i] != 2:
      ok = False

if not ok:
  print(0)
else:
  res = 1
  for i in range(0, n // 2):
    res *= 2
    res %= 1000000007
  print(res)


Measured memory_bytes: 14008
from collections import defaultdict
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
a = 1
for i in range(2,n+1):
  a = (a*i)%(10**9+7)
print(a)

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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
//#define int long long

using namespace std;
const int INF = 2e15;
const int MB = 20;
const int MOD = 1e9 + 7;


void solve() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2] && s[0] == 'R') cout << 3;
	else if ((s[0] == s[1] && s[0] == 'R') || (s[1] == s[2] && s[1] == 'R')) cout << 2;
	else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cout << 1;
	else cout << 0;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	//srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 3668
#include <iostream>
#include <stdio.h>

typedef long long ll;

using namespace std;

int main() {
  ll N, M;
  cin >> N >> M;
  ll res = 0;
  if (2 * N <= M) {
    res = N + (ll)(M - 2 * N) / 4;
  } else {
    res = M / 2;
  }
  printf("%lld\n", res);
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    ll n, k;
    cin >> n >> k;
    unordered_set<ll> visited;
    visited.emplace(n);
    ll m = 1e18;
    while(true){
        if (n >= k * 2) {
            n -= n / k * k;
        }
        n = abs(n - k);
        m = min(m, n);
        if (visited.count(n) >= 1) {
            put(m);
            return 0;
        }
        visited.emplace(n);
    }



    return 0;
}

Measured memory_bytes: 3636
package main

import (
    "fmt"
)

func main() {
    var N int
    fmt.Scan(&N)
    cnt := map[int]int{}
    for i := 0; i < N; i++ {
        var S int
        fmt.Scan(&S)
        cnt[S] += 1
    }
    ans := 0
    for _, v := range cnt {
        if v % 2 == 1 {
            ans++
        }
    }
    fmt.Println(ans)
}

Measured memory_bytes: 8064
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque

INF = 1 << 50



def run():
    X = int(input())
    if X >= 30:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    run()

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

using namespace std;

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

int main(){
    int n;
    cin >> n;
    vector<vector<int> > card(4, vector<int>(13, 1));
    rep(i,n){
        char pic;
        int num;
        cin >> pic >> num;
        if(pic == 'S')card[0][num-1]--;
        else if(pic == 'H')card[1][num-1]--;
        else if(pic == 'C')card[2][num-1]--;
        else if(pic == 'D')card[3][num-1]--;
    }

    rep(i,4)rep(j,13)if(card[i][j]){
        if(i == 0)printf("S ");
        else if(i == 1)printf("H ");
        else if(i == 2)printf("C ");
        else if(i == 3)printf("D ");
        cout << j+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3292
def bubble_sort(lis, l):
    flag = 1
    while flag:
        flag = 0
        for i in range(l - 1, 0, -1):
            if int(lis[i][1:]) < int(lis[i - 1][1:]):
                ele = lis[i]
                lis[i] = lis[i - 1]
                lis[i - 1] = ele
                flag = 1
    return 'Stable'


def selection_sort(lis, l):
    for i in range(0, l - 1):
        minj = i
        for j in range(i, l):
            if int(lis[j][1:]) < int(lis[minj][1:]):
                minj = j
        ele = lis[i]
        lis[i] = lis[minj]
        lis[minj] = ele

inputs = []
while True:
    try:
        inputs.append(input())
    except(EOFError):
        break

ln = int(inputs[0])
li_1 = list(inputs[1].split())
li_2 = li_1.copy()

stab_1 = bubble_sort(li_1, ln)
stab_2 = selection_sort(li_2, ln)

sortComp = 'Stable' if (li_1 == li_2) else 'Not stable'

print(*li_1)
print(stab_1)
print(*li_2)
print(sortComp)



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  // 標準入力高速化のおまじない
  // scanfとの同期を切る。以降紛らわしいのでscanf使用不可。
  ios::sync_with_stdio(false);
  // // cin前の自動flashをやめる
  cin.tie(nullptr);

  int N;
  cin >> N;
  int count_AC = 0;
  int count_WA = 0;
  int count_TLE = 0;
  int count_RE = 0;
  for(int i=0; i<N; i++){
    string x;
    cin >> x;
    if(x == "AC") count_AC++;
    else if(x == "WA") count_WA++;
    else if(x == "TLE") count_TLE++;
    else if(x == "RE") count_RE++;
  }
  cout << "AC x " << count_AC << endl;
  cout << "WA x " << count_WA << endl;
  cout << "TLE x " << count_TLE << endl;
  cout << "RE x " << count_RE << endl;

  return 0;
}

Measured memory_bytes: 3572
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

int main()
{
  int L, R, d;
  cin >> L >> R >> d;

  int result = 0;

  for (int i = L; i <= R; i++) {
    if (i % d == 0) {
      result++;
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int max_n = 500010;
const ll mod = 1e9 + 7;
vector<ll> fac(max_n);
vector<ll> ifac(max_n);

int N;
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n){
        if(n % 2){
            ans = ans * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return ans;
}

ll comb(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < 0 || b < 0) return 0;
    ll tmp = ifac[b] * ifac[a-b] % mod;
    return tmp * fac[a] % mod;
}



int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    fac[0] = 1;
    ifac[0] = 1;
    REP(i,N){
        fac[i+1] = fac[i] * (i+1) % mod; // fac[i] = n! % mod;
        ifac[i+1] = ifac[i] * mpow(i+1,mod-2) % mod; // ifac[i] = (i!) * pow(i, mod-2) % mod;
    }

    ll N;
    cin>>N;
    ll ans = (3*mod - (2 * mpow(9,N)) % mod +  mpow(8,N) + mpow(10,N) ) % mod;
    cout << ans << endl;

}

Measured memory_bytes: 11032
#include<bits/stdc++.h>
using namespace std;
int main(void) {
 
  long long x, nowMoney = 100, tempMoney = 100;
  long long ans = 0;
  
  cin >> x;
  while (nowMoney < x) {
    tempMoney = nowMoney / 100;
	nowMoney += tempMoney;
	tempMoney = nowMoney;
	ans++;
  }
  cout << ans << endl;
 
  return 0;
}

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

int main()
{
	int n, w;
	cin >> n >> w;
	vector<pair<int, int> > items;
	for(int i=0;i<n;i++)
	{
		pair<int, int> item;
		cin >> item.first >> item.second;
		items.push_back(item);
	}
	sort(items.begin(), items.end());
	vector<long long int> dp(w+1, 0);
	vector<long long int> new_dp(w+1, 0);
	for(int i=1;i<=n;i++)
	{
		int currWt = items[i-1].first;
		int currVal = items[i-1].second;
		for(int j=0;j<=w;j++)
		{	
			if(currWt <= j)
			{
				new_dp[j] = max((long long int)(currVal) + dp[j-currWt], dp[j]);
			}
			else
			{
				new_dp[j] = dp[j];
			}
		}
		dp = new_dp;
	}
	cout << dp[w] << endl;
	return 0;
}


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

using namespace std;
double f(pair<double , double> x , pair<double , double> y)
{
    double x1 = x.first , y1 = x.second , x2 = y.first , y2 = y.second;
    return sqrt(pow(x2 - x1 , 2) + pow(y2 - y1 , 2));
}
int main()
{
    int n;
    cin >> n;
    vector<pair<double , double> > v(n);
    for(int i = 0; i < n; i ++)
    {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin() , v.end());
    double ans = 0;
    do{
        for(int i = 1; i < v.size(); i ++)
        {
            ans += f(v[i] , v[i - 1]);
        }
    }while(next_permutation(v.begin() , v.end()));
    double r = 1;
    while(n > 1)
    {
        r*=n;
        n --;
    }
    cout <<fixed << setprecision(8)<< ans / r;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define M 36

typedef struct {
  char mark;
  int value;
} Card;

void BubbleSort(Card *, int);
void SelectionSort(Card *, int);
void disply(Card *, int);
int isStable(Card *, Card *, int);

int main()
{
  Card c1[M+1], c2[M+1];
  int i, N;

  scanf("%d", &N);

//文字列と数字でそれぞれ格納
  for( i = 0 ; i < N ; i++ ){
    scanf(" %c%d", &c1[i].mark, &c1[i].value);
  }

//BubbleSortとSelectionSortで比較するためにもう一つの配列に格納する
  for( i = 0 ; i < N ; i++ ) c2[i] = c1[i];

  BubbleSort(c1, N);
  disply(c1, N);
  //BubbleSortは常に安定なソートとなるため比較不要
  printf("Stable\n");

  SelectionSort(c2, N);
  disply(c2, N);

//c1に安定ソートされた文字列数字が格納されているためそれと比較し、同じでなければNot Stable
  if( isStable(c1, c2, N) == 0 ) printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}
void BubbleSort(Card c1[], int N)
{
  int i, j;
  Card t;

  for( i = 0 ; i < N ; i++ ){
    for( j = N-1 ; j > i ; j-- ){
      if( c1[j].value < c1[j-1].value ){
        t = c1[j];
        c1[j] = c1[j-1];
        c1[j-1] = t;
      }
    }
  }
}

void SelectionSort(Card c2[], int N)
{
  int i, j, minj;
  Card t;

  for( i = 0 ; i < N ; i++ ){
    minj = i;
    for( j = i ; j < N ; j++ ){
      if( c2[j].value < c2[minj].value ) minj = j;
    }
    t = c2[i];
    c2[i] = c2[minj];
    c2[minj] = t;
  }
}

void disply(Card c[], int N)
{
  int i;

  for( i = 0 ; i < N ; i++ ){
    if( i > 0 ) printf(" ");
    printf("%c%d", c[i].mark, c[i].value);
  }
  printf("\n");
}

int isStable(Card c1[], Card c2[], int N)
{
  int i;

  for( i = 0 ; i < N ; i++ )
  if( c1[i].mark != c2[i].mark ) return 1;

  return 0;
}



Measured memory_bytes: 2048
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++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 INF10 1001001001 
#define INF5 100000
#define EPS 1e-10



int main() {
	int N; cin >> N;
	int D, X; cin >> D >> X;
	int cnt = X;
	REP(i, N) {
		int ipt; cin >> ipt;
		int day = 1;
		do {
			cnt++;
			day += ipt;

		} while (D >= day);
	}
	print(cnt);


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	sort(all(v));
	double ans = v.front();
	rep2(i, 1, n) {
		ans = (ans + v[i]) / 2;
	}
	printf("%05f\n", ans);
}


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

int main(){
	int N, M;
	cin >> N >> M;
	int a[N], b[N], c[M], d[M], i, j;
	for(i=1; i<=N; i++){
		cin >> a[i] >> b[i];
	}
	for(j=1; j<=M; j++){
		cin >> c[j] >> d[j];
	}
	
	int dis[N][M], min[N], num[N];
	for(i=1; i<=N; i++){
//		cout << endl << "i=" << i << endl;
		min[i] = 1000000000;
		num[i] = 0;
//		cout << "min=" << min[i] << endl;
		for(j=1; j<=M; j++){
			dis[i][j] = abs(a[i]-c[j]) + abs(b[i]-d[j]);
//			cout << dis[i][j] << " " << min[i] <<  endl;
			if(dis[i][j]<min[i]){
				min[i]=dis[i][j];
				num[i]=j;
//				cout << "min=" << min[i] << endl;
			}
		}
	}
	
	cout << endl;
	for(i=1; i<=N; i++){
		cout << num[i] << endl;
	}
	return 0;
}


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

int main()
{
  long a;
  float b;
  cin >> a >> b;
  if (a == 0) {
    cout << 0 << endl;
    return 0;
  }

  long b1 = (long)floor(b*1000) / 10;
  long ans = a*b1;
  ans = ans / 100;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

// find_by_order(k) returns the iterator to the kth largest element (start from 0)
// order_of_key(k) returns the number of elements in the set which are strictly less than the value k

using namespace std;
using namespace __gnu_pbds;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout << fixed; cout << setprecision(x); cout << y;
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

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

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
int32_t main()
{
	g_b();
	string s; cin >> s;
	int sum = 0;
	for (char c :  s)
	{
		c = c - '0';
		sum += c;
	}
	if (sum % 9)cout << "No";
	else cout << "Yes";
	return 0;
}

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

int main() {
  int N;
  long long Y;
  int check = 0;
  cin >> N >> Y;
  for (int i = 0; i <= N; i++){
    for (int j = 0; j <= (N - i); j++){
        int k = N - i - j;
        if (i * 10000 + j * 5000 + k * 1000 == Y){
          cout << i << " " << j << " " << k << endl;
          check++;
          break;
        }
      }
    if (check != 0){
      break;
    }
  }
  
  if (check == 0){
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

#define ROUNDUP(num) (((num + 10 - 1) / 10) * 10)

int main(int argc, char* argv[])
{
  int diff = 0;
  int total = 0;

  for(int i = 0; i < 5; i++) {
    int cook; cin >> cook;
    total += ROUNDUP(cook);
    diff = max(diff, ROUNDUP(cook) - cook);
  }

  cout << total - diff << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 23 16:12:35 2019

@author: Wataru
"""

def solve(i,m):
    
    if (i,m) in dp:
        return dp[(i,m)]
    
    if m==0:
        dp[(i,m)]=1
    elif i>=n:
        dp[(i,m)]=0
    elif solve(i+1,m)==1:
        dp[(i,m)]=1
    elif solve(i+1,m-A[i])==1: 
        dp[(i,m)]=1
    else:
        dp[(i,m)]=0
    return dp[(i,m)]
#%%
def main():
    
    global n,A,q,m, dp

    n=int(input())
    A=list(map(int,input().split()))
    q=int(input())
    m=list(map(int,input().split()))
#    n=5;
#    A=[1,5,7,10,21]
#    q=4
#    m=[2,4,17,8]

    
    for mi in m:
        dp={};

        if solve(0,mi)==1:
            print('yes')
        else:
            print('no')
    return 0
#%%
if __name__ == "__main__":
    main()       


Measured memory_bytes: 6508
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

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


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

int main() {
    int n;
    int res[] = {0, 1, 2, 4, 6, 16, 12, 64, 24, 36, 48, 1024, 60};
    scanf("%d", &n);
    printf("%d\n", res[n]);
    return 0;
}



Measured memory_bytes: 2732
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<sstream>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


int main()
{
    int n;
    cin>>n;
    int cnt = 0;
    while(n) {
        if(n%10 == 2) cnt++;
        n/=10;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )

#define MOD 1000000007

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void print(int A[], int n)
{
	int i;
	for (i = 0; i < n; i++)
	{
		printf("%d", A[i]);
		if (i != n - 1)
			printf(" ");
	}
	printf("\n");
}

int gcd(int a, int b)
{
	if (a < b)
		swap(&a, &b);

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

int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
		printf("res:%lld a:%lld\n", res,a);
	}
	return res;
}

int main()
{
	int n;
	int A[10];

	scanf("%d", &n);

	int i;

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

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


Measured memory_bytes: 2048
from collections import deque

N,A,B = map(int, input().split())
X = list(map(int, input().split()))

INF = float("inf")

dist = deque(X)

next_x = +1
i = 0
ans = 0
while len(dist) != 1:

    if A*abs(dist[i+next_x] - dist[i]) <= B:
        ans += A*abs(dist[i+next_x] - dist[i])
        if next_x == 1:
            dist.popleft()
            i = 0
        else:
            dist.pop()
            i = len(dist)-1
    else:
        ans += B
        if next_x == 1:
            dist.popleft()
            i = len(dist)-1
        else:
            dist.pop()
            i = 0
        
        next_x = -next_x
        
print(ans)

Measured memory_bytes: 14628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	string s;	cin >> s;
	int a = -1, z = 1;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'A'&&a == -1) {
			a = i;
		}
		if (a != -1 && s[i] == 'Z') {
			z = i;
		}
	}
	cout << z - a + 1 << endl;
	cin >> s;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int w,h,n;cin>>w>>h>>n;
  int xmin=0,xmax=w,ymin=0,ymax=h;
  REP(i,n){
    int x,y,a;cin>>x>>y>>a;
    if(a==1){
      xmin=max(xmin, x);
    }
    if(a==2){
      xmax=min(xmax, x);
    }
    if(a==3){
      ymin=max(ymin, y);
    }
    if(a==4){
      ymax=min(ymax, y);
    }
  }
  if(xmin<xmax && ymin<ymax){
    P((xmax-xmin)*(ymax-ymin));
  }else{
    P(0);
  }
  return 0;
}


Measured memory_bytes: 256