akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
int p, q;
bool basic(int x,int y) {
	int a[8] = { 1,0,-1,0,p,-p,q,-q };
	int b[8] = { 0,1,0,-1,q,-q,-p,p };
	rep(i, 8) {
		if (x == a[i] && y == b[i])return true;
	}
	return false;
}
int main() {
	int r; cin >> r;
	rep(i, r) {
		cin >> p >> q;
		bool out = false;
		int a = p * p + q * q;
		int b = (int)sqrt(a + 0.5);
		Rep1(m, -b, b) {
			int c = a - m * m;
			int d = (int)sqrt(c + 0.5);
			Rep1(n, -d, d) {
				int x = m * m + n * n;
				if (x == 0)continue;
				int s = m * p + n * q;
				int t = m * q - n * p;
				if (!basic(m, n) && s%x == 0 && t%x == 0) {
					out = true; break;
				}
			}
			if (out)break;
		}
		if (out)cout << "C" << endl;
		else cout << "P" << endl;
	}
	return 0;
}


Measured memory_bytes: 3016
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;

namespace ABC121D_2
{
    public partial class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var A = ss.Next(long.Parse);
            var B = ss.Next(long.Parse);
            sw.WriteLine(F(A - 1) ^ F(B));
            //---------------------------------
        }

        long F(long n)
        {
            var ret = 0L;

            if (n % 4 == 1 || n % 4 == 2) ret++;

            for (var i = 1; i < 50; i++)
            {
                var pot = 1L << i;
                var pos = (n + 1) % (pot << 1);
                if (pos < pot || pos % 2 == 0) continue;
                ret += pot;
            }

            return ret;
        }
    }

    public class StreamScanner
    {
        static readonly char[] Separator = {' '};
        readonly StreamReader streamReader;

        string[] line = new string[0];
        int index = 0;

        public StreamScanner(Stream stream)
        {
            this.streamReader = new StreamReader(stream);
        }

        public string Next()
        {
            return Next(s => s);
        }

        public string[] Next(int x)
        {
            return Next(s => s, x);
        }

        public string[][] Next(int x, int y)
        {
            return Next(s => s, x, y);
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (index < line.Length) return parser(line[index++]);
            index = 0;
            line = streamReader.ReadLine()?.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }

    public partial class Program
    {
        static void Main()
        {
            Excute(Console.OpenStandardInput(), Console.OpenStandardOutput());
        }

        public static void Excute(Stream input, Stream output)
        {
            var ss = new StreamScanner(input);
            var sw = new StreamWriter(output);
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }
}

Measured memory_bytes: 13140
// abc057_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
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 REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

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

    int ans = (A + B) % 24;
    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cstring>

typedef struct status
{
	int x;
	int y;
	int hp;
	int time;
	int ate;
}status;

std::queue<status> que;

char field[1000][1000];
bool visited[1000][1000];

int bfs(int xs,int ys,int h,int w,int n);

int main()
{
	char buf[1024];
	int h,w,n,xs,ys;

	std::cin>>h>>w>>n;
	std::cin.getline(buf,1024);
	for(int i=0;i<h;i++)
	{
		std::cin.getline(buf,w+2);
		for(int j=0;j<w;j++)
		{
			field[i][j]=buf[j];
			if(field[i][j]=='S')
			{
				xs=j;
				ys=i;
			}
		}
	}
	std::cout<<bfs(xs,ys,h,w,n)<<std::endl;
	
	return 0;
}

int bfs(int xs,int ys,int h,int w,int n)
{
	status survey,next;
	int cost,t;
	memset(visited,0,sizeof(visited));
	survey.x=xs;
	survey.y=ys;
	survey.hp=1;
	survey.ate=0;
	survey.time=0;
	t=0;
	que.push(survey);
	while(!que.empty())
	{
		survey=que.front();
		que.pop();
		next=survey;
		
		if(field[survey.y][survey.x]!='.'&&field[survey.y][survey.x]!='S')
		{
			cost=field[survey.y][survey.x]-'0';
			if(survey.hp==cost)
			{
				next.ate++;
				next.hp++;
				while(!que.empty()){que.pop();}
				memset(visited,0,sizeof(visited));
				visited[next.y][next.x]=true;
				if(next.ate==n)break;
			}
		}
		next.time++;

		if(survey.x>0&&field[next.y][next.x-1]!='X')
		{
			if(!visited[next.y][next.x-1])
			{
				next.x--;
				que.push(next);
				visited[next.y][next.x]=true;
				next.x++;
			}
		}
		if(survey.x<w-1&&field[next.y][next.x+1]!='X')
		{
			if(!visited[next.y][next.x+1])
			{
				next.x++;
				que.push(next);
				visited[next.y][next.x]=true;
				next.x--;
			}
		}
		if(survey.y>0&&field[next.y-1][next.x]!='X')
		{
			if(!visited[next.y-1][next.x])
			{
				next.y--;
				que.push(next);
				visited[next.y][next.x]=true;
				next.y++;
			}
		}
		if(survey.y<h-1&&field[next.y+1][next.x]!='X')
		{
			if(!visited[next.y+1][next.x])
			{
				next.y++;
				que.push(next);
				visited[next.y][next.x]=true;
				next.y--;
			}
		}
	}
	return survey.time;
}

Measured memory_bytes: 2836
#include<iostream>
using namespace std;
void deal(long long&n,long long p,int &ans){
	if(n%p)return;
	int t=0;
	int c=1;
	while(n%p==0){
		n=n/p;
		++t;
		if(t==c){
			t=0;
			++c;
		}
	}
	ans+=c-1;
	return;
}
int main(){
	long long n;
	cin>>n;
	int ans=0;
	deal(n,2,ans);
	deal(n,3,ans);
	long long p=5;
	while(p*p<n){
		deal(n,p,ans);
		p+=6;
	}
	p=7;
	while(p*p<n){
		deal(n,p,ans);
		p+=6;
	}
	if(n>1)++ans;
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define PI pair<int,int>
#define PL pair<long int,long int>
#define PLL pair<ll,ll>
#define Tcase int t;cin>>t;while(t--)   
int main(){/*
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif*/
  int r;cin>>r;
  cout<<fixed<<setprecision(2)<<(float)2*M_PI*r<<"\n";
return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  ll n;
  cin >> n;
  ll v = 100;
  for (int i = 0; i < 456789; i++){
    if (v >= n){
      cout << i << "\n";
      break;
    }
    v += (v / 100);
  }
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

const int k = 4;
const int t[k] = { 10, 50, 100, 500 };

vector<int> clerk(int change) {
	vector<int> coins(k);
	
	for(int i = 3; i >= 0; i--) {
		coins[i] = change / t[i]; 
		change -= t[i] * coins[i];
	}
	
	return coins;
}

int main() {
	bool first = true;
	
	for(int C; cin >> C && C; ) {
		if(first) first = false;
		else cout << endl;
		
		vector<int> coins(k);
		int all = 0;
		
		for(int i = 0; i < k; i++) {
			cin >> coins[i];
			all += coins[i] * t[i];
		}
		
		vector<int> change = clerk(all - C);
		
		for(int i = 0; i < k; i++) {
			if(coins[i] - change[i] > 0) {
				cout << t[i] << " " << coins[i] - change[i] << endl; 
			}
		}
	}
}

Measured memory_bytes: 3100
N = int(input())
A = [int(i) for i in input().split()]

from fractions import gcd

L = [0, 0]
for i in range(N):
    L.append(gcd(L[-1], A[i]))

R = [0, 0]
for i in range(N - 1, -1, -1):
    R.append(gcd(R[-1], A[i]))
R.reverse()

print(max(gcd(l, r) for l, r in zip(L, R)))


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

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

	if (0 <= a && a <= 9
		&& 0 <= b && b <= 9) {
		out(a * b);
	}
	else {
		out(-1);
	}

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
 


int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		map<int, int>mp;
		for (int i = 0; i < N; ++i) {
			int a; cin >> a;
			mp[a]++;
		}
		int ans = -1;
		for (auto& m : mp) {
			if (m.second*2 >N) {
				ans = m.first; break;
			}
		}
		if (ans == -1)cout << "NO COLOR" << endl;
		else cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string o,e;
  cin >> o >> e;
  rep(i, o.length()){
   	if(o[i])
      cout << o[i]; 
    if(e[i])
      cout << e[i]; 
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
/*
author: Apoorv Singh
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

typedef vector <int> vi;
typedef vector <long long> vl;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define ll long long
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second

ll modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    FOR(i,0,s.length())
    {
        if (s[i] == '1')
            cout << '9';
        else
            cout << '1';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
S = input()

idx = []
i = 0
W_flag = False
for s in S:
    if not W_flag:
        if s == "W":
            continue
        elif s == "B":
            W_flag = True
    
    if s == "W" and W_flag:
        idx.append(i)
    i+=1
print(int(np.sum(idx) - ((0+len(idx)-1)*len(idx)/2)))
        

Measured memory_bytes: 26256
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string.h>
#include<cstdlib>
using namespace std;

const double eps = 1e-8;
typedef vector<double> array;
typedef vector<array> matrix;
int S,N,K;
double prob[12][110];


matrix identity_matrix(int n) {
  matrix A(n, array(n));
  for (int i = 0; i < n; ++i) A[i][i] = 1;
  return A;
}

matrix mul(const matrix &A, const matrix &B) {
  matrix C(A.size(), array(B[0].size()));
  for (int i = 0; i < C.size(); ++i)
    for (int j = 0; j < C[i].size(); ++j)
      for (int k = 0; k < A[i].size(); ++k)
        C[i][j] += A[i][k] * B[k][j];
  return C;
}
matrix pow(const matrix &A, int e) {
  return e == 0 ? identity_matrix(A.size())  :
     e % 2 == 0 ? pow(mul(A, A), e/2) : mul(A, pow(A, e-1));
}


vector<double> gauss_jordan(const matrix& A,const array& b){
	int n=A.size();
	matrix B(n,array(n+1));
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++) B[i][j]=A[i][j];

	for(int i=0;i<n;i++) B[i][n]=b[i];

	for(int i=0;i<n;i++){
		int pivot =i;
		for(int j=i;j<n;j++){
			if(abs(B[j][i])>abs(B[pivot][i])) pivot=j;
		}
		swap(B[i],B[pivot]);

		if(abs(B[i][i])<eps){ cout<<"error\n";return array();}

		for(int j=i+1;j<=n;j++) B[i][j]/=B[i][i];
		for(int j=0;j<n;j++){
			if(i!=j){
				for(int k=i+1;k<=n;k++) B[j][k]-=B[j][i]*B[i][k];
			}
		}
	}
	array x(n);

	for(int i=0;i<n;i++) x[i]=B[i][n];
	return x;
}


void solve()
{
	
	S = abs(S);
	if(N==1){	
		if(S%K==0) cout << S/K << endl;
		else       cout << -1 << endl;
		return;
		}
	memset(prob,0,sizeof(prob));
	prob[0][0]=1.0;
	for(int i=0;i<K;i++)
		for(int j=0;j+N<=N*K;j++)
			for(int z=1;z<=N;z++)
				prob[i+1][j+z]+=prob[i][j]/N;

	matrix A(K*N+1,array(K*N+1,0));
	A[0][0]=1;
	for(int i=1;i<=K*N;i++){
		A[i][i]=1;
		for(int j=0;j<=K*N;j++){
			A[i][abs(i-j)]-=prob[K][j];
		}
	}
	array V(K*N+1,0);
	V[0]=0;
	for(int i=1;i<=K*N;i++)	V[i]=1;

	V=gauss_jordan(A,V);

	matrix a(N*K+1,array(N*K+1,0));
	a[N*K][N*K]=a[0][N*K]=1;
	for(int i=0;i<N*K;i++)
		a[0][i]=prob[K][i+1];
	for(int i=0;i<K*N-1;i++)
		a[i+1][i]=1;


	
	if(S < N*K){printf("%.6lf\n", V[S]);return;}
	a=pow(a,S-N*K+1);
	
	double res=a[0][N*K];
	for(int i=0;i<N*K;i++){
		res+=a[0][i]*V[N*K-i-1];
	}
	
	printf("%.6lf\n", res);

}


int main()
{
	while(cin>>S>>N>>K)
		solve();
	return 0;
}

Measured memory_bytes: 3464
#include<iostream>
using namespace std;
int main() {
    int len,ans;
    string str;
    cin >> str;
    len = str.length();
    ans = len/2;
    for(int i=0;i<len-1-i;i++) {
        if(str[i] == str[len-1-i]) {
            ans--;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)

	tmp := a + b

	if tmp2 := a - b; tmp < tmp2 {
		tmp = tmp2
	}

	if tmp2 := a * b; tmp < tmp2 {
		tmp = tmp2
	}

	fmt.Println(tmp)
}



Measured memory_bytes: 512
#include <iostream>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

bool check(int n, const set<int> &d) {
  while(n > 0) {
    if(d.count(n % 10) != 0) return false;
    n /= 10;
  }
  return true;
}

int main(){
  const int n = getInt();
  const int k = getInt();

  set<int> d;
  REP(i,k) d.insert(getInt());

  for(int a = n; ; a++){
    if(check(a, d)) {
      printf("%d\n", a);
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
S=int(input())
List=[S]

i=1
while 1==1:
    i+=1
    if S%2==0:
        S=S/2
    else:
        S=(S*3)+1
    List.append(S)
    
    if len(List) != len(set(List)):
        break
    #i+=1
    
print(i)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;

using PII = pair<int, int>;

const long long inf = 1e18;

int main() {
	int n, q, k;
	cin >> n;

	vector<vector<PII>> edges(n);
	int a, b, c;
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b >> c;
		a--;
		b--;

		edges[a].emplace_back(make_pair(b, c));
		edges[b].emplace_back(make_pair(a, c));
	}
	cin >> q >> k;
	k--;
	vector<int> x(q), y(q);
	for (int i = 0; i < q; i++) {
		cin >> x[i] >> y[i];
		x[i]--;
		y[i]--;
	}

	vector<long long> dist(n, inf);
	queue<int> que;
	dist[k] = 0;
	que.push(k);
	while(!que.empty()) {
		int x = que.front();
		que.pop();

		for (PII p: edges[x]) {
			if (dist[p.first] == inf) {
				dist[p.first] = dist[x] + p.second;
				que.push(p.first);
			}
		}
	}

	for (int i = 0; i < q; i++) {
		cout << dist[x[i]] + dist[y[i]] << endl;
	}

	// for (int i = 0; i < dist.size(); i++) {
	// 	printf("dist[%2d]: %3lld\n", i, dist[i]);
	// }

	return 0;
}


Measured memory_bytes: 9588
#include<cstdio>
#include<algorithm>
using namespace std;

const int Maxn=1e5;

int N,A[Maxn+5];
long long ans=0;

inline long long Abs(long long x) {
	if(x<0)return -x;
	return x;
}

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
		scanf("%d",&A[i]);
	sort(A+1,A+N+1);
	int l=A[1],r=A[N];
	ans=r-l;
	for(int i=2;i+i<=N;i++) {
		ans+=A[N-i+1]-l;
		ans+=r-A[i];
		l=A[i],r=A[N-i+1];
	}
	if(N&1)ans+=max(r-A[N/2+1],A[N/2+1]-l);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x))
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2 * acos(0))
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define ll long long
typedef long double ld;
typedef complex<double>point;
typedef tuple<int, int, int> line;
typedef pair<point, point>segment;
typedef vector<point>polygon;
const int N = 1e5 + 5, M = 20 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7, base = 131, mod2 = 1000136437, mod3 = 998244353;
const double EPS = 1e-9;
ll n, w, memo[105][N], W[105], v[105], sum;
ll solve(int i, int V)
{
    if(i == n)
        return (!V)? 0 : LLMX;
    ll &ret = memo[i][V];
    if(~ret)
        return ret;
    ret = solve(i + 1, V);
    if(V - v[i] >= 0)
        ret = min(ret, solve(i + 1, V - v[i]) + W[i]);
    return ret;
}
int main()
{
    MuhammedAly
    mem(memo, -1);
    cin >> n >> w;
    for(int i = 0 ; i < n ;i++)
        cin >> W[i] >> v[i], sum += v[i];
    int ans = 0;
    for(int i = 1 ; i <= sum ; i++)
        if(solve(0, i) <= w)
            ans = i;
    cout << ans;
    return 0;
}


Measured memory_bytes: 82304
#include"bits/stdc++.h"
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20)
#define ll long long
#define endl '\n'
//       Author
//        ::
//    (  NOBODY  )
//   No Copyright .....You can copy and paste it without my permission...................................
// !!!!!!!!!!!!!!!
#define pb push_back
#define N 300009
int a[N],b[N],c[N];
int dp[40008][102][3];
int mo=1e9+7;
int n;
vector<int>v;
ll digit(int indx,int sum,int ok,int div)
{
   if(indx==-1)return (sum%div==0);
   if(dp[indx][sum][ok]!=-1)return dp[indx][sum][ok];
   int num=(ok)?v[indx]:9;
   ll sm=0;
   for(int i=0;i<=num;i++)
   {
     int new_ok=(i==v[indx])?ok:0;
     sm+=(ll)digit(indx-1,(sum+i)%div,new_ok,div);
     if(sum+i==0&&indx==n-1)sm--;
     sm%=mo;
   }
   if(!ok)dp[indx][sum][ok]=sm;
   return (sm%mo);

}
int main()
{
    FAST_IO;
    string s;
    memset(dp,-1,sizeof(dp));
    int k;
    cin>>s>>k;
     n=s.size();
    for(int i=n-1;i>=0;i--)
    {
      v.pb(s[i]-'0');
      //cout<<v.back()<<" ";
    }
   cout<< digit(n-1,0,1,k)%mo;
    return 0;
}


Measured memory_bytes: 50432
import math
R,G,B,N = map(int,input().split())
cnt = 0
for i in range(math.ceil(N/G)+1):
	for j in range(math.ceil(N/R)+1):
			tmp = N - i * G - j * R
			if tmp < 0:
				break
			if tmp % B == 0:
				cnt += 1
print(cnt)

Measured memory_bytes: 3060
N = int(input())

red = []
blue = []
count = 0

dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]

for n in range(2*N):
    v = list(map(int, input().split()))
    if n < N:
        red.append(v)
    else:
        blue.append(v)


for x in range(2*N):

    for k in range(2):
        r_remove_list = []
        b_remove_list = []

        for i, b in enumerate(blue):
            if b[k] == x:
                cand = -1
                max_ = -1
                max_j = -1
                for j, r in enumerate(red):
                    if r[k] < x:
                        if r[1-k] < b[1-k] and max_ < r[1-k]:
                            cand = j
                            max_ = r[1-k]
                            max_j = j
                if cand >= 0:
                    r_remove_list.append(max_j)
                    b_remove_list.append(i)

        blue = dellist(blue,b_remove_list)
        red = dellist(red,r_remove_list)
        count += len(b_remove_list)


print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define N (1000000000+7)
#define INF (ll)1e16
typedef pair<int,int> P;
typedef long long ll;
char board[60][60];
char board1[60][60];


int main(void){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>board[i][j];
        }
    }
    for(int i=1;i<=m;i++){
        for(int j=1;j<=m;j++){
            cin>>board1[i][j];
        }
    }
    for(int i=1;i<=n-m+1;i++){
        for(int j=1;j<=n-m+1;j++){
            bool flag=false;
            for(int i1=i;i1<i+m;i1++){
                for(int j1=j;j1<j+m;j1++){
                    if(board[i1][j1]!=board1[i1-i+1][j1-j+1])flag=true;
                }
            }
            if(!flag){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    *x, = map(int, input().split())
    if n >= m: return 0
    x = sorted(x)
    sec_x = [abs(x[i] - x[i+1]) for i in range(m-1)]
    sec_x = sorted(sec_x)
    ans = sum(sec_x[:(m-1 - (n-1))])
    return ans

print(main())

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

int main() {
  string C1, C2;
  cin >> C1 >> C2;
  if (C1[0] == C2[2] && C1[1] == C2[1] && C1[2] == C2[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    while(1)
    {
        c=c-b;
        if(c<=0)
        {printf("Yes\n");
        break;
        }
        a=a-d;
        if(a<=0)
        {
        printf("No\n");
        break;
        }
    }

    return 0;
}


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

typedef long long ll;

int main() {
    ll T1, T2; cin >> T1 >> T2;
    ll A1, A2; cin >> A1 >> A2;
    ll B1, B2; cin >> B1 >> B2;
    A1 = A1 * T1; A2 = A2 * T2;
    B1 = B1 * T1; B2 = B2 * T2;

    ll P = A1 - B1;
    ll Q = A2 - B2;
    if (P > 0) {
        P *= -1;
        Q *= -1;
    }
    if (P + Q < 0) {
        cout << 0 << endl;
    } else if(P + Q == 0) {
        cout << "infinity" << endl;
    } else {
        if (P % (P + Q) == 0) {
            cout << -1 * P / (P + Q) * 2 << endl;
        } else {
            cout << -1 * P / (P + Q) * 2 + 1 << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    ll K, A, B;
    cin >> K >> A >> B;
    ll res = 0LL;
    if(B - A <= 2 || K < A-1) res = 1 + K;
    else {
        res = A;
        K -= A-1;
        res += (K/2LL)*(B-A);
        res += K%2LL;
    }
    cout << res << endl;
    return 0;
}

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

int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  long long int N,M,K,S;
  cin >> N >> M >> K;
  long long int A[N+1], B[M+1];
  A[0]=0;
  B[0]=0;
  long long int C=N;
  
  for(long long int i=1;i<N+1;i++){
    cin >> A[i];
    A[i] = A[i]+A[i-1];
    if(C==N && A[i]>K){
      C = i-1;
    }
  }

  for(long long int i=1;i<M+1;i++){
    cin >> B[i];
    B[i] = B[i]+B[i-1];
  }
  
  long long int D=0;
  
  while(A[C] + B[D+1]<=K && D<M){
    D++;
  }
  //cout << C << ":" << D << endl;
  
  long long int Max = C+D;
  for(long long int i=1;i<C+1;i++){
    while(A[C-i]+B[D+1]<=K){
      if(D==M){
        break;
      }
      D++;
    }
    S=C-i+D;
    //cout << C-i << ":" << D << endl;
    if(S>Max){
      Max=S;
    }
  }
cout << Max <<endl;
  return 0;
}


int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


Measured memory_bytes: 6740
#include<iostream>
#include<string>
#include<cstdlib>
#include<stack>
using namespace std;

int RPN();//Reverse Polish Notation
 
int main()
{
	int answer ;

	answer = RPN() ;

	cout << answer << endl ;

	return 0;
 
}
 
int RPN()
{
	int x,y,answer;
	string ss ;
	stack<int> stk;

	while(1){
		cin >> ss;
		if(cin.eof()) break ;

		if(ss == "+") {
			y = stk.top() ;
			stk.pop() ;
			x = stk.top() ;
			stk.pop();
			answer = x + y ;
			stk.push(answer);
			continue ;
		}

		if(ss == "-") {
			y = stk.top() ;
			stk.pop() ;
			x = stk.top() ;
			stk.pop();
			answer = x - y ;
			stk.push(answer);
			continue ;
		}

		if(ss == "*") {
			y = stk.top() ;
			stk.pop() ;
			x = stk.top() ;
			stk.pop();
			answer = x * y ;
			stk.push(answer);
			continue ;
		}

		stk.push(atoi(ss.c_str()));
	}

	return answer ;
}

Measured memory_bytes: 1204
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	ll a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	if(a > b) {
		swap(a, b);
	}
	cout << ((a + v * t) >= (b + w * t) ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int monthTable[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int monthTable2[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};

bool isLeapYear(int year){
	if(year % 4 == 0){
		if(year % 100 == 0){
			if(year % 400 == 0){
				return true;
			}else{
				return false;
			}
		}else{
			return true;
		}
	}else{
		return false;
	}
}

int main(){

	long long int sum,tmp,year,month,day,b,ka,t,w,ki,NUMBER = 735224;
	int count,status;
	char buf[100];

	while(true){
		scanf("%s",buf);
		if(buf[0] == '#')break;

		count = 0;

		for(int i = 0;buf[i] != '\0';i++){
			if(buf[i] == '.')count++;
		}

		sum = 0;
		if(count == 2){
			status = 0;
			tmp = 0;

			for(int i = 0; buf[i] != '\0';i++){
				if(buf[i] >= '0' && buf[i] <= '9'){
					tmp = 10*tmp+(buf[i]-'0');

					if(buf[i+1] == '\0'){
						day = tmp;
					}
				}else{
					if(status == 0){
						year = tmp;
					}else{
						month = tmp;
					}
					status++;
					tmp = 0;
				}
			}

			if(year == 2012){
				sum = day - 21;
			}else{

				sum += 10;

				for(int i = 2013; i <= year-1; i++){
					if(isLeapYear(i))sum += 366;
					else{
						sum += 365;
					}
				}

				for(int i = 1; i <= month-1; i++){
					if(i == 2 && isLeapYear(year) == true){
						sum += 29;
					}else{
						sum += monthTable[i];
					}
				}
				sum += day;
			}

			printf("%lld.",(sum/144000)%13);
			sum %= 144000;
			printf("%lld.",sum/7200);
			sum %= 7200;
			printf("%lld.",sum/360);
			sum %= 360;
			printf("%lld.",sum/20);
			sum %= 20;
			printf("%lld\n",sum);

		}else{ //????????´?????\??????????????´???
			status = 0;
			tmp = 0;

			for(int i = 0; buf[i] != '\0';i++){
				if(buf[i] >= '0' && buf[i] <= '9'){
					tmp = 10*tmp + (buf[i] - '0');

					if(buf[i+1] == '\0'){
						ki = tmp;
					}
				}else{
					if(status == 0){
						b = tmp;
					}else if(status == 1){
						ka = tmp;
					}else if(status == 2){
						t = tmp;
					}else if(status == 3){
						w = tmp;
					}
					status++;
					tmp = 0;
				}
			}

			sum = 144000*b + 7200*ka + 360*t + 20*w + ki + NUMBER;

			year = 0,month = 1;

			for(int i = 0;sum > 366; i++){
				if(isLeapYear(i)){
					sum -= 366;
				}else{
					sum -= 365;
				}
				year++;
			}

			if((sum <= 365) || (sum == 366 && isLeapYear(year))){

				if(isLeapYear(year)){
					for(int i = 1; i <= 12 && sum > monthTable2[i];i++){
						sum -= monthTable2[i];
						month++;
					}
				}else{
					for(int i = 1; i <= 12 && sum > monthTable[i];i++){
						sum -= monthTable[i];
						month++;
					}
				}
			}else{
				year++;
				month = 1;
				sum = 1;
			}
			printf("%lld.%lld.%lld\n",(year)%10000001,month,sum);
		}
	}
	return 0;
}

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

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            int  a, b, x, y, z;

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

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

            x = a + b;
            y = a - b;
            z = a * b;

            if (x >= y && x >= z)
                Console.WriteLine(x);

            else if (y >= x && y >= z)
                Console.WriteLine(y);

            else
                Console.WriteLine(z);

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int a,b;
  cin>>a>>b;

  if(a>b){
    REP(i,a) cout<<b;
    cout<<endl;
  }else{
    REP(i,b) cout<<a;
    cout<<endl;
  }

  return 0;

}


Measured memory_bytes: 256
a, b, c = (int(i) for i in input().split())
if a >= b and a >= c and b >= c:
  print(abs(b-a)+abs(c-b))
elif a >= b and a >= c and c >= b:
  print(abs(c-a)+abs(b-c))
elif b >= a and b >= c and a >= c:
  print(abs(a-b)+abs(c-a))
elif b >= a and b >= c and c >= a:
  print(abs(c-b)+abs(a-c))
elif c >= b and c >= a and a >= b:
  print(abs(a-c)+abs(b-a))
elif c >= b and c >= a and b >= a:
  print(abs(b-c)+abs(a-b))



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

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

  string res = "YES";
  for (int i = 0; i < s.size(); ++i) {
    string subS = s.substr(i, 5);
    if (subS == "dream") {
      i += 4;
      if (i + 3 < s.size() && s.substr(i + 1, 3) == "era") {
        continue;
      }
      if (i + 2 < s.size() && s.substr(i + 1, 2) == "er") {
        i += 2;
      }
    } else if (subS == "erase") {
      i += 4;
      if (i + 1 < s.size() && s.substr(i + 1, 1) == "r") {
        i++;
      }
    } else {
      res = "NO";
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);

     string a,b;
     cin>>a;
     b=a;
     int n= a.size();
     for(int i=0,j=n-1;i<n;++i,--j)
     {
         b[i]=a[j];
     }
     if(a==b){cout<<"Yes";}
     if (a!=b) {cout<<"No";}
}








Measured memory_bytes: 3636
N = int(input())

sum = 0
l = [1] * N

for i in range(N):
    if (i+1)%15 == 0:
        l[i] = 0
    elif (i+1)%3 == 0:
        l[i] = 0
    elif (i+1)%5 == 0:
        l[i] = 0

for i in range(N):
    if l[i] == 1:
        sum += i+1

print(str(sum))

Measured memory_bytes: 74808
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

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

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

const double PI = acos(-1.0);

int main() {
    double r;
    cin >> r;
    printf("%.10lf\n", r * 2 * PI);
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
const int MOD = 1000000007;

int main()
{
    ll a, b, x; cin >> a >> b >> x;
    ll adiv = (a + x - 1) / x;
    ll bdiv = b / x;
    cout << bdiv - adiv + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



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

bool comp(pair<int, int> a, pair<int, int> b){
    return a.first > b.first;
}

bool comp2(pair<int, int> a, pair<int, int> b){
    return a.second > b.second;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n, m;
    vector<vector<ll> > vv(1e5+1);
    cin >> n >> m;
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        vv[a].push_back(b);
    }
    priority_queue<ll> q;
    ll ans = 0;
    rep2(i, 1, m+1){
        rep(j, vv[i].size()){
            q.push(vv[i][j]);
        }
        if(q.empty()) continue;
        ans += q.top(); q.pop();
    }
    cout << ans << endl;
    // for(pair<ll, ll> f : v){
    //     print(f.first, f.second);
    // }
    
    return 0;
}



Measured memory_bytes: 5632
S = input()
S = S.replace('><','>,<').split(',')

ans = 0

for s in S:
    small = s.count('<')
    big = s.count('>')
    tmp = max(small,big)\
        + (max(small,big)-1)*max(small,big)//2\
        + (min(small,big)-1)*min(small,big)//2
    ans += tmp
print(ans)

Measured memory_bytes: 12828
#include<algorithm>
#include<iostream>
#include<string>

const std::string bstop = "012345678954321";

int main()
{
	int n;
	std::cin >> n;
	while( n-- )
	{
		int s, e;
		std::cin >> s >> e;
		
		bool fl = false;
		std::string ans;

		while( true )
		{
			for( int i = 0; i != bstop.size(); ++i )
			{
				if( fl )
				{
					ans += ' ';
					ans += bstop[i];
				}

				if( bstop[i] == s + '0' )
				{
					ans.clear();
					fl = true;
					ans = bstop[i];
				}

				if( fl && bstop[i] == e + '0' )
					goto end;
			}
		}
end:;
		std::cout << ans << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'

const int N = 200;
set<int> marked;

class node {
public:
  int num, distance;
  bool operator < (const node &other) const {
    if (distance == other.distance) 
      return num < other.num;
    return distance < other.distance;
  }
};

int32_t main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(nullptr), cout.tie(nullptr);

    int x, n; 
    cin >> x >> n;
    for (int i = 0; i < n; i++) {
      int x; cin >> x;
      marked.insert(x);
    }
    vector<node> ans;
    for (int i = 0; i <= N; i++) {
      if (!marked.count(i))
        ans.push_back({i, abs(i - x)});
    }
    sort(ans.begin(), ans.end());
    cout << ans[0].num << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  for (int i = 0; i < m; i++) {
    cin >> x.at(i);
  }

  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }
  sort(x.begin(), x.end());
  vector<int> d(m - 1);
  for (int i = 0; i < m - 1; i++) {
    d.at(i) = abs(x.at(i) - x.at(i + 1));
  }
  sort(d.rbegin(), d.rend());
  int d_sum = accumulate(d.begin(), d.end(), 0);
  for (int i = 0; i < n - 1; i++) {
    d_sum -= d.at(i);
  }
  
  cout << d_sum  << endl;

}


Measured memory_bytes: 1024
N = int(input())
array = [list(map(int, input().split())) for i in range(N)]
for line in array:
    line.append(line[0] - line[1])
    line.append(line[0] + line[1])
array = sorted(array, key=lambda x: x[3])

count = 0
max_r = -float('inf')
for i in range(N):
    current = array[i]
    if current[2] >= max_r:
        count += 1
        max_r = current[3]
print(count)


Measured memory_bytes: 65752
import sys
input = sys.stdin.readline

k, n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

a.sort()

b = []

for i in range(n - 1):
    b.append(a[i + 1] - a[i])

b.append(k - sum(b))

ans = sum(b) - max(b)

print(ans)

Measured memory_bytes: 81612
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ll n;
    cin>>n;
          ll d ;
  ll cnt = 0;
    for(ll i = 0;i<n;i++){
        cin>>d;
        if(d != i+1){
            cnt++;
        }

    }
    if(cnt == 2 || cnt == 0){
        cout<<"YES"<<"\n";
    }
    else{
        cout<<"NO"<<"\n";
    }
}


Measured memory_bytes: 256
def main():
    n = int(input())
    p_l = list(map(int, input().split()))
    cnt = 0
    for i in range(n):
        if p_l[i] == i + 1: continue
        else: cnt += 1
    if cnt > 2: print("NO")
    else: print("YES")
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int s=0,max=0;
	int fool;
	string sa;
	cin>>fool;
	cin>>sa;
	for(int i=0;i<fool;i++){
		s=0;
		for(char c='a';c<='z';c++){
			bool left=false,right=false;
			for(int j=0;j<i;j++){
				if(sa[j]==c){
					left=true;
				}
			}
			for(int j=i;j<sa.size();j++){
				if(sa[j]==c){
					right=true;
				}
			}
			if(left==true&&right==true){
				s++;
			}
		}
		if(s>max){
			max=s;
		}
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


s = S()
q = I()
queries = SR(q)
que = deque(list(s))
top = True  # 先頭の位置 Trueが左（初期位置）
for query in queries:
    if query[0] == '1':
        top = not(top)
    else:
        _, f, c = query.split()
        if f == '1':
            if top:
                que.appendleft(c)
            else:
                que.append(c)
        else:
            if top:
                que.append(c)
            else:
                que.appendleft(c)
if top:
    print(''.join(list(que)))
else:
    print(''.join(list(que))[::-1])


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

using i64 = long long;
using P = pair<i64, i64>;


void solve(std::string S){
    string s = S;
    i64 ans = 0;
    for(int i = 0; i < s.length() / 2; ++i){
        if(s[i] != s[s.length() - i - 1]) ++ans;
    }
    cout << ans << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch AirConditioner | diff AirConditioner.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address AirConditioner.cpp && ./a.out

/*

 8/2/2020

 5:00-

 */

int X;

void solve() {
  cout<<(X>=30?"Yes":"No")<<endl;
}

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

  cin>>X;
  solve();

  return 0;
}


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

// dp[i][j]:i番目まで確定、i番目より大きいのはj個
ll dp[3030][3030];
ll sum[3030];

int main(){
  int N; cin>>N;
  string S; cin>>S;
  rep(i,N+1) dp[1][i]=1;
  for(int i=1;i<N;i++){
    for(int j=0;j<=N-i;j++){
      int k=(N-i)-j;
      if(S[i-1]=='<'){
        (dp[i+1][0]+=dp[i][j])%=MOD;
        (dp[i+1][j]=dp[i+1][j]-dp[i][j]+MOD)%=MOD;
      }else{
        (dp[i+1][j]+=dp[i][j])%=MOD;
        (dp[i+1][j+k]=dp[i+1][j+k]-dp[i][j]+MOD)%=MOD;
      }
    }
    for(int j=0;j<N-i;j++)
      (dp[i+1][j+1]+=dp[i+1][j])%=MOD;
  }
  cout<<dp[N][0]<<endl;
  return 0;
}


Measured memory_bytes: 71936