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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

    int n; cin >> n;
    cout << pow(n, 3) << endl;

    return 0;
}


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

const ll mod = 1e9+7;


int main() {

    string s;
    cin>>s;
    map<char,ll> m;
    for(ll i=0;s[i];i++){
        m[s[i]]++;
    }
    for(auto i:m){
        if(i.second%2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
n, m = map(int, input().split())
ans = [list(input().split()) for i in range(m)]
ac = [0 for i in range(n)]
penali = [0 for i in range(n)]

a = 0

for s,t in ans:
    if t== 'WA' and ac[int(s)-1] == 0:
        penali[int(s)-1] += 1
    if t == 'AC':
        if ac[int(s)-1] == 0:
            a +=1
        ac[int(s)-1] = 1

for i in range(n):
    if ac[i] == 0:
        penali[i] = 0

pena = 0
for i in penali:
    pena += i

print(a, pena)

Measured memory_bytes: 27544
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int a,b;
    cin >> a >> b;
    char grid[100][100];
    rep(i,50)rep(j,100){
        grid[i][j]='.';
        grid[i+50][j]='#';
    }
    int cntw=1,cntb=1;
    int cnt=0;
    while(cntb<b){
        grid[(cnt/50)*2][(cnt%50)*2]='#';
        cntb++;
        cnt++;
    }
    cnt=0;
    while(cntw<a){
        grid[99-(cnt/50)*2][cnt%50*2]='.';
        cntw++;
        cnt++;
    }
    printf("100 100\n");
    rep(i,100){
        rep(j,100){
            cout << grid[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregio

class UnionFind
{
private:
  vector<int> par, sizes;

public:
  UnionFind(int n = 200010) : par(n), sizes(n, 1)
  {
    rep(i, n) par[i] = i;
  }

  int root(int x)
  {
    if (x == par[x])
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
      return;
    if (sizes[x] < sizes[y])
      swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y)
  {
    return root(x) == root(y);
  }

  int size(int x)
  {
    return sizes[root(x)];
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  ll n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  ll cnt[100010] = {};
  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    uf.unite(a, b);
    cnt[a]--;
    cnt[b]--;
  }
  rep(i, k)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (uf.same(a, b))
      cnt[a]--;
    if (uf.same(a, b))
      cnt[b]--;
  }
  rep(i, n)
  {
    cnt[i] += uf.size(i) - 1;
  }
  rep(i, n) cout << cnt[i] << (i == n - 1 ? "\n" : " ");
  return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

int w, h;
char field[100][100];

int dfs(int x, int y) {
  if (field[y][x] == '#') { return 0; }
  field[y][x] = '#';
  int ret = 1;
  const int dx[4] = { 1, -1, 0, 0 };
  const int dy[4] = { 0, 0, 1, -1 };
  REP(i, 4) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    ret += dfs(nx, ny);
  }
  return ret;
}

int main() {
  while (scanf("%d %d", &w, &h), w|h) {
    MEMSET(field, '#');
    int sx, sy;
    FOR(y, 1, h + 1) FOR(x, 1, w + 1) {
      scanf(" %c ", &field[y][x]);
      if (field[y][x] == '@') {
        field[y][x] = '.';
        sx = x; sy =y;
      }
    }
    printf("%d\n", dfs(sx, sy));
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int T = sc.nextInt();

		int max = 0;
		int[] a = new int[T];
		for (int i = 0; i < T; i++) {
			a[i] = sc.nextInt();
			max = Math.max(a[i], max);
		}
		sc.close();

		int ans = 0;
		if (max <= K - max + 1) {
			ans = 0;
		} else {
			ans = 2 * max - K - 1;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 9936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll n,r;
	cin>>n>>r;
	if(n>=10){
		cout <<r;
	}
	else{
		cout << r+100*(10-n);
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3552
#include <stdio.h>
 
#define Max 1000000
 
void printA(int A[Max], int N) {
    int i;
 
    for (i = 0; i < N - 1; i++)
        printf("%d ", A[i]);
    printf("%d\n", A[i]);
}
 
int insertionSort(int A[Max], int N, int g) {
    int i, j, v;
    int cnt = 0;
 
    for (i = g; i < N; i++) {
        v = A[i];
        j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
 
    return cnt;
}
 
void shellSort(int A[Max], int N) {
    int i = 0;
    int cnt = 0;
    int m = 0;
    int box[20];
    int G[Max];
 
 
    box[0] = 1;
    for (i = 1; i < 20; i++) box[i] = 3 * box[i - 1] + 1;
 
    for (i = 20 - 1; i >= 0; i--) {
        if (box[i] <= N) G[m++] = box[i];
    }
 
    printf("%d\n", m);
 
    printA(G, m);
 
    for (i = 0; i < m; i++) cnt += insertionSort(A, N, G[i]);
 
    printf("%d\n", cnt);
 
    for (i = 0; i < N; i++) printf("%d\n", A[i]);
}
 
int main( ) {
    int N, i, j;
    int A[Max];
 
    scanf("%d", &N);
 
    for (i = 0; i < N; i++) scanf("%d", &A[i]);
 
    shellSort(A, N);
 
    return 0;
}

Measured memory_bytes: 4508
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, m, c;
  cin >> n >> m >> c;
  vi b(m);
  rep(i,m) cin >> b[i];
  vvi a(n,vi(m));
  rep(i,n)rep(j,m) cin >> a[i][j];

  int ans = 0;
  rep(i,n) {
    int sum = c;
    rep(j,m) {
      sum += a[i][j]*b[j];
    }
    if (sum > 0) ans++;
  }

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

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define INF 1000000000
#define pb push_back
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define tr(c, i) for (typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())

ll bigmod(ll a, ll b, ll m)
{

    if (b == 0)
        return 1;
    ll x = bigmod(a, b / 2, m);
    x = (x * x) % m;

    if (b % 2)
        x = (x * a) % m;
    return x;
}

ll bigsum(ll a, ll b, ll m)
{
    ll s;
    if (b == 0)
        return b;
    if (b == 1)
        return a + 1;
    if (b % 2)
    {
        b = b / 2;
        s = bigsum(a, b, m) % m;
        s = (s * bigmod(a, b + 1, m)) % m;
        return s;
    }
    else
    {
        s = bigsum(a, b - 1, m) % m;
        s = (a * s + 1) % m;
        return s;
    }
}


int main()
{
    ll d,t,s;
    cin>>d>>t>>s;

    if(t*s>=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

     
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> point(N);
  for(int i=0;i<N;i++){
    cin >> point.at(i);
  }
  
  sort(point.begin(), point.end());
  reverse(point.begin(), point.end());
  
  int alice=0, bob=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      alice += point.at(i);
    }else{
      bob += point.at(i);
    }
  }
  
  cout << alice - bob << endl;
  
  return(0);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    Integer n = Integer.parseInt(r.readLine());
    int[] c = new int[555];
    int[] s = new int[555];
    int[] f = new int[555];
    int[] a = new int[555];
    int goal = n;


    for(int i = 1; i < n; i++)
    {
      String[] z = r.readLine().split("[\\s]+");
      c[i] = Integer.parseInt(z[0]);
      s[i] = Integer.parseInt(z[1]);
      f[i] = Integer.parseInt(z[2]);
    }


    for(int start = 1; start <= goal; start++)
    {
      a[start] = 0;
      int now = 0;
      //System.out.println("start : " + start);

      for(int pos = start; pos < goal; pos++)
      {
        //System.out.println("pos : " + pos + "     now : " + now);
        if(now < s[pos])
        {
          now = s[pos] + c[pos];
        }
        else if(now % f[pos] == 0)
        {
          now += c[pos];
        }
        else
        {
          now += f[pos] - (now % f[pos]) + c[pos];
        }
      }
      //System.out.println("     now : " + now);

      a[start] = now;
    }

    for(int start = 1; start <= goal; start++)
    {
      System.out.println(a[start]);
    }
  }
}


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

using i64 = int64_t;

int main(){
    int n, q;
    while(cin >> n >> q, n != 0){
        map<string, pair<int, int>> mp;
        for(int i=0;i<n;++i){
            string name;
            int era, western;
            cin >> name >> era >> western;
            mp[name].first = western - era + 1;
            mp[name].second = max(mp[name].second, western);
        }
        for(int i=0;i<q;++i){
            int q;
            cin >> q;
            bool found = false;
            pair<string, int> ans;
            for(auto e: mp){
                if(e.second.first <= q && e.second.second >= q){
                    found = true;
                    ans.first = e.first;
                    ans.second = q - e.second.first + 1;
                    break;
                }
            }
            if(found){
                cout << ans.first << " " << ans.second << endl;
            }else{
                cout << "Unknown" << endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3180
#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {

	int n, m;
	int a[100][100], b[100],c[100];

	//n,m?????\???
	cin >> n >> m;

	//a,b,c?????????????¢????(malloc???????????´???)
	/*
	a = (int **)malloc(sizeof(int)*n);
	for (int i = 0; i < n; i++) {
		a[i] = (int *)malloc(sizeof(int)*m);
	}
	b = (int *)malloc(sizeof(int)*m);
	c = (int *)malloc(sizeof(int)*m);
	if (a == NULL || b == NULL||c==NULL) {
		cout << "malloc error" << endl;
		exit(1);
	}
	*/

	//???????????°
	//cout << "n=" << n << " m=" << m << endl;

	//a?????\???
	for (int i = 0; i < n; i++) {
		//cout << "i=" << i << endl;
		for (int j = 0; j < m; j++) {
			//cout << "j=" << j << endl;
			cin >> a[i][j];
		}
	}

	//b?????\???
	for (int j = 0; j < m; j++) {
		cin >> b[j];
	}

	//???????¨?????????¨?????????
	for (int i = 0; i < n; i++) {
		c[i] = 0;
		for (int j = 0; j < m; j++) {
			c[i] += a[i][j] * b[j];
		}
		cout << c[i] << endl;
	}

	//?????¢????§£???(malloc???????????´???)
	/*
	for (int i = 0; i < n; i++) {
		free(a[i]);
	}
	free(a);
	free(b);
	*/

	return 0;
}

Measured memory_bytes: 3092
sub f{my$r=my$s=$v[$_]=1;my$p=$h[my$c=$c[$_-1]-1];$v[$_]or$a[$c]+=($;=($r+=$t=f())-$s-$h[$c]+$p)*$s,$s+=$;for@$_;$a[$c]+=($p+$r-$h[$c])*(@a-($h[$c]=$p+$r))+1;$r}$_=@a=(0)x<>;@c=glob<>;map{push@$_,$u-$_+$;for($u,$;)=split}<>;f;print"@a"

Measured memory_bytes: 547928
#include<iostream>
//#include<string>
#include<bits/stdc++.h>
using namespace std;
string x,y;
void input()
{
    cin >> x >> y;
}
    void cheack()
    {
        y.pop_back();
        if(x==y)
        {
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
int main()
{
    input();
    cheack();
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int x=0,f=1;
	char c=getchar();
	for (;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int maxn=1e3+10;
int n,m,A,B;
int a[maxn][maxn];
void first(int k) {
	for (int i=1;i<=A;++i) a[k][i]=1;
}
void second(int k) {
	for (int i=A+1;i<=m;++i) a[k][i]=1;
}
int main() {
	n=read(),m=read(),A=read(),B=read();
	for (int i=1;i<=B;++i) first(i);
	for (int i=B+1;i<=n;++i) second(i);
	for (int i=1;i<=n;++i) {
		for (int j=1;j<=m;++j) printf("%d",a[i][j]);
		puts("");
	}
	return 0;
}


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

int main() {
    int cnt=0;
    string str; cin >> str;
    int start = 0;
    int end = str.length() - 1;
    while(start != end){
        if(str[start] == str[end]) {
            if (end-start == 1) break;
            start++; end--;
        } else if(str[start] == 'x') {
            cnt++; start++;
        } else if(str[end] == 'x') {
            cnt++; end--;
        } else if(str[start] != str[end]) { // 詰み状態
            cout << "-1" << endl;    
            return 0;
        }
    }
    cout << cnt << endl;    
}

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

int main() {
    for (;;) {
        int m, f, r;
        cin >> m >> f >> r;

        if (m == -1 && f == -1 && r == -1) {
            break;
        } else {
            if (m == -1 || f == -1) {
                cout << 'F' << endl;
                continue;
            }
            int sum = m + f;
            if (80 <= sum) {
                cout << 'A' << endl;
                continue;
            }
            if (65 <= sum && sum < 80) {
                cout << 'B' << endl;
                continue;
            }
            if (50 <= sum && sum < 65) {
                cout << 'C' << endl;
                continue;
            }
            if (30 <= sum && sum < 50) {
                if (50 <= r) {
                    cout << 'C' << endl;
                    continue;
                } else {
                    cout << 'D' << endl;
                    continue;
                }
            }
            cout << 'F' << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;

int n, k;

int f(int s){
    if(s % k == 0) s++;
    return s - s / k - 1;
}

signed main(){
    cin >> n >> k;
    int t = 0;
    rep(i, 0, n - 1){
        int l = 0, r = 2e18;
        while(r - l > 1){
            int mid = (l + r) / 2;
            // cout << mid << ' ' << f(mid) << ' ' << t << endl;
            if(f(mid) > t){
                r = mid;
            }else{
                l = mid;
            }
        }
        // cout << " " << l << " " << r << endl;
        t = l;
    }
    cout << t << endl;
}


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

int main(void){
  char s[1000], t[1000];
  scanf("%s", s);
  scanf("%s", t);

  int ans = strlen(t);
  int len_s = strlen(s);
  int len_t = strlen(t);

  for(int i = 0; i <= len_s - len_t; i++){
    int diff = 0;
    for(int j = 0; j < len_t; j++){
      if(t[j] != s[i + j]) diff++;
    }
    ans = (ans < diff) ? ans : diff;
  }

  printf("%d\n", ans);

  return 0;

}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  // 計算
  vector<vector<int>> c(h, vector<int>(w));
  bool toRight = true;
  int curH = 0;
  int curW = 0;
  rep(i, n) {
    int aa = a.at(i);
    rep(j, aa) {
      c.at(curH).at(curW) = i + 1;
      if (toRight) {
        if (curW == w - 1) {
          curH++;
          toRight = false;
        } else {
          curW++;
        }
      } else {
        if (curW == 0) {
          curH++;
          toRight = true;
        } else {
          curW--;
        }
      }
    }
  }
  // 出力
  rep(i, h) {
    rep(j, w) {
      if (j != 0) {
        cout << " ";
      }
      cout << c.at(i).at(j);
    }
    cout << endl;
  }
  return 0;
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n , a, b , ans=0;
    cin >> n >> a >> b;
    ll tmp = n/(a+b);
    ans = tmp*a , n -= (tmp*(a+b));

    ll tmpp = min(a , n);
    ans += tmpp;
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
void solve()
{
  int n;
  cin>>n;
  int h[n],a[n];
  rep(i,n){cin>>h[i];}
  rep(i,n){cin>>a[i];}
  set<pair<int,ll>>s;
  s.insert({0,0});
  rep(i,n)
  {
    auto it=s.lower_bound({h[i],0});
    //cout<<s.size()<<endl;
    //cout<<it->F<<"a"<<it->S<<endl;
    it--;
    //cout<<it->F<<"b"<<it->S<<endl;
    it=s.insert({h[i],a[i]+it->S}).F;
  //  cout<<it->F<<" "<<it->S<<endl;
    while(1)
    {
      auto p=next(it);
      if(p==s.end()){break;}
      if(it->S>p->S){s.erase(p);}
      else{break;}
    }

  }
  cout<<s.rbegin()->S;
//cout<<(6&-6);
}
int main()
{
  fastio;
  //fopen();
  int t;
  //cin>>t;
  rep(i,1)
  { 
    solve();
    cout<<endl;
  }
  
}


Measured memory_bytes: 14336
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <atcoder/all>

using ll = long long int;
const int INF = (1<<25);
const ll INFLL = (1ll<<60);
const ll MOD = 998244353ll;

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n;
ll a[500500],segtree[2002002][3];
bool delayed[2002002];

void init(int i=0, int l=0, int r=n){
	segtree[i][1] = 1ll;
	if(r-l>1){
		init(i*2+1,l,(l+r)/2);
		init(i*2+2,(l+r)/2,r);
		segtree[i][0] = (segtree[i*2+1][0]+segtree[i*2+2][0])%MOD;
	}else{
		segtree[i][0] = a[l];
	}
}
void eval(int i, int l, int r){
	if(delayed[i]){
		mul_mod(segtree[i][0],segtree[i][1]);
		add_mod(segtree[i][0],segtree[i][2]*(r-l)%MOD);
		if(r-l>1){
			mul_mod(segtree[i*2+1][1],segtree[i][1]);
			mul_mod(segtree[i*2+1][2],segtree[i][1]);
			add_mod(segtree[i*2+1][2],segtree[i][2]);
			mul_mod(segtree[i*2+2][1],segtree[i][1]);
			mul_mod(segtree[i*2+2][2],segtree[i][1]);
			add_mod(segtree[i*2+2][2],segtree[i][2]);
			delayed[i*2+1] = true;
			delayed[i*2+2] = true;
		}
		segtree[i][1] = 1ll;
		segtree[i][2] = 0ll;
		delayed[i] = false;
	}
}
 
ll query(int a, int b, int i=0, int l=0, int r=n){
	eval(i,l,r);
	if(r<=a || b<=l){
		return 0ll;
	}else if(a<=l && r<=b){
		return segtree[i][0];
	}else{
		return (query(a,b,i*2+1,l,(l+r)/2)+query(a,b,i*2+2,(l+r)/2,r))%MOD;
	}
}
 
void update(int a, int b, ll c, ll d, int i=0, int l=0, int r=n){
	eval(i,l,r);
	if(r<=a || b<=l){
		return;
	}else if(a<=l && r<=b){
		delayed[i] = true;
		segtree[i][1] = c;
		segtree[i][2] = d;
		eval(i,l,r);
	}else{
		update(a,b,c,d,i*2+1,l,(l+r)/2);
		update(a,b,c,d,i*2+2,(l+r)/2,r);
		segtree[i][0] = (segtree[i*2+1][0]+segtree[i*2+2][0])%MOD;
	}
}

int main(void){
	int q,t,i,l,r;
	ll b,c;
	std::cin >> n >> q;
	for(i=0; i<n; ++i){
		std::cin >> a[i];
	}
	init();
	for(i=0; i<q; ++i){
		std::cin >> t >> l >> r;
		if(t){
			std::cout << query(l,r) << std::endl;
		}else{
			std::cin >> b >> c;
			update(l,r,b,c);
		}
	}
	return 0;
}


Measured memory_bytes: 33184
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>

using namespace std;
#define N 4
#define N2 16

 struct Puzzle {
  int f[N2];
  int space,MD;
  int cost;

  bool operator < (const Puzzle &p) const {
    for(int i=0;i<N2;i++) {
      if(f[i]==p.f[i])continue;
      return f[i] < p.f[i];
    }
    return false;
  }
};

static const char dir[4] = {'r','u','l','d'};
static const int dx[4] = {0,-1,0,1};
static const int dy[4] = {1,0,-1,0};
int MDT[N2][N2];

struct State {
  Puzzle puzzle;
  int estimated;
  bool operator < (const State &s) const {
    return estimated > s.estimated;
  }
};

int getAIIMD(Puzzle pz) {
  int sum= 0;
  for(int i=0;i<N2;i++) {
    if(pz.f[i] == N2) continue;
    sum += MDT[i][pz.f[i] - 1];
  }
  return sum;
}

int astar(Puzzle s) {
  priority_queue<State> PQ;
  s.MD = getAIIMD(s);
  s.cost=0;
  map<Puzzle, bool> V;
  Puzzle u,v;
  State initial;
  initial.puzzle = s;
   initial.estimated = getAIIMD(s);
   PQ.push(initial);

   while(!PQ.empty()) {
     State st = PQ.top(); PQ.pop();
     u=st.puzzle;

     if(u.MD == 0) return u.cost;
     V[u] = true;

     int sx = u.space/N;
     int sy = u.space%N;

     for(int r = 0;r<4;r++) {
       int tx = sx + dx[r];
       int ty = sy + dy[r];
       if(tx < 0 || ty < 0||tx>=N||ty >= N) continue;
       v = u;

       v.MD -= MDT[tx * N + ty][v.f[tx * N + ty] -1];
       v.MD += MDT[sx * N + sy][v.f[tx * N +ty] - 1];

       swap(v.f[sx * N + sy],v.f[tx * N + ty]);
       v.space  = tx * N +ty;
       if(!V[v]) {
         v.cost++;
         State news;
         news.puzzle = v;
         news.estimated = v.cost + v.MD;
         PQ.push(news);
       }
     }
   }
   return -1;
}

int main() {
 for(int i = 0;i<N2;i++)
 for(int j  = 0;j<N2;j++)
 MDT[i][j]=abs(i/N-j/N) + abs(i % N - j%N);

 Puzzle in;

 for(int i = 0;i<N2;i++) {
   cin >> in.f[i];
   if(in.f[i] == 0) {
     in.f[i] =N2;
     in.space = i;
   }
 }
 cout << astar(in) << endl;

 return 0;
}

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

int main() {
  long long K, A, B, sum;
  cin >> K >> A >> B;
  long long num = K-(A+1);
  if(B-A >= 3 && K -A >= 1) {
  sum = (num / 2) * (B - A) +  (num % 2) + B;
    cout << sum;
  }else{
    cout << K+1;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def main():
    num_mat = int(stdin.readline())
    r = [int(s) for s in stdin.readline().split()]
    for _ in range(num_mat-1):
        _, row = (int(s) for s in stdin.readline().split())
        r.append(row)

    if num_mat < 2:
        print(0)
        return
    elif num_mat < 3:
        print(r[0]*r[1]*r[2])
        return

    M = []
    M.append([0] * num_mat)
    M.append([r[i]*r[i+1]*r[i+2] for i in range(len(M[-1])-1)])

    for i in range(2, num_mat):
        N = []
        for j in range(num_mat-i):
            N.append(min(M[k][j]+M[i-1-k][1+j+k]+r[j]*r[1+j+k]*r[i+1+j]
                         for k in range(i)))
        M.append(N)
    print(M[-1][0])


main()

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n); rep(i,n) cin >> a[i];
    int res=0;

    range(i,1,n){
        if(a[i-1]>a[i]){
            res+=a[i-1]-a[i];
            a[i]+=a[i-1]-a[i];
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 4700
S = input()

results = []

l_delete_flag = False
r_delete_flag = False


if S[0] == ">":
    S = S + "S"
    cnt = 0
    i = 1
    while S[i] == ">":
        results.append(i + 1)
        i += 1
    results.append(1)
    S = S.rstrip("S")
    l_delete_flag = True


if S[-1] == "<":
    S = "S" + S
    i = len(S) - 1
    r = 1
    while S[i] == "<":
        results.append(r)
        r += 1
        i -= 1
    S = S.lstrip("S")
    r_delete_flag = True

if l_delete_flag:
    S = S.lstrip(">")


if r_delete_flag:
    S = S.rstrip("<")
    


if S:
    end_flag = False
    l_cnt = 0
    m_cnt = 0
    for i, s in enumerate(S):
        if end_flag:
            l_cnt = 0
            m_cnt = 0
            end_flag = False
        
        if s == "<":
            l_cnt += 1
        else:
            m_cnt += 1
        
        if (i == len(S) - 1) or ((s == ">") and (S[i + 1] == "<")):
            if l_cnt > m_cnt:
                results.append(int((l_cnt * (l_cnt + 1)) / 2))
                results.append(int((m_cnt * (m_cnt - 1)) / 2))
            else:
                results.append(int((m_cnt * (m_cnt + 1)) / 2))
                results.append(int((l_cnt * (l_cnt - 1)) / 2))
            end_flag = True

print(sum(results))





Measured memory_bytes: 79144
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
i8 = np.int64
i4 = np.int32
dot = 46

stdin = open(0).read().split(sep='\n', maxsplit=1)
H, W = map(int, stdin[0].split())
s = np.frombuffer(np.array(stdin[1]), dtype=i4).reshape(H, W+1)
s = np.vstack((s, np.zeros(W + 1, i4)))
g = np.zeros((H * W, H * W), i8)
for i in range(H):
    for j in range(W):
        if s[i, j] == dot:
            if s[i, j + 1] == dot:
                g[W * i + j, W * i + j + 1] = 1
                g[W * i + j + 1, W * i + j] = 1
            if s[i + 1, j] == dot:
                g[W * i + j, W * (i + 1) + j] = 1
                g[W * (i + 1) + j, W * i + j] = 1

dist_matrix = floyd_warshall(g)
print(int(np.max(dist_matrix[dist_matrix < 1000])))


Measured memory_bytes: 20900
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<ctype.h>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X;}
#define TF(f) {f;}
#define END {}
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,a) for (int i=1;i<=(a);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);

    string A,B,C;
    int N,M,K,X,Y,W,H;
    int ans;
    string S;
    int temp[100]={0};
    bool f=true;
    bool fir=true;

int main(){
    cin>>A>>B;
    if(A[0]=='H'){
        cout<<B;
    }else{
        B[0]=='H'?cout<<"D":cout<<"H";
    }

}
/*A.size()!=0&&B.size()!=0&&C.size()!=0*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5,YL=1e9+7;
inline int MO(const int &x){return x>=YL?x-YL:x;}
inline int in(){int k;cin>>k;return k;}
inline int low(int x){return x&(-x);}
int n,tot;
typedef std::pair<int,int> P;
#define mk make_pair
std::vector<P>ans;
int head[N],to[N<<1],nxt[N<<1],cnt,vis[N],du[N],m;
multiset<int>G[N];
inline void add(int u,int v){G[u].insert(v),G[v].insert(u),++du[u],++du[v];}
int main()
{
	ios::sync_with_stdio(0);
	int a,b,c;cin>>a>>b>>c;
	if(a==b&&b==c)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <string>
#include <queue>
#include <cmath>
#include <map>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(v) (v).rbegin(), (v).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> P;
typedef long long ll;

int main(){
	const int MAX = 1000000;
	bool isp[MAX];
	vector<int> prime;
	for(int i = 0; i < MAX; i++) isp[i] = 1;
	isp[0] = isp[1] = 0;
	for(int i = 2; i < MAX; i++){
		if(isp[i]){
			prime.push_back(i);
			for(int j = i*2; j < MAX; j+= i) isp[j] = 0;
		}
	}

	int n, p;
	while(cin >> n >> p, (n+1|p+1)){
		int idx = 0;
		while(prime[idx] <= n) idx++;
		vector<int> matsuzaki;
		for(int i = 0; i < p; i ++){
			for(int j = i; j < p; j ++){
				matsuzaki.push_back(prime[idx+i]+prime[idx+j]);
			}
		}
		sort(all(matsuzaki));
		cout << matsuzaki[p-1] << endl;
	}
	

	return 0;
}

Measured memory_bytes: 2564
#include <iostream>

using namespace std;

const int MAX_N = 1e5 + 5;

char colors [4] = {'R', 'G', 'B', 'Y'};

int main () {
  ios::sync_with_stdio(false);

  int n, m, d;
  cin >> n >> m >> d;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int dd = ((MAX_N + i + j) / d) % 2;
      int ud = ((MAX_N + i - j) / d) % 2;
      cout << colors[dd + 2 * ud];
    }
    cout << '\n';
  }
}


Measured memory_bytes: 3132
#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;

vector<ll> enum_div(ll n)  // nの約数を列挙
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> ret = enum_div(N);
    debug(ret);
    ll ans = 10000000000;
    REP(i, ret.size()) {
        ll res =
            max(to_string(ret[i]).length(), to_string(N / ret[i]).length());
        if (res < ans) {
            ans = res;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        vector<vector<int>> grid(110, vector<int>(110, -1));
        for (int i = 0; i < 105; ++i) {
            for (int j = 0; j < 105; ++j) {
                grid[i+1][j+1] = MOD;
            }
        }
        queue<pair<int, int>> q;
        for (int i = a; i <= c; ++i) {
            for (int j = b; j <= d; ++j) {
                grid[i][j] = 0;
                q.emplace(i, j);
            }
        }
        array<int, 4> dx{1, -1, 0, 0}, dy{0, 0, -1, 1};
        while(!q.empty()){
            int xx, yy; tie(xx, yy) = q.front(); q.pop();
            for (int k = 0; k < 4; ++k) {
                if((~grid[xx+dx[k]][yy+dy[k]]) && grid[xx][yy]+1 < grid[xx+dx[k]][yy+dy[k]]){
                    grid[xx+dx[k]][yy+dy[k]] = grid[xx][yy]+1;
                    q.emplace(xx+dx[k], yy+dy[k]);
                }
            }
        }
        int x, y;
        cin >> x >> y;
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            int xx, yy;
            cin >> xx >> yy;
            ans += min(max(grid[x][y]-1, 0)+grid[xx][yy], abs(xx-x)+abs(yy-y));
            x = xx; y = yy;
        }
        cout << ans << "\n";
    }
    return 0;
}


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

int main() {
    
    int a,b;
    
    cin >> a >> b;
    
    if(a > 8 || b > 8){
        cout << ":(" << endl;
        return 0;
    }
    
    cout << "Yay!" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<stack>
using namespace std;
int main()
{
    int num,len,i;
    stack<char> tion;
    char s[100005];
    cin>>s;
    len=strlen(s);
    num=len;
    for(i=0;i<len;i++){
        if(tion.empty()||tion.top()==s[i])
            tion.push(s[i]);
        else tion.pop();
    }
    num=len-tion.size();
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x,y;
  cin >> x >> y;
  if(x==y){
    cout << "Yes" << endl;
  }
  else if(x==2 || y==2) {
    cout <<"No" << endl;
  }
  else if(x==4 || x==6 || x==9 || x==11){
    if(y==4 || y==6 || y==9 || y==11){
      cout << "Yes" << endl;
    }
    else cout << "No" << endl;
  }
  else{
    if(y==4 || y==6 || y==9 || y==11){
      cout << "No" << endl;
    }
    else cout <<"Yes" << endl;
  }
  
  return 0;
    

}


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


int main() {
	
	int N, mcnt;
	string s;
	cin >> N >> s;
	set<char> t;
	multiset<char> x, y;
	for(auto i:s) t.insert(i), x.insert(i);
	
	for(int i=0; i<N; i++){
		int cnt = 0;
		y.insert(s.at(i));
		int a;
		a = x.erase(s.at(i));
		if(a>=2){
			for(int k=0; k<a-1; k++) x.insert(s.at(i));
		}
		
		for(auto j:t){
			if(x.count(j)>0 && y.count(j)>0) cnt++;
		}
		mcnt = max(cnt, mcnt);
	}
	cout << mcnt << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    int N,K,Q;
    cin>>N>>K>>Q;
    vector<int> A(N);
    vector<int> C(N);
    rep(i,Q){
        int a;
        cin>>a;
        a--;
        C[a] += 1;
    }
    rep(i,N){
        int x = K - (Q - C[i]);
        if(x>0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		long[] x = new long[n];
		for (int i = 0; i < n; i++) {
			x[i] = Integer.parseInt(sa[i]);
		}
		sa = br.readLine().split(" ");
		long[] y = new long[m];
		for (int i = 0; i < m; i++) {
			y[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int mod = 1000000007;
		long xx = 0;
		for (int i = 0; i < n; i++) {
			xx += i * x[i] - (n - i - 1) * x[i];
			xx %= mod;
		}
		long yy = 0;
		for (int i = 0; i < m; i++) {
			yy += i * y[i] - (m - i - 1) * y[i];
			yy %= mod;
		}
		long ans = xx * yy % mod;
		if (ans < 0) {
			ans += mod;
		}
		System.out.println(ans);
	}
}


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

int main()
{string S;
 int N;
 cin >> S;
 N=S.size();
vector<int> ans(N);
 rep(k, 2){
   int cnt=0;
   rep(i, N){
     if(S[i]=='R')
       cnt ++;
     else{
       ans[i] += cnt/2;
       ans[i-1] += (cnt+1)/2;
       cnt=0;
      
     }
     }
   reverse(ans.begin(), ans.end());
   reverse(S.begin(), S.end());
   rep(i, N){
     if(S[i]=='L') S[i]='R';
     else S[i]='L';
   }
 }
 rep(i, N) {
		if (i != 0) cout << " ";
		cout << ans[i];
	}
 cout << endl;   
       
     
     
  
 }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   string str;
   cin>>str;
   set<char> s;
   for(int i=0;i<str.length();i++)
   {
    s.insert(str[i]);
   }
   if(s.size()==str.length())
    cout<<"yes";
else
    cout<<"no";


    return 0;
}








Measured memory_bytes: 3660
import sys
from operator import itemgetter
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, M = MAP()
Cities = []
for i in range(M):
	Cities.append([i, MAP()])

Pref = [[] for _ in range(N)]
#print(Cities)
#print(Pref)

for c in Cities:
	i, [p, y] = c
	Pref[p-1].append([y, i])

for p in Pref:
	p.sort()
#print(Pref)

ans = []
for i,p in enumerate(Pref):
	for j in range(len(p)):
		ans.append([p[j][1] ,str(i+1).zfill(6)+str(j+1).zfill(6)])
ans.sort()

for a in ans:
	print(a[1])

Measured memory_bytes: 112348
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int mx = 0, mn = 0;
	vector<bool> c(8);
	rep(i, n)
	{
		if(a[i] >= 3200) {
			mx++;
		}
		else
		{
			int now = a[i] / 400;
			if(!c[now]) {
				c[now] = true;
				mx++;
				mn++;
			}
		}
	}

	if (mn == 0)
		mn++;
	cout << mn << " " << mx << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
 
 
int main()
{
	long long int X, ure;
	cin >> X;
 
	ure = (X/500)*1000 + ((X%500)/5)*5;

	cout << ure;
 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
 
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if ( a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0] ) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0; 
}

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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);


long long kill(ll health) {
    if(health==1) {
        return 1;
    }

    return 2*kill(health/2)+1;


}
int main() {
    fast_io;
    ll h;
    cin>>h;

    ll ans;
    ans=kill(h);
    cout<<ans<<endl;
}




Measured memory_bytes: 3580
object Main {

  def main(args: Array[String]): Unit = {
    import scala.io.StdIn._

    val abcd = readLine().map(_.toString.toInt).toList

    var result: String = abcd.head.toString
    // 見つかったら終了
    def dfs(lst: List[Int], r: Int, res: String): Boolean =
      if (lst.isEmpty) {
        if (r == 7) {
          result += res + "=7"
          true
        } else false
      } else
        dfs(lst.tail, r + lst.head, res + "+" + lst.head) ||
          dfs(lst.tail, r - lst.head, res + "-" + lst.head)

    dfs(abcd.tail, abcd.head, "")
    println(result)
  }

}


Measured memory_bytes: 25424
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
	int a[10],s=0;
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	for(int i=1;i<3;i++)
		s+=a[i]-a[i-1];
	cout<<s<<endl; 
	return 0;
}

Measured memory_bytes: 256