akhauriyash/Code-Regression huggingface dataset:
// マニ

#include<bits/stdc++.h>
#define ll            long long 
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define rrep(i,a,b) for(ll int i=a;i>=b;i--)
#define all(a)      (a).begin(),(a).end()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define PI 3.14159265358979323846
#define tr(i, cont) for(auto i=cont.begin();i!=cont.end();i++)
#define ios            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define trace(x)                 cerr << #x << ": " << x << "\n";
#define trace1(x)                cerr << #x << ": " << x << "\n";
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << "\n";
#define ar array
#define endl "\n"
using namespace std;

int main(){
    ios;
    ll n;
    cin>>n;
    vi v(n);
    rep(i,0,n){
        cin>>v[i];
    }
    sort(all(v));
    priority_queue<ll> pq;
    pq.push(v[n-1]);
    ll ans=0;
    rrep(i,n-2,0){
        ll cur=pq.top();
        pq.pop();
        ans+=cur;
        pq.push(v[i]);
        pq.push(v[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 6896
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<vector>
#include<tuple>
using namespace std;

int main(){
  int d;
  cin >> d;
  if(d==25){
    cout << "Christmas";
  }else if(d==24){
    cout << "Christmas Eve";
  }else if(d==23){
    cout << "Christmas Eve Eve";
  }else{
    cout << "Christmas Eve Eve Eve";
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){long long int n,i,ans=0;
cin>>n;
long long int a[n];
long long int cnt[n+1]={0};
for(i=0;i<n;i++){cin>>a[i];
    cnt[a[i]]++;
}
for(i=1;i<=n;i++){
    ans+=cnt[i]*(cnt[i]-1);
}ans/=2;
for(i=0;i<n;i++){
    cout<<min(ans,(ans+1-cnt[a[i]]))<<endl;
}
    return 0;}

Measured memory_bytes: 5760
n = gets.chomp.to_i
x=[]
y=[]
n.times do
  xx,yy = gets.chomp.split.map(&:to_i)
  x.push xx
  y.push yy
end

def len(x,y,x2,y2)
  Math.sqrt((x-x2)**2 + (y-y2)**2)
end

ans = 0

n.times do |i|
  n.times do |j|
    next if i==j
    ans += len(x[i], y[i], x[j], y[j])
  end
end

puts ans/n

Measured memory_bytes: 1916
import java.util.Scanner;
import java.util.Random;
import java.io.*;

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

		int length1 = scanner.nextInt();
		int[] arr1 = new int[length1];

		for (int i = 0; i < length1; i++) {
			arr1[i] = scanner.nextInt();
		}

		int length2 = scanner.nextInt();
		int[] arr2 = new int[length2];

		for (int i = 0; i < length2; i++) {
			arr2[i] = scanner.nextInt();
		}

		// Linear Search
		int count = 0;
		boolean cont = true;
		for (int i = 0; i < length2; i++) {
			cont = true;
			for (int j = 0; j < length1; j++) {
				if (arr2[i] == arr1[j]&& cont) {
					cont = false;
					count++;
				}
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 39896
n=int(input())
ab=[]
for i in range(n):
  ab.append(list(map(int,input().split())))
ab.sort(key=lambda x:x[1])
def ans():
  t=0
  for i in range(n):
    t+=ab[i][0]
    if t>ab[i][1]:
      print("No")
      return
  print("Yes")
ans()
  

Measured memory_bytes: 53656
def main():
    N = int(input())

    total = float('inf')
    for a in range(1, N):
        b = N - a
        n = 0
        while a > 0:
            n += a % 10
            a //= 10
        while b > 0:
            n += b % 10
            b //= 10
        total = min(total, n)

    print(total)

main()


Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    //const int MOD = 1000000007;
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int n = cin.NextInt();
        int count = 0;
        for (int i = 1; i <= n; i++)
        {
            if (((int)Math.Log10(i) + 1) % 2 == 1)
            {
                count++;
            }
        }
        Console.WriteLine(count);
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main(){
int a[3000],b[3000];
int count=0;
for(int i=0;i<3000;i++){
count++;
cin>>a[i]>>b[i];
if(a[i]==0&&b[i]==0)break;
       if(a[i]>b[i]){
             int tmp;
             tmp=a[i];
             a[i]=b[i];
            b[i]=tmp;
      }
}

for(int j=0;j<count-1;j++){
cout<<a[j]<<" "<<b[j]<<endl;
}
}
   

Measured memory_bytes: 3072
var
  min,n,i,x,s:longint;
begin
  readln(n);
  min:=maxlongint;
  for i:=1 to n do
    begin
      read(x);s:=0;
      while x mod 2=0 do begin inc(s);x:=x div 2;end;
      if s<min then min:=s;
    end;
  writeln(min);
end.

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#define LL long long
using namespace std;
const LL N=2e5+10;
struct jgt{
	LL x,y,next,w;
}bian[N];
LL n,m,black,white,co[N],h[N],cnt[10],tot,head[N];
bool vis[N],flag=true;
void add_edge(LL a,LL b)
{
	tot++;
	bian[tot].x=a;
	bian[tot].y=b;
	bian[tot].next=head[a];
	head[a]=tot;
}
void dfs(LL now,LL pre)
{
	LL i;
	vis[now]=true;
	for (i=head[now];i!=-1;i=bian[i].next)
	{
		LL v=bian[i].y;
		if (!vis[v])
		{
			co[v]=pre^1;
			cnt[co[v]]++;
			dfs(v,co[v]);
			if (!flag)
			  return;
		}
		else
		if (co[v]!=pre^1)
		{
		  flag=false;
		  return ;
	    }
	}
}
int main()
{
	LL i,a,b; 
	memset(head,-1,sizeof(head));
	scanf("%lld%lld",&n,&m);
	for (i=1;i<=m;i++)
	  scanf("%lld%lld",&a,&b),add_edge(a,b),add_edge(b,a);
	cnt[co[1]]++;
	dfs(1,0);
	if (!flag)
		printf("%lld",n*(n-1)/2-m);
	else
		printf("%lld",n*(n-1)/2-cnt[0]*(cnt[0]-1)/2-cnt[1]*(cnt[1]-1)/2-m);
} 

Measured memory_bytes: 11392
fun main(args: Array<String>) {
    val (n, p) = readLine()!!.split(' ').map { it.toInt() }
    val s = readLine()!!.reversed()

    val ans = if (10 % p == 0) {
        (0 until n)
                .filter { (s[it] - '0') % p == 0 }
                .map { 0L + n - it }
                .sum()
    } else {
        val cnt = IntArray(p)
        var x = 0
        var b = 1
        (0 until n)
                .map {
                    cnt[x]++
                    x += (s[it] - '0') * b
                    x %= p
                    b = b * 10 % p
                    cnt[x].toLong()
                }
                .sum()
    }

    println(ans)
}


Measured memory_bytes: 50456
import collections

N = int(input())
A = sorted(map(int, input().split()))

dp = collections.defaultdict(lambda: True)

for i in range(N):
    if i < N - 1 and A[i] == A[i + 1]:
        dp[A[i]] = False
    k = 2
    while True:
        if A[i] * k > A[-1]:
            break
        else:
            dp[A[i] * k] = False
            k += 1

print(sum(dp[a] for a in A))

Measured memory_bytes: 101700
main()
{
    int N, H[20], i, HH, ans=1;
    scanf("%d%d", &N, &H[0]);HH=H[0];
    for(i=1;i<N;i++)
    {
        scanf("%d", &H[i]);
        if(HH <= H[i]){ans++;HH=H[i];}
    }
    printf("%d", ans);
}


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


int main(){
    int D,N;
    cin >> D >> N;
    int k;
    if(D==0) k=1;
    else if(D==1) k=100; 
    else k=10000;
    if(N==100) ++N;
    cout << N*k << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+100;
const int nl=-1;
struct node
{
	int p,l,r;
}T[N];
int leve[N];
void rec(int u,int p)
{
	leve[u]=p;
	if(T[u].r!=nl) rec(T[u].r,p);//右侧兄弟设置为相同深度
	if(T[u].l!=nl) rec(T[u].l,p+1);//最左侧结点的深度设置为自己深度+1 
 } 
void print(int u)
{
	
	cout<<"node "<<u<<": ";
	cout<<"parent = "<<T[u].p<<", ";
	cout<<"depth = "<<leve[u]<<", ";
	if(T[u].p==nl) cout<<"root, ";
	else if(T[u].l==nl) cout<<"leaf, ";
	else  cout<<"internal node, ";
	cout<<"[";
	bool flag=false;
	for(int i=T[u].l;i!=nl;i=T[i].r){
		if(flag) cout<<", ";
		cout<<i;
		flag=true;
	}
	cout<<"]"<<endl;
 	
} 
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++) T[i].p=nl,T[i].l=nl,T[i].r=nl;
	for(int i=0;i<n;i++){
		int v,d;
		cin>>v>>d;
		int t;
		for(int j=0;j<d;j++){
			int c;
			cin>>c;
			if(j==0){
				T[v].l=c;
			}
			else{
				T[t].r=c;	
			}
			t=c;
			T[c].p=v;
		}
	}
	int id;
	for(int i=0;i<n;i++){
		if(T[i].p==nl){
			id=i;
			break;
		}
	}
	rec(id,0);
	for(int i=0;i<n;i++){
		print(i);
	}
	return 0;
}














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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int n; cin >> n;
    vi p(n); REP(i, n) cin >> p[i];
    int ans = 0;
    REP1(i, n-2)
    {
        if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])) ans++;
    }
    cout << ans << endl;
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        int num1 = Integer.parseInt(line[0]),
            num2 = Integer.parseInt(line[2]);
        if(line[1].equals("+")) System.out.println(num1+num2);
        else System.out.println(num1-num2);
    }
}

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

// bit全探索で書いてみる
int main() {

    vector<char> S(4);
    for (int i = 0; i < 4; i++)
    {
        cin >> S[i];
    }

    for (int tmp = 0; tmp < (1 << 3); tmp++)
    {
        int sum = (int)(S[0] - '0');
        string res = "";
        res += S[0];

        bitset<3> s(tmp);
        for (int i = 0; i < 3; i++)
        {
            /* code */
            if (s.test(i))
            {
                sum += (int)(S[i+1] - '0');
                res += '+';
                res += S[i + 1];
            }
            else
            {
                sum -=(int)(S[i+1] - '0');
                res += '-';
                res += S[i+1];
            }
        }

        if (sum == 7) {
            res += "=7";
            cout << res << endl;
            break;
        }
        }
}

Measured memory_bytes: 256
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
#define biggest(A,B) A=max(A,B)
#define smallest(A,B) A=min(A,B)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n;
LL a[303];
int main(){
	fastio;
	cin>>n;
	rb(i,1,n)
		cin>>a[i];
	LL tmp=0;
	// a xor b = a+b - 2*(a and b)
	rb(i,3,n){
		tmp^=a[i];
	}			
	LL need=a[1]+a[2]-tmp;
	if(need<0||need%2==1){
		cout<<"-1"<<endl;
		return 0; 
	}
  LL sum=a[1]+a[2];
	LL rest=a[1]+a[2]-need;
	need/=2;
	LL upp=a[1];
	a[1]=need;
  	a[2]=need;
	rl(i,42,0){
		if(need&(1ll<<i)){
			if(rest&(1ll<<i)) {
				cout<<-1<<endl;
				return 0;
			}
			continue;
		}	
		if(rest&(1ll<<i)){
			if(a[1]+(1ll<<i)<=upp){
				a[1]+=1ll<<i;
			}
          	else{
            	a[2]+=1ll<<i;
            }
		}
	}
	if(a[1]==0||a[2]>=sum||a[1]>upp){
		cout<<-1<<endl;
		return 0;
	}
	cout<<upp-a[1]<<endl;
	return 0;
}


Measured memory_bytes: 3640
x,k,d = map(int,input().split())
x = abs(x)
c = x//d
if c >= k:
    print(x - k*d)
else:
    y = x - c*d
    z = x - (c+1) * d
    if (c-k) %2 == 0:
        print(y)
    else:
        print(abs(z))

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int h, w, k;
  cin >> h >> w >> k;
  vvi a(h, vi(w));
  vvi c(h, vi(w));
  rep(j, h) {
    string s;
    cin >> s;
    rep(i, w) a[j][i] = s[i] == '#' ? 1 : 0;
  }
  int cnt = 1;
  vi b(h);
  rep(j, h) rep(i, w) if (a[j][i]) b[j]++;
  rep(j, h) {
    if (b[j] == 0) continue;
    int n = 0;
    rep(i, w) {
      if (a[j][i]) {
        n++;
        if (n > 1) cnt++;
      }
      c[j][i] = cnt;
    }
    if (n > 0) cnt++;
  }
  dump(k, cnt);
  rep(j, h - 1) {
    if (b[j] > 0 && b[j + 1] == 0) {
      rep(i, w) c[j + 1][i] = c[j][i];
      b[j + 1] = b[j];
    }
  }
  for (int j = h - 1; 0 < j; j--) {
    if (b[j] > 0 && b[j - 1] == 0) {
      rep(i, w) c[j - 1][i] = c[j][i];
      b[j - 1] = b[j];
    }
  }
  dumpv(c, h, w);
  rep(j, h) {
    rep(i, w) cout << c[j][i] << ' ';
    cout << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 1536
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        r: i64,
        d: i64,
        x: i64,
    }
    let mut x = x;
    for i in 0..10 {
        x = r * x - d;
        println!("{}", x);
    }
}

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

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

	int n; cin >> n;
	long long f[n + 1][3] = {0};
	for (int i = 1; i <= n; i++) cin >> f[i][0] >> f[i][1] >> f[i][2];
	
	for (int i = 1; i <= n; i++) {
		f[i][0] += max (f[i - 1][1], f[i - 1][2]);
		f[i][1] += max (f[i - 1][0], f[i - 1][2]);
		f[i][2] += max (f[i - 1][0], f[i - 1][1]);
	}

	cout << max (f[n][0], max (f[n][1], f[n][2]));
	return 0;
}

Measured memory_bytes: 5984
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b)(fabs((a)-(b))<EPS)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

struct Point {
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}
	Point operator*(double a) { return Point(a*x, a*y); }
	Point operator-(Point p) { return Point(x - p.x, y - p.y); }
};
struct Segment {
	Point p1, p2;
};
double cross(Point a, Point b) {
	return a.x*b.y - a.y*b.x;
}
double dot(Point a, Point b) {
	return a.x*b.x + a.y*b.y;
}
bool isPrallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
bool isOrthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
typedef vector<Point>Polygon;
int contains(Polygon g, Point p) {
	int n = g.size();
	bool x = false;
	rep(i, n) {
		Point a = g[i] - p, b = g[(i + 1) % n] - p;
		if (abs(cross(a, b)) < EPS&&dot(a, b) < EPS)return 1;
		if (a.y > b.y)swap(a, b);
		if (a.y < EPS&&EPS<b.y&&cross(a, b)>EPS)x = !x;
	}
	return x ? 2 : 0;
}
int main() {
	while (1) {
		Polygon g;
		double x, y;
		rep(i, 3) {
			if (!(cin >> x))return 0;
			cin >> y;
			g.push_back(Point(x, y));
		}
		cin >> x >> y;
		if (contains(g, Point( x,y )) == 2)puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 3168
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int c[12], a[12][12], s[12];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n = gi();
    int m = gi();
    int x = gi();
    for (int i = 0; i < n; i++) {
        c[i] = gi();
        for (int j = 0; j < m; j++)
            a[i][j] = gi();
    }
    int h = (1 << n);
    int res = -1;
    for (int i = 0; i < h; i++) {
        memset(s, 0, sizeof(s));
        int C = 0;
        int w = i;
        for (int j = 0; j < n; j++) {
            if (w%2) {
                C += c[j];
                for (int i = 0; i < m; i++)
                    s[i] += a[j][i];
            }
            w /= 2;
        }
        int f = 1;
        for (int i = 0; i < m; i++)
            if (s[i] < x) {
                f = 0;
                break;
            }
        if (f) {
            if (res == -1 || C < res)
                res = C;
        }
    }

    printf("%d\n", res);

    return 0;
}


Measured memory_bytes: 3852
#include <iostream>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

const long long INF = 1e18;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx=tx-sx, dy=ty-sy;
    string ans="";
    ans += string(dx, 'R') + string(dy, 'U');
    ans += string(dx, 'L') + string(dy, 'D');
    ans += "D" + string(dx+1, 'R') + string(dy+1, 'U') + "L";
    ans += "U" + string(dx+1, 'L') + string(dy+1, 'D') + "R";

    cout << ans << endl;
}

Measured memory_bytes: 256
while True:
 n, x = map(int, input().split())
 if n == x == 0:
  break
 Sum = 0
 count = 0
 for a in range(1, n + 1):
  for b in range(a + 1, n + 1):
   for c in range(b + 1, n + 1):
    Sum = a + b + c
    if Sum == x:
     count = count + 1
 print(count)

Measured memory_bytes: 7696
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, m;
    cin >> n >> m;
    map <pii, bool> used;
    vector <int> row(n), col(m);
    int k;
    cin >> k;
    forn (i, 0, k) {
        int x, y;
        cin >> x >> y, --x, --y;
        row[x]++, col[y]++;
        used[{x, y}] = true;
    }
    int mx_row = *max_element(all(row)),
        mx_col = *max_element(all(col));
    vector <int> good_row, good_col;
    forn (i, 0, n)
        if (row[i] == mx_row)
            good_row.pb(i);
    forn (i, 0, m)
        if (col[i] == mx_col)
            good_col.pb(i);
    for (int x : good_row) {
        for (int y : good_col) {
            if (!used[{x, y}]) {
                cout << mx_row + mx_col;
                return 0;
            }
        }
    }
    cout << mx_row + mx_col - 1;
    return 0;
}

Measured memory_bytes: 28460
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<pair<int,int>>st(n);
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		st[i]={a[i],i};	
	}
	sort(st.begin(),st.end());
	for(int i=0;i<n;i++)
	{
		if(st[n-1].second==i)
			cout<<st[n-2].first<<endl;
		else
			cout<<st[n-1].first<<endl;
	}
	return 0;
}

Measured memory_bytes: 3968
#include<iostream>
#include<map>
#include<string>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::string S; std::cin >> S;
  std::map<char,int> m;
  for(int i = 0; i < 4; ++i) ++m[S[i]];
  for(auto const& p: m) if(p.second != 2) fin("No");
  fin("Yes");
  return 0;
}


Measured memory_bytes: 256
A, B, N = map(int, input().split())
# pre_x = list()
# ind = B-1
# while ind <= N:
#     pre_x.append(ind)
#     ind += B

# if len(pre_x) == 0:
#     ans = int(A*N/B) - A*int(N/B)
#     print(ans)
# else:
#     ans = 0
#     for x in pre_x:
#         ans = max(ans, int(A*x/B) - A*int(x/B))
    
#     print(ans)

# if B > N:
#     print(int(A*N/B) - A*int(N/B))
# else:
#     x_under = max(int())

if B > N:
    print(int(A*N/B) - A*int(N/B))
else:
    x = B - 1
    print(int(A*x/B) - A*int(x/B))


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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++){
        cin >> l.at(i);
    }
    sort(l.begin(), l.end());
    l.erase(unique(l.begin(),l.end()), l.end());
    cout << l.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=1e9;
const double eps=1e-9;
const int maxn=2e4+10;
struct node{
	int x,y;
}a[maxn],b[maxn];
int vis[maxn],to[maxn<<1],nex[maxn<<1],beg[maxn],flow[maxn<<1],dis[maxn],gap[maxn];
int e=1,s,t,n;
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
inline void add(int x,int y,int z){
	to[++e]=y;
	nex[e]=beg[x];
	beg[x]=e;
	flow[e]=z;
}
int isap(int x,int f){
	if(x==t)return f;
	int res=f,i;
	for(i=beg[x];i;i=nex[i])
		if(flow[i]>0 && dis[x]==dis[to[i]]+1){
			int minflow=isap(to[i],min(res,flow[i]));
			flow[i]-=minflow;
			flow[i^1]+=minflow;
			res-=minflow;
			if(!res)return f;
		}
	if(!(--gap[dis[x]]))dis[s]=(2*n+2);
	gap[++dis[x]]++;
	return f-res;
}
int main(){
	int i,j,k,m;
	n=read();s=2*n+1;t=2*n+2;
	for(i=1;i<=n;i++)a[i].x=read(),a[i].y=read();
	for(i=1;i<=n;i++)b[i].x=read(),b[i].y=read();
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(a[i].x<b[j].x && a[i].y<b[j].y)add(i,j+n,1),add(j+n,i,0);
	for(i=1;i<=n;i++)add(2*n+1,i,1),add(i,2*n+1,0);
	for(i=1;i<=n;i++)add(i+n,2*n+2,1),add(2*n+2,i+n,0);
	int maxflow=0;
	for(gap[0]=(2*n+2);dis[s]<(2*n+2);)maxflow+=isap(s,1e9);
	printf("%d\n",maxflow);
	return 0;
}


Measured memory_bytes: 384
# include <bits/stdc++.h>
# define ll long long
using namespace std;
ll count(ll a, ll b, ll c){
	ll lcm = c / __gcd(c, b) * b;
	ll x = a / b, y = a / c, z = a / lcm;
	return a + z - x - y;
}
int main(){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << count(b, c, d) - count(a - 1, c, d) << endl;
}


Measured memory_bytes: 256
N = gets.to_i

require 'prime'
dict = Hash.new { 0 }
(2..N).each do |a|
  a.prime_division.each do |n, e|
    dict[n] += e
  end
end
MOD = 10 ** 9 + 7
ans = 1
dict.each do |_, c|
  ans = (ans * (c + 1)) % MOD
end
puts ans

Measured memory_bytes: 2300
#include <bits/stdc++.h>
#define PII pair<int, int>
#define LL long long
#define double long double
using namespace std;
const int MAXN = 205;
 
struct Vector {
	int x, y;
	LL cross(const Vector &v) const {
		return (LL) x * v.y - (LL) y * v.x;
	}
	bool operator < (const Vector &v) const {
		if (v.x == 0 && v.y == 0) return false;
		if (x == 0 && y == 0) return true;
		int id1 = y > 0 || (y == 0 && x >= 0) ? 1 : 2;
		int id2 = v.y > 0 || (v.y == 0 && v.x >= 0) ? 1 : 2;
		if (id1 != id2) return id1 < id2;
		return cross(v) > 0;
	}
};
 
int N;
LL sumx[MAXN], sumy[MAXN];
Vector vec[MAXN];
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
 
	cin >> N;
	for (int i = 1; i <= N; i++) {
		int x, y;
		cin >> x >> y;
		vec[i] = {x, y};
	}
	sort(vec + 1, vec + 1 + N);
	for (int i = 1; i <= 2 * N; i++) {
		sumx[i] = sumx[i - 1] + vec[i].x;
		sumy[i] = sumy[i - 1] + vec[i].y;
		if (i <= N) {
			vec[i + N] = vec[i];
		}
	}
	
	LL ans = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = i; j - i + 1 <= N; j++) {
			LL vx = sumx[j] - sumx[i - 1];
			LL vy = sumy[j] - sumy[i - 1];
			ans = max(ans, vx * vx + vy * vy);
		}
	}
	
	cout << fixed << setprecision(18) << sqrt(ans) << '\n';
 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int array1[n], array2[n];
    int menorh;
    for (int i = 0; i<n;i++) {
        cin>>array1[i];
    }
    
    for (int i = 0; i<n-1;i++) {
        if(i==0)
        {
            array2[i+1]=abs(array1[i]-array1[i+1]);
            array2[i+2]=abs(array1[i]-array1[i+2]);
            menorh=min(array2[i+1], array2[i+2]);
        }
        else if(i==n-2)
        {
            array2[i+1]=min(abs(array1[i]-array1[i+1])+array2[i], array2[i+1]);
            menorh=array2[i+1];
        }
        else
        {
            array2[i+1]=min(abs(array1[i]-array1[i+1])+array2[i], array2[i+1]);
            array2[i+2]=abs(array1[i]-array1[i+2])+array2[i];
            menorh=min(array2[i+1], array2[i+2]);
        }
    }
    
    cout << menorh;
    return 0;

}

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

l=0
r=0

li=0
ri=0

for i in range(N):
    if l<=r:
        l+=A[li]
        li+=1
    else:
        r+=A[-1-ri]
        ri+=1
        
print(abs(l-r))

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

struct UnionFind {
  int num;
  vector<int> par, rank;
  UnionFind() {}
  UnionFind(int n) : num(n), par(n, 1), rank(n, 0) { iota(par.begin() ,par.end(), 0); }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  bool unite (int x, int y) {
    x = find(x);
    y = find(y);
    if (x==y) return true;
    if (rank[x] < rank[y]) swap(x, y);
    rank[x] += rank[y];
    par[y] = x;
    num--;
  }
  int size(int x) {
    return rank[find(x)];
  }
  int count() const {
    return num;
  }
};


int ABC126_E () {
  int n, m;
  cin >> n >> m;
  UnionFind uni(n);
  for (int i=0; i<m; i++){
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--;
    uni.unite(x, y);
  }
  cout << uni.count() << endl;
}

int main(){
  ABC126_E();

  return 0;
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

int main(){
  int ans = 0;
  rep(i, 5) {
    int n;
    cin >> n;
    if (n == 0) {
      ans = i + 1;
    }
  }

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <queue>
#include <map>
#include <string.h>
#include <vector>

const int MAX_N = 100010;

int par[MAX_N];
int rank[MAX_N];
int size[MAX_N];

void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rank[i] = 0;
    size[i] = 1;
  }
}

int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rank[x] < rank[y]) {
    par[x] = y;
    size[y] += size[x];
  } else {
    par[y] = x;
    size[x] += size[y];
    if (rank[x] == rank[y]) rank[x]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int getSize(int x) {
  return size[find(x)];
}

using namespace std;
typedef long long ll;

struct Query {
  int x;
  int y;
  int z;

  Query(int x, int y, int z) {
    this->x = x;
    this->y = y;
    this->z = z;
  }
};

struct Node {
  int parent;
  int size;

  Node (int parent = -1, int size = -1) {
    this->parent = parent;
    this->size = size;
  }

  bool operator>(const Node &n) const {
    return size < n.size;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  init(N + 1);
  vector<Query> query;

  for (int i = 0; i < M; ++i) {
    int x, y, z;
    cin >> x >> y >> z;

    query.push_back(Query(x, y, z));
  }

  for (int i = 0; i < M; ++i) {
    Query q = query[i];

    unite(q.x, q.y);
  }

  int ans = 0;

  bool checked[N + 1];
  memset(checked, false, sizeof(checked));

  priority_queue <Node, vector<Node>, greater<Node>> pque;

  for (int i = 1; i <= N; i++) {
    Node node(par[i], getSize(i));
    pque.push(node);
  }

  while (!pque.empty()) {
    Node node = pque.top();
    pque.pop();

    if (checked[node.parent]) continue;
    checked[node.parent] = true;
    ++ans;
  }

  for (int i = 1; i <= N; ++i) {
    if (checked[par[i]]) continue;
    checked[par[i]] = true;
    ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4468
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

// #define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
using P = pair<int, int>;
using ll = long long;
vector<int> to[100005];
int cost[100005];
int a, b;
ll calcCost(ll x) {
    return x*a + ((int)log10(x)+1)*b;
}

signed main(){
    int a,b;
    cin >> a>>b;
    cout << a*b << endl;
    
    return 0;
}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Count Order
            int N = int.Parse(Console.ReadLine());
            var numbers = Enumerable.Range(1, N).ToList();

            var lib = new Library.Combination();
            var combis = lib.AllCombinations<int>(numbers, N, true);

            var dic = new Dictionary<string, int>();
            int i = 1;

            foreach(var c in combis)
            {
                var s = String.Join(" ", c);
                dic.Add(s, i);
                i++;
            }

            var P = Console.ReadLine();
            var Q = Console.ReadLine();

            int ans = Math.Abs(dic[P] - dic[Q]);
            Console.WriteLine(ans);
        }
    }
}

namespace Library
{
    class Combination
    {
        public IEnumerable<List<T>> AllCombinations<T>(List<T> source, int n,
                                                       bool isAllowDupication = false)
        {
            //[summary]異なる要素から、n個を選ぶ組み合わせを列挙する
            //"isAllowDupication"を"true"にすると、重複を許可する
            //(重複を許可して、nを要素数と同じにすると、順列を列挙する)

            if (n == 1)
            {
                foreach (var s in source)
                {
                    yield return new List<T> { s };
                }

                yield break;
            }
            else
            {
                for (int i = 0; i < source.Count; i++)
                {
                    List<T> clone;

                    if (isAllowDupication)
                    {
                        //重複を許可する場合は、その要素のみを削除
                        clone = new List<T>(source);
                        clone.RemoveAt(i);
                    }
                    else
                    {
                        //重複を許可しない場合は、自分よりも前の要素はすべて削除
                        clone = new List<T>(source.Skip(i + 1));
                    }

                    //再帰処理
                    var items = AllCombinations(clone, n - 1, isAllowDupication);

                    foreach (var item in items)
                    {
                        item.Insert(0, source[i]);
                        yield return item;
                    }
                }
            }
        }

        public int CountCombinations(int n, int r)
        {
            //[summary]組み合わせの数 nCr を計算
            //(n種類の中から、r種類を選ぶ)
            int ans = 1;

            for (int i = 1; i <= r; i++)
            {
                ans = ans * (n - i + 1) / i;
            }

            return ans;
        }
    }
}

Measured memory_bytes: 24772
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  n;
  cin >>  n;
  vector<long long> cnt(5);
  string s;
  long long ans = 0, m = 0;
  for(int i = 0; i<n; i++){
    cin >> s;
    if(s[0] == 'M'){
      cnt[0]++;
    }else if(s[0] == 'A'){
      cnt[1]++;
    }else if(s[0] == 'R'){
      cnt[2]++;
    }else if(s[0] == 'C'){
      cnt[3]++;
    }else if(s[0] == 'H'){
      cnt[4]++;
    }
  }
  
  for(int i = 0; i<5;i++){
    for(int j = i+1;j<5;j++){
      for(int k = j+1;k<5;k++){
        m = cnt[i]*cnt[j]*cnt[k];
        ans += m;
      }
    }
  }
 

  cout << ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
 #define int long long
 #define pa pair<int,int>
  #define  mp make_pair
  #define  pb push_back
 using namespace std;





 signed main(){
 	
 
    cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
 	cin>>n;
 	vector<int> ve(n);
 	for(int i=0;i<n;i++)cin>>ve[i];
 	map<int,int>ma;
 	for(int i=0;i<n;i++){
 		int y=ve[i];
 		int yy=y;
 		for(int j=2;j*j<=y;j++)if(yy%j==0){
 			ma[j]+=y;
 			while(yy%j==0)yy/=j;
 		}
 		if(yy>1)ma[yy]+=y;
 	}
 	int ans=0;
 	for(auto it=ma.begin();it!=ma.end();it++)ans=max(ans,(*it).second);
 	cout<<ans<<endl;
return 0;

 }


Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//解説AC
//参考:公式解説放送 youtube.com/watch?v=bHzohtVsG0Q

int n;

void dfs(string s, char mx){
  if(s.size() == n)
  {cout << s << endl;
  return;}

  for (char c = 'a'; c<= mx+1; c++)
  {
    string t = s;
    t += c;
    dfs(t, max(mx,c));
  }
}


int main()
  {
  cin >> n;
  dfs("",'a'-1);

  return 0;
  }


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N ;
  cin >> N ;
  int a = N/1000;
  int b = (N-a*1000)/100; 
  int c = (N-a*1000-b*100)/10;
  int d = N%10;
  if (a == b && b == c ){
    cout << "Yes" << endl ;
  }
  
  
  else if (c == b && b == d ){
    cout << "Yes" << endl ;
  }
  else{
    cout << "No" << endl ;
  }

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define INF (1<<21)

static const int M[6] = {1, 5, 10, 50, 100, 500};

int getMin(int T[], int x){
    int sum = 0, c;
    for ( int i = 5; i >= 0; i--){
	if ( x >= M[i] && T[i] > 0 ){
	    c = min(T[i], x/M[i]);
	    x -= c*M[i];
	    sum += c;
	}
    }

    if ( x > 0 ) return INF;
    return sum;
}

main(){
    int p, T[6];
    int O[6] = {INF, INF, INF, INF, INF, INF};

    while( cin >> p && p ){
	for ( int i = 0; i < 6; i++ ) cin >> T[i];
	int ans = INF;
	for ( int add = 0; add <= 500; add++ ){
	    ans = min(ans, getMin(T, p+add) + getMin(O, add) );
	}
	cout << ans << endl;
    }
}

Measured memory_bytes: 0
import java.util.*;
import static java.lang.System.*;

class Main{
  public static void main(String[] a){
    Scanner sc = new Scanner(in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int t = sc.nextInt();
    
    int y = (n+x-1)/x;
    out.print(y * t);
  }
}

Measured memory_bytes: 35660
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int s=700;
	char c;
	scanf("%c",&c);
	if(c=='o')
		s+=100;
	scanf("%c",&c);
	if(c=='o')
		s+=100;
	scanf("%c",&c);
	if(c=='o')
		s+=100;
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		
		short[] a_array = new short[A];
		short[] b_array = new short[B];
		
		for(int i = 0; i < A; i++){
			a_array[i] = sc.nextShort();
		}
		
		for(int i = 0; i < B; i++){
			b_array[i] = sc.nextShort();
		}
		
		short[][] dp = new short[A+1][B+1];
		int max = 0;
		for(int i = 0; i < A; i++){
			for(int j = 0; j < B; j++){
				if(a_array[i] == b_array[j]){
					dp[i+1][j+1] = (short) (dp[i][j] + 1);
				}else{
					dp[i+1][j+1] = dp[i][j+1];
				}
			}
		}
		
		for(int i = 0; i <= B; i++){
			max = Math.max(max, dp[A][i]);
		}
		/*
		for(int i = 0; i <= A; i++){
			System.out.print((i == 0 ? " " : a_array[i-1]) + " :");
			for(int j = 0; j <= B; j++){
				System.out.print(" " + dp[i][j]);
			}
			System.out.println();
		}
		*/
		System.out.println(max);
	}

}

Measured memory_bytes: 86104
L = int(input())
N=0
A=[]
ret=[]
while True:
    N += 1
    A.append(L % 2)
    L //= 2
    if L<1:
        break

s=2
l=1
M = 0
for i in range(len(A)-2,-1,-1):
    ret.append("{0} {1} {2}".format(s-1, s, l))
    ret.append("{0} {1} {2}".format(s-1, s, 0))
    M += 2
    if A[i]==1:
        l *= 2
        ret.append("{0} {1} {2}".format(1, s, l))
        l += 1
        M += 1
    else:
        l *= 2
        
    s += 1
        
print ("{0} {1}".format(N, M))
for r in ret:
    print (r)

Measured memory_bytes: 3064
#include <climits>
#include <iostream>
#include <map>
#include <queue>

using namespace std;

vector<int> mc;

int cost(int w)
{
	int c = 0;
	
	if( w <= 10 ) {
		c = 1150;
	} else if( 10 < w && w <= 20 ) {
		c = 1150 + (w - 10)*125;
	} else if( 20 < w && w <= 30 ) {
		c = 1150 + 125*10 + (w - 20)*140;
	} else if( 30 < w ) {
		c = 1150 + 125*10 + 10*140 + (w - 30)*160;
	}

	return c;
}

int main(int argc, char* argv[])
{
	int w;
	
	while(1) {

		cin >> w;

		if( w == -1 ) break;

		mc.push_back(cost(w));

	}

	for( int i = 0; i < mc.size(); i++ ) {

		int c0 = mc[i];

		cout << 4280 - c0 << endl;
		
	}

    return 0;
}

Measured memory_bytes: 2996
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string s; cin >> s;
	int c, f; c = f = -1;
	rep(i, s.size())if (s[i] == 'C')
	{
		c = i; break;
	}
	rrep(i, s.size())if (s[i] == 'F')
	{
		f = i; break;
	}
	if (c >= 0 && f >= 0 && c < f)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
namespace my_header {
#define pb push_back
#define mp make_pair
#define pir pair<int, int>
#define vec vector<int>
#define pc putchar
#define clr(t) memset(t, 0, sizeof t)
#define pse(t, v) memset(t, v, sizeof t)
#define bl puts("")
#define wn(x) wr(x), bl
#define ws(x) wr(x), pc(' ')
	const int INF = 0x3f3f3f3f;
	typedef long long LL;
	typedef double DB;
	inline char gchar() {
		char ret = getchar();
		for(; (ret == '\n' || ret == '\r' || ret == ' ') && ret != EOF; ret = getchar());
		return ret; }
	template<class T> inline void fr(T &ret, char c = ' ', int flg = 1) {
		for(c = getchar(); (c < '0' || '9' < c) && c != '-'; c = getchar());
		if (c == '-') { flg = -1; c = getchar(); }
		for(ret = 0; '0' <= c && c <= '9'; c = getchar())
			ret = ret * 10 + c - '0';
		ret = ret * flg; }
	inline int fr() { int t; fr(t); return t; }
	template<class T> inline void fr(T&a, T&b) { fr(a), fr(b); }
	template<class T> inline void fr(T&a, T&b, T&c) { fr(a), fr(b), fr(c); }
	template<class T> inline char wr(T a, int b = 10, bool p = 1) {
		return a < 0 ? pc('-'), wr(-a, b, 0) : (a == 0 ? (p ? pc('0') : p) : 
			(wr(a/b, b, 0), pc('0' + a % b)));
	}
	template<class T> inline void wt(T a) { wn(a); }
	template<class T> inline void wt(T a, T b) { ws(a), wn(b); }
	template<class T> inline void wt(T a, T b, T c) { ws(a), ws(b), wn(c); }
	template<class T> inline void wt(T a, T b, T c, T d) { ws(a), ws(b), ws(c), wn(d); }
	template<class T> inline T gcd(T a, T b) {
		return b == 0 ? a : gcd(b, a % b); }
	template<class T> inline T fpw(T b, T i, T _m, T r = 1) {
		for(; i; i >>= 1, b = b * b % _m)
			if(i & 1) r = r * b % _m;
		return r; }
};
using namespace my_header;

const int MOD = 1e9 + 7;
int stk[111111], top;
int n;

int main() {
#ifdef lol
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
#endif
	fr(n);
	int ans = 1;
	for (int i = 1; i <= n; ++i) {
		int x = fr();
		if (top >= 1 && top * 2 - 1 > stk[top]) {
			ans = 1LL * ans * top % MOD;
			--top;
		}
		stk[++top] = x;
	}
	for (; top > 1; --top)
		ans = 1LL * ans * top % MOD;
	wt(ans);


	return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.math.*;
 
class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
while(sc.hasNextDouble()){
double a=sc.nextDouble();
double b=sc.nextDouble();
double c=sc.nextDouble();
double d=sc.nextDouble();
double e=sc.nextDouble();
double f=sc.nextDouble();
double x=(c*e-b*f)/(a*e-b*d);
double y=(c*d-a*f)/(b*d-a*e);
BigDecimal p=new BigDecimal(x);
BigDecimal q=new BigDecimal(y);
p=p.setScale(3,BigDecimal.ROUND_HALF_UP);
q=q.setScale(3,BigDecimal.ROUND_HALF_UP);
System.out.printf("%.3f %.3f%n",p,q);
}
}
}

Measured memory_bytes: 20776
import java.util.*;

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

    int x = sc.nextInt();
    int y = sc.nextInt();
    int z = sc.nextInt();

    int ans = 0;

    ans = Math.max(x, Math.max(y, z)) - Math.min(x, Math.min(y, z));

    System.out.println(ans);
  }
}


Measured memory_bytes: 23636
n, k = map(int, input().split())

ans = 0
for a in range(1, n+1):
    b = a % k
    c = a % k
    if (b + c) % k != 0:
        continue

    count = (n-b)//k
    if b != 0:
        count += 1
    ans += count**2

print(ans)

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

int x,y,z;
int ar[100];

int main() {
	scanf("%d%d",&x,&y);
	for (int a = 0; a < x; a++) {
		scanf("%d",&ar[a]);
		z+=ar[a];
	}
	sort(ar,ar+x);
	float minreq = z*(1.0/(4.0*y));
	if (ar[x-y] < minreq) printf("No\n"); else printf("Yes\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];
    ll ans=0;
    for(int i=n-1;i>=0;i--){
        if((a[i]+ans)%b[i]!=0) ans+=b[i]-(a[i]+ans)%b[i];
    }
    cout<<ans;
}

Measured memory_bytes: 4828