akhauriyash/Code-Regression huggingface dataset:
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
		
const double eps = 1e-9;																							   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	int a, b, c;
	cin >> a >> b >> c;
	if(a + b >= c){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	









	return 0;
}


Measured memory_bytes: 256
#include <iostream>
    using namespace std;
     
    int main() {
        //Recieve the inputs
        int D, T, S;
        cin >> D >> T >> S;
     
        //Calculate the possible distance of Takahashi's travel
        int dist = S * T;
     
        //Output depending on the inequality between D and dist
        if (dist >= D) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int pid=0,pnum=0,rpid[NUM];LL costa[NUM],costb[NUM],cpid[NUM],que[NUM];
int judge(int a,int b){if(pnum<b||b==1)return 0;return cpid[que[a]]>cpid[que[b]]?1:0;}
void push(LL a,int n){int i=++pid,j=++pnum;rpid[i]=n,cpid[i]=a,que[j]=i;while(judge(j/2,j))que[j]=que[j/2],que[j/=2]=i;}
int pop(){int ans=rpid[que[1]],i=1,j;LL n=que[pnum--];que[1]=n;while(judge(i,j=i*2+judge(i*2,i*2+1)))que[i]=que[j],que[i=j]=n;return ans;}
void Dijkstrau(int v,int e,int* a,int* b,int* l,int ver){int i,flag[NUM]={0},pre[e+1],last[e+1];FOR(i,1,v+1)costa[i]=LNF,last[i]=-1;costa[ver]=0;FOR(i,0,e)pre[i]=last[a[i]],last[a[i]]=i;while(flag[ver]==0){flag[ver]++;for(i=last[ver];i+1;i=pre[i])if(costa[b[i]]>costa[ver]+l[i]){costa[b[i]]=costa[ver]+l[i];push(costa[b[i]],b[i]);}while(flag[ver]&&pnum)ver=pop();}}
void Dijkstrav(int v,int e,int* a,int* b,int* l,int ver){int i,flag[NUM]={0},pre[e+1],last[e+1];FOR(i,1,v+1)costb[i]=LNF,last[i]=-1;costb[ver]=0;FOR(i,0,e)pre[i]=last[a[i]],last[a[i]]=i;while(flag[ver]==0){flag[ver]++;for(i=last[ver];i+1;i=pre[i])if(costb[b[i]]>costb[ver]+l[i]){costb[b[i]]=costb[ver]+l[i];push(costb[b[i]],b[i]);}while(flag[ver]&&pnum)ver=pop();}}

int main(){
  int N,u,v,i;
	LL ans=0;
  scanf("%d%d%d",&N,&u,&v);
	int A[2*N-2],B[2*N-2],l[2*N-2];
	FOR(i,0,N-1)scanf("%d%d",&A[i],&B[i]);
	FOR(i,0,N-1)A[N-1+i]=B[i],B[N-1+i]=A[i],l[i*2]=1,l[i*2+1]=1;
	Dijkstrau(N,2*N-2,A,B,l,u);
	Dijkstrav(N,2*N-2,A,B,l,v);
	ans=costb[u];
	FOR(i,1,N+1)if(costa[i]<costb[i])ans=MAX(ans,costb[i]);

	printf("%lld\n",ans-1);
	return 0;
}


Measured memory_bytes: 13184
#pragma warning(disable:4996)
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<time.h>

using namespace std;
typedef unsigned long long ull;

int main() {
	ull n;
	cin >> n;
	for (ull i = sqrt(n); i >=1 ; --i) {
		if (n % i == 0) {
			cout << i + n / i - 2;
			break;
		}
	}

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	ll i,a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2==0)cout<<(a-b);
	else cout<<(a-b)*(-1);
	
	
	
	
	
	
	
	
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
struct point{
    ll x, y;
};
typedef vector<point> vp;

/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n, k, a, answer = 0; cin >> n >> k;
    map<int,int> a_map;
    vi a_vec;
    for(int i = 0; i < n; i++){
        cin >>a; 
        auto itr = a_map.find(a);
        if(itr != a_map.end()) a_map[a]++;
        else a_map[a] = 1;
    }
    int sa =  a_map.size() - k;
    for(auto i : a_map){
        a_vec.push_back(i.second);
    }
    sort(a_vec.begin(), a_vec.end());
    for(int i = 0; i < sa; i++){
        answer += a_vec.at(i);
    }
    cout << (answer >= 0 ? answer : 0) <<'\n';
}

Measured memory_bytes: 10744
#include <bits/stdc++.h>
using namespace std;
 
typedef long long           ll;
typedef vector<int>         vi;
typedef vector<ll>          vll;

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                10000
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

int main(){
        int n, k; sii(n, k);
        vi v(n);
        FOR(i, 0, n) si(v[i]);
        sort(all(v));
        int sum = 0;
        FOR(i, 0, k) sum += v[i];
        cout << sum << endl;


    return 0;
}

Measured memory_bytes: 3692
function Main(input) {
    const arr = [
  '1',                  '3',                  '4',
  '7',                  '11',                 '18',
  '29',                 '47',                 '76',
  '123',                '199',                '322',
  '521',                '843',                '1364',
  '2207',               '3571',               '5778',
  '9349',               '15127',              '24476',
  '39603',              '64079',              '103682',
  '167761',             '271443',             '439204',
  '710647',             '1149851',            '1860498',
  '3010349',            '4870847',            '7881196',
  '12752043',           '20633239',           '33385282',
  '54018521',           '87403803',           '141422324',
  '228826127',          '370248451',          '599074578',
  '969323029',          '1568397607',         '2537720636',
  '4106118243',         '6643838879',         '10749957122',
  '17393796001',        '28143753123',        '45537549124',
  '73681302247',        '119218851371',       '192900153618',
  '312119004989',       '505019158607',       '817138163596',
  '1322157322203',      '2139295485799',      '3461452808002',
  '5600748293801',      '9062201101803',      '14662949395604',
  '23725150497407',     '38388099893011',     '62113250390418',
  '100501350283429',    '162614600673847',    '263115950957276',
  '425730551631123',    '688846502588399',    '1114577054219522',
  '1803423556807921',   '2918000611027443',   '4721424167835364',
  '7639424778862807',   '12360848946698171',  '20000273725560978',
  '32361122672259149',  '52361396397820127',  '84722519070079276',
  '137083915467899403', '221806434537978679', '358890350005878082',
  '580696784543856761', '939587134549734843'
]
console.log(arr[input-1]);
}Main(require("fs").readFileSync("/dev/stdin","utf8").trim());


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;

char to(char c) {
  return (c + 0x20);
}

int main(){
  int N,K;
  cin>>N>>K;
  K = K-1;
  string s;
  cin>>s;
  s.at(K) == to(s.at(K));
  for(int i = 0;i<N;i++){
    if(i == K){
      cout << to(s.at(i));
    }
    else{
      cout << s.at(i);
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
# 0と1で表せる。
# hの選び方, 0,0, 1,0 0,1 1,1
# wの選び方, 0,0,0, 0,0,1, 0,1,0, 1,0,0, 0,1,1, 1,0,1, 1,1,0, 1,1,1

h,w,k=gets.split.map &:to_i
c = h.times.map { gets.chomp.chars }
c2 = Marshal.load(Marshal.dump(c))
res=0
=begin
#ph = [*0..h]
#pw = [*0..w]
pc = [h,w].max
p c
h.times do |i|
  w.times do |j|
   c[i][j]
  end
end
=end
ch = [0,1].repeated_permutation(h).to_a
cw = [0,1].repeated_permutation(w).to_a

# 組み合わせを全て試す。
ch.each do |i|
  cw.each do |j|
    # 赤く塗る作業
    # indexメソッドだと全ての1を取得できない
    #h_paint_idx = i.index(1)
    #h_paint_idx = j.index(1)
    i.each_with_index do |ii, eii|
      j.each_with_index do |jj, ejj|
        #if i == [0, 0] && j == [0, 1, 1]
        #  puts "=========#{jj}==and===#{j.index(jj)}===" 
        #end
        if ii == 1
          w.times do |wj|
            c[eii][wj] = 'red'
          end
        elsif  jj == 1
          h.times do |hi|
            c[hi][ejj] = 'red'
          end
        end # if end
      end # j
    end # i
    res += 1 if c.flatten.count('#') == k
    #p res
    #p c
    #puts "i:#{i}, j:#{j}"
    c = Marshal.load(Marshal.dump(c2))
    #p "##ターン##"
  end # cw
end # ch

puts res

Measured memory_bytes: 14168
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#define MAXN 100000
using namespace std;

typedef long long int lli;

int N, M;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> M;
    int s = 0, e = 1;
    for(int j = 0; j < M; j += 2){
        cout << min(s + 1, e + 1) << " " << max(s + 1, e + 1) << "\n";
        s--; e++;
        s = (s + N) % N;
        e %= N;
    }
    int m = (s + e) / 2;
    s = m - 1; e = m + 1;
    for(int j = 1; j < M; j += 2){
        cout << min(s + 1, e + 1) << " " << max(s + 1, e + 1) << "\n";
        s--; e++;
        s = (s + N) % N;
        e %= N;
    }
    return 0;
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Object o = run();
        if (o != null)
            System.out.println(o);
    }

    static Object run() {
        try (Scanner sc = new Scanner(System.in)) {
            String n = sc.next();
            long result = 0;
            for (char c : n.toCharArray()) {
                result += Integer.parseInt(String.valueOf(c));
                result %= 9;
            }
            return result == 0 ? "Yes" : "No";
        }
    }
}

class ChenNumberUtil {
    static Collection<Integer> getDivisors(int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                al.add(i);
                if (n / i != i)
                    al.add(n / i);
            }
        }
        Collections.sort(al);
        return al;
    }
}

class ChenBitUtil {
    static int popCount(int bit) {
        return Integer.bitCount(bit);
    }

    static boolean isFlag(int bit, int i) {
        return 0 != (bit & (1 << i));
    }

    static int setTrue(int bit, int i) {
        return bit |= (1 << i);
    }

    static int setFalse(int bit, int i) {
        return bit &= ~(1 << i);
    }

    static int setReverse(int bit, int i) {
        return isFlag(bit, i) ? setFalse(bit, i) : setTrue(bit, i);
    }

    static int reverseAll(int bit) {
        return ~bit;
    }
}


Measured memory_bytes: 41156
#include <iostream>
#include <vector>
#include <string.h>
#include <stdio.h>
using namespace std;

int main() {

    long long A, B, C;
    cin >> A >> B >> C;

    if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0)
        cout << 0 << endl;
    else {
        long long min_v = min(A*B, A*C);
        min_v = min(min_v, B*C);
        cout << min_v << endl;
    }

    return 0;
}


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

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

using namespace std;

typedef long long ll;

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

  string s;
  cin >> s;

  int ans = 0;

  if (s == "SUN") {
    ans = 7;
  } else if ( s == "MON" ) {
    ans = 6;
  } else if ( s == "TUE" ) {
    ans = 5;
  } else if ( s == "WED" ) {
    ans = 4;
  } else if ( s == "THU" ) {
    ans = 3;
  } else if ( s == "FRI" ) {
    ans = 2;
  } else if ( s == "SAT" ) {
    ans = 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())
t={}
for i in range(N):
    s = input()
    s = list(s)
    s.sort()
    s = ''.join(s)
    if t.get(s, None) == None:
        t[s] = 1
    else:
        t[s] += 1

ans = 0
for i in t.values():
    ans += i * (i-1) / 2
print(int(ans))

Measured memory_bytes: 17928
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD ((ll)1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)
template<class F,class S>void add(map<F,S>&mp,F f,S s){if(mp.find(f)==mp.end())mp[f]=F();mp[f]+=s;}
 
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}


int main(){
    dcl(h,w);
    vi a('z'+1,0);
    rep(i,h*w){
        char c;cin>>c;
        a[c]++;
    }
    vi x(3,0);
    vi need(3,0);
    for(auto i:a){
        x[0]+=i%2;
        x[1]+=i%4/2;
        x[2]+=i/4;
    }
    
    rep(i,h)rep(j,w){
        if(i<h/2 && j<w/2) need[2]++;
    }
    if(h%2){
        need[1]+=w/2;
    }
    if(w%2){
        need[1]+=h/2;
    }
    if(h%2 && w%2)need[0]++;
    // puti(x);
    // puti(need);

    bool ok=true;
    if(need[2]<=x[2]){
        x[1]+=(x[2]-need[2])*2;
    }else{
        ok=false;
    }
    if(need[1]<=x[1]){
        x[0]+=(x[1]-need[1])*2;
    }else{
        ok=false;
    }
    if(need[0]<=x[0]){
        ;
    }else{
        ok=false;
    }
    
    cout<<(ok?"Yes":"No")<<endl;
}


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

int main() {
    ll n;
    cin>>n;
    int mn=10;
    for (ll i=1;i*i<=n;i++)
        if (n%i==0)
            mn=min(mn,(int)max(to_string(i).size(),to_string(n/i).size()));
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  
  while(n--){
    int runner = 0;
    int out = 0;
    int point = 0;
    
    while(out<3) {
      string s;
      cin >> s;
      
      if(s=="HIT"){
	runner++;
      }

      else if (s=="OUT"){
	out++;
      }

      else if (s=="HOMERUN"){
	point+=runner+1;
	runner = 0;
      }
      
      if(runner == 4) {
	point++;
	runner = 3;
      }
      
    }
    cout << point << endl;
  }
  return 0;
}



Measured memory_bytes: 3160
import queue
I=lambda:map(int,input().split())
N,M=I()
ls=[[] for _ in range(N+1)]
for _ in[0]*M:
  A,B=I()
  ls[A]+=[B]
  ls[B]+=[A]
q = queue.Queue()
v=[-1]*(N+1)
v[0]=v[1]=0
q.put(1)
while not(q.empty()):
  top=q.get()
  for l in ls[top]:
    if v[l]<0:
      v[l]=top
      q.put(l)
if -1 in v:
  print("No")
else:
  print("Yes")
  [print(k) for k in v[2::]]

Measured memory_bytes: 35728
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int dis(int a,int b,int x,int y){
	return abs(a-x)+abs(b-y);
}
int main(){
	int n;
	cin>>n;
	vector<int>x(n),y(n),h(n);
	int a,b,c,hi,a1,a2,a3;
	rep(i,n) {cin>>x[i]>>y[i]>>h[i];if (h[i]>0) a1=x[i],a2=y[i],a3=h[i];}
	int flg;


	rep(i,101){
		rep(j,101){
			hi=dis(i,j,a1,a2)+a3;
			//cout<<"i="<<i<<"j="<<j<<"hi="<<hi<<endl;
			flg=0;
			rep(k,n) if((hi!=dis(i,j,x[k],y[k])+h[k]&&h[k]!=0)||(dis(i,j,x[k],y[k])<hi&&h[k]==0)) {flg=1;break;}
			if (flg==0) a=i,b=j,c=hi;
		}
	}
	cout<<a<<" "<<b<<" "<<c<<endl;



	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <numeric>
#include <ctime>
#include <algorithm>
#include <set>
#include <stdio.h>

using namespace std;

typedef enum {
	EMPTY,
	INTX,
	PLUS,
	EQ,
	_EOF
} token_kind_t;

class token{
public:
	int c;
	token_kind_t kind;
	string str;

	token();
	token next_tok();
};

token::token(){
	c = 0;
	kind = EMPTY;
	str.clear();
}

token token::next_tok()
{
	while (c == ' ' || c == '\n') {
		c = getchar();
	}
	if (isdigit(c) || c == 'X'){
		str.clear();
		kind = INTX;
		while (isdigit(c) || c == 'X'){
			char buf[2];
			buf[0] = c; buf[1] = 0;
			str.append(buf);
			c = getchar();
		}
	}
	else if (c == EOF){
		kind = _EOF;
		exit(0);
	}
	else{
		if (c == '+') kind = PLUS;
		else if (c == '=') kind = EQ;
		else exit(1);

		c = getchar();
	}

	return *this;
}

int fill(string &op, int X)
{
	int ret = 0;

	for (int i = 0; i < op.size(); i++){
		ret *= 10;
		if (op.at(i) == 'X'){
			ret += X;
		}
		else {
			ret += op.at(i) - '0';
		}
	}
	return ret;
}

void alphametic(string &op1, string &op2, string &op3)
{
	for (int X = 0; X < 10; X++){
		if (X == 0){
			if ((op1.size() > 1 && op1.at(0) == 'X') ||
				(op2.size() > 1 && op2.at(0) == 'X') ||
				(op3.size() > 1 && op3.at(0) == 'X'))
			{
				continue;
			}
		}
		int iop1 = fill(op1, X);
		int iop2 = fill(op2, X);
		int iop3 = fill(op3, X);
		if (iop1 + iop2 == iop3){
			cout << X << endl;
			return;
		}
	}
	cout << "NA" << endl;
}

int main()
{
	token t;

	t.c = getchar();
	t.next_tok();
	while (t.c != EOF){
		string op1 = t.str;
		t.next_tok();
		if (t.kind != PLUS) exit(1);
		t.next_tok();
		string op2 = t.str;
		t.next_tok();
		if (t.kind != EQ) exit(1);
		t.next_tok();
		string op3 = t.str;
		alphametic(op1, op2, op3);
		t.next_tok();
	}
	return 0;
}

Measured memory_bytes: 1172
#include<stdio.h>

int main(){
    int total[4];
    int method=0;
    int i,j,k=0;
    //printf("\n");
    int sum=0;


    //この下の１行だけでもいい。
    scanf("%d%d%d%d",&total[0],&total[1],&total[2],&total[3]);
    //金額sumの値を全数探索で計算
    for(i=0;i<=total[0];i++){
        for(j=0;j<=total[1];j++){
            for(k=0;k<=total[2];k++){
                sum=i*500+j*100+k*50;

                if(sum==total[3]){
                    method++;
                    //printf("%d,%d,%d sum=%d,method=%d\n",i,j,k,sum,method);

                }


            }

        }

    }
    printf("%d\n",method);
    //printf("%d円となる方法の数は%d\n",total[3],method);
    return 0;
}


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

using namespace std;

int main(){
	int x,n;
	cin >> x >> n;
	if( n == 0){
		cout << x << "\n";
		return 0;
	}
	vector<int> p(200);
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		++p[x];
	}
	int best = -1;
	int mn = 100000;
	for(int i = 0; i < 200; i++){
		if(p[i]==0){
			if(abs(x - i) < mn){
				mn = abs(x-i);
				best = i;
			}
		}
	}
	cout << best << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

struct uf {
private:
	vector<int> par, ran;
public:
	void init(int n) {
		par.resize(n, 0);
		ran.resize(n, 0);
		rep(i, n) {
			par[i] = i;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y)return;
		if (ran[x] < ran[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (ran[x] == ran[y])ran[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

struct vertice {
	int l, r;
	ll cost;
	bool operator<(const vertice &v)const {
		return (vec{ cost,l,r } < vec{v.cost, v.l,v.r});
	}
};
ll v[1<<18];
void solve() {
	int n, q; cin >> n >> q;
	vector<vertice> al;
	fill(v, v + n, INF);
	rep(i, q) {
		int a, b; ll c; cin >> a >> b >> c;
		al.push_back({ a,b,c });
		v[a] = min(v[a], c + 1);
		v[b] = min(v[b], c + 2);
	}
	ll mi = INF; int chk;
	rep(i, n) {
		if (v[i] < mi) {
			mi = v[i]; chk = i;
		}
	}
	ll curc = mi;
	rep(j, n) {
		int id = (j + chk) % n;
		curc = min(curc, v[id]);
		al.push_back({ id,(id + 1) % n,curc });
		curc += 2;
	}
	ll ans = 0;
	sort(al.begin(), al.end());
	uf u; u.init(n);
	rep(i, al.size()) {
		int l = al[i].l, r = al[i].r; ll c = al[i].cost;
		if (!u.same(l, r)) {
			u.unite(l, r);
			ans += c;
		}
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


Measured memory_bytes: 16360
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(){
int x,y;
cin>>x>>y;
char c[101];
for (int j=0 ; j<x ; j++){
    for(int i=0 ; i<y ; i++){
        cin>>c[i];
    }
    for(int l=0 ; l<y ;l++){
        cout <<c[l];
    }
    cout<<"\n";
     for(int l=0 ; l<y ;l++){
        cout <<c[l];
    }
    cout<<"\n";
}
return 0;
}


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

int main(void){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    string ans = "";
    ans += s1.at(0);
    ans += s2.at(0);
    ans += s3.at(0);

    cout << ans << endl;
}

Measured memory_bytes: 256
A = [[int(zz) for zz in input().split()] for _ in range(3)]
N = int(input())

hit = [[0]*3 for _ in range(3)]
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                hit[i][j] = 1

for i in range(3):
    if sum(hit[i]) == 3:
        print('Yes')
        exit()

for i in range(3):
    if hit[0][i]*hit[1][i]*hit[2][i] == 1:
        print('Yes')
        exit()

if hit[0][0]*hit[1][1]*hit[2][2] == 1 or hit[0][2]*hit[1][1]*hit[2][0] == 1:
    print('Yes')
    exit()

print('No')


Measured memory_bytes: 3064
#include <stdio.h>

long gcd(long a, long b)
{
    long c;
    while ( a != 0 ) {
        c = a;
        a = b % a;
        b = c;
    }
    return b;
}

int main() {
    long a, b;
    long tmp_gcd;
    
    while (scanf("%ld %ld", &a, &b) != EOF) {
        tmp_gcd = gcd(a, b);
        printf("%ld %ld\n", tmp_gcd, (a * b) / tmp_gcd);
    }
    return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int ab=sc.nextInt(),bc=sc.nextInt(),ca=sc.nextInt();
        System.out.println(ab*bc/2);

    }
}


Measured memory_bytes: 22740
#include<iostream>
#include<vector>
using namespace std;
#define MAX 10005
int n,k,m;

int bit[MAX];
void init(){for(int i=0;i<MAX;i++)bit[i]=0;}
int sum(int i){
  int s=0;
  while(i>0){
    s+=bit[i];
    i-=i&-i;
  }
  return s;
}

void add(int i,int x){
  while(i<=n){
    bit[i]+=x;
    i+=i&-i;
  }
}

void func(int a){
  int L=1,R=n,M;

  while(L<R){
    M=(L+R)/2;
    int v=M-sum(M);
    if(a<=v)R=M;
    else L=M+1;
  }
  add(L,1);
}

int main(){
  while(1){
    cin>>n>>k>>m;    
    if(n==0&&k==0&&m==0)break;
    init();

    int cnt=n;

    m--;
    for(int i=0;i<n-1;i++){
      func(m+1);
      cnt--;

      if(m==cnt)m=0;
      m+=k-1;
      m%=cnt;
    }

    int ans;
    for(int i=1;i<=n;i++){
      if(i!=sum(i)){
	ans=i;
	break;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  string s; cin >> s;
  int cnt[26] = {};
  REP(i, 4){
    cnt[s[i]-'A']++;
  }
  int a = 0;
  REP(i, 26){
    if(cnt[i] > 0){
      if(cnt[i] != 2){
        cout << "No" << endl; cerr << "a" << endl;
        return 0;
      }
      a++;
    }
  }
  if(a != 2){
    cout << "No" << endl; cerr << "b" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
S=input()

if S=="MON":
    print(6)
elif S=="TUE":
    print(5)
elif S=="WED":
    print(4)
elif S=="THU":
    print(3)
elif S=="FRI":
    print(2)
elif S=="SAT":
    print(1)
elif S=="SUN":
    print(7)

Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int read(){
	int x=0,w=1;
	char ch=0;
	while (ch<'0' || ch>'9'){
		  if (ch=='-') w=-1;
		  ch=getchar();
	}
	while (ch<='9' && ch>='0'){
		  x=(x<<1)+(x<<3)+ch-'0';
		  ch=getchar();
	}
	return x*w;
}
int a[100]; 
struct node{
	int x,y;
}s[100010];
int Abs(int x){
	return x>0?x:-x;
}
int main(){
	int n=read();
	for (int i=1;i<=n;++i)
		a[i]=read();
	int max=-1,id,ans=0;
	for (int i=1;i<=n;++i)
		if (max<Abs(a[i])){
			max=Abs(a[i]);
			id=i;
		}	
	for (int i=1;i<=n;++i){
		a[i]+=a[id];
		s[++ans].x=id;
		s[ans].y=i;
	}
	if (a[1]>0){
		for (int i=2;i<=n;++i)
			if (a[i]<a[i-1]){
				a[i]+=a[i-1];
				s[++ans].x=i-1;
				s[ans].y=i; 
			}
	}else{
		for (int i=n-1;i>=1;--i)
			if (a[i]>a[i+1]){
				a[i]+=a[i+1];
				s[++ans].x=i+1;
				s[ans].y=i; 
			}	
	}
	printf("%d\n",ans);
	for (int i=1;i<=ans;++i)
		printf("%d %d\n",s[i].x,s[i].y);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main()
{
	char b;

	cin >> b;

	if(b == 'A')
	{
		cout << 'T' << endl;
	}
	else if(b == 'T')
	{
		cout << 'A' << endl;
	}
	else if(b == 'G')
	{
		cout << 'C' << endl;
	}
	else if(b == 'C')
	{
		cout << 'G' << endl;
	}

	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);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = 2 * (a + b);
        System.out.println(area + " " + length);
        sc.close();
    }
}


Measured memory_bytes: 26104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, M;
vector<ll> A, B, L, R;
vector<ll> cmp;
vector<ll> field;
vector<ll> delta;
vector<bool> visited;
vector<int> ans;
bool clear = true;
vector<vector<i_i>> paths;

bool dfs(int now, int e) {
    if(visited[now]) return false;
    visited[now] = true;
    for(auto tmp : paths[now]) {
        int to = tmp.first;
        int idx = tmp.second;
        if(dfs(to, idx)) {
            ans.push_back(idx);
            if(now < N) delta[now] ^= 1;
        }
    }
    if(e != -1) {
        return delta[now];
    }
    if(now != N and delta[now] == 1) clear = false;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    visited.resize(N + 1);
    paths.resize(N + 1);
    A.resize(N);
    B.resize(N);
    L.resize(M);
    R.resize(M);
    field.resize(N);
    delta.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        cmp.push_back(A[i]);
    }
    sort(cmp.begin(), cmp.end());
    for(int i = 0; i < N; i++) {
        auto itr = lower_bound(cmp.begin(), cmp.end(), A[i]);
        A[i] = distance(cmp.begin(), itr);
        //cerr << i << " " << A[i] << " " << B[i] << endl;
        field[A[i]] = B[i];
    }
    delta[0] = field[0];
    for(int i = 1; i < N; i++) {
        delta[i] = field[i] ^ field[i-1];
    }
    for(int i = 0; i < N; i++) cerr << field[i];
    cerr << endl;
    for(int i = 0; i < N; i++) cerr << delta[i];
    cerr << endl;
    for(int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
        auto itr = lower_bound(cmp.begin(), cmp.end(), L[i]);
        L[i] = distance(cmp.begin(), itr);
        itr = upper_bound(cmp.begin(), cmp.end(), R[i]);
        R[i] = distance(cmp.begin(), itr);
        //cerr << L[i] << " " << R[i] << endl;
        paths[L[i]].push_back({R[i], i});
        paths[R[i]].push_back({L[i], i});
    }
    for(int i = N; i >= 0; i--) {
        dfs(i, -1);
    }
    if(!clear) {
        cout << -1 << endl;
    } else {
        sort(ans.begin(), ans.end());
        cout << ans.size() << endl;
        for(int i = 0; i < ans.size(); i++) {
            if(i != 0) cout << " ";
            cout << ans[i] + 1;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 21108
#include <bits/stdc++.h>
using namespace std ;
const int MAXN = 200000 + 5 ;
int n , t ;
int a[ MAXN ] ;
inline int read () {
	int tot = 0 , f = 1 ;
	char c = getchar () ;
	while ( c < '0' || c > '9' ) {
		if ( c == '-' ) f = -1 ;
		c = getchar () ;
	}
	while ( c >= '0' && c <= '9' ) {
		tot = ( tot << 1 ) + ( tot << 3 ) + ( c ^ 48 ) ;
		c = getchar () ;
	}
	return tot * f ;
	
}
signed main () {
	n = read () ; a[ 1 ] = read () ;
	t = a[ 1 ] ;
	for ( int i = 2 ; i <= n ; i ++ ) {
		a[ i ] = read () ;
		t ^= a[ i ] ;
	}
	for ( int i = 1 ; i <= n ; i ++ ) {
		cout << ( t ^ a[ i ] ) << " " ; 
	}
	cout << endl ;
	return 0 ;
}

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

int main (){
  int n;
  cin >> n;
  long long hoge = 0;
  for(int i = 1; i <= n; i++){
    if(i % 3 != 0 && i % 5 != 0){
      hoge += i;
    }
  }
  cout << hoge << endl;
  return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int main(){

	vector<pair<pair<int,int>,int>> ans;
	REP(i,13){
		ans.PB(MP(MP(i+1,i+2),0));
	}

	int n;cin >> n;n--;
	int now = 0;
	for(int i = 0;i < 13;i++){
		if(2 * now + 1 <= n){
			ans.PB(MP(MP(i+1,i+2),now+1));
			now = 2 * now + 1;
		}
		else{
			break;
		}
		if(((now + 1) / 2) * 3 - 1 <= n){
			ans.PB(MP(MP(i+1,i+2),now+1));
			now = ((now + 1) / 2) * 3 - 1;
		}
		else {
			break;
		}
	}

	while(now != n){
		int tmp = 1;
		int num = 1;
		while(now + 3*tmp < n){
			tmp *= 3;
			num++;
		}
		ans.PB(MP(MP(num,14),now+1));
		now += tmp;
	}

	cout << 14 << " " << ans.size() << endl;
	REP(i,ans.size())cout << ans[i].FI.FI << " " << ans[i].FI.SE << " " << ans[i].SE << endl;

	return 0;
}


Measured memory_bytes: 384
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n,x=map(int,input().split())
xx = list(map(int,input().split()))
xx.append(x)
xx.sort()

dif=[]

for i in range(1,n+1):
    dif.append(xx[i]-xx[i-1])

print(gcd_list(dif))
    


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

#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 
#define INF 1999999999

int main() {
    int ans = 0;
    int N, M, a, b, c;
    cin >> N >> M;
    int dp[2][1<<12];
    
    REP(i, 2){
        REP(j, 1 << 12){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    
    int op;
    REP(i, M){
        cin >> a >> b;
        op = 0;
        REP(j, b){
            cin >> c;
            op |= 1 << (c-1);
        }
        REP(j, 1 << 12){
            if(dp[i&1][j] != INF){
                dp[(i+1)&1][j] = min(dp[(i+1)&1][j], dp[i&1][j]);
                dp[(i+1)&1][j|op] = min(dp[(i+1)&1][j|op], dp[i&1][j] + a);
            }
        }
    }
    int fop = (1 << N) - 1;
    if(dp[M&1][fop] != INF)cout << dp[M&1][fop] << endl;
    else cout << -1 << endl;
    
}

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

const ll big  = 1e18;

int main() {
  /*
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
  */
	int N; cin >> N;
	ll A[N];
	ll mul = 1;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		if (!A[i]) {
			cout << 0 << "\n";
			exit(0);
		}
	}
	for (int i = 0; i < N; ++i) {
		if (big/A[i] < mul) {
			cout << "-1" << "\n";
			exit(0);
		}
		mul *= A[i];
		if (mul > big) {
			cout << "-1" << "\n";
			exit(0);
		}
	}
	cout << mul << "\n";
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define test(t) int t;cin>>t;while(t--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
const int MOD = 1e9+7,MAX = 1e5+5;
ll powN(ll a,ll p,ll b)
{
	if(p==0) return 1;
	ll z=powN(a,p/2,b);
	z=(z*z)%b;
	if(p%2) z=(z*a)%b;
	return z;
}
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
ll modInv(ll a)
{
	return powN(a,MOD-2,MOD);
}



int main()
{
	ll fact[10];
	fact[0]=1;
	for(int i=1;i<10;i++) fact[i]=fact[i-1]*i;
	int n;
	cin>>n;
	int x[n],y[n];
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i];
	}
	double dis=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			dis+=(sqrt(pow((x[i]-x[j])*1.0,2)+pow((y[i]-y[j])*1.0,2))*2)/n;
		}
	}
	printf("%.7lf\n",dis);

}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] num = new int[n];
		for (int i = 0; i < n; i++)
			num[i] = scanner.nextInt();
		Arrays.sort(num);
		System.out.println(1);
		int x = 2;
		loop: while (x * 2 <= num[0]) {
			for (int i = 0; i < n; i++) {
				if (num[i] % x != 0) {
					x++;
					continue loop;
				}
			}
			System.out.println(x);
			x++;

		}
	}
}

Measured memory_bytes: 18896
#include "bits/stdc++.h"
#define ll long long
using namespace std;

ll lcm(ll a,ll b){
        ll tmp;
        ll c = a;
        c*=b;
        while((tmp = a%b)!=0){
        a=b;
        b=tmp;
        }
        return (c/b);
}

ll checkh(ll min,ll max,ll m1){
ll tmp = max/m1 - min/m1;
if(min%m1==0)
        tmp++;
return tmp;
}

int main(){
ll a,b,c,d;
cin>>a>>b>>c>>d;
cout<<b-a+1-(checkh(a,b,c)+checkh(a,b,d)-checkh(a,b,lcm(c,d)))<<endl;
}

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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if(x < y){
        swap(x, y);
        swap(a, b);
    }
    ll t1 = x * a + y * b;
    ll t2 = 2 * c * y + min((x - y) * a, (x - y) * 2 * c);
    cout << min(t1, t2);
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,w;
  cin>>n>>w;
  vector<vector<int>>a;long dp[n+1][w+1];
  a.push_back({0,0});
  for(int i=0;i<n+1;i++){
  for(int j=0;j<w+1;j++)dp[i][j]=0;}
  for(int i=1;i<=n;i++){
  int x,y;
  cin>>x>>y;
    a.push_back({x,y});
  }
   for(int i=1;i<=n;i++){
   for(int j=1;j<=w;j++){
                dp[i][j] = max(dp[i][j], dp[i-1][j]);
            if( j-a[i][0] >= 0 ) dp[i][j] = max(dp[i][j], dp[i-1][j-a[i][0]]+a[i][1]);
    // cout<<dp[i][j]<<" ";
   }//cout<<endl;
   }cout<<dp[n][w];
	
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
//issame:同じか判定
//unite:併合
//findroot:根の検索
//treesize:その木の要素数
struct UnionFind{
    vector<long long> size, par;
    UnionFind(long long n) {
        size.resize(n, 0);
        par.resize(n, 0);
        for (long long i = 0; i < n;i++){
            maketree(i);
        }
    }
    void maketree(long long x){
        par[x] = x;
        size[x] = 1;
    }
    long long findroot(long long x){
        if (x != par[x]) par[x] = findroot(par[x]);
        return par[x];
    }
    bool issame(long long x,long long y){
        return findroot(x) == findroot(y);
    }
    bool unite(long long x,long long y){
        x = findroot(x);
        y = findroot(y);
        if (x == y) return false;  //already united
        if(size[x]>size[y]){
            par[y] = x;
            size[x] += size[y];
        }
        else{
            par[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    long long treesize(long long x){
        return size[findroot(x)];
    }
};

int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(m), b(m);
    for (ll i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    vector<ll> c(k), d(k);
    for (ll i = 0; i < k; i++) {
		cin >> c[i] >> d[i];
        c[i]--;
        d[i]--;
    }
    UnionFind friends(n);
    vector<vector<ll>> wrong(n);
    for (ll i = 0; i < m; i++) {
        friends.unite(a[i], b[i]);
        wrong[a[i]].push_back(b[i]);
	    wrong[b[i]].push_back(a[i]);
    }
    for (ll i = 0; i < k;i++){
	    if(friends.issame(c[i],d[i])){
            wrong[c[i]].push_back(d[i]);
            wrong[d[i]].push_back(c[i]);
        }
    }
    for (ll i = 0; i < n;i++){
        cout << friends.treesize(i) - wrong[i].size() - 1 << " \n"[i == n - 1];
    }
}

Measured memory_bytes: 16660