akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>

using namespace std;

struct dice{
	int q1,q2,q3,q4,q5,q6;
};

void mN(dice &d){
	int tmp=d.q1;
	d.q1=d.q2;
	d.q2=d.q6;
	d.q6=d.q5;
	d.q5=tmp;
}

void mE(dice &d){
	int tmp=d.q1;
	d.q1=d.q4;
	d.q4=d.q6;
	d.q6=d.q3;
	d.q3=tmp;
}

void spin(dice &d){
	int tmp=d.q2;
	d.q2=d.q3;
	d.q3=d.q5;
	d.q5=d.q4;
	d.q4=tmp;
}

bool isSame(dice y, dice z){
	bool flag = false;

	for(int i=0; i<4; ++i){
		for(int j=0; j<4; ++j){
			if(y.q1==z.q1 && y.q2==z.q2 && y.q3==z.q3 && y.q4==z.q4 && y.q5==z.q5 && y.q6==z.q6) {
				flag = true;
				break;
			}
			spin(y);	
		}
		if(flag) break;
		mN(y);
	}
	
	mE(y);
	
	for(int i=0; i<4; ++i){
		for(int j=0; j<4; ++j){		
			if(y.q1==z.q1 && y.q2==z.q2 && y.q3==z.q3 && y.q4==z.q4 && y.q5==z.q5 && y.q6==z.q6) {
				flag = true;
				break;
			}
			spin(y);	
		}
		if(flag) break;
		mN(y);
	}	
			
	return flag;
}

int main(){
	dice a[100];
	int n;
	bool ans=false;
	
	scanf(" %d", &n);
	
	for(int i=0; i<n; ++i)
		scanf(" %d %d %d %d %d %d", &a[i].q1, &a[i].q2, &a[i].q3, &a[i].q4, &a[i].q5, &a[i].q6);
		
	for(int i=0; i<n-1; ++i){
		for(int j=i+1; j<n; ++j){
			ans=isSame(a[i], a[j]);
			if(ans) break;
		}
		if(ans) break;
	}
	
	if(ans) printf("No\n");
	else printf("Yes\n");
		
	return 0;
}



Measured memory_bytes: 3160
from fractions import gcd
import sys

n = int(input())
nums = list(map(int, sys.stdin.readline().split()))

l_gcds = [nums[0]]
r_gcds = [nums[n-1]]

for i in range(n - 1):
  l_gcds.append(gcd(l_gcds[i], nums[i+1]))
for j in range(n - 1, 0, -1):
  r_gcds.append(gcd(r_gcds[n - 1 - j], nums[j-1]))

max_num = 0
for k in range(n):
  t = 0
  if k == 0:
    t = l_gcds[n-2]
  elif k == n-1:
    t = r_gcds[n-2]
  else:
    t = gcd(l_gcds[k-1], r_gcds[n-2-k])
  if t > max_num:
    max_num = t

print(max_num)

Measured memory_bytes: 16108
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

int main(){
    int N,K; cin >> N >> K;
    vector<int> h(N);
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    ll out = 1000000000;
    for(int i=0;i<=N-K;i++){
        cerr << h[i+K-1] << " " << h[i] << endl;
        if(out>h[i+K-1]-h[i]){
            out = h[i+K-1]-h[i];
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextInt();
		double b = sc.nextInt();
		if(a*b%2!=0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

int A[101];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K, T;
    cin >> K >> T;
    int max_cnt = 0;
    for (int i = 0; i < T; i++) {
        cin >> A[i];
        max_cnt = max(max_cnt, A[i]);
    }
    if (max_cnt * 2 > K) cout << max_cnt * 2 - K - 1 << endl;
    else cout << 0 << endl;
    return 0;
}

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

int[10^^5] BS;
bool[10^^5] HS;

void main()
{
    auto n = readln.chomp.to!int;
    foreach (i; 0..n) {
        BS[i] = readln.chomp.to!int - 1;
    }

    int p, cnt;
    for (;;) {
        ++cnt;
        HS[p] = true;
        p = BS[p];
        if (p == 1) {
            writeln(cnt);
            return;
        }
        if (HS[p]) {
            writeln(-1);
            return;
        }
    }
}

Measured memory_bytes: 1788
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        if(Math.abs(a - c) <= d || Math.abs(a - b) <= d && Math.abs(b - c) <= d) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    
    rep(i,5){
        int x;
        cin>>x;
        if(x==0){
            cout<<i+1<<endl;
        }
    }
    return 0;

}
/*


*/


Measured memory_bytes: 3632
while True:
    m, f, r = (int(x) for x in input().split())
    if m == -1 or f == -1:
        if m == f == r == -1:
            break
        else:
            print('F')
    else:
        if m + f >= 80:
            print('A')
        elif 65 <= (m + f) < 80:
            print('B')
        elif 50 <= (m + f) < 65 or r >= 50:
            print('C')
        elif 30 <= (m + f) < 50:
            print('D')
        else:
            print('F')


Measured memory_bytes: 5604
N, K, S = [int(_) for _ in input().split()]

a = [S for _ in range(K)]
if S != 1:
    b = [S - 1 for _ in range(N-K)]
else: 
    b = [S + 1 for _ in range(N-K)]

print(" ".join([str(v) for v in a + b]))


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

int p, q, a, n;

int solve(int num, int den, int cnt, int pro, int e)
{
  if (cnt > n || p*den < num*q)
    return 0;
  else if (p*den == num*q)
    return 1;

  int res = 0;
  for (int i = e; i <= a; ++i) {
    if (pro*i > a)
      break;

    int x = num * i + den;
    int y = den * i;
    /*
    int gcd = __gcd(x, y);
    x /= gcd;
    y /= gcd;
    */

    res += solve(x, y, cnt+1, pro*i, i);
  }
  return res;
}

int main()
{
  while (~scanf("%d %d %d %d", &p, &q, &a, &n)) {
    if ((p|q|a|n) == 0)
      break;
    printf("%d\n", solve(0, 1, 0, 1, 1));
  }
  return 0;
}

Measured memory_bytes: 0
from collections import Counter
n = int(input())
d = [int(_) for _ in input().split()]
c = Counter(d)
ans = 0
dmax = max(d)

f = 1
for i in range(dmax+1):
    f *= c[i]

if d[0] == 0 and c[0] == 1 and f:
    ans = 1
    if dmax > 1:
        for i in range(2, dmax+1):
            ans *= c[i-1]**c[i]
print(ans%998244353)

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

int main() {
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, M;
	cin >> N;
	map<string, int> smap;
	string s;
	rep(i, 0, N)
	{
		cin >> s;
		smap[s]++;
	}
	cin >> M;
	rep(i, 0, M)
	{
		cin >> s;
		smap[s]--;
	}

	int ans = 0;
	for (auto p : smap)
	{
		chmax(ans, p.second);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$h = explode(' ', trim(fgets(STDIN)));

$max = 0;
for ($i = 0; $i < $n; $i++) {
    $max = max($max, $h[$i]);
    if ($max - $h[$i] >= 2) {
        echo "No" . PHP_EOL;
        exit;
    }
}
echo "Yes" . PHP_EOL;

Measured memory_bytes: 14840
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
n,x = list(map(int,input().split()))
data = [int(s) for s in input().split()]
dis = [None] * (n-1)
#distanceの生成
for i in range(n-1):
    dis[i] = abs(data[i+1] - data[i])
if n == 1:
    print(abs(x-data[0]))
    exit()

dis.sort()
if n == 2:
    temp = min(abs(x-data[0]),abs(x-data[1]))
    print(gcd(temp,dis[0]))
    exit()
#distanceのGCD



for i in range(n-2):#n-2→n == 2 の時を考慮
    dis[i+1] = gcd(dis[i+1],dis[i])
    
print(dis[i+1])


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



int main(){
  int n,k;
  cin>>n>>k;
  if(k==0){
    cout<<0;
    return 0;
  }
  vector< int > v(n);
  for(int i =0; i<n; i++){
    cin>>v[i];
  }
  int step[n];
  step[0]=0;
  step[1] = abs(v[1]-v[0]);
  for(int i=2; i<n;i++){
    int best = INT_MAX;
    for(int j=1; j<k+1 && i-j>-1; j++){
      step[i] = min(best, (abs(step[i-j])+abs(v[i] - v[i-j])));
      best = step[i];
    }
  }
  if(n==0 || n==1){
    cout<<0;
    return 0;
  }

  cout<<step[n-1]<<"\n";

}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	llong k;
	cin>>n>>k;
	
	vi a(n);
	REP(i,n){
		cin>>a[i];
		a[i]--;
	}
	
	int now=0;
	bool jud[n]={};
	jud[0]=true;
	vi d(n,-1);//d[i]:=distance of i betweem 0.
	d[0]=0;
	int cnt=0;
	while(1){
		now=a[now];
		cnt++;
		jud[now]=true;
		d[now]=cnt;
		if(jud[a[now]]) break;
	}
	//line(d);
	
	if(k<cnt){
		REP(i,n){
			if(d[i]==k){
				cout<<i+1<<endl;
				return 0;
			}
		}
	}
	
	int tmp=(k-d[a[now]])%(cnt+1-d[a[now]]);
	//debug(d[now]+tmp);
	REP(i,n){
		if(d[i]==d[a[now]]+tmp){
			cout<<i+1<<endl;
			return 0;
		}
	}
}

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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[])
{
	int n,m;
	scanf("%d%d",&n,&m);
	int ans = 0;
	for(register int i = 0;i < n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(1ll*x*x+1ll*y*y <= 1ll*m*m)
			ans++;
	}
	printf("%d\n",ans );
	return 0;
}

Measured memory_bytes: 3800
#define DEBUGGING  // Enables DEBUG macro.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifndef DEBUGGING
#define debug(...)
#define DEBUG(...)
#else
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                     \
  do {                                 \
    cerr << " (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ": ";      \
    debug(__VA_ARGS__);                \
    cerr << endl;                      \
  } while (0)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<i64> A(N);
  for (auto& x : A) cin >> x;
  sort(A.begin(), A.end());
  i64 amax = A[N - 1];
  vector<bool> non_divisible(amax + 1, true);
  REP(i, N - 1) {
    i64 x = A[i];
    if (!non_divisible[x]) continue;
    for (i64 y = 2 * x; y <= amax; y += x) {
      non_divisible[y] = false;
    }
  }
  REP(i, N - 1) {
    if (A[i] == A[i + 1]) {
      non_divisible[A[i]] = false;
    }
  }
  int ans = 0;
  REP(i, N) {
    if (non_divisible[A[i]]) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4948
n = input()
nums = input()
nums = nums.split()
nums = list(map(int, nums))

cnt = 0
for i in range(int(n)-1):
    for j in range(int(n)-1):
        if nums[j] > nums[j+1]:
            tmp = nums[j+1]
            nums[j+1] = nums[j]
            nums[j] = tmp
            cnt += 1

print(' '.join(map(str, nums)))
print(cnt)


Measured memory_bytes: 5596
using System;

namespace AtcoderABC045A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            c = int.Parse(Console.ReadLine());
            int ans = (a + b) * c / 2;
            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::str::FromStr;

// 755.rs --- 755
// author: Seong Yong-ju <sei40kr@gmail.com>

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
  ($($a:expr),*) => {
    println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
  }
}

#[allow(dead_code)]
fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer);
}

fn num(e: &[i32], m: i32) -> usize {
    return e.iter().filter(|x| m - 1 <= **x).count();
}

fn main() {
    input! {
      n:i32
    }
    let mut e = vec![0i32; (n + 1) as usize];

    for mut i in 2..n + 1 {
        for j in 2..i + 1 {
            while i % j == 0 {
                e[j as usize] += 1;
                i /= j;
            }
        }
    }

    let ans = num(&e, 75)
        + num(&e, 25) * (num(&e, 3) - 1)
        + num(&e, 15) * (num(&e, 5) - 1)
        + num(&e, 5) * (num(&e, 5) - 1) * (num(&e, 3) - 2) / 2;

    with_bufwriter(|mut out| writeln!(out, "{}", ans).unwrap());
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}


//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n,m;
cin>>n>>m;
ll cost=m*1900+(n-m)*100;
ll per=(ll)pow(2,m);
cout<<cost*per<<endl;
}








Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int INF = 1000000000;

    int N, M;
    cin >> N >> M;
    int g[N][N];

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            g[i][j] = -1;
        }
    }
    for(int i=0; i<M; i++){
        int s, t, d;
        cin >> s >> t >> d;
        g[s][t] = d;
    }

    int dp[(1<<N)][N];
    for(int i=0; i<(1<<N); i++){
        for(int j=0; j<N; j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int S=1; S<=(1<<N)-1; S++){
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                int t = S ^ (1<<j);
                if(g[i][j] == -1) continue;
                if(!(S>>j)) continue;
                if(dp[t][i] == INF) continue;
                dp[S][j] = min(dp[S][j], dp[t][i]+g[i][j]);
            }
        }
    }

    if(dp[(1<<N)-1][0] == INF) cout << -1 << endl;
    else cout << dp[(1<<N)-1][0] <<endl;
    
    return 0;
}


Measured memory_bytes: 5016
#500円玉の数
a = int(input())
#100円玉の数
b = int(input())
#50円玉の数
c = int(input())
#払う金額
x = int(input())

count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x - 500*i - 100*j - 50*k == 0:
                count += 1
                

print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

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

    sort(a.begin(), a.end());

    map<int, int> mp;
    rep(i, N) {
        mp[a[i]]++;
    }

    int cnt_max = 0;
    rrep(x, a[0], a[N - 1]) {
        int cnt = 0;
        cnt += mp[x - 1];
        cnt += mp[x];
        cnt += mp[x + 1];
        cnt_max = max(cnt_max, cnt);
    }
    
    cout << cnt_max << endl;
    return 0;
}


Measured memory_bytes: 5376
MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
 
one_count = [0] * 61
for v in a:
  count = 0
  while v != 0:
    if v % 2 == 1:
      one_count[count] += 1
      
    count += 1
    v //= 2
  
 
ans = 0
for i in range(len(one_count)):
  ans += (one_count[i] * (n - one_count[i]) * (2 ** i))
  ans %= MOD
  
print(ans)

Measured memory_bytes: 122808
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  string s;
  cin>>s;
  s.pop_back();
  if(s.length()%2!=0) s.pop_back();
  while(1){
    bool flg = true;
    for(int i = 0; i < s.length()/2; i++){
      if(s[i]!=s[i+s.length()/2]){
        flg = false;
        break;
      }
    }
    if(flg) {
      cout<<s.length()<<endl;
      return 0;
    }
    else{
      s.pop_back();
      s.pop_back();
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void solve()
{
	int mn=INT_MAX; 
	string s, t;
	cin >> s >> t;
	for(int i=0; i<=s.length()-t.length(); ++i)
	{
		string tmp=s.substr(i, t.length());
		int cnt=0;  
		for(int j=0; j<t.length(); ++j)
		{
			if(tmp[j]!=t[j]) ++cnt; 
		}
		mn=min(mn, cnt); 
	}
	cout << mn << endl;
	return; 
}
int main()
{
	int t=1;
	//cin >> t;
	while(t--) solve();
	return 0; 
}

Measured memory_bytes: 3600
import collections
import itertools
from pprint import pprint as pp

H,W,D = tuple(map(int, input().split()))
A = [tuple(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [tuple(map(int, input().split())) for _ in range(Q)]

Arev = [None] * (H*W+1)
for h in range(H):
  for w in range(W):
    Arev[A[h][w]] = (h,w)

tbl = []
for i in range(D):
  ary = []
  mp = 0
  start = Arev[i+1]
  for x in range(i, H*W, D):
    next_ = Arev[x+1]
    mp += abs(start[0]-next_[0]) + abs(start[1]-next_[1])
    ary.append((x+1,mp))
    start = next_
  tbl.append(ary)
#pp(A)
#pp(tbl)
for L,R in LR:
  col1, row = divmod(L, D)
  col2 = R // D
  if row == 0:
    col1 -= 1
    col2 -= 1
  row -= 1
  #pp((row,col1,col2))
  print(tbl[row][col2][1] - tbl[row][col1][1])


Measured memory_bytes: 47544
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

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

void test() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<int> x, y;
    x.emplace_back(a);
    x.emplace_back(b);
    if (a < 0 and b > 0) {
        x.emplace_back(0);
    }
    if (a < -1 and b > -1) {
        x.emplace_back(-1);
    }
    y.emplace_back(c);
    y.emplace_back(d);
    if (c < 0 and d > 0) {
        y.emplace_back(0);
    }
    if (c < -1 and d > -1) {
        y.emplace_back(-1);
    }
    long long ans = LLONG_MIN;
    for (auto &t: x) {
        for (auto &v: y) {
            ans = max(ans, 1ll * t * v);
        }
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <random>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;

int main() {
    int N;
    cin >> N;
    for (int i = 1; i <= 3500; i++) {
        for (int j = 1; j <= 3500; j++) {
            long long A = 1ll * N * i * j;
            long long B = 4ll * i * j - N * i - N * j;
            if (B != 0 && A % B == 0 && A / B > 0) {
                cout << i << " " << j << " " << A / B << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	
	int k;
     string s;
     cin>>k>>s;
     if(s.length()>k)
	 {
	 	for(int i=0;i<k;i++)
	 	cout<<s[i];
	 	cout<<"...";
	 }
	else
	cout<<s;
	
	
	
	
	return 0;
 } 

Measured memory_bytes: 3024
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if(a < b)
		cout << "a < b";
	else if(a > b)
		cout << "a > b";
	else
		cout << "a == b";

	cout << endl;
	return 0;
}

Measured memory_bytes: 1156
n = gets.chomp.to_i
p = gets.chomp.split(" ").map(&:to_i)
comp = [*(1..n)]
count = 0
ans = "YES"


for i in 0..n-1
    if comp[i] != p[i]
        count += 1
    end
    if count > 2
        ans = "NO"
        break
    end
end
puts ans


Measured memory_bytes: 1788
// A - Colorful Subsequence

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
const ll MOD = 1e9 + 7;

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

	string S;
	cin >> S;

	unordered_map<char, int> cnt;

	for (int i=0; i<N; i++) {
		cnt[S[i]]++;
	}

	ll ans = 1;
	for (auto itr : cnt) {
		ans *= itr.second + 1;
		ans %= MOD;
	}

	ans--;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <array>
#include <algorithm>

int main(int, char**) {
  std::array<int, 5> arr;
  int time{};
  int cnt{};

  for(int i{}; i < 5; ++i) {
    std::cin >> arr[i];
    if(arr[i] % 10 == 0) {
      time += arr[i];
      arr[i] = 0;
      ++cnt;
    }
  }

  if(cnt != 5) {
    auto it = std::remove_if(begin(arr), end(arr), [](int n){ return n == 0; });
    std::sort(begin(arr), it, [](int lhs, int rhs){ return lhs % 10 > rhs % 10; });
    for(auto jt = begin(arr); jt != std::prev(it); ++jt) {
      time += (*jt / 10 + 1) * 10;
    }
    time += *std::prev(it);
  }

  std::cout << time << std::endl;

  return 0;
}


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

int x[1000][5];//0=left,1=right,2=parent,3=sibling;

void S1(int u){
	if(u==-1){
		return;
	}
	cout<<' '<<u;
	S1(x[u][0]);
	S1(x[u][1]);
}

void S2(int u){
	if(u==-1){
		return;
	}
	S2(x[u][0]);
	cout<<' '<<u;
	S2(x[u][1]);
}

void S3(int u){
	if(u==-1){
		return;
	}
	S3(x[u][0]);
	S3(x[u][1]);
	cout<<' '<<u;
}

int main(){
	memset(x,-1,sizeof(x));
	int n,a,c;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		cin>>x[a][0]>>x[a][1];
		x[x[a][0]][2]=a;
		x[x[a][1]][2]=a;
		x[x[a][0]][3]=x[a][1];
		x[x[a][1]][3]=x[a][0];
	}
	cout<<"Preorder"<<endl;
	for(int i=0;i<n;i++){
		if(x[i][2]==-1){
			c=i;
			break;
		}
	}
	S1(c);cout<<endl;
	cout<<"Inorder"<<endl;
	S2(c);cout<<endl;
	cout<<"Postorder"<<endl;
	S3(c);cout<<endl;
	return 0;
}



Measured memory_bytes: 3140
#include<iostream>
#include<map>
#include<vector>
 
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	if(b>=0&&a<=0)
		cout<<"Zero\n";
	else{
		if(a>0&&b>0)
			cout<<"Positive\n";
		else{
			int count=(-a)+b+1;
			if(count&1)
				cout<<"Negative\n";
			else
				cout<<"Positive\n";
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 
int main() {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
     string s;
  ll l,i,max=0,c=0;
  cin>>s;
   if(s=="SSS") cout<<0;
  else if(s=="RSR"||s=="SRS"||s=="SSR"||s=="RSS") cout<<1;
  else if(s=="RRS"||s=="SRR") cout<<2;
  else if(s=="RRR") cout<<3;
  else cout<<0;
	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline int mul(int x, int y) { return (1LL*x*y)%MOD; }
inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }


int N;
int sz[5000], mc[5000];
vector<int> G[5000];
int fact[5001];
int nCr[5001][5001];

void dfs2(int x, int p) {
  sz[x] = 1;
  for (int t : G[x]) if (t != p) dfs2(t, x), sz[x] += sz[t], mc[x] = max(mc[x], sz[t]);
  mc[x] = max(mc[x], N-sz[x]);
}

int dp[5001][5001];
int solve(vector<int> seq) {
  //cout<<"{";for (int x : seq) cout << x<<",";cout<<"}\n";
  int n = seq.size(), sum = 0;
  for (int x : seq) sum += x;
  rep(i, n+1) rep(j, sum+1) dp[i][j] = 0;
  dp[0][0] = 1;
  rep(i, n) {
    int a = seq[i];
    rep(j, sum-a+1) {
      rep(c, a+1) add(dp[i+1][j+c], mul(dp[i][j], mul(mul(nCr[a][c], nCr[a][c]), fact[c])));
    }
  }
  int s = 0;
  rep(i, sum+1) {
    int w = mul(dp[n][i], fact[sum-i]);
    if (i%2) w = MOD-w;
    add(s, w);
  }
  return s;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  nCr[0][0] = 1;
  for (int i=1; i<=5000; i++) {
    nCr[i][0] = 1;
    for (int j=1; j<=5000; j++) nCr[i][j] = (nCr[i-1][j-1]+nCr[i-1][j]) % MOD;
  }
  fact[0] = 1;
  for (int i=1; i<=5000; i++) fact[i] = (1LL*i*fact[i-1]) % MOD;
  cin >> N;
  rep(i, N-1) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    G[u].pb(v);
    G[v].pb(u);
  }
  dfs2(0, -1);
  vector<P> ps;
  rep(i, N) ps.pb(P(mc[i], i));
  sort(all(ps));
  int s = 0;
  if (ps[0]._1==ps[1]._1) {
    s = solve({N/2, N/2});
  }
  else {
    vector<int> seq;
    int g = ps[0]._2;
    for (int t : G[g]) {
      dfs2(t, g);
      seq.pb(sz[t]);
    }
    s = solve(seq);
    seq.pb(1);
    add(s, solve(seq));
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 196096
// -*- coding:utf-8-unix -*-

use proconio::*;
//use std::collections::*;

#[fastout]
fn main() {
    input! {
        n: u32,
        a: [u32; n]
    }
    let mut m = 1000000000;
    for i in a {
        let mut j = i;
        let mut c = 0;
        while j % 2 == 0 {
            j /= 2;
            c += 1;
        }
        m = std::cmp::min(m, c);
    }
    println!("{}", m);
}

Measured memory_bytes: 2176
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  ll ans=0;
  ans+=(n/11)*2;
  n%=11;
  if(1<=n && n<=6){
    ans++;
  }else if(7<=n){
    ans+=2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G1[500005];
vector<ll> G2[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 1000000007;
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

 
//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,ans,a,b,c,e,g,h,w,i,j,k,q;
ll x[500005],y[500005],z[500005];
P table[500005];
ll push_num;
ll ruiseki;

int main(){
    cin >> n >> m;
    for(i=0;i<n;i++){
        cin >> a >> b;
        table[i].first = a;
        table[i].second = b;
    }
    sort(table,table+n);
    table[n].first = INF;
    ll idx = 0;
    for(ll lookday=1;lookday<=m;lookday++){
        while(table[idx].first <= lookday){
            pql.push(table[idx].second);
            idx++;
        }
        if(pql.size() != 0){
            //p("pop");
            ans += pql.top();
            pql.pop();
        }
    }
    p(ans);
    return 0;
}












Measured memory_bytes: 27512
#include <iostream>
#include <queue>
 
int main(){
  std::priority_queue<int> price;
  int n,m;
 
  while(std::cin >> n >> m){
    int sum = 0;
    if(n == 0 && m == 0){ break; }
    for(int i = 0; i < n; ++i){
      int temp;
      std::cin >> temp;
      price.push(temp);
    }
    for(int i = 1; i <= n; ++i){
      if(i%m != 0){
        sum += price.top();
      }
      price.pop();
    }
    std::cout << sum << std::endl;
  }
 
  return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (auto &v : a)
    cin >> v;
  for (auto &v : b)
    cin >> v;
  for (auto &v : c)
    cin >> v;

  int ans = b[a[0] - 1];
  for (int i = 1; i < n; ++i) {
    ans += b[a[i] - 1];
      if (a[i-1] + 1 == a[i])
        ans += c[a[i-1] - 1];
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int n;

void compute(int depth,double x1,double y1,double x2,double y2)
{
  double sin60 = sqrt(3.0)/2.0;
  double cos60 = 0.5;

  double sx = (x1+x1+x2)/3.0;
  double sy = (y1+y1+y2)/3.0;
  double tx = (x1+x2+x2)/3.0;
  double ty = (y1+y2+y2)/3.0;

  double vx = tx-sx;//vector no x zahyou
  double vy = ty-sy;//vector no y zahyou

//sx wo kiten to suru.
  // vx wo cos 60 de sinsyuku
  // vy wo sin 60 de sinsyuku
  double ux = sx + cos60*vx - sin60*vy;

//sy wo kiten to suru.
  // vx wo sin 60 de sinsyuku
  // vy wo cos 60 de sinsyuku
  double uy = sy + sin60*vx + cos60*vy;

  if(depth>= n) return;

  compute(depth +1,x1,y1,sx,sy);
  printf("%.8f %.8f\n",sx,sy);
 compute(depth +1,sx,sy,ux,uy);
  printf("%.8f %.8f\n",ux,uy);
  compute(depth+1,ux,uy,tx,ty);
  printf("%.8f %.8f\n",tx,ty);
  compute(depth+1,tx,ty,x2,y2);
}




int main(void)
{
  scanf("%d",&n);
  printf("%.8f %.8f\n",0.0,0.0);
  compute(0,0.0,0.0,100.0,0.0);
  printf("%.8f %.8f\n",100.0,0.0);
  return 0;
}

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

const int INF = 100000000;
int n, G[101][101];

int main(void) {
    int u, k, v;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            G[i][j] = INF;
        }
        G[i][i] = 0;
    }

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v;
            G[u - 1][v - 1] = 1;
        }
    }

    for (int k = 0; k < n; k++)
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);

    for (int i = 0; i < n; i++)
        printf("%d %d\n", i + 1, (G[0][i] < INF ? G[0][i] : -1));

    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int solve(){
    ll n,m;
    cin >> n >> m;
    if(n==0 && m == 0) return 1;
    vector<ll> p(n);
    Rep(i,n) cin >> p[i];
    Rep(i,n) Rep(j,n){
        p.emplace_back(p[i]+p[j]);
    }
    sort(p.begin(),p.end());
    ll ans = 0;
    Rep(i,p.size()){
        ll x = m-p[i];
        if(x<0) break;
        auto y = lower_bound(p.begin(),p.end(),x);
        if(y-p.begin()==0) chmax(ans,p[i]);
        else{
            chmax(ans,p[i]+p[y-p.begin()-1]);
        }
    }
    std::cout << ans << endl;
    return 0;
}

int main(){
    int a = 0;
    while(a==0){
        a = solve();
    }
}


Measured memory_bytes: 18652
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    REP(i,n / 2){
        if(s[i] != s[n - 1 - i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{

		Scanner scan = new Scanner(System.in);
		//BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> suite = new ArrayList<String>();
//		ArrayList<Integer> number = new ArrayList<Integer>();
		ArrayList<String> hikaku = new ArrayList<String>();
		int n =scan.nextInt();
		for(int ii=0;ii<n;ii++){
			String x = scan.next();
			String y = scan.next();
			String xy =x+" "+y;
			suite.add(xy);
			//System.out.println(xy);
		}
//		for(int na=1;na<suite.size();na++){
//			System.out.println(suite.get(na));
//		}
		//////////////////////////////////////////////?????????????????§?????????
		for(int na=1;na<14;na++){
			hikaku.add("S "+na);
		}
		for(int na=1;na<14;na++){
			hikaku.add("H "+na);
		}
		for(int na=1;na<14;na++){
			hikaku.add("C "+na);
		}
		for(int na=1;na<14;na++){
			hikaku.add("D "+na);
		}
//		for(int na=1;na<hikaku.size();na++){
//			System.out.println(hikaku.get(na));
//		}
			/////////////////////////////////////////////??????
		int atta =0;
		for(int i=0;i<hikaku.size();i++){
			atta = 0;
			for(int ii=0;ii<suite.size();ii++){
				String hk = hikaku.get(i);
				String su = suite.get(ii);
				if(hk.equals(su)){
//					System.out.println("atta");
					atta =1;
					break;
				}
				else{
//					System.out.println(hikaku.get(i));
					atta =0;
				}
			}
			if(atta == 0){
				System.out.println(hikaku.get(i));
			}
		}
	}
}

Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x;
    cin >>x;
    while(1){
        bool ok=true;
        for(int i=2;i<x;i++){
            if(x%i==0){
                ok =false;
                break;
            }
        }
        if(ok)break;
        x++;

    }
    cout<<x<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,a[5]={0,-1,-1,-1},l,r;
	cin>>n>>m;
	int ok=1;
	for(int i=0;i<m;i++){
		cin>>l>>r;
		if(a[l]!=-1&&a[l]!=r) ok=0;
		else a[l]=r;
	}
	if(a[1]==0&&n!=1)ok=0;
	if(ok){
		if(a[1]==-1&&n==1) a[1]=0;
		else if(a[1]==-1) a[1]=1;
		for(int i=1;i<=n;i++){
			if(a[i]==-1) a[i]=0;
			cout<<a[i];
		}
	}
	else cout<<-1;
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define pf push_front
#define ll long long
using namespace std;
void TxtRead(){
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
}
void TheTime(){
    ios_base::sync_with_stdio(false);
	cin.tie();
}
const int N = 3e3+5;
const ll INF = 1e9+5;
const ll MOD = 1e9+7;
const double PI = 3.141592653589793116;

int n;
double ar[N], dp[N][N];

int main()
{
    //TxtRead();
    TheTime();
	
	scanf("%d", &n);
	dp[0][0]=1;
	for(int i=1; i<=n; i++){
		scanf("%lf", &ar[i]);
		dp[i][0]=dp[i-1][0]*(1-ar[i]);
	}
	dp[1][1]=ar[1];
	
	for(int i=1; i<=n; i++){
		for(int j=i; j<=n; j++){
			dp[j][i]=dp[j-1][i-1]*ar[j]+dp[j-1][i]*(1-ar[j]);
		}
	}
	
	double ans=0;
	for(int i=n/2+n%2; i<=n; i++){
		ans+=dp[n][i];
	}
	printf("%.9lf\n", ans);
}


Measured memory_bytes: 69120
#!python3.4.3

n = int(input())
t = list(map(int, input().split(' ')))
m = int(input())
t_sum = sum(t)

for i in range(m):
    p, x = map(int, input().split(' '))
    s = t[p-1] - x
    print(t_sum - s)

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  for(int i=0; i<n; i++)cin >> a[i];
  int s = 0;
  for(int k=0; k<n; k++){
    s=s+a[k];
  }
  int u=4*m;
  int l=ceil((double)s/(double)u);
  int count = 0;
  for(int j=0; j<n; j++){
    if(a[j]>=l)count++;
  }
  if(count>=m)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;
using llong = long long;
const int MOD=1000000007;


int main(int argc, char**argv){
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (int i = 0; i < m; i++){
        cin >> b[i];
    }
    int ans = 0;
    vector<int> tmp(m);
    for (int i = 0; i < n; i++){
        int k;
        for (k = 0; k < m; k++){
            cin >> tmp[k];
        }
        int sum = c;
        for (k = 0; k < m; k++){
            sum += tmp[k] * b[k];
        }
        if (sum > 0) ans++;
    }

    cout << ans << endl;

    return 0;
}













Measured memory_bytes: 256