akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cassert>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb         push_back

const double eps  = 1e-10;
const int inf = (1 << 21);

class state{
public:
  int t,now,ori;
  int cnt;
  bool operator<(const state & a)const{
    if (now*a.t != a.now*t)return now*a.t < a.now*t;
    return t > a.t;
  }
};

int solve(int n,vector<state>& in){
  int ans=0;
  sort(ALL(in));
  int m= n;

  while(n){
    int mint = inf;
    rep(i,n){
      //      cout << in[i].now <<" " << in[i].t <<" " << in[i].now%in[i].t << " " 
      //	   << in[i].t-in[i].now%in[i].t << endl;
      mint = min(mint,in[i].t-in[i].now%in[i].t);
    }
    
    //    cout << "first step mint " << mint << endl;
    rep(i,n){
      in[i].now+=1;
      int tnow=in[i].now-1,tt=in[i].t;
      rep(j,n){
	if (i == j)continue;
	if ((tnow)*in[j].t >=(in[j].now)*tt)continue;
	if (in[i].t <= in[j].t)continue;
	//	double t = (in[j].now-in[i].now)/(double)(in[j].t-in[i].t);
	double t = (in[i].t*in[j].t)*(in[j].now-in[i].now)/(double)(in[j].t-in[i].t);
	if (t <0)continue;
	if (t < mint){
	  //	  cout << mint <<" cmpt " << t << endl;
	  mint=(int)(t+1);
	}
      }
      in[i].now-=1;
    }
    
    //    cout << ans <<" tt " << mint << endl;

    rep(i,n){
      in[i].now+=mint;
      int tnow=in[i].now-mint,tt=in[i].t;
      rep(j,n){
	if (i == j)continue;
	if ((tnow)*in[j].t >=(in[j].now)*tt)continue;
	if ((in[i].now)*in[j].t >= (in[j].now+mint)*in[i].t){
	  in[i].now=in[j].now+mint;
	  in[i].t=in[j].t;
	}
      }
      in[i].now-=mint;
    }
    
  
    /*
      rep(i,n){
      in[i].now+=1;
      int tnow=in[i].now-1,tt=in[i].t;
      rep(j,n){
	if (i == j)continue;
	if ((tnow)*in[j].t >=(in[j].now)*tt)continue;
	if ((in[i].now)*in[j].t >= (in[j].now+1)*in[i].t){
	  in[i].now=in[j].now+1;
	  in[i].t=in[j].t;
	  mint=1;
	}
      }
      in[i].now-=1;
    }
    */
    

    rep(i,n){
      in[i].now+=mint;
    }

    rep(i,n){
      if (in[i].now%in[i].t == 0){
	if (in[i].now/in[i].t == 1){
	  in[i].t=in[i].ori;
	  in[i].now=in[i].ori;
	}else if (in[i].now/in[i].t==2){
	  in[i].t=in[i].ori;
	  in[i].now=0;
	  in[i].cnt--;
	  if (in[i].cnt == 0)in[i].now=inf,m--;
	}
      }
    }
    


    sort(ALL(in));
    for(int i=n-1;i>=0;i--){
      if (in[i].now == inf)n--;
    }
    ans+=mint;
  }
  return ans;
}

main(){
  int n;
  while(cin>>n && n){
    vector<state> in;
    rep(i,n){
      int t;
      int lap;
      cin>>t>>lap;
      in.pb((state){t,0,t,lap});
    }
    cout << solve(n,in) << endl;
  }
}

Measured memory_bytes: 908
/*
cat <<EOF >mistaken-paste
*/

#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

#define BIG 2000000007
#define VERYBIG 200000000000007LL

#define MOD 1000000007
typedef uint64_t ull;
typedef  int64_t sll;

#define N_MAX 100000
#define M_MAX 200000

typedef struct {
	int32_t a;
	int32_t b;
} hw;

typedef struct {
	sll a;
	sll b;
} hwll;

typedef struct {
	hwll a;
	hwll b;
} linell;


typedef struct {
	ull s;
	ull t;
	int32_t c;
} struct_a;

typedef struct {
	int32_t from;
	int32_t to;
	sll cost;
} struct_b;

ull n, m;
ull h, w;
ull k;
ull q;
ull vua, vub, vuc, vud, vue, vuf;
sll vsa, vsb, vsc, vsd, vse, vsf;
long double vra, vrb, vrc;
double vda, vdb, vdc;
size_t slen;
size_t tlen;
char ch, dh;

ull a[N_MAX];
ull dp[N_MAX + 1];
hwll arr[N_MAX];

hwll unionpresident[N_MAX];
bool ispres[N_MAX];

int32_t pullcomp (const void *left, const void *right) {
	ull l = *(ull*)left;
	ull r = *(ull*)right;
	if (l < r) {
		return -1;
	}
	if (l > r) {
		return +1;
	}
	return 0;
}

ull rank[N_MAX];
ull parent[N_MAX];

void uf_init (ull n) {
	for (sll i = 0; i < n; i++) {
		rank[i] = 0;
		parent[i] = i;
	}
}

ull uf_find (ull x) {
	if (parent[x] == x) return x;
	return parent[x] = uf_find(parent[x]);
}

void uf_union (ull a, ull b) {
	ull ap = uf_find(a);
	ull bp = uf_find(b);
	if (ap == bp) return;

	if (rank[ap] > rank[bp]) {
		parent[bp] = ap;
	} else {
		parent[ap] = bp;
		if (rank[ap] == rank[bp]) {
			rank[bp]++;
		}
	}
	return;
}

ull solve () {
	sll i, j, ki;
	sll result = 0;

	if (m + n / 2 < n - 1) goto fail;

	uf_init(n);
	for (i = 0; i < n; i++) {
		uf_union(arr[i].a, arr[i].b);
	}

	ull roots = 0;
	for (i = 0; i < n; i++) {
		unionpresident[i].a = BIG;
		unionpresident[i].b = BIG;
	}
	for (i = 0; i < n; i++) {
		ull root = uf_find(i);
		if (a[i] < unionpresident[root].a) {
			unionpresident[root].a = a[i];
			unionpresident[root].b = i;
		}
	}

	sll s1 = 0;
	for (i = 0; i < n; i++) {
		if (unionpresident[i].a == BIG) continue;
		ispres[unionpresident[i].b] = true;
		dp[s1++] = unionpresident[i].a;
	}
	sll s2 = 0;
	for (i = 0; i < n; i++) {
		if (ispres[i]) continue;
		dp[s1 + s2++] = a[i];
	}
	qsort(dp, s1, sizeof(ull), pullcomp);
	qsort(dp + s1, s2, sizeof(ull), pullcomp);

	for (i = 0; i < (n - 1 - m) * 2; i++) {
		result += dp[i];
	}

	printf("%llu\n", result);

	return 0;

	fail:
	puts("Impossible");
	return 1;
}

int32_t main (void) {
	int32_t i, j;
	int32_t x, y;

	scanf("%llu%llu", &n, &m);
	for (i = 0; i < n; i++) {
		scanf("%llu", &a[i]);
	}
	for (i = 0; i < m; i++) {
		scanf("%llu", &arr[i].a);
		scanf("%llu", &arr[i].b);
	}

	solve();

	return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T){
    for (size_t i= 0;i<S.size();i++){
        if (S[i] != T[i]) {
            printf("No\n");
            return;
        }
    }
    printf("Yes\n");

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    int b;
    for (int i = 0; i < K; i++) {
        cin >> b;
        for (int j = 0; j < b; j++) {
            int t;
            cin >> t; t--;
            a[t]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) if (a[i] == 0) ans++;
    cout << ans << '\n';
}


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

int main(){
  int S;
  cin >> S;
  int s3 = S % 10;
  int s2 = (S - s3)/10 % 10;
  int s1 = (S - s3 - s2 * 10)/100 % 10;
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll maxm = 200000;
int main()
{
	ll n,w;
	cin>>n>>w;
	ll weight[n+1],val[n+1];
	for(ll i = 1;i<=n;i++)
		cin>>weight[i]>>val[i];
	ll dp[maxm+1];
	for(int i = 1;i<=maxm;i++)
		dp[i] = INT_MAX;
	dp[0] = 0;
	for(int i = 1;i<=n;i++)
	{
		for(int j = maxm;j>=0;j--)
		{
			if(dp[j]!=INT_MAX && dp[j]+weight[i]<=w)
			{
				dp[j+val[i]] = min(dp[j+val[i]],dp[j]+weight[i]);
			}
		}
	}
	int ans = 0;
	for(int i = 1;i<=maxm;i++)
	{
		if(dp[i]!=INT_MAX)
			ans = i;
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define nl n<<1
#define nr (n<<1)  1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
const ll mod=1e9+7;
vector<int>vec[200010];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int flag=0;
    for(int i=1;i<=m;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        vec[a].push_back(b);
    }
    for(int i=0;i<vec[1].size();i++)
    {
        int j=vec[1][i];
        for(int k=0;k<vec[j].size();k++)
        {
            if(vec[j][k]==n)
            {
                flag=1;
                break;
            }
        }
        if(flag)
            break;
    }
    if(flag)
    {
        printf("POSSIBLE\n");
    }
    else
    {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}







//#include<bits/stdc++.h>
//using namespace std;
//typedef long long ll;
//char s1[30],s2[100010],s3[100010];
//int vis[205];
//int main()
//{
//    scanf("%s%s",s1,s2);
//    int l1=strlen(s2);
//    for(int i=0;i<strlen(s1);i++)vis[s1[i]]=1;
//    int q;scanf("%d",&q);
//    while(q--)
//    {
//        scanf("%s",s3);
//        int l2=strlen(s3);
//        if(l1-l2>1)
//        {
//            printf("NO\n");continue;
//        }
//    }
//    return 0;
//}


Measured memory_bytes: 8576
import java.lang.Math.*

fun main(args:Array<String>):Unit {
    val n = readLine()!!.trim().toInt()
    repeat(n){
        val (r, t) = readLine()!!.trim().split(' ').map(String::toInt)
        println(measurePoint(r, t).sorted().joinToString(" "))
    }
}
fun measurePoint(distance:Int, angle:Int):Iterable<Int> {
    return (if (distance % 100 == 0)
        listOf(distance / 100)
    else
        listOf(distance / 100, (distance + 100) / 100)).flatMap{d ->
        (if (angle % 30 == 0)
            listOf(angle / 30)
        else
            listOf(angle / 30, (angle + 30) / 30)).map{it * 5 + d}
    }
}


Measured memory_bytes: 32100
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n, k = f.read_int_list()
    a = [f.read_int() for _ in xrange(n)]

    s = [0] * (n+1)
    for i in xrange(n):
        s[i+1] = s[i] + a[i] - k

    ss = compress(s)

    ans = 0
    bit = BinaryIndexedTree(n+1)
    for si in ss:
        ans += bit.sum(si+1)
        bit.add(si+1, 1)

    return ans


def compress(ary):
    d = dict(zip(sorted(set(ary)), range(len(ary))))
    return [d[item] for item in ary]


class BinaryIndexedTree(object):
    """Binary Indexed Tree (1-indexed)"""
    def __init__(self, size, default=0):
        self.bit = [default for _ in range(size + 1)]
        self.size = size

    def sum(self, i):
        """sum 1 to i"""
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, x):
        """add x to bit[i]"""
        while i <= self.size:
            self.bit[i] += x
            i += i & -i


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define dump(x) cout << #x << " = " << (x) << endl
#define vuniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define minse(m, s) m.insert(make_pair(s, 1));
#define mfin(m, s) m.find(s) != m.end()

#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9 + 7;

int main(){
    ll n;
    cin >> n;
    
    ll ans = (n - 1) * n / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
N,M=list(map(int,input().strip().split(" ")))
keys=[]
want=2**N-1
for _ in range(M):
    a,b=list(map(int,input().strip().split(" ")))
    c=list(map(int,input().strip().split(" ")))
    temp=0
    for i in c:
        temp+=2**(i-1)
    keys+=[(a,temp)]

dp=[float("inf")]*(2**N)
dp[0]=0
for i in range(len(dp)):
    for j in range(len(keys)):
        price,val=keys[j]
        if i&val==0:
            continue
        dp[i]=min(dp[i-(i&val)]+price,dp[i])
        #print(keys[j])
        #print(dp[i],i,i&val)        
#print(keys)
#print(dp)
if dp[-1]==float("inf"):
    print(-1)
else:
    print(dp[-1])




Measured memory_bytes: 47064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

int N;
P red[110],blue[110];
//それぞれのblueのどのredとれるか
int used_a[110];
int used_b[110];
int ans;
int main(){
  cin>>N;
  rep(i,N){
    cin>>red[i].second>>red[i].first;
  }
  rep(i,N){
    cin>>blue[i].first>>blue[i].second;
  }
  sort(red,red+N);
  reverse(red,red+N);
  sort(blue,blue+N);
  rep(i,N){
    rep(j,N){
      if(!used_a[j]&&!used_b[i]&&blue[i].first>red[j].second && blue[i].second>red[j].first){
        used_a[j]=true;
        used_b[i]=true;
        ans++;
      }
    }
  }

  cout<<ans<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
pair<int, int> a[1010];
int mem[10010][1010], p[10010];
int dp(int x, int num){
    if(num<=0){
        return 0;
    }
    if(x<0){
        return 1e9;
    }
    if(mem[num][x]!=-1){
        return mem[num][x];
    }
    int res=dp(x-1, num), tmp;
    for(int i=a[x].fs, j=a[x].sc; i<=num; i+=a[x].fs,j+=a[x].sc){
        tmp=j+dp(min(x-1, p[num-i]), num-i);
        if(tmp<res)
            res=tmp;
    }
    res=min(res, num/a[x].fs*a[x].sc+a[x].sc);
    mem[num][x]=res;
    return res;
}
int main(){
    int n, h;
    while(cin>>h>>n){
        int ans=0;
        int x, y;
        for(int i=0; i<n; ++i){
            scanf("%d%d",&x, &y);
//x=i+1;y=i+2;
            a[i]=mk(x, y);
        }
        sort(a, a+n);
        for(int i=0; i<n; ++i){
            if(a[i].fs==-1){
                continue;
            }
            for(int j=i+1; j<n; ++j){
                if(a[j].fs==-1){
                    continue;
                }
                if(((a[j].fs+a[i].fs-1)/a[i].fs)*a[i].sc<=a[j].sc){
                    a[j].fs=-1;
                }
            }
        }
        for(int i=n-1; i>=0; --i){
            if(a[i].fs==-1){
                continue;
            }
            for(int j=i-1; j>=0; --j){
                if(a[j].fs==-1){
                    continue;
                }
                if(a[i].sc<=a[j].sc){
                    a[j].fs=-1;
                }
            }
        }
        for(int i=0; i<n; ++i){
            if(a[i].fs==-1){
                for(int j=i+1; j<n; ++j){
                    if(a[j].fs!=-1){
                        a[i]=a[j];
                        a[j].fs=-1;
                        break;
                    }
                }
            }
        }
        for(int i=0; i<n; ++i){
            if(a[i].fs==-1){
                n=i;
                break;
            }
        }
        for(int i=0; i+1<n; ++i){
            for(int j=a[i].fs+1; j<=a[i+1].fs; ++j){
                p[j]=i+1;
            }
        }
        for(int i=0; i<=a[0].fs; ++i){
            p[i]=0;
        }
        for(int i=a[n-1].fs; i<=h; ++i){
            p[i]=n-1;
        }
        memset(mem, -1, sizeof mem);
        ans=dp(p[h], h);
        printf("%d\n",ans);
    }
  return 0;
}




Measured memory_bytes: 39808
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0,d=0,e=0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <long long int> vec{}, vecsec{}, vecth{};
long long int iremono[100001], koware[100001];
long long int iremono2[100001], check[100001],xpo[10000001],ypo[10000001],hei[1000001];
std::vector<std::string>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;
pair<pair<std::string,long long int>, long long int>pairs[101];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char re;
int starta, startb, enda, endb,ab;


unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int H, W;//はんい
bool qw = false, er = false, ty = false,ui=false;
int main() {
	cin >> a >> b;
	counter = 1;
	while(a*2<=b){
		counter++;
		a *= 2;
	}
	cout << counter << endl;
}


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

int main()
{
    ll N;
    cin >> N;
    vector<ll> L;

    for(ll i = 0; i < N;i++)
    {
        ll temp;
        cin >> temp;
        L.push_back(temp);
    }

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

    ll j;
    ll a,b,c;
    ll num=0;

    for(ll i = 0;i<N-1;i++)
    {
        a = L[i];
        
        for(ll j = i+1;j<N;j++)
        {
            b = L[j];

            ll temp  = a+b;
            for(ll k = j+1;k<N;k++)
            {
                if(temp <= L[k])
                {
                    break;
                }
                else
                {
                    num++;
                }   
            }
        }
    }

    cout << num << endl;

    return 0;
}



Measured memory_bytes: 256
import numpy as np

def main():
    N = int(input())
    X = list(map(int, input().split()))
    X = np.array(X)
    m = int(np.mean(X))
    n = m + 1

    print(min(np.sum((X - m) ** 2), np.sum((X - n) ** 2)))




    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 18740
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int m = scan.nextInt();
        int f = scan.nextInt();
        int r = scan.nextInt();
        while(m != -1 || f != -1 || r!= -1){
            if(m == -1 || f == -1){
                System.out.println("F");
            }
            else if(m + f >= 80){
                System.out.println("A");
            }
            else if(m + f >= 65 ){
                System.out.println("B");
            }
            else if(m + f >= 50){
                System.out.println("C");
            }
            else if(m + f >= 30){
                if(r >= 50){
                 System.out.println("C");
                }
                else {
                    System.out.println("D");
                }
            }
            else{
                System.out.println("F");
            }
            m = scan.nextInt();
            f = scan.nextInt();
            r = scan.nextInt();
        }
    }
}


Measured memory_bytes: 26332
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
const int N = 21;
int mod = 1e9+7;
int dp[((int)1<<N)][N];
int a[N][N];
int n;
int add(int a,int b)
{
    return ((a%mod)+(b%mod))%mod;
}
int solve(int mask,int idx)
{
    if(idx == n)
    {
        if(mask == ((1<<n)-1))
            return 1;
        return 0;
    }
    if(dp[mask][idx]!=-1)
        return dp[mask][idx];
    dp[mask][idx] = 0;
    for(int i=0;i<n;i++)
    {
        if(a[idx][i]==0)
            continue;
        if(mask&((int)1<<i))
            continue;
        dp[mask][idx] = add(dp[mask][idx],solve(mask|(1<<i),idx+1));
    }
    return dp[mask][idx];
}
signed main()
{
    fast;
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,0);
}


Measured memory_bytes: 344320
N = int(input())
A = list(map(int, input().split()))

ary = [0]*(N-1)
for i in reversed(range(N-1)):
    if i+1 >= (N-1):
        ary[i] = A[N-1]
    else:
        ary[i] = ary[i+1] + A[i+1]

s = 0
for i in range(N-1):
    s += A[i]*ary[i]

print(s%(10**9+7))

Measured memory_bytes: 31512
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
ll h[100001],dp[100001];
ll frog(ll n)
{
    if(n == 0) return 0;
    if(n == 1) return abs(h[0] - h[1]);

    if(dp[n] != -1)
        return dp[n];

    ll cost1 = frog(n-1) + abs(h[n-1] - h[n]);
    ll cost2 = frog(n-2) + abs(h[n-2] - h[n]);
    dp[n] = min(cost1, cost2);
    return dp[n];
}

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

Measured memory_bytes: 9852
n=int(input())
dp=[float('inf')]*(n+1)
dp[0]=0


tup=((1,6,9,6**2,9**2,6**3,9**3,6**4,9**4,6**5,6**6,9**5))

for i in range(1,n+1):
    for j in tup:
        if i-j<0:
            break
        dp[i]=min(dp[i],dp[i-j]+1)
print(dp[-1])

Measured memory_bytes: 3828
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    ll n,k;
    cin>>k>>n;
    if(n%2){
        ll a=k/n;
        cout<<a*a*a<<endl;
    }
    else{
        ll a=k/n;
        ll b=k/(n/2)-a;
        cout<<a*a*a+b*b*b<<endl;
    }
    return 0;
}

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

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

fn main() {
  let a: u32 = read();
  let b: u32 = read();
  let ans = a * b;
  println!("{}", ans);
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  string t;
  cin >> t;
  for(char x : t){
    if(x == '?') cout << "D";
    else cout << x;
  }
  return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
int ref1;
int find(int curr, vector<int> &v){
    vector<int> bin(12);
    for(int i=0; i<12; i++){
        bin[i] = curr%2;
        curr /= 2;
    }
    for(int i=0; i<v.size(); i++)
        bin[v[i]] |= 1;
    int ans = 0, powof2 = 1;
    for(int i=0; i<12; i++){
        if(bin[i])
            ans += powof2;
        powof2 *= 2;
    }
    return ans;
}
int dp(int index, int vis, vector<vector<int> > &memo, vector<vector<bool> > &visited, vector<int> &cost, vector<vector<int> > &key){
    if(vis>=ref1)
        return 0;
    if(vis<ref1 && index>=cost.size())
        return inf;
    if(visited[index][vis])
        return memo[index][vis];
    int res = dp(index+1, vis, memo, visited, cost, key);
    int vis1 = find(vis, key[index]);
    res = min(res, dp(index+1, vis1, memo, visited, cost, key)+cost[index]);
    visited[index][vis] = res;
    memo[index][vis] = res;
    return res;
}
int main(){
    int n, m;
    cin >> n >> m;
    ref1 = (1<<n)-1;
    vector<int> cost(m);
    vector<vector<int> > key(m);
    for(int i=0; i<m; i++){
        cin >> cost[i];
        int size;
        cin >> size;
        vector<int> v(size);
        for(int j=0; j<size; j++)
            cin >> v[j];
        key[i] = v;
    }
    for(int i=0; i<key.size(); i++){
        for(int j=0; j<key[i].size(); j++)
            key[i][j]--;
    }
    vector<vector<int> > memo(m);
    vector<vector<bool> > visited(m);
    for(int i=0; i<m; i++){
        vector<int> t(ref1);
        vector<bool> t1(ref1);
        memo[i] = t;
        visited[i] = t1;
    }
    int res = dp(0, 0, memo, visited, cost, key);
    if(res>=inf)
        cout << -1;
    else
        cout << res;
    return 0;
}

Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

template <typename T>
class SegmentTree
{
public:
  using Fn = function<T(T, T)>;
  int N; //要素数
  vector<T> dat;
  const T unit; //単位元 a * e = a
  Fn func;

  SegmentTree(int n_, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    while (N < n_)
      N *= 2;
    dat.assign(2 * N - 1, unit);
  }

  void update(int k, T a)
  {             //k番目(0-indexed)をaに変更
    k += N - 1; //一番下
    dat[k] = a;
    while (k > 0)
    {
      k = (k - 1) / 2; //1つ上がる
      //更新
      dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]); //
    }
  }

  //[a, b)の値（最小値/和/etc.）を求める
  //kは節点の番号、l, rはその節点が[l,r)に対応づいていることを表す
  //外からはquery(a, b)と呼ぶ

  T query(int a, int b, int k = 0, int l = 0, int r = -1)
  {
    if (r < 0)
      r = N;
    if (r <= a || b <= l)
      return unit;
    //[a, b)が[l,r)を完全に含む
    if (a <= l && r <= b)
      return dat[k];
    else
    {
      int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return func(vl, vr); //
    }
  }
};

inline ll gcd(ll a, ll b)
{
  if (a < b)
    swap(a, b);
  return b == 0 ? a : gcd(b, a % b);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);

  int n;
  cin >> n;
  ll a[100010];
  rep(i, n) cin >> a[i];

  SegmentTree<ll> sg(n, gcd, 0);
  rep(i, n)
  {
    sg.update(i, a[i]);
  }

  ll Max = 1;
  rep(i, n)
  {
    Max = max(Max, gcd(sg.query(0, i), sg.query(i + 1, n)));
  }
  cout << Max << endl;
  return 0;
}

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

using namespace std;

#define int 		long long
#define endl 		"\n"
#define mod 		1000000007
#define inf 		1e18
#define IOS 		ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

	string s, t;
	cin >> s >> t;

	int ls = s.size(), lt = t.size();

	int ans = INT_MAX;

	for (int i = 0; i <= ls - lt; i++) {
		int change = 0;
		for (int j = 0; j < lt; j++) {
			if (t[j] != s[i + j])
				change++;
		}

		ans = min(ans, change);
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    ll N, K;
    cin >> N >> K;
    ll h[N];
    REP(i, N) cin >> h[i];

    const ll INF = 1LL << 60;
    ll dp[N];
    REP(i, N) dp[i] = INF;

    dp[0] = 0;

    ll cnt = 0;
    FOR(i, 1, N) {
        for(ll j = 1; j <= K; j++) {
            if(i - j >= 0) chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << dp[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

const int INF = 1e6;
V<V<int>> c(10, V<int>(10, 0));

int distance(int src) {
  V<int> r(10, INF);
  priority_queue<P, V<P>, greater<P>> q;

  q.push({0, src});
  while (!q.empty()) {
    auto e = q.top();
    q.pop();
    rep(i, 10) {
      if (i == e.second) continue;
      int dist = e.first + c[e.second][i];
      if (dist < r[i]) {
        r[i] = dist;
        q.push({dist, i});
      }
    }
  }
  return r[1];
}

int main() {
  int h, w;
  cin >> h >> w;
  rep(i, 10) rep(j, 10) cin >> c[i][j];

  V<V<int>> a(h, V<int>(w, 0));
  rep(i, h) rep(j, w) cin >> a[i][j];

  V<int> cost(10, 0);
  rep(i, 10) cost[i] = distance(i);

  int ans = 0;
  rep(i, h) rep(j, w) {
    if (a[i][j] == -1 || a[i][j] == 1) continue;
    ans += cost[a[i][j]];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
s = input()
n = len(s) // 5
for i in range(n + 1):
   if len(s) == 0:
      print('YES')
      exit()
   if s[:6] == 'eraser':
      s = s[6:]
   elif s[:5] == 'erase':
      s = s[5:]
   elif ((s[:7] == 'dreamer') and (s[:10] != 'dreamerase') and (s[:11] != 'dreameraser')) or ((len(s) == 7) and (s == 'dreamer')):
      s = s[7:]
   elif (s[:5] == 'dream'):
      s = s[5:]
   else:
      print('NO')
      exit()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

struct store{
    ll a, b;

    bool operator<(const store& s){
        return a < s.a;
    }
};

void solve(){
    ll n, m;
    cin >> n >> m;
    vector<store> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i].a >> a[i].b;
    }

    sort(all(a));

    ll ans = 0;
    for (int i = 0; i < n; i++){
        ll d = min(a[i].b, m);
        m -= d;
        ans += d*a[i].a;
    }
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

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

const double eps = 1e-9;

struct Task {
	int n;
	vector<int> a;

	Task(int n): n(n), a(n) {
		for (auto& item : a) {
			cin >> item;
		}
	}

	void run() {
		sort(a.begin(), a.end());
		int result = 0;
		long long sum = a[0];
		for (int i = 1; i < n; ++i) {
			if (2 * sum < a[i]) {
				result = i;
			}
			sum += a[i];
		}
		result = n - result;
		cout << result << '\n';
	}
};

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

	int t = 1;
	while (t--) {
		int n;
		cin >> n;
		Task test(n);
		test.run();
	}
	return 0;
}

Measured memory_bytes: 640
#N=gets.to_i
#S=gets.chomp
#A=(0...N).map{gets.to_i}
#sum=A.inject(&:+)
#B=gets.split.map(&:to_i)




class WeightedUnionFind
  @par=[] # 親の番号
  @ws=[]  # 親との重みの差
  
  def initialize(n)
      @par = (0...n).to_a
      @ws  = Array.new(n,0)
  end
  
  def find(x)
      if @par[x]==x
          return x
      else
          parent = find(@par[x])
          @ws[x] += @ws[@par[x]]
          @par[x]=parent
          return parent
      end
  end
  
  def weight(x)
      find(x) 
      return @ws[x]
  end
  
  def union(x,y,w) # x <-(w)- y (x + w = y)
      w += weight(x)
      w -= weight(y)
      x = find(x)
      y = find(y)
      
      if x != y
          @par[y] = x
          @ws[y] = w
          return true
      else
          return false
      end
  end
  
  def same(x, y)
      return find(x) == find(y)
  end
  
  def diff(x,y) # x - y を求める. 比較不能ならnil
      return nil if !same(x, y)
      return weight(x) - weight(y)
  end
end


N,M=gets.split.map(&:to_i)
uf=WeightedUnionFind.new(N)

M.times do
  x,y,z=gets.split.map(&:to_i)
  uf.union(x-1,y-1,1)
end


parcount={}
N.times do |i|
  parcount[uf.find(i)]=1
end
puts parcount.size


Measured memory_bytes: 9852
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  T = "ACGT";
  cin>>S;
  
  int count = 0;
  int a = 0;
  for(int i=0;i<S.size();i++){
    
    bool ok=false;
    for(int j=0;j<4;j++){
      if(S.at(i)==T.at(j)){
        ok = true;
      }
    }
    
    if(ok){
      count++;
      a=max(a,count);
    }
    else{
      count=0;
    }
  }
  cout<<a<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

struct items{
    ll t, v;
};
static const ll MAX = 100001;

bool asc( const items& left, const items& right ) {
    return left.v == right.v ? left.t >= right.t : left.v >= right.v;
}
int main() {
    

    ll n,k;
    cin >> n >> k;
    vector <items> lis, rem;
    for (ll i=0;i<n;i++){
        items p;
        cin >> p.t >> p.v;
        lis.push_back(p);
    }
    sort(lis.begin(), lis.end(), asc);
   // reverse(lis.begin(), lis.end());
    ll eachmax[MAX] = {};
    ll per = 0;
    for(ll i=0;i<n;i++){
        if(eachmax[lis[i].t] < lis[i].v){
            eachmax[lis[i].t] = lis[i].v;
        }
    } 
    ll numt = 0;
    ll exist[MAX] = {};
    for(ll i=0;i<k;i++){
        per += lis[i].v;
        if(exist[lis[i].t] == 0){
            numt++;
        }else{
            rem.push_back(lis[i]);
        }
        exist[lis[i].t] = 1;
//        cout << lis[i].t << endl;
    }
    reverse(rem.begin(), rem.end());
    ll ans = 0;
    if(ans < per + numt*numt){
        ans = per + numt*numt;
    }

//    cout << ans << endl;
    vector <ll> memo;
    for (ll i=0;i<n;i++){
        if(exist[i] == 0 and eachmax[i] > 0){
            memo.push_back(eachmax[i]);
        }
    }
    sort(memo.begin(), memo.end());
    reverse(memo.begin(), memo.end());
//    cout << rem.size() << endl;
//    cout << memo.size() << endl;
    for(ll i = 0;i<min(memo.size(), rem.size());i++){
        per -= rem[i].v;
        per += memo[i];
        numt++;
        if(ans < per + numt*numt){
            ans = per + numt*numt;
        }
//        cout << ans << endl;
    }
//    cout << "mofu" << endl;
    cout << ans << endl;


}




Measured memory_bytes: 5104
// Vicfred
// https://atcoder.jp/contests/abc159/tasks/abc159_a
// math
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

long gauss(long n) {
    return n*(n-1)/2;
}

void main() {
    long n = readln.chomp.to!long;
    long[] a = readln.split.map!(to!long).array;

    long[long] balls;
    foreach(ball; a) {
        if(ball in balls)
            balls[ball] += 1;
        else
            balls[ball] = 1;
    }

    long ways = 0;
    foreach(i; balls.keys)
        ways += gauss(balls[i]);

    for(int k = 0; k < n; k++) {
        long ans = ways-balls[a[k]]+1;
        ans.writeln;
    }
}



Measured memory_bytes: 27024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  ll a, b;
  char op;
  cin >> a >> op >> b;

  if(op == '+'){
    cout << a + b << endl;
  } else {
    cout << a - b << endl;
  }

  return 0;
}


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

int main(){
    string S,T,tmpS,tmpT;
    cin >> S;
    int N = S.size();
    T = S;
    reverse(T.begin(),T.end());
    if (S!=T){
        cout << "No" << endl;
    }else{
        tmpS = S.substr(0,(N-1)/2);
        tmpT = tmpS;
        reverse(tmpT.begin(),tmpT.end());
        if(tmpS != tmpT){
            cout << "No" << endl;
        }else{
            tmpS = S.substr((N-1)/2-1,N-(N-1/2));
            tmpT = tmpS;
            reverse(tmpT.begin(),tmpT.end());
            if(tmpS != tmpT){
                cout << "No" << endl;
            }else{
                cout << "Yes" << endl;                
            }
        }   
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int a[]=new int [n];
	      for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
			h-=a[i];
	      }
	      if(h<=0) {
	  		System.out.print("Yes");
	      }else {
		  		System.out.print("No");
	      }
	}
}

Measured memory_bytes: 51060
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

void print(vector<int> &v, int N) {
	cout << N << endl;
	for(int i = 0; i < N; ++i) {
		cout << v[i] << (i == N - 1 ? "\n": " ");
	}
}
void func(vector<int> &v) {
	int N = v.size();
	int idx = 0;
	for(int i = 1; i < N; ++i) {
		if(v[idx] < v[i]) {
			idx = i;
		}
	}
	for(int i = 0; i < N; ++i) {
		if(i == idx) {
			v[i] -= N;
		} else {
			v[i]++;
		}
	}
}

bool finished(const vector<int> &v) {
	int N = v.size();
	for(int i = 0; i < N; ++i) {
		if(v[i] >= N) {
			return false;
		}
	}
	return true;
}

bool check(vector<int> v, int m) {
	int N = v.size();
	for(int i = 0; i < m; ++i) {
		if(finished(v)) return false;
		func(v);
	}
	return finished(v);
}

signed main(){
	int K;
	cin >> K;
	const int N = 50;
	int m = (N - K % N) % N, l = (K + N - 1) / N;
	vector<int> v(N, l + 49);
	for(int i = 0; i < m; ++i) {
		func(v);
	}
	print(v, N);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String s = sc.nextLine();
			String []n = s.split(" ");
			double[] v = new double[6];
			for(int i = 0; i < 6; i++) {
				v[i] = Double.parseDouble(n[i]);
			}
			double d = v[0] * v[4] - v[1] * v[3];
			double x = v[4] * v[2] - v[1] * v[5];
			double y = -v[3] * v[2] + v[0] * v[5];
			x /= d;
			y /= d;
			if(x==0)x=0;
            if(y==0)y=0;
			System.out.printf("%.3f %.3f\n", x, y);
		}
		sc.close();
	}
}


Measured memory_bytes: 26240
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

#define PRINT(s) cout << (s);
#define PRINTLN(s) cout << (s) << endl;

using namespace std;

// #define REP(i,N) for(int i = 0; i < N; i++)

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (c >= a && c <= b) {
        PRINTLN("Yes");
    } else {
        PRINTLN("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
int n;
int it[200001];
pair<int,int> tree[800001][2];
int build(int no,int l,int r,int ind){
	if(l==r){
		if(l%2==ind){
			tree[no][ind]={it[l],l};
		}
		else{
			tree[no][ind]={n+1,l};
		}
	}
	else{
		int mid=(l+r)/2;
		build(no*2+1,l,mid,ind);
		build(no*2+2,mid+1,r,ind);
		if(tree[no*2+1][ind].a<tree[no*2+2][ind].a){
			tree[no][ind]=tree[no*2+1][ind];
		}
		else{
			tree[no][ind]=tree[no*2+2][ind];
		}
	}
}
pair<int,int> query(int no,int l,int r,int aa,int bb,int ind){
	if(bb<l or aa>r){
		return {n+1,-1};
	}
	if(aa<=l and r<=bb){
		return tree[no][ind];
	}
	else{
		int mid=(l+r)/2;
		pair<int,int> ac=query(no*2+1,l,mid,aa,bb,ind);
		pair<int,int> cc=query(no*2+2,mid+1,r,aa,bb,ind);
		if(ac.a<cc.a){
			return ac;
		}
		else{
			return cc;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>it[i];
	}
	build(0,0,n-1,0);
	build(0,0,n-1,1);
	priority_queue<pair<pair<int,int>,pair<int,int>>> no;
	pair<int,int> st=query(0,0,n-1,0,n-1,0);
	st.a=-st.a;


	no.push({st,{0,n-1}});
	vector<int> ans;
//	while(no.size()){
	while(no.size()){
		pair<pair<int,int>,pair<int,int>> ac=no.top();
	//	cout<<ac.b.a<<','<<ac.b.b<<endl;
		no.pop();
		ac.a.a=-ac.a.a;
		ans.pb(ac.a.b);
		pair<int,int> bb=query(0,0,n-1,ac.a.b+1,ac.b.b,1-(ac.b.a%2));
		ans.pb(bb.b);
	//	cout<<ac.a.b<<":"<<bb.b<<endl;
	//	cout<<ac.a.a<<"::"<<bb.a<<endl;
		if(ac.a.b>ac.b.a){
			pair<int,int> pp=query(0,0,n-1,ac.b.a,ac.a.b-1,ac.b.a%2);
			pp.a=-pp.a;
			no.push({pp,{ac.b.a,ac.a.b-1}});
	//		cout<<ac.b.a<<"   "<<ac.a.b-1<<endl;

		}
		if(bb.b>ac.a.b+1){
			pair<int,int> pp=query(0,0,n-1,ac.a.b+1,bb.b-1,(ac.a.b+1)%2);
			pp.a=-pp.a;
			no.push({pp,{ac.a.b+1,bb.b-1}});
			//cout<<ac.a.b+1<<",,,,,,,"<<bb.b-1<<endl;
		}
		if(bb.b<ac.b.b){
			pair<int,int> pp=query(0,0,n-1,bb.b+1,ac.b.b,(bb.b+1)%2);
			pp.a=-pp.a;
			no.push({pp,{bb.b+1,ac.b.b}});
		}

	}
	for(auto j:ans){

		cout<<it[j]<<" ";
	}
	cout<<endl;









	return 0;
}

Measured memory_bytes: 14068
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll i,o,t,j,l,s,z;
  cin >> i >> o >> t >> j >> l >> s >> z;
  ll ans = 0;
  ans += o;
  ll e = 0;
  {
    ll ni = i,nj = j,nl = l;
    ll c = 0;
    if (ni > 0 && nj > 0 && nl > 0) {
      ni--;nj--;nl--;
      c += 3;
    }
    c += (ni/2)*2;
    c += (nj/2)*2;
    c += (nl/2)*2;
    chmax(e,c);
  }
  {
    ll ni = i,nj = j,nl = l;
    ll c = 0;
    c += (ni/2)*2;
    c += (nj/2)*2;
    c += (nl/2)*2;
    chmax(e,c);
  }
  ans += e;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    const double PI = acos(-1);

    int A, B, H, M;
    cin >> A >> B >> H >> M;

    int h = H * 60 + M;
    double ah = 2 * PI * h / (60 * 12);
    double am = 2 * PI * M / 60;

    double hx = A * cos(ah);
    double hy = A * sin(ah);

    double mx = B * cos(am);
    double my = B * sin(am);

    double dx = hx-mx;
    double dy = hy-my;

    double dist = sqrt(dx*dx + dy*dy);
    cout << setprecision(10) << dist << endl;

    return 0;
}


Measured memory_bytes: 4116
N,M=gets.chomp.split.map(&:to_i)
NUM=[0,2,5,5,4,5,6,3,7,6]
A = gets.chomp.split.map(&:to_i).sort.reverse

dp = Array.new(N+1, -Float::INFINITY)
dp[0] = 0
1.upto(N) do |i|
  A.each do |a|
    if i - NUM[a] >= 0
      if dp[i] < dp[i - NUM[a]] + 1
        dp[i] = dp[i - NUM[a]] + 1
      end
    end
  end
end

n = N
ans = []
while(n > 0)
  A.each do |a|
    next if n - NUM[a] < 0
    if dp[n - NUM[a]] == dp[n] - 1
      n -= NUM[a]
      ans << a
      break
    end
  end
end

puts ans.map(&:to_s).join

Measured memory_bytes: 2044