akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

  long long int n;

  while( true ) {

    cin >> n;
    if ( n == 0 ) break;

    vector< pair< long long int, long long int > > v;

    for ( long long int i = 0; i < n; i++ ) {

      long long int h, m, s;
      char c;

      cin >> h >> c >> m >> c >> s;
      v.push_back( make_pair( h * 60 * 60 + m * 60 + s, 1 ) );

      cin >> h >> c >> m >> c >> s;
      v.push_back( make_pair( h * 60 * 60 + m * 60 + s, 0 ) );

    }

    sort( v.begin(), v.end() );

    long long int ans = 0;
    long long int cnt = 0;

    for ( long long int i = 0; i < v.size(); i++ ) {

      if ( v[i].second == 0 ) {
	cnt--;
      }else {
	cnt++;
	ans = max( ans, cnt );
      }

    }

    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 1840
//==========================================================================
    #define mod 1e9+7
    #include<decimal/decimal>
    #include <iostream>           //  CCCCC RRRRR  EEEEE  AAA   TTTTT EEEEE DDDD
    #include<algorithm>           //  C     R  R   E     A   A    T   E     D  D
    #include<bits/stdc++.h>       //  C     RRRR   EEEE  AAAAA    T   EEEE  D  D
    #include<cstring>             //  C     R  R   E     A   A    T   E     D  D
    #include<vector>              //  CCCCC R   R  EEEEE A   A    T   EEEEE DDDD
    //==========================================================================
    #include<stack>               //  BBBB   Y   Y
    #include<queue>               //  B   B   Y Y
    #include<deque>               //  BBBB     Y
    #include<cmath>               //  B   B    Y
    #include<numeric>             //  BBBB     Y
    //==========================================================================
    #include<utility>             //   AAA  M   M M   M IIIII TTTTT
    #include<unordered_map>       //  A   A MMMMM MMMMM   I     T
    #include<unordered_set>       //  AAAAA M M M M M M   I     T
    #include<set>                 //  A   A M   M M   M   I     T
    #include<map>                 //  A   A M   M M   M IIIII   T
    #include<list>
    #include<set>
    #include<string>
    //==========================================================================
    //==========================================================================
     
using namespace std;

int main() 
 {
      ios_base::sync_with_stdio(false); 
      cin.tie(NULL); 
      string a,b;
      cin>>a>>b;
      string c;
      c=b+a;
      cout<<c<<endl;
}

Measured memory_bytes: 256
s = input()
t = input()
d = {}
d2 = {}
for i in range(len(s)):
  if t[i] in d:
    if d[t[i]] != s[i]:
      print("No")
      break
  if s[i] in d2:
    if d2[s[i]] != t[i]:
      print("No")
      break
  else:
    d[t[i]] = s[i]
    d2[s[i]] = t[i]
else:
  print("Yes")


Measured memory_bytes: 3632
require "prime"
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

X=gets.to_i
ans=0
X.upto(10**9+7) do|i|
  if Prime.prime?(i)
    ans=i
    break
  end
end
puts ans

Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,m,acnum=0,wanum=0;
    cin>>n>>m;
    bool ac[100010];
    int wa[100010];
    repi(i,1,n+1){
        ac[i]=false;
        wa[i]=0;
    }
    for(int i=0;i<m;i++){
        int p;
        string s;
        cin>>p>>s;
        if(ac[p]) continue;
        if(s=="AC"){
            ac[p]=true;
            acnum++;
            wanum+=wa[p];
        }
        else if(s=="WA") wa[p]++;
    }
    cout<<acnum<<" "<<wanum;
}

Measured memory_bytes: 4060
#include <iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;++i)
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	string s;
	cin >> s;
	bool ans = false;
	if(n%2==0){
		if(s.substr(0,n/2)==s.substr(n/2))ans=true;
	}
	if(ans)cout<<"Yes"<<endl;
	else cout << "No"<<endl;
	return 0;
}


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

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine().ToArray();

            var k = long.Parse(Console.ReadLine());

            var flag = true;

            for (long i = 0; i < k; i++)
            {
                if (s[i] == '1')
                {

                }
                else
                {
                    flag = false;
                    Console.WriteLine(int.Parse(s[i].ToString()));
                    break;
                }
            }

            if (flag)
            {
                Console.WriteLine(1);
            }
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define int long long
using namespace std;
const int mod = 1e9+7;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int a[100010],sum[4];
signed main(){
	n=read();
	int anss=1;
	for(register int i=1;i<=n;i++)a[i]=read();
	for(register int i=1;i<=n;i++){
		int ans=0,num=0;
		if(a[i]==sum[0]){ans++;num=0;}
		if(a[i]==sum[1]){ans++;num=1;}
		if(a[i]==sum[2]){ans++;num=2;}
		(anss*=ans)%=mod;
		sum[num]++;
	}
	printf("%lld\n",anss);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

int main(){
  int n,m,k;cin>>n>>m>>k ;
  bool ok=0 ;
  if(n>m) swap(n,m) ;
  rep2(i,0,n){
    int x =k- n*m + m*i;
    if(2*i-n==0){
      if(n*m-m*i==k) ok=1 ;
    }
    else if(x%(2*i-n)==0 && (x/(2*i-n))>=0 && (x/(2*i-n)) <= m)
    ok= 1 ;
    }
  if(ok) cout<<"Yes"<<endl ;
  else cout<<"No"<<endl ;
      return 0;
  }
  

Measured memory_bytes: 3644
N, M=(int(i) for i in input().split())
P=[[int(j)-1  if i==0 else j for i, j in enumerate(input().split())] for  _ in range(M)]
ac="AC"
wa="WA"
flag=[0]*N
ans=0
pe=0

for i in range(M):
    if flag[P[i][0]]!=-1 and P[i][1]==ac:
        ans+=1
        pe+=flag[P[i][0]]
        flag[P[i][0]]=-1
    elif flag[P[i][0]]!=-1 and P[i][1]==wa:
        flag[P[i][0]]+=1
        
print(ans,pe)


Measured memory_bytes: 70436
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = a; i < b; ++i)
#define ll long long
#define M 100000007
#define fr first
#define sc second
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll, ll>
#define psi pair<string, ll>
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define PI 3.14159265
#define r0 return 0
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
const char char_max = (char)(((unsigned char) char(-1)) / 2);


int main() {
  fast
  ll n;
  cin>>n;
  ll a[n],dp[n];
  rep(i,0,n) cin>>a[i];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  rep(i,2,n) {
      dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));

  }
  cout<<dp[n-1];
  //dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]))
}



Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val (N, D, A) = readLongList()
    val list = Array(N.toInt()) { readLongList().toPair() }.sortedBy { it.first }
    var ans = 0L
    var d = 0L
    var dmg = mutableListOf<Pair<Long, Long>>()

    for ((x, h) in list) {
        while (!dmg.isEmpty()) {
            val e = dmg.first()
            if (e.first >= x) break
            d -= e.second
            dmg.removeAt(0)
        }

        if (h > d) {
            val n = (h - d + A - 1) / A
            dmg.add(x + 2 * D to A * n)
            d += A*n
            ans += n
        }
    }

    println(ans)
}

fun readString() = readLine()!!
fun readStringList() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun <E> List<E>.toPair() = this[0] to this[1]


Measured memory_bytes: 133392
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <list>
#include <utility>
using namespace std;

int main(){
    string s;
    cin>> s;

    int i = s.length(), j=0;
    for(char x:s){
            if(x=='7'){cout<<"Yes"<<endl;break;}
            else{j+= 1;};}
    if(j==i){cout<<"No"<<endl;}
    return 0;}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <utility>
#include <cstdlib>

using namespace std;


int main() {
    int n,l;
    cin>>n>>l;
    
    int mi=299,sum=0;
    for(int i=1;i<n+1;i++){
        sum+=l+i-1;
        if(abs(mi)>=abs(l+i-1)){
        mi=l+i-1;
        }
    }
    cout<<sum-mi<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long N, std::vector<long long> A) {
  ll ans = 0;
  int upordown = 0; // 0: not decided, 1: up, 2; down
  int pre = A[0];
  rep(n, N) {
    if (pre == A[n]) {
      continue;
    }

    // pre != A[n]
    if (upordown == 0) {
      if (pre > A[n]) {
        upordown = 2;
      } else {
        upordown = 1;
      }
    } else if (upordown == 1) {
      if (pre > A[n]) {
        ans++;
        upordown = 0;
      }
    } else {
      if (pre < A[n]) {
        ans++;
        upordown = 0;
      }
    }

    pre = A[n];
  }
  ans++;

  print(ans);
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 1024
# https://atcoder.jp/contests/abc155/submissions/10175015

def main():
    n = list(map(int, input()[::-1])) + [0]
    s = 0
    res = 0
    for i, ni in enumerate(n[:-1]):
        k = ni + s
        if k < 5 or (k == 5 and int(n[i + 1]) < 5):
            res += k
            s = 0
        else:
            res += 10 - k
            s = 1
    res += s
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 18768
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
 
  int main(){
     int n,n2,sum=0;
     cin >> n >> n2;
     int a[n];
     for(int i = 0; i<n; i++){
		 cin >> a[i];
		 }
     sort(a,a+n);
     for(int i = 0; i<n2; i++){
		 sum += a[i];}
		 
		 cout << sum;
}

   
	
	
         







Measured memory_bytes: 3636
N,K = map(int,input().split())

mod = 10**9+7

low = [0]*(N+1)
high = [0]*(N+1)
ls = [0]*(N+1)
high[0] = N
ls[0] = high[0] - low[0] + 1

for i in range(1,N+1):
    low[i] = i + low[i-1]
    high[i] = N-i + high[i-1]
    ls[i] = high[i] - low[i] + 1

ans = 0

for i in range(K-1,N+1):
    ans = (ans + ls[i])%mod

print(ans)


Measured memory_bytes: 41076
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,r=1;cin >> n;
  while (r) {
    long long n2=sqrt(n),n3=1;
    for (int i=2;i<=n2;i++) {n3*=n%i;if (n3>0) n3=1;}
	if (n3>0) r=0;
	n++;
  }
  cout << n-1 << endl;
}

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

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

    int ans = 0;
    rep(i, n + 1) ans += i;

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


Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
struct city{
	string name;
	int pos,val;
};
bool sortbysec(const struct city &a,const struct city &b){
	if(a.name==b.name){
		return a.val<b.val;
	}
	return a.name>b.name;
}
int main(){
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		vector< struct city >v(n);
		for(int i=0;i<n;i++){
			struct city c;
			//string s,int w;
			cin>>c.name>>c.val;
			c.pos=i+1;
			v.push_back(c);
		}
		sort(v.begin(),v.end(),sortbysec);
		for(int i=n-1;i>=0;i--){
			cout<<v[i].pos<<endl;
		}
		// int res;
		// cout<<res<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    int sum = 0;
    int MIN = INF;
    int idx = -1;
    rep(i, 0, n){
        a[i] = l + i;
        sum += a[i];
        if(MIN > abs(a[i])){
            MIN = abs(a[i]);
            idx = i;
        }
    }
    cout << sum - a[idx] << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	vector<int>a;
	vector<int>b;
	int n;
	int x, y;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &x);
		a.push_back(x);
		b.push_back(x);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++){
		x = a[(n / 2) - 1];
		y = a[(n / 2)];
	}
	for (int i = 0; i < n; i++){
		if (b[i] <= x)	printf("%d\n", y);
		else	printf("%d\n", x);
	}



	return 0;
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];

    sort(A.begin(), A.end());

    bool flag = false; 
    for(int i = 1; i < N; ++i) {
        if(A[i - 1] == A[i]) {
            cout << "NO" << endl;
            flag = true;
            break;
        }
    }

    if(flag == false) {
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 1024
n = int(input())
h = list(map(int,input().split()))

ans_list = []
ans = 0
for i in range(1,n):
    if h[i-1] >= h[i]:
        ans += 1
    else:
        ans_list.append(ans)
        ans = 0
ans_list.append(ans)
print(max(ans_list))

Measured memory_bytes: 63984
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100010
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,ans,mx,mn,l[N],r[N],L,R,suf[N][2],pre[N][2];
struct Seg{
	int l,r;
}a[N];
bool cmp1(Seg a,Seg b){
	return a.l==b.l?a.r<b.r:a.l<b.l;
}
void Solve(){
	pre[1][0]=a[1].l,pre[1][1]=a[1].r;
	for(int i=2;i<=n;++i){
		pre[i][0]=max(pre[i-1][0],a[i].l);
		pre[i][1]=min(pre[i-1][1],a[i].r);
	}
	suf[n][0]=a[n].l,suf[n][1]=a[n].r;
	for(int i=n-1;i>=1;--i){
		suf[i][0]=max(suf[i+1][0],a[i].l);
		suf[i][1]=min(suf[i+1][1],a[i].r);
	}
	for(int i=1;i<n;++i){
		ans=max(ans,max(0,pre[i][1]-pre[i][0]+1)+max(0,suf[i+1][1]-suf[i+1][0]+1));
	}
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		l[i]=read(),r[i]=read();
	}
	R=*min_element(r+1,r+n+1);
	L=*max_element(l+1,l+n+1);
	for(int i=1;i<=n;++i){
		ans=max(ans,max(0,R-L+1)+r[i]-l[i]+1);
		a[i].l=l[i],a[i].r=r[i];
	}
	sort(a+1,a+n+1,cmp1);
	Solve();
	printf("%d\n",ans);
	return 0;
}



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

int main() {
    int N; cin >> N;
    int p[N];
    for (int i = 0; i < N; i++) cin >> p[i];

    int ans = 0;
    for (int i = 1; i < N; i++) {
        if (p[i-1] == i) {
            swap(p[i-1], p[i]);
            ans++;
        }
    }
    if (p[N-1] == N) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PI;
using namespace std;
#define MAX  999999
int main(){
    while(true){
    int n,a,b,c,x; cin >> n >>a >> b >> c>> x;
        if(n+a+b+c+x == 0) break;
        vi v(10000,0); rep(i,n) cin >> v[i];
        vi ans(10000,0); int cnt = 0; int kotae =-1;
        rep(i,10001){
            if(i == 0){ans[i+1] = (a*x+b)%c; ans[i] = x;}
            else ans[i] = (a*ans[i-1]+b)%c;
            if(v[cnt] == ans[i]){cnt++;}
            if(cnt == n) {kotae= i;break;}
        }
        cout << kotae << endl;
    }
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    string s;
	cin >> s;
	int t = 0, c = 0;
	rep(i, 0, s.size()){
		if(s[i] == 'T'){
			if(t <= 0) c++;
			else t--;
		}
		if(s[i] == 'S') t++;
	}
	cout << 2 * c << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
int main(void){
  ll n;
  string s;
  cin>>n>>s;
  int ans=0;
  for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1])ans++;
  }
  cout<<ans+1;
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
void dij(void);
int n,G[MAX][MAX];
int main(){
  int i, j,a,b,c,d;

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

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

  dij();
  return 0;
}

void dij(){
  int i,j,k,b,c,min,X[MAX],color[MAX];

  
  for ( i=0; i < n; i++ ) {
    X[i] = 1000000;
    color[i] = 0;
  }

  X[0] = 0;

  while(1){
    min=1000000;
    b=-1;
    for ( i = 0; i < n; i++ ){
      if (min>X[i]&&BLACK!=color[i] ){
	b=i;
	min=X[i];
      }
    }
    if (min==1000000) break;
    color[b]=BLACK;
    for (c=0; c<n;c++ ){
      if ( BLACK!=color[c] && G[b][c] != 1000000 ){
	if ( X[c] > X[b] + G[b][c] ){
	  X[c] = X[b] + G[b][c];
	  color[c]=GRAY;
	}
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (X[i]==1000000?-1:X[i]));
  }
}



Measured memory_bytes: 2052
#include<stdio.h>
#include<string.h>
void inputcards(char type, int number);

int main(void){
    int n, i, number = 0, x=0, array[53], d;
    char type = 'a';
    for(i = 1; i <= 52; i ++){
        array[i] = 0;
    }
    scanf("%d", &n);
    for(i = 1 ;i <= n ;i++){
        scanf("%s %d", &type, &number);
        if(type == 'S'){
            x = 0;
        } else if(type == 'H'){
            x = 1;
        } else if(type == 'C'){
            x = 2;
        } else if(type == 'D'){
            x = 3;
        }
        array[x * 13 + number] = 1;
        }
    
    for(i = 1; i <= 52; i++){
        if(array[i] == 0){
            if(0 < i && i < 14){
                type = 'S';
            } else if(13 < i && i < 27){
                type = 'H';
            } else if(26 < i && i < 40){
                type = 'C';
            } else if(39 < i && i < 53){
                type = 'D';
            }
        d = i % 13;
        if(d == 0) d = 13;

        switch(type){
            case 'S':
                printf("S %d\n", d);
                break;
            case 'H':
                printf("H %d\n", d);
                break;
            case 'C':
                printf("C %d\n", d);
                break;
            case 'D':
                printf("D %d\n", d);
                break;
        }
    }
    }
    return 0;
}

Measured memory_bytes: 596
def LI():return list(map(int,input().split()))
def II():return int(input())
#def yes():return print("Yes")
#def no():return print("No")
#INF=float("inf")
from collections import deque, defaultdict, Counter
# from heapq import heappop, heappush
# from itertools import product, combinations
# from functools import reduce, lru_cache
# from math import pi, gcd
# from decimal import Decimal

# class Combination:
#     """
#     O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
#     n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
#     使用例：
#     comb = Combination(1000000)
#     print(comb(5, 3))  # 10
#     """
#     def __init__(self, n_max, mod=10**9+7):
#         self.mod = mod
#         self.modinv = self.make_modinv_list(n_max)
#         self.fac, self.facinv = self.make_factorial_list(n_max)

#     def __call__(self, n, r):
#         return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

#     def make_factorial_list(self, n):
#         # 階乗のリストと階乗のmod逆元のリストを返す O(n)
#         # self.make_modinv_list()が先に実行されている必要がある
#         fac = [1]
#         facinv = [1]
#         for i in range(1, n+1):
#             fac.append(fac[i-1] * i % self.mod)
#             facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
#         return fac, facinv

#     def make_modinv_list(self, n):
#         # 0からnまでのmod逆元のリストを返す O(n)
#         modinv = [0] * (n+1)
#         modinv[1] = 1
#         for i in range(2, n+1):
#             modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
#         return modinv

# class Unionfind:
#     def __init__(self, N):
#         self.p = list(range(N))
#         self.rank = [0] * N
#         self.size = [1] * N

#     def root(self, x):
#         if self.p[x] != x:
#             self.p[x] = self.root(self.p[x])

#         return self.p[x]

#     def same(self, x, y):
#         return self.root(x) == self.root(y)

#     def unite(self, x, y):
#         u = self.root(x)
#         v = self.root(y)

#         if u == v: return

#         if self.rank[u] < self.rank[v]:
#             self.p[u] = v
#             self.size[v] += self.size[u]
#             self.size[u] = 0
#         else:
#             self.p[v] = u
#             self.size[u] += self.size[v]
#             self.size[v] = 0

#             if self.rank[u] == self.rank[v]:
#                 self.rank[u] += 1

#     def count(self, x):
#         return self.size[self.root(x)]

n=II()
a=LI()
b=LI()
c=b[::-1]
bb=deque(b)
ac=Counter(a)
bc=Counter(b)

for i in range(n):
    if ac[i]+bc[i]>n:
        print("No")
        exit()
        
# bd=bc.most_common()

# ans=[-1]*n

import time
# import random
t1=time.time()
for i in range(10000000):
    if time.time()-t1>1.5:
        print("No")
        exit()        
    tmp=bb.popleft()
    bb.append(tmp)
    if any(d==e for d,e in zip(a,bb)):
        continue
    print("Yes")
    print(*bb)
    exit()


Measured memory_bytes: 169060
<?php
  fscanf(STDIN, "%i", $x);
  if ($x > pow(10, 15) + pow(10, 12) * 125) throw null;
  $d = (int)ceil($x / 11);
  $m = $x % 11;
  echo ($d * 2 - (($m >= 1 && $m <= 6) ? 1 : 0)).PHP_EOL;
?>


Measured memory_bytes: 3064
object Main extends App {
  val fibs: Array[Option[Int]] = Array.fill(45)(None)
  val n: Int = io.StdIn.readInt()
  fibs(0) = Some(1); fibs(1) = Some(1)
  println(fib(n))

  def fib(n: Int): Int = fibs(n) match {
    case None =>
      val fibN: Int = fib(n-1) + fib(n-2)
      fibs(n) = Some(fibN)
      fibN
    case Some(x) => x
  }
}


Measured memory_bytes: 43840
#include<iostream>
#include<vector>
using namespace std;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
 
 
#define int long long
const int INF = 1001001001;
 
 
int rec(int i, vector<int> &dp, vector<int> &h){
    if(i == 0) return 0;
    if(dp[i] < INF) return dp[i];
 
    int ans = INF;
    amin(ans, rec(i-1, dp, h) + abs(h[i] - h[i-1]));
    amin(ans, rec(i-2, dp, h) + abs(h[i] - h[i-2]));
 
    return dp[i] = ans;
}
 
signed main(){
 
    int n;cin >> n;
    vector<int> h(n);
    for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> h[i];
 
    vector<int> dp(n+1, INF);
 
    dp[0] = 0;
    dp[1] = (int)abs(h[0] - h[1]);
cout << rec(n-1, dp, h) << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int n;
    cin >> n;
    int h = n % 10;
    if(h == 2 || h == 4 ||h == 5 ||h == 7 ||h == 9)
    cout << "hon" << endl;
    else if(h == 0 || h == 1 ||h == 6 ||h == 8)
    cout << "pon" << endl;
    else
    cout << "bon" << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


using namespace std;

struct pro {
  int s;
  int t;
  int c;

  bool operator<(pro& r) {
    if (c < r.c) {
      return true;
    } else if (c > r.c) {
      return false;
    }
    if (s < r.s) {
      return true;
    };
    return false;
  }
};

int main(){
  int n,c;
  cin >> n>>c;
  vector<pro> f(n);
  for (auto& e : f) {
    cin >> e.s >> e.t >> e.c;
  }
  sort(f.begin(),f.end());
  // for(int i=0;i<n-1;i++){
  //   if(f[i].c==f[i+1].c && f[i].t==f[i+1].s){
  //     f[i].t=f[i+1].t;
  //     n=n-1;
  //     f.erase(f.begin()+i+1);
  //     i=i-1;
  //   }
  // }
  vector<pro> p2;
  for (auto& e : f) {
    if (p2.empty()) {
      p2.push_back(e);
      continue;
    }
    auto last = p2.end() - 1;
    if (last->c != e.c || last->t != e.s) {
      p2.push_back(e);
    } else {
      last->t = e.t;
    }
  }
  f = p2;
  n = p2.size();

  // cout << "--" << endl;
  // for(auto& p : f)cout<<p.s<<" "<<p.t<<" "<<p.c<<endl;
  int rec[100001]={0};
  for(int i=0;i<n;i++){
    for(int j=f[i].s;j<f[i].t+1;j++)rec[j]+=1;
  }
  cout<<*max_element(&rec[0],&rec[100001])<<endl;
  return 0;
}


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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 1001
#define MOD 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main(){

    fast;

    ld n;
    cin >> n;

    cout << 2*3.14159265359*n << endl;

}










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

using namespace std;

int main(){
    int a , b ,c, d ;

    cin >> a >> b >> c >> d ;
     if ( abs(a-c)< abs(c-b)){
        cout << " Yes";
     }

   else if ( abs(a-b)<= d && abs( b-c)<=d ) {
        cout<<"Yes";
    }
    else {
        cout<< "No";
    }
    return 0 ;
}


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

//#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

//#define int long long
using namespace std;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int n, q;
	cin >> n >> q;
	vector<pair<pair<int, int>, int>> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first.first >> a[i].first.second >> a[i].second;
		a[i].first.first -= a[i].second;
		a[i].first.second -= a[i].second;
	}
	sort(all(a));
	vector<int> b(q);
	for (int i = 0; i < q; i++) cin >> b[i];

	map<int, int> open;
	set<pair<int, int>> close;
	int id = 0;
	for (int i = 0; i < q; i++) {
		while (id < n && a[id].first.first <= b[i]) {
			open[a[id].second]++;
			close.insert({a[id].first.second, id});
			id++;
		}
		while (!close.empty() && close.begin()->first <= b[i]) {
			int j = close.begin()->second;
			close.erase(close.begin());
			open[a[j].second]--;
			if (!open[a[j].second]) open.erase(a[j].second);
		}
		
		cout << (open.empty() ? -1 : open.begin()->first) << '\n';
	}
}


signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

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

int main(){
  int n,k;
  cin >> n >> k;
  int h[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  sort(h,h+n);
  int min=1000000000;
  for(int i=0;i<n-k+1;i++){
    if(min > h[i+k-1] - h[i]) min = h[i+k-1] - h[i];
  }
  cout << min;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define sc(x) scanf("%lld",&x);
#define fi first
#define se second
#define endl '\n'
#define P pair<int,int>
priority_queue<int> pq;
signed main()
{
    int x;
    int n,m;
    sc(n)sc(m)
    int ans = min(n%m,m-(n%m));
    cout<<ans<<'\n';
}


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

using namespace std;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define pb push_back
#define mk make_pair

#define flu(i, s, e) for(int i = s; i < e; i++)
#define fld(i, s, e) for(int i = s; i >= e; i--)


int main(){
	fast;

	// freopen("input.txt", "r", stdin);
	// freopen("myoutput.txt", "w", stdout);

	int n; scanf("%d", &n);
	n %= 10;
	if(n == 0 || n == 1 || n == 6 || n == 8) printf("pon\n");
	else if(n == 3) printf("bon\n");
	else printf("hon\n");

	return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	vll up[2],down[2],stay[2];
	scan(N);
	rep(i,N){
		ll x[2];
		char d;
		char hit[2][2]={{'R','L'},{'U','D'}};
		scan(x[0]>>x[1]>>d);
		rep(j,2){
			if(d==hit[j][0]) up[j].push_back(x[j]);
			else if(d==hit[j][1]) down[j].push_back(x[j]);
			else stay[j].push_back(x[j]);
		}
	}
	rep(j,2){
		if(!up[j].empty()) sort(ALL(up[j]));
		if(!down[j].empty()) sort(ALL(down[j]));
		if(!stay[j].empty()) sort(ALL(stay[j]));
	}
	pair<double,double> maxf[2],minf[2];
	vector<double> turn(1,0);
	double upmax[2],downmax[2],staymax[2],upmin[2],downmin[2],staymin[2];
	rep(j,2){
		upmax[j]=-INFl,downmax[j]=-INFl,staymax[j]=-INFl;
		upmin[j]=INFl,downmin[j]=INFl,staymin[j]=INFl;
		if(!up[j].empty()) upmax[j]=up[j].back(),upmin[j]=up[j].front();
		if(!down[j].empty()) downmax[j]=down[j].back(),downmin[j]=down[j].front();
		if(!stay[j].empty()) staymax[j]=stay[j].back(),staymin[j]=stay[j].front();
		turn.push_back(staymax[j]-upmax[j]),turn.push_back(downmax[j]-staymax[j]),turn.push_back((downmax[j]-upmax[j])/2.0);
		turn.push_back(staymin[j]-upmin[j]),turn.push_back(downmin[j]-staymin[j]),turn.push_back((downmin[j]-upmin[j])/2.0);
	}
	double ans=INFl;
	for(auto t:turn){
		if(t>=0&&t<1e+9){
			double seki=1;
			rep(j,2){
				seki*=max({t+upmax[j],staymax[j],-t+downmax[j]})-min({t+upmin[j],staymin[j],-t+downmin[j]});
			}
			ans=min(ans,seki);
		}
	}
	prin(setprecision(10)<<ans);
	return 0;
}


Measured memory_bytes: 2288
#include <iostream>

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  int ans = 0;
  if(a<b){
    int temp = a;
    a = b;
    b =temp;
  }
  if(a-1>b){
    ans = a*2-1;
  }else{
    ans=a+b;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
vector<int> V;
int N;
cin >> N;
for (int i = 0; i < N; ++i){
int tmp;
cin >> tmp;
V.push_back(tmp);
}
int MAX = *max_element(V.begin(),V.end());
int MIN = *min_element(V.begin(),V.end());
cout << MAX - MIN << endl;
return 0;
}

Measured memory_bytes: 256
height, wide = map(int, input().split())
color = int(input())
colorNum = list(map(int, input().split()))
ans = [0] * wide
heightCheck = "even"
outputCount = 0
for i in range(color):
  for j in range(colorNum[i]):
    if heightCheck == "even":
      ans[outputCount] = i + 1
      outputCount += 1
    else:
      ans[outputCount] = i + 1
      outputCount -= 1
    if outputCount == wide:
      for k in range(wide):
        if k != wide - 1:
          print(str(ans[k]) + " ", end = "")
        else:
          print(ans[k])
      heightCheck = "odd"
      outputCount -= 1
    elif outputCount == -1:
      for k in range(wide):
        if k != wide - 1:
          print(str(ans[k]) + " ", end = "")
        else:
          print(ans[k])
      heightCheck = "even"
      outputCount = 0

Measured memory_bytes: 3828
/*
Rathin Bhargava
IIIT Bangalore

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int n;
  cin >> n;
  vector<int> v(2*n);
  for(int i=0;i<2*n;i++) cin >> v[i];
  sort(v.begin(),v.end());

  ll sum1 = 0;
  for(int i=0;i<n;i++)
  {
    sum1 += v[2*i];
  }

  cout << sum1 << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
ll tree[800005];
ll a[200005];
void built(int start,int end,int index)
{
	if(start==end)
	{
		tree[index]=0;
		return;
	}
	int mid=(start+end)/2;
	built(start,mid,2*index);
	built(mid+1,end,2*index+1);
	tree[2*index]=0;
	tree[2*index+1]=0;
}
ll query(int start,int end,int index,int l,int r)
{
//	cout<<start<<" "<<end<<endl;
	if(start>r || end<l)return 0LL;
	if(start>=l && end<=r)return tree[index];
	int mid=(start+end)/2;
	return max(query(start,mid,2*index,l,r),query(mid+1,end,2*index+1,l,r));
}
void update(int start,int end,int index,int f,ll val)
{
	if(start==end)
	{
		tree[index]=val;
		return;
	}
	int mid=(start+end)/2;
	if(mid>=f)update(start,mid,2*index,f,val);
	else update(mid+1,end,2*index+1,f,val);
	tree[index]=max(tree[2*index],tree[2*index+1]);
}
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	int n;
  	cin>>n;
  	ll b[n+1],c[n+1];
  	For(i,n)cin>>b[i+1];
  	For(i,n)cin>>c[i+1];
  	built(1,n,1);
  	ll ans=0;
  	for(int i=1;i<=n;i++)
  	{
  		ll g=query(1,n,1,1,b[i]);
  		ans=max(ans,g+c[i]);
  		update(1,n,1,b[i],g+c[i]);
  	//	for(int i=1;i<=7;i++)cout<<tree[i]<<" ";
  	//	cout<<endl;
  	}
  	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7936
from math import ceil
def main():
    N = int(input())
    P = list(map(float,input().split()))
    f = [[0]*(N + 1) for _ in range(N + 1)]
    f[0][0] = 1 - P[0]
    f[0][1] = P[0]
    for i in range(1,N):
        p = P[i]
        f[i][0] = f[i - 1][0]*(1 - p)
        for j in range(max(1,ceil((N + 1)/2) - N + i - 3),i + 2):
            f[i][j] += p*f[i - 1][j - 1] + (1 - p)*f[i - 1][j]
    print(sum(f[N - 1][N //2 + 1:]))
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 274568
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

const ll MAXN = (ll)2e3+10;
const ll DIV = (ll)1e9+7;


int main(void) {
   ll N,K;
   cin>>N>>K;
   vector<ll> A(N);
   rep(i,0,N) cin>>A[i];
   vector<ll> Nab(N,0);
   vector<ll> Nab2(N,0);
   rep(i,0,N) {
      rep(j,0,N) {
         if (A[j]>A[i]) Nab[i]++;
      }
      rep(j,0,i) {
         if (A[j]>A[i]) Nab2[i]++;
      }
   }
   // rep(i,0,N) cout<<i<<" "<<Nab[i]<<endl;
   // rep(i,0,N) cout<<i<<" "<<Nab2[i]<<endl;

   ll ans = 0;
   rep(i,0,N) {
      ll num = (K-1)*K/2;
      ans += (Nab[i])*(num%DIV);
      ans = ans%DIV;
      ans += Nab2[i]*K;
      ans = ans%DIV;
   }
   cout<<ans%DIV<<endl;


   return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, TreeNode> nodes = new HashMap<>();
        int rootID = 0;
        ArrayList<Integer> notRoots = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            String treeString = in.readLine();
            String[] data = treeString.split(" ");
            int id = Integer.parseInt(data[0]);
            int degree = Integer.parseInt(data[1]);
            int[] children = new int[degree];
            for (int j = 0; j < degree; j++) {
                children[j] = Integer.parseInt(data[j+2]);
                notRoots.add(children[j]);
            }
            TreeNode node = new TreeNode(id, degree, children);
            nodes.put(node.id, node);
        }
        notRoots.sort(Integer::compareTo);
        for (Integer i : notRoots) {
            if (rootID == i) {
                rootID++;
            }
        }
        updateNodes(nodes, rootID, -1, 0);

        int id = 0;
        TreeNode node = nodes.get(id);
        while (node != null) {
            System.out.println("node " + id + ": parent = " + node.parent + ", depth = " + node.depth + ", "
                    + node.getType() + ", " + Arrays.toString(node.children));
            node = nodes.get(++id);
        }
    }

    private static void updateNodes(HashMap<Integer, TreeNode> nodes, int currentID, int parent, int depth) {
        TreeNode node = nodes.get(currentID);
        node.parent = parent;
        node.depth = depth;
        if (!node.isLeaf()) {
            for (int child : node.children) {
                updateNodes(nodes, child, currentID, depth+1);
            }
        }
    }
}

class TreeNode {
    int id;
    int degree;
    int[] children;
    int parent;
    int depth;

    public TreeNode(int id, int degree, int[] children) {
        this.id = id;
        this.degree = degree;
        this.children = children;
    }

    boolean isLeaf() {
        return degree == 0;
    }

    String getType() {
        if (depth == 0) {
            return "root";
        } else if (isLeaf()) {
            return "leaf";
        } else {
            return "internal node";
        }
    }
}



Measured memory_bytes: 112540
def solve(a, b, t):
    result = int(t / a) * b
    return result

def input_from_console():
    a, b, t = map(int, input().split())
    return a, b, t


def main():
    a, b, t = input_from_console()
    print(solve(a, b, t))

if __name__ == "__main__":
    main()

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N, A, B;
  cin >> N >> A >> B;

  if (N * A < B) {
    cout << N * A << endl;
  } else {
    cout << B << endl;
  }

  return 0;
}


Measured memory_bytes: 256