akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int priceA(int amount){
	if(amount % 200 != 0){ return -1; }
	amount /= 200;
	return (amount / 5 * 5) * 380 * 80 / 100 + (amount % 5) * 380;
}
int priceB(int amount){
	if(amount % 300 != 0){ return -1; }
	amount /= 300;
	return (amount / 4 * 4) * 550 * 85 / 100 + (amount % 4) * 550;
}
int priceC(int amount){
	if(amount % 500 != 0){ return -1; }
	amount /= 500;
	return (amount / 3 * 3) * 850 * 88 / 100 + (amount % 3) * 850;
}

int main(){
	while(true){
		int amount;
		cin >> amount;
		if(amount == 0){ break; }
		int price = INT_MAX;
		for(int a = 0; a <= amount; a += 200){
			for(int b = 0; b + a <= amount; b += 300){
				for(int c = 0; c + b + a <= amount; c += 500){
					if(a + b + c != amount){ continue; }
					int pa = priceA(a), pb = priceB(b), pc = priceC(c);
					price = min(price, pa + pb + pc);
				}
			}
		}
		cout << price << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define vi vector<int>
#define umap unordered_map
#define pii pair<int, int>
#define vpii vector<pii>
#define uset unordered_set
#define frw(i, a, b) for(int i = (a); i < (b); i++)
#define bck(i, a, b) for(int i = (a); i > (b); i--)
#define T() int testcases; cin >> testcases; frw(TC, 1, testcases + 1)
#define tez ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define fi first
#define se second
#define pow asdihagsiduh
#define pub push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) (int)(a.size())
#define sq(a) ((a) * (a))

#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1> 
void ZZ(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}

//console o/p without variable names
#define trace1(...) ZZZ(__VA_ARGS__)
template<typename Arg1>
void ZZZ(Arg1&& arg1){
    cerr << arg1 << endl;
}
template<typename Arg1, typename... Args>
void ZZZ(Arg1&& arg1, Args&&... args){
    cerr << arg1 << ' ';
    ZZZ(args...);
}

int n, m, mat[25][25], vis[25][25];

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

bool valid(int x, int y){
    return (x >= 1 && y >= 1 && x <= n && y <= m && !mat[x][y] && !vis[x][y]);
}

int dist(int x, int y){
    if(mat[x][y])   return -1e5;
    int dis[n + 1][m + 1];
    memset(dis, 0, sizeof dis);
    memset(vis, 0, sizeof vis);
    queue<pii> q;
    q.push({x, y});
    int ret = 0;
    dis[x][y] = 0;
    vis[x][y] = 1;
    while(!q.empty()){
        auto s = q.front();
        q.pop();
        // if(x == 3 && y == 1)
        // trace(s.fi, s.se);
        frw(i, 0, 4){
            int nx = s.fi + dx[i], ny = s.se + dy[i];
            if(valid(nx, ny)){
                dis[nx][ny] = 1 + dis[s.fi][s.se];
                vis[nx][ny] = 1;
                q.push({nx, ny});
                ret = max(ret, dis[nx][ny]);
            }
        }
    }
    return ret;
}

signed main(){
    tez
    cin >> n >> m;
    memset(mat, 0, sizeof mat);
    frw(i, 1, n + 1){
        frw(j, 1, m + 1){
            char c; cin >> c;
            if(c == '#')    mat[i][j] = 1;
        }
    }
    int ans = 0;
    frw(i, 1, n + 1){
        frw(j, 1, m + 1){
            ans = max(ans, dist(i, j));
            // trace(i, j, dist(i, j));
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	string s;
	cin >> s;
	int n = s.size() + 1;

	int L = 0;
	int R = 0;
	char now = '<';
	int ans = 0;
	for(auto c:s){
		// cerr << L << ", " << R << endl;
		if(now == c){
			if(c == '<')L++;
			if(c == '>')R++;
		}
		else if(now == '<' && c == '>'){
			now = '>';
			R++;
		}
		else if(now == '>' && c == '<'){
			now = '<';
			int mini = min(L,R);
			int maxi = max(L,R);
			// cerr << L << ", " << R << endl;
 			ans += mini*(mini-1)/2 + maxi*(maxi+1)/2;
			L = 1;
			R = 0;
		}
	}
	// cerr << L << ", " << R << endl;
	int mini = min(L,R);
	int maxi = max(L,R);
	ans += mini*(mini-1)/2 + maxi*(maxi+1)/2;
	cout << ans << endl;

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://agc040.contest.atcoder.jp/tasks/agc040_a

Measured memory_bytes: 4316
def main():
    a, b = map(int, input().split())
    if b == 1:
        print(0)
    elif b - a <= 0:
        print(1)
    else:
        if (b-1) % (a-1) == 0:
            print((b-1)//(a-1))
        else:
            print((b-1)//(a-1) + 1)
            
if __name__ == '__main__':
    main()

Measured memory_bytes: 8988
#include<bits/stdc++.h>
using namespace std;
map<string,int>M;
int x[999999];
int main()
{
    M["Male"]=1;
    M["Female"]=0;
    int n;
    scanf("%d",&n);
    string s;
    cout<<0<<endl;
    fflush(stdout);
    cin>>s;
    if(s=="Vacant")return 0;
    int lval=M[s];
    cout<<n-1<<endl;
    fflush(stdout);
    cin>>s;
    if(s=="Vacant")return 0;
    int rval=M[s];
    int l=0,r=n-1;
    while(true)
    {
        int mi=(l+r)/2;
        cout<<mi<<endl;
        fflush(stdout);
        cin>>s;
        if(s=="Vacant")return 0;
        int val=M[s];
        if(!((mi-l+1)%2&1)&&val==lval)
        {
            r=mi;
            rval=val;
        }
        else if((mi-l+1)&1&&val!=lval)
        {
            r=mi;
            rval=val;
        }
        else if(!((r-mi+1)%2)&&val==rval)
        {
            l=mi;
            lval=val;
        }
        else if((r-mi+1)&1&&val!=rval)
        {
            l=mi;
            lval=val;
        }
    }
    return 0;
}


Measured memory_bytes: 852
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int d, g;
  long long ans = 100000000000;
  cin >> d >> g;
  g /= 100;
  vector<pair<int, int>> ps(d);
  for (int i = 0; i < d; i++)
    cin >> ps[i].first >> ps[i].second;
  for (int i = 0; i < (1 << d); i++) {
    long long sum = 0, b = 0;
    for (int j = 0; j < d; j++) {
      if ((i >> j) & 1) {
        sum += ps[j].first;
        b += ps[j].first * (j + 1) + ps[j].second / 100;
      }
    }
    for (int j = d - 1; j >= 0 && g > b; j--) {
      if ((i >> j) & 1)
        continue;
      for (int k = 0; k < ps[j].first && g > b; k++) {
        sum += 1;
        b += j + 1;
      }
    }
    if (b >= g) {
      ans = min(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>

#define N 100

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int d[ N ];
  int n;
  int i, j;

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

  for ( j = 1; ; ++j )
  {
    int k;

    for ( i = 0; i < n; ++i )
    {
      if ( i ) putchar ( ' ' );
      printf ( "%d", d[ i ] );
    }
    puts ( "" );
    if ( j >= n ) break ;

    k = d[ j ];
    for ( i = j; i > 0 && d[ i - 1 ] > k; --i )
    {
      d[ i ] = d[ i - 1 ];
    }
    d[ i ] = k;
  }

  return ( 0 );
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
   public static void main(String args[]) {
     int a;
     int b;
     int c;
     Scanner sc = new Scanner(System.in);


     a = sc.nextInt();


     b = sc.nextInt();


     c = sc.nextInt();

     if (a + b >= c)
        System.out.println("Yes");
     else
        System.out.println("No");


   }
 }


Measured memory_bytes: 22612
using System;
using System.Linq;

namespace AtTest.C_Challenge
{
    class ABC_062
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long h = long.Parse(input[0]);
            long w = long.Parse(input[1]);
            if (h % 3 == 0 || w % 3 == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                var margin = new long[4];
                //タテ3分割
                margin[0] = w;
                //ヨコ3分割
                margin[1] = h;

                //タテ1ヨコ2
                long h1 = h / 2;
                long h2 = (h + 1) / 2;
                for (int i = 1; i < w; i++)
                {
                    var tempArea = new long[3];
                    tempArea[0] = h * i;
                    tempArea[1] = h1 * (w - i);
                    tempArea[2] = h2 * (w - i);
                    long newMargin = tempArea.Max() - tempArea.Min();
                    if (margin[2] == 0 || newMargin < margin[2])
                    {
                        margin[2] = newMargin;
                    }
                }

                //タテ2ヨコ1
                long w1 = w / 2;
                long w2 = (w + 1) / 2;
                for (int i = 1; i < h; i++)
                {
                    var tempArea = new long[3];
                    tempArea[0] = w * i;
                    tempArea[1] = w1 * (h - i);
                    tempArea[2] = w2 * (h - i);
                    long newMargin = tempArea.Max() - tempArea.Min();
                    if (margin[3] == 0 || newMargin < margin[3])
                    {
                        margin[3] = newMargin;
                    }
                }
                Console.WriteLine(margin.Min());
            }
        }
    }
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    ll ans = 0;
    std::multiset<ll> s;
    s.insert(-1);
    for (ll i = N - 1; i >= 0; --i) {
        auto it = s.upper_bound(A[i]);
        if (it == s.end()) {
            ans++;
            s.insert(A[i]);
            continue;
        }
        s.erase(it);
        s.insert(A[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define maxn 100010

using namespace std;

int n,m;

int x[maxn],y[maxn],ans;

bool f[510][510],S[510];

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
		scanf("%d%d",&x[i],&y[i]);
	for (int i=1;i<=n;i++){
		f[i][i]=1;
		for (int j=m;j>=1;j--){
			int x1=f[i][x[j]],y1=f[i][y[j]];
			if (x1 && y1) {
				S[i]=1;
				break;
			}else if (x1) f[i][y[j]]=1;
			else if (y1) f[i][x[j]]=1;
		}
	}
	for (int i=1;i<=n;i++){
		if (S[i]==1) continue;
		for (int j=i+1;j<=n;j++){
			if (S[j]==1) continue;
			bool flag=1;
			for (int k=1;k<=n;k++)
				if (f[i][k] && f[j][k]){
					flag=0;
					break;
				}
			if (flag==1) ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    for(int i = 1; i <= N;i++){
        res += (to_string(i).length()%2==1);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long n,i,j,temp;
    cin>>n;
    long long p[n+1],a[n+1],b[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    for(i=1,j=n;i<=n;i++,j--)
    {
        a[i]=i;
        b[i]=j;
    }
    for(i=1;i<=n;i++)
    {
        a[p[i]]=a[p[i]]+i;
        for(j=p[i];j<=n;j++)
        {
            a[j]=a[j]+n;
            b[j]=b[j]-n;
        }
    }
    temp=1-b[n];
    for(i=1;i<=n;i++)
    {
        a[i]=a[i]+temp;
        b[i]=b[i]+temp;
    }
    for(i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
    for(i=1;i<=n;i++)
    {
        cout<<b[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 4076
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int fa[200010],n,m,siz[200010];
int find(int x) {
    if(fa[x]==x)
        return x;
    return fa[x]=find(fa[x]);
}
void merge(int x,int y) {
    int fx=find(x),fy=find(y);
    if(fx==fy)
        return;
    if(siz[fx]>siz[fy]) {
        fa[fy]=fx;
        siz[fx]+=siz[fy];
    }
    else {
        fa[fx]=fy;
        siz[fy]+=siz[fx];
    }
}
int ans;
int main() {
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)
        fa[i]=i,siz[i]=1;
    for(int i=1,x,y;i<=m;i++) {
        scanf("%d %d",&x,&y);
        merge(x,y);
    }
    for(int i=1;i<=n;i++)
        ans=max(ans,siz[i]);
    printf("%d\n",ans);
}

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

using namespace std;

int main() {
  vector<string> lines;

  string l;
  while (cin >> l) {
    lines.push_back(l);
  }

  for (int i = 0; i < 3; i++) {
    if (lines[0][i] != lines[1][2 - i]) {
      cout << "NO";
      return 0;
    }
  }

  cout << "YES";
  return 0;
}


Measured memory_bytes: 256
import Data.List

main = do
 [k,n] <- map read . words <$> getLine :: IO [Int]
 aList <- map read . words <$> getLine :: IO [Int]
 let bList = (map (\x -> x - k) aList) ++ aList ++ (map (\x -> x - k) aList)
 print $ minimum $ map (\x -> abs x) $ zipWith (-) (drop (n - 1) bList ) (take (length bList - n + 1) bList)

Measured memory_bytes: 181948
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N;
vector <ll> All, Odd;
int C1[int(1e6 + 5)], C2[int(1e6 + 5)];
int Prepare(){
  ll cnt = 1, now = 1;
  while (now < 1e6){
    now = cnt * (cnt + 1) * (cnt + 2) / 6;
    All.push_back(now);
    if (now % 2 != 0) Odd.push_back(now);
    cnt++;
  }

  queue <int> que; que.push(0);
  while (!que.empty()){
    int Q = que.front(); que.pop();
    for (int i = 0; i < All.size(); i++){
      int num = Q + All[i];
      if (num > 1e6) break;
      if (C1[num] == 0){
        C1[num] = C1[Q] + 1; que.push(num);
      }
    }
  }
  que.push(0);
  while (!que.empty()){
    int Q = que.front(); que.pop();
    for (int i = 0; i < Odd.size(); i++){
      int num = Q + Odd[i];
      if (num > 1e6) break;
      if (C2[num] == 0){
        C2[num] = C2[Q] + 1; que.push(num);
      }
    }
  }
  return 0;
}


int main(){
  Prepare();
  while (cin >> N){
    if (N == 0) return 0;
    cout << C1[N] << " " << C2[N] << endl;
  }
  
  return 0;
}



Measured memory_bytes: 12452
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX
#define MAX 100000

using namespace std;
using LL=long long;

int parent(int i){return i/2;}
int left(int i){return i*2;}
int right(int i){return i*2+1;}

int main(){
    int H,i,A[MAX+1];
    cin>>H;
    for(i=1;i<=H;i++) cin>>A[i];
    for(i=1;i<=H;i++){
        cout<<"node "<<i<<": key = "<<A[i]<<", ";
        if(parent(i)>=1) cout<<"parent key = "<<A[parent(i)]<<", ";
        if(left(i)<=H) cout<<"left key = "<<A[left(i)]<<", ";
        if(right(i)<=H) cout<<"right key = "<<A[right(i)]<<", ";
        cout<<endl;
    }
    return 0;
}



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

vector<vector<int>> adj;
vector<int> dist1,dist2;

void dfs1(int cur,int prv){
  for(auto nxt:adj[cur]){
    if(nxt==prv)continue;
    dfs1(nxt,cur);
    dist1[cur] = max(dist1[cur],dist1[nxt]+1);
  }
}

void dfs2(int cur,int prv){
  vector<pair<int,int>> tmp;
  tmp.emplace_back(dist2[cur],prv);
  for(auto nxt:adj[cur]){
    if(nxt==prv)continue;
    tmp.emplace_back(dist1[nxt]+1,nxt);
  }
  sort(tmp.begin(),tmp.end(),greater<>());
  for(auto nxt:adj[cur]){
    if(nxt==prv)continue;
    dist2[nxt] = max(dist2[nxt],tmp[tmp[0].second==nxt].first+1);
    dfs2(nxt,cur);
  }
}

signed main(){

  int n;
  cin>>n;
  adj.resize(n);
  dist1.resize(n);
  dist2.resize(n);
  for(int i=0;i<n-1;++i){
    int u,v;
    cin>>u>>v;
    u--;v--;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }
  dfs1(0,-1);
  dfs2(0,-1);
  for(int i=0;i<n;++i){
    cout<<(n-1)*2-max(dist1[i],dist2[i])<<endl;
  }

}


Measured memory_bytes: 24688
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
struct edge{int v,nxt,f;};
class Graph{
	edge e[200100];
	int tot,head[1010],cur[1010],b[1010];
public:
	int t;
	Graph(){tot=1;memset(head,0,sizeof(head));}
	void add(int x,int y,int z){
		e[++tot]={y,head[x],z};
		head[x]=tot;
		e[++tot]={x,head[y],0};
		head[y]=tot;
	}
	bool bfs(){
		memset(b,0,sizeof(b));b[0]=1;
		queue<int> q;q.push(0);
		while(!q.empty()){
			int u=q.front();q.pop();
			for(int i=head[u];i;i=e[i].nxt)
				if(e[i].f&&!b[e[i].v]){
					b[e[i].v]=b[u]+1;
					q.push(e[i].v);
				}
		}
		return b[t];
	}
	int dfs(int x,int flow){
		if(x==t||!flow) return flow;
		int f=flow,tmp;
		for(int &i=cur[x];i;i=e[i].nxt)
			if(b[e[i].v]==b[x]+1&&(tmp=dfs(e[i].v,min(e[i].f,f)))){
				f-=tmp;
				e[i].f-=tmp;e[i^1].f+=tmp;
				if(!f) break;
			}
		return flow-f;
	}
	int Dinic(){
		int ans=0;
		while(bfs()){
			memcpy(cur,head,sizeof(cur));
			ans+=dfs(0,100000000);
		}
		return ans;
	}
	int chk(int x){
		for(int i=head[x];i;i=e[i].nxt)
			if(e[i].v&&!e[i].f) return e[i].v;
	}
};
int n,m,a[110][110],ans1[110][110],ans2[110][110];
stack<int> h[110][110];
int main(){
	read(n);read(m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			int x;read(x);
			h[i][(x-1)/m+1].push(x);
		}
	for(int k=1;k<=m;k++){
		Graph G;G.t=2*n+1;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				if(h[i][j].size()) G.add(i,j+n,1);
		for(int i=1;i<=n;i++)
			G.add(0,i,1),G.add(i+n,G.t,1);
		G.Dinic();
		for(int i=1;i<=n;i++){
			int p=G.chk(i)-n;
			int now=h[i][p].top();h[i][p].pop();
			ans1[i][k]=now;
			ans2[p][k]=now;
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cout<<ans1[i][j]<<" \n"[j==m];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cout<<ans2[i][j]<<" \n"[j==m];
	return 0;
}


Measured memory_bytes: 8832
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		int R = sc.nextInt();
		int d = sc.nextInt();
		int ans = 0;
		for(int i = L; i <= R; i++)
			if(i % d == 0)
				ans++;
		System.out.println(ans);
	}

}


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

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	string s, t;
	int q;
	cin >> s >> q;
	while (q--) 
	{
		int type;
		cin >> type;
		if (type == 1) swap(s,t);
		else 
		{
			int f; char c;
			cin >> f >> c;
			if (f == 1) t.push_back(c);
			else s.push_back(c);
		}
	}
	reverse(t.begin(), t.end());
	cout << t + s;
    return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, modinv, bitSearch, bitList, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 0;
vl flag, color; vll path; vl D; ll C;
//***********//
int main() {
	cin >> N;
	vl A(N), B(N);
	ll allEqual = 1;
	for (i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		if (A[i] != B[i]) allEqual = 0;
		ans += A[i];
	}
	if (allEqual) cout << 0;
	else {
		ll count = 0; ll pre = INF;
		for (i = 0; i < N; i++) {
			if (A[i] > B[i]) pre = min(pre, B[i]);
		}
		cout << ans-pre;
	}
}

Measured memory_bytes: 512
#include <stdio.h>

void call(int n){
  int i=1,x;
  
  while(i <= n){
    x = i;
    if(x % 3 == 0)//CHECK_SUM:
      printf(" %d",i);
    else{//INCLUDE3:
      while(x){
	if(x % 10 == 3){
	  printf(" %d", i);
	  break;
	}
	else
	  x /= 10;
      }
    }
    //END_CHECK_NUM:
    i++;
  }
  
  printf("\n");
}


int main(){
  int n;

  scanf("%d", &n);
  call(n);
  
  return 0;
}

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

using namespace std;

const int N=1e6+3;

const double eps=1e-9;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;

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

const int mod=1e9+7;

int n,a[N],b[N],m,k,q,u,v,x,y,tc,l,r,c,ans;

char s[N],grid[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

int main(){
	//IO();
	cin >> n;
	set<string> ans;
	while(n--){
		string s;
		cin >> s;
		ans.insert(s);
	}
	printf("%d\n",sz(ans));
}


Measured memory_bytes: 19360
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



int main() {
	
	ll x, a, b;
	cin >> x >> a >> b;
	cout << (x - a) % b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define re cin>>
#define pr cout<<
#define in(x) scanf("%d",&x)
#define inn(x,y) scanf("%d%d",&x,&y)
#define innn(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)

const int N=2e6+5;
const int mod=1e9+7;

string s;
bool check(int i, int j){
    while(i<=j){
        if(s[i]!=s[j]) return 0;
        i++,j--;
    }
    return 1;
}
int main(){
    cin>>s;
    if(check(0,s.size()-1) && check(0,(s.size()/2-1))) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
bool dfs(int x,int y,int h,int w,vector<vector<bool> >& map){

for(int i=2;i<=3;i++){
	if(map[x+dx[i]][y+dy[i]]){
		return false;
	}
}

map[x][y]=false;
if(x==h&&y==w){
		return true;
	}
if(map[x+dx[0]][y+dy[0]]&&map[x+dx[1]][y+dy[1]]){
	return false;
}else if(map[x+dx[0]][y+dy[0]]){
	return dfs(x+dx[0],y+dy[0],h,w,map);
}else{
	return dfs(x+dx[1],y+dy[1],h,w,map);
}
	

}
int main(void){
	int h,w;
	cin>>h>>w;
	vector<vector<bool> > map(h+2,vector<bool>(w+2,false));
	char a;
for(int i=1;i<=h;i++){
	for(int j=1;j<=w;j++){
cin>>a;
if(a=='#'){
	map[i][j]=true;
}
	}
}
if(dfs(1,1,h,w,map)){
	cout<<"Possible"<<endl;
}else{
	cout<<"Impossible"<<endl;
}
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := make([]int, N)
	B := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = sc.NextInt()
		B[i] = sc.NextInt()
	}
	p := 0
	for i := N - 1; i >= 0; i-- {
		d := (B[i] - ((A[i] + p) % B[i])) % B[i]
		p += d
	}
	fmt.Println(p)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 6528
S=input()
data=[0 for i in range(len(S))]

count=0
for i in range(len(S)-1):

    if S[i]+S[i+1]=="RL":
        count+=1
        #print(count,count%2)
        data[i+1]+=int(count/2)
        data[i]+=int(count/2)+count%2
        count=0
    elif S[i]=="R":
        count+=1
    #print(data,i,count)
count=0
#print(data)
for i in range(len(S)-2,-1,-1):
    if S[i]+S[i+1]=="RL":
        count+=1
        #print(count)
        data[i]+=int(count/2)
        data[i+1]+=int(count/2)+count%2
        count=0
    elif S[i+1]=="L":
        count+=1
    #print(data,i,count)
data=list(map(str,data))
print(" ".join(data))


Measured memory_bytes: 10364
mod=10**9+7
N,K=map(int,input().split())

def P(x, y):
    r = 1
    for i in range(y):
        r = (r * (x - i)) % mod
    return r
g=[0]*(N+1)
for v in range(N-1):
    a,b=map(int,input().split())
    g[a] += 1
    g[b] += 1
r = 1
for v in range(N-1):
    r=(P(K-2,g[v+1]-1)*r)%mod
print((K*P(K-1,g[-1])*r)%mod)



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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);

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

    for (int i = 0; i < N; i++)
    {
        if ((A.at(i) % 2) == 0)
        {
            if (((A.at(i) % 3) == 0) || ((A.at(i) % 5) == 0))
            {
            }
            else
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

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

sum_of_pairs = 0
for i,rabbit in enumerate(like_rabbits_list):
    if like_rabbits_list[rabbit - 1] == (i+1):
        sum_of_pairs += 1

print (int(sum_of_pairs / 2))

Measured memory_bytes: 14008
c = [[0]*10 for _ in range(10)]

n = int(input())

for i in range(1,n+1):
    si = str(i)
    c[int(si[0])][int(si[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j]*c[j][i]

print(ans)

Measured memory_bytes: 73660
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

from itertools import product

N,M = II()
x,y,z = Line(N)

a = [[0]*N for _ in range(8)]
p = list(product(['1','-1'],repeat=3))

for i,p0 in enumerate(p):
    for j in range(N):
        a[i][j] = eval(p0[0])*x[j]+eval(p0[1])*y[j]+eval(p0[2])*z[j]

for i in range(8):
    a[i].sort(reverse=True)

ans = -float('inf')
for i in range(8):
    temp = sum(a[i][:M])
    if temp>ans:
        ans = temp

print(ans)

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

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

  long long tk, nk, hk;
  tk = b + c;
  nk = a + c;
  hk = a + b;
  long long e = 1000000000000000000;
  long long ans;
  if (abs(ans) > e) {
    cout << "Unfair" << endl;
  } else {
    if (k == 0) {
      ans = a - b;
      cout << ans << endl;
    } else {
      if (k % 2 != 0) {
        ans = tk - nk;
        cout << ans << endl;
      } else {
        ans = tk - nk;
        ans *= -1;
        cout << ans << endl;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
map <int, int> mp;
int work(int n)
{
	for(int i = 1; i < 1e4 + 5; i++) {
		int x = i;
		vector <int> v;
		while(x) {
			v.pb(x % 10);
			x /= 10;
		}
		int l = v.size();
		if(l != n) continue;
		
		reverse(all(v));
		bool poss = true;
		for(auto it : mp) {
			if(it.s != v[it.f - 1]) {
				poss = false;
				break;
			}
		}
		if(poss) return i;
	}
	bool zero = false;
	if(n == 1) {
		for(auto it : mp) {
			if(it.s == 0)
			return 0;
		}
	}
	
	return -1;
}
int main()
{
	boost;
	int n, m, i;
	bool poss = true;
	cin >> n >> m;
	if(n == 1 && m == 0) {
		cout << 0;
		return 0;
	}
	fo(i, 0, m) {
		int x, y;
		cin >> x >> y;
		if(x == 1 && y == 0 && n != 1) poss = false;
		if(mp[x]) {
			if(mp[x] != y) 
			poss = false;
		}
		mp[x] = y;
	}
	if(!poss) {
		cout << -1;
		return 0;
	}
	cout << work(n);
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define rep(i, a, n)  for(int i=0; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define pb  push_back
#define eb  emplace_back

const int INF = 1<<28;
const int MOD = 1000000007;

int len;
bool isAns;
string str;
void solve(string s, int sum, int cur){
  if(cur == len){
    if(sum == 7 && isAns){
      s += "=7";
      cout << s << endl;
      isAns = false;
      return;
    }
    return;
  }
  solve(s+'+'+str[cur], sum+(str[cur]-'0'), cur+1);
  solve(s+'-'+str[cur], sum-(str[cur]-'0'), cur+1);
}

int main(){
  cin >> str;
  isAns = true;
  len = SZ(str);
  solve(str.substr(0,1), str[0]-'0', 1);
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>


int main() {
	int i, a, b, c,count = 0;
	
	scanf("%d %d %d", &a, &b, &c);

	for (i = a; i < b+1 ; i++) {
		if (c % i == 0) {
			count++;
		}
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 2140
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const LL MOD = 1000000007LL;
int main() {
	string S;
	cin >> S;
	reverse(S.begin(), S.end());
	string words[] = { "dream","dreamer","erase","eraser" };
	for (int i = 0; i < 4; i++) reverse(words[i].begin(), words[i].end());
	int pos = 0;
	while (pos < S.size()) {
		bool NG = 1;
		for (int i = 0; i < 4; i++) {
			if (pos + words[i].size() <= S.size() && S.substr(pos, words[i].size()) == words[i]) {
				pos += words[i].size();
				NG = 0;
				break;
			}
		}
		if (NG) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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 MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}
 

void solve() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int mn = INF;
    REP(i, max(x, y) + 1) {
        chmin(mn, 2 * c * i + a * max(0, x - i) + b * max(0, y - i));
    }
    cout << mn << EOL;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

int dp[55][55] = {};
int dp2[55][55] = {};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	int N, A, B; cin >> N >> A >> B;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
	dp[0][0] = 0;
	dp2[0][0] = 1;
	rep(i, 0, N)rep(j, 0, 51) {
		if (dp[i + 1][j + 1] == dp[i][j] + v[i]) {
			dp2[i + 1][j + 1] += dp2[i][j];
		}
		else if (chmax(dp[i + 1][j + 1], dp[i][j] + v[i])) {
			dp2[i + 1][j + 1] = dp2[i][j];
		}
		if (dp[i + 1][j] == dp[i][j]) {
			dp2[i + 1][j] += dp2[i][j];
		}
		else if (chmax(dp[i + 1][j], dp[i][j])) {
			dp2[i + 1][j] = dp2[i][j];
		}
	}
	int ans = dp[N][A], ans_n = A, ans2 = dp2[N][A];
	rep(i, A + 1, B + 1) {
		dump(ans, ans_n, ans2);
		if (ans*i == dp[N][i] * ans_n) {
			ans2 += dp2[N][i];
		}
		else if (ans*i < dp[N][i] * ans_n) {
			ans = dp[N][i];
			ans_n = i;
			ans2 = dp2[N][i];
		}
	}
	cout << (double)ans / ans_n << endl;
	cout << ans2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, X;
    int L[200]={};
    int pos=0;
    int cnt = 1;
    cin >> N >> X;
    for(int i=0;i<N;i++){
        cin >> L[i];
        pos += L[i];
        if(pos <= X){
            cnt++;
        }else{
            break;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 1e5;

int N, A, B;

int main() {

    cin >> N >> A >> B;
    int mx = min(A, B);
    int mn = max(0, A+B-N);
    cout << mx << " " << mn << endl;
    return 0;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		// スペース区切りの整数の入力
		int amari = n%28;

		boolean flag= isflag(amari);
		if(flag){

			System.out.println("Yes");
		}else {
			amari=amari-7;

				if(amari>0&&isflag(amari)){
					System.out.println("Yes");
				}else {
					amari=amari-7;

						if(amari>0&&isflag(amari)){
							System.out.println("Yes");
						}else {
							amari=amari-7;

							if(amari>0&&isflag(amari)){
								System.out.println("Yes");
							}else {
								System.out.println("No");		
							}
						}
				}
		}




	}

	public static boolean isflag(int amari) {
		boolean flag =false;
		if(amari == 4){
			flag=true;
		}else if(amari == 4){
			flag=true;
		}else if(amari %4==0){
			flag=true;
		}else if(amari %7==0){
			flag=true;
		}else if(amari %7==4){
			flag=true;
		}
		return flag;
	}

}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	string S;
	cin >> S;
	int year = stoi(S.substr(0,4));
	int month = stoi(S.substr(5,2));
	int day = stoi(S.substr(8,2));
	debug(year)
	debug(month)
	debug(day)
	if(year < 2019){
		cout << "Heisei" << endl;
		return 0;
	}
	if(year > 2019){
		cout << "TBD" << endl;
		return 0;
	}
	if(month < 4){
		cout << "Heisei" << endl;
		return 0;
	}
	if(month > 4){
		cout << "TBD" << endl;
		return 0;
	}
	if(day <= 30){
		cout << "Heisei" << endl;
		return 0;
	}
	cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define P 1000000007
#define M 2005
int c[2005][2005];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<M;++i){
		c[i][0]=1;
		for(int j=1;j<=i;++j)c[i][j]=(c[i-1][j-1]+c[i-1][j])%P;
	}
	for(int i=1;i<=k;++i){
		int w=c[k-1][i-1],m=n-k-i+1;
		w=1ll*w*c[m+i][i]%P;
		printf("%d\n",w);
	}
}

Measured memory_bytes: 15104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		String relation;

		if(a > b){
			relation = ">";
		}else if(a < b){
			relation = "<";
		}else{
			relation = "==";
		}

		System.out.printf("a %s b\n", relation);
	}
}




Measured memory_bytes: 26328
#include<iostream>

using namespace std;

int main()
{
	int n;
	bool can = false;

	cin >> n;

	for(int i=0; i<=n/4; i++){
		for(int j=0; j<=n/7; j++){
			if((4 * i) + ( 7 * j) == n)
				can = true;
		}	
	}
		if(!can)
			cout << "No" << endl;
		else 
			cout << "Yes" << endl;
	}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res="{"; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res+"}";}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H,W;
  cin >> H >> W;
  MAT2D(m,int,H+2,W+2);
  REP(i,H) {
    string s;
    cin >> s;
    REP(j,W) {
      if (s[j] == '.') m[i+1][j+1] = 1;
    }
  }
  MAT3D(d,int,H+2,W+2,4);
  RREP(i,1,H+1) {
    RREP(j,1,W+1) {
      if (m[i][j] == 1) {
        d[i][j][0] = d[i][j-1][0] + 1;
        d[i][j][1] = d[i-1][j][1] + 1;
      }
      int ri = H+1-i, rj = W+1-j;
      if (m[ri][rj] == 1) {
        d[ri][rj][2] = d[ri][rj+1][2] + 1;
        d[ri][rj][3] = d[ri+1][rj][3] + 1;
      }
    }
  }
  int ans = 0;
  RREP(i,1,H+1) {
    RREP(j,1,W+1) {
      ans = max(ans, accumulate(d[i][j].begin(), d[i][j].end(), 0));
    }
  }
  cout << ans - 3 << endl;
  return 0;
}

Measured memory_bytes: 235392