akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
using ll = long long;


int main(){
    string str;
    ll ans = 0;
    cin >> str;
    for(ll i=0;i<str.size();i+=2){
        if(str[i]=='p') ans--;
        if(str[i+1]=='g')   ans++;
    }
    cout << ans << endl;
    return 0;
}

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


int a_val(int t);
int b_val(int t, int K);

 
int main()
{
    int N, K;
    cin >> N >> K;
    
    vector<int> ans(N+1);
    ans.at(0)=1;
    
    for(int i = 0;i < N; i++)
    {
        if(a_val(ans.at(i))< b_val(ans.at(i),K))
        {
            ans.at(i+1)=a_val(ans.at(i));
        }
        else
        {
            ans.at(i+1)=b_val(ans.at(i),K);
        }
        //cout << ans.at(i) << endl;  
    }
    cout << ans.at(N) << endl;
}

//操作A
int a_val(int t)
{
    int retval = t*2;
    return retval;
}



//操作B
int b_val(int t, int K)
{
    int retval = t+K;
    return retval;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <utility>
#include <cstdlib>
using namespace std;

typedef pair<int,int> pii;
typedef pair<int,pii> piii;

struct Sparse_Table {
	static const int MAX_N = 2e5 + 6;
	static const int MAX_P = __lg(MAX_N)+1;
	int st[MAX_P][MAX_N];
	int lg2[MAX_N];
	int pow2[MAX_P];
	int n;
	//starting from 1 ~ n
	vector<int> a;
	void init(int _n,vector<int> &_a) {
		n=_n;
		for (int i:_a) a.push_back(i);
//		cout<<"n = "<<n<<" , a : ";
//		for (int i:a) cout<<i<<' ';
//		cout<<endl;
		lg2[1] = 0;
		for (int i=2;MAX_N>i;i++) lg2[i] = lg2[i/2]+1;
		pow2[0]=1;
		for (int i=1;MAX_P>i;i++) pow2[i] = pow2[i-1] * 2;
		for (int i=1;n>=i;i++) {
			st[0][i] = a[i];
		}
		for (int i=1;MAX_P>i;i++) {
			for (int j=1;n>=j;j++) {
				int r=j+pow2[i-1];
				if (r>n) r=n;
				st[i][j] = min(st[i-1][j],st[i-1][r]);
			}
		}
	}
	int query(int l,int r) {
		int dis=(r-l+1);
		return min(st[lg2[dis]][l],st[lg2[dis]][r-pow2[lg2[dis]]+1]);
	}
	
} all,odd,even;

const int INF = 1e9 + 7;
const int MAX_N = 2e5 +6;
int pos[MAX_N];

priority_queue<piii,vector<piii>,greater<piii> > pq;

void add(int L,int R,int l,int r) {
	if (L>=R) return;
//	if (l>R || L>r) return;
	if (L%2==0) pq.push(make_pair(even.query(L,R),make_pair(L,R)) );
	else pq.push(make_pair(odd.query(L,R),make_pair(L,R)) );
}

int main () {
	vector<int> a,b,c;
	a.resize(1);
	b.resize(1);
	c.resize(1);
	int n;
	scanf("%d",&n);
	for (int i=1;n>=i;i++) {
		int x;
		scanf("%d",&x);
		a.push_back(x);
		pos[x] = i;
		if (i%2==1) {
			b.push_back(x);
			c.push_back(INF);
		}
		else {
			b.push_back(INF);
			c.push_back(x);
		}
	}
	all.init(n,a);
	odd.init(n,b);
	even.init(n,c);
//	cout<<"query = "<<all.query(1,n)<<endl;
//	system("pause");
	bool check=false;
	pq.push(make_pair(odd.query(1,n),make_pair(1,n)));
	while (!pq.empty()) {
		piii p=pq.top();
		pq.pop();
		if(check) printf(" ");
		check=true;
		printf("%d",p.first);
		int p1=pos[p.first];
		int v1=p.first;
		int L=p.second.first,R=p.second.second;
//		cout<<"L  = "<<L<<" , R= "<<R<<endl;
		int v2;
		if (L%2 == 1) v2 = even.query(p1,R);
		else v2=odd.query(p1,R);
		printf(" %d",v2);
		int p2=pos[v2];
//		cout<<"p1 = "<<p1<<" , p2 = "<<p2<<endl;
		add(L,p1-1,L,R);
		add(p1+1,p2-1,L,R);
		add(p2+1,R,L,R);
	}
	puts("");
}


Measured memory_bytes: 52704
#include<iostream>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>

using namespace std;
const int INF=10000000LL;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> Pa;
int N,Y,ans=0;
bool b;
P C[35][35];
int main(){
	cin>>N>>Y;
	for(int i=0;i<=N;++i){
		for(int j=0;j<=N-i;++j){
			if(i*10000+j*5000+(N-i-j)*1000==Y){
				cout<<i<<" "<<j<<" "<<N-i-j<<endl;
				b=true;
				break;
			}
		}
		if(b)break;
	}
	if(!b)cout<<"-1 -1 -1"<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define deb(a) cout << #a << ": " << a << ENDL;
#define all(a) begin(a), end(a)
#define sz(a) (int)(a.size())
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef vector<lli> vi;
typedef long double ld;
typedef pair<lli, lli> ii;

const int MAXN = 3005;

lli dp[4][MAXN][MAXN];

lli n, m;

vector<vi> val;

bool valid(int u, int v) {
    return u >= 0 and u < n and v >= 0 and v < m;
}

lli solve(lli r, lli u, lli v) {
    lli &ans = dp[r][u][v];
    if(ans != -1) return ans;
    ans = 0;
    if(u == n - 1 and v == m - 1) return ans;
    if(u < n - 1) ans = max(ans, max(solve(0, u + 1, v) , solve(1, u + 1, v) + val[u + 1][v]) );
    if(v < m - 1) ans = max(ans, solve(r, u, v + 1));
    if(v < m - 1 and r < 3) ans = max(ans, solve(r + 1, u, v + 1) + val[u][v + 1]);
    return ans;
}


int main() { _
    lli k, u, v, w; cin >> n >> m >> k;
    fore(i, 0, 4) fore(j, 0, MAXN) fore(k, 0, MAXN) dp[i][j][k] = -1;
    val.assign(n, vi(m, 0));
    fore(i, 0, k) {
        cin >> u >> v >> w; --u; --v;
        val[u][v] = w;
    }
    cout << max(solve(0, 0,0), solve(1, 0, 0) + val[0][0]) << ENDL;
    return 0;
}


Measured memory_bytes: 356328
import java.util.Scanner;
public class Main {
	static int cu = 1;
	static int cd = 6;
	static int n =  5;
	static int s =  2;
	static int e = 4;
	static int w = 3;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int k = stdIn.nextInt();
			if(k == 0) {
				break;
			}
			cu = 1;
			cd = 6;
			n =  5;
			s =  2;
			e = 4;
			w = 3;
			
			int ans = 1;
			for(int i = 0; i < k; i++) {
				String tmp = stdIn.next();
				if (tmp.equals("North")) {
					north();
				}
				if (tmp.equals("South")) {
					south();
				}
				if (tmp.equals("East")) {
					east();
				}
				if (tmp.equals("West")) {
					west();
				}
				if (tmp.equals("Right")) {
					right();
				}
				if (tmp.equals("Left")) {
					left();
				}
				ans += cu;
			}
			System.out.println(ans);
		}
	}
	
	static void north() {
		int tmp = cu;
		cu = s;
		s = cd;
		cd = n;
		n = tmp;
	}
	static void south() {
		int tmp = cu;
		cu = n;
		n = cd;
		cd = s;
		s = tmp;
	}
	static void east() {
		int tmp = cu;
		cu = e;
		e = cd;
		cd = w;
		w = tmp;
	}
	static void west() {
		int tmp = cu;
		cu = w;
		w = cd;
		cd = e;
		e = tmp;
	}
	static void right() {
		int tmp = n;
		n = e;
		e = s;
		s = w;
		w = tmp;
	}
	static void left() {
		int tmp = n;
		n = w;
		w = s;
		s = e;
		e = tmp;
	}
}

Measured memory_bytes: 25444
int main(void)
{
	char carry[1000];
	int result = 0;
	int i,c = 0;
	
	for(i = 0;i < 1000;i++){
		carry[i] = '0';
	}
	
	while(1){
		scanf("%s",carry);
		if(carry[0] == '0')break;
		
		for(i = 0;i < 1000;i++){
			if(carry[i] == '\0')carry[i] = '0';
			result += (int)carry[i]-48;
			carry[i] = '0';
		}
		printf("%d\n",result);
		result = 0;
	}
	return 0;
}

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

int main() {
    bool b[26] = {false};
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        b[s[i] - 'a'] = true;
    }
    for(int i=0;i<26;i++){
        if(!b[i]){
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> v(n);
	int sum = 0;
	rep(i,n) {
		cin >> v[i];
		sum += v[i];
	}
	sort(ALL(v), greater<>());
	rep(i,m) {
		if (4 * m * v[i] < sum) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;
typedef long double ld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	ll x, y, z, k;
	cin>>x>>y>>z>>k;
	vector<ll> a(x);
	vector<ll> b(y);
	vector<ll> c(z);
	for(int i=0; i<x; i++) {
		cin>>a[i];
	}
	sort(a.rbegin(), a.rend());
	for(int i=0; i<y; i++) {
		cin>>b[i];
	}
	sort(b.rbegin(), b.rend());
	for(int i=0; i<z; i++) {
		cin>>c[i];
	}
	sort(c.rbegin(), c.rend());
	
	map<tuple<int, int, int>, bool> mm;
	priority_queue<pair<ll, tuple<int, int, int>>> q;
	q.push(make_pair(a[0]+b[0]+c[0], make_tuple(0, 0, 0)));
	
	while(!q.empty() and k) {
		auto p = q.top();
		q.pop();
		if(mm[p.second]) continue;
		mm[p.second]=1;
		k--;
		cout<<p.first<<"\n";
		int i1, i2, i3;
		tie(i1, i2, i3) = p.second;
		
		if(i1!=x-1) {
			q.push(make_pair(a[i1+1]+b[i2]+c[i3], make_tuple(i1+1, i2, i3)));
		}
		if(i2!=y-1) {
			q.push(make_pair(a[i1]+b[i2+1]+c[i3], make_tuple(i1, i2+1, i3)));
		}
		if(i3!=z-1) {
			q.push(make_pair(a[i1]+b[i2]+c[i3+1], make_tuple(i1, i2, i3+1)));
		}
	}
    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>

using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f

//std::ios::sync_with_stdio(0); std::cin.tie(0);
int main() {
	char a;
	cin >> a;
	if (a >= 'a' && a <= 'z')cout << 'a' << endl;
	else cout << 'A' << endl;
	return 0;
}

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

int main()
{
	int H, W;
	
	while (cin >> H >> W) {
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
const int N=20;
typedef long long ll;
int n,m,k;
string s[N];
int main()
{
    int ans=0;
    cin>>n>>m>>k;
    for(int i=0;i<n;i++) cin>>s[i];
    for(int i=0;i<1<<n;i++)for(int j=0;j<1<<m;j++)
    {
        int sum=0;
        for(int h=0;h<n;h++)
            for(int k=0;k<m;k++)
        {
            if(i>>h&1) continue;
            if(j>>k&1) continue;
            if(s[h][k]=='#') sum++;
        }
        ans+=sum==k;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 3692
n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
    x,u=map(str,input().split())
    x=float(x)
    if u=="BTC":
        x=380000.0*x
    ans+=x
print('{:.7f}'.format(ans))

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k, q;
    cin >> k >> q;
    vector<int> d(k);
    for(auto &x : d)
        cin >> x;
    while(q--){
        int n, x, m;
        cin >> n >> x >> m;
        --n;
        ll s=0, ss=0;
        for(int i=0;i<k;i++){
            ll tmp = d[i]%m;
            if(!tmp)
                tmp = m;
            s+=tmp;
            if(i<n%k)
                ss+=tmp;
        }
        ll xx = x+s*(n/k)+ss;
        cout << n-(xx/m-x/m) << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    priority_queue<ll> PQ;
    ll sum = 0;
    for(int i=0;i<n;i++){
        ll a; cin >> a;
        sum += a;
        PQ.push(a);
    }
    for(int i=0;i<m;i++){
        ll t = PQ.top(); PQ.pop();
        ll diff = t - (t / 2);
        sum -= diff;
        PQ.push(t / 2);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 ll n;
  cin>>n;
  ll a,b;
  cin>>a>>b;
  vin x(n);
  rep(i,0,n){
    cin>>x[i];
  }
  ll ans=0;
  rep(i,0,n-1){
    if((x[i+1]-x[i])*a>b){
      ans+=b;
    }
    else{
       ans+=(x[i+1]-x[i])*a;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3740
#include <iostream>
using namespace std;
int main(){
long long int a,b,gcd,lcm,tmp,r,num_a,num_b;
while(cin>>num_a>>num_b){
a=num_a;
b=num_b;
if(a<b){
tmp = a;
a = b;
b = tmp;
}
r=a%b;
while(r!=0){
a = b;
b = r;
r = a % b;
}
gcd = b;
lcm = (num_a*num_b)/gcd;
cout<<gcd<<" "<<lcm<<endl;
}
return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> memo;
ll a,b,c,d;

ll solve(ll n) {
    if (memo.count(n)) return memo[n];
    ll mi = 1e12;
    // n/2
    mi = min(mi, solve(n/2) + a + n % 2 * d);
    
    // n/2 + 1
    if (n % 2 == 1)
        mi = min(mi, solve(n/2+1) + a + d);
    
    // n/3
    mi = min(mi, solve(n/3) + b + n % 3 * d);
    
    // n/3 + 1
    if (n % 3 != 0)
        mi = min(mi, solve(n/3+1) + b + (3 - n % 3) * d);

    // n/5
    mi = min(mi, solve(n/5) + c + n % 5 * d);

    // n/5 + 1
    if (n % 5 != 0)
        mi = min(mi, solve(n/5+1) + c + (5 - n % 5) * d);
    
    // 0
    if (d <= mi / n) mi = min(mi, d * n);
    return memo[n] = mi;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n >> a >> b >> c >> d;
        memo.clear();
        memo[0] = 0;
        memo[1] = d;
        cout << solve(n) << endl;
    }
    return 0;
}

Measured memory_bytes: 4384
main = do
  xs <- map read . lines <$> getContents
  putStrLn . show $ sum (map (\x -> 10 * (ceiling $ toRational x / 10)) xs) + minimum' ([x `mod` 10 | x <- xs, x `mod` 10 /= 0]) - 10

minimum' [] = 10
minimum' x = minimum x


Measured memory_bytes: 508
package main

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

const INF = 1000000001
const MAX = 500000

var (
	sc   = bufio.NewScanner(os.Stdin)
	cnt  = 0
	L, R = make([]int, MAX), make([]int, MAX)
)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func String(A []int) string {
	return strings.Trim(fmt.Sprint(A), "[]")
}

func main() {
	n := scanInt()
	A := make([]int, n)
	for i := range A {
		A[i] = scanInt()
	}
	mergeSort(A, 0, n)
	fmt.Println(String(A))
	fmt.Println(cnt)
}

func merge(A []int, left, mid, right int) {
	n1 := mid - left
	n2 := right - mid
	for i := 0; i < n1; i++ {
		L[i] = A[left+i]
	}
	for i := 0; i < n2; i++ {
		R[i] = A[mid+i]
	}
	L[n1], R[n2] = INF, INF

	l, r := 0, 0
	for i := left; i < right; i++ {
		cnt++
		if L[l] <= R[r] {
			A[i] = L[l]
			l++
		} else {
			A[i] = R[r]
			r++
		}
	}
}

func mergeSort(A []int, left, right int) {
	if left+1 < right {
		mid := (left + right) / 2
		mergeSort(A, left, mid)
		mergeSort(A, mid, right)
		merge(A, left, mid, right)
	}
}



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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a, b; cin>>a>>b;
	int x = a+b, y = a - b, z = a * b;
	int mx;
	mx = max(x, y);
	mx = max(mx, z);
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

int cnt(ll x) {
	int r = 0;
	while(x>=10) {
		r++;
		x/=10;
	}
	return r+1;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll n;
	cin >> n;
	ll ans = 1000000;
	for(ll i = 1; i*i<=n; i++){
		if (n%i==0) {
			ll d1 = i, d2 = n/i;
			int r = max(cnt(d1),cnt(d2));
			if (r < ans) {
				ans = r;
			}
		}
	}
	cout << ans << "\n";
	

}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static Scanner sc = new Scanner();

    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var A = sc.ReadInt();
        var B = sc.ReadInt();
        var ans = Math.Min(N * A, B);
        Console.WriteLine(ans);
    }

    static long Gcd(long a, long b)
    {
        var v = new[] { a, b };
        while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
        return v[0];
    }

    static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }

    public string ReadStr()
    {
        return this.Next();
    }

    public char ReadChar()
    {
        return this.Next()[0];
    }

    public int ReadInt()
    {
        return int.Parse(this.Next());
    }

    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }

    public long ReadLong()
    {
        return long.Parse(this.Next());
    }

    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }

    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }

    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }

    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}

class HashMap<K, V> : Dictionary<K, V> where V : new()
{
    private V DefaltValue = new V();
    public HashMap() { }
    public HashMap(V defaultValue)
    {
        this.DefaltValue = new V();
    }
    new public V this[K i]
    {
        get
        {
            V v;
            return TryGetValue(i, out v) ? v : base[i] = this.DefaltValue;
        }
        set { base[i] = value; }
    }
}

Measured memory_bytes: 11092
import java.util.*;

public class Main {
    public static void main(String[] args) {

        //solve_148_A();
        //solve_148_B();
        solve_148_C();
        return;
    }

    private static void solve_148_C() {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();

        for(int i=1; i<=B; i++){
            if((A * i) % B == 0){
                System.out.println(A*i);
                break;
            }
        }
    }
}

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

using namespace std;

int main() {
  priority_queue<int, vector<int>, greater<int>> pq;
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int n;
    cin >> n;
    pq.push(n);
  }
  int sum = 0;
  for (int i = 0; i < K; i++) {
    sum += pq.top();
    pq.pop();
  }
  cout << sum << endl;
  return 0;
}

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

int main(){

  int N, M; cin >> N >> M;

  // vector<int> X(10010, 0);
  vector<int> X;
  // vector<int> dx(10010, 0);
  vector<int> dx;

  int tmp;
  for(int i = 0 ; i < M ; ++i){
    cin >> tmp;
    X.push_back(tmp);
    // cin >> X[i];
  }

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

  for(int i = 1 ; i < M ; ++i){
    dx.push_back( X[i] - X[i-1] );
    // dx[i] = X[i] + X[i-1];
    // cout << dx[i-1] << endl;
  }

  sort(dx.begin(), dx.end());
  int ans = 0;

  for(int i = 0 ; i < M - N ; ++i){
    ans += dx[i];
  }
  cout << ans << endl;

}

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

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
// #define f(i,a,b) for(int (int)i = (int)a;i<b;i++)
// #define rf((i),(a),(b)) for(int (i) = b; (i)>(a);(i--))
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mp make_pair

int main(void)
{
    ios_base::sync_with_stdio(false);
    ll n,w;
    scanf("%lld %lld" ,&n ,&w);
    vector<pair<ll,ll>> val;
    for(int i = 0;i<n;i++)
    {
        ll temp1,temp2;
        scanf("%lld %lld",&temp1 ,&temp2);
        val.pb(mp(temp1,temp2));
    }
    vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));//note where the variable name comes here.
    for(int i = 1;i<=n;i++)
        for(int j=1;j<=w;j++)
            if(val[i-1].first<=j)
                dp[i][j] = max((val[i-1].second + dp[i-1][j-val[i-1].first]),dp[i-1][j]);
            else
                dp[i][j] = dp[i-1][j];
    
    printf("%lld\n",dp[n][w]);
    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    string a, b;
    cin >> a;
    cin >> b;
    if(a.size() > b.size()) {
        cout << "GREATER" << endl;
        return 0;
    }
    else if(a.size() < b.size()) {
        cout << "LESS" << endl;
        return 0;
    }
    else {
        rep(i, a.size()) {
            if(a[i] > b[i]) {
                cout << "GREATER" << endl;
                return 0;
            }
            else if(a[i] < b[i]) {
                cout << "LESS" << endl;
                return 0;
            }
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int, S: str):
    A = S[:K-1] + S[K-1].lower() + S[K:]
    print(A)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, S)


if __name__ == '__main__':
    main()


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

vector<pair<int,int>> edges;
void add(int a, int b) {
    edges.push_back({a,b});
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int N; cin >> N;
    if (N&1) {
        for (int i = 1; i < N; i++) add(i,N);
        for (int i = 1; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                if (j != N - i) add(i,j);
            }
        }
    }
    else {
        for (int i = 1; i <= N; i++) {
            for (int j = i + 1; j <= N; j++) {
                if (i+j != N+1) add(i,j);
            }
        }
    }
    //output
    cout << edges.size() << '\n';
    for (auto p: edges) {
        cout << p.first << ' ' << p.second << '\n';
    }
}



Measured memory_bytes: 384
#include<stdio.h>
int main()
{
int A, B;
scanf("%d %d", &A, &B);
int size = A + B + 1;
char str[100];
scanf("%s", str);
int i, count = 0;
if (str[A] == '-')
{
    for (i = 0; i < size; i++)
    {
        if (str[i] >= '0' && str[i] <= '9')
        {
            count++;
        }
    }
        
    if (count + 1 == size)
    {
        printf("Yes\n");
    }
        
    else
    {
        printf("No\n");
    }
}
else
{
    printf("No\n");
}
return 0;
}

Measured memory_bytes: 1592
fun main(args: Array<String>) {
    val (n, d) = readLine()!!.split(" ").map { it.toInt() }

    val cov = 2*d + 1

    if(n % cov == 0 ) {
        println(n/cov)
    } else {
        print(n/cov + 1)
    }
}

Measured memory_bytes: 37652
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
using LL = long long;

int main() {
	LL A, B, C, X, Y;
	cin >> X >> Y >> A >> B >> C ;
	vector<LL> P(A), Q(B), R(C);
	for (int i = 0; i < A; i++) {
		cin >> P[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> Q[i];
	}
	for (int i = 0; i < C; i++) {
		cin >> R[i];
	}
	sort(P.begin(), P.end(), std::greater<LL>());
	sort(Q.begin(), Q.end(), std::greater<LL>());
	sort(R.begin(), R.end(), std::greater<LL>());

	// 赤色X個食べたとき
	LL sum_A = 0;
	LL A_num = X;
	LL sum_B = 0;
	LL B_num = Y;
	LL C_num = 0;
	while (true) {
		if (P[A_num - 1] <= Q[B_num - 1] && P[A_num - 1] < R[C_num]) {
			A_num--;
			C_num++;
		}
		else if (P[A_num - 1] > Q[B_num - 1] && Q[B_num - 1] < R[C_num]) {
			B_num--;
			C_num++;
		}
		else if (min(P[A_num - 1], Q[B_num - 1]) >= R[C_num]) {
			break;
		}
		if (A_num == 0 || B_num == 0 || C_num >= C) {
			break;
		}
	}
	// 赤だけ(B枯渇)
	while (C_num < C && A_num != 0) {
		if (P[A_num - 1] < R[C_num]) {
			A_num--;
			C_num++;
		}
		else if (P[A_num - 1] >= R[C_num]) {
			break;
		}
	}

	while (C_num < C && B_num != 0) {
		if (Q[B_num - 1] < R[C_num]) {
			B_num--;
			C_num++;
		}
		else if (Q[B_num - 1] >= R[C_num]) {
			break;
		}
	}


	LL ans = 0;
	for (int i = 0; i < A_num; i++) {
		ans += P[i];
	}
	for (int j = 0; j < B_num; j++) {
		ans += Q[j];
	}	
	for (int i = 0; i < C_num; i++) {
		ans += R[i];
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define pf printf
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define REPSZ(i,v) REP(i,SZ(v))
#define pll pair <ll, ll>

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

ll n,m;
vector<ll> arr[2];

void print(vector <ll> &v){cout << v.size() << endl;for(int i = 0; i < v.size(); i++){pf("%lld ", v[i]);}pf("\n");}
void print(vector <pll> &v){ cout << v.size() << endl; for(int i = 0; i < v.size(); i++){pf("%lld %lld\n", v[i].first, v[i].second);}}
void print(set<ll> s){set <ll> :: iterator itr;for (itr = s.begin(); itr != s.end(); ++itr){cout << *itr << " ";}cout << endl;}
void print(double d){cout << fixed << setprecision(10) << d << endl;}

void from_file(void){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);}

/* ------------------main section-------------! */

void solve() {
    
}


void run() {
    fastio;
    int n;
    cin >> n;
    REP(i,2)
    {
        REP(j,n)
        {
            int x;
            cin >> x;
            arr[i].pb(x);
        }
    }
    FOR(i,1,n)
    {
        arr[0][i] += arr[0][i-1];
    }

    for(int i = n-2; i >= 0; i--)
    {
        arr[1][i] += arr[1][i+1];
    }
    ll mx = 0;
    REP(i,n)
    {
        mx = max(mx,arr[0][i]+arr[1][i]);
    }
    cout << mx << endl;
}


int main() {
    #ifndef ONLINE_JUDGE
        from_file();
    #endif
    run();
    return 0;
}


Measured memory_bytes: 3668
#include<stdio.h>
#include<stdlib.h>

int ball[200000];
int N,K,ans;

int compare(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(){
	scanf("%d%d",&N,&K);
	
	for(int i=0;i<N;i++){
		int b;
		scanf("%d",&b);
		ball[b-1]++;
	}
	
	qsort(ball,200000,sizeof(int),compare);
	
	for(int i=K;ball[i]>0;i++)ans+=ball[i];
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 1404
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repi(i, a, b) for(int i=(a); i>(b); i--)
#define db(x) (cerr << #x << ": " << x << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define iceil(n, x) ((n + x - 1) / x)
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define fi first
#define se second
#define umap unordered_map
#define uset unordered_set
#define pqueue priority_queue
#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld", &a)
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 
using namespace std;

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;

//All indexing is 0-based
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
			 tree_order_statistics_node_update> ordered_set;
//methods: find_by_order(k); & order_of_key(k);

main()
{	
	#ifndef ONLINE_JUDGE
		//freopen("/home/tarun/Desktop/input.txt", "r", stdin);
//		freopen("/home/tarun/Desktop/output.txt", "w", stdout);
	#endif
	clock_t clk = clock();
	cerr << "I will return...\n";
	
	int n; cin >> n;
	int a[n << 1];
	for(int&i : a) cin >> i;
	sort(a, a + 2 * n);
	int ans = 0;
	rep(i, 0, n) {
		ans += a[i << 1];
	}
	cout << ans << '\n';
	
	cerr << "...don't you ever hang your head.\n";
	cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << '\n';
}

//Compile using:
//g++ -o filename.exe --std=c++11 filename.cpp







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

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int main() {
    long long k = read(), a = read(), b = read();
    if (b - a < 3 || a >= k) {
        printf("%lld", k + 1);
        return 0;
    }
    k -= a - 1;
    printf("%lld", a + (k & 1) + (k >> 1) * (b - a));
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
string cal(lint n,lint x,int y){
	if(n<x){
		string ret="";
		rep(i,y){
			ret+=('a'+(n%26));n/=26;
		}
		reverse(All(ret));
		return ret;
	}
	n-=x;x*=26;y++;return cal(n,x,y);
}
int main()
{
	lint n;cin>>n;n--;
	cout<<cal(n,26,1)<<endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
 
#define y1 aklsdja
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >
 
#define fi first
#define se second
#define pb push_back
#define t top()
#define fr front()
 
#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)
 
#define oo 1e17 + 5
#define ll long long
#define int long long
#define pow poww
 
const int N = 3e3 + 5;
int n , m;
int dp[N][N];
char f1[N] , f2[N];
 
 
void tr(int x , int y)
{
    if(x != 0 && y != 0)
    {
        if(dp[x][y] == dp[x - 1][y])
            tr(x - 1 , y);
        else if(dp[x][y] == dp[x][y - 1])
            tr(x , y - 1);
        else
        {
            tr(x - 1 , y - 1);
            cout << f1[x];
        }
    }
}
 
main()
{
    //freopen("F.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> f1;
    cin >> f2;
    n = strlen(f1);
    m = strlen(f2);
    FORD(i , n , 1)
        f1[i] = f1[i - 1];
    FORD(i , m , 1)
        f2[i] = f2[i - 1];
 
    FOR(i , 1 , n)
        FOR(j , 1 , m)
        {
            if(f1[i] == f2[j])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j] , dp[i][j - 1]);
        }
    tr(n , m);
}

Measured memory_bytes: 70784
n=int(input())
s=[]
ans=0
for _ in range(n):
    S=int(input())
    if S%10!=0:
        s.append(S)
    ans+=S
s.sort()
if ans%10==0:
    if len(s):
        ans-=s[0]
    else:
        ans=0
print(ans)

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


#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 3e3 + 5;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

void initFactorials()
{
  fat[0] = 1;
  inv[0] = 1;
  for(int i = 1; i < maxn; i++)
  {
    fat[i] = (i * fat[i-1]) % mod;
    inv[i] = exp(fat[i], mod - 2);
  }
}

int n,m;

ll dp[maxn][maxn];

pair<int,int> a[maxn];

ll solve(int pos, int sum)
{
  if(sum >= m)
    return 0;
  if(pos == n )
    return 0;

  ll &ans = dp[pos][sum];
  if(ans != -1)
    return ans;

  ans = -(1LL << 60);
  ans = max(solve(pos + 1, sum), ans);
  ans = max(ans, solve(pos + 1, sum + a[pos].first) + a[pos].second);
  
  return ans;
}


int main()
{
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for(int i = 0 ; i < n ; i++)
  {
    cin >> a[i].first >> a[i].second;
  }
  sort(a, a + n);
  MSET(dp, - 1);
  cout << solve(0,0) << endl;
  return 0;
}

Measured memory_bytes: 74316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long ans = Long.MAX_VALUE;
		for(int i = 1 ; i * 2 <= n ; i++) {
			long j = n - i;
			long a = func(i);
			long b = func(j);
			ans = Math.min(a + b, ans);

		}
		System.out.println(ans);
	}

	static long func(long x) {
		long ret = 0;
		while(x > 0) {
			ret += x % 10;
			x /= 10;
		}
		return ret;
	}

}


Measured memory_bytes: 21844
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
    if(a>=b&&a>=c&&b>=c){printf("%d %d %d\n",c,b,a);}
    else if(a>=b&&b<=c&&a>=c){printf("%d %d %d\n",b,c,a);} 
    else if(a>=b&&b<=c&&a<=c){printf("%d %d %d\n",b,a,c);}
    else if(c<=b&&c<=a&&a<=b){printf("%d %d %d\n",c,a,b);}
    else if(a<=c&&a<=b&&c<=b){printf("%d %d %d\n",a,c,b);}
    else{printf("%d %d %d\n",a,b,c);}

	   return 0;
}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

  int n, m, Q;
  cin >> n >> m >> Q;
  vi l(m), r(m);
  vvi map(501, vi(501, 0));

  REP(i, m) {
    cin >> l[i] >> r[i];
    l[i]--;
    r[i]--;
    map[l[i]][r[i]]++;
  }

  REP(i, 501) {
    REP(j, 501) {
      if (j == 0)
        continue;
      map[i][j] += map[i][j - 1];
    }
  }

  REP(i, 501) {
    if (i == 500)
      continue;
    REP(j, 501) { map[500 - i - 1][j] += map[500 - i][j]; }
  }

  /*
  REP(i, 20) {
    REP(j, 20) cout << map[i][j] << " ";
    cout << endl;
  }
  */

  vi p(Q), q(Q);
  REP(i, Q) cin >> p[i] >> q[i];

  REP(i, Q) {
    p[i]--;
    q[i]--;

    int ans = map[p[i]][q[i]];
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int data[2]={0,0};
	int n;
	string s;
	cin>>n;
	cin>>s;
	int count=0;
	int ans=0;
	for(int i=1;i<n;i++){
		if(s[i]=='E')count++;
	}
	ans=count;
	for(int i=1;i<n;i++){
		if(s[i-1]=='W'){
			count++;
		}
		if(s[i]=='E')count--;
		if(ans>count)ans=count;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 900
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int d1,d2,m1,m2;
	cin>>m1>>d1;
	cin>>m2>>d2;
	if( (m1 == 1 || m1 == 3 || m1 == 5 || m1 == 7 || m1 == 8 || m1 == 10 || m1 == 12) && (d1 == 31)){
		cout<<"1"<<endl;
	}else if( m1 == 2 && d1 == 28 ){
		cout<<"1"<<endl;
	}else if(( m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11 ) && (d1 == 30) ){
		cout<<"1"<<endl;
	}else{
		cout<<"0"<<endl;
	}
}

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

// 円環の問題は切り開くと楽2周文とか
int main() {
  int k, n;
  int l_max = -1; // 家と家の距離の最大値
  std::cin >> k >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) std::cin >> a[i];
  
  for (int i = 0; i < n; i++)
    if (i == n-1) // 最初の家と最後の家の距離
      l_max = std::max(l_max, k+a[0]-a[i]);
    else
      l_max = std::max(l_max, a[i+1]-a[i]);

  std::cout << (k-l_max);
    

  return 0;
}

Measured memory_bytes: 4020
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
 
 
int main()
{
    // std::cout << std::fixed << std::setprecision(10);
    int n; std::cin >> n;
    int ans = 0;
    for(int i=1; i<n+1; i++)
        if(std::to_string(i).length() % 2 == 1) ans += 1;
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [, W] = input[0].map(Number);

  let field = input.slice(1, -1).map((line) => line[0]);

  field = field.filter((row) => !/^\.+$/.test(row));

  let count = 0;

  for (let j = 0; j < W; j++) {
    const cursor = j - count;

    if (field.every((row) => row[cursor] === ".")) {
      field = field.map(
        (row) => `${row.slice(0, cursor)}${row.slice(cursor + 1)}`
      );

      count += 1;
    }
  }

  return field.join("\n");
};

console.log(main(read()));


Measured memory_bytes: 30516
import itertools
import math
n = int(input())

pos = []

for _ in range(n):
  x, y = map(int, input().split())
  pos.append((x, y))

routes= list(itertools.permutations(pos, n))

sum = 0
for r in routes:
  for i in range(1, n):
    d = ((r[i][0] - r[i-1][0]) ** 2) + ((r[i][1] - r[i-1][1]) ** 2)
    sum += math.sqrt(d)

print(sum/len(routes))
    


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

const long long MOD = 1000000007;

void solve(long long N, std::vector<long long> A){
    vector<long long> s(N + 1);
    for (int i = N - 1; i >= 0; i--) {
        s[i] = (s[i + 1] + A[i]) % MOD;
    }
    long long ans = 0;
    for (int i = 0; i < N - 1; i++) {
        ans += (A[i] * s[i + 1]);
        ans %= MOD;
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 6448
#include<iostream>
#include<string>
using namespace std;
int main(){
    int i,j,n,l,mini=1000000,pos,total=0,tt=0,df,crt;
    cin >> n >> l;
    int a[n];
    for(i=0;i<n;i++){
        a[i] = l+i;
    }
    for(i=0;i<n;i++){
        total+=a[i];
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(j!=i){
                tt +=a[j];
            }
        }
        if(tt-total>0){
            df = tt-total;
        }
        else{
            df = total - tt;
        }
        if(df<mini){
            mini = df;
            crt = tt;
        }
        tt =0;
    }
    cout <<crt;
}

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

const int INF = 1e9;

int main() {
    int n, m;
    cin >> n >> m;
    int dp[5000];
    fill(dp, dp + 5000, INF);
    for (int i = 0; i < m; i++) {
        int a, b, x = 0;
        cin >> a >> b;
        for (int i = 0; i < b; i++) {
            int c;
            cin >> c;
            c--;
            x += (1 << c);
        }
        dp[x] = min(dp[x], a);
    }
    for (int i = 0; i < 1 << n; i++) {
        for (int j = 0; j < i; j++) {
            if ((j | i) == i) dp[j] = min(dp[i], dp[j]);
        }
    }
    for (int i = 1; i < 1 << n; i++) {
        for (int j = 1; j < i; j++) {
            if ((i | j) != i) continue;
            if (dp[j] < INF && dp[j ^ i] < INF) dp[i] = min(dp[i], dp[j] + dp[j ^ i]);
        }
    }
    if (dp[(1 << n) - 1] == INF)
        cout << -1 << endl;
    else
        cout << dp[(1 << n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

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

    vs32 a(A);
    int amin = (int)1e9;
    rep (i, A) { cin >> a[i]; amin = MIN(amin, a[i]); }
    vs32 b(B);
    int bmin = (int)1e9;
    rep (i, B) { cin >> b[i]; bmin = MIN(bmin, b[i]); }

    int ans = amin + bmin;

    int x, y, c;
    rep (i, M)
    {
        cin >> x >> y >> c;
        --x; --y;
        ans = MIN(ans, a[x] + b[y] - c);
    }

    cout << ans << "\n";
    return 0;
}



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



int main(){
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	for(int i=0; i<n-2; i++){
		if(s[i]=='A' && s[i+1]=='B' &&s[i+2]=='C') ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    bool ok[n + 1];
    for (int i = 0; i < n + 1; i++) {
        ok[i] = true;
    }
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        ok[a] = false;
    }
    ll dp[n + 1];
    for (int i = 0; i < n + 1; i++) {
        dp[i] = 0;
    }
    dp[0] = 1;
    for (int i = 1; i < n + 1; i++) {
        if (ok[i]) {
            dp[i] += dp[i - 1];
            if (i > 1) dp[i] += dp[i - 2];
        } else
            dp[i] = 0;
        dp[i] %= MOD;
    }
    OUT(dp[n]);
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define cout(n) cout<<(n)<<endl;
#define inf 1000000007
using namespace std;

int main(){
	ll n;
	cin>>n;
	vector<ll>vec(n);
	vector<ll>vek(n);
	for(ll i=0;i<n;i++) {
		ll t;
		cin>>t;
		vec[i]=t;
		vek[i]=t;
	}
	ll m;
	cin>>m;
	for(ll i=0;i<m;i++) {
		ll p,x;
		cin>>p>>x;
		vek[p-1]=x;
		ll ans=0;
		for(ll j=0;j<n;j++) {
			ans+=vek[j];
		}
		for(ll j=0;j<n;j++) {
			vek[j]=vec[j];
		}
		cout(ans);
	}
}


Measured memory_bytes: 256