akhauriyash/Code-Regression huggingface dataset:
s = input()
t = input()

dict_st = {}
dict_ts = {}

for x, y in zip(s, t):
    if x not in dict_st:
        dict_st[x] = y 
    else:
        if dict_st[x] != y:
            print("No")
            exit()

    if y not in dict_ts:
        dict_ts[y]=x
    else:
        if dict_ts[y]!=x:
            print("No")
            exit()

print("Yes")

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

using namespace std;
using ll = long long;

#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)

int main()
{
    ll N, M;
    string s;

    map<string, ll> m;

    cin >> N;
    rep(i, N)
    {
        cin >> s;
        m[s]++;
    }

    cin >> M;
    rep(i, M)
    {
        cin >> s;
        m[s]--;
    }

    ll ans = 0;
    for (auto i = m.begin(); i != m.end(); i++)
    {
        ans = max(ans, i->second);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m;
int turn[2][21];
int main() {
  int test_case = 0;
  while (scanf("%d %d", &n, &m), n|m) {
    test_case++;
    MEMSET(turn, 0);
    turn[0][0] = n;
    REP(t, 1000000) {
      int prev = t & 1;
      int next = prev ^ 1;
      MEMSET(turn[next], 0);
      if (turn[prev][m]) {
        printf("Case %d: %d\n", test_case, t);
        goto end;
      }
      REP(i, n) {
        turn[next][i + 1] += turn[prev][i] / 2;
        turn[next][0] += turn[prev][i] / 2;
        turn[next][i] += turn[prev][i] % 2;
      }
    }
    assert(false);
end:;
  }
}

Measured memory_bytes: 872
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using vd = vector<double>;
using i64 = int64_t;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> &v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

int main() {
  int n;
  cin >> n;
  vi a(n + 1, 0);
  FOR(i, 1, n + 1) cin >> a[i];
  FOR(i, 1, n + 1) {
    cout << "node " << i << ": key = " << a[i] << ", ";
    if (parent(i) >= 1) cout << "parent key = " << a[parent(i)] << ", ";
    if (left(i) <= n) cout << "left key = " << a[left(i)] << ", ";
    if (right(i) <= n) cout << "right key = " << a[right(i)] << ", ";
    cout << endl;
  }
}


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

using namespace std;

void solve() {
  int h, n;
  cin >> h >> n;
  // vector<int> damage(n);
  // vector<int> consume(n);
  // vector<pair<int, int>> magics;
  map<int, int> magics;
  // magics.reserve(n);
  int min_cost = INT_MAX;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    if (b < min_cost) {
      auto res = magics.emplace(a, b);
      if (!res.second) {
        auto& val = res.first->second;
        val = min(val, b);
      }
      int cost = ((h - 1) / a + 1) * b;
      min_cost = min(min_cost, cost);
    }
  }

  // sort(magics.begin(), magics.end(), [](auto&& a, auto&& b) {
  //   return static_cast<double>(a.first) / a.second >
  //          static_cast<double>(b.first) / b.second;
  // });

  // magic, hp -> consume
  vector<vector<int>> dp(n + 1, vector<int>(h + 1, INT_MAX));
  dp[0][h] = 0;

  auto it = magics.rbegin();
  for (int i = 0; i < n && it != magics.rend(); ++i, ++it) {
    int dmg, cst;
    tie(dmg, cst) = *it;
    // tie(dmg, cst) = magics[i];
    for (int remain = 0; remain <= h; ++remain) {
      auto cur_cost = dp[i][remain];
      if (cur_cost < min_cost) {
        for (int use = 0;; ++use) {
          int r = max(0, remain - use * dmg);
          int cost = cst * use;
          int next_cost = cost + cur_cost;
          if (min_cost <= next_cost) {
            break;
          }
          auto& next = dp[i + 1][r];
          next = min(next, next_cost);
          if (!r) {
            min_cost = min(min_cost, next);
            break;
          }
        }
      }
    }
  }

  cout << min_cost << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}

Measured memory_bytes: 39552
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
//     for(int i=0; i<N;i++){
//     }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N,M;
    char op;
    cin>>N>>op>>M;
    int ans = 0;
    int cnt = 0;

    if(op=='+'){
      ans = N+M;
    }else{
      ans = N-M;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;

using namespace std;

const ll INF = 1e18;
const ll maxn = 3120;
const ll mod = 1e9+7;

ll n , m , w;
ld dp[maxn][maxn];
ld p[maxn];

int main()
{
    cin>> n;
    for(ll i = 1; i <= n; i++) cin>> p[i];

    ld ans = 0;
    dp[1][0] = 1 - p[1];
    dp[1][1] = p[1];
    if(n == 1)
        ans += dp[1][1];
    for(ll i = 2; i <= n; i++)
    {
        for(ll j = 0; j <= i; j++)
        {
            dp[i][j] = (1-p[i]) * dp[i-1][j] + p[i] * dp[i-1][j-1];

            if(i == n && j > n/2)
                ans += dp[i][j];
        }
    }

    cout<< setprecision(10) << fixed << ans;
}










Measured memory_bytes: 145920
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 998244353
#define INF2 1000000000000000000
#define int long long

int inversefact[300011] = {};
int fact[300011] = {};

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int comparison(int n, int r) {
	if (n < r) return 0;
	int ret;
	ret = Mul(Mul(fact[n], inversefact[n - r]), inversefact[r]);
	// cout << fact[n] << " " << inversefact[n - r] << " " << inversefact[r] << endl;
	return ret;
}
void init(void) {
	fact[0] = 1;
	rep(i, 300011) fact[i + 1] = (fact[i] * (i + 1)) % mod;
	inversefact[300010] = power(fact[300010], mod - 2);
	for (int j = 300009; j >= 0; j--) {
		inversefact[j] = inversefact[j + 1] * (j + 1) % mod;
	}

}

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

	int N, A, B, K;
	cin >> N >> A >> B >> K;

	int ans = 0;

	rep(i, N + 1) {
		int red = i;
		int tmp = K - red * A;
		if (tmp < 0) break;
		if (tmp % B) continue;
		int blue = tmp / B;
		ans = (ans + comparison(N, red) * comparison(N, blue)) % mod;
		// cout << ans << endl;
	}
	cout << ans << endl;



    return 0;
}


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


int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(30);
    int N,a,b,c,ans;
    vector<int> A;
    vector<int> B;
    vector<int> C;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >>a;
        A.push_back(a);
    }
    for(int i=0;i<N;i++){
        cin >>b;
        B.push_back(b);
    }
    for(int i=0;i<N-1;i++){
        cin >> c;
        C.push_back(c);
    }
    ans=0;
    for(int i=0;i<N;i++){
        ans+=B[A[i]-1];
        if(A[i+1]==A[i]+1){
            ans+=C[A[i]-1];
        }
    }
    cout << ans;
    return 0;
}

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

int main(){
	int N,A,B,KJ;
	int tpg[110];//??????????????°????????????
	int dp[110];
	cin>>N>>A>>B>>KJ;
	for(int i=0;i<N;i++){
		cin>>tpg[i];
	}
	sort(tpg,tpg+N,greater<int>());
	dp[0]=KJ;
	for(int i=0;i<N;i++){
		dp[i+1]=dp[i]+tpg[i];
	}
	int cnt=0;
	for(int i=1;i<=N;i++){
		cnt=max(cnt,(dp[i]/(A+i*B)));
	}
	cout<<cnt<<endl;
	return 0;
}

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

using namespace std;

const int N = 2e5 + 5;

char s[N];
int cnt[26];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  long long ans = 1;
  for (int i = n - 1; i >= 0; i--) {
    ans += (n - i - 1) - cnt[s[i] - 'a'];
    cnt[s[i] - 'a']++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
from collections import defaultdict
d = defaultdict(int)

def main(s, x=1):
    f = True
    l = 0
    r = 0
    index = float("INF")
    res = 0
    i = 0
    lis = []
    if x:
        while i < len(s):
            if s[i].isupper():
                tmp = s[i]
                i += 1
                while i < len(s) and s[i].islower():
                    tmp += s[i]
                    i += 1
                lis.append(tmp)

            elif s[i].isdecimal():
                tmp = s[i]
                i += 1
                while i < len(s) and s[i].isdecimal():
                    tmp += s[i]
                    i += 1
                lis.append(tmp)

            else:
                lis.append(s[i])
                i += 1
    else:
        lis = s
    s = lis
    ans = 0
    i = 0
    # print(s,x)
    while i < len(s):
        if s[i] == "(":
            f = False
            l += 1
            index = min(index, i)

        elif s[i] == ")":
            r += 1
            if l == r:
                res = main(s[index + 1 :i], 0)
                if res == "UNKNOWN":
                    return res
                f = True
                if i != len(s) - 1:
                    if s[i + 1].isdecimal():
                        i += 1
                        res *= int(s[i])
                ans += res
                index = float("INF")
                l = 0
                r = 0
        
        else:
            if f:
                if not (s[i] in d.keys()):
                    return "UNKNOWN"
                res = d[s[i]]
                if i != len(s) - 1:
                    if s[i + 1].isdecimal():
                        i += 1
                        res *= int(s[i])
                ans += res

        i += 1
    return ans


if __name__ == "__main__":
    while 1:
        n = input()
        if n == "END_OF_FIRST_PART":
            break
        a, b = n.split()
        b = int(b)
        d[a] = b
    while 1:
        n = input()
        if n == "0":
            break
        print(main(n))


Measured memory_bytes: 6020
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;

ll pref[MAXN];

ll suff[MAXN];

int arr[MAXN];

int n, k;

ll ans;

void solve() {
    scanf("%d %d", &n, &k);

    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i]);
    }

    for (int i = 1; i <= n; ++i) {
        pref[i] = pref[i - 1] + max(0, arr[i]);
    }

    for (int i = n; i > 0; --i) {
        suff[i] = suff[i + 1] + max(0, arr[i]);
    }

    ll sum = 0;

    for (int i = 1; i <= k; ++i) {
        sum += arr[i];
    }

    for (int i = 1; i + k - 1 <= n; ++i) {
        ans = max(ans, pref[i - 1] + max(0ll, sum) + suff[i + k]);
        sum = sum - arr[i] + arr[i + k];
    }

    printf("%lld\n", ans);
}

int main() {
    int tt = 1;

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

    return 0;
}

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

using namespace std;

class BipariteGraph {
public:
    // Bipartite Graph G = (A; B, E), A = [0, L), B = [L, L + R)
    BipariteGraph(int _L, int _R) : L(_L), R(_R), adj(L + R), match_to(L + R, -1), visited(L + R), size_match(0) {}

    void add_edge(const int v1, const int v2) {
        adj[v1].push_back(L + v2);
        adj[L + v2].push_back(v1);
    }

    int MaximumMatching() {
        for (int v = 0; v < L; ++v) {
            fill(visited.begin(), visited.end(), false);
            if (Augment(v)) ++size_match;
        }

        return size_match;
    }

private:
    const int L, R;
    vector<vector<int>> adj;
    vector<int> match_to;
    vector<bool> visited;
    int size_match;

    bool Augment(const int cur) {
        for (const int dst : adj[cur])
            if (!visited[dst]) {
                visited[dst] = true;
                if (match_to[dst] < 0 || Augment(match_to[dst])) {
                    match_to[cur] = dst; match_to[dst] = cur;
                    return true;
                }
            }
        return false;
    }
};

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

    int n;

    cin >> n;
    vector<pair<int, int>> red(n);
    for (int i = 0; i < n; ++i)
        cin >> red[i].first >> red[i].second;

    BipariteGraph g(n, n);
    pair<int, int> blue;
    for (int i = 0; i < n; ++i) {
        cin >> blue.first >> blue.second;
        for (int j = 0; j < n; ++j)
            if (red[j].first < blue.first && red[j].second < blue.second)
                g.add_edge(j, i);
    }

    cout << g.MaximumMatching() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  cout<<"ABC"<<n<<endl;
}


Measured memory_bytes: 256
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 3005;
int n,S; 
int a[MAXN];

int dp[MAXN][MAXN];
const int MOD = 998244353;

int rec(int idx,int sum){
    if(idx == n+1) return 0;

    int &ans = dp[idx][sum];

    if(ans != -1) return ans;

    ans = 0;

    ans = (ans + rec(idx+1,sum));

    int n_S = sum + a[idx];
    if(n_S < S) ans = (ans + rec(idx+1,n_S)%MOD)%MOD;
    if(n_S == S) ans = (ans + (n-idx+1)%MOD)%MOD; 

    return ans;
}

void solve(){
    cin>>n>>S;

    FOR(i,1,n) cin>>a[i];

    MINUS(dp);

    int ans = 0;
    FOR(i,1,n){
        ans = (ans + rec(i,0))%MOD;
    }
    cout<<ans<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 71040
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

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

  int key = 1;
  int a, broken = 0;
  REP1(i, N) {
    cin >> a;
    (a == key ? key : broken)++;
  }
  cout << (N == broken ? -1 : broken) << endl;
  return 0;
}


Measured memory_bytes: 3624
package main

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

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	bs := NewBufScanner(in)
	bw := NewBufWriter(out)
	defer bw.w.Flush()
	n, k := bs.Int64Scan(), bs.Int64Scan()

	ans := n % k
	ansDiv := ans - k
	if ansDiv < 0 {
		ansDiv *= -1
	}

	if ans > ansDiv {
		bw.Printf("%v", ansDiv)
	} else {
		bw.Printf("%v", ans)
	}
}

// BufScanner original scanner
type BufScanner struct {
	s *bufio.Scanner
}

// NewBufScanner constructer
func NewBufScanner(in io.Reader) *BufScanner {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 1024), 1e+9)
	s.Split(bufio.ScanWords)
	return &BufScanner{
		s: s,
	}
}

// Scan Scan Data
func (b *BufScanner) Scan() string {
	b.s.Scan()
	return b.s.Text()
}

// Int64Scan Scan Data
func (b *BufScanner) Int64Scan() int64 {
	v, err := strconv.ParseInt(b.Scan(), 10, 64)
	if err != nil {
		panic(err)
	}
	return v
}

// BufWriter original writer
type BufWriter struct {
	w *bufio.Writer
}

// NewBufWriter constructer
func NewBufWriter(out io.Writer) *BufWriter {
	w := bufio.NewWriter(out)
	return &BufWriter{
		w: w,
	}
}

// Printf Output file
func (b *BufWriter) Printf(format string, a ...interface{}) {
	fmt.Fprintf(b.w, format, a...)
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <vector>
#include <stack>
#include <string>
#include <limits.h>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end());
    if(arr[0] >= 0)
    {
        int res = -arr[0];
        for(int i = 1; i < n; i++)
            res += arr[i];
        cout << res << endl;
        int temp = arr[0];
        for(int i = 1; i < n; i++)
        {
            if(i < n-1)
            {
                cout << temp << " " << arr[i] << endl;
            }
            else
            {
                cout << arr[i] << " " << temp << endl;
            }
            temp -= arr[i];
        }
    }
    else if(arr[n-1] <= 0)
    {
        reverse(arr.begin(), arr.end());
        int res = arr[0];
        for(int i = 1; i < n; i++)
            res += abs(arr[i]);
        cout << res << endl;
        int temp = arr[0];
        for(int i = 1; i < n; i++)
        {
            cout << temp << " " << arr[i] << endl;
            temp -= arr[i];
        }
    }
    else
    {
        int res = 0;
        for(int i = 0; i < n; i++)
            res += abs(arr[i]);
        cout << res << endl;
        int p = 0;
        while(arr[p] < 0)
            p++;
        for(int i = 0; i < p-1; i++)
        {
            cout << arr[p] << " " << arr[i] << endl;
            arr[p] -= arr[i];
        }
        int temp = arr[p-1];
        for(int i = p; i < n; i++)
        {
            if(i < n-1)
            {
                cout << temp << " " << arr[i] << endl;
            }
            else
            {
                cout << arr[i] << " " << temp << endl;
            }
            temp -= arr[i];
        }    
    }
	return 0;
}

Measured memory_bytes: 2304
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
        String[] a=null;
        int m=0;
        int f=0;
        int r=0;
		int k=0;
		String g=null;
        while(true){
        	a=br.readLine().split(" ");
            m=Integer.parseInt(a[0]);
            f=Integer.parseInt(a[1]);
            r=Integer.parseInt(a[2]);
            k=m+f;
            if(m==-1&&f==-1&&r==-1){
            	break;
            }else if(m==-1||f==-1||k<30){
        		g="F";
        	}else if(30<=k&&k<50){
        		if(r>=50){
        			g="C";
        		}else{
        			g="D";
        		}
        	}else if(50<=k&&k<65){
        		g="C";
        	}else if(65<=k&&k<80){
        		g="B";
        	}else{
        		g="A";
        	}
            sb.append(g+"\n");
        }
        System.out.print(sb);
	}
}

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1000000007
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'

struct custom_hash {    // anti-hack for unordered_map. To declare: unordered_map<long long, int, custom_hash> safe_map;
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//

vector<int>parent,rnk;


void make_set(int v)
{
	parent[v] = v;
	rnk[v] = 0;
}

int find_set(int v)
{
	if(parent[v] == v)
		return v;
	return parent[v] = find_set(parent[v]);
}

void union_set(int a, int b)
{
	a = find_set(a);
	b = find_set(b);
	if(a != b)
	{
		if(b>a)
			swap(a,b);
		parent[b] = a;
		if(rnk[a]==rnk[b])
			rnk[a]++;
	}
}

void solve()
{
	int n, m;
	cin >> n >> m;
	parent = rnk = vector<int>(n+1);
	for(int i=1;i<=n;i++)
		make_set(i);
	for(int i=0; i<m; i++)
	{
		int a, b;
		cin >> a >> b;
		union_set(a,b);
	}
	unordered_map<int,int>um;
	for(int i=1;i<=n; i++)
	{
		um[find_set(i)]++;
	}
	int res = 1;
	for(auto &i: um)
		res = max(res, i.second);
	cout << res;
   
}


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

	return 0;
}

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

typedef long long ll;

ll solve(ll h, ll w) {
  ll mini = 1e5;
  int tmp_w = w / 2, tmp_h;
  for (ll i = 1; i < h; i++) {
    tmp_h = (h - i) / 2;
    ll h_min = min(i * w, min((h - i) * tmp_w, (h - i) * (w - tmp_w)));
    ll h_max = max(i * w, max((h - i) * tmp_w, (h - i) * (w - tmp_w)));
    ll w_min = min(i * w, min(w * tmp_h, w * ((h - i) - tmp_h)));
    ll w_max = max(i * w, max(w * tmp_h, w * ((h - i) - tmp_h)));
    mini = min(mini, min(h_max - h_min, w_max - w_min));
  }

  return mini;
}

int main() {
  ll H, W;
  cin >> H >> W;

  cout << min(solve(H, W), solve(W, H)) << endl;
  return 0;
}


Measured memory_bytes: 256
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))

def primes(n):
    is_prime = [-1] * (n + 1)
    is_prime[1]=1
    for i in range(2, int(n**0.5) + 1):
        if is_prime[i]!=-1:
            continue
        for j in range(i * 2, n + 1, i):
            if is_prime[j]==-1:
                is_prime[j] = i
    for i in range(n):
        if is_prime[i+1]==-1:
            is_prime[i+1]=i+1
    return is_prime


def factorize(N,prime_list):  # prime_listに素数のリストをぶち込め！
    lst = []
    # if N==1:
    #     lst.append(1)
    while prime_list[N]!=1:
        lst.append(prime_list[N])
        N//=prime_list[N]
    return lst

tmp=a[0]
for i in range(n):
    tmp=math.gcd(tmp,a[i])
if tmp!=1:
    print("not coprime")
    exit()
dic={}
plst=primes(10**6)
for i in range(n):
    lst=factorize(a[i],plst)
    for j in lst:
        if j in dic:
            print("setwise coprime")
            exit()
    for j in lst:
        dic[j]=1
print("pairwise coprime")

Measured memory_bytes: 201008
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, K = LI()
    S = SI()
    ans = S[:K-1] + S[K-1].lower() + S[K:]
    return ans

print(main())

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var w, h, x, y, r int
	fmt.Scan(&w, &h, &x, &y, &r)

	if x < 0 ||
		y < 0 ||
		w == x ||
		h == y ||
		h < y+r ||
		w < x+r {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}

}



Measured memory_bytes: 1180
#include<stdio.h>

int main(int argc, char const *argv[]) {
    int x,y,r,W,H;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if((x-r>=0)&&(x+r<=W)&&(y-r>=0)&&(y+r<=H))printf("Yes\n");
else printf("No\n");
return 0;
}

Measured memory_bytes: 584
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    string num;
    int tr=0;
    cin>>num;
    for(int i=0;i<3;i++)
        if(num[i]=='7'){
            tr=1;
        }
    
    if(tr==1)
        cout<<"Yes";
    else
        cout<<"No";

}

Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10**7) #追加

n,q = map(int,input().split())

counter = [0 for _ in range(n)]
E = [[] for _ in range(n)]

#辺の定義
#辺E(u,v)の重みがw
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  E[b].append(a)
  E[a].append(b)

for i in range(q):
	p,x = map(int,input().split())
	counter[p-1] += x

res = 0
#行ったかどうか
color = [-1 for _ in range(n)]

#dfsで色を塗っていく
stack = [0]
color[0] = counter[0]
while stack:
  u = stack.pop()
  for v in E[u]:
    if color[v] == -1:
      stack.append(v)
      color[v] = color[u] + counter[v]

ans = [str(color[i]) for i in range(n)]
print(" ".join(ans))


Measured memory_bytes: 75932
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  int dp[n];
  dp[0]=0;
  if(k>n)
  {
    k=n-1;
  }
  for(int i=1;i<k;i++)
  {
  dp[i]=abs(arr[0]-arr[i]);
  }
  
  for(int i=k;i<n;i++)
  { dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
    for(int j=1;j<=k;j++)
    {
    dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
    }
  }
  cout<<dp[n-1];
  
}

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

int main() {

  int N;
  cin >> N;

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

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

  int answer = 0;

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int d = L[i] + L[j];
      int r = lower_bound(L.begin(), L.end(), d) - L.begin();
      int l = j + 1;
      answer += max(0, r - l);
    }
  }

  cout << answer << endl;

}

Measured memory_bytes: 256
let make_string_list2 s = Str.split (Str.regexp " ") s


let n_ref = ref 0

let f s =
  let n = int_of_string s in
  let () = n_ref := !n_ref + 1 in
  let n_sub = !n_ref in
  if n = n_sub then
    0
  else
    1


let answer _ str =
  let lst = make_string_list2 str in
  let n =
    List.map f lst |> List.fold_left (+) 0
  in
    if n = 2 || n = 0 then
      "YES"
    else
      "NO"

let n = int_of_string (read_line ())
let s = read_line ()

let () = print_endline (answer n s)


Measured memory_bytes: 384
def readInt():
  return int(input())


def readInts():
  return [int(i) for i in input().split()]


N = readInt()
AS = readInts()

print(' '.join([str(i) for i in AS]))
for i, a in enumerate(AS[1:]):
    while i >= 0 and AS[i] > a:
        AS[i + 1] = AS[i]
        i -= 1
    AS[i + 1] = a
    print(' '.join([str(i) for i in AS]))



Measured memory_bytes: 5608
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll dp[200001][5];//i番目での現在の状態がjのときの操作回数の最小
ll a[200000];
ll aop[200000][3];
int main()
{
	int l;
	cin>>l;
	for(int i=0;i<l;i++)
		cin>>a[i];
	for(int i=0;i<l;i++)
	{
		aop[i][0]=a[i];
		aop[i][1]=((a[i]+1)&1LL);//奇数なら0、偶数なら1
		if(a[i]==0)
			aop[i][2]=2;
		else
			aop[i][2]=(a[i]&1LL);
	}

	//start dp
	fill(dp[0],dp[200001],1e16-1);
	dp[0][0]=0;
	dp[0][1]=0;
	dp[0][2]=0;
	dp[0][3]=0;
	dp[0][4]=0;
	for(int i=0;i<l;i++)
	{
		//次が0の場合
		dp[i+1][0]=dp[i][0]+aop[i][0];
		//次が偶数の場合
		dp[i+1][1]=min(dp[i][0]+aop[i][2],dp[i][1]+aop[i][2]);
		//次が奇数の場合
		dp[i+1][2]=min(dp[i][2],dp[i][1]);
		dp[i+1][2]=min(dp[i+1][2],dp[i][0]);
		dp[i+1][2]+=aop[i][1];
		//次が偶数（2回目）の場合
		dp[i+1][3]=min(dp[i][2],dp[i][3])+aop[i][2];//このケースは奇数の場合からしか遷移しない
		//次が0の場合
		dp[i+1][4]=min(dp[i][4],dp[i][2]);
		dp[i+1][4]=min(dp[i+1][4],dp[i][1]);
		dp[i+1][4]=min(dp[i+1][4],dp[i][3])+aop[i][0];
	}
	ll ans=1e16-1;
	for(int i=0;i<5;i++)
		ans=min(ans,dp[l][i]);
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int ans = 0;
  int N;
  cin >> N;
  for(int i=0;i<26;i++){
    for(int j=0;j<15;j++){
      int total = 4*i + 7*j;
      if(total==N) ans++;
    }
  }
  if(ans==0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

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

Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで


using namespace std;
int a,b;
int ans;
signed main(){
  cin >> a >> b;
  if(a >= 13) ans = b;
  else if(a>=6) ans = b/2;
  else ans = 0;
  cout << ans << endl;
  return 0;
}


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

int S[1000],top;

void push(int x){
	S[++top] = x;
}

int pop(){
	top--;
	return S[top + 1];
}

int main(){
	string st;
	int a, b;
	top = 0;
	while (cin >> st){
		if (st == "+"){
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (st == "-"){
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (st == "*"){
			a = pop();
			b = pop();
			push(a*b);
		}
		else{
			int tmp = atoi(st.c_str());
			push(tmp);
		}
	}
	printf("%d\n", pop());
	return 0;
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
long long int a1[200000];
long long int a2[200000];
int main(){
    long long int n,m,k;
    cin>>n>>m>>k;
    for(long long int i=0;i<n;i++){
        cin>>a1[i];
    }
    for(long long int i=0;i<m;i++){
        cin>>a2[i];
    }
    long long int p1[n+1];
    long long int p2[m+1];
    p1[0]=0;
    p2[0]=0;
    for(long long int i=1;i<=n;i++){
        p1[i]=p1[i-1]+a1[i-1];
    }
    for(long long int i=1;i<=m;i++){
        p2[i]=p2[i-1]+a2[i-1];
    }
    long long int res=0;
    for(int i=0;i<=n;i++){
        long long int temp=k-p1[i];
        if(temp<0){
            break;
        }
        long long int in=lower_bound(p2,p2+m+1,temp)-p2;
        if(in==m+1 || p2[in]>temp){
            in--;
        }
        res=max(res,i+in);
    }
    cout<<res;

    return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int k, s;
    cin >> k >> s;
    int t = 0;
    REP(i, k + 1) {
        REP (j, k + 1) {
            if (i + j <= s && s - (i + j) <= k) {
                t++;
            }
        }
    }
    cout << t << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll mod=1000000007;
ll MOD=INF;


int main() {
  int h,w;
  cin >> h >> w;
  vector<vector<int>> a(w+8,vector<int>(h+8,-1));
  int sy,sx,gy,gx;
  cin >> sy >> sx >> gy >> gx;
  sy+=2;sx+=2;gy+=2;gx+=2;
  rep(i,h){
      rep(j,w){
          char r;
          cin >> r;
          if (r=='.') a[j+3][i+3]=inf;
      }
  }
  a[sx][sy]=0;
  queue<pair<int,int>> q;
  queue<pair<int,int>> qq;
  q.push(mk(sx,sy));
  qq.push(mk(sx,sy));
  while(!qq.empty()){
      while(!q.empty()){
          int ff=q.front().first,gg=q.front().second;
          q.pop();
          if (a[ff+1][gg]>a[ff][gg]){
              a[ff+1][gg]=a[ff][gg];
              q.push(mk(ff+1,gg));
              qq.push(mk(ff+1,gg));
          }
          if (a[ff-1][gg]>a[ff][gg]){
              a[ff-1][gg]=a[ff][gg];
              q.push(mk(ff-1,gg));
              qq.push(mk(ff-1,gg));
          }
          if (a[ff][gg+1]>a[ff][gg]){
              a[ff][gg+1]=a[ff][gg];
              q.push(mk(ff,gg+1));
              qq.push(mk(ff,gg+1));
          }
          if (a[ff][gg-1]>a[ff][gg]){
              a[ff][gg-1]=a[ff][gg];
              q.push(mk(ff,gg-1));
              qq.push(mk(ff,gg-1));
          }
      }
      int f=qq.front().first,g=qq.front().second;
      qq.pop();
      rep(i,5){
          rep(j,5){
              if (a[f+i-2][g+j-2]>a[f][g]+1){
                  a[f+i-2][g+j-2]=a[f][g]+1;
                  q.push(mk(f+i-2,g+j-2));
                  qq.push(mk(f+i-2,g+j-2));
              }
          }
      }
  }
  if (a[gx][gy]==inf) cout << -1 << endl;
  else cout << a[gx][gy] << endl;
}


Measured memory_bytes: 7656
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

typedef long long LL;
static const LL MOD = 1000000007;

int n;
map<string, LL> memo[102];

bool check(const string &s) {
	for (int i = 0; i < 4; ++i) {
		string t = s;
		if (i) {
			t[i - 1] = s[i];
			t[i] = s[i - 1];
		}
		if (t.find("AGC") != string::npos) {
			return false;
		}
	}
	return true;
}

LL dfs(int pos, const string &last) {
	map<string, LL> &m = memo[pos];
	if (pos == n) {
		return 1;
	}
	if (m.find(last) == m.end()) {
		LL cnt = 0;
		const string T = "AGCT";
		for (char c : T) {
			if (check(last + c)) {
				cnt = (cnt + dfs(pos + 1, last.substr(1) + c)) % MOD;
			}
		}
		m[last] = cnt;
	}
	return m[last];
}

int main(int argc, char *argv[]) {
	cin >> n;
	LL ans = dfs(0, "ZZZ");
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
  int a, b;
  cin >> a >> b;
  if(a <= b)
    a++;
  a--;
  cout << a << endl;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
n=int(input())
s=list(input())
counter=0
for i in range(1000):
	while len(str(i))<3:
		i="0"+str(i)
	i=str(i)
	if i[0] in s:
		a=s.index(i[0])
		if i[1] in s[a+1:]:
			b=s[a+1:].index(i[1])+a+1
			if i[2] in s[b+1:]:
				counter+=1
print(counter)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <cassert>
#include <atcoder/dsu>
typedef long long int ll;
using namespace std;
using namespace atcoder;

// @@ !! LIM()
// --> 
// @@ !! LIM  -- end mark --

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, Q; cin >> N >> Q;
  dsu d(N);
  for (ll _q = 0; _q < Q; _q++) {
    ll t, u, v; cin >> t >> u >> v;
    if (t == 0) d.merge(u, v);
    else {
      cout << (d.same(u, v) ? 1 : 0) << "\n";
    }
  }


  return 0;
}



Measured memory_bytes: 3948
/*
*  Author: windystreet
*  Date  : 2019-03-03 11:46:33
*  Motto : Think twice, code once.
*/
#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

void solve(){
    int s[10];
    for(int i=1;i<=6;i++){
    	scanf("%d",s+i);
    }
    int flag = 0;
    for(int i=1;i<=5;i++){
    	for(int j=i+1;j<=5;j++){
    		if(s[j] - s[i]>s[6]){
    			flag = 1;break;
    		}
    	}
    }
    if(flag){
    	printf(":(\n");
    }else{
    	printf("Yay!\n");
    }
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("F:/in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
    return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    --a; --b;
    if ((b-a)%2==0) cout << ((b-a)/2) << endl;
    else {
        ll ans = (b-a) / 2;
        ans += min(a, (n-1-b)) + 1;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
minans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
A=list(map(int,input().split()))
k=1
for i ,ai in enumerate(A):
    if ai!=k:
        count+=1
    else:
        k+=1
if count==n:
    print(-1)
else:
    print(count)

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

int main() {
	// your code goes here
	
    long long a,b,v,w;
    cin>>a>>v>>b>>w;
    
    long long x;
    cin>>x;
    
    long long k1=x*v,k2=x*w+abs(a-b);
    
    if(k1>=k2)
    cout<<"YES";
    else
    cout<<"NO";
    
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <cassert>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef pair<int,int> P;
typedef pair<int,P>Q;
#define fi first
typedef long long ll;
#define sc second

string s;
int n;
int rec(int L,int R,int a,int b,int c){
	int xx[3]={a,b,c};
	if('0'<=s[L] && s[L] <= '2') return s[L]-'0';
	if('P'<=s[L] && s[L] <= 'R') return xx[s[L]-'P'];
	if(s[L] == '-') return 2 - rec(L+1,R,a,b,c);
	int dep = 0;
	for(int i=L+1;i<R;i++){
		if(s[i] == '(') dep++;
		else if(s[i] == ')') dep--;
		else if(dep == 0 && s[i] == '*'){
			int ll = rec(L+1,i-1,a,b,c);
			int rr = rec(i+1,R-1,a,b,c);
			if(ll == 0  || rr == 0) return 0;
			else if(ll==2&&rr==2) return 2;
			else return 1;
		}
		else if(dep == 0 && s[i] == '+'){
			int ll = rec(L+1,i-1,a,b,c);
			int rr = rec(i+1,R-1,a,b,c);
			if(ll==0&&rr==0) return 0;
			else if(ll<=1&&rr<=1) return 1;
			else return 2;
		}
	}
	assert(0);
}
int main(){
	while(1){
		cin>>s;n=s.size();if(s==".")return 0;
		int ans =0;
		rep(i,3)rep(j,3)rep(k,3) ans += rec(0,n-1,i,j,k) == 2;
		cout << ans << endl;
	}
}



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


void push(int);
int pop(void);
int top=0,S[201];

void push(int x){
    top++;
    S[top]=x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a,b,i;
    char s[201];
    while(scanf("%s",s)!=EOF){
        if(s[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(s[0] == '-'){
            b=pop();
            a=pop();
            push(a-b);
        }
        else if(s[0] == '*'){
            a=pop();
            b=pop();
            push(a*b);
        }else{
            push(atoi(s));
        }
    }
    i=pop();
    printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	vector<int> card(N);

	for(int i = 0 ; i < N ; i++) scanf("%d", &card[i]);
	
	sort(card.begin(), card.end(), greater<int>());
	
	int A, B;
	A = B = 0;
	
	for(int i = 0 ; i < N ; i++){
		if(i % 2 == 0) A += card[i];
		else B += card[i];
	}
	
	printf("%d\n", A-B);

	return 0;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-
 
import sys
 
def main():
    k = int(input())
    sevens=0
    if k%2==0:
      print(-1)
      exit()
    for i in range(1,k+1):
        sevens=(sevens*10+7)%k
        if sevens==0:
            print(i)
            exit()
    print(-1)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 9212
import qualified Data.ByteString.Char8 as C
import Data.List

main = C.interact $ put . sol . get

get = unfoldr (C.readInt . C.dropWhile (==' ')) . last . C.lines

put = C.pack . show

sol = min <$> g (-1) <*> g 1

g d = (\(c,_,_) -> c) . foldl' f (0,0,d)

f (c,s,d) a 
  | d*s'>0    = (c,s',-d)
  | otherwise = (c+1+abs s',d,-d)
  where
  s' = s+a

Measured memory_bytes: 17788
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

N,d=gets.chomp.split(' ').map{|n| n.to_i}
A = Array.new(N)
0.upto(N-1){|d|
	A[d],dum=gets.chomp.split(' ').map{|n| n.to_i}
}
if(A[0] != 0)
	puts -1
	exit 0
end
a_pv = A[0]
1.upto(N-1){|d|
	if(A[d] - a_pv > 1)
		puts -1
		exit 0
	end
	a_pv = A[d]
}

cnt = 0
a_pv = A[0]
1.upto(N-1){|d|
	a_cr = A[d]
	if(a_cr - a_pv == 1)
		cnt += 1
	else
		cnt += a_cr
	end
	a_pv = a_cr
}

puts cnt



Measured memory_bytes: 3964
/*
 * B.c
 *
 *  Created on: 2018/04/16
 *      Author: Haruyuk1
 */
# include <stdio.h>

int main(void){
	int a, b, k, i;

	scanf("%d %d %d", &a, &b, &k);

	if (b - a + 1 <= 2 * k){
		for (i = a; i <= b; i++){
			printf("%d\n", i);
		}
	} else {
		for (i = a; i <= a + k - 1; i++){
			printf("%d\n", i);
		}
		for (i = b - k + 1; i <= b; i++){
			printf("%d\n", i);
		}
	}
}


Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    X, Y = map(int, input().split())
    for i in range(X+1):
        for j in range(X+1):
            if i + j == X and 2*i + 4*j == Y:
                print('Yes')
                exit()
    print('No')


if __name__ == "__main__":
    main()


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using tlll = tuple<ll,ll,ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

const ll INF = 1e11;
vector<ll> manbgn[200010], manend[200010];

int main()
{
    ll n,q;
    cin>>n>>q;
    vector<tlll> koji(n*2);
    for (int i = 0; i < n; i++)
    {
        ll ss,tt,xx;
        cin>>ss>>tt>>xx;
        koji[i*2]=make_tuple(ss-xx,1,xx);
        koji[i*2+1]=make_tuple(tt-xx,-1,xx);
    }
    vector<ll> ans(q);
    vector<ll> man(q);
    for (int i = 0; i < q; i++)
    {
        cin>>man[i];
        ans[i]=-1;
    }
    sort(all(koji));
    set<ll> se;
    ll nowt = -INF;
    ll kojicnt=0;

    for (ll mani = 0; mani < q; mani++)
    {
        nowt=man[mani];
        while (kojicnt<n*2)
        {
            ll t,b,x;
            t=get<0>(koji[kojicnt]);
            b=get<1>(koji[kojicnt]);
            x=get<2>(koji[kojicnt]);
            if(nowt < t) break;

            kojicnt++;

            if(b==1) se.insert(x);
            else se.erase(x);

        }
        if(se.size()>0)
        {
            ans[mani]=*se.begin();
        }
    }
    
    for (int i = 0; i < q; i++)
    {
        cout<<ans[i]<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 32512