akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

template<typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<int>A(N);
    cin >> A;
    int ans = 0;
    FOR(i, 1, N) {
        if (A[i] == A[i - 1]) {
            A[i] = -1;
            ans++;
        }
    }

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

Measured memory_bytes: 256
def main():
    n = int(input())
    h_list = list(map(int, input().split()))
    highest = h_list[0]
    is_able = True

    for h in h_list:
        if highest > h:
            is_able = False
            break

        if highest + 1 < h:
            highest = h - 1

    if is_able:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 85408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

ll calc(ll k){
  if(k == 0){
    return 0;
  }else{
    return 1 + calc(k/10);
  }
}
int main(){
  ll n,m;
  cin >> n >> m;
  vector<pair<ll,ll>> pa(m);
  rep(i,m){
    cin >> t1 >> t2;
    t1 = (ll)pow(10,n - t1);
    pa[i] = make_pair(t1,t2);
    //cout << pa[i].first << pa[i].second << endl;
  }
  ll maxi = (ll)pow(10,n);
  ll ans = -1;
  ll st = maxi / 10;
  rep(i,10000){
    bool can = true;
    rep(j,m){
      if(i == 55){
        //cout << i << " " << pa[j].first << " " << pa[j].second << endl;
      }
      if(i / pa[j].first % (10) != pa[j].second){
        can = false;
        break;
      }
    }
    ll keta = calc(i / 10);
    if(can && keta+1 == n){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, counter2 = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001], sec[100001];
long long int iremono2[100001], check[100001];
std::vector<long long int>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;

bool relation[1000][1000];
int twod[1001][1001];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2, input3;
char rev[100001];


int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int N, M;//はんい
int bfs() {
	queue<pair<int, int>> que;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			twod[i][j] = INF;
		}
	}
	que.push(pair<int, int>(sx, sy));
	twod[sx][sy] = 1;
	while (que.size()) {
		pair<int, int> p = que.front();
		que.pop();
		if (p.first == gy && p.second == gx) {
			break;
		}
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (1 <= nx && nx <= N && 1 <= ny && ny <= M && maze[nx][ny] != '#'&&twod[nx][ny] == INF) {
				que.push(pair<int, int>(nx, ny));
				twod[nx][ny] = twod[p.first][p.second] + 1;
			}
		}
	}
	return twod[gy][gx];
}
vector <int> g[100100];
int main()
{
	rep(i, 5) {
		cin >> iremono[i];
	
	}
	mini = 9999999;
	rep(i, 5) {
		counter = 0;
		rep(j, 5) {
			if (j == i) {
				counter += iremono[j];
			}
			else if (iremono[j] % 10 != 0) {
				counter += ((iremono[j] / 10) + 1) * 10;
			}
			else {
				counter += iremono[j];
			}
		}
		if (mini > counter) {
			mini = counter;
		}
	}
	cout << mini << endl;
}


Measured memory_bytes: 6400
#!/usr/bin/env python3
#AOJ C

while 1:
    N,M = map(int,input().split())
    if N == 0 and M == 0:
        break
    I = [list(map(int,input().split())) for _ in range(M)]
    P = [0 for _ in range(N)]
    mP = [0 for _ in range(N)]
    for i in range(M):
        k = I[i][1]
        if k == 1:
            mP[I[i][2]-1] += I[i][0]
        for j in range(k):
            P[I[i][2+j]-1] += I[i][0]
    maxp = 0
    minp = float("inf")
    for i in range(N):
        if maxp < P[i]:
            maxp = P[i]
            index = i
    for i in range(N):
        if i != index:
            if minp > mP[i]:
                minp = mP[i]
    f = 0
    for i in range(N):
        if i != index:
            if mP[i] == 0:
                f = 1
    if f:
        print(max(P)+1)
    else:
        print(max(P)+1-minp)



Measured memory_bytes: 12888
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, K, A[1234];

int main() {

	cin >> N >> K;
	rep(i, N) cin >> A[i];

	sort(A, A + N);

	ll sum = 0;
	rep(i, K) sum += A[i];

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>            
using namespace std;
#define pb push_back
typedef long long ll;
typedef long double ld;
const int add = 1e9;
const int INF = 2e9;
const ll mod = 1e9 + 7;
const ll mod1 = 3e9 + 19;
const ll mod2 = 3e9 - 71;
const ll longINF = 3e18;
const ll ph = 31;
const ld pi = acos(-1);
const ld eps = 1e-8;
const int M = 1 << 18;

string s;
                                                                                                                                                                                                               
int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);                                                                                         
	cout.tie(0);
	#ifdef LOCAL
        	freopen("input.txt", "r", stdin);
        	freopen("output.txt", "w", stdout);
        #endif
        cin >> s;
        if (s.substr(0, 4) == "YAKI")
        	cout << "Yes";
        else
        	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a=0,b=0,c=0,d=0;
	string s;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		if(s=="AC")
		{
			a++;
		}
		if(s=="TLE")
		{
			c++;
		}
		if(s=="WA")
		{
			b++;
		}
		if(s=="RE")
		{
			d++;
		}

	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;
	

}

Measured memory_bytes: 3596
n,m = (int(i) for i in input().split())
tuple_list = []

for _ in range(n):
  a, b = (int(i) for i in input().split())
  tuple_list.append((a,b))

tuple_sorted = sorted(tuple_list, key=lambda x: x[0])

cost = 0
cans = 0
for t in tuple_sorted:
  if cans + t[1] < m:
    cost += t[0]*t[1]
    cans += t[1]
  else:
    buy_cans = m - cans
    cost += t[0] * buy_cans
    break

print(cost)

Measured memory_bytes: 18900
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

const int mod = 998244353;

long long int mypow(long long int a, long long int b) {
	if (b == 0) return 1;
	if (b == 1) return a;
	long long int res = mypow(a, b / 2);
	res = res * res % mod;
	if (b % 2 == 1) res = res * a % mod;
	return res;
}

vector<long long int> fac;

long long int myc(long long int a, long long int b) {
	return fac[a] * mypow(fac[b], mod - 2) % mod * mypow(fac[a - b], mod - 2) % mod;
}

int main() {
	long long int n, m, k;
	cin >> n >> m >> k;
	fac.push_back(1);
	for (int i = 1; i <= n; i++) {
		fac.push_back(fac.back() * i % mod);
	}
	long long int res = 0;
	for (long long int kk = 0; kk <= k; kk++) {
		long long int ret = myc(n - 1, kk);
		ret = ret * m % mod * mypow(m - 1, n - kk - 1) % mod;
		res += ret;
		res %= mod;
	}
	cout << res << endl;
	
}


Measured memory_bytes: 5284
// from https://atcoder.jp/contests/abc116/submissions/4055058
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
 
bool used[100010];
int main() {
    ll n, k;
    cin >> n >> k;
    pair<ll, ll> sushi[n];
    rep(i, n) {
        ll kind, value;
        cin >> kind >> value;
        sushi[i]={value, kind};
    }
    sort(sushi,sushi + n);
    reverse(sushi,sushi + n);
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    ll sum = 0;
    ll nKinds = 0;
    rep(i, k) {
        sum += sushi[i].first;
        if (used[sushi[i].second]) {
            pq.push(sushi[i].first);
        } else {
            nKinds++;
            used[sushi[i].second] = true;
        }
    }
    ll ans = sum + nKinds * nKinds;
    for (int i=k; i<n; i++) {
        if (!used[sushi[i].second]) {
            used[sushi[i].second] = 1;
            if (pq.size() > 0) {
                ll x = pq.top(); pq.pop();
                sum += sushi[i].first - x;
                nKinds++;
                ans = max(ans, sum + nKinds * nKinds);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int x;
  int gohyakuYen = 0;
  int goYen = 0;
  int happiness;
  cin >> x;
  
  gohyakuYen = x / 500;
  x -= gohyakuYen * 500;
  goYen = x / 5;
  
  happiness = 1000 * gohyakuYen + 5 * goYen;
  
  cout << happiness << endl;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  string x="##";
  for(int j=0;j<W;j++)
    x += '#';
  
  cout << x << endl;
  for(int i=0;i<H;i++){
    string a;
    cin >> a;
    cout << '#' << a << '#' << endl;
  }
  cout << x << endl;
  
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<int> RR(N), LW(N);
  RR.at(N - 1) = 0;
  for (int i = N - 2; i >= 0; i--) {
    if (S.at(i + 1) == 'R') RR.at(i) = RR.at(i + 1) + 1;
    else RR.at(i) = RR.at(i + 1);
  }
  LW.at(0) = 0;
  for (int i = 1; i < N; i++) {
    if (S.at(i - 1) == 'W') LW.at(i) = LW.at(i - 1) + 1;
    else LW.at(i) = LW.at(i - 1);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'W' && RR.at(i) > LW.at(i)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5228
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;


int main() 
{	
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n - h + 1) * (n - w + 1);
}

Measured memory_bytes: 256
import java.util.Scanner;


// 149_c
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int p = 0;

        boolean p_flg = false;

        for (int i = x; i < 100004; i++) {
            for (int j = 2; j < Math.sqrt(i) + 1; j++) {
                if (i % j == 0 && i != 2) {
                    p_flg = false;
                    break;
                }
                p_flg = true;
            }
            if (p_flg) {
                out(i);
                break;
            }
        }
    }

    /*
     * 以下メソッド集
     */

    static long gcd(long a, long b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static int gcd(int a, int b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static void out(String info) {

        System.out.println(info);
    }

    static void out(int info) {

        System.out.println(info);
    }

    static void out(double info) {

        System.out.println(info);
    }

    static void out(long info) {

        System.out.println(info);
    }

}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main() {
  int i, j, n;
  cin >> n;
  for(i = 1; i <= n; i++) {
	if(i % 3 == 0) {
	  cout << " " << i;
	}
	else {
	  j = i;
	  while(j > 0) {
		if(j % 10 == 3) {
		  cout << " " << i;
		  break;
		}
		j /= 10;
	  }//END:while
	}//END:else
  }//END:for
  cout << endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<string> S(N);
  
  for(int i=0; i<N; i++) cin >> S.at(i);
  
  sort(S.begin(), S.end());
  
  int cnt = 0;
  
  for(int i=0; i<N-1; i++){
    if(S.at(i)==S.at(i+1)) cnt++;
  }
  
  cout << N - cnt << endl;
}
 

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

int main()
{
        int n,c=0,d=0;
        cin>>n;
        d=n/1000;
        if(n%1000==0)
                d=d;
        else
                d=d+1;
        c=(d*1000)-n;
        cout<<c<<endl;
        return 0;
}


Measured memory_bytes: 3592
using System;
public class Hello{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        Array.Sort(nums);
        int ans = 0;
        for(int i = 0;i < n * 2;i += 2){
            ans += Math.Min(nums[i],nums[i + 1]);
        }
        Console.WriteLine(ans);
    }
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) for(int i = 0; i < (n); ++i)

using ll = long long;
using namespace std;

constexpr int INF = 2147483647; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	int q = 0, e = 0;
	cin >> n;
	REP(i, n){
		int t;
		cin >> t;
		t %= 4;
		if(t == 0) ++q;
		if(t == 2) ++e;
	}
	if(n / 2 <= q) cout << "Yes\n";
	else if(n - e - q <= q) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;

int main(void)
{
	double a, l, x;

	while (scanf("%lf %lf %lf", &a, &l, &x) != EOF){

		double s = 0, ret = 0;

		s = (a + l + l) / 2.0;
		ret += sqrt(s * (s - a) * (s - l) * (s - l));

		s = (l + l + x) / 2.0;
		ret += (sqrt(s * (s - l) * (s - ((l + x) / 2.0)) * (s - ((l + x) / 2.0))) * 2.0);

		printf("%.08lf\n", ret);
	}

	return 0;
}

Measured memory_bytes: 1240
odds = ['R', 'U', 'D']
evens = ['L', 'U', 'D']

line = input().strip()

for i, c in enumerate(line):
    if (i+1) % 2 == 1:
        if c not in odds:
            print("No")
            exit(0)
    else:
        if c not in evens:
            print("No")
            exit(0)
else:
    print("Yes")
    exit(0)


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

using namespace std;

int main()
{
    long long n,i,k;
    cin>>n;
    long long a[n+1];
    for(i=0;i<n+1;i++)
    {
        a[i]=0;
    }
    for(i=0;i<n-1;i++)
    {
        cin>>k;
        a[k]++;
    }
    for(i=1;i<n+1;i++)
    {
        cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5156
while True:
 a,op,b = map(str,raw_input().split())
 a=int(a)
 b=int(b)

 if(op=='?'):
  break
 if(op=='+'):
  print a+b
 elif(op=='-'):
  print a-b
 elif(op=='*'):
  print a*b
 elif(op=='/'):
  print a/b

Measured memory_bytes: 6440
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn main() {
    input! {
        n: usize,
        tt: [u64;n]
    }
    println!("{}",
        tt.iter().skip(1).fold(tt[0], |a, t| lcm(a,*t)));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007



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

  vector<string> S(0);
  for(int i = 0;i < N;i++) {
      string s;
      cin >> s;

      sort(s.begin(),s.end());
      S.push_back(s);
  }

  sort(S.begin(),S.end());
  S.push_back("aa");

  long long ans = 0,count = 1;

  for(int i = 0;i < N;i++) {
      
      if(S.at(i) == S.at(i + 1)) {
          count++;
      }else {
          ans += count * (count - 1) / 2;
          count = 1;
      }


  }

  cout << ans << endl;



  }

Measured memory_bytes: 5748
from numba import jit, i8, void


@jit(i8(i8))
def g(n):
    return n * (n + 1) // 2


@jit(i8(i8))
def solve(n):
    ans = 0
    for i in range(1, n + 1):
        ans += i * g(n // i)
    return ans

def main():
    print(solve(int(input())))


main()


Measured memory_bytes: 109076
'use strict';

function main(input) {
  const arr = input.split('\n');
  const nums = arr[0];
  const k = parseInt(arr[1]);
  let vals = nums.split(' ').map(num => parseInt(num));

  for (let i = 0; i < k; i++) {
    vals = doubleMax(vals);
  }

  console.log(vals.reduce((prev, current) => prev + current));
}

function doubleMax(vals) {
  const result = [...vals];
  const max = Math.max(...vals);
  const index = result.indexOf(max);
  result[index] = max * 2;
  return result;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22204
#include <bits/stdc++.h>
#define ll long long int
#define INF 1000000000000
#define MOD 1000000007
#define DEBUG(x) cerr<<'>'<<#x<<':'<<x<< endl
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    ans += (N) * (N - 1) / 2;
    ans += (M) * (M - 1) / 2;
    cout << ans << endl;    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}
int keta(int a) {
	return to_string(a).size();
}

signed main() {
	int n,a,b;
	cin>>n>>a>>b;
	if((b-a)%2){
		cout<<min((a+b-1)/2,(n*2-a-b+1)/2)<<endl;
	}
	else cout<<(b-a)/2<<endl;
}




Measured memory_bytes: 256
w,h,n = map(int,input().split())
a = [0,0] #左下の座標
b = [w,h] #右上の座標

for i in range(n):
    x,y,z = map(int,input().split())
    if z==1 and a[0]<x:
        a[0] = x
    elif z==2 and b[0]>x:
        b[0] = x
    elif z==3 and a[1]<y:
        a[1] = y
    elif z==4 and b[1]>y:
        b[1] = y
if a[0]<b[0] and a[1]<b[1]:
    print((b[0]-a[0])*(b[1]-a[1]))
else:
    print(0)

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

import math

s = input()
num = s.split(" ")
N = int(num[0])
A = int(num[1])
B = int(num[2])

X = math.floor(N/(A+B))
resid = N-(A+B)*X

if A>=resid:
  add_val = resid
else:
  add_val = A

print(A*X + add_val)


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

int main() {
  int H, W;
  cin >> H >> W;

  for (int i = 0; i < W + 2; i++) cout << '#';
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    vector<string> vec(3, "#");
    cin >> vec.at(1);
    for (int i = 0; i < 3; i++) cout << vec.at(i);
    cout << endl;    
  }
  
  for (int i = 0; i < W + 2; i++) cout << '#';
  cout << endl;

}


Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        static int[][] D = {
        		{1, 1, 1},
        		{-1, 1, 1},
        		{1, -1, 1},
        		{1, 1, -1},
        		{1, -1, -1},
        		{-1, 1, -1},
        		{-1, -1, 1},
        		{-1, -1, -1},
        };
        
        int N, M;
        List<long[]> cake = new ArrayList<>();
        long ans = 0;
        
        void solve(InputReader in, PrintWriter out) {
        	N = in.nextInt();
        	M = in.nextInt();
        	
        	for (int i = 0; i < N; ++i) {
        		long[] item = {
	        		in.nextLong(),
	        		in.nextLong(),
	        		in.nextLong()
        		};
        		cake.add(item);
        	}
        	
        	for (int[] d : D) {
        		Collections.sort(cake, (a, b) -> 
        			Long.signum(
        					(b[0]*d[0] + b[1]*d[1] + b[2]*d[2]) - 
        					(a[0]*d[0] + a[1]*d[1] + a[2]*d[2]))
        		);
        		long cur = 0;
        		for (int i = 0; i < M; ++i) {
        			cur += cake.get(i)[0]*d[0] + cake.get(i)[1]*d[1] + cake.get(i)[2]*d[2];
        		}
        		ans = Math.max(cur, ans);
        	}
        	
        	out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

        long[] nextLongArray(int n) {
        	long[] arr = new long[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextLong();
        	}
        	return arr;
        }
    }
}


Measured memory_bytes: 27604
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    use std::collections::BTreeMap;
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut c = BTreeMap::new();
    for _ in 0..1 << n {
        let s: usize = scan(tokens);
        *c.entry(s).or_insert(0) += 1;
    }
    let mut q: Vec<usize> = vec![0; n + 1];
    let mut p: Vec<usize> = vec![0; n + 1];
    q[n] = 1;
    for &k in c.values().rev() {
        let mut k = k;
        for i in (0..n + 1).rev() {
            if k <= q[i] {
                p[i] = k;
                q[i] -= k;
                k = 0;
            } else {
                k -= q[i];
                p[i] = q[i];
                q[i] = 0;
            }
        }
        if k > 0 {
            println!("No");
            return;
        }
        let mut cumsum = 0;
        for i in (0..n + 1).rev() {
            q[i] += cumsum;
            cumsum += p[i];
        }
    }
    println!("Yes");
}


Measured memory_bytes: 14712
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 50 + 10;

int n, m, k[N];
int s[N][N], p[N];

int32_t main(){_

   cin>>n>>m;

   for (int i = 0; i < m; ++i)
   {
      cin>>k[i];
      for (int j = 0; j < k[i]; ++j)
      {
         cin>>s[i][j];
         --s[i][j];
      }
   }

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

   int ans = 0;
   for (int i = 0; i < (1<<n); ++i)
   {
      vector<int> which_on(n);
      for (int j = 0; j < n; ++j)
      {
         if (i&(1<<j)){
            which_on[j] = 1;
         }
         else{
            which_on[j] = 0;            
         }
      }

      int cnt = 0;
      for (int x = 0; x < m; ++x)
      {
         int per = 0;
         for (int y = 0; y < k[x]; ++y)
         {
            per ^= (which_on[s[x][y]]);
         }
         if(per == p[x]){
            cnt++;
         }
      }
      if(cnt == m)ans++;
   }

   cout<<ans;

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

Measured memory_bytes: 256
#include <iostream>
#include<string.h>
using namespace std;
int main()
{
    long i; char c;
    int n,sum=0;
    string s;
    cin>>s;
    for( i=0;s[i]!='\0';++i)
    {
        c=s[i];
        n=c-'0';
        sum=sum+n;
    }
    if(sum%9==0)
    cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3712
#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(){
	int a[N];
	f(i, N)a[i] = 0;
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %d", &x,&y);

	if(x%2==1&&y%2==1)printf("Yes\n");
	else printf("No\n");


	return 0;
}

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

int main()
{
  long long K, cnt=1, cnt2=0, cnt3=1, cnt4=1, A=1;
  string S;
  cin >> S >> K;
  rep(i, S.size()-1){
    if(S.at(i)!=S.at(i+1)) A=0;
  }
  if(A==1) cnt2=K*S.size()/2;
  else if(A==0 && S.at(0)!=S.at(S.size()-1)){
    rep(i,S.size()-1){
      while(1){
        if(i==S.size()-1) break;
        if(S.at(i)==S.at(i+1)){
          cnt++;
          i++;
        }
        else break;
      }
      cnt2=cnt2+cnt/2;
      cnt=1;
    }
    cnt2=cnt2*K;
  }
  else if(A==0 && S.at(0)==S.at(S.size()-1)){
    rep(i, S.size()-1){
      if(S.at(i)==S.at(i+1)) cnt3++;
      else break;
    }
    for(int i=S.size()-1; i>0; i--){
      if(S.at(i)==S.at(i-1)) cnt4++;
      else break;
    }
    for(int i=cnt3; i<S.size()-cnt4; i++){
      while(1){
        if(i==S.size()-cnt4-1) break;
        if(S.at(i)==S.at(i+1)){
          cnt++;
          i++;
        }
        else break;
      }
      cnt2=cnt2+cnt/2;
      cnt=1;
    }
    cnt2=cnt2*K+(cnt3+cnt4)/2*(K-1)+cnt3/2+cnt4/2;      
  }
  cout << cnt2 << endl;
}

Measured memory_bytes: 256
#
# abc053 b
#
import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


def resolve():
    s = input()

    S = 0
    E = len(s)
    for i in range(len(s)):
        if s[i] == "A":
            S = i
            break
    for j in reversed(range(len(s))):
        if s[j] == "Z":
            E = j+1
            break
    print(len(s[S:E]))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """QWERTYASDFZXCV"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """ZABCZ"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """HASFJGHOGAKZZFEGA"""
        output = """12"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 5988
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

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


func main(){
	sc.Split(bufio.ScanWords)
	var res int
	res=0
	for i:=0; i<3; i++{
		res+=nextInt()
	}
	if res>=22{
		fmt.Println("bust")
	}else{
		fmt.Println("win")
	}
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	string s;
	cin >> s;
	int n = s.size();
	cout << s.substr(0, n - 8) << endl;
}


Measured memory_bytes: 768
#include<stdio.h>
int main(void)
{
	int n,a,b,c;
	scanf("%d %d",&n,&a);
	b=n%500;
	c=b-a;
	if(0>=c){
			printf("Yes\n");
	}
	else{
			printf("No\n");
	}
	return 0;
}


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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    queue<int> q[3];
    rep(i,3){
        string s;
        cin >> s;
        for(char c : s){
            q[i].push(c - 'a');
        }
    }
    
    int now = 0;
    while(!q[now].empty()){
        int next = q[now].front();
        q[now].pop();
        now = next;
    }
    
    cout << (char)(now + 'A') << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    input=sys.stdin.readline
    h,n=map(int,input().split())
    a=[]
    b=[]
    for i in range(n):
        ai,bi=map(int,input().split())
        a.append(ai)
        b.append(bi)
    inf=max(b)*h
    
    #dp[i]=体力をi減らすために消耗する魔力の最小値
    dp=[inf]*(h+max(a))
    dp[0]=0
    for i in range(h):
        for j in range(n):
            dp[i+a[j]]=min(dp[i+a[j]],dp[i]+b[j])
    print(min(dp[h:]))
    
if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

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

    ll A,B,C,D; cin >> A >> B >> C >> D;

    ll l = C*D/gcd(C,D);

    //cout <<l << " " << gcd(C,D) << endl;

    ll s = B/C-(A-1)/C + B/D-(A-1)/D - (B/l-(A-1)/l);

    cout << (B-A+1)-s << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
#define mod 998244353
#define int long long
using namespace std;
const int N=1e6+100;
int n,a,b,k,fac[N],inv[N],ans;
int C(int n,int m){return fac[n]*inv[m]%mod*inv[n-m]%mod;}
void add(int &a,int b){a=(a+b)%mod;}
int m_pow(int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) ans=(ans*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return ans;
}
signed main()
{
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	fac[0]=1;
	for (int i=1;i<=3*n;i++) fac[i]=(fac[i-1]*i)%mod;
	inv[3*n]=m_pow(fac[3*n],mod-2);
	for (int i=3*n-1;i>=0;i--) inv[i]=(inv[i+1]*(i+1))%mod;
	for (int i=0;i<=n;i++)
	{
		if (i*a>k) break;
		if ((k-i*a)%b!=0) continue;
		int j=(k-i*a)/b,k=max(i+j-n,0ll);
		if (k>min(i,j) || k>n) continue;
		// printf("%lld %lld %lld\n",i,j,k);
		// printf("%lld %lld %lld\n",C(n,k),C(n-k,i-k),C(n-k,j-k));
		add(ans,C(n,i)*C(n,j)%mod);
		// printf("%lld\n",ans);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 17836
#include<stdio.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
long long n, k,s=0,
		w[100000];
long long f(long long a);
int main() {	
	S(lld, n), S(lld, k);
	int i;
	for (i = 0; i < n; i++) scanf("%lld", w + i), s += w[i];
	long long a = s / k;
	while (f(a) != n)a++;
	P(lld, a);
	return 0;
}

long long f(long long a){
	int x = 0;
	int i;
	for (i = 0; i < k; i++) {
		long long s = 0;
		while (s + w[x] <= a) {
			s += w[x++];
			if (x >= n)return n;
		}
	}
	return x;
}

Measured memory_bytes: 1380
z = input()
d = {}
c = 0
 
L = ['S','H','C','D']
for i in L:
    for j in range(1,14):
        d[i] = d.get(i,[]) + [j]
 
 
while c < z:
    x = raw_input().split()
    d[x[0]].remove(int(x[1]))
    c += 1
 
 
for i in L:
    for j in sorted(d[i]):
        print i + " " + str(j)

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

#define int long long

int32_t main(){
	int n , m ;
	cin >> n >> m ;
	int a[n] ;
	for(int i = 0 ; i < n; i++) cin >> a[i] ;
	int sum = accumulate(a,a+n,0LL) ;
	int count = 0 ;
	for(int i = 0 ; i < n ; i++){
		if(4*m*a[i] >= sum){
			count++ ;
		}
	}
	cout << (count >= m? "Yes":"No") ;
	return 0 ;
}


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

using namespace std;

int main() {

  int N , X;

  cin >> N >> X;

  vector <int> L(N);

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

    cin >> L.at(i);

  }

  int count = 0;

  int bounce = 0;

  while(count <= N - 1 && bounce <= X){

    bounce += L.at(count);

    count++;

  }

  if(bounce <= X){

    cout << count + 1 << endl;

  }

  else{

    cout << count << endl;
    
  }

}


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

int main() {
  string s;
  char c[4];
  cin >> s;
  for (int i = 0; i < 4; i++) {
      c[i] = s.at(i);
  }
  sort(c, c + 4);
  if (c[0] == c[1] && c[2] == c[3] && c[1] != c[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int Insertion(vector<int> a, int N) {
    for(int i=0; i<N-1; i++) {
        for(int j=i+1; j>=1; j--) {
            if(a.at(j-1)>a.at(j)) {
                int tmp;
                tmp = a.at(j);
                a.at(j) = a.at(j-1);
                a.at(j-1) = tmp;
            }
        }
        for(int i=0; i<N; i++) {
            cout<<a.at(i);
            i==N-1 ? cout<<endl: cout<<' ';
        }
    }
}

int main() {
    int N;  cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin>>a.at(i);
  	for(int i=0; i<N; i++) {cout<<a.at(i);i==N-1? cout<<endl: cout<<' ';}
    Insertion(a, N);
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
int main()
{
	string str;
	getline(cin, str);
	istringstream iss(str);
	iss >> str;
	int N = stoi(str);
	iss >> str;
	int T = stoi(str);
	int minC = 1001;
	int minT = 1001;
	for (int i = 0; i < N; i++) {
		int c, t;
		getline(cin, str);
		iss = istringstream(str);
		iss >> str;
		c = stoi(str);
		iss >> str;
		t = stoi(str);
		if (t <= T && c < minC) {
			minC = c;
			minT = t;
		}
	}
	if (minC == 1001) {
		cout << "TLE" << endl;
	}
	else {
		cout << minC << endl;
	}
	return 0;

}


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

int main(){
    int n,dx,dy;
    cin>>n;
    while(n--){
        int x=0,y=0;
        int ax,ay,mx=0;
        while(cin>>dx>>dy,dx|dy){
            x+=dx,y+=dy;
            if(mx<x*x+y*y||mx==x*x+y*y&&ax<x){
                mx=x*x+y*y,ax=x,ay=y;
            }
        }
        cout<<ax<<" "<<ay<<endl;
    }
    return 0;
}


Measured memory_bytes: 3012
N = int(input())
S = input()

if N % 2 == 1:
    print('No')
else:
    long = len(S)
    # print(long)
    # print(S[0:long//2] , S[long//2:long])
    if S[0:long//2] == S[long//2:long]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
int a[110];

int main()
{
	scanf("%d", &n);
	for (int i = 0 ; i < n ; i++)
		scanf("%d", &(a[i]));
		
	bool isAccepted = true;
	for (int i = 0 ; i < n ; i++)
	{
		if (a[i] % 2 == 0) {
			if ((a[i] % 3 == 0) || (a[i] % 5 == 0))
			{
				continue;
			} else {
				isAccepted = false;
				break;
			}
		}
	}
	
	if (isAccepted) 
		printf("APPROVED\n");
	else
		printf("DENIED\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

ll a[300000];
ll Max[300000], Min[300000];
signed main() {
	ll n; scanf("%lld", &n);
	rep(i, 3 * n)scanf("%lld", &a[i]);
	priority_queue<int, vector<int>,greater<int>>p;
	ll sum = 0;
	rep(i, n)p.push(a[i]), sum += a[i];
	Max[n - 1] = sum;
	for (int i = n; i < 2 * n; i++) {
		if (p.top() < a[i]) {
			sum += a[i] - p.top();
			p.pop(); p.push(a[i]);
		}
		Max[i] = sum;
	}
	sum = 0;
	priority_queue<int>q;
	for (int i = 3 * n - 1; i >= 2 * n; i--)sum += a[i], q.push(a[i]);
	Min[2 * n] = sum;
	for (int i = 2 * n - 1; i >= n; i--) {
		if (q.top() > a[i]) {
			sum -= q.top() - a[i];
			q.pop(); q.push(a[i]);
		}
		Min[i] = sum;
	}
	ll ans = LLONG_MIN;
	for (int i = n - 1; i < 2 * n; i++) {
		ans = max(ans, Max[i] - Min[i + 1]);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 6904
n = int(input())
c = input()
l = 0
j = 0
a = [0]*n
b = [0]*n
for i in range(n):
  if(c[i]=='W'):
    a[l] =i+1
    l +=1
l = 0
for i in range(n-1,0,-1):
  if(c[i]=='R'):
    b[j] = i+1
    j +=1
j = 0
while(a[l] < b[l] and not(a[l]==0 or b[l] == 0)):
      a[l]=0
      b[l]=0
      l+=1
      j+=1
print(j)

Measured memory_bytes: 18624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#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 <iomanip>
#include <numeric>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;
#define INF_I  			(int)100000009;

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

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

	int H,W;
	int h,w;

	cin >> H >> W;
	cin >> h >> w;

	cout << H*W - (W*h + H*w - h*w) << endl;


	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define pb push_back
#define mk make_pair

using namespace std;
typedef long long ll;
ll mod = 998244353;
int main() {
	fastio;
	ll n;
	cin>>n;
	ll minn = 1e9;
	ll sum = 0;
	for(ll i=0;i<n;i++){
		ll x;cin>>x;
		if(x%10){
			minn = min(minn,x);
		}
		sum += x;
	}
	if(minn<1e9){
		if(sum%10){
			cout<<sum<<"\n";
		}
		else{
			cout<<sum-minn<<"\n";
		}
	}
	else{
		cout<<0<<"\n";
	}
}






Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int t(int a[], int n, int s){
int flag = 0;
for(int i = 0; i < n; i++){
if(a[i] == s){
flag = 1;
break;
}
}
return flag;
}
int main()
{
int n,x,y,z;
int a[100];
int b[100];
int c[100];
cin>>n;
cin>>x;
for(int i=0;i<x;i++)
{
cin>>a[i];
}
cin>>y;
for(int i=0;i<y;i++)
{
cin>>b[i];
}
cin>>z;
for(int i=0;i<z;i++)
{
cin>>c[i];
}
int count = 0;
for(int i = 1; i <= n; i++){
if(((t(a,x,i) == 0) && (t(c, z, i) == 1))){
count++;
}
else if((t(b, y, i) == 1) && (t(c, z, i) == 1)){
count++;
}
}


cout << count << endl;
return 0;
}

Measured memory_bytes: 3116