akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
using Graph = vector<vector<pair<int, int> > >;
typedef long long ll;
typedef pair<ll, ll> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

vector<int> color;

Graph g(100010);

void dfs(int current, int col) {
	color[current] = col;
	for (int i = 0; i < g[current].size(); i++) {
		if (color[g[current][i].first] != 0)continue;
		else {
			if (g[current][i].second % 2 == 0) {
				dfs(g[current][i].first, col);
			}
			else dfs(g[current][i].first, -1 * col);
		}
	}
	return;
}



int main(){
	int N; cin >> N;
	for (int i = 0; i < N-1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		g[u].push_back(pair<int, int>(v, w));
		g[v].push_back(pair<int, int>(u, w));
	}
	color.assign(N, 0);

	for (int i = 0; i < N; i++) {
		if (color[i] != 0)continue;
		dfs(i, 1);
	}
	for (int i = 0; i < color.size(); i++) {
		cout << max(color[i], 0) << endl;
	}


	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 5;

int n;
bitset<N> val, seen;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<int> a(n);
    for (auto& i : a) cin >> i;
    sort(a.begin(), a.end());
    
    val.set(); seen.reset();
    int ans = 0;
    for (auto i : a) {
        if (!val[i]) continue;
        else {
            if (seen[i]) {
                val[i] = false;
                ans--;
                continue;
            }

            ans++;
            seen[i] = true;
            for (int j = i + i; j < N; j += i) val[j] = false;
        }
    }

    cout << ans;
}


Measured memory_bytes: 4264
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  
  int x, a, b;
  readf("%s %s %s\n", &x, &a, &b);

  if (a - b >= 0) {
    writeln("delicious");
  } else if (a - b + x >= 0) {
    writeln("safe");
  } else {
    writeln("dangerous");
  }
}


Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int t[64];
int d[100100];
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}

void Solve() {

	int n, m;
	cin >> n >> m;

	int t[35];
	fill(t, t + m + 1, 0);
	for (size_t i = 0; i < n; i++)
	{
		int k;
		cin >> k;
		for (size_t j = 0; j < k; j++)
		{
			int a;
			cin >> a;
			t[a]++;
		}
	}

	int res = 0;
	for (size_t i = 1; i <= m; i++)
	{
		if (t[i] == n) res++;
	}

	cout << res << endl;
}


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



Measured memory_bytes: 6016
N = int(input())
F = []
P = []
for _ in range(N):
    F.append([int(f) for f in input().split()])
for _ in range(N):
    P.append([int(p) for p in input().split()])
res = []
for bit in range(1, 1 << 10):
    open_times = []
    for i in range(10):
        if((bit >> i) & 1) == 1 and P:
            open_times.append(i)

    profit = 0
    for i in range(N):
        num_open = 0
        for open_time in open_times:
            if F[i][open_time]:
                num_open += 1
        profit += P[i][num_open]
    res.append(profit)

print(max(res))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int inf = 100000000;

int main() {
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<int>> field(h,vector<int>(w));
  rep(i,0,h) {
    string s;
    cin >> s;
    rep(j,0,w) field[i][j] = s[j]-'0';
  }
  int ans = 10000000;
  vector<int> ws;
  rep(bit,0,1<<(h-1)) {
    int c = __builtin_popcount(bit);
    int a = 0; int p;
    bool flag = false;
    ws.assign(c+1,0);
    rep(j,0,w) {
      int q = 0;
      rep(i,0,h) {
        ws[q] += field[i][j];
        if (ws[q] > k) flag = true;
        if (bit & (1 << i)) q++;
      }
      if (flag) {
        if (p == j) {
          a = inf;
          break;
        }
        p = j;
        a++; j--;
        ws.assign(c+1,0);
        flag = false;
      }
    }
    ans = min(ans,a+c);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		private const int mod = 1000000007;  // 10^9+7

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int x = n % 10;
			switch (x) {
				case 2:
				case 4:
				case 5:
				case 7:
				case 9:
					Console.WriteLine("hon");
					break;
				case 0:
				case 1:
				case 6:
				case 8:
					Console.WriteLine("pon");
					break;
				case 3:
					Console.WriteLine("bon");
					break;
			}
		}

	}
}


Measured memory_bytes: 27464
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
struct in {
    int n; in() {} in(int n_) : n(n_){}
    template <class T> operator T() { T ret; cin >> ret; return ret; }
    template <class T> operator vector<T>() { vector<T> ret(n); for (int i = 0; i < n; i++) cin >> ret[i]; return ret; }
};
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Jan 11 20:00:19 JST 2020
 **/

signed main() {
    Int n = in();
    vector<string> ss(n);
    vector<Int> ts(n);
    REP(i, n) cin >> ss[i] >> ts[i];
    string s = in();
    Int ans = 0;
    bool done = false;
    REP(i, n) {
        if (done) ans += ts[i];
        if (ss[i] == s) done = true;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
int main() {
    ll L,N;
    cin >> L >> N;
    vector<string> str(L);
    rep(i,L){
        cin >> str[i];
    }
    sort(all(str));
    rep(i,L){
        cout << str[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>

using namespace std;

int main()
{
    string s;
    getline(cin,s);
    if(s=="ABC")
    {
        printf("ARC\n");
    }
    else
    {
        printf("ABC\n");
    }
    
    //system("pause");
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 998244353;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = n*2;
    ll b = 1;
    unordered_map<int,ll> mp;
    for (int i = n-1;i >= 0;--i) {
        if (s[i] == '1') (ans += 2*b*n) %= mod;
        (b *= 2) %= mod;
    }
    for (int x = n/2*2+1;x > 2;x -= 2)  if (n%x == 0) {
        b = 1;
        ll cnt = 0;
        for (int i = n/x-1;i >= 0;--i) {
            if (s[i] == '1') (cnt += b) %= mod;
            (b *= 2) %= mod;
        }
        string t = "",u = s.substr(0,n/x),revu = "";
        for (int i = 0;i < n/x;++i) {
            if (s[i] == '1') revu += '0';
            else revu += '1';
        }
        for (int i = 0;i < x;++i) {
            if (i&1) t += revu;
            else t += u;
        }
        if (t <= s) cnt++;
        (cnt -= mp[x]) %= mod;
        (ans -= (n*2-n*2/x)*cnt%mod) %= mod;
        for (int i = x-2;i > 2;i -= 2) if (x%i == 0 && n%i == 0) (mp[i] += cnt) %= mod;
    }
    cout << (ans+mod)%mod << endl;
}

Measured memory_bytes: 1068
A, B = map(int, input().split())
for x in range(max(int(12.5 * A), int(10 * B)), min(int(12.5 * A + 12.5), int(10 * B + 10)) + 1):
    if int(x * 0.08) == A and int(x * 0.1) == B:
        print(x)
        break
else: print(-1)

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

typedef long long ll;
const int mod = 1e9+7;
const int maxn = 1e4+5;
ll a[maxn];
int p[1000005];
ll inv[1000005];
void getinv()
{
	inv[1] = 1;
	for(int i=2;i<1000005;i++)
	{
		inv[i] = (ll)(mod - mod/i)*inv[mod%i]%mod;
		inv[i] = (inv[i]%mod+mod)%mod;
		//cout<<inv[i]<<" ";
	}
}

int main()
{
	int n;
	getinv();
	while(cin>>n)
	{
		memset(p,0,sizeof(p));
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			int tmp = a[i];
			for(int j=2;j*j<=a[i];j++)
			{
				int cnt = 0;
				while(tmp%j==0)
				{
					tmp/=j;
					cnt++;
				}
				if(cnt > p[j])
				{
					p[j] = cnt;
				}
				//if(cnt>0) cout<<j<<" "<<cnt<<" ";
			}
			if(tmp>=2) 
			{
				p[tmp] = max(1,p[tmp]);
			}
		}
		ll lcm = 1;
		for(int i=0;i<1000005;i++)
		{
			if(p[i]>0)
			{
				lcm = lcm*pow(i,p[i]);
				lcm%=mod;
			}
			
		}//cout<<lcm<<"\n";
		ll ans = 0;
		for(int i=1;i<=n;i++)
		{
			ans+=lcm*inv[a[i]]%mod;
			ans=(ans%mod+mod)%mod;
		} 
		cout<<ans<<"\n";
	}
}
/*
5
1000000 999999 999998 999997 999996
*/

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

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

  int ans = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (500 * i + 100 * j + 50 * k == x) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
}

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

    divisors.sort()
    return divisors
def main():
    N = int(input())
    div = make_divisors(N)
    res = 0
    for p in div:
        m = (N // p) - 1
        if p == m:
            continue
        if p >= m:
            break
        res += m
    print(res)
main()

Measured memory_bytes: 3264
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void Unification()//problem120
{
  string st;
  cin >> st;
  int zero_count = 0;
  int one_count = 0;
  for (int i = 0; i < st.length(); i++)
  {
    if (st[i] == '0') zero_count++;
    else one_count++;
  }
  int ans = min(zero_count, one_count);

  cout << ans * 2 << endl;
  return;
}


int main()
{
  Unification();
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    String strFront = sc.next();
    String strBlue = sc.next();
    String strRed = sc.next();
    long Front = Long.parseLong(strFront);
    long Blue = Long.parseLong(strBlue);
    long Red = Long.parseLong(strRed);
    
    if(Blue == 0) {
    	System.out.println(0);
    	return;
    }
    long cycle = Front / (Blue + Red);
    long remainder = Front % (Blue + Red);
    if(remainder > Blue) {
    	remainder = Blue;
    }
    
    System.out.println(cycle * Blue + remainder);

}
}

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


using namespace std;

#define int long long

int  m =1e9+7;


int32_t main()
{

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


	char a[h+1][w+1];

	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>a[i][j];
		}
	}

	int dp[h+1][w+1];


	memset(dp,0,sizeof(dp));


	if(a[1][1]=='.')
		dp[1][1]=1;



	for(int i=2;i<=w;i++)
	{
		if(a[1][i]=='#')
			dp[1][i]=0;
		else
			dp[1][i]=dp[1][i-1];

	}

	for(int i=2;i<=h;i++)
	{
		if(a[i][1]=='#')
			dp[i][1]=0;
		else
			dp[i][1]=dp[i-1][1];

	}


	for(int i=2;i<=h;i++)
	{
		for(int j=2;j<=w;j++)
		{
			if(a[i][j]=='#')
				dp[i][j]=0;
			else
				dp[i][j]=dp[i-1][j]%m + dp[i][j-1]%m;


			dp[i][j]=dp[i][j]%m;
		}
	}

	cout<<dp[h][w]<<endl;



}

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

const ll mod = 1e9 + 7;
int N;
string S;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> N >> S;
	vector<vector<ll>> dp(N + 1, vector<ll> (N + 1, 0));
	dp[1][1] = 1;
	for (int i = 2; i <= N; i++) {
		vector<ll> pre(i, 0);
		for (int j = 1; j < i; j++) {
			pre[j] = (pre[j - 1] + dp[i - 1][j]);
			if (pre[j] >= mod)
				pre[j] -= mod;
		}
		for (int j = 1; j <= i; j++) {
			int l, r;
			if (S[i - 2] == '<') {
				l = 1, r = j - 1;
			} else {
				l = j, r = i - 1;
			}
			if (l <= r) {
				dp[i][j] = (pre[r] - pre[l - 1] + mod);
				if (dp[i][j] >= mod)
					dp[i][j] -= mod;
			}
		}
	}
	ll answer = 0;
	for (int i = 1; i <= N; i++) {
		answer += dp[N][i];
		if (answer >= mod)
			answer -= mod;
	}
	cout << answer;

	return 0;
}

Measured memory_bytes: 74080
import java.util.*;
import java.awt.Frame;
import java.io.*;

public class Main {
	// static ArrayList<Integer>[] g;

	static pair[] a;
	static int[][] memo;

	static int dp(int l, int r) {
		if (l > r)
			return 0;
		if (memo[l][r] != -1)
			return memo[l][r];
		int ans = dp(l + 1, r);
		ans = Math.max(ans, dp(l, r - 1));
		for (int idx : startAt[l]) {
			if (a[idx].y >= r)
				continue;
			int inc = exist[a[idx].y + 1][r] ? 1 : 0;
			ans = Math.max(ans, 1 + dp(a[idx].x, a[idx].y) + inc + dp(a[idx].y + 1, r));
		}
		for (int idx : endAt[r]) {
			if (a[idx].x <= l)
				continue;
			int inc = exist[l][a[idx].x - 1] ? 1 : 0;
			ans = Math.max(ans, 1 + dp(a[idx].x, a[idx].y) + inc + dp(a[idx].y + 1, r));
		}

		return memo[l][r] = ans;
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
				char[] a=br.readLine().toCharArray();
				if(a[0]=='R' && a[1]=='R' && a[2]=='R')
					pw.println(3);
				else if((a[0]=='R' && a[1]=='R')|| (a[1]=='R' && a[2]=='R'))
					pw.println(2);
				else if(a[0]=='R' || a[1]=='R'|| a[2]=='R')
					pw.println(1);
				else
					pw.println(0);

		pw.flush();
		pw.close();

	}

	static int maxSize;
	static boolean[][] exist;
	static ArrayList<Integer>[] startAt, endAt;

	static void compress(pair[] arr) {
		TreeSet<Integer> tr = new TreeSet<>();
		for (int i = 0; i < arr.length; i++) {
			tr.add(arr[i].x);
			tr.add(arr[i].y);
		}
		tr.add(0);
		tr.add((int) 1e9);
		HashMap<Integer, Integer> hm = new HashMap<>();
		for (int x : tr)
			hm.put(x, hm.size());
		for (int i = 0; i < arr.length; i++) {
			arr[i].x = hm.get(arr[i].x);
			arr[i].y = hm.get(arr[i].y);
		}
		maxSize = hm.size();
	}

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int d, int u) {
			x = d;
			y = u;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			int x1 = y - x;
			int x2 = o.y - o.x;
			return x1 - x2;
		}

	}

}

Measured memory_bytes: 32904
#include<iostream>
#include<array>
#include<algorithm>
 
using namespace std;
 
int main(){
    
    array<int, 3> ar;
 
    for(int i = 0; i < 3; i++){
        cin >> ar[i];
    }
 
    sort(ar.begin(), ar.end());

    cout << ar[2] * 10 + ar[1] + ar[0] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C'){
			for(int j=i+1;j<s.size();j++){
				if(s[j]=='F'){
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;

  int ans = 0;
  for(int i = 0; i < 2; i++)
  {
    if (H >= W) {
      ans += H;
      H--;
    }else{
      ans += W;
      W--;
    }
    
  }
  
  cout << ans << endl;

  return 0;

}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong N, M;
	vector<llong> S, T;
	vector<vector<llong> > dp;

	cin >> N >> M;
	S.resize(N+1);
	T.resize(M+1);
	for (int i = 1; i <= N; ++i)
		cin >> S[i];
	for (int i = 1; i <= M; ++i)
		cin >> T[i];

	dp.resize(N+1, vector<llong>(M+1, 0));
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= M; ++j) {
			if (S[i] == T[j])
				dp[i][j] = (dp[i-1][j] + dp[i][j-1] + 1)%mod;
			else
				dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]+mod)%mod;
		}
	}

	cout << (dp[N][M]+1)%mod << endl;

	return 0;
}

Measured memory_bytes: 31616
S = input()

N = len(S)
ans = [0] * (N+1)

for i in range(N):
    if S[i] == '<':
        ans[i+1] = ans[i] + 1

for i in range(N-1, -1, -1):
    if S[i] == '>' and ans[i] <= ans[i+1]:
        ans[i] = ans[i+1]+1
print(sum(ans))


Measured memory_bytes: 29216
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
      line=line.replace("1",",");
      line=line.replace("9","1");
      line=line.replace(",","9");
        System.out.println(line);
    }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    VI p(n);
    rep(i,n) cin >> p[i];
    int cou = 0;
    rep(i,n) if(p[i] != i + 1) cou++;
    if(cou <= 2) {
        YES;
    }else{
        NO;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Edge {
    int to;
    ll cost;
};
using Graph = vector<vector<Edge>>;

// 幅優先探索
vector<ll> dist;  // 始点からの距離を記録
void bfs(const Graph &G, int s) {
    const ll INF = 1e15;
    dist.assign((int)G.size(), INF);  // 初期化

    queue<int> que;
    que.emplace(s);  // sから探索する
    dist[s] = 0;
    while (que.size() != 0) {   // 幅優先探索
        int now = que.front();  // 現在の状態
        que.pop();
        for (auto e : G[now]) {
            if (dist[e.to] == INF) {  // 未探索の時のみ行う
                dist[e.to] = dist[now] + e.cost;
                que.emplace(e.to);
            }
        }
    }
}

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

    int V;
    cin >> V;

    Graph G(V);
    for (int i = 0; i < V - 1; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }

    int Q, K;
    cin >> Q >> K;
    K--;
    vector<int> x(Q), y(Q);
    for (int i = 0; i < Q; i++) {
        cin >> x.at(i) >> y.at(i);
        x[i]--, y[i]--;
    }
    bfs(G, K);

    for (int i = 0; i < Q; i++) {
        cout << dist[x[i]] + dist[y[i]] << "\n";
    }

    return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
template<int NV,class V> class MinCostFlow {
public:
	struct edge { int to; V capacity; V cost; int reve;};
	vector<edge> E[NV]; int prev_v[NV], prev_e[NV]; V dist[NV];
	void add_edge(int x,int y, V cap, V cost) {
		E[x].push_back((edge){y,cap,cost,(int)E[y].size()});
		E[y].push_back((edge){x,0, -cost,(int)E[x].size()-1}); /* rev edge */
	}
	
	V mincost(int from, int to, ll flow) {
		V res=0; int i,v;
		ZERO(prev_v); ZERO(prev_e);
		while(flow>0) {
			fill(dist, dist+NV, numeric_limits<V>::max()/2);
			dist[from]=0;
			priority_queue<pair<V,int> > Q;
			Q.push(make_pair(0,from));
			while(Q.size()) {
				V d=-Q.top().first;
				int cur=Q.top().second;
				Q.pop();
				if(dist[cur]!=d) continue;
				if(d==numeric_limits<V>::max()/2) break;
				FOR(i,E[cur].size()) {
					edge &e=E[cur][i];
					if(e.capacity>0 && dist[e.to]>d+e.cost) {
						dist[e.to]=d+e.cost;
						prev_v[e.to]=cur;
						prev_e[e.to]=i;
						Q.push(make_pair(-dist[e.to],e.to));
					}
				}
			}
			
			if(dist[to]==numeric_limits<V>::max()/2) return -1;
			ll lc=flow;
			for(v=to;v!=from;v=prev_v[v]) lc = min(lc, E[prev_v[v]][prev_e[v]].capacity);
			flow -= lc;
			res += lc*dist[to];
			for(v=to;v!=from;v=prev_v[v]) {
				edge &e=E[prev_v[v]][prev_e[v]];
				e.capacity -= lc;
				E[v][e.reve].capacity += lc;
			}
		}
		return res;
	}
};

MinCostFlow<3000,ll> mcf;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	int S=0;
	FOR(i,N) {
		cin>>x>>y>>r;
		S+=r;
		mcf.add_edge(0,1+i,r,0);
		mcf.add_edge(1+i,N+1,10000,x+y+(2LL<<30));
		mcf.add_edge(1+i,N+2,10000,x-y+(2LL<<30));
		mcf.add_edge(1+i,N+3,10000,-x+y+(2LL<<30));
		mcf.add_edge(1+i,N+4,10000,-x-y+(2LL<<30));
	}
	FOR(i,N) {
		cin>>x>>y>>r;
		mcf.add_edge(N+5+i,2*N+6,r,0);
		mcf.add_edge(N+1,N+5+i,10000,-x-y+(2LL<<30));
		mcf.add_edge(N+2,N+5+i,10000,-x+y+(2LL<<30));
		mcf.add_edge(N+3,N+5+i,10000,x-y+(2LL<<30));
		mcf.add_edge(N+4,N+5+i,10000,x+y+(2LL<<30));
	}
	ll ret=mcf.mincost(0,2*N+6,S);
	ret-=(4LL*S)<<30;
	cout<<-ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1544
#include<cstdio>
int main(void)
{
    int a,b;
    scanf("%d %d" ,&a,&b);
    for(int i=10*b;i<10*b+10;i++)
    {
        if(100*a<=8*i && 8*i<100*a+100)
        {
            printf("%d" ,i);
            return 0;
        }
    }
    printf("-1");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using ld = long double;
    using Pair = pair<int, int>;
    using Graph = vector<vector<int>>;
    #define MOD 1000000007
    #define INF 1000000007
    #define SEP " "
     
    int     main()
    {
    	ll n;
    	cin >> n;
    	if (n == 1)
    	{
    		cout << 0 << endl;
    		return (0);
    	}
    	ll lim = sqrt(n);
    	ll div = 2;
    	ll c = 0;
    	while (div <= lim)
    	{
    		ll e = 1;
    		ll ec = 0;
    		while (n % div == 0)
    		{
    			ec++;
    			if (e == ec)
    			{
    				ec = 0;
    				e++;
    				c++;
    			}
    			n /= div;
    		}
    		div++;
    	}
      if (n != 1)
        c++;
      
    	cout << c << endl;
    }
     

Measured memory_bytes: 3684
N = int(input())
C = []
for _ in range(5):
    C.append(int(input()))
minA = min(C)
if N - minA <= 0:
    print(5)
else:
    n = (N - minA) 
    if n % minA == 0:
        print(5 + (n // minA))
    else:
        print(6 + (n // minA))

Measured memory_bytes: 3060
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <functional>
#include <array>
#include <climits>
//#include "debug.h"
using namespace std;
 
#define A first
#define B second
 
typedef long long ll;
constexpr int MOD = 1000000007;

template<typename T>
void print(const vector<T> &v, bool add_one = false, int start = -1, int end = -1) {
  if (start < 0) start = 0;
  if (end < 0) end = int(v.size());
 
  for (int i = start; i < end; i++)
    cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}

void solve() {
  int D, T, S; cin >> D >> T >> S;
  if(T * S >= D) cout << "Yes";
  else cout << "No";
}
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  T = 1;
  //cin >> T;
  while(T--){
    solve();
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = n - 1; i>= 0; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;


const double pi = 3.14159265359;
const int MAXN = 100005;
ll mod=1000000007;

ll gcd(ll a, ll b){
	return b? gcd(b,a%b):a;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	map<pair<ll,ll>,pair<ll,ll>> slope;
	int n;
	ll pw[2*MAXN]= {1};
	pw[0] = 1;
	for(int i = 1; i <= 2*MAXN - 1; i++) pw[i] = (pw[i-1]*2)%mod;
	cin>>n;
	
	ll z = -1;	
	rep(i,n){
		ll x,y;
		cin>>x>>y;
		if(x == 0 and y == 0){
		 	z++;continue;
		}
		if(make_pair(x,y) < make_pair(0ll,0ll)) x = -x, y = -y;
		ll g = gcd(abs(x),abs(y));
		x /= g, y /= g;		
		if(y <= 0) slope[{-y,x}].second++;
		else slope[{x,y}].first++;
	}
	ll r = 1;
	for(auto& p:slope){
		r = (r*(pw[p.second.first] + pw[p.second.second] - 1)%mod)%mod;	
	} 
	cout<<(r + z + mod)%mod<<nl;
	
	return 0;
}



Measured memory_bytes: 20672
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")

#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define pp pair<pii,pii>
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define ins insert


const double PI= acos(-1);

#define yu using
#define don namespace
#define sei std

yu don sei;



int main()
{
	int n;
	cin>>n;
	map<int,int>M;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		M[x]++;
	}
	int m;
	cin>>m;
	for(int i=0;i<m;i++)
	{
		int x;
		cin>>x;
		if(M.count(x)==0)
		{	
			cout<<"NO"<<endl;
			return 0;
		}
		else
		{
			if(M[x]==0)
			{
				cout<<"NO"<<endl;
				return 0;
			}
			else
			{
				M[x]--;
			}
		}
	}
		cout<<"YES"<<endl;

	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <cstdlib>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int a;
    cin >> a;
    cout << 1-a << endl;
    return 0;
}

Measured memory_bytes: 3604
n = int(input())
lis = []
for i in range(n):
    lis.append(list(map(int, input().split())))
lis.append([int(),0])
lis = sorted(lis, key=lambda x:x[0])

#print(lis)
lis.reverse()
#print(lis)
print(lis[0][0]+lis[0][1])

Measured memory_bytes: 29864
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#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>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};


int main(){
  int x, a, b; cin >> x >> a >> b;
  if(a >= b){
    cout << "delicious" << endl;
  }else if(x + a - b >= 0){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**9)

def dfs(n,arr,visited):
    for i in graph[n]:
        if visited[i]==False:
            arr[n]=max(arr[n],dfs(i,arr,visited)+1)
            visited[i]=True
        else:
            arr[n]=max(arr[n],arr[i]+1)
    return arr[n]

n,m=map(int,input().split())

graph=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    if a!=b:
        graph[a-1].append(b-1)

visited=[False for i in range(n)]

arr=[0 for i in range(n)]

for i in range(n):
    if visited[i]==False:
        dfs(i,arr,visited)
print(max(arr))


Measured memory_bytes: 130076
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

Measured memory_bytes: 3576
#include<iostream>

using namespace std;

int main()
{
        int c[3][3],i,j;

        for(i=0; i<3; i++){
                for(j=0; j<3; j++)
                        cin >> c[i][j];
        }

        int flagcount = 0;

        j=0;
        for(i=0; i<2; i++){
                if(c[i][j]-c[i+1][j] == c[i][j+1]-c[i+1][j+1] && c[i][j]-c[i+1][j] == c[i][j+2]-c[i+1][j+2]) flagcount++;
        }

        i=0;
        for(j=0; j<2; j++){
                if(c[i][j]-c[i][j+1] == c[i+1][j]-c[i+1][j+1] && c[i][j]-c[i][j+1] == c[i+2][j]-c[i+2][j+1]) flagcount++;
        }

        if(flagcount == 4)
                cout << "Yes" << endl;
        else
                cout << "No" << endl;

        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

const long long INF = 1LL << 60;
const long long P = 1000000007;

int main() {
  string s;
  cin >> s;
  int size = s.size() - 7;
  cout << s.substr(0,size-1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    string s, t;
    cin >> s >> t;

    vector<int> salp(26, -1), talp(26, -1);
    REP(i, s.size()) {
        int sa = s[i] - 'a';
        int ta = t[i] - 'a';
        if (salp[sa] > -1 || talp[ta] > -1) {
            if (salp[sa] != ta || talp[ta] != sa) {
                cout << "No" << endl;
                return 0;
            }
        }

        salp[sa] = ta;
        talp[ta] = sa;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int r = 0, b = 0;
  for (int i = 0; i < s.size(); i ++) {
    if (s[i] == 'R') r++;
    else b ++;
  }

  if (r > b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

lst = []
m = 0
temp = [[0]]

while temp:
    p = temp.pop()
    if len(p)==N:
        lst.append(p)
    else:
        for i in range(max(p)+2):
            s = p[:]
            s.append(i)
            temp.append(s)

lst.sort()
abc = 'abcdefghij'
for l in lst:
    print(*[abc[i] for i in l], sep='')


Measured memory_bytes: 30184
let N = Int(readLine()!)!
var C = [Int]()
var S = [Int]()
var F = [Int]()
for i in 1..<N {
    let input = readLine()!.characters.split(" ").map{Int(String($0))!}
    C += [input[0]]
    S += [input[1]]
    F += [input[2]]
}
for i in 0..<N {
    var t = 0
    for j in i..<N-1 {
        t = max(S[j], t)
        t += (F[j] - t%F[j]) % F[j]
        t += C[j]
    }
    print(t)
}

Measured memory_bytes: 4208
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

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

    if (N % 111 == 0) {
        cout << N << endl;
    } else {
        cout << ((N / 111) + 1) * 111 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
s = list(input())
t = list(input())

l1, l2 = len(s), len(t)

res = ['z'] * l1
flag2 = False
for i in range(l1-l2+1):
    tmp_s = s.copy()
    flag1 = True
    for j in range(l1):
        if j < i or i + l2 <= j:
            if tmp_s[j] == '?':
                tmp_s[j] = 'a'
        else:
            if tmp_s[j] == t[j-i]:
                continue
            elif tmp_s[j] == '?':
                tmp_s[j] = t[j-i]
            else:
                flag1 = False

    if flag1:
        flag2 = True
        res = min(res, tmp_s)

if flag2:
    print(''.join(res))
else:
    print('UNRESTORABLE')

Measured memory_bytes: 65080
#include <cstdio>

using namespace std;

int side(double a, double b, double c, double d) {
  return a * d - b * c >= 0 ? 1 : -1;
}

int main() {
  double x[8], y[8];
  while (scanf("%lf,%lf", x, y) == 2) {
    for (int i = 1; i < 4; i++)
      scanf(",%lf,%lf", x+i, y+i);
    for (int i = 0; i < 4; i++)
      x[i+4] = x[i];
    int s = 0;
    for (int i = 0; i < 4; i++)
      s += side(x[i+1]-x[i], y[i+1]-y[i], x[i+2]-x[i+1], y[i+2]-y[i+1]);
    puts((s == 4 || s == -4) ? "YES" : "NO");
  }
  return 0;
}

Measured memory_bytes: 0
main :: IO ()
main = do
  [n, k] <- readsLn
  [r, s, p] <- readsLn
  ts <- getLine
  print $ solve n k r s p ts

solve :: Int -> Int -> Int -> Int -> Int -> String -> Int
solve _ k r s p ts = sum $ map winPoint xs
  where xs = map winHand us ++ zipWith f xs vs
        (us, vs) = splitAt k ts
        winHand 'r' = 'p'
        winHand 's' = 'r'
        winHand 'p' = 's'
        winPoint 'r' = r
        winPoint 's' = s
        winPoint 'p' = p
        winPoint 'x' = 0
        f x v
          | x == y    = 'x'
          | otherwise = y
          where y = winHand v

readsLn :: Read a => IO [a]
readsLn = map read . words <$> getLine


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
 
#define vi vector<int>
#define ll long long
#define vvi vector<vi>
#define vll vector<ll>
#define vvll vector<vll>
#define MOD 998244353
#define endL << '\n'
#define ii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define endL << '\n'
#define vii vector<ii>
#define pb push_back

/*
ll powmod(ll x, ll y, ll mod){
	ll res = 1;
	while (y > 0){
		if (y%2) res = (res*x) % mod;
		x = (x*x) % mod;
		y /= 2;
	}
	return res;
}
*/

/*const int N = 1000000;
int lp[N+1];
vector<ll> pr;

void sieve(){
	for (int i=2; i<=N; ++i) {
	    if (lp[i] == 0) {
	        lp[i] = i;
	        pr.push_back (i);
	    }
	    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
	        lp[i * pr[j]] = pr[j];
	}
}*/

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1; //cin >> t;
	while(t--){
		int n, w; cin >> n >> w;
		vector<pair<int, ll>> inp(n);
		for (int i = 0; i < n; i++){
			cin >> inp[i].fi >> inp[i].se;
		}
		vvll dp(n+1, vll(w+1, 0));
		ll val; int wt;
		for (int i = 1; i <= n; i++){
			val = inp[i-1].se; wt = inp[i-1].fi;
			for (int j = 1; j <= w; j++){
				dp[i][j] = dp[i-1][j];
				if (j < wt) continue;
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-wt] + val);
			}
		}
		
		cout << dp[n][w];
	}
}

Measured memory_bytes: 80256
let solve s i =
  let rec find_aux s i cur = match String.get s (cur-1) with
    | '1' when i > cur -> find_aux s i (cur+1)
    | '1' when i = cur -> '1'
    | x -> x
  in
  find_aux s i 1


let () =
  let rec read () =
    try let ans = (Scanf.scanf "%s\n%i\n" solve) in
        Printf.printf "%c\n" ans
    with End_of_file -> ()
  in
  read ()
;;


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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, j, n) for(int i = j; i < n; ++i)
using ll = long long;

ll n, m, q;
ll a[100], b[100], c[100], d[100];
ll ans = 0;

void dfs(int p, vector<int>& e) {
	if (e.size() == n) {
		ll tmp = 0;
		rep(i, q) {
			if (e[b[i]] - e[a[i]] == c[i]) tmp += d[i];
		}
		ans = max(ans, tmp);
	}
	else {
		REP(i, p, m + 1) {
			e.push_back(p);
			dfs(i, e);
			e.pop_back();
		}
	}
}


int main() {
	cin >> n >> m >> q;
	rep(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		--a[i];
		--b[i];
	}

	vector<int> unko;
	dfs(1, unko);
	cout << ans;
	return 0;
}


Measured memory_bytes: 3588
#include<stdio.h>
#include<math.h>
main(){
  double a,b,c;
  scanf("%lf%lf%lf",&a,&b,&c);
  //??蔵???
  printf("%lf\n",a*b*sin((M_PI*c/180))/2);
  //??即
  printf("%lf\n",a+b+sqrt(a*a+b*b-2*a*b*cos((M_PI*c/180))));
  //??????
  printf("%lf\n",b*sin((M_PI*c/180)));
  return 0;
}

Measured memory_bytes: 696
import numpy as np
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
li = [[0 if s[i][j] == "#" else 1 for j in range(w)] for i in range(h)]
l, r, u, d = np.array(li), np.array(li), np.array(li), np.array(li)
for i in range(1, h):
    u[i] *= (u[i - 1] + 1)
    d[-i - 1] *= (d[-i] + 1)
for i in range(1, w):
    l[:, i] *= (l[:, i - 1] + 1)
    r[:, -i - 1] *= (r[:, -i] + 1)
print((l + r + u + d - 3).max())

Measured memory_bytes: 247176
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	vector<int>vec;
	for(int i=2;i<=10000;i++){
		bool v=false;
		for(int j=2;j*j<=i;j++){
			if(i%j==0){
				v=true;
				break;
			}
		}
		if(!v){
			vec.push_back(i);
		}
	}
	int l;
	while(scanf("%d",&l) && l){
		int ans=0;
		for(int i=0;i<vec.size();i++){
			int sum=0;
			for(int j=i;j<vec.size();j++){
				sum+=vec[j];
				if(sum==l){
					ans++;
					break;
				}else if(sum>l){
					break;
				}else if(j==vec.size()-1){
					break;
				}
			}
		}
		printf("%d\n",ans);
	}
}

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


double powd(double x){ return x * x; }
double absd(double x){ return x >= 0 ? x : -x; }

int main(){
  int n;
  int x[100000],r[100000];

  cin >> n;

  for(int i = 0;i < n;i++){
    cin >> x[i] >> r[i];
  }

  int x1,x2;
  x1 = x[0] - r[0];
  x2 = x[0] + r[0];

  for(int i = 1;i < n;i++){
    int tmp1,tmp2;
    tmp1 = x[i] - r[i];
    tmp2 = x[i] + r[i];
    if(tmp1 > x1){
      x1 = tmp1;
    }
    if(tmp2 < x2){
      x2 = tmp2;
    }

  }


  double left = x1;
  double right = x2;
  double y1;
  double y2;
  int cnt = 0;
  while(right - left > 0.0001){
    double le = (left*2+right)/3;
    double ri = (left+right*2)/3;
    cnt++;
    y1 = sqrt(powd(r[0])-powd(absd(x[0]-le)));
    y2 = sqrt(powd(r[0])-powd(absd(x[0]-ri)));
    for(int i = 1;i < n;i++){
      y1 = min(y1,sqrt(powd(r[i]) - powd(absd(x[i]-le))));
      y2 = min(y2,sqrt(powd(r[i]) - powd(absd(x[i]-ri))));
    }

    if(y1 > y2){
      right = ri;
    }else{
      left  = le;
    }
  }
  printf("%lf\n",y1 > y2 ? y1 : y2);
  return 0;
}





Measured memory_bytes: 3996
N, K = map(int, input().split())
if K == 0:
    print(N * N)
    exit()
ans = 0
for b in range(K + 1, N + 1):
    p = N // b
    ans += p * max(0,b - K) + max(0, N - p * b - K + 1)
print(ans)

Measured memory_bytes: 39408
#include<bits/stdc++.h>
#include<cxxabi.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
#define TYPEVS(x) typeid(x).name()
#define TYPEGC(x) abi::__cxa_demangle(typeid(x).name(), 0, 0, 0)
#define Y1 "YES"
#define N1 "NO"
#define ENDL '\n'
#define count2(x) _builtin_popcount(x)
int main(){
	ll m;
	cin>>m;
	ll sq=sqrt(m);
	ll ans=0;
	for(ll i=2;i<=sqrt(m);++i){
		if(m%i==0){
			ll ip=i;
			ll cnt=0;
			while(m%i==0){
				m/=i;
				cnt++;
			}
			for(int j=1;cnt>=j;j++){
				ans++,cnt-=j;
			}
		}
	}
	if(m!=1)ans++;
	cout<<ans;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a / gcd(a, b) * b; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll n,fir = 0,sec = 0;
    cin>>n;
    vector<int>a(n);
    unordered_map<int,int>mp;
    rep(i,n)cin>>a[i];

    rep(i,n){
        if(++mp[a[i]] == 2){
            if(fir < a[i]){
                sec = fir;
                fir = a[i];
                mp[a[i]] = 0;
            }
            else if(sec < a[i]){
                sec = a[i];
            }
        }
    }
    cout<<fir * sec<<endl;
}

Measured memory_bytes: 4772