akhauriyash/Code-Regression huggingface dataset:
/**
 * Distance.cpp
 * Create:20180430
 * Description:２点間の距離を求めるプログラム
 */
#include <iostream>
#include <cmath>

/**
 * 座標クラス
 * @param x x座標
 * @param y y座標
 */
class Point{
private:
  double x;
  double y;
public:
  /**
   * コンストラクタ
   * @param x x座標
   * @param y y座標
   */
  Point(double x, double y){
    this->x = x;
    this->y = y;
  }

  /**
   * x座標
   * @return x座標
   */
  double get_x(){
    return x;
  }

  /**
   * y座標
   * @return y座標
   */
  double get_y(){
    return y;
  }
};

/**
 * 距離計算関数
 * @param  a 座標１
 * @param  b 座標２
 * @return   2点間の距離
 */
double distance(Point a, Point b){
  double width = a.get_x() - b.get_x();
  double height = a.get_y() - b.get_y();
  double hypotenuse = pow(width,2) + pow(height,2);
  return sqrt(hypotenuse);
}

int main(int argc, char* argv[]){
  double x1, y1, x2, y2;

  std::cin >> x1 >> y1 >> x2 >> y2;
  Point a = Point(x1, y1);
  Point b = Point(x2, y2);

  printf("%.8f", distance(a, b));

  return 0;
}


Measured memory_bytes: 3176
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,r;
  cin >> n >> r;

  cout << r + 100*max(0LL,10-n) << endl;

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;


int main(){
  string s;
  cin >>s;
  int t=s.size();
  int count0=0;
  int count1=0;
  
  for (int i=0;i<t;i++){
    if (s.at(i)=='1') count1++;
    else count0++;
  }
  int x =abs(count1-count0);
  int ans =(t-x);
  cout << ans << endl;
}

  

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define INF (1<<29)
using namespace std;
typedef long long ll;
int main(){
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      cout<<(a+b+c+d)/60<<endl;
      cout<<(a+b+c+d)%60<<endl;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
//int abs(x){
 // if(x>=0)return x;
 // else return -x;
int main() {
	int n,a,b,ans,ah=10000000;
	cin>>n>>a>>b;
    int p[n+1];
    for(int i=1;i<=n;i++){
      cin>>p[i];
    }
    for(int j=1;j<=n;j++){
      if(abs(a*1000-b*1000-p[j]*6)<ah){
        ah=abs(a*1000-b*1000-p[j]*6);
        ans=j;
               }
               }
               cout<<ans;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
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;}

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 223450
#endif

int N,Q,K;
int A[SIZE];

int calc(int a0, int a1, int x) {
    int ret = 1e15;
    if ((a0^a1)==x) return 0;
    int tmp;
    if (a0 && (a0^a1)%2 == x%2) {
        tmp = calc(a0/2,a1/2,x/2);
        chmin(ret, tmp*2);
        tmp = calc((a0-1)/2,(a1+1)/2,x/2);
        chmin(ret, tmp*2+1);
    }
    return ret;
}

void solve() {
    cin>>N;
    REP(i,N)cin>>A[i];
    int base = 0;
    FOR(i,2,N) base ^= A[i];
    int ret = calc(A[0],A[1],base);
    cout << (ret>=A[0]?-1:ret) << endl;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	int t=1;
	// cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		if(n>=30) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3628
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
        int x = int.Parse(input[2]);
        int[,] value = new int[n,m];
        int[] price = new int[n];
        int[] algoCheck = new int[m];
        for(int i=0; i<n; i++){
            string[] input2 = Console.ReadLine().Split(' ');
            price[i] = int.Parse(input2[0]);
            for(int j=0; j<m; j++){
                value[i,j] = int.Parse(input2[j+1]);
                algoCheck[j] += value[i,j];
            }           
        }
        for(int j=0; j<m; j++){
            if(algoCheck[j] < x){
                Console.WriteLine(-1);
                return;
            }
        }
        /*for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                Console.Write(value[i,j]+" ");
            } 
            Console.WriteLine();          
        }*/
        int min = 100000000;
        int sum = 0;
        int[] algoPoint = new int[m];
        bool flag = true;
        for (int bit = 0; bit < (1 << n); ++bit){ //n=2であれば100未満(=3)まで調べる
            sum = 0;
            flag = true;
            for (int i = 0; i < n; i++) { //N=3であれば0001(=1), 0010(=2), 0100(=4)まで調べる
                if ((bit & (1 << i)) == (1 << i)) { //bitが1である部分に関して何らかの処理を行う
                    sum += price[i];
                    for(int j=0; j<m; j++){
                        algoPoint[j] += value[i,j];
                    }
                }
            }
            for(int k=0; k<m; k++){
                if(algoPoint[k] < x) flag = false; 
                algoPoint[k] = 0;
            }
            if(flag && (min > sum)) min = sum; 
        }
        Console.WriteLine(min);
	}
}

Measured memory_bytes: 27564
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			
			boolean nearCoffee = s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5);
			
			System.out.println(nearCoffee ? "Yes" : "No");
		}
	}

}

Measured memory_bytes: 21972
import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * D2
 */
public class Main {

    private static int cnt = 0;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line = br.readLine();
        int len = Integer.parseInt(line);
        int[] arr = new int[len];
        for(int i=0; i<len; i++){
            arr[i] = Integer.parseInt(br.readLine());
        }
        List<Integer> G = makeH(len);
        for(int i=G.size()-1; i>=0; i--) {
            insertionSort(arr, len, G.get(i));
            System.out.print(G.get(i) + " ");
        }
        System.out.println();
        System.out.println(cnt);
        for(int s: arr){
            System.out.println(s);
        }
    }

    private static void insertionSort(int[] arr, int len, int g){
        for(int i=g; i<len; i++){
            int v = arr[i];
            int j = i-g;
            while (j >= 0 && arr[j] > v){
                arr[j+g] = arr[j];
                j = j - g;
                cnt++;
            }
            arr[j+g] = v;
        }
    }

    private static List<Integer> makeH(int len){
        List<Integer> list = new ArrayList<>();
        int n = 0;
        int max = 0;
        while(true){
            n = n*3 + 1;
            if(len < n) break;
            list.add(n);
            max++;
        }
        System.out.println(max);
        return list;
    }
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  VL a(n);
  priority_queue<ll> q;
  rep(i, n) {
    cin >> a[i];
    q.push(a[i]);
  }
  rep(i, m) {
    ll v = q.top();
    q.pop();
    q.push(v / 2);
  }
  ll sum = 0;
  while(!q.empty()) {
    sum += q.top();
    q.pop();
  }
  out(sum);
  return 0;
}


Measured memory_bytes: 2168
n,m = map(int,input().split())
a = [list(map(int,input().split()))for i in range(n)]
ans = 0
for i in range(1,m+1):
    check = 0
    for j in range(n):
        if i in a[j][1:]:
            check += 1
        if check == n:
            ans += 1
            
print(ans)   

Measured memory_bytes: 3064
N, M, K = map(int, input().split())
par = list(range(N))
siz = [1] * N
n_friend = [0] * N


def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]


def same(x, y):
    return root(x) == root(y)


def unite(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if siz[x] > siz[y]:
        x, y = y, x
    siz[y] += siz[x]
    par[x] = y


def tree_size(x):
    return siz[root(x)]


B = {}
for i in range(N):
    B[i] = set()
for _ in range(M):
    p, q = map(int, input().split())
    n_friend[p - 1] += 1
    n_friend[q - 1] += 1
    unite(p - 1, q - 1)
for _ in range(K):
    p, q = map(int, input().split())
    B[p - 1].add(q - 1)
    B[q - 1].add(p - 1)


# calc friend candidate
i, blocked = 0, 0
for b in B[0]:
    if same(i, b):
        blocked += 1
print(tree_size(i) - 1 - n_friend[i] - blocked, end='')
for i in range(1, N):
    print(' ', end='')
    blocked = 0
    for b in B[i]:
        if same(i, b):
            blocked += 1
    print(tree_size(i) - 1 - n_friend[i] - blocked, end='')
print('')


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

int inf=1e9;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    for(int i=0; i<m; i++) cin >> c[i];

    vector<int> dp(n+1,inf);
    dp[0]=0;
    for(int i=1; i<n+1; i++){
        for(int j=0; j<m; j++){
            if(i-c[j]>=0){
                dp[i]=min(dp[i],dp[i-c[j]]+1);
            }
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3152
s=gets.chomp


if s !~ /^1.*0$/ || s[0..-2] != s[0..-2].reverse
  p -1
  exit
end

puts "1 2"

ptr = 2

(1...s.size/2).each{|i|
  puts "#{ptr} #{i+2}"
  if s[i]==?1
    ptr = i+2
  end
}

(s.size/2...s.size-1).each{|i|
  puts "#{ptr} #{i+2}"
}

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

void a()
{
    int n;
    cin >> n;
    string n_str = to_string(n);
    for (int i = 0; i < 3; i++)
    {
        if (n_str[i] == n_str[i + 1])
        {
            cout << "Bad";
            return;
        }
    }
    cout << "Good";
    return;
}
int main(void)
{
    a();
    return 0;
}

Measured memory_bytes: 256
/*
    if you can't see the repay
    Why not just work step by step
    rubbish is relaxed
    to ljq
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define lc (rt<<1)
#define rc (rt<<11)
#define mid ((l+r)>>1)

typedef pair<int,int> pll;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll _INF = 0xc0c0c0c0c0c0c0c0;
const ll mod =  (int)1e9+7;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}
void exgcd(ll a,ll b,ll &x,ll &y,ll &d){if(!b) {d = a;x = 1;y=0;}else{exgcd(b,a%b,y,x,d);y-=x*(a/b);}}//printf("%lld*a + %lld*b = %lld\n", x, y, d);
char str[3025];
ll dp[3025][3025];
void add_self(int& a,ll b)
{
    a+=b;
    if(a>=mod)
    {
        a-=mod;
    }
}
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n,ans = 0;
    scanf("%d",&n);
    scanf("%s",str+1);
    dp[1][1] = 1;
    for(int i = 2;i<=n;++i)
    {
        if(str[i-1]=='<')
        {
            dp[i][1] = 0;
            for(int j = 2;j<=i;++j)
                dp[i][j] = (dp[i][j-1] + dp[i-1][j-1])%mod;
        }
        else
        {
            dp[i][i] = 0;
            for(int j = i-1;j>=1;--j)
                dp[i][j] = (dp[i][j+1] + dp[i-1][j])%mod;
        }
    }
    for(int i = 1;i<=n;++i)
        add_self(ans,dp[n][i]);
    printf("%d\n",ans);
    //fclose(stdin);
    //fclose(stdout);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 69504
from math import gcd

def p_factorization_osa_k(vl):
    vmax = max(vl)
    min_primes = list(range(vmax+1))  # initialize all values by its own value
    for i in range(2, int(vmax**0.5) + 1):
        if min_primes[i] != i: continue  # if not prime
        for j in range(i,vmax+1,i): 
            min_primes[j] = min(min_primes[j], i) # -> if min_primes[j] == j: min_primes[j] = i

    results = []
    for v in vl:
        p_cnt = {}
        curr_v = v
        while curr_v > 1:
            min_p = min_primes[curr_v]
            p_cnt.setdefault(min_p,0)
            p_cnt[min_p] += 1
            curr_v //= min_p
        results.append(p_cnt)
    return results


n = int(input())
al = list(map(int, input().split()))
afl = p_factorization_osa_k(al)

pset = set()
no_pairwise = False
for af in afl:
    for p in af.keys():
        if p in pset:
            no_pairwise = True
            break
        pset.add(p)
    if no_pairwise:
        break
else:
    print('pairwise coprime')
    exit()


c_gcd = al[0]
for a in al[1:]:
    c_gcd = gcd(c_gcd,a)

if c_gcd == 1: print('setwise coprime')
else: print('not coprime')

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


 int main()
 {
	int total;
	int books;
		int count=0;

	while(true){
		if(count==0){
		  cin>>total;		
		  if(total==0){
			break;
		  }
		  count++;
		}else{
		 cin>>books;
		 total-=books; 
		 count++;
		}
		if(count==10){
		cout<<total<<'\n';
		count=0;
		}
	}
       return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100

typedef vector<double> V;
typedef vector<V> MATRIX;
int N,start,goal;
int dist[NUM][NUM],min_dist[NUM][NUM];
bool exist_sign[NUM];

void gauss_jordan(MATRIX A){

	MATRIX C(N,V(N+1));

	for(int row = 0; row < N; row++){
		for(int col = 0; col <= N; col++){
			C[row][col] = A[row][col];
		}
	}

	int base_row;
	double tmp;

	for(int i = 0; i < N; i++){
		base_row = i;
		for(int row = i+1; row < N; row++){
			if(fabs(C[row][i]) > fabs(C[base_row][i])){
				base_row = row;
			}
		}

		if(fabs(C[base_row][i]) < EPS)continue;

		if(base_row != i)swap(C[base_row],C[i]);

		tmp = C[i][i];
		for(int col = 0; col <= N; col++){
			C[i][col] /= tmp;
		}

		for(int row = 0; row < N; row++){
			if(row == i || fabs(C[row][i]) < EPS)continue;

			tmp = C[row][i];

			for(int col = i; col <= N; col++){
				C[row][col] -= C[i][col]*tmp;
			}
		}
	}

	printf("%.10lf\n",C[start][N]);
}

void func(){

	start--;
	goal--;

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){
			if(i != k){
				dist[i][k] = BIG_NUM;
				min_dist[i][k] = BIG_NUM;
			}else{
				dist[i][k] = 0;
				min_dist[i][k] = 0;
			}
		}
	}

	int tmp;
	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		exist_sign[i] = (tmp == 1);
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){
			scanf("%d",&tmp);
			if(tmp == 0)continue;
			dist[i][k] = tmp;
			min_dist[i][k] = tmp;
		}
	}

	for(int mid = 0; mid < N; mid++){
		for(int st = 0; st < N; st++){
			if(min_dist[st][mid] == BIG_NUM)continue;
			for(int gl = 0; gl < N; gl++){
				if(min_dist[mid][gl] == BIG_NUM)continue;
				min_dist[st][gl] = min(min_dist[st][gl],min_dist[st][mid]+min_dist[mid][gl]);
			}
		}
	}

	if(min_dist[start][goal] == BIG_NUM){
		printf("impossible\n");
		return;
	}

	MATRIX A(N,V(N+1));

	for(int row = 0; row < N; row++){
		for(int col = 0; col <= N; col++){
			A[row][col] = 0;
		}
	}

	int count;

	for(int i = 0; i < N; i++){

		if(min_dist[i][goal] == BIG_NUM || i == goal){
			A[i][i] = 1;
			continue;
		}

		if(exist_sign[i]){

			count = 0,tmp = 0;

			for(int k = 0; k < N; k++){
				if(k == i)continue;
				if(dist[i][k] == BIG_NUM || min_dist[k][goal] == BIG_NUM)continue;

				if(dist[i][k]+min_dist[k][goal] == min_dist[i][goal]){
					count++;
					tmp += dist[i][k];
					A[i][k] = -1;
				}
			}

			A[i][i] = count;
			A[i][N] = tmp;

		}else{

			count = 0,tmp = 0;

			for(int k = 0; k < N; k++){
				if(k == i)continue;
				if(dist[i][k] == BIG_NUM)continue;

				count++;
				tmp += dist[i][k];
				A[i][k] = -1;
			}
			A[i][i] = count;
			A[i][N] = tmp;
		}
	}


	gauss_jordan(A);
}

int main(){

	while(true){
		scanf("%d %d %d",&N,&start,&goal);
		if(N == 0 && start == 0 && goal == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3460
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define AC ios::sync_with_stdio(0),cin.tie(0);

int main()
{
    AC
    int n,w,r=0;
    cin>>n>>w;
    vector<ll> dp(100001,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        int wei,val;
        cin>>wei>>val;
        for(int j=100000;j>=val;j--)
            dp[j]=min(dp[j],dp[j-val]+wei);
    }
    for(int i=1;i<dp.size();i++)
        if(dp[i]<=w) r=i;
    cout<<r<<'\n';
}


Measured memory_bytes: 3980
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
#define PF(a) pop_front(a)
 
#define MP(a,b) make_pair(a,b)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
//grobal var
//------------------------------------------
const LL MAX = 500020LL;
const LL MOD = 1e9+7;
LL fac[MAX],finv[MAX],inv[MAX];

// ---------------calculate combination nCk-----------
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;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1LL, v = 0LL;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
template< typename T > 
void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
long long modPow(long long x, long long k) {
	long long ret = 1;	
	while (k > 0) {
		if (k & 1) modMul(ret, x, MOD);
		modMul(x, x, MOD);
		k >>= 1;
	}
	return ret;
}

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  int N,A,B,C;
  COMinit();
  while(cin >> N >> A >> B >> C){
    LL ans=0;

    FOR(i,N,2*N){
      LL x = inv[A+B];
      LL tmp = (modPow(A*x%MOD,N)*modPow(B*x%MOD,i-N))%MOD;
      tmp += (modPow(A*x%MOD,i-N)*modPow(B*x%MOD,N))%MOD;
      tmp %= MOD;

      tmp *= COM(i-1,N-1);
      tmp %= MOD;
      
      LL tmp2 = (i*100%MOD)*inv[100-C]%MOD;
      ans+=tmp*tmp2;
      ans %= MOD;
    }
    cout << ans << endl;

  }

  return 0;
}

Measured memory_bytes: 12032
from operator import itemgetter

m_inf = float("-inf")
n = int(input())
phrase = [0]*(394)
for s, l, p in (map(int, input().split()) for _ in [0]*n):
    for i, _p in enumerate(phrase[s:l+1], start=s):
        phrase[i] = _p if _p > p else p

dp = [0] + [m_inf]*393
for length, p in filter(itemgetter(1), enumerate(phrase)):
    for from_p, to_p, to in zip(dp, dp[length:], range(length, 395)):
        dp[to] = to_p if to_p >= from_p+p else from_p+p

result = [dp[int(input())] for _ in [0]*int(input())]
print(*(result if m_inf not in result else [-1]), sep="\n")


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

int main(){
    int d, n;   cin >> d >> n;
    int cnt=0, ans=0;

    for(int i=1; ; i++){
        int tmp=i, dig=0;
        while(99<tmp){
            if(tmp%100==0){
                dig+=1; tmp /= 100;}
            else break;
        }
        if(dig!=d) continue;
        cnt += 1;
        if(n==cnt){
            ans = i; break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import collections as cs

def solve(N: int, A: "List[int]"):
    if len(set(A))==len(A):
        for i in range(N):
            print(0)
        exit()
    q=0
    p=cs.Counter(A)
    for o in p.values():
        q+=o*(o-1)//2
    for i in range(N):
        print(q-p[A[i]]+1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38884
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

const double eps = 1e-7;
const int MOD = 1000000007;
const int MOD_MAX = 200000;

using ll = long long;
using vi = vector<int>; using vi2 = vector<vi>; using vi3 = vector<vi2>;
using vll = vector<ll>; using vll2 = vector<vll>; using vll3 = vector<vll2>;
using vd = vector<double>; using vd2 = vector<vd>; using vd3 = vector<vd2>;
using pi = pair<int, int>; using pll = pair<ll, ll>;
using vpi = vector<pi>; using vpll = vector<pll>;

#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define loopll(i, n) for (ll i = 0; i < (ll)n; i++)
#define looplleq(i, n) for (ll i = 0; i <= (ll)n; i++)
#define rloopi(i, a, b) for(int i = (int)a - 1; i >= (int)b; i--)
#define rloop(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define rloopeq(i, n) for (int i = (int)n - 1; i >= 1; i--)
#define rloopll(i, n) for (int i = (ll)n - 1; i >= 0; i--)
#define rlooplleq(i, n) for (int i = (ll)n - 1; i >= 1; i--)
#define all(a) (a).begin(), (a).end()

bool feq(float x, float y) { return abs(x-y) <= eps; }
bool deq(double x, double y) { return abs(x-y) <= eps; }
int ceillog2(ll x) { return int (ceil(log2(x))); }
int floorlog2(ll x) { return int (floor(log2(x))); }
template<class T> T reversed (T container) { reverse(container.begin(), container.end()); return container; }
template<class T> T sort (T container) { sort(container.begin(), container.end()); return container; }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

int main() {
	int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k; cin >> k;
	cout << a[k - 1] << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

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

	for(int n; cin >> n, n;) {
		int m;
		cin >> m;

		int p, q, r;
		cin >> p >> q >> r;

		vector<pair<int, bool> > cards;
		cards.push_back(make_pair(r, true));
		cards.push_back(make_pair(n - r, false));

		for(int i = 0; i < m; ++i) {
			int x, y;
			cin >> x >> y;

			vector<pair<int, bool> > tmp;
			int j, sum = 0, idxA, idxB, sumA, sumB;
			for(j = 0;; ++j) {
				sum += cards[j].first;
				if(sum >= x) {
					idxA = j;
					sumA = sum;
					sum -= cards[j].first;
					break;
				}
			}

			for(;; ++j) {
				sum += cards[j].first;
				if(sum >= y) {
					idxB = j;
					sumB = sum;
					break;
				}
			}

			if(sumB != y) {
				tmp.push_back(make_pair(sumB - y, cards[idxB].second));
				cards[idxB].first -= sumB - y;

				if(idxA == idxB)
					sumA -= sumB - y;
			}

			for(j = idxB + 1; j < cards.size(); ++j)
				tmp.push_back(cards[j]);

			if(sumA != x) {
				tmp.push_back(make_pair(sumA - x, cards[idxA].second));
				cards[idxA].first -= sumA - x;
			}

			for(j = idxA + 1; j <= idxB; ++j)
				tmp.push_back(cards[j]);

			for(j = 0; j <= idxA; ++j)
				tmp.push_back(cards[j]);

			cards.swap(tmp);
		}

		int ans = 0;
		int i = 0, sum = 0;
		for(; i < cards.size(); ++i) {
			sum += cards[i].first;
			if(sum >= p) {
				if(cards[i].second)
					ans += sum - p + 1;

				break;
			}
		}

		for(++i; i < cards.size(); ++i) {
			sum += cards[i].first;
			if(sum > q) {
				if(cards[i].second)
					ans += cards[i].first - (sum - q);

				break;
			}
			else {
				if(cards[i].second)
					ans += cards[i].first;
			}
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1368
import math
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def 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)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
c = collections.Counter(input())
mod = 10**9+7
ans = 1
for v in c.values():
    ans *= (v+1)
    ans %= mod
print((ans-1)%mod)
        




Measured memory_bytes: 3828
def main():
    # 行先、上限、逆辺
    def add_edge(From, to, cap):
        g[From][to] = cap
        g[to][-From-1] = 0

    def max_flow(s, t):
        def dfs():
            while q:
                v, t, f = q[-1]
                if ans[0] == 0:
                    if v == t:
                        ans[0] = f
                        continue
                    used[v] += 1
                    while True:
                        i = used2[v]
                        used2[v] += 1
                        if i < len(gkey[v]):
                            to = gkey[v][i]
                            cap = g[v][to]
                            if to < 0:
                                to2 = -to-1
                            else:
                                to2 = to
                            if used[to2] or cap == 0:
                                continue
                            q.append((to2, t, min(f, cap)))
                            break
                        else:
                            q.pop()
                            ans[0] = 0
                            break
                else:
                    q.pop()
                    if q:
                        v, t, f = q[-1]
                        i = used2[v]-1
                        to = gkey[v][i]
                        if to < 0:
                            to2 = -to-1
                        else:
                            to2 = to
                        g[v][to] -= ans[0]
                        g[to2][-v-1] += ans[0]

        flow = 0
        while True:
            used = [0]*n
            used2 = [0]*n
            q = [(s, t, 10**6)]
            ans = [0]
            dfs()
            if not ans[0]:
                return flow
            flow += ans[0]

    h, w = map(int, input().split())
    n = h+w+2
    g = [dict() for _ in range(n)]
    for i in range(h):
        A = input()
        for j in range(w):
            if A[j] == "o":
                add_edge(i, j+h, 1)
                add_edge(j+h, i, 1)
            elif A[j] == "S":
                add_edge(h+w, i, 10**6)
                add_edge(h+w, j+h, 10**6)
            elif A[j] == "T":
                add_edge(i, h+w+1, 10**6)
                add_edge(j+h, h+w+1, 10**6)
    gkey = [list(i.keys()) for i in g]

    ans = max_flow(h+w, h+w+1)
    if ans >= 10**6:
        print(-1)
    else:
        print(ans)


main()


Measured memory_bytes: 6516
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>

int main(){
  int ain,as,n;
  std::cin >> n;
  std::vector<int> a(n,0);
  for(int i=1;i<n;i++){
    std::cin >> ain;
    a[ain-1]++;
  }
  as=a.size();
  for(int i=0;i<as;i++){
    std::cout << a[i] << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 4040
import datetime


s = input()
s_date = datetime.datetime.strptime(s, '%Y/%m/%d')


ref = "2019/04/30"
ref_date = datetime.datetime.strptime(ref, '%Y/%m/%d')

if s_date <= ref_date:
  print("Heisei")
else:
  print("TBD")

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int H, A;
    cin >> H >> A;

    cout << (H + A - 1) / A << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

bool water[3005];
bool sugar[3005];

int main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    int index = 0;
    a *= 100;
    b *= 100;
    while (a*index<=3000) {
        water[a*index] = true;
        index++;
    }
    rep(i, 3001) {
        if (water[i]) continue;
        if (i-b>=0 && water[i-b]) water[i] = true;
    }
    index = 0;
    while (c*index<=3000) {
        sugar[c*index] = true;
        index++;
    }
    rep(i, 3001) {
        if (sugar[i]) continue;
        if (i-d>=0 && sugar[i-d]) sugar[i] = true;
    }

    P ans = P(0, 0);
    double v = 0.0;

    rep(i, 3001) rep(j, 3001) {
        if (!water[i]) continue;
        if (!sugar[j]) continue;
        if (i==0 || j==0) continue;
        int sum = i+j;
        if (i+j>f) continue;
        double p = 100.0*j/(i);
        if (p>e) continue;
        if (p>v) {
            ans = P(i, j);
            v = p;
        }
    }

    if (ans==P(0, 0)) {
        ans.first = a;
    }
    
    cout << ans.first+ans.second << " " << ans.second << endl;
    return 0;
}


Measured memory_bytes: 3572
using System;
using System.Text;

namespace _035_IsitConvex
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;
			StringBuilder output = new StringBuilder (100 * 4);

			while ((inputStr = Console.ReadLine ()) != null)
			{
				decimal[] inputNum = Array.ConvertAll (inputStr.Split (','), decimal.Parse);

				Vector2 point1 = new Vector2 (inputNum[0], inputNum[1]);
				Vector2 point2 = new Vector2 (inputNum[2], inputNum[3]);
				Vector2 point3 = new Vector2 (inputNum[4], inputNum[5]);
				Vector2 point4 = new Vector2 (inputNum[6], inputNum[7]);

				Vector2 line1 = point2 - point1;
				Vector2 line2 = point3 - point2;
				Vector2 line3 = point4 - point3;
				Vector2 line4 = point1 - point4;

				int sign1 = Math.Sign (Vector2.CrossProduct (line1, line2));
				int sign2 = Math.Sign (Vector2.CrossProduct (line2, line3));
				int sign3 = Math.Sign (Vector2.CrossProduct (line3, line4));
				int sign4 = Math.Sign (Vector2.CrossProduct (line4, line1));

				bool isConvex =
					sign1 == sign2 &&
					sign2 == sign3 &&
					sign3 == sign4;

				if (isConvex)
				{
					output.AppendLine ("YES");
				}
				else
				{
					output.AppendLine ("NO");
				}
			}

			Console.Write (output);
		}
	}

	class Vector2
	{
		public Vector2 ( decimal x, decimal y )
		{
			this.X = x;
			this.Y = y;
		}

		public decimal X { private set; get; }
		public decimal Y { private set; get; }

		public static Vector2 operator - ( Vector2 ob1, Vector2 ob2 )
		{
			return new Vector2 (ob1.X - ob2.X, ob1.Y - ob2.Y);
		}

		public decimal Length ()
		{
			return X * X + Y * Y;
		}

		public Vector2 Normalize ()
		{
			decimal length = this.Length ();

			if (length != 0)
				return new Vector2 (X / length, Y / length);
			else
				return new Vector2 (X, Y);
		}

		public static decimal DotProduct ( Vector2 line1, Vector2 line2 )
		{
			return line1.X * line2.X + line1.Y * line2.Y;
		}

		public static decimal CrossProduct ( Vector2 line1, Vector2 line2 )
		{
			return line1.X * line2.Y - line1.Y * line2.X;
		}
	}
}

Measured memory_bytes: 9412
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M = 2e5+5;
int L[M][2],R[M][2];
int valid[M],A[M],B[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	memset(L,-1,sizeof(L));
	memset(R,-1,sizeof(R));
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>A[i];
	for(int i=0;i<n;i++)
		cin>>B[i];
	for(int i=0;i<n;i++)
	{
		R[A[i]][0] = i;
		R[B[i]][1] = i;
	}
	for(int i=n-1;i>=0;i--)
	{
		L[A[i]][0] = i;
		L[B[i]][1] = i;
	}
	for(int i=1;i<=n;i++)
	{
		int a = L[i][0], b = R[i][0];
		int c = L[i][1], d = R[i][1];
		if(a == -1 || c == -1)
		{
			valid[0] += 1;
			continue;
		}
		int d1 = (a-d+n)%n;
		int d2 = (b-c+n)%n;
		// not intersecting
		if(c > b || a > d)
		{
			valid[0] += 1;
			valid[d1] -= 1;
			valid[d2+1] += 1;
		}
		else
		{
			if(d1 == 0)
				d1 = n;
			if(d2+1 <= d1)
			{
				valid[d2+1]++;
				valid[d1]--;
			}
		}
	}
	vector<int> res(n, 0);
	for(int i=0;i<n;i++)
	{
		if(i)
			valid[i] += valid[i-1];
		if(valid[i] == n)
		{
			for(int j = 0; j < n; j++)
				res[(i+j)%n] = B[j];
			cout<<"Yes\n";
			for(int j=0;j<n;j++)
				cout<<res[j]<<" ";
			cout<<"\n";
			return 0;
		}	
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 9568
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <bitset>

#define Z class
#define ln cout<<'\n'
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

//===== グラフ受け取り =====//
/*
    int N, M; cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);

        // 無向グラフの場合は以下を追加
        // G[b].push_back(a);
    }
    
    // == 重み付きグラフ == //
    
    struct Edge {
        int to; 
        int weight; 
        Edge(int t, int w) : to(t), weight(w) { }
    };
    using Graph = vector<vector<Edge>>;
    int main() {
        int N, M; cin >> N >> M;
        Graph G(N);
        for (int i = 0; i < M; ++i) {
            int from, to, weight;
            cin >> from >> to >> weight;
            G[from].push_back(Edge(to, weight));
        }
    }
*/    

using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
using pll = pair<long long, long long>;

template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
   int a, b; cin >> a >> b;
   cout << (b-a)*(b-a+1)/2-b << endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
long long solve(string t){
	long long same=0,count=0;
	for(int i=0;i<t.size();i++){
		same=same+1;
		if(i==t.size()-1||t[i]!=t[i+1]){
			count+=same/2;
			same=0;
		}
	}
	return count;
}

int main(){
	string s,st;
	long long k,lens,sum=0;
	cin>>s;
	cin>>k;
	lens=s.size();
	bool f=true;
	for(int i=0;i<lens-1;i++)if(s[i]!=s[i+1])f=false;          //下标 
    if(f==true)cout<<(lens*k)/2;
    else
	{
    	st=s+s;
    	long long scount=solve(s);
    	long long stcount=solve(st);
    	//cout<<scount<<" "<<stcount<<endl;
    	cout<<scount+(stcount-scount)*(k-1);	
	}			
	return 0;
}





Measured memory_bytes: 256