akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static void solve(InputReader in, PrintWriter out) {
      int a = in.nextInt();
      out.println(a + a * a + a * a * a);
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

      public String nextToken() {
         while (st == null || !st.hasMoreTokens()) {
            try {
               st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }
         return st.nextToken();
      }

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

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

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

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


Measured memory_bytes: 32964
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
struct node{
	int x,y;
}a[20005];
vector<int> vec[20005];
int n,k,x,y,ans,sum;
int dfs(int pos,int fa,int dep){
	if(dep>k/2)	sum++;
	for(int i=0;i<vec[pos].size();i++){
		if(vec[pos][i]==fa) continue;
		dfs(vec[pos][i],pos,dep+1);
	}
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		a[i].x=x;a[i].y=y;
		vec[x].push_back(y);
		vec[y].push_back(x);
	}ans=n;
	if(!(k%2)){
		for(int i=1;i<=n;i++){
			sum=0;
			dfs(i,-1,0);
			ans=min(ans,sum);
		}
	}
	else{
		for(int i=1;i<n;i++){
			sum=0;
			dfs(a[i].x,a[i].y,0);
			dfs(a[i].y,a[i].x,0);
			ans=min(ans,sum);
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i,l,r) for(ll i=(l); i<(r); i++)
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; }
const ll INF = 1LL << 60;
const int inf = 1001001001;
const ll mod = 1000000007;
using pp=pair<ll,ll>;
 
// union by size + path having
class UnionFind {
public:
   vector <ll> par; // 各元の親を表す配列
   vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
   // Constructor
   UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
       for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
   }
   void init(ll sz_) {
       par.resize(sz_);
       siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
       for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
  }
 
   // Member Function
   // Find
   ll root(ll x) { // 根の検索
      while (par[x] != x) {
           x = par[x] = par[par[x]]; // x の親の親を x の親とする
       }
       return x;
  }
 
   // Union(Unite, Merge)
   bool unite(ll x, ll y) {
       x = root(x);
       y = root(y);
       if (x == y) return false;
       // merge technique（データ構造をマージするテク．小を大にくっつける)
       if (siz[x] < siz[y]) swap(x, y);
       siz[x] += siz[y];
       par[y] = x;
       return true;
  }
 
  bool same(ll x, ll y) { // 連結判定
       return root(x) == root(y);
  }
 
  ll size(ll x) { // 素集合のサイズ
      return siz[root(x)];
  }
};
 
ll modpow(ll x, ll n) {
   x = x%mod;
   if(n==0) return 1;  //再帰の終了条件
 
   else if(n%2==1) {
       return (x*modpow(x, n-1))%mod;  //nが奇数ならnを1ずらす
   }
   else return modpow((x*x)%mod, n/2)%mod;  //nが偶数ならnが半分になる
}
 
ll com(ll n, ll k) {
   ll x = 1;
   for(int i=n-k+1; i<=n; i++) {
      x = x*i%mod;
   }
 
   ll y = 1;
   for(int i=1; i<=k; i++) {
       y = y*i%mod;
   }
   y = modpow(y, mod-2);
 
   return x*y%mod;
}
 
bool is_prime(const unsigned n){
   switch(n){
       case 0: // fall-through
       case 1: return false;
       case 2: // fall-through
       case 3: return true;
  } // n > 3 が保証された
 
   if(n % 2 == 0 || n % 3 == 0) return false;
   // n は 2 と 3 のいずれの倍数でもないことが保証された
   // これより n は (6の倍数)-1 か (6の倍数)+1 である
 
   // 6の倍数前後の数を使って試し割りをする
   for(unsigned i = 5; i * i <= n; i += 6) {
       if(n % i     == 0) return false; // (6の倍数)-1
       if(n % (i+2) == 0) return false; // (6の倍数)+1
   }
 
   return true;
}
 
int digsum(int n) {
   int res = 0;
   while(n > 0) {
       res += n%10; //ここをres++;に変えたら桁数を求める関数になる
       n /= 10;
   }
   return res;
}
vector<ll> divisor(ll n){
   vector<ll> ret;
   for(ll i = 1 ; i*i <= n ; i++){
       if(n%i == 0){
           ret.push_back(i);
           if(i*i != n) ret.push_back(n/i);
       }
   }
   sort(ret.begin(),ret.end());
   return ret;
}
 
int main(){

    ll n;
    cin >> n;
    vector<ll> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cout << a[n-1] << endl;
 
}

Measured memory_bytes: 256
class Main{
	public static void main(String[]$){
		String v=new java.util.Scanner(System.in).next();
		for(int i=v.length();i>0;--i){
			if(v.replaceAll(v.substring(0,i),"#").matches("##.+")){
				System.out.println(i*2);
				return;
			}
		}
	}
}


Measured memory_bytes: 21844
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : a : b : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print $ min (n * a) b

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
import java.util.*;
import java.io.*;
import java.text.*;
import java.util.zip.Adler32;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int x = sc.nextInt();
        pw.println(x+x*x+x*x*x);
        pw.flush();
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < arr.length; i++)
                arr[i] = nextInt();
            return arr;
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}

Measured memory_bytes: 32900
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool isset(int n, int k) 
{ 
    return (n&(1<<k));
} 
signed main()
{
    int n,m,k,y,z,answer=0,i,j;
    cin>>n>>m>>k;
    char a[n][m];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        cin>>a[i][j];
    }
    int r=pow(2,n),c=pow(2,m);
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            int count=0;
            for(y=0;y<n;y++)
            {
                for(z=0;z<m;z++)
                {
                    if(isset(i,y) || isset(j,z))
                    continue;
                    if(a[y][z]=='#')
                    count++;
                }
            }
            if(count==k)
            answer++;
        }
    }
    cout<<answer;
    return 0;
}

Measured memory_bytes: 4088
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	int n, x, i, j, k, num;

	while(1){
		//input
		cin >> n >> x;

		//init
		num = 0;
		for(i = 1; i <= n; i++){
			for(j = (i + 1); j <= n; j++){
				for(k = (j + 1); k <= n; k++){
					if((i + j + k) == x){
						//hit
						num++; 
						break;
					}
				}
			}
		}

		//end condition
		if(n == 0 && x == 0){
			break;
		}
		else{
			//output
			cout << num << endl;
		}
	}

	return 0;

}

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

int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll> A(N),F(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>F.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  sort(F.begin(),F.end());

  ll left=0;
  ll right=1000000000000;
  ll x;
  while(left+1<right){
    x=(left+right)/2;
    ll count=0;
    for(int i=0;i<N;i++){
      count+=max<ll>(A.at(i)-x/F.at(i),0);
    }
    if(count<=K){
      right=x;
    }else{
      left=x;
    }
  }

  x=(left+right)/2;
  ll count=0;
  for(int i=0;i<N;i++){
    count+=max<ll>(A.at(i)-x/F.at(i),0);
  }
  if(count<=K){
    right=x;
  }else{
    left=x;
  }

  cout<<right<<endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    int a,b,c,n,x,y,z,cnt=0,sum=0;
    string str;
    cin>>n;
    int arr[n];
    for(int i=1; i<=n; i++)cin>>arr[i];
    for(int i=1; i<=n; i++)
    {
        if(i%2!=0 && arr[i]%2!=0)cnt++;
    }
    cout<<cnt<<endl;

}



Measured memory_bytes: 3568
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  rep(i,N) cin >> H[i];
  sort(H.rbegin(), H.rend());
  ll res = 0;
  for (int i = K; i < N; i++) {
    res += H[i];
  }
  cout << res << endl;
  return 0;
}


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

const long double PI = M_PI;

long double max_volume(long double a, long double b, long double theta) {
    if (theta >= PI / 2) {
        return 0.0;
    }

    if (a * tan(theta) > b) {
        return a * b * b / tan(theta) / 2.0;
    } else {
        return a * a * b - a * a * a * tan(theta) / 2.0;
    }
}

int main() {
    long double a, b, x;
    cin >> a >> b >> x;
    
    long double left = 0.0;
    long double right = PI / 2.0;
    for (int i = 0; i < 100000; i++) {
        long double mid = (left + right) / 2.0;
        if (max_volume(a, b, mid) > x) {
            left = mid;
        } else {
            right = mid;
        }
    }

    long double ans = right * 180 / PI;
    printf("%.10Lf\n", ans);

    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

// const long long INF = 1LL << 60;

template <typename T>
struct Edge {
  int to;
  T cost;
};

// Dijkstra
template <typename T>
class Dijkstra {
 private:
  vector<vector<Edge<T>>> G;
  int num_v;

 public:
  Dijkstra(int num_v) : G(num_v), num_v(num_v) {
  }

  void add_edge(int from, int to, T cost) {
    G[from].push_back((Edge<T>){to, cost});
  }

  // start: Start point
  // result: result
  void solve(int start, vector<T>& result) {
    vector<int> tmp;
    solve(start, result, tmp);
  }

  void solve(int start, vector<T>& result, vector<int>& prev) {
    result.resize(num_v, INF);
    prev.resize(num_v, -1);

    // get<0>(T): cost
    // get<1>(T): index
    // get<2>(T): ... ( for extent)
    using Tup = tuple<T, int>;
    priority_queue<Tup, vector<Tup>, greater<Tup>> que;

    que.emplace(0, start);
    result[start] = 0;

    while (!que.empty()) {
      Tup p = que.top();
      que.pop();

      T t = get<0>(p);
      int v = get<1>(p);

      // queueに入れてから別の最短経路が見つかった場合、探索処理は不要
      if (result[v] != t) {
        continue;
      }

      // vの各辺に対しよりコストの低い経路があるかを確認
      for (auto& e : G[v]) {
        if (result[e.to] > result[v] + e.cost) {
          prev[e.to] = v;
          result[e.to] = result[v] + e.cost;
          que.emplace(result[v] + e.cost, e.to);
        }
      }
    }
  }

  // t: 目的地
  vector<int> get_path(const vector<int>& prev, int t) {
    vector<int> path;

    for (int v = t; v != -1; v = prev[v]) {
      path.push_back(v);
    }

    reverse(path.begin(), path.end());
    return path;
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, m;
  cin >> n >> m;

  Dijkstra<ll> d(n + m + 1);

  rep(i, n) {
    ll k;
    cin >> k;
    rep(j, k) {
      ll l;
      cin >> l;
      d.add_edge(i, n + l, 0);
      d.add_edge(n + l, i, 0);
    }
  }
  vll res;
  d.solve(0, res);
  rep(i, n) {
    if (res[i] != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 15088
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N;
  cin >> N;
  ll a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  ll m = (N * (N+1LL)) / 2LL;
  m += 1LL;
  m /= 2LL;
  ll left = -1;
  ll right = Mod * 2;
  while (right - left > 1LL) {
    ll mid = (left + right) / 2LL;
    ll R[N+1];
    // 450個ごと　平方分割
    // -200000 ~ 200000
    vector<ll> num(400001);
    vector<ll> B(888);
    ll sum = 0;
    R[0] = 0;
    for (int i = 0; i < N; i++) {
      if (a[i] >= mid) {
        R[i+1] = R[i] + 1;
      } else {
        R[i+1] = R[i] - 1; 
      }
    }
    num[200000]++;
    B[200000/450]++;
    
    for (ll i = 0; i < N; i++) {
      ll l = (R[i+1] + 200000) / 450;
      ll s = 0;
      for (ll j = 0; j < l; j++) {
        s += B[j];
      }
      for (ll j = l * 450; j <= (R[i+1] + 200000); j++) {
        s += num[j];
      }
      sum += s;
      num[R[i+1]+200000]++;
      B[(R[i+1]+200000)/450]++;
    }
    if (sum >= m) {
      left = mid;
    } else {
      right = mid;
    }
  }
  cout << left << endl;
  return 0;
}

Measured memory_bytes: 8316
# vim: fileencoding=utf-8


def main():
    n, y = map(int, input().split())
    maxA = min(n, y // 10000)
    maxB = min(n, y // 5000)
    for i in range(maxA, -1, -1):
        t = y - 10000 * i
        if t == 0:
            if n == i:
                print(f"{i} 0 0")
                return
            continue
        for j in range(min(maxB, n - i), -1, -1):
            tt = t
            tt -= 5000 * j
            if tt == 0:
                if n == i + j:
                    print(f"{i} {j} 0")
                    return
            if tt > 0 and tt == (n - (i + j)) * 1000:
                print(f"{i} {j} {n-(i+j)}")
                return
    print("-1 -1 -1")


if __name__ == "__main__":
    main()


Measured memory_bytes: 67596
#include <stdio.h>

int n;
int num[100010];

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

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include<iomanip>
#include<limits>
#include <utility>
typedef long long lint;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e18

int ans2 = 0;
signed main()
{
	// 
	int A,B;
	cin >> A >> B;

	int ans = 0;
	if (A <= 5) ans = 0;
	else if (A <= 12) ans = (B/2);
	else ans = B;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    
    int a,b,c;
    cin>>a>>b>>c;
    if((b-a)==(c-b)){puts("YES");}else{puts("NO");}
return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class A
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int H = int.Parse(s[0]);
        int N = int.Parse(s[1]);
        int count = 0;

        string[] ss = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++)
        {
            count += int.Parse(ss[i]);
        }

        if (count >= H)
        {
            Console.WriteLine("Yes");
            return;
        }

        Console.WriteLine("No");
    }
}

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

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;

    int ans = 0;
    for (size_t i = 0; i < s.size(); i++) {
        if (s[i] == 'R') {
            if (i > 0 && s[i-1] == 'R') {
                ++ans;
            }else{
                ans = 1;
            }
        }
    }

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


Measured memory_bytes: 3632
from sys import stdin
import bisect
import math

n,m = [int(x) for x in stdin.readline().rstrip().split()]
a,b = [],[]
for i in range(n):
    x,y = [int(x) for x in stdin.readline().rstrip().split()]
    a.append(x)
    b.append(y)
a.sort()
b.sort()
max_a = a[-1]
li = b[bisect.bisect_left(b,max_a):]

damage = 0
point = 0

while True:
    if li:
        damage += li.pop()
        point += 1
    else:
        break
    if damage >= m:
        print(point)
        exit()

point += math.ceil((m-damage)/max_a)
print(point)






Measured memory_bytes: 11988
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int n;
pair<int, int>ta[100000];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ta[i].first >> ta[i].second;
	}
	sort(ta, ta + n);
	cout << ta[n - 1].first + ta[n - 1].second << endl;
	return 0;
}

Measured memory_bytes: 1024
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    A, B, C, D = map(int, input().split())

    if A * B <= C * D:
        print(C * D)
    else:
        print(A * B)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10376
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
    double x1,x2,y1,y2,p1p2;
    cin >> x1 >> x2 >> y1 >> y2;
    p1p2 = sqrt(pow((y1-x1), 2) + pow((y2-x2), 2));
    
    cout << fixed << setprecision(15) << p1p2 << "\n";
    
    return 0;
}


Measured memory_bytes: 3296
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;

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

ll maxVec(vector<ll> &v) {
	ll ans = -INF;
	rep(i, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}


int main() {
	ll h, w;
	char s;
	cin >> h >> w;
	vvl table = vvl(h, vl(w, 0));
	vvl dp = vvl(h, vl(w, 0));
	dp[0][0] = 1;
	rep(i, h) {
		rep(j, w) {
			cin >> s;
			if (s == '#')table[i][j] = 1;
			else table[i][j] = 0;
		}
	}

	rep(i, h) {
		rep(j, w) {
			if (i != h - 1 && table[i + 1][j] == 0) {
				dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
			}
			if (j != w - 1 && table[i][j + 1] == 0) {
				dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MOD;
			}
		}
	}
	cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 16000
n, k = map(int, input().split())
if n == 0 or k == 1:
    print(0)
    exit()
elif n < k:
    print(min(n ,abs(n-k)))
    exit()
elif n % k == 0:
    print(0)
    exit()
else:
    max = n % k

print(min(abs(max-k), max))


Measured memory_bytes: 2940
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	std::string s;
	std::cin >> s;
	int n = s.size();
	std::vector<std::vector<int> > r(n,std::vector<int>(2,0));
	rep(i,n) if(s[i]=='R') r[i][0] = 1;

	std::vector<std::vector<int> > l(n,std::vector<int>(2,0));
	rep(i,n) if(s[i]=='L') l[i][0] = 1;

	rep(i,n) {
		if(s[i]=='R') {
			r[i+1][0] += r[i][1];
			r[i+1][1] += r[i][0];
			rep(x,2) r[i][x]=0;
		}
	}
	rep(j,n) {
		int i = n-1-j;
		if(s[i]=='L') {
			l[i-1][0] += l[i][1];
			l[i-1][1] += l[i][0];
			rep(x,2) l[i][x]=0;
		}
	}
	rep(i,n) {
		if(s[i]=='L') {
			r[i-1][0] += r[i][1];
		}
	}
	rep(j,n) {
		int i = n-1-j;
		if(s[i]=='R') {
			l[i+1][0] += l[i][1];
		}
	}
	
	rep(i,n) {
		std::cout << r[i][0]+l[i][0] << ' ';
	}
	return 0;
}


Measured memory_bytes: 11520
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    // 整数の入力
    int N, M;
    scanf("%d %d", &N, &M);
    int L, R;
    int min, max;
    scanf("%d %d", &min, &max);

    for(int i=0; i < M-1; i++){
        scanf("%d %d", &L, &R);
        if(min < L)
            min = L;
        if(R < max)
            max = R;
        
        if(min > R || max < L){
            min = -1;
            max = -1;
            break;
        }
    }


    // 出力
    if(min==-1 && max==-1)
        cout << 0 << endl;
    else
        cout << max - min + 1 << endl;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int pls(int x,int sign){
    if(!sign)return x;
    else return x*(-1);
}

char sign(int i){
    if(!i)return '+';
    else return '-';
}

int main(){

    string s;
    cin >> s;

    int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
    bool flg=false;
    REP(i,2){
        REP(j,2){
            REP(k,2){
                if(a+pls(b,i)+pls(c,j)+pls(d,k)==7){
                    cout <<a<<sign(i)<<b<<sign(j)<<c<<sign(k)<<d<<"=7"<<endl;
                    return 0;
                }
            }
        }
    }

}


Measured memory_bytes: 256
program abc13
 implicit none
 integer,allocatable::a(:)
 integer::X,N,ia,b=0,ib=1,ic,c,d,s=0,id,ie=0
 read(*,*)X,N
 allocate(a(N))
 read(*,*)(a(ia),ia=1,N)
 do id=1,N
  if(X==a(id))then
   ie=1
  end if
 end do
 if(ie==0)then
  print'(i0)',X
  stop
 end if
 do while(b==0)
  c=0
  d=0
  do ic=1,N
   if(X+ib==a(ic))then
    c=1
   end if
   if(X-ib==a(ic))then
    d=1
   end if
  end do
  if(d==0)then
   s=X-ib
  else if(c==0)then
   s=X+ib
  end if
  if(c==0.or.d==0)then
   b=1
  end if
  ib=ib+1
 end do
 print'(i0)',s
end program abc13

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

using namespace std;

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);


struct P{
  double x, y;
};

bool operator<(const P& p1, const P& p2){
  return p1.x+EPS < p2.x || (abs(p1.x - p2.x) < EPS && p1.y+EPS < p2.y);
}

P operator-(const P& p1, const P& p2){
  P d;
  d.x = p1.x - p2.x;
  d.y = p1.y - p2.y;
  return d;
}

bool operator==(const P& p1, const P& p2){
  return abs(p1.x - p2.x) < EPS && abs(p1.y - p2.y) < EPS;
}

double cross(const P& p1, const P& p2){
  return p1.x * p2.y - p1.y * p2.x;
}

bool is_intersect(P& p11, P& p12, P& p21, P& p22){
  return (cross(p12-p11, p21-p11) * cross(p12-p11, p22-p11) < 0)
	&& (cross(p22-p21, p11-p21) * cross(p22-p21, p12-p21) < 0); 
}

P calc_intersect(P& p11, P& p12, P& p21, P& p22){
  P d = p22 - p21;
  double t1 = abs(cross(d, p11-p21));
  double t2 = abs(cross(d, p12-p21));
  double t = t1 / (t1 + t2);
  P p1 = p12 - p11;
  p1.x *= t, p1.y *= t;
  P p = p11;
  p.x += p1.x, p.y += p1.y;
  return p;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int N;
  while(cin>>N,N){
	int ans = 1;
	vector< pair<P,P> > ps(N);
	REP(i,N){
	  cin >> ps[i].first.x >> ps[i].first.y >> ps[i].second.x >> ps[i].second.y;
	  int cnt = 0;
	  set<P> intersects;
	  REP(j,i)
		if(is_intersect(ps[j].first, ps[j].second,
						ps[i].first, ps[i].second)){
		  P in = calc_intersect(ps[j].first, ps[j].second,
								ps[i].first, ps[i].second);
		  if(!intersects.count(in)){
			intersects.insert(in);
			++cnt;
		  }
		}

	  ans += cnt+1;
	}
	cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int c11,c12,c13,c21,c22,c23,c31,c32,c33;
    cin >> c11;
    cin >> c12;
    cin >> c13;
    cin >> c21;
    cin >> c22;
    cin >> c23;
    cin >> c31;
    cin >> c32;
    cin >> c33;
    int a1,a2,a3,b1,b2,b3;
    a1 = 0;
    b1 = c11;
    b2 = c12;
    b3 = c13;
    a2 = c21-b1;
    a3 = c31 - b1;
    bool ok = true;
    if (c11 != a1 + b1){
        ok = false;
    }
    if (c12 != a1 + b2){
        ok = false;
    }
    if (c13 != a1 + b3){
        ok = false;
    }
    if (c21 != a2 + b1){
        ok = false;
    }
    if (c22 != a2 + b2){
        ok = false;
    }
    if (c23 != a2 + b3){
        ok = false;
    }
    if (c31 != a3 + b1){
        ok = false;
    }
    if (c32 != a3 + b2){
        ok = false;
    }
    if (c33 != a3 + b3){
        ok = false;
    }
    if (ok){
        cout <<"Yes" << endl;
    }else{
        cout << "No" << endl;
    } 


    
}

Measured memory_bytes: 256
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}


ll take_gcd(ll a, ll b)
{
    // cout << a << ' ' << b << endl;
    if (a>b) swap(a, b);
    if (b%a == 0) return a;
    else return take_gcd(a, b%a);
}
int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    ll d = abs(c - a - b);

    ll e = a*b;
    ll gcd = take_gcd(d, e);
    // cout << e << ' ' << a * b << ' ' << gcd << endl;
    d /= gcd;
    e /= gcd;

    // cout << e << ' ' << d << ' ' << gcd << endl;
    if (4*e<d*d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
 
int main(){
  string N;
  cin>>N;
  int K;
  cin>>K;
  ll B[N.size()][8]={};
  if(N.size()<K) cout<<0<<endl;
  else{
    B[0][1]=1;
    B[0][2]=1;
    B[0][3]=N[0]-'1';
    rep(i,N.size()-1){
      rep(j,8){
        if(j%2){
          B[i+1][j]+=B[i][j];
          if(j!=1) B[i+1][j]+=B[i][j-2]*9;
        }
      }
      if(N[i+1]=='0'){
        rep(j,8) if(j%2==0) B[i+1][j]+=B[i][j];
      }else{
        rep(j,8){
          if(j%2==0){
            B[i+1][j+1]+=B[i][j];
            if(j!=6){
              B[i+1][j+2]+=B[i][j];
              B[i+1][j+3]+=B[i][j]*(N[i+1]-'1');
            }
          }
        }
      }
    }
    cout<<B[N.size()-1][K*2]+B[N.size()-1][K*2+1]<<endl;
  }
}

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


int main(){
   
    ll n;
    cin >> n;
    if(n%2 * n%5 == 0)
    {
        cout << -1;
    }
    else{
        ll k = 7;
        ll a = 1;
        while(k%n != 0)
        {
            k = (k*10 + 7)%n;
            a++;
        }
        cout << a << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 3588
import sys
input = sys.stdin.readline  #文字列入力では注意！
from bisect import bisect
N = int(input())
XL = [list(map(int,input().split())) for _ in range(N)]
S = []
for x,l in XL:
    S.append([x-l,x+l])

S.sort(key=lambda x: x[1])
ans = 1
mi = S[0][1]
for i in range(1,N):
    if mi <= S[i][0]:
        mi = S[i][1]
        ans += 1
print(ans)

Measured memory_bytes: 42664
#include <stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(r<=x&&x<=W-r&&r<=y&&y<=H-r)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
/// a.cpp
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < decltype(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < pll >
# define pb push_back
# define pdd pair < db , db >
# define all(s) s.begin(),s.end()
//# define CF
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
inline int readChar();
template <class T = int> inline T readInt();
template <class T> inline void writeInt( T x, char end = 0 );
inline void writeChar( int x );
inline void writeWord( const char *s );
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(__rdtsc());
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int a,b,c,d;
    fi>>a>>b>>c>>d;
    smin(b,a + a);
    smin(c,b + b);
    smin(d,c + c);
    int n;
    fi>>n;
    fo << (1ll * (n / 2) * d + 1ll * (n & 1) * c) << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}
/** Read */

static const int buf_size = 4096;

inline int getChar()
{
    static char buf[buf_size];
    static int len = 0, pos = 0;
    if (pos == len)
        pos = 0, len = fread(buf, 1, buf_size, stdin);
    if (pos == len)
        return -1;
    return buf[pos++];
}

inline int readChar()
{
    int c = getChar();
    while (c <= 32)
        c = getChar();
    return c;
}

template <class T>
inline T readInt()
{
    int s = 1, c = readChar();
    T x = 0;
    if (c == '-')
        s = -1, c = getChar();
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    return s == 1 ? x : -x;
}

/** Write */

static int write_pos = 0;
static char write_buf[buf_size];

inline void writeChar( int x )
{
    if (write_pos == buf_size)
        fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
    write_buf[write_pos++] = x;
}

template <class T>
inline void writeInt( T x, char end )
{
    if (x < 0)
        writeChar('-'), x = -x;

    char s[24];
    int n = 0;
    while (x || !n)
        s[n++] = '0' + x % 10, x /= 10;
    while (n--)
        writeChar(s[n]);
    if (end)
        writeChar(end);
}

inline void writeWord( const char *s )
{
    while (*s)
        writeChar(*s++);
}

struct Flusher
{
    ~Flusher()
    {
        if (write_pos)
            fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
    }
} flusher;


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string O, E;
    cin >> O >> E;
    
    string ans = "";
    rep(i, E.size()) {
        ans.push_back(O[i]);
        ans.push_back(E[i]);
    }
    if (E.size() < O.size()) ans.push_back(O.back());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ts: List<Town> = (1..n).map {
        val map = readLine()!!.split(" ").map { it.toInt() }
        Town(map[0], map[1])
    }

    var sum: Double = 0.0
    for (s in (0 until (ts.size - 1))) {
        for (e in (s until ts.size)) {
            val length: Double = length(ts[s], ts[e])
            sum += length
        }
    }

    println(sum * 2 / n)

}

fun length(a: Town, b: Town): Double {
    val x = (a.x - b.x)
    val y = (a.y - b.y)
    return Math.sqrt(x * x + y * y * 1.0)
}

data class Town(val x: Int, val y: Int)


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

int main()
{
  int a, b, c, k, ans;
  cin >> a >> b >> c >> k;
  ans = min(a, k);
  k -= a;
  if (0 < k)
    k -= b;
  if (0 < k)
  {
    ans -= k;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    ll sum = 0;
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }
    set<ll> candidates;
    for(int i=1;i*i<=sum;i++){
        if(sum%i == 0){
            candidates.insert(i);
            candidates.insert(sum/i);
        }
    }
    ll ans = 1;
    for(ll x : candidates){
        ll cnt = LINF;;
        vector<ll> r(n);
        REP(i,n) r[i] = a[i] % x;
        sort(r.begin(),r.end());
        ll B = 0;
        REP(i,n) B += x-r[i];
        ll A = 0;
        REP(i,n){
            A += r[i];
            B -= x-r[i];
            cnt = min(cnt,max(A,B));
        }
        if(cnt <= k) ans = max(ans,x);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#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>;


int main() {
    int N, K;
    double tmp;
    cin >> N >> K;
    vector<double> p(N);
    rep(i,N) {
        cin >> tmp;
        p.at(i) = (tmp + 1.0) / 2.0;
    }
    double sum = 0;
    vector<double> S(N+1);
    rep(i,N) {
        sum += p.at(i);
        S.at(i+1) = sum;
    }
    double ans = 0;
    rep(i,N-K+1) {
        ans = max(ans, S.at(i+K) - S.at(i));
    }
    cout << fixed << setprecision(1) << ans << endl;
}


Measured memory_bytes: 6464
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int s1 = sc.nextInt();
   int s3 = sc.nextInt();
   
   if(s1==s3)System.out.println("Draw");
   else if(s1==1)System.out.println("Alice");
   else if(s3==1)System.out.println("Bob");
   else if(s1>s3)System.out.println("Alice");
   else System.out.println("Bob");
 }
}

Measured memory_bytes: 21972
#-*-coding:utf-8-*-

def main():
    while True:
        a,op,b = input().split()
        if op=="?":
            break
        else:
            if op=="+":
                print(int(a)+int(b))
            elif op=="-":
                print(int(a)-int(b))
            elif op=="*":
                print(int(a)*int(b))
            else:
                print(int(a)//int(b))

if __name__=="__main__":
    main()


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

int main(){
 long long int n;
   cin>>n;
  if(n%2) cout<<0<<endl;
    else{
        n/=2;
        long long int ans=0;
  while(n>0){
      n/=5;
          ans +=n;
  }
  cout<<ans<<endl;
    }
     return 0;
}
  


Measured memory_bytes: 256
N, Y = (list)(map(int, input().split()))

Y /= 1000


def search(N, Y):
    for i in range(N+1):
        for j in range(N+1-i):
            if 10*i+5*j+(N-i-j) == Y:
                return [i, j, N-i-j]
    return [-1, -1, -1]


print(' '.join(list(map(str, search(N, Y)))))


Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var a,b,c,k int
  	fmt.Scan(&a,&b,&c,&k)
  
  max := a
  if max < b {
  	max = b
  }
  if max < c {
  	max = c
  }
  sum := a + b + c
  for i := 0; i < k; i++ {
  	sum += max
    max = max * 2
  }
  fmt.Println(sum)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ld, ld> pld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <ld> vld;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef set <ld> sld;
typedef set <ll> sll;
typedef set <pll> spll;
typedef char ch;
typedef string str;
typedef tree <int,
            null_type,
            less<int>,
            rb_tree_tag,
            tree_order_statistics_node_update> super_set;
const ll DIM = 1*1e5+7;
const ll MODULO = 1e9+7;
const ld INF = 1e9;
const ld eps = 1e-9;
const ld pi = acos(-1.0);
const ld e = pow(1.0 + 1.0/INF, INF);
const ld gr = (1.0+sqrt(5.0))/2.0;
const ld alpha0 = 2*cos(pi/8)/(1+cos(pi/8));
const ld beta0 = 2*sin(pi/8)/(1+cos(pi/8));
ll n,a[DIM],F[DIM];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //freopen("paintbarn.in", "r", stdin);
    //freopen("paintbarn.out", "w", stdout);

    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    F[1] = 0;
    F[2] = abs(a[2]-a[1]);
    for (int i = 3; i <= n; i++) {
        if (F[i-1] + abs(a[i-1]-a[i]) < F[i-2] + abs(a[i-2]-a[i]))
            F[i] = F[i-1] + abs(a[i-1]-a[i]);
        else
            F[i] = F[i-2] + abs(a[i-2]-a[i]);
        //cout << F[i] << endl;
    }
    cout << F[n] << endl;
    return 0;
}
///if (dist[v]+dd < dist[to]) dist[to] = dist[v]+dd;


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

typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

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

const int NM = 2 * 1e5+1;
ll h[NM];
//vector<ll> h;

int main(){
    ll n, k; cin >> n >> k;
    rep(i, n){
        cin >> h[i];
    }
    if(n <= k){
        cout << 0 << endl;
        return 0;
    }

    sort(h, h+n);
    ll cnt=0;
    for(int i=0; i<n-k; i++){
        cnt+=h[i];
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
	int n,m,t =0 ;
	cin >>n;
  	m = n;
	while(n>9) {
    	t *= 100;
      	t += 9;
      	n /= 100;
    }
 	if (to_string(m).length() % 2 != 0) {
    	t += (m - pow(10, to_string(m).length()-1))+1; 
    }
	cout << t << endl;
	
}

Measured memory_bytes: 256
s=input()+"R"

ans=[0]*(len(s)-1)
r_num=0
l_num=0
r_place=0
l_place=0

for i in range(1,len(s)):
    if s[i-1]=="R" and s[i]=="L":
        r_num+=1
        r_place=i-1
        l_place=i
        ans[r_place]+=r_num-r_num//2
        ans[l_place]+=r_num//2
    elif s[i-1]==s[i] and s[i-1]=="R":
        r_num+=1
    elif s[i-1]==s[i] and s[i-1]=="L":
        l_num+=1
    elif s[i-1]=="L" and s[i]=="R":
        l_num+=1
        ans[r_place]+=l_num//2
        ans[l_place]+=l_num-l_num//2
        r_num=0
        l_num=0
print(*ans)

Measured memory_bytes: 6400
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let s: Vec<char> = buf.chars().collect();

    if s[0] == s[1] || s[1] == s[2] || s[2] == s[3] {
        println!("Bad");
    }
    else {
        println!("Good");
    }
}


Measured memory_bytes: 4352
N = int(input())

S = (1+N)*N//2

fizz = (3+(N//3)*3)*(N//3)//2
buzz = (5+(N//5)*5)*(N//5)//2
fizzbuzz = (15+(N//15)*15)*(N//15)//2

print(S-fizz-buzz+fizzbuzz)

Measured memory_bytes: 9188
n,k=map(int,input().split())
stack=[0]*(2*10**5+1)
a=list(map(int,input().split()))
num=len(set(a))
for i in a:
  stack[i]+=1
stack.sort()
def binarysearch():
  ng=-1
  ok=2*10**5+1
  while abs(ng-ok)>1:
    mid=(ng+ok)//2
    if stack[mid]==0:
      ng=mid
    else:
      ok=mid
  return ok
p=binarysearch()
ans=0
if num<=k:
  print(0)
  exit()
for i in range(num-k):
  ans+=stack[p+i]
print(ans)
  

Measured memory_bytes: 27392
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      a: i64,
      b: i64,
    }
    let mut ans = a +b;
    ans = max(a-b, ans);
    ans = max(ans, a*b);
    puts!("{}\n", ans);
}


Measured memory_bytes: 4352