akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EVirusTree2 solver = new EVirusTree2();
        solver.solve(1, in, out);
        out.close();
    }

    static class EVirusTree2 {
        long mod = 1_000_000_007;
        long[] fact;
        long[] factR;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            EVirusTree2.Node[] nodes = new EVirusTree2.Node[n];
            for (int i = 0; i < n; i++)
                nodes[i] = new EVirusTree2.Node();
            for (int i = 0; i < n - 1; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                nodes[a].id = a + 1;
                nodes[b].id = b + 1;
                nodes[a].nexts.add(nodes[b]);
                nodes[b].nexts.add(nodes[a]);
            }
            fact = new long[k + 1];
            factR = new long[k + 1];
            fact[1] = k - 2;
            factR[1] = k - 1;
            for (int i = 2; i < k; i++) {
                fact[i] = fact[i - 1] * (k - 1 - i);
                factR[i] = factR[i - 1] * (k - i);
                fact[i] %= mod;
                factR[i] %= mod;
            }
            EVirusTree2.Node root = nodes[0];
            root.isAdded = true;
            long res = solveMe(k, root, k);
            out.println(res);
        }

        private long solveMe(int k, EVirusTree2.Node node, long res) {
            int siblings = node.nexts.size() - 1;
            if (node.level == 0)
                siblings++;
            if (siblings == 0)
                return res;
            if (node.level == 0 && siblings >= k)
                return 0;
            if (node.level >= 1 && siblings >= k - 1)
                return 0;
            if (node.level == 0) {
                res *= factR[siblings];
            } else {
                res *= fact[siblings];
            }
            res %= mod;

            for (EVirusTree2.Node child : node.nexts) {
                if (child.isAdded)
                    continue;
                child.level = node.level + 1;
                child.isAdded = true;
                res = solveMe(k, child, res);
            }
            return res;
        }

        public static class Node {
            int level;
            boolean isAdded;
            List<EVirusTree2.Node> nexts = new ArrayList<>();
            int id;

        }

    }
}



Measured memory_bytes: 110452
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N; cin >> N;
	if(N % 2 == 0){
		cout << "0.5000000000" << endl;
	}else{
	double s = (N + 1)/ 2;
	double ans = s / N;
	cout << ans << endl;
	}

}

Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))

tmp = k - a[n-1] + a[0]
ans = 0
maxDiff = 0
for i in range(n-1):
  ans += a[i+1] - a[i]
  if a[i+1]-a[i] > maxDiff:
    maxDiff = a[i+1]-a[i]
print(min(ans, ans - (maxDiff - tmp)))
  

Measured memory_bytes: 25452
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, Q; cin >> N >> Q;
	string S; cin >> S;

	vector<int> csum(N + 1, 0), rsum(N + 1, 0);
	for (int i = 1; i <= N; ++i){
		if (i - 2 >= 0 && S[i-2] == 'A' && S[i-1] == 'C'){
			++csum[i];
		} // end if
	} // end for

	for (int i = 1; i <= N; ++i){
		csum[i] += csum[i-1];
	} // end for

	for (int i = 1; i <= N; ++i){
		if (i - 2 >= 0 && S[i-2] == 'A' && S[i-1] == 'C'){
			++rsum[i-1];
		} // end if
	} // end for

	for (int i = 1; i <= N; ++i){
		rsum[i] += rsum[i-1];
	} // end for

/*	
	for (int i = 1; i <= N; ++i){
		cerr << csum[i] << ' ';
	} // end for
	cerr << endl;

	for (int i = 1; i <= N; ++i){
		cerr << rsum[i] << ' ';
	} // end for
	cerr << endl;
*/
	rep (i, Q){
		int l, r; cin >> l >> r;
		int res = 0;
//		cerr << "l: " << l << " r: " << r << endl;
		if (rsum[l-1] == rsum[l]){
			res = csum[r] - csum[l];
		}else{
			res = csum[r] - csum[l-1];
		} // end if
		cout << res << endl;
//		cerr << "l: " << l << " r: " << r << " res: " << res << endl;
	} // end rep
		
	return 0;
}

Measured memory_bytes: 1872
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Q 10

int isPayable(int N, const int islike[Q]);
int main (int argc, char *argv[]) {
	int N, K, i, islike[Q], dislike;
	scanf("%d %d[^\n]", &N, &K);
	if (N < 1 || N >= 10000 || K < 1 || K >= Q) return -1;
	for (i = 0; i < Q; i++) islike[i] = 1;
	for (i = 0; i < K; i++) {
		scanf("%d", &dislike);
		if (dislike >= 0 && dislike < Q) islike[dislike] = 0;
	}
	scanf("[^\n]");
	while (isPayable(N, islike) == 0) N++;
	printf("%d\n", N);
	return 0;
}

int isPayable(int N, const int islike[Q]) {
	if (islike[N % Q] == 0) return 0;
	if (N >= Q) {
		N /= Q;
		return isPayable(N, islike);
	}
	return 1;
}

Measured memory_bytes: 128
n=gets.to_i
t,a=gets.split.map(&:to_i)
h=gets.split.map(&:to_i)
min,mini=0
h.each_with_index{|hn,i|
  tem=(a-t+0.006*hn).abs
  if i==0||tem<min then min=tem;mini=i+1 end
}
puts mini


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int num,d[120][3];
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	int i,maxv=-0x7fffffff,p;
	bool flag=true;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		if(abs(a[i])>maxv)
		{
			maxv=abs(a[i]);
			p=i;
			if(a[i]<0)
			{
				flag=false;
			}
			else
			{
				flag=true;
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		num++;
		d[num][1]=p;
		d[num][2]=i;
		a[i]+=a[p];
	}
	if(flag)
	{
		for(i=2;i<=n;i++)
		{
			num++;
			d[num][1]=i-1;
			d[num][2]=i;
		}
	}
	else
	{
		for(i=n;i>=2;i--)
		{
			num++;
			d[num][1]=i;
			d[num][2]=i-1;
		}
	}
	cout<<num<<endl;//2*n-1;
	for(i=1;i<=num;i++)
	{
		cout<<d[i][1]<<' '<<d[i][2]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import bisect
n = int(input())
l = list(map(int, input().split( )))

l.sort()

ans = 0
for i in range(n):
    for j in range(i):
        c = l[i]-l[j] + 0.01
        k = bisect.bisect_left(l,c)
        k = min(k,j)
        ans += (j-k)
print(ans)

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

typedef struct {
	char words[1000][50];
	int freq[1000];
} WORDS;

void word_sort(WORDS *ptr, int n);

int main(void)
{
	WORDS list;
	char message[2001], most[50], mlen[50];
	char kasira, len;
	int i, j, k, l;
	
	scanf("%[^\n]", message);
	getchar();
	
	i = k = len = 0;
	
	while (message[i] != '\0'){
		l = 0;
		while (message[i] != ' ' && message[i] != '\0'){
			list.words[k][l] = message[i];
			i++;
			l++;
		}
		if (l > len){
			len = l;
			strcpy(mlen, list.words[k]);
		}
		k++;
		if (message[i] == '\0'){
			break;
		}
		i++;
	}
	
	memset(list.freq, 0, sizeof(list.freq));
	word_sort(&list, k);
	
	printf("%s %s\n", list.words[0], mlen);
	
	return (0);
}

void word_sort(WORDS *ptr, int n)
{
	int i, j;
	char temp[33];
	
	for (i = 0; i < n - 1; i++){
		for (j = 0; j < n - i - 1; j++){
			if (strcmp(ptr->words[j], ptr->words[j + 1]) > 0){
				strcpy(temp, ptr->words[j]);
				strcpy(ptr->words[j], ptr->words[j + 1]);
				strcpy(ptr->words[j + 1], temp);
				
				ptr->freq[j] += ptr->freq[j + 1];
				ptr->freq[j + 1] = ptr->freq[j] - ptr->freq[j + 1];
				ptr->freq[j] -= ptr->freq[j + 1];
			}
			else if (strcmp(ptr->words[j], ptr->words[j + 1]) == 0){
				ptr->freq[j]++;
				ptr->freq[j + 1]++;
			}
		}
	}
	
	for (i = 0; i < n - 1; i++){
		for (j = 0; j < n - i - 1; j++){
			if (ptr->freq[j] < ptr->freq[j + 1]){
				strcpy(temp, ptr->words[j]);
				strcpy(ptr->words[j], ptr->words[j + 1]);
				strcpy(ptr->words[j + 1], temp);
				
				ptr->freq[j] += ptr->freq[j + 1];
				ptr->freq[j + 1] = ptr->freq[j] - ptr->freq[j + 1];
				ptr->freq[j] -= ptr->freq[j + 1];
			}
		}
	}
}

Measured memory_bytes: 0
#include <stdio.h>
int main()
{
    int arr[10000];
    int i,n,n1;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&arr[i]);
    }
    n1=n-1;
    for(i=n1; i>=0; i--)
    {
        if(i>0){printf("%d ",arr[i]);}
        else {printf("%d",arr[i]);}
    }
    printf("\n");





    return 0;
}



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

//Common
using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;template<typename T> using Func=function<T>;template<typename T> using Str=basic_string<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQ std::priority_queue

//Math
template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
template<typename T> inline T sq(T x){return x*x;}
cxp int lgc(int x){return 64-__builtin_clzll(x-1);}
cxp int lgf(int x){return 63-__builtin_clzll(x);}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1), eps=1e-10;

//IO
template<typename T>ostream& operator<<(ostream& s, const Arr<T>& a) {for(auto i:a) cout<<i<<' '; return s;}
int getint(){int x;cin>>x;return x;}
char getchr(){char x;cin>>x;return x;}
#ifndef DEBUG
	//#pragma GCC optimize ("Ofast") //somtimes it become more slower
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

//Misc
int sz(const auto& x){return x.size();}
auto split(auto s, auto p){
	Arr<decltype(s)> ret;
	auto it1=s.begin();
	for(auto it2=it1; (it2 = find(it1,s.end(),p)) != s.end(); it1=it2+1)
		ret.pushb({it1, it2});
	ret.pushb({it1,s.end()});
	return ret;
}
template<typename T> T rev(const T& a){return {a.rbegin(),a.rend()};}
Arr<int> range(int n){ Arr<int> ret(n); rep(i,n)ret[i]=i; return ret; }
struct defer{ defer(auto f):f(f){} ~defer(){f();} function<void()> f; };
#define defer(x) auto _##__COUNTER__ = defer([&](){x;});
#define lam(expr, ...) [&](__VA_ARGS__){return expr;}
#define reduce accumulate

#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

const int A=1e6;

signed main(){
	int n; cin>>n;
	map<int,int> c;
	int a[n]; rep(i,n)cin>>a[i];
	rep(i,n)
		c[a[i]]++;
	int z[A+1]{};
	for(auto [v,cnt]:c){
		if(z[v])continue;
		for(int j=v*2;j<=A;j+=v)
			z[j]=true;
	}
	int ans=0;
	rep(i,n)
		ans+=!z[a[i]] and c[a[i]]==1;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 25464
(defun solve (A B C K)
  (loop repeat (1+ K)
        if (>= B C) do (setf C (* 2 C))
        else
        if (>= A B) do (setf B (* 2 B))
        else do (return "Yes")
        finally (return "No")))

(princ (solve (read) (read) (read) (read)))

Measured memory_bytes: 24440
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#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);
	
	int ans=0,i,tmp;
	string t;
	cin>>t;
	stack<int> s;
	for(i=0;i<t.length();i++){
		s.push(t[i]-'0');
		if(s.size()>=2){
			tmp=s.top();
			s.pop();
			if(tmp!=s.top()){
				s.pop();
				ans+=2;
			}
			else{
				s.push(tmp);
			}
		}
	}
	cout<<ans<<endl;
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 720
#include <stdio.h>
#include <string.h>
int main(void)
{
  int a,b,i,j=0,k,n,p[60],x,y,z;
  char s[500],c[500];

  scanf("%d",&n);

  for (size_t i = 0; i < n; i++)
  {
    scanf("%d",&p[i]);
  }
  for (size_t i = 0; i < n; i++)
  {
    if(p[i]!=i+1) j++;  
  } 
    if(j>2) printf("NO");
    else printf("YES");
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    ll n,m;
    string s,t;
    cin >> n >> m >> s >> t;
    ll g = gcd(n,m);
    n /=g;
    m /=g;
    rep(i,g){
        if(s[i*n]!=t[i*m]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << lcm(n,m)*g << endl;
}

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

int main(){
  int N,a=300000,b,count=0;
  cin >> N;
  for(int i=0;i<N;i++) {
    cin >> b;
    if(a>b) {
      count++;
    a = min (a,b);
  }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int A,B,M; cin >> A >> B >> M;
	vector<int> a(A),b(B);
	rep(i,A) cin >> a[i];
	rep(i,B) cin >> b[i];
	map<int,Pi> mp;
	rep(i,M){
		int x,y,c; cin >> x >> y >> c;
		x--; y--;
		if(mp[x].second < c){
			mp[x] = Pi(y,c);
		}
	}
    vector<int> c = b;
	sort(b.begin(),b.end());
	int ans = INF;
	rep(i,A){
		int now = min(a[i]+b[0],a[i]+c[mp[i].first]-mp[i].second);
		ans = min(ans,now);
	}
	cout << ans << endl;
}



Measured memory_bytes: 7680
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

int N;
long long h[100010];

long long dp[100010];

long long rec(int i) {
    if (dp[i] < INF) return dp[i];

    if (i == 0) return 0;

    long long res = INF;
    chmin(res, rec(i - 1) + abs(h[i] - h[i - 1]));
    if (i > 1) chmin(res, rec(i - 2) + abs(h[i] - h[i - 2]));

    return dp[i] = res;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> h[i];
    for (int i = 0; i < N; i++) dp[i] = INF;

    cout << rec(N - 1) << endl;

    return 0;
}

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

int main()
{
	int D,G;
	cin >> D >> G;
	for(int i = 1; i <= D; ++i)
	{
		cin >> p[i] >> c[i];
	}

	int ans = 2000;
	int tempp = 0, score = 0;
	bool flag = false;
	/*
	for (int i = D; i > 0; --i)
	{
		rep(j,p[i])
		{
			score += 100 * i;
			tempp++;
			if (score >= G)
			{
				flag = true;
				break;
			}
		}
		if (flag) break;
	}
	if (flag) ans = min(tempp,ans);
	*/

	for (int i = 0; i < (1 << D); ++i)
	{
		tempp = 0; score = 0; flag = false;
		for (int j = 1; j <= D; ++j)
		{
			if (i & (1 << (j-1)))
			{
				tempp += p[j];
				score += 100*j*p[j] + c[j];
			}
		}
		if (score >= G) 
		{
			//cout << i << " " << tempp << endl;
			ans = min(tempp,ans);
		}
		else
		{
			for (int j = D; j > 0; --j)
			{
				if (!(i & (1 << (j-1))))
				{
					rep(k,p[j]-1)
					{
						score += 100*j;
						tempp++;
						if (score >= G)
						{
							flag = true;
							break;
						}
					}
				}
				if (flag) break;
			}
			if (score >= G) ans = min(tempp,ans);// cout << i << " " << tempp << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split())))

ans = [0] * N
for i in range(K):
    for j in range(len(A[i])):
        ans[A[i][j] - 1] = 1

print(ans.count(0))

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll p,q,r;
    cin>>p>>q>>r;
    ll ans=min(p+q,min(q+r,r+p));
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a, b;
    scanf("%d%d",&a,&b);
    if (a>b)
    {
    printf("a > b\n");
    }
    else if (a<b)
    {
    printf("a < b\n");
    }
    else if (a==b)
    {
    printf("a == b\n");
    }
}


Measured memory_bytes: 2036
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;
fn main() {
    input!{
        N: usize,
        K: usize,
    }

    let mut ans = 0f64;
    for deme in 1..N+1 {
        let mut p = 1;
        while deme * p < K {
            p <<= 1;
        }
        ans += 1f64 / ((p*N) as f64);
    }
    println!("{:?}", ans);
}


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

int main(void){
    int n;
    cin>>n;
    int b[n];
    rep(i,n) cin>>b[i];
    int ans=0;
    int count;
    rep(i,n-1){
        if(b[i]>=b[i+1]){
            count++;
            ans=max(ans,count);
        }else{
            ans=max(ans,count);
            count=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
n,k = map(int, input().split())
a = sorted(list(map(int,input().split())), reverse=True)

l = 1
h = a[0]
while l != h:
    m = (l + h) // 2
    cut = 0
    for x in a:
        cut += x // m + (x % m != 0) - 1
    if cut <= k:
        h = m
    else:
        l = m + 1

print(l)

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

int main(){
    while(1){
        char trump;
        cin >> trump;
        if(trump == '#') break;

        pair<char, int> logs[13][4];
        for(int i=0; i<4; i++){
            for(int j=0; j<13; j++){
                string s;
                cin >> s;
                int n = s[0]-'0';
                if(s[0]=='T') n=10;
                if(s[0]=='J') n=11;
                if(s[0]=='Q') n=12;
                if(s[0]=='K') n=13;
                if(s[0]=='A') n=14;
                logs[j][i].first = s[1];
                logs[j][i].second = n;
            }
        }

        int lead=0;
        vector<int> wins(4,0);
        for(int i=0; i<13; i++){
            int high=0, high_t=0;
            int winner = -1;
            char suit = logs[i][lead].first;
            for(int j=0; j<4; j++){
                int tp = (lead+j)%4;
                int rank = logs[i][tp].second;
                if(logs[i][tp].first == suit){
                    if(rank > high && high_t==0){
                        high = rank;
                        winner = tp;
                    }
                }
                if(logs[i][tp].first == trump){
                    if(rank > high_t){
                        high_t = rank;
                        winner = tp;
                    }
                }
            }
            lead = winner;
            wins[winner]++;
        }
        
        if(wins[0]+wins[2] >= 7){
            cout << "NS " << wins[0]+wins[2]-6 << endl;
        }else{
            cout << "EW " << wins[1]+wins[3]-6 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3060
n=int(input())
s=input()
tmp=0
ans=10**6
W=s.count('W')
for i in range(n):
  if s[i]=='W':
    ans=min(ans,n-1-(W-1)+tmp)
    tmp+=1
  else:
    ans=min(ans,n-1-W+tmp)
    tmp-=1
print(ans)

Measured memory_bytes: 9752
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
int main() {
  stack<int> s;
  vector<int> v;
  int n;
  while (cin >> n) {
    if (n == 0 && !s.empty()) {
      v.push_back(s.top());
      s.pop();
    } else {
      s.push(n);
    }
  }
  for (int i = 0; i < v.size(); ++i) {
    cout << v[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3028
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

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

int n, k, c;
bool can[200010];
int nxt[200010];
int suf[200010];
vector<int> v;

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n >> k >> c;
    Forn(i, n)
    {
        char x;
        cin >> x;
        if(x == 'o') can[i] = 1;
    }
    int now = -1;
    for(int i=n; i>=1; i--)
    {
        nxt[i] = now;
        if(can[i]) now = i;
    }
    for(int i=n; i>=1; i--)
    {
        if(!can[i])
        {
            if(nxt[i] == -1) suf[i] = 0;
            else suf[i] = suf[nxt[i]];
            //cout << "x " << nxt[i] << " " << suf[i] << endl;
        }
        else
        {
            int j = i+c+1;
            if(j>n) suf[i] = 1;
            else suf[i] = 1 + suf[j];
            //cout << "o " << j << " " << suf[j] << endl;
        }
    }
    int nowtake = 0;
    int lasttake = -100;
    int ans = 0;
    Forn(i, n)
    {
        if(can[i] && i - lasttake > c)
        {
            if(suf[i+1] + nowtake < k) v.pb(i);
            nowtake++;
            lasttake = i;
        }
    }
    forn(i, v.size()) cout << v[i] << '\n';
}


Measured memory_bytes: 4212
A, B, C, X, Y = map(int, input().split())

p1 = A * X + B * Y
p2 = max(X, Y) * 2 * C
p3 = min(X, Y) * 2 * C + ((Y - X) * B if (X < Y) else (X - Y) * A)

print(min([p1, p2, p3]))


Measured memory_bytes: 2940
#include<stdio.h>

int main(){
 int q;
 double x;
 double a;

 while(1)
 {

  scanf("%d",&q);
  if(q==-1)break;
  x = q/2.0;
  while(1){
   a=(x*x*x-q)/(3*x*x);
   x=x-a;
   if( (x*x*x-q)<0.00001*q && (x*x*x-q)>0.00001*q*(-1) ){printf("%lf\n",x);break;}
  }
 }

return 0;
}


Measured memory_bytes: 2028
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 100000000

int p[21],q[51][21],r[51][21];
int cost[20][100001];
struct edge{
    int dis;
    int com;
    int cos;
};

vector<edge> G[101][101];
int D[21][101][101];
int dp[21][101];

int main(){
    while(1){
        int n,m,c,s,g;
        scanf("%d%d%d%d%d",&n,&m,&c,&s,&g);
        if(n == 0 && m == 0 && c == 0 && s == 0 && g == 0){
            break;
        }
        s--;g--;

        REP(k,c){
            REP(i,n){
                REP(j,n){
                    D[k][i][j] = INF * (i != j);
                }
            }
        }

        REP(i,m){
            int x,y,d,c2;
            scanf("%d%d%d%d",&x,&y,&d,&c2);
            x--;y--;c2--;
            D[c2][x][y] = D[c2][y][x] = min(D[c2][x][y],d);
        }
        REP(i,c){
            scanf("%d",&p[i]);
        }
        REP(i,c){
            q[i][0] = -1;
            REP(j,p[i] - 1)
                scanf("%d",&q[i][j]);
            REP(j,p[i])
                scanf("%d",&r[i][j]);
        }
        REP(i,c){
            int k = 0;
            cost[i][0] = 0;
            FOR(j,1,100001){
                cost[i][j] = cost[i][j - 1] + r[i][k];
                if(k < p[i] - 1 && j == q[i][k])
                    k++;
            }
        }
        REP(l,c){
            REP(k,n){
                REP(i,n){
                    REP(j,n){
                        D[l][i][j] = min(D[l][i][j],D[l][i][k] + D[l][k][j]);
                    }
                }
            }
        }
        REP(k,c){
            REP(i,n){
                if(D[k][s][i] != INF)
                    dp[k][i] = cost[k][D[k][s][i]];
                else
                    dp[k][i] = INF;
            }
        }

        bool update = true;
        while(update){
            update = false;
            REP(k,c){
                int mini = INF;

                REP(i,n){
                    REP(l,c){
                        if(k == l)continue;
                        REP(j,n){
                            if(i != j && D[k][j][i] < INF && dp[k][i] > dp[l][j] + cost[k][D[k][j][i]]){
                                dp[k][i] = dp[l][j] + cost[k][D[k][j][i]];
                                update = true;
                            }
                        }
                    }
                }
            }
        }

        int mini = INF;
        REP(i,c){
            mini = min(mini,dp[i][g]);
        }
        if(mini == INF)
            printf("-1\n");
        else
            printf("%d\n",mini);
    }
    return 0;
}

Measured memory_bytes: 12056
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;

int n,d0,x;


void run() {
	scanf("%d%d%d",&n,&d0,&x); assert(n<=MAXN);

	double ret=0; double cd0=d0,cx=x;
	for(int cn=n;cn>0;--cn) {
		ret+=cd0+cx*(2*cn-1)/2;
		cd0+=0.5/cn*(2*cd0+5*cx);
		cx+=0.5/cn*(4*cx);
	}
	printf("%.9lf\n",ret);
}

int main() {
	run();
	//test();
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 500000

int a[N],n1,n2,number,count;

int searchNumber(int);

int searchNumber(int x){
  int left,right,mid;
  left = 0;
  right = n1;
  while( left < right ){
    mid = ( left + right ) / 2;
    if( a[mid] == x ) return a[mid];
    else if ( x < a[mid] ) right = mid;
    else left = mid + 1;
  }
  return -1;
}

int main(){

  int i,j;
  int b[N];
  scanf("%d",&n1);
  for(i=0;i<n1;i++){
    scanf("%d",&a[i]);
  }

  scanf("%d",&n2);
  for(i=0;i<n2;i++){
    scanf("%d",&b[i]);
    number = searchNumber(b[i]);
    if( number != -1 ) count++;
  }

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

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

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF 2e14
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	string s; ll k;
	cin>>s>>k;
	int n=s.length();
	
	bool same=1;
	forn(i,1,n){
		if(s[i]!=s[i-1]) same=0;
	}
	if(same){
		cout<<(n*k)/2<<'\n';
		return 0;
	}
	
	ll L=0,R=0;
	ll cm=0,prev=0;
	forn(i,1,n){
		if(s[i]!=s[i-1]){
			if(prev==0) L=i-prev;
			else cm+=(i-prev)/2;
			prev=i;
		}
	}
	R=n-prev;
	
	ll ans=k*cm+L/2+R/2;
	if(s[0]==s[n-1]) ans+=(k-1)*((L+R)/2);
	else ans+=(k-1)*(L/2+R/2);
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end());

const int MOD = 1000000007;
const int INF = INT_MAX;



int main()
{
    char c[3][3];
    rep(i, 3){
        rep(j, 3){
            cin >> c[i][j];
        }
    }

    cout << c[0][0] << c[1][1] << c[2][2] << endl;


    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 504
using System;
class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine().ToString();

            var arr = str.Split(' ');

            var a = Convert.ToInt64(arr[0]);
            var b = Convert.ToInt64(arr[1]);

            int cnt = 2;
            Int64 ans = -1;

            if (a % b == 0)
            {

            }
            else
            {
                while (true)
                {
                    ans = a * cnt;

                    Int64 mod = ans % b;

                    if (mod != 0)
                    {
                        break;
                    }
                    else if (ans > 1000000000000000000)
                    {
                        break;
                    }

                    cnt++;
                }
            }

            Console.WriteLine(ans);
        }
    }

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;

int n;
int depth[MAX_N];
int height[MAX_N];
int parent[MAX_N];
pair<int, int> child[MAX_N];

void Calc() {
	int rt;
	vector<int> leaf;
	for (int i = 0; i < n; i++) {
		if (child[i].first == -1 && child[i].second) {
			leaf.push_back(i);
		}
		if (parent[i] == -1) {
			rt = i;
		}
	}
	for (auto lf : leaf) {
		for (int i = 0; lf != -1; lf = parent[lf], i++) {
			height[lf] = max(height[lf], i);
		}
	}
	queue<int> q;
	q.push(rt);
	depth[rt] = 0;
	while (!q.empty()) {
		if (child[q.front()].first != -1) {
			q.push(child[q.front()].first);
			depth[child[q.front()].first] = depth[q.front()] + 1;
		}
		if (child[q.front()].second != -1) {
			q.push(child[q.front()].second);
			depth[child[q.front()].second] = depth[q.front()] + 1;
		}
		q.pop();
	}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		parent[i] = -1;

	for (int i = 0, id; i < n; i++) {
		cin >> id;
		cin >> child[id].first >> child[id].second;
		if (child[id].first != -1) parent[child[id].first] = id;
		if (child[id].second != -1) parent[child[id].second] = id;
	}

	Calc();

	for (int i = 0; i < n; i++) {
		cout << "node " << i << ':';
		cout << " parent = " << parent[i] << ',';
		cout << " sibling = " << (parent[i] == -1 ? -1 : (child[parent[i]].first == i ? child[parent[i]].second : child[parent[i]].first)) << ',';

		int degree = 0;
		if (child[i].first != -1) degree++;
		if (child[i].second != -1) degree++;

		cout << " degree = " << degree << ',';
		cout << " depth = " << depth[i] << ',';
		cout << " height = " << height[i] << ',';
		cout << (parent[i] == -1 ? " root" : (child[i].first == -1 && child[i].second == -1 ? " leaf" : " internal node")) << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] > i + 1) {
            if (A[A[i] - 1] == i + 1) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <ctype.h>
 
int main(void) {
     
    char c;
     
    for(;;){    
         
        scanf("%c",&c);
        if (islower(c) != 0) 
            printf("%c",toupper(c));
        else if (isupper(c) != 0) 
            printf("%c",tolower(c));
        else if (c == '\n') 
            break;
        else if (islower(c) == 0)
            printf("%c",c);
        else{break;}
    }
     
    printf("\n");
    return 0;
}

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

using namespace std;

#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)

typedef complex<double> C;

const double PI = 4*atan(1.0);

bool eq(double a,double b)
{
  return (-EPS<a-b&&a-b<EPS);
}

bool eq(const C c1,const C c2)
{
  return (eq(c1.real(),c2.real()) && eq(c1.imag(),c2.imag()));
}

namespace std
{
    bool operator < (const C a, const C b) {
        return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
    }
    bool operator == (C a, C b){
      return abs(a-b)<EPS;
    }
}

struct L : public vector<C>
{
    L(){}
    L(const C a, const C b) {
        push_back(a); push_back(b);
    }
};


//条件付きsqrt
double Sqrt(double x)
{
    if(x<0) return 0;
    else    return sqrt(x);
}

//正規化
C normalize(C c)
{
    return c / abs(c);
}

//角度(rad)
double getarg(C a,C b){
    return arg(b*conj(a));
}

//外積
double cross(const C a, const C b)
{
    return imag(conj(a)*b);
}
//内積
double dot(const C a, const C b)
{
    return real(conj(a)*b);
}

int ccw(C a, C b, C c)
{
    b -= a; c -= a;
    if(cross(b, c) > 0)   return +1;       // counter clockwise
    if(cross(b, c) < 0)   return -1;       // clockwise
    if(dot(b, c) < 0)     return +2;       // c--a--b on line
    if(norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;   //b--a--c on line
}
//直線どうしの交差判定(同一直線はTrue)
bool intersectLL(const L& l, const L& m)
{
    return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;
}
//直線と線分の交差判定(一点共有も交差と判定)
bool intersectLS(const L& l, const L& s)
{
    return cross(l[1]-l[0], s[0]-l[0]) * cross(l[1]-l[0], s[1]-l[0]) < EPS;
}
//直線と点の交差(共有)判定
bool intersectLP(const L& l, const C p)
{
    return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
//線分どうしの交差判定(一点共有も交差と判定)
bool intersectSS(const L& s, const L& t)
{
    return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 && ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
//線分と点の交差(共有)判定
bool intersectSP(const L& s, const C p)
{
    return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS;
}
//直線および線分の交点
C crosspointLL(const L& l, const L& m)
{
    double A = cross(l[1] - l[0], m[1] - m[0]);
    double B = cross(l[1] - l[0], l[1] - m[0]);
    //同一直線のとき
    if(abs(A) < EPS && abs(B) < EPS){
        return m[0];
    }
    return m[0] + B / A * (m[1] - m[0]);
}


int main(){

  while(1){
    int n;
    cin >> n;
    if(!n)break;
    vector<L> lines(n);
    rep(i,n){
      double a,b,c,d;
      cin >> a >> b >> c >> d;
      complex<double> x(a,b),y(c,d);
      lines[i] = L(x,y);
    }
    int sum = 1;
    rep(i,n){
      L l = lines[i];
      set<C> s;
      rep(j,i){
        L ls = lines[j];
        complex<double> cro = crosspointLL(l,ls);
        if (-100<cro.real()&&cro.real()<100&&-100<cro.imag()&&cro.imag()<100){
          s.insert(cro);
        }
      }
      int del = 0;
      vector<C> vec(s.begin(),s.end());
      rep(i,vec.size()){
        if (i<vec.size()-1&&vec[i]==vec[i+1])del++;
        // cout << vec[i] << endl;
      }
      sum += s.size()+1-del;
    }
    cout << sum << endl;
  // break;
  }

  return 0;
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define o(s) cout<< s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int n,i; cin>>n>>i;
    o(n-i+1);
}


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

int main()
{
    string line;
    int s;
    while(getline(cin, line))
    {
        if(line.length() == 1 && line[0] == '0')
            break;
        s = 0;
        for(int i = 0; i < line.length(); i++)
        {
            s += line[i] - '0';
        }
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int h, w, k;
    cin >> h >> w >> k;
    int xs, ys, xt, yt;
    cin >> ys >> xs >> yt >> xt;
    --xs, --xt, --ys, --yt;
    char c[h][w];
    rep (i, 0, h) rep (j, 0, w) cin >> c[i][j];
    int dist[h][w];
    rep (i, 0, h) rep (j, 0, w) dist[i][j] = inf;
    queue<pint> q;
    q.push ({ys, xs});
    dist[ys][xs] = 0;
    while (!q.empty()) {
        pint now = q.front();
        q.pop();
        int ny = now.first, nx = now.second;
        rep (i, 0, 4) {
            rep (j, 1, k + 1) {
                int nexty = ny + dy[i] * j, nextx = nx + dx[i] * j;
                if (nexty < 0 || nexty >= h || nextx < 0 || nextx >= w) break;
                if (c[nexty][nextx] == '@') break;
                if (dist[nexty][nextx] <= dist[ny][nx]) break;
                if (dist[nexty][nextx] > dist[ny][nx] + 1) {
                    dist[nexty][nextx] = dist[ny][nx] + 1;
                    q.push ({nexty, nextx});
                }
            }
        }
    }
    /*
    rep (i, 0, h) {
        rep (j, 0, w) cout << dist[i][j] << " ";
        cout << "\n";
    }
    */
    if (dist[yt][xt] == inf) {
        cout << "-1\n";
    } else {
        cout << dist[yt][xt] << "\n";
    }
}

Measured memory_bytes: 14024
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    int NN=N;
    int cnt=1;
    int S=0;
    int GO=0;
    while(true){
           if(N<10){
            S+=N;
            break;
           }
        
        N/=10;
        cnt*=10;
             if(N<10){
                 S+=N;
                 GO+=(N*cnt);
                 cnt=1;
                 N=NN;
                 N-=GO;
                }     
        }
       
        if((NN%S) == 0){
           cout << "Yes";
        }else{
            cout << "No";
        }
    
      
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		// Union Find
		UnionFind uf = new UnionFind(N);
		for (int i = 0; i < M; i++) {
			uf.unite(sc.nextInt() - 1, sc.nextInt() - 1);
		}
		sc.close();

		int cnt = 0;
		for (int i = 0; i < N; i++) {
			if (uf.isRoot(i)) {
				cnt = Math.max(cnt, uf.size(i));
			}
		}

		System.out.println(cnt);
	}
}

class UnionFind {
	int[] parent; // インデックスとノードを対応させ、そのルートノードのインデックスを保持
	int[] size; // 属しているグループのサイズを保持
	int[] rank; // parentと同様に、木の高さを保持

	public UnionFind(int n) {
		this.parent = new int[n];
		this.size = new int[n];
		this.rank = new int[n];

		for (int i = 0; i < n; i++) {
			makeSet(i);
		}
	}

	public void makeSet(int i) {
		parent[i] = i;
		size[i] = 1;
		rank[i] = 0;
	}

	public int size(int i) {
		return size[find(i)];
	}

	public void unite(int x, int y) {
		int xRoot = find(x);
		int yRoot = find(y);

		if (xRoot == yRoot) {
			return;
		}
		// xが属する木の方が大きい場合
		if (rank[xRoot] > rank[yRoot]) {
			parent[yRoot] = xRoot; // yの親をxに更新
			size[xRoot] += size[yRoot];
		} else {
			// yが属する木のランクがxのそれ以上の場合
			parent[xRoot] = yRoot;
			size[yRoot] += size[xRoot];
			if (rank[xRoot] == rank[yRoot]) {
				rank[xRoot]++;
			}
		}
	}

	// 引数の属する木のルートを返す
	public int find(int i) {
		if (i != parent[i]) {
			parent[i] = find(parent[i]);
		}
		return parent[i];
	}

	// 同じ木に属しているか
	public boolean isSame(int x, int y) {
		return find(x) == find(y);
	}

	public boolean isRoot(int i) {
		return rank[i] == 0;
	}
}


Measured memory_bytes: 62340
#include <bits/stdc++.h>
  #include <vector>
  #include <math.h>
  #include <string>
  #include <algorithm>
  #include <stack>
  #include <queue>
  #include <ctype.h>
  #include <unordered_map>
  #include <set>
  #include <iterator>
  #include <deque>
  #include <string.h>
  using namespace std;

  typedef long long int lli;


  #define MOD (lli)(1e9+7)
  #define endl "\n"
  #define pb push_back
  #define TEST_CASES  lli t;cin >> t;while(t--)
  #define forn(i,n) for (int i = 0; i < n; ++i)
  
  lli powD(lli x,lli y){
    
    lli res = 1;
    while(y > 0){
      if(y & 1)
        res = (res*x)%MOD;
      x = (x*x)%MOD;
      y = y>>1;
    }
    return res;
  }

  

  int main()
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    lli sum =0;
    forn(i,n+2-k){
      sum += 1LL*i*(n-i+1)+1;
      sum %= MOD;
    }
    cout<<sum<<endl;
   

    

  }


Measured memory_bytes: 3608
import java.util.*;

public class Main {

    private static final int MOD = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        System.out.println( solve(N, M) );
    }

    private static long solve(int N, int M) {
        if( N == M + 1 ) {
            return calc(M) * N % MOD;

        } else if( M == N + 1 ) {
            return calc(N) * M % MOD;

        } else if( N == M ) {
            return calc(N) * 2 % MOD;

        } else {
            return 0;
        }
    }

    private static long calc(int n) {
        // n! * n!
        long result = 1;
        for (int i = 1; i <= n; i++) {
            result = result * i % MOD;
        }
        return result * result % MOD;
    }
}


Measured memory_bytes: 21844