akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>


using namespace std;

int main(){
  int N,Q; cin >> N >> Q;
  string S; cin >> S;
  vector<int> l(Q),r(Q);
  for(int i = 0; i < Q; i++){
    cin >> l[i] >> r[i]; l[i]--; r[i]--;} //0-indexed
  
  vector<int> cumul(N,0);
  
  for(int i = 0; i < N - 1; i++){
    if(S[i+1] == 'C' && S[i] == 'A'){ cumul[i+1] = cumul[i] + 1;}
    else{ cumul[i+1] = cumul[i];}}
  
  //i番目までの累積和をcumulvectorに作る
  
  for(int i = 0; i < Q; i++){
    cout << cumul[r[i]] - cumul[l[i]] << endl;}
  return 0;}
    
  

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <limits>
#include <numeric>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;

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

	int N, x, temp;
	vector<int> kids;
	vector<int> stat;
	int total = 0;
	int count = 0;

	cin >> N >> x;

	REP(i, N)
	{
		cin >> temp;
		kids.push_back(temp);
		stat.push_back(0);
		total += temp;
	}


	sort(kids.begin(), kids.end());
	REP(i, kids.size())
	{
		if (x >= kids[i])
		{
			x = x - kids[i];
			stat[i] = 1;
			count++;
		}
		else
		{
			break;
		}
	}
	temp = 1;
	REP(i, stat.size())
	{
		if (stat[i] == 0)temp = 0;
	}
	if (x > 0 && count != 0 && temp == 1)count--;
	cout << count << endl;


	return 0;
}

Measured memory_bytes: 256
use std::io::Write;
use std::cmp;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let margin = 10;

    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let mut s = String::from(s);
    let len = s.len();
    for _ in 0..margin {
        s.push(' ');
    }
    debugln!("\"{}\"", s);
    debugln!("len: {}", len);
    debugln!("len after: {}", s.len());

    // dp[i][j]はs[i..j]が最後の区切りになるパターンの最大値
    let mut dp = vec![vec![1; 4]; len + margin];

    for i in 0..len {
        for j in 0..4 {
            for k in 0..4 {
                if s[i..(i+j+1)] != s[(i+j+1)..(i+j+k+2)] {
                    dp[i+j+1][k] = cmp::max(dp[i+j+1][k], dp[i][j] + 1)
                }
            }
        }
    }

    let mut result = 0;
    for i in 0..4 {
        result = cmp::max(result, dp[len - i - 1][i])
    }
    println!("{}", result);
}


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

#define INF 1e9
#define LLINF 1e18
#define PI 3.1415926535897932384
#define MOD 1000000007

#define REP(i, n) for(int i=0; i<n; ++i)
#define REPR(i, n) for(int i=n; i>=0; --i)
#define REPS(i, m, n) for(int i=m; i<n; ++i)
#define SORT(v, n) sort(v, v+n)
#define RSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define PB(n) push_back(n)
using namespace std;

int main() {
  int n;
  vector<int> v;
  REP(i, 12) {
    cin >> n;
    v.PB(n);
  }
  int cnt = 0;
  VSORT(v);
  REPS(i, 0, 11) {
    if(v[i] != v[i+1]) {
      ++cnt;
      if(((i == 3) && (i+1 == 4)) || ((i == 7) && (i+1 == 8))) {
        continue;
      } else {
        cout << "no" << endl;
        return 0;
      }
    }
  }
  if(cnt == 0 || cnt == 1 || cnt == 2) cout << "yes" << endl;

}






Measured memory_bytes: 3160
#include <iostream>
#include <vector>

using namespace std;
using int64 = long long;

int main() {
    int64 n;
    cin >> n;
    vector<int64> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int _n = a.back(); a.pop_back();
    double mid = _n / 2.0;

    int pre = INT_MAX;
    int _r = 0;

    for (auto ai : a) {
        double ab = mid - ai;
        if (ab < 0) ab = -ab;
        if (pre > ab) pre=ab,_r=ai;
    }

    cout << _n << " " << _r << endl;
}

/*
 * nCr = n! / r! * (n-r)!
 */

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }

int main()
{
    int n,k,r,s,p,ans=0; //r=0,s=1,p=2
    string q,x;
    cin>>n>>k>>r>>s>>p>>q;
    
    rep(i,n){

        if(q[i]=='r'){
            if(i>=k) {
                if(x[i-k]=='p')x+='a';
                else x+='p',ans+=p;
            }
            else x+='p',ans+=p;
        }
        if(q[i]=='s'){
            if(i>=k) {
                if(x[i-k]=='r')x+='a';
                else x+='r',ans+=r;
            }
            else x+='r',ans+=r;
        }
        if(q[i]=='p'){
            if(i>=k) {
                if(x[i-k]=='s')x+='a';
                else x+='s',ans+=s;
            }
            else x+='s',ans+=s;
        }
        //cout<<ans<<" "<<x<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll X;
    cin >> X;
    if (400 <= X && X <= 599) {
        cout << 8 << '\n';
    } else if (600 <= X && X <= 799) {
        cout << 7 << '\n';
    } else if (800 <= X && X <= 999) {
        cout << 6 << '\n';
    } else if (1000 <= X && X <= 1199) {
        cout << 5 << '\n';
    } else if (1200 <= X && X <= 1399) {
        cout << 4 << '\n';
    } else if (1400 <= X && X <= 1599) {
        cout << 3 << '\n';
    } else if (1600 <= X && X <= 1799) {
        cout << 2 << '\n';
    } else {
        cout << 1 << '\n';
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define popb pop_back
#define all(A) A.begin(),A.end()
#define mod 1000000007
using namespace std;
int main() {
	int n;
	ll a=0,b=0,k;
	cin>>n>>k;
	vector<int> arr(n);
	for(int i=0;i<n;i++) cin>>arr[i];
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(arr[i]<arr[j]) a++;
			if(arr[i]>arr[j]) b++;
		}
	}
	ll ans=(k*(k-1))/2;
	ans%=mod;
	ans*=a+b;
	ans%=mod;
	ans+=(k*b)%mod;
	ans%=mod;
	cout<<ans<<"\n";
	return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

	ll n, m;
	string s, t;
	cin >> n >> m >> s >> t;

	ll l = lcm(n, m);
	map<ll, char> mp1;
	map<ll, char> mp2;

	for(int i = 0; i < n; ++i)
		mp1[l/n*i] = s[i];

	for(int i = 0; i < m; ++i)
		mp2[l/m*i] = t[i];

	for(auto &&x : mp1)
		if(mp2.count(x.first) && mp2.at(x.first) != x.second) {
			cout << "-1\n";
			return 0;
		}
	cout << l << '\n';
	return 0;
}


Measured memory_bytes: 10880
#include<stdio.h>
int main(void)
{
	int n;
	int a[20];
	int i, j, co = 0, flag;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = n-1; i > 0; i--) {
		flag = 0;
		for (j = i - 1; j >= 0; j--) {
			if (a[i] >= a[j]&&flag!=2) {
				flag = 1;
			}
			else {
				flag = 2;
			}
		}
		if (flag == 1) {
			co++;
		}
	}
	printf("%d\n", co+1);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int NMAX=1<<17;
bool prim[100010];
vector<int> vi;
int q;
int l[100010],r[100010];
int sieve(int a){
  int res=0;
  rep1(i,a){
    prim[i]=true;
  }
  prim[1]=false;
  for(int i=2;i<=a;i++){
    if(prim[i]){
      int b=i*2;
      while(b<=a){
	prim[b]=false;
	b+=i;
      }
      res++;
    }
  }
  return res;
}

int main(){
  scan(q);
  rep(i,q){
    scan(l[i]);scan(r[i]);
  }
  sieve(100000);
  int s[100001];
  int cnt=0;
  rep(i,100001){
    if(prim[i]&&prim[(i+1)/2]){
      cnt++;
    }
    s[i]=cnt;
  }
  rep(i,q){
    prin(s[r[i]]-s[l[i]-1]);
  }


  
  return 0;
}


Measured memory_bytes: 1920
H, W, A, B = map(int, input().split())

G = [['0'] * W for _ in range(H)]
for h in range(H - B):
    for w in range(W - A):
        G[h][w] = '1'
for h in range(H - B, H):
    for w in range(W - A, W):
        G[h][w] = '1'

for row in G:
    print(''.join(row))



Measured memory_bytes: 16564
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<char>> A(H);
    vector<bool> B(H, true), C(W, true);
    for (int i = 0; i < H; i++)
    {
        vector<char> tmp(W);
        for (int j = 0; j < W; j++)
        {
            cin >> tmp[j];
        }
        A[i] = tmp;
    }
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (A[i][j] != '.')
            {
                B[i] = false;
                break;
            }
        }
    }
    for (int i = 0; i < W; i++)
    {
        for (int j = 0; j < H; j++)
        {
            if (A[j][i] != '.')
            {
                C[i] = false;
                break;
            }
        }
    }
    for (int i = 0; i < H; i++)
    {
        if (!B[i])
        {
            for (int j = 0; j < W; j++)
            {
                if (!C[j])
                {
                    cout << A[i][j];
                }
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	char a,b,t,n;
	scanf("%c %c",&a,&b);
	if(a=='A')
		t=10;
		else if(a=='B')
		t=11;
		else if(a=='C')
		t=12;
		else if(a=='D')
		t=13;
		else if(a=='E')
		t=14;
		else if(a=='F')
		t=15;
	if(b=='A')
		n=10;
		else if(b=='B')
		n=11;
		else if(b=='C')
		n=12;
		else if(b=='D')
		n=13;
		else if(b=='E')
		n=14;
		else if(b=='F')
		n=15;
	if(t>n)
		printf(">\n");
		else if(t<n)
		printf("<\n");
		else if(t==n)
		printf("=\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int N,M;
	cin>>N>>M;
	
	long long sum=1;
	if(N==M || N==(M+1) || (N+1)==M){
		for(int i=1 ; i<=M ; i++){
			sum=(sum*i)%(1000000000+7);
		}
		for(int i=1 ; i<=N ; i++){
			sum=(sum*i)%(1000000000+7);
		}
		
		if(N==M)sum=(sum*2)%(1000000000+7);
		cout<<sum<<"\n";
	}
	else{
		cout<<0<<"\n";
	}
	
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	ll A, B, ans = LLONG_MAX, sum = 0;
	for (int i = 0;i < N;i++) {
		cin >> A >> B;
		if (A > B)
			ans = min(ans, B);
		sum += A;
	}
	if (ans == LLONG_MAX)
		cout << 0 << endl;
	else
		cout << sum - ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
ll mod = 1000000007;
/* references
https://drken1215.hatenablog.com/entry/2020/04/29/171300
https://hiramekun.hatenablog.com/entry/2020/04/27/031032
https://qiita.com/Seika139/items/8cacdb3cc8fa6655573c
*/
int main(){
  string s; cin >> s;
  map<ll,ll> m;
  m[0]++; // ここの理由がよくわからない
  ll prev=0;
  ll x=1;
  for(ll i=s.size()-1; i>=0; i--){
    ll cur = (s[i] - '0');
    cur*=x;
    cur+=prev;
    cur%=2019;
    m[cur]++;
    prev=cur;
    x*=10;
    x%=2019;
  }
  ll ans = 0;
  for(auto p:m){
    ans += p.second*(p.second-1)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3748
#include<iostream>
using namespace std;
long long a[10][10][60], x[10][60]; int n, m;
int main() {
	a[0][0][0] = 1; a[1][0][0] = 1;
	for (int i = 1; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 60; k++) {
				for (int l = j + 1; l < 10; l++) {
					a[i][l][k + l] += a[i - 1][j][k];
				}
			}
		}
	}
	for (int i = 1; i < 10; i++) {
		for (int j = 0; j < 60; j++) {
			for (int k = 0; k < 10; k++) {
				x[i][j] += a[i][k][j];
			}
		}
	}
	while (true) {
		cin >> n >> m;
		if (!n) { break; }
		cout << x[n][m] << endl;
	}
}

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    ll n, m;
    cin >> n >> m;
    vl h(n);
    rep(i, n) cin >> h[i];

    vii g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ll ans = 0;
    rep(i, n) {
        bool ok = true;
        foreach (e, g[i]) {
            if (h[i] <= h[e]) ok = false;
        }
        if (ok) {
            ans++;
        }
    }

    out(ans);
    return 0;
}


Measured memory_bytes: 9244
import java.util.Arrays;
import java.util.Scanner;

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

        if (a + b + 1 < c)
            System.out.println(a + b + 1 + b);
        else
            System.out.println(b + c);
    }

}










Measured memory_bytes: 21716
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  string s;
  cin>>s;
  bool flag=0;
  rep(i,3){
    if(s[i]=='7') flag=1;
  }

  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3592
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
				
		int n = sc.nextInt();
		int ans = 0;
		ans = n/3;
		
		out.println(ans);
		out.close();
	}

	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	//--------------------------------------------------------

}

Measured memory_bytes: 21204
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
using ll = long long;
//#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
int ans=0;
signed main(){
    int n,m; cin >> n>>m;
    cout<<((n-m)*100+1900*m)*(int)pow(2,m)<<endl;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
    int W, H, x, y, r;
    std::cin >> W >> H >> x >> y >> r;
    if((x+r)<=W && (y+r)<=H && (x-r)>=0 && (y-r)>=0) std::cout << "Yes" << std::endl;
    else std::cout <<"No" <<std::endl;
    return 0;
}


Measured memory_bytes: 3104
while True:
    n = input().split()
    h = int(n[0])
    w = int(n[1])
    if h ==0 and w==0:
        break
    a = "#" * w
    b = "#" + "." * (w-2) + "#"
    print(a)
    for x in range(h-2):
        print(b)
    print(a)
    print()


Measured memory_bytes: 5608
#include <iostream>

using namespace std;

int main(){
    int i,j,temp;
    int n=3;
    int s[100000];
    
    for(i=0; i<n; i++){
    cin >> s[i];
    }
    
    for (i=0; i<n; ++i) {
        for (j=i+1; j<n; ++j) {
            if (s[i] > s[j]) {
                temp = s[i];
                s[i] = s[j];
                s[j] = temp;
            }
        }
    }

    for (i=0; i<n; i++){
        if(i<2){
        cout << s[i] <<" ";
        }else{
        cout << s[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1168
gets
h = Hash.new(0)

a = gets.chomp.split(" ").map(&:to_i)
a.each { |c| h[c] += 1}

x = Array.new
h.sort.reverse.each do | key, val|
  if h[key] >= 4 then
    x.push(key)
    x.push(key)
  elsif h[key] >= 2 then
    x.push(key)
  end
  break if x.size == 2
end

if x.size >= 2 then
  puts x[0] * x[1]
else
  puts 0
end

Measured memory_bytes: 22528
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;

void solve(void){

  long long int a,b;
  cin >>a >>b;
  
  if(a>12) cout << b <<endl;
  else if(a>5) cout << b/2 <<endl;
  else cout << 0 <<endl;
    
return;
}
int main(void){
  
	solve();
	return 0; 
}

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

const int size = 301;
int n, m;
int C[size], V[size], D[size], L[size];
int dpV[size], dpD[size], dpL[size];

void solve() {
  // init
  for ( int i = 0; i <= m; i++ ) {
    dpV[i] = dpD[i] = dpL[i] = 0;
  }

  // input
  for ( int i = 0; i < n; i++ ) {
    string name;
    cin.ignore();
    cin.clear();
    getline( cin, name );
    cin >> C[i] >> V[i] >> D[i] >> L[i];
  }

  // proc
  for ( int i = 0; i <= m; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      int next_i = i+C[j];
      if ( next_i > m ) continue;

      dpV[next_i] = max( dpV[next_i], dpV[i]+V[j] );
      dpD[next_i] = max( dpD[next_i], dpD[i]+D[j] );
      dpL[next_i] = max( dpL[next_i], dpL[i]+L[j] );
    }
  }

  int answer = 0;
  for ( int i = 0; i <= m; i++ ) {
    answer = max( answer, dpV[i] );
    answer = max( answer, dpD[i] );
    answer = max( answer, dpL[i] );
  }

  cout << answer << endl;
}

int main() {
  while ( cin >> n >> m ) {
    solve();
  }
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif

void solve() {
    long long n, k;
    cin >> n >> k;
    vector<long long> arr(n);

    for (long long &i: arr)
        cin >> i;

    long long lo = 0, hi = 1e9, mid, req;
    while(lo + 1 < hi) {
        mid = (lo + hi) >> 1;
        req = 0;
        for (long long i: arr) {
            req += ((i + mid - 1)/ mid) - 1;
        }

        if (req <= k)
            hi = mid;
        else
            lo = mid;
    }

    cout << hi;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
string s;
int vst[1];
int main(){
    cin>>s;
    for(int i=0;i<s.length();i++){
        if((!vst[0])&&s[i]=='C') vst[0]=1;
        if(vst[0]&&s[i]=='F') vst[1]=1;
        if(vst[1]&&vst[0]){cout<<"Yes";return 0;}
    }
    cout<<"No";
    return 0;
}

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

using namespace std;
int a[200005];
int main(){
	int n,b;
	cin>>n>>b;
	long long ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	for(int i=b;i<n;i++)ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val as = List.fill(n)(sc.nextLong())
  if (as.contains(0)) {
    println(0)
  } else {
    var ans = 1L
    var continue = true
    for (a <- as) {
      if (continue) {
        val prev = ans
        ans *= a
        if (ans < prev || ans > 1000000000000000000L) {
          continue = false
          ans = -1
        }
      }
    }
    println(ans)
  }
}

Measured memory_bytes: 63144
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,m;cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
using namespace std;

int main() {
	int A,B,C,D,E,F;
	cin >> A>>B>>C;
	D = A - B;
	E = B - C;
	F = A - C;
	if (D == 0 && (A != C)) {
		cout << "Yes" << endl;
	}
	else if (E == 0 && (A != B)) {
		cout << "Yes" << endl;
	}
	else if (F == 0 && (B != C)) {
		cout << "Yes" << endl;
	}
	else { cout << "No" << endl; };
	return 0;
}

Measured memory_bytes: 256
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define LLINF 100000000000000005LL
#define INF (int)1e9+1
#define pb push_back

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

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

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

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

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

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

int main() {
	IOS;
	double d, t, s;
	cin >> d >> t >> s;
	if (d / s > t) cout << "No";
	else cout << "Yes";
}


Measured memory_bytes: 3724
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c,d;
	cin>>n;
	b=MAX,c=0,d=0;
	for(i=0;i<n;i++){
		cin>>a;
		if(i==0){
			b=a;continue;
		}
		if(b>=a)c++;
		else d=max(d,c),c=0;
		b=a;
	}
	d=max(d,c);
	cout<<d<<endl;
}

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

using namespace std;
#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 rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int m;
	cin >> m;
	print(48 - m);
}

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

int main(){
    int people, current, least;
    unsigned long long total = 0;
    cin >> people >> current;
    least = current;
    for(int i = 0; i < people-1; i++){
        cin >> current;
        if(current < least) total += least - current;
        else least = current;
    }
    cout << total << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 3.141592653589;

int main(){
  cout << fixed << setprecision(20);
  ll a, b, x;
  cin >> a >> b >> x;
  if(a * a * b >= x * 2){ // 三角柱の形 a * b * b / tan(theta) / 2
    double tanx = a * b * b / 2.0 / x;
    cout << atan(tanx) * 180 / PI << endl;
  }
  else{ // 直方体 - 三角柱の形 a * a * b - a * a * atan(theta) / 2
    double tanx = 2.0 * (a * a * b - x) / a / a / a;
    cout << atan(tanx) * 180 / PI << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
const long long int mod=1e9+7;
typedef long long ll;

ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

bool issq(int n){
    int i=1;
    while(i*i<=n){
        if(i*i==n){
            return true;
        }
        i++;
    }
    return false;
}
int main(){
    int N,D;
    cin >>N>>D;
    int ans=N/((2*D)+1);
    if(N%(2*D+1)!=0){
        ans++;
    }

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




Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();
    
    if (x < 1200) {
      System.out.println("ABC");
    } else {
      System.out.println("ARC");
    }
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<math.h>
#define pi acos(-1)
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ld x;
	cin>>x;
	ld res = 2*x*pi;
	cout << fixed << setprecision(20) << res << endl;
	return 0;
}


Measured memory_bytes: 3768
#include<algorithm>
#include<cstdio>
#include<map>
#include<vector>
using namespace std;

int n, a, b;
vector<long> v;

struct choice {
    long sum;
    double avg;
    map<long, int> cnt;
};

choice c[50];

int main() {
    scanf("%d %d %d", &n, &a, &b);
    for (int i = 0; i < n; i++) {
        long x;
        scanf("%ld", &x);
        v.push_back(x);
    }
    
    sort(v.begin(), v.end(), [](const long &l1, const long &l2)->bool {
        return l1 > l2;
    });
    
    c[0].cnt[v[0]]++;
    c[0].sum = v[0];
    c[0].avg = v[0];
    for (int i = 1; i < n; i++) {
        c[i].cnt = map<long, int>(c[i - 1].cnt);
        c[i].cnt[v[i]]++;
        c[i].sum = c[i - 1].sum + v[i];
        c[i].avg = static_cast<double>(c[i].sum) / (i + 1);
    }

    map<long, int> &m = c[n - 1].cnt;
    
    long ans = 0;
    double am = c[a - 1].avg;
    for (int i = a - 1; i < b; i++) {
        if (c[i].sum * a != c[a - 1].sum * (i + 1)) break;
        long ans1 = 1;
        for (auto &j : c[i].cnt) {
            for (int k = 0; k < j.second; k++) {
                ans1 = ans1 * (m[j.first] - k) / (k + 1);
            }
        }
        ans += ans1;
    }

    printf("%lf\n", am);
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

const int N = 1e5 + 5;

ll dpM[N], dpm[N], a[N];

vector<int> g[N];
bool ans = true;

void gdp(int u, int p = -1){
	if(g[u].size() == 1){
		dpM[u] = dpm[u] = a[u];
		return;
	}
	ll maxw = -1, sumM = 0, summ = 0;
	for(int v: g[u]){
		if(v == p)continue;
	 	gdp(v, u);
		gmax(maxw, dpM[v]);
		sumM += dpM[v];
		summ += dpm[v];
	}
	if(sumM < a[u])ans = false;
	ll w = a[u];
	dpM[u] = min(w,2 * w - summ);
	dpm[u] = max(max(w-(2*maxw > sumM?sumM-maxw:sumM/2),2*w-sumM),0LL);
	if(dpm[u] > sumM || dpm[u] > dpM[u])ans = false;
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	rep(i,0,n)cin >> a[i];
	if(n == 2){
		cout << (a[0] == a[1]?"YES":"NO") << '\n';
		return 0;
	}
	rep(i,0,n-1){
		int x,y;
		cin >> x >> y;
		--x,--y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	rep(i,0,n){
		if(g[i].size() != 1){
			gdp(i);
			ans &= dpm[i] == 0;
			break;
		}
	}
	cout << (ans?"YES":"NO") << '\n';
}


Measured memory_bytes: 14720
H = int(input())
W = int(input())

N = int(input())

boad = [[0] * W for i in range(H)]
n = 0
# boad.pop()
count = 1
j = 1
# print(boad)
if N <= H or N <= W:
    print(1)

elif H < W:

    boad.pop()
    n = W
    while(True):
        
        if n + len(boad[0]) >= N:
            count += 1
            print(count)
            break

        elif n + len(boad) >= N:
            count += 1
            print(count)
            break

        n += W
        count += 1
        boad.pop()

elif W < H:
    W -= 1
    boad = boad = [[0] * W for i in range(H)]
    n = H

    while(True):
        
        if n + len(boad[0]) >= N:
            count += 1
            print(count)
            break

        elif n + len(boad) >= N:
            count += 1
            print(count)
            break

        n += H
        W -= 1
        count += 1
        boad = [[0] * W for i in range(H)]

else:
    boad.pop()
    n = W
    while(True):
        
        if n + len(boad[0]) >= N:
            count += 1
            print(count)
            break

        elif n + len(boad) >= N:
            count += 1
            print(count)
            break

        n += W
        count += 1
        boad.pop()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
int n;
cin >> n;
  double sum = 0;
rep(i,n){
  double x;
  cin >> x;
  double y = 1/x;
  sum += y;
}
 printf("%.10f\n",1/sum);
}
  


Measured memory_bytes: 256
func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts(separator: String.Element = " ") -> [Int] {
    return readLine()!.split(separator: separator).map { Int($0)! }
}

func readTwoInts(separator: String.Element = " ") -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

func mainB() {
    let N = readInt()
    let pairs = (0..<N).map { _ in readTwoInts() }

    var count = 0
    for pair in pairs {
        if pair.a == pair.b {
            count += 1
        } else {
            count = 0
        }

        if count == 3 {
            print("Yes")
            return
        }
    }

    print("No")
}
mainB()

Measured memory_bytes: 8328
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    char c=in.next().charAt(0);
    char up=Character.toUpperCase(c);
    char down=Character.toLowerCase(c);
    if(c==up)
    {
      System.out.println("A");
    }
    else
    {
      System.out.println("a");
    }
  }
}

Measured memory_bytes: 35520
#include <iostream>
#include <cmath>
#define rep(a,i,n) for(int i=(a);i<(n);i++)
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
ll n,k,max=0,min=0,sum=0;
cin >> n;
cin >> k;
rep(0,i,n+1){
  max += n-i;
  min += i;
 if(i < k-1)
   continue;
sum += max - min + 1;
}
cout << sum%mod << endl;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;

    for (int i = 0; i < A + B + 1; i++)
    {
        if (i == A)
        {
            if (S.at(i) != '-')
            {
                cout << "No" << endl;
                return 0;
            }
        }
        else
        {
            if (S.at(i) == '-')
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int	main(void)
{
  int times, start, end, people = 0;
  cin >> times;
  
  while (times > 0)
  {
    cin >> start >> end;
    people += (end - start) + 1;
    times--;
  }
  
  cout << people << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <utility>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <stack>
using namespace std;

#define LL   long long
#define ld   long double
#define pii  pair<int,int>
#define pLL  pair<LL,LL>
#define vint vector<int>
#define vLL  vector<LL>

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define MP make_pair
#define PB push_back

#define Si(x) scanf("%d",&(x));
#define Sii(x,y) scanf("%d %d",&(x),&(y));
#define Siii(x,y,z) scanf("%d %d %d",&(x),&(y),&(z));
#define SL(x) scanf("%lld",&(x));
#define SLL(x,y) scanf("%lld %lld",&(x),&(y));
#define SLLL(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z));

#define Pi(x) printf("%d\n",(x));
#define Pii(x,y) printf("%d %d\n",(x),(y));
#define Piii(x,y,z) printf("%d %d %d\n",(x),(y),(z));
#define Piiii(x,y,z,w) printf("%d %d %d %d\n",(x),(y),(z),(w));
#define Piiiii(a,b,c,d,e) printf("%d %d %d %d %d\n",(a),(b),(c),(d),(e));
#define Piiiiii(a,b,c,d,e,f) printf("%d %d %d %d %d %d\n",(a),(b),(c),(d),(e),(f));
#define PL(x) printf("%lld\n",(x)*1LL);
#define PLL(x,y) printf("%lld %lld\n",(x)*1LL,(y)*1LL);
#define PLLL(x,y,z) printf("%lld %lld %lld\n",(x)*1LL,(y)*1LL,(z)*1LL);
#define PLLLL(x,y,z,w) printf("%lld %lld %lld %lld\n",(x)*1LL,(y)*1LL,(z)*1LL,(w)*1LL);

#define Pi1(x) printf("%d",  (x));
#define PiL(x) printf("%lld",(x));
#define Pspace putchar(' ');
#define Pendl  puts("");

#define MEM0(x) memset( (x), 0, sizeof( (x) ) )
#define MEM1(x) memset( (x),-1, sizeof( (x) ) )
#define REP1(i,n)  for (int i = 1; (n) >= i ; ++i)
#define REP0(i,n)  for (int i = 0; (n) >  i ; ++i)
#define REP(L,R,k) for (int i = (L); (R) >= i; i+= (k) )

int myRnd(int L,int R) {
    return abs(( (rand()<<15)|rand() ) ) % (R-L+1) + L;
}

const int N = 1006;
const LL INF = 1e18 + 6;

LL a[N],b[N];

int main () {
    srand(time(NULL));
    int n;
    Si(n);
    REP1(i,n) {
        SLL(a[i],b[i]);
        if (i==1) continue;
        if (a[i] >= a[i-1] && b[i] >= b[i-1]) continue;
        LL L=1,R=INF/max(a[i],b[i]);
        while (R-L!=1) {
            LL mid=(L+R)>>1;
            if (a[i]*mid >= a[i-1] && b[i]*mid >= b[i-1]) R=mid;
            else L=mid;
        }
        a[i] *= R;
        b[i] *= R;
    }
    PL(a[n]+b[n]);
}



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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s, t, u;

int main() {
	cin >> s >> t >> u;
	
	cout << s[0] << t[0] << u[0] << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long gcd(long a, long b) {
    if (a%b)
        return gcd(b, a%b);
    else
        return b;
}

int main() {
    long a, b;
    cin >> a >> b;
    
    long num = gcd(b, a);
    long cnt = 2;
    int ans = 1;
    while (num >= cnt*cnt) {
        if (!(num%cnt))
            ans++;
        while (!(num%cnt))
            num /= cnt;
        cnt++;
    }
    if (num != 1)
        ans++;

    cout << ans << endl;
}



Measured memory_bytes: 888
#include <cstdio>
#include <algorithm>
#include <climits>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int candidate[100];
int cn;
int fr[100][100];
int n, m;
int ans;

void solve(int now){
  if(now == cn){
    if(cn == 1) return;
    int tmp = 0;
    REP(i,cn){
      int mm = INT_MAX;
      REP(j,cn)if(i != j){
	mm = min(mm, fr[candidate[i]][candidate[j]]);
      }
      tmp += mm;
    }

    //REP(i,cn) printf("%d ", candidate[i]+1); printf(": %d\n", tmp);

    ans = max(ans, tmp);
  }else{
    // select
    {
      int cntmp = cn;
      int rab = candidate[now];
      for(int i = now + 1; i < cn;){
	if(fr[rab][candidate[i]] == 0){
	  --cn;
	  swap(candidate[i], candidate[cn]);
	}else{
	  ++i;
	}
      }

      solve(now + 1);

      cn = cntmp;
    }
    // not select
    {
      --cn;
      swap(candidate[now], candidate[cn]);
      solve(now);
      swap(candidate[now], candidate[cn]);
      ++cn;
    }
  }
}

int main(){
  scanf("%d%d", &n, &m);
  cn = n;
  REP(i,m){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    fr[a-1][b-1] = fr[b-1][a-1] = c;
  }
  REP(i,n) candidate[i] = i;
  
  solve(0);

  printf("%d\n", ans);

  return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s;
    vector<int> alp(30);
    for(int i=0;i<n;i++){
        cin >> s;
        vector<int> temp(30);
        for(int j=0;j<s.size();j++){
            temp[s[j]-'a']++;
        }
        for(int l=0;l<26;l++){
            if(i==0){
                alp[l]=temp[l];
            }
            else{
                alp[l]=min(alp[l],temp[l]);
            }
        }
    }
    for(int i=0;i<26;i++){
        for(int j=0;j<alp[i];j++){
            printf("%c",'a'+i);
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
import re
import sys

if __name__ == '__main__':
    a,b,k = map(int , raw_input().split())
    l = []
    for i in range(k):
        if a + i <= b:
            print a + i
            l.append(a+i)
    for i in range(k):
        if (b - k + i + 1) not in l and (b - k + i + 1) >= a:
            print b - k + i + 1


Measured memory_bytes: 2568
#include <cstdio>
#include <utility>
#include <queue>

using namespace std;

typedef pair<int, int> pii;
typedef pair<int, pii> P;

#define fst first
#define scd second
#define rep(i,x) for(int i=0;i<(x);++i)

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

int st[1000][1002];

int main()
{
	int H, W; scanf("%d %d", &H, &W);

	queue<P> q;

	rep(i, H) rep(j, W) {
		char c; scanf("\n%c", &c);
		if (c == '.') {
			st[i][j] = -1;
			q.push(P(0, pii(i, j)));
		} else {
			st[i][j] = c - '0';
		}
	}

	int ans;

	while (q.size()) {
		P p = q.front(); q.pop();
		ans = p.fst;
		rep(i, 8) {
			int ny = p.scd.fst + dy[i], nx = p.scd.scd + dx[i];
			if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
			if (--st[ny][nx] == 0) {
				q.push(P(p.fst + 1, pii(ny, nx)));
			}
		}
	}

	printf("%d\n", ans);
}

Measured memory_bytes: 5248
#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
using namespace std;

int main() {
	int N;
	cin >> N;
	int hundred = N / 100;
	int ten = N / 10 % 10;
	int one = N % 100 % 10;
	if (hundred < ten) {
		cout << (hundred + 1) * 111 << endl;
	}
	else if (hundred >= ten && hundred >= one) {
		cout << hundred * 111 << endl;
	}
	else {
		cout << (hundred + 1) * 111 << endl;
	}
}


Measured memory_bytes: 3596
#include <iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
    int N;
    int x[105], y[105], h[105];
    int rec[3];
    bool flag = true;
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] >= 1 && flag){
            rec[0] = x[i];
            rec[1] = y[i];
            rec[2] = h[i];
            flag = false;
        }
    }

    int X, Y, H, tmp;
    for (int i = 0; i <= 100; i++){
        for (int j = 0; j <= 100; j++){
            tmp = abs(i - rec[0]) + abs(j - rec[1]) + rec[2];
            bool flag = true;
            for (int k = 0; k < N; k++){
                if (max(0, tmp - abs(i - x[k]) - abs(j - y[k])) != h[k]){
                    flag = false;
                }
            }
            if(flag){
                X = i;
                Y = j;
                H = tmp;
            }

        }
    }
    cout << X << " " << Y << " " << H << endl;

	return 0;
}

Measured memory_bytes: 256