akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public enum mark{

		S,
		H,
		C,
		D;

	}

	public static void main(String[] args) {

		List<String> allCard = new ArrayList<>();

		for(mark mark: mark.values()){

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

				allCard.add(String.valueOf(mark) + " " + i);

			}
		}

		Scanner in = new Scanner(System.in);

		int cardCount = in.nextInt();

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

			allCard.remove(in.nextLine());

		}

		for(String result: allCard) {

			System.out.println(result);

		}
	}
}

Measured memory_bytes: 26248
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<vector<int> > f(n,vector<int >(10,0));
  REP(i,n){
    REP(j,10){
      cin >> f[i][j];
    }
  }
  vector<vector<int> > p(n,vector<int >(11,0));
  REP(i,n){
    REP(j,11){
      cin >> p[i][j];
    }
  }
  int ans = -1e9;
  for(int bit = 1; bit < (1 << 10);bit ++){
    // cout << bit << endl;
    int score = 0;
    vector<int > tmp(n,0);
    // date
    REP(i,10){
      if(bit & (1 << i)){
	REP(j, n){
	  if(f[j][i] == 1){
	    tmp[j] ++;
	  }
	}
      }
    }
    // date

    // score
    REP(i,n){
      score += p[i][tmp[i]];
    }
    // score
    ans = max(ans,score);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
module Main where

import qualified Data.ByteString.Char8         as BS
import           Data.List
import           Data.Char
import           Control.Arrow
import qualified Data.IntSet                   as IntSet
import qualified Data.Vector.Unboxed           as VU

main :: IO ()
main = do
  [n] <- unfoldr (BS.readInteger . BS.dropWhile isSpace) <$> BS.getLine
  print $ solve n
 where
  solve n = minimum
    $ map (\x -> if mod n x == 0 then x - 1 + div n x - 1 else n) [1 .. sqn]
    where sqn = floor $ sqrt $ fromIntegral n


Measured memory_bytes: 892
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <fstream>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <assert.h>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 998244353LL 
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
 
 
#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
 
//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)
 
struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
 
};
typedef vector<vector<Edge>> Graph;
typedef unsigned long long ull;
 
 
inline ll ksum(ll n, ll k){
  return k * (2*n - k - 1);
}

pii updtp2(pii p, int nw){
  if(p.first == -1) p.first = nw;
  else if(p.second == -1) p.second = nw;
  else if(p.first >= nw) {
    p.second = p.first;
    p.first = nw;
  }
  else if(p.second >= nw) p.second = nw;
  return p;
}
 
#define isValid(y,x) (y >=0 && y < n && x >= 0 && x < m)

int main(){
  string s;
  cin >> s;
  int c = 0;
  for(auto& itr : s){
    if(itr == '?') itr = 'D';
  }

  // REP(i, s.length()){
  //   if(s[i] == 'D') c++;
  //   if(i > 0 && s[i-1] == 'P' && s[i] == 'D') c++;
  // }

  cout << s << endl;
	return 0;
} 

Measured memory_bytes: 3748
n = int(input())
s = []
for i in range(n):
    a = input()
    s.append(a)
m = int(input())
t = []
for i in range(m):
    a = input()
    t.append(a)
c = []
k = 0
for i in s:
    for j in s:
        if i == j:
            k += 1
    for j in t:
        if i == j:
            k -= 1
    c.append(k)
    k = 0
if max(c) < 0:
    print(0)
else:
    print(max(c))


Measured memory_bytes: 3064
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MOD 1000000007

void solve();

string s;
int len;
string t;

int main() {
  cin >> s;
  len = (int)(s.length());

  solve();

  return 0;
}

void solve() {

  rep(i, len) {
    if(s[i]=='0') t += '0';
    else if(s[i]=='1') t += '1';
    else if((int)(t.length()!=0))t.pop_back();
  }

  cout << t << endl;
}


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

int main(){
  int n,l;
  int res = 0;
  cin >> n >> l;
  vector<int> t(n+1);
  for(int i = 1; i <= n; ++i){
    t[i] = l + i - 1;
  }
  int p = 100000;
  for(int i = 1; i <= n; ++i){
    p = min(p,abs(t[i]));
  }
  //cout << p << endl;
  for(int i = 1; i <= n; ++i){
    if(t[i] != p && t[i] != -1 * p){
      res += t[i];
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3592
#include<iostream>

#define LL long long

using namespace std;

const int maxn=100010;

int po[maxn],dis[maxn];
int cha[maxn],tmp[maxn];
int ans[maxn];
int n;

void work(int a[],int b[])
{
    for (int j=1;j<n;++j)
        tmp[j]=a[b[j]];
    for (int j=1;j<n;++j)
        a[j]=tmp[j];
    return;
}

int main()
{
    cin>>n;
    for (int j=1;j<=n;++j)
        cin>>po[j];

    for (int j=1;j<n;++j)
        dis[j]=po[j+1]-po[j];

    for (int j=1;j<n;++j)
        cha[j]=j;

    int m;
    long long int num;

    cin>>m>>num;

    for (int j=1;j<=m;++j)
    {
        int x;
        cin>>x;
        swap(cha[x-1],cha[x]);
    }

    while (num)
    {
        if (num&1)
            work(dis,cha);
        work(cha,cha);
        num/=2LL;
    }
    cout<<po[1]<<".0\n";
    LL sum=po[1];
    for (int j=1;j<n;++j)
    {
        sum+=dis[j];
        cout<<sum<<".0\n";
    }
    return 0;
}


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

typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;

#define MOD1        1000000007
#define MOD2        998244353
#define PI          3.1415926535897932384626433832795
#define FILL(a, value) memset(a, value, sizeof(a))
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ASSERT(left,operator,right) { if(!((left) operator (right))){ std::cerr << "ASSERT FAILED: " << #left << #operator << #right << " @ " << __FILE__ << " (" << __LINE__ << "). " << #left << "=" << (left) << "; " << #right << "=" << (right) << std::endl; } }

#define rep01(k,n)      for (ll i=k; i<n; i++)
#define rep02(k,n)      for (ll j=k; j<n; j++)
#define rep03(k,n)      for (ll k=k; k<n; k++)
#define rep11(k,n)      for (ll i=k; i<=n; i++)
#define rep12(k,n)      for (ll j=k; j<=n; j++)
#define rep13(k,n)      for (ll k=k; k<=n; k++)
#define repIT(c,it)     for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define all(c)      c.begin(), c.end()

using namespace std;

const double pi = acos(-1.0);
const double epsilon = 1e-9;        // Add epsilon when casting double to int to avoid rounding pitfall issues, eg, 0.94*8178 in int
const int maxn = 1e6+10;

void solve()
{
    string s;
    cin >> s;

    int ans = 0, curr = 0;
    for(int i = 0; i < s.length(); i++)
    {
        if(s[i]== 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T')
            curr++;
        else
        {
            ans = max(ans, curr);
            curr = 0;
        }
    }
    cout << max(ans, curr);

}

int main()
{
   
    int t = 1;
    //cin >> t;
    while(t--)
        solve();

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3832
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
    int W,H;
    while(1){
        scanf("%d %d",&H,&W);
        if(W==0&&H==0){
            break;
        }
        for(int i=0; i<H; i++){
            for(int i=0; i<W; i++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}



Measured memory_bytes: 2616
package main

import (
	"fmt"
)

func main() {
	var N string
	fmt.Scan(&N)
	
	if (N[0] == N[1] && N[1] == N[2] || N[1] == N[2] && N[2] == N[3]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  int count;
  for(int i=1,a;i<=N;i++){
    cin >> a;
    if(a!=i)count++;
  }
  if(count>2)
    cout<<"NO";
  else
    cout<<"YES";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <bits/stdc++.h>
#include <string>
#define pb          push_back
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353
#define PI          3.141592653589
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define MAX 1e18
#define MIN -1e9
#define ll long long
#define ull unsigned long long
#define ld long double
#define all(x) x.begin(),x.end()
#define rep(i, l, r) for (ll i = (l); i < (r); i++)
#define repb(i, r, l) for (ll i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define cl(x) (int)ceil((double)x/2);
#define fl(x) (int)floor((double)x/2);
#define watch(x) cout << (#x) << " is " << (x) << endl
using namespace std;
//cout << fixed << setprecision(13) << x;
bool cmp(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second < b.second);
}

bool mod(double a,double b)
{
    return a/b - floor(a/b);
}

int logb(int base, int x)
{
    return (log(x) / log(base));
}

void sortString(string &str)
{
    sort(str.begin(), str.end());
}

int lcm(int a,int b)
{
    return (a*b)/__gcd(a,b);
}

bool find(ll x,ll a[],ll n)
{
    rep(i,0,n)
    if(a[i]==x)
        return true;
    return false;
}

//floor(log10(N)) + 1;
//swap two no.		a ^= b; b ^= a; a ^= b;
// to_string(s)  to convert the string to int
//x ^ ( x & (x-1)) : Returns the rightmost 1 in binary representation of x.
//x&(-x) : Returns the rightmost 1 in binary representation of x.
//x | (1 << n) : Returns the number x with the nth bit set.
int btd(ll n)
{
    ull num = n,dec_value = 0,base = 1,temp = num;
    while (temp)
    {
        int last_digit = temp % 10;
        temp = temp / 10;

        dec_value += last_digit * base;

        base = base * 2;
    }
    return dec_value;
}

bool isPowerOfTwo (int x) { return x && (!(x&(x-1))); }


int main()
{
    FLASH
   ll n;
   cin>>n;
   string a;
   cin>>a;

   ll l=0,r=n-1,cnt=0;

   while(l<r)
   {
       while(a[l]=='R')
        l++;

       if(a[r]=='R' && l!=r+1)
       {
           swap(a[r],a[l]);
           r--;
           cnt++;
       }
       else
        r--;
        
   }
    cout<<cnt<<endl;

   return 0;

}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define UM unordered_map
#define MP map
#define ST set
#define US unordered_set
#define V vector
#define S string
#define D deque
#define L list
#define Q queue
#define PQ priority_queue
#define DB double
#define LDB long double
#define FOR(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define FFOR(i, n) for (int(i) = 0; (i) <= (n); ++(i))
#define RFOR(i, n) for (int(i) = (n)-1; (i) >= 0; --(i))
#define all(v) (v).begin(), (v).end()

const int dr[] = {0, 1, 0, -1};
const int dc[] = {1, 0, -1, 0};

int nxt()
{
    int n;
    cin >> n;
    return n;
}

LL llnxt()
{
    LL l;
    cin >> l;
    return l;
}

LDB ldbnxt()
{
    LDB n;
    cin >> n;
    return n;
}

DB dbnxt()
{
    DB n;
    cin >> n;
    return n;
}

void bfs(VVI &graph, int start)
{
    int n = graph.size();
    Q<int> q;
    V<bool> visited(n);
    q.push(start);
    visited[start] = true;
    while (not q.empty())
    {
        auto curr = q.front();
        q.pop();
        for (auto i : graph[curr])
        {
            if (not visited[i])
            {
                q.push(i);
                visited[i] = true;
            }
        }
    }
}

int main()
{
    int n;
    cin >> n;
    MP<int, int> m;
    LL sum = 0;
    FOR(i, n)
    {
        int t;
        cin >> t;
        sum += t;
        m[t]++;
    }
    int k;
    cin >> k;
    FOR(i, k)
    {
        int b, c;
        cin >> b >> c;
        sum += (LL)m[b] * (c - b);
        m[c] += m[b];
        m[b] = 0;
        cout << sum << "\n";
    }
}

Measured memory_bytes: 7956
n = gets.to_i
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)

z = n.times.map{|i| (x[i] - y[i]).abs}

1.upto(3) do |_p|
	d = z.map{|i| i ** _p}.inject(&:+) ** (1r/_p)
	puts "%.6f" % d
end

puts "%.6f" % z.max

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

const long long MOD=1000000007;

int main(void){
    // Your code here!
    int N;
    cin >> N;
    
    long long K=1, L=1, M=1;
    
    for (int i=1; i<=N; i++){
        K *= 10, L *= 9, M *= 8;
        K = K%MOD, L = L%MOD, M = M%MOD;
    }
    
    long long ans=K-2*L+M+2*MOD;
    ans = ans % MOD;
    
    cout << ans << endl;
    
    return 0;
}

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

void add_dir(string& way, char dir, int num) {
    for (int i = 0; i < num; i++) {
        way.push_back(dir);
    }
}

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string way = "";
    add_dir(way, 'U', ty - sy);
    add_dir(way, 'R', tx - sx);
    add_dir(way, 'D', ty - sy);
    add_dir(way, 'L', tx - sx);
    add_dir(way, 'L', 1);
    add_dir(way, 'U', ty - sy + 1);
    add_dir(way, 'R', tx - sx + 1);
    add_dir(way, 'D', 1);
    add_dir(way, 'R', 1);
    add_dir(way, 'D', ty - sy + 1);
    add_dir(way, 'L', tx - sx + 1);
    add_dir(way, 'U', 1);

    cout << way << endl;
    return 0;
}

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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  if(A >= K){
    cout << K << endl;
  }
  else if(A + B >= K){
    cout << A << endl;
  }
  else{
    cout << A - (K - A - B);
  }
}

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

using namespace std;

int main(){
    string s;
    cin>>s;
    auto sa=s.substr(0,2);
    auto sb=s.substr(2,2);
    int a=stoi(sa),b=stoi(sb);
    bool ym=false,my=false;
    if(1<=b&&b<=12)ym=true;
    if(1<=a&&a<=12)my=true;
    if(ym&&my)cout<<"AMBIGUOUS"<<endl;
    else if(ym)cout<<"YYMM"<<endl;
    else if(my)cout<<"MMYY"<<endl;
    else cout<<"NA"<<endl;
    return 0;
}

Measured memory_bytes: 256
loop do
  m, f, r = gets.split.map(&:to_i)
  if m == -1 && f == -1 && r == -1
    break
  end
  if m == -1 || f == -1
    puts "F"
  elsif m + f >= 80
    puts "A"
  elsif m + f >= 65
    puts "B"
  elsif m + f >= 50
    puts "C"
  elsif m + f >= 30
    if r >= 50
      puts "C"
    else
      puts "D"
    end
  else
    puts "F"
  end
end



Measured memory_bytes: 6868
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int D=1e9;

 int main()
 {
	int n,mn;
	mn=D+1;
	scanf("%d",&n);
	int sm,a;
	sm=0;

	while(n--)
	{
		scanf("%d",&a);
		sm+=a;
		if(a%10!=0) mn=min(mn,a);
	}

	if(sm%10!=0) printf("%d\n",sm);
	else if(mn!=D+1) printf("%d\n",sm-mn);
	else printf("0\n");
 }


Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]
def sol(N,M):
  if N==0 or M==0:
      return 0
  elif N==1 or M==1:
    return abs(abs(N-M)-1)
  x = (abs(3-N)+1)*(M-2)
  y = (abs(3-M)+1)*abs((N-2))
  return min(x,y)

print(sol(N,M))

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

int n;
ll ans;
ll mi = 1e18;

int main() {
    cin >> n;
    bool f = 1;
    for (int i = 0; i < n; i++) {
        ll a,b;
        cin >> a >> b;
        ans += a;
        if (a != b) f = 0;
        if (a > b) mi = min(mi, b);
    }
    if (f) {
        cout << 0 << endl;
        return 0;
    }
    cout << ans - mi << endl;
    return 0;
}


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

struct Node
{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else
		{
			x = x->right;
		}
	}

	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if (u == NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node *u) {
	if (u == NIL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main() {
	int n, i, x;
	string com;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		cin >> com;
		if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 26692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

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

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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


using pint = pair<int,int>;
int H, W, N;

map<int, set<int> > ma;

int main() {
    while (cin >> H >> W >> N) {
        ma.clear();
        for (int i = 0; i < N; ++i) {
            int x, y;
            cin >> x >> y;
            ma[x].insert(y);
        }
        int res = H;
        int left = 1, right = 1;
        for (int x = 2; x <= H; ++x) {

            
            if (!ma.count(x)) {
                right = min(right + 1, W);
            }
            else {
                int first = *ma[x].begin();
                if (left <= first && first <= right) {
                    chmin(res, x - 1);
                    break;
                }
                if (first != right + 1) {
                    right = min(right + 1, W);
                }
            }

            //cout << x << ": " << pint(left, right) << endl;
        }
        cout << res << endl;
        
    }
}



























Measured memory_bytes: 28416
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

int seen[200001] = { false };
int a[200001] = { 0 };
int ans[200001] = { 0 };
void dfs(int v, int sum,whei(int)&G) {
	seen[v] = true;
	ans[v] = sum;
	for (auto x : G[v]) {
		if (seen[x])continue;
		dfs(x, sum + a[x], G);
	}
}

int main() {
	int n;
	cin >> n;
	vector<pair<llint,llint>> a(n);
	rep(i, 0, n) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end());
	llint ans = a[n - 1].first + a[n - 1].second;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <stack>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <cstring>

using namespace std;

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

using ll = long long;
using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

#define eb emplace_back
#define pb push_back
#define mp make_pair

#define F first
#define S second

#define popcnt __builtin_popcountll

#define rep( i, n ) for ( ll i = 0; i < (ll)( n ); ++i )
#define reps( i, n ) for ( ll i = 1; i <= (ll)( n ); ++i )
#define rrep( i, n ) for ( ll i = (ll)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( ll i = (ll)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }

template<typename T = ll> struct UnionFind {
	vector<T> par;

	UnionFind( T n ) : par( n, -1 ) {}

	void init( T n ) { par.assign( n, -1 ); }
	T find( T x ) {
		if ( par[x] < 0 ) return ( x );
		else return ( par[x] = find( par[x] ) );
	}
	bool isSame( T x, T y ) {
		return ( find( x ) == find( y ) );
	}
	bool unite( T x, T y ) {
		x = find( x ); y = find( y );
		if ( x == y ) return ( false );
		if ( par[x] > par[y] ) swap( x, y );
		par[x] += par[y];
		par[y] = x;
		return ( true );
	}
	T size( T x ) { return ( -par[find( x )] ); }
};


int main()
{
	ll n, m; cin >> n >> m;
	UnionFind<ll> uf( m );
	map<ll, ll> mm;
	rep( i, n )
	{
		ll k; cin >> k;
		ll l0; cin >> l0;
		--l0;
		mm[l0]++;
		rep( i, k - 1 )
		{
			ll l1; cin >> l1;
			--l1;
			mm[l1]++;
			uf.unite( l0, l1 );
		}
	}

	ll cnt = 0;
	arep( it, mm )
	{
		if ( uf.find( it.F ) == it.F )
			++cnt;
	}

	if ( cnt > 1 )
		cout << "NO" << endl;
	else
		cout << "YES" << endl;

	return ( 0 );
}


Measured memory_bytes: 7452
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
using namespace std;
typedef long long int ll;

const int N=1299709+10;

bool not_prime[N];
vector<int> prime;

void make_prime(){
	not_prime[0]=not_prime[1]=1;
	for(int i=2;i<N;i++){
		if(!not_prime[i]){
			prime.push_back(i);
			for(int j=i+i;j<N;j+=i){
				not_prime[j]=1;
			}
		}
	}
}

int n;

void solve(){
	if(!not_prime[n]){
		printf("0\n");
		return;
	}
	auto it=lower_bound(prime.begin(),prime.end(),n);
	auto it2=it;
	it--;
	printf("%d\n",*it2-*it);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	make_prime();
	while(1){
		cin >> n;
		if(n==0)break;
		solve();
	}
}


Measured memory_bytes: 4612
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        M: usize,
        C: i32,
        B: [i32; M],
        A: [[i32; M]; N],
    }

    let count: usize = A.iter().filter(|array| 
        array.iter().zip(B.iter())
        .map(|(a_ij, b_j)| a_ij*b_j).sum::<i32>() + C > 0
        ).count();

    println!("{}", count);
}


Measured memory_bytes: 4352
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
scr_A=[]
scr_B=[]
for i in range(len(a)):
  if i%2==0:
    scr_A.append(a[i])
  else:
    scr_B.append(a[i])
print(sum(scr_A)-sum(scr_B))

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{
    ll n;
    cin >> n;
    vector<ll> v;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    sort(v.begin(), v.end());
    ll ans = v[n/2]-v[n/2-1];
    cout << ans;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
const int inf_int=1e8;
const ll inf_ll=1e16;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double dbl;
#define pb push_back
const double pi=3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
#define prev sdghjk
const int MX = 1e6+1;
const int MAXN = 4e5+100;
const int LOG = 20;
const ll mod =1e9;
#define x1 xvxbn
#define y1 afsdgjj

void bad(){
    cout <<"NO";
    exit(0);
}
int a[MAXN];
void solve(){
    int n;
    cin >> n;
    for(int i=1;i<=n;++i){
        cin >> a[i];
    }
    int ans = 0;
    for(int i=2;i<=n;++i){
        if(a[i]==a[i-1]){
            ans++;
            i++;
        }
    }
    cout << ans<<endl;


}


#define FILE "taxi"
signed main()
{
        #ifdef taow
            debug = 1;
           freopen("input.txt","r",stdin);
         //   freopen("output.txt","w",stdout);
        #else

    //        freopen(FILE".in","r",stdin);
   //         freopen(FILE".out","w",stdout);
        #endif // taow
        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);
        cout.setf(ios::fixed);
        cout.precision(20);

        int t = 1;
        while(t--)
            solve();
}


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

int main(){
    int n,i;
    while(cin>>n,n){
        map<int,long long>m;
        vector<int>vec;
        long long p,q;
        bool s=0;
        while(n--){
            cin>>i>>p>>q;
            if(!m[i])vec.push_back(i);
            m[i]+=p*q;
        }
        for (int i=0;i<vec.size();i++){
            if(m[vec[i]]>=1000000){
                s=1;
                cout<<vec[i]<<endl;
            }
        }
        if(!s)cout<<"NA"<<endl;
    }
}

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

using namespace std;

using ll = long long;

template <class SemiGroup>
struct DisjointSparseTable {
    using T = typename SemiGroup::T;

    int n;
    vector< vector<T> > table;
    vector<int> msb_table;

    DisjointSparseTable() {}
    DisjointSparseTable(const vector<T>& v) {
        n = v.size();

        table.emplace_back(n);
        for (int i = 0; i < n; i++) {
            table[0][i] = v[i];
        }

        for (int i = 1; (1 << i) < n; i++) {
            table.emplace_back(n);
            int shift = (1 << i);
            for (int j = 0; j < n; j += (shift << 1)) {
                int m = min(j + shift, n);
                table[i][m - 1] = v[m - 1];
                for (int k = m - 2; k >= j; --k) table[i][k] = SemiGroup::merge(v[k], table[i][k + 1]);

                if (m >= n) break;

                int r = min(m + shift, n);
                table[i][m] = v[m];
                for (int k = m + 1; k < r; ++k) table[i][k] = SemiGroup::merge(table[i][k - 1], v[k]);                
            }
        }
    }

    //区間[l, r)に対するクエリに答える
    T query(int l, int r) {
        assert(l < r && r <= n);

        if (l == --r) return table[0][l];
        int msb = 31 - __builtin_clz(l ^ r);
        return SemiGroup::merge(table[msb][l], table[msb][r]);
    }
};

//以下、SemiGroupの例
template <class U = ll>
struct RSQSG {
    using T = U;
    static T merge(T a, T b) { return a + b; }
};

vector<bool> sieve(int n) {
    vector<int> res;
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (!is_prime[i]) continue;
        res.emplace_back(i);
        for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
    }
    return is_prime;
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    vector<bool> hoge(sieve(100000));
    vector<int> foo(100005, 0);
    for (int i = 1; i <= 100000; i++) {
        if (hoge[i] && hoge[(i + 1) / 2]) foo[i] = 1;
    }
 
    DisjointSparseTable< RSQSG<int> > st(foo);
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        cout << st.query(l, r + 1) << "\n";
    }
    return 0;
}


Measured memory_bytes: 7808
def calc(S):
    p = q = 0
    for c in S[1:]:
        if c == 'A':
            p += 1
        else:
            q += 1
    return p, q
def check(p, q):
    if q < 10:
        return p == 11
    return p - q == 2

while 1:
    S1 = input()
    if S1 == "0":
        break
    S2 = input()
    S3 = input()

    p1, q1 = calc(S1)
    if S2[0] == 'A':
        p1 += 1
    else:
        q1 += 1
    print(p1, q1)

    p2, q2 = calc(S2)
    if S3[0] == 'A':
        p2 += 1
    else:
        q2 += 1
    print(p2, q2)

    p3, q3 = calc(S3)
    if check(p3+1, q3):
        print(p3+1, q3)
    else:
        print(p3, q3+1)


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

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

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

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  COMinit();
  int k; cin >> k;
  string s; cin >> s;
  
  vector<ll> tf(1000005), ts(1000005);
  rep(i, 1000005){
    if(i == 0){ tf[i] = ts[i] = 1; continue;}
    tf[i] = tf[i-1]*25 % MOD;
    ts[i] = ts[i-1]*26 % MOD;
  }
  
  ll ans = 0;
  rep(i, k+1){
    ans = (ans + ((COM(i+s.size()-1, s.size()-1)*ts[k-i]) % MOD * tf[i] ) % MOD ) % MOD;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 90372
sa = input()
sb = input()
sc = input()
acount = 0
bcount = 0
ccount = 0
flag = True
ans = ''
tmp = sa[acount]
if len(sa) == 1:
    ans = 'A'
else:
    while flag:
        if tmp == 'a':
            if acount == len(sa):
                flag = False
                ans = 'A'
            else:
                tmp = sa[acount]
                acount += 1
        if tmp == 'b':
            if bcount == len(sb):
                flag = False
                ans = 'B'
            else:
                tmp = sb[bcount]
                bcount += 1
        if tmp == 'c':
            if ccount == len(sc):
                flag = False
                ans = 'C'
            else:
                tmp = sc[ccount]
                ccount += 1
                        
print(ans)

Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        s: chars
    }

    let mut srev = s;
    srev.reverse();
    let mut dream = "dream".chars() .collect::<Vec<_>>();
    dream.reverse();
    let mut dreamer = "dreamer".chars() .collect::<Vec<_>>();
    dreamer.reverse();
    let mut erase = "erase".chars() .collect::<Vec<_>>();
    erase.reverse();
    let mut eraser = "eraser".chars() .collect::<Vec<_>>();
    eraser.reverse();

    let mut is_ok = true;
    let mut i = 0;
    loop {
        if i >= srev.len() {
            break;
        }
        if starts_with(&srev, &dream, i) {
            i += dream.len();
        } else if starts_with(&srev, &dreamer, i) {
            i += dreamer.len();
        } else if starts_with(&srev, &erase, i) {
            i += erase.len();
        } else if starts_with(&srev, &eraser, i) {
            i += eraser.len();
        } else {
            is_ok = false;
            break;
        }
    }
    println!("{}", if is_ok {"YES"} else {"NO"});
}

fn starts_with(s: &[char], key: &[char], start: usize) -> bool {
    for i in 0..key.len() {
        if i + start >= s.len() {
            return false;
        }
        if s[i + start] != key[i] {
            return false;
        }
    }
    true
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

char *demangle(const char *demangle)
{
    int status;
    return abi::__cxa_demangle(demangle, 0, 0, &status);
}
int n, m;
vector<int> A(20 + 10);
vector<int> Q(200 + 10);

int main()
{
    cin >> n;
    int total = 0;
    rep(i, n)
    {
        cin >> A[i];
        total += A[i];
    }
    cin >> m;
    rep(i, m) cin >> Q[i];

    rep(i, m)
    {
        if(total<Q[i])
        {
            puts("no");
            continue;
        }
        bool ok = false;
        for (int bit = 0; bit < (1 << n); bit++)
        {
            int res = 0;
            for (int j = 0; j < n; j++)
            {
                if (bit & (1 << j))
                {
                    res += A[j];
                    if(res>Q[i]){
                        break;
                    }
                }
                
            }
            if (res == Q[i])
            {
                ok = true;
                break;
            }
        }
        puts(ok ? "yes" : "no");
    }

    return 0;
}



Measured memory_bytes: 3068
#include <stdio.h>

#define N 100

int main(){
  int inp, i, j, flag=1, temp, cha=0;
  int A[N];
  
  scanf("%d", &inp);
  for(i = 0; i < inp; i++){
    scanf("%d", &A[i]);
  }
  while(flag == 1){
    flag = 0;
    for(j = inp-1; j > 0; j--){
      if(A[j] < A[j-1]){
        temp = A[j];
        A[j] = A[j-1];
        A[j-1] = temp;
        flag = 1;
        cha++;
      }
    }
  }
  for(i = 0; i < inp-1; i++){
    printf("%d ", A[i]);
  }
  printf("%d", A[i]);
  
  printf("\n%d\n", cha);
  return 0;
}



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

# たこ焼き器の価値
N = [0] + list(map(int, tuple(input().rstrip("\n"))))

def main():
    # 支払額
    Ncopy = N.copy()
    # 紙幣の枚数
    ans = 0

    # 繰り上げ発生時に変更
    flag = False
    for i in range(len(N)-1, 0, -1):
        # 繰り上げしない場合
        if (Ncopy[i] <= 4) or (Ncopy[i] == 5 and N[i-1] <= 4):
            ans += Ncopy[i]
            flag = False
        # 繰り上げする場合
        else:
            Ncopy[i-1] += 1
            # 最後だけ特殊
            if not flag:
                ans += 10 - N[i]
            else:
                ans += 9 - N[i]
            Ncopy[i] = 0
            flag = True

    if Ncopy[0] == 1:
        ans += 1

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 20692
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		while (a > 0) {
			if ((c -= b) <= 0) {
				break;
			}
			a -= d;
		}
		System.out.println(a <= 0 ? "No" : "Yes");
	}

	static class FastScanner {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

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

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

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

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

		public double nextDouble() {
			return Double.parseDouble(next());
		}

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

Measured memory_bytes: 32760
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
//#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int a[100][100], b[100][100];
bool dp[100][100][100*(100+100)];
signed main()
{
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> b[i][j];
        }
    }
    dp[0][0][abs(a[0][0] - b[0][0])] = true;
   
    
    
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            for (int dif = 0; dif <= (h+w)*80; dif++)
            {

                if (i >= 1){
                    if (dp[i-1][j][dif]){
                        dp[i][j][dif + abs(a[i][j] - b[i][j])] = dp[i - 1][j][dif];
                        dp[i][j][abs(dif - abs(a[i][j] - b[i][j]))] = dp[i - 1][j][dif];
                    }
                }
                if (j >= 1){
                    if(dp[i][j-1][dif]){
                     dp[i][j][dif + abs(a[i][j] - b[i][j])] = dp[i][j - 1][dif];
                        dp[i][j][abs(dif - abs(a[i][j] - b[i][j]))] = dp[i][j - 1][dif];
                    }
                }
            }
        }
        
    }
 // cerr << dp[1][0][3] << endl;
  /*  for (int i = 0; i < 10; i++)
    {
        cerr << dp[1][1][i] << endl;

    }*/

    for (int i = 0; i <= (h + w) * 80; i++)
    {
        if(dp[h-1][w-1][i]) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 156544
#include <bits/stdc++.h>
#define rep(i, n) for (int 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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ld l;
  cin >> l;

  ld ans = l * l * l / 27;
  cout << setprecision(20) << ans << endl;


  
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * A - Next Alphabet
 * z でない英小文字 C が与えられます。アルファベット順で C の次の文字を出力してください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 入力されたアルファベット
        String c = sc.next();

        List<String> alphabetList = Arrays.asList( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" );

        int cIndex = alphabetList.indexOf( c );
        System.out.println( alphabetList.get( cIndex + 1 ) );

        sc.close();
    }
}

Measured memory_bytes: 22996
N, M = gets.split.map(&:to_i)
NG = M.times.map{[gets.to_i, true]}.to_h
step = [1, 1]
step[0] = 0 if NG[0]
step[1] = 0 if NG[1]
2.step(N) do |i|
  if NG[i]
    step[i] = 0
  else
    step[i] = (step[i-2] + step[i-1]) % 1000000007
  end
end
puts step[N]

Measured memory_bytes: 16636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int n, a[110];
int main() {
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			while (a[i] == a[i + 1] || a[i + 1] == a[i + 2]) {
				a[i + 1] = rand() % 10000 + 1;
			}
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

#define        optimize           ios::sync_with_stdio(0); cin.tie(0);
#define PI    acos(-1.0)
#define pb push_back
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define RESET(a, b) memset(a, b, sizeof(a))
#define pii pair <int, int>
#define gcd(a, b) __gcd(a, b)
#define min3(a, b, c) min(c, min(a, b))
#define max3(a, b, c) max(c, max(a, b))

#define        MX        200005

vector <int> ara;

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

    for(int i = 0; i < n; i++){
        int x;
        cin>>x;
        ara.push_back(x);
    }

    sort(ara.begin(), ara.end());
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                if(ara[k] < ara[i]+ara[j] && ara[i] != ara[j] && ara[j] != ara[k] && ara[i] != ara[k]){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3648