akhauriyash/Code-Regression huggingface dataset:
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//関係性は隣接行列で記録
//過半数：N/2.0で判定
//ある量からある量を引く系の問題：端から定義してやる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll N, K; cin >> N >> K;
	vector<ll> a(N), b(N); rep(i, N)cin >> a[i] >> b[i];

	vector<pair<ll, ll>> ab(N);
	rep(i, N) {
		ab[i].first = a[i];
		ab[i].second = b[i];
	}

	sort(ALL(ab));

	rep(i, N) {
		if (K <= ab[i].second) {
			cout << ab[i].first;
			return 0;
		}
		K -= ab[i].second;
	}
}

Measured memory_bytes: 11136
#include <stdio.h>

int main()
{
  int N, i, flag=1, work, count=0, A[100];

  //inpput number that is used this program
  scanf("%d", &N);
  for(i=0;i<N;i++){
    scanf("%d", &A[i]);
  }

  //do babble sort
  while(flag==1){
    flag=0;
    for(i=N-1;i>0;i--){
      if(A[i]<A[i-1]){
	work=A[i];
	A[i]=A[i-1];
	A[i-1]=work;
	flag=1;
	count++;
      }
    }
  }

  //output this sort's result
  for(i=0;i<N;i++){
    if(i==N-1){
      printf("%d",A[i]);
      break;
    }
    printf("%d ", A[i]);
  }

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

Measured memory_bytes: 600
import java.util.*

val sc = Scanner(System.`in`)
val H = sc.nextInt()
val W = sc.nextInt()

fun main(args: Array<String>) {
    var a = Array(H) { "" }
    for (i in 0 until H) {
        a[i] = sc.next()
    }

    for (i in 0 until 4) {
        a = a.filter { it.contains('#') }.toTypedArray()
        a = rotated(a)
    }
    println(a.joinToString("\n"))
}


fun rotated(a: Array<String>): Array<String> {
    val result = Array(a[0].length) { "" }

    for (i in 0 until a[0].length) {
        for (j in 0 until a.size) {
            result[i] += a[a.size - 1 - j][i].toString()
        }
    }
    return result
}


Measured memory_bytes: 48020
import bisect as b
from collections import deque
n=int(input())
ans=1
clist=deque([int(input())])
for i in range(n-1):
    next=int(input())
    pos=b.bisect_left(clist,next)
    if pos==0:
        clist.appendleft(next)
        ans+=1
    else:
        clist[pos-1]=next
print(ans)


Measured memory_bytes: 47832
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int INF = numeric_limits<int>::max() / 2;

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

	ll n, m; cin >> n >> m;
	vector<ll> dist(n, -1);
	vector<vector<ll> > tree(n);
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	dist[0] = 0;
	queue<ll> q;
	bool flag = false;
	q.push(0);//点、距離
	while (!q.empty()) {
		int v = q.front(); q.pop();
		//for (int i = 0; i < (int)tree[v].size(); i++) {
		for( auto next : tree[v]){
			if (dist[next] == -1) {
				dist[next] = 1-dist[v];
				q.push(next);
			}
			else if(dist[next]==1-dist[v]){
				continue;
			}
			else {
				flag = true;
				break;
			}
		}
	}
	ll cnt=0;
	for (int i = 0; i < n; i++) {
		cnt += dist[i];
	}
	if (flag) cout << n*(n - 1) / 2 - m << endl;
	else cout << cnt*(n-cnt) - m << endl;
	return 0;
}

Measured memory_bytes: 7168
N,M=map(int,input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans=0
table=make_divisors(M)
table.sort()

for i in table:
    if i<=M//N:
        ans=i
        
print(ans)






Measured memory_bytes: 38768
#include<iostream>
#include<algorithm> 
#include<vector>
using namespace std;
int dp[100000][3];
int main()
{
	int n;
	cin>>n;
	int a[n][3];
	for(int i = 0; i < n; i++)
	cin>>a[i][0]>>a[i][1]>>a[i][2];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i =1;i < n; i++)
	{
		for(int j = 0; j < 3; j++)
		{
                     
                      dp[i][j]= max(dp[i-1][(j-1+3)%3],dp[i-1][(j+1+3)%3])+a[i][j];
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
 } 

Measured memory_bytes: 2560
#include<stdio.h>
int main() {
	char ch;
	int num = 0, counter[26] = { 0 };
	while ((ch=getchar()) != EOF) {
		if ('a' <= ch&&ch <= 'z') {
			num = ch - 'a';
			counter[num]++;
		}
		if ('A' <= ch&&ch <= 'Z') {
			num = ch - 'A';
			counter[num]++;
		}
	}
	for(num=0;num<26;num++) {
		printf("%c : %d\n", num + 'a', counter[num]);
	}
	return 0;
}

Measured memory_bytes: 524
N, X, Y = map(int, input().split())
graph = [set() for _ in range(N)]
graph[X - 1].add(Y - 1)
graph[Y - 1].add(X - 1)
for i in range(N - 1):
    graph[i].add(i + 1)
    graph[i + 1].add(i)


dist = [[10 ** 9] * N for _ in range(N)]
for i in range(N):
    queue = [i]
    seen = {i}
    dist[i][i] = 0
    while queue:
        new = []
        for cur in queue:
            for nei in graph[cur]:
                dist[i][nei] = min(dist[i][nei], dist[i][cur] + 1)
                if nei not in seen:
                    new.append(nei)
                    seen.add(nei)
        queue = new
count = [0] * N
for i in range(N):
    for j in range(i + 1, N):
        count[dist[i][j]] += 1

for c in count[1:]:
    print(c)

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

int main(){
    ll N;
    cin >> N;
    vector<ll> array(N),x(N),y(N); //順列の一覧
    rep(i,N){
        array.at(i) = i;
        cin >> x.at(i) >> y.at(i);
    }
    double sum = 0;
    ll length = 0;
    do{
        rep(i,N-1){
            ll fr=array.at(i),to=array.at(i+1);
            sum += sqrt(pow(x.at(to)-x.at(fr),2) + pow(y.at(to)-y.at(fr),2));
            //cout << pow(x.at(to)-x.at(fr),2) + pow(y.at(to)-y.at(fr),2) << endl;
        }
        length++;
    }while(next_permutation(array.begin(),array.end()));
    cout << fixed << setprecision(10) << sum / double(length) << endl; 
    return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF=1<<30;
const ll INF=1ll<<60;
const ll MOD = 1000000007;
int n;
vector<lld> dijkstra(map<int,vector<pair<int,lld>>> &g,int start){
    priority_queue<pair<lld,int>,vector<pair<lld,int> >,greater<pair<lld,int>>> pque;
    pque.push({0,start});
    vector<lld> ret(n+2,INF);
    while (!pque.empty()){
        auto cost=pque.top().first;
        auto cur=pque.top().second;
        pque.pop();
        if (ret[cur]<=cost) continue;
        ret[cur]=cost;
         for (auto x:g[cur]){
             int next=x.first;
             lld d=x.second;
             pque.push({cost+d,next});
         }
     }

    return ret;
} 

lld dist(vector<lld> &a,vector<lld> &b){
    return max((lld)0,sqrtl((a[0]-b[0])*(a[0]-b[0]) + (a[1]-b[1])*(a[1]-b[1]))-a[2]-b[2]);
}

int main(){
    lld x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    cin>>n;
    vector<vector<lld>> p(n+2,vector<lld>(3));
    p[0]={x1,y1,0};
    p[1]={x2,y2,0};
    rep(i,n){
        cin>>p[2+i][0]>>p[2+i][1]>>p[2+i][2];
    }
    map<int,vector<pair<int,lld>>> g;
    rep(i,n+2){
        rep(j,n+2){
            if (i==j) continue;
           // cerr<<i<<" -> "<<j<<":"<<dist(p[i],p[j])<<endl;
            g[i].push_back({j,dist(p[i],p[j])});
        }
    }
    auto cost=dijkstra(g,0);
    cout<<fixed<<setprecision(18)<<cost[1]<<endl;
    return 0;
}

Measured memory_bytes: 67300
h,w,k = map(int,input().split())
d = []
for i in range(h):
  d.append(list(input()))

c = 0
for x in range(2**h):
  for y in range(2**w):
    e =  [['t' for _ in range(w)] for _ in range(h)]
    for i in range(h):
      if ((x >> (h-1-i)) & 1) == 1:
        for l in range(w):
          e[i][l] = 'R'
    
    for j in range(w):
      if ((y >> (w-1-j)) & 1) == 1:
        for m in range(h):
          e[m][j] = 'R'
    
    s = 0     
    for p in range(h):
      for q in range(w):
        if d[p][q] == '#' and e[p][q] != 'R':
          s += 1
    
    if s == k:
      c += 1
            
print(c)        

Measured memory_bytes: 9132
// Note that by default C++ creates a max-heap 
// for priority queue 
#include <iostream> 
#include <queue> 
#include <bits/stdc++.h>
using namespace std; 



int main () 
{ 
       int a,b,c,d;
       cin>>a>>b>>c>>d;
       while(c>0 && a>0)
       {
           c=c-b;
           if(c<=0)
           {
                cout<<"Yes"<<endl;
                break;
           }
            a=a-d;
           if(a<=0)
           {
                cout<<"No"<<endl;
                break;
           }
       }
       
       
    
} 



Measured memory_bytes: 3624
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let k: i64 = read(&mut stdin_lock, &mut buf, b'\n');
    let cv: Vec<char> = s.chars().collect();

    let mut ans = cv[0];
    let mut l = k;
    for i in 0..cv.len() {
        ans = cv[i];
        if cv[i] == '1' {
            l -= 1;
            if l == 0 {
                break;
            }
        } else {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main() {
    int n = 0;
    scanf("%d", &n);

    char s[10];
    sprintf(s, "%d", n);

    int flag = 0; 
    int i;
    for (i = 0; s[i] != '\0'; i++) {
        if (s[i] == '7') {
            flag = 1;
            break;
        }
    }

    if (flag == 1) {
        printf("Yes");
    }
    else {
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 1728
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<sstream>

using namespace std;
#define ll 		long long
#define int     long long
#define ld 		long double
#define vll 	vector<ll>
#define pll 	pair<ll,ll>
#define map1 	map<ll,ll>
#define pqb 	priority_queue<ll>
#define pqs 	priority_queue<ll, vll,greater<ll> >
#define push_back emplace_back
#define N 		100009
#define mod 	1e9+9
#define MAX 	1e9
#define test(tt123) ll Tt123,tt123; cin>>Tt123; for(tt123=1 ; t<=Tt123 ; t++)    
#define one(x)	__builtin_popcountll(x)
#define zero(x) __builtin_ctzll(x)
#define precision(x) cout<<fixed<<setprecision(x);
#define debug(x)   cout<<"HELLO "<<x<<endl
const double pi = 3.14159265358979323846;
//vector<pll> p;
void fast(){
	//p.push_back({1,0}); p.push_back({0,1}); p.push_back({-1,0});p.push_back({0,-1});
	//p.push_back({-1,-1}); p.push_back({-1,1}); p.push_back({1,-1});p.push_back({1,1});
	ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//#endif
}
int32_t main(){
	fast();
	int n,x,t; cin>>n>>x>>t;
	
	int ans = (n%x==0)? n/x : n/x+1;
	cout<<ans*t;
}


Measured memory_bytes: 3632
import sys
  
for s in list(sys.stdin):
    a,b,e,c,d,f = list(map(float,s.split()))
    base = a*d-b*c
    x = e*d-b*f
    y = a*f-e*c
    print('%.3f %.3f' % (x/base+0,y/base+0))

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

using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  
           ll x,k,d;
      ll c=0;
      cin>>x>>k>>d;
      if(x<0)
      {
          x=x*(-1);
      }
    ll i=x/d;
    if(x%d!=0)
    i++;
      ll s=k-i;
      if(s<1)
      {
          x=x-k*d;
          if(x<0)
          {
              x=x*(-1);
          }
        cout<<x;  
      }
      else
      {
          if(s%2==0)
          {
              x=x-(i*d);
                if(x<0)
          {
              x=x*(-1);
          }
        cout<<x ;
          }
          else
          {
              x=x-(i*d);
              x=x+d;
               if(x<0)
          {
              x=x*(-1);
          }
        cout<<x;
          }
      }
      

    
     return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll SUM(vector<ll>&& vec){return accumulate(all(vec),0LL);} // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
bool isPrime(ll n); // 素数か
vector<ll> primes(ll n); // 素因数分解
int ctoi(char c){return c - '0';}

const ll COM_MAX = (ll)(1e6+100); // combinationの最大値
vector<ll> fac(COM_MAX),finv(COM_MAX),inv(COM_MAX);
void comb_init(); // 初期化
ll comb(ll n,ll k); // nCk

// TODO: write
int main() { 
  int n,m;cin>>n>>m;
  int ans = 0;
  rep(i,n){
    int a;cin>>a;
    ans = gcd(abs(a-m),ans);
  }
  print(ans);
  return 0;
}

void comb_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<COM_MAX;++i){
    fac[i]=fac[i-1]*i%INF;
    inv[i]=INF-inv[INF%i]*(INF/i)%INF;
    finv[i]=finv[i-1]*inv[i]%INF;
  }
}

ll comb(ll n,ll k){
  if(n<k)return 0;
  if(n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%INF)%INF;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v;
  for (ll i = 2; i*i <= n; ++i) {
    while(n%i==0){
      n/=i;
      v.pb(i);
    }
  }
  if(n != 1)v.pb(n);
  return v;
}


/* 二分探索の時に使う
template<typename T>bool isOk(T key,T value){
  return key <= value;
}
template<typename T>T binary_search(vector<T> a,T key){
  T ok = a.size();
  T ng = -1;
  while(abs(ok - ng) > 1){
    T mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}
*/

Measured memory_bytes: 23680
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
A = LI()
B = LI()
C = LI()
ans = 0
before = -1
for i in range(n):
    taberuNo = A[i]-1
    ans += B[taberuNo]
    if taberuNo -1 == before and i != 0:
        ans += C[before]
    before = taberuNo
print(ans)

Measured memory_bytes: 73940
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 1;
        while(sc.hasNextInt()){
            int n = sc.nextInt();
            if(n == 0) break;
            else System.out.printf("Case %d: %d\n",i++,n);
        }
        sc.close();
    }

}

Measured memory_bytes: 80296
#include <iostream>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll a[1000][1000];
ll x[200000] = {};
ll y[200000] = {};
ll x2[200000] = {};
ll y2[200000] = {};

int main() {
	ll h, w, v; cin >> h >> w;
	rep(i, 0, h)rep(j, 0, w) {
		cin >> v;
		a[i][j] = v % 2;
	}

	ll cnt = 0;
	rep(i, 0, h) {
		rep(j, 0, w - 1) {
			if (a[i][j] & 1) {
				a[i][j + 1]++;

				y[cnt] = i + 1;
				x[cnt] = j + 1;
				y2[cnt] = i + 1;
				x2[cnt] = j + 2;
				cnt++;
			}
		}

		if (i != h - 1) {
			if (a[i][w - 1] & 1) {
				a[i + 1][w - 1]++;

				y[cnt] = i + 1;
				x[cnt] = w;
				y2[cnt] = i + 2;
				x2[cnt] = w;
				cnt++;
			}
		}
	}

	printf("%d\n", cnt);
	rep(i, 0, cnt)	printf("%d %d %d %d\n", y[i], x[i], y2[i], x2[i]);

	return 0;
}

Measured memory_bytes: 11904
open System
open System.Collections.Generic

module InputUtility =
    let InputTokens = new Queue<string>()

    let EnsureInput () =
        if InputTokens.Count = 0 then
            let input = Console.ReadLine ()
            let s = input.Split ([|' '|], StringSplitOptions.RemoveEmptyEntries)
            if s.Length > 0 then
                for x in s do InputTokens.Enqueue(x)
                true
            else false
        else true

    let rec ReadNext () =
        if EnsureInput () then InputTokens.Dequeue ()
        else ReadNext ()

    let ReadNextInt () = ReadNext () |> int

    let Read2Int () = ReadNextInt (), ReadNextInt ()

    let Read3Int () = ReadNextInt (), ReadNextInt (), ReadNextInt ()

    let ReadListOf f n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop ((ReadNext () |> f) :: acc) (c-1)
        loop [] n

    let MultipleCaseWithId f =
        let caseNum = ReadNextInt ()
        let rec loop index =
            if index = caseNum then ()
            else
                f index
                loop (index + 1)
        loop 0

    let MultipleCase f = MultipleCaseWithId (fun _ -> f ())

    let ReadList n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop (ReadNext () :: acc) (c-1)
        loop [] n

open InputUtility

module ARC077 =
    let private Guruguru () =
        let n, m = Read2Int ()
        let ps = Array.create (m + 1) (0L, 0L)
        let ns = Array.create (m + 1) (0L, 0L)
        let rec add b s t =
            if s > t then
                add b s m + add (b + m - s + 1) 1 t
            elif b < 2 then
                if s = t then 1L
                else 1L + add (b + 1) (s + 1) t
            else
                let d = t - s + 1 |> int64
                let nb = b - 1 |> int64
                let mx, my = ps.[s]
                ps.[s] <- mx + 1L, my + nb - 1L
                let nx, ny = ns.[t]
                ns.[t] <- nx + 1L, ny + nb + int64 d - 1L
                //printfn "%d,%A %d,%A => %d" s ps.[s] t ns.[t] d
                d
        let rec read i s p =
            if i = n then s
            else
                let q = ReadNextInt ()
                let ns = s + add 0 p q - 1L
                read (i + 1) ns q
        let sum = ReadNextInt () |> read 1 0L
        //printfn "sum = %d" sum
        let rec cal i c e r =
            if i > m then r
            else
                let mx, my = ps.[i]
                let pc = c + mx
                let pe = e + pc + my
                let nr = max pe r
                let nx, ny = ns.[i]
                let nc, ne = pc - nx, pe - ny
                //printfn "%d: %A %A => %d %d %d | %d %d %d" i ps.[i] ns.[i] pc pe nr nc ne r
                cal (i + 1) nc ne nr
        sum - cal 1 0L 0L 0L
        |> printfn "%d"

    let Entry = Guruguru

ARC077.Entry ()

Measured memory_bytes: 30800
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=5005;

int n,x,ans,sz,mx;
int a[N],b[N];
bool b1[N][N],b2[N][N];

int main(){
	int i,j,k;
	scanf("%d%d",&n,&x);
	for (i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i]=min(a[i],x);
	}
	b1[0][0]=b2[n+1][0]=1;
	for (i=1;i<=n;i++){
		for (j=x;j>=a[i];j--)
			if (b1[i-1][j-a[i]]) b1[i][j]=1;
		for (j=0;j<=x;j++) b1[i][j]|=b1[i-1][j];
	}
	for (i=n;i>=1;i--){
		for (j=x;j>=a[i];j--)
			if (b2[i+1][j-a[i]]) b2[i][j]=1;
		for (j=0;j<=x;j++) b2[i][j]|=b2[i+1][j]; 
	}
	for (i=1;i<=n;i++){
		sz=0;
		for (j=0;j<x;j++) if (b2[i+1][j]) b[++sz]=j;
		k=sz; mx=0;
		for (j=0;j<x;j++)
			if (b1[i-1][j]){
				while (k>0&&b[k]+j>=x) k--;
				mx=max(mx,b[k]+j);
			}
		if (a[i]+mx>=x) ans++;
	}
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 49152
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

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

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,j,N,H,W,ans;
  cin>>N;
  string s;
  cin>>s;
  rep(i,s.size()){
    s[i]=(s[i]-'A'+N)%26+'A';
  }
  cout<<s<<endl;
  return 0;
}

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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b + c || b == a + c || c == a + b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX_A 20
#define MAX_M 200
int n, A[MAX_A], M[MAX_M];
int solve(int,int);

int main(){

    int i, q;

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

    scanf("%d",&q);
    for(i=0; i<q;i++){
        scanf("%d", &M[i]);
    }

    for(i=0;i<q;i++){
        if(solve(0,M[i])){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
   
    return 0;
}

int solve(int i, int m){
    if(m == 0)return 1;
    if(i >= n)return 0;
    return solve(i+1, m) || solve(i+1, m-A[i]);
}



Measured memory_bytes: 2052
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//int dx[] = { 1, -1 , 0 , 0 };
//int dy[] = { 0,  0,  1, -1 };
int dx[] = { 1, 0 };
int dy[] = { 0, 1 };
ll MOD = 1000000007;

unsigned long long str_to_int(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve(){
	int h,w;
	cin >> h >> w;
	int count = 0;
	rep(i,h){
		string s;
		cin >> s;
		rep(j,w){
			count += (s[j] == '.' ? 0 : 1);
		}
	}
	if(count == h+w-1){
		P("Possible");
	}else{
		P("Impossible");
	}
}

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

Measured memory_bytes: 256
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let [|N;Y|] = reada int

    seq {
        for i in 0..N do
            for j in 0..N-i do
                let k = N-i-j
                yield (i, j, k)
    }
    |> Seq.tryFind (fun (x, y, z) -> 10000 * x + 5000 * y + 1000 * z = Y)
    |> function
        | Some a -> a
        | None -> (-1, -1, -1)
    |> fun (x, y, z) -> printfn "%d %d %d" x y z
    0


Measured memory_bytes: 18212
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;

int main(){
  int N,a;
  cin >> N;
  int count[100005]={};
  for(int i=0; i<N; i++){
    cin >> a;
    count[a]+=1; count[a+1]+=1; count[a+2]+=1;
  }int sum=-1;
  for(int i=0; i<N; i++){
    sum = max(sum,count[i]);
  }
  if(sum==0){
    sum=1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
using namespace std;
static const int MAX_Q = 100000;

typedef struct{
    int id;
    int score;
}Person;

int main(void){
    int n, k, q;
    int A[MAX_Q+1];
    cin >> n >> k >> q;
    for(int i=1; i<=q; i++){
        cin >> A[i]; // 1スタート
    }

    Person P[n+1]; // 1スタート
    // 初期値k-qにする(全問不正解)
    for(int i=1; i<=n; i++){
        P[i].score = k-q;
    }

    // 正解者に1点ずつ与える
    for(int i=1; i<=q; i++){
        P[A[i]].score += 1;
    }

    // 1点以上残っていたら "Yes"
    for(int i=1; i<=n; i++){
        if(P[i].score >= 1) cout << "Yes" << "\n";
        else cout << "No" << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}

   


  int main(){

    lint K,T,count=0;
    cin>>K>>T;
    vector <lint> J;
    rep(i,T){
      lint f;
      cin>>f;
       J.push_back(f);
        count+=J[i];
    }
    lint v=*max_element(J.begin(),J.end());
    cout<<max((lint)0,2*v-count-1);
  }

Measured memory_bytes: 256
s = input()[::-1]
c = [0] * 2019
c[0] = 1
mod = 0
ten = 1
ans = 0

for i in s:
    mod = (mod + int(i) * ten) % 2019
    ten = ten * 10 % 2019
    c[mod] += 1

for i in c:
    ans += i * (i - 1) // 2

print(ans)

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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

const int MOD = 1e9+7;

int main(){ _
	int n, k; cin >> n >> k;
	vector<int> v(n);
	for(int& i : v) cin >> i;
	
	vector<int> memo(k+1), pref(k+1);

	auto query = [&] (int l, int r) {
		int ret = pref[r];
		if(l) ret -= pref[l-1];
		return (ret + MOD) % MOD;
	};

	memo[0] = 1;
	for(int i=0; i<n; i++) {
		pref[0] = memo[0];
		for(int j=1; j<k+1; j++) pref[j] = (pref[j-1]+memo[j]) % MOD;

		for(int j=0; j<=k; j++)
			memo[j] = query(max(0, j-v[i]), j);
	}

	cout << memo[k] << endl;

	return 0;
}


Measured memory_bytes: 3948
#include <stdio.h>

#define MAX 100

int BubbleSort(int [],int);
void swap(int [],int,int);

int main(){
  int A[MAX],N;
  int i;
  int answer;

  scanf("%d",&N);

  for (i = 0;i < N;i++)
    scanf("%d",&A[i]);

  answer = BubbleSort(A,N);

  for (i = 0;i < N;i++){
    if (i)
      printf(" ");

    printf("%d",A[i]);
  }

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

int BubbleSort(int A[],int N){
  int cnt = 0;
  int flag = 1;
  int i,j;

  i = 0;
  
  while (flag){
    flag = 0;

    for (j = N - 1;j != i;j--)
      if (A[j - 1] > A[j]){
	swap(A,j - 1,j);
	cnt++;
	flag = 1;
      }
    
    i++;
    
  }

  return cnt;
}

void swap(int A[],int a,int b){
  int temp;

  temp = A[a];
  A[a] = A[b];
  A[b] = temp;
}



Measured memory_bytes: 2120
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int,int> P;
int w,h;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int calc(vector<string> grid, P p1, P p2){
  int used[20][20];
  memset(used, -1, sizeof(used));
  queue<P> que;
  que.push(p1);
  used[p1.first][p1.second] = 0;
  while(!que.empty()){
    P st = que.front(); que.pop();
    if(st == p2) return used[st.first][st.second];
    REP(r,4){
      int cost = used[st.first][st.second];
      int ny = st.first + dy[r];
      int nx = st.second + dx[r];;
      if(0<=ny && ny<h && 0<=nx && nx<w){
        if(used[ny][nx] == -1 && grid[ny][nx] != 'x'){
          used[ny][nx] = cost + 1;
          que.push(P(ny,nx));
        }
      }
    }
  }
  return INF;
}
int main(){
  while(cin>>w>>h,w){
    vector<string> grid(h);
    REP(i,h)cin>>grid[i];
    P start;
    vector<P> target;
    REP(y,h)REP(x,w){
      if(grid[y][x]=='o'){
        start = P(y,x);
      }else if(grid[y][x] == '*'){
        target.push_back(P(y,x));
      }
    }
    int n = target.size();
    int d[10][10] = {};
    REP(i,n)REP(j,n){
      d[i][j] = (i!=j)?(calc(grid,target[i],target[j])):0;
    }
    int dp[1<<10][10];
    REP(i,1<<n)REP(j,n)dp[i][j] = INF;
    REP(i,n)dp[1<<i][i] = calc(grid, start, target[i]);
    REP(s,1<<n)REP(from,n){
      REP(to,n){
        dp[s|1<<to][to] = min(dp[s|1<<to][to], dp[s][from] + d[from][to]);
      }
    }
    int ans = INF;
    REP(i,n)ans = min(ans, dp[(1<<n)-1][i]);
    if(ans == INF) ans = -1;
    cout<<ans<<endl;
  }
	return 0;
}

Measured memory_bytes: 968
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        String[] S = new String[N]; 
        
        //文字列を格納し、辞書順に並び替え
        for(int i = 0; i < N; i++)S[i] = sc.next();
        Arrays.sort(S);
        
        //可変長のクラスを利用した文字列結合
        StringBuilder bf = new StringBuilder();
        for(int i = 0; i < N; i++)bf.append(S[i]);
        
        String ans = bf.toString();
        System.out.println(ans);
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<(a*3+b)/2<<'\n';
}



Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if (n>=64) cout<<64;
    if (n<64&&n>=32) cout<<32;
    if (n<32&&n>=16) cout<<16;
    if (n<16&&n>=8) cout<<8;
    if (n<8&&n>=4) cout<<4;
    if (n<4&&n>=2) cout<<2;
    if (n<2) cout<<1;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n, 0);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> h.at(i);
		if (h.at(i) >= k) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
    int n,k,s=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;++i)
    cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<k;++i)
    {
        s+=a[i];
    }
    cout<<s;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

  int max = 0;
  int result = 0;
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    if (max <= h) {
      result++;
      max = h;
    }
  }

  cout << result;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static final int MOD = (int) (Math.pow(10, 9) + 7);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long m = Long.parseLong(sc.next());
        if (Math.abs(n - m) >= 2) {
            System.out.println(0);
        } else if (n == m) {
            long ans = factorial(n) * factorial(m) * 2 % MOD;
            System.out.println(ans);
        } else {
            long ans = factorial(n) * factorial(m) % MOD;
            System.out.println(ans);
        }
    }

    private static long factorial(long n) {
        long ans = 1;
        for (int i = 1; i <= n; i++) {
            ans = ans * i % MOD;
        }
        return ans;
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    ll a,b,ans=-1;
    cin>>a>>b;
    for(int i=b*10;i<(b+1)*10;i++){
        if((ll)(i*0.08+0.001)==a){
            ans=i;
            break;
        }
    }
    cout <<ans;
}

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

public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder s=new StringBuilder(br.readLine());
		int n=s.length();
		int mod=0;
		for(int i=0;i<n;i++)
		{
			int x=s.charAt(i)-'0';
			mod=(mod+x)%9;
		}
		if(mod==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 36200
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

int main(){
    int N,S;
    cin>>N>>S;
    vector<ll> A(N+1);

    A[0]=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    ll mod=998244353;
    ll ans=0;

    vector<ll> x(S+1,0);
    for(int i=0;i<N;i++){
        x[0]++;
        vector<ll> x2(S+1,0);
        for(int j=0;j<S+1;j++){
            x2[j]+=x[j];
            x2[j]%=mod;
            if(j+A[i]<=S){
                x2[j+A[i]]+=x[j];
                x2[j+A[i]]%=mod;
            }
        }
        x=x2;
        ans+=x[S];
        ans%=mod;
    }


    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3676
#include <iostream>
using namespace std;
 
int main(void){
    int n, m, a;
    cin >> n >> m;
    int sum = 0;
    for(int i = 0; i < m; i++){
        cin >> a;
        sum += a;
    }
    
    n -= sum;
    if(n >= 0) cout << n << endl;
    else cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 3632
//According to all known laws of aviation, there is no way that a bee should be able to fly.
//Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway.
//Because bees don't care what humans think is impossible.
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;

map<bigint , int> m ;
int count1( int N ){
    return int((-1 + sqrt(1 + 8 * N)) / 2);
}
void factorize(bigint N ){
    for( bigint i = 2 ; i * i <= N ; i++ ){
        while( N % i == 0 ){
            m[i]++ ;
            N /= i ;
        }
    }
    if( N > 1 )
        m[N]++ ;
}
int main(){
    bigint N ; cin >> N ;
    factorize(N) ;
    int ans = 0 ;
    for( auto x : m ){
        ans += ( count1(x.second)) ;
    }
    cout << ans << endl ;
    return 0 ;
}



Measured memory_bytes: 3656
def calc(n):
    if (n <= 0): return 0
    ret = 0
    n += 1
    for i in range(1, 50):
        l = 1 << i
        # cnt := 1の個数
        cnt = (n // l) * (l // 2)
        cnt += max(0, (n % l) - (l // 2) )            
        if (cnt % 2 == 1):
            # print(n, i, l, cnt, 1 << i-1)
            ret += (1 << (i-1))
    return ret

A, B = [int(x) for x in input().split()]
ans = calc(A-1) ^ calc(B)
print(ans)



Measured memory_bytes: 38384
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.print(a* b);
        System.out.print(" ");
        System.out.println(2*(a+b));

    }
}


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

typedef long long ll;

int main() {
	ll n, a, b, ans;
	cin >> n >> a >> b;
	ans = (n / (a + b)) * a + min(a, n % (a + b));
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int N = IN();
	OUT(N*(N + 1) / 2);
	return 0;
}

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

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

    int numbers[length];
    for (int i = 0; i < length; i++) {
        cin >> numbers[i];
    }

    int count = 0;
    while (1) {
        bool ok = true;
        for (int i = 0; i < length; i++) {
            if (numbers[i] % 2 != 0) {
                ok = false;
                break;
            }
            numbers[i] = numbers[i] / 2;
        }
        if (!ok) {
            break;
        }
        count++;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
inline void shoki()
{
	srand((unsigned int)time(NULL));
}

/*Library End!*/
int n, a[100007];
pair<int, int>p1[100007];
pair<int, int>p2[100007];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i % 2) {
			p1[a[i]].first++;
			p1[a[i]].second = a[i];
		}
		else {
			p2[a[i]].first++;
			p2[a[i]].second = a[i];
		}
	}
	sort(p1, p1 + 100005);
	sort(p2, p2 + 100005);
	if (p1[100004].second != p2[100004].second)cout << n - (p1[100004].first + p2[100004].first) << endl;
	else cout << n - (max(p1[100003].first + p2[100004].first, p1[100004].first + p2[100003].first)) << endl;
end:;
	system("PAUSE");
	return 0;
}



Measured memory_bytes: 4344
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;

const long long int INF=1000000000000000000;

int main(){
	//freopen("Knapcak.out","w",stdout);
	int N,W;
	cin>>N>>W;
	vector<long long int>Value(N+10);
	vector<long long int>Weight(N+10);
	int i,j;
	for(i=1;i<=N;i++){
		cin>>Weight[i]>>Value[i];
	}
	vector<vector<long long int>>DP(N+10,vector<long long int>(100005,INF));
	DP[0][0]=0LL;
	for(i=1;i<=N;i++){
		for(j=0;j<100005;j++){
			if(j-Value[i]<0){
				DP[i][j]=min(DP[i-1][j],Weight[i]);
			}
			else{
				DP[i][j]=min(DP[i-1][j],DP[i-1][j-Value[i]]+Weight[i]);
			}
		}
	}
	/*for(i=0;i<=N;i++){
		for(j=0;j<100;j++){
			cout<<"DP["<<i<<"]["<<j<<"]="<<DP[i][j]<<endl;
		}
	}*/
	int result=0;
	for(j=0;j<100005;j++){
		//cout<<result<<endl;
		if(DP[N][j]<=W){
			result=max(result,j);
		}
	}
	cout<<result;
	return 0;
}


Measured memory_bytes: 87296
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL r;
    LL c;
    LL k;
    cin >> r >> c >> k;
    vector<vector<LL>> v(r, vector<LL>(c, 0));
    LL tmp_r;
    LL tmp_c;
    LL tmp_v;
    for(LL i=0; i<k; i++){
        cin >> tmp_r >> tmp_c >> tmp_v;
        tmp_r--;
        tmp_c--;
        v[tmp_r][tmp_c]=tmp_v;
    }
    vector<vector<vector<LL>>> dp(r, vector<vector<LL>>(c,vector<LL>(4,0)));
    dp[0][0][1]=dp[0][0][0]+v[0][0];
    for(LL i=0; i<r; i++){
        for(LL j=0; j<c; j++){
            for(LL k=0; k<4; k++){
                if(i!=0){
                    dp[i][j][0]=max(dp[i][j][0], dp[i-1][j][k]);
                    if(v[i][j]!=0){
                        dp[i][j][1]=max(dp[i][j][1], dp[i-1][j][k]+v[i][j]);
                    }
                }
                if(j!=0){
                    dp[i][j][k]=max(dp[i][j][k], dp[i][j-1][k]);
                    if(v[i][j]!=0 && k>=1){
                        dp[i][j][k]=max(dp[i][j][k], dp[i][j-1][k-1]+v[i][j]);
                    }
                }
            }
        }
    }

    LL max_ans=0;
    for(LL i=0; i<4; i++){
        max_ans=max(max_ans, dp[r-1][c-1][i]);
    }

    cout << max_ans << endl;

    return 0;
}


Measured memory_bytes: 706740