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

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

int n, m;
int dp[1010][1 << 12 + 1];
vector<int> M[1010];
int a[1010];

int solve(int i, int st) {
  if (i == m) {
    if (st == (1 << n) - 1)
      return 0;
    else
      return inf;
  }
  if (dp[i][st] != -1)
    return dp[i][st];

  int op1 = solve(i + 1, st);

  int msk = st;
  for (int j = 0; j < M[i].size(); ++j)
    msk |= (1 << M[i][j]);

  int op2 = solve(i + 1, msk) + a[i];

  return dp[i][st] = min(op1, op2);
}

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

  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a[i];
    int b; cin >> b;
    for (int j = 0; j < b; ++j) {
      int x; cin >> x; x--;
      M[i].pb(x);
    }
  }

  mset(dp, -1);
  int ans = solve(0, 0);
  if (ans >= inf)
    cout << -1 << ende;
  else
    cout << ans << ende;
  return 0;
}


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

int main()
{
	int n;
	cin >> n;
	int d = n % 10;
	if (d == 2 || d == 4 || d == 5 || d == 7 || d == 9)
		cout << "hon";
	else if (d == 0 || d == 1 || d == 6 || d == 8)
		cout << "pon";
	else if (d == 3)
		cout << "bon";
	return 0;

}


Measured memory_bytes: 3040
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        a: isize,
        s: String,
    }
    if a >= 3200 {
        println!("{}", s);
    } else {
        println!("red");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}


int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>h(n);
    rep(i,0,n)
        cin>>h[i];
    int dp[n];
    for(int i=0;i<n;i++)
        dp[i]=10e9;
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        if(i>=k)
        {
            for(int j=1;j<=k;j++)
                dp[i]=std::min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
        else
        {
            for(int j=1;j<=i;j++)
                dp[i]=std::min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}



Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

ll gcd(ll a,ll b){
    ll temp;
    while(b){
        temp=b;
        b=a%b;
        a=temp;
    }
    return a;
}

int main(){
    int n,ans=0; cin>>n;
    map<int,int> m;
    rep(i,n){
        int a; cin>>a;
        if(!(m.count(a))) m[a]=0;
        m[a]++;
    } 
    for(auto q:m){
        if(q.first<=q.second) ans+=q.second-q.first;
        else ans+=q.second;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4736
S = input()
Q = int(input())
queries = [list(map(str, input().split())) for _ in range(Q)]

from collections import deque
s = deque(S)

mode = True
for query in queries:
    if len(query) == 1:
        mode = False if mode else True
        continue
    f = int(query[1])
    c = query[2]
    if mode:
        if f == 1:
            s.appendleft(c)
        else:
            s.append(c)
    else:
        if f == 2:
            s.appendleft(c)
        else:
            s.append(c)

if mode:
    print(*s, sep='')
else:
    print(*list(s)[::-1], sep='')

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

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;

	vector<vector<char>> S(H + 2, vector<char>(W + 2,'#'));
	

	for (int i = 1; i < H+1; i++) {
		for(int j = 1; j < W+1; j++) {
			cin >> S[i][j];
		}
	}

	



	//cout << "start" << endl;
	int max = 0;
	for (int i = 1; i < H+1; i++) {
		for (int j = 1; j < W+1; j++) {
			pair<int, int> place;
			queue<pair<int, int>> que;
			place.first = i;
			place.second = j;
			if (S[i][j] != '.')continue;
			que.push(place);
			vector<vector<int>> check(H + 2, vector<int>(W + 2, 0));
			vector<vector<int>> count(H + 2, vector<int>(W + 2, 0));
			check[i][j] = 1;
			
			while (que.size() != 0) {
				place = que.front();
				pair<int, int> next_place;
				if (S[place.first - 1][place.second] != '#' &&check[place.first - 1][place.second] == 0) {
					next_place.first = place.first - 1;
					next_place.second = place.second;
					check[place.first - 1][place.second] = 1;
					count[place.first - 1][place.second] = count[place.first][place.second] + 1;
					que.push(next_place);

				}
				if (S[place.first + 1][place.second] != '#'&&check[place.first + 1][place.second] == 0) {
					next_place.first = place.first + 1;
					next_place.second = place.second;
					check[place.first + 1][place.second] = 1;
					count[place.first + 1][place.second] = count[place.first][place.second] + 1;

					que.push(next_place);

				}
				if (S[place.first][place.second - 1] != '#'&&check[place.first][place.second - 1] == 0) {
					next_place.first = place.first;
					next_place.second = place.second - 1;
					check[place.first][place.second - 1] = 1;
					count[place.first][place.second - 1] = count[place.first][place.second] + 1;

					que.push(next_place);
				}
				if (S[place.first][place.second + 1] != '#' &&check[place.first][place.second + 1] == 0) {
					next_place.first = place.first;
					next_place.second = place.second + 1;
					check[place.first][place.second + 1] = 1;
					count[place.first][place.second + 1] = count[place.first][place.second] + 1;

					que.push(next_place);
				}

				que.pop();
			}
			if (max < count[place.first][place.second]) {
				max = count[place.first][place.second];
			}
			/*
			for (int k = 1; k <= H; k++) {
				for (int l = 1; l <= W; l++) {
					cout << count[k][l];

				}
				cout << endl;
			}
			cout << endl;
			*/
		}


	}
	cout << max;
	return 0;
}

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


int main(){
    string s;
    cin >> s;

    int n;
    n = s.size() + 1;
    int u[n], d[n];
    int tmp = 0;
    u[0] = 0;

    rep(i, n){
        if (s[i] == '<') tmp ++;
        else tmp = 0;
        u[i + 1] = tmp;
    }

    tmp = 0;
    rrep(i, n - 1){
        if (s[i] == '>') tmp ++;
        else tmp = 0;
        d[i] = tmp;
    }
    d[n - 1] = 0;

    ll ans = 0;

    rep(i, n){
        ans += max(u[i], d[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4740
N = int(input())
A = []
for i in range(2):
  A.append([int(j) for j in input().split()])
open = [[0, 0, A[0][0]]]  # [x, y, score]
close = []

while(open!=[]):
  p = open.pop(0)
  if p[0] < 1:
    open.append([p[0]+1, p[1], p[2]+A[p[0]+1][p[1]]])
  if p[1] < N-1:
    open.append([p[0], p[1]+1, p[2]+A[p[0]][p[1]+1]])
  close.append(p)
  open = sorted(open, key=lambda x:x[2])

close = sorted(close, key=lambda x:-x[2])
print(close[0][2])

Measured memory_bytes: 3952
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<int> fib(n+1,1);
    REP(i,2,n+1) fib[i]=fib[i-1]+fib[i-2];
    cout<<fib[n]<<endl;
}


Measured memory_bytes: 3220
//	-*- mode: C++ -*-
//	Counting Characters
//
//		Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.
//
//	Input
//		A sentence in English is given in several lines.
//
//	Output
//		Prints the number of alphabetical letters in the following format:
//
//		a : The number of 'a'
//		b : The number of 'b'
//		c : The number of 'c'
//		  .
//		  .
//		z : The number of 'z'
//	Constraints
//		The number of characters in the sentence < 1200
//	Sample Input
//		This is a pen.
//	Sample Output
//		a : 1
//		b : 0
//		c : 0
//		d : 0
//		e : 1
//		f : 0
//		g : 0
//		h : 1
//		i : 2
//		j : 0
//		k : 0
//		l : 0
//		m : 0
//		n : 1
//		o : 0
//		p : 1
//		q : 0
//		r : 0
//		s : 2
//		t : 1
//		u : 0
//		v : 0
//		w : 0
//		x : 0
//		y : 0
//		z : 0

#include <iostream>
#include <string>
#include <vector>
#include <utility>

int	main(int	argc,
		 char*	argv[])
{
	std::vector<std::pair<char, unsigned int>>	counter;

	for(unsigned int i = 0; i < 26; i++){
		counter.push_back(std::make_pair('a' + i, 0));
	}

	std::string	str	{};

	while(std::cin >> str){
		for(unsigned int i = 0; i < str.length(); i++){
			if(isupper(str[i])){
				str[i] = tolower(str[i]);
			}

			int	index	= str[i] - 'a';
			if((index >= 0) && (i < 26)){
				counter[index].second++;
			}
		}
	}

	for(auto count : counter){
		std::cout << count.first << " : " << count.second << '\n';
	}

    return 0;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x,y,z;
    cin>>x>>y>>z;
    if (x<y&&z<y&&z>x)
        cout<<"Yes";
    else if (x>y &&z>y&&z<x)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;long long K;cin>>S>>K;
    long long x=S.size();
    bool ans=true;
    for(long long i=0;i<x;i++){
        if(S[i]!='1'){
                if(i<K){
                cout<<S[i]<<endl;
                ans=false;
            }
            break;
        }
    }
    if(ans)cout<<'1'<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    vector<pll> xy;
    ll xmax = 0, ymax = 0, xmin = 1e10, ymin = 1e10;
    for (int i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;
        if (x > y)
            swap(x, y);
        xy.emplace_back(x, y);
        chmax(xmax, x);
        chmax(ymax, y);
        chmin(xmin, x);
        chmin(ymin, y);
    }
    sort(xy.begin(), xy.end());
    ll ret  = INF;
    ll smax = 0, smin = 1e10;
    for (int i = 0; i < n; ++i) {
        chmax(smax, min(xy[i].first, xy[i].second));
        chmin(smin, max(xy[i].first, xy[i].second));
    }
    ll maxi = max(xmax, ymax);
    ll mini = min(xmin, ymin);
    chmin(ret, (smax - mini) * (maxi - smin));

    smax = 0, smin = 1e10;
    chmin(ret, (maxi - mini) * (xy[n - 1].first - xy[0].first));
    for (int i = 0; i < n; ++i) {
        chmax(smax, xy[i].second);
        chmin(smin, xy[i].second);
        chmin(ret, (maxi - mini) * (max(smax, xy[n - 1].first) - min(smin, xy[i + 1].first)));
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
 
long long v[110],w[110];
long long N,W;
long long MEM[100010][110];

long long dp(long long num,int i){
    if(num<0 || i>=N){
        return 0;
    }
    if(MEM[num][i]!=-1){
        return MEM[num][i];
    }
    long long aux=dp(num,i+1);
    if(num>=v[i]){
        aux=max(w[i]+dp(num-v[i],i+1),aux);
    }
//    cout<<num<<" "<<aux<<endl;
    return MEM[num][i]=aux;
}
int main(){
    cin>>N>>W;
    memset(MEM,-1,sizeof(MEM));
    for(int i=0;i<N;i++){
        cin>>v[i]>>w[i];
    }
    cout<<dp(W,0)<<endl;
    return 0;
}

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

int main() {
    int n,x,t; cin >> n >> x >> t;
    int ans = n / x * t;
    ans += (n % x != 0) * t;
    cout << ans << endl;
}

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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  x -= a;
  
  while(x >= b){
    x -= b;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    if i<k:
        c = 0
        num = i
        while num*2 < k:
            num *= 2
            c += 1
        else:
            c += 1
        rate = float(1/n) * float((1/2)**c)
    else:
        rate = float(1/n)
    ans += rate
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
  int n,p;
  int m[100];

  while( cin>>n>>p && (n|p) ){
    for( int i=0;i<n;i++ )
      m[i]=0;

    int z=0;
    while(true){
      if( p>0 ){
	p--;
	m[z]++;
	if(p==0){
	  bool f=true;
	  for( int i=0;i<n;i++){
	    if( i==z)continue;
	    if( m[i]>0 ){
	      f=false;
	      break;
	    }
	  }
	  if( f ){
	    cout << z << endl;
	    break;
	  }
	}
      }else{
	if( m[z]>0 ){
	  p+=m[z];
	  m[z]=0;
	}
      }
      z=(z+1)%n;
    }

  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(){
  int a, b;
  int x, y;

  scanf("%d %d",&x,&y);
  if(x>y){
    a=x;
    x=y;
    y=a;
  }
  while(x>0){
    a=y%x;
    y=x;
    x=a;
  }
  printf("%d\n",y);
  return 0;
}

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

int main () {
  int D,G;
  scanf("%d %d", &D, &G);
  int p[D];
  int c[D];
  for(int i = 0; i<D; i++) scanf("%d %d", &p[i], &c[i]);
  int res = INT_MAX;
  for(int i = 0; i < (1<<D); i++) {
    int cnt = 0;
    int sum = 0;
    int tmp = 0;
    for(int j = 0; j<D; j++) {
      if(i & (1<<j)) {
        cnt += 100 * (j + 1) * p[j] + c[j];
        sum += p[j];
      } else {
        tmp = j;
      }
    }
    if(cnt < G) {
      int chk = 100 * (1 + tmp);
      int com = (G - cnt + chk - 1) / chk;
      if(com > p[tmp]) continue;
      sum += com;
    }
    res = min(res , sum);
  }
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a: Int = sc.nextInt()
  val b: Int = sc.nextInt()
  if (a > 2*b) {
    println(a - 2*b)
  }else{
    println(0)
  }
}

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


int main(){
    string S;
    cin >> S;
    if (S[0]!=S[1] && S[1]!=S[2] && S[2]!=S[3]){
        cout << "Good" << endl;
    }
    else {
        cout << "Bad" << endl;
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

int main() {
    int R, G;
    cin >> R >> G;
    cout << 2 * G - R << endl;
}


Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Function (on)

main :: IO ()
main = do
  n <- getl toInt
  unless (n == 0) $ do
    (solve n) <$> replicateM n (getl $ wrds toInt) >>= mapM_ print
    main

solve :: Int -> [[Int]] -> [Int]
solve n xs = [ls !! 0, ls !! 1, ls !! (n - 2)]
  where
    toTime [c1, m1, s1, m2, s2, m3, s3, m4, s4] = (c1, (m1+m2+m3+m4)*60+s1+s2+s3+s4)
    ls = map fst . sortBy (compare `on` snd) . map toTime $ xs

toInt :: String -> Int
toInt s = read s

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 12104
#include<stdio.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7,MAX=1e6;
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline int IN(void)
{
  int x=0,f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
typedef struct{int SPF[1000001];int Primes[1000001];int sz;}Template;
Template P;
static inline int MPow(int a,int b){return b?1l*MPow(1l*a*a%MOD,b>>1)*(b&1?a:1)%MOD:1;}
static inline void ready(void)
{
  *P.SPF=1,*P.Primes=2,P.sz=1;
  rep(i,MAX/2)P.SPF[2*(i+1)]=2,P.SPF[2*(i+1)-1]=2*(i+1)-1;
  rep(i,MAX/2-1)
  {
    int x=2*(i+1)+1;if(P.SPF[x]==x){P.Primes[P.sz++]=x;}
    rep(j,P.sz){if(P.Primes[j]<=P.SPF[x]&&x*P.Primes[j]<=MAX)P.SPF[x*P.Primes[j]]=P.Primes[j];else break;}
  }
}
int main(void)
{
  int N=IN(),A=0,factor=0,invsum=0,lcm=1,x=0,box[1000001]={0};ready();
  rep(i,P.sz/2)box[P.Primes[2*i]]=box[P.Primes[2*i+1]]=0;
  rep(i,N)
  {
    A=IN();invsum=(invsum+1l*MPow(A,MOD-2))%MOD;
    while(A>1)
    {
      factor=P.SPF[A];
      x=1;A/=factor;
      while(A%factor==0)A/=factor,x++;
      if(box[factor]<x)box[factor]=x; 
    }
  }
  rep(i,P.sz){if(box[P.Primes[i]])lcm=1l*lcm*MPow(P.Primes[i],box[P.Primes[i]])%MOD;}
  return printf("%ld\n",1l*lcm*invsum%MOD),0;
}

Measured memory_bytes: 9716
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;

map<int, int> m;
void find(int n) {
	for(int i = 2; i <= n; ++i) {
		if(n % i == 0) {
			n /= i;
			m[i]++;
			i--;
			}
		}
}

void solve() {
	int n;
	cin >> n;
	for(int i = n; i > 0; --i) find(i);
	ll ans = 1;
	for(auto x : m) (ans *= (x.second + 1)) %= mod;
	cout << ans << endl;
}
	

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}


Measured memory_bytes: 3632
N,M = gets.split.map &:to_i
switches = Array.new(N,0)
M.times{ |j|
  k,*s = gets.split.map &:to_i
  s.each{ |i| switches[i-1] += (1 << j) }
}
P = gets.split.reverse.join.to_i(2)
p (0...(1<<N)).count{ |s|
  t = 0
  (0...N).each{ |i|
    t ^= switches[i] if (s & (1 << i)) > 0
  }
  t == P 
}


Measured memory_bytes: 1916
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 100005
using namespace std;
typedef long long ll;
const ll inf=1e17;
struct edge{
	int k,next;
}e[N<<1];
int home[N],cnt=-1,n,m,fa[N],sx,sy,dep[N];
ll f[N],w[N];
int find(int k){
	if(fa[k]!=k) fa[k]=find(fa[k]);
	return fa[k];
}
void add(int x,int y){
	cnt++;
	e[cnt].k=y;
	e[cnt].next=home[x];
	home[x]=cnt;
}
ll Abs(ll a){return a<0?-a:a;}
int op=0;
void dfs(int k,int F,int dep){
	if(dep) w[k]=1;
	else w[k]=-1;
	::dep[k]=dep;
	f[k]=0;
	for(int i=home[k];~i;i=e[i].next){
		if(e[i].k!=F){
			dfs(e[i].k,k,dep^1);
			f[k]+=f[e[i].k]+Abs(w[e[i].k]);
			w[k]+=w[e[i].k];
		}
	}
}
void dfs1(int k,int F,int W){
	dep[k]=dep[F]^1;
	f[k]=w[k]=0;
	if(dep[k]) w[k]=1;
	else w[k]=-1;
	for(int i=home[k];~i;i=e[i].next){
		if(e[i].k!=F){
			dfs1(e[i].k,k,W);
			f[k]+=f[e[i].k]+Abs(w[e[i].k]);
			w[k]+=w[e[i].k];
		}
	}
	if(op==1){
		if(k==sy) w[k]-=W;
		if(k==sx) f[k]+=Abs(W),w[k]+=W;
	}
	else{
		if(k==sy) w[k]+=W;
		if(k==sx) w[k]+=W; 
	}
}
int main(){
	memset(home,-1,sizeof(home));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1,x,y;i<=m;i++){
		scanf("%d%d",&x,&y);
		if(find(x)!=find(y)){
			add(x,y);add(y,x);
			fa[find(x)]=find(y);
		}else{
			sx=x;sy=y;
		}
	}
	dfs(1,0,1);
	ll ans=f[1];
	if(w[1]) ans=inf;
	if(n==m){
		if(dep[sx]!=dep[sy]){
			if(w[1]) return puts("-1"),0;
			op=1;
			int l=-n,r=n,L,R;
			while(l<=r){
				L=l+(r-l)/3;
				R=r-(r-l)/3;
				dfs1(sx,0,L);
				ll wl=w[sx]==0?f[sx]:inf;
				dfs1(sx,0,R);
				ll wr=w[sx]==0?f[sx]:inf;
				if(wl<wr) ans=min(ans,wl),r=R-1;
				else l=L+1,ans=min(ans,wr);
			}
			printf("%lld",ans);
			return 0;
		}
		else{
			if(w[1]%2) return puts("-1"),0;
			ll G=-w[1]/2;
			op=2;
			dfs1(1,0,G);
			ans=min(ans,f[1]+Abs(G));
			printf("%lld",ans);
		}
		return 0;
	}
	if(ans==inf) puts("-1");
	else printf("%lld",ans);
	return 0;
}

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

string* BubbleSort(string C0[], int N) {
	string *C; C = new string[N];
	for (int i = 0; i < N; i++) C[i] = C0[i];

	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j > i; j--) {
			if (C[j][1] < C[j - 1][1]) {
				swap(C[j], C[j - 1]);
			}
		}
	}

	for (int i = 0; i < N; i++) {
		if (i != 0) cout << " ";
		cout << C[i];
	}
	cout << endl;

	cout << "Stable" << endl;
	return C;
}

void SelectionSort(string C0[], string B[], int N) {
	string *C; C = new string[N];
	for (int i = 0; i < N; i++) {
		C[i] = C0[i];
	}

	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i + 1; j < N; j++) {
			if (C[j][1] < C[minj][1]) {
				minj = j; 
			}
		}
		swap(C[i], C[minj]);
	}

	for (int i = 0; i < N; i++) {
		if (i != 0) cout << " ";
		cout << C[i];
	}
	cout << endl;

	bool flg = true;
	for (int i = 0; i < N; i++) {
		if (C[i] != B[i]) flg = false;
	}

	if (flg) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
}

int main() {
	int N; cin >> N;
	string *C; C = new string[N];
	for (int i = 0; i < N; i++) cin >> C[i];

	string *B =	BubbleSort(C, N);
	SelectionSort(C, B, N);
	return 0;
}



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

int main(){
    int n;
    cin >> n;
    if(400 <= n && n <= 599)cout << 8 << endl;
    if(600 <= n && n <= 799)cout << 7 << endl;
    if(800 <= n && n <= 999)cout << 6 << endl;
    if(1000 <= n && n <= 1199)cout << 5 << endl;
    if(1200 <= n && n <= 1399)cout << 4 << endl;
    if(1400 <= n && n <= 1599)cout << 3<< endl;
    if(1600 <= n && n <= 1799)cout << 2<< endl;
    if(1800 <= n && n <= 1999)cout << 1<< endl;
}


Measured memory_bytes: 3668
from collections import deque

S = input()
Q = int(input())
query = [input() for _ in range(Q)]

S = deque(S)

inv = 0
for q in query:
    if q[0] == "1":
        inv += 1
    else:
        _, f, c = q.split()
        if f == "1":
            if inv % 2 == 0:
                S.appendleft(c)
            else:
                S.append(c)
        else:
            if inv % 2 == 0:
                S.append(c)
            else:
                S.appendleft(c)
S = "".join(S)
print(S if inv % 2 == 0 else S[::-1])

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

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

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
	for (auto i : a) cerr << i << ' ';\
	cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	ll s = 0, ans = 0;
	forn(i, 0, n) {
		int x;
		cin >> x;
		if (x == 0) {
			ans += s / 2;
			s = 0;
		} else s += x;
	}
	ans += s / 2;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 +c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,M;
int c[16],dp[(1 << 15) + 5],cnt[(1 << 15) + 5],pw[100005];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
int lowbit(int x) {
    return x & (-x);
}
void update(int &x,int y) {
    x = inc(x,y);
}
void Solve() {
    read(N);read(M);
    pw[0] = 1;
    for(int i = 1 ; i <= M ; ++i) pw[i] = mul(pw[i - 1],2);
    for(int i = 1 ; i < (1 << N) ; ++i) cnt[i] = cnt[i - lowbit(i)] + 1;
    int x,y;
    for(int i = 1 ; i <= M ; ++i) {
        read(x);read(y);
        c[x] |= 1 << y - 1;
    }
    dp[0] = 1;
    for(int S = 1 ; S < (1 << N) ; ++S) {
        if((S & 3) != 3 && (S & 3) != 0) continue;
        for(int T = S; T ; T = (T - 1) & S) {
            if((T & 3) != 3 && (T & 3) != 0) continue;
            int d = 1;
            for(int i = 1 ; i <= N ; ++i) {
                if(T & (1 << i - 1)) d = mul(d,pw[cnt[c[i] & (S ^ T)]]);
                if((S ^ T) & (1 << i - 1)) d = mul(d,pw[cnt[c[i] & T]] - 1);
            }
            d = mul(d,dp[S ^ T]);
            update(dp[S],d);
        }
    }
    out(inc(pw[M],MOD - dp[(1 << N) - 1]));enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=998244353;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}


const int N=200005;

void solve(){ 
	int n;
	cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++){
		sum+=i;
		if(i%3==0||i%5==0){
			sum-=i;
		}
	}
	cout<<sum;
	
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //~cin>>tc;
  for(int _=0;_<tc;_++){
    //~cout<<"Case #"<<_+1<<": \n";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}



Measured memory_bytes: 3656
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) ll(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
 
const ll mod = 1e9 + 7;
const int inf = 1e9 + 5;
const int N = 2e5 + 5;

signed main(){
    fastio;
    string s;
    cin>>s;
    for(int i=0;i<sz(s);++i)
        cout<<"x";
    return 0;
}

Measured memory_bytes: 256
import re

d,g = map(int,input().split() )
l = [list(map(int,input().split() ))+[100*(x+1)] for x in range(d) ] 

mondai_num = []

for k in range(2**d):

  #先に全完するカテゴリ(何百点問題を全完するか)を決め、回す
  bin_str = format(k, "0{}b".format(d) )#二進数の文字列を取得
  #これが全完する問題のリスト
  zenkan_list = [ x.start() for x in re.finditer("1",bin_str)  ] 
  

  #0~9のリストと和の初期化
  d_list = [i for i in range(d)]
  wa = 0
  cnt = 0
  #全完した点数のみ先に足す
  for i in zenkan_list:
    wa = wa+(l[i][0])*((i+1)*100)
    wa = wa + l[i][1]  
    cnt = cnt + l[i][0]
  #全完したやつだけで目標を超えたらそこでストップ
  if wa>=g:
    mondai_num.append( cnt )

  #全完したやつだけでたらなかったら素点が大きいやつを全完一歩手前まで足す
  else:
    #全完したカテゴリを除外
    for i in zenkan_list:
      d_list.remove(i)
    #残ったカテゴリの中で最大の点数のカテゴリを探す
    max_set = l[max(d_list)]

    for i in range( max_set[0]  ):
      wa = wa + max_set[2]
      if wa >= g:
        mondai_num.append(cnt + i+1 )
        break
print(min(mondai_num))

Measured memory_bytes: 45292
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    int N, K;
    string S;
    cin >> N >> K >> S;
    
    S[K-1] = 'a' + (S[K-1]-'A');
    cout << S << endl; 
}


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

int main(){
  int n,m ; cin >> n >> m ;
  vector<vector<bool>> pass(n,vector<bool>(n,false)) ;
  for(int i=0;i<n;i++) pass.at(i).at(i) = true ;
  for(int i=0;i<m;i++){
    int a,b ;
    cin >> a >> b ;
    pass.at(a-1).at(b-1) = pass.at(b-1).at(a-1) = true ;
  }
  vector<int> num ;
  for(int i=0;i<n;i++) num.push_back(i) ;
  int ans = 0 ;
  do{
    if(num.at(0)!=0) break ;
    bool check = true ;
    for(int i=0;i<n-1;i++){
      if(!pass.at(num.at(i)).at(num.at(i+1))){
        check = false ;
        break ;
      }
    }
    if(check) ans++ ;
  }while(next_permutation(num.begin(),num.end())) ;
  cout << ans << endl ;
}

Measured memory_bytes: 256
#include<cstdio>
const int MaxN=100010,MaxH=210;
int N,H;
struct edge{int to;edge*next;}E[MaxN*2],*ne=E,*fir[MaxH*2];
void link(int u,int v){*ne=(edge){v,fir[u]};fir[u]=ne++;}
int deg[MaxH*2],Q[MaxH*2];
bool vis[MaxH*2];
int main(){
	scanf("%d%d",&N,&H);
	for(int i=0;i<N;i++){
		int A,B,C,D;
		scanf("%d%d%d%d",&A,&B,&C,&D);
		A=C?C+H:A;
		B=D?D:B+H;
		link(A,B);link(B,A);
		deg[A]++;deg[B]--;
	}
	for(int i=1;i<=H*2;i++)if(!vis[i]&&fir[i]){
		bool fl=1,ex=0;
		int*h=Q,*t=Q;
		vis[*t++=i]=1;
		for(;h<t;h++){
			if(*h<=H&&deg[*h])ex=1,deg[*h]<0?fl=0:1;
			if(*h>H&&deg[*h])ex=1,deg[*h]>0?fl=0:1;
			for(edge*e=fir[*h];e;e=e->next)
				if(!vis[e->to])vis[*t++=e->to]=1;
		}
		if(!fl||!ex)return puts("NO"),0;
	}
	puts("YES");
}

Measured memory_bytes: 3328
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a = []
for i in range(5):
    b = int(input())
    a.append(b)
k = int(input())
if k < a[-1] - a[0]:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 7240
N = int(input())
#N = 4
def to_str(n):
    s = [chr(i + 97) for i in reversed(n)]
    s = "".join(s)
    return s
n = [0] * N
n_max = list(reversed(list(range(N))))

s = to_str(n)
print(s)
while True:
    for j in range(N-1):
        #if n[j] < n[j+1]+1:
        if n[j] < max(n[j+1:]) + 1:
            n[j] += 1
            for k in range(j):
                n[k] = 0
            s = to_str(n)
            print(s)
            break
    if n == n_max:
        break

Measured memory_bytes: 4340
#include<iostream>
        #include<vector>
        #define REP(m,n) for(int i=m;i<n;i++)
        using namespace std;
        int main(){
         long long int pow=1,N;
         cin>>N;
         REP(0,N) pow=(pow*(i+1))%1000000007;
         cout<<pow<<endl;
         return 0;
        }

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

int main(){
  ll n,m,ans=0;cin>>n>>m;
  vvb g(m,vb(n,false));
  rep(i,0,m){
      ll k;cin>>k;
      rep(j,0,k){
        ll s;cin>>s;
        g[i][--s]=true;
      }
  }
  vin p(m);
  rep(i,0,m){cin>>p[i];}
  rep(i,0,1<<n){
      vin cnt(m,0);
      ll c=0;
      rep(j,0,n){
          if(i>>j&1){
              rep(k,0,m){
                  if(g[k][j]){cnt[k]++;}
              }
          }
      }
      rep(j,0,m){
          if(cnt[j]%2==p[j]){c++;}
      }
      if(c==m){ans++;}
  }
  out(ans);
}


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

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

	vector<tuple<string,int,int> > a(N);
	
	for(int i=0;i<N;i++){
		string s;
		int p;
		cin>>s>>p;
		a.at(i)=make_tuple(s,100-p,i+1);
	}
	sort(a.begin(),a.end());


	//cout<<"\n";
	for(int i=0;i<N;i++){
		string s;
		int p,k;
		tie(s,p,k)=a.at(i);
		cout<<k<<endl;
	}		
	
}



Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
for i in range(q):
    u,v=map(int,input().split())
    if n==1:
        print(min(u,v))
        continue
    u-=1
    v-=1
    while u!=v:
        if u>v:
            if (u-1)//n>v:
                u=(((u-1)//n)-1)//n
            else:
                u=(u-1)//n
        else:
            if (v-1)//n>v:
                v=(((v-1)//n)-1)//n
            else:
                v=(v-1)//n
    print(u+1)


Measured memory_bytes: 52572
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();

        long digits = Integer.MAX_VALUE;
        for (long i = 1; i*i <= n; i++) {
            if (n % i != 0) continue;

            long tmpB = n/i;
            int tmpDigits = Math.max(digitsCount(i), digitsCount(tmpB));

            if (digits > tmpDigits) digits = tmpDigits;
        }

        System.out.println(digits);
    }

    public static int digitsCount(long a) {
        int ans = 0;
        while (a>0) {
            a/=10;
            ans++;
        }
        return ans;
    }
}


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

int main()
{
	int i,j,k;
	long long n,m,l,a[101][101],b[101][101],c[101][101] ={};
	cin>>n>>m>>l;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
			cin>>a[i][j];
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=l;j++)
			cin>>b[i][j];
	}
	
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=l;j++)
		{
			for(k=1;k<=m;k++)
			{
				c[i][j]+= a[i][k]*b[k][j];
			}
		}
	}
	
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=l;j++)
			cout<<(j==1?"":" ")<<c[i][j];
		cout<<endl;
	}		
	return 0;
 } 


Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
#define sorted(a) sort(a.begin(), a.end());
#define ALL(a) (a).begin(), (a).end()
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int i = 0; i <= N; i++) {
    if (i * R > N) break;
    for (int j = 0; j <= N; j++) {
      int k = N - ((i * R) + (j * G));
      if (k < 0)
        break;
      else if (k % B == 0)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <cmath>
#include <cstdio>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

const double PI=4*atan(1.0);
typedef complex<double> P;

// àÏ
double dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
// OÏ
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
// a©çbÖ¶üèÅ½x©
double diffAngle(P a,P b){
  // cos>0&&sin>0 -> 0 -> 90
  // cos<0&&sin>0 -> 90->180
  // cos<0&&sin<0 -> 180->270
  // cos>0&&sin<0 -> 270 -> 359
    //double cosn=dot(a,b)/(abs(a)*abs(b));
    //double sinn=cross(a,b);
    //double angle=acos(cosn);
    //if(sinn>0||EQ(sinn,0))
    //    return angle;
    //return 2*PI-angle;
    double angle=atan2(cross(a,b)/(abs(a)*abs(b)),dot(a,b)/(abs(a)*abs(b)));
    if(angle<0)
        return 2*PI+angle;
    return angle;
}

int main(){
    int n;
    while(cin>>n&&n!=0){
        vector<P> points;
        for(int i = 0; i < n; i++){
            int x,y;
            cin>>x>>y;
            points.push_back(P(x,y));
        }
        vector<bool> isUsed(points.size(),false);
        double sum=0;
        P cp=P(0,1);
        P pp=P(0,0);
        int cnt=n;
        while(cnt--){
            int idx=-1;
            double minAngle=100000000;
            for(int i = 0; i < points.size(); i++){
                if(isUsed[i]) continue;
                double ca=diffAngle(points[i]-pp,cp);
                //cout<<ca<<endl;
                if(EQ(minAngle,ca)){
                    if(abs(points[idx]-pp)>abs(points[i]-pp))
                        idx=i;
                }
                else if(minAngle>ca){
                    idx=i;
                    minAngle=ca;
                }
            }
            isUsed[idx]=true;
            double inc=abs(points[idx]-pp);
            sum+=inc;
            P p=(points[idx]-pp);
            cp=p/abs(p);
            pp=points[idx];
        }
        printf("%.1f\n",sum);
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;

#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, N = 5e5 + 10;
const ll LINF = LLONG_MAX;
int a,b,c,d,e,n,sum;
str s1,s2,s;
int32_t main() {
    fast();
    char ch;
    cin >> ch;
    ch++;
    cout<<ch;

    return 0;
}
 

Measured memory_bytes: 256
H, W = map(int, input().split())
s = []
OK = True
# OK1 = True
# OK2 = True
# OK3 = True
# OK4 = True
for _ in range(H):
    s.append(input())
for i in range(H):
    for j in range(W):
        OK1 = True
        OK2 = True
        OK3 = True
        OK4 = True
        if s[i][j] == '#':
            if i != 0:
                if s[i-1][j] != '#':
                    OK1 = False
            if i != H-1:
                if s[i+1][j] != '#':
                    OK2 = False
            if j != 0:
                if s[i][j-1] != '#':
                    OK3 = False
            if j != W-1:
                if s[i][j+1] != '#':
                    OK4 = False
        if OK1 or OK2 or OK3 or OK4:
            continue
        else:
            OK = False

if OK:
    print('Yes')
else:
    print('No')
        

Measured memory_bytes: 3064
n,m,x = map(int, input().split())
a=[list(map(int,list(input().split()))) for i in range(n)]

ans = 10**9

for i in range(2**n):
    price = 0
    score = [0]*m
    for j in range(n):
        if (i>>j) & 1 == 1:
            for k in range(m):
                score[k] += a[j][k+1]
            price += a[j][0]
        if all(l >= x for l in score):
            ans = min(ans,price)
            break


if ans != 10**9:    
    print(ans)
else:
    print(-1)

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec cnt(n + 1);
    int tmp;

    For(i, 2, n) {
        cin >> tmp;
        cnt[tmp]++;
    }
    For(i, 1, n) print(cnt[i]);

    return 0;
}


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
   string s;
   cin>>s;
   if(s.size()==2) cout<<s<<endl;
   else {
       reverse(s.begin(),s.end());
       cout<<s<<endl;
   }
   return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

string str;
vector<bool> ass;
bool calc(int a,int b, const string& str){
  switch(str[a]){
  case '-':
	return !calc(a+1, b, str);
  case 'T':
	return true;
  case 'F':
	return false;
  case '(':
	int cnt = 0;
	for(int i=a+1;i<b-1;++i){
	  if(str[i] == '(') ++cnt;
	  else if(str[i] == ')') --cnt;
	  else if(cnt == 0){
		if(str[i] == '*') return calc(a+1, i, str) && calc(i+1, b, str);
		else if(str[i] == '+') return calc(a+1, i, str) || calc(i+1, b, str);
		else if(i+1<b-1 && str[i] == '-' && str[i+1] == '>')
		  return !calc(a+1, i, str) || calc(i+2, b, str);
	  }
	}
  }
  
  return false;
}

bool dfs(int i){
  if(i == 12){
	string rep = str;
	int div;
	for(int i=0;i<SZ(rep);++i){
	  if('a' <= rep[i] && rep[i] <= 'k')
		rep[i] = (ass[rep[i]-'a']? 'T': 'F');
	  if(rep[i] == '=') div = i;
	}
	string fr = rep.substr(0,div), bc = rep.substr(div+1);
	return calc(0, SZ(fr), fr) == calc(0, SZ(bc), bc);
  }
  ass[i] = true;
  if(!dfs(i+1)) return false;
  ass[i] = false;
  return dfs(i+1);
}

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

  while(cin >> str, str!="#"){
	ass.assign(12, false);
	cout << (dfs(0)? "YES": "NO") << endl;
  }

  return 0;
}

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



int main(){

    string s;
    cin>>s;

    if(s[s.size()-1]=='s'){
        s=s+"es";
        cout<<s<<endl;
    }

    else{
        s=s+"s";
        cout<<s<<endl;
    }






    return 0;
}


Measured memory_bytes: 3620