akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
  int h,w,a,b,i,j;
  
  scanf("%d%d%d%d",&h,&w,&a,&b);
  
  if((a <= w/2) && (b <= h/2)){
    for(i=0;i<b;i++){
      for(j=0;j<a;j++)
        printf("0");
      for(;j<w;j++)
        printf("1");
      printf("\n");
    }
    for(;i<h;i++){
      for(j=0;j<a;j++)
        printf("1");
      for(;j<w;j++)
        printf("0");
      printf("\n");
    }
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1152
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    if A[0] >= 0:
        printAllPlus(A)
    elif A[-1] <= 0:
        printAllMinus(A)
    else:
        printMixed(A)


def printMixed(nums):
    i = -1
    for k, n in enumerate(nums):
        if n >= 0:
            i = k
            break
    plus = nums[i:]
    minus = nums[:i]
    print(sum(plus) - sum(minus))
    while len(plus) > 1:
        p = plus.pop()
        m = minus.pop()
        print(m, p)
        minus.append(m - p)
    p0 = plus.pop()
    for m in minus:
        print(p0, m)
        p0 -= m


def printAllPlus(nums):
    ans = sum(nums) - 2 * nums[0]
    print(ans)
    tmp = nums[0]
    for n in nums[1:-1]:
        print(tmp, n)
        tmp -= n
    print(nums[-1], tmp)


def printAllMinus(nums):
    nums.reverse()
    ans = -sum(nums) + 2 * nums[0]
    print(ans)
    tmp = nums[0]
    for n in nums[1:]:
        print(tmp, n)
        tmp -= n


if __name__ == "__main__":
    main()


Measured memory_bytes: 60828
/*
  AOJ 2105
  Title:Rythm Machine
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#include <limits.h>
int D,N;
unsigned char pattern[8][1024];
int length[8];
unsigned char result[1024];

int gcd(int a, int b)
{
        int c;
        while (b > 0) {
                c = a % b;
                a = b;
                b = c;
        }
        return a;
}
int lcm(int a, int b)
{
  return a/gcd(a,b)*b;
}

void print_pat(char pat[],int len)
{
  int i;
  for(i=0;i<len;i++)
    printf("%02X",(unsigned char)pat[i]);
  printf("\n");
}

check_zero(char pat[],int len,int period)
{
  int i;
  for(i=0;i<len;i++)
    if((i % period) && pat[i])
      return(0);
  return(1);
}
void expand(char pat[],int *len,int ratio)
{
  char buf[1025];
  int i;

  memset(buf,0,sizeof(buf));
  for(i=0;i < *len;i++)
      buf[i*ratio]=pat[i];

  memcpy(pat,buf,*len * ratio);
  *len *= ratio;
}
void shrink(char pat[],int *length)
{
  int i,j;
  char buf[1025];
  int len=*length;

  for(i=len;i>1;i--)
    {
      if(len % i)
	continue;
      if(check_zero(pat,len,i))
	{
	  memset(buf,0,sizeof(buf));
	  for(j=0;j<len/i;j++)
	    buf[j]=pat[j*i];
	  *length /= i;
	  memcpy(pat,buf,*length);
	  break;
	}
    }
}

int all_lcm(int a[],int len)
{
  int i,ret;

  ret=a[0];
  for(i=1;i<len;i++)
    {
      ret = lcm(ret,a[i]);
      if(ret>1024)
	return(INT_MAX);
    }
  return(ret);
}
main()
{
  int i,j,k,len,buflen,alllen;
  unsigned int x;
  char buf[2049];

  scanf("%d",&D);
  for(;D>0;D--)  
  {
    memset(pattern,0,sizeof(pattern));
    memset(buf    ,0,sizeof(buf));
    memset(length ,0,sizeof(length));
    scanf("%d",&N);
    for(j=0;j<N;j++)
      {
	scanf("%s",buf);
	buflen=strlen(buf);

	for(k=0;k*2<buflen;k++)
	{
	  sscanf(buf+k*2,"%2x",&x);
	  pattern[j][k]=x;
	}
	length[j]=buflen/2;
	shrink(&pattern[j][0],&length[j]);
      }
    alllen=all_lcm(length,N);
 
    if(alllen>1024)
    {
      printf("Too complex.\n");
      continue;
    }
    
    for(i=0;i<N;i++)
      expand(&pattern[i][0],&length[i],alllen/length[i]);

    
#ifdef DEBUG
    for(i=0;i<N;i++)
      {
	printf("[%d]",length[i]);
	print_pat(&pattern[i][0],length[i]);
      }
#endif        
    
    memset(result,0,sizeof(result));
    for(i=0;i<N;i++)
      for(j=0;j<alllen;j++)
	result[j] |= pattern[i][j];
    print_pat(result,alllen);
    
  }
  return(0);
}

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

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//**********

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

  int h, w;
  cin >> h >> w;
  int ans;

  if (h == 1 || w == 1) {
    ans = 1;
  } else if ((h * w) % 2 == 0) {
    // even
    ans = h * w / 2;
  } else {
    // odd
    ans = (h * w + 1) / 2;
  }

  cout << ans << endl;

  return 0;
};


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

using namespace std;

int a, b, c;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> a >> b >> c;
    int res = (a + b) * (c / 2);
    cout << res << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=6;
int n,m,s[N],c[N]; 
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)cin>>s[i]>>c[i];
    for(int i=0;i<1000;i++){
        string t=to_string(i);
        if(t.size()==n){
            int j;for(j=1;j<=m;j++)if(t[s[j]-1]!=c[j]+'0')break;
            if(j==m+1){cout<<i<<endl;return 0;}
        }
    }
    return cout<<-1,0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define ol(c, s, e) for(int pos=s; pos<e; pos++)cout << c[pos] << " ";cout <<"\n";
#define PI acos(-1LL)

const int M = 1000000007;
const int N = 2e5 + 5;
const long long INF = 1e9 + 12;

string a,b;
int dp[3005][3005];
int fun(int i, int j){
    if(i<0 || j<0)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(a[i] == b[j]){
        return dp[i][j] =  1 + fun(i-1, j-1);
    }
    else{
        return dp[i][j] = max(fun(i-1,j), fun(i, j-1));
    }
}
string ans;
void path(int i, int j){
    if(i<0 || j<0)
        return;
    if(a[i] == b[j]){
        ans+=a[i];
        path(i-1,j-1);
    }else{
        if(fun(i,j) == fun(i-1,j))
            path(i-1,j);
        else
            path(i,j-1);
    }
}
void solve(){
    cin >> a >> b;
    int n = a.size() , m = b.size();
    memset(dp, 0, sizeof dp);
//    fun(a.size()-1,b.size()-1);
//    path(a.size()-1,b.size()-1);
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(a[i-1] == b[j-1]){
                dp[i][j] = 1 + dp[i-1][j-1];
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    int i=n, j = m;
    while(i!=0 && j!=0){
        if(a[i-1]==b[j-1]) ans+=a[i-1], i--, j--;
        else{
            if(i>0 && dp[i][j] == dp[i-1][j]) i--;
            else j--;
        }
    }
    reverse(all(ans));
    cout << ans;
}

signed main(){
    FAST
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a + b > c + d)
        cout << "Left" << endl;
    else if (a + b < c + d)
        cout << "Right" << endl;
    else
        cout << "Balanced" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 21:12:05 2020

@author: NEC-PCuser
"""

X, K, D = map(int, input().split())

if abs(X) > K * D:
	print(abs(X) - K * D)
else:
	#1000 / 3 333・・・1
	N = X // D
	if (N - K) % 2 == 0:
		print(X % D)
	else:
		print(D - (X % D))
	
	

Measured memory_bytes: 9172
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld inf=pow(10,10);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

void solve(){
  ll n,x;cin>>n>>x;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  vector<vector<ll>>dp(n,vector<ll>(n+2,INF));
  rep(i,n)dp[i][0]=a[i];
  rep(i,n){
    rep(j,n){
      dp[i][j+1]=min(a[(i-(j+1)+3*n)%n],dp[i][j]);
      //cout<<dp[i][j]<<" ";
    }
    //cout<<endl;
  }
  ll ans=INF;
  rep(j,n+1){
    //j回回す
    ll num=j*x;
    rep(i,n){
      num+=dp[i][j];
    }
    ans=min(ans,num);
  }
  cout<<ans<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}

Measured memory_bytes: 31616
(* O((n+m)log(n+m)) *)
open Array
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let a_s = init n @@ fun _ -> Scanf.scanf " %d" @@ fun a -> a, 1
let cbs = init m @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> b, a
let cards = make (n + m) (0, 0)
let rec f acc i r =
  if r <= 0 then acc
  else
    let x, c = cards.(i) in
    f (acc + x * min c r) (i + 1) @@ r - min c r
let _ =
  iteri (fun i a -> cards.(i) <- a) a_s;
  iteri (fun i cb -> cards.(n + i) <- cb) cbs;
  sort (fun x y -> compare y x) cards;
  f 0 0 n |> Printf.printf "%d\n"

Measured memory_bytes: 12672
import java.util.List;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {

	public static void main(String[] args) {

		Input stdIn = new Input();

		int n = stdIn.getValue();
		List<Integer> values = stdIn.getLine();

		bubbleSort(values, n);

		stdIn.close();

	}

	public static void bubbleSort(List<Integer> values, int n) {

		int count = 0;

		for (int i = n; i > 1; i--) {
			for (int j = 0; j < i - 1; j++) {
				if (values.get(j) > values.get(j + 1)) {
					values.add(j, values.get(j + 1));
//					System.out.println(values);
					values.remove(j + 2);
					count++;
				}
//				System.out.println(values);
//				System.out.println(count);
			}
		}
		StringBuilder output = new StringBuilder();
		for(int k = 0; k < values.size(); k++) {
			output.append(values.get(k) + " ");
		}
		System.out.println(output.delete(output.length()-1, output.length()));
		System.out.println(count);
	}
}
class Input {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public int getValue() {
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return n;
	}

	public List<Integer> getValueLines(int n) {
		List<Integer> values = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			values.add(getValue());
		}
		return values;
	}

	public List<Integer> getLine() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<Integer> ary = new ArrayList<>();
			for (int i = 0; i < s.length; i++) {
				ary.add(Integer.parseInt(s[i]));
			}
			return ary;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public void close() {
		try {
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24680
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(args){
    var input = args.split(" ");
    var K = parseInt(input[0], 10);
    var S = parseInt(input[1], 10);
    var count = 0;

    for(var i = 0; i<=K; i++){
        for(var j=0; j<=K; j++){
            if(0<=S-i-j && S-i-j<=K){
                count++;
            }
        }
    }

    console.log( count );
}

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

int main()
{
	ll N;
	cin >> N;
	if (N == 2)
	{
		cout << "1" << endl;
		return 0;
	}
	for (ll i = 1; i * i <= N; ++i)
	{
		if (N % i == 0)
		{
			D.push_back(i);
			if (i * i != N) D.push_back(N/i);
		}
	}
	ll ans = 0;
	//if (N != 2) ans++; //K = N-1 も解
	rep(i,D.size())
	{
		//cout << D[i] << endl;
		ll temp = N, d = D[i];
		if (d == 1) continue;
		while(temp % d == 0)
		{
			temp /= d;
		}
		//cout << "t:" << temp << endl;
		if (temp % d == 1) ans++;
	}

	N--;
	for (ll i = 1; i * i <= N; ++i)
	{
		if (N % i == 0)
		{
			D2.push_back(i);
			if (i * i != N) D2.push_back(N/i);
		}
	}
	cout << ans+D2.size()-1 << endl;
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

int main(){
  string s;
  cin >> s;
  ll len,x1=0,x2=0;
  len = s.length();
  for(int i=0;i<len;i++){
    if(s[i] == '0'){
      x1++;
    }else{
      x2++;
    }
  }
  cout << 2 * min(x1,x2);

}


Measured memory_bytes: 512
from functools import partial
from itertools import islice


def take(n, iterable):
    return list(islice(iterable, n))


def chunked(iterable, n):
    return iter(partial(take, n, iter(iterable)), [])


def solve(s):
    n, m, *xyz = map(int, s.split())
    ans = 0
    for sign_x in [1, -1]:
        for sign_y in [1, -1]:
            for sign_z in [1, -1]:
                ordered = sorted(
                    [x * sign_x + y * sign_y + z * sign_z for x, y, z in chunked(xyz, 3)],
                    reverse=True)
                ans = max(ans, sum(ordered[:m]))
    return ans


if __name__ == "__main__":
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 3916
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
  int n;
  cin>>n;
  ll ans=0;
  for(int i=1; i<n; i++){
      ll x= n/i;
      if(n%i==0){
          x--;
      }
      //cout<<x<<" ";
      ans += x;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3652
// https://beta.atcoder.jp/contests/abc110/tasks/abc110_a

#pragma GCC diagnostic ignored "-Wunused-result"

#include <stdio.h>

int main(void) {
  // char      short           long
  // 2^8       2^16            2^32
  //    0-255        0-65,535               0-4,294,967,295
  // -128-127  -32,768-32,767  -2,147,483,648-2,147,483,647

  int A,B,C; // 1 <= A,B,C <= 9
  int ret;
  
  scanf("%d %d %d", &A, &B, &C);

  if (A>=B && A>=C) {
    ret = 10*A+B+C;
  } 
  else if (B>=A && B>=C) {
    ret = 10*B+A+C;
  } 
  else if (C>=A && C>=A) {
    ret = 10*C+A+B;
  } 
  printf("%d\n",ret);

  return 0;

}


Measured memory_bytes: 128
const main = (standardInput) => {
    const a = standardInput.split(' ');
    const h = 3600;
    const m = 60;

    console.log(Math.floor(a/h) + ":" + Math.floor(a%h/m) + ":" + a%h%m);
  }

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));



Measured memory_bytes: 15148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

vector<long long> divisor(long long n) {
  vector<long long> ret;
  for (long long 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, m;
  cin >> n >> m;
  vector<ll> data = divisor(m);
  if (n == 1) {
    cout << m << endl;
  } else {
    auto itr = upper_bound(ALL(data), m / n);
    itr--;
    cout << *itr << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<vector<int>> dist(N, vector<int>(N, INF));
  vector<vector<bool>> visited(N, vector<bool>(N, false));
  REP(i, N) REP(j, N){
    chmin(dist[i][j], min(min(i, N-i-1), min(j, N-j-1)));
  }

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

  int ans = 0;
  REP(k, N*N){
    int A;
    cin >> A; A--;
    
    int x = A/N;
    int y = A%N;

    ans += dist[x][y];
    visited[x][y] = true;

    REP(i, 4){
      int nx = x+dx[i];
      int ny = y+dy[i];
      if(OUT(0, nx, N) || OUT(0, ny, N)){
        dist[x][y] = -1;
        break;
      }
      chmin(dist[x][y], dist[nx][ny]);
    }

    deque<pair<int, int>> deq({make_pair(x, y)});

    while(!deq.empty()){
      auto [x, y] = deq.front(); deq.pop_front();

      REP(i, 4){
        int nx = x+dx[i];
        int ny = y+dy[i];

        if(OUT(0, nx, N) || OUT(0, ny, N)) continue;
        int cost = dist[x][y]+(visited[nx][ny]? 0 : 1);
        if(dist[nx][ny] > cost){
          dist[nx][ny] = cost;
          if(visited[nx][ny]) deq.emplace_front(nx, ny);
          else deq.emplace_back(nx, ny);
        }
      }
    }
  }

  cout << ans << "\n";

  return 0;
}

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

int N;

int main(){
    cin >> N;
    vector<int> A(N);
    for(auto &v: A)
        cin >> v;
    
    sort(A.begin(), A.end());
    
    cout << A[N-1] - A[0] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int ans = 0;
	rep(i,3001){
		int sum = R * i;
		if(sum > N) break;
		else if(sum == N){
			ans++;
			break;
		} 
		rep(j,3001){
			sum = R * i + G * j;
			if(sum > N) break;
			else if(sum == N){
				ans++;
				break;
			} 
			else{
				int W = N - sum;
				if(W % B == 0) ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import collections
import sys


def main():
    N, M = map(int, input().split())
    data = []

    for num in range(N):
        result_data = list(input().split(' '))
        if N == 1:
            result = result_data[0]
            print(result)
            sys.exit(0)
        else:
            for i in result_data[1:]:
                data.append(int(i))

    c = collections.Counter(data)

    counter = 0

    for i in c.values():
        if i == N:
            counter += 1

    print(counter)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
N, K = list(map(int, input().split()))
C = 10**9+7

ans = 0
A = sum(list(range(N, N-K, -1)))
B = sum(list(range(K)))
for i in range(K, N+2):
    # print(A,B)
    ans += A-B+1
    A += N-i
    B += i
    ans %= C
print(ans)

Measured memory_bytes: 66536
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define lun(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<60);
const int inf=(1<<30);
const int nmax=2e5+50;
const ll mod=1e9+7;
using namespace std;
int n,m,i,l,r,mid,rs;
ll k,a[nmax],b[nmax],tot;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m>>k;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=m;i++)cin>>b[i],b[i]+=b[i-1];
	for(i=0;i<=n;i++)
	{
		tot+=a[i];
		if(tot>k)break;
		l=0,r=m;
		while(l<=r)
		{
			mid=(l+r)/2;
			if(tot+b[mid]>k)r=mid-1;
			else l=mid+1;
		}
		rs=max(rs,i+r);
	}
	cout<<rs<<endl;
	return 0;
}


Measured memory_bytes: 6776
#include<iostream>
#include<cstdio>

using namespace std;

int CHARtoINT(char ch[]){
  int j;
  int cur=0;

  for(j=0;ch[j];j++){
    if(ch[j]=='m'){
      if(j==0){
        cur+=1000;
      }else{
        cur+=(ch[0]-'0')*1000;
      }
    }else if(ch[j]=='c'){
      if(j==0){
        cur+=100;
      }else if('2'<=ch[j-1] && ch[j-1]<='9'){
        cur+=(ch[j-1]-'0')*100;
      }else{
        cur+=100;
      }
    }else if(ch[j]=='x'){
      if(j==0){
        cur+=10;
      }else if('2'<=ch[j-1] && ch[j-1]<='9'){
        cur+=(ch[j-1]-'0')*10;
      }else{
        cur+=10;
      }
    }else if(ch[j]=='i'){
      if(j==0){
        cur++;
      }else if('2'<=ch[j-1] && ch[j-1]<='9'){
        cur+=(ch[j-1]-'0');
      }else{
        cur++;
      }
    }
  }

  return cur;
}

void printCHAR(int num){
  char ans[10];

  if(num>=2000){ cout << num/1000; }
  if(num>=1000){ cout << "m"; }
  num%=1000;
  if(num>=200){ cout << num/100; }
  if(num>=100){ cout << "c"; }
  num%=100;
  if(num>=20){ cout << num/10; }
  if(num>=10){ cout << "x"; }
  num%=10;
  if(num>=2){ cout << num; }
  if(num>=1){ cout << "i"; }

  cout << endl;

  return ;
}

int main(void) {
  int i,j;
  int n;
  int num1,num2;
  char s1[10],s2[10];

  cin >> n;

  for(i=0;i<n;i++){
    cin >> s1 >> s2;
    
    num1=CHARtoINT(s1);
    num2=CHARtoINT(s2);

    printCHAR(num1+num2);
  }

  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
  long n,i,max,result=0,a[200000];

  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  
  max=a[0];
  for(i=1;i<n;i++){
    if( (max-a[i])>0 ){
      result+=(max-a[i]);
    } else {
      max=a[i];
    }
  }
  
  printf("%ld",result);
}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 200003;
int n, head[N], to[N << 1], nxt[N << 1];
inline void add(int a, int b){
	static int cnt = 0;
	to[++ cnt] = b; nxt[cnt] = head[a]; head[a] = cnt;
}
int now, ans, dep[N];
inline void dfs(int x, int f){
	for(Rint i = head[x];i;i = nxt[i])
		if(to[i] != f){
			dep[to[i]] = dep[x] + 1;
			dfs(to[i], x);
		}
}
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i < n;i ++){
		int a, b;
		scanf("%d%d", &a, &b);
		add(a, b); add(b, a);
	}
	dfs(1, 0);
	for(Rint i = 1;i <= n;i ++)
		if(ans < dep[i]){
			ans = dep[i];
			now = i;
		}
	dep[now] = ans = 0;
	dfs(now, 0);
	for(Rint i = 1;i <= n;i ++)
		ans = max(ans, dep[i]);
	puts(ans % 3 == 1 ? "Second" : "First");
}

Measured memory_bytes: 9728
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		int[] As = new int[N];
		for(int i = 0; i < N; i++){
			As[i] = sc.nextInt();
		}
		
		int[] counts = new int[N];
		for(int i = 0; i < N; i++){
			counts[As[i]]++;
		}
		
		if(N % 2 == 0){
			for(int i = 0; i < N; i++){
				if(i % 2 == 0 && counts[i] > 0){
					System.out.println(0);
					return;
				}else if(i % 2 != 0 && counts[i] != 2){
					System.out.println(0);
					return;
				}
			}
		}else{
			for(int i = 0; i < N; i++){
				if(i % 2 != 0 && counts[i] > 0){
					System.out.println(0);
					return;
				}else if(i == 0 && counts[0] == 0){
					System.out.println(0);
					return;
				}else if(i != 0 && i % 2 == 0 && counts[i] != 2){
					System.out.println(0);
					return;
				}
			}
		}
		
		long answer = 1;
		for(int i = 0; i < N / 2; i++){
			answer *= 2;
			answer %= 1000000007;
		}
		
		System.out.println(answer);
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;

using Ki = vector<vector<int>>;
using Vi = vector<int>;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    rep(i,n){
        cout<<s[i]<<t[i];
    }
}

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

#define int long long

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

#define endl '\n'
#define fi first
#define se second
#define all(v) v.begin(), v.end()

#define print(x)    cout << #x << " : " << x << endl;
#define darr(a,n)   for(int i=0; i<n; i++) cout << a[i] <<' '; cout<< '\n';
#define fast        ios_base::sync_with_stdio (false); cin.tie (nullptr);
#define dvec(vct)   for(auto i : vct) cout << i << " "; cout << endl;

const int maxn = 1e6;
const int mod = 1e9 + 7;
// const int mod = 998244353;


/*****************************************************************************/



void solve() {
    string s, s1, s2; cin >> s;
    int n = s.size();
    string r1, r2, r;
    r = s;
    reverse(r.begin(), r.end());

    s1 =  s.substr(0, (n-1)/2);
    r1 = s1;
    reverse(all(r1));

    s2 = s.substr((n-1)/2 + 1, (n-1)/2);
    r2 = s2;
    reverse(all(r2));

    if (r == s && r1 == s1 && r2 == s2) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}



/*****************************************************************************/



int32_t main() {
    fast;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    auto start = chrono::steady_clock::now();
    solve();

    auto end = chrono::steady_clock::now();
    auto diff = end - start;
    // #ifndef ONLINE_JUDGE
    //     cout << "\n\n";
    //     cout << "TIME : " << chrono::duration<double, milli> (diff).count() << " ms" << endl;
    // #endif
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * 鈴木くんのプログラムを元（参考）に作成 クラス内の変数を直接読み込ませないようにカプセル化（？）をしてみたが、
 * 果たしてこれがカプセル化なのかがわからない…
 * 
 * @author U633758
 *
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		Dice3 dc = new Dice3();
		Dice3 hikaku_dc = new Dice3();
		dc.dice(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
		hikaku_dc.dice(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());

	//	int q = sc.nextInt();
	//	int top, front;
	//	int[] r = new int[q];
	/*	for (int i = 0; i < q; i++) {
			top = sc.nextInt();
			front = sc.nextInt();
			r[i] = dc.getRight(top, front);
		}
		*/
		if(dc.check(hikaku_dc)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		

		sc.close();// Scannerを閉じる
	}

}

/**
 * Dice3クラス ダイスの面に数字をインプットする。回転させたりする。
 * 
 * @author U633758
 *
 */
class Dice3 {
	private int T, S, E, W, N, U;

	Dice3() {
		this.T = 0; // Top
		this.S = 0;
		this.E = 0;
		this.W = 0;
		this.N = 0;
		this.U = 0; // Under
	}

	/**
	 * Diceに数字をインプットする
	 * @param T_1	真上
	 * @param S_2	南
	 * @param E_3	東
	 * @param W_4	西
	 * @param N_5	北
	 * @param U_6	真下
	 */
	void dice(int T_1, int S_2, int E_3, int W_4, int N_5, int U_6) {
		this.T = T_1; // Top
		this.S = S_2;
		this.E = E_3;
		this.W = W_4;
		this.N = N_5;
		this.U = U_6; // Under
		// TODO 自動生成されたコンストラクター・スタブ
	}

	/**
	 * 南方向にサイコロを傾ける
	 */
	void MoveSouth() {
		int a = T;
		T = N;
		N = U;
		U = S;
		S = a;
	}

	void MoveEast() {
		int a = T;
		T = W;
		W = U;
		U = E;
		E = a;
	}

	void MoveNorth() {
		int a = T;
		T = S;
		S = U;
		U = N;
		N = a;
	}

	void MoveWest() {
		int a = T;
		T = E;
		E = U;
		U = W;
		W = a;
	}

	void right() {// 時計周りの回転
		int a = S;
		S = E;
		E = N;
		N = W;
		W = a;
	}

	/**
	 * 
	 * @param t 真上の数字（上面）
	 * @param f 南側の数字（前面）
	 * @return 東側（側面）の求めるべき数字
	 */
	int getRight(int t, int f) {
		for (int i = 0; i < 3; i++) {
			if (t == T) {
				break;
			}
			MoveNorth();
			if (t == T) {
				break;
			}
			MoveWest();
		}
		for (int i = 0; i < 3; i++) {
			if (f == S) {
				break;
			}
			right();
		}
		return E;
	}
	
	boolean check(Dice3 hikaku) {
		for (int i = 0; i < 4; i++) {
			if (checkAll(hikaku)) {
				break;
			}
			MoveNorth();
			for(int j = 0; j < 4; j++){
			if (checkAll(hikaku)) {
				break;
			}
			right();
			}
		}
			
		for (int i = 0; i < 4; i++) {
			if (checkAll(hikaku)) {
				break;
			}
			MoveWest();
			for(int j = 0; j< 4; j++){
				if(checkAll(hikaku)){
					break;
				}
				right();
			}
		}
		if(checkAll(hikaku)){
			return true;
		}
		return false;
	}
	
	boolean checkAll(Dice3 hikaku) {
        if (this.T == hikaku.T && this.S == hikaku.S && this.W == hikaku.W
        		&& this.E == hikaku.E && this.N == hikaku.N && this.U == hikaku.U) {
        	
            return true;
        }
        return false;
    }


}


Measured memory_bytes: 26328
function main(input){
  var a = parseInt(input.split("\n")[0].split(" ")[0]);
  var b = parseInt(input.split("\n")[0].split(" ")[1]);
  var c = parseInt(input.split("\n")[0].split(" ")[2]);
  var d = parseInt(input.split("\n")[0].split(" ")[3]);
  
  if (a*b >= c*d){
    console.log(a*b);
  }else{
    console.log(c*d);
  }
}

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

Measured memory_bytes: 7372
import math

n = int(input())
a = [int(_) for _ in input().split()]

CARD = 10**5+1

num = [0] * CARD
for i in a:
    num[i] += 1

ans = 0
cnt = 0
for i in range(CARD):
    while num[i] > 2:
        ans += 2
        num[i] -= 2
    if num[i] == 2:
        cnt += 1
ans += math.ceil(cnt/2) * 2
print(n-ans)

Measured memory_bytes: 14396
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func frog1(n int, heights []int) int {
	minInt := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}
	absInt := func(a int) int {
		if a < 0 {
			return -a
		}
		return a
	}
	costs := make([]int, n)
	costs[0] = 0
	costs[1] = absInt(heights[1] - heights[0])
	for i := 2; i < n; i++ {
		costs[i] = minInt(
			absInt(heights[i]-heights[i-1])+costs[i-1],
			absInt(heights[i]-heights[i-2])+costs[i-2])
	}
	return costs[n-1]
}

var inp *bufio.Scanner

func ScanInt() int {
	inp.Scan()
	res, _ := strconv.Atoi(inp.Text())
	return res
}

func ScanIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		inp.Scan()
		res[i], _ = strconv.Atoi(inp.Text())
	}
	return res
}

func main() {
	inp = bufio.NewScanner(os.Stdin)
	inp.Split(bufio.ScanWords)
	stones := ScanInt()
	heights := ScanIntArray(stones)
	fmt.Println(frog1(stones, heights))
}

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

int main(){
  int s,hoge,foo;
  cin >> s;
  hoge=s/3600;
  s=s-hoge*3600;
  foo=s/60;
  s=s-foo*60;
  cout << hoge << ":" << foo << ":" << s << '\n';
  return 0;
}



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

using namespace std;

#define li long long int

const int N 	= 3e3 + 5;
const li mod 	= 1e9 + 7;

string a, b;
int n, m;
int dp[N][N];

int go(int x, int y) {
	if (x >= n or y >= m) return dp[x][y] = 0;
	if (dp[x][y] != -1) return dp[x][y];
	int ans = 0;
	if (a[x] == b[y]) ans = 1 + go(x + 1, y + 1);
	else ans = max(go(x, y + 1), go(x + 1, y));
	return dp[x][y] = ans;
}

void reconstruct(int x, int y) {
	if (x >= n or y >= m) exit(0);
	if (dp[x][y + 1] != -1 and dp[x][y] == dp[x][y + 1]) {
		reconstruct(x, y + 1);
	} else if (dp[x + 1][y] != -1 and dp[x][y] == dp[x + 1][y]) {
		reconstruct(x + 1, y);
	} else if (dp[x + 1][y + 1] != -1 and dp[x][y] == 1 + dp[x + 1][y + 1]) {
		cout << a[x];
		reconstruct(x + 1, y + 1);
	}
}

void solve() {
	cin >> a >> b;
	n = (int)a.length();
	m = (int)b.length();
	memset(dp, -1, sizeof(dp));
	go(0, 0);
	reconstruct(0, 0);
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

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

int main() {
  int A,B,T;
  cin >> A >> B >> T;
  int maisuu = 0;
  for(int i = A; i < T + 0.5; i += A){
    maisuu += B;
  }
  cout << maisuu << endl;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;cin >> n;
    vector<ll> a(n);rep(i,n)cin >> a[i];
    int minus = 0;
    ll mn = INF;
    rep(i,n)
    {
        if(a[i]<0)
        {
            minus++;
        }
        chmin(mn, abs(a[i]));
    }
    ll sum = 0;
    rep(i, n)
    {
        sum += abs(a[i]);
    }
    if(minus%2==1)
    {
        sum -= 2*mn;
    }
    cout << sum << endl;
}

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

using namespace std;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

ll min(ll a, ll b){return (a<b?a:b);}
ll max(ll a, ll b){return (a>b?a:b);}

int main(){
	ll n, m, v, p;
	cin >> n >> m >> v >> p;
	int a[n];
	REP(i, n) cin >> a[i];
	sort(a, a+n, greater<int>());
	int l = 0, r = n;
	while((r-l)!=1){
		int md = (l+r)/2;
		ll remvote = m*v - p*m;
		ll cur = a[md] + m;
		ll cap = 0;
		FOR(i, p-1, n){
			if(i != md) cap += min(m, cur-a[i]);
		}
		if(cur < a[p-1]) r = md;
		else if(cap>=remvote) l = md;
		else r = md;
	}
	cout << l+1 << endl;
	return 0;
} 


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    vec<int> x(3);
    cin >> x[0] >> x[1] >> x[2];
    sort(all(x));
    int ans = 0;
    int mxdiff = x[2]-x[0];
    int mndiff = x[2]-x[1];
    ans+=mndiff;
    if((mxdiff - mndiff)%2 == 0){
        ans+=((mxdiff - mndiff)/2);
    } else {
        ans+=((mxdiff - mndiff + 1)/2)+1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define  fo(i,a,b) for(ll i=a;i<b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

#define err() cout<<"----------"<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589
const ll MOD=1e9+7;
ll mod(ll x)
{
   return (x%MOD+MOD)%MOD;
   // works for neg and pos values of x.
}
void solve()
{
    string s;
    cin>>s;
    ll sum=0;
    fo(i,0,s.size())
    {
        sum=sum+(s[i]-'0');
    }
    if(sum%9==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return;
}
int main()
{

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
//  clock_t time_req;
//  time_req = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

// time_req = clock()-time_req;
//  cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;

    return 0;
}

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

Measured memory_bytes: 6300
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int n=ni();
        int k=ni();
        int[]A=new int[k+1];
        for(int i=0;i<k;i++)
            A[i]=ni();
        A[k]=A[0]+n;
        int max=0;
        for(int i=0;i<k;i++)
            max=Math.max(max,A[i+1]-A[i]);
        pn(n-max);
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 48080
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <vector>
#include <sstream>
#include <functional>
using namespace std;
char table[6][5]={
{'a','b','c','d','e'},
{'f','g','h','i','j'},
{'k','l','m','n','o'},
{'p','q','r','s','t'},
{'u','v','w','x','y'},
{'z','.','?','!',' '},
};
int main()
{
	string s;
    while(cin>>s){
		string ans="\0";
		if(!(s.length()%2)){
			for(int i=0;i<(int)s.length();i+=2){
				if('1'<=s[i]&&s[i]<='6'&&'1'<=s[i+1]&&s[i+1]<='5'){
					ans+=table[s[i]-'0'-1][s[i+1]-'0'-1];
				}else{
					ans="NA";
					break;
				}
			}
		}else{
			ans="NA";
		}
		cout<<ans<<endl;
	}
    return 0;
}

Measured memory_bytes: 1196