akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>
#include <string>
#include <valarray>
// #include <cctype>

#define INF -1

using namespace std;
/*  class   */
class Dice
{
    private:
        // vector<int> face(6);
        int face[7];
        // string west = "face4", east = "face3",
        //         south = "face2" , north = "face5",
        //         bottom = "face6", top = "face1";
        int W = 4, E = 3, S = 2, N = 5, B = 6, T = 1;

    public:
        void assign()
        {
            int i = 0;
            while (i++ < 6)
            {
                cin >> face[i];
            }

        }
        void roll_W()
        {
            int temp = W;
            W = T;
            T = E;
            E = B;
            B = temp;
        }

        void roll_E()
        {
            int temp = E;
            E = T;
            T = W;
            W = B;
            B = temp;
        }
        
        void roll_S()
        {
            int temp = S;
            S = T;
            T = N;
            N = B;
            B = temp;
        }

        void roll_N()
        {
            int temp = N;
            N = T;
            T = S;
            S = B;
            B = temp;
        }

        int top()
        {
            return face[T];
        }
};


int main()
{
    Dice dice;

    dice.assign();

    char ch;
    cin.ignore();
    while (cin.get(ch) && ch != '\n')
    {
        if (ch == 'W')
            dice.roll_W();
        else if (ch == 'E')
            dice.roll_E();
        else if (ch == 'S')
            dice.roll_S();
        else
            dice.roll_N();
        
    }

    cout << dice.top() << endl;

}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ld A, B; cin >> A >> B;
    // A*B;
    ll res = A*B;
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7844
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
in ab(in a){
  return a<0?-a:a;
}
map<in,in> shd,hv;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  forn(i,n)
    ++shd[ab(i-(n-i-1))];
  in a;
  forn(i,n){
    cin>>a;
    ++hv[a];
  }
  if(hv!=shd){
    cout<<0<<endl;
    return 0;
  }
  const in mdl=1000000007;
  in sm=1;
  fors(i,shd)
    if(i->second==2)
      sm=sm*2%mdl;
  cout<<sm<<endl;
  return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int k,n; cin>>k>>n;
	n--;
	ll ans=-1;
	ll memo;
	cin>>memo;
	ll cnt=memo;
	while(n>0){
		ll a; cin>>a;
		ans=max(ans,a-memo);
		memo=a;
		n--;
	}
	ll cnt2=memo;
	ll v=cnt+(k-cnt2);
	ans=max(ans,v);
	cout<<k-ans;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int sum = 0;
    int A[200010];
    rep(i, N) cin >> A[i];
    rep(i, N) sum += A[i];
    int ans = INF2;
    int tmp = 0;
    rep(i, N) {
        tmp += A[i];
        ans = min(ans, abs(sum - tmp - tmp));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
int main(void) 
{
	int n, i;
	double x1, x2, x3, y1, y2, y3, px, py, r;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
		px = ((y1-y3)*(y1*y1-y2*y2+x1*x1-x2*x2)-(y1-y2)*(y1*y1-y3*y3+x1*x1-x3*x3)) / (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));
		py = ((x1-x3)*(x1*x1-x2*x2+y1*y1-y2*y2)-(x1-x2)*(x1*x1-x3*x3+y1*y1-y3*y3)) / (2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3));
		r = sqrt((x1 - px) * (x1 - px) + (y1 - py) * (y1 - py));
		printf("%.3f %.3f %.3f\n", px, py, r);
	}
	return 0;
}



Measured memory_bytes: 2060
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
	int n, i, j;
	int a[100];

	cin >> n;

	i = 0;
	while (i < n) {
		cin >> a[i];
		i++;
	}

	j = n-1;
	while (0<j) {
		printf("%d ", a[j]);
		j = j - 1;
	}
	printf("%d\n", a[0]);
    return 0;
}




Measured memory_bytes: 3200
n = int(input())

ans = []
if n & 1 == 1:
    for i in range(n):
        if i + 1 != n:
            ans.append((i+1, n))
    n -= 1

for i in range(n):
    for j in range(i+1, n+1):
        if j != n - i and j != i + 1:
            ans.append((i+1, j))

print(len(ans))
for i in range(len(ans)):
    print(ans[i][0], ans[i][1])

Measured memory_bytes: 3956
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  string s;
  cin>>s;

  if (s == "ARC")
    cout<<"ABC"<<endl;
  else
    cout<<"ARC"<<endl;
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 3652
#include<iostream>
#include<stdio.h>
#include<set>
#include<map>
#include<utility>
#include<math.h>
#include<iomanip>
#include<string>
#include<vector>
using namespace std ;
using ll = long long ;
using vll = vector<ll> ;
using vi = vector<int> ;
using ld = long double ;
using pii = pair<int,int> ;

int main(){
	int n ; cin >> n ;
	cout << (n+1)/2 << endl ;
}


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

void main_()
{
    ll N;
    cin >> N;
    vector<pair<ll, ll>> ABs;
    ABs.reserve(N);
    for (ll i = 0; i < N; ++i) {
        ll A, B;
        cin >> A >> B;
        ABs.emplace_back(A, B);
    }

    reverse(begin(ABs), end(ABs));
    ll ans = 0;
    for (auto&& ab : ABs) {
        auto a = ab.first + ans;
        auto b = ab.second;
        auto remainder = a % b;
        if (remainder != 0) {
            ans += (b - remainder);
        }
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 1792
#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 MP make_pair
#define PB push_back
#define in int
#define ll long long
#define ull unsigned long long
#define vc vector
#define SQ(j) (j)*(j)
#define ch first
#define range second
//
//#define ld long double
#define dbl  double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define sz(xxx) ((int)(xxx.size()))
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

//#define printf(...) (0)
#define db(x) if(DEBUG) {cout << #x << " = " << x << endl;}
#define dbCont(x) if(DEBUG) {cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;}

using namespace std;

template<class K, class V>
ostream &operator<<(ostream &out, pair<K, V> &elem) {
    out << "{" << elem.first << "," << elem.second << "}";
    return out;
}


int DEBUG = 0;

using namespace std;

int n,m;


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

    map<int,int> ac;
    map<int,int> wa;
    int score = 0;
    int penalty = 0;

    loop(i,m){
        int p;
        string v;
        cin >> p >> v;

        if(v == "AC") {
            if(ac[p]){
                // hech
            } else {
                ac[p] = true;
                score += 1;
                penalty += wa[p];
            }
        } else if(v == "WA") {
            if(ac[p]){
                // hech
            } else {
                wa[p]++;
            }
        }
    }

    cout << score << ' ' << penalty << endl;


    return 0;
}

/*

7
1 0 0 5 0 0 2

 */

Measured memory_bytes: 9600
N, K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))
scores = []
for i in range(N):
  pos = P[i]-1
  s = [C[i]]
  j = 1
  while j < K and pos != i:
    s.append(s[-1]+C[pos])
    pos = P[pos]-1
    j += 1
  smax = max(s)
  length = len(s)
  if length < K and s[-1] > 0:
    if K%length != 0:
      smod = s[:K%length]
      smodmax = max(smod)
    else:
      smodmax = 0
    scores.append(max(s[-1] * ((K//length)-1) + smax, s[-1] * (K//length), s[-1] * (K//length) + smodmax))
  else:
    scores.append(smax)
print(max(scores))

Measured memory_bytes: 85004
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 998244353
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=3001 ;
ll dp[N][N] ;
ll n,s ;
vector<ll>a(N) ;
ll fun(ll i,ll j)
{
    if(j==0)
    {
        return n-i+1 ;
    }
    if(i==n)
    {
        if(j==0)
            return 1 ;

        return 0 ;
    }
    else if(dp[i][j]!=-1)
        return dp[i][j] ;
    else
    {
        ll ans=fun(i+1,j) ;
        if(a[i]<=j)
        {

            ans=(ans+fun(i+1,j-a[i]))%maa ;
        }
      //  cout<<i<<" "<<j<<" "<<ans<<endl  ;
        return dp[i][j]=ans ;
    }
}
int main()
{
   fast ;
   ll tests=1 ;
   //cin>>tests ;
   for(ll testcase=1;testcase<=tests;testcase++)
   {
     ///cout<<"Case #"<<testcase<<": " ;
     ///Read ,Think and Test Properly,then code
     cin>>n>>s ;
     for(ll i=0;i<n;i++)
        cin>>a[i] ;

     for(ll i=0;i<N;i++)
     {
         for(ll j=0;j<N;j++)
            dp[i][j]=-1 ;
     }
     ll ans=0 ;

     for(ll i=0;i<n;i++)
     {
         ll x=0 ;
         if(s>=a[i])
            x=fun(i+1,s-a[i]) ;


         //cout<<i<<" "<<x<<endl ;
         x=(x*(i+1))%maa ;

         ans=(ans+x)%maa ;

     }
     cout<<ans ;



   }
}


Measured memory_bytes: 70784
N = int(input())
SP = []
name = []
for i in range(N):
    x = list(input().split())
    x = [x[0], int(x[1]), int(i)]
    name.append(x[0])
    SP.append(x)


# sort on secondary key
s = sorted(SP, key=lambda x: (x[0], -x[1]))
# now sort on primary key, descending
#sorted(s, key=attrgetter('grade'), reverse=True)

for i in range(N):
    print(s[i][2] + 1)


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

//nの桁数を求める関数
int FindDigits(long int n){
  long int cnt = 0;
  while(n != 0){
    n /= 10;
    cnt++;
  }
  return cnt;
}

int main(void){
  long int N, a, b;
  int dig, mindig = 100;
  cin >> N;
  for(a = 1; a <= sqrt(N); a++){
    if(N % a == 0){
      b = N / a;
      dig = max(FindDigits(a), FindDigits(b));
      //cout << a << " " << b << " " << dig << endl;
      if(mindig > dig){mindig = dig;}
    }
  }
  cout << mindig << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i,j,n,m=0,l=0;
    char T[101],H[101];
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%s %s",T,H);
        
        for(j=0;;j++){
            if(T[j]>H[j]){
                m+=3;
                break;
            }
            else if(T[j]<H[j]){
                l+=3;
                break;
            }
            else if(T[j]+H[j]==0){
                m++;
                l++;
                break;
            }
        }
    }
    printf("%d %d\n",m,l);
    return 0;
    
}


Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var N = LnInt();
        var dict = new Dictionary<string, int>();
        for (var i = 0; i < N; i++)
        {
            var S = LnStr();
            if (dict.ContainsKey(S))
            {
                dict[S]++;
            }
            else
            {
                dict[S] = 1;
            }
        }
        var max = dict.Max(x => x.Value);
        var array = dict.Where(i => i.Value == max).Select(x => x.Key);
        array = array.OrderBy(x => x, StringComparer.Ordinal);
        foreach (var i in array)
        {
            print(i);
        }
    }

public static long PowLite(long n, long p, int mod = (int)1e9 + 7){long ans = 1;long now = n;for (; p > 0; p >>= 1){if ((p & 1) == 1){ans *= now;ans %= mod;}now *= now;now %= mod;}return ans;}
public static void print(object obj) { Console.WriteLine(obj); }
public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
public static List<T[]> AllPermutation<T>(params T[] array) where T : IComparable{var a = new List<T>(array).ToArray();var res = new List<T[]>();res.Add(new List<T>(a).ToArray());var n = a.Length;var next = true;while (next){next = false;int i;for (i = n - 2; i >= 0; i--){if (a[i].CompareTo(a[i + 1]) < 0) break;}if (i < 0) break;var j = n;do{j--;} while (a[i].CompareTo(a[j]) > 0);if (a[i].CompareTo(a[j]) < 0){var tmp = a[i];a[i] = a[j];a[j] = tmp;Array.Reverse(a, i + 1, n - i - 1);res.Add(new List<T>(a).ToArray());next = true;}}return res;}}



Measured memory_bytes: 43760
N, M = map(int, input().split())
shop = []
for i in range(N):
  shop.append([int(i) for i in input().split()])

shop.sort()
cost = 0
for i in range(N):
  if shop[i][1] < M:
    M -= shop[i][1]
    cost += shop[i][0] * shop[i][1]
  else:
    cost += shop[i][0] * M
    break
print(cost)


Measured memory_bytes: 21616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    rep1(i, n) cin >> a[i];
    ll ans = 0, res = 0;
    bool flag = true;
    rep1(i, n-1){
        if (a[i]>a[i+1]){
            if (flag){
                flag = false;
                ans += a[i] - res;
                res = a[i+1];
            }
            else res = a[i+1];
            }
        if (a[i]<a[i+1]){
            flag = true;
        }

    }
    if (flag) ans += a[n-1] - res;
    cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}

	public Main() {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter(",|(\\s+)");
		
		while(sc.hasNext()){
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double xp = sc.nextDouble();
			double yp = sc.nextDouble();
			solve(x1, y1, x2, y2, xp, yp);
		}
	}

	private void solve(double x1, double y1, double x2, double y2, double xp,
			double yp) {

		double vxp = xp-x1;
		double vyp = yp-y1;
		double vx = x2-x1;
		double vy = y2-y1;
		
		double angle = (Math.atan2(vyp, vxp) - Math.atan2(vy, vx))*(-2);
		double resx = Math.cos(angle)*vxp - Math.sin(angle)*vyp+x1;
		double resy = Math.sin(angle)*vxp + Math.cos(angle)*vyp+y1;
		System.out.println(String.format("%.6f %.6f", resx, resy));
		
	}


}

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

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

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

  ll x; cin >> x;
  int ans = 0;
  for(int i = 1; i*(i+1)/2 < x; i++) ans = i;

  cout << ans+1 << '\n';
  return 0;
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int n,x;
    cin>>n>>x;
    Vi l(n);
    REP(i,n) cin>>l[i];

    int d = 0;
    int cnt = 1;
    REP2(i,1,n+1){
        d += l[i-1];
        if(d>x) break;
        cnt++;
    }

    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    K, N = map(int, input().split())
    A = tuple(map(int, input().split()))

    d = K - A[-1] + A[0]
    for i in range(N - 1):
        d = max(d, A[i+1] - A[i])
    print(K - d)


main()


Measured memory_bytes: 26700
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
long long L[100];
int main(){
	int n;
	L[0]=2,L[1]=1;
	for(int i=2;i<=86;i++)
		L[i]=L[i-1]+L[i-2];
	while(scanf("%d",&n)!=EOF){
		printf("%lld\n",L[n]);
	}
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

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

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

const int PrimeMax = 100001;
int is_prime[PrimeMax];
void Eratosthenes(int N){
  for(int i = 0; i < N; i++){
    is_prime[i] = 1;
  }
  is_prime[1] = 0;
  for(int i = 2; i*i < N ; i++){
    if(is_prime[i]){
      for(int j = 0; i * (j + 2) < N; j++){
        is_prime[i *(j + 2)] = 0;
      }
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  Eratosthenes(PrimeMax);
  while(cin >> N ){
    ll ans = 0;
    REP(i,1,N+1){
      if(is_prime[i] && is_prime[N+1-i]){
        ++ans;
      }
    }
    cout << ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int n;
  cin>>n;
  vector<int> b(n);
  int f=0;
  for(int i=0;i<n;i++){
    cin>>b[i];
    b[i]--;
    if(b[i]>i)f=1;
  }
  if(f){
    cout<<-1<<endl;
    return 0;
  }

  vector<int> ans(n);
  
  for(int i=0;i<n;i++){
    int f=1;
    for(int j=b.size()-1;j>=0;j--){
	 if(j==b[j]){
	   ans[n-1-i]=j;
	   b.erase(b.begin()+j);
	   f=0;
	   break;
	 }
    }
    if(f){
	 cout<<-1<<endl;
	 return 0;
    }
  }

  for(int i=0;i<n;i++)cout<<ans[i]+1<<endl;
  
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> sat(n);
  vector<int> c(n);
  
  for(int i = 0; i < n; i++) {
    int t;
    cin >> t;
    --t;
    a.at(i) = t;
  }
  
  for(int i = 0; i < n; i++) {
    int t;
    cin >> t;
    sat.at(i) = t;
  }
  
  for(int i = 0; i < n - 1; i++) {
    int t;
    cin >> t;
    c.at(i) = t;
  }
  
  int sum = 0;
  int prev = -2;
  for(int i = 0; i < n; i++) {
    int x = a.at(i);
    sum += sat.at(x);
    if(prev == x - 1) {
      sum += c.at(x - 1);
    }
    prev = x;
  }
  cout << sum << endl;
  return 0;
}

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

#define fi first
#define se second

using namespace std;

typedef pair <int,int> ii;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> v(n);
	for (int i = 0; i < n; ++i){
		cin >> v[i];
	}	
	vector <int> f(v);
	sort(f.begin(),f.end());
	for (int i = 0; i < n; ++i){
		if (v[i] == f[n-1]){
			cout << f[n-2] << " ";
		}		
		else{		
			cout << f[n-1] << " ";
		}
	}
	return 0;    
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int x = sc.nextInt();
		int y = sc.nextInt();

		int ans = Integer.MAX_VALUE;
		for (int i=0; i<=Math.max(x, y)*2; i+=2){
			int aNum = Math.max(0, x - (i / 2));
			int bNum = Math.max(0, y - (i / 2));
			int cNum = i;
			ans = Math.min(ans, (aNum * a) + (bNum * b) + (cNum * c));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n,a;cin >> n >> a;
    n%=500;
    if(n<=a)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3628
#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;
  string s; cin >> s;
  int ans = 0;
  rep(i, n-2){
    if((s[i] == 'A') && (s[i+1] == 'B') && (s[i+2] == 'C')){
      ans++;
    }
  }
  cout << ans << endl;
}

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


#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph;


signed main(){
	IOS

		ll n, m; 
	cin >> n >> m;
	
	ll a, b;
	cin >> a >> b;
	a -= m;
	if (a <= 0){
		cout << "Yes";
		return 0;
	}
	while (n > 0 and a > 0){
		n -= b;
		a -= m;
	}
	if (n <= 0){
		cout << "No";
	}
	else{
		cout << "Yes";
	}

	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

// sを2倍の大きさにして考える。大きさ2n*2n
// a a      a a a a
// a a 　→  a a a a
//          a a a a
//          a a a a
// A=0、B=0からn*nの盤面を抜き出し、その盤面が対称であれば、A=1, B=1, A=2, B=2の場合にも対称が成り立つ。
// したがって、A=0, B=i (i = 0,...,n-1)の盤面についてそれぞれ対称かどうか確認し、
// 対称であればA=1, B=i+1...の時にも対称であるため、よい盤面の選び方をn個増加させるということを繰り返す。

int main(){
    Init();
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i, n){
        cin >> s[i];
        s[i] += s[i];
    }

    // A=0, b=iからn*nの盤面を切り出して、その盤面が対称であれ選び方をn個増加させる。
    ll ans = 0;
    for(ll i=0; i<n; i++){
        bool symmetry = true;
        for(ll y=0; y<n; y++){
            if(!symmetry) break;
            for(ll x=y+1; x<n; x++){
                if(s[y][x+i] != s[x][y+i]) symmetry = false;
                if(!symmetry) break;
            }
        }
        if(symmetry) ans += n;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3876
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int main() {

	int N;
	cin >> N;
	vector<int> A(N);

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

		cin >> A[i];
		if (A[i] % 2 == 0) {
			if (A[i] % 3 == 0 || A[i] % 5 == 0) {

				continue;
			}
			else {
				cout << "DENIED";
				return 0;
			}

		}

	}

	cout << "APPROVED";
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<Pii> Vp;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 266666, inf = 0x3f3f3f3f;
int n,l,a[N];ll res;map<Pii,Vp>Set;//pos,val: vector<Pii>
set<Pii>heap;//val,pos
void merge_front(map<Pii,Vp>::iterator it){
	if(it==Set.begin())return;map<Pii,Vp>::iterator it1=it;it1--;
	if((*it).fi.se!=(*it1).fi.se)return;
//	cerr<<"merge "<<(*it).fi.fi<<' '<<(*it1).fi.fi<<endl;
	heap.erase(Pii((*it).fi.se,(*it).fi.fi));
	rep(i,0,SZ((*it).se)-1)(*it1).se.pb((*it).se[i]);Set.erase(it);
}
inline ll calc(Vp a){
	static ll qz[N];
	rep(i,0,SZ(a)-1)qz[i]=(i-1>=0?qz[i-1]:0)+a[i].fi;
	ll res=0;rep(i,l-1,SZ(a)-1)res+=qz[i-l+1]*a[i].se;
	rep(i,0,SZ(a)-1)res+=1LL*a[i].fi*a[i].se;
	return res;
}
int main() {
	read(n);read(l);rep(i,1,n)read(a[i]);
	rep(i,1,n){
		int j=i;while(j+1<=n&&a[j+1]==a[i])j++;
		Vp b;rep(k,i,j)b.pb(Pii(1,1));Set[Pii(i,a[i])]=b;//Set.insert(pair<Pii,Vp>(Pii(i,a[i]),b));
		heap.insert(Pii(a[i],i));i=j;
	}
	while(!Set.empty()){
		Pii tmp=*heap.begin();heap.erase(heap.begin());
		if(tmp.fi==inf)break;
		map<Pii,Vp>::iterator it=Set.find(Pii(tmp.se,tmp.fi)),it1;
	//	cerr<<(*it).fi.fi<<' '<<res<<endl;
		if(SZ((*it).se)<l){
			res+=calc((*it).se);
			int pos=(*it).fi.fi;
			Set.erase(it);Set.insert(pair<Pii,Vp>(Pii(pos,inf),{}));heap.insert(Pii(inf,pos));
			continue;
		}
		res+=calc((*it).se);
		Vp b(SZ((*it).se)/l,Pii(0,0));
		rep(i,l-1,SZ((*it).se)-1)b[(i+1)/l-1].se+=(*it).se[i].se;
		int pos=SZ(b)-1,cnt=0;per(i,SZ((*it).se)-l,0){
			cnt++;if(cnt>l)cnt-=l,pos--;
			b[pos].fi+=(*it).se[i].fi;
		}
		pos=(*it).fi.fi;int val=(*it).fi.se+1;Set.erase(it);
		it=Set.insert(pair<Pii,Vp>(Pii(pos,val),b)).fi;heap.insert(Pii(val,pos));
		res-=calc((*it).se);
		it1=it;it1++;merge_front(it);if(it1!=Set.end())merge_front(it1);
	}
	cout<<res;
	return 0;
}


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

int main(){
	int n;scanf("%d",&n);
	int i;
	for(i=1;i*i<=n;i++);
	i--;
	cout<<i*i<<endl;
}

Measured memory_bytes: 256
//*******************************************************ランダムなもの***********************************************************************
// double num1 = 3.12345678; cout << fixed << showpoint; cout << setprecision(9); cout << num1 << endl; printf("%0.9lf \n", side); for double
// struct foo{ int a,b,c; }; typedef struct foo foo;
// typedef pair<int, int> pi; 
// struct Compare{ bool operator()(pi const & a, pi const & b){ if(a.first==b.first){ return a.second>b.second; } return a.first<b.first; } };
// priority_queue<pi , vector<pi>, Compare> pq; priority_queue <int, vector<int>, greater<int> > pq; # Min Heap
// for(ll i=1;i<=m+1;i++) f[i]=(f[i-1]%mod * i%mod)%mod; mcn = (f[m]%mod * power(f[n],mod-2,mod)%mod * power(f[m-n],mod-2,mod)%mod)%mod;
// void bfs(int i){ queue<pair<int,int>> q; q.push(mp(i,0)); vis[i]=1;
// while(!q.empty()) { pair<int,int> temp=q.front(); q.pop(); d[i][temp.first]=temp.second;
// for(auto it=g[temp.first].begin();it!=g[temp.first].end();it++) {if(vis[*it]==0){vis[*it]=1; q.push(mp(*it,(temp.second)+1));}}}}
// void dfs(int child,int parent,vector<int> &d,vector<int> &p,int &tx,vector<int> &tin,vector<int> &tout) { tin[child]=tx++;
// for(auto it = g[child].begin();it!=g[child].end();it++) { if(*it==parent) continue;
// d[*it]=1+d[child]; p[*it]=child; dfs(*it,child,d,p,tx,tin,tout);} tout[child]=tx++; }
//**********************************************************数や******************************************************************************
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define endl '\n'
#define PI 3.14159265
#define ff first
#define ss second
#define tab '\t'
#define deb cout<<"error"<<endl
#define uset unordered_set
#define mset multiset
#define umap unordered_map
#define mmap multimap
#define len length
#define SZ(x) (int)(x).size()
#define nbits(d) (int)log2(d)+1
// struct chash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
// x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
// size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
// return splitmix64(x + FIXED_RANDOM);} };
ll gcd (ll a, ll b){ if(b==0) return a; else return gcd(b,a%b); }
ll power(ll a, ll n){ ll res=1; while(n!=0) { if(n%2){ res=res*a; n--; } else { a=a*a; n=n/2; } } return res;}
ll powermod(ll a, ll n, ll m){ ll res=1; while(n!=0) { if(n%2){ res=(res%m*a%m)%m; n--; } else { a=(a%m*a%m)%m; n=n/2; } } return res%m;}
/*Any INT overflow ? Inside while loop < n, okay ? ! Multiple GRAPHS in testcases ? Reinitialize global ! End cases n=0 || n=1 ?
*Do and write something insted of nothin okay?! * これらのコードの作成者 - ビベックシャルマ */

void jiejue() 
{   
    int n;
    cin>>n;
    if(n>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int teseuteu;
teseuteu=1; while(teseuteu--) jiejue();
// cin>>teseuteu; while(teseuteu--) jiejue();
}


Measured memory_bytes: 3644
n, m = gets.split.map(&:to_i)

a = []
n.times do
  a << gets.split.map(&:to_i)
end

b = []
m.times do
  b << gets.to_i
end

a.each do |a_ary|
  sum = 0
  m.times do |i|
    sum += a_ary[i] * b[i]
  end

  puts sum
end

Measured memory_bytes: 8832
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    for(int i=0;i<3000;i++){
    cin>>x>>y;
    if(x==0&&y==0){
        break;
    }
    if(x<y){
        cout<<x<<" "<<y<<endl;
        
    }
    else if(y<x){
        cout<<y<<" "<<x<<endl;
    }
    else{
        cout<<x<<" "<<y<<endl;
    }
    }
}


Measured memory_bytes: 2980
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int dp[4][4][4][100] = {};

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

    int n;
    cin >> n;

    rep(i, 4) rep(j, 4) rep(k, 4){
        if(i == 0 && j == 2 && k == 1){
            continue;
        }
        if(i == 0 && j == 1 && k == 2){
            continue;
        }
        if(i == 2 && j == 0 && k == 1){
            continue;
        }
        dp[i][j][k][0] = 1;
    }
    rep(i, n - 3){
        rep(j, 4) rep(k, 4) rep(l, 4) rep(m, 4){
            if(k == 0 && l == 2 && m == 1){
                continue;
            }
            if(k == 0 && l == 1 && m == 2){
                continue;
            }
            if(k == 2 && l == 0 && m == 1){
                continue;
            }
            if(j == 0 && l == 2 && m == 1){
                continue;
            }
            if(j == 0 && k == 2 && m == 1){
                continue;
            }
            dp[k][l][m][i+1] += dp[j][k][l][i];
            dp[k][l][m][i+1] %= MOD;
        }
    }

    int ans = 0;
    rep(i, 4) rep(j, 4) rep(k, 4){
        ans += dp[i][j][k][n-3];
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, x, total = 0;
    scanf("%d%d", &n, &x);
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; ++i)
    {
        x -= a[i];
        if (x < 0)
        {
            break;
        }
        else if(x == 0)
        {
            ++total;
            break;
        }
        ++total;
    }
    if (total == n)
    {
        if (x)
        {
            printf("%d\n", total - 1);
        }
        else
        {
            printf("%d\n", total);
        }
    }
    else
    {
        printf("%d\n", total);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i <(b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a,value, sizeof(a))

#define ALL(a) a.begin(),a.end()
#define SZ(a) (int)a.size()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<LL> VI;
typedef pair<int, LL> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 * 100 + 47;


LL gcd(LL a, LL b)
{
    if (!a)return b;
    return gcd(b %a, a);
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //ios::sync_with_stdio(false);cin.tie(NULL);
    
    LL n, x;
    cin >> n >> x;
    cout << 3 * n - 3 * gcd(n, x) << endl;
}


Measured memory_bytes: 256
from operator import itemgetter
              

N, M = map(int, input().split())
A = input().split()
A = list(map(int, A))
A.sort()


cng = []
for i in range(M):
    B, C = map(int, input().split())
    cng.append((B,C))
    
cng = sorted(cng, key=itemgetter(1),reverse=True)

f=1
i=0
crd_cnt=0
crd_idx=0
while(f==1):
    if(A[i]<=cng[crd_idx][1]):
        A[i] = cng[crd_idx][1]
        crd_cnt += 1
    else:
        f=0

    if(N==crd_cnt):
        f=0

    if(crd_cnt==cng[crd_idx][0]):
        crd_idx += 1
        crd_cnt = 0
    
    if(M==crd_idx):
        f=0
    elif(i+1==N):
        f=0
    
    i+=1

print(sum(A))

Measured memory_bytes: 22836
#include <stdio.h>
#include <string.h>
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a>b)?(a):(b))

void reverse(char str[]){
        int len=strlen(str);
        int i,temp;
        for(i=0;i<len/2;i++){
                temp=str[i];
                str[i]=str[len-i-1];
                str[len-i-1]=temp;
        }

}
int main(void){
        int q;
        char str1[1000],str2[1000],str3[1000];
        int len1,len2;
        int work,i,kuriage;
        char c1,c2;
        scanf("%d",&q);

        while(q--){
                scanf("%s",str1);
                scanf("%s",str2);
                len1=strlen(str1);
                len2=strlen(str2);
                if(len1>80 || len2>80){printf("overflow\n");continue;}
                reverse(str1);
                reverse(str2);
                kuriage=0;
                if(len1>len2){
                        for(i=len2;i<len1;i++) str2[i]='0';
                        str2[i]='\0';
                        len2=len1;
                }else if(len1<len2){
                        for(i=len1;i<len2;i++) str1[i]='0';
                        str1[i]='\0';
                        len1=len2;
                }

                for(i=0;i<MIN(len1,len2);i++){
                        c1=str1[i];
                        c2=str2[i];
                        work=(int)(c1-'0' + c2-'0') + kuriage;
                        if(work>=10){
                                work-=10;
                                kuriage=1;
                        }else{
                                kuriage=0;
                        }
                        str3[i]=work+'0';
                }
                if(kuriage==1) str3[i++]='1';
                str3[i]='\0';
                reverse(str3);
                if(strlen(str3)>80) printf("overflow\n");
                else printf("%s\n",str3);
        }
        return 0;
}

Measured memory_bytes: 588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	char a, b;
	cin >> a >> b;
	if (a == 'H'&&b == 'H') {
		cout << "H";
	}
	else if (a == 'H'&&b == 'D') {
		cout << "D";
	}
	else if (a == 'D'&&b == 'D') {
		cout << "H";
	}
	else {
		cout << "D";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){
  int n;cin>>n;
  int d[n];

  REP(i,n){
    cin>>d[i];
  }

  ll ans = 0;

  REP(i,n){
    for(int j=i+1;j<n;j++){
      if(i!=j){
        ans += d[i]*d[j];
      }
    }
  }
  cout<<ans<<endl;
 

  return 0;
}

Measured memory_bytes: 256
x,y=input().split()
x=int(x);
y=int(y);
l1=[1,3,5,7,8,10,12]
l2=[4,6,9,11]
if(x in l1 and y in l1):
    print("Yes")
elif(x in l2 and y in l2):
    print("Yes")
elif(x==2 and y==2):
    print("Yes")
else:
    print("No")

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

using namespace std;
char t[200010],d[200010];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	int i,n,q;
	string s;
	cin >> n >> q >> s;
	for(i=0;i<q;i++){
		cin >> t[i] >> d[i];
	}
	int l = -1,r = n;
	for(i=q-1;i>=0;i--){
		if(d[i]=='L'){
			if(l<n-1 && s[l+1]==t[i]) l++;
			if(r<n && s[r]==t[i]) r++;
		}else{
			if(r>0 && s[r-1]==t[i]) r--;
			if(l>=0 && s[l]==t[i]) l--;
		}
	}
	cout << max(0,r - l - 1) << endl;
}

Measured memory_bytes: 976