akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	int a[3],ans;
	while(~scanf("%d%d%d",a,a + 1,a + 2)){
		sort(a,a + 3);ans = 1;
		for(int i = 1;i < 3;i++) if(a[i] != a[i - 1]) ans++;
		printf("%d\n",ans);
	}
    return 0;
}

Measured memory_bytes: 128
W, H, N = map(int, input().split())
u = H
d = 0
r = W
l = 0
for _ in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    l = max(l, x)
  elif a == 2:
    r = min(r, x)
  elif a == 3:
    d = max(d, y)
  else:
    u = min(u, y)
dx = max(0, r - l)
dy = max(0, u - d)
print(dx * dy)

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

#define  pf                  printf
#define  sc                  scanf
#define  PI                  2*acos(0.0)
#define  fast                ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define  mem(a,b)            memset(a, b, sizeof(a) )
#define  gcd(a,b)            __gcd(a,b)
#define  lcm(a,b)            (a*(b/gcd(a,b)))
#define  MAX                 1234567899
#define  mod                 1000000007
#define  all(v)              (v).begin(),(v).end()
#define  vSort(v)            sort(all(v))
#define  maxSort(v)          sort(all(v),greater<int>())
#define  Unique(v)           v.erase(unique(all(v)),v.end())
#define  sqr(x)              ((x)*(x))
#define  qube(x)             ((x)*(x)*(x))
#define  deci(n)             cout<<fixed<<setprecision(n)
#define  sci(n)              sc("%d",&(n))
#define  scii(x,y)           sc("%d %d",&(x),&(y))
#define  scl(x)              sc("%lld",&(x))
#define  scll(x,y)           sc("%lld %lld",&(x),&(y))
#define  vi                  vector<int>
#define  hi                  pf(" HI \n")
#define  pp                  pair<int,int>
#define  pb(x)               push_back(x)
#define  mp(x,y)             make_pair(x,y)
#define  F                   first
#define  S                   second
#define  check(n,pos)        (n & (1<<(pos)))
#define  biton(n,pos)        (n  (1<<(pos)))
#define  bitoff(n,pos)       (n & ~(1<<(pos)))
typedef  long long int       lli;
typedef  unsigned long long int ulli;
int dx4[] = { 0, 0, -1, 1 } ;
int dy4[] = { -1, 1, 0, 0 } ;
bool valid( int r, int c, int x, int y )
{
    if( x >= 1 && x <= r && y >= 1 && y <= c ) return 1 ;
    return 0 ;
}

using namespace std;

lli DP[100005][5];
lli a[100005][3];
lli n;

lli cal(lli pos,lli k)
{
    if(pos==(n+1))
        return 0;
    if(DP[pos][k]!= -1)
        return DP[pos][k];
    lli val=0,val1=0;
    if(k==1)
    {
        val = a[pos][2]+cal(pos+1,2);
        val1 = a[pos][3]+cal(pos+1,3);
    }
    if(k==2)
    {
        val = a[pos][1]+cal(pos+1,1);
        val1 = a[pos][3]+cal(pos+1,3);
    }
    if(k==3)
    {
        val = a[pos][1]+cal(pos+1,1);
        val1 = a[pos][2]+cal(pos+1,2);
    }
    DP[pos][k]= max(val,val1);
    return DP[pos][k];
}
int main ()
{
    mem(DP,-1);
    cin >> n;
    for(int i=1; i<=n; i++)
        cin >> a[i][1] >> a[i][2] >> a[i][3];

    lli ans1  = a[1][1]+ cal(2,1);
    mem(DP,-1);
    lli ans2  = a[1][2]+ cal(2,2);
    mem(DP,-1);
    lli ans3  = a[1][3]+ cal(2,3);
    cout << max(ans1,max(ans2,ans3)) <<endl;
    return 0;
}



Measured memory_bytes: 11136
#include <string>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
string s,t,u;int a,b;
int main()
{
	cin>>s>>t>>a>>b>>u;
	if(s==u)--a;else if(t==u)--b;
	printf("%d %d\n",a,b);return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int main(){
  vector<string> data;
  char __s[252];
  while(~scanf("%s",__s)){
    string tmp(__s);
    if(tmp=="HELLO")break;
    data.push_back(string(__s));
  }
  int n = data.size();
  int val[n][n];
  int dp[n][n];
  REP(i,n)REP(j,n)val[i][j]=dp[i][j]=0;
  REP(i,n){
    string s = data[i];
    s += ",";
    int tmp = 0;
    int iter = max<int>(0,n/2-i);
    REP(j,s.size()){
      if(s[j]==','){
        val[i][iter++] = tmp;
        tmp = 0;
      }else{
        tmp *= 10;
        tmp += (s[j]-'0');
      }
    }
  }
  REP(i,n)REP(j,n){
    if(i==0){
      dp[i][j] = val[i][j];
    }else{
      dp[i][j] = val[i][j] + max<int>(dp[i-1][j],dp[i-1][j+1]);
    }
  }
  cout<<dp[n-1][0]<<endl;
  return 0;
}

Measured memory_bytes: 1308
#include <iostream>

using namespace std;

int main() {
  int N, Y;
  cin >> N;
  cin >> Y;
  int i, j, k;
  i = j = k = 0;
  int bill[3] = {-1, -1, -1};
  int num, total;

  for(i = 0; i <= N; i++) {
    for(j = 0; j <= N; j++) {
      k = N - i - j;
      total = 10000 * i + 5000 * j + 1000 * k;
      if(k < 0) total = -1;
      if(total == Y) {
        bill[0] = i;
        bill[1] = j;
        bill[2] = k;
      }
    }
  }

  cout << bill[0] << " " << bill[1] << " " << bill[2] << endl;


}


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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

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; }

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

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

  string s;
  ll ans;

  ll n, m;
  vector<ll> a, b;

  cin >> n;
  ans = n * (n - 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,i,w[10],n,j;
	while (1) {
		scanf("%d",&n);
		if (n == 0) {
			break;
		}
		for (i = 0; i < 10; i++) {
			w[i] = 0;
		}
		for(i=0;i<n;i++){
			scanf("%d",&a);
			w[a]+=1;
		}
		for(i=0;i<10;i++){
			if(w[i]==0){
				printf("-");
			}
			else{
				for(j=0;j<w[i];j++){
					printf("*");
				}
			}
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 998'244'353;

int main() {
    std::ios::sync_with_stdio(false);
    llint X;
    cin >> X;
    set<llint> pow5;
    for(llint i = -1000; i < 1000; i++) {
        pow5.insert(i * i * i * i * i);
    }
    llint a, b;
    for(auto B: pow5) {
        if(pow5.count(X + B)) {
            a = X + B;
            b = B;
            break;
        }
    }
    llint A, B;
    for(llint i = -1000; i < 1000; i++) {
        if(i * i * i * i * i == a) {
            A = i;
        }
        if(i * i * i * i * i == b) {
            B = i;
        }
    }
    cout << A << " " << B;
}




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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int32 N, M, K;
vector<int64> A, B;
string s;

double abss(double x){
	if(x < 0) return x*-1;
	return x;
}

int main(void){
	double T, A;
	cin >> N >> T >> A;
	int32 res = 0;
	double val = INF;
	REP(i, N){  
		double H;
		cin >> H;
		double t = T-0.006*H;
		if(abss(A-t) < abss(A-val)){
			val = t;
			res = i+1;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
struct rect_t { int h, w; };
template <typename T>
T sq(T x) { return x * x; }
int sqlen(rect_t const & a) { return sq(a.h) + sq(a.w); }
bool operator < (rect_t const & a, rect_t const & b) {
    if (sqlen(a) != sqlen(b)) {
        return sqlen(a) < sqlen(b);
    } else {
        return a.h < b.h;
    }
}
int main() {
    while (true) {
        rect_t a;
        cin >> a.h >> a.w;
        if (a.h == 0 and a.w == 0) break;
        rect_t result = { 151, 151 };
        repeat_from (h,1,150+1) {
            repeat_from (w,h+1,150+1) {
                rect_t b = { h, w };
                if (a < b and b < result) {
                    result = b;
                }
            }
        }
        cout << result.h << " " << result.w << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main{
  static long[] time;

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      time = new long[N];
      for(int i=0;i<N;i++){
        time[i] = sc.nextLong();
      }
      for(int i=0;i<N-1;i++){
        time[i+1] = (time[i])/GCD(time[i],time[i+1])*time[i+1];
        //System.out.println(GCD(time[i],time[i+1]));
      }
      System.out.println(time[N-1]);
  }

  static long GCD(long a,long b){
    if(a<b){
      return GCD(b,a);
    }
    else{
    if(a%b==0){
      return b;
    }
    else{
      return GCD(b,a%b);
    }
  }
 }

}

Measured memory_bytes: 24148
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int n,b,c,a[1005];

int num(int a,int b,int c)
{
	return a*a*c - 2*b*a;
}

int main() {
	IO
	cin>>n;
	for(int i=0;i<n;i++)
    {
		cin>>a[i];
		b+=a[i];
		c+=a[i]*a[i];
	}
	int l=-101,h=101;
	for(int i=0;i<100;i++)
	{
		int m1=2*l+h;
		int m2=2*h+l;
		m1/=3;
		m2/=3;
		if(num(m1,b,n)<num(m2,b,n)){
			h=m2;
		}
		else l=m1;
	}
	int cur=100000000;
	for(int i=l;i<=h;i++){
		cur=min(cur,num(i,b,n)+c);
	}
	cout<<cur<<endl;
	return 0;
}


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

int c[30]={0};

bool chck(int k){
	for(int i=0;i<26;i++){
		if(c[i]>=k) {c[i] -= k; return true;}
	}
	return false;
}

#define Return(x) {cout<<x<<endl; return 0;}

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

	for(int i=0;i<m;i++){
		string s; cin>>s;
		for(char x:s) c[x-'a']++;
	}
	int ok=1;
	for(int i=1;i<=m/2;i++){
		for(int j=1;j<=n/2;j++){
			if(!chck(4)) Return("No");
		}
	}

	if(n%2 == 1){
		for(int i=1;i<=m/2;i++) if(!chck(2)) Return("No");
	}

	if(m%2 == 1){
		for(int i=1;i<=n/2;i++) if(!chck(2)) Return("No");
	}

	if((n%2==1) and (m%2==1)) {
		if(!chck(1)) Return("No");
	}

	Return("Yes");
}

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

#include <cmath>
#include <map>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[]){

  int N;
  cin >> N;
  int H = 0;
  int count = 0;
  for(int i = 0; i < N; i++){
    int tmp = 0;
    cin >> tmp;
    if(H <= tmp){
        count++;
        H = tmp;
    }
  }


  cout << count << endl;

  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();
		boolean j = false;

		if(n%2==0 && s.substring(0, n/2).equals(s.substring(n/2, n))) j = true;

		System.out.println(j ? "Yes" : "No");
	}
}

Measured memory_bytes: 35576
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int i,j;
  int ans=10000;
  for(i=0;i<s.size()-t.size()+1;i++){
    int x=0;
    for(j=0;j<t.size();j++){
      if(s[i+j]!=t[j]){
        x++;
      }
    }
    ans=min(ans,x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int x;
    cin>>x;
    int max=1;
    for (int i=2;i<x;i++) {
        for (int j=2;pow(i,j)<=x;j++) {
            if (pow(i,j)>max) {
                max=pow(i,j);
            }
        }
    }
    cout<<max<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    person_count = int(input())
    duration, x = map(int, input().split())
    a = [int(input()) for _ in range(person_count)]

    count = 0

    for i in a:
        y = 0

        while i * y + 1 <= duration:
            count += 1
            y += 1

    print(count + x)


Measured memory_bytes: 3060
/*------------------GZ:-)------------------*/
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set

//#define      ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define        fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define        f first
#define        s second
#define        pb push_back
#define        eb emplace_back
#define        mp  make_pair
#define        forn(i,n) for(int i=0;i<n;++i)
#define        show(b) for(auto const&x: b) cout<<x<<" "
#define        sshow(b) for(auto x:b) cout<<x<<" "
#define        fix(b,val)   memset(b,val,sizeof(b))
#define        pill(b,n,v)  fill(b,b+n,v)
#define        itn          int
#define        w(t)     int t;cin>>t;while(t--)
#define        mx(a,b,c) max(a,max(b,c))
#define        mn(a,b,c) min(a,min(b,c))
#define        intmax    INT_MAX
#define        intmin    INT_MIN
#define        nl        "\n"
#define        prt(val)  cout<<val<<"\n"
#define        all(v)    v.begin(),v.end()
#define        trace1(x)                cerr<<#x<<": "<<x<<endl
#define        trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define        trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define        trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define        trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define        trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef       long long int ll;
typedef       long double LD;
typedef       unsigned long long int LL;
typedef       pair<int,int> pii;
typedef       pair<long long int,int> pli;
typedef       pair<int,long long int> pil;
typedef       pair<long long int,long long int> pll;
const int N=1e5+5;
const int mod=1e9+7;
//mt19937 rnd(time(NULL));

/*-----Functions------*/
template<typename T>
void show2d(const vector<vector<T>>& adj)
{
    for(auto x:adj)
    {
        for(auto y:x)
        { 
           cout<<y<<" ";
        }
    cout<<"\n";
    }
}

ll modexp(ll a,ll b,ll mod)
{
    ll x=1;
    while(b)
    {
        if(b&1)
        x = ((x%mod) * (a%mod))%mod;
        a = ((a%mod) * (a%mod))%mod;
        b = b / 2;
    }
    return x;
}

void rf()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main()
{
    fast;
    //rf();
    int a,b;
    cin>>a>>b;
    int one = (b - 2*a)/2;
    int two = (4*a - b)/2;
    if(one<0 || two<0){
        cout<<"No\n";
    }
    else if((one+two) == a){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}


Measured memory_bytes: 3604
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;
	while(left < right) {
		mid = (left + right) / 2;
		if(A[mid] == key) return 1;
		if(key < A[mid]) right = mid;
		else if(key > A[mid]) left = mid+1; 
	}
	return 0;	
}

int main() {
	int i, q, key, sum = 0;
	
	scanf("%d", &n);
    for(int i = 0; i < n; i++) { 
        scanf("%d", &A[i]);
    }
    
    scanf("%d", &q);
    for(int i = 0; i < q; i++) {
	    scanf("%d", &key);
		if( binarySearch(key)) sum++; 
	}
	printf("%d\n", sum);
	
	return 0;    
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define loop(i,a,b) for(i=a;i<b;i++)
#define INF 10000000000
#define pb push_back
#define lim 100001

using namespace std;
int main()
{ll x,n,i,j,ans=0,diff=INF;
	
	cin>>x>>n;
ll a[n];
	loop(i,0,n)
	cin>>a[i];

	
    
	loop(i,0,102){
		loop(j,0,n)
		if(a[j]==i)
			break;
		if(j==n && diff>abs(x-i))
		{
			ans=i; diff=abs(x-i);
		}}

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


	




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

const int INF = 1000000000;

int
main ()
{
  while (true)
    {
      int n;
      cin >> n;

      if (n == 0)
	break;

      int T[10][10];
      for (int i = 0; i < 10; i++)
	{
	  for (int j = 0; j < 10; j++)
	    {
	      if (i == j)
		{
		  T[i][j] = 0;
		}
	      else
		{
		  T[i][j] = INF;
		}
	    }
	}

      int m = 0;		// ????????°

      for (int i = 0; i < n; i++)
	{
	  int a, b, c;
	  cin >> a >> b >> c;

	  T[a][b] = T[b][a] = c;

	  if (a + 1 > m)
	    {
	      m = a + 1;
	    }
	  if (b + 1 > m)
	    {
	      m = b + 1;
	    }
	}

      for (int k = 0; k < m; k++)
	{
	  for (int i = 0; i < m; i++)
	    {
	      for (int j = 0; j < m; j++)
		{
		  if (T[i][j] > T[i][k] + T[k][j])
		    {
		      T[i][j] = T[i][k] + T[k][j];
		    }

		}
	    }
	}

      int Count[m];
      for (int i = 0; i < m; i++)
	{
	  Count[i] = 0;
	  for (int j = 0; j < m; j++)
	    {
	      Count[i] = Count[i] + T[i][j];
	    }
	}

      int mnum = 0;
      for (int i = 0; i < m; i++)
	{
	  if (Count[0] > Count[i])
	    {
	      Count[0] = Count[i];
	      mnum=i;
	    }
	}
      cout << mnum << ' ' << Count[0] << endl;

    }

  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N), F(N);
	for (int i = 0;i < N;i++)cin >> A[i];
	for (int i = 0;i < N;i++)cin >> F[i];
	sort(all(A));
	reverse(all(A));
	sort(all(F));

	ll ng = -1, ok = LLONG_MAX / 2, mid, v, ans = 0;
	while (ok - ng > 1) {
		mid = (ng + ok) / 2;
		ans = 0;
		for (int i = 0;i < N;i++) {
			v = mid / F[i];
			ans += max(A[i] - v, 0LL);
		}
		if (ans > K) {
			ng = mid;
		}
		else {
			ok = mid;
		}
	}
	cout << ok << endl;
}

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

int main() {
  int x ;
  cin >> x ;
  int ans = 1;
  
  for(int i=2;i*i<=x;i++){
    int now = 1;
    while(now*i<=x){
      now *=i;
    }
    ans = max(ans,now);
  }
  
  cout << ans ;
  
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define pi 3.14159265358979323846
using namespace std;
typedef long long ll;

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

int main()
{

  int n,i; cin >> n >> i;
  cout << n+1-i << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
num = [0]*(10**6+1)
for x in a:
    if num[x] != 0:
        num[x] = 2
        continue
    for i in range(x, 10**6+1, x):
        num[i] += 1

ans = 0
for x in a:
    if num[x] == 1:
        ans += 1

print(ans)

Measured memory_bytes: 32212
#include <stdio.h>
#include <math.h>
int main()
{
  int a, b, c ;
  double d, r, s, l, h ;
  scanf("%d %d %d",&a,&b,&c) ;

  /*ラジアンrを出す*/
  r = ( c * M_PI) / 180 ;

  s = ( a * b * sin(r) ) / 2 ;
  d = a*a + b*b - 2*a*b*cos(r) ;
  l = a + b + sqrt(d) ;
  h = b * sin(r) ;

  printf("%10.8f\n", s) ;
  printf("%10.8f\n", l) ;
  printf("%10.8f\n", h) ;

  return 0 ;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;

int main() {
	int n, wei;
	cin >> n >> wei;
	vector<int> w(n);
	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	long long dp[n + 1][wei + 1];
	for(int i = 0; i < n; i++) {
		for(int j = 0; j <= wei; j++) {
			dp[i][j] = 0;
		}
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j <= wei; j++) {
			if(j >= w[i]) {
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	cout << dp[n][wei] << endl; 
}

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

int main() {
  string str;
  cin >> str;
  bool n=false, w=false, s=false, e=false;
  for (int i = 0; i < str.length(); ++i) {
    switch (str[i]) {
      case 'N':
        n = true;
        break;
      case 'W':
        w = true;
        break;
      case 'S':
        s = true;
        break;
      case 'E':
        e = true;
        break;
    }
  }
  cout << (((n == s) && (w == e)) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
inf = 10**18
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
dp = [[inf]*(N+1) for _ in range(H+1)]
for h in range(H+1):
    for i in range(N+1):
        if i > 0 and h - AB[i - 1][0] > 0:
            dp[h][i] = min(dp[h][i-1], dp[h-AB[i-1][0]][i] + AB[i-1][1])
        elif i > 0:
            dp[h][i] = min(dp[h][i-1], AB[i-1][1])

print(dp[H][N])

Measured memory_bytes: 121820
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " << a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n, m;
		cin >> n >> m;
		vii ab;
		rep(i, 0, n)
		{
			ll x, y;
			cin >> x >> y;
			ab.pb({x, y});
		}

		sort(all(ab));
		ll ans = 0;
		for (auto it : ab)
		{
			ll x = min(m, it.ss);
			ans += x * it.ff;
			m -= x;

			if (m == 0)
				break;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 5336
#include <algorithm>
#include <climits>
#include <iostream>

using namespace std;

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

  int m = 0;
  int d = INT_MIN;
  int x;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    if (i == 0) {
      m = x;
      continue;
    }
    d = max(d, x - m);
    m = min(m, x);
  }

  cout << d << endl;
  return 0;
}

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

public class Main{

	public static void main(String[] args) throws IOException {
		String s = next();
		
		s = "2018"+s.substring(4);
		println(s);
		exit();
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	static String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}

	static long readLong() throws IOException {
		return Long.parseLong(next());
	}

	static float readFloat() throws IOException {
		return Float.parseFloat(next());
	}

	static boolean readBoolean() throws IOException {
		return Boolean.parseBoolean(next());
	}

	static short readShort() throws IOException {
		return Short.parseShort(next());
	}

	static byte readByte() throws IOException {
		return Byte.parseByte(next());
	}

	static int readInt() throws IOException {
		return Integer.parseInt(next());
	}

	static double readDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static char readCharacter() throws IOException {
		return next().charAt(0);
	}

	static String readLine() throws IOException {
		return br.readLine().trim();
	}

	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	static void print(String s) {
		pr.print(s);
	}

	static void print(int s) {
		pr.print(s);
	}

	static void print(long s) {
		pr.print(s);
	}

	static void print(boolean s) {
		pr.print(s);
	}

	static void print(short s) {
		pr.print(s);
	}

	static void print(byte s) {
		pr.print(s);
	}

	static void print(double s) {
		pr.print(s);
	}

	static void print(char s) {
		pr.print(s);
	}

	static void print(float s) {
		pr.print(s);
	}

	static void println(String s) {
		pr.println(s);
	}

	static void println(int s) {
		pr.println(s);
	}

	static void println(long s) {
		pr.println(s);
	}

	static void println(boolean s) {
		pr.println(s);
	}

	static void println(short s) {
		pr.println(s);
	}

	static void println(byte s) {
		pr.println(s);
	}

	static void println(double s) {
		pr.println(s);
	}

	static void println(char s) {
		pr.println(s);
	}

	static void println(float s) {
		pr.println(s);
	}

	static void flush() {
		pr.flush();
	}

	static void exit() throws IOException {
		br.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 22484
import java.util.Scanner;

/**
 * ABC079C_Train_Ticket
 */
public class Main {
    private static Scanner sc;

    public static void main(String[] args) {
        sc = new Scanner(System.in);

        String ABCD = sc.next();
        String[] strArray = ABCD.split("");
        int length = ABCD.length() - 1; // 文字列の間に"+"を入れるかどうか、文字列の間の数

        String answer = "";
        int ansNum = 0;
        for (int i = 0; i < (1 << length); i++) {
            // パターン1つ1つの繰り返し区切り場所をリセット
            answer = strArray[0];
            ansNum = Integer.valueOf(strArray[0]);
            for (int j = 0; j < length; j++) {
                // 場所ごとの組み合わせで対応が異なる処理を入れる
                if ((i >> j) % 2 == 0) {
                    // "-"を入れる場合
                    answer += "-" + strArray[j + 1];
                    ansNum -= Integer.valueOf(strArray[j + 1]);
                } else {
                    // "+"を入れる場合
                    answer += "+" + strArray[j + 1];
                    ansNum += Integer.valueOf(strArray[j + 1]);
                }
            }
            if (ansNum == 7) {
                answer += "=7";
                break;
            }
        }

        System.out.println(answer);

        sc.close();
    }
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define rad M_PI/3
#define N 500001
#define Max 10000
#define NTL -1
typedef struct{
  int key, left, right;
}Node;
 
Node tree[N+1];
int size;
 
void insert(int x){
  int p = 0;
  while(1){
    if(x < tree[p].key){
      if(tree[p].left == -1){
        tree[p].left = size;
        tree[size++].key = x;
        break;
      }else p = tree[p].left;
    }else{
      if(tree[p].right == -1){
        tree[p].right = size;
        tree[size++].key = x;
        break;
      }else p = tree[p].right;
    }
  }
}
 
void inorder(int p){
  if(tree[p].left != -1) inorder(tree[p].left);
  printf(" %d", tree[p].key);
  if(tree[p].right != -1) inorder(tree[p].right);
}
 
void preorder(int p){
  printf(" %d", tree[p].key);
  if(tree[p].left != -1) preorder(tree[p].left);
  if(tree[p].right != -1) preorder(tree[p].right);
}
int main()
{
   int n, i, first;
  first = 1;
  scanf("%d", &n);
  for(i=0;i<=n;i++) tree[i].key = tree[i].left = tree[i].right = -1;
  size = 0;
  while(n--){
    char str[100];
    scanf("%s", str);
    if(!strcmp(str, "insert")){
      int in;
      scanf("%d", &in);
      if(first){
        tree[size++].key = in;
        first = 0;
      }
      else insert(in);
    }else{
      inorder(0);
      printf("\n");
      preorder(0);
      printf("\n");
    }
  }
  return 0;
}


Measured memory_bytes: 7644
// ABC-142 A:
// 2019.9.28 bal4u
// Template for Online Contest

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int N;
	
	scanf("%d", &N);
	if (N & 1) printf("%lf\n", (double)(N-(N/2))/N);
	else puts("0.5");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define Would
#define you
#define please

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

	if (N % 2 == 1) {
		N *= 2;
	}
	cout << N << "\n";

	Would you please return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> PP;

struct edge {
	int from,to,cost;
	edge(int f,int t,int c):from(f),to(t),cost(c) {}
};

int n;
map<ll,int> xs,ys;
vector<P> vx,vy;
vector<edge> es;
vector<int> data;

int root(int);

void UnionFind() {
	data.resize(n);
	REP(i,n) data[i]=-1;
}

bool unite(int x,int y) {
	x=root(x),y=root(y);
	if(x!=y) {
		if(data[y]<data[x]) swap(x,y);
		data[x]+=data[y],data[y]=x;
	}
	return x!=y;
}

bool same(int x,int y) {
	return root(x)==root(y);
}

int root(int x) {
	return data[x]<0?x:data[x]=root(data[x]);
}

int size(int x) {
	return -data[root(x)];
}

bool comp(const edge& e1,const edge& e2) {
	return e1.cost<e2.cost;
}

void kruskal() {
	sort(ALL(es),comp);
	UnionFind();
	ll ans=0;
	REP(i,es.size()) {
		edge e=es[i];
		if(!same(e.from,e.to)) {
			unite(e.from,e.to);
			ans+=e.cost;
		}
	}
	cout<<ans<<endl;
}

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

	cin>>n;
	REP(i,n) {
		ll x,y; cin>>x>>y;
		vx.pb(P(x,i));
		vy.pb(P(y,i));
	}
	sort(ALL(vx));
	sort(ALL(vy));
	REP(i,n-1) {
		es.pb(edge(vx[i].se,vx[i+1].se,abs(vx[i].fi-vx[i+1].fi)));
		es.pb(edge(vy[i].se,vy[i+1].se,abs(vy[i].fi-vy[i+1].fi)));
	}

	kruskal();

	return 0;
}


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

int main() {
int A,B,C;
  int count = 0;
  cin >> A >> B >> C;
  if(A == B && B != C){count ++;}
  if(B == C && C != A){count++;}
  if(C == A && A != B){count++;}
  
  if(count == 0){
  	cout << "No" << endl;
  }
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define x first
#define y second
using namespace std;
using ll  = long long;
#define int ll

const int N = 3030;
const int M = 998244353;

int a;
int b;
int c;
int d;
int dow[N][N]; // white right side
int rig[N][N]; // no info

signed main() {
#ifdef LC
    assert(freopen("input.txt", "r", stdin));
#endif
    ios::sync_with_stdio(0), cin.tie(0);

	cin >> a >> b >> c >> d;
	rig[a][b] = 1;
	for (int i = a; i <= c; ++i) {
		for (int j = b; j <= d; ++j) {
			(rig[i][j + 1] += rig[i][j] * i) %= M;
			(dow[i + 1][j] += rig[i][j] * j) %= M;
			(rig[i][j + 1] += dow[i][j]) %= M;
			(dow[i + 1][j] += dow[i][j] * j) %= M;
		}
	}
	int ans = rig[c][d] + dow[c][d];
	ans %= M;
	cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 145648
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var nk=Arr.shift().split(" ").map(Number);
   var n=nk[0];
   var k=nk[1];
   if(n==0 && k==0)break;
   var N=[];
   for(var i=0;i<=n+1;i++)N[i]=0;
   for(var i=0;i<k;i++)N[Arr.shift()-0]=1;
   var flag=(N[0]===1)?true:false;
   var str="";
   for(var i=1;i<=n;i++)str+=N[i];
   var arr=str.split("0");
   var maxA=0;
   var maxB=0;
   for(var i=0;i<arr.length-1;i++){
      maxA=Math.max(maxA,arr[i].length+arr[i+1].length);
      maxB=Math.max(maxB,arr[i].length);
   }
   console.log((flag)?maxA+1:maxB);
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int x[9] = {};
  int y[9] = {};
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  double d[9][9] = {};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j) {
        int xd = x[i] - x[j];
        int yd = y[i] - y[j];
        d[i][j] = sqrt(xd * xd + yd * yd);
      }
    }
  }

  // for (int i = 0; i < n; i++) {
  //   for (int j = 0; j < n; j++) {
  //     cout << d[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  int n_kai = 1;
  for (int i = 2; i <= n; i++) {
    n_kai *= i;
  }
  // cout << n_kai << endl;

  vi v;
  for (int i = 0; i < n; i++) {
    v.push_back(i);
  }

  double sum = 0.0;
  do {
    int prev = v[0];
    for (int i = 1; i < n; i++) {
      int next = v[i];
      sum += d[next][prev];
      prev = next;
    }
  } while (next_permutation(v.begin(), v.end()));

  cout << fixed << setprecision(10) << sum / (double)n_kai << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int inputInteger;
	double oddsNumber;
	scanf("%d", &inputInteger);

	if (inputInteger % 2 != 0)
	{
		oddsNumber = inputInteger / 2 + 1;
	}
	else
	{
		oddsNumber = inputInteger / 2;
	}

	printf("%f \n", oddsNumber / inputInteger);

	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int h, w, n; cin>>h>>w>>n;
  int sr, sc; cin>>sr>>sc;
  int a=1, b=h, c=1, d=w;
  string s, t;
  cin>>s>>t;
  for(int i=n-1; i>=0; i--){
    if(t[i]=='L') d=min(d+1, w);
    else if(t[i]=='R') c=max(c-1, 1);
    else if(t[i]=='U') b=min(b+1, h);
    else a=max(a-1, 1);
    if(s[i]=='L') c=min(c+1, w+1);
    else if(s[i]=='R') d=max(d-1, 0);
    else if(s[i]=='U') a=min(a+1, h+1);
    else b=max(b-1, 0);
    if(a>b || c>d){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  if(a<=sr && sr<=b && c<=sc && sc<=d) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 776
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int A,B,C,X;
    
    cin>>A>>B>>C>>X;
    
    int count=0;
    
    
    for(int i=0;i<=A;++i){
        for(int j=0;j<=B;++j){
            for(int k=0;k<=C;++k){
                
                if(500*i+100*j+50*k==X){
                    ++count;
                }
                
            }
        }
    }
    
    cout<<count<<endl;
    

    return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>

using namespace std;

int main()
{
    double n;
    int k;
    double p = 0.0;
    cin >> n >> k;

    for(int i = 1; i <= n; i++)
    {
        int ci = i;
        double ip = 1;
        for(int j = 0; k > ci; j++)
        {
            ci *= 2;
            ip *= 0.5;
        }
        p += 1 / n * ip;
    }
    cout << fixed << setprecision(12) << p << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

good = [1] * n

for a, b in ab:
    a -= 1
    b -= 1

    if h[a] >= h[b]:
        good[b] = 0

    if h[a] <= h[b]:
        good[a] = 0

ans = good.count(1)
print(ans)


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

char table[6][5] = {
  {'a','b','c','d','e'},
  {'f','g','h','i','j'},
  {'k','l','m','n','o'},
  {'p','q','r','s','t'},
  {'u','v','w','x','y'},
  {'z','.','?','!',' '}
};

int main(){
  string s;
  while( cin >> s ){
    string ans;
    if( s.size() % 2 ){
      cout << "NA" << endl;
    }else{
      bool flag = false;
      for(int i=1 ; i < s.size() ; i+=2 ){
	int y = s[i-1]-'0'-1;
	int x = s[i]-'0'-1;
	if( y < 0 || x < 0 || y >= 6 || x >= 5 ){
	  flag = true;
	  break;
	}
	ans += table[y][x];
      }
      if( flag )
	cout << "NA" << endl;
      else
	cout << ans << endl;
    }
  }
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLine();

            var result = "No";

            if(n[0] == '9' || n[1] == '9') {
                result = "Yes";
            }

            Console.WriteLine(result);
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

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

using namespace std;

const int MAX = 401;
struct Edge{int f,t,c;};
vector<Edge> V;
int n,m,T[MAX];

void input(){
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    Edge e;
    cin >> e.f >> e.t >> e.c;
    V.push_back(e);
  }
}

void solve(){

  while(1){
    bool update = false;

    for(int i = 0; i < V.size(); i++){
      if(T[V[i].t] < T[V[i].f]+V[i].c){
	 T[V[i].t] = T[V[i].f]+V[i].c;
	update = true;
      }
    }
    if(!update) break;
  }
  cout << T[n-1] << endl;
}

int main(){
  input();
  solve();
  return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

	sort(all(a));

	cout << a.back() - a.front() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;
const ll MAX = 100005;

signed main(){
	int N, C;
	cin >> N >> C;
	vector<vector<ll>> ch(C, vector<ll>(2*MAX, 0));
	vector<ll> chall(2*MAX, 0);
	for(int i=0;i<N;i++) {
		int s, t, c;
		cin >> s >> t >> c;
		c--;
		ch[c][2*s]++;
		ch[c][2*t]--;
	}

	for(int i=1;i<2*MAX;i++) {
		for(int j=0;j<C;j++) {
			ch[j][i] += ch[j][i-1];
		}
	}
	for(int i=2;i<2*MAX;i+=2) {
		for(int j=0;j<C;j++) {
			if(ch[j][i-1] < ch[j][i]) {
				ch[j][i-1]++;
			}
		}
	}
	for(int i=0;i<2*MAX;i++) {
		for(int j=0;j<C;j++) {
			chall[i] += ch[j][i];
		}
	}
	ll ans = 0;
	for(int i=0;i<2*MAX;i++)
		if(ans < chall[i])
			ans = chall[i];

	cout << ans << endl;
}

Measured memory_bytes: 48768
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	ans := 0
	for i := 1; i*i <= n; i++ {
		if (n-1)%i == 0 {
			if i*i == n-1 {
				ans += 1
			} else {
				ans += 2
			}
		} else if n%i == 0 && i != 1 {
			x := n
			for x%i == 0 {
				x /= i
			}
			if x%i == 1 {
				ans++
			}
			x = n
			j := n / i
			if i != j {
				for x%j == 0 {
					x /= j
				}
				if x%j == 1 {
					ans++
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int,int> mp;
    mp[0] = 0;
    int now = 1;
    for (int i = 1; i <= k; i++) { //k回移動
        now = a[now-1]; //i回目の移動
        if (mp[now-1] == 0 && now != 0) {
            mp[now-1] = i; //i回目にはじめてきた
        }
        //きたことがある
        else {
            int d = i-mp[now-1]; //１ループの回数
            int rem = k - i; //残り移動
            int t = rem / d; //ループ回数
            int rest = rem % d; //ループ後移動回数
            i += t * d;
        }

    }
    cout << now << endl;
    
    return 0;
}

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

int main()
{
    string s,t;
    cin>>s>>t;
    int i,l=s.size(),c=0;
    for(i=0;i<l;i++)
    {
        if(s[i]==t[i])
            c++;
    }
    if(c==l)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
	return 0;
}




Measured memory_bytes: 3528
#include<stdio.h>

int main(void){


  int i,n;


  long int a,min = 1000000,max = -1000000,sum = 0;


  scanf("%d",&n);


  for(i = 1;i <= n;i++)


  {


    scanf("%ld",&a);


    if(a < min)


      min = a;


    if(a > max)


      max = a;


    sum += a;


  }


  printf("%ld %ld %ld\n",min,max,sum);


  return 0;


}


  

Measured memory_bytes: 600
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())

s, w = inpl()
if w >= s:
    print("unsafe")
else:
    print("safe")

Measured memory_bytes: 75156
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 405;

ll dp[MAX_N][MAX_N];
ll a[MAX_N], sm[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        cin >> a[i];
        sm[i+1] = sm[i] + a[i];
    }
    rep(i,n){
        srep(j,i,n+1){
            dp[i][j] = (1LL << 60);
        }
    }
    rep(i,n){
        dp[i][i+1] = 0;
    }
    srep(i,2,n+1){
        rep(j,n-i+1){
            srep(k,j+1,i+j){
                cmn(dp[j][i+j], dp[j][k]+dp[k][i+j]+sm[i+j]-sm[j]);
            }
        }
    }
    cout << dp[0][n] << "\n";
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main(){
    int N , sum =0;
    cin >> N;
    
    int B[N-1];
    cin >> B[0];
    sum += B[0];
    for(int i = 1; i < N-1; i++){
        cin >> B[i];
        sum += (B[i] - B[i-1] > 0) ? B[i-1] : B[i];
    }
   
    sum += B[N-2];
    
    cout << sum << endl;
    
    return 0;
}



Measured memory_bytes: 256