akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if (m == -1 && f == -1 && r == -1) break;
            if (m == -1 || f == -1) {
                System.out.println("F");
            } else {
                if ((m + f) >= 80) {
                    System.out.println("A");
                } else if ((m + f) >= 65) {
                    System.out.println("B");
                } else if ((m + f) >= 50) {
                    System.out.println("C");
                } else if ((m + f) >= 30) {
                    if (r >= 50) {
                        System.out.println("C");
                    } else {
                        System.out.println("D");
                    }
                } else {
                    System.out.println("F");
                }
            }
        }
    }
}



Measured memory_bytes: 26372
# TLE
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp= [0]*n

for i in range(1,n):
  tmp = float('inf')
  for j in range(1,min(i+1,k+1)):    
    d = dp[i-j] + abs(h[i] - h[i-j])    
    tmp = min(tmp,d)  
  dp[i] = tmp
  
print(dp[-1])  

Measured memory_bytes: 52576
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

//i番目まで見たとき,合計がjになる場合の数。
int dp[101][10010];

int main() {
	int n; cin >> n;

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

	dp[0][0] = 1;

	for (int i = 0; i < n; i++) {
		for (int j = 10009; j >= 0; j--) {

			if (j - a[i] >= 0) {
				dp[i + 1][j] = dp[i][j - a[i]];
			}

			if (dp[i][j] == 1) {
				dp[i + 1][j] = 1;
			}
			
		}
	}

	for (int j = 10009; j >= 0; j--) {
		if (dp[n][j] != 0 && j % 10 != 0) {
			cout << j << endl;
			return 0;
		}
	}	

	cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 4224
#include<iostream> 
using namespace std;
int main(){
	int n,d,x;
	cin>>n>>d>>x;//n个参赛者 ，共持续了d天，还剩x个 
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		x+=(d+a-1)/a;
	}
	cout<<x<<endl;
} 

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();
		double v[]=new double[n];
		for(int i=0;i<n;i++){
			v[i]=sc.nextDouble();
		}

		for(int i=0;i<n-1;i++){
			Arrays.sort(v);
			v[i+1]=(v[i]+v[i+1])/2;
		}

		System.out.println(v[n-1]);


	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, x;
    cin >> n >> x;
    vl l(n);
    rep(i, n) cin >> l[i];
    int d = 0, ans = 1;
    rep(i, n) {
        d += l[i];
        if(d <= x) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::f64::consts::PI;

#[fastout]
fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }

    let rad = PI * 2.0 * (h / 12.0 + (m / 60.0) / 12.0 - m / 60.0);
    let ans = (a * a + b * b - 2.0 * a * b * rad.cos()).sqrt();

    println!("{}", ans);
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi d(N);
  rep(i,N) {
    cin >> d[i];
  }
  sort(rng(d));
  uni(d);
  cout << sz(d) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long int a[n],b[n],c[n],ans=0,p,t;
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++) cin >> b[i];
  for(int i=0;i<n;i++) cin >> c[i];
  sort(a,a+n);sort(c,c+n);
  for(int i=0;i<n;i++){
    p=lower_bound(a,a+n,b[i])-a;//二部探索でb[i]より小さいものの数を返す
    t=n-(upper_bound(c,c+n,b[i])-c);//二部探索でb[i]より大きいものの数を返す
    ans+=p*t;
  }
  cout <<ans<<endl;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
	int n,x,r=0,z=0,mn=9999999;
	scanf("%i%i",&n,&x);
	int m[n+1];
	for(int i=1;i<=n;i++)
	{
		scanf("%i",&m[i]);
		z+=m[i];
		if(m[i]<=mn)	mn=m[i];
	}
	r=n;
	x-=z;
	r+=x/mn;
	printf("%i",r);
	return 0;
}


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

int main(){
  string S,T;
  cin>>S>>T;
  int n=S.size();
  bool flag=false;
  for(int i=0;i<n;i++){
    if(S.at(i)==T.at(0)){
      bool sub=true;
      for(int j=0;j<n;j++){
        if(S.at((i+j)%n)!=T.at(j)){
          sub=false;
          break;
        }
      }
      if(sub){
        flag=true;
        break;
      }
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

using namespace std;

int n, x;
double ans;

int main () {
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> x;
        double p = 1;
        p /= x;
        ans += p;
    }
    double a = 1;
    a /= ans;
    cout << setprecision(10) << a;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int h,m,s,x;
	scanf("%d",&x);
	m=x/60;
	s=x%60;
	h=m/60;
	m=m%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;

}

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

int main() {
    int N;
    cin >> N;
    set<int> st;
    int A;
    for (int i = 0; i < N; i++) {
        cin >> A;
        st.insert(A);
    }
    if ((int)st.size() == N) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

class WithIndex<T>
{
    public T Value;
    public int Index;
    public WithIndex(T value, int index)
    {
        this.Value = value;
        this.Index = index;
    }
}

static class Template
{
    public static int LineToInt()
    {
        return int.Parse(Console.ReadLine());
    }

    public static string[] LineToStrings()
    {
        return Console.ReadLine().Split();
    }

    public static int[] LineToInts()
    {
        return LineToStrings()
            .Select(s => int.Parse(s))
            .ToArray();
    }


    public static int[,] LinesToIntTable(int lineCount, int columnCount)
    {
        var value = new int[lineCount, columnCount];
        foreach (var y in Enumerable.Range(0, lineCount))
        {
            var ints = LineToInts();
            foreach (var x in Enumerable.Range(0, columnCount))
            {
                value[y, x] = ints[x];
            }
        }
        return value;
    }

    public static IEnumerable<WithIndex<T>> WithIndex<T>(this IEnumerable<T> sequence)
    {
        int index = 0;
        foreach (var item in sequence)
        {
            yield return new WithIndex<T>(item, index);
            index++;
        }
    }

    static void Main(string[] args)
    {
        var count = LineToInt();
        var nums = LineToInts();
        var trans = 0;
        for (int i = 0; i < count - 1; i++)
        {
            if (nums[i] != i + 1) trans++;
        }
        Console.WriteLine(trans <= 2 ? "YES" : "NO");
    }
}



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

int main(){

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (abs(a-c) <= d){
		cout << "Yes" << endl;
	}else if (abs(a-b) <= d && abs(b-c) <= d){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
while True:
    input_data = input()
    if input_data == "#":
        break
    g, y, m, d = input_data.split()
    y = int(y)
    m = int(m)
    d = int(d)
    if y < 31 or (y == 31 and m <= 4):
        print(g, y, m, d)
    else:
        print("?", str(y - 30), str(m), str(d))


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

int main() {
    string s;
    cin >> s;
    int n = s.length();
    if(s[0] == '0' || s[n - 1] == '1'){
        cout << -1;
        // cout << "666";
        return 0;
    }

    for(int i = 0; i < n - 1; i++) {
        if(s[i] == '1' && s[n - 1 - i - 1] == '0') {
            cout << -1;
            // cout << 777;
            return 0;
        }
    }

    int now = 0;
    for(int i = 1; i < n; i++) {
        printf("%d %d\n", now + 1, i + 1);
        if(s[i - 1] == '1') now = i;
    }
}

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

#define task "D"
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<ll, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int N = 5002;
int n, k, a[N], c[N], ncyc;
bool vis[N];
vi cyc[N];
ll maxSubarr(vi &v, int len, bool mx0)
{

    deque<ii> mn;
    mn.pb(ii(0, -1));
    ll pre = 0, mx = -1e18;
    if (mx0) mx = 0;
    rep(i, 0, SZ(v) - 1)
    {
        while (!mn.empty() && mn.front().S < i - len) mn.pop_front();
        pre += v[i];
        if (SZ(mn)) mx = max(mx, pre - mn.front().F);
        while (!mn.empty() && pre < mn.back().F) mn.pop_back();
        mn.pb(ii(pre, i));
    }
    return mx;
}
void loadCyc()
{
    rep(i, 1, n) if (!vis[i])
    {
        int u = i;
        vis[u] = 1;
        cyc[++ncyc].eb(i);
        while (!vis[a[u]])
        {
            u = a[u];
            vis[u] = 1;
            cyc[ncyc].eb(u);
        }
    }
}
void load()
{
    ll ans = -1e18;
    rep(i, 1, ncyc)
    {
        ll sum = 0;
        for (int v : cyc[i]) sum += c[v];
        int nc = SZ(cyc[i]);
        vi t(2 * nc, 0);
        rep(j, 0, nc - 1) t[j] = t[nc + j] = c[cyc[i][j]];
        if (sum < 0) ans = max(ans, maxSubarr(t, min(nc, k), 0));
        else
        {
            int rem = (k % nc);
            ans = max(ans, sum * (k / nc) + maxSubarr(t, rem, (k / nc > 0)));
            if (k / nc > 0) ans = max(ans, sum * (k / nc - 1) + maxSubarr(t, nc, (k / nc > 1)));
        }
    }
    cout << ans;
}
int main()
{
#ifdef HynDuf
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif
    cin >> n >> k;
    rep(i, 1, n) cin >> a[i];
    rep(i, 1, n) cin >> c[i];
    loadCyc();
    load();
    return 0;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;
vvp g;
vvl dp[2];

bool dfs(int v,ll c,ll m){
	if(g[v].empty()){
		dp[0][v].push_back(c);
		dp[1][v].push_back(c);
		return 1;
	}
	bool B=1;
	for(auto i:g[v]) B&=dfs(i.first,i.second,m);
	if(!B) return 0;
	int u=g[v][0].first,w=g[v][1].first,Su=dp[0][u].size(),Sw=dp[0][w].size();
	vpll DP;
	if(Su>Sw){
		swap(u,w);
		swap(Su,Sw);
	}
	for(int i=0;i<Su;i++){
		ll A=dp[0][u][i],B=dp[1][u][i];
		for(int j=0;j<2;j++) if(A+dp[0][w][0]<m){
			ll b=(A+dp[1][w][0]<m?1:0);
			ll A_=dp[!b][w][dp[b][w].begin()-lower_bound(dp[b][w].begin(),dp[b][w].end(),m-A)+Sw]+c,B_=B+c;
			if(A_>B_) swap(A_,B_);
			DP.push_back({A_,B_});
			swap(A,B);
		}
	}
	if(DP.empty()) return 0;
	sort(DP.begin(),DP.end());
	dp[0][v].push_back(DP[0].first);
	dp[1][v].push_back(DP[0].second);
	for(int i=1;i<DP.size();i++){
		ll A=DP[i].first,B=DP[i].second;
		if(B<dp[1][v].back()){
			dp[0][v].push_back(A);
			dp[1][v].push_back(B);
		}
	}
	reverse(dp[1][v].begin(),dp[1][v].end());
	return 1;
}

int main(){
	cin>>n;
	g=vvp(n);
	for(int i=1;i<n;i++){
		int p,c;
		cin>>p>>c;
		g[p-1].push_back({i,c});
	}
	ll l=0,r=INF;
	while(r-l>1){
		ll m=(l+r)/2;
		dp[0]=dp[1]=vvl(n);
		if(dfs(0,0,m)) r=m;
		else l=m;
	}
	cout<<l<<endl;
}

Measured memory_bytes: 37120
import java.io.*;
import java.util.*;

public class Main {
	static int mod = (int)1e9+7;
	static Comparator<Integer> lower_bound = (x, y) -> x.compareTo(y) >= 0 ? 1 : -1;
	static Comparator<Integer> upper_bound = (x, y) -> x.compareTo(y) > 0 ? 1 : -1;

	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		out.println(c - a + b >= 0 ? c - a+ b : 0);
 	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}

	public static long factorial(int n) {
		long a;

		if(n > 0) {
			a = n * factorial(n - 1);
		}else{
			a = 1;
		}
		return a;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class UnionFind {
	int[] par;

	public UnionFind(int n) {
		par = new int[n];

		Arrays.fill(par, -1);
	}

	int root(int x) {
		if(par[x] < 0) return x;
		return par[x] = root(par[x]);
	}

	boolean unite(int x,int y) {
		x = root(x);
		y = root(y);

		if(x == y) return false;

		if(size(x) < size(y)) {
			int tmp = x;
			x = y;
			y = tmp;
		}

		par[x] += par[y];
		par[y] = x;

		return true;
	}

	boolean same(int x,int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}

	int size(int a) {
		return -par[root(a)];
	}
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 26708
nmax=8
#深さ優先探索
def dfs(v,n,visited):
    all_visited=True
    for i in range(n):
        #ある経路においてvisitedすべてTrueか
        if visited[i]==False:
            all_visited=False
    if all_visited:
        return 1
    
    ans=0
    for i in range(n):
        #パスがないならcontinue
        if graph[v][i]==False:
            continue
        #すでに通ったならcontinue
        if visited[i]:
            continue
        #通った頂点をTrueにする
        visited[i]=True
        #次の深さを探索
        ans += dfs(i,n,visited)
        #深いところから戻るのでvisitedをFalseに
        visited[i]=False
    return ans

n,m = map(int,input().split())
#graph[n][n]をFalseで初期化
graph=[]
for i in range(n):
    graph.append([False]*n)
#graph上でパスの通っているものをTrueとする
for _ in range(m):
    a,b = map(int,input().split())
    graph[a-1][b-1]=True
    graph[b-1][a-1]=True
#visited[n]をFalseで初期化
visited=[]
for _ in range(n):
    visited.append(False)
#頂点1を始点とする(visited[(頂点)-1])
visited[0]=True
print(dfs(0,n,visited))

Measured memory_bytes: 3064
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

nn = inputs[0][0]
ii = inputs[0][1]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p nn
  p ii
end

puts nn - ii + 1


Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n,m,x = map(int, input().split())
cas = [tuple(map(int,input().split())) for i in range(n)]

ans = float('inf')


for i in range(2 ** n):
    d = [0]*m
    tmp = 0
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            ca = cas[j]
            c= ca[0]
            for k,a in enumerate(ca[1:]):
                d[k]+=a
            tmp+=c

    if min(d)>=x:
        ans = min(ans,tmp)

if ans == float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 74552
#include<bits/stdc++.h>
#define ll long long
#define lld long double
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 101000,mod = 1e9+7;
ll ans;
int n,A,B;
int f[2][5010][2][2];
int s[5010][5010][2],sum[5010][2];
int main(){
	read(n);read(A);read(B);
	if(A<B) swap(A,B);
	s[0][0][0]=1;
	f[0][0][0][0]=1;
	sum[0][0]=1;
	for(int i=1;i<=n;i++){
		int now=i&1,lst=i-1&1;
		memset(f[now],0,sizeof(f[now]));
		for(int j=0;j<=i;j++) s[i][j][0]=s[i-1][j][0],s[i][j][1]=s[i-1][j][1];
		sum[i][0]=sum[i-1][0];sum[i][1]=sum[i-1][1];
		for(int j=0;j<=i;j++){
			if(i-j<A){
				f[now][j][0][0]=(f[lst][j][0][0]+f[lst][j][1][0])%mod;
				f[now][j][0][1]=(f[lst][j][0][1]+f[lst][j][1][1])%mod;
				if(i-j<B){
					if(i==j){
						f[now][j][1][0]=sum[i-1][0]-(i>=B?sum[i-B][0]:0);
						f[now][j][1][1]=sum[i-1][1]-(i>=B?sum[i-B][1]:0);
					}
				}
				else{
					f[now][j][1][1]=s[i-B][j][1];
					f[now][j][1][0]=s[i-B][j][0];
				}
			}
			else{
				f[now][j][0][1]=(0ll+f[lst][j][0][0]+f[lst][j][0][1]+f[lst][j][1][0]+f[lst][j][1][1])%mod;
				if(i>=B)
					f[now][j][1][1]=(s[i-B][j][0]+s[i-B][j][1])%mod;
			}
		//	cerr<<i<<' '<<j<<' '<<f[now][j][0][0]<<' '<<f[now][j][0][1]<<' '<<f[now][j][1][0]<<' '<<f[now][j][1][1]<<'\n';
			sum[i][0]=(sum[i][0]+f[now][j][0][0])%mod;
			sum[i][1]=(sum[i][1]+f[now][j][0][1])%mod;
			s[i][j][0]=(s[i][j][0]+f[now][j][0][0])%mod;
			s[i][j][1]=(s[i][j][1]+f[now][j][0][1])%mod;
			if(i==n) ans=(ans+f[now][j][0][1]+f[now][j][1][1])%mod;
		}
	}
	cout<<(ans+mod)%mod<<'\n';
	return 0;
}



Measured memory_bytes: 120508
/**
 *    author:  math2do
 *    created: 18.01.2020 02:39:54
**/

#include <bits/stdc++.h>

using namespace std;

const int pinf = (1U << 31) - 1;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  #ifdef LOCAL
    freopen("A_frog_1.in", "rt", stdin);
  #endif

  int n;
  cin >> n;
  vector <int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  } 
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector <int> dp(n, pinf);
  dp[0] = 0;
  dp[1] = abs(arr[1] - arr[0]);
  //..b a
  for (int i = 2; i < n; i++) {
    int a = dp[i - 1] + abs(arr[i - 1] - arr[i]);
    int b = dp[i - 2] + abs(arr[i - 2] - arr[i]);
    dp[i] = min(a, b);
  }
  cout << dp[n - 1] << '\n'; 
  return 0;
}


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

int main(){
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    int T,F;
    char C;

    bool reverse=false;

    for(int i=0; i<Q; i++){
        cin >> T;
        if(T==1){
            reverse = (!reverse);
        }else{
            cin >> F >> C;
            if(F==1){
                string str(1,C);
                int position = reverse*S.size();
                S.insert(position, str);
            }else{
                string str(1,C);
                int position = (!reverse)*S.size();
                S.insert(position, str);                
            }
        }
    }

    if(reverse){
        for(int i=S.size()-1; i>=0; i--){
            cout << S[i];
        }
    }else{
        for(int i=0; i<=S.size()-1; i++){
            cout << S[i];
        }        
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#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(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  string s;
  cin >> s;

  int n = sz(s);
  
  if (n == 1) {
    cout << stoi(s) << endl;
    return 0;
  }

  ll ans = 0;
  rep(b,1<<(n-1)) {
    string tmp;
    tmp += s[0];
    rep(i,n-1) {
      if (b&(1<<i)) {
        ans += stoll(tmp);
        tmp = s[i+1];
      }
      else {
        tmp += s[i+1];
      }

      if (i == n-2) ans += stoll(tmp);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a>b) swap(a,b);
	if((b-a)&1) printf("%lld\n",(b-a+1)/2+min(a-1,n-b));
	else printf("%lld\n",(b-a)/2);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin >> N;

    vector<int> moths(2*N);
    for(int i=0; i<2*N; i++)
        cin >> moths[i];

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

    int length = 0;
    for(auto i=moths.begin(); i!=moths.end(); i += 2)
        length += *(i);
    cout << length << endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
namespace aizu
{
    public class No0100
    {
        private static readonly int Limit = 1000000;
        private static readonly int MaxNumber = 4000;
        public static void Main()
        {
            // ※ 1000000 * 100000はint型だとオーバーフローしてしまう
            int count;
            while(int.TryParse(Console.ReadLine(), out count) && count != 0) {
                Dictionary<int, long> value = new Dictionary<int, long>(MaxNumber);
                List<int> numbers = new List<int>(MaxNumber);
                for(int i=0; i < count; ++i) {
                    int[] input = (from q in Console.ReadLine().Split() select int.Parse(q)).ToArray();
                    if(value.ContainsKey(input[0]) == false) {
                        value.Add(input[0], 0);
                        numbers.Add(input[0]);
                    }
                    if(value[input[0]] < Limit) {
                        value[input[0]] += (long)input[1] * (long)input[2];
                    }
                }
                List<int> output = (from q in numbers where value[q] >= Limit select q).ToList();
                if(output.Count == 0) {
                    Console.WriteLine("NA");
                }
                else {
                    output.ForEach(number => Console.WriteLine(number));
                }
            }
        }
    }
}

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

ll solve() {
    ll INF = 1LL<<60;
    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }

    auto check = [&](ll m) {
        vector<vector<ll>> v;
        v.push_back(vector<ll>());
        for ( int i = 0; i < N; i++ ) {
            if ( A[i] > m ) {
                v[v.size()-1].push_back(A[i]);
            } else {
                v.push_back(vector<ll>());
            }
        }
        ll c = 0;
        for ( auto u : v ) {
            c += max((ll)(u.size() - K + 1), 0LL);
        }
        if ( c < Q ) return INF;
        vector<ll> w;
        for ( auto u : v ) {
            if ( u.size() < K ) continue;
            sort(u.begin(), u.end());
            for ( int j = 0; j < u.size() - K + 1; j++ ) {
                w.push_back(u[j]);
            }
        }
        sort(w.begin(), w.end());
        return w[Q-1] - w[0];
    };
    ll ans = check(0);
    for ( int i = 0; i < N; i++ ) {
        ans = min(ans, check(A[i]));
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#define I(i,n)for(int i=0;i<n;i++)
long long M=1e9+7,n,a[2],s[100000],w[2][100001],e[2],l[2][100000],p,v[2];
int main(){
	std::cin>>n>>a[0]>>a[1];
	I(i,n)std::cin>>s[i];
	I(k,2){
		p=0;
		I(i,n){
			while(s[i]-s[p]>=a[k]&&p<i-1)p++;
			l[k][i]=p;
		}
	}
	I(k,2){e[k]=-1;w[k][0]=1;}
	I(i,n){if(i){
		I(k,2)w[k][i]=(e[1-k]<l[k][i]?w[1-k][l[k][i]]:0);
		I(k,2)if(s[i]-s[i-1]<a[k]){e[k]=i-1;}else{(w[k][i]+=w[k][i-1])%=M;}
	}
	}
	std::cout<<(w[0][--n]+w[1][n])%M;
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <queue>
 
#define P pair<int,int>
using namespace std;
 
// マスの縦横
int H,W;
// #,.を格納するマス
char A[1000][1000];
// 幅優先探索の深さを格納するマス
int am[1000][1000];
// 隣り合う辺への移動量
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
// 答え
int ans=0;
 
void BFS(){
  // 入力を受取り、キューに位置x,yを格納
  cin >> H >> W;
  queue<P> que;
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      cin >> A[i][j];
      am[i][j] = -1;
      if (A[i][j]=='#'){
        am[i][j] = 0;
        que.push(P(i,j));
      }
    }
  }
  // キューを前から取り出し、隣り合う辺が.か#か調べ.なら#に更新し、深さを1足す
  while (!que.empty()){
    P p = que.front();
    que.pop();
    for (int i=0;i<4;i++){
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (nx>=0 && nx<H && ny>=0 && ny<W && A[nx][ny]!='#'){
        A[nx][ny] = '#';
        am[nx][ny] = am[p.first][p.second]+1;
        que.push(P(nx,ny));
      }
    }
  }
}
 
int main(){
  BFS();
  // 答えとなる最も深いものを取り出す
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      ans = max(ans, am[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define ll long long
#define rep(i, n) for(int i=0; i < (n); ++i)
#define repr(i, n) for(int i=n; i>= 0; --i)
#define FOR(i, m, n) for(int i=m; i<(n); ++i)



int main(){
    int A, B, C;
    cin >> A >> B >> C;

    cout << ((A <= C && C <= B)? "Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

using namespace std;

char field[2005][2005];
vector<int> inRow[2005];
vector<int> inCol[2005];


int main(void) {
  int h, w;
  scanf("%d%d", &h, &w);
  REP(i, h) {
    scanf("%s", field[i]);
    REP(j, w) {
      if(field[i][j] == '#') {
        inRow[i].push_back(j);
        inCol[j].push_back(i);
      }
    }
  }

  int res = 0;
  REP(i, h) REP(j, w) {
    if(field[i][j] == '#') continue;
    int cur = -1;

    auto it1 = lower_bound(inRow[i].begin(), inRow[i].end(), j);
    int tmp1 = -1;
    tmp1 += it1 == inRow[i].end() ? w : *it1;
    if(it1 != inRow[i].begin()) {
      --it1;
      tmp1 -= *it1;
    } else {
      tmp1 -= -1;
    }
    cur += tmp1;

    auto it2 = lower_bound(inCol[j].begin(), inCol[j].end(), i);
    int tmp2 = -1;
    tmp2 += it2 == inCol[j].end() ? h : *it2;
    if(it2 != inCol[j].begin()) {
      --it2;
      tmp2 -= *it2;
    } else {
      tmp2 -= -1;
    }
    cur += tmp2;

    if(cur > res) {
      res = cur;
      // cerr << "> " << i << " " << j << " " << res << " " << tmp1 << " " << tmp2 << endl;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 38400
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<ii> vii;

#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e5+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}


lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}

lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}

int dx[4]={0,0,1,-1}, dy[4]={1,-1,0,0};

vvi graph(int n, int m){
	vv(int,v,n+1,0);
	fore(i,0,m){
		int a,b; cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	return v;
}

// ---- コーディングはここから！ ('-')7

void solve(){
	int n; cin>>n;
	fore(i,0,n)cout<<"ACL";cout<<ENDL;
}

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


Measured memory_bytes: 3616
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	
	int a,b;
	int ans=-10000000;

	cin >> a >> b;

	ans = max(a + b, a - b);
	ans = max(ans, a * b);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

bool solve(int *A, int k, int x) {
  if (x == 0)
    return true;
  if (k == 0)
    return false;
  return solve(A, k - 1, x) || solve(A, k - 1, x - A[k - 1]);
}

int main() {
  int n, q;
  std::cin >> n;
  int A[n];
  rep(i, n) std::cin >> A[i];
  std::cin >> q;
  int m[q];
  rep(i, q) std::cin >> m[i];

  rep(i, q) {
    if (solve(A, n, m[i]))
      std::cout << "yes" << '\n';
    else
      std::cout << "no" << '\n';
  }

  return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      int n,q;
      cin>>n>>q;
      string s;
      cin>>s;
      int x[n];
      x[0]=0;
      for(int i=1;i<n;i++)
      {
        if(s[i]=='C' && s[i-1]=='A')
          x[i]=x[i-1]+1;
        else
          x[i]=x[i-1];
      }
      while(q--)
      {
        int l,r;
        cin>>l>>r;
        cout<<x[r-1]-x[l-1]<<"\n";
      }
      return 0;
    }

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define MOD 1000000007ll
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int f(ll x){
	int res = 0;
	while(x){
		x/=10ll;
		res++;
	}
	return res;
}
ll num(int x){
	x--;
	ll res = 9ll;
	for(int i=0;i<x;i++){
		res=(res*10ll)%MOD;
	}
	return res;
}
int S;
int d[3000000];
int main(){
	cin >> S;
	ll ans = 0ll;
	for(int i=1;i*i<=S;i++){
		if(S%i!=0)continue;
		ll add = num(i)-S/i+1ll;
		if(i>=9||add>0){
			ans += add;
			ans %= MOD;
		}
		if(i==S/i)continue;
		add = num(S/i)-i+1ll,0ll;
		if(i>=9||add>0){
			ans += add;
			ans %= MOD;
		}
	}
	int sum = 0;
	ll r = 1ll;
	for(int i=1;i<1000000;i++){
		while(sum<S){
			sum += f(r++);
		}
		if(sum==S&&f(i)<f(r-1))ans++;
		sum -= f(i);
	}
	ans %= MOD;
	int L = 9000000;
	for(int i=1;i<=S/7;i++){
		if(S%i==0)continue;
		int a = i-(S%i);
		if(S/i==7&&a>L)continue;
		ans++;
	}
	ans %= MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

#include <functional>
vector<int> StronglyConnectedComponent(vector<vector<int>> &G, vector<vector<int>> &rG) {
    int n = G.size();
    vector<bool> used(n, false);
    vector<int> V;
    vector<int> res(n, -1);
    function<void(int)> dfs = [&](int v) {
        if (used[v]) return;
        used[v] = true;
        for (auto &e : G[v]) {
            dfs(e);
        }
        V.push_back(v);
    };
    function<void(int, int)> rdfs = [&](int v, int k) {
        if (used[v]) return;
        res[v] = k;
        used[v] = true;
        for (auto &e : rG[v]) {
            rdfs(e, k);
        }
    };
    for (int i = 0; i < n; i++) {
        if (!used[i]) dfs(i);
    }
    used.assign(n, false);
    int k = 0;
    for (auto it = rbegin(V); it != rend(V); it++) {
        if (!used[*it]) rdfs(*it, k++);
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n, n) {
        vector<double> p(n);
        vector<vector<int>> G(n), rG(n);
        REP(i, 0, n) {
            cin >> p[i];
            int m;
            cin >> m;
            REP(j, 0, m) {
                int a;
                cin >> a;
                a--;
                G[i].push_back(a);
                rG[a].push_back(i);
            }
        }
        auto res = StronglyConnectedComponent(G, rG);
        int sz = *max_element(res.begin(), res.end()) + 1;
        vector<double> pp(sz, 1.0);
        REP(i, 0, n) {
            pp[res[i]] *= p[i];
        }
        REP(i, 0, pp.size()) {
            pp[i] = 1 - pp[i];
        }
        vector<int> DAG(sz, 0);
        REP(i, 0, n) {
            REP(j, 0, G[i].size()) {
                if (res[i] == res[G[i][j]]) continue;
                DAG[res[G[i][j]]]++;
            }
        }
        double ans = 1.0;
        REP (i, 0, sz) {
            if (DAG[i] == 0) {
                ans *= pp[i];
            }
        }
        cout << fixed << setprecision(10) << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  if(A+B>C+D){
    cout<<"Left"<<endl;
  }
  if(A+B==C+D){
    cout<<"Balanced"<<endl;
  }
  if(A+B<C+D){
    cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N;
char s[101][101];
int main()
{
  scanf("%d", &N);
  for(int i=0; i<N; ++i)
    scanf("%s", s[i]);
  for(int i=0; i<N-1; ++i)
  {
    if( s[i][strlen(s[i])-1] != s[i+1][0])
    {
      puts("No");
      return 0;
    }
  }
  for(int i=0; i<N; ++i)
    for(int j=0; j<i; ++j)
      if(0 == strcmp(s[i], s[j]))
      {
        puts("No");
        return 0;
      }
  puts("Yes");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <string>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<tuple<string, int, int>> a;

    for (int i = 1; i <= n; i++){
        string s;
        int p;
        cin >> s >> p;
        p = -p;
        a.push_back(tie(s, p, i));
    }

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

    for (int i = 0; i < n; i++){
        cout << get<2>(a[i]) << endl;
    }
    /*
    for (int i = 0; i < n; i++){
        string s;
        int p;
        int id;
        tie(s, p, id) = a[i];
        cout << id << endl;
    }
    */
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define cq(i,s,n) for(int i=s;i<=n;i++)
using namespace std;
const double eps=1e-12;
struct Point{
    double x,y;
}a[500005];
Point o;
int n; 
double ri;
double dis(Point a,Point b){
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); 
}

void tt(Point p1,Point p2,Point p3){
    double a,b,c,d,e,f;
    a=p2.y-p1.y;
    b=p3.y-p1.y;
    c=p2.x-p1.x;
    d=p3.x-p1.x;
    f=p3.x*p3.x+p3.y*p3.y-p1.x*p1.x-p1.y*p1.y;
    e=p2.x*p2.x+p2.y*p2.y-p1.x*p1.x-p1.y*p1.y;
    o.x=(a*f-b*e)/(2*a*d-2*b*c);
    o.y=(d*e-c*f)/(2*a*d-2*b*c);
    ri=dis(o,p1);
}

int main(){
    scanf("%d",&n);
    cq(i,1,n){
        scanf("%lf%lf",&a[i].x,&a[i].y);
    }
    random_shuffle(a+1,a+n+1);
    o=a[1];ri=0;
    cq(i,2,n){
        if(dis(a[i],o)>ri+eps){
            o=a[i];ri=0;
            cq(j,1,i-1){
                if(dis(o,a[j])>ri+eps){
                    o.x=(a[i].x+a[j].x)/2;
                    o.y=(a[i].y+a[j].y)/2;
                    ri=dis(o,a[j]);
                    cq(k,1,j-1){
                        if(dis(o,a[k])>ri+eps){
                            tt(a[i],a[j],a[k]);
                        }
                    }
                }
            }
        }
    }
    printf("%.10lf",ri);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair

using namespace std;

int main() {
    
    ll n; cin>>n;
    ll ar[n];
    for(int i = 0;i < n;i++) cin>>ar[i];
    sort(ar, ar+n, greater<ll>());
    
    vector<int> vec;
    
    ll comf = ar[0];
    
    for(int i = 1;i < n;i++){
        vec.pb(ar[i]);
        vec.pb(ar[i]);
        if(vec.size() >= n-1) break;
    }
    
    for(int i = 0;i < n-2;i++){
        comf += vec[i];
    }
    
    cout<<comf;
    
}

Measured memory_bytes: 5876
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

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

void Main()
{
  ld a, b, x; cin >> a >> b >> x;
  if(b * a * a == x) fin(0.);
  x /= a;
  if(b * a / 2. >= x)
  {
    ld base = x * 2. / b;
    fin(90. - atan(base / b) * 180 / PI);
  }
  else
  {
    ld S = a * b - x;
    ld hide = S * 2. / a;
    fin(atan(hide / a) * 180 / PI);
  }
  
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();
        System.out.println(s1.substring(0, 1).toUpperCase()
                + s2.substring(0, 1).toUpperCase()
                + s3.substring(0, 1).toUpperCase());
    }
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	string s; cin >> s;
	int n = s.length();
	for(int i = 0; i < n; i++)cout << 'x';
	cout << endl;
}	


Measured memory_bytes: 256