akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int x;
  cin >> x;

  int ans = 0;
  for (int i = x;; i++) {
    int t = 0;
    for(int j = 2; j * j < i; j++) {
      if (i % j == 0) t++;
    }
    if (t) continue;
    ans = i;
    if (ans) break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

using P = pair<int, int>;

int n, m, q;
int ans = 0;
vector<pair<P, P>> dat;

void check (const vector<int> &a) {
    int ret = 0;
    for (const auto &e : dat) {
        int l, r, c, d;
        tie(l, r) = e.first;
        tie(c, d) = e.second;
        if (a[r] - a[l] == c) ret += d;
    }
    ans = max(ans, ret);
}

void dfs (vector<int> a, int val) {
    if (a.size() == n) {
        check(a);
    } else {
        for (int i = val; i <= m; i++) {
            a.push_back(i);
            dfs(a, i);
            a.pop_back();
        }
    }
}

int main() {
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        dat.emplace_back(P(a, b), P(c, d));
    }
    
    dfs(vector<int>(), 1);
    
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S; cin >> S;
	int N = S.size();
	if (S[0] != '1' || S.back() != '0') {
		cout << -1 << endl;
		return 0;
	}
	int q = 0, w = N - 2;
	while (q < w) {
		if (S[q] != S[w]) {
			cout << -1 << endl;
			return 0;
		}
		q++;
		w--;
	}
	VP ans;
	int k = 0;
	FOR(i, 1, N) {
		ans.push_back(pii(k, i));
		if (S[i-1] == '1') k=i;
	}

	fore(i, ans) cout << i.first + 1 << " "<< i.second + 1 << endl;


	return 0;
}



Measured memory_bytes: 3264
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class APayment {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int n = s.nextInt();
            if (n % 1000 == 0)
                w.println(0);
            else
                w.println(1000 - (n % 1000));
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

using namespace std;
using ll = long long;

int main() {
  int h, n;
  cin >> h >> n;
  ll sum = 0;
  rep(i, n) {
    int a;
    cin >> a;
    sum += a;
  }
  if (h <= sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

neg = 0
for i in range(N):
  if A[i]<0:
    A[i]=-A[i]
    neg+=1
    
if (neg % 2) == 0:
  print(sum(A))
else:
  print(sum(A)-2*min(A))


Measured memory_bytes: 14332
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

// ei1333's BIT
struct BIT {
  VI data;
  BIT(){}
  BIT(ll sz) {
    resize(sz);
  }
  void resize(ll sz){
    data.assign(++sz, 0);
  }
  ll sum(ll k) {
    ll ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }
  void add(ll k, ll x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

// 区間更新・区間和
struct Range{
  BIT P, Q;
  Range(ll sz){
    P.resize(sz+1);
    Q.resize(sz+1);
  }
  // [a, b)
  void update(ll a, ll b, ll w){
    P.add(a, -w*a);
    P.add(b,  w*b);
    Q.add(a,  w);
    Q.add(b, -w);
  }
  // [0, c)
  ll simple_sum(ll c){
    return P.sum(c) + Q.sum(c) * c;
  }
  // [a, b)
  ll sum(ll a, ll b){
    return simple_sum(b) - simple_sum(a);
  }
};

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

    // input
    ll N, K, Q;
    cin >> N >> K >> Q;

    VI A(Q);
    rep(i, Q){
        cin >> A.at(i);
        A[i]--;
    }

    Range r(N);
    r.update(0, N, K);

    rep(i, Q){
      ll a = A[i];
      r.update(0, N, -1);
      r.update(a, a+1, +1);
    }

    FOR(i, 0, N){
      if(r.sum(i, i+1)>0){
        p_yes();
      }else{
        p_no();
      }
    }
    
    return 0;
}


Measured memory_bytes: 2944
#include <cstdio>

using namespace std;

int n, cnt = 0;
bool f[1000010] = { false };

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		int temp;
		scanf("%d", &temp);
		if (f[temp]) cnt++;
		else f[temp] = true;
	}
	if (cnt & 1) cnt++;
	printf("%d\n", n - cnt);
	return 0;
}

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

using namespace std;
char str[10000];
int n,pi[10000];

int main()
{
    scanf("%d\n%s",&n,str);
    int ans = 0;
    for(int i=0;i<n;++i)
    {
        memset(pi,0,sizeof(pi));
        for(int j=i+1;j<n;++j){
            int k = pi[j-1];
            while(k>0&&str[i+k]!=str[j]) k = pi[i+k-1];
            if(str[i+k]==str[j]) ++k;
            pi[j] = k;
            //cout << k << " " << j<< " " <<str[i] << endl;
            ans = max(ans,min(k,(j-i+1)/2));
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    long n, k;

    cin >> n >> k;
    vector<long> vec(n);
    long a;
    long b;
    for (int i = 0; i < k; i++)
    {
        cin >> a;
        for (int j = 0; j < a; j++)
        {
            cin >> b;
            vec.at(b - 1) = 1;
        }
    }
    long c = 0;
    for (int i = 0; i < n; i++)
    {
        if (vec.at(i) == 0)
        {
            c++;
        }
    }

    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3632
{-# OPTIONS_GHC -O2 #-}

import qualified Data.List             as L
import qualified Data.Maybe            as Maybe
import qualified Data.ByteString.Char8 as BSC8

readIntegers :: IO [Integer]
readIntegers = map ( fst . Maybe.fromJust . BSC8.readInteger ) . BSC8.words <$> BSC8.getLine

main :: IO ()
main = do
  BSC8.getLine
  xs <- readIntegers
  if elem 0 xs
    then print 0
    else print $ (\x -> if x > 10^18 then -1 else x)
                $ L.foldr1 (\x acc -> if acc == -1 || acc > 10 ^ 18 then -1 else x * acc) xs


Measured memory_bytes: 13952
#include <algorithm>
#include <bitset>
#include <iostream>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;

int main() {
    // input
    int m; cin >> m;
    vector<string> name(m);
    vector<int> l(m), r(m); // [l, r]
    repeat (i, m) {
        cin >> name[i] >> l[i] >> r[i];
    }
    int n; cin >> n;
    vector<string> es(n);
    repeat (i, n) {
        cin >> es[i];
    }
    // solve
    bool result = true;
    stack<bitset<256> > stk;
    for (string e : es) {
        if (isdigit(e[0])) {
            bitset<256> num = {};
            num[stoi(e)] = true;
            stk.push(num);
        } else if (isalpha(e[0])) {
            int i = whole(find, name, e) - name.begin();
            bitset<256> var = {};
            repeat_from (j, l[i], r[i] + 1) {
                var[j] = true;
            }
            stk.push(var);
        } else {
            bitset<256> b = stk.top(); stk.pop();
            bitset<256> a = stk.top(); stk.pop();
            if (e == "/" and b[0]) {
                result = false;
                break;
            }
            bitset<256> c = {};
            repeat (i, 256) if (a[i]) {
                repeat (j, 256) if (b[j]) {
                    if (e == "+") {
                        c[(i + j) % 256] = true;
                    } else if (e == "-") {
                        c[(i - j + 256) % 256] = true;
                    } else if (e == "*") {
                        c[i * j % 256] = true;
                    } else if (e == "/") {
                        c[i / j] = true;
                    }
                }
            }
            stk.push(c);
        }
    }
    // output
    cout << (result ? "correct" : "error") << endl;
    return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n, d; cin >> n >> d;
    d = d * 2 + 1;
    cout << (n+d-1)/d << endl;
}

Measured memory_bytes: 256
program main;
type
    arraytype = array[1..200000] of string[10];
var
    i, n, count : longint;
    A : arraytype;

procedure Quicksort(var A : arraytype; left, right : integer);
var
   i, j : integer;
   pivot, temp : string;
begin
    i := left; 
    j := right;
    pivot := A[(left + right) div 2];
    while i <= j do begin
        while A[i] < pivot do 
            i := i + 1;
        while A[j] > pivot do 
            j := j - 1;
        if i <= j then begin 
            temp := A[i];
            A[i] := A[j];
            A[j] := temp;
            i := i + 1;
            j := j - 1;
        end;
    end;
    if left < j
        then Quicksort(A, left, j);
    if i < right 
        then Quicksort(A, i, right);
end;

begin
    //read
    readln(n);
    for i := 1 to n do 
        readln(A[i]);
    
    //sort
    Quicksort(A, 1, n);

    //count
    count := 1;
    for i := 2 to n do
       if A[i] <> A[i-1]
           then count := count + 1;
    writeln(count);
end.

Measured memory_bytes: 2404
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    static int[] getHammingArray( final int lim ) {
	final ArrayList<Integer> ham = new ArrayList<Integer>();
	ham.add( 1 );
	
	int index2 = 0;
	int index3 = 0;
	int index5 = 0;
	int next = 1;

	while ( next <= lim ) {
	    next = min( ham.get( index2 ) * 2, min( ham.get( index3 ) * 3, ham.get( index5 ) * 5 ) );
	    if ( next <= lim ) {
		if ( next == ham.get( index2 ) * 2 ) {
		    if ( ham.get( ham.size() - 1 ) < next ) {
			ham.add( ham.get( index2 ) * 2 );
		    }
		    index2++;
		} else if ( next == ham.get( index3 ) * 3 ) {
		    if ( ham.get( ham.size() - 1 ) < next ) {
			ham.add( ham.get( index3 ) * 3 );
		    }
		    index3++;
		} else { // if next == num5 * 5
		    if ( ham.get( ham.size() - 1 ) < next ) {
			ham.add( ham.get( index5 ) * 5 );
		    }
		    index5++;
		}
	    }
	}

	int[] array = new int[ ham.size() ];
	for ( int i = 0; i < ham.size(); i++ ) {
	    array[ i ] = ham.get( i );
	}
	return array;
    }
        
    public static void main(String[] args) {

	final Scanner stdin = new Scanner( System.in );
	final int[] array = getHammingArray( 1000000 );
	//System.err.println( Arrays.toString( array ) );

	while ( true ) {
	    final int m = stdin.nextInt();
	    if ( m == 0 ) {
		break;
	    }
	    final int n = stdin.nextInt();
	    final int lower = Arrays.binarySearch( array, m );
	    final int indexLower = lower >= 0 ? lower : -lower - 1;
	    final int upper = Arrays.binarySearch( array, n );
	    final int indexUpper = upper >= 0 ? upper : -upper - 2;
	    System.out.println( indexUpper - indexLower + 1 );
	}	
    }    
}

Measured memory_bytes: 17264
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"

string s;

bool read() {
	if  (!getline(cin, s)) {
		return 0;
	}
	return 1;
}

const string PREF = "YAKI";

bool solve() {
	return sz(s) >= sz(PREF) && s.substr(0, sz(PREF)) == PREF;
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		puts(solve() ? "Yes" : "No");
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


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

// nの約数を全列挙。但し 1 は除外。n 自身は含む。
// ※結果はソートされていない
template <typename T> vector<T> ListDivisors(T n)
{
	vector<T> res;
	for (T i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;

		// 1は除外
		if (1 < i) res.push_back(i);

		if (i * i != n) res.push_back(n / i);
	}
	return res;
}

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

	set<ll> set;

	auto ds = ListDivisors(N - 1);
	for (auto &&d : ds) {
		if (N % d != 0) {
			set.insert(d);
			cerr << " 1: " << d << endl;
		}
	}

	ds = ListDivisors(N);
	for (auto &&d : ds) {
		auto n = N;
		while (n % d == 0)
			n /= d;

		if (n % d == 1) {
			set.insert(d);
			cerr << " 2: " << d << endl;
		}
	}

	cout << set.size() << endl;
}

Measured memory_bytes: 384
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        h: usize,
        w: usize,
        ss: [Chars; h]
    };
    let mut vv = vec![vec![0; w]; h];
    for (y, s) in ss.iter().enumerate() {
        for (x, &c) in s.iter().enumerate() {
            if c == '#' {
                use std::cmp::min;
                for xx in x.checked_sub(1).unwrap_or(0)..=min(x + 1, w - 1) {
                    for yy in y.checked_sub(1).unwrap_or(0)..=min(y + 1, h - 1) {
                        vv[yy][xx] += 1;
                    }
                }
            }
        }
    }
    let mut s = String::new();
    for y in 0..h {
        for x in 0..w {
            let c = if ss[y][x] == '#' {
                '#'
            } else {
                std::char::from_digit(vv[y][x], 10).unwrap()
            };
            s.push(c);
        }
        s.push('\n');
    }
    print!("{}", s);
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
#define se second
#define fi first
#define pb push_back
#define cn cout<<"\n"
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repr(i,a,b) for(int i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

#define _ ios::sync_with_stdio(0); cin.tie(0);

#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>
#define flush fflush(stdout)

const int INF = 1e8;
const ll MOD = 1e9 + 7;

using namespace std;

int main(){
	_

	int t = 1;

	vi v;
	int aux, k;
	bool y = 1;

	rep(i, 0, 5){
		cin>>aux;
		v.pb(aux);
	}

	cin>>k;

	rep(i, 0, v.size()){
		rep(j, i + 1, v.size()){
			if(abs(v[j] - v[i]) > k)
				y = 0;
		}
	}

	if(y) cout<<"Yay!";
	else cout<<":(";
	cn;
	return 0;
}

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

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

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

#define INF 5e18
#define mod 1000000007

struct edge{
  ll v,a,b;
};
struct state{
  ll v,d;
};
bool operator<(const state& a,const state& b){
  return a.d > b.d;
}

ll N,M,S,G;
vector<edge> g[200010];
ll dist[200010];

int main(){
  cin>>N>>M>>S>>G;
  S--;G--;

  rep(i,M){
    ll u,v,a,b;
    cin>>u>>v>>a>>b;
    u--;v--;
    g[u].push_back((edge){v,a,b});
    g[v].push_back((edge){u,a,b});
  }

  priority_queue<state> que;
  que.push((state){S,0});
  rep(i,N)dist[i]=INF;
  while(que.size()){
    state crt=que.top(); que.pop();
    if(dist[crt.v]!=INF)continue;
    dist[crt.v]=crt.d;
    ll v=crt.v; ll t=crt.d;
    for(edge e : g[v]){
      ll k=max(0LL,(ll)floor(sqrt((double)e.b))-e.a-t);
      rep(add,3){
        ll nk=k+add;
        que.push((state){e.v,t+nk+((e.b+t+nk+e.a-1)/(t+nk+e.a))});
      }
    }
  }

  if(dist[G]==INF)cout<<-1<<endl;
  else cout<<dist[G]<<endl;

  return 0;
}



Measured memory_bytes: 54160
#include<stdio.h>

int main(){
	int n,m,c,i,j,cnt=0;


	scanf("%d", &n);
	scanf("%d", &m);
	scanf("%d", &c);
  int b[m],a[n][m];
  for(i=0;i<m;i++){

    scanf("%d", &b[i]);
  }
  for(i=0;i<n;i++){
    int sum=c;
    for(j=0;j<m;j++){
    	scanf("%d", &a[i][j]);
      sum += (a[i][j])*(b[j]);
    }
    if( sum>0 ) cnt++;
  }
	printf("%d",cnt++ );
	return 0;
}

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

int main(){
	string str;
  cin >> str;
  str[5]=' ';
  str[13]=' ';
  
  cout << str << endl;

  return 0;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  
  if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9)
    cout << "hon" << endl;
  else if(n%10==0 || n%10==1 || n%10==6 || n%10==8)
    cout << "pon" << endl;
  else
    cout << "bon" << endl;
  
  return 0;
}


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

int query[50][4];

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> a(n);
  rep(i, q) rep(j, 4) {int k; cin >> k; query[i][j] = k;}
  rep(i, n) a[i] = 1;
  int ans = 0;
  while (a[0] < m) {
    int sum = 0;
    rep(j, q) {
      if (a[query[j][1]-1] - a[query[j][0]-1] == query[j][2]) sum += query[j][3];
    }
    ans = max(sum, ans);
    int i = n-1;
    while (m == a[i]) {a[i] = 0; i--;}
    a[i]++;
    i++;
    while (i < n) {a[i] = a[i-1]; i++;}
  }
  a[0] = m;
  int sum = 0;
  rep(j, q) {
    if (a[query[j][1]-1] - a[query[j][0]-1] == query[j][2]) sum += query[j][3];
  }
  ans = max(sum, ans);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
using namespace std;

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
using namespace std;


long long gcd(long long a, long long b) {
  return (b == 0) ? a : gcd(b, a % b);
}
int main(void){
	long long A,B,C,D,CD;

	cin >> A >> B >> C >> D;
  
  CD = C * D / gcd(C, D);

  A--;
	cout << (B - (B / C) - (B / D) + (B / CD)) - 
      (A - (A / C) - (A / D) + (A / CD)) << endl;

	return 0;
}


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

using namespace std;
using ll=long long;


/*
    priority-queue
    ->要素をqueueに追加した瞬間に、中の値を自動的にsortする。
    <<宣言>>
    priority-queue<型> 変数名;(降順)
    priority-queue<型,vector<型>,greator<型>> 変数名；（昇順）

    要素の追加:変数名.push(値);
    要素の取得:変数名.top();
    要素の削除:変数名.pop();
    要素数の取得:変数名.size();
    からかどうかの判定:変数名.empty();

*/

int main()
{
    int n,m;
    cin >> n >> m;
    priority_queue<ll> s;
    for(int i=0;i<n;i++)
    {
        int a;
        cin >> a;
        s.push(a);
    }
    for(int i=0;i<m;i++)
    {
        int x;
        x=s.top();
        s.pop();
        x/=2;
        s.push(x);
    }
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        ans+=s.top();
        s.pop();
    }
    cout << ans << endl;
    return(0);
}

Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    int a[2];
    cin>>a[0]>>a[1];

    sort(a,a+2);
    if(a[1]-a[0]<=8-a[0])cout<<"Yay!";
    else cout<<":(";
 
    return 0;
}

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

int main() {
  int x; cin >> x;
  if (400 <= x && x <= 599) {
    cout << 8 << endl;
  }else if (600 <= x && x <= 799) {
    cout << 7 << endl;
  }else if (800 <= x && x <= 999) {
    cout << 6 << endl;
  }else if (1000 <= x && x <= 1199) {
    cout << 5 << endl;
  }else if (1200 <= x && x <= 1399) {
    cout << 4 << endl;
  }else if (1400 <= x && x <= 1599) {
    cout << 3 << endl;
  }else if (1600 <= x && x <= 1799) {
    cout << 2 << endl;
  }else if (1800 <= x && x <= 1999) {
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<math.h>
using namespace std;
int main() {
	double x1, y1, x2, y2, x3, y3, xp, yp, a, b, c, d, e, f, s1, s2, s3,s4, S1, S2, S3,S4;
	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
		a = pow((pow(x1 - xp, 2) + pow(y1 - yp, 2)), 1.0 / 2);
		b = pow((pow(x2 - xp, 2) + pow(y2 - yp, 2)), 1.0 / 2);
		c = pow((pow(x3 - xp, 2) + pow(y3 - yp, 2)), 1.0 / 2);
		d = pow((pow(x2 - x3, 2) + pow(y2 - y3, 2)), 1.0 / 2);
		e = pow((pow(x1 - x3, 2) + pow(y1 - y3, 2)), 1.0 / 2);
		f = pow((pow(x1 - x2, 2) + pow(y1 - y2, 2)), 1.0 / 2);
		s1 = (b + c + d) / 2;
		s2 = (a + c + e) / 2;
		s3 = (a + b + f) / 2;
		s4 = (d + e + f) / 2;
		S1 = pow(s1*(s1 - b)*(s1 - c)*(s1 - d), 1.0 / 2);
		S2 = pow(s2*(s2 - a)*(s2 - c)*(s2 - e), 1.0 / 2);
		S3 = pow(s3*(s3 - a)*(s3 - b)*(s3 - f), 1.0 / 2);
		S4 = pow(s4*(s4 - d)*(s4 - e)*(s4 - f), 1.0 / 2);
		if ((S4+0.001>S1+S2+S3)&&(S1 + S2 + S3 > S4-0.001)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  if(n==m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3600
class UnionFind(object):
    def __init__(self, N):
        self.parent = [-1] * N #parent[i] は(i+1)番目の要素が含まれる要素数の(-1)倍
    #要素が負-->その数を親とするグループに属する要素の数×(-1)
    #要素が正-->親のindex

    #Aがどのグループに属しているかを調べる
    def root(self, A):
        if self.parent[A-1] < 0: #負の数-->その数は親
            return A
        self.parent[A-1] = self.root(self.parent[A-1]) #負では無い時、親の場所が入っているから、親が属しているグループを、自分自身に入れる(一度確認したところは直接親を見れるようにする)
        return self.parent[A-1] #親の位置を返す

    #Aが含まれているグループに属している数を返す
    def size(self, A):
        return -1 * self.parent[self.root(A)-1]

    #AとBをくっ付ける
    def connect(self, A, B):
        A = self.root(A) #Aを含むグループの親を返す
        B = self.root(B) #Bを含むグループの親を返す
        if A == B: #親が同じならなにもしない
            return False
        
        #大きい方(A)に小さい方(B)をつなぎたい
        if self.size(A) < self.size(B): #大小関係が逆の時は入れ替える
            A, B = B, A
        
        self.parent[A-1] += self.parent[B-1] #大きい方に小さい方を加える　（負の数＋負の数 = 新しいグループに含まれる数×(-1)）
        self.parent[B-1] = A #加えられた親の値を、加えた先の親の位置に書き変える
        return True
    
    def same(self, A, B):
        if self.root(A) == self.root(B):
            return True
        else:
            return False

N = int(input())

lst = []
l_append = lst.append
for i in range(N):
    x, y = map(int, input().split())
    l_append([x, y, i])
# print (lst)
edge = []
e_append = edge.append
lst.sort(key = lambda x: x[0])
for i in range(1, N):
    e_append([lst[i-1][2], lst[i][2], min(abs(lst[i-1][0]-lst[i][0]), abs(lst[i-1][1]-lst[i][1]))])
# print (edge)
lst.sort(key = lambda x: x[1])
for i in range(1, N):
    e_append([lst[i-1][2], lst[i][2], min(abs(lst[i-1][0]-lst[i][0]), abs(lst[i-1][1]-lst[i][1]))])
# print (edge)
edge.sort(key = lambda x: x[2])

uni = UnionFind(N)
ans = 0
for i in edge:
    if not uni.same(i[0], i[1]): #違うグループのとき
        uni.connect(i[0], i[1])
        ans += i[2]
print (ans)

Measured memory_bytes: 53416
#include <iostream>

using namespace std;
 
int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if (a > b) {
        return 0;
    }

    int count = 0;
    for (int x=a; x <= b; x++) {
        if ((c % x)==0) {
            count += 1;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(a,s,d) for(int a=s;a<d;a++)
using namespace std;
typedef long long ll;
const int maxn=100010;
int x[maxn];

int gcd(int a,int b)
{
    return b>0?gcd(b,a%b):a;
}

int main()
{
    int n;cin>>n;
    cin>>x[0];
    rep(i,1,n+1) scanf("%d",&x[i]);
    sort(x,x+n+1);
    int ans=x[1]-x[0];
    rep(i,2,n+1) ans=gcd(ans,x[i]-x[i-1]);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 640
#include <stdio.h>

int timing[100000];
int divisor[10000];

int main() {

    int max_t = 0, ndiv = 0, adj = 0;
    int i, j, n;
    scanf("%d", &n);

    for ( i=0; i<n; ++i ) {
	scanf("%d", &timing[i]);
	if ( timing[i] > max_t ) max_t = timing[i];
    }

    for ( i=1; i<=max_t>>1; ++i ) {
	if ( max_t%i == 0 ) divisor[ndiv++] = i;
    }
    divisor[ndiv++] = max_t;

    for ( i=0; i<n; ++i ) {
	for ( j=0; j<ndiv; ++j ) {
	    if ( divisor[j] >= timing[i] ) {
		adj += divisor[j] - timing[i];
		break;
	    }
	}
    }

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



Measured memory_bytes: 2096
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*


fun gcd(a:Long, b:Long):Long {
    val c = a % b
    if (c == 0L) return b
    return gcd(b, c)
}

fun lcm(a:Long, b:Long):Long {
    return a / gcd(a, b) * b
}

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val t = Array(n) { sc.nextLong() }
    var l = t[0]
    for (i in 1 until n) {
        l = lcm(l, t[i])
    }
    println(l)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 31144
while True:
    li = raw_input().split()
    if li[1] == "+":
        print int(li[0]) + int(li[2])
    elif li[1] == "-":
        print int(li[0]) - int(li[2])
    elif li[1] == "*":
        print int(li[0]) * int(li[2])
    elif li[1] == "/":
        print int(li[0]) / int(li[2])
    elif li[1] == "?":
        break

Measured memory_bytes: 4220
import java.util.InputMismatchException;
import java.util.Scanner;

public class Main {

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

			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();

			int answer = 0;

			if ((a + b) == c) {
				answer = c + b;
			} else if ((a + b) < c) {
				answer = a + b + 1 + b;
			} else {
				answer = b + c;
			}

			System.out.println(answer);

			scanner.close();
		} catch (InputMismatchException e) {
			System.out.println("整数を入力してください。");
		}
	}

}


Measured memory_bytes: 22612
#include <iostream>
#include <cstdint>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;
using u8 = uint64_t;
using u4 = uint32_t;

int main() {
    u4 n;
    cin >> n;
    vector<u4> a(n);
    
    u4 tmp_in;
    for (u4 i=0; i < n; i++) {
        cin >> tmp_in;
        a[tmp_in-1] = i;
    }

    for (auto i : a) {
        cout << i+1 << " ";
    }

    return 0;
}


Measured memory_bytes: 1152
import java.util.*;
import java.util.Map.Entry;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < N; i++) {
            int x = sc.nextInt();
            
            if( map.containsKey(x) ) {
                int v = map.get(x);
                map.put(x, v+1 );
            } else {
                map.put(x, 1);
            }
        }
        
        long ans = 0;
        for (Entry<Integer, Integer> entry : map.entrySet() ) {
            int key = entry.getKey();
            int value = entry.getValue();
            
            if( key > value ) {
                ans += value;
            } else {
                ans += value - key;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 63464
from sys import stdin
##  input functions for me
def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##

## main ##
A, B = map(int, input().split())
ans = 0
ans = max(ans, A + B)
ans = max(ans, A + A - 1)
ans = max(ans, B + B - 1)
print(ans)





Measured memory_bytes: 3064
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int n, m, p;
pair<pii, int> a[200000];

vector<pll> edge[300000];

int check[300000];
ll d[300000];

int main()
{
	int i, j, k, l;
	cin>>n>>m>>p;
	for(i=0;i<p;i++)
	{
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z), x--, y--;
		a[i]=mp(mp(x, y), z);
		edge[x].emplace_back(y+n, z);
		edge[y+n].emplace_back(x, z);
	}
	for(i=0;i<n+m;i++)
	{
		if(check[i]) continue;
		check[i]=1;
		vector<int> q;
		q.push_back(i);
		for(j=0;j<q.size();j++)
		{
			int now=q[j];
			for(auto e : edge[now])
			{
				ll u;
				if(now < n) u=d[now]-e.second;
				else u=d[now]+e.second;
				if(check[e.first])
				{
					if(d[e.first] != u) return !printf("No\n");
					continue;
				}
				check[e.first]=1;
				d[e.first]=u;
				q.push_back(e.first);
			}
		}
		ll amin=MAX2, bmin=MAX2;
		for(auto e : q)
		{
			if(e < n) amin=min(amin, d[e]);
			else bmin=min(bmin, -d[e]);
		}
		if(amin+bmin < 0) return !printf("No\n");
	}
	printf("Yes\n");
	return 0;
}
//*/

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

int main() {
    int A, B; cin >> A >> B;
    int m = 1000000;
    for (int i = 1300; 1 <= i; i--) {
        int x = (int)(i*0.08);
        int y = (int)(i*0.1);
        if (x == A && y == B) {
            m = min(m, i);
        }
    }
    if (m == 1000000) {
        cout << -1 << endl;
    } else {
        cout << m << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
ll INF = 10010001010;

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

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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    map<string, int> M;
    for (int i = 0; i < N;i++)
    {
        cin >> S[i];
        M[S[i]]++;
    }
    int maxcount = 0;
    for (int i = 0; i < N; i++)
    {
        maxcount = max(M[S[i]], maxcount);
    }
    vector<string> T;
    for (int i = 0; i < N;i++)
    {
        if(maxcount == M[S[i]]){
            T.push_back(S[i]);
        }
    }
    sort(all(T));
    T.erase(unique(all(T)), T.end());
    for (int i = 0; i < T.size(); i++)
    {
        cout << T[i] << endl;
    }
}


Measured memory_bytes: 28404
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i < n; i++)
#define INF 1001001001
#define LINF (1LL << 62)
using namespace std;
using ll = long long;
using P = pair<int,int>;

void solv() {
    string S;
    string dust;
    cin >> dust >> S >> dust;
    cout << "A" << S[0] << "C" << endl;
}

int main() {
    solv();
    return 0;
}

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

using namespace std;

#define endl '\n'

vector<int> vi, wi;
long long dp[101][100005];

long long solve(int idx, int cap) {
  if (cap <= 0 || idx < 0) return 0;
  if (dp[idx][cap] != -1) return dp[idx][cap];
  long long val = 0;
  if (cap - wi[idx] >= 0)
    val = vi[idx] + solve(idx - 1, cap - wi[idx]);
  return dp[idx][cap] = max(val, solve(idx - 1, cap));
}

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

  int n, w;
  cin >> n >> w;
  vi.resize(n);
  wi.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> wi[i] >> vi[i];
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= w; j++) {
      dp[i][j] = -1;
    }
  }
  long long ans = -1e18;
  cout << solve(n - 1, w) << endl;

	return 0;
}


Measured memory_bytes: 82528
n, k = map(int, input().split())
s = input()
pre = 0
sepS = []
happyCount = 0
RLcount = 0
for i in range(1, n):
    if s[i] == s[i - 1]:
        happyCount += 1
    if s[i] == 'L' and s[i - 1] == 'R':
        RLcount += 1
#print("now HP =>{}".format(happyCount))
happyCount += min(k, RLcount) * 2
if k > RLcount:
    happyCount += 1
print(min(n - 1, happyCount))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;

#define INF (i32)1e9
#define INF_LL (i64)1e18
#define REP(i, n) for(i64 i = 0; i < n; i++)
#define RANGE(i, a, b) for(i64 i = a; i < b; i++)

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

  vector<bool> is_prime(3163);
  vector<i64> primes;
  REP(i, 3162) is_prime[i] = true;
  RANGE(i, 2, 3163) {
    if (is_prime[i]) {
      RANGE(j, i * 2, 3163) {
        if (j % i == 0) is_prime[j] = false;
      }
      primes.emplace_back(i);
    }
  }

  vector<i64> v(n);
  i64 ans = 1;
  v[0] = 1;
  RANGE(i, 1, n) {
    i64 po = i + 1;
    i64 p = 0;
    for (auto&& prime : primes) {
      if (prime * prime > po) break;
      if (po % prime == 0) {
        p = prime;
        break;
      }
    }
    v[i] = 2;
    if (p != 0) {
      i64 cnt = 1;
      while (po % p == 0) {
        po /= p;
        cnt++;
      }
      v[i] = cnt * v[po - 1];
    }
    ans += (i + 1) * v[i];
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{
    int n,cnt=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        if(i%2==1){
            if(x%2==1){
                cnt++;
            }
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <queue>
#include <algorithm>
#include <utility>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
queue<pii> q;
pii arr[200001];
int main(){
    int N,D,A;scanf("%d %d %d",&N,&D,&A);
    for(int i=0;i<N;i++){
        int a,b;scanf("%d %d",&a,&b);
        arr[i]={a,b};
    }
    sort(arr,arr+N);
    ll sum=0,cnt=0;
    for(int i=0;i<N;i++){
        while((!q.empty()) && q.front().first<arr[i].first){
            cnt-=q.front().second;
            q.pop();
        }
        ll cha = (arr[i].second - cnt*A);
        if(cha>0){
            cnt += cha/A + (cha%A>0);
            sum += cha/A + (cha%A>0);
            q.push({arr[i].first+2*D,cha/A + (cha%A>0)});
        }
    }
    printf("%lld",sum);
}

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


char tile[100][100];
int h, w;
int ax, ay;
bool loop = false;


void solve(int x, int y){
	if (tile[y][x] == '>'){
		tile[y][x] = '*';
		solve(x + 1, y);
	}
	else if (tile[y][x] == '<'){
		tile[y][x] = '*';
		solve(x - 1, y);
	}
	else if (tile[y][x] == '^'){
		tile[y][x] = '*';
		solve(x, y - 1);
	}
	else if (tile[y][x] == 'v'){
		tile[y][x] = '*';
		solve(x, y + 1);
	}
	else if (tile[y][x] == '.'){
		ax = x;
		ay = y;
	}
	else if (tile[y][x] == '*'){
		loop = true;
	}
}


int main(){


	while (cin >> h >> w, h || w != 0){
		for (int y = 0; y < h; y++){
			for (int x = 0; x < w; x++){
				cin >> tile[y][x];
			}
		}
		solve(0, 0);
		if (!loop) cout << ax << ' ' << ay << endl;
		else cout << "LOOP" << endl;
		loop = false;
	}

	return 0;
}

Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        
        int x = (Math.max(Math.max(a, b), c) *3) - (a+b+c);
        if(x%2 == 0){
            System.out.println(x/2);
        }else{
            System.out.println(x/2 +2);
        }
    }
}

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

int main(){
    string s;
    cin >> s;
    int counter = 0;
    for (int i = 0; i < s.size(); i++){
        if(s[i] == 'o') ++counter;
    }
    cout << counter * 100 + 700 <<endl;
}
            


Measured memory_bytes: 256
loop do
  x, y, s = gets.split.map(&:to_i)
  break if x==0

  puts ((1..(s-1)).each.to_a.repeated_permutation(2).map do |a,b|
    ax = (1.0*a*(100.0+x)/100.0).to_i
    bx = (1.0*b*(100.0+x)/100.0).to_i
    next -1 unless ax + bx == s

    ay = (1.0*a*(100.0+y)/100.0).to_i
    by = (1.0*b*(100.0+y)/100.0).to_i
    ay + by
  end.max)
end

Measured memory_bytes: 123436
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
map<ll,ll> a;
ll r;
for(ll i=0; i<n; i++){
cin>>r;
a[r]++;}
ll m;
cin>>m;
map<ll,ll> b;
for(ll i=0; i<m; i++){
cin>>r;
b[r]++;}
ll k=0;
for(auto p:b){
if(b[p.first]>a[p.first]){
k++;
break;}}
if(k==1){
cout << "NO" << endl;}
else{
cout << "YES" << endl;}}


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


class Node
{
private:
    int _id;
    int _parent;
    int _depth;
    std::vector<int> _children;

public:
    Node() {
        this->_id = -1;
        this->_parent = -1;
        this->_depth = 0;
    }

    Node(int id) {
        this->_id = id;
        this->_parent = -1;
        this->_depth = 0;
    }

    ~Node() {
        ;
    }

    const int& id() const {
        return this->_id;
    }

    int& id() {
        return this->_id;
    }

    const int& parent() const {
        return this->_parent;
    }

    int& parent() {
        return this->_parent;
    }

    const int& depth() const {
        return this->_depth;
    }

    int& depth() {
        return this->_depth;
    }

    const std::vector<int>& children() const {
        return this->_children;
    }

    void set_child(int childid) {
        this->_children.push_back(childid);
    }

    std::string type() {
        if (this->_parent == -1)
            return "root";
        else if (this->_children.empty())
            return "leaf";
        else
            return "internal node";
    }

};

std::vector<Node> nodelist;

void print(Node node) {
    std::cout << "node " << node.id() << ": parent = " << node.parent() << ", depth = " << node.depth() << ", " << node.type() << ", [";
    if (node.children().size() != 0) {
        for (int i = 0; i < node.children().size() - 1; i++) {
            std::cout << node.children()[i] << ", ";
        }
        std::cout << node.children()[node.children().size() - 1] << "]" << std::endl;
    } else {
        std::cout << "]" << std::endl;
    }
}

void setdepth(Node& node, int curdepth)
{
    node.depth() = curdepth;

    for (int childid : node.children())
        setdepth(nodelist[childid], curdepth + 1);
}

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    nodelist.resize(n);
    int id;
    int child_id;
    int k;
    for (int i = 0; i < n; i++) {
        nodelist[i].id() = i;

        std::cin >> id >> k;
        for (int j = 0; j < k; j++) {
            // set children
            std::cin >> child_id;
            nodelist[id].set_child(child_id);

            // set parent
            nodelist[child_id].parent() = id;
        }
    }

    // calculate depth
    int rootid = 0;
    for (int i = 0; i < n; i++) {
        if (nodelist[i].parent() == -1) {
            rootid = i;
            break;
        }
    }
    setdepth(nodelist[rootid], 0);

    // output
    for (int i = 0; i < n; i++) {
        print(nodelist[i]);
    }

    return 0;
}

Measured memory_bytes: 7712
import itertools
n = int(input())
p = list(map(int, input().split()))
pp = "".join((str(n) for n in p))
q = list(map(int, input().split()))
qq = "".join((str(n) for n in q))
a = [i+1 for i in range(n)]
b = 0
c = 0
d = 0
for i in itertools.permutations(a):
	d += 1
	x = "".join((str(n) for n in i))
	if pp == x:
		b = d
	if qq == x:
		c = d
print (abs(b-c))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	std::vector<int> got(4, 0);
	int ans = 0;
	for(int i = 0; i < n; i++) {
		std::string str;
		std::cin >> str;
		int mask = 0;
		if(str[0] == 'B') {
			mask |= 1;
		}
		if(str.back() == 'A') {
			mask |= 2;
		}
		got[mask]++;
		for(int j = 0; j + 1 < (int) str.size(); j++) {
			if(str.substr(j, 2) == "AB") {
				ans++;
			}
		}
	}
	int tot = 0;
	for(int i = 0; i <= std::min(got[1], got[2]); i++) {
		int cur = i + std::max(got[3] - 1, 0);
		if(got[2] > i && got[3]) cur++;
		if(got[1] > i && got[3]) cur++;
		tot = std::max(tot, cur);
	}
	std::cout << ans + tot << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
int main () {
string S , T ; cin >> S >> T ;
bool ans = false ;
for ( int i = 0; i < S . size (); ++ i ) {
if ( S == T ) {
ans = true ;
break ;
}
S = S . back () + S . substr (0 , S . size () -1);
}
if ( ans ) {
cout << " Yes " << endl ;
}
else {
cout << "No" << endl ;
}
}

Measured memory_bytes: 256