akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case,unused_imports,dead_code)]
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::Ordering;

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        S:Chars,
    }
    let T = S.iter().filter(|&&s| s!='x').collect::<Vec<_>>();
    let n = T.len();
    for i in 0..n{
        let j = n-1-i;
        if T[i] != T[j]{
            println!("-1");
            return;
        }
    }
    let mut ans = 0;
    let mut i = 0;
    let mut j = S.len()-1;
    while i < j{
        if S[i] == S[j]{
            i += 1;
            j -= 1;
        } else if S[i] == 'x' {
            ans += 1;
            i += 1;
        } else {
            ans += 1;
            j -= 1;
        }
    }
    println!("{}",ans);
}

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

int main() {

  int h, w;
  cin >> h >> w;

  vector<string> c(h);
  for(int i = 0; i < h; i++) cin >> c[i];

  for(int i = 0; i < h; i++) cout << c[i] << endl << c[i] << endl;

}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
import bisect

def main():
    _,M= map(int,input().split())
    A = list(map(int,input().split()))
    A.sort()
    
    B = []
    for _ in range(M):
        b,c = map(int,input().split())
        B.append((b,c))
    B.sort(key=lambda x: x[1])

    x = 0
    m = 0
    while B:
        b,c = B.pop()
        n = bisect.bisect(A,c,lo=m,hi=min(m+b,len(A)))
        x += (n-m)*c
        m = n

    print(x + sum(A[n:]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 22604
#include <stdio.h>

int main (){
 
 int h, w, n;
 scanf("%d %d %d", &h, &w, &n);
 
 int sum;
 
 	if(h>=w) 
 	{
        if(n%h == 0) 
		{
            sum = n/h;
        } 
		
		else 
		{
            sum = n/h+1;
        }
 	} 
 		
	else 
	{
        if(n%w == 0) 
		{
            sum = n/w;
        } 
		
		else 
		{
            sum = n/w+1;
        }
    }
 	 printf("%d", sum);
 
 return 0;
}

Measured memory_bytes: 1732
import sys
import math
from collections import deque
import bisect

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N = NI()
    W = NLI()
    cum = []
    cum.append(W[0])
    for i in range(1, N):
        cum.append(cum[-1] + W[i])
    total = cum[-1]
    idx = 0
    for i in range(N):
        if cum[i] <= total / 2:
            idx = i
        else:
            idx_r = i
            break
    print(min(abs(total - cum[idx]*2) ,abs(total - cum[idx_r]*2)))




if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
A = [[0 for i in range(10)] for j in range(12)]
count = 0

n = int(input())

for _ in range(n):
    a = [int(x) for x in input().split()]
    A[3*(a[0]-1)+a[1]-1][a[2]-1] += a[3]

for _ in range(12):
    for i in range(0,10):
        print(" ", end="")
        print(A[_][i],end="")
    print()
    count += 1
    if count >= 3 and not _ == 11:
        count = 0
        print("####################")
        continue


Measured memory_bytes: 5636
fun main(args: Array<String>) = abc164d()

@OptIn(ExperimentalStdlibApi::class)
fun abc164d() {
    val s = readLine()!!.reversed().map { Character.getNumericValue(it) }.toIntArray()
    val mod = 2019
    
    val modded = IntArray(s.size)
    var digit = 1
    for (i in s.indices) {
        modded[i] = (s[i] * digit) % mod
        digit *= 10
        digit %= mod
    }

    val moddedCSum = modded.scan(0) { acc: Int, i: Int -> (acc + i) % mod }.toIntArray()

    val appeared = mutableMapOf<Int, Int>().withDefault { 0 }
    var answer = 0L

    for (mcs in moddedCSum) {
        val app = appeared.getValue(mcs)
        answer += app
        appeared[mcs] = app + 1
    }

    println(answer)
}


Measured memory_bytes: 56612
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int array[3];
	for(int i = 0; i < 3; i++) scanf("%d",&array[i]);
	for(int i = 2; i > 0; i--){
		for(int j = 0; j < i; j++){
			if(array[j] > array[j+1])swap(array[j],array[j+1]);
		}
	}
	printf("%d %d %d\n",array[0],array[1],array[2]);
}


Measured memory_bytes: 2696
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int A = 0;
  int B = 0;
  std::cin >> A >> B;
  int Wa = A + B;
  int Sa = A - B;
  int Seki = A * B;

  int Max = log(0);
  if (Max < Wa) {
    Max = Wa;
  }
  if (Max < Sa) {
    Max = Sa;
  }
  if (Max < Seki) {
    Max = Seki;
  }

  std::cout << Max << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
	ll n, x;	cin >> n >> x;
	ll ret = n;//最初の2本
	ll a = x, b = n - x;
	if (a > b)	swap(a, b);
	while (true) {
		if (b%a == 0) {
			ll l = b / a;
			cout << ret + 2 * a * l - a << endl;
			return 0;
		}
		else {
			ll l = b / a;
			ret += 2 * a * l;
			b %= a;
			swap(a, b);
		}
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    string s[3];
    while(cin >> s[0])
    {
        if(s[0] == "0") return 0;
        cin >> s[1];
        cin >> s[2];

        int a[3] = {}, b[3] = {};

        int l;
        rep(j,3)
        {
            l = s[j].size();
            if(j>0)
            {
                if(s[j][0] == 'A')a[j-1]++;
                else b[j-1]++;
            }

            REP(l - 1)
                if(s[j][i + 1] == 'A') a[j]++;
                else b[j]++;
        }
        if(a[2] < b[2]) b[2]++; else a[2]++;

        REP(3)cout << a[i] << " " << b[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 0
N,Q=map(int,input().split())
S=input()
t=[0]*N
for i in range(N-1):
    t[i+1]=t[i]+(1 if S[i:i+2]=='AC' else 0)
for i in range(Q):
    l,r=map(int,input().split())
    print(t[r-1]-t[l-1])

Measured memory_bytes: 7748
#include<bits/stdc++.h>
using namespace std;
#define ld float
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second
#define all(a) a.begin(),a.end()
#define rev(a) reverse(all(a))
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mod 1000000007
#define inf 2000000000
#define limit 1000005
#define minval -100000000000000000
#define maxval 1000000000000000
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}

void solve(int test_case)
{
    str s;
    cin >> s;
    int n = s.length();
    if(s[n-1] == 's')
        s += "es";
    else
        s += "s";
    cout << s << '\n';
}
int main()
{
   /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   */
    fastio();
    int q = 1;
    //cin >> q;
    rep(i,q)
        solve(i+1);
}


Measured memory_bytes: 3620
/*********************
*  Author: xuziyuan  * 
*********************/
 
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

LL n,k,a[200010],ans=0;

int main()
{
	cin>>n>>k;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	rep(i,n-k) ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>

int n, h[100005];
long long dp[100005];
int main() {
	std::cin >> n;
	for (int i = 0; i < n; ++i)
		std::cin >> h[i];

	for (int i = 0; i < n - 1; ++i) {
		long long in = 0;
		in = dp[i] + std::abs(h[i + 1] - h[i]);
		if (i > 0)
			in = std::min(in, dp[i - 1] + std::abs(h[i + 1] - h[i - 1]));
		dp[i + 1] = in;
	}
	std::cout << dp[n - 1] << std::endl;
	return 0;
}


Measured memory_bytes: 1408
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

ans = []

for i in range(1, N + 1):
    ans.extend([i] * A[i - 1])

for i in range(H):
    if i % 2 == 0:
        print(*ans[i * W:i * W + W])
    else:
        print(*ans[i * W:i * W + W][::-1])


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

int helper(int *ar,int n)
{
    int *dp = new int[n];
    dp[0] = 0;
    dp[1] = abs(ar[1] - ar[0]);
    for(int i = 2;i<n;i++)
    {
        dp[i] = min(abs(ar[i] - ar[i-1]) + dp[i-1],abs(ar[i] - ar[i-2]) + dp[i-2]);
    }
    
    return dp[n-1];
}

int main()
{
  int n;
  cin>>n;
  int *ar = new int[n];
  for(int i = 0;i<n;i++)
  {
      cin>>ar[i];
  }
  cout<<helper(ar,n)<<endl;
}

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

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

    ll x = 0, y = 0; 
    for(ll i = 0; i < k; i++){
        x = a + i;
        if(x <= b){
            cout << x << endl;
        }
    }

    for(ll i = k-1; i >= 0; i--){
        y = b - i;
        if(y > x && y <= b){
            cout << y << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int m1, d1, m2, d2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;

  int ans = 0;
  if (m1 < m2) ans = 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#define up(l,r,i) for(int i=l;i<=r;i++)
#define dn(l,r,i) for(int i=l;i>=r;i--)
using namespace std;

typedef long long LL;
const int INF =2147483647;
int qread(){
	int w=1,c,ret;
	while((c=getchar())> '9'||c< '0')
	w=(c=='-'?-1:1); ret=c-'0';
	while((c=getchar())>='0'&&c<='9')
	ret=ret*10+c-'0';
	return ret*w;
}
const int MAXN =1e5+3;
int n,t,cnt,P[MAXN],mn=INF,tmp;
int main(){
	n=qread(),t=qread();
	up(1,n,i){
		P[i]=qread();
		if(P[i]<mn) mn=P[i];
		tmp=max(tmp,P[i]-mn);
	}
	mn=INF;
	up(1,n,i){
		if(P[i]<mn) mn=P[i];
		if(P[i]-mn==tmp) cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    return ret;
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.is_err() || res.ok().unwrap() == 0 || u8b[0] <= ' ' as u8 {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = std::string::String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}
fn parse<T: std::str::FromStr>(s: &str) -> T { s.parse::<T>().ok().unwrap() }

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { parse(&get_word()) }

fn main() {
    let n = get();
    let a: Vec<usize> = (0 .. n).map(|_| get()).collect();
    const W: usize = 100100;
    let mut freq = vec![0; W];
    for v in a {
        freq[v] += 1;
    }
    let mut twos: i32 = 0;
    let mut uniq: i32 = 0;
    for i in 0 .. W {
        if freq[i] > 0 {
            uniq += 1;
            if freq[i] % 2 == 0 {
                twos += 1;
            }
        }
    }
    println!("{}", uniq + if twos % 2 == 1 { -1 } else { 0 });
}


Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define dbg puts("bug bug bagum");
#define CHECK(x) cout << (#x) << " is " << (x) << endl;
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pr printf
#define sc scanf
#define IN(x) scanf("%d",&x);
#define INL(x) scanf("%lld",&x);
#define OUT(x) printf("%d",x);
#define OUTL(x) printf("%lld",x);
#define SP printf(" ");
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define EPS 1e-9
#define PI acos(-1.0)
#define MAX 200005
#define MOD 1000000007
#define INF (1 << 31)
#define nl '\n'
#define ext exit(0)
#define fast ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define newl printf("\n")
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define fora(i,n) for(int (i)=0; (i) < (n); (i)++)
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define pqmin(x) priority_queue<x, vector<x>, greater<x> >
#define pqmax(x) priority_queue<x>
#define sortd(x) sort(all(x), greater<int>())
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) __lcm(x,y)
#define fact(x) factorial(x)
#define sieve(x) normal_sieve(x)
#define bsieve(x) bitwise_sieve(x)
#define bprime(x) !Chk(x)
#define runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef pair<int,int> pii;
typedef pair<int,pii > tii;
typedef vector <int> VI;
typedef vector<ll> VL;
typedef set<int> SI;

///code starts from here..........................................
int main() {
    fast;
    //in_file;
    //out_file;
   int n;
   cin>>n;
   if(n>81)cout<<"No"<<endl;
   else{
      for(int i=1;i<10;i++){
        for(int k=1;k<10;k++){
            if(i*k==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
      }
      cout<<"No"<<endl;
   }
   return 0;
}
///code ends here..................................................


Measured memory_bytes: 256
using System;

public class C
{
    public const int INF = 999999999;
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var e = int.Parse(line[0]);
            var n = int.Parse(line[1]);
            if (e == 0 && n == 0) break;
            var dp0 = new int[n, n];   //cost
            var dp1 = new int[n, n];   //time
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    if (i != j) { dp0[i, j] = C.INF; dp1[i, j] = C.INF; }
            for (int i = 0; i < e; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                var a = int.Parse(line2[0]) - 1;
                var b = int.Parse(line2[1]) - 1;
                var c = int.Parse(line2[2]);
                var t = int.Parse(line2[3]);
                dp0[a, b] = c; dp0[b, a] = c;
                dp1[a, b] = t; dp1[b, a] = t;
            }
            goWarshall(dp0 ,dp1);
            var k = int.Parse(Console.ReadLine().Trim());
            for (int i = 0; i < k; i++)
            {
                string[] line3 = Console.ReadLine().Trim().Split(' ');
                var p = int.Parse(line3[0]) - 1;
                var q = int.Parse(line3[1]) - 1;
                var r = int.Parse(line3[2]);
                Console.WriteLine(r == 0 ? dp0[p, q] : dp1[p, q]);
            }
        }
    }
    public static void goWarshall(int[,] dp0, int[,] dp1)
    {
        var n = dp0.GetLength(0);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                {
                    dp0[j, k] = Math.Min(dp0[j, k], dp0[j, i] + dp0[i, k]);
                    dp1[j, k] = Math.Min(dp1[j, k], dp1[j, i] + dp1[i, k]);
                }
    }
}

Measured memory_bytes: 9516
toInt :: (String -> Int)
toInt x = read x ::Int

getInts = do
  x <- getLine
  let y = (map$toInt)$words x
  return y



a_bTimes :: Char -> Int -> String
a_bTimes a 0 = ""
a_bTimes a n = a:(a_bTimes a (n-1))

main = do
  x <- getLine
  let a = x !! 0
  let b = x !! 2
  putStrLn $ if a < b then a_bTimes a (read [b])
                      else a_bTimes b (read [a])

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

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

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

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};


vector<int> to[100005];
int n;
vector<int> dist;
void dfs(int v, int d=0, int p=-1) {
    dist[v] = d;
    for (int u: to[v]) {
        if (u == p) continue;
        dfs(u, d+1, v);
    }
}

vector<int> calcDist(int s){
    dist = vector<int>(n);
    dfs(s);
    return dist;
}
int main() {
    ll n, a, b; cin >> n >> a >> b;
    ll ans = pow(10, 18);
    bool isEven = (b - a) % 2 == 0;
    if (isEven) {
        ans = (b - a) /2;
    } else {
        ll c = a - 1;
        ll d = n - b;
        bool isOne = c < d;
        if (isOne) {
            ans = ((b + c + 1) - 1) / 2;
        } else {
            ans = (n - a + (d + 1)) / 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <utility>

const int N = 100000;
int main() {
  int n, m, x, y;
  bool can_exist[N];
  int count[N];
  int num = 0;
  std::cin >> n >> m;
  std::fill(can_exist, can_exist + n, false);
  std::fill(count, count + n, 1);
  can_exist[0] = true;
  for (int mi = 0; mi < m; ++mi) {
    std::cin >> x >> y;
    --count[x - 1];
    ++count[y - 1];
    if (can_exist[x - 1]) {
      if (count[x - 1] == 0) {
        can_exist[x - 1] = false;
      }
      can_exist[y - 1] = true;
    }
  }
  for (int ni = 0; ni < n; ++ni) {
    if (can_exist[ni]) {
      ++num;
    }
  }
  std::cout << num << std::endl;
  return 0;
}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

const int mod = 1000000000 + 7;

ll dp[61][3];
ll N;

ll rec(int pos, int k){
    if(pos < 0){
        return 1;
    }
    if(dp[pos][k] >= 0) return dp[pos][k];
    ll res = 0;
    int nk_base = k * 2;
    if((N >> pos) & 1) nk_base++;
    
    for(int i = 0; i < 3; i++){
        int nk = nk_base;
        nk -= i;
        if(nk >= 0)
            (res += rec(pos - 1, min(2, nk))) %= mod;
    }
    return dp[pos][k] = res;
}

int main(){

    cin >> N;
    memset(dp, -1, sizeof(dp));
    cout << rec(60, 0) << endl;

    return 0;
}


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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;





int main() {
	int n, kk;
	cin >> n >> kk;
	VLL x(n), y(n);
	REP(i, n)cin >> x[i] >> y[i];
	VLL xx = x, yy = y;
	sort(ALL(xx));
	sort(ALL(yy));
	ll ans = INFL;
	REP(i, n) {
		REP(j, n) {
			FOR(k, i+1, n) {
				FOR(l, j+1, n) {
					int res = 0;
					REP(m, n) {
						if (xx[i] <= x[m] && x[m] <= xx[k] && yy[j] <= y[m] && y[m] <= yy[l]) res++;
					}
					if (res >= kk) {
						ans = min(ans, (xx[k] - xx[i])*(yy[l] - yy[j]));
					}
					
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int w,h;
  cin>>w>>h;
  vector<string> vs(h,string(w,'.'));
  vs.front()=vs.back()=string(w,'-');
  for(int i=0;i<h;i++) vs[i].front()='|',vs[i].back()='|';
  vs.front().front()=vs.front().back()=vs.back().front()=vs.back().back()='+';
  cin>>vs[h/2][w/2];
  for(string s:vs) cout<<s<<endl;
  return 0;
}

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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int c = 0;
  int ans = 0;
  for (int i = 0; i < N; i++){
     if (S.at(i) == 'R') c++;
  }
  for (int i = 0; i < c; i++){
    if (S.at(i) == 'W') ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a, b, x;
  cin >> a >> b >> x;
  long long ca = (a-1) / x + 1;
  if(a == 0) ca = 0LL;
  long long cb = b / x + 1;
  cout << cb - ca << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll n,a,b,c,d;cin >> n >> a >> b >> c >> d;
    ll len=d-c;
    bool link=false;
    if(2*c<=len*(n-2))link=true;
    if(link){
        if(abs(a-b)<=d*(n-1))cout <<"YES" <<endl;
        else cout <<"NO" <<endl;
    }
    else{
        ll p=(d-c)*(n-1),q=2*c-len*(n-2);
        ll s=d*(n-1);if(s<abs(a-b))cout <<"NO" <<endl,exit(0);
        s=s-abs(a-b);
        s%=(p+q);
        if(s<=p)cout <<"YES" <<endl;
        else cout <<"NO"<<endl;
    } 
} 

Measured memory_bytes: 256
K = int(input())

lunlun = list(range(1, 10))
last_lunlun = lunlun
for j in range(9):
    new = []
    for l in last_lunlun:
        last = int(str(l)[-1])
        for i in [-1, 0, 1]:
            if last + i >= 0 and last + i < 10:
                new.append(10 * l + last + i)
    last_lunlun = new
    lunlun.extend(new)

lunlun.sort()

print(lunlun[K-1])


Measured memory_bytes: 12692
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x)  x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    int n,k,var=0;
    cin>>n>>k;
    vector<int> a(n+1,0);
    rep(i,n){
        int tmp;
        cin>>tmp;
        if(a[tmp]==0)   var++;
        a[tmp]++;
    }
    if(var<k){
        cout<<0<<endl;  return 0;
    }
    vector<int> b;
    rep(i,n+1){
        if(a[i]>0){
            b.push_back(a[i]);
        }
    }
    sort(ALL(b));
    int ans=0,c=0;
    while(var>k){
        ans+=b[c];
        c++;var--;
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void CodeFest2017qA_C_PalindromicMatrix();

#if 1
int main()
{
	CodeFest2017qA_C_PalindromicMatrix();
	fflush(stdout);
	return 0;
}
#endif

static void CodeFest2017qA_C_PalindromicMatrix()
{
	int H, W;
	get2int(H, W);

	auto tmp = new char[H][101];
	for (int h = 0; h < H; h++) {
		getstring(tmp[h]);
	}

	std::map<char, int> chars;
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			chars[tmp[h][w]]++;
		}
	}

	int count[4] = { 0 };
	for (auto it = chars.begin(); it != chars.end(); it++) {
		count[it->second % 4]++;
	}

	const char* ans = "No\n";
	if ((H % 2) && (W % 2)) {
		int elem = (H / 2) + (W / 2);

		if ((count[1] == 1) && (count[2] <= elem) && (count[3] == 0)) {
			ans = "Yes\n";
		}
		else if ((count[1] == 0) && (count[2] <= elem) && (count[3] == 1)) {
			ans = "Yes\n";
		}
	}
	else if ((H % 2) || (W % 2)) {
		int elem = H / 2;
		if (H % 2) elem = W / 2;

		if ((count[2] <= elem) && (count[1] == 0) && (count[3] == 0)) {
			ans = "Yes\n";
		}
	}
	else {
		if ((count[1] == 0) && (count[2] == 0) && (count[3] == 0)) {
			ans = "Yes\n";
		}
	}
	printf(ans);
	delete[] tmp;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A=[(A[i],i) for i in range(N)]
B=[(B[i],i) for i in range(N)]

check=True
Ainc=True
Binc=True
ABinc=True
A.sort()
B.sort()

for i in range(N):
    if A[i][0]>B[i][0]:
        check=False
    if i>0:
        if A[i-1]==A[i]:
            Ainc=False
        if B[i-1]==B[i]:
            Binc=False
        if B[i-1]>=A[i]:
            ABinc=False

if not check:
    print("No")
else:
    if (not Ainc) or (not Binc) or (not ABinc):
        print("Yes")
    else:
        edge=[[] for i in range(N)]
        for i in range(N):
            edge[A[i][1]].append(B[i][1])

        que=[0]
        while True:
            v=que[-1]
            nv=edge[v][0]
            if nv==0:
                break
            else:
                que.append(nv)
        if len(que)==N:
            print("No")
        else:
            print("Yes")

Measured memory_bytes: 97732
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

template<ll MOD = 1000000007>
class ModInt {
    ll n;
    ModInt constexpr inverse() const {
        return ModInt::pow(*this, MOD - 2);
    }

public:
    ModInt()
        : n(0) {}
    ModInt(ll _n)
        : n(((_n % MOD) + MOD) % MOD) {}
    ModInt operator+=(const ModInt &m) {
        n += m.n;
        if (n >= MOD) n -= MOD;
        return *this;
    }
    ModInt operator-=(const ModInt &m) {
        n -= m.n;
        if (n < 0) n += MOD;
        return *this;
    }
    ModInt operator*=(const ModInt &m) {
        n *= m.n;
        if (n >= MOD) n %= MOD;
        return *this;
    }
    ModInt operator/=(const ModInt &m) {
        (*this) *= m.inverse();
        return *this;
    }
    friend ModInt operator+(ModInt t, const ModInt &m) {
        return t += m;
    }
    friend ModInt operator-(ModInt t, const ModInt &m) {
        return t -= m;
    }
    friend ModInt operator*(ModInt t, const ModInt &m) {
        return t *= m;
    }
    friend ModInt operator/(ModInt t, const ModInt &m) {
        return t /= m;
    }
    ModInt operator=(const ll l) {
        n = l % MOD;
        if (n < 0) n += MOD;
        return *this;
    }
    friend ostream &operator<<(ostream &out, const ModInt &m) {
        out << m.n;
        return out;
    }
    friend istream &operator>>(istream &in, ModInt &m) {
        ll l;
        in >> l;
        m = l;
        return in;
    }
    static constexpr ModInt pow(const ModInt x, ll p) {
        ModInt<MOD> ans = 1;
        for (ModInt<MOD> m = x; p > 0; p /= 2, m *= m) {
            if (p % 2) ans *= m;
        }
        return ans;
    }
};
using mint = ModInt<>;
mint operator"" _m(unsigned long long m) {
    return mint(m);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin, n, k;
    cout << (n <= k) << endl;
    return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

// Segment Tree で解きたい
struct SegTree {
  vector<int> seg_tree;
  int sz;

  SegTree(int _n) {
    sz = 1;
    while (sz < _n) {
      sz *= 2;
    }

    seg_tree.resize(2* sz - 1);
  }

  void add(const int i, const int value, const int n) {
    int k = i + sz-1;
    seg_tree[k] += value;
    while (k > 0) {
      k = (k-1) / 2;
      seg_tree[k] += value;
    }
  }
  
  int sum_w(const int a, const int b) {
    return this->sum(a,b,0,0,sz);
  }

  int sum(const int a, const int b, int k, int l, int r) {
    if (b <= l || r <= a) return 0;

    if (a <= l && r <= b) return seg_tree[k];

    else {
      int res = 0;
      res += sum(a,b,2*k+1,l,(l+r)/2);
      res += sum(a,b,2*k+2,(l+r)/2,r);
      return res;
    }
  }

};

int main() {
  int n, q;
  cin >> n >> q;
  SegTree segTree(n);
  rep(i, q) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      x--;
      segTree.add(x, y, n);
    } else {
      x--;
      cout << segTree.sum_w(x,y) << "\n";
    }
  }
}


Measured memory_bytes: 3900
cup= [True, False, False]
while True:
    try:
        p= list(map(str, input().split(',')))
    except:
        break
    x, y= sorted(p)
    if x=='A' and y=='B':
        cup[0], cup[1]= cup[1], cup[0]
    elif x=='A' and y=='C':
        cup[0], cup[2]= cup[2], cup[0]
    elif x=='B' and y=='C':
        cup[1], cup[2]= cup[2], cup[1]
for i in range(3):
    if cup[i]:
        print('A' if i==0 else('B' if i==1 else 'C'))
        break

Measured memory_bytes: 7396
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  if(abs(n-m) > 1){cout << 0 << endl;return 0;}
  long long ans = 1;
  if(abs(n-m) < 1)ans = 2;
  do{
      (ans *= n) %= MOD;
  }while(--n>0);
  do{
      (ans *= m) %= MOD;
  }while(--m>0);
  cout << ans %MOD  << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define long long long
using namespace std;
long n, res;

int main()
{
    cin >> n;
    for (int i=1; (long) i*i<=n; ++i) {
        if (!(n % i))
            if ( i < (n/i - 1)) res += n/i - 1;
    }
    cout << res;
    return 0;
}


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

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<char>> c(h,vector<char>(w));
    rep(i,h) rep(j,w) cin>>c[i][j];
    int ans=0;
    for(int bith=0;bith<(1<<h);bith++){
        for(int bitw=0;bitw<(1<<w);bitw++){
            int black=0;
            rep(i,h){
                rep(j,w){
                    if(bith & (1<<i) && bitw & (1<<j)){
                        if(c[i][j]=='#') black++;

                    }
                }
            }
            if(black==k) ans++;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3644
import sys
def input():
    return sys.stdin.readline().strip()

n, m = map(int, input().split())
l, d = [[] for _ in range(n)], [[] for _ in range(n)]
for _ in range(m):
    i, j, k = map(int, input().split())
    i -= 1
    j -= 1
    l[i].append(j)
    l[j].append(i)
    d[i].append(k)
    d[j].append(-k)

# DFS
seen = ['yet' for _ in range(n)]
todo = []
for i in range(n):
    if seen[i] != 'yet':
        continue
    seen[i] = 0
    todo.append(i)
    while todo != []:
        j = todo.pop(-1)
        for k in range(len(l[j])):
            if seen[l[j][k]] != 'yet':
                if seen[j] + d[j][k] != seen[l[j][k]]:
                    print('No')
                    exit()
                continue
            seen[l[j][k]] = seen[j] + d[j][k]
            todo.append(l[j][k])
print('Yes')

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

int main() {
  string before, after;
  cin >> before >> after;
  string test = before + 'A';
  after.at(after.size() - 1) = 'A';
  
  if(after == test) {
    cout << "Yes"; }
  else {
    cout << "No"; }
  
}

Measured memory_bytes: 3628
#include <stdio.h>

void call(int);

int main(){
  int n;
  scanf("%d",&n);


  call(n);
  return 0;
}

void call(int n){

  int i,x;

  for( i=1;i<=n; i++){
  x = i;
  if(x % 3 == 0){
    printf(" %d",i);
  }
  else if(x % 10== 3){
      printf(" %d",i);
    }
    else {
      while(x !=0){
	if(x % 10 == 3){
	  printf(" %d", i);
	  break;
	}
	x /=10;
      }
    }
}

printf("\n");
}



Measured memory_bytes: 2128
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)
#define PI acos(-1)

struct Point{
  double x,y;

  Point(){}
  Point(double x,double y) : x(x),y(y) {}

  Point operator + (const Point &p)const{
    return Point(x + p.x , y + p.y);
  }

  Point operator - (const Point &p)const{
    return Point(x - p.x , y - p.y);
  }

  Point operator * (const double &k)const{
    return Point(x * k , y * k);
  }

  Point operator / (const double &k)const{
    return Point(x / k , y / k);
  }

  bool operator < (const Point &p)const{
    if(y != p.y) return (y - p.y < -EPS);
    else return (x - p.x < -EPS);
  }

  double dot(const Point &p)const{
    return x*p.x + y*p.y;
  }

  double cross(const Point &p)const{
    return x*p.y - p.x*y;
  }

  double dist(const Point &p)const{
    return sqrt(pow(x-p.x,2) + pow(y-p.y,2));
  }

  double norm(){
    return x*x + y*y;
  }

  double Abs(){
    return sqrt(norm());
  }
};

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;

int ccw(Point p0,Point p1,Point p2){
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(a.cross(b) > EPS){ return COUNTER_CLOCKWISE; }
  if(a.cross(b) < -EPS){ return CLOCKWISE; }
  if(a.dot(b) < -EPS){ return ONLINE_BACK; }
  if(a.norm() < b.norm()){ return ONLINE_FRONT; }
  return ON_SEGMENT;
}

typedef vector<Point> Polygon;

Polygon convex_hull(Polygon &ps){
  int N = ps.size(),j = 0;
  Polygon pg(N*2);
  sort(ps.begin(),ps.end());
  for(int i = 0 ; i < N ; i++,j++){
    while(j >= 2 && ccw(pg[j-2],pg[j-1],ps[i]) == -1){
      j--;
    }
    pg[j] = ps[i];
  }
  int k = j+1;
  for(int i = N-2 ; i >= 0 ; i--,j++){
    while(j >= k && ccw(pg[j-2],pg[j-1],ps[i]) == -1){
      j--;
    }
    pg[j] = ps[i];
  }
  pg.resize(j-1);
  return pg;
}

int main(){
  int N;
  cin >> N;
  Polygon pg(N),res;
  for(int i = 0 ; i < N ; i++){
    cin >> pg[i].x >> pg[i].y;
  }
  res = convex_hull(pg);
  N = res.size();
  cout << N << endl;
  for(int i = 0 ; i < N ; i++){
    cout << res[i].x << " " << res[i].y << endl;
  }
  return 0;
}

Measured memory_bytes: 5952
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a[100005]={},ans=0,cnt=0,x=INF;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    if(a[i]<0) {
      cnt++;
    }
    ans+=abs(a[i]);
    x=min(x,abs(a[i]));
  }
  cout << (cnt%2?ans-=2*x:ans) << endl;
}

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

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

  int fX = 0;
  rep(i, X.size()) fX += X[i] - '0';
  string ans;
  if ((stoi(X) % fX) == 0) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60; 
#define MOD 1000000007

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(min(b, d) - max(a, c), 0) << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool prime[1 << 16]={true,true};
int main(){
  for(int i = 2 ; i < (1 << 16) ; i++){
    if(!prime[i]){
      for(int j = 2 ; i * j < (1 << 16) ; j++){
        prime[i*j] = true;
      }
    }
  }
  int n;
  while(cin >> n , n){
    int cnt = 0 ;
    for(int i = 2 ; 2 * i <= n ; i++){
      if(!prime[i] && !prime[n-i]) cnt++;
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1224
N=int(input())
A=sorted(map(int,input().split()))
m,M=A[0],A[-1]
L=[]

for i in range(1,N-1):
    v=A[i]
    if v>=0:
        L.append((m,v))
        m-=v
    else:
        L.append((M,v))
        M-=v
L.append((M,m))
ans=M-m

print(ans)
for a,b in L:
    print(a,b)

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

int main(){
  int D[1001][1001];
  string a,b;
  cin >> a >> b;

  for(int i = 0;i <= a.size(); i++) D[i][0]=i;
  for(int i = 0;i <= b.size(); i++) D[0][i]=i;
  
  for(int i = 1; i <= a.size(); i++){
    for(int j = 1; j <= b.size(); j++){
      int k;
      k = (a[i-1]==b[j-1]) ? 0 : 1;
      D[i][j] = min(D[i-1][j]+1, min(D[i][j-1]+1, D[i-1][j-1]+k));
    }
  }
  cout << D[a.size()][b.size()] << endl;
  return 0;
}


Measured memory_bytes: 7096
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = in.nextIntArray(n);

		for (int i = 0; i < Math.min(k, 100); ++i) {
			int[] b = new int[n];
			for (int j = 0; j < n; ++j) {
				int l = Math.max(0, j - a[j]);
				int r = Math.min(n - 1, j + a[j]);
				b[l]++;
				if (r + 1 < n)
					b[r + 1]--;
			}
			a = b.clone();
			for (int x = 1; x < n; ++x) {
				a[x] += a[x - 1];
			}

		}

		StringBuilder res = new StringBuilder();

		for (int i = 0; i < n; i++) {
			res.append(a[i] + " ");
		}
		out.println(res.toString());
		out.flush();
		out.close();
	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

		public int[] nextIntArray(int n) throws IOException {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextInt();
			}
			return ret;
		}

		public long[] nextIntLong(int n) throws IOException {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextLong();
			}
			return ret;
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

}

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

using namespace std;


#define PI 3.14159265
#define int long long


const int MAXN = 1e5 + 5;
int mod = 1e9 + 7;

set <int> g[MAXN];

int res = 1;

int f(int k, int n){
	if(k > n) return 0;
	int res = 1;
	for(int i = n - k + 1; i <= n; i++){
		res *= i;
		res %= mod;
	}

	return res;
}

void dfs(int v){

	for(int to : g[v]){
		g[to].erase(v);
		dfs(to);
	}

}


void dfs2(int v, int k){

	if(v == 0){
		res *= f(g[v].size() + 1, k);
		res %= mod;
	}else{
		res *= f(g[v].size(), k - 2);
		res %= mod;
	}


	// if(res == 0){
	// 	cout << v + 1 << endl;
	// 	cout << g[v].size() << endl;
	// }

	for(int to : g[v]){
		dfs2(to, k);
	}
	
}


main(){


	int n, k;

	cin >> n >> k;


	int a, b;
	for(int i = 0; i < n - 1; i++){
		cin >> a >> b;
		a--; b--;
		g[a].insert(b);
		g[b].insert(a);
	}


	dfs(0);
	

	dfs2(0, k);
	

	cout << res << endl;

	return 0;
}

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


int main(void) {
  int N;
  cin >> N;
  map<string, int> m;
  rep(i, N) {
    string temp;
    cin >> temp;
    m[temp]++;
  }

  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;
  
  return 0;
}

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

int main() {
	int h, w;
	while (true) {
		cin >> h >> w;
		if ((h | w) != 0) {
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if ((i + j) % 2 == 0) {
						cout << "#";
					} else {
						cout << ".";
					}
				}
				cout << endl;
			}
			cout << endl;
		} else {
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
A = list(input())
count = 0
if int(A[0]) == 1:
    flg = 1
else:
    flg = 0
for i in A:
    if int(i) == flg:
        if flg == 0:
            flg = 1
        else:
            flg = 0
    else:
        count += 1
        if flg == 0:
            flg = 1
        else:
            flg = 0
print(count)

Measured memory_bytes: 4084