akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int s = a + b + c;
    int mx = max({a, b, c});
    if (s - mx == mx) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 500005;


int32_t main()
{






    int n,k;
    cin >> n >> k;


    double x = 1.0000/n;
    double ans = 0.00;

    for(int i = 1; i <= n; i++)
    {
      int y = i;
      int sum = i;
      int t = 0;
      while(sum < k)
      {
        t++;
        sum += y;
        y*=2;
      }

      ans += x*pow(0.5000000000,t);

    }

    cout << fixed << setprecision(12) << ans << endl;

   
   

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 1000;
// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}

int n, wlim;
int w[N_MAX], v[N_MAX];
ll dp[101][100001];


ll dfs(int i, int noww){
  if(dp[i][noww] > 0){
    return dp[i][noww];
  }
  ll ret;
  if(i == n){
    // 全て見たので探索を終える
    ret = 0;
  }
  else if(noww + w[i] > wlim){
    // 今回の要素は含まずに次へ進む
    ret =  dfs(i+1, noww);
  }
  else{
    ret = max(dfs(i+1, noww), dfs(i+1, noww+w[i]) + v[i]);
  }
  return dp[i][noww] = ret;
}


int main() {
  cin >> n >> wlim;
  rep(i,n) cin >> w[i] >> v[i];

  memset(dp, -1, sizeof(dp));

  cout << dfs(0,0) << endl;
}


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

void prt(int A[], int N){
    for(int i=0; i<N; i++){
        if(i!=0) cout<<" ";
        cout << A[i];
    }
    cout << endl;
}

void insertion(int A[], int N){
    for(int i=1; i<N; i++){
        prt(A, N);
        int key = A[i];
        int j = i-1;
        while(j>=0&&A[j]>key){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = key;
    }
}
int main(){
    int A[100];
    int N;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    insertion(A, N);
    prt(A, N);
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int n,m,a[maxn],b[maxn],ans[maxn];
vector<int> edge[maxn];
bool vis[maxn];
queue<int> q;
int main() 
{
	cin>>n>>m;
	for(int i=0;i<m;i++) 
	{
		cin>>a[i]>>b[i];
		edge[a[i]].push_back(b[i]);
		edge[b[i]].push_back(a[i]);
	}
	q.push(1);
	vis[1]=true;
	while(!q.empty())
	{
		int now=q.front();
		q.pop();
		for(auto to:edge[now]) if(!vis[to])
		{
			ans[to]=now;
			vis[to]=true;
			q.push(to);
		}
	}
	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 14380
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  string a , b , c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long int
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(),v.rend() //reverse
#define vl vector<long long>v(n);
#define mii unordered_map<ll,ll>
#define pb push_back
double pi = 2*acos(0.0);
//ll power(ll a,ll b){ ll res=1;while(b){if(b&1)res=res*a;b=b/2; a=(a*a); }return res;}

      
 int main()
 {
       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
       ll tst;
       tst=1;
       //cin>>tst;
    
       while(tst--)
       {
        ll l,r,d;
        cin>>l>>r>>d;
        cout<<((r)/d)-((l-1)/d);
         
       }
 }

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
  int n,m;
  cin >> n >> m;
  
  int array_x[m], array_y[m];
  rep(i,m){
    cin >> array_x[i] >> array_y[i];
    array_x[i]--; array_y[i]--;
  }
  
  int num[n];
  rep(i,n) num[i] = 1;
  
  bool isRed[n];
  rep(i,n) isRed[i] = false;
  isRed[0] = true;
  
  rep(i,m){
    int x = array_x[i];
    int y = array_y[i];
    if(isRed[x]){
      isRed[y] = true;
      if(num[x] == 1) isRed[x] = false;
    }
    num[x]--; num[y]++;
  }
  
  int ans = 0;
  rep(i,n) if(isRed[i]) ans++;
  
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define int long long
#define range(i,x,y) i=(x);i<(y);i++
#define rep(i,n) for(int i=0,i##_len=n;i<i##_len;i++)
#define all(x) begin(x),end(x)
#define lim(x,r,l) (r<=x&&x<l)
typedef long long ll;
typedef long double ld;
using namespace std;

signed main(){
  int n, k; cin >> n >> k;
  const int alp = 'Z' - 'A' + 1;
  vector<int> probs(alp);
  rep(i, n){
    string s; cin >> s;
    probs[s[0] - 'A']++;
  }
  int res = 0;
  while(true){
    sort(all(probs)); reverse(all(probs));
    int oks = 0;
    rep(i, k){
      if(probs[i] > 0){
        probs[i] --;
        oks ++;
      }
    }
    if(oks != k) break;
    res ++;
  }
  cout << res << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    if (S[0] == 'S') cout << "Cloudy" << endl;
    if (S[0] == 'C') cout << "Rainy" << endl;
    if (S[0] == 'R') cout << "Sunny" << endl;

    return 0;
}


Measured memory_bytes: 256
//
//取り組んだ問題:平安京
//プロ怖い
//
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <list>
#define rep(i,n) for(int i = 0; i < n;i++)
#define Rep(i,n) for(int i = 0; i <= n;i++)

using namespace std;

int main(){
    int gx,gy;
    int x1,y1,x2,y2;
    int p;
    int dataset;
    cin >> dataset;
    rep(xxxxx,dataset){
        int map[20][20]={};
        int dp[20][20]={};
        dp[0][0]=1;
        cin >> gx >> gy;
        cin >> p;
        rep(xxxxxxx,p){
            cin >> x1 >> y1  >> x2 >> y2;
            if(x1 == x2){
                if(y1 > y2){
                    map[x1][y2] += 2;
                }else{
                    map[x1][y1] += 2;
                }
            }else{
                if(x1 > x2){
                    map[x2][y1] += 1;
                }else{
                    map[x1][y1] += 1;
                }
            }
        }
        for(int i = 0;i <= gx;i++){
            for(int j = 0;j <= gy;j++){
                if((map[i][j]&2) == 0)
                    dp[i][j+1] += dp[i][j];
                if((map[i][j]&1) == 0)
                    dp[i+1][j] += dp[i][j];
            }
        }
        if(dp[gx][gy]==0){
            cout << "Miserable Hokusai!" << endl;
        }else{
            cout << dp[gx][gy] << endl;
        }
    }
}

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

public class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		ArrayList<Integer> array = new ArrayList<Integer>();

		int w = in.nextInt();
		int n = in.nextInt();

		for (int i = 1; i <= w; i++) {
			array.add(i);
		}

		//System.out.println(array);
		for (int j = 1; j <= n; j++) {
			String[] values = in.next().split(",");
			int a = Integer.parseInt(values[0]);
			int b = Integer.parseInt(values[1]);
			int c = array.get(a - 1);
			int d = array.get(b - 1);

			array.set(a - 1, d);
			array.set(b - 1, c);
		}

		for (int k = 0; k < w; k++) {
			int amida = array.get(k);
			System.out.println(amida);
		}
	}
}

Measured memory_bytes: 17208
a,b,c = map(int, input().split())
if a < b:
    if b < c:
        print(f"{a} {b} {c}")
    else:
        if a < c:
            print(f"{a} {c} {b}")
        else:
            print(f"{c} {a} {b}")
else:
    if a < c:
        print(f"{b} {a} {c}")
    else:
        if b < c:
            print(f"{b} {c} {a}")
        else:
            print(f"{c} {b} {a}")




Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
void Main()
{
    string s;
    cin >> s;

    s.erase(unique(all(s)), s.end());
    put(s.size() - 1);
}
signed main(){ Main();return 0;}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  int res = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int k = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();
      res += max(k - j - 1, 0);
    }
  }
  cout << res << '\n';
  return 0;
}


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

int n;
int hd[200005], nx[400005], to[400005], cnt;
void add(int f, int t) { nx[++cnt] = hd[f], hd[f] = cnt, to[cnt] = t; }
char s[200005];

int deg[200005], del[200005], w[200005], res, rmx;
queue<int> q;
void init() {
    for (int i = 1; i <= n; ++i)
        if ((w[i] = deg[i]) <= 1 && s[i] == 'B') q.push(i), del[i] = i;
    while (!q.empty()) {
        int u = q.front();
        q.pop(), --res;
        for (int i = hd[u], v; i; i = nx[i])
            if ((--deg[v = to[i]]) <= 1 && s[v] == 'B' && !del[v])
                q.push(v), del[v] = 1;
    }
    if (res <= 1) printf("%d\n", res), exit(0);
    res = (res << 1) - 2;
    for (int i = 1; i <= n; ++i)
        res += (w[i] = (!del[i] && ((s[i] == 'W') ^ (deg[i] & 1))));
}

int dfs(int u, int fa) {
    int mx1 = 0, mx2 = 0;
    for (int i = hd[u], v, d; i; i = nx[i])
        if ((v = to[i]) != fa)
            mx2 = max(mx2, dfs(v, u)), mx2 > mx1 ? swap(mx2, mx1) : void();
    rmx = max(rmx, mx1 + w[u] + mx2);
    return mx1 + w[u];
}

int main() {
    scanf("%d", &n);
    if (!n) return puts("0"), 0;
    for (int i = 1, u, v; i < n; ++i)
        scanf("%d%d", &u, &v), ++deg[u], ++deg[v], add(u, v), add(v, u);
    scanf("%s", s + 1), res = n, init();
    dfs(1, 0), printf("%d\n", res - rmx * 2);
    return 0;
}

Measured memory_bytes: 10752
#解説のコードそのもの

N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(n, a, b, c):
    if n == N:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a,b,c)>0 else INF
    ret0 = dfs(n + 1, a, b, c)
    ret1 = dfs(n + 1, a + l[n], b, c) + 10
    ret2 = dfs(n + 1, a, b + l[n], c) + 10
    ret3 = dfs(n + 1, a, b, c + l[n]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))


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

using namespace std;

typedef long long ll;

#define mod 1000000007
#define siz 100001

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n,k;
	cin >> n >> k;
	
	ll x = 1;
	vector<ll> v(n),dp;
	
	for(ll i = 0; i < n; i++) cin >> v[i];
	
	for(ll i = k; i < n; i++){
		if(v[i] <= v[i - k]){
			cout << "No" << "\n";
		}else {
			cout << "Yes" << "\n";
		}
	}
}

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

int main()
{
	unsigned int N;
	std::vector<unsigned long> v;

	std::cin >> N;

	for ( int i = 0; i < N; i++ )
	{
		unsigned long tmp;
		std::cin >> tmp;
		v.emplace_back( tmp );
	}

	// 要素を降順ソートする
	std::sort( v.begin(), v.end(), []( unsigned long a, unsigned long b ) {
			return ( a > b );
		} );

	// 最初と最後の差分が最大値になる
	std::cout << v[0] - v.back() << std::endl;

	return ( 0 );
}


Measured memory_bytes: 888
#include <cstdio>
using namespace std;

int main() {
    int n;
    char s[100];

    scanf("%d", &n);

    printf("%d\n", 0);
    fflush(stdout);
    scanf("%s", s);
    if(s[0] == 'V') return 0;

    char c = s[0];

    int l = 0;
    int r = n;
    int m;
    while(r-l>1){
        //cout << l << " " << r << endl;
        m = (r+l)/2;

        printf("%d\n", m);
        fflush(stdout);
        scanf("%s", s);
        if(s[0] == 'V') return 0;

        if((s[0] != c && (m-l)%2 == 0) || (s[0] == c && (m-l)%2 != 0)){
            r = m;
        }else{
            c = s[0];
            l = m;
        }
    }
    printf("%d\n", m);
    fflush(stdout);
    scanf("%s", s);
    return 0;
}


Measured memory_bytes: 760
object Main extends App {
  val n: Int = io.StdIn.readInt()
  val bt: BTree = Empty

  (0 until n).foldLeft[BTree](bt){(t, _) =>
    val op: Array[String] = io.StdIn.readLine().split(" ")
    op(0) match {
      case "print" => t.show; t
      case "insert" => t.insert(op(1).toInt)
      case "find" => {
        val key: Int = op(1).toInt
        println(if (t.find(key)) "yes" else "no")
        t
      }
      case "delete" => {
        val key: Int = op(1).toInt
        t.delete(key)
      }
      case _ => throw new Error("Unknown operation")
    }
  }

  sealed trait BTree {
    def insert(x: Int): BTree
    def preorder: List[Int]
    def inorder: List[Int]
    def show: Unit = {
      println(" " + this.inorder.mkString(" "))
      println(" " + this.preorder.mkString(" "))
    }
    def find(x: Int): Boolean
    def delete(x: Int): BTree
    def leftmost: Int
  }
  case object Empty extends BTree {
    def insert(x: Int): BTree = Node(x, Empty, Empty)
    def preorder: List[Int] = Nil
    def inorder: List[Int] = Nil
    def find(x: Int): Boolean = false
    def delete(x: Int): BTree = this
    def leftmost: Int = throw new NoSuchElementException("error")
  }
  case class Node(v: Int, l: BTree, r: BTree) extends BTree {
    def insert(x: Int): BTree =
      if (x < v) Node(v, l.insert(x), r)
      else Node(v, l, r.insert(x))
    def preorder: List[Int] = v :: (l.preorder ::: r.preorder)
    def inorder: List[Int]  = l.inorder ::: (v :: r.inorder)
    def find(x: Int): Boolean =
      if (x == v) true
      else if (x < v) l.find(x)
      else r.find(x)
    def delete(x: Int): BTree = {
      if (x == v) {
        this match {
          case Node(_, Empty, Empty) => Empty
          case Node(_, _, Empty) => l
          case Node(_, Empty, _) => r
          case _ => {
            val n: Int = r.leftmost
            Node(n, l, r.delete(n))
          }
        }
      }
      else if (x < v) Node(v, l.delete(x), r)
      else Node(v, l, r.delete(x))
    }
    def leftmost: Int = l match {
      case Empty => v
      case _ => l.leftmost
    }
  }
}


Measured memory_bytes: 466720
import numpy

X, K, D = map(int, input().split())
longest = D * K

ans = 0
if numpy.abs(X) > longest:
    ans = numpy.abs(X) - longest
else:
    m = numpy.abs(X) // D
    if (K - m) % 2 == 0:
        ans = numpy.abs(X) - D * m
    else:
        ans = numpy.abs(X) - D * (m + 1)

ans = numpy.abs(ans)
print(ans)

Measured memory_bytes: 27128
#ifdef _WIN32
#define NOMINMAX
#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>
#define DEBUGBREAK() ::DebugBreak()
#else
#define DEBUGBREAK() static_cast<void>(0)
#endif

#include <iostream>
#include <sstream>
#include <iomanip>
#include <valarray>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>
#include <queue>
#include <array>
#include <functional>
#include <stack>
#include <bitset>
#include <random>
#include <algorithm>
#include <unordered_map>

using namespace std;

const int64_t dx4[4] = { 0, -1, 1, 0 };
const int64_t dy4[4] = { -1, 0, 0, 1 };
const int64_t dx5[5] = { 0, -1, 0, 1, 0 };
const int64_t dy5[5] = { -1, 0, 0, 0, 1 };
const int64_t dx8[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int64_t dy8[8] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int64_t dx9[9] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
const int64_t dy9[9] = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };

#define REP(i, K) for (int64_t i = 0; i < K; ++i)
#define REPYX() for (int64_t y = 0; y < H; ++y) for (int64_t x = 0; x < W; ++x)
#define REPX() REP(x, W)
#define REPY() REP(y, H)
#define INSIDE(x_, y_) (0 <= (x_) && 0 <= (y_) && (x_) < W && (y_) < H)
#define INSIDE_MARGIN(x_, y_, m_) ((m_) <= (x_) && (m_) <= (y_) && (x_) < W - (m_) && (y_) < H - (m_))

int get_assert_level() {
    const char* s = getenv("ASSERT_LEVEL");
    if (s) { return atoi(s); }
    return 0;
}
static int g_assert_level = get_assert_level();

#define LV_1() if (g_assert_level >= 1)
#define LV_2() if (g_assert_level >= 2)
#define LV_3() if (g_assert_level >= 3)
#define ASSERT_1(expr) do { const bool b = bool(expr); if (g_assert_level >= 1 && !b) { std::cerr << "[ASSERT 1] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)
#define ASSERT_2(expr) do { const bool b = bool(expr); if (g_assert_level >= 2 && !b) { std::cerr << "[ASSERT 2] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)
#define ASSERT_3(expr) do { const bool b = bool(expr); if (g_assert_level >= 3 && !b) { std::cerr << "[ASSERT 3] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)

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

    LV_1() cerr << "LV 1" << endl;

    int N;
    cin >> N;

    vector<int64_t> count0s(200000, 0); // oome.
    int64_t sum1 = 0; // sum1 <= max(A,B,C) * max(N) ~ 10^10. ~ 34bit.
    REP(i, N) {
        int a1;
        cin >> a1;
        ++count0s[a1 - 1];
        sum1 += a1;
    }

    int Q;
    cin >> Q;
    REP(i, Q) { 
        int64_t b1, c1;
        cin >> b1 >> c1;
        const int64_t n_move = count0s[b1 - 1];
        count0s[b1 - 1] = 0;
        count0s[c1 - 1] += n_move;
        sum1 = sum1 - n_move * b1 + n_move * c1;
        cout << sum1 << endl;
    }

    return 0;
}



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  pqmaxi p,q,r;
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  rep(i,a){
    int tmp;
    cin>>tmp;
    p.push(tmp);
  }
  rep(i,b){
    int tmp;
    cin>>tmp;
    q.push(tmp);
  }
  rep(i,c){
    int tmp;
    cin>>tmp;
    r.push(tmp);
  }
  rep(i,x){
    int tmp=p.top();
    p.pop();
    r.push(tmp);
  }
  rep(i,y){
    int tmp=q.top();
    q.pop();
    r.push(tmp);
  }
  ll cnt=0;
  rep(i,x+y){
    cnt+=r.top();
    r.pop();
  }
  cout<<cnt<<endl;
  return 0;
  }


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

int c[500001];
void dfs(int p){
  if(c[p]++)c[p]=0,dfs(p-1);
}

int main(){
  int n;
  cin>>n;
  int len=0,mx=0;
  while(n--){
    int x;
    cin>>x;
    mx=max(mx,x);
    if(x>5e5)x=5e5;
    if(!c[0]&&(len<x||(len==x&&mx<=x))){
      dfs(x);
      int llen=max(len,1);
      while(c[llen])llen++;
      len=llen-1;
      cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
  }
  return 0;
}

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

#define ll long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll mod = 1000000007;
ll INF = 1e9 + 5;

int main(){
    FAST;
    ll n,w;
    cin >> n >> w;
    vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));
    vector<ll> wt(n),v(n);
    for(int i=0;i<n;i++)
    {
        cin >> wt[i] >> v[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(j >= wt[i-1])
            {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-wt[i-1]] + v[i-1]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}


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

using namespace std;

int main() {

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

	double n;
	cin >> n;
	double total = 0;
	for (int i = 1; i <= n; ++i) {
		if (i % 2 != 0) total++;
	}
	cout << total / n << '\n';
	return 0;
}

Measured memory_bytes: 256
using System;
namespace ABC151A
{
    public class MainClass
    {
        public static void Main(string[] args)
        {
            string inp = Console.ReadLine();
            char c = inp.ToCharArray()[0];
            int ascii = (int)c;
            ascii += 1;
            Console.WriteLine((char)ascii);
        }
    }
}


Measured memory_bytes: 11092
D=100000
$dp = Array.new(D).map{ Array.new(32, 0.0) }
$ans = Array.new(D+1)
def solve n
  $dp[0][1] = 1.0
  $ans[1] = 1.0
  ps = 1.0
  for d in 1...n
    p = 1.0
    for i in 1...32
      pa = $dp[d-1][i-1]*(1-p)
      pb = $dp[d-1][i-1]*p
      $dp[d][0] += pa
      $dp[d][i] += pb
      ps += pb
      p/=2
    end
    $ans[d+1] = ps
  end
end

solve D

n=nil
puts "%.5f" % $ans[n] while (n=gets.chomp.to_i)!=0

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>

#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >  



int main()
{
    IOS;
 
    int n,m;
    cin>>n>>m;
    vi id(n+1,0);
    int a,b;
    vii g(n+1);
    int level[n+1];
    memset(level,0,sizeof(level));
    int ans = 0;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        id[b]++;
        g[a].pb(b);
    }
    priority_queue<int,vector<int>,greater<int> > pq;
    for(int i=1;i<=n;i++)
    {
        if(id[i]==0)
            pq.push(i);
    }
    while(!pq.empty())
    {
        int d=pq.top();
        //trace1(d);
        pq.pop();
        vi::iterator it=g[d].begin();
        for(;it!=g[d].end();it++)
        {
            id[*it]--;
            level[*it] = max(level[*it],level[d]+1);
            ans = max(ans,level[*it]);
            if(id[*it]==0)
                pq.push(*it);
        }
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

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

int main() {
  
  int N, nums[1000], a[1000], b[1000], c[1000];
  int p, q, r, s;
  while(cin >> N && N) {
    rep(i, N)
      cin >> nums[i] >> a[i] >> b[i] >> c[i];
    cin >> p >> q >> r >> s;
    bool ok = 0;
    rep(i, N) {
      if(a[i] > p || b[i] > q || c[i] > r || 4*a[i]+9*b[i]+4*c[i] > s);
      else { cout << nums[i] << endl; ok = 1; }
    }
    if(!ok) {
      cout << "NA\n";
    }
  }
  
  return 0;
}

Measured memory_bytes: 1172
X = int(input())
a_list = []
for s in range(1, 32):
    for i in range(2, 10):
        a = s ** i
        if a > 1000:
            break
        a_list.append(a)
a2 = sorted(list(set(a_list)), reverse=True)
for n in a2:
    if n <= X:
        print(n)
        break

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;

string make(string a, string b){
	string dp[60][60] = {};
	int a_len = a.size();
	int b_len = b.size();
	a = ' ' + a;
	b = ' ' + b;

	FOR(i,1,a_len+1){
		FOR(j,1,b_len+1){
			if(a[i]==b[j]) {
				dp[i][j] = dp[i-1][j-1] + a[i];
			}
			else {
				if (dp[i-1][j].size()>=dp[i][j-1].size()){
					dp[i][j] = dp[i-1][j];
				}
				else {
					dp[i][j] = dp[i][j-1];
				}
			}
		}
	}

		return dp[a_len][b_len];
}

int main(){
	int n;
	cin >> n;
	string str;
	vector<string> s;
	rep(i,n){
		cin >> str;
		sort(str.begin(),str.end());
		s.push_back(str);
	}

	string ans = s[0];

	FOR(i,1,n){
		ans = make(ans,s[i]);
	}

	cout << ans << "\n";

	return 0;
}





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

int main(void)
{
    int n, l;
    cin >> n >> l;
    
    multiset<string> strSet;
    string a_string, result;
    for (int i = 0; i < n; i++)
    {
        cin >> a_string;
        strSet.insert(a_string);
    }
    for(auto x : strSet)
    {
        result += x;
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

map<ll, ll> m;
ll sum;

int main(void) {
    int n, q;
    cin >> n;
    rep(i, 0, n) {
        ll x;
        cin >> x;
        m[x]++;
        sum += x;
    }
    cin >> q;
    rep(i, 0, q) {
        ll b, c;
        cin >> b >> c;
        sum -= b*m[b];
        sum -= c*m[c];
        m[c] += m[b];
        m[b] = 0;
        sum += c*m[c];
        printf("%lld\n", sum);
    }



    return 0;
}



Measured memory_bytes: 9632
using System;

namespace ABC062
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            var h = long.Parse(s[0]);
            var w = long.Parse(s[1]);

            var min = long.MaxValue;

            for (var i = 1; i < h; i++)
            {
                var x = FromTop(h, w, i);
                if (x < min) min = x;
            }

            for (var i = 0; i < w; i++)
            {
                var x = FromLeft(h, w, i);
                if (x < min) min = x;
            }

            Console.WriteLine(min);
        }

        static long FromTop(long h, long w, long x)
        {
            var s1 = x * w;

            var hRemaining = h - x;
            var wHalf = w / 2;

            var s2 = hRemaining * wHalf;
            var s3 = hRemaining * (w - wHalf);

            var ret1 = Math.Max(Math.Max(s1, s2), s3)
                - Math.Min(Math.Min(s1, s2), s3);

            var hHalf = hRemaining / 2;

            var s4 = hHalf * w;
            var s5 = (hRemaining - hHalf) * w;

            var ret2 = Math.Max(Math.Max(s1, s4), s5)
                - Math.Min(Math.Min(s1, s4), s5);

            return Math.Min(ret1, ret2);
        }

        static long FromLeft(long h, long w, long x)
        {
            var s1 = x * h;

            var wRemaining = w - x;
            var hHalf = h / 2;

            var s2 = hHalf * wRemaining;
            var s3 = (h - hHalf) * wRemaining;

            var ret1 = Math.Max(Math.Max(s1, s2), s3)
               - Math.Min(Math.Min(s1, s2), s3);

            var wHalf = wRemaining / 2;

            var s4 = h * wHalf;
            var s5 = h * (wRemaining - wHalf);

            var ret2 = Math.Max(Math.Max(s1, s4), s5)
              - Math.Min(Math.Min(s1, s4), s5);

            return Math.Min(ret1, ret2);
        }
    }
}


Measured memory_bytes: 11220
while !STDIN.eof?
    arr=Array.new
    8.times do
        arr<<gets.chomp.split(//).map(&:to_i)
    end
    gets
    8.times do |k|
        if (arr[k].find_all{|i|i==1}.size==4)
            puts "C"
            break
        elsif (arr[k].find_all{|i|i==1}.size==2)
            if (arr[k+1][arr[k].index(1)]==1)
                if (arr[k+1][arr[k].index(1)+1]==1)
                    puts "A"
                    break
                else
                    puts "G"
                    break
                end
            else
                puts"E"
                break
            end
        elsif (arr[k].find_all{|i|i==1}.size==1)
            if (arr[k+1][arr[k].index(1)+1]==1)
                puts "F"
                break
            elsif (arr[k+1][arr[k].index(1)-1]==1)
                puts "D"
                break
            else
                puts "B"
                break
            end
        else
        end
    end
end

Measured memory_bytes: 6116
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		if(b - a + 1 <= 2 * k) {
			for(int i = a; i <= b; i++) {
				System.out.println(i);
			}
		} else {
			for(int i = a; i < a + k; i++) {
				System.out.println(i);
			}
			for(int i = b - k + 1; i <= b; i++) {
				System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 21844
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#include <cmath>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  int cnt=0;
  rep(i,n) cin >>l[i];
  sort(l.begin(),l.end()); //Lを昇順にソートした
  rep(i,n)rep(j,n)rep(k,n){
    if(i<j && j<k){
      if(l[i]==l[j]) continue;
      if(l[i]==l[k]) continue;
      if(l[j]==l[k]) continue;
      if(l[k]<l[i]+l[j]) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<int> W(N);
	int all=0;
	for(int i=0;i<N;i++){
		cin >> W.at(i);
		all+=W.at(i);
	}

	int ans=1e9;
	int sum=0;
	for(int i=0;i<N-1;i++){
		sum+=W.at(i);
		ans=min(ans,abs(sum-(all-sum)));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  char s[4];
  scanf("%s", s);
  
  int rainyDayCount = 0, maxRainyDayCount = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'R') {
      rainyDayCount++;
    } else {
      rainyDayCount = 0;
    }
    
    if (rainyDayCount > maxRainyDayCount) {
      maxRainyDayCount = rainyDayCount;
    }
  }
  
  printf("%d\n", maxRainyDayCount);
  
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr ll INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    ll N,T;cin >> N >> T;
    vector<pair<ll,ll>> V(N);
    REP(i,N) cin >> V[i].first >> V[i].second;
    sort ALL(V);
    ll dp[3100][6100] = {};
    int A[N],B[N];
    REP(i,N){
        A[i] = V[i].first;B[i] = V[i].second;
        REP(j,6100){
            if(j < T){
                dp[i+1][j+A[i]] = max(dp[i+1][j+A[i]],dp[i][j] + B[i]);
            }
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
        }
    }
    ll maxv = 0;
    REP(j,N+1){
        REP(i,6100){
            maxv = max(maxv,dp[j][i]);
        }
    }
    cout << maxv << endl;
}


Measured memory_bytes: 148096
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        k: i64
    }

    let mut ans = -1;
    let mut i = 0;
    let mut a = 0;

    while i < k {
        i += 1;
        a = (10 * a + 7) % k;
        if a == 0 {
            ans = i;
            break;
        }
    }

    println!("{}", ans);

}


Measured memory_bytes: 2180
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
#define rep(i,n) for (int i=0; i < int(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
vector<pair<pair<ll,ll>,int > > x, y;
ll n, m;
// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<ll> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<ll> sizes;

  UnionFind(ll n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
    
  }

  // データxが属する木の根を得る
  ll find(ll x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(ll x, ll y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(ll x, ll y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  ll size(ll x) {
    return sizes[find(x)];
  }
};


// 頂点a, bをつなぐコストcostの（無向）辺
struct Edge
{
  ll cost;
    int a, b;
  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};

// 頂点数と辺集合の組として定義したグラフ
struct Graph
{
  ll n;  // 頂点数
  vector<Edge> es;  // 辺集合

  // クラスカル法で無向最小全域木のコストの和を計算する
  // グラフが非連結のときは最小全域森のコストの和となる
  ll kruskal() {
    // コストが小さい順にソート
    sort(es.begin(), es.end());
    UnionFind uf(n);
    ll min_cost = 0;
    
    rep(ei, es.size()) {
      Edge& e = es[ei];
      if (!uf.same(e.a, e.b)) {
        // 辺を追加しても閉路ができないなら、その辺を採用する
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }

    return min_cost;
  }
};

// 標準入力からグラフを読み込む
Graph input_graph() {
  Graph g;
  g.n=n;
  sort(ALL(x));
  sort(ALL(y));
  rep(i, n-1) {
    Edge ex, ey;
    ex.a=x[i].second;
    ex.b=x[i+1].second;
    ex.cost=min(abs(x[i].first.first-x[i+1].first.first),abs(x[i].first.second-x[i+1].first.second));
    ey.a=y[i].second;
    ey.b=y[i+1].second;
    ey.cost=min(abs(y[i].first.first-y[i+1].first.first),abs(y[i].first.second-y[i+1].first.second));
    g.es.push_back(ex);
    g.es.push_back(ey);
  }
  return g;
}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    m=n;
    for(int i=0;i<n;i++){
        ll temp1, temp2;
        cin>>temp1>>temp2;
        x.push_back(make_pair(make_pair(temp1,temp2),i));
        y.push_back(make_pair(make_pair(temp2,temp1),i));
    }
  Graph g = input_graph();
  
  cout << g.kruskal() << endl;
  return 0;
}

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

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=(a+d-1)/d;
    int y=(c+b-1)/b;
    if(x>=y)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;

int main()
{
  int A;
  int B;
  int C;
  int D;
  C=0;
  cin>>A;
  REP(i,9)
  {
    B=A%(i+1);
    D=A/(i+1);
    if(B==0)
    {
      if(D<10)
      {
        C=1;
      }

    }

  }
  if(C==1)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

void solve(int N, int Q, string S) {
  vector<int> t(N + 1, 0);
  for (int i = 0; i < N; i++) {
    if (S[i] == 'A' && S[i + 1] == 'C') {
      t[i] = 1;
    }
  }
  vector<int> tt(N + 1, 0);
  for (int i = 0; i < N; i++) {
    tt[i + 1] = tt[i] + t[i];
  }
  int l, r;
  for (int i = 0; i < Q; i++) {
    scanf("%d %d", &l, &r);
    cout << tt[r - 1] - tt[l - 1] << endl;
    ;
  }
}
int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;

  solve(N, Q, S);
  return 0;
}


Measured memory_bytes: 1856
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		char x = stdIn.next().charAt(0);
		char y = stdIn.next().charAt(0);
		
		if(x-y <0) {
			System.out.println("<");
		}else if(x-y >0) {
			System.out.println(">");
		}else {
			System.out.println("=");
		}
		
		
		
	}

}


Measured memory_bytes: 23636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[] b = new int[m];
		for(int i=0; i< m; i++)
			b[i] = sc.nextInt();
		
		int count = 0;
		for(int i= 0; i< n; i++) {
			int sum = c;
			for(int j = 0; j <m; j++) 
				sum += sc.nextInt() * b[j];
			if(sum > 0)
				count++;
		}
		System.out.println(count);
		
	}
}

Measured memory_bytes: 24020
import numpy as np

n,k = map(int,input().split())
comp = []
s = input()
f = s[0]
b = f
temp = 0
for c in s:
    if c == b:
        temp += 1
    else:
        comp.append(temp)
        temp = 1
        b = c
comp.append(temp)

if s[0] == "0":
    comp.insert(0,0)

if s[-1] == "0":
    comp.append(0)
# print(comp)


if 2*k+1 >= len(comp):
    print(sum(comp))
else:
    first = sum(comp[:2*k+1])
    ans = first
    # print((len(comp)-2*k+1)//2)
    # print(first)
    for i in range((len(comp)-2*k+1)//2-1):
        # print(i)
        first -= comp[i*2]
        first -= comp[i*2+1]
        first += comp[i*2+2*k+1]
        first += comp[i*2+2*k+2]
        if ans < first:
            ans = first
    print(ans)



Measured memory_bytes: 14172
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
     int i,j,k,n,m;
     scanf("%d%d%d",&n,&m,&k);
     if(n*m<k)
          printf("%d\n",n*m);
     else
          printf("%d\n",k);
     return 0;
}


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

vector<pair<int, int>> perse(string s) {
  vector<pair<int, int>> v;
  int cnt = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '0') {
      if (cnt) v.push_back(make_pair(s[i - 1] - '0', cnt));
      cnt = 0;
    }
    else ++cnt;
  }

  return v;
}

char c[10][10] = {
  {},
  {'.', ',', '!', '?', ' '},
  {'a', 'b', 'c'},
  {'d', 'e', 'f'},
  {'g', 'h', 'i'},
  {'j', 'k', 'l'},
  {'m', 'n', 'o'},
  {'p', 'q', 'r', 's'},
  {'t', 'u', 'v'},
  {'w', 'x', 'y', 'z'}
};

char ans(int a, int b) {
  b--;
  if (a == 1) b %= 5;
  else if (a == 7 || a == 9) b %= 4;
  else b %= 3;
  return c[a][b];
}

int main() {
  int n;
  string s;

  cin >> n;

  while (n--) {
    cin >> s;

    vector<pair<int, int>> v = perse(s);

    for (int i = 0; i < v.size(); ++i) {
      cout << ans(v[i].first, v[i].second);
    }
    cout << endl;
  }
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int a,b;
  cin >> a >> b;
  if(a+b==15) std::cout << "+" << std::endl;
  else if(a*b==15) std::cout << "*" << std::endl;
  else std::cout << "x" << std::endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
p = 10**9 + 7
r = 1
cur = [0, 0, 0]
for i in range(N):
  fi = -1
  t = 0
  for c in range(3):
    if cur[c] == A[i]:
      t += 1
      fi = c
  if fi >= 0:
    cur[fi] += 1
  r = r * t % p

print(r)

Measured memory_bytes: 14004
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<int>a(N);
	rep(i, 0, N)cin >> a[i];
	int ans = 0;
	rep(i, 0, N) {
		if (a[a[i] - 1] == i + 1)ans++;
	}
	cout << ans / 2 << "\n";

	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	static ArrayList<Integer> list = new ArrayList<Integer>();
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		makePrimeList();
		while(true) {
			int a = sc.nextInt();
			if(a == 0) break;
			int ansa = 0;
			int ansb = 0;
			
			for(int i = 1; i < list.size(); i++) {
				if(list.get(i) <= a &&list.get(i) - list.get(i-1) == 2) {
					ansa = list.get(i-1);
					ansb = list.get(i);
				}
			}
			System.out.println(ansa + " " + ansb);
		}
		sc.close();
	}
	
	static void makePrimeList() {
		boolean[] isntPrime = new boolean[10000];
		int i = 2;
		for(; i*i < 10000; i++) {
			if(!isntPrime[i]) {
				list.add(i);
				for(int j = i + i; j < 10000; j += i) {
					isntPrime[j] = true;
				}
			}
		}
		for(; i < 10000; i++) {
			if(!isntPrime[i]) {
				list.add(i);
			}
		}
	}
}     

Measured memory_bytes: 32956
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll x=0,n,last,sum=1;
inline void f(ll k){
	if(x==0){
		if(k>last)x=1;
		else if(k<last)x=2;
	}
	else{
		if(k>last&&x==2)sum++,x=0;
		else if(k<last&&x==1)sum++,x=0;
	}
}
int main(){
	register int i,j;
	scanf("%lld",&n);
	for(i=1;i<=n;i++){
		ll k;
		scanf("%lld",&k);
		if(i>1)f(k);
		last=k;
	}
	cout<<max(sum,(ll)1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,coin=0,niti=0;
	scanf("%d %d %d",&a,&b,&c);
	while(coin<c){
		coin+=a;
		niti++;
		
		if(niti%7==0){
			coin+=b;
		}
	}
	printf("%d\n",niti);
	return 0;
}


Measured memory_bytes: 2120