akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <numeric>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

struct Matrix
{
    vvi A;
    Matrix() {}
    Matrix(int n) { A.assign(n, vi(n));}
    vi &operator [](int n){ return A[n];}
};

int operator *(vi& a, vi& b)
{
    return inner_product(a.begin(), a.end(), b.begin(), 0, add, mul);
}

Matrix operator *(Matrix A, Matrix B)
{
    int n = A.A.size();
    Matrix C(n);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            for (int k = 0; k < n; ++k)
                adds(C[i][j], mul(A[i][k], B[k][j]));

    return C;
}

Matrix operator ^(Matrix A, ll k)
{
    int n = A.A.size();
    Matrix R(n);
    for (int i = 0; i < n; ++i)
        R[i][i] = 1;

    while (k > 0)
    {
        if (k % 2)
            R = R * A;

        A = A * A;
        k /= 2;
    }
    return R;
}

int main() {
    int n;
    ll k;
    cin >> n >> k;
    
    Matrix Mat(n);
    
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            cin >> Mat[i][j];
    
    Mat = Mat ^ k;
    
    int mx = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            mx = add(mx, Mat[i][j]);
    
    cout << mx;
    return 0;
}

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

int main() {
  string a;
  cin >> a;
  if (a[0] == a[1] && a[2] == a[3] && a[0] != a[2]){
    cout << "Yes" << endl;
  }
  else if (a[0] == a[2] && a[1] == a[3] && a[0] != a[1]){
    cout << "Yes" << endl;
  }
  else if (a[0] == a[3] && a[1] == a[2] && a[0] != a[1]){
    cout << "Yes" << endl;
  }
  else {cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

struct UnionFind {
  vector<ll> data;

  UnionFind(ll sz) { data.assign(sz, -1); }

  bool unite(ll x, ll y) {
    x = find(x), y = find(y);
    if (x == y) return (false);
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  ll find(ll k) {
    if (data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  ll size(ll k) { return (-data[find(k)]); }

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

int main() {
  ll n, m, k;
  scanf("%lld %lld %lld", &n, &m, &k);

  map<ll, ll> direct_friends;
  map<ll, ll> fucks;

  UnionFind uf = UnionFind(n + 1);

  for (ll i = 0; i < m; i++) {
    ll a, b;
    scanf("%lld %lld", &a, &b);

    uf.unite(a, b);

    direct_friends[a] += 1;
    direct_friends[b] += 1;
  }

  for (ll i = 0; i < k; i++) {
    ll c, d;
    scanf("%lld %lld", &c, &d);

    if (uf.same(c, d)) {
      fucks[c] += 1;
      fucks[d] += 1;
    }
  }

  for (ll i = 1; i <= n; i++) {
    // cout << i << endl;

    ll group_num = uf.size(i);
    ll dfirends = direct_friends[i];
    ll fuck = fucks[i];

    // cout << "fuck:" << fuck << endl;

    ll ans = group_num - dfirends - fuck - 1;
    if (i < n) {
      cout << ans << " ";
    } else {
      cout << ans;
    }
  }
  cout << endl;
}


Measured memory_bytes: 9892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    int n,k;
    cin>>n>>k;
    int S=1;
    for(int i=0;i<n-1;i++) S*=k-1;
    cout<<k*S<<endl;;
    return 0;
}

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

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int l=sc.nextInt();
    long A[][];
    long B[][];
    long C[][];
    A=new long [n][m];
    B=new long [m][l];
    C=new long [n][l];
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        A[i][j]=(long)sc.nextInt();
      }
    }
    for(int i=0;i<m;i++){
      for(int j=0;j<l;j++){
        B[i][j]=(long)sc.nextInt();
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<l;j++){
        for(int k=0;k<m;k++){
          C[i][j]+=A[i][k]*B[k][j];
        }
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<l;j++){
        System.out.print(C[i][j]);
        if(j!=l-1) System.out.print(" ");
        else System.out.println();
      }
    }
  }
}



Measured memory_bytes: 54224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the multiset
//order_of_key(k) - Number of elements striclty samller than k
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,d;
    cin>>n>>d;
    vector<ll> v[n];
    set<ll> st;
    for(int i=0;i<10000;i++)
    {
        st.insert(i*i);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<d;j++)
        {
            ll a;
            cin>>a;
            v[i].pb(a);
        }
    }
    ll ans=0;
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            ll temp=0;
            for(int k=0;k<v[i].size();k++)
            {
                temp+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
            }
            if(st.count(temp)>0)
                ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 768
import sys
input=sys.stdin.buffer.readline
n,a,b=map(int,input().split())
S=input()[:-1]
total=0
b_lim=0
for i in range(n):
    if S[i]==97 and total<a+b:
        print("Yes")
        total+=1
        continue
    if S[i]==98 and total<a+b and b_lim<b:
        print("Yes")
        total+=1
        b_lim+=1
        continue
    else:print("No")

Measured memory_bytes: 4144
#include <iostream>
#include <vector>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;

lli dp[105][100005] = {};
int main() {
  lli n, W;
  cin >> n;
  cin >> W;

  vector<lli> w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  rep(i, n) rep(j, W + 1) {
    if (j + w[i] <= W) {
      dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
    }
    dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
  }
  lli ans = 0;
  rep(i, W + 1) { ans = max(dp[n][i], ans); }
  cout << ans << endl;
}


Measured memory_bytes: 79360
let () =
  let rec read () =
    let line = read_line () |> String.trim in
    if line = "END OF INPUT" then
      ()
    else
      let n = (Str.split (Str.regexp " ") line
               |> List.fold_left (fun x y -> x^(String.length y |> string_of_int)) "") in
      Printf.printf "%s\n" n;
      read ()
  in read ();;

Measured memory_bytes: 2288
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
int main(){
  	string s, xs;
  cin >> s;
 	vector<int> xc(1);
  
  for(int i = 0; s.length()> i; i ++){
  	if(s[i] != 'x'){
      xs += s[i];
  		xc.push_back(0);
    }
    else xc[xc.size() - 1]++;
  }
  
  for(int i = 0; xs.length() > i; i++){
	if(xs[i] != xs[xs.length() - 1 - i]) {
	cout << -1 << endl;
      return 0;
    }
  }
	int ans = 0;
  for(int i = 0; xc.size() / 2 > i; i++){
  	ans += max(xc[i], xc[xc.size() - 1 - i]) - min(xc[i], xc[xc.size() - 1 - i]);
  }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1148
'use strict'
function Main(input) {

  let tmp = input.split('\n');
  let Num = parseInt(tmp[0]);
  let Mtn = tmp[1].split(' ').map(Number);

  let Count = 1;
  let Higher = Mtn[0];

  for (let i = 1; i <= Num - 1; i++) {
    if (Higher <= Mtn[i]) {
      Count += 1;
      Higher = Mtn[i];
    }
  }

  console.log(Count);


}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <string>
using namespace std;

int main(){
  int N, M;
  int C;
  cin >> N >> M >> C;

  int B[M] = {};
  for(int j=0;j<M;j++){
    cin >> B[j];
  }

  int result = 0;
  int A[M] = {};
  for(int i=0;i<N;i++){
    int tmp_result = 0;
    for(int j=0;j<M;j++){
      cin >> A[j];
      tmp_result += A[j] * B[j];
    }

    if(tmp_result + C > 0){
      result++;
    }
  }

  cout << result << "\n";
  return 0;
}


Measured memory_bytes: 256
use std::collections::VecDeque;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn dfs(color: &mut Vec<Option<usize>>, target: usize, id: usize, g: &mut Vec<Vec<usize>>) {
    let mut s: VecDeque<usize> = VecDeque::new();
    s.push_back(target);
    color[target] = Some(id);

    while s.len() > 0 {
        let u: usize = s.pop_front().unwrap() as usize;
        for i in 0..g[u].len() {
            let v: usize = g[u][i];
            if color[v] == None {
                dfs(color, v, id, g);
            }
        }
    }
}

fn assign_color(color: &mut Vec<Option<usize>>, g: &mut Vec<Vec<usize>>, n: usize) {
    let mut id: usize = 1;
    for u in 0..n {
        if color[u] == None {
            id = id + 1;
            dfs(color, u, id, g);
        }
    }
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut g: Vec<Vec<usize>> = vec![vec![]; n];
    let mut color: Vec<Option<usize>> = vec![None; n];
    for _ in 0..m {
        let person_index1: usize = read();
        let person_index2: usize = read();
        g[person_index1].push(person_index2);
        g[person_index2].push(person_index1);
    }
    assign_color(&mut color, &mut g, n);
    let question_count: usize = read();
    for _ in 0..question_count {
        let from: usize = read();
        let to: usize = read();
        if color[from] == color[to] {
            println!("yes");
        } else {
            println!("no");
        }
    }
}



Measured memory_bytes: 26892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    // Your code here!
    vector<string> YN{"NO","YES"};
    vector<string> yn{"No","Yes"};
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(abs(a-b)<abs(a-c)?"A":"B")<<endl;
}


Measured memory_bytes: 256
n=int(input())
keta=len(list(str(n)))

if keta%2==0:
    keta-=1
    new_n=0
    for i in range(1,keta+1):
        new_n+=9*(10**(i-1))
    n=new_n

ans=0
for i in range(1,keta+1,2):
    c=n if i==keta else 10**i-1
    cc=10**(i-1) if i!=1 else 1
    ans+=c-cc+1
print(ans)

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

char str[200001];
int length;

int main(void)
{
    int pos, ans = 0, s = 0;

    scanf("%s", str);

    length = strlen(str);

    pos = 0;
    while (pos < length) {
        if (str[pos] == 'S') {
            s++;
        } else if (s && str[pos] == 'T') {
            s--;
            ans += 2;
        }
        pos++;
    }

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



Measured memory_bytes: 384
#include <iostream>

using namespace std;

long long int N;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		if (i*i > N) {
			cout << (i - 1)*(i - 1) << endl;
			return 0;
		}
		if (i*i == N) {
			cout << i*i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

int main(void)
{
    const long double pi = 3.141592653589793;
    int A, B, Hour, Minutes;
    std::cin >> A >> B >> Hour >> Minutes;

    // get degree
    long double rad;
    rad = 2.0 * pi * (Hour / 12.0 + 
    Minutes / 60.0 / 12.0 - 
    Minutes / 60.0);

    // get distance
    std::cout << std::setprecision(10) << std::sqrt(A * A + B * B - 2.0 * A * B * std::cos(rad)) << std::endl;

    return 0;
}

Measured memory_bytes: 4132
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>


#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
const int MAX = 500050;
typedef pair<int, int>P;

signed main(){
int a,b,c,d,e,k;
cin>>a>>b>>c>>d>>e>>k;
if(e-a>k)print(":(")
else print("Yay!");
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll a, b, c;
  cin >> a >> b >> c;
  ll M = max(a,max(b,c));
  ll sum = a+b+c;
  if(sum%2==M%2) cout << (3*M-sum)/2 << newl;
  else cout << (3*(M+1)-sum)/2 << newl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
void exchange(unsigned int *a, unsigned int *b) {
  unsigned int tmp = *a;
  *a = *b;
  *b = tmp;
}
int main() {
  unsigned int a, b, c;   //3つの整数
  cin >> a >> b >> c;   //入力
  if(a > b) exchange(&a, &b);   //1と2番目が逆順であれば入れ替える。
  if(b > c) exchange(&b, &c);   //2と3番目が逆順であれば入れ替える。
  if(a > b) exchange(&a, &b);   //1と2番目が逆順であれば入れ替える。
  cout << a << ' ' << b << ' ' << c << endl;    //出力。
  return 0;
}



Measured memory_bytes: 3100
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    string s;
    ll n;
    cin>>s>>n;
    for(ll i=0;i<n;i++){
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b string
	fmt.Scan(&a, &b)

	if a == "H" && b == "H" {
		fmt.Println("H")
	} else if a == "H" && b == "D" {
		fmt.Println("D")
	} else if a == "D" && b == "H" {
		fmt.Println("D")
	} else if a == "D" && b == "D" {
		fmt.Println("H")
	}
}


Measured memory_bytes: 1832
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int X = sc.nextInt();
		int Y = sc.nextInt();
	

		if (Y % 2 == 0 && X * 2 <= Y && Y <= X * 4) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int A[N];
  
  int z=0;
  for(int i=0; i<N; i++){
    cin >> A[i];
    z+=A[i];
  }
 
  int count=0;
  double a=4*M;
  double x=z/a;
  for(int i=0; i<N; i++){
    if(A[i]>=x) count++;
  }
  
  if(count>=M) cout <<"Yes"<<endl;
  else cout << "No"<<endl;
  
}


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char> > s(H,vector<char>(W));
  set< pair<int,int> > sp;
  bool flag=true;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> s.at(i).at(j);
    }
  }
  for(int i=0;i<H;i++){
    if((s.at(i).at(0)=='#')&&(s.at(i).at(1)=='.')){
      sp.insert(make_pair(i,0));
    }
    if((s.at(i).back()=='#')&&(s.at(i).at(W-2)=='.')){
      sp.insert(make_pair(i,W-1));
    }
    for(int j=1;j<W-1;j++){
      if((s.at(i).at(j)=='#')&&(s.at(i).at(j-1)=='.')&&(s.at(i).at(j+1)=='.')){
        sp.insert(make_pair(i,j));
      }
    }
  }
  for(int i=0;i<W;i++){
    if((s.at(0).at(i)=='#')&&(s.at(1).at(i)=='.')){
      if(sp.count(make_pair(0,i))){
        flag=false;
      }
    }
    if((s.at(H-1).at(i)=='#')&&(s.at(H-2).at(i)=='.')){
      if(sp.count(make_pair(H-1,i))){
        flag=false;
      }
    }
    for(int j=1;j<H-1;j++){
      if((s.at(j).at(i)=='#')&&(s.at(j-1).at(i)=='.')&&(s.at(j+1).at(i)=='.')){
        if(sp.count(make_pair(j,i))){
          flag=false;
        }
      }
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
  int n;
  scanf("%d",&n);
  long a[100001];
  long b[100000];
  for(int i=0;i<n+1;i++){
    scanf("%ld",&a[i]);
  }
  for(int i=0;i<n;i++){
    scanf("%ld",&b[i]);
  }
  int i;
  long answer = 0;
  for(i=0;i<n;i++){
    if(a[i] >= b[i]){
      answer += b[i];
      a[i] = a[i] - b[i];
      b[i] = 0;
    }else{
      answer += a[i];
      b[i] = b[i] - a[i];
      a[i] = 0;
      if(a[i+1] >= b[i]){
        a[i+1] -= b[i];
        answer += b[i];
        b[i] = 0;
      }else{
        answer += a[i+1];
        b[i] -= a[i+1];
        a[i+1] = 0;
      }
    }
  }
  printf("%ld\n",answer);
  return 0;
}

Measured memory_bytes: 1664
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		long N = sc.nextLong();
		int d = 0;
		long temp = N;
		ArrayList<Integer> digit = new ArrayList<>();
		while(temp > 0) {
			digit.add((int)(temp % 10));
			temp /= 10;
			d++;
		}
		for(int i=0; i<digit.size()-1; i++) {
			if(digit.get(i) != 9) {
				System.out.println((d-1)*9 + digit.get(digit.size()-1)-1);
				return;
			}
		}
		System.out.println((d-1)*9 + digit.get(digit.size()-1));
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin >> n >> m;
    int wa[n+5], ac[n+5];
    memset (wa, 0, sizeof(wa));
    memset (ac, 0, sizeof(ac));
    int pen = 0;
    for (int i=1;i<=m;i++) {
        int x;
        string s;
        cin >> x >> s;
        if (s == "WA") wa[x]++;
        else {
            if (ac[x] == 0) {
                ac[x]++;
                pen += wa[x];
            }
        }
    }
    int ans = 0;
    for (int i=1;i<=n;i++) {
        if (ac[i]) ans++;
    }
    cout << ans << " " << pen << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using Lf = long double;
using plong = pair<ll,ll>;
const int mod = 1000000007;
 
 
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll flag = (c-a-b)*(c-a-b)-4*a*b;
    if(c-a-b<0)flag=-1;
    if(flag>0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
 
 
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if((x)>(y))(x)=(y)
#define chmax(x,y) if((x)<(y))(x)=(y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
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);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, nm, dp[14][1<<14], cm[14][14], res;
bool b[14];
string s[14];

signed main() {
	while (1) {
		cin >> n;
		if (n==0) break;
		rep(i,n) cin >> s[i];
		
		// 部分文字列チェック
		nm = 0;
		memset(b,0,sizeof(b));
		rep(i,n) rep(j,n) if (i!=j && s[i].find(s[j])!=string::npos) b[j] = 1;
		rep(i,n) if (b[i]) s[i] = "_", nm++;
		sort(s,s+n);
		n -= nm;
		
		// 最後につけたのがi番目、付け終わった名前の集合がj
		rep(i,n) rep(j,1<<n) dp[i][j] = inf;
		rep(i,n) dp[i][1<<i] = s[i].size();
		rep(i,n) rep(j,n) cm[i][j] = s[j].size();
		rep(i,n) rep(j,n) if (i!=j)
			repst(d,1,min(s[i].size(),s[j].size())) if (s[i].substr(s[i].size()-d,d) == s[j].substr(0,d))
				chmin(cm[i][j], s[j].size() - d);
		reps(j,1,(1<<n)-1) rep(i,n)
			rep(k,n) if (!(j>>k&1))
				chmin(dp[k][j|(1<<k)], dp[i][j] + cm[i][k]);
		
		res = inf;
		rep(i,n) chmin(res,dp[i][(1<<n)-1]);
		cout << res << ln;
	}
}


Measured memory_bytes: 4012
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);

int main(void) {
	int  R;
	float tmp;

	i_cin(R);

	f_cout((float)R * 3.14*2.0);

	return 0;
}

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

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

namespace No1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            string str = Console.ReadLine();
            string[] strs = str.Split(' ');
            a = int.Parse(strs[0]);
            b = int.Parse(strs[1]);
            c = int.Parse(strs[2]);
            if (a + b + c < 22)
                Console.WriteLine("win");
            else
                Console.WriteLine("bust");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e6;
typedef pair<ll,ll> pairs;
vector<pairs> p;


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// ------------------------------------

int main(){
    ll n, x;
    cin>>n>>x;
    vector<ll> a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a.begin(), a.end());
    ll ans=0;
    ll flag=0;
    for(ll i=0;i<n;++i){
        if(flag >= x){
            break;
        }else{
            flag += a[i];
            ans++;
        }
    }
    if(flag==x){
        ans++;
    }
    cout<<ans-1<<endl;

    return 0;
}

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

int main() {
int A,B;
string S;
cin >> A >> B >> S;
bool f=1;
for (int i = 0; i < A+B+1; i++)
{
    if(i==A)
    {
        if(S[i]!='-') f=0;
        continue;
    }
    if(isdigit(S[i]));
    else f=0;   
}

if(f) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long X = Long.parseLong(sc.next());
        int a = 0;
        int b = 0;
        if(X == 1) {
            b = -1;
        }else {
            for(int i = -(int)Math.pow(X, 1.0/5.0); i < Math.sqrt(X); i++) {
                if((float)Math.pow(X + Math.pow(i, 5), 1.0/5.0) % 1 == 0) {
                    a = (int)(Math.pow((X + Math.pow(i, 5)), 1.0/5.0));
                    b = i;
                    break;
                }
            }
        }
        
        System.out.println(a+" "+b);
    }
}

Measured memory_bytes: 38928
//

#include<iostream>
#include<algorithm>

using namespace std;

const long long MAXN=1e2+10;
const long long MAXN2=1e5+10;

long long f[MAXN][MAXN2];
long long card[MAXN];
long long n,a;
long long ans;

int main()
{
	ios_base::sync_with_stdio(false);
	
	cin>>n>>a;
	
	for(long long i=1;i<=n;++i)
		cin>>card[i];
		
	f[0][0]=1;
	long long temp=0;
	for(long long i=1;i<=n;++i)
	{
		temp+=card[i];
		
		for(long long j=i;j>=1;--j)
			for(long long k=temp;k>=card[i];--k)
				f[j][k]+=f[j-1][k-card[i]];				
	}
	
	for(long long i=1;i<=n;++i)
		ans+=f[i][i*a];
		
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 39168
answer = []
3.times do
  time = gets.split.map(&:to_i)
  t1 = Time.new(2015, 9, 16, time[0], time[1], time[2])
  t2 = Time.new(2015, 9, 16, time[3], time[4], time[5])
  hours = (t2 - t1).divmod(3600)
  minutes = hours[1].divmod(60)
  seconds = minutes[1]
  answer << [hours[0], minutes[0], seconds.to_i].join(" ")
end
puts answer

Measured memory_bytes: 8604
#include <iostream>
using namespace std;
#define NIL -1
#define MAX 100001
struct Node
{
	int nParent;
	int nLeft, nRight;
};
Node nN[MAX];
int nD[MAX], nH[MAX];


void Depth(int nRoot, int nDepth)
{
	if (nRoot == NIL)
	{
		return;
	}
	nD[nRoot] = nDepth;
	if (nN[nRoot].nRight != NIL)
	{
		Depth(nN[nRoot].nRight, nDepth + 1);
	}
	if (nN[nRoot].nLeft != NIL)
	{
		Depth(nN[nRoot].nLeft, nDepth + 1);
	}
}

int Height(int nRoot)
{
	int h1 = 0, h2 = 0;
	if (nN[nRoot].nLeft != NIL)
	{
		h1 = Height(nN[nRoot].nLeft) + 1;
	}
	if (nN[nRoot].nRight != NIL)
	{
		h2 = Height(nN[nRoot].nRight) + 1;
	}
	return nH[nRoot] = (h1 > h2) ? h1 : h2;
}

int getsibling(int u)
{
	if (nN[u].nParent == NIL)
	{
		return NIL;
	}
	if (nN[nN[u].nParent].nLeft != u && nN[nN[u].nParent].nLeft != NIL)
	{
		return nN[nN[u].nParent].nLeft;
	}
	if (nN[nN[u].nParent].nRight != u && nN[nN[u].nParent].nRight != NIL)
	{
		return nN[nN[u].nParent].nRight;
	}
	return NIL;
}

void print(int u)
{
	int i, c;
	cout << "node " << u << ": parent = " << nN[u].nParent << ", sibling = " << getsibling(u) << ", ";
	int deg = 0;
	if (nN[u].nLeft != NIL)
	{
		deg++;
	}
	if (nN[u].nRight != NIL)
	{
		deg++;
	}
	cout << "degree = " << deg << ", depth = " << nD[u] << ", height = " << nH[u] << ", ";
	if (nN[u].nParent == NIL)
	{
		cout << "root" << endl;
	}
	else if (nN[u].nLeft == NIL && nN[u].nRight == NIL)
	{
		cout << "leaf" << endl;
	}
	else
	{
		cout << "internal node" << endl;
	}
}


int main()
{
	int nIn;
	cin >> nIn;
	int id, left, right;
	int r;
	for (int i = 0; i < nIn; i++)
	{
		nN[i].nLeft = NIL;
		nN[i].nRight = NIL;
		nN[i].nParent = NIL;
	}
	for (int i = 0; i < nIn; ++i)
	{
		cin >> id >> left >> right;
		nN[id].nLeft = left;
		nN[id].nRight = right;
		nN[left].nParent = id;
		nN[right].nParent = id;
	}
	for (int i = 0; i < nIn; ++i)
	{
		if (nN[i].nParent == NIL)
		{
			r = i;
		}
	}
	Depth(r, 0);
	Height(r);

	for (int i = 0; i < nIn; ++i)
	{
		print(i);
	}
	return 0;
}


Measured memory_bytes: 3108
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# from atcoder.fenwicktree import FenwickTree

# available on Google, not available on Codeforces
# import numpy as np
# import scipy


def solve(grid, n):  # fix inputs here
    console("----- solving ------")
    grid = [(x-1, y-1) for x,y in grid]

    m = {}
    for i,(x,y) in enumerate(grid):
        m[x] = i
    
    grid = sorted(grid)
    console(grid)

    g = defaultdict(list)
    y_heap = []
    heapq.heapify(y_heap)

    for x,y in grid:
        if y_heap:
            ymin,xmin = y_heap[0]
            if ymin < y:
                while y_heap and y_heap[0] < (y,x):
                    ycur,xcur = heapq.heappop(y_heap)
                    g[x].append(xcur)
                    g[xcur].append(x)
                heapq.heappush(y_heap, (ymin,xmin))
        heapq.heappush(y_heap, (y,x))
        
    console(g)

    res = [0 for _ in grid]
    visited_1 = [0 for _ in grid]
    visited_2 = [0 for _ in grid]

    for i in range(n):
        if res[i]:  # if visited
            continue
        visited_1[i] = 1
        stack = [i]
        cnt = 1
        while stack:
            cur = stack.pop()
            for nex in g[cur]:
                if not visited_1[nex]:
                    cnt += 1
                    visited_1[nex] = 1
                    stack.append(nex)
                
        # print(i,cnt)
        visited_2[i] = 1
        stack = [i]
        while stack:
            cur = stack.pop()
            res[cur] = cnt
            for nex in g[cur]:
                if not visited_2[nex]:
                    visited_2[nex] = 1
                    stack.append(nex)

    console(res)
    console(visited_1)
    console(visited_2)
    res2 = [0 for _ in grid]
    for i,x in m.items():
        res2[x] = res[i]

    return res2




def console(*args):  # the judge will not read these print statement
    # print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
inp = sys.stdin.readlines()

for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
    nrows = int(inp[0])
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    # lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    grid = []
    for n in range(nrows):
        grid.append(list(map(int,inp[n+1].split())))

    res = solve(grid, nrows)  # please change
    
    res = "\n".join(str(x) for x in res)
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)


Measured memory_bytes: 146392
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	int n=Integer.parseInt(input.readLine());
	for(int i=0;i<n;i++)
	    {
		int s=Integer.parseInt(input.readLine());
		System.out.println("Case "+(i+1)+":");
		for(int j=0;j<10;j++)
		    {
			s*=s;
			String str=Integer.toString(s);
			String zero="";
			for(int k=0;k<8-str.length();k++)
			    {
				zero+="0";
			    }
			str=zero+str;
			
			String str_ans="";
			for(int k=2;k<=5;k++)
			    {
				str_ans+=str.charAt(k);
			    }
			String str_s="";
			int count=0;
			for(int k=0;k<4;k++)
			    {
				if(str_ans.charAt(k)!='0')
				    {
					str_s+=str_ans.charAt(k);
					count++;
				    }
				else if(str_ans.charAt(k)=='0' && count!=0)
				    {
					str_s+=str_ans.charAt(k);
				    }
			    }
			if(str_s.length()==0)str_s="0";
			System.out.println(Integer.parseInt(str_s));
			s=Integer.parseInt(str_s);
		    }
	    }
    }
}

Measured memory_bytes: 17020
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())

    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        G[u].append(v)
        G[v].append(u)

    connect = [len(g) for g in G]

    #根を0として木を構築
    root = 0
    stack = [root]
    order = []
    lst = [0] * N
    while len(stack) != 0:
        tmp = stack.pop()
        order.append(tmp)
        for to in G[tmp]:
            if to == lst[tmp]:
                continue
            lst[to] = tmp
            stack.append(to)
        
    dp1 = [0] * N
    for v in order[::-1]:
        d = connect[v]
        if v != root and d == 1:
            continue
        x = sum(dp1[c] for c in G[v])
        if v == root:
            dp1[v] = x/connect[v] + 1
        else:
            dp1[v] = x/(connect[v] - 1) + 1

    dp2 = [0] * N
    for v in order:
        d = connect[v]
        n_child = d if v == root else d - 1
        S = dp1[v] * n_child
        if v != root:
            S += dp2[v] + 1
        for c in G[v]:
            if c == lst[v]:
                continue
            if d == 1:
                dp2[c] = 0
            else:
                dp2[c] = (S - dp1[c] - 1)/(d - 1)

    ans = []
    for v in range(N):
        d = connect[v]
        n_child = d if v == root else d - 1
        S = dp1[v] * n_child
        if v != root:
            S += dp2[v] + 1
        ans.append(S/d)

    print (*ans, sep = '\n')

    # print (dp1)
    # print (dp2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 51740
use proconio::marker::Usize1;
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        d: usize,
        a: [[Usize1;w];h],
        q: usize,
        lr: [(Usize1,Usize1);q],
    }
    let n=h*w;
    let mut p=vec![(0,0);n];
    for i in 0..h {
        for j in 0..w {
            p[a[i][j]]=(i,j);
        }
    }
    let m=n.next_power_of_two().trailing_zeros()as usize+1;
    let mut s=vec![0;n];
    for i in d..n {
        let (x1,y1)=p[i];
        let (x2,y2)=p[i-d];
        s[i]=s[i-d]+x1.max(x2)-x1.min(x2)+y1.max(y2)-y1.min(y2);
    }
    for (l,r) in lr {
        println!("{}",s[r]-s[l]);
    }
}

Measured memory_bytes: 7956
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    string s[n];
    for(int i=0;i<n;i++)
        cin>>s[i];
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
        dp[i][0]=0;
    for(int j=0;j<=m;j++)
        dp[0][j]=0;
    int val;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            val=dp[i-1][j]+dp[i][j-1];
            if(s[i-1][j-1]=='#')
                dp[i][j]=0;
            else if(i==1 && j==1)
                dp[i][j]=1;
            else
                dp[i][j]=val%mod;
        }
    }
    cout<<dp[n][m];
    return 0;
}

/*
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
*/


Measured memory_bytes: 5248
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int b[] = new int[m];
        int suc = 0;
        int anm = 0;
        int ab = 0;
        int sum = 0;

        for (int i = 0; i < m; i++) {
            b[i] = sc.nextInt();
        }

        for (int i = 0; i < n; i++) {
            sum = 0;
            anm = 0;
            ab = 0;
            for (int j = 0; j < m; j++) {
                anm = sc.nextInt();
                ab = anm * b[j];
                sum = sum + ab;
            }

            if (sum + c > 0) {
                suc++;
            }

        }

        System.out.println(suc);

        sc.close();
    }
}


Measured memory_bytes: 37248
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int i, I;
	for(i = 1; i < 10 ;i++)
	{
		for(I = 1 ; I < 10 ; I++)
		{
			printf("%dx%d=%d\n", i, I, i*I);
		}
	}
	return 0;
}


Measured memory_bytes: 2008
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

ll modpow(ll a,ll n,ll m){
    ll res=1;
    while(n){
        if(n&1)res=res*a%m;
        a=a*a%m;
        n>>=1;
    }
    return res;
}

int main(){
    ll h;cin>>h;
    ll res=0;
    while(h>0){
        h/=2;
        res++;
    }
    cout<<modpow(2,res,INF)-(ll)1<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int i;
    char in;
    int alph_in_sma;
    int alph_in_cap;    /*small and capital*/
    int cnt[26];
    char alph_ord[26];    /*alphabet in order; for output*/

    /*alph_ord[26] = {a, b, c, ... , z}*/
    alph_ord[0] = 'a';
    for (i = 1; i < 26; i++){
        alph_ord[i] = alph_ord[i - 1] + 1;
    }
    
    /*initialize*/
    for (i = 0; i < 26; i++){
        cnt[i] = 0;
    }
    
    /*input*/
    while ((scanf("%c", &in)) != EOF){
        /*alph_in_sma = 0, 1, 2, ... , 25; a = 0, z = 25*/
        alph_in_sma = in - 'a';
        /*alph_in_cap = 0, 1, 2, ... , 25; A = 0, Z = 25*/
        alph_in_cap = in - 'A';
        /*if alphabet*/
        if (alph_in_sma >= 0 && alph_in_sma <= 25){
            cnt[alph_in_sma]++;
        }
        if (alph_in_cap >= 0 && alph_in_cap <= 25){
            cnt[alph_in_cap]++;
        }
    }

    /*output*/
    for (i = 0; i < 26; i++){
        printf("%c : %d\n", alph_ord[i], cnt[i]);
    }

    return 0;
}

Measured memory_bytes: 540
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		scan.close();

		System.out.println(func(h));
	}

	static long func(long h) {
		if(h==1)return 1;
		else return 2*func(h/2)+1;
	}
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int i;
	cin>>a;
	for(i=0;i<a.size();i++)
	{
		if(a[i]=='C')
		{
			for(i=i+1;i<a.size();i++)
				if(a[i]=='F') 
				{
					cout<<"Yes"<<endl;
					return 0;
				}
		}
	}
	cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define N 100
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.141592653
#define cot cout.tie(0)
#define endl "\n"
using namespace std;
/**
  * @author :: Sawlani
  *
  */

int main()
{
 
    ll x;
    cin >> x;

    if(x==0)
    cout << 1;
    else
    {
        cout << 0;
    }
    }

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    ll a;
    cin >> a;
    ll b;
    cin >> b;
    ll c;
    cin >> c;
    ll k;
    cin >> k;
    ll count=0;
    if(a>=k)cout << k << endl;
    else if(a<k&&k<=a+b) cout << a << endl;
    else cout << a-(k-a-b) << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

vector<int> to[2505];
vector<int> rto[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];

struct edge {
    int from, to, cost;
};
 
void dfs(int v) {
    if (reachableFrom1[v]) return;
    reachableFrom1[v] = true;
    for (int u : to[v]) {
        dfs(u);
    }
}
 
void rdfs(int v) {
    if (reachableToN[v]) return;
    reachableToN[v] = true;
    for (int u : rto[v]) {
        rdfs(u);
    }
}
 
int main() {
    int n, m, p; cin >> n >> m >> p;
    vector<edge> edges;
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        c -= p;
        c = -c;
        edge e = {a,b,c};
        edges.push_back(e);
        to[a].push_back(b);
        rto[b].push_back(a);
    }
    dfs(0);
    rdfs(n-1);
    rep(i, n) ok[i] = reachableFrom1[i] & reachableToN[i];
 
    //bellman-ford
    vector<int> d(n, INF);
    d[0] = 0;
    bool upd = true;
    int step = 0;
    while (upd) {
        upd = false;
        rep(i, m) {
            edge e = edges[i];
            if (!ok[e.from]) continue;
            if (!ok[e.to]) continue;
            int newD = d[e.from]+e.cost;
            if (newD < d[e.to]) {
                upd = true;
                d[e.to] = newD;
            }
        }
        step++;
        if (step > n) {
            puts("-1");
            return 0;
        }
    }
    int ans = -d[n-1];
    chmax(ans, 0);
    cout << ans << endl;
 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.14159265

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

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};



int main() { 
	int sheeps, wolves; cin>> sheeps >> wolves;
	if (wolves >= sheeps)
		cout<<"unsafe";
	else
		cout<<"safe";
	return 0;
} 




Measured memory_bytes: 3620