akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll n, ans;
    ans = 0;
    cin >> n;

    for(ll i = 1; i <= n; i++) {
        ll y = n / i;
        ans += y * (y + 1) * i / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3568
n=int(input())
l=list(map(int,input().split()))
f=0
h=0
for i in range(n-1):
    if l[i]-l[i+1]>=2:
        f+=1
    if l[i]-l[i+1]==1:
        if h>=l[i]:
            f+=1
        h=l[i+1]
if f>0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 14396
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define int long long
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<20, mod = 1e9 + 7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct node
{
	int sum, lazy;

	node() {sum = -(1<<30); lazy = 0;}
	node(int val)
	{
		sum = val;
		lazy = 0;
	}
};

node temp, broken;

node merge(node l, node r)
{
	temp.sum = max(l.sum, r.sum);
	temp.lazy = 0;
	return temp;
}

struct segment_tree
{
	node tr[4 * (1<<18)];

	void push(int l, int r, int idx)
	{
		if(tr[idx].lazy)
		{
			tr[idx].sum += tr[idx].lazy;

			if(l != r)
			{
				tr[2 * idx + 1].lazy += tr[idx].lazy;
				tr[2 * idx + 2].lazy += tr[idx].lazy;
			}

			tr[idx].lazy = 0;
		}
	}

	void init(int l, int r, int idx)
	{
		if(l == r)
		{
			tr[idx] = -l;
			return;
		}

		int mid = (l + r) >> 1;
		init(l, mid, 2 * idx + 1);
		init(mid + 1, r, 2 * idx + 2);

		tr[idx] = merge(tr[2 * idx + 1], tr[2 * idx + 2]);
	}

	void update(int qL, int qR, int val, int l, int r, int idx)
	{
		push(l, r, idx);

		if(qL > r || l > qR)
			return;

		if(qL <= l && r <= qR)
		{
			tr[idx].lazy += val;
			push(l, r, idx);
			return;
		}

		int mid = (l + r) >> 1;
		update(qL, qR, val, l, mid, 2 * idx + 1);
		update(qL, qR, val, mid + 1, r, 2 * idx + 2);

		tr[idx] = merge(tr[2 * idx + 1], tr[2 * idx + 2]);
	}

	node query(int qL, int qR, int l, int r, int idx)
	{
		push(l, r, idx);

		if(l > qR || r < qL)
			return broken;

		if(qL <= l && r <= qR)
			return tr[idx];

		int mid = (l + r) >> 1;
		return merge(query(qL, qR, l, mid, 2 * idx + 1), query(qL, qR, mid + 1, r, 2 * idx + 2));
	}
};
int a[maxn], n, m;
vector<int> cl[maxn];
int op[maxn];
signed main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	for(int l, r, i = 0; i < n; i++) {
		cin >> l >> r;
		cl[r].push_back(l);
		op[l]++;
	}
	segment_tree s;
	s.init(0, m+1, 1);
	int curOP = 0, duh = max(n-m, (int)0);
	for(int i = 0; i <= m+1; i++) {
		curOP += op[i];
		if(i) {
			s.update(0, i-1, -op[i], 0, m+1, 1);
		}
		//cout << curOP << " | " << i << " : ";
		//for(int j = 0; j <= i; j++) cout << s.query(j, j, 0, m+1, 1).sum << " "; cout << endl;
		duh = max((ll)duh, curOP + s.query(0, i, 0, m+1, 1).sum - (m+1-i));
		for(auto &j : cl[i]) {
			if(j) s.update(0, j-1, 1, 0, m+1, 1);
			curOP--;
		}
	}
	//cout << "Matching : " << n-duh << endl;
	cout << duh << endl;
}



Measured memory_bytes: 50068
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

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

const int MAX_N = 300001;
const ll MOD = 1000000007;

ll dp[MAX_N+1];

int main() {
    int n;
    cin >> n;
    if(n == 3) {
        cout << "2\n1 3\n2 3\n";
        return 0;
    }

    vector<Pii> edges;

    int m = n/2*2;
    for(int i=1;i<=m;++i) {
        for(int j=i+1;j<=m;++j) {
            if(j == m+1-i) continue;
            edges.emplace_back(i, j);
        }
    }
    if(n % 2) {
        for(int i=1;i<=m;++i) {
            edges.emplace_back(i, n);
        }
    }

    cout << edges.size() << "\n";
    for(Pii e: edges) cout << e.first << " " << e.second << "\n";
}


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

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

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    int a, b, c;
    cin >> a >> b >> c;

    vector<int> num;

    num.push_back(a);
    num.push_back(b);
    num.push_back(c);

    int ans = 0;

    int check = 0;
    roop(i, 3) if(num[i] % 2 == 0) check++;

    if(check == 1){
        roop(i, 3) if(num[i] % 2 == 1) num[i]++;
        ans++;
    }
    if(check == 2){
        roop(i, 3) if(num[i] % 2 == 0) num[i]++;
        ans++;
    }

    int maxValue = max({num[0], num[1], num[2]});
    roop(i, 3){
        ans += (maxValue - num[i])/2;
    }

    cout << ans << endl;



    return 0;
}

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

int main()
{
    list<int> stack;

    for (int n; cin >> n;)
        if (n == 0) {
            cout << stack.front() << endl;
            stack.pop_front();
        } else
            stack.push_front(n);

    return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i  ;
        //inv[i] = MOD - inv[MOD%i] * (MOD / i)  ;
        //finv[i] = finv[i - 1] * inv[i]  ;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] / fac[k] / fac[n - k]  ;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[400010];
    // 前処理
    //COMinit();
    
    for (int i=0;i<n;i++) {
        cin >> a[i];
    }
    map<int, ll> m;
    for (int i=0;i<n;i++) {
        m[a[i]] = m[a[i]] + 1;
    }
    ll sum = 0;
    for (const auto& x : m) {
        sum += x.second * (x.second-1) / 2;
    }
    for (int i=0; i<n; i++) {
        // if (even[a[i]]){
        //     cout << sum - COM() << "\n";
        // } else {
        //     cout << sum << "\n";
        // }
        // if (m[a[i]] - 1 >= 0) {
            ll res = sum - m[a[i]] * (m[a[i]]-1)/2  + (m[a[i]]-2) * (m[a[i]]-1)/2;
            cout << res << "\n";
        // } else {
        //     cout << sum << "\n";
        // }
        
    }

}

Measured memory_bytes: 10368
#include <iostream>
using namespace std;
int main()
{

	int a[1000];
	char b[1000];

	cin >> b;

	for (int i = 0; b[i] != '\0'; i++) {
		a[i] = b[i];
		if (b[i] != 'A' && b[i] != 'B' && b[i] != 'C') a[i] -= 3;
		else a[i] += 23;
		b[i] = a[i];
	}

	for (int i = 0; b[i] != '\0'; i++){
		cout << b[i];
	}

	cout << endl;

}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ios::sync_with_stdio(0),
	cin.tie(0), cout.tie(0);
 
	int a,b;
	while(cin >>a){
		cin >>b;
		if(b%2==1){
			cout <<"No"<<'\n';
		}
		else if(a*4<b){
			cout <<"No"<<'\n';
		}
		else if(a*2>b){
			cout <<"No"<<'\n';
		}
		else{
			cout <<"Yes"<<'\n';
		}
	}
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string s;cin>>s;
  ll k;cin>>k;
  int n=s.size();
  ll A=0,B=0;
  if(s==string(n,s[0])){
    cout<<n*k/2<<endl;
    return 0;
  }
  rep(i,n-1){
    if(s[i%n]==s[(i+1)%n]){
      A++;
      i++;
    }
  }
  rep(i,n*2-1){
    if(s[i%n]==s[(i+1)%n]){
      B++;
      i++;
    }
  }
  cout<<(A+(B-A)*(k-1))<<endl;
  return 0;
}

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

#define B



#ifdef A

int main(void) {
	int n;

	cin >> n;

	if (n % 10 == 9)
	{
		cout << "Yes" << endl;
		return 0;
	}
	n /= 10;
	if (n % 10 == 9)
	{
		cout << "Yes" << endl;
		return 0;
	}

	cout <<"No" <<endl;
	return 0;
}
#endif // A



#ifdef B
const int MAX = 100000;
int main(void) {

	int n;
	int cunt = 0;
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		int s, e;
		cin >> s >> e;
		cunt += e - s + 1;
	}
	cout << cunt << endl;


	return 0;
}

#endif // B

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i++)
#define reprev(i, n) reprrev(i, 0, n)

#define PI M_PI
#define INF 100000000
#define NINF -100000000

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;



int main()
{
	int N;
	cin >> N;
	int ans = 0;
	int l, r;

	rep(i, N) {
		cin >> l >> r;
		ans += r - l + 1;
	}

	cout << ans << endl;

	return 0;
}



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

namespace ABC_118A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b,c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            if (b % a == 0)
                 Console.WriteLine(a + b);

            else
                Console.WriteLine(b - a);

            
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main(){
  long int a,b,c,d;
  cin>>a>>b>>c;
  for(int i=0;a+i<=b;i++){
    if(c%(a+i)==0){
      d+=1;
    }
  }
  cout<<d<<endl;
  return 0;
}

Measured memory_bytes: 3116
#include "bits/stdc++.h"
using namespace std;

int main(){
	string s;
	cin>>s;
	long long int ans=0;
	
	for(int i=0;i<s.size();i++){
		ans+=s[i]-'0';
	}
	
	long long tmp=(s.size()-1)*9;
	tmp+=s[0]-'0';
	tmp-=1;
	ans=max(ans,tmp);
	cout<<ans<<endl;
	
	
	
	
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

template<class T>
vector<T> makeDigits(ll N, const vector<T>& digits){
  ll M = digits.size();
  ll sum = 1;
  ll p = M;
  ll keta = 1;
  while(true){
    if(sum <= N && N < sum + p) break;
    sum += p;
    p *= M;
    keta++;
  }
  N -= sum;
  p /= M;
  vector<T> ret;
  while(keta--){
    ret.push_back(digits[N/p]);
    N %= p;
    p /= M;
  }
  return ret;
}


int main(){
  ll N;
  cin >> N;
 
  vector<char> digits;
  rep(i,26) digits.push_back('a' + i);

  vector<char> ret = makeDigits<char>(N, digits);
  rep(i,ret.size()){
    cout << ret[i];
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
	int i,j,k,n;
	cin>>n;
	double dp[n+1][n+1];
	double p[n+1];
	for(i=1;i<=n;i++){
	    cin>>p[i];
	}
	if(n==1){
	    cout<<p[1];
	    return 0;
	}
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(i=1;i<=n;i++){
	    for(j=0;j<=i;j++){
	        if(j!=0)
	            dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
	        else
	            dp[i][j]=dp[i-1][j]*(1-p[i]);
	    }
	}
	double ans=0;
	for(i=(n+1)/2;i<=n;i++){
	    ans=ans+dp[n][i];
	}
	cout<<setprecision(10)<<ans;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int N,M; cin>>N>>M;
  vector<int> S(N,0);
  rep(i,M){
    int a,b; cin>>a>>b;
    S.at(a-1)++;
    S.at(b-1)++;
  }
  rep(i,N){
    cout<<S.at(i)<<endl;
  }
}


Measured memory_bytes: 3628
/*input
2
10 10
*/
 
#include <unordered_map>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define ar array
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int r; cin >> r; while(r--)
#define MP make_pair
#define PI acos(-1)
typedef pair<long long, long long> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
 
#define M(x) ((x)%(1000000007))
 
 int64 fact(int n) {
   int64 count = 1;
   for(int64 i = 1;i<=n;i++){
   		count = M(count * i);
   }
   return count;
}
 
 
 
int main() {
	int n;
	cin>>n;
	int64 arr[n];
	rep(i,n){
		int a;
		cin>>a;
		arr[i] = a;
	}
	int64 dp[n];
	dp[0] = 0;
	dp[1] = abs(arr[1]-arr[0]);
	for(int i = 2;i<n;i++){
		dp[i] = min(dp[i-1] + abs(arr[i-1]-arr[i]),dp[i-2] + abs(arr[i]-arr[i-2]));
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 5152
/*
	"We know what we are, but know not what we may be."
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

/*
	"You never know how strong you are until being strong is the only choice you have."
*/

long long dp[101][10001];

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

/*
	"With self-discipline most anything is possible."
*/
	
	long long n; cin >> n;
	
	long long W = 0;
	vector<long long> a(n + 1);
	for(long long i = 1; i <= n; i++){
		cin >> a[i];
		W += a[i];	
	}
		
	long long ans = 0;
	for(long long i = 1; i <= n; i++){
		for(long long j = 0; j <= W; j++){
			dp[i][j] = dp[i - 1][j];
			if(j - a[i] >= 0){
				dp[i][j] = max(dp[i][j], dp[i - 1][j - a[i]] + a[i]);
			}
			if(dp[i][j] % 10 != 0){
				ans = max(ans, dp[i][j]);
			}
		}
	}
	cout << ans;
	return 0;
}

/*
	"Reach for it. Push yourself as far as you can."
*/


Measured memory_bytes: 8064
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		String A=scan.next();
		String B=scan.next();
		String C=scan.next();
		int ac=0,bc=0,cc=0,c=0;
		for(;;) {
			if(c==0) {
				ac++;
				if(ac==A.length()+1) {
					System.out.println("A");
					break;
				}
				switch(A.charAt(ac-1)) {
				case 'a':c=0;break;
				case 'b':c=1;break;
				case 'c':c=2;break;
				}
			}if(c==1) {
				bc++;
				if(bc==B.length()+1) {
					System.out.println("B");
					break;
				}
				switch(B.charAt(bc-1)) {
				case 'a':c=0;break;
				case 'b':c=1;break;
				case 'c':c=2;break;
				}
			}if(c==2) {
				cc++;
				if(cc==C.length()+1) {
					System.out.println("C");
					break;
				}
				switch(C.charAt(cc-1)) {
				case 'a':c=0;break;
				case 'b':c=1;break;
				case 'c':c=2;break;
				}
			}
		}
	}
}

Measured memory_bytes: 22868
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
     
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    


int main() {
  ll x,y,z=0,k,n,m,h,w,ans=0,sum=0,Max=-1,Min=1e9+1;
  bool ok = true;
  string s,t,r;
  cin >> n;
  for(int i=1; i<=n;i++){
    for(int j=1; j<=n;j++){
      for(int k=1; k<=n;k++){
          ans += gcd(gcd(i,j),k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
N, M = [int(i) for i in input().split()]
ab = []

possible = False
for _ in range(M):
    ab.append([int(i) for i in input().split()])
    

c = []
e = []
for d in ab:
    if d[1] == N:
        c.append(d[0])
    elif d[0] == 1:
        e.append(d[1])

if len(set(c) & set(e)):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 48572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	ll X,Y; cin >> X >> Y;
	if(X==1&&Y==1){
		cout << 300000+300000+400000 << endl;
		return 0;
	}
	ll ans = 0;
	if(X==1) ans += 300000;
	if(X==2) ans += 200000;
	if(X==3) ans += 100000;
	if(Y==1) ans += 300000;
	if(Y==2) ans += 200000;
	if(Y==3) ans += 100000;
	cout << ans << endl;




    return 0;
}

Measured memory_bytes: 256
program keyence2019B
    implicit none
    integer(8)::i,j,flg,S_len,cur,diff_count,diff_flg
    character(100)::S
    character(7)::mask="keyence"
    read(5,*)S
    S_len=len_trim(S)
    flg=1
    !1分割
    do i=1,S_len-6
        if(S(i:i+6)==mask)then
            flg=0
        end if
    end do

    !2分割
    do i=1,6
        if(S(1:i)==mask(1:i).and.S(S_len-6+i:S_len)==mask(i+1:7))then
            flg=0
            exit
        end if
    end do
    if(flg==0)print'(A)',"YES"
    if(flg==1)print'(A)',"NO"
end program keyence2019B

Measured memory_bytes: 256
n, m = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(m)]
D.sort()
result = 1
checker = D[0][1]
for i in range(m):
    if checker <= D[i][0]:
        result += 1
        checker = D[i][1]
    elif checker > D[i][1]:
        checker = D[i][1]
print(result)

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

using namespace std;

#define ll  long long
#define f first
#define s second

const int N = 1e6+5;

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


    ll a,b,c,d,ans=-2e18;
    cin >> a >> b >> c >> d;

    if (b >= 0 && a <= 0) ans=0;
    if (d >= 0 && c <= 0) ans=0;

    //mx pos
    ans = max(ans , b*d);

    //mx neg
    ans = max(ans , a*c);

    //mn neg
    if (b < 0 && c > 0)
    {
        ans = max(ans , b*c);
    }
    if (d < 0 && a > 0)
    {
        ans = max(ans , a*d);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	long int i, j, index;
	long int n;
	long int sum;
	long int left, right;
	long int work, flg;
	long int ans;
	char str[500001];
	
	scanf("%s", str);
	
	n = strlen(str);
	
	ans = 0;
	left = 0;
	right = 0;
	
	flg = 0;
	
	if(str[0] == '<') {
		left = 1;
		for(i = 1; i < n; i++) {
			if( (flg == 0) && (str[i] == '<') ) {
				left++;
			} else if( (flg == 0) && (str[i] == '>') ) {
				flg = 1;
				right++;
			} else if( (flg == 1) && (str[i] == '>') ) {
				right++;
			} else if( (flg == 1) && (str[i] == '<') ) {
				flg = 0;
				//printf("%ld %ld ", left, right);
				if(left > right) {
					ans += ( left * (left + 1) / 2 );
					ans += ( right * (right - 1) / 2 );
				} else if(left < right) {
					ans += ( right * (right + 1) / 2 );
					ans += ( left * (left - 1) / 2 );
				} else {
					ans += ( left * (left + 1) / 2 );
					ans += ( left * (left - 1) / 2 );
				}
				//printf("%ld\n", ans);
				left = 1;
				right = 0;
			}
		}
	} else {
		right = 1;
		for(i = 1; i < n; i++) {
			if( (flg == 0) && (str[i] == '<') ) {
				left++;
			} else if( (flg == 0) && (str[i] == '>') ) {
				flg = 1;
				right++;
			} else if( (flg == 1) && (str[i] == '>') ) {
				right++;
			} else if( (flg == 1) && (str[i] == '<') ) {
				flg = 0;
				//printf("%ld %ld ", left, right);
				if(left > right) {
					ans += ( left * (left + 1) / 2 );
					ans += ( right * (right - 1) / 2 );
				} else if(left < right) {
					ans += ( right * (right + 1) / 2 );
					ans += ( left * (left - 1) / 2 );
				} else {
					ans += ( left * (left + 1) / 2 );
					ans += ( left * (left - 1) / 2 );
				}
				//printf("%ld\n", ans);
				left = 1;
				right = 0;
			}
		}
	}
	
	//printf("%ld %ld ", left, right);
	
	if(left > right) {
		ans += ( left * (left + 1) / 2 );
		ans += ( right * (right - 1) / 2 );
	} else if(left < right) {
		ans += ( right * (right + 1) / 2 );
		ans += ( left * (left - 1) / 2 );
	} else {
		ans += ( left * (left + 1) / 2 );
		ans += ( left * (left - 1) / 2 );
	}
	
	
	printf("%ld", ans);
	
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int n;
  cin>>n;
  ll cur = 100000;
  REP(i,n){
    cur *= 1.05;
    if(cur%1000 != 0){
      cur -= cur%1000;
      cur += 1000;
    }
  }
  cout<<cur<<endl;
  return 0;
}

Measured memory_bytes: 1152
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b;
  cin>>a>>b;
  double c=a*(pow(10,keta(b)))+b;
  YesNo(sqrt(c)==floor(sqrt(c)));
    
}

Measured memory_bytes: 512
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back
#define FILE freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);


using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 1000001;
const int mod = 1000000007;

ll fac[MAXN];
ll inv[MAXN];

ll modPower(ll x,ll y){
    x%=mod;
    ll res = 1;
    while(y){
        if(y&1)res= (res*x)%mod;
        x = (x*x)%mod;
        y>>=1;
    }
    return res;
}

void pre(){
    fac[0] = 1;
    for(ll i = 1; i < MAXN; i++)fac[i] = (i * fac[i-1])%mod;
    inv[MAXN-1] = modPower(fac[MAXN-1] , mod-2);
    for(ll i = MAXN-2; i >= 0; i--)inv[i] = (inv[i+1] * (i+1))%mod;
}

ll nCr(ll n, ll r){
    if(r > n)return 0;
    return fac[n] * (inv[r] * inv[n-r] % mod) % mod;
}


int main(){
    int n;
    cin>>n;
    string s[n];
    int t[n];
    fr(i,n){
        cin>>s[i]>>t[i];
    }
    string x;
    cin>>x;
    int ans = 0;
    bool found = 0;

    fr(i,n){
        if(found)ans += t[i];
        else if(s[i] == x)found = 1;
    }

    cout<< ans << endl;

}


Measured memory_bytes: 256
N, M = map(int, input().split())

d = [None] * N

doubled = False

for _ in range(M):
	s, c = map(int, input().strip().split())
	if d[s - 1] == None:
		d[s - 1] = c
	else:
		if d[s - 1] != c:
			doubled = True

if doubled or (N > 1 and d[0] == 0):
	print(-1)
else:
	if d[0] == None:
		if N == 1:
			d[0] = 0
		else:
			d[0] = 1
	for i in range(1, N):
		if d[i] == None:
			d[i] = 0
	print("".join(map(str, d)))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
#define MP make_pair
struct t{
	ll r,s1,s2;
	t(void){r=0,s1=0,s2=0;}
	void up(ll x){
		if(s1<x)swap(s1,x);
		s2=max(s2,x);
	}
	void mn(ll x){
		if(s1==x){
			s1=s2;
			s2=0;
		}
	}
};
ll n,cs[100005],ans;
vector<ll>g[100005];
map<ll,t>dp[100005];
t dfs(ll v,ll p,ll f){
	if(dp[v].count(p))return dp[v][p];
	t res;
	if(p==-1||f){
		for(int i=0;i<g[v].size();i++){
			ll u=g[v][i];
			if(u==p)continue;
			t x=dfs(u,v,f);
			x.r-=2;
			x.s1--;
			if(x.r>0){
				res.r+=x.r;
				res.up(-x.r+x.s1);
			}else res.up(x.s1);
		}
		res.r+=cs[v];
		res.s1+=res.r;
		res.s2+=res.r;
	}else{
		res=dfs(v,-1,0);
		t x=dfs(p,v,0);
		x.r-=2;
		x.s1--;
		if(x.r>0){
			res.r-=x.r;
			res.mn(res.r+x.s1);
			res.s1-=x.r;
		}else res.mn(res.r+x.s1);
	}
	return dp[v][p]=res;
}
int main(void){
	scanf("%lld",&n);
	ll ma=-INF;
	for(int i=0;i<n;i++){
		scanf("%lld",cs+i);
		ma=max(ma,cs[i]);
	}
	if(ma<=0){
		printf("%lld\n",ma);
		return 0;
	}
	for(int i=0;i<n-1;i++){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		g[--a].PB(--b);
		g[b].PB(a);
	}
	dfs(0,-1,1);
	for(int i=0;i<n;i++)ans=max(ans,dfs(i,-1,0).s1);
	printf("%lld\n",ans);
}


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

int N;
vector<pair<char,int> > vec;

// dp[i][j] := 左から (B, 0), ..., (B, i-1)、(W, 0), ..., (W, j-1) を敷き詰めるまでの最短 swap 数
int dp[2100][2100];

int main() {
    cin >> N;
    vec.resize(N*2);
    for (int i = 0; i < N*2; ++i) {
        cin >> vec[i].first >> vec[i].second;
        --vec[i].second;
    }
    
    // (B, i) の前に (B, iより大きい) + (W, j以上) が何個あるか
    vector<vector<int> > black(N, vector<int>(N+1, 0));
    
    // (W, i) の前に (W, iより大きい) + (B, j以上) が何個あるか
    vector<vector<int> > white(N, vector<int>(N+1, 0));
    
    vector<int> bnum(N, 0);
    vector<int> wnum(N, 0);
    for (int k = 0; k < N*2; ++k) {
        char c = vec[k].first;
        int num = vec[k].second;
        vector<int> wsum(N+1, 0), bsum(N+1, 0);
        for (int l = N; l > 0; --l) {
            bsum[l-1] = bsum[l] + bnum[l-1];
            wsum[l-1] = wsum[l] + wnum[l-1];
        }
        for (int l = N+1; l > 0; --l) {
		  if (c == 'B') black[num][l-1] = wsum[l-1] + bsum[num+1];
		  if (c == 'W') white[num][l-1] = wsum[num+1] + bsum[l-1];
        }
        if (c == 'B')  bnum[num]++;
        else wnum[num]++;
    }
    
    /* DP */
    for (int i = 0; i < 2100; ++i) for (int j = 0; j < 2100; ++j) dp[i][j] = 1<<29;
    dp[0][0] = 0;
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= N; ++j) {
            if (i < N) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + black[i][j]);
            if (j < N) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + white[j][i]);
        }
    }
    cout << dp[N][N] << endl;
}


Measured memory_bytes: 48896
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  string ans = "NO";

  b = abs(a - b);
  a = 0;

  if (a + v * t >= b + w * t) {
    ans = "YES";
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3600
N,M=gets.split.map &:to_i;r=N;A=$<.map{|e|h={};e.split.map{|f|h[f.to_i]=1};h};(M-1).times{h=Hash.new 0;A.map{|e|h[e.first[0]]+=1};k,v=h.max_by &:last;r=[r,v].min;A.map{|e|e.delete k}};p r

Measured memory_bytes: 8188
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int x[m];
    rep(i, m) cin >> x[i];
    if (n >= m)
    {
        cout << 0 << endl;
        return 0;
    }
    sort(x, x + m);
    int l[m - 1];
    rep(i, m - 1) l[i] = x[i + 1] - x[i];
    sort(l, l + m - 1, greater<int>());
    int ans = x[m - 1] - x[0];
    rep(i, n - 1)
    {
        cerr << ans << endl;
        ans -= l[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    int n;
    cin >> n;
    map<int, int> m;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        m[a]++;
    }
    int ans = 0;
    for (auto&& p : m) {
        if (p.second < p.first) {
            ans += p.second;
        }
        else {
            ans += p.second - p.first;
        }
    }
    cout << ans << "\n";
}

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

int main(void){
    int n;
    long long ans=0;
    cin>>n;
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
        sort (s[i].begin(),s[i].end());
    }
    sort(s,s+n);
    long long x=0;
    for(int i=1;i<n;i++){
        if(s[i-1]==s[i]){
            x++;
            if(i==n-1){
                ans+=(x*(x+1))/2;
                break;
            }
        }
        else{
            ans+=(x*(x+1))/2;
            x=0;
        }
    }
    
    cout<<ans;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const int mod = 998244353;
inline int qp(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = 1ll * res * a % mod;
		a = 1ll * a * a % mod;
		b >>= 1;
	}
	return res;
}
int fact[N], ifact[N], inv[N];
inline void Init(int n = 1000000) {
	inv[1] = 1;
	for (int i = 2; i <= n; i++) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = 1ll * fact[i - 1] * i % mod;
		ifact[i] = 1ll * ifact[i - 1] * inv[i] % mod;
	}
}
inline int C(int n, int m) {
	if (n < m || n < 0 || m < 0) return 0;
	return 1ll * fact[n] * ifact[m] % mod * ifact[n - m] % mod;
}
int n, m;
int main() {
	Init();
	scanf("%d%d", &n, &m);
	if (n < m) swap(n, m);
	int ans = 0;
	for (int i = 1; i <= m; i++) ans = (ans + 1ll * C(2 * i, i) * C(n + m - 2 * i, n - i)) % mod;
	ans = 1ll * ans * qp(2 * C(n + m, n) % mod, mod - 2) % mod;
	ans = (ans + n) % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 15552
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include<string>
#include <stack>
#include<queue>
#include<map>
#include <stdlib.h>
#include <set>

using namespace std;

int main() {
	string s,w="";
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s.substr(i,1)=="B"&&w.length()>0){
			w.erase(w.length()-1);
		}else if(s.substr(i,1)=="B"){

		}else{
			w+=s[i];
		}
	}
	cout<<w<<endl;
	return 0;
}



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

using namespace std;

int n;
vector<int> g[100000];
vector<int> path, mem;
vector<int> col;

void dfs1(int v, int p) {
	path.push_back(v);
	if(v == n - 1) mem = path;
	for(int to : g[v])
		if(to != p) dfs1(to, v);
	path.pop_back();
}

void dfs2(int v, int c) {
	for(int to : g[v])
		if(col[to] == -1)
			col[to] = c, dfs2(to, c);
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for(int i = 0; i < n - 1; i++) {
		int u, v; cin >> u >> v; --u; --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs1(0, -1);
	col.assign(n, -1);
	int sz = mem.size();
	for(int i = 0; i < (sz + 1) / 2; i++) col[mem[i]] = 0;
	for(int i = (sz + 1) / 2; i < sz; i++) col[mem[i]] = 1;
	for(int i = 0; i < sz; i++) dfs2(mem[i], col[mem[i]]);
	int dif = 0;
	for(int i = 0; i < n; i++) dif += (col[i] == 0 ? 1 : -1);
	cout << (dif > 0 ? "Fennec" : "Snuke");
}

Measured memory_bytes: 14840
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    for (int i = 0; i < S.size(); i++) {
        S[i] = (S[i] - 'A' + N) % 26 + 'A';
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long
vector<pair<int,int> > ans;

void doit(int x1,int y1,int mul,int x2,int y2,int d1)
{
  int i,j;
  if (d1%4==0)
  {
    doit(x1,y1,mul*2,x2,y2,d1/4);
    doit(x1,y1+mul,mul*2,x2,y2,d1/4);
    doit(x1+mul,y1,mul*2,x2,y2,d1/4);
    doit(x1+mul,y1+mul,mul*2,x2,y2,d1/4);
  }
  else
  {
    if (d1%4==1)
    {
      for (i=x1;i<x2;i+=mul*2)
        for (j=y1;j<y2;j+=mul*2)
          ans.push_back(make_pair(i,j));
      for (i=x1+mul;i<x2;i+=mul*2)
        for (j=y1+mul;j<y2;j+=mul*2)
          ans.push_back(make_pair(i,j));
    }
    else
    {
      for (i=x1;i<x2;i+=mul*2)
        for (j=y1;j<y2;j+=mul*2)
          ans.push_back(make_pair(i,j));
      for (i=x1;i<x2;i+=mul*2)
        for (j=y1+mul;j<y2;j+=mul*2)
          ans.push_back(make_pair(i,j));
    }
  }
}

void doit(int x1,int y1,int mul,int x2,int y2,int d1,int d2)
{
  int i,j;
  if ((d1%4!=0)&&(d2%4==0)) swap(d1,d2);
  if (d1%4==0)
  {
    if (d2%4==0)
    {
      doit(x1,y1,mul*2,x2,y2,d1/4,d2/4);
      doit(x1+mul,y1,mul*2,x2,y2,d1/4,d2/4);
      doit(x1,y1+mul,mul*2,x2,y2,d1/4,d2/4);
      doit(x1+mul,y1+mul,mul*2,x2,y2,d1/4,d2/4);
    }
    else
    {
      if (d2%4==1)
      {
        doit(x1,y1,mul*2,x2,y2,d1/4);
        doit(x1+mul,y1+mul,mul*2,x2,y2,d1/4);
      }
      else
      {
        doit(x1,y1,mul*2,x2,y2,d1/4);
        doit(x1,y1+mul,mul*2,x2,y2,d1/4);
      }
    }
  }
  else
  {
    for (i=x1;i<x2;i+=mul*2)
      for (j=y1;j<y2;j+=mul*2)
        ans.push_back(make_pair(i,j));
  }
}

int main()
{
  int n,d1,d2,i,j,k,l,mul;
  scanf("%d%d%d",&n,&d1,&d2);
  ans.clear();
  doit(0,0,1,n+n,n+n,d1,d2);
  for (i=0;i<n*n;i++)
    printf("%d %d\n",ans[i].first,ans[i].second);
  return 0;
}

Measured memory_bytes: 1908
n,m,x = gets.split(' ').map(&:to_i)
c = Array.new(n)
a = Array.new(n).map{ Array.new(m) }

n.times do |i|
    args = gets.chomp.split(' ').map(&:to_i)
    c[i] = args[0]
    m.times do |j|
        a[i][j] = args[j+1]
    end
end

bignum = 9999999999
min_price = bignum

(2 ** n).times do |bk_bit|
    price = 0
    skills = Array.new(m, 0)
    n.times do |i|
        if bk_bit[i] != 0
            m.times do |j|
                skills[j] += a[i][j]
            end
            price += c[i]
        end
    end

    if skills.all?{ |s| s >= x } && price < min_price
        min_price = price
    end
end

min_price == bignum ? (puts '-1') : (puts min_price.to_s)

Measured memory_bytes: 14612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n)cin >> a[i];
	ll ans = 0;
	rep(i,n-1)
	{
		if(a[i]>1)
		{
			ans += a[i]/2;
			a[i] -= a[i]/2*2; 
		}
		if(a[i]>0&&a[i+1]>0)
		{
			ll fo = min(a[i],a[i+1]);
			a[i] -= fo;
			a[i+1] -= fo;
			ans += fo;
		}
	}
	ans+=a[n-1]/2;
	cout<<ans<<endl;
	return 0;
}


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

int main() {

    int n;

    std::cin >> n;

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

        int x = i;

        if ( x % 3 == 0 ) std::cout << " " << i;
        else for ( ; x; x /= 10 ) {
            if ( x % 10 == 3 ) { std::cout << " " << i; break; }
        }
    }

    std::cout << std::endl;

    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#define MAX 200001
using namespace std;
typedef long long ll;

int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	int len = s1.length();
	if (len != s2.length()) {
		cout << "No";
		return 0;
	}
	for (int i = 0; i < len; i++) {
		if (s1.at(0) == s2.at(i)) {
			int flag = 1;
			for (int j = i + 1; j < len + i; j++) {
				if (s1.at(j - i) != s2.at(j % len)) {
					flag = 0;
					break;
				}
			}
			if (flag == 1) {
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
from collections import deque
n, x, y = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(n-1):
    G[i].append(i+1)
    G[i+1].append(i)
G[x-1].append(y-1)
G[y-1].append(x-1)
ans = [0]*n
for i in range(n):
    que = deque([i])
    dist = [-1]*n
    dist[i] = 0
    while que:
        v = que.popleft()
        for nv in G[v]:
            if dist[nv] == -1:
                dist[nv] = dist[v]+1
                que.append(nv)
    for i in range(n):
        ans[dist[i]]+=1
for i in range(n):
    ans[i]//=2
print(*ans[1:], sep = '\n')


Measured memory_bytes: 47708
#include<stdio.h>
int main()
{
    int a,b,sum;
    char op;
    scanf("%d %c %d",&a,&op,&b);
    if(op=='+')
    {
        printf("%d",a+b);
    }
    else if(op=='-')
    {
        printf("%d",a-b);
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

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

using namespace std;
int N;
long long int k[10];
int P[10] = {0,0,0,0,0,0,1,1,1,2};
int Q[10] = {1,1,1,2,2,3,2,2,3,3};
int R[10] = {2,3,4,3,4,4,3,4,4,4};

int main(){
  cin >> N;
  REP(i,N){
    string s;
    cin >> s;
    if(s[0]=='M') k[0] ++;
    if(s[0]=='A') k[1] ++;
    if(s[0]=='R') k[2] ++;
    if(s[0]=='C') k[3] ++;
    if(s[0]=='H') k[4] ++;
  }
  long long int res = 0;
  REP(i,10){
    res += k[P[i]]*k[Q[i]]*k[R[i]];
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import bisect
N,K=map(int, input().split())
p=998244353
L=[]
for i in range(K):
    l,r=map(int, input().split())
    L.append([l,r])

L=sorted(L)

def add(a,b):
    return a+b

class SegmentTree:
    def __init__(self, init_value: list, segfunc, ide_ele):
        n = len(init_value)
        self.N0 = 1 << (n - 1).bit_length()
        self.ide_ele = ide_ele
        self.data = [ide_ele] * (2 * self.N0)
        self.segfunc = segfunc
        
        for i, x in enumerate(init_value):
            self.data[i + self.N0 - 1] = x
        for i in range(self.N0 - 2, -1, -1):
            self.data[i] = self.segfunc(self.data[2 * i + 1], self.data[2 * i + 2])
    
    # k: index , x: value
    def update(self, k: int, x):
        k += self.N0 - 1
        ############################
        self.data[k] = x
        ###########################
        while k:
            k = (k - 1) // 2
            self.data[k] = self.segfunc(self.data[k * 2 + 1], self.data[k * 2 + 2])
    
    # rightは開区間  l<=x<r
    def query(self, left: int, right: int):
        L = left + self.N0
        R = right + self.N0
        res = self.ide_ele
        ##########################
        a, b = [], []
        while L < R:
            if L & 1:
                a.append(L - 1)
                L += 1
            if R & 1:
                R -= 1
                b.append(R - 1)
            L >>= 1
            R >>= 1
        for i in a + b[::-1]:
            res = self.segfunc(res, self.data[i])
        ##########################
        return res




dp=[0]*N
dp[0]=1
lis=[0]*N
lis[0]=1
seg=SegmentTree(lis, add, 0)
acc=1
#print(L)
for i in range(1,N):
    now=i+1
    temp=0
    for l in L:
        left, right=l
        Left=max(now-right-1,0)
        Right= max(now-left,0)
        temp+=seg.query(Left,Right)
        #print(left, right)
    temp%=p

    dp[i]=temp


    
    if dp[i]!=0:
        seg.update(i,temp)

print(dp[-1])



Measured memory_bytes: 76532