akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    int mx=0,cnt=0;
    cin>>s>>t;
    for(int i=0;i<=s.size()-t.size();i++)
    {
        cnt=0;
        int k=i;
        for(int j=0;j<t.size();j++)
        {
            if(s[k]==t[j])
            {
                cnt++;
            }
            k++;
        }
        mx=max(mx,cnt);
    }
    cout<<t.size()-mx<<endl;
}


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

int main(){
    int x,y;
    int turu=2,kame=4,sum1=0,sum2=0;
    string ans = "No";
    cin >> x >> y;
    for(int i = 0 ;i <= x;i++){
        int j = x - i;
        sum1 = turu * i + kame * j;
        sum2 = turu * j + kame * i;
        //cout << sum1 << "," << sum2 << endl;
        if(sum1 == y || sum2 == y){
            ans = "Yes";
        }
        sum1 = sum2 = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
from collections import deque

N, K = map(int, input().split())
T = [[] for i in range(N)]
E = []
for i in range(N-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    T[a].append(b)
    T[b].append(a)
    E.append([a, b])


def bfs(n):
    visited = [False] * N
    dist = [0] * N
    queue = deque([n])
    while queue:
        node = queue.pop()
        if visited[node]:
            continue
        visited[node] = True
        for n in T[node]:
            if not visited[n]:
                dist[n] = dist[node] + 1
                queue.appendleft(n)
    return dist


dist = []
for i in range(N):
    dist.append(bfs(i))

ans = float('inf')
if K % 2 == 0:
    for i in range(N):
        ans = min(ans, len([d for d in dist[i] if d > K / 2]))
else:
    for a, b in E:
        ans = min(ans, len([d for d in [min(d1, d2) for d1, d2 in zip(dist[a], dist[b])] if d > (K-1) / 2]))

print(ans)


Measured memory_bytes: 86488
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		int dist = in.nextInt();
		int time = in.nextInt();
		int speed = in.nextInt();
      	int need = dist / speed;
      	if (dist%speed != 0) need += 1;
      
      	if (time >= need) {
          	System.out.println("Yes");
        } else {
          	System.out.println("No");
        }
    }
}


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

int main(void){

  int s[100],i;
  char a[100];
  i=0;
  while(scanf("%s",a) != EOF){
    if(a[0] == '+'){
      s[i - 2] = s[i - 2] + s[i - 1];
      i--;
    }
    
    else if(a[0] == '-'){
      s[i - 2] = s[i - 2] - s[i - 1];
      i--;
    }

    else if(a[0] == '*'){
      s[i - 2] = s[i - 2] * s[i - 1];
      i--;
    }
    
    else{
      s[i] = atoi(a);
      i++;
    }
  }
  printf("%d",s[0]);
  printf("\n");
  return 0;
}

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

int main(void)
{
	char s[90];
	int i;
	
	while (fgets(s, 90, stdin) != NULL){
		
		while (1){
			if (strstr(s, "the") != NULL || strstr(s, "this") != NULL || strstr(s, "that") != NULL){
				break;
			}
			for (i = 0; s[i] != '\0'; i++){
				if ('a' <= s[i] && s[i] <= 'y'){
					s[i]++;
				}
				else if ('z' == s[i]){
					s[i] = 'a';
				}
			}
		}
		printf("%s", s);
	}
	
	return (0);
}

Measured memory_bytes: 524
#include<stdio.h>
int main(){
  int w,h,x,y,r=0;
  scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
 
  if(w<x || h<y || x+r>h || y+r>h || x-r<0 || y-r<0){
    printf("No\n");}
  else{printf("Yes\n");}
  return 0;
}    

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

#define MAX 100

int isEmpty();
int isFull();
void push(int);
int pop();

int top = 0;
int S[MAX];

int main() {
  int a,b;
  char c[10];

  while (scanf("%s", c) != EOF) {
    if (c[0] == '+') {
      a = pop();
      b = pop();
      push(b+a);
    } else if (c[0] == '-') {
      a = pop();
      b = pop();
      push(b-a);
    } else if (c[0] == '*') {
      a = pop();
      b = pop();
      push(b*a);
    } else {
      a = atoi(c);
      push(a);
    }
  }

  a = pop();
  printf("%d\n", a);

  return 0;
}

int isEmpty() {
  return top == 0;
}

int isFull() {
  return top > MAX-1;
}

void push(int x) {
  if (isFull()) printf("overflow\n");
  top++;
  S[top] = x;
}

int pop() {
  if (isEmpty()) printf("underflow\n");
  top--;
  return S[top+1];
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#define MOD  1000000007

using namespace std;
typedef long long int lli;
typedef long double ld;

ld dp[301][301][301];
int n;

lli power(lli a, lli b){
    if(b==0){
        return 1;
    }
    if(b&1){
        return a*power(a*a,b/2);
    }
    return power(a*a,b/2);
}

ld recu(int x, int y, int z){
    //cout<<x<<" "<<y<<" "<<z<<endl;
    if(x<0 || y<0 || z<0){
        return 0;
    }
    if(x+y+z == 0){
        return 0;
    }
    if(dp[x][y][z] > 0){
        return dp[x][y][z];
    }
    ld p0=(x+y+z),p1=x, p2=y, p3=z;
    //cout<<p0<<" "<<p1<<" "<<p2<<" "<<p3<<endl;
    dp[x][y][z]=(n + p1*recu(x-1,y,z) + p2*recu(x+1,y-1,z) + p3*recu(x,y+1,z-1))/(p0);
    //cout<<dp[x][y][z]<<endl;
    return dp[x][y][z];
}

void solve(){
    cin>>n;
    int p[n];
    int ar[4];
    memset(dp, (ld)-1, sizeof(dp));
    memset(ar, 0, sizeof(ar));
    for(int i=0; i<n; i++){
        cin>>p[i];
        ar[p[i]]++;
    }
    //cout<<ar[1]<<" "<<ar[2]<<" "<<ar[3]<<endl;
    ld ans=recu(ar[1], ar[2], ar[3]);
    cout<<setprecision(30)<<ans<<endl;
}

signed main(){
    /*#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}


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

#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = INF + 7;
 
/////////////////////////////////////////////////////////////////////
 
const int N = 5e3 + 5;

int DP[N][N];

int Power(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1LL * a * a % MOD) if (b & 1) res = 1LL * res * a % MOD;
	return res;
}

int main() {
 
	sync;

	DP[0][0] = 1;
	for (int i = 1; i < N; i++) for (int j = 0; j <= i; j++) {
		if (j) DP[i][j] = 2LL * DP[i - 1][j - 1] % MOD;
		else DP[i][j] = DP[i - 1][j];
		if (j + 1 < N) DP[i][j] = (DP[i][j] + DP[i - 1][j + 1]) % MOD;
	}
	
	int n; cin >> n;
	string s; cin >> s;
	cout << 1LL * DP[n][sz(s)] * Power(Power(2, sz(s)), MOD - 2) % MOD << endl;

	return 0;
}


Measured memory_bytes: 96512
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> inline T pow2_L(T a){
  return a*a;
}
inline long long Isqrt_f_L(const long long n){
  long long r = sqrt(n);
  r =max_L(r-2, 0);
  while(pow2_L((r+1))<= n ){
    r++;
  }
  return r;
}
long long X;
long long Y;
int main(){
  int Lj4PdHRW;
  long long k;
  long long z;
  int KL2GvlyY = rd_int();
  for(Lj4PdHRW=(0);Lj4PdHRW<(KL2GvlyY);Lj4PdHRW++){
    rd(X);
    rd(Y);
    if(X==Y){
      wt_L(2*X-2);
      wt_L('\n');
      continue;
    }
    z = X * Y - 1;
    k =Isqrt_f_L(z);
    if(k*(k+1) <= z){
      wt_L(2*k-1);
      wt_L('\n');
    }
    else{
      wt_L(2*k-2);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20191110-1

// --- original code ---
// ll X, Y;
// {
//   ll k, z;
//   REP(rd_int()){
//     rd(X,Y);
//     if(X==Y) wt(2X-2), continue;
//     z = X * Y - 1;
//     k = Isqrt(z);
//     wt(if[k*(k+1) <= z, 2k-1, 2k-2]);
//   }
// }

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

int id = INT_MAX;
int merge (int l, int r) {
	return min(l, r);
}

struct node {
	int val;
	int all;
	node *ch[2];
	unsigned int pri;
	int size;
	int sum;
	node(int v, unsigned int p) : val(v), all(v), pri(p), size(1), sum(v) {
		ch[0] = ch[1] = nullptr;
	}
};

random_device rd;

int count(node *t) { return t == nullptr ? 0 : t->size; }
int sum(node *t) { return t == nullptr ? 0 : t->sum; }
int que(node *t) { return t == nullptr ? id : t->all; }
node *update(node *t) {
	t->size = count(t->ch[0]) + count(t->ch[1]) + 1;
	t->sum = sum(t->ch[0]) + sum(t->ch[1]) + t->val;
	t->all = merge(que(t->ch[0]), merge(t->val, que(t->ch[1])));
	return t;
}
node *rotate(node *t, int b) {
	node *s = t->ch[1 - b];
	t->ch[1 - b] = s->ch[b];
	s->ch[b] = t;
	update(t); update(s);
	return s;
}
node *insert(node *t, int k, int v, unsigned int pri) {
	if (t == nullptr) return new node(v, pri);
	int c = count(t->ch[0]), b = (k > c);
	t->ch[b] = insert(t->ch[b], k - (b ? (c + 1) : 0), v, pri);
	update(t);
	if (t->pri > t->ch[b]->pri) t = rotate(t, 1 - b);
	return t;
}
node *erase(node *t) {
	if (t == nullptr) return nullptr;
	if (t->ch[0] == nullptr && t->ch[1] == nullptr) {
		delete t;
		return nullptr;
	}
	int b = (t->ch[0] != nullptr && t->ch[1] != nullptr) ? (t->ch[0]->pri > t->ch[1]->pri) : (t->ch[0] != nullptr);
	t = rotate(t, b);
	t->ch[b] = erase(t->ch[b]);
	update(t);
	return t;
}
node *erase(node *t, int k) {
	if (t == nullptr) return nullptr;
	int c = count(t->ch[0]);
	if (k < c) {
		t->ch[0] = erase(t->ch[0], k);
	}
	else if (k > c) {
		t->ch[1] = erase(t->ch[1], k - (c + 1));
	}
	else {
		t = erase(t);
	}
	return t;
}
node *merge(node *l, node *r) {
	node *p = new node(0, 0);
	p->ch[0] = l, p->ch[1] = r;
	p = erase(p);
	return p;
}
pair<node*, node*> split(node *t, int k) {
	if (t == nullptr) return make_pair(nullptr, nullptr);
	node *p = insert(t, k, 0, UINT32_MAX);
	auto res = make_pair(p->ch[0], p->ch[1]);
	delete p;
	return res;
}
int find(node *t, int l, int r) {
	if (t == nullptr) return id;
	if (r < 0 || l >= count(t)) return id;
	if (l <= 0 && r >= t->size) return t->all;
	int c = count(t->ch[0]);
	return merge(t->ch[0] == nullptr ? id : find(t->ch[0], l, r), merge(l <= c && c < r ? t->val : id, t->ch[1] == nullptr ? id : find(t->ch[1], l - (c + 1), r - (c + 1))));
}
void print(node *t) {
	if (t == nullptr) return;
	print(t->ch[0]);
	printf(" %d", t->val);
	print(t->ch[1]);
}

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	int n, q, com, x, y;
	cin >> n >> q;
	node* root = nullptr;
	for (int i = 0; i < n; i++) {
		root = insert(root, i, INT_MAX, rd());
	}
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", find(root, x, y + 1));
		}
		else {
			root = erase(root, x);
			root = insert(root, x, y, rd());
		}
	}
	return 0;
}

Measured memory_bytes: 7876
// atcoder/abc158/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

int di[] = {0, 1, -1, 0, 1, -1, 1, -1};
int dj[] = {1, 0, 0, -1, 1, -1, -1, 1};
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  str s;
  int q;
  while (cin >> s >> q) {
    deque<char> d;
    each (c, s) d.push_back(c);

    bool rev = false;
    while (q--) {
      int t;
      cin >> t;
      if (t == 1) {
        rev = rev ^ 1;
      }
      if (t == 2) {
        int f;
        char c;
        cin >> f >> c;
        if (rev) f = (f == 1 ? 2 : 1);
        if (f == 1) d.push_front(c);
        if (f == 2) d.push_back(c);
        // cout << rev << ": "; for (int i = 0; i < d.size(); ++i) cout << d[i]; cout << endl;
      }
    }

    str t;
    while (!d.empty()) {
      if (rev) {
        t += d.back();
        d.pop_back();
      } else {
        t += d.front();
        d.pop_front();
      }
    }
    cout << t << endl;
  }

  return 0;
}


Measured memory_bytes: 1368
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc= new Scanner(System.in);
		
		long n=sc.nextLong();
		long k=sc.nextLong();
		
		System.out.println(Math.min(n%k, Math.abs((n%k)-k)));
		

}
}

Measured memory_bytes: 22864
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std; 

int f(int x) {
  if(x%100 != 0) return 0;
  return f(x/100) + 1;
}

int main() {
  int d, n;
  cin >> d >> n;
  vector<int> a;
  int i = 1;
  while(true) {
    if(f(i) == d) a.push_back(i);
    if(a.size() == n) {
      cout << a[n-1] << endl;
      break;
    }
    i++;
  }
  return 0;
}

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

using namespace std;



int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  vector<int> in(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    ++in[b];
  }
  vector<int> order;
  order.reserve(n);
  queue<int> q;
  for (int i = 0; i < n; ++i)
    if (in[i] == 0)
      q.push(i);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    order.push_back(u);
    for (auto v : g[u]) {
      if (--in[v] == 0) {
        q.push(v);
      }
    }
  }
  vector<int> dp(n, 0);
  int ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    int u = order[i];
    for (auto v : g[u]) {
      dp[u] = max(dp[u], 1 + dp[v]);
    }
    ans = max(ans, dp[u]);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 6912
/* ex3_2
  bonbonc */

#include<stdio.h>
#include<stdbool.h>

int main(){
	int number;
	bool flag; /*終わったかどうか*/
	flag = false;
	scanf("%d",&number);
	for(int i = 1;i<=9;i++){/*全探索*/
		for(int j = 1;j<=9;j++){
			if(i*j==number){
				flag = true;
			}
		}
	}

	if(flag){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int resolve(const int n, const vpii &sc) {
    REP(i, 1000) {
        str s = to_string(i);
        if(s.length() != n) continue;
        if(sc.size() == 0) return i;
        REP(j, sc.size()) {
            if(s[sc[j].first - 1] != sc[j].second + '0') break;
            if(j == sc.size() - 1) return i;
        }
    }
    return -1;
}

int main() {
    int n, m;
    cin >> n >> m;
    vpii sc(m);
    REP(i, m) {
        cin >> sc[i].first >> sc[i].second;
    }
    cout << resolve(n, sc) << "\n";

    return 0;
}


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

//#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    int res = 0;
    for (int i = 0; i < k; i++) {
        res += v[i];
    }
    cout << res << '\n';
}
/*

 */


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ms(x, t) memset(x, t, sizeof(x))
typedef long long int ll;
typedef unsigned long long int ull;
const int limit = 1e2 + 1;
const int inf = 1e7;
int main()
{
    ll n, W;
    cin >> n >> W;
    ll w[n + 1], v[n + 1];
    
    for (int i = 1; i <= n; i++)
    {
        cin >> w[i] >> v[i];
    }
    ll m[n + 1][W + 1];
    ms(m, 0);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            if (w[i] <= j)
            {
                m[i][j] = max(m[i - 1][j], v[i] + m[i-1][j - w[i]]);
            }
            else
            {
                m[i][j] = m[i - 1][j];
            }
        }
    }
    cout<<m[n][W]<<endl;
    return 0;
}

Measured memory_bytes: 79104
from itertools import combinations_with_replacement

x, y = map(int, input().split())

choise_list = []

for A in combinations_with_replacement(range(1, 3), x):
    choise_list.append(A)
    
flag = False
    

for choise in choise_list:
    ans = choise.count(1) * 2 + choise.count(2) * 4
    if ans == y:
        print("Yes")
        flag = True
        break

if not flag:
    print("No")

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

int main(){
  long long n;
  cin >> n;
  long long ans = (n / 11) * 2;
  n -= n / 11 * 11;
  if(n != 0 && n <= 6) ans++;
  else if(n != 0 &&n <= 11) ans += 2;
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int main() {
	//cout << ( (206 * 206 * 206 * 206));
	ll n, p;
	cin >> n >> p;
	if (n == 1) {
		cout << p;
		return 0;
	}
	for (int i = 1e6; i >= 2; --i) {
		ll tmp = 1;
		for (int j = 1; j <= n; ++j) {
			if (p / tmp < i) {
				tmp = p + 1;
				break;
			}
			tmp *= i;
		}
		if (tmp > p) continue;
		//if (i == 206) cout << (ll)tmp << endl;
		if (p % tmp != 0) continue;
		cout << i << endl;
		return 0;
	}
	cout << 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
 
using namespace std;
 
int main() {
        int i,j;
    int sum; //because 9*1000<int size 
    char buf;
    
    //????????????????????????????????????????????????????????則?????????
    while(1){
        sum=0;
        cin.get(buf);
        //???????????其
        if ( buf == '0' ) break;        
        while(1){    
            //??????????????其
            if ( buf == '\n' ) break;
            //???????????属???????????則???atoi?????????????????????????????????????属?????????????
            sum+= atoi(&buf);
            cin.get(buf);
        }
        cout << sum <<endl;
    }
    
        return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int m, f, r;
    while (cin>>m>>f>>r, m != -1 || f != -1 || r != -1) {
        if (m == -1 || f == -1) {
            cout<<'F'<<endl;
        } else if (m + f >= 80){
            cout<<'A'<<endl;
        } else if (m + f >= 65){
            cout<<'B'<<endl;
        } else if (m + f >= 50 || r >= 50){
            cout<<'C'<<endl;
        } else if (m + f >= 30){
            cout<<'D'<<endl;
        } else
            cout<<'F'<<endl;
    }


    return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n;
	cin>>n;
	bool ans=0;
	while(n){
		int rem=n%10;
		n=n/10;
		if(rem==7)ans=1;
	}
	cout<< (ans ? "Yes":"No");
	
	
}
 
 
 
int main(){
	solve();
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)   for(signed i=0; i<n; i++)
#define FOR(i, k, n)    for(signed i=k; i<n; i++)
#define yn(b)   cout << ((b)?"Yes":"No") << endl
#define YN(b)   cout << ((b)?"YES":"No") << endl
#define pr(r)   cout << r << endl
#define min(x,y)    (x<y)?x:y
#define max(x,y)    (x>y)?x:y
#define ll  long long
int main(void){
    int n, a, b;
    cin >> n >> a >> b;
    if(n*a > b) pr(b);
    else pr(n*a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <tgmath.h>
using namespace std;
typedef long double ll;
ll a, b,x, emp;
double h, ans;

int main() {
cin >> a >> b >> x;
if (x == 0){
	cout << 90; return 0;
	}
	if (x == a*a*b){
		cout << 0; return 0;
		}
emp = a*a*b - x;
ll half = (a*a*b)/2;
if (emp > half){
h = (2*x)/(a*b);
ans = atan2(b, h);
ans = ans *180.0000000000/3.14159265358979323846264338327950288419716939937510;
cout << setprecision(8) << ans;
	}else{
h = (2*emp)/(a*a);
ans = atan2(h, a);
ans = ans * 180.000000000/3.14159265358979323846264338327950288419716939937510;
cout << setprecision(8) << ans;
//cout << '\n' << h;
}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	cout << min(A,B)+min(C,D)<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	long long n, a, b; scanf("%lld%lld%lld", &n, &a, &b);
	if ((b - a) % 2 == 0) printf("%lld\n", (b - a) / 2);
	else printf("%lld\n", (b - a) / 2 + min(a, n - b + 1));
	return 0;
}


Measured memory_bytes: 764
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		String[] s= sc.nextLine().split(" ");
		long n=Long.parseLong(s[0]);
		long m=Long.parseLong(s[1]);
		if(n>1 && m>1){
			System.out.println((n-2)*(m-2));
		}else if(n==1 && m==1){
			System.out.println(1);
		}else{
			System.out.println(n*m-2);
		}
	}
}

Measured memory_bytes: 21844
N, K = map(int, input().split())
res = 0
for b in range(1, N+1):
  if K:
    res += (N//b) * max(0, b-K) + max(0, (N%b)-K+1) 
  else:
    res += (N//b) * max(0, b-K) + max(0, (N%b)-K+1) - 1

print(res)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}


bool vis[1000000 + 10];

int f(int n) {
  if (n % 2 == 0) return n / 2;
  else return 3 * n + 1;
}
int main2() {
  CLR(vis, 0);
  int x = nextInt();
  for (int i = 1;; i++) {
    if (vis[x]) {
      cout << i << endl;
      break;
    }
    vis[x] = true;
    x = f(x);
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;
    return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{-1};
    lol a, b; cin >> a >> b;
    FOR(i, 1, 1300)
    {
        lol ai = round(i*8/100);
        lol bi = round(i*10/100);
        if(ai == a && bi == b)
        {
            result = i;
            break;
        }
    }
    

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3620
N = int(input())
s = [input() for i in range(N)]

A = 0
B = 0
BA = 0
cnt = 0
for i in s:
    if i.startswith("B"):
        B += 1
    if i.endswith("A"):
        A += 1
    if i.startswith("B") and i.endswith("A"):
        BA += 1
    for j in range(1,len(i)):
        if i[j-1] + i[j] == "AB":
            cnt += 1

if BA == 0:
    cnt += min(A,B)
    print(cnt)
else:
    B -= BA
    A -= BA
    if A >= 1:
        cnt += 1
    if B >= 1:
        cnt += 1
    if A >= 2 and B >= 2:
        cnt += min(A-1,B-1)
    print(cnt + BA-1)

Measured memory_bytes: 46464
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
a = list(map(int, readline().split()))
dict = [-1] * (n + 1)
now = a[0]
dict[0] = 0
for i in range(1, n * 2):
    if i == k:
        print(now)
        exit()
    now = a[now - 1]
    if dict[now] != -1:
        k -= (i + 1)
        k %= (i - dict[now])
        break
    else:
        dict[now] = i
for i in range(k):
    now = a[now - 1]
print(now)


Measured memory_bytes: 92000
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, a=0, b=0;
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin >> v.at(i);
  }
  std::sort(v.begin(),v.end(),greater<int>());
  for(int i=0;i<N;i++){
    if(i % 2 == 0){
      a += v.at(i);
    }else{
      b += v.at(i);
    }
  }
  cout << a - b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int posc;
	int fl=0; 
	for(int i=0;i<s.length();++i){
		if(s[i]=='C'){
			posc=i;
			fl=1;
			break;
		}
	}
	if(fl==0){
		cout<<"No";
		return 0;
	} 
	int flag=0; 
	for(int i=posc;i<s.length();++i){
	   if(s[i]=='F'){
	   	flag=1;
	   }
	}
	if(flag)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(A) < sum(B):
    print(-1)
    exit(0)

C = [A[k]-B[k] for k in range(N)]
C.sort()
t = 0
ans = 0
for k in range(N):
    if C[k] >= 0:
        break
    else:
        t -= C[k]
        ans += 1

for k in range(N-1,-1,-1):
    if t <= 0:
        break
    else:
        t -= C[k]
        ans += 1

print(ans)


Measured memory_bytes: 93804
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;


main(){
    string s,t;
    cin>>s>>t;
    int count=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]) count++;
    }
    cout<<count;
}

Measured memory_bytes: 3916
#![allow(non_snake_case)]

use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();

    let mut ws = buf.split_whitespace();
    let a: i32 = ws.next().unwrap().parse().unwrap();
    let b: i32 = ws.next().unwrap().parse().unwrap();
    let c: i32 = ws.next().unwrap().parse().unwrap();

    if a < b && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}



Measured memory_bytes: 5024
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int n,m,a;
pair<int,pair<int,int> > p[1000];

int main(){
	while(cin>>n>>m>>a&&n){
		rep(i,m){
			cin>>p[i].first>>p[i].second.first>>p[i].second.second;
			p[i].first*=-1;
		}
		sort(p,p+m);
		rep(i,m){
			if(a==p[i].second.first)a=p[i].second.second;
			else if(a==p[i].second.second)a=p[i].second.first;
		}
		cout<<a<<endl;
	}
}

Measured memory_bytes: 884
#include<stdio.h>
int main(void){
  
double w=0;
double h=0;
double x=0;
double y=0;
double max;
  
scanf("%lf %lf %lf %lf", &w,&h,&x,&y);
  
max=(w*h)/2;

if(w==x*2 && h==y*2){
  printf("%lf %d",max,1);
}else{
  printf("%lf %d",max,0);
}

return 0;
}

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

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

long long read(){
	long long i;
	cin >> i;
	return i;
}

char MarkToNum(char c) {
	int  n = -1;
	switch(c) {
		case 'S': n = 0; break;
		case 'H': n = 1; break;
		case 'C': n = 2; break;
		case 'D': n = 3; break;
	}
	return n;
}

int main(void){
	const int MARKS = 4;
	const int NUMS = 13;
	const char num_to_mark[4] = {'S', 'H', 'C', 'D'};
	int cards[4][13] = {};

	long long size = read();
	REP(i, size) {
		char c;
		int n;
		cin >> c >> n;
		cards[MarkToNum(c)][n - 1] = 1;
	}

	REP(i, MARKS) {
		REP(j, NUMS) {
			if (!cards[i][j]) {
				cout << num_to_mark[i] << " " << j + 1 << endl;
			}
		}
	}
	return 0;
}



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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
#define int long long

int divisor_func(int num){
    int divisors = 1;
    for(int i=2; i*i <= num; i++){
        int p = 0;
        while(num%i==0){ num /= i; p++; }
        divisors *= (p+1);
    }
    if(num != 1) divisors *= 2;
    return divisors;
}

bool is_2017like(int n){
    if(n % 2 == 0) return false;
    return divisor_func(n)==2 && divisor_func((n+1)/2)==2;
}

signed main(){
    vector<int> f(1e5+1, 0);
    reps(i,2,1e5){
        f[i] = f[i-1] + is_2017like(i);
    }
    int Q; cin >> Q;
    rep(query, Q){
        int l, r;
        cin >> l >> r;
        cout << f[r] - f[l-1] << endl;
    }
}

Measured memory_bytes: 1408
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

int solve(string s, char c){
    int n = s.size();
    bool ok = false;

    ok = true;
    for(int i = 0; i < n; i++){
        if(s[i] != c){
            ok = false;
        }
    }
    if(ok){
        return 0;
    }

    while(not ok){
        n--;
        for(int i = 0; i < n; i++){
            if(s[i+1] == c){
                s[i] = c;
            }
        }
        ok = true;
        for(int i = 0; i < n; i++){
            if(s[i] != c){
                ok = false;
            }
        }
    }
    return (int)s.size() - n;
}

signed main(){
    string s;
    cin >> s;

    int ans = INF;
    for(int i = 'a'; i <= 'z'; i++){
        int tmp = solve(s, i);
        if(tmp < ans){
            ans = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 380
N,M=map(int,input().split())

ab=[list(map(int,input().split())) for i in range(M)]

ans=0
stack=[]

for i in ab:
    if i[0]==1:
        stack.append([i[1],1+2**(i[1]-1)])

while len(stack)>0:
    p=stack.pop()

    if p[1]==2**N-1:
        ans+=1
    else:
        for i in ab:
            if i[0]==p[0] and not(2**(i[1]-1)&p[1]):
                stack.append([i[1],p[1]+2**(i[1]-1)])
            if i[1]==p[0] and not(2**(i[0]-1)&p[1]):
                stack.append([i[0],p[1]+2**(i[0]-1)])

print(ans)


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int K,T;
    cin>>K>>T;
    vint C(T);
    rep(i,T)cin>>C[i];

    rep(i,T){
        if(C[i]*2-1<=K)continue;
        int t=C[i]-(K+1)/2;
        cout<<t*2-(K%2==0)<<endl;
        return 0;
    }

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


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

typedef long long ll;

int main()
{
    int n, m;
    cin >> n >> m;
    int ans = 1800 * m + 100 * n;
    rep(i, m) ans *= 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
using namespace std;
template<class T>inline void rd(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=3000;
ll n,x,y;
ll ans[maxn];
int main()
{
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            ll dis1=j-i;
            ll dis2=1+abs(x-i)+abs(j-y);
            ll dis3=1+abs(y-i)+abs(x-j);
            ans[min(dis1,min(dis2,dis3))]++;
        }
    }
    rep(i,1,n-1) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# abc132/abc132_a
import sys
import collections

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = i2s()
    c = collections.Counter(S)
    if tuple(c.values()) == (2, 2):
        print('Yes')
    else:
        print('No')
    return

main()


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  ll X;
  cin >> X;
  ll tmp = 0;
  REP(i,X+1){
    tmp += i;
    if(tmp >= X){
      cout << i << endl;
      return 0;
    }
  }
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;

  map<char, char> table1, table2;
  for (int i = 0; i < (int)s.length(); i++) {
    if (table1.find(t[i]) != table1.end()) {
      if (table1[t[i]] != s[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
    if (table2.find(s[i]) != table2.end()) {
      if (table2[s[i]] != t[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
    table1[t[i]] = s[i];
    table2[s[i]] = t[i];
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 776
double p[333][333][333],r;n,c[4];double f(i,j,k){r=~i&~j&~k?p[i][j][k]?:(p[i][j][k]=(i*f(i-1,j,k)+j*f(i+1,j-1,k)+k*f(i,j+1,k-1)+n)/(i+j+k)):0;}main(){for(***p=1;~scanf("%d",n?c:&n);)c[*c]++;printf("%.9f",f(c[1],c[2],c[3])-1);}

Measured memory_bytes: 260224
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 998244353
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n;
    cin >> n;

    int ans = 0;

    for(int i = 1; i < (n + 1) / 2; i++){
        if(n - i > 0) ans++;
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
# 初期入力
import sys
input = sys.stdin.readline
n = int(input())
p = list(map(int, input().split()))

#
count =[]
for i in range(1,n-1):
    p3 =p[i-1:i+2]
    p3.sort()
    if p3[1] ==p[i]:
        count.append(i)
print(len(count))

Measured memory_bytes: 3060
n,y=map(int,input().split())
b=0
for i in range(n+1):
    for j in range(n-i+1):
        if y- (10000*i + 5000*j)==1000*(n-i-j):
            print(i,j,n-i-j)
            b=1
            break
    if b==1:
        break    
if b==0:
    print(-1,-1,-1)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>

int main()
{  
  int N, M, a[50], b[50], c[50], d[50], goal_num[50], goal_dist[50];
  std::cin >> N >> M;
  
  for(int i = 0; i < N; i++)
  {
    std::cin >> a[i] >> b[i];
    goal_dist[i] = 1000000000;
  }

  for(int i = 0; i < M; i++)
  {
    std::cin >> c[i] >> d[i];  
  }
  
  for(int i = 0; i < N; i++)
  {
    for(int k = 0; k < M; k++)
    {
      int dist = (std::abs(a[i] - c[k]) + std::abs(b[i] - d[k]));
      if(dist < goal_dist[i])
      {
        goal_dist[i] = dist;
        goal_num[i] = k;
      }
    }
  }
  
  for(int i = 0; i < N; i++)
  {
    std::cout << (goal_num[i] + 1) << "\n";  
  }

  return 0;
}

Measured memory_bytes: 3176
import java.util.Scanner;

public class Main{
    
    public static void main (String[] args){
        
        Scanner sc = new Scanner (System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if ((A+B)%2!=0){
            System.out.println("IMPOSSIBLE");
        } else {
            int middle = (A+B)/2;
            System.out.println(middle);
        }
    }
}

Measured memory_bytes: 21716
N, Q = map(int, raw_input().split())
S = raw_input()
ac_counter = [0] * (N + 1)
total = 0
for i in range(1, N):
  if S[i - 1:i + 1] == 'AC':
    ac_counter[i] += 1
  ac_counter[i] += total
  total = ac_counter[i]

for _ in range(Q):
  l, r = map(int, raw_input().split())
  print ac_counter[r] - ac_counter[l - 1] - (ac_counter[r] - ac_counter[r - 1])

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#define MPS
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 105;

int n, k, cnt;
ll ans;

int main()
{
	cin >> n >> k;
	if(!k) ans = n*1ll*n;
	else fo(b,max(1,k),n) ans += (b-k)*1ll*(n/b)+max(n%b-k+1,0); 
	pf("%lld\n",ans);
	return 0;
}

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

using ll=long long;
const int mod=1e9+7;
int N;

map<int,int> pf(int m) {
  map<int,int> r;
  for(int i=2; i*i<=m; i++)
    while(!(m%i)) {
      r[i]++;
      m /= i;
    }
  if(m!=1)
    r[m]++;
  return r;
}

ll modinv(ll a, ll m) {
  ll b=m, u=1, v=0;
  while(b) {
    ll t=a/b;
    a -= t*b; swap(a, b);
    u -= t*v; swap(u, v);
  }
  u %= m;
  if(u<0)
    u += m;
  return u;
}

ll cmb(ll b) {
  ll i, x=1, y=1;
  for(i=b+N-1; i>N-1; i--) {
    x *= i;
    x %= mod;
  }
  for(i=2; i<=b; i++) {
    y *= i;
    y %= mod;
  }
  return x * modinv(y,mod) % mod;
}

int main() {
  int M;
  ll s=1;
  map<int,int> x;
  cin >> N >> M;
  x = pf(M);
  for(pair<int,int> p : x) {
    s *= cmb(p.second);
    s %= mod;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
import sys
N, M = map(int, input().split())
adj = [[] for _ in range(N)]

for l, r, d in (map(int, l.split()) for l in sys.stdin):
    adj[l-1].append((r-1, d))
    adj[r-1].append((l-1, -d))

visited = [0]*N
dist = [0]*N

for i in range(N):
    if visited[i]:  # 探索したことのある(つまり矛盾がなかった)場所なら次の場所へ
        continue
    visited[i] = 1  # 探索したフラグを立てる
    stack = [i]  # 探索候補へ追加
    vset = set()  # 今回(iのターンで)探索する場所のリスト(という名のセット)

    while stack:
        v = stack.pop()  # 今探索する場所をvとする
        vset.add(v)  # 探索する場所を追加する
        for dest, d in adj[v]:
            if visited[dest]:
                continue
            visited[dest] = 1  # 探索したフラグ立てる
            dist[dest] = dist[v] + d  # 今回の情報でとりあえず距離を設定
            stack.append(dest)

    for v in vset:  # 今回探索した場所それぞれについて
        for dest, d in adj[v]:
            if dist[v] + d != dist[dest]:  # ほかの情報と矛盾するか
                print('No')  # 矛盾してたらNoとなる
                exit()

print('Yes')


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

typedef long long ll;

int rnum(ll n){
    while(n>=10) n/=10;
    return n;
}

int main(){
	ll N;
    cin>>N;
    vector<vector<ll>> as(10,vector<ll>(10,0));
    rep(i,10)rep(j,10){
        if(i==0 || j==0) continue;
        rep1(k,N) {
            if((k%10==i) && (rnum(k)==j)) as[i][j]+=1;
        }
    }
    ll res=0;
    rep1(i,N) res+=as[rnum(i)][i%10];
    cout<<res<<endl;
}


Measured memory_bytes: 256
// Problem : E - Count Median
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull ;
typedef long double ld;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a;a%=b;return gcd(b,a);}
ll power(ll x, ll y) { if (y == 0) return 1;  ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {    if (ex & 1ll) ans = (ans * x) % md;    ex >>= 1ll;x = (x * x) % md;}return ans;}
const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const long double eps = 1e-9;
const ll N = 1e6 + 1;

void solve(){
	ll n;
	cin >>  n;
	ld a[n] ;
	ld b[n];
	rep(i , n){
		cin >> a[i] >> b[i];
	}
	sort(a , a + n);
	sort(b , b + n);
	ld mn = 0;
	ld mx = 0;
	if(n%2 == 0){
		mn = (a[n/2] + a[(n/2) - 1])/2;
		mx = (b[n/2] + b[(n/2) - 1])/2;
		mn = 2*mn;
		mx = 2*mx;
		ll ans =  mx - mn + 1;
		cout << ans << endl;		
	} 
	else{
		mn = a[n/2];
		mx = b[n/2];
		ll ans = mx - mn + 1;
		cout << ans << endl;
	}
}
int main(){
    IOS;
    cout<<fixed<<setprecision(20);
    ll T=1;
    // cin>>T;
    ll t=0;
    while(t++<T){
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 10048
function main(input) {
    var a = input[0].split(" ")[0]-0;
    var b = input[0].split(" ")[1]-0;
    var c = input[0].split(" ")[2]-0;
    var x = input[0].split(" ")[3]-0;
    var y = input[0].split(" ")[4]-0;
    var ans = a*x+b*y;
    ans = Math.min(ans, Math.min(x,y)*c*2 + (x>y?((x-y)*a):((y-x)*b)));
    ans = Math.min(ans, Math.max(x,y)*c*2);
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));


//1 2 3 4 5 6


Measured memory_bytes: 7372