akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int main(){
    
	int N, T, A;
  	cin >> N >> T >> A;
    int ans;
    double now = 1000;
  	for(int i=0; i<N; i++){
     	int tmp;
        cin >> tmp;
        if(now > abs(A-(T-tmp*0.006))){
             now = abs(A-(T-tmp*0.006));
             ans = i+1;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int r;
    scanf("%d", &r);
    if(r < 1200){
        printf("ABC\n");
    }else if(r >= 1200 && r < 2800){
        printf("ARC\n");
    }else{
        printf("AGC\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    
    long long a, b, c, k, res = 0;
    cin >> a >> b >> c >> k;
    if(k <= a){
        res = k;
    	cout << res << endl;
    }
     else if(k <= (a + b)){
     	res = a;
        cout << res << endl;
     }
    else{
        res = a + (k - (a + b)) * (-1);
    	cout << res << endl;
    }
  
	return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n,l; cin>>n>>l;
	int sum=0;
	for(int i=l;i<l+n;i++){
		sum+=i;
	}
	// cerr<<sum<<endl;
	int ans,diff=INF;
	for(int i=l;i<l+n;i++){
		if(abs(i)<diff){
			ans=sum-i;
			diff=abs(i);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
bool wh[51][51];
bool bl[51][51];
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
vector<string> grid;
int w,h;
void dfs(int x,int y,bool cl[51][51]){
  REP(r,4){
    int nx = x + dx[r];
    int ny = y + dy[r];
    if(nx >=0 && nx < w && ny >= 0 && ny < h){
      if(grid[ny][nx] == '.' && !cl[ny][nx]){
        cl[ny][nx] = true;
        dfs(nx,ny,cl);
      }
    }
  }
}
int main(){
  while(cin>>w>>h,w){
    memset(wh,0,sizeof(wh));
    memset(bl,0,sizeof(bl));
    grid = vector<string>(h);
    REP(i,h)cin>>grid[i];
    REP(y,h)REP(x,w){
      if(grid[y][x]=='W'){
        dfs(x,y,wh);
      }else if(grid[y][x] == 'B'){
        dfs(x,y,bl);
      }
    }
    int ans1=0,ans2=0;
    REP(y,h)REP(x,w){
      if(bl[y][x]&&!wh[y][x])ans1++;
      if(wh[y][x]&&!bl[y][x])ans2++;
    }
    printf("%d %d\n",ans1,ans2);
  }
  
  return 0;
}



  

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int ans;
bool def_2(int i,int j,int s){
	if(j==0){
		if(s==0){
			ans++;
		}else return false;
	}
	if(i>9)return false;
	if(s<=0)return false;
	def_2(i+1,j,s);
	def_2(i+1,j-1,s-i);
	return false;
}
int def(int k,int n,int s){
	if(n==0){
		if(s==0) return 1;
		else return 0;
	}
	int a=0;
	for(int i=k;i<=9;++i){
		a+=def(i+1,n-1,s-i);
	}
	return a;
}
main(){
	int s,n;
	while(cin>>n>>s,n||s){
		ans=0;
		cout<<def(0,n,s)<<endl;
		//cout<<ans<<endl;
	}
}

Measured memory_bytes: 1164
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define _GLIBCXX_DEBUG

using _loop_ll = long long;
#define REP(i,n) for(_loop_ll i=0; i<(_loop_ll)(n); i++)
#define FOR(i,a,b) for(_loop_ll i=(_loop_ll)(a); i<(_loop_ll)(b); i++)
#define FORR(i,a,b) for(_loop_ll i=(_loop_ll)(b)-1; i>=(_loop_ll)(a); i--)
 
#define ALL(v) (v).begin(),(v).end()
 
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

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

    int N;
    cin >> N;

    vl luc(100);
    luc[0] = 2;
    luc[1] = 1;
    FOR(i, 2, 87) luc[i] = luc[i-1] + luc[i-2];

    cout << luc[N] << endl;

    return 0;
};


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int h,w,i,p;
	while(1){
		scanf("%d %d",&h,&w);
		if((h+w)==0){break;}
		for(i=0;i<h;i++){for(p=0;p<w;p++){printf("#");}printf("\n");}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>

int main(int argc, char const* argv[])
{
	int m,n;
	int a[100][100];
	int b[100];
	int c[100] = {0,0,0};

	std::cin >> n >> m ;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			std::cin >> a[i][j] ;
		}
	}
	for (int i = 0; i < m; i++) {
		std::cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			c[i] += a[i][j] * b[j];
		}
	}
	for (int i = 0; i < n; i++) {
		std::cout << c[i] << std::endl;
	}

}

Measured memory_bytes: 1196
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll X,A;
    cin >> X >> A;
    if(X<A)cout <<0;else cout << 10;
    return 0;
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int n;
  string a,b,c;
  cin >> n;
  cin >> a >> b >> c;

  int cnt = 0;
  rep(i,n){
    if(a[i] == b[i] && a[i] == c[i] && b[i] == c[i]) continue;
    else if(a[i] == b[i]) cnt++;
    else if(a[i] == c[i]) cnt++;
    else if(b[i] == c[i]) cnt++;
    else cnt += 2;
  }

  cout << cnt << 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 sum = 0;
        int buf1 = -1;
        int buf2 = -1;
        for(int i = 0; i < a; i++){
            if(i != a - 1){
                buf1 = sc.nextInt();
            }
            if(i == 1){
                if(buf2 <= buf1){
                    sum += (buf2 * 2);
                }else{
                    sum += buf2 + buf1;
                }
            }else if(i == a - 1){
                sum += buf1;
            }else if(buf2 >= buf1 && buf2 >= 0){
                sum += buf1;
            }else if(buf2 < buf1 && buf2 >= 0){
                sum += buf2;
            }
            //System.out.println(buf2  + " " + buf1 + " " + sum);
            buf2 = buf1;
        }
        System.out.println(sum);
    }
}

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

using namespace std; 

int main(){
  string s="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  bool x=false;
  int h,w;
  cin>>h>>w;
  vector<vector<string>> data(h, vector<string>(w)); 

for (int i = 0; i < h; i++) { 

for (int j = 0; j < w; j++) { 

cin >> data.at(i).at(j); 
  if(data.at(i).at(j)=="snuke"){
    cout<<s[j]<<i+1;
    x=true;
    break;
  }
  if (x==true){
    break;
  }
}
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define sti stack<int>
#define stkl stack<ll>
#define qi queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
using namespace std;
int c=0;

void solve(){
	string s;
	cin>>s;
	int n=s.size();
	if(s[n-1]=='s')
		s+="es";
	else
		s+='s';
	cout<<s<<endl;
}
 
int main(){
    IOS;
    int q=1;
    //cin>>q;
    while(q--){
    	c++;
        solve();
    }
}


Measured memory_bytes: 3644
n, a, b, c = map(int, input().split())
L = [a, b, c]
X = [0]*n
for i in range(n):
    s = str(input())
    if s == 'AB':
        x, y = 0, 1
    elif s == 'AC':
        x, y = 0, 2
    else:
        x, y = 1, 2
    X[i] = (x, y)

ans = []
for i in range(n):
    x, y = X[i]
    if i != n-1:
        if L[x] == 0 and L[y] == 0:
            print('No')
            exit()
        else:
            if L[x] == 0:
                L[x] += 1
                L[y] -= 1
                ans.append(x)
            elif L[y] == 0:
                L[x] -= 1
                L[y] += 1
                ans.append(y)
            else:
                nx, ny = X[i+1]
                if x in {nx, ny}:
                    L[x] += 1
                    L[y] -= 1
                    ans.append(x)
                else:
                    L[x] -= 1
                    L[y] += 1
                    ans.append(y)
    else:
        if L[x] == 0 and L[y] == 0:
            print('No')
            exit()
        else:
            if L[x] == 0:
                L[x] += 1
                L[y] -= 1
                ans.append(x)
            elif L[y] == 0:
                L[x] -= 1
                L[y] += 1
                ans.append(y)
            else:
                L[x] += 1
                L[y] -= 1
                ans.append(x)

print('Yes')
d = {0:'A', 1:'B', 2:'C'}
for i in range(n):
    print(d[ans[i]])


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

int main() {
	ll a;
	double b;
	scanf("%lld%lf", &a, &b);
	int k = (int)(b*100+0.5);
	printf("%lld\n", a*k/100);
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))
 

int main(){ 
	ll N,M,ans=0;
	cin >> N >> M;
	vector<ll> num_pass(N+2,0);
	FOR(i,0,M){
		ll l,r;
		cin >> l >> r;
		num_pass[l]++;
		num_pass[r+1]--;
	}
	FOR(i,1,N+1){
		num_pass[i] += num_pass[i-1];
		if(num_pass[i]==M){
			ans++;
		}
	}
	cout << ans << endl;
}


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

typedef long long llong;

using namespace std;

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

	int q;
	cin >> q;
	while (q--) {
		string a, b;
		cin >> a >> b;
		int n = a.length(), m = b.length();
		vector<int> prev(m + 1, 0);
		for (int i = 1; i <= n; ++i) {
			vector<int> current(m + 1);
			current[0] = 0;
			for (int j = 1; j <= m; ++j) {
				if (a[i - 1] == b[j - 1]) {
					current[j] = 1 + prev[j - 1];
				} else {
					current[j] = max(current[j - 1], prev[j]);
				}
			}
			prev = current;
		}
		cout << prev[m] << '\n';
	}

	return 0;
}



Measured memory_bytes: 3256
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val (H, W, M) = rd.readIntArray()
    val X = IntArray(M); val Y = IntArray(M)
    val rowSum = IntArray(H){0}
    val colSum = IntArray(W){0}
    val st = mutableSetOf<IntPair>()
    for (i in 0 until M) {
        val (x, y) = rd.readIntArray().map{ it - 1 }
        X[i] = x; Y[i] = y
        rowSum[x]++
        colSum[y]++
        st.add(IntPair(x, y))
    }

    val rsMax = rowSum.max()!!
    val bxs = rowSum.withIndex()
            .filter { it.value == rsMax }.map{ it.index }

    val csMax = colSum.max()!!
    val bys = colSum.withIndex()
            .filter { it.value == csMax }.map { it.index }

    var occupied = true
    for (bx in bxs) {
        for (by in bys) {
            if (!st.contains(IntPair(bx, by))) {
                occupied = false
                break
            }
        }
    }

    val ans = if (occupied) rsMax+csMax-1 else rsMax+csMax
    print(ans)
}


//val rd = debug.Reader("abc", "176", "e", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 123900
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b; cin >> a >> b;
    cout << (a + b) % 24 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c,m;
    cin>>a>>b;
    a--;
    n=b-a;
    m=b+a;
    for(i=n;i<=m;i++) cout<<i<<" ";
    
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
const int INF = 1e9;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** 幾何ライブラリ **/
// to do : 1183

#include <complex>

#define X real()
#define Y imag()

const double EPS = 1e-11;

typedef double D;
typedef complex<D> P; // Point

struct L { // Line
	P a, b;
	L(){}
	L(P aa, P bb) : a(aa), b(bb){}
};

// 共役複素数 conj(a);

// 符号
int sig(D a, D b=0) { return a < b - EPS ? -1 : (a > b + EPS ? 1 : 0); }

// 内積
D dot(P a, P b) { return (conj(a)*b).real(); }

// 外積
D cross(P a, P b) { return (conj(a)*b).imag(); }

// 線分abに対する点cの位置
enum CCW{LEFT=1, RIGHT=-1, BACK=2, FRONT=-2, ON=0};
int ccw(P a, P b, P c)
{
	b -= a, c -= a;
	D s = sig(cross(b, c));
	if (s) return s>0 ? LEFT : RIGHT;
	if (sig(dot(b, c))<0) return BACK;
	if (sig(abs(c), abs(b))>0) return FRONT;
	return ON;
}

// 直線abと点cの距離
D distLP(L l, P c)
{
	return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
}

// 線分abと点cの距離
D distSP(L l, P c)
{
	if (sig(dot(l.b-l.a, c-l.a))<0) return abs(c-l.a);
	if (sig(dot(l.a-l.b, c-l.b))<0) return abs(c-l.b);
	return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
}

// 線分と線分の交差判定
bool iSS(L s, L t)
{
	return (ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0)
			&& (ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0);
}

// 線分と線分の交点 (公差していることが前提)
P cSS(L s, L t)
{
	D d1 = distLP(t, s.a);
	D d2 = distLP(t, s.b);
	D tmp = d1 / (d1 + d2);
	return s.a + (s.b-s.a)*tmp;
}

int main()
{
	L s, t;
	int q; cin>>q;
	rep(i, q) {
		cin>>s.a.X>>s.a.Y>>s.b.X>>s.b.Y;
		cin>>t.a.X>>t.a.Y>>t.b.X>>t.b.Y;
		
		cout << fixed << setprecision(15);
		cout << cSS(s, t).X << " " << cSS(s, t).Y << endl;
	}
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define endl '\n'
#define pi acos(-1)
#define pque priority_queue
typedef pair < int, int > ii;
typedef vector < int > vi;
typedef vector < vi > vii;
int mod = 1000000007;
vector < ii > v[100009];
int n, m, c, a[200009], b[200009], x[200009], d[100009], sum, ans, cur;
pque < ii, vector < ii >, greater < ii > > pq;
signed main()
{
	//freopen("cak.inp","r",stdin);
	//freopen("cak.out","w",stdout);
	cin >> n >> m >> c;
	for(int i = 1; i <= m; i++)
	{
		cin >> a[i] >> b[i] >> x[i];
		sum += x[i];
		v[a[i]].pb(mp(b[i], x[i]));
		v[b[i]].pb(mp(a[i], x[i]));
	}
	ans = sum;
	for(int i = 2; i <= n; i++)
		d[i] = LONG_LONG_MAX;
	d[1] = 0;
	pq.push(mp(0, 1));
	while(!pq.empty())
	{
		int dis = pq.top().fi;
		int id = pq.top().se;
		pq.pop();
		if(d[id] == dis)
		{
			for(int i = 0; i < v[id].size(); i++)
			{
				int u = v[id][i].fi;
				int q = v[id][i].se;
				if(dis + q < d[u])
					d[u] = dis + q, pq.push(mp(d[u], u));
			}
		}
	}
	while(!pq.empty())
		pq.pop();
	for(int i = 1; i <= m; i++)
		pq.push(mp(max(d[a[i]], d[b[i]]), i));
	while(!pq.empty())
	{
		int dis = pq.top().fi;
		int i = pq.top().se;
		sum -= x[i];
		pq.pop();
		while(!pq.empty())
		{
			int u = pq.top().fi;
			int q = pq.top().se;
			if(u > dis)
				break;
			pq.pop();
			sum -= x[q];
		}
		ans = min(ans, c * dis + sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 25144
N,M = map(int,input().split())
d = [list(map(str,input().split())) for _ in range(M)]

A = [0]*N
B = [0]*N

for i in range(M):
  if d[i][1] == 'AC':
    A[int(d[i][0])-1] = 1
  elif A[int(d[i][0])-1] == 0:
    B[int(d[i][0])-1] += 1

c = 0

for i in range(N):
  c += A[i]*B[i]

print("{} {}".format(sum(A),c))

Measured memory_bytes: 33688
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
#include <queue>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;

const int INF = 1001001001;
vector<int> to[100005];
int main() {
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
}

Measured memory_bytes: 5940
def bit():
    n, m, x = map(int, input().split())
    books = [list(map(int, input().split())) for _ in range(n)]
    ans = 99999999999999999
    for i in range(2 ** n):
        cost = 0
        level = [0] * (m)
        for j in range(n):
            if ((i >> j) & 1):
                cost += books[j][0]
                for k in range(m):
                    level[k] += books[j][k+1]

        if level and min(level) >= x:
            ans = min(ans, cost)

    if ans == 99999999999999999:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    bit()


Measured memory_bytes: 9216
x, y = map(int,input().split())
#ls = list(map(int,input().split()))
#r = int(input())
#s = input()
#x, y = input().split()

if x%3 == 0 or y%3 == 0 or (x + y)%3 == 0:
  print("Possible")
else:
  print("Impossible")

Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================


ll a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	cin >> n;
	vector<int> a(3); rep(i, n) {
		cin >> b;
		if (b % 4 == 0)a[2]++;
		else if (b % 4 == 2)a[1]++;
		else a[0]++;
	}
	Cout(Yes(a[0] <= a[2]||(a[0]==(a[2]+1)&&a[1]==0)));

	return 0;
}


Measured memory_bytes: 256
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    N,M=pin()
    a=set()
    b=set()
    for i in range(M):
        s,t=pin()
        if s==1:a.add(t)
        if t==N:b.add(s)
    x=len(a&b)
    print(["IMPOSSIBLE","POSSIBLE"][x>0])    
        

    
        
#%%submit!    
resolve()

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

using namespace std;

typedef long long ll;

//#include<ext/pb_ds/assoc_container.hpp>
//#nclude<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pii pair<int,ll>
#define pi pair<int,ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 1000000007
#define pai acos(-1)
//#define mx 1000000000
#define N 2005

vector<int>G[N];
int d[N],ans[N];

void bfs(int s){
    memset(d,-1,sizeof d);
    queue<int>q;
    d[s]=0;
    int u;
    q.push(s);
    while(!q.empty()){
        u=q.front();
        q.pop();
        for(int v:G[u]){
            if(d[v]==-1){
                d[v]=d[u]+1;
                q.push(v);
                ans[d[v]]++;
            }
        }
    }
    return ;
}

int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x,y,m;
    cin>>n>>x>>y;
    for(int i=1;i<n;i++){
        G[i].pb(i+1);
        G[i+1].pb(i);
    }
    G[x].pb(y);
    G[y].pb(x);
    for(int i=1;i<=n;i++){
        bfs(i);
    }
    for(int i=1;i<n;i++){
        cout<<ans[i]/2<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, long long K, std::vector<long long> p){
  int max_idx = 0;
  long long max_sum = 0;
  for (int i = 0; i < K; ++i) {
    max_sum += p[i];
  }

  long long cur = max_sum;

  for (int i = 0; i < N-K; i++) {
    cur -= p[i];
    cur += p[i+K];
    if (cur > max_sum) {
      max_sum = cur;
      max_idx = i+1;
    }
  }

  double ret = static_cast<double>(max_sum + K)/2.0;

  std::cout << fixed << setprecision(10) << ret << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> p(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&p[i]);
  }
  solve(N, K, std::move(p));
  return 0;
}


Measured memory_bytes: 1792
#include <cstdlib>
#include <set>
#include <cstdio>
#include <queue>
#include <climits>
#include <cassert>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define f first
#define s second
#define mp make_pair

using namespace std;

typedef vector<vector<int> > G;

int flow(G &g, int s, int d, bool one = false){
  int n = g.size();
  int ans = 0;

  if(s == d) return 0;

  while(true){
    vector<int> prevs(n,-1);
    queue<int> q;
    bool ok = false;

    prevs[s]=n;
    q.push(s);
    while(!q.empty()){
      int now = q.front();
      q.pop();
      if(now == d){
        ok = true;
        break;
      }
      for(int i=0;i<n;i++){
        if(g[now][i] > (one ? 1 : 0)){
          /*
          if(one){
            if((s == 0 || d == 0) && i == n - 1)
              continue;
            if((s == n - 1 || d == n - 1) && i == 0)
              continue;
          }
          */
          if(prevs[i]==-1){
            prevs[i]=now;
            q.push(i);
          }
        }
      }
    }

    if(!ok) return ans;

    int f = 100000;
    int pos = d;
    while(pos != s){
      int pos2 = prevs[pos];
      f = min(f,g[pos2][pos]);
      pos = pos2;
    }
    if(one) f = 1;
    pos = d;
    while(pos != s){
      int pos2 = prevs[pos];
      g[pos2][pos]-=f;
      g[pos][pos2]+=f;
      pos = pos2;
    }
    ans += f;
    if(one) return ans;
  }
}

int main(){
  int n, e, q;
  scanf("%d%d%d", &n, &e, &q);
  vector<vector<int> > g(n, vector<int>(n, 0));

  REP(i, e){
    int a, b;
    scanf("%d%d", &a, &b);
    g[a-1][b-1] = g[b-1][a-1] = 1;
  }

  int ans = flow(g, 0, n-1);

  REP(i, q){
    int m, a, b;
    scanf("%d%d%d", &m, &a, &b);

    //REP(i,n){REP(j,n)printf("%d ", g[i][j]); puts("");}
    //printf("%d %d %d : %d %d : %d\n", a - 1, b - 1, m,
    // g[a-1][b-1], g[b-1][a-1], ans);

    if(m == 1){
      g[a-1][b-1] = 1;
      g[b-1][a-1] = 1;
      ans += flow(g, 0, n-1);
    }else{
      if(g[a-1][b-1] != 0 && g[b-1][a-1] != 0){
        g[a-1][b-1] = g[b-1][a-1] = 0;
      }else{
        if((a - 1 == 0 && b - 1 == n - 1) ||
           (a - 1 == n - 1 && b - 1 == 0)){
          ans--;
          g[a-1][b-1] = g[b-1][a-1] = 0;
        }else{
          ans--;
          int tmp = g[a-1][b-1];
          g[a-1][b-1] = g[b-1][a-1] = 0;
          if(tmp == 0){
            int f3 = flow(g, a-1, 0,   true);
            int f1 = flow(g, n-1, b-1, true);
            // printf("0: f1 = %d  f3 = %d\n", f1, f3);
          }else{
            int f3 = flow(g, b-1, 0,   true);
            int f1 = flow(g, n-1, a-1, true);
            // printf("1: f1 = %d  f3 = %d\n", f1, f3);
          }
          // REP(i,n){REP(j,n)printf("%d ", g[i][j]); puts("");}
          ans += flow(g, 0, n-1);
        }
      }
    }

    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1808
import sys
input = sys.stdin.readline

def main():
    S = int(input())
    x1, y1 = 0, 0
    if S <= 10**9:
        x2, y2 = S, 0
        x3, y3 = 0, 1
    else:
        x2, y2 = 10**9, 1
        x3 = (10**9 - S%10**9)%10**9
        y3 = (S+x3)//(10**9)
    print(x1, y1, x2, y2, x3, y3)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import scala.collection.mutable
object Main extends App {
  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val vertexs = readLine.trim.split(' ').map(_.toLong)
  val union = vertexs.map(w ⇒ new UnionFindTree(w))
  val nodes = Array.tabulate(n){_ ⇒ Nil: List[(Int, Long)]}
  val edges = Array.tabulate(m){_ ⇒
    val Array(a, b, y) = readLine.trim.split(' ').map(_.toInt)
    nodes(a - 1) ::= (b - 1, y)
    nodes(b - 1) ::= (a - 1, y)
    Edge(a - 1, b - 1, y)
  }.sortBy(_.weight)
  val needNotRemove = Array.tabulate(m){_ ⇒ false}
  for (i ← edges.indices){
    union(edges(i).from).merge(union(edges(i).to))
    if (union(edges(i).from).weight >= edges(i).weight) {
      needNotRemove(i) = true
    }
  }
  val max = Array.tabulate(n){_ ⇒ 0L}
  val queue = mutable.Queue[Int]()
  for (i ← needNotRemove.indices.reverse if needNotRemove(i)){
    val weight = edges(i).weight
    if (max(edges(i).from) < weight) {
      queue.enqueue(edges(i).from)
      max(edges(i).from) = weight
      while (queue.nonEmpty) {
        val top = queue.dequeue()
        for ((to, w) ← nodes(top) if w <= weight && max(to) < weight) {
          max(to) = weight
          queue.enqueue(to)
        }
      }
    }
  }

  println(edges.count(e ⇒ max(e.from) < e.weight || max(e.to) < e.weight))

  case class Edge(from: Int, to: Int, weight: Long)
  class UnionFindTree(private var mWeight: Long){
    private var mParent: Option[UnionFindTree] = None
    private var mSize: Int = 1
    private def parent: UnionFindTree = {
      mParent.map{_.parent} match {
        case None ⇒ this
        case c@Some(p) ⇒
          mParent = c
          p
      }
    }
    def weight: Long = parent.mWeight
    def size: Int = parent.mSize
    def isTop: Boolean = mParent.isEmpty
    def isSameUnion(that: UnionFindTree): Boolean = {
      parent == that.parent
    }
    def merge(that: UnionFindTree): Unit = {
      if (!isSameUnion(that)){
        val p = parent
        val tp = that.parent
        if (p.mSize > tp.mSize){
          tp.mParent = Some(p)
          p.mSize += tp.mSize
          p.mWeight += tp.mWeight
        }else {
          p.mParent = Some(tp)
          tp.mSize += p.mSize
          tp.mWeight += p.mWeight
        }
      }
    }
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int Mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void f()
{
  int k;
  cin>>k;
  for(int i=1;i<=k;i++)
    cout<<"ACL";
  cout<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3564
// input
let D = Int(readLine()!)!
let cs: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
let ss: [[Int]] = (1...D).map { _ in readLine()!.split(separator: " ").map { Int($0)! } }

// output
let ts: [Int] = (1...D).map { _ in Int(readLine()!)! }


func calculateSatisfactionPoint(D: Int, cs: [Int], ss: [[Int]], ts: [Int]) {
    var lastContestDate: [Int] = Array(repeating: 0, count: 26)
    var vs: [Int] = [0]
    for d in 1...D {
        let todayContestType: Int = ts[d-1]
        vs.append(vs[d-1] + ss[d-1][todayContestType-1])
        lastContestDate[todayContestType-1] = d
        
        var decreaseSatisfactionPoint: Int = 0
        for i in 0..<26 {
            decreaseSatisfactionPoint -= cs[i]*(d - lastContestDate[i])
        }
        vs[d] += decreaseSatisfactionPoint
        print(vs[d])
    }
}

calculateSatisfactionPoint(D: D, cs: cs, ss: ss, ts: ts)	// (๑•ૅㅁ•๑)

Measured memory_bytes: 8440
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;

    int answer = 0;
    for (int i = 0; i <= 25; i++){
        for (int j = 0; j < 15; j++){
            if (i * 4 + j * 7 == N){
                answer++;
                break;
            }
        }
    }
    if (answer != 0){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
def factor(n):
    factor_set = {1}
    tmp = int(n**0.5)+1
    for i in range(2, tmp):
        while n % i == 0:
            n = n // i
            factor_set.add(i)
    factor_set.add(n)
    return factor_set


A, B = map(int, input().split())

print(len(factor(A) & factor(B)))


Measured memory_bytes: 2940
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 2000005;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
  IOS
   
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  int t1 = h1*60+m1;
  int t2 = h2*60+m2;
  t2-=(k);
  t2-=t1;
  cout<<t2<<endl;

}
 

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

int weatherForecast( char m[100][100], int i, int j )
{
    if( m[i][j] == 'c' )
        return 0;

    int cnt = 1, k = j - 1;
    while( k >= 0 && m[i][k] != 'c' )
    {
        cnt++;
        k--;
    }
    if( k == -1 )        //雲が存在しない
        return -1;
    else
        return cnt;
}

int main()
{
    int h, w;

    cin >> h >> w;

    char m[100][100];
    int res[100][100];

    for( int i = 0; i < h; i++ )
        for( int j = 0; j < w; j++ )
        {
            cin >> m[i][j];
            if( m[i][j] == '.' )
                res[i][j] = -1;
            else
                res[i][j] = 0;
        }

    for( int i = 0; i < h; i++ )
    {
        for( int j = 0; j < w; j++ )
        {
            res[i][j] = weatherForecast( m, i, j );
            cout << res[i][j];
            if( j != w - 1 )
                cout << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include<string>


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

#define vi         vector<int>
#define vs         vector<string>

#define vpii       vector<pair<int,int>>
#define vpis       vector<pair<int,string>>
#define vpss       vector<pair<string,string>>
#define mkp        make_pair

#define vvi        vector<vector<int>>

using namespace std;

int main()
{
  int a, b, c, d;

  cin >> a >> b >> c >> d;

  while (1) {
    c = c - b;

    if (c <= 0) {
        cout << "Yes";
        break;
    }

    a = a - d;

    if (a <= 0) {
      cout << "No";
      break;
    }
  }


  return 0;
}


Measured memory_bytes: 3592
# code-festival-2017-qualaB - fLIP
def main():
    N, M, K = tuple(map(int, input().split()))
    cand = [i * (M - j) + j * (N - i) for i in range(N + 1) for j in range(M + 1)]
    flg = K in cand
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 42776
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int a[5];
    rep(i, 5) cin >> a[i];
    int k;
    cin >> k;
    int d = a[4] - a[0];
    cout << (d <= k ? "Yay!" : ":(") << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define MAX_N 40010

struct BIT{
  ll bit[MAX_N+1];

  void init(){
    memset(bit,0,sizeof(bit));
  }

  ll sum(int i){
    ll s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }

  void add(int i,ll v){
    while(i<=MAX_N){
      bit[i]+=v;
      i+=i&-i;
    }
  }
};

ll n,K;
double a[40100],b[40100],c[40100];

bool okx(double x){
  BIT bit;
  bit.init();
  vector<double> cs;
  vector<P> ids;
  rep(i,n){
    cs.push_back(c[i]/b[i]-x*(a[i]/b[i]));
    ids.push_back(P(a[i]/b[i],i));
  }
  sort(all(cs));
  sort(all(ids));
  ll cnt=0;
  rep(i,n){
    ll j=ids[i].se;
    ll idx=lower_bound(all(cs),c[j]/b[j]-x*(a[j]/b[j]))-cs.begin();
    cnt+=bit.sum(n)-bit.sum(idx);
    bit.add(idx+1,1);
  }
  return cnt>=K;
}

bool oky(double x){
  BIT bit;
  bit.init();
  vector<double> cs;
  vector<P> ids;
  rep(i,n){
    cs.push_back(c[i]/a[i]-x*(b[i]/a[i]));
    ids.push_back(P(b[i]/a[i],i));
  }
  sort(all(cs));
  sort(all(ids));
  ll cnt=0;
  rep(i,n){
    ll j=ids[i].se;
    ll idx=lower_bound(all(cs),c[j]/a[j]-x*(b[j]/a[j]))-cs.begin();
    cnt+=bit.sum(n)-bit.sum(idx);
    bit.add(idx+1,1);
  }
  return cnt>=K;
}

int main(){
	cin>>n;
  K=n*(n-1)/2;
  if(K%2==0)K=(K/2)-1;
  else K/=2;
  K++;
  rep(i,n)cin>>a[i]>>b[i]>>c[i];
  
  /*if(n==2){
    double yy=((c[0]/a[0])-(c[1]/a[1]))/((b[0]/a[0])-(b[1]/a[1]));
    double xx=((c[0]/b[0])-(c[1]/b[1]))/((a[0]/b[0])-(a[1]/b[1]));
    printf("%.15f %.15f\n",xx,yy);
    return 0;
  }*/

  double resx,resy;

  {
    double lb=-1e18,ub=1e18;
    rep(hoge,100){
      double mid=(lb+ub)/2.0;
      if(okx(mid))ub=mid;
      else lb=mid;
    }
    resx=ub;
  }

  {
    double lb=-1e18,ub=1e18;
    rep(hoge,100){
      double mid=(lb+ub)/2.0;
      if(oky(mid))ub=mid;
      else lb=mid;
    }
    resy=ub;
  }

  printf("%.15f %.15f\n",resx,resy);
	return 0;
}


Measured memory_bytes: 3640
s=input()
n=len(s)
a=["1"]*n
b=["0"]*n
for i in range(1,n):
    if a[i-1]=="1":
        a[i]="0"
    else:
        a[i]="1"
for i in range(1,n):
    if b[i-1]=="1":
        b[i]="0"
    else:
        b[i]="1"
cnt=0
for i in range(n):
    if a[i]!=s[i]:
        cnt+=1
ans=cnt
cnt=0
for i in range(n):
    if b[i]!=s[i]:
        cnt+=1
ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 4852
#include<iostream>
using namespace std;
int main(){
  int min=10000;
  int max=0;
  int n,x,home;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x;
    if(min>=x) min=x;
    if(max<=x) max=x;
  }
    home=(max+min)/2;
    cout<<max-home<<endl;
}



Measured memory_bytes: 3104
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#define inf 1000000007

int main(void) {
	// your code goes here
	int n,i,a[300001],sums=0,minsums;
	char s[300001];
	scanf("%d %s",&n,s);
	a[0]=0;
	for(i=1;i<n;i++){
		if(s[i]=='E') a[i]=1;
		else a[i]=0;
		sums=sums+a[i];
	}
	minsums=sums;
	for(i=1;i<n;i++){
		sums=sums-a[i-1]-a[i];
		if(s[i-1]=='W') a[i-1]=1;
		a[i]=0;
		sums=sums+a[i-1]+a[i];
		if(minsums>sums) minsums=sums;
	}
	printf("%d\n",minsums);
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
typedef long long ll;
#define mod 998244353
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int n,lim;
struct qaq{
	int SG[100010],yes[100010],cnt[1020];
	int fir[100010],dis[100010],nxt[100010],id;
	void input(){
		int m=gi(),a,b;
		while(m--){
			a=gi(),b=gi();if(a>b)std::swap(a,b);
			nxt[++id]=fir[a],fir[a]=id,dis[id]=b;
		}
		for(int i=n;i;--i){
			for(int j=fir[i];j;j=nxt[j])yes[SG[dis[j]]]=1;
			while(yes[SG[i]])++SG[i];
			for(int j=fir[i];j;j=nxt[j])yes[SG[dis[j]]]=0;
		}
		for(int i=1,p=716070898;i<=n;++i,p=716070898ll*p%mod)inc(cnt[SG[i]],p),cxk(lim,SG[i]);
	}
}A,B,C;
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	n=gi();
	A.input();B.input();C.input();
	int ans=0;
	for(int i=0;i<=lim;++i)
		for(int j=0;j<=lim;++j)
			inc(ans,1ll*A.cnt[i]*B.cnt[j]%mod*C.cnt[i^j]%mod);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1234567890;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
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;
}
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    int a, b, k;
    cin >> a >> b >> k;

    int tkhs, aoki;
    if (k >= a)
    {
        tkhs = 0;
    }
    else
    {
        tkhs = a - k;
    }

    if (tkhs == 0)
    {
        aoki = b - (k - a);
        if (aoki < 0)
            aoki = 0;
    }
    else
        aoki = b;

    cout << tkhs << " " << aoki << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5+5;

bool dp[mx] = {};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector <int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int i = 0; i <= k; i++) {
    for(int j = 0; j < n; j++) {
      if(i - a[j] >= 0) dp[i] |= (!(dp[i-a[j]]));
    }
  }
  cout << ((dp[k] == 1)?"First":"Second");
	return 0;		
} 



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define win first
#define lose second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
using namespace std;

int N;
pii a[maxn],b[maxn];int tailA,tailB;

void init(string &s){
	int w = 0,l = 0;
	for(auto c:s){
		if(c == '(') w++;
		else if(w) w--;
		else l++;
	}
	if(w >= l) a[++tailA] = {w,l};
	else b[++tailB] = {w,l};
}

bool cmp1(pii &a,pii &b) {
	return a.lose < b.lose;
}
bool cmp2(pii &a,pii &b){
	return a.win > b.win;	
}

int solve(){
	sort(a+1,a+tailA+1,cmp1);
	sort(b+1,b+tailB+1,cmp2);
	int cur = 0;
	for(int i = 1;i<=tailA;i++){
		cur -= a[i].lose;
		if(cur < 0) return cout<<"No\n",0;
		cur += a[i].win;
	}
	for(int i = 1;i<=tailB;i++){
		cur -= b[i].lose;
		if(cur < 0) return cout<<"No\n",0;
		cur += b[i].win;
	}
	if(cur !=0) return cout<<"No\n",0;
	return cout<<"Yes\n",0;
}
int main(){
	// debug;
	ios;
	cin>>N;
	for(int i = 1;i<=N;i++){
		string s;cin>>s;
		init(s);
	}
	solve();
	
	return 0;
}


Measured memory_bytes: 11368
import collections
N = int(input())
L = list(map(int, input().split()))
L = collections.Counter(L)
L = list(L.items())
L = sorted(L)
N = len(L)

ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i][0]+L[j][0] > L[k][0]:
                ans += L[i][1]*L[j][1]*L[k][1]

print(ans)

Measured memory_bytes: 9336