akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;

const D EPS = 1e-8;

namespace std{
  bool operator<(const P &a,const P &b){
    return EQ(real(a),real(b))?imag(a)<imag(b):real(a)<real(b);
  }
  bool operator==(const P &a, const P &b){return EQ(a,b);}
}

inline D dot(P x, P y){return real(conj(x)*y);}
inline D cross(P x, P y){return imag(conj(x)*y);}

int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)+EPS<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

inline bool para(L a,L b){return abs(cross(a.fs-a.sc,b.fs-b.sc))<EPS;}

inline bool is_cp(L a,L b){
  if(para(a,b))return false;
  if(ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<=0)
    if(ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<=0)return true;
  return false;
}

inline P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

vector<P> p[2];
inline D len(D x, int id){
  L l = L( P(x,-1000), P(x,1000) );
  vector<P> res;
  rep(i,p[id].size()){
    L a = L( p[id][i], p[id][(i+1)%p[id].size()] );
    if(is_cp(a,l)){
      P cp = line_cp(a,l);
      if(!EQ(cp,p[id][i]))res.push_back(cp);
    }else if(para(a,l) && ccw(l.fs,l.sc,a.sc)==0){
      res.push_back(a.sc);
    }
  }

  if(res.size()<2)return 0;
  return abs(res[0]-res[1]);
}

inline D f(D x){
  return len(x,0) * len(x,1);
}

int main(){
  int m,n;
  while(cin >> m >> n, m){
    D minx[2], maxx[2];
    p[0].resize(m); p[1].resize(n);
    minx[0] = minx[1] = 1000;
    maxx[0] = maxx[1] = -1000;

    rep(i,m){
      D x,y;
      cin >> x >> y;
      p[0][i] = P(x,y);
      minx[0]=min(minx[0],x);
      maxx[0]=max(maxx[0],x);
    }

    rep(i,n){
      D x,z;
      cin >> x >> z;
      p[1][i] = P(x,z);
      minx[1]=min(minx[1],x);
      maxx[1]=max(maxx[1],x);
    }

    D ans = 0;
    for(D i=-100;i<100;i+=1){
      if(minx[0]<=i+0.5 && i+0.5<=maxx[0]){
	if(minx[1]<=i+0.5 && i+0.5<=maxx[1]){
	  ans += f(i)+4*f(i+0.5)+f(i+1);
	}
      }
    }
    cout << fixed << setprecision(9) << ans/6 << endl;
  }
}

Measured memory_bytes: 1320
import itertools
import collections
def prime_factor_table(n):
    table = [0] * (n + 1)
    
    for i in range(2, n + 1):
        if table[i] == 0:
            for j in range(i + i, n + 1, i):
                table[j] = i
    
    return table

def prime_factor(n, prime_factor_table):
    prime_count = collections.Counter()
    
    while prime_factor_table[n] != 0:
        prime_count[prime_factor_table[n]] += 1
        n //= prime_factor_table[n]
    prime_count[n] += 1
    
    return prime_count

N = int(input())
A_s = list(map(int, input().split()))
# A_s = [int(i+1) for i in range(N)]
pc = True
sc = True
M = {}
MAX = 0
TABLE = prime_factor_table(10**6+1)

for i,A in enumerate(A_s):
    L = prime_factor(A, TABLE)
    for l in L.keys():
        if l == 1:
            continue
        if l in M:
            # print()
            M[l] += 1
            pc = False
        else:
            M[l] = 1
        MAX = max(MAX, M[l])
    if not pc and MAX <= i:
        break
else:
    sc = False

if pc:
    print('pairwise coprime')
elif sc:
    print('setwise coprime')
else:
    print('not coprime')

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

int main() {
  
 int N,answer,count,btnum;
 answer = -1;
 count = 0;
 btnum = 1;
 cin >> N;
 vector<int> button(N);
 
 for (int i=0; i < N; i++) {
   cin >> button.at(i);
 }
  
 for (int i=0; i < N; i++) {
   
   btnum = button.at(btnum-1);
   
   count++;
   if (btnum == 2) {
     answer = count;
     break;
   }
 }
 
 cout << answer<< endl;
}


Measured memory_bytes: 640
char x[9],buf[2<<17];
N;
T;
i;
main()
{
	N=read(0,buf,2<<17)-1;
	for(;i<N;++i)
	{
		T+=(buf[i]&1)*4-2;
		if(T<0)T=0;
	}
	i=8;
	do
	{
		x[--i]=T%10+'0';
		T/=10;
	}while(T);
	write(1,x+i,8-i);
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define roop(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

 map<string,int> A;
 ll int x,y;
 string C, D,E;
 cin >> C >> D;
 cin >> x >> y;

 A[C] = x;
 A[D] = y;

 cin >> E;

 A[E] = A[E] -1;

  cout << A[C]  << " " << A[D];









	return 0;

}



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

int main(){
	int a[10];
	
	for(int i=0;i<10;i++){
		cin>>a[i];
	}
	
	sort(a,a+10);
	cout<<a[9]<<endl<<a[8]<<endl<<a[7]<<endl;
	return 0;
	
}

Measured memory_bytes: 3100
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static int n;
    public static int[] p;
    public static long[] val;
    public static ArrayList<ArrayList<Integer>> adj;
    public static boolean[] visited;
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        StringTokenizer st = new StringTokenizer(bf.readLine());
        n = Integer.parseInt(st.nextToken());
        int q = Integer.parseInt(st.nextToken());
        adj = new ArrayList<ArrayList<Integer>>();
        for(int i=0; i<n; i++) adj.add(new ArrayList<Integer>());
        for(int i=0; i<n-1; i++) {
          st = new StringTokenizer(bf.readLine());
          int a = Integer.parseInt(st.nextToken())-1;
          int b = Integer.parseInt(st.nextToken())-1;
          adj.get(a).add(b);
          adj.get(b).add(a);

        }
        visited = new boolean[n];
        p = new int[n];
        dfs(0);

        val = new long[n];
        for(int i=0; i<q; i++) {
          st = new StringTokenizer(bf.readLine());
          int pp = Integer.parseInt(st.nextToken())-1;
          int x = Integer.parseInt(st.nextToken());
          val[pp] += x;
        }

        dfs2(0);
        StringBuilder ans = new StringBuilder();
        for(int i=0; i<n; i++) ans.append(val[i]+" ");
        out.println(ans.toString());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        // int n = Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }
    public static void dfs(int v) {
      visited[v] = true;
      for(int i : adj.get(v)) {
        if(!visited[i]) {
          p[i] = v;
          dfs(i);
        }
      }
    }
    public static void dfs2(int v) {
      if(v != 0)
        val[v] += val[p[v]];
      for(int i : adj.get(v)) {
        if((p[i]==v)) {

          dfs2(i);
        }
      }
    }
}


Measured memory_bytes: 153280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    string ans = "No";
    if (s < t) ans = "Yes";
    cout << ans << endl;
    return 0;
}

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

using ll = long long;

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n - 1; ++i) {
        for (int j = 1; j <= n / i; ++j) {
            int c = n - i * j;
            if (c > 0) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

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

		int k = sc.nextInt();
		int t = sc.nextInt();

		int max = 1;

		for (int i = 0; i < t; i++) {
			int a = sc.nextInt();
			if (a > max) {
				max = a;
			}
		}

		int minPair = Math.max(max - 1 - (k - max), 0);
		System.out.println(minPair);

		sc.close();
	}

}


Measured memory_bytes: 23636
n = int(input())
a = list()
for i in range(n):
    x,y = input().split()
    y = int(y)
    if x == 'S':
        a.append(y+0)
    elif x == 'H':
        a.append(y+13)
    elif x == 'C':
        a.append(y+26)
    else:
        a.append(y+39)
for i in range(1,53):
    if not (i in a):
        if i <= 13:
            print('S {}'.format(i))
        elif 13 < i <= 26:
            print('H {}'.format(i-13))
        elif 26 < i <=39:
            print('C {}'.format(i-26))
        else:
            print('D {}'.format(i-39))


Measured memory_bytes: 5596
using System;
using System.Collections.Generic;

class C3{
  public static void Main(){
    int count = 0;
    var list = new LinkedList<string>();
    int n = int.Parse(Console.ReadLine());

    for(int i = 0;i < n;i++){
      string[] str = Console.ReadLine().Split(' ');

      if(str[0].Equals("insert")){
        list.AddFirst(str[1]);
      }
      else if(str[0].Equals("delete")){
        list.Remove(str[1]);
      }
      else if(str[0].Equals("deleteFirst")){
        list.RemoveFirst();
      }
      else list.RemoveLast();
    }

    foreach(string s in  list){
      Console.Write(s);
      count++;
      if(count != list.Count)Console.Write(" ");
      else Console.WriteLine("");
    }
  }
}


Measured memory_bytes: 138876
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define pll pair<long long, long long>
using namespace std;
using ll = long long;
using ld = long double;

// ----本問について----
// 問題：
// 問題文URL：
// 所要時間：
// 学んだこと：
// ------------------

// ----ここから本問のソースコード----

// グローバル変数（入力）
ld x[4],y[4];

void solve() {
  if ((y[1]-y[0])*(x[3]-x[2])==(x[1]-x[0])*(y[3]-y[2])){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

int main() {
  ll n;
  cin >> n;
  rep(i,n){
    cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];
    solve();
  }
  return 0;
}



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

using namespace std;

typedef long long ll;

ll mod;

ll powimod(ll x,ll n,ll mod){
    ll res=1;
    while(n){
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}

ll powi(ll x,ll n){
    ll res=1;
    while(n){
        if(n&1) res*=x;
        x*=x;
        n>>=1;
    }
    return res;
}

vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int temp;
    int a[10001];
    memset(a,0,sizeof(a));
    for(int x=1;x*x<=n;x++)
    {
    for(int y=1;y*y<=n;y++)
    {
    for(int z=1;z*z<=n;z++)
    {
    temp=x*x+y*y+z*z+x*y+y*z+z*x;
    if(temp<=10000) a[temp]++;
    }
    }
    }
    for(int i=1;i<=n;i++)
    {
    cout<<a[i]<<"\n";
    }
}


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

int main(){
 string strt;
 int n,f=0;
 cin>>strt;
 cin>>n,f;
 
 string strr;
 for(int i=0;i<n;i++){
	cin>>strr;
	if((strr+strr).find(strt)!=-1){
		f++;
	}
 }
 cout<<f<<'\n';
 return 0;
}

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define int long long
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9 + 7;
const double P = 3.141592653589793238462643;

int a[N], c[N], mx = -inf;

main()
{
    int n;
    cin >> n;
    for( int i = 1; i <= n; i++ )
    {
        cin >> a[i];
        c[a[i]] ++;
        c[a[i] + 1] ++;
        c[a[i] - 1] ++;
        mx = max( mx, a[i] + 1 );
    }
    int ans = -inf;
    for( int i = 0; i <= mx; i++ )
    {
        ans = max( ans, c[i] );
    }
    cout << ans;
}


Measured memory_bytes: 1792
n=int(input())
M=[list(map(int,input().split()))for _ in[0]*n]
d=[0]+[1e4]*~-n
p=[-1]*n
b=[1]*n
while 1:
 m,u=1e4,-1
 for i in range(n):
  if m>d[i]and b[i]:m,u=d[i],i
 if u<0:break
 b[u]=0
 for v in range(n):
  if b[v]and 1+M[u][v]and d[v]>M[u][v]:
   d[v],p[v]=M[u][v],u
print(sum(M[i][p[i]]for i in range(n)if p[i]+1))


Measured memory_bytes: 5908
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

#define MAX_N 101

bool include(const vector<int> &a, const vector<int> &b) {
	for (int i = 0; i < b.size(); i++) {
		bool found = false;
		for (int j = 0; j < a.size(); j++) {
			if (b[i] == a[j]) found = true;
		}
		if (!found) return false;
	}
	return true;
}

int main() {
	int N;
	while (cin >> N) {
		if (N == 0) break;

		vector<int> know[MAX_N];
		for (int i = 1; i <= N; i++) {
			int M; cin >> M;
			for (int j = 0; j < M; j++) {
				int p; cin >> p;
				know[i].push_back(p);
			}
		}

		int K; cin >> K;
		vector<int> leak(K);
		for (int i = 0; i < K; i++) cin >> leak[i];
		
		vector<int> suspect;
		for (int i = 1; i <= N; i++) 
			if (include(know[i], leak)) suspect.push_back(i);

		if (suspect.size() == 1) 
			cout << suspect[0] << endl;
		else 
			cout << -1 << endl;
	}
	return 0;
}

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

using namespace std;

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

	int e, y;
	cin >> e >> y;
	if( e == 0 )
	{
		if( y <= 1911 )cout << "M" << y - 1867 << endl;
		else if( y <= 1925 )cout << "T" << y - 1911 << endl;
		else if( y <= 1988 )cout << "S" << y - 1925 << endl;
		else cout << "H" << y - 1988 << endl;
	}
	else if( e == 1 )cout << y + 1867 << endl;
	else if( e == 2 )cout << y + 1911 << endl;
	else if( e == 3 )cout << y + 1925 << endl;
	else if( e == 4 )cout << y + 1988 << endl;

	return 0;
}



Measured memory_bytes: 3220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = br.readLine();
            int count = 0;
            
            while(line.equals("0") == false){
            	System.out.println("Case "+ ++count + ": " +line);
                line = br.readLine();
            }
            br.close();
        } catch (IOException e) {
            System.err.println(e);
        }
    }
}

Measured memory_bytes: 27944
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
        int R[MAX], n;
        cin >> n;
        for (int i=0; i<n; ++i) cin >> R[i];

        int maxv = R[1] - R[0];
        int minv = R[0];
        
        for (int i=1; i<n; ++i) {
                maxv = max(maxv, R[i] - minv);
                minv = min(minv, R[i]);
        }       
        
        cout << maxv << endl;
        return 0;
}       



Measured memory_bytes: 3860
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class FloorFunction
{
    static void Main(string[] args)
    {

        var input = Console.ReadLine().Split(' ');

        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        long n = long.Parse(input[2]);
        long max = 0;
        long number = 0;


        if (b > n)
        {
            max = a * n / b;
        }
        else if(b == n){
            max = a * (n - 1) / b;
        }
        else
        {
            max = a * (b - 1) / b - a * ((b - 1) / b);
        }


    
        Console.WriteLine(max);

    }
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  set<ll>st;
  ll n;cin>>n;
  rep(i,0,n){
    ll x;cin>>x;st.insert(x);
  }
  ans2(st.size()==n);
  return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int W, H, X, Y;
	cin >> W >> H >> X >> Y;

	double kotae = 1.0 * W * H / 2;
	cosp(kotae);
	if (W % 2 == 0 && H % 2 == 0 && W / 2 == X && H / 2 == Y) co(1);
	else co(0);



	Would you please return 0;
}

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

constexpr int mod = 1e9 + 7;

int main() {
    int h, w; cin >> h >> w;
    vector<string> a(h);
    for(int i = 0; i < h; ++i) {
        cin >> a[i];
    }

    vector<vector<int>> dp(h, vector<int>(w));
    dp[0][0] = 1;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(a[i][j] == '#') continue;
            if(i - 1 >= 0) (dp[i][j] += dp[i - 1][j]) %= mod;
            if(j - 1 >= 0) (dp[i][j] += dp[i][j - 1]) %= mod;
        }
    }

    cout << dp[h - 1][w - 1] << endl;
}


Measured memory_bytes: 5248
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll gcd(ll a, ll b)
{
    ll tmp;
    ll c;
    if (a < b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }

    do
    {
        c = a % b;
        a = b;
        b = c;
    } while (c != 0);

    return a;
}

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

int main(void)
{
    ll n, x;
    cin >> n >> x;

    vector<ll> a(n);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

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

    ll ans = abs(x - a[0]);

    for (int i = 0; i < n - 1; i++)
    {
        ans = gcd(ans, a[i + 1] - a[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

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

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

int main()
{
    int N, M;
    input(N, M);
    
    int s = 0;
    rep(i, 0, M)
    {
        int m;
        input(m);
        s += m;
    }

    cout << (N >= s ? N - s : -1) << endl;
    
    return 0;
}


Measured memory_bytes: 3668
#include <stdio.h>
int main ()
{
    int n, a, b, c, d;
    scanf("%d", &n);
    a = n % 10;
    n /= 10;
    b = n % 10;
    n /= 10;
    c = n % 10;
    n /= 10;
    d = n;
    if (d + c + b + a == 7)
        printf("%d+%d+%d+%d=7", d, c, b, a);
    else if (d + c + b - a == 7)
        printf ("%d+%d+%d-%d=7", d, c, b, a);
    else if (d + c - b + a == 7)
        printf ("%d+%d-%d+%d=7", d, c, b, a);
    else if (d + c - b - a == 7)
        printf ("%d+%d-%d-%d=7", d, c, b, a);
    else if (d - c + b + a == 7)
        printf ("%d-%d+%d+%d=7", d, c, b, a);
    else if (d - c + b - a == 7)
        printf ("%d-%d+%d-%d=7", d, c, b, a);
    else if (d - c - b + a == 7)
        printf ("%d-%d-%d+%d=7", d, c, b, a);
    else if (d - c - b - a == 7)
        printf ("%d-%d-%d-%d=7", d, c, b, a);

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

//Kanglish:Analysis on Artificial Language
public class Main{

	void run(){
		String[] kang = {"a", "b", "c", "d", "e", "f", "g", "h",
				"i", "j", "k", "l", "m", "n", "o", "p", "q", "r",
				"s", "t", "u", "v", "w", "x", "y", "z",
				"ld", "mb", "mp", "nc", "nd", "ng", "nt", "nw", "ps", "qu", "cw", "ts"
		};
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); sc.nextLine();
		int[][] c = new int[38][38];
		while(N--!=0){
			for(String s:sc.nextLine().split(" ")){
				int p = -1;
				while(!"".equals(s)){
					for(int k=37;k>=0;k--){
						if(s.startsWith(kang[k])){
							if(p!=-1)c[p][k]++;
							p = k;
							s = s.substring(kang[k].length(), s.length());
							break;
						}
					}
				}
			}
		}
		for(int i=0;i<38;i++){
			int k = 0;
			for(int j=1;j<38;j++){
				if(c[i][k]<c[i][j])k=j;
			}
			System.out.println(kang[i]+" "+kang[k]+" "+c[i][k]);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

H, W, D = map(int, input().split())
HW = []
for i in range(H):
    HW.append(list(map(int, input().split())))

# 各マス番号の座標位置をメモしておく
pos = [None] * (H*W+1)
for i in range(H):
    for j in range(W):
        pos[HW[i][j]] = (i, j)
# 間隔をDずつ空けた累積和
sm = [0] * (H*W+1)
for i in range(D+1, H*W+1):
    sm[i] = sm[i-D] + abs(pos[i][0] - pos[i-D][0]) + abs(pos[i][1] - pos[i-D][1])
# 各QはO(1)で解けるはず
Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    print(sm[r] - sm[l])


Measured memory_bytes: 18176
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    string s;
    cin>>s;
    int d=s.length()/2;
    int cnt=0;
    for(int i=0;i<d;i++){
        if(s[i]!=s[s.length()-i-1]){
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>
#include <iomanip>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
long long A[200005] = {};
long long B[5005][5] = {};
long long C[205][205] = {};
long long D[200005] = {};
long long E[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl[3];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


bool fs[2005][2005] = {};

double aa[5005];
double bb = 0;

int main() {


	cin >> N>>a>>b;

	if ((b - a) % 2 == 0) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}

	return 0;

}


Measured memory_bytes: 2304
#include <stdio.h>
#include <string.h>

int main(void)
{
	int dp[50][3001];
	int i, j, k;
	int n, m, s;
	
	while (1){
		scanf("%d%d%d", &n, &m, &s);
		
		if (n + m + s == 0){
			break;
		}

		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		for (i = 1; i <= m; i++){
			for (j = n * n; j >= 1; j--){
				for (k = i; k <= s; k++){
					dp[j][k] += dp[j - 1][k - i];
					if (dp[j][k] >= 100000){
						dp[j][k] -= 100000;
					}
				}
			}
		}
	
		printf("%d\n", dp[n * n][s]);
	}
	
	return (0);
}

Measured memory_bytes: 996
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int x,y,s;
	while(cin>>x>>y,x){
		if(y>x)swap(x,y);
		for(s=0;y;)s++,x%=y,swap(x,y);
		cout<<x<<" "<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)(1e9)+7)

int main(){
	int n;
	string s;
	cin >> n;
	cin >> s;
	int a[n+1];
	a[0]=0;
	for(int i=1; i<=s.length(); i++){
		if(s[i-1]=='E') a[i]=a[i-1]+1;
		else a[i]=a[i-1];
	}
	int min=3*1e5;
	for(int i=1; i<=n; i++){
		int t=a[n]-a[i-1]-a[i]+i-1;
		if(t<min) min=t;
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 1796
#include<stdio.h>
int main()
{
    long long int N,x,i,j;
    scanf("%lld",&N);
    x=sqrt(N);
    while(1)
    {
        if(N%x==0)
        {
            i=N/x;
            break;
        }
        else
            x--;
    }

    j=x+i-2;
    printf("%lld",j);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
using namespace std;
typedef long long ll;

int gcd(int a,int b){
    int t;
    while(b>0){
        t=b;
        b=a%b;
        a=t;
    }
    return a;
}

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

int main(){
    ll f,k,l,m,n,o=1,o1,p,q,r,x,y,z,max1=0,ans=0;
    string t,u;
    cin>>n>>m;
    ll a[n],b[n],c[n],e[n];
    for(ll i=0;i<n;i++){
        cin>>a[i]>>b[i];
        c[i]=a[i]*1000000+b[i];
    }
    sort(c,c+n);
    priority_queue<ll>d;
    o=0;
    for(ll i=1;i<m+1;i++){
        o1=1;
        while(o1){
            o1=0;
            if(c[o]/1000000==i){
                d.push(c[o]%1000000);
                o++;
                o1=1;
            }
        
        }
        if(d.size()){
            ans+=d.top();
            d.pop();
            
        }
    }
     cout<<ans<<endl;
}




   



Measured memory_bytes: 3704
#include <vector>
#include <iostream>
using namespace std;
int N, M, l[200009], r[200009], d[200009], a[200009]; bool vis[100009]; vector<int> g[100009];
bool dfs(int pos) {
	vis[pos] = true;
	for (int i : g[pos]) {
		if (l[i] == pos) {
			if (vis[r[i]]) {
				if (a[r[i]] != a[pos] + d[i]) return false;
			}
			else {
				a[r[i]] = a[pos] + d[i];
				if (!dfs(r[i])) return false;
			}
		}
		else {
			if (vis[l[i]]) {
				if (a[l[i]] != a[pos] - d[i]) return false;
			}
			else {
				a[l[i]] = a[pos] - d[i];
				if (!dfs(l[i])) return false;
			}
		}
	}
	return true;
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> l[i] >> r[i] >> d[i];
		g[l[i]].push_back(i);
		g[r[i]].push_back(i);
	}
	bool ret = true;
	for (int i = 0; i < N; i++) {
		if (!vis[i]) {
			if (!dfs(i)) ret = false;
		}
	}
	cout << (ret ? "Yes\n" : "No\n");
	return 0;
}

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

using namespace std;

typedef long long ll;
ll n,a,b,c,d;
ll fac[1005];
ll dp[1005][1005];
const ll mod = 1e9 + 7;

ll f(ll a, ll x) {
  ll res = 1;
  while(x > 0) {
    if(x & 1) res = res * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return res;
}

ll rfac(ll x) {
  return f(x,mod - 2);
}

ll P(ll n, ll r) {
  return fac[n] * rfac(fac[n-r]) % mod;
}


int main() {
  cin >> n >> a >> b >> c >> d;
  fac[0] = 1;
  for(int i = 1; i <= n; i++) {
    fac[i] = i * fac[i-1] % mod;
  }

  dp[a-1][0] = 1;

  for(ll i = a; i <= b; i++) {
    for(ll j = 0; j <= n; j++) dp[i][j] = dp[i-1][j];
    for(ll j = 0; j <= n; j++) {
      for(ll k = c; k <= d; k++) {
	ll x = k * i;
	if(j - x < 0) continue;
	dp[i][j] = (dp[i][j] + (dp[i-1][j-x] * P(j,x) % mod) * rfac(f(fac[i],k) * fac[k] % mod) % mod) % mod; 
      }
    }
  }

  cout << dp[b][n] % mod << endl;
}




    


Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
    string s;
    
    cin >> s;
    string t = "";
    string r = s;
    reverse(s.begin(), s.end());
    
    for (int i = 0; i < r.length(); i++) {
        if (r[i] == 'b') t += 'd';
        else if (r[i] == 'd') t += 'b';
        else if (r[i] == 'p') t += 'q';
        else if (r[i] == 'q') t += 'p';
    }
    
    if (t == s) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <limits>

using namespace std;
using ull = unsigned long long;

int main() {
    ull l, r;
    cin >> l >> r;
    ull x = numeric_limits<ull>::max();
    for (ull i = l; i < r; ++i) {
        for (ull j = l + 1; j <= r; ++j) {
            if ((i * j) % 2019 == 0) {
                cout << 0 << endl;
                return 0;
            }
            x = min(x, (i * j) % 2019);
        }
    }
    std::cout << x << std::endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 

void solve()
{
	int n;
	cin>>n;
	vector<vector<p64> > matrix(n);
	for (int i=0; i<n; i++)
	{
		int x;
		cin>>x;
		for (int j=0; j<x; j++)
		{
			int a,b;
			cin>>a>>b;
			a--;
			matrix[i].push_back(p64(a,b));
		}
	}
	int ans=0;
	// cout<<((16>>3))<<endl;
	for (int i=0; i<(1<<n); i++)
	{
		bool f=1;
		for (int j=0; j<n; j++)
		{
			if ((i & (1<<j))==0)
				continue;
			for (int k=0; k<matrix[j].size(); k++)
			{
				int x=matrix[j][k].fi;
				int y=matrix[j][k].se;
				if (( (i>>x) & 1) != y)
					f=0;
			}
		}
		if (f)
			ans=max(ans,__builtin_popcount(i));
	}	
	cout<<ans<<endl;
}
int32_t main()
{
    fast_cin();
    int t;
    t=1;
    while (t--)
    {
    	solve();
    }
    return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u) {
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for ( v = 0; v < n; v++ ) {
    if ( M[u][v] == 0) continue;
    if ( color[v] == WHITE )
      dfs_visit(v);
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs() {
  int u;
  for ( u = 0; u < n; u++ ) color[u] = WHITE;
  tt = 0;

  for ( u = 0; u < n; u++ )
    if ( color[u] == WHITE ) dfs_visit(u);
  for ( u = 0; u < n; u++ )
    printf("%d %d %d\n", u + 1, d[u], f[u]);
}

int main() {
  int u, v, k, i, j;

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

  for ( i = 0; i < n; i++ ) {
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ) {
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}


Measured memory_bytes: 2732
n = int(input())

def divs(n:int):
    divs = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    return len(divs)

ans = 0
for i in range(1,n+1,2):
    if divs(i) == 8:
        ans += 1

print (ans)


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

count = 0
for i in range(N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
    if minj != i:
        A[i], A[minj] = A[minj], A[i]
        count += 1

for k in range(N):
        if k > 0:
            print(' ', end='')
        print(A[k], end='')

print('')
print(count)


Measured memory_bytes: 5620
import itertools
l,r=map(int,input().split())
d = r-l
mod_min=2018
if d > 2017:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019
    if lmod < rmod:
        mod_set = set(range(lmod,rmod+1))
    else:
        mod_set = set(range(r+1))|set(range(l,2019))
    for x,y in itertools.combinations(mod_set,2):
        mod_min = min(mod_min,(x*y)%2019)
    print(mod_min)

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

bool solve(){
    int n;
    cin >> n;
    if(n == 0) return false;
    int y, b, t;
    double r, maxi = 0;
    cin >> y;
    int ans = 0;
    for(int i=0;i<n;i++){
        cin >> b >> r >> t;
        double tmp;
        if(t == 1){
            tmp = (1.0+y*(r/100));
        }else{
            tmp = pow(1.0+(r/100), y);
        }
        if(tmp > maxi){
            maxi = tmp;
            ans = b;
        }
    }
    cout << ans << endl;
    return true;
}

int main(){
    while(solve());
    return 0;
}



Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	int A[N + 1];
	for(int i = 0; i < N + 1; i++) cin >> A[i];
	int B[N];
	for(int i = 0; i < N; i++) cin >> B[i];

	ll ans = 0;
	for(int i = 0; i < N; i++) {
		if(A[i] <= B[i]) {
			ans += A[i];
			B[i] -= A[i];
			ans += min(A[i + 1], B[i]);
			A[i + 1] = max(0, A[i + 1] - B[i]);
		} else
			ans += B[i];
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 1024
// =====================================================================================
// 
//       Filename:  C.cpp
//        Created:  2017년 06월 10일 21시 02분 41초
//       Compiler:  g++ -O2 -std=c++14
//         Author:  baactree ,  bsj0206@naver.com
//        Company:  Chonnam National University
// 
// =====================================================================================

#include <bits/stdc++.h>
using namespace std;
int n;
int arr[100];
set<int> s;
int cnt;
int main(){
	scanf("%d", &n);
	for(int i=0;i<n;i++){
		int in;
		scanf("%d", &in);
		if(in<400){
			s.insert(0);
		}
		else if(in<800){
			s.insert(1);
		}
		else if(in<1200){
			s.insert(2);
		}
		else if(in<1600){
			s.insert(3);
		}
		else if(in<2000){
			s.insert(4);
		}
		else if(in<2400){
			s.insert(5);
		}
		else if(in<2800){
			s.insert(6);
		}
		else if(in<3200){
			s.insert(7);
		}
		else{
			cnt++;
		}
	}
	printf("%d %d\n", max(1, (int)s.size()), (int)s.size()+cnt);
	return 0;
}



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

using namespace std;

char dp[1<<24];
int n, x[25], y[25], r[25], c[25], up[25];

int main(){
	int i, j,k, ans;
	while(1){
		cin >> n;
		if(!n) break;
		ans = 0;
		for(i=0;i<(1<<n);i++) dp[i]=-1;
		for(i=0;i<24;i++) up[i] = 0;
		for(j=0;j<n;j++){
			cin >> x[j] >> y[j] >> r[j] >> c[j];
		}
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(pow(x[i]-x[j],2)+pow(y[i]-y[j],2) < pow(r[i]+r[j],2)){
					up[j] += 1<<i;
				}
			}
		}
		dp[(1<<n)-1]=0;
		for(i=(1<<n)-1;i>=0;i--){
			ans = max(ans, (int)dp[i]);
			if(dp[i]==-1)continue;
			for(j=0;j<n;j++){
				if((i&(1<<j))==0||(up[j]&i)) continue;
				for(k=j+1;k<n;k++){
					if((i&(1<<k))==0||(up[k]&i)||(c[j]!=c[k])) continue;
					int yy = i - (1<<j) - (1<<k);
					dp[yy] = max((int)dp[i]+2,(int)dp[yy]);
				}
			}
		}
		
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 17528
D = gets.to_i
C = gets.chomp.split.map(&:to_i)
s = D.times.map{gets.split.map(&:to_i)}
c = Array.new(26, 0)
t = []

(0..D-1).each do |i|

  (0..25).each do |l|
    c[l] += C[l]
  end
ans = 0
boder = s[i][0]+11*c[0]

  (1..25).each do |e|
    if s[i][e]+11*c[e] >= boder
      ans = e
      boder = s[i][e]+11*c[e]
    end
  end
c[ans] = 0
puts ans+1
end


  



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

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif
/*---------------------------Defines----------------------*/
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
/*-----------------------Modular Arithmetic---------------*/
inline ll add(ll x,ll y,ll mod){x+=y; if(x>=mod) return x-mod; return x;}
inline ll sub(ll x,ll y,ll mod){x-=y; if(x<0) return x+mod; return x;}
inline ll mul(ll x,ll y,ll mod){return (x*1ll*y)%mod;}
inline ll power(ll x,ll y,ll mod){ll ans=1; while(y){if(y&1) ans=mul(ans,x,mod); x=mul(x,x,mod); y>>=1;} return ans;}
inline ll inv(ll x,ll mod){return power(x,mod-2,mod);}
/*-----------------------------Code begins----------------------------------*/

const ll INF = 1e18;

void solve(){
    ll a;
    double bb;
    cin>>a>>bb;
    ll b=bb*100+0.5;
    ll ans=(a*1LL*b)/100;
    cout<<ans<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);
    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3692
import math
def koch(n, p1, p2):
    if n == 0:
        return None
    s = [(p1[0] * 2 + p2[0]) / 3, (p1[1] * 2 + p2[1]) / 3]
    t = [(p1[0] + p2[0] * 2) / 3, (p1[1] + p2[1] * 2) / 3]
    u = [
        (t[0] - s[0]) * math.cos(math.pi / 3) - (t[1] - s[1]) * math.sin(math.pi / 3) + s[0],
        (t[0] - s[0]) * math.sin(math.pi / 3) + (t[1] - s[1]) * math.cos(math.pi / 3) + s[1]
    ]

    koch(n-1, p1, s)
    print(f"{s[0]:.8f} {s[1]:.8f}")
    koch(n-1, s, u)
    print(f"{u[0]:.8f} {u[1]:.8f}")
    koch(n-1, u, t)
    print(f"{t[0]:.8f} {t[1]:.8f}")
    koch(n-1, t, p2)

n = int(input())
print(0, 0)
koch(n, [0.0, 0.0], [100.0, 0.0])
print(100, 0)



Measured memory_bytes: 5784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;

int partition(int A[], int p, int r){
    int x = A[r];
    int i = p-1;
    for(int j = p; j < r;j++){
        if(A[j] <= x){
            i = i+1;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}

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

    int n;
    cin >> n;
    int A[n];
    for(int i = 0; i < n;i++){
        cin >> A[i];
    }
    int r = A[n-1];
    int ind = partition(A,0,n-1);
    for(int i = 0; i < n;i++){
        if(i == ind){
            cout << "[" << A[i] << "] ";
        }else if(i == n-1){
            cout << A[i];
        }else{
            cout << A[i] << " ";
        }
    }
    cout << endl;


    return 0;
}


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

int main()
{
  int r,c;
  cin >> r >> c;
  int A[r+1][c+1];

  // initialize
  for(int i=0; i<r+1; i++){
    for(int j=0; j<c+1; j++){
      A[i][j] = 0;
    }}

  // input
  for(int i=0; i<r; i++){
    for(int j=0; j<c; j++){
      cin >> A[i][j] ;
    }}

    // culculation
    int t,y;
    
    // yoko
    for(int i=0; i<r; i++){
      y = 0;
      for(int j=0; j<c; j++){	
	y = y + A[i][j];
      }
      A[i][c] = y;
    }
    // tate
    for(int i=0; i<c; i++){
      t = 0;
      for(int j=0; j<r; j++){
	t = t + A[j][i];
      }
      A[r][i] = t;
    }

    // total
    int total = 0;
    for(int i=0; i<r; i++){
      for(int j=0; j<c; j++){
	total = total + A[i][j];
      }}
    A[r][c] = total;

    //   cout << endl << "CHECK  " << total << endl;
    

    // output
    for(int i=0; i<r+1; i++){
      for(int j=0; j<c+1; j++){
	if(j != 0)
	  {cout << " " << flush;}
	cout << A[i][j] << flush;}
      cout << endl;
    }
    return 0;
}


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

int main() {
	int n, cnt1 = 0, cnt2 = 0;
	cin >> n;

	vector < int > a(n), b(n), p(n), q(n);

	for ( auto &i: a ) {
		cin >> i;
	}
	for ( auto &i: b ) {
		cin >> i;
	}
	for ( int i = 0; i < n; i++ ) {
		p[i] = i + 1;
		q[i] = i + 1;
	}
	do {
		cnt1++;
		int ok = 1;

		for ( int i = 0; i < n; i++ ) {
			if ( p[i] != a[i] ) {
				ok = 0;
				break;
			}
		}
		if ( ok ) {
			break;
		}
	}
	while ( next_permutation( p.begin(), p.end() ) );

	do {
		cnt2++;
		int ok = 1;

		for ( int i = 0; i < n; i++ ) {
			if ( q[i] != b[i] ) {
				ok = 0;
				break;
			}
		}
		if ( ok ) {
			break;
		}
	}
	while ( next_permutation( q.begin(), q.end() ) );

	cout << abs( cnt1 - cnt2 );
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

int main() {
    SS(ll,a,b);
    for(int i=1;i<=100000;i++){
        if(floor(i*0.08)==a&&floor(i*0.1)==b){
            p(i);
            return 0;
        }
    }
    p(-1);
}

Measured memory_bytes: 256