akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main
{
	public static void main ( String[] args ) {
		Scanner sc = new Scanner ( System.in );
		int a[] = new int[ 3 ];
		int tmp = 0;

		for ( int i = 0; i < 3; i++ ) {
			a[ i ] = sc.nextInt ();
		}
		
		for ( int j = 1; 0 <= j; j-- ) {
			if ( a[ j + 1 ] < a[ j ] ) {
				tmp = a[ j + 1 ];
				a[ j + 1 ] = a[ j ];
				a[ j ] = tmp;
			}
		}
		
		if ( a[ 2 ] < a[ 1 ] ) {
			tmp = a[ 2 ];
			a[ 2 ] = a[ 1 ];
			a[ 1 ] = tmp;
		}

		System.out.println ( a[ 0 ] + " " + a[ 1 ] + " " + a[ 2 ] );
	}
}

Measured memory_bytes: 26184
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


from numba import njit
import numpy as np


N, K = ints()
W, V = read_col(N)
W = np.array(W, dtype=np.int64)
V = np.array(V, dtype=np.int64)


@njit('(i8,i8,i8[:],i8[:])', cache=True)
def main(N, K, W, V):
    dp = np.zeros((N + 1, K + 1), dtype=np.int64)
    for i in range(N + 1):
        dp[i, 0] = 0

    for i in range(N):
        w, v = W[i], V[i]
        for sum_w in range(K + 1):
            if sum_w - w < 0:
                dp[i + 1, sum_w] = dp[i, sum_w]
            else:
                dp[i + 1, sum_w] = max(
                    dp[i, sum_w],
                    dp[i, sum_w - w] + v)
    print(dp[-1, -1])


main(N, K, W, V)


Measured memory_bytes: 190964
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};



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

  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  int x = INF, y = 0;
  rep(i, n) {
    chmin(x, a[i]);
    chmax(y, a[i]);
  }
  cout << (y - x + 1) / 2 << endl;
  return 0;
}



Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] input = sc.next().toCharArray();
        int countPlus = 0;
        int countMinus = 0;

        for(char c: input){
            if(c == '+'){
                countPlus++;
            } else {
                countMinus--;
            }
        }

        System.out.println(countPlus + countMinus);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }

    public static int gcd(int a, int b){
        if (b == 0) return a;
        return gcd(b, a % b);
    }

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


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

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	ll a[n],sum=0;
	ll b[n]{};
	
	forn(i,0,n){
		cin>>a[i]; sum+=a[i];
	}
	
	sum/=2;
	b[0]=sum;
	for(int i=2;i<n;i+=2){
		b[0]-=a[i];
	}
	
	forn(i,1,n){
		b[i]=a[i]-b[i-1];
	}
	
	cout<<b[n-1]*2<<" ";
	forn(i,0,n-1) cout<<b[i]*2<<" ";
	
	return 0;
}


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

int main()
{
    int n, k; cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    if (k >= n) {
        cout << 0 << endl;
        return 0;
    }

    sort(h.begin(), h.end());
    int cut = n - k;

    ll ans = 0;

    rep(i,cut) {
        ans += h[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
sx, sy, tx, ty = map(int, input().split())
ans = ""
for i in range(sx, tx): ans += 'R'
for i in range(sy, ty): ans += 'U'
for i in range(sx, tx): ans += 'L'
for i in range(sy, ty): ans += 'D'
ans += 'D'
for i in range(sx, tx + 1): ans += 'R'
for i in range(sy - 1, ty): ans += 'U'
ans += 'LU'
for i in range(sx - 1, tx): ans += 'L'
for i in range(sy, ty + 1): ans += 'D'
ans += 'R'
print(ans)

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

int main(){
    int n,x,i;
    cin>>n>>x;
    int arr[n];
    for(i=0;i<n;i++){
        cin>>arr[i];
    }

    sort(arr,arr+n);
    for(i=0;i<n;i++){
        x-=arr[i];
        if(x<0){
            break;
        }
    }
    if(x>0) 
      i--;
    cout<<i;
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vvi g;
vi a;

void dfs(int v){
	a[v]=1;
	for(auto u:g[v]) if(!a[u]) dfs(u);
}

int main(){
	cin>>n>>m;
	g=vvi(n);
	a=vi(n);
	for(int i=0;i<m;i++){
		int u,v,c;
		cin>>u>>v>>c;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int t=0;
	for(int i=0;i<n;i++) if(!a[i]) t++,dfs(i);
	cout<<t<<endl;
}

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

void solve() {
    int s, t, p, q, M, y;
    cin >> s >> t >> p >> q >> M >> y;
    cout << (t ^ y ^ s) << endl;
}

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



    solve();

    return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
string s,t,ans;
int dp[4000][4000];
int lcs(int i, int j)
{
	if(i<=0 || j<=0)
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	if(s[i-1]==t[j-1])
	{
		// printf("%d %d\n",i,j );
		dp[i][j] = lcs(i-1,j-1) + 1;
	}
	else
	{
		dp[i][j] = max(lcs(i-1,j) , lcs(i,j-1));
	}
	return dp[i][j];
}

void print(int i, int j)
{
	if(i==0 || j==0)
	{
		return;
	}
	if(dp[i][j]==dp[i-1][j])
		print(i-1,j);
	else if(dp[i][j]==dp[i][j-1])
		print(i,j-1);
	else if(dp[i][j]>0)
	{
		ans += s[i-1];
		print(i-1,j-1);
	}
}

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

	for (int i = 0; i < s.length()+1; ++i)
	{
		for(int j = 0; j < t.length()+1 ;j++)
		{
			dp[i][j] = -1;
		}
	}
	lcs(s.length(),t.length());
	print(s.length(),t.length());
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;


	
	return 0;
}

Measured memory_bytes: 47872
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int l =s.size();
    REP(i,l){
        if(s[i]!=t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
int main() {
	char s[50];
	S(s,s);
	P(c, s[0] == 'o' ? 'o' : s[strlen(s) - 1]);
	return 0;
}

Measured memory_bytes: 540
import math

n=int(input())
L=[list(map(int,input().split())) for _ in range(n)]
D=0
for i in range(n-1):
    for j in range(i+1,n):
        D += 2*math.factorial(n-1)*(((L[i][0]-L[j][0])**2 
        + (L[i][1]-L[j][1])**2)**0.5)
print(D/math.factorial(n))

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    ll X,Y,Z,tmp;
    cin>>X>>Y>>Z;
    cout<<Z<<" "<<X<<" "<<Y;
    return 0;
}

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

int n, m, p, a[7][7][7], h[7][7];
int dx[]{ 1,1,-1,0,0,0,0,1,1,1,1,-1,-1 };
int dy[]{ 0,0,0,1,-1,1,0,1,-1,1,-1,-1,1 };
int dz[]{ 0,1,1,1,1,0,1,0,0,1,1,1,1 };

bool judge() {
	rep(t, 13)rep(i, n)rep(j, n)rep(k, n) {
		int x = i, y = j, z = k;
		int back = a[i][j][k], cnt = 0;
		while (x >= 0 && x < n&&y >= 0 && y < n&&z < n) {
			if (back != a[x][y][z])cnt = 0;
			back = a[x][y][z];
			if (++cnt >= m&&back != -1)return 1;
			x += dx[t]; y += dy[t]; z += dz[t];
		}
	}
	return 0;
}
int main() {
	while (scanf("%d%d%d", &n, &m, &p), n) {
		memset(a, -1, sizeof(a));
		memset(h, 0, sizeof(h));
		bool ok = true;
		rep(i, p) {
			int x, y; scanf("%d%d", &x, &y); x--; y--;
			a[x][y][h[x][y]++] = i & 1;
			if (ok && judge()) {
				printf(i & 1 ? "White " : "Black ");
				printf("%d\n", i + 1);
				ok = false;
			}
		}
		if (ok)puts("Draw");
	}
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

const int MAX_N = 200005;

int n;
ll x[MAX_N], y[MAX_N];

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

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i];

	ll result = 0;
	for (ll p : {1, -1})
	{
		for (ll q : {1, -1})
		{
			ll smallest = p * x[0] + q * y[0];
			for (int i = 1; i < n; i++)
			{
				ll cur = p * x[i] + q * y[i];
				result = max(result, cur - smallest);
				smallest = min(smallest, cur);
			}
		}
	}
	cout << result << '\n';

	return 0;
}

Measured memory_bytes: 6784
#include <stdio.h>
int main()
{
    int N,x;
    scanf("%d", &N);
    x = N % 10;
    if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9 ){
        printf("hon\n");
    }
    else if(x == 0 || x == 1 || x == 6 || x == 8){
        printf("pon\n");
    }
    else{
        printf("bon\n");
    }
}


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

int main()
{
    int a[105],n;
    cin>>n;
    int i;
    for(i=1;i<=n;i++)
        cin>>a[i];
    int cnt=0;
    for(i=1;i<=n;i++){
        if(i%2&&a[i]%2)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

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

typedef complex<double> P;

int n;
P p[3000];

int comp(P a,P b){
  if(a.real()<b.real())return -1;
  if(a.real()==b.real()){
    if(a.imag()<b.imag())return -1;
    else if(a.imag()==b.imag())return 0;
  }
  return 1;
}

bool exist(P a){
  int lb = -1,ub = n;
  while(ub-lb>1){
    int mid = (ub+lb)/2;
    if(comp(p[mid],a)==0)return true;
    if(comp(p[mid],a)>0)ub = mid;
    else lb = mid;
  }
  if(!comp(p[ub],a) || !comp(p[lb],a))return true;
  return false;
}

int main(){
  while(scanf("%d",&n) && n){
    for(int i=0;i<n;i++)scanf("%lf %lf",&p[i].real(),&p[i].imag());

    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
	if(comp(p[i],p[j])>0)swap(p[i],p[j]);

    double ans = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i==j)continue;
	P n = (p[j]-p[i])*P(0,-1);
	if(exist(p[i]+n) && exist(p[j]+n))ans = max(ans,abs(n)*abs(n));
      }
    }
    printf("%d\n",(int)(ans+1e-6));
  }
}

Measured memory_bytes: 856
#include<stdio.h>
#include<math.h>
int main()
{
    int m,a[100];
    scanf("%d",&m);
    int x=m,i=0;
    while(x!=0)
    {
        int c,d,f;
        c=x/10;
        a[i]=x-c*10;
        x/=10;
        i++;
    }
    int j,s=0;
    for(j=0;j<i;j++) s+=a[j];
    if(m%s==0) printf("Yes\n");
    else printf("No\n");
}



Measured memory_bytes: 128
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let d: usize = sc.read();
    println!(
        "{}",
        match d {
            22 => "Christmas Eve Eve Eve",
            23 => "Christmas Eve Eve",
            24 => "Christmas Eve",
            25 => "Christmas",
            _ => unreachable!(),
        }
    );
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;

struct BIT
{
  vector< int > data;

  BIT(int sz) : data(++sz, 0) {}

  void set(int k, int x)
  {
    for(++k; k < data.size(); k += k & -k) data[k] = max(data[k], x);
  }

  int query(int k)
  {
    int ret = 0;
    for(++k; k > 0; k -= k & -k) ret = max(ret, data[k]);
    return (ret);
  }
};

int main()
{
  int N, A[100000], B[100000];
  vector< int > nums;

  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    scanf("%d %d", &A[i], &B[i]);
    nums.push_back(A[i]);
    nums.push_back(B[i]);
  }

  sort(begin(nums), end(nums));
  nums.erase(unique(begin(nums), end(nums)), end(nums));

  vector< vector< int > > add1(nums.size()), add2(nums.size());
  for(int i = 0; i < N; i++) {
    A[i] = lower_bound(begin(nums), end(nums), A[i]) - begin(nums);
    B[i] = lower_bound(begin(nums), end(nums), B[i]) - begin(nums);
    add1[A[i]].push_back(B[i]);
    add2[B[i]].push_back(A[i]);
  }

  BIT latte(nums.size()), malta(nums.size());
  for(int i = 0; i < nums.size(); i++) {
    vector< pair< int, int > > beet, uku;
    for(auto &s : add1[i]) beet.emplace_back(s, malta.query(s - 1) + 1);
    for(auto &s : add2[i]) uku.emplace_back(s, latte.query(s - 1) + 1);
    for(auto &s : beet) latte.set(s.first, s.second);
    for(auto &s : uku) malta.set(s.first, s.second);
  }

  printf("%d\n", max(latte.query(nums.size() - 1), malta.query(nums.size() - 1)));
}

Measured memory_bytes: 21600
n, k = map(int, input().split())
d = []
a = []
for _ in range(k):
    d.append(int(input()))
    a.append(list(map(int, input().split())))
    
o = set(range(1, n+1))
for i in a:
    for j in i:
        if j in o:
            o.remove(j)
print(len(o))

Measured memory_bytes: 9196
// AOJ Volume 1 Problem 0169 Blackjack

#include <stdio.h>

int main(void)
{
    char str[1000];
    int card[1000];
    int card_num;
    int i;
    int point;
    int ace_flag;

    while (1){
        fgets(str, 1000, stdin);
        
        if (str[0] == '0'){
            break;
        }
        card_num = 1;
        card[0] = 0;
        i = 0;
        while (str[i] != '\n'){
            if (str[i] == ' '){
                card_num++;
                card[card_num - 1] = 0;
            }
            else {
                card[card_num - 1] = card[card_num - 1] * 10 + str[i] - '0';
            }
            i++;
        }
        
        point = 0;
        ace_flag = 0;
        
        for (i = 0; i < card_num; i++){
            if (card[i] > 10){
                point += 10;
            }
            else {
                point += card[i];
            }
            if (card[i] == 1){
                ace_flag = 1;
            }
        }
        if (point <= 11 && ace_flag == 1){
            point += 10;
        }
        if (point > 21){
            point = 0;
        }
        printf("%d\n", point);
    }
    
    return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	int ans;
	if (n == 2) ans = a[1];
	else {
		for (int i = a[1]; i > 0; --i) {
			int flag = 0;
			for (int j = 0; j < n; ++j) {
				if (a[j] % i) flag++;
				if (flag > 1) break;
			}
			if (flag < 2) {
				ans = i;
				break;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
  int n;
  cin >> n;
  double a=2*n*3.1415926;
  pt(a);
  return 0;
}

Measured memory_bytes: 3784
#include<stdio.h>

int main(void)
{
	int a,b;

	scanf("%d %d",&a,&b);

	if(a < b){
	printf("a < b\n");	
	}

	else if(a > b){
	printf("a > b\n");
	}	
	else{
	printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Bits ((.&.), (.|.), shift, rotate, testBit)
import Data.Array.Unboxed

main :: IO ()
main = do
  getLine
  solve <$> getLine >>= print

solve :: String -> Int
solve xs = flip mod mv $ sum $ elems $ foldl g ia ys
  where
    (y:ys) = map f xs
    f x
      | x == 'J' = 2
      | x == 'O' = 1
      | otherwise = 0
    ia = accumArray (+) 0 (1,7) [(i,1)|i <- [4..7], testBit i y] :: UArray Int Int
    g :: UArray Int Int -> Int -> UArray Int Int
    g a x = accumArray (\p q -> (p + q) `mod` mv) 0 (1,7) [(i, a ! j) | i <- [1..7], j <- [1..7], testBit i x, i .&. j /= 0]
      
toInt :: String -> Int
toInt = read

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

mv :: Int
mv = 10007

Measured memory_bytes: 5572
"use strict"

const Main =(nyuuryoku)=>{
const Array=nyuuryoku.split("\n")
const N = Array[0]-0
const colorArray=Array[1].split(" ")

const isyellow=colorArray.some((ele=>{return ele=="Y"}))

console.log(isyellow?"Four":"Three")
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 20808
#[allow(dead_code)]
fn scan<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn scan_split<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_split_with<T: std::str::FromStr>(ch: char) -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split(ch)
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_lines<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| scan::<T>()).collect()
}

#[allow(unused_macros)]
macro_rules! scan_as_tuple {
    ( $t:ty ) => {
        (scan::<$t>(),)
    };
    ( $( $t:ty ),* ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok();
            let v = s.trim().split_whitespace();
            let mut it = v;
            let ret = ( $(it.next().unwrap().parse::<$t>().ok().unwrap()),* );
            assert!(it.next() == None, "not all tokens consumed");
            ret
        }
    };
}

fn main() {
    let (a, b) = scan_as_tuple![i32, i32];
    println!("{}", (a+b)%24);
}

Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N,M,K;
    cin >> N >> M >> K;
    lint A[N],B[M];
    rep(i,N) cin >> A[i];
    rep(i,M) cin >> B[i];
    lint Asum[N+1]={};
    lint Bsum[M+1]={};
    rep(i,N) Asum[i+1]=Asum[i]+A[i];
    rep(i,M) Bsum[i+1]=Bsum[i]+B[i];
    lint ans=0;
    rep(i,N+1){
        lint rem=K-Asum[i];
        lint cmp=i;
        if(rem<0) continue;
        cmp+=upper_bound(Bsum,Bsum+M+1,rem)-Bsum-1;
        ans=max(ans,cmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9864
#include<stdio.h>

int main(){

int D,N;
scanf("%d%d",&D,&N);
if (N==100)N++;

switch (D)
{
case 0:
  printf("%d",N);
  break;
case 1:
  printf("%d",N*100);
  break;
case 2:
  printf("%d",N*10000);
  break;

default:
  break;
}

return 0;

}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif

int n,k;
cin>>n>>k;
int j=1;
double ans = 0;
forn(i,1,n){
    double fraccion = (double)1.0/n;
    int aux=j;
    while(aux<k){
        aux*=2;
        fraccion/=2;
        //cout<<fraccion<<endl;
    }
    ans+=fraccion;
        j++;
}
//cout<<ans<<endl;
cout << fixed << setprecision(9) <<ans<<endl;
}


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

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

}

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

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	int alice = a, borys = b;
	int flag = 1;

	while(true){
		if(a == 1 && b == 2 && flag == 1){
			cout << "Borys" << endl;
			return 0;
		}
		if(a == n - 1 && b == n && flag == 2){
			cout << "Alice" << endl;
			return 0;
		}

		if(flag == 1 && b > a + 1){
			a++;
			flag = 2;
		}
		else if(flag == 1 && b == a + 1) {
			a--;
			flag = 2;
		}
		else if(flag == 2 && a < b - 1) {
			b--;
			flag = 1;
		}else if(flag == 2 && a == b - 1){
			b++;
			flag = 1;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;
long long a[2001] = {};
long long t[2001][2001];
long long acc_t[2001][2001];
long long g[2001][2001];
long long N, x;
vector<long long> rest_transform[2001];
long long result = 0;

int main(){

  cin >> N >> x;
  for (int j=0;j<N;j++) {
    long long aa;
    cin >> aa;
    acc_t[0][j] = aa;
    g[0][j] = aa;
    /*    for (int j=0;j<N;j++) {
      t[(N+i-j)%n][j] = a + ((N+i-j)%N)*x;
      }*/
  }

  
  for (int j=0;j<N;j++) {
    for (int k=1;k<N;k++) {
      if (g[k-1][j] > g[0][(N+j-k)%N]) {
	g[k][j] = g[0][(N+j-k)%N];
      } else {
	g[k][j] = g[k-1][j];
      }
    }
  }

  // for (int j=0;j<10;j++) {
  //   for (int k=0;k<10;k++) {
  //     cout << g[k][j] << "\t";
  //   }
  //   cout << endl;
  // }

  
  long long result_min = 100000000000000;
  //  cout << result_min << endl;
  for (int k = 0;k<N;k++) {
    long long result_tmp = k*x;
    for (int j=0;j<N;j++) {
      //      cout << g[k][j] << endl;
      result_tmp += g[k][j];
    }
    //    cout << result_tmp << endl;
    if (result_tmp < result_min) {
      result_min = result_tmp;
    }
  }
  cout << result_min << endl;
  return(0);
}


Measured memory_bytes: 33024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>



/*以下便利なマクロを定義する。*/

#define refor(i, min, max) for(i=min; i<=max; i=i+1)



#define if_forall(i, min, max, prop)\
	bool if_forall_condition=1;\
\
	for(i=min; i<=max; i=i+1)\
	{\
		if(!(prop))\
		{\
			if_forall_condition=0;\
			break;\
		}\
	}\
\
	if(if_forall_condition==1)\



#define if_exists(i, min, max, prop)\
	bool if_exists_condition=0;\
\
	for(i=min; i<=max; i=i+1)\
	{\
		if(prop)\
		{\
			if_exists_condition=1;\
			break;\
		}\
	}\
\
	if(if_exists_condition==1)\











/*以下便利な関数を定義する。*/



void ini_int(int a[], int num)
{
	int i=0;

	for(i=0; i<=num; i=i+1)
	{
		a[i]=0;
	}

}



void ini_char(char array[], int num)
{
	int i=0;

	for(i=0; i<=num; i=i+1)
	{
		array[i]='\0';
	}

}



int powi(int base, unsigned int exponent)
{
	int answer=1;

	answer=(int)pow((double)base, (double)exponent);

	return answer;
}



void sort_asc_int(int a[], int min, int max)
{
	int i, j;
	int dumy;

	for(i=min; i<=max; i=i+1)
	{
		for(j=i+1; j<=max; j=j+1)
		{
			if(a[i]>a[j])
			{
				dumy=a[i];
				a[i]=a[j];
				a[j]=dumy;
			}
		}
	}
}



void sort_des_int(int a[], int min, int max)
{
	int i, j;
	int dumy;

	for(i=min; i<=max; i=i+1)
	{
		for(j=i+1; j<=max; j=j+1)
		{
			if(a[i]<a[j])
			{
				dumy=a[i];
				a[i]=a[j];
				a[j]=dumy;
			}
		}
	}
}



int max(int a, int b)
{
	int answer=a;
	if(a<b)
	{
		answer=b;
	}

	return answer;
}



int min(int a, int b)
{
	int answer=a;
	if(a>b)
	{
		answer=b;
	}

	return answer;
}



int max_int(int a[], int min, int max)
{
	int i;
	int answer;

	answer=a[min];

	for(i=min+1; i<=max; i=i+1)
	{
		if(answer<a[i])
		{
			answer=a[i];
		}
	}

	return answer;
}



int min_int(int a[], int min, int max)
{
	int i;
	int answer;

	answer=a[min];

	for(i=min+1; i<=max; i=i+1)
	{
		if(answer>a[i])
		{
			answer=a[i];
		}
	}

	return answer;
}



bool containelement_int(int array[], int min, int max, int element)
{
	int i;
	bool answer=0;

	if_exists(i, min, max, array[i]==element)
	{
		answer=1;
	}

	return answer;
}



int count_differentelement_int(int array[], int min, int max)
{
	int i=min;
	int pickup[max];
	ini_int(pickup, max);
	int answer=0;

	for(i=min; i<=max; i=i+1)
	{
		if(containelement_int(pickup, 0, answer-1, array[i])==0)
		{
			pickup[answer]=array[i];
			answer=answer+1;
		}
	}

	return answer;
}



int count_equalelement_int(int array[], int min, int max, int element)
{
	int i;
	int answer=0;

	for(i=min; i<=max; i=i+1)
	{
		if(array[i]==element)
		{
			answer=answer+1;
		}
	}

	return answer;
}











int main()
{

	int i=1;
	int N, K, X, Y;

	scanf("%d %d %d %d", &N, &K, &X, &Y);

	printf("%d\n", X*min(N, K)+Y*max(0, N-K));
	return 0;

}


Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().strip()

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

dist = 0
start = -1
for i in range(N - 1):
    a = A[i + 1]
    pre = A[i]
    if dist < a - pre:
        dist = a - pre
        start = i

if dist < A[0] + (K - A[N - 1]):
    dist = A[0] + (K - A[N - 1])
    start = N - 1

print(K - dist)

Measured memory_bytes: 73332
N, K = map(int, input().split())
A = list(map(int, input().split()))
foo = [[0 for k in range(N)] for k in range(42)]
for k in range(len(A)):
    foo[0][k] = A[k]
if K <42:
    for q in range(K):
        unko = [0 for k in range(N)]
        for k in range(N):
            if k + foo[q][k]+1 < N:
                unko[k + foo[q][k]+1] -=1
            unko[max(k - foo[q][k], 0)] +=1
        unchi = 0
        for k in range(N):
            unchi += unko[k]
            foo[q+1][k] = unchi
        #print(unko)
        #print(foo[q+1])
        count =0
        for l in range(N):
            if foo[q+1][l] < N:
                break
            else:
                count +=1
        
        if count == N:
            break
        
                        
        #print(foo)
    print(" ".join(map(str, foo[q+1])))

     
else:
    print((str(N)+" ")*(N-1)+str(N))




Measured memory_bytes: 226228
#include<stdio.h>
int main(void)
{
    int n,x,y,b,p,i,k,s,m,r,j;
	scanf("%d",&n);
	for (i=0;i<n;i++){
	    scanf("%d %d",&x,&y);
		scanf("%d %d",&b,&p);
		k=x*b+y*p;
		m=x*5+y*p-(x*2/10)*5-(y*2/10)*p;
		r=x*b+y*2-(x*2/10)*b-(y*2/10)*2;
		if (b>=5&&p>=2){
		    s=x*b+y*p-(x*2/10)*b-(y*2/10)*p;
		    printf("%d\n",s);
		}
		else if (p>=2&&m<k){
		    printf("%d\n",m);
		}
		else if (b>=5&&r<k){
		    printf("%d\n",r);
		}
		else {
		    printf("%d\n",k);
		}
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

const int MAX = 10;
int N, M;
int cost[MAX][MAX];
VI graph[MAX];
LL dp[1 << MAX][MAX];

int main(void) {
    scanf("%d%d", &N, &M);
    REP(i, M) {
        int a, b;
        scanf("%d%d", &a, &b);
        a--;b--;
        cost[a][b] = 1;
        cost[b][a] = 1;
    }
    dp[1][0] = 1;
    REP(i, 1 << N) {
        REP(j, N) {
            REP(k, N) if (cost[j][k] && ((i & (1 << k)) == 0)) {
                dp[i | (1 << k)][k] += dp[i][j];
            }
        }
    }
    LL ans = 0;
    FOR(i, 1, N) {
        ans += dp[(1 << N) - 1][i];
        //cout<<i<<" "<<ans<<endl;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
A,B,C = map(int,input().split(' '))


ans = 0

if C == A+B:
    ans = B +C
if C < A+B:
    ans = C +B
if C > A+B:
    ans = A
    C = C -A
    if C >= B:
        ans = ans + B + B + 1
    elif C < B:
        ans = ans + C +B
        
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<queue>
#include<cmath>
#define LL long long
using namespace std;
inline int read( )
{
  int sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
const int N=500005;
int n,d[N],f[N],g[N];
int main( )
{
  int i,j;
  n=read( );f[0]=read( );g[n+1]=1;
  for(i=1;i<=n;i++) d[i]=read( );
  for(i=1;i<=n;i++) f[i]=min(f[i-1],abs(f[i-1]-d[i]));
  for(i=n;i>=1;i--) g[i]=g[i+1]+(g[i+1]<=(d[i]>>1)?0:d[i]);
  int T=read( );
  while(T--) j=read( ),puts(g[j+1]<=f[j-1]?"YES":"NO");
  return 0;
}

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

int main() {
  string S = "";
  cin >> S;
  
  int dp[13] = {};
  dp[0] = 1;
  int mod = 1000000007;
  int d = 1;
  for (int i = S.length() - 1; i >= 0; i--)
  {
    int dp2[13] = {};
    char c = S[i];
    if (c == '?')
    {
      for (int n = 0; n <= 9; n++)
      {
        for (int m = 0; m <= 12; m++)
        {
          dp2[(n * d + m) % 13] += dp[m];
          dp2[(n * d + m) % 13] %= mod;
        }
      }
    }
    else
    {
      int k = c - '0';
      for (int m = 0; m <= 12; m++)
      {
        dp2[(k * d + m) % 13] += dp[m];
        dp2[(k * d + m) % 13] %= mod;
      }
    }
    for (int l = 0; l < 13; l++)
    {
      dp[l] = dp2[l];
    }
    d *= 10;
    d %= 13;
  }
  
  cout << dp[5] << endl;
  return 0;
}

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


using namespace std;



int main() {
    long long k; cin >> k;

    queue<long long> q;
    for (long long i=1; i<=9; i++) q.push(i);

    long long cnt = 0;
    long long t, s;
    vector<long long> ns;
    while (true) {
        t = q.front(); q.pop();
        s = t - ((t / 10) * 10);

        if (s == 0) ns = {0, 1};
        else if (s == 9) ns = {8, 9};
        else ns = {s-1, s, s+1};

        for (long long n: ns) {
            q.push(t*10 + n);
        }

        cnt++;
        if (cnt == k) {
            cout << t << endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e5 + 5;
const ll mod = 1e9 + 7;
ll add(ll x, ll y) {
  x = x%mod;
  y = y%mod;
  x = x + y;
  x = x%mod;
  while (x<0) x+=mod;
  return x;
}
int n,m;
ll dp[maxn];
int broken[maxn];
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  
  cin>>n>>m;
  for (int i=0; i<m; i++) {
    int x; cin>>x; broken[x] = 1;
  }
  dp[0] = 1;
  for (int i=0; i<n; i++) {
    if (broken[i]) continue;
    dp[i+1] = add(dp[i+1], dp[i]);
    dp[i+2] = add(dp[i+2], dp[i]);
  }

  cout<<dp[n]<<endl;
  
  return 0;
}



Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[11];
int n;
cin>>n;
for(int i=0;i<=n;i++){
	cin>>a[i];
	
}
sort(a,a+n);
int sum=0;
for(int i=0;i<n-1;i++){
	sum+=a[i];
}
sum+=a[n-1]/2;
printf("%d",sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD (int)(1e9+7)
#define INF 0x3f3f3f3f
#define MAXN (int)(1e5+1)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
int match[21][21];
int main()
{
	fastio;
	int n;cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			cin>>match[i][j];
	}
	//dp[i][mask] represent number of ways to match subset women(mask) with upto 0 to i men
	//for i+1 iterate over masks then jth women 
	//if jth women can pair with ith men
	//dp[i+1][mask^(1<<j)]+=dp[i][mask]
	//else dp[i+1][mask]+=dp[i][mask]//dont pair ith men(note if we iterate mask big to small then this will be first update of dp[i+1][mask])
	vector<int> dp(1<<n);
	dp[0]=1;
	for(int i=0;i<n;i++)//ith men
	{
		for(int mask=(1<<n)-1;mask>=0;mask--)
		{
			if(dp[mask]==0)continue;
			for(int j=0;j<n;j++)
			{
				if(match[i][j] && !(mask&(1<<j)))
				{
					dp[mask^(1<<j)]=addmod(dp[mask^(1<<j)],dp[mask]);
				}
			}
		}
	}  
	cout<<dp[(1<<n)-1]<<endl;
}


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

int main() {
  int a, b, c;
  int n[3];
  for(int i = 0; i < 3; i++) cin >> n[i];
  sort(n, n + 3);
  cout << (n[0]==5 && n[1]==5 && n[2]==7 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

#include <deque>

#include <cassert>

#include <memory>

using namespace std;

typedef unsigned long long LL;

int n;

LL ans;

int main() {

   
    cin >> n;

    while (n >= 500) {
        n-=500;
        ans += 1000;
    }

    while (n >= 5) {
        n -= 5;
        ans += 5;
    }

    cout << ans << endl;
    

}

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

const int Maxn=10;

int N,G,P[Maxn+5],C[Maxn+5];

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d %d",&N,&G);
	for(int i=1;i<=N;i++)
		scanf("%d %d",&P[i],&C[i]);
	int ans=1e9;
	for(int s=0;s<(1<<N);s++) {
		int sum=0,val=0,x=-1;
		for(int i=1;i<=N;i++)
			if(s&(1<<(i-1))) {
				val+=P[i]*100*i+C[i];
				sum+=P[i];
			} else x=i;
		if(val<G) {
			int tmp=100*x;
			int ned=ceil(1.0*(G-val)/tmp);
			if(ned>=P[x])
				continue;
			sum+=ned;
		}
		ans=min(ans,sum);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc =  new Scanner(System.in);
		while(sc.hasNext()) {
			int  a = sc.nextInt();
			int b = sc.nextInt();
			int x,y;
			int temp = 0;
			if (a < b) {
				x = b;
				y = a;
			} else {
				x = a;
				y = b;
			}
			while(b != 0) {
				temp = b;
				b = a % b;
				a = temp;
			}
			System.out.println(a + " " + (x * (y / a)));
		}
	}
}

Measured memory_bytes: 17216
#include <iostream>
#include <math.h>

using namespace std;

int main(void){
  long long N;
  cin >> N;
  long long square_N = sqrt(N);
  long A = 1;
  //cout << square_N << endl;
  for(long i = 1; i<=square_N; i++){
    if (N%i == 0){
      A = i;
    }
  }
   long B = N/A;
   cout << to_string(B).length() << endl;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			int d = scanner.nextInt();
			System.out.println(Math.min(a, b) + Math.min(c, d));
		}
	}
}


Measured memory_bytes: 21844
using System;

namespace Volume6_0652
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] vs = Console.ReadLine().Split(' ');
			long a = long.Parse(vs[0]);
			long b = long.Parse(vs[1]);
			long c = long.Parse(vs[2]);

			int login = 0;
			long i = 0L;

			while(i < c) {
				i += a;
				if(++login % 7 == 0) {
					i += b;
				}
			}

			Console.WriteLine(login);
		}
	}
}



Measured memory_bytes: 17968
N = int(input())
AB = [list(map(int,input().split())) for _ in range (N)]
MOD = 10**9+7

from collections import defaultdict
from math import gcd
def cmp(x,y):
    g = gcd(abs(x),abs(y))
    if x*y<0:
        return (-abs(x)//g, abs(y)//g)
    else:
        return (abs(x)//g, abs(y)//g)
def rev(x):
    # x = (a,b)
    # ret = (-b,a)
    a = x[0]
    b = x[1]
    if a<0:
        return (abs(b), abs(a))
    else:
        return (-abs(b), abs(a))

dnums = defaultdict(int)
dnums2 = defaultdict(int)
num_zero = 0
num_az = 0
num_bz = 0
keys = set()
for a,b in AB:
    if a!=0 and b!=0:
        k1 = cmp(a,b)
        dnums[k1] += 1
        keys.add(k1)
    elif a==0 and b==0:
        num_zero += 1
    elif a == 0 and b!=0:
        num_az += 1
    elif a != 0 and b==0:
        num_bz += 1

mydict = dict()
for key in list(keys):
    mydict[key] = False

ans = 1
for key in list(keys):
    if mydict[key]:
        continue
    rkey = rev(key)
    if rkey in keys:
        mydict[rev(key)] = True
        mydict[key] = True

    ans *= pow(2, dnums[key], MOD) + pow(2, dnums[rkey], MOD) - 1
    ans %= MOD

ans *= pow(2, num_az, MOD) + pow(2, num_bz, MOD) - 1
ans += num_zero
ans += MOD - 1
print(ans%MOD)



Measured memory_bytes: 184708
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    int a,b;
    cin>>a>>b;
    if(a<=5)b=0;
    else if(a<=12)b/=2;
    cout<<b<<endl;
    return 0;
}


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

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

using namespace std;

int main(){
	int n,q; scanf("%d%d",&n,&q);

	vector<int> deg(n);
	rep(_,q){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		deg[u]++;
		deg[v]++;
	}

	bool ok=true;
	rep(u,n) if(deg[u]%2==1) ok=false;
	puts(ok?"YES":"NO");

	return 0;
}


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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;

int l[Sz], r[Sz];
     
ll solve (int par) {
  static set <pii> L, R;
  for (int i = 1; i <= n; i++)
    L.insert (mp (l[i], i)), R.insert (mp (r[i], i));
  
  ll ans = 0;
  int cur = 0;
  for (int k = 1; k <= n; k++) {
    int i;
    if ((k & 1) == par)    
      i = L.rbegin()->y;
    else
      i = R.begin()->y; 
    
    L.erase (mp (l[i], i));
    R.erase (mp (r[i], i));

    if (cur < l[i])
      ans += abs (cur - l[i]), cur = l[i];
    else  if (cur > r[i]) 
      ans += abs (cur - r[i]), cur = r[i];
  }
  ans += abs (cur);
   
  return ans;
}
                  
int main()
{                                  
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> l[i] >> r[i];
  
  cout << max (solve (0), solve (1));




  return 0;
}






// Coded by Z..



Measured memory_bytes: 12032