akhauriyash/Code-Regression huggingface dataset:
nums = list(map(int, input().split()))
rotation = input()

for i in rotation:
    top = nums[0]
    if i == "S":
        top = nums[4]
        nums = [top, nums[0], nums[2], nums[3], nums[5], nums[1]]
    elif i == "E":
        top = nums[3]
        nums = [top, nums[1], nums[0], nums[5], nums[4], nums[2]]
    elif i == "N":
        top = nums[1]
        nums = [top, nums[5], nums[2], nums[3], nums[0], nums[4]]
    elif i == "W":
        top = nums[2]
        nums = [top, nums[1], nums[5], nums[0], nums[4], nums[3]]

print(top)



Measured memory_bytes: 5600
#include <iostream>
#include <string>

constexpr int diff = 'A' - 'a';

int main(void){
    std::string s; std::getline(std::cin,s);
    for(char &c : s){
        if('a' <= c and c <= 'z') c += diff;
        else if('A' <= c and c <= 'Z') c -= diff;
    }
    std::cout << s << std::endl;
    return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int U[2003][2003];

int main() {
  ll D,A;
  cin >> D>>A;
  cout << D+A/2 <<endl;
}

Measured memory_bytes: 888
/*
    A - Entrance Examination
    https://atcoder.jp/contests/abc117/tasks/abc117_a
*/
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    double t, x;
    cin >> t >> x;

    cout << fixed;
    cout << setprecision(10) << (t / x) << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
if a[-1] == 0:
    print(0)
    exit()
total = 1
maxi = 10 ** 18
for ae in a:
    total *= ae
    if total > maxi:
        print(-1)
        exit()
print(total)



Measured memory_bytes: 21648
#include<bits/stdc++.h>
#define ll long long
#define MAX 100005

using namespace std;

const int INF = 1e9 + 5;
ll arr[MAX];
vector <ll> dp(MAX,INF);


int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>arr[i];
    dp[1] = 0;
    dp[2] = abs(arr[2] - arr[1]);
    for(int i = 3;i<=n;i++)
        for(int j=1;j<=k;j++){
        if(i-j<=0)break;
        dp[i] = min(dp[i - j] + abs(arr[i] - arr[i - j]),dp[i]);
        }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1792
def resolve():
    N, A, B, C, D = map(int, input().split())
    S = str(input())
    if C < D:
        if '##' in S[min(A, B):D]:
            print('No')
        else:
            print('Yes')
    elif C > D:
        if '##' in S[min(A, B):C]:
            print('No')
        else:
            if '...' in S[B-2:D+1]:
                print('Yes')
            else:
                print('No')


resolve()

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

using namespace std;

using int64 = long long;

int main()
{
  string S, T;
  cin >> S >> T;
  string X = S, Y = T;
  reverse(begin(S), end(S));
  reverse(begin(T), end(T));
  if(X == T && Y == S) {
    puts("YES");
  } else {
    puts("NO");
  }
}


Measured memory_bytes: 256
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	string s;
	cin>>s;
	int n=s.length();
	rb(i,1,n){
		cout<<'x';
	}
	return 0;
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n,k=get_i
h=array(n,1)
n.times do|i|
  h[i]=gets.to_i
end
h.sort!
min=10**9
(n-k+1).times do|i|
  if min>(h[i]-h[i+k-1]).abs
    min=(h[i]-h[i+k-1]).abs
  end
end
puts min

Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  bool prime[n + 1];
  rep(i, n + 1) prime[i] = true;
  prime[1] = false; prime[0] = false;
  for(int i = 2; i <= n; i++) {
    if(prime[i]) {
      for(int j = i * 2; j <= n; j += i) {
        prime[j] = false;
      }
    }
  }
  ll ans = 1;
  for(int i = 2; i <= n; i++) {
    if(prime[i]) {
      int t = n;
      int cnt = 0;
      while(t > 0) {
        t = t / i;
        cnt += t;
      }
      ans = ans * (cnt + 1) % MOD;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main(void){
    int A,B,cnt=0;
    cin>>A>>B;
    int i=A;
    while(i<=B){
        string a=to_string(i);

        if(a[0]==a[4]&&a[1]==a[3]){
            cnt++;
        }
        i++;
    }
    cout<<cnt<<endl;
    return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] a = new long[n];
        long[] b = new long[n];
        long[] c = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = Long.parseLong(sc.next());
        }
        for (int i = 0; i < n; i++) {
            b[i] = Long.parseLong(sc.next());
        }
        for (int i = 0; i < n; i++) {
            c[i] = Long.parseLong(sc.next());
        }
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
        long ans = 0;
        for (int i = 0; i < n; i++) {
            long temp = b[i];
            long idx = lowerBound(n, a, temp);
            long idx2 = upperBound(n, c, temp);
            ans += idx * (n - idx2);
        }
        System.out.println(ans);
    }

    private static long lowerBound(int n, long[] x, long y) {
        int left = 0;
        int right = n;
        while (left < right) {
            int mid = (left + right) / 2;
            if (x[mid] < y) {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        return left;
    }

    private static long upperBound(int n, long[] x, long y) {
        int left = 0;
        int right = n;
        while (left < right) {
            int mid = (left + right) / 2;
            if (x[mid] <= y) {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        return left;
    }
}

Measured memory_bytes: 66804
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int main(){
  long ii,jj,kk;
  //vector<int> a;
  int a,b;

  cin >> a >> b;
  cout << a*b << " " << (2*a)+(2*b) << endl;
  
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define endl "\n"
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    int n, k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    vector<int> dp(n, INT_MAX);
    dp[0]=0;
    dp[1] = abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        int j = max(0, i-k);
        for( ;j<i;j++)
            dp[i] = min(dp[i],dp[j]+ abs(a[i]-a[j]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 3856
#include <iostream>
#include <cstdio>
using namespace std;
int n, k, nums[101000], ans = 0x3f3f3f3f;
int f[101000];
bool vis[101000];
inline int abs( int r ){
	return r < 0 ? -r : r;
}
int main(){
	scanf("%d%d", &n, &k);
	nums[0] = 0x3f3f3f3f;
	for( int i = 1; i <= n; ++i )
		scanf("%d", &nums[i]);
	for( int i = 1; i+k-1 <= n; ++i ){
		int y = nums[i+k-1] - nums[i], x = min(abs(nums[i]), abs(nums[i+k-1]));
		ans = min(ans, x+y);
	}
	printf("%d\n", ans);
	return 0;
}

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

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

string n;

int main() {
  cin >> n;
  int sol = 9 * (int)n.size() - 9;
  sol += n[0] - '0' - 1;
  int tmp = 0;
  REP(i, (int)n.size()) tmp += n[i] - '0';
  printf("%d\n",max(sol, tmp));
  return 0;
}

Measured memory_bytes: 256
A, B, C = map(int,input().split())
li = [A, B, C]
li.sort()

ans = "No"

if li[0] == li[1] and li[1] != li[2] :
  ans = "Yes"

elif li[0] != li[1] and li[1] == li[1] == li[2]:
  ans = "Yes"

print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll N, M;
ll a[100000];

ll check(ll p){
    ll cnt = 0;
    for(int i = 0; i < N; i++){
        ll c = p - a[i];
        int pos = lower_bound(a, a + N, c) - a;
        cnt += N - pos;
    }

    return cnt;
}

int main(){
    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> a[i];
    sort(a, a + N);

    ll l = 0, r = (1LL << 60);
    while(l + 1 != r){
        ll p = (l + r) / 2;
        if(check(p) >= M) l = p;
        else r = p;
    }

    //cout << l << endl;

    ll sum[N + 1];
    sum[0] = 0;
    for(int i = 0; i < N; i++) sum[i + 1] = sum[i] + a[i];

    ll ans = 0;
    for(int i = 0; i < N; i++){
        ll c = l - a[i];
        int pos = lower_bound(a, a + N, c) - a;
        ans += sum[N] - sum[pos];
        ans += a[i] * (N - pos);
    }

    ans -= (check(l) - M) * l;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int b[505][505];

bool can(int H, int W, int h, int w) {
  if (w == 1) {
    return false;
  }
  
  int x = H * ((w-1) * (W / w) + max(0, W % w - 1));
  int a = W * H;
    
  for (int d = 1; d <= (int)1e6; d++) {
    int lo = 1, hi = (int)1e6, q = -1;
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      double p = (double)d / double(mid);
      if (double(x)/double(a-x) < p && p < w-1) {
        q = mid;
        break;
      } else if (p >= w-1) {
        lo = mid + 1;
      } else {
        hi = mid - 1;
      }
    }

    if (q > 0) {
      for (int j = 0; j < W; j++) {
        for (int i = 0; i < H; i++) {
          b[i][j] = (j % w) ? -q : d;
        }
      }
      return true;
    }
  }

  return false;
}

int main(void) {
  int H, W, h, w;
  scanf("%i %i %i %i", &H, &W, &h, &w);
  
  if (can(H, W, h, w)) {
    puts("Yes");
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        printf("%i%c", b[i][j], (j+1<W) ? ' ' : '\n');
      }
    }
  } else if (can(W, H, w, h)) {
    puts("Yes");
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        printf("%i%c", b[j][i], (j+1<W) ? ' ' : '\n');
      }
    }
  } else {
    puts("No");
  }
  
  return 0;
}

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

string S, T;
int A, B;
string U;

void solve(){
    if(U == S) A--;
    else B--;
    cout << A  << " " << B;
}
int main(){
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    int H = gi();
    int W = gi();
    int h = gi();
    int w = gi();

    printf("%d\n", (H-h) * (W-w));

    return 0;
}


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

int main() {
  int N;
  string S;
  cin >> S;
  S += '0';
  N = S.size();
  int A = 0;
  long long ans = 0;
  for (int i=0; i<N; i++) {
    if (S[i] == 'A') {
      A++;
    }
    else if (S[i] == 'B' && S[i+1] == 'C') {
      ans += A;
      i++;
    }
    else {
      A = 0;
    }
  }
  cout << ans << endl;
}

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

int main()
{
    /*int n,m;
    scanf("%d%d",&n,&m);
    printf("%d",n*(n-1)/2+m*(m-1)/2);
    return 0;*/
    char str[105];
    scanf("%s",str);
    int n=strlen(str);
    bool flag1=true,flag2=true;
    for(int i=0;i<(n-1)/2;i++)
    {
        if(str[i]==str[(n-1)/2-i-1])
        {
            continue;
        }
        flag1=false;
        break;
    }
    for(int i=(n+3)/2;i<n;i++)
    {
        if(str[i]==str[n-i-1])
        {
            continue;
        }
        flag2=false;
        break;
    }
    if(flag1&&flag2)puts("Yes");
    else puts("No");
    return 0;
} 


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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}

template<typename T>
ll com(T n, T m, T mod){
  ll a = 1, b = 1, ans;
  if(n == m || m == 0){
    ans = 1;
  }else{
    for(ll i = 0;i < m; i++){
      a *= n-i;
      a %= mod;
      b *= i+1;
      b %= mod;
    }
    ans = (a * powmod(b, mod-2, mod)) % mod;
  }
  
  return ans;
}

 
int main() {
  int K;
  string S;

  cin >> K;
  cin >> S;

  if(K >= S.length()){
    cout << S << endl;
    return 0;
  }else{
    
    rep(i, 0, K){
      cout << S[i];
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char s[4];
    scanf("%s", s);
    if (s[0] == s[1] && s[1] == s[2])
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }

    return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Here your code

A, B, C, X, Y = map(int, input().split())

result = 50000000000
for i in range(max(X+1,Y+1)):
    price = i * 2 * C + max(0,X-i)* A + max(0,Y-i)*B
    result = min(result,price)

print(result)




Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;

Node * listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;    
    nil->next = x;
    x->prev = nil;
}

void deleteNode(Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while (1) {
        if (cur == nil)
            break;
        if (isf++ > 0)
            printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

int main()
{
    int n, key, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);

    init();

    for (int i = 0; i < n; i++) {
        scanf("%s%d", com, &key);
        if (com[0] == 'i') {
            insert(key);
            size++;
            np++;
        }
        else if (com[0] == 'd') {
            if (strlen(com) > 6) {
                if (com[6] == 'F')
                    deleteFirst();
                else if (com[6] == 'L')
                    deleteLast();
            }
            else {
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }

    printList();

    return 0;
}

Measured memory_bytes: 33960
#include <stdio.h>
int main(){
  char c, str[6]="aeiou";
  scanf("%c", &c);
  for (int i=0; i<6; i++) {
    if (str[i]==c) {
      printf("vowel\n");
      return 0;
    }
  }
  printf("consonant\n");
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>
#include <time.h>
using namespace std;

int main(){ 
	long long N, K, ans = 1e10;
	vector<long long> h(1e5);

	cin >> N >> K;


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

	sort(h.begin(), h.end(), greater<long long>());

	for (int i = K - 1; i < N; ++i){
		ans = min(ans, h[i - K + 1] - h[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n;
	scanf("%lld",&n);
	printf("%lld",(n/2)*((n+1)/2));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n[3];
    rep(i, 3) cin >> n[i];
    sort(n, n + 3);
    int ans = 0;
    if(n[0] % 2 != n[1] % 2) { n[1]++; n[2]++; ans++; }
    ans += (n[2] * 2 - n[0] - n[1]) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def check_inner( W, H, x, y, r):
    if (x-r) < 0:
        return False
    if (x+r) > W:
        return False
    if (y-r) < 0:
        return False
    if (y+r) > H:
        return False
    return True

if __name__ == "__main__":

    nums = map( int, raw_input().split())
    if check_inner( nums[0], nums[1], nums[2], nums[3], nums[4]):
        print "Yes"
    else:
        print "No"

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}

// end of Template

ll n,ans,a[350][350];
bool valid = true;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }

    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            bool take = true;
            for(int k=1;k<=n;k++){
                if(k==i || k==j){continue;}
                if(a[i][j] > a[i][k] + a[k][j]){valid=false;break;}
                if(a[i][j] == a[i][k] + a[k][j]){take=false;}
            }
            if(!valid)break;
            if(take)ans+=a[i][j];
        }
    }
    if(!valid)ans=-1;
    cout<<ans<<newl;
}


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

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

Measured memory_bytes: 256
ans = 'Yes'
c = []
for _ in range(3):
  c.append(list(map(int, input().split())))
adiff = []
bdiff = []
for i in range(2):
  adiff.append(c[i+1][0] - c[i][0])
  bdiff.append(c[0][i+1] - c[0][i])
for i in range(1, 3):
  for j in range(1, 3):
    if adiff[i-1] != c[i][j] - c[i-1][j] or bdiff[j-1] != c[i][j] - c[i][j-1]:
      ans = 'No'
      break
print(ans)


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

int a, b, c, k, i, x;
int main(){
cin>>a>>b>>c>>k;
if(k==0){
  cout<<0;
  return 0;
}
if(k>=a+b){
  x=a;
  k=k-a-b;  
}
else if(k>=a){
  cout<<a;
  return 0;
}
else{ 
  cout<<k;
  return 0;
}
if(k==0){
  cout<<x;
  return 0;
}
else
  cout<<x-k;
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  string s;
  cin >> s;
  int q;
  cin >> q;
  
  string op,p;
  int a,b;
  string newStr;
  for(int i=0;i<q;i++){
    cin >> op >> a >> b;
    if(op.compare("replace")==0){
       cin >> p; 
       s.replace(a,b-a+1,p);
    }
    else if(op.compare("print")==0){
       cout << s.substr(a,b-a+1) << endl;
    }
    else if(op.compare("reverse")==0){
      newStr = s.substr(a,b-a+1);
      reverse(newStr.begin(),newStr.end());
        s.replace(a,b-a+1,newStr);
    }
  }
 
  return 0;
}


Measured memory_bytes: 3176
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18+5;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int n,m,par[100005]={},ans=0,p[100005]={},x,y;
struct unionfind {
  vector<int> par;
  unionfind(int n) : par(n,-1) {}
  void init(int n) {par.assign(n,-1);}
  int find(int x) {
    if (par[x]<0) return x;
    else return par[x]=find(par[x]);
  }
  bool issame(int x,int y) {
    return find(x)==find(y);
  }
  bool unit(int x,int 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;
  }
  int size(int x) {
    return -par[find(x)];
  }
};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  unionfind uf(n);
  for(int i=0; i<n; i++) {
    cin >> p[i];
    p[i]--;
    par[i]=i;
  }
  while(m--) {
    cin >> x >> y;
    x--,y--;
    uf.unit(x,y);
  }
  for(int i=0; i<n; i++) {
    if(uf.find(i)==uf.find(p[i])) {
      ans++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1408
let n, ans = read_int (), ref 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let _ = Array.fold_left (fun c a -> if a = c then c + 1 else (incr ans; c)) 1 a_s
let _ = Printf.printf "%d\n" @@ if !ans = n then -1 else !ans

Measured memory_bytes: 6272
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(void){
	int N;
	VI arr;
	cin >> N;
	for (int i = 0; i < N;i++){
		int a;
		cin >> a;
		arr.push_back(a);
	}
	int cnt = 0;
	while (1)
	{
		REP(i,N){
			if (arr[i] % 2 != 0){
				cout << cnt << endl;
				return 0;
			}
			arr[i] = arr[i] / 2;
		}
		cnt++;
	}
	return 0;
}



Measured memory_bytes: 256
X, N = [int(i) for i in input().split()]
if N == 0:
# if False:
    print(X)
else:
    Ps = set([int(i) for i in input().split()])
    # if not X in Ps:
    #     print(X)

    # print(f'{X} {sorted(Ps)}')
    diff = 0
    while True:
        a = X - diff
        if a not in Ps:
            print(a)
            break
        a = X + diff
        if a not in Ps:
            print(a)
            break
        diff += 1

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

void solve() {
	int gx, gy;
	cin >> gx >> gy;

	const int w = gx + 1, h = gy + 1;
	vector<vector<bool>> can_move_right(h, vector<bool>(w, true));
	auto can_move_down(can_move_right);

	for(int y = 0; y <= gy; ++y) can_move_right[y][gx] = false;
	for(int x = 0; x <= gx; ++x) can_move_down[gy][x]  = false;

	int p;
	cin >> p;

	while(p--) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		auto &tmp = (x1 != x2 ? can_move_right : can_move_down);
		tmp[min(y1, y2)][min(x1, x2)] = false;
	}

	vector<vector<int>> dp(h, vector<int>(w, 0));
	dp[0][0] = 1;

	for(int y = 0; y <= gy; ++y) {
		for(int x = 0; x <= gx; ++x) {
			if(can_move_right[y][x]) dp[y][x + 1] += dp[y][x];
			if(can_move_down[y][x])  dp[y + 1][x] += dp[y][x];
		}
	}

	if(dp[gy][gx]) {
		cout << dp[gy][gx] << endl;
	}
	else {
		cout << "Miserable Hokusai!" << endl;
	}
}

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

	int T;
	cin >> T;

	while(T--) {
		solve();
	}

	return EXIT_SUCCESS;
}

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




const double INF = 1e12;
typedef long long ll;
double xs, ys, xt, yt;
int N;
double x[1010], y[1010], r[1010];
//-----------------------------------------------------------------
double E[1010][1010];
struct Comp {
	bool operator() (pair<int, double> a, pair<int, double> b) {
		return a.second > b.second;
	}
};
priority_queue<pair<int, double>, vector<pair<int, double>>, Comp> que;
double D[1010];
bool done[1010];
int main() {
	cin >> xs >> ys >> xt >> yt >> N;
	x[0] = xs;
	y[0] = ys;
	r[0] = 0;
	rep(i, 1, N + 1) {
		cin >> x[i] >> y[i] >> r[i];
	}
	x[N + 1] = xt;
	y[N + 1] = yt;
	r[N + 1] = 0;

	N += 2;

	rep(i, 0, N) rep(j, i + 1, N) {
		double d1 = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
		double d2 = r[i] + r[j];

		double d3 = max(0.0, d1 - d2);

		E[i][j] = E[j][i] = d3;
	}

	rep(i, 0, N) D[i] = INF;

	que.push(make_pair(0, 0));
	while (!que.empty()) {
		auto q = que.top();
		que.pop();

		int i = q.first;
		double c = q.second;

		if (done[i]) continue;
		done[i] = true;

		rep(j, 0, N) if(!done[j]){
			double cc = c + E[i][j];
			if (cc < D[j]) {
				D[j] = cc;
				que.push(make_pair(j, cc));
			}
		}
	}

	printf("%.10f\n", D[N - 1]);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, x;
  cin >> n >> x;
  int a[1000];
  rep(i, 0, n) cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  rep(i, 0, n) {
    if(x >= a[i]) {
      x -= a[i];
      ans++;
    }
  }
  if(ans == n && x > 0) ans--;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	int N;
	scanf("%d",&N);
	long long L[87];
	L[0] = 2;
	L[1] = 1;
	for(int i=2;i<87;i++){
		L[i] = L[i-1] + L[i-2];
	}

	printf("%lld\n",L[N]);

	return 0;
}


Measured memory_bytes: 128
import copy
S = str(input())
lst = []
output = [0] * len(S)

for i in range(1, len(S)):
	if S[i - 1] == S[i]:
		pass
	else:
		lst.append(i)
# print(lst)

right_id = 0
left_id = 0
lst_2 = copy.deepcopy(lst)
lst_2.insert(0, 0)

for i in range(len(S)):
	# print(lst_2[left_id], lst[right_id])
	if i == lst[right_id] and right_id < len(lst) - 1:
		right_id += 1
	if left_id < len(lst_2) - 1 and i - lst_2[left_id] > i - lst_2[left_id + 1] and i - lst_2[left_id + 1] >= 0:
		left_id += 1
	if S[i] == "R":
		if (lst[right_id] - i - 1) % 2 == 0:
			output[lst[right_id]- 1] += 1
		else:
			output[lst[right_id]] += 1
	else:
		if (i - lst_2[left_id]) % 2 == 0:
			output[lst_2[left_id]] += 1
		else:
			output[lst_2[left_id] - 1] += 1
	# print(i)
	# print(output)
for i in range(len(output)):
	print(output[i], end = " ")

Measured memory_bytes: 77600
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
n =  int(input())
lista = a+b+c
call_number = []
for i in range(n):
    k = int(input())
    call_number.append(k)
bingo_number_list = []
for m,n in enumerate(lista):
    if n in call_number:
        bingo_number_list.append(m)
    
list0 = [0,1,2]
list1 = [3,4,5]
list2 = [6,7,8]
list3 = [0,3,6]
list4 = [1,4,7]
list5 = [2,5,8]
list6 = [0,4,8]
list7 = [2,4,6]
bingo = 0
for i in range(8):
    if set(list0) <= set(bingo_number_list):
        bingo += 1
    if set(list1) <= set(bingo_number_list):
        bingo += 1
    if set(list2) <= set(bingo_number_list):
        bingo += 1
    if set(list3) <= set(bingo_number_list):
        bingo += 1
    if set(list4) <= set(bingo_number_list):
        bingo += 1
    if set(list5) <= set(bingo_number_list):
        bingo += 1
    if set(list6) <= set(bingo_number_list):
        bingo += 1
    if set(list7) <= set(bingo_number_list):
        bingo += 1

if bingo > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
require 'prime'

# $st = Array.new(2**18-1, 0)
is_prime = Array.new( 10 ** 5 + 30, false )

# def query(a, b, k, l, r)
  
#   return 0 if r<=a || b<=l
#   return $st[k] if a <= l && r<=b
  
#   vl = query(a, b, k * 2 + 1, l, (l+r)/2 )
#   vr = query(a, b, k * 2 + 2, (l+r)/2, r )
#   return vl + vr
# end

primes = Prime.each(10**5+15).to_a

primes.each do |p|
  is_prime[p] = true
end

# 2 ** 17     = 101072 
# 2 ** 17 - 1 = 131071

# primes.each do |p|
  
#   $st[131070 + p] = 1  if is_prime[(p+1)/2]
# end

nums_like_2017 = []
primes.each do |p|
  nums_like_2017 << p if is_prime[(p+1)/2]
end

# p ?o
# p nums_like_2017.size
# p nums_like_2017
# p ?e

# 16.downto(0) do |i|
  
#   start = 2 ** i - 1
#   # p start
#   (start..(start*2)).each do |j|
#     $st[j] = $st[j*2+1] + $st[j*2+2]
#   end
# end

# p $st[2**17-1,30]
# p $st[2**16-1,30]
# p $st[2**15-1,30]
# p $st[2**5-1,30]
# p $st[0,1]
# p $st[65535, 100]

Q = gets.to_i


ary = nums_like_2017
# p ary
Q.times do |i|
  
  l, r = gets.split.map(&:to_i)
  
  # puts query(l, r, 0, 0, 10**5)
  rn = ary.bsearch_index{ |x| x > r }
  rn = 672 if rn.nil?
  ln = ary.bsearch_index{ |x| x >= l }
  ln = 672 if ln.nil?
  
  # p [ln, rn]
  puts rn - ln
end

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

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

#define U 1e+18

int main(){
  LL a,b,c,k,ret;
  cin>>a>>b>>c>>k;
  LL mod = k%2;
  if(mod==0)
    ret = a-b;
  else
    ret = b-a;
  if(ret > U)
    cout<<"Unfair"<<endl;
  else
    cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define FOR(i, c) for (int i = 0; i < c; i++)
#define MOD 1000000007
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> A(n+1, false);
  FOR(i, k) {
    int d; cin >> d;
    FOR(j, d) {
      int a; cin >> a;
      A[a] = true;
    }
  }

  int res = 0;
  FOR(i, n+1) {
    if (i && !A[i]) res++;
  }
  cout << res << endl;
  return 0;
}



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

int main() {
  int s1, s2, s3, x;
  double y;
  cin >> y;
  s1 = y/100;
  s2 = (y-s1*100)/10;
  s3 = (y-s1*100-s2*10);
  x = s1+s2+s3;
  cout << x << endl;
}

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

int main() {
	int n; cin >> n;
	int one = n % 10;
	if (one == 0 || one == 1 || one == 6 || one == 8) cout << "pon";
	else if (one == 3) cout << "bon";
	else cout << "hon";
	cout << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    ld R;
    cin >> R;
    ld pi = 3.14159265358979323846264338327950288;
    ld ans = 2 * pi * R;

    cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 3788
n = int(input())
s = list(input() for _ in range(n))
m = int(input())
t = list(input() for _ in range(m))

d = {}
for each in s:
  d[each] = d.get(each, 0) + 1
for each in t:
  d[each] = d.get(each, 0) - 1

print(max(max(d.values()), 0))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  int N,D;
  cin>>N>>D;
  int X[11][11];
  for (int i=1; i<=N; i++){
    for (int j=1; j<=D; j++){
      cin>>X[i][j];}}
  int counter=0;
  for (int i=1; i<N; i++){
    for (int j=i+1; j<=N; j++){
      int distance=0;
     
      for(int k=1; k<=D; k++) distance+=pow((X[i][k]-X[j][k]),2);
       bool t=false;
        for (int l=1; l<=1000; l++){
          if (distance==pow(l,2)) t=true;
        }
      if (t) counter++;}}
  cout<<counter<<endl;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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() {
    string t;
    cin >> t;
    for(auto &c : t)if(c == '?')c = 'D';
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3768
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def judge(s:list) -> bool:
    
    if not s[0] == 'A':
        return False
        
    if not 'C' in s[2:-1]:
        return False
        
    s.remove('C')
    s.remove('A')
    
    for si in s:
        if not 'a' <= si <= 'z':
            return False
            
        
    return True


s = lc()

ac = judge(s)
print('AC') if ac else print('WA')

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<set>
#include<map>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

int main(void){
  vector<set<int> > a(9);
  map<char,int> m;
  rep(i,9)m[(char)(i+'A')] = i;
  int i;
  a[0].insert('B'); a[0].insert('D');
  a[1].insert('A'); a[1].insert('C'); a[1].insert('E');
  a[2].insert('B'); a[2].insert('F');
  a[3].insert('A'); a[3].insert('G'); a[3].insert('E');
  a[4].insert('D'); a[4].insert('B'); a[4].insert('H'); a[4].insert('F');
  i = 5;a[i].insert('C'); a[i].insert('I'); a[i].insert('E');
  i = 6;a[i].insert('D'); a[i].insert('H');
  i = 7;a[i].insert('G'); a[i].insert('I'); a[i].insert('E');
  i = 8;a[i].insert('H'); a[i].insert('F');
  string s;
  bool f;
  while(cin>>s){
    f = true;
    rep(i,s.size()-1){
      if(a[m[s[i]]].find(s[i+1])==a[m[s[i]]].end()){
        f = false;
      //  cout<<s[i]<<" "<<s[i+1]<<endl;
      }
    }


    if(f)cout<<s<<endl;
  }
}

Measured memory_bytes: 3132
#include <iostream>
using namespace std;
int main(void) {
    // Your code here!
    int INF = 10000000;
    
    while(true) {
        int n, m;
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        
        int tableC[m][m];
        int tableT[m][m];
        
        for(int i = 0; i < m; i++) {
            for(int j = 0; j < m; j++) {
                tableC[i][j] = INF;
                tableT[j][i] = INF;
            }
        }
        
        int a, b, c, t;
        for(int k = 0; k < n; k++) {
            cin >> a >> b >> c >> t;
            tableC[a-1][b-1] = c;           
            tableC[b-1][a-1] = c;            
            tableT[a-1][b-1] = t;            
            tableT[b-1][a-1] = t;            
        }
        
        for(int k = 0; k < m; k++) {
            for(int i = 0; i < m; i++) {
                for(int j = 0; j < m; j++) {
                    if(tableT[i][j] > tableT[i][k] + tableT[k][j]) {
                        tableT[i][j] = tableT[i][k] + tableT[k][j];
                    }
                    if(tableC[i][j] > tableC[i][k] + tableC[k][j]) {
                        tableC[i][j] = tableC[i][k] + tableC[k][j];
                    }
                }
            }
        }
        
        int l, p, q, r;
        cin >> l;
        for(int i = 0; i < l; i++) {
            cin >> p >> q >> r;
            if(r == 0) {
                cout << tableC[p-1][q-1] << endl;
            } else {
                cout << tableT[p-1][q-1] << endl;
            }
        }
    }
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
  
using namespace std;
  
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
const char d[4] = {'L', 'U', 'R', 'D'};
  
int main()
{
    char ch;
    bool G[6][6][4];
    memset(G, 0, sizeof(G));
    for (int i = 0; i < 9; i++) {
	int d = i%2;
	for (int j = 0; j < 4+d; j++) {
	    cin >> ch;
	    if (ch == '1') {
		if (d % 2) {
		    G[i/2+1][j][2] = G[i/2+1][j+1][0] = 1;
		} else {
		    G[i/2][j+1][3] = G[i/2+1][j+1][1] = 1;
		}
	    }
	}
    }
    int x = 1, y = 0, dir = 2;
    string ans;
    while(1){
	if (!x && !y) break;
	ans += d[dir];
	int rh = (dir+1) % 4;
	if (G[y][x][dir]) {
	    dir--;
	    dir = (dir == -1 ? 3 : dir);
	} else if (!G[y+dy[dir]][x+dx[dir]][rh]) {
	    x += dx[dir], y += dy[dir];
	    if (!x && !y) break;
	    x += dx[rh], y += dy[rh];
	    dir = rh;
	    int nrh = (rh+1) % 4;
	    if (!G[y][x][nrh] && !(!x && !y)) {
		x += dx[nrh], y += dy[nrh];
		dir = nrh;
	    }
	} else {
	    x += dx[dir]; y += dy[dir];
	}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3044