akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> colors(8, 0);

  int joker = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (1 <= a && a <= 399) {
      colors[0]++;
    }
    if (400 <= a && a <= 799) {
      colors[1]++;
    }
    if (800 <= a && a <= 1199) {
      colors[2]++;
    }
    if (1200 <= a && a <= 1599) {
      colors[3]++;
    }
    if (1600 <= a && a <= 1999) {
      colors[4]++;
    }
    if (2000 <= a && a <= 2399) {
      colors[5]++;
    }
    if (2400 <= a && a <= 2799) {
      colors[6]++;
    }
    if (2800 <= a && a <= 3199) {
      colors[7]++;
    }
    if (3200 <= a) {
      joker++;
    }
  }

  int cnt = 0;
  for (int i = 0; i < 8; i++) {
    if (colors[i] != 0) {
      cnt++;
    }
  }
  if (cnt == 0) {
    cout << 1 << " " << joker << endl;
  } else {
    cout << cnt << " " << cnt + joker << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long dp[1005][1005],n,m;
bool a[1005][1005];
char c;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>c,a[i][j]=(c=='.');
	dp[1][1]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(i==1&&j==1)
				continue;
			if(!a[i][j])
				dp[i][j]=0;
			else
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		}
	cout<<dp[n][m];
	return 0;
}

Measured memory_bytes: 9088
#include <cctype>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define LL long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

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

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

	LL b[2 * 100000 + 1];

	REP(i, n){
		LL x;
		cin >> x;
		if((i % 2 == 0 && n % 2 == 0) ||
			(i % 2 == 1 && n % 2 == 1)){
			b[(int)(n / 2.0 - 0.5) + (i / 2) + 1] = x;
		}else{ 
			b[(int)(n / 2.0 - 0.5) - (i / 2)] = x;
		}
	}

	REP(i, n){
		cout << b[i];
		if(i != n - 1){
			cout << " ";
		}
	}
	cout << endl;

}


Measured memory_bytes: 3712
#include <stdio.h>

int main(){
  double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
  while(~scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &xa1, &ya1, &xa2, &ya2, &xb1, &yb1, \
&xb2, &yb2)){
    if(xa1 > xb2 || ya1 > yb2 || xa2 < xb1 || ya2 < yb1) puts("NO");
    else puts("YES");
  }
  return 0;
}

Measured memory_bytes: 612
main = do
    (a:s) <- getLine
    let p1 = a == 'A'
        p2 = (== 1) . length $ filter (== 'C') (init (tail s))
        p3 = (== length s - 1) . length $ filter (`elem` ['a'..'z']) $ filter (/= 'C') s
    putStrLn $ if p1 && p2 && p3 then "AC" else "WA"

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string ans;
  rep (i, s.size()) {
    ans += (s[i] - 'A' + n) % 26 + 'A';
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
#define x first
#define y second
#define ll long long
#define _for(i,j,k) for(int i=j;i<k;i++)
#define endl  '\n'
#define inf 1<<31-1
#define ull unsigned long long  
const int mod=1e9+7;
const int MAX=500000;

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int k,a;
	cin>>k;
	ll sum=0;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			for(int z=1;z<=k;z++)
			{
				a=__gcd(i,j);
				sum+=__gcd(a,z);
			 } 
		}
	 } 
	cout<<sum;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void){
    
    int x=1;
    
 
	int i = 1;
	while(x!=0) {
		scanf("%d", &x);
		if (x != 0) {
			printf("Case %d: %d\n", i, x);
			i++;
		}
		else break;
		
	}
    /*for(int i=1;x!=0;i++){
    scanf("%d",&x);
    printf("Case %d: %d",i,x);
    }*/
    
    return 0;
}


Measured memory_bytes: 1980
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    ll n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    if(n % 2 == 0){
        vector<ll> v;
        for(ll i = 0; i < n / 2; i++){
            v.emplace_back(a + c + 2 * c * i);
            v.emplace_back(a - c - 2 * c * i);
        }
        sort(ALL(v));
        for(ll i = 0; i < v.size(); i++){
            ll l = v[i] - (d - c) * (n - 1 - i);
            if(l <= b && b <= l + (d - c) * (n - 1)){
                cout << "YES" << endl;
                return 0;
            }
        }
    }else{
        vector<ll> v;
        v.emplace_back(a);
        for(ll i = 1; i <= n / 2; i++){
            v.emplace_back(a + 2 * c * i);
            v.emplace_back(a - 2 * c * i);
        }
        sort(ALL(v));
        for(ll i = 0; i < v.size(); i++){
            ll l = v[i] - (d - c) * (n - 1 - i);
            if(l <= b && b <= l + (d - c) * (n - 1)){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 6384
#include<cstdio>
#include<cmath>
#include<cctype>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<string>
#define INF 0x3f3f3f3f
#define LC(a) (a<<1)
#define RC(a) (a<<1|1)
#define MID(a,b) ((a+b)>>1)
#define fin(name)  freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FOR(i,start,end) for(int i=start;i<=end;i++)  
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long LL;
const int N=5e4+5;

int main(){
	int A,B,C,D,E,F;
	scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
	double lim=E/100.0,ans=-1;
	int x=0,y=0;
	for(int i=0;i*A*100<=F;i++){
		for(int j=0;i*A*100+j*B*100<=F;j++){
			for(int k=0;k*C<=1.0*F/100*E;k++){
				for(int p=0;k*C+p*D<=1.0*F/100*E;p++){
					if(i==0&&j==0&&k==0&&p==0)
						continue;
					if(i*A*100+j*B*100+k*C+p*D>F||i==0&&j==0)
						continue;
					double rate=(k*C+p*D)/(1.0*i*A*100+j*B*100);
					if(rate<=lim&&ans<rate){
						ans=rate;
						x=i*A*100+j*B*100;
						y=k*C+p*D;
					}
						
				}
			}
		}
	}
	printf("%d %d\n",x+y,y);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
using namespace std;

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

template <class T> struct FenwickTree {

    vector < T > node;
    FenwickTree (int n) : node(n, 0) {}

    void add(int idx, T val) {
        for (int i = idx; i < node.size(); i |= i + 1) {
            node[i] += val;
        }
    }

    void update(int idx, T val) {
        add(idx, -sum(idx, idx + 1));
        add(idx, val);
    }

    T sum(int idx) {
        T ret = 0;
        for (int i = idx - 1; i >= 0; i = (i & (i + 1)) - 1) {
            ret += node[i];
        }
        return ret;
    }

    T sum(int l, int r) {
        return sum(r) - sum(l);
    }

};


long long InversionNumber(vector < int > &arr) {
    ll ret = 0;
    FenwickTree < ll > inst(100010);
    REP(i,arr.size()) {
        ret += inst.sum(arr[i] + 1);
        inst.add(arr[i], 1);
    }
    return ret;
}

ll N;
ll a[100010];

bool check (ll x) {
    vector < int > S(N + 1);
    REP(i,N) {
        if (a[i] >= x) S[i + 1] = 1;
        else S[i + 1] = -1;
    }
    REP(i,N) S[i + 1] = S[i] + S[i + 1];
    int min_v = 1e9;
    REP(i,N + 1) min_v = min(min_v, S[i]);
    REP(i,N + 1) S[i] -= min_v;
    REP(i,N + 1) S[i]++;

    ll inv = InversionNumber(S);
    ll Sum = N * (N + 1) / 2 + 1;
    if (Sum / 2 <= inv) return true;
    return false;
}

int main () {

    cin >> N;
    REP(i,N) cin >> a[i];

    ll l = 0, r = 1e9 + 7;
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        if (check(mid)) l = mid;
        else r = mid;
    }

    cout << l << endl;

    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
long long x,a,b;
int main(void)
{
    cin>>x>>a>>b;
    if(-a+b<=0)
    {
        cout <<"delicious"<<endl;
        return 0;
    }
    else if(-a+b<=x)
    {
        cout <<"safe"<<endl;
        return 0;
    }
    else
    {
        cout <<"dangerous"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#define N 23
typedef long long ll;
template<typename T> inline void read(T &x) {
	x = 0; char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
}
using namespace std;
const ll inf = 1e16;
inline void MIN(ll &a, ll b) {
	if (b < a)	a = b;
}
int n;
ll a[N];
ll dfs(int l, int r, int x, int y) {
	if (l == r - 1 || l == r)	return 0;
	ll res = inf;
	for (int i = l + 1; i < r; ++i)
		MIN(res, dfs(l, i, x, x + y) + dfs(i, r, x + y, y) + a[i] * (x + y));
	return res;
}
int main() {
	read(n);
	for (int i = 1; i <= n; ++i)	read(a[i]);
	printf("%lld\n", a[1] + a[n] + dfs(1, n, 1, 1));
	return 0;
}


Measured memory_bytes: 3116
n = int(input())
s = input()
dp = [[0] * (n + 1) for _ in range(n + 1)]
ans = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        if s[i] == s[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
            ans = max(ans, min(abs(i - j), dp[i][j]+1))
print(ans)


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

int main(){
	int a,b,c,d,e,f,g,h;
	int sum=0;
	while(cin>>a){
		if(a==0)break;
		b=1000-a;
		c=b/500;
		d=(b-500*c)/100;
		e=(b-500*c-100*d)/50;
		f=(b-500*c-100*d-50*e)/10;
		g=(b-500*c-100*d-50*e-10*f)/5;
		h=b-500*c-100*d-50*e-10*f-5*g;
		cout<<c+d+e+f+g+h<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cmath>

int main(void) {
	// in
	int n;
	std::cin >> n;
	std::vector<long long> a(n);
	for(int i = 0; i < n; ++i) std::cin >> a[i];

	// sum
	long long cost_all = -1;
	std::vector<long long> s(n, 0);
	
	for(int k = 0; k < 2; ++k) {
		long long cost = 0;
		if(k == 0) {
			s[0] = (a[0] > 0 ? a[0] : 1);
			cost += std::abs(a[0] - s[0]);
		}
		else {
			s[0] = (a[0] < 0 ? a[0] : -1);
			cost += std::abs(a[0] - s[0]);
		}
		for(int i = 1; i < n; ++i) {
			// current sum
			s[i] = s[i-1] + a[i];
			if(s[i] * s[i-1] < 0) continue;
			else {
				if(s[i-1] < 0) {
					cost += std::abs(1 - s[i-1] - a[i]);
					s[i] = s[i-1] + 1 - s[i-1];
				}
				else {
					cost += std::abs(- 1 - s[i-1] - a[i]);
					s[i] = s[i-1] - 1 - s[i-1];
				}
			}
		}
		if(cost_all < 0) cost_all = cost;
		else cost_all = (cost < cost_all ? cost : cost_all);
	}
	
	std::cout << cost_all << std::endl;

	return 0;
}


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

namespace AtCoder3005
{
	class Program
	{
		static void Main(string[] args)
		{
			C();
		}

		static void C()
		{
			var n = int.Parse(Console.ReadLine());
			var a = Console.ReadLine().Split().Select(x => long.Parse(x)).ToList();

			var maxAtLevelsByTop = new long[n + 1];
			var maxAtLevelsByBot = new long[n + 1];
			var minAtLevelsByBot = new long[n + 1];
			minAtLevelsByBot[n] = a[n];
			maxAtLevelsByBot[n] = a[n];

			for (int i = n - 1; i >= 0; i--)
			{
				var leavesAtLevel = a[i];
				var minNext = minAtLevelsByBot[i + 1];
				var maxNext = maxAtLevelsByBot[i + 1];

				var currentMin = leavesAtLevel + (minNext + 1 )/ 2;
				var currentMax = leavesAtLevel + maxNext;
				minAtLevelsByBot[i] = currentMin;
				maxAtLevelsByBot[i] = currentMax;
			}

			maxAtLevelsByTop[0] = 1;

			for (int i = 1; i <= n; i++)
			{
				var lastMax = maxAtLevelsByTop[i - 1];
				var d= lastMax - a[i - 1];

				var possible = d <= long.MaxValue / 8 ? d * 2 : long.MaxValue / 8;
				maxAtLevelsByTop[i] = possible;
			}

			long count = 0;
			for (int i = 0; i <= n; i++)
			{
				if (maxAtLevelsByTop[i] < minAtLevelsByBot[i])
				{
					Console.WriteLine(-1);
					return;
				}

				var maxCount = Math.Min(maxAtLevelsByTop[i], maxAtLevelsByBot[i]);
				count += maxCount;
			}

			Console.WriteLine(count);
		}

		static void B()
		{
			var str = Console.ReadLine();
			var newStr = str.Replace('?', 'D');
			Console.WriteLine(newStr);
		}

		static void A()
		{
			var ints = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
			var h1 = ints[0];
			var m1 = ints[1];
			var h2 = ints[2];
			var m2 = ints[3];
			var k = ints[4];

			var start = 60 * h1 + m1;
			var end = 60 * h2 + m2;
			if (end < start)
				end += 1440;

			var diff = end - start;
			Console.WriteLine(diff - k);
		}
	}
}


Measured memory_bytes: 39480
while (True):
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    cnt = 0
    n += 1
    for i in range(1, n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if (i + j + k == x):
                    cnt += 1
    print(cnt)



Measured memory_bytes: 5592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            long x = in.nextLong();
            long ans = 0;
            long p = 0;
            long i = 0;
            while (p != x) {
                if (p + i == x || (p + 2 * i + 1 < x)) {
                    ans++;
                    p += i;
                }
                i++;
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

    }
}



Measured memory_bytes: 22868
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    if (a >= 10){
      System.out.println(b);
    }
    else{
      int g = 10-a;
      System.out.println(g*100+b);
    }
  }
}


Measured memory_bytes: 35768
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)

const double pi=acos(-1);
// cout<<fixed<<setprecision(15)

int main(){
  double r;
  cin>>r;
  
  cout<<fixed<<setprecision(10)<<r*r*pi<<" "<<2*pi*r<<endl;
}


Measured memory_bytes: 3188
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	dp := makeGrid(n+1, n+1)
	ww := makeGrid(n<<1+1, n+1)
	bb := makeGrid(n<<1+1, n+1)

	wa := map[int]int{}
	ba := map[int]int{}
	for i := 0; i < n<<1; i++ {
		c := getNextString(scanner)
		a := getNextInt(scanner)
		if c == "W" {
			ww[i+1][a]++
			wa[a] = i
			continue
		}
		bb[i+1][a]++
		ba[a] = i
	}
	for i := 0; i < n<<1+1; i++ {
		for j := 0; j < n; j++ {
			ww[i][j+1] += ww[i][j]
			bb[i][j+1] += bb[i][j]
		}
	}
	for j := 0; j < n+1; j++ {
		for i := 0; i < n<<1; i++ {
			ww[i+1][j] += ww[i][j]
			bb[i+1][j] += bb[i][j]
		}
	}
	for i := 0; i < n+1; i++ {
		for j := 0; j < n+1; j++ {
			dp[i][j] = math.MaxInt32
		}
	}
	dp[0][0] = 0
	for w := 0; w < n+1; w++ {
		for b := 0; b < n+1; b++ {
			if w < n {
				dp[w+1][b] = min(dp[w+1][b], dp[w][b]+cost(n, w, b, wa[w+1], wa[w+1], ww, bb))
			}
			if b < n {
				dp[w][b+1] = min(dp[w][b+1], dp[w][b]+cost(n, w, b, ba[b+1], ba[b+1], ww, bb))
			}
		}
	}
	fmt.Fprintln(writer, dp[n][n])
}

func makeGrid(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func cost(n, w, b, wi, bi int, ww, bb [][]int) int {
	costw := ww[n<<1][w] - ww[wi][w]
	costb := bb[n<<1][b] - bb[bi][b]
	return costw + costb
}


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

const ll mod = ll(1e9) + 7;
const int INF = 1<<29;
const ll lINF = 1l<<40;

int main(){
    int n,q;
    cin >> n;
    vecInt a(n);
    rep(i,0,n) cin >> a[i];
    cin >> q;
    vector<P> bc(q);
    rep(i,0,q){
        int b,c;
        cin >> b >> c;
        bc[i] = make_pair(b,c);
    }
    vecInt v(100010);
    ll ans = 0;
    rep(i,0,n){
        v[a[i] ] += 1;
        ans += a[i];
    }
    rep(i,0,q){
        int b,c;
        b = bc[i].first;
        c = bc[i].second;
        ans += (c - b) * v[b];
        v[c] += v[b];
        v[b] = 0;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4820
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define bs binary_search
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define mkp make_pair
#define mod 1000000007
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,m;
	cin>>n;
	char ar[n+1];
	ll fe[26]={0};
	cin>>ar;
	for(i=0;i<n;i++){
		fe[ar[i]-'a']++;
	}

	k=1;
	for(i=0;i<26;i++){
		k=((k%mod)*((fe[i]+1)%mod))%mod;
	}
	cout<<k-1;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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

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

	map<int,int> mp;
	int N;
	cin>>N;

	for (int i = 0; i < N; i++) {
		int tmp;
		cin>>tmp;
		mp[tmp]++;
	}

	cout << mp.size() << endl;

	return 0;
}

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

int mod;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

ll b, ten;

mint pow_(mint x, ll t) {
  if (t == 0) return 1;
  if (t%2 == 1) {
    return pow_(x,t-1)*x;
  } else {
    mint y = pow_(x,t/2);
    return y*y;
  }
}

mint f(ll l) {
  if (l == 0) return 0;
  if (l%2 == 1) {
    ll pl = l-1;
    mint x = f(pl);
    return x*ten + 1;
  } else {
    ll pl = l/2;
    mint x = f(pl);
    return x*pow_(ten, pl) + x;
  }
}
mint g(ll l) {
  if (l == 0) return 0;
  if (l%2 == 1) {
    ll pl = l-1;
    mint x = g(pl);
    return x*ten + mint(b)*pl;
  } else {
    ll pl = l/2;
    mint x = g(pl);
    return x*pow_(ten, pl) + x + mint(b)*pl*f(pl);
  }
}

int main() {
  ll L, a;
  cin >> L >> a >> b >> mod;
  ll last = a+b*(L-1);
  mint ans = 0;
  ten = 10;
  for (int i = 1; i <= 18; ++i, ten *= 10) {
    ll l = ten/10, r = ten-1;
    if (last < l) continue;
    if (a > r) continue;
    ll na = 0; // 初項
    ll nl = 0; // 長さ
    {
      if (a >= l) na = a;
      else {
        na = ((l-a)+(b-1))/b*b+a;
        na = min(na, last);
      }
    }
    {
      ll nlast = 0;
      if (last <= r) nlast = last;
      else {
        nlast = (r-a)/b*b+a;
      }
      nl = (nlast-na)/b+1;
    }
    // cerr << i << ' ' << na << " " << nl << endl;
    ans *= pow_(ten, nl);
    ans += f(nl)*na;
    ans += g(nl);
    // cerr << f(nl).x << endl;
    // cerr << g(nl).x << endl;
    // cerr << ans.x << endl;
  }
  cout << ans.x << endl;
  return 0;
}    


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

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

    vector<long long> divs = divisor(N);
    long long ans = 100100100100100;
    for (int i = 0; i < divs.size(); i++) {
        chmin(ans, divs[i] + divs[divs.size() - i - 1] - 2);
    }
    cout << ans << endl;
}

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

int main(void){
    string s;
    cin >> s;
    int a = -1, z = -1;
    for (int i=0; i<s.size(); i++){
        if (a==-1 && s[i]=='A') a = i;
        if (z==-1 && s[s.size()-1-i]=='Z') z = s.size()-1-i;
        if (a!=-1 && z!=-1) break;
    }
    cout << z - a + 1 << endl;
    return 0;
}

Measured memory_bytes: 3720
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            Console.WriteLine(N * (N + 1) / 2);
        }
    }
}


Measured memory_bytes: 27436
def atoNum(s):
    return ord(s)-97
where = [[]for i in range(0,26,1)]
from bisect import bisect_right

s = list(input())
t = list(input())

for i in range(0,len(s),1):
    where[atoNum(s[i])].append(i)
ans = 0
cersol = -1

for i in range(0,len(t),1):
    if len(where[atoNum(t[i])])==0:
        print(-1)
        exit()
    tmpCersol = bisect_right(where[atoNum(t[i])],cersol)
    if tmpCersol < len(where[atoNum(t[i])]):
        cersol = where[atoNum(t[i])][tmpCersol]
    else:
        ans += len(s)
        cersol = where[atoNum(t[i])][0]
ans += cersol
print(ans+1)

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

#define i64 int64_t


int main()
{
  int K;
  cin >> K;
  
  queue<i64> lunlunQueue;
  lunlunQueue.push(1);
  lunlunQueue.push(2);
  lunlunQueue.push(3);
  lunlunQueue.push(4);
  lunlunQueue.push(5);
  lunlunQueue.push(6);
  lunlunQueue.push(7);
  lunlunQueue.push(8);
  lunlunQueue.push(9);
  
  int i;
  i64 num;
  for(i=0;i<K;i++){
    num = lunlunQueue.front();
    lunlunQueue.pop();
    
    if(num%10 != 0)lunlunQueue.push(10*num+num%10-1);
    
    lunlunQueue.push(num*10+num%10);

    if(num%10!=9)lunlunQueue.push(10*num+num%10+1);
  }
  
  cout << num;
}

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

#define ii pair<int, int>
#define vi vector<int>
#define LL long long int 
#define VLL vector<LL>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define INF int(1e9)

using namespace std;
bool isPrime(int n) { 
  int cont = 0;
  for (int i=1; i<=sqrt(n); i++) { 
    if (n%i==0) { 
      if (n/i == i)
        cont++;
      else
          cont+=2;
    } 
  } 
  return (cont==2?1:0);
} 


int main () {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    for(int i=n; ; i++){
        if(isPrime(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest114-B
#  https://beta.atcoder.jp/contests/abc114/tasks/abc114_b


def minus_753(s):

	length = len(s)
	extractLength=3
	minDiff=999
	for i in range(0,length-2,1):
		checkInt=int(s[i:i+extractLength])
		nowDiff = abs(checkInt-753)
		if nowDiff < minDiff :
			minDiff = nowDiff

	answer=minDiff
	return answer


if __name__ == '__main__':
	problemStr=input()
	answerInt=minus_753(problemStr)
	print(answerInt)

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

int main(){
  int iv,ie,r;
  cin >> iv >> ie >> r;
  int d[100010];
  for (int i=0;i<iv;i++){
    d[i]= 1000000010;
  }
  d[r]=0;
  vector<pair<int,int> > w(ie);
  vector<int> cost(ie);
  for(int i=0;i<ie;i++){
    int s0,e0,d0;
    cin>>s0>>e0>>d0;
    w[i] = make_pair(s0,e0);
    cost[i]=d0;
  }
  for(int i=0;i<iv-1;i++){
    int k=0;
    for(int j=0;j<ie;j++){
      int s1,e1,d1;
      s1=w[j].first;
      e1=w[j].second;
      d1=cost[j];
      if(d[e1]>d[s1]+d1) k+=1;
      d[e1]=min(d[e1],d[s1]+d1);
    }
    if(k==0) break;
   }

  for(int i=0;i<iv;i++){
    if(d[i]==1000000010){
      cout<<"INF"<<endl;
    }else{
      cout<<d[i]<<endl;
    }
  }
}

Measured memory_bytes: 8768
/*
取りうる座標はn * D + X(n は任意の実数）
よって各座標から初期座標を引いて最大公約数を求めるだけ
*/
#include <bits/stdc++.h>
using namespace std;

// C++17ならgcd導入されてるらしいんですけどね
// スタートに都市は無いという条件なので引数が0になることは無い。よってy!=0のチェック不要
int gcd(int x, int y)
{
  if(x < y)
  {
    int temp;
    temp = x;
    x = y;
    y = temp;
  }

  while(x % y != 0)
  {
    int temp;
    temp = x;
    x = y;
    y = temp % y;
  }

  return y;
}

int main()
{
  int N, X;
  cin >> N >> X;
  
  int ans;
  cin >> ans;
  // 座標　- スタートで負になる場合があるので。計算上絶対値で問題ない
  ans = int(abs(ans - X));
  
  // 複数の値（a, b, c, d......)の最大公約数を求める
  // aとbのgcdを求める。その答えとcのgcdを求める。その答えとdの以下略
  for(int i = 1; i < N; ++i)
  {
    int city;
    cin >> city;
    city = int(abs(city - X));
    ans = gcd(ans, city);
  }

  cout << ans << endl;

  return 0;
}    

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll X, N;
    ll mini = numeric_limits<ll>::max();
    ll ans = 0;
    bool values[300] = {};
    cin >> X >> N;
    rep(i, N) {
        ll temp;
        cin >> temp;
        values[100 + temp] = true;
    }
    rep(i, 300) {
        if(!values[i]) {
            ll temp = abs(X - (i - 100));
            if(temp < mini) {
                mini = temp;
                ans = i - 100;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
s = int(input())
a = s//100
b = s%100
if b <= 12 and b >= 1:
    if a <= 12 and a >= 1:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if a <= 12 and a >= 1:
        print("MMYY")
    else:
        print("NA")

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    lli A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    lli ans = 0;
    lli m = min(X, Y);
    ans += min(A + B, 2 * C) * m;
    X -= m;
    Y -= m;
    ans += Y * min(B, 2 * C);
    ans += X * min(A, 2 * C);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int n;
        scanf("%d",&n);
        if(n == 0) break;
        int msum = 500,mxsum = 0;
        for(int i = 0; i < n; i++){
            int sum = 0;
            for(int i = 0; i < 5; i++){
                int a;
                scanf("%d",&a);
                sum += a;
            }
            msum = min(msum,sum);
            mxsum = max(mxsum,sum);
        }
        printf("%d %d\n",mxsum,msum);
    }

    return 0;
}

Measured memory_bytes: 1028
class Card
  attr_reader :suit, :number

  def initialize(suit, number)
    @suit   = suit
    @number = number.to_i
  end

  def <=(other)
    @number <= other.number
  end

  def prints
    print "#{suit} #{number}\n"
  end

  def <=>(other)
   @number - other.number 
  end
end

def quick_sort(a, p, r)
  if p < r
    q = partition(a, p, r)
    quick_sort(a, p, q-1)
    quick_sort(a, q+1, r)
  end
end

def partition(a, p, r)
  x = a[r]
  i = p-1
  p.upto(r-1) do |j|
    if a[j] <= x
      i += 1
      tmp  = a[i]
      a[i] = a[j]
      a[j] = tmp
    end
  end
  tmp    = a[r]
  a[r]   = a[i+1]
  a[i+1] = tmp
  return i+1
end

n = STDIN.gets.to_i
inputs = STDIN.read.split("\n")

cards = []

inputs.each do |input|
  card = input.split(" ")
  cards.push(Card.new(card[0],card[1]))
end
orig_cards = cards.dup

quick_sort(cards,0,cards.length-1)

if cards==orig_cards.sort
  print "Stable\n"
else
  print "Not stable\n"
end

cards.each do |card|
  card.prints
end

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	map<int32, int32> mp[2];
	int32 n;
	cin >> n;
	REP(i, n){
		int32 v;
		cin >> v;
		mp[i%2][v]++;
	}
	vector<PII> v[2];
	REP(i, 2){
		for(auto x : mp[i]){
			v[i].push_back(PII(x.sc, x.fs));
		}
		sort(all(v[i]), greater<PII>());
	}
	if(v[0][0].sc == v[1][0].sc){
		cout << min(n-v[0][0].fs-v[1][1].fs, n-v[0][1].fs-v[1][0].fs) << endl;
	}else{
		cout << n-v[0][0].fs-v[1][0].fs << endl;
	}
}


Measured memory_bytes: 8824
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	A := nextInt()
	B := nextInt()
	if B == 1 {
		fmt.Fprintln(out, 0)
		return
	}
	ans := 1
	B -= A
	for ; B > 0; B -= (A - 1) {
		ans++
	}
	fmt.Fprintln(out, ans)
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// Genericsがないので筋肉で...
// interfaceでの取扱がようわからんし
func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// mapからkeysとvaluesを返す感じのやつ
// なんかしらんけどmap[interface{}]interface{}しか受け付けない。なんのためのinterface{}やねん
// なので呼ぶときのmapはmap[int]stringとかじゃダメ
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


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

using namespace std;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    for (int i = 0 ; i < 4; ++i)
        cout << s[i];
    cout << ' ';
    for (int i = 4; i < s.length(); ++i)
        cout << s[i];
    cout << endl;
    return 0;
}


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

int z[15];

int main(){
  
  int a,b,c;cin>>a>>b>>c;
  z[a]++;z[b]++;z[c]++;
  if(z[a]==2 ||z[b]==2||z[c]==2)cout<<"Yes";
  else cout<<"No";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.util.control.Breaks

object Main extends App {

  val b = new Breaks

  val sc = new Scanner(System.in)
  val n = sc.nextInt()
  val y = sc.nextInt()

  b.breakable {
    for (itiman <- 0 to n) {
      for (gosen <- 0 to n - itiman) {
        if (y == itiman * 10000 + gosen * 5000 + (n - itiman - gosen) * 1000) {
          println(s"$itiman $gosen ${n - itiman - gosen}")
          b.break()
        }
      }
    }
    println("-1 -1 -1")
    b.break()
  }
}


Measured memory_bytes: 27316
/*
    やるだけに時間を取られて辛い
 */

#include <cstdio>
#include <cassert>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

#define INF 0x7fffffff

typedef pair<int, int> Pair;

int n;
Pair ps[500000];

bool cmp(const Pair &a, const Pair &b) {
    if (a.second != b.second) return a.second < b.second;
    return a.first < b.first;
}

int shortest(Pair *ps, int n) {
    Pair *r;
    int lsize = n/2;
    int rsize = n-lsize;
    int minval;
    int xline;
    vector<Pair> within;

    if (n <= 1) return INF;
    
    r = ps + lsize;
    xline = ps[lsize].first;
    minval = min(shortest(ps, lsize), shortest(r , rsize));
    inplace_merge(ps, ps+lsize, ps+n, cmp);

    for (int i=0; i<n; i++) {
        int size;
        int cmpval = xline-ps[i].first;
        if (cmpval*cmpval >= minval) continue;

        size = (int)within.size()-1;
        for (int j=size; j>=0; j--) {
            int diffx = ps[i].first - within[j].first;
            int diffy = ps[i].second - within[j].second;

            assert(diffy >= 0);
            if (diffy*diffy >= minval) break;
            minval = min(minval, diffx*diffx + diffy*diffy);
        }
        within.push_back(ps[i]);
    }

    return minval;
}

int main() {
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        ps[i] = Pair(x, y);
    }
    sort(ps, ps+n);
    
    printf("%d\n", shortest(ps, n));
}

Measured memory_bytes: 10548
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    
    for c in s.chars() {
        let x = match c {
            t @ 'a'...'z' => t.to_uppercase().to_string(),
            t @ 'A'...'Z' => t.to_lowercase().to_string(),
            t => t.to_string(),
        };

        print!("{}", x);
    }
}



Measured memory_bytes: 5052
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long n,m;
int main(){
	cin>>n>>m;
	if(n!=1&&m!=1)
	{
		cout<<(n*m+1)/2<<'\n';
		return 0;
	}
	cout<<1;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int a,b;
    cin>>a>>b;
    if(a-b-b>=0){
        cout<<a-b-b<<endl;
    }
    else{
        cout<<0<<endl;
    }
}

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

int main() {
    int n;
    cin>>n;
    int first, second, curr;
    cin>>first>>second;
    int prev1 = 0, prev2 = abs(second - first), temp;
    for(int i=2; i<n; i++) {
        cin>>curr;
        temp = prev1, prev1 = prev2;
        prev2 = min(temp + abs(curr - first), prev1 + abs(curr - second));
        first = second, second = curr;
    }
    cout<<prev2<<endl;
    return 0;
}


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

int di[] = {0,1};
int dj[] = {1,0};

int main(){
  int h,w;
  cin >> h >> w;
  
  vector<string> a(h);
  rep(i,h) cin >> a[i];
  
  bool ok = true;
  
  queue<P> q;
  q.emplace(0,0);
  
  vector<vector<bool>> map(h,vector<bool>(w));
  map[0][0] = true;
  while( !q.empty() ){
    int i = q.front().first;
    int j = q.front().second; q.pop();
    bool flag[2]; 
    flag[0]  = false; flag[1] = false;
    rep(dir,2){
      int ni = i + di[dir];
      int nj = j + dj[dir];
      if(ni<0||nj<0||ni>=h||nj>=w) continue;
      if(a[ni][nj] == '.') continue;
      flag[dir] = true;
      map[ni][nj] = true;
      q.emplace(ni,nj);
    }
    if(flag[0] && flag[1]) ok = false;
  }
  
  rep(i,h) rep(j,w){
    if(a[i][j] == '#') ok &= map[i][j];
  }
  
  cout << ( ok ? "Possible" : "Impossible" ) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,i;
	char s[101];
	while(~scanf("%d",&n))
	{
		int sum1=0,sum2=0;
		scanf("%s",s);
		for(i=0;i<n;i++)
		{
			if(s[i]=='R')
			{
				sum1++;
			}
			if(s[i]=='B')
			{
				sum2++;
			}
		}
		if(sum1>sum2)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
} 


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

typedef long long ll;

string N;
int K;

ll dp[101][2][5];

ll solve(int pos = 0, bool tight = true, int ck = 0)
{
    if (ck > K) {
        return 0;
    }
    if (pos == N.size()) {
        return ck == K ? 1 : 0;
    }

    int digit = N[pos] - '0';

    ll& rdp = dp[pos][tight][ck];
    if (~rdp) return rdp;

    ll res = 0;
 
    for (int i = 0; i <= (tight ? digit : 9); i++) {
        res += solve(pos+1, tight && digit == i, i==0 ? ck : ck + 1);
    }

    return rdp = res;
}

int main()
{
    cin >> N>>K;
    memset(dp, -1, sizeof(dp));

    cout << solve() <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
    char str[11];
    char str2[11];
    scanf("%s", str);
    scanf("%s", str2);
    for(int i = 0; i < strlen(str);i++){
        if(str[i] != str2[i]){
            printf("No");
            return 0;
        }
    }
    if(strlen(str) + 1== strlen(str2)){
        printf("Yes");
    }else
    {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  int count = 0;
  int i = 0;
  while(i < n){
    int j = i + 1;
    while(j < n && s[i] == s[j]){
      ++j;
    }
    ++count;
    i = j;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 1144
#include "bits/stdc++.h"
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

const ll MOD = 1000000007;

void Main() {
  ll n;
  cin >> n;
  vector<ll> C(n);
  rep(i, n) cin >> C[i];
  sort(C.begin(), C.end());
  ll ans = 0;
  ll nn = 1;
  ll nnn = 1;
  ll nnnn = 1;
  rep(i, n)(nn *= 2) %= MOD;
  rep(i, n - 1)(nnn *= 2) %= MOD;
  rep(i, n - 2)(nnnn *= 2) %= MOD;
  rep(i, n) {
    ll x = ((nnn) + (n - i - 1) * (nnnn)) % MOD;
    (x *= (nn)) %= MOD;
    (x *= C[i]) %= MOD;
    (ans += x) %= MOD;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



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

namespace abc061_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] number = Console.ReadLine().Split(' ');
            int A = int.Parse(number[0]);
            int B = int.Parse(number[1]);
            int C = int.Parse(number[2]);

            if(C >= A && C <= B)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
const int N=2e6;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int p[N];
int head[N],nxt[N],to[N],d[N],tot,ans[N];
struct cmp{ inline bool operator () (const int &a,const int &b) const { return p[a]<p[b]; } };
struct cmp2{ inline bool operator () (const int &a,const int &b) const { return a>b; } };
inline void link(int a,int b) { d[to[++tot]=b]++,nxt[tot]=head[a],head[a]=tot; }
int main()
{
	int n=gi(),m=gi(),i,k,t;
	for (i=1;i<=n;i++) p[i]=gi();
	set<int,cmp>s;set<int>::iterator it;
	priority_queue<int,vector<int>,cmp2>q;
	for (i=1;i<=n;i++) {
		if (i>m) s.erase(i-m);
		it=s.insert(i).first;
		if (++it!=s.end()) link(i,*it);
	}
	s.clear();
	for (i=n;i;i--) {
		if (i+m<=n) s.erase(i+m);
		it=s.insert(i).first;
		if (++it!=s.end()) link(i,*it);
	}
	for (i=1;i<=n;i++) if (!d[i]) q.push(i);
	for (t=1;t<=n;t++) {
		k=q.top();q.pop();
		ans[k]=t;
		for (i=head[k];i;i=nxt[i]) if (!--d[to[i]]) q.push(to[i]);
	}
	for (i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 53504