akhauriyash/Code-Regression huggingface dataset:
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

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

int n,m,dp[N];
vector<int>v[N];
int dfs(int x){
    if(dp[x]!=-1) return dp[x];
    int tans=0;
    if(v[x].empty()) return dp[x]=0;
    for(int i:v[x]) tans=max(tans,dfs(i));
    return dp[x]=1+tans;
}
signed main(){
    FastIO;
    cin>>n>>m;
    rep(i,1,m){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
    }
    int ans=0;
    memset(dp,-1,sizeof dp);
    rep(i,1,n) ans=max(ans,dfs(i));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <set>
using namespace std;

const int N = 1010000;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int x, a; cin >> x >> a;
  cout << (x < a ? 0: 10) << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back

#define f(i,n) for(i=0;i<n;i++)
#define fr(i,n) for(i=1;i<=n;i++)
#define fi first
#define se seecond
#define in insert

using namespace std;

int main() {
  ll n,i,j;
  string s="",t="zabcdefghijklmnopqrstuvwxy";
 
 cin>>n;
 while(n)
 {  j=n%26;
     s+=t[j];
     n=ceil(n/26.0)-1;
 }
 reverse(s.begin(),s.end());
 cout<<s;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int n, math, jap, p, q,a=0,b=0,c=0;
	cin >> n >> jap >> math >> p >> q;
	
	if (jap % p != 0) {
		a = jap / p + 1;
	}
	else {
		a = jap / p;
	}
	if (math%q != 0) {
		b = math / q + 1;
	}
	else {
		b = math / q;
	}
	c=max(a, b);

	cout << n - c << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)

signed main() {
  ll n,k; cin >> n >> k;
  vector<ll> p(n), c(n);
  rep(i,n) {cin >> p[i]; p[i]--;}
  rep(i,n) cin >> c[i];

  vector<int> loopsize(n);
  vector<ll> loopvalue(n);
  vector<vector<ll>> a(n, vector<ll>(n, 0));

  rep(i,n) {
    ll current = i;
    ll ss = 0;
    ll val = 0;
    rep(j,n) {
      ss++;
      ll pnext = p[current];
      val += c[pnext];
      a[i][j] = c[pnext] + (j>0 ? a[i][j-1] : 0);
      current = pnext;
      if(current==i) {
        loopsize[i] = ss;
        loopvalue[i] = val;
        break;
      }
    }
  }

  ll ans = -1000000000;
  rep(i,n) {
    if(loopvalue[i] <= 0) {
      rep(j,loopsize[i]) ans = max(ans, a[i][j]);
    }
    else {
      ll loops = k / loopsize[i];

      ll base = loops * loopvalue[i];
      ans = max(ans, base);
      rep(j,k%loopsize[i]) ans = max(ans, base+a[i][j]);

      ll base2 = (loops-1) * loopvalue[i];
      rep(j,n) ans = max(ans, base2+a[i][j]);
    }
  }
  cout << ans << endl;
}


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

template<class T, class E>
struct SegTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  typedef function<E(E,E)> H;
  typedef function<E(E,int)> P;
  int n;
  F f;
  G g;
  H h;
  P p;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> lazy;
  SegTree(int n_, F f, G g, H h, T d1, E d0, P p=[](E a, int b){ return a; })
    : f(f), g(g), h(h), d1(d1), d0(d0), p(p) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, d1);
    lazy.resize(2 * n - 1, d0);
  }
  void eval(int k, int l, int r) {
    if (lazy[k] == d0) return;
    dat[k] = g(dat[k], p(lazy[k], r - l));
    if (k < n - 1) {
      lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
      lazy[2 * k + 2] = h(lazy[2 * k + 2], lazy[k]);
    }
    lazy[k] = d0;
  }
  void update(int a, int b, E x, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] = h(lazy[k], x);
      eval(k, l, r);
    }
    else {
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
    }
  }
  // return op[a..b)
  // k: node id, [l, r): node interval
  E query(int a, int b, int k = 0, int l = 0, int r = -1) {
    // cerr << "a = " << a << ", b = " << b << ", k = " << k << ", l = " << l << ", r = " << r << endl;
    if (r == -1) r = n;
    eval(k, l, r);
    if (r <= a || b <= l) return d1;
    if (a <= l && r <= b) return dat[k];
    E vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    E vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return f(vl, vr);
  }
  void print() {
   int j = 2;
   for (int i = 0; i < 2 * n - 1; i++) {
     cerr << "(" << dat[i] << ", " << lazy[i] << ")";
     if (i == j - 2) { cerr << endl; j *= 2;}
     else { cerr << " "; }
   }
 }
};

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

  int n, q;
  cin >> n >> q;
  SegTree<int, int> seg(
    n,
    [](int a, int b){ return std::min(a, b); },
    [](int a, int b){ return b; },
    [](int a, int b){ return b; },
    INT_MAX,
    -1);
  rep(i, q) {
    int t;
    cin >> t;
    if (t == 0) {
      int a, b, x;
      cin >> a >> b >> x;
      seg.update(a, b + 1, x);
    }
    else {
      int a, b;
      cin >> a >> b;
      cout << seg.query(a, b + 1) << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 4976
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];

  ll ans = 0;
  rep(l, 0, k + 1) {
    rep(r, 0, k - l + 1) {
      if (l + r > n)
        continue;
      int d = k - l - r;
      ll now = 0;
      vector<int> x;
      rep(i, 0, l) {
        now += v[i];
        x.push_back(v[i]);
      }
      rep(i, n - r, n) {
        now += v[i];
        x.push_back(v[i]);
      }
      sort(x.begin(), x.end());
      rep(i, 0, d) {
        if (i >= x.size())
          break;
        if (x[i] > 0)
          break;
        now -= x[i];
      }
      chmax(ans, now);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]
b*=10**5+1
for i in a:
    b[i]+=1
ans=sum(a)
q=int(input())
for i in range(q):
    bi,ci=map(int,input().split())
    d=b[bi]
    b[ci]+=d
    b[bi]=0
    ans=ans+d*(ci-bi)
    print(ans)

Measured memory_bytes: 21056
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[100], tmp[100];
int top;
int n, nn;
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	nn = n;
	for (int i = 1; i <= nn; i++) {
		if (s[i] != s[nn - i + 1]) {
			puts("No");
			return 0;
		}
	}
	nn = (n - 1) / 2;
	for (int i = 1; i <= nn; i++) {
		if (s[i] != s[nn - i + 1]) {
			puts("No");
			return 0;
		}
	}
	nn = (n + 3) / 2;
	for (int i = nn; i <= n; i++) {
		tmp[++top] = s[i];
	}
	for (int i = 1; i <= top; i++) {
		if (tmp[i] != tmp[top - i + 1]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

const int MAX_N=100;
int n,x,y,z,pos;
bool an[MAX_N+1]={},bn[MAX_N+1]={},cn[MAX_N+1]={};

int main(){
	cin >> n;
	cin >> x;
	for(int i=0;i<x;i++){
		cin >> pos;
		an[pos]=true;
	}
	cin >> y;
	for(int i=0;i<y;i++){
		cin >> pos;
		bn[pos]=true;
	}
	cin >> z;
	for(int i=0;i<z;i++){
		cin >> pos;
		cn[pos]=true;
	}
	int s=0;
	for(int i=0;i<n+1;i++){
		if(cn[i]&&!an[i]) s++;
		else if(cn[i]&&bn[i]) s++;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    int r;
    cin >> r;
    long double ans = 0;

    ans = (long double)(2 * r) * M_PI;
    cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
const ll Mod = 1000000007;
int main() {
  int Q;
  cin >> Q;
  multiset<ll> Set;
  int _1,aa,bb;
  cin >> _1 >> aa >> bb;
  ll bsum = bb;
  ll asum = 0;
  Set.insert(aa);
  auto itr = Set.begin();
  ll left = 0;
  ll right = 0;
  for (int i = 0; i < Q-1; i++) {
    int mode;
    cin >> mode;
    if (mode == 1) {
      ll a,b;
      cin >> a >> b;
      bsum += b;
      if ((int)Set.size() % 2 == 0) {
        Set.insert(a);
        if (a >= *itr) {
          auto itr2 = next(itr,1);
          asum += (ll)(*itr2 - *itr) * (left + 1);
          asum -= (ll)(*itr2 - *itr) * (right);
          left++;
          itr = itr2;
        } else {
          left++;
        }
        asum += abs((ll)*itr - a);
      } else {
        Set.insert(a);
        if (a < *itr) {
          auto itr2 = prev(itr,1);
          asum -= (ll)(*itr - *itr2) * (left);
          asum += (ll)(*itr - *itr2) * (right + 1);
          right++;
          itr = itr2;
        } else {
          right++;
        }
        asum += abs((ll)(*itr) - a);
      }
    } else if (mode == 2) {
      ll ans = asum + bsum;
      ll x = (ll)(*itr);
      cout << x << " " << ans << endl;
    }
  }
  return 0;
}

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

using namespace std;

int main() {
    char c;
    cin >> c;
    switch (c) {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u': {
            cout << "vowel" << endl;
            break;
        }
        default: {
            cout << "consonant" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 36

typedef struct{
  char pic;
  int num;
}TRUMP;

void input(TRUMP [], int);
void display(TRUMP [], int);
void swap(TRUMP *, TRUMP *);
void copy(TRUMP [], TRUMP [], int);
int isSame(TRUMP [], TRUMP [], int);
void selectionSort(TRUMP[], int);
void bubbleSort(TRUMP[], int);

int main(){
  int N;
  TRUMP A[MAX];
  TRUMP B[MAX];
  
  scanf("%d", &N);
  
  input(A, N);
  copy(A, B, N);

  bubbleSort(A, N);
  selectionSort(B, N);

  display(A, N);

  printf("Stable\n");
  
  display(B, N);

  if(isSame(A, B, N)) printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}

void input(TRUMP A[], int N) {
  int i;

  for (i = 0; i < N; i++) {
    scanf(" %c%d", &A[i].pic, &A[i].num);
  }
}

void display(TRUMP A[], int N) {
  int i;
  for (i = 0; i < N; i++) {
    if (i) printf(" ");
    printf("%c%d",A[i].pic, A[i].num);
  }
  printf("\n");
}

void swap(TRUMP *x, TRUMP *y) {
  TRUMP temp;
  temp = *x;
  *x = *y;
  *y = temp;
}

void copy(TRUMP A[], TRUMP B[], int N) {
  int i;
  for (i = 0; i < N; i++) {
    B[i] = A[i];
  }
}

int isSame(TRUMP A[], TRUMP B[], int N) {
  int i;
  for (i = 0; i < N; i++) {
    if(B[i].num != A[i].num) return 0;
    if(B[i].pic != A[i].pic) return 0;
  }
  return 1;
}

void selectionSort(TRUMP A[], int N) {
  int i, j, tmp, cnt = 0;
  int minj;
  
  for (i = 0; i < N; i++) {
    minj = i;
    for (j = i; j < N; j++) {
      if (A[j].num < A[minj].num) {
	minj = j;
      }
    }
    if (i != minj) {
      swap(&A[i], &A[minj]);
      cnt++;
    }
  }
}

void bubbleSort(TRUMP A[], int N) {
  int i, cnt = 0;
  int flag = 1;
  
  while (flag) {
    flag = 0;
    for (i = N - 1; 0 < i; i--) {
      if (A[i].num < A[i - 1].num) {
	swap(&A[i], &A[i - 1]);
	cnt++;
	flag = 1;
      }
    }
  }
}



Measured memory_bytes: 2104
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,a[12] = {1,3,5,7,9,11,15,17,19,21,23,25};
  cin >>n;
  cin.ignore();
  while(n--){
    string s;
    getline(cin,s);
    for(int i=0; i<12; i++){
      for(int j=0; j<26; j++){
	string f = s;
	for(int k=0; k<s.size(); k++){
	  if(f[k] >= 'a' && f[k] <= 'z'){f[k] = (a[i]*(f[k]-'a')+j)%26+'a';}
	}
	string::size_type pos_this = f.find("this");
	string::size_type pos_that = f.find("that");
	if(pos_this != string::npos){cout <<f<<endl;}
	if(pos_that != string::npos){cout <<f<<endl;}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
vector<int> V;
int main()
{
  int N,M;
  cin>>N>>M;
  int Sum=0;
  while(N--)
  {
    int X;
    cin>>X;
    Sum+=X;
    V.push_back(X);
  }
  sort(V.rbegin(),V.rend());
  if(V[M-1]>=(Sum+(4*M)-1)/(4*M))
    puts("Yes");
  else	puts("No");
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

public static partial class Program
{
    public static void Main()
    {
        var abt = CRL().ArrayInts();
        var a = abt[0];
        var b = abt[1];
        var t = abt[2];

        var val = 0;
        for (int i = a; i <= t; i++)
        {
            if (i % a == 0)
            {
                val += b;
            }
        }

        CWL(val);
    }
}

public static partial class Program
{
    //テンプレここから
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static string RL() => ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static void WL(object obj) => WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] {0, -1, 0, 1};
    public static long[] dy = new long[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);

    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    //テンプレここまで
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,k;
    cin>>n>>k;
    ll p[n];
    for(ll i=0; i<n; i++)
        cin>>p[i];
    sort(p, p + n);
    ll ans = 0;
    for(ll i=0; i<k; i++)
        ans += p[i];
    cout<<ans<<'\n';
}

Measured memory_bytes: 3640
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
P=LIST()

cnt=0
for i in range(1, N-1):
    if P[i+1]<P[i] and P[i]<P[i-1] or P[i-1]<P[i] and P[i]<P[i+1]:
        cnt+=1
print(cnt)


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(){
	int a,b,c,i;
	i=0;
	while(cin>>a>>b){
	c=a+b;
	while(c>0){
	c /= 10;
	i += 1;
	}
	cout<<i<<endl;
	i=0;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22)puts("bust"); else {
		puts("win");
	}
	return 0;
}

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


int main(){
    int a, b;
    char  op;
    int c;
    while(1){ 
        int d; 
//        cin >> a >> op >> b;
        scanf("%d %c %d", &a, &op, &b);
//       if(&op == "+"){
       if(strncmp(&op, "?", 1) == 0)
        {break;}
       else if(strncmp(&op, "+", 1) == 0){
           c = a + b;
           } 
       else if(strncmp(&op, "-", 1) == 0){
           c = a - b;
        }
       else if(strncmp(&op, "*", 1) == 0){
           c = a * b;
        }
       else if(strncmp(&op, "/", 1) == 0){
           c = a / b;
        }
       cout << c << endl;
    }
return 0;
}

Measured memory_bytes: 1208
def main():
    n = int(raw_input())
    m = [ [0] * n for _ in xrange(n)]
    p = [ 0 for _ in xrange(n+1)]
    for i in xrange(n):
        a = map(int, raw_input().split())
        if i == 0:
            p[0] = a[0]
            p[1] = a[1]
        else:
            p[i+1] = a[1]

    for l in xrange(2,n+1):
        for i in xrange(0,n-l+1):
            j = i + l -1
            m[i][j] = float('inf')
            for k in xrange(i,j):
                m[i][j] = min(m[i][j], m[i][k]+m[k+1][j] + p[i-1]*p[k]*p[j])
    
    print m[0][n-1]
    return 0

main()

Measured memory_bytes: 6508
#include <cstdio>

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

  int res = 0;
  for (int i = A; i <= B; ++i) {
    if (i % 10 != i / 10000) continue;
    if ((i % 100) / 10 != (i / 1000) % 10) continue;
    ++res;
  }
  printf("%d\n", res);
}

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

#define INF -(1<<20)

int max(int len, ...) {
    int i, _max, num;
    va_list ap;
    va_start(ap, len);

    _max = va_arg(ap, int);
    for (i = 1; i < len; i++) {
        num = va_arg(ap, int);
        if (num > _max)
            _max = num;
    }
    va_end(ap);
    return _max;
}

int C[10] = {0,2,5,5,4,5,6,3,7,6};

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main(void) {
    int flag, i, j, K, min, N, M, A[10], AS[10], dp[100010];
    scanf("%d%d", &N, &M);
    for (i=1;i<=M;i++) scanf("%d",&A[i]);

//    memmove(AS,A,sizeof(int)*10);

    dp[0] = 0;
    flag = 0;
    for (i=1;i<=N;i++) {
        dp[i] = INF;
        for (j=1;j<=M;j++) {
            if (i-C[A[j]] >= 0) {
                dp[i] = max( 2, dp[i], dp[i-C[A[j]]] );
                flag = 1;
            }
        }
        if (flag) dp[i] += 1;
    }

    K = N;
    memmove(AS,A,sizeof(int)*10);
    qsort(AS+1,9,sizeof(int),desc);
    while (K>0) {
        for (j=1;j<=M;j++) {
//            printf("%d %d\n", K, K-C[AS[j]]);
            if (K-C[AS[j]] >= 0) { //printf(" %d %d\n", dp[K], dp[K-C[AS[j]]]);
                if (dp[K] == dp[K-C[AS[j]]] + 1) {
                    printf("%d", AS[j]); 
                    K -= C[AS[j]];
                    break;
                }
            }
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i,j;
    int ans;
    
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            ans=j*i;
            printf("%dx%d=%d\n",i,j,ans);
        }
    }
    
    return 0;
}

Measured memory_bytes: 524
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, M;
  string s;
  map<string, int> mp_b, mp_r;
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> s;
    if(mp_b.find(s) != mp_b.end()) mp_b[s]++;
    else mp_b.insert( make_pair(s, 1) );
  }
    
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> s;
    if(mp_r.find(s) != mp_r.end()) mp_r[s]++;
    else mp_r.insert( make_pair(s, 1) );
  }

  int ans = 0;
  for (auto itr = mp_b.begin(); itr != mp_b.end(); itr++) {
    int tmp;
    if(mp_r.find(itr->first) != mp_r.end()) tmp = itr->second - mp_r[itr->first];
    else tmp = itr->second;
    ans = max(ans, tmp);
  }

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


Measured memory_bytes: 256
/**
 *    Author:  "Robin Singh" !!!!    
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return 
#define itt(a)   __typeof((a).begin())
#define RT  (cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n")  // Run Time
#define nl "\n"  // New Line
#define dbg(x) (cerr << #x << " = " << x << "  ")
#define enl (cerr << "\n")
#define dbgg(x,y) (cerr << #x << " = " << x << " -> " << #y << " = " << y << "\n")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const int inf = (1<<30);
const ll INF = (1LL<<61);

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, mx = 0;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            mx = max(mx, abs(a[i]-a[j]));
        }
    }
    cout << mx;
    return 0;
}

Measured memory_bytes: 256
/**
*   @Author : MeGaCrazy
*   @InitTime : Sun Dec 30 19:19:39 2018
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
int fact[1001];
int cal(int n){
        for(int i=2;i*i<=n;i++){
       while(n%i==0){
       	  fact[i]++;
       	  n/=i;
       }
   }
   if(n>1){
   	fact[n]++;
   }



}
int main(){
#ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
   int n;
   cin>>n;
   for(int i=2;i<=n;i++){
   	cal(i);
   }
   int ans=1;
   for(int i=2;i<=n;i++){
       if(fact[i]>0){
       	    ans=(1ll*ans*(fact[i]+1))%(int)(1e9+7);
       }
   }
   cout<<ans<<endl;





}

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}



int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    ll n,d;
    cin>>n>>d;
    d=sq(d);

    ll ans=0;

    for(ll i=0;i<n;i++)
    {
    	ll x,y;
    	cin>>x>>y;
    	ll dist=sq(x)+sq(y);
    	ans+=(dist<=d);
    }

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

Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
	string str;
	cin>>str;
	int l=str.size();
	int s=l-2;
	cout<<str[0]<<s<<str[l-1]<<endl;
	return 0;
}

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

int main() {
	int n, count=1; string s;
	cin>>n>>s;
	for(int i=1;i<n;i++){
		if(s[i]!=s[i-1]) count++;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 512
#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 n;
	cin >> n;
	int x = floor(sqrt(n));
	cout << x * x << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		int m1 = sc.nextInt(); 
      	int d1 = sc.nextInt();
      	int m2 = sc.nextInt();
      	int ans = 0;
      
      	if(m1 != m2) ans = 1;
      	
      	System.out.println(ans);
        
	}
}


Measured memory_bytes: 35512
const main = lines => {
  console.log(solve(lines));
};

const solve = (lines: string[]): string => {
  const [S, T] = parseLines(lines);

  var cnt = 0;

  for (let i = 0; i < 3; i++) {
    if (S.charAt(i) === T.charAt(i)) cnt++;
  }

  return cnt.toString();
};

const parseLines = (lines: string[]) => {
  const obj = lines;
  debug(obj);
  return obj;
};

const debug = (message?: any, ...optionalParams: any[]) => {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
};

if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}

export default solve;


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

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

    int ans = 0;

    for (int i = 1; i <= N; i++) {
        int k = i;
        int s = 0;
        while (k > 0) {
            s += k % 10;
            k /= 10;
        }
        if (s >= A && s <= B) ans += i;
    }

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

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
use std::cmp::Ordering;
 
use std::cmp;
use std::cmp::min;
use std::collections::BTreeMap;
use std::process;
use std::cmp::Ord;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::collections::BTreeSet;
use std::mem;
 
use std::ops::{Deref, DerefMut, Index, IndexMut};
use std::any::{Any, TypeId};

fn main(){
    input!{
        n:usize,
        t:[i64;n],
        v:[i64;n],
    }
    let mut t = t.clone();
    let mut v = v.clone();
    t.reverse();
    t.push(0);
    t.reverse();
    v.reverse();
    v.push(0);
    v.reverse();

    let mut n = n;
    let mut i = 0;
    let mut j:i64 = 0;
    let mut mv = 0;
    let mut to = 0;
    let mut s = 0;
    let mut z = vec![0;40010];
    for i in 0..t.len(){
        t[i] = t[i]*2;
        v[i] = v[i]*2;
    }

    for i in 1..n+1{
        to+=t[i];
        z[j as usize] = cmp::min(z[j as usize], v[i]);
        j+=1;
        while((j as i64)<=to){
            z[j as usize] = cmp::min(z[(j-1) as usize]+1, v[i]);
            j+=1;
        }
        j-=1;
    }
    for l in (1..j).rev(){
        mv = cmp::min(z[l as usize], mv+1);
        s+=mv;
    }
    println!("{}", (s as f64)/4.0);

}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	int a,x=0;
	cin>>a;
	int b[a];
	forr(i,0,a)
		cin>>b[i], x^=b[i];
	forr(i,0,a)
	{
		cout<<(x^b[i])<<' ';
	}	
	
	return 0; 	
}

Measured memory_bytes: 4272
#include <stdio.h>

/* constant */

#define MAX_N   (30)
#define MAX_P   (1000000)
#define S_MAX_P (1000)

/* global variables */

static int menu[MAX_N];
static char primes[MAX_P + 1];
static char sums[MAX_P + 1];

/* subroutines */

void gen_primes() {
  int p, q;

  primes[0] = primes[1] = 0;
  for (p = 2; p <= MAX_P; p++) primes[p] = 1;

  for (p = 2; p <= S_MAX_P; p++)
    if (primes[p])
      for (q = p * p; q <= MAX_P; q += p)
        primes[q] = 0;
}

/* main */

int main() {
  int i, j, max_j, max_sum, n, pr, x;

  gen_primes();

  while (1) {
    scanf("%d %d", &n, &x);
    if (n == 0 && x == 0) break;

    for (i = 0; i <= x; i++) sums[i] = 0;

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

    for (i = 0; i < n; i++) {
      pr = menu[i];
      max_j = x - pr;
      for (j = 0; j <= max_j; j++)
        if (sums[j]) sums[j + pr] = 1;
    }

    max_sum = 0;

    for (j = x; j >= 0; j--)
      if (sums[j] & primes[j]) {
        max_sum = j;
        break;
      }

    if (max_sum > 0)
      printf("%d\n", max_sum);
    else
      puts("NA");
  }

  return 0;
}

Measured memory_bytes: 2564
#include<stdio.h>
int main(){
  int n,max=0,i,b,v,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&b,&v);
    if(max<v||(max==v&&c>b)){
      max=v;
      c=b;
    }
  }
  printf("%d %d\n",c,max);
  return 0;
}

Measured memory_bytes: 600
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, a, b; cin >> n >> a >> b;
    ll ans = 0;

    if(a > b) ans = 0;
    else if(n == 1 && a == b) ans = 1;
    else if(n == 1 && a != b) ans = 0;
    else ans = (b - a) * (n - 2) + 1;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <sstream>  
#include <string>


int main()
{
    std::stack<int> Stack;
    // while(std::cin.eof() == false){
    // while(std::cin){
    while(true){
        std::string in;
        std::cin >> in;
        if(std::cin.good() == false){
            break;
        }
        switch(in[0]){
        case '+':{
            int a = Stack.top();
            Stack.pop();
            int b = Stack.top();
            Stack.pop();
            Stack.push(b + a);
            break;
        }
        case '-':{
            int a = Stack.top();
            Stack.pop();
            int b = Stack.top();
            Stack.pop();
            Stack.push(b - a);
            break;
        }
        case '*':{
            int a = Stack.top();
            Stack.pop();
            int b = Stack.top();
            Stack.pop();
            Stack.push(b * a);
            break;
        }
        default:{
            int Num;
            std::stringstream ss;
            ss << in;
            ss >> Num;
            Stack.push(Num);
            break;
        }
        }
    }
    std::cout << Stack.top() << std::endl;
    return 0;
}

Measured memory_bytes: 1228
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int t, x;
	cin >> t >> x;
	cout << 1.0 * t / x << endl;
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		string s;
		cin >> n >> s;
		for(int i=0; i < s.length(); i++){
			s[i] = (s[i] - 'A' + n) % 26 + 'A';
		}
		cout << s << "\n";
		
		return;
	};
};

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int T; cin >> T;
    while (T--) {
        int N, D; cin >> N >> D;
        if (N % 2 == 0) D ^= 127;
        cout << 127 * (N - 1) + D << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>

using namespace std;

int main()
{
    long n, m;
    cin >> n >> m;

    if (n > m / 2) {
        cout << m/2 << endl;
    } else {
        cout << (n * 2 + m)/4 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

type burger struct {
	P, B, Sum int
}

func count(N, X, tmp int, L []burger) int {
	if N == 0 {
		return tmp + 1
	}

	if X == 1 {
		return tmp
	} else if X < (L[N].Sum/2 + 1) {
		return count(N-1, X-1, tmp, L)
	} else if X == (L[N].Sum/2 + 1) {
		return tmp + L[N-1].P + 1
	} else if X < L[N].Sum {
		return count(N-1, X-L[N-1].Sum-2, tmp+L[N-1].P+1, L)
	}
	return tmp + L[N].P

}

func main() {
	var N, X int
	fmt.Scan(&N, &X)

	L := make([]burger, N+1)
	L[0].P, L[0].B, L[0].Sum = 1, 0, 1
	for i := 1; i <= N; i++ {
		L[i].P, L[i].B, L[i].Sum = 2*L[i-1].P+1, 2*L[i-1].B+2, 2*L[i-1].Sum+3
	}

	ans := count(N, X, 0, L)
	fmt.Println(ans)
}


Measured memory_bytes: 1860
#import <stdio.h>
#import <limits.h>
#define MIN(a,b) ((a)<(b)?(a):(b))
int main() {
    long N;
    scanf("%ld",&N);
    char S[300002] = {'\0'};
    scanf("%s",S);
    long L[300002] = {0L};
    long R[300002] = {0L};
    for(long i=1;i<N;i++){
       L[i] = L[i-1] + ((S[i-1] == 'W') ? 1 : 0);
       R[N-1-i] = R[N-i] + ((S[N-i] == 'E') ? 1 : 0);
    }
    long min = LONG_MAX;
    for(long i=0;i<N;i++){
       min = MIN(min,L[i]+R[i]);
    }
    printf("%ld",min);
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library
//

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int a, b; cin >> a >> b;
    int ans = max(a + b, a - b);
    ans = max(ans, a * b);
    cout << ans << endl;
}



Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int P[170000];
int kuro[170000];

int Find(int A) {
	if (P[A] == A) return A;
	else {
		P[A] = Find(P[A]);
		return P[A];
	}
}

void Union(int A, int B) {
	int a = Find(A);
	int b = Find(B);
	if (a != b) {
		P[b] = a;
		kuro[a] += kuro[b];
	}
}

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


	int H, W;
	cin >> H >> W;
	string S[400];
	rep(i, H) cin >> S[i];

	rep(i, 170000) P[i] = i;
	rep(i, H) rep(j, W) if(S[i][j] == '#') kuro[i * W + j] = 1;


	rep(i, H - 1) rep(j, W) {
		int k = i * W + j;
		if (S[i][j] != S[i + 1][j]) Union(k, k + W);
	}
	rep(i, H) rep(j, W - 1) {
		int k = i * W + j;
		if (S[i][j] != S[i][j + 1]) Union(k, k + 1);
	}

	ll kotae = 0;
	rep(i, H) rep(j, W) {
		if (S[i][j] == '.') {
			kotae += kuro[Find(i * W + j)];
		}
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1792
// ABC065B - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

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

	int ans = 0;
	int index = 1;
	while (1) {
//		cout << ans << ":" << index << endl;
		if (ans >= N) {
			cout << -1 << endl;
			return 0;
		}
		++ans;
		index = a[index];
		if (index == 2) {
			cout << ans << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');
            int i;
            int[] num = new int[N];
            bool[] flag = new bool[N];
            int chance = N;
            int max=0;
            int sum=0;
            int biggest=0;

            for(i=0;i < N; i++)//代入
            {
                num[i] = int.Parse(a[i]);
            }

            while (true)
            {
                biggest = 0;
                for (i = 0;i<N; i++)
                {
                    if(num[i] > biggest && !flag[i])
                    {
                        max = i;
                        biggest = num[i];
                    }
                }
                sum += num[max];flag[max] = true;
                if (--chance == 0) { break; }

                biggest = 0;
                for (i = 0; i < N; i++)
                {
                    if (num[i] > biggest && !flag[i])
                    {
                        biggest = num[i];
                        max = i;
                    }
                }
                sum -= num[max]; flag[max] = true;
                if (--chance == 0) { break; }
            }
            Console.WriteLine(sum);


        }
    }
}


Measured memory_bytes: 11092
name1, a1, b1=input().split()
name2, a2, b2=input().split()
name3, a3, b3=input().split()
name4, a4, b4=input().split()
name5, a5, b5=input().split()
name6, a6, b6=input().split()
name7, a7, b7=input().split()
name8, a8, b8=input().split()
name9, a9, b9=input().split()

print(name1 , int(a1)+int(b1) , int(a1)*200+int(b1)*300)
print(name2 , int(a2)+int(b2) , int(a2)*200+int(b2)*300)
print(name3 , int(a3)+int(b3) , int(a3)*200+int(b3)*300)
print(name4 , int(a4)+int(b4) , int(a4)*200+int(b4)*300)
print(name5 , int(a5)+int(b5) , int(a5)*200+int(b5)*300)
print(name6 , int(a6)+int(b6) , int(a6)*200+int(b6)*300)
print(name7 , int(a7)+int(b7) , int(a7)*200+int(b7)*300)
print(name8 , int(a8)+int(b8) , int(a8)*200+int(b8)*300)
print(name9 , int(a9)+int(b9) , int(a9)*200+int(b9)*300)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define int long long
using namespace std;

int n ,q,k;
const int N = 1e5 + 100;
vector<pair<int,int>> g[N];
int dist[N];

void dfs(int node , int par , int dis){

      dist[node] = dis;

      for(auto child : g[node]){
            
            if(child.first != par){
                  dfs(child.first , node , dis + child.second);
            }
      }

}


int32_t main(){

      cin >> n;
      for(int x=1;x<n;x++){
            int u , v , w;    cin >>  u >> v >> w;
            g[u].push_back({v , w});
            g[v].push_back({u , w});
      }

      cin >> q >> k;

      dfs(k , 0 , 0);

      for(int x = 0; x < q; x++){
            int u , v;  cin >> u >> v;
            cout << (dist[u] + dist[v]) << endl;
      }

     
     return 0;
}

Measured memory_bytes: 14336
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}

int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//これは昇べきの順のソート

//int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
//これは降べきの順のソート

//qsort(配列, 長さ, sizeof(int), compare_int);

double BS(int array[],int len,int target);

//////////////////////////////////////////

int a[5];
int now;

int main(){
    int n = 10;
    int keep = 0;
    for(int i = 0;i < 5;i++){
        scanf("%d",&a[i]);
        if(n > (a[i]-1)%10){
            n = (a[i]-1)%10;
            keep = i;
        }
    }
    //printf("%d\n",n);
    now = 0;
    for(int i = 0;i < 5;i++){
        if(i == keep){
            now += a[i];
            //printf("%d\n",a[i]);
        }else{
            now += ((a[i]+9)/10)*10;
        }
    }
    
    printf("%d\n",now);
    
    return 0;
}



///////////////////////////////////////////


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

int x, y;

int main()
{
	scanf("%d %d", &x, &y);
	if (x % y == 0) printf("-1\n");
	else printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    long long a, b, n;
    cin >> n >> a >> b;
    long long tmp, tmp2;
    tmp = n / (a + b);
    tmp2 = n % (a + b);
    long long ans;
    ans = tmp * a;
    if(tmp2 >= a){
        tmp2 = a;
    }
    ans += tmp2;
    cout << ans << endl;
    
    solve();
    return 0;
}



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

void Main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> c(h, vector<int>(w));
    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++)
        {
            c[i][j] = s[j] == '#' ? 1 : 0;
        }
    }
    int sum = 0;
    for (int i = 0; i < 1<<h; i++)
    {
        for (int j = 0; j < 1<<w; j++)
        {
            int kuro = 0;
            for (int k = 0; k < h; k++)
            {
                for (int l = 0; l < w; l++)
                {
                    if(i>>k & 1 && j>>l & 1 && c[k][l]) kuro++;
                }
                
            }
            if(kuro == k) sum++;
        }
    }
    cout << sum << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3676