akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    int N; cin >>N;
    vei s(N); rep(i,N) cin >> s[i];

    int sum = acc(all(s),0);
    sort(all(s));
    if(sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }

    rep(i,N) {
        if(s[i] % 10 == 0) continue;
        sum -= s[i];
        if(sum % 10 != 0){
            cout << sum << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
	string T; cin >> T;
	for (auto c : T){
		if (c == '?') cout << 'D';
		else cout << c;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  cin >> s;

  // 解答
  cout << (s.find("AC") != string::npos ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

ll dp[105][2][105];

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

    string s;
    int k;
    cin >> s >> k;
    int n = s.length();
    dp[0][1][0] = 1;
    for(int i = 0; i < n; ++i){
        int hoge = s[i] - '0';
        for(int x = 0; x < 10; ++x){
            if(x == 0){
                if(x < hoge){
                    for(int j = 0; j <= 100; ++j){
                        dp[i+1][0][j] += dp[i][0][j];
                        dp[i+1][0][j] += dp[i][1][j];
                    }
                }
                else if(x == hoge){
                    for(int j = 0; j <= 100; ++j){
                        dp[i+1][0][j] += dp[i][0][j];
                        dp[i+1][1][j] += dp[i][1][j];
                    }
                }
                else{
                    for(int j = 0; j <= 100; ++j){
                        dp[i+1][0][j] += dp[i][0][j];
                    }
                }
            }
            else{
                if(x < hoge){
                    for(int j = 0; j < 100; ++j){
                        dp[i+1][0][j+1] += dp[i][0][j];
                        dp[i+1][0][j+1] += dp[i][1][j];
                    }
                }
                else if(x == hoge){
                    for(int j = 0; j < 100; ++j){
                        dp[i+1][0][j+1] += dp[i][0][j];
                        dp[i+1][1][j+1] += dp[i][1][j];
                    }
                }
                else{
                    for(int j = 0; j < 100; ++j){
                        dp[i+1][0][j+1] += dp[i][0][j];
                    }
                }
            }
        }
    }
    cout << dp[n][0][k] + dp[n][1][k] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

void solve(int n, auto & A, auto & ans) {
	if(n == 0) return;
	vector<int> Al(1<<(n-1)), Ar(1<<(n-1));
	for(int i = 0; i < (1<<(n-1)); i++) {
		Al[i] = A[i];
		Ar[i] = max(A[i], A[i+(1<<(n-1))]);
		ans[i+(1<<(n-1))] = max(ans[i+(1<<(n-1))], A[i] + A[i+(1<<(n-1))]);
	}
	solve(n-1, Al, ans);
	vector<int> ansr(1<<(n-1), 0);
	solve(n-1, Ar, ansr);
	for(int i = 0; i < (1<<(n-1)); i++)
		ans[i+(1<<(n-1))] = max(ans[i+(1<<(n-1))], ansr[i]);
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	int N = 1<<n;
	vector<int> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	vector<int> ans(N, 0);
	solve(n, A, ans);
	for(int i = 0; i < N; i++) ans[i] = max(ans[i], ans[i-1]);
	for(int i = 1; i < N; i++) cout << ans[i] << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 5356
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

//<editor-fold defaultstate="collapsed" desc="Headers & Macros">
#include <bits/stdc++.h>

#pragma GCC optimize("O3")

using namespace std;
//</editor-fold>

class AABCSwap {
public:
    void solve(std::istream &in, std::ostream &out) {
        int a, b, c;

        in >> a >> b >> c;

        swap(a, b);
        swap(a, c);

        out << a << ' ' << b << ' ' << c << '\n';
    }
};


int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    AABCSwap solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  int n,m;cin>>n>>m;
  int sum=0;
  int A[n+10];
  int a;
  REP(i,n) {
    cin>>a;
    A[i]=a;
    sum+=a;
  }
  int cnt=0;
  REP(i,n) {
    if(A[i]>=(sum*1.0)/(4*m)) {
      cnt++;
    }
  }
  if(cnt>=m) {
    pr("Yes");
  } else {
    pr("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,x,y;
	cin >> n >> x >> y;
	vector<int> b(n);

	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			int d = min(abs(j-i),min(abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(x-j)));
			b.at(d)++;
		}
	}

	for(int i=1;i<n;i++){
		cout << b.at(i) << endl;
	}
	return 0;
}


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

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

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

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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

    cout << N*(N-1)/2 + M*(M-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
pmin = 10**10
for i in range(max(x, y)+1): # 2i枚のABピザを買う
    bx = max(0, x - i)
    by = max(0, y - i)
    pay = a*bx + b*by + 2*c*i
    pmin = min(pmin, pay)


print(pmin)

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

using namespace std;

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

    int n;
    cin >> n;
    
    vector<int> h(n);
    for(int i=0; i<n; ++i)
    {
        cin >> h[i];
    }
    
    int curr=0,step1=1e5,step2;
    
    for(int i=0; i<n-1; ++i)
    {
        step1 = min(step1,curr + abs(h[i+1]-h[i]));
        
        if(i == n-2)  break;
        
        step2 = curr + abs(h[i+2]-h[i]);
        
        curr = step1;
        step1 = step2;
        
    }
    
    cout << step1;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
from functools import reduce
import fractions

MOD = 1000000007  # type: int

GCD_CACHE = {}


def gcd(x, y):
    if (x, y) in GCD_CACHE:
        return GCD_CACHE[(x, y)]
    d = fractions.gcd(x, y)
    GCD_CACHE[(x, y)] = d
    return d


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def solve(N: int, A: "List[int]"):
    m = lcm(*A) % MOD
    sum = 0
    for a in A:
        sum = (sum + m*pow(a, MOD-2, MOD)) % MOD
    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 171120
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

ll d[100010];

int main(void){
	          int i;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);

	      	  int N;
	      	  cin >> N;
	      	  for(i=1;i<=N;i++) cin >> d[i];

	      	  ll S=0;
	      	  for(i=1;i<=N;i++) S+=llabs(d[i]-d[i-1]);
	      	  S+=llabs(d[N]);

	      	  for(i=1;i<=N;i++){
	      		  ll x=S+llabs(d[i+1]-d[i-1])-llabs(d[i]-d[i-1])-llabs(d[i+1]-d[i]);
	      		      cout << x << endl;

	      	  }


	          return 0;
}


Measured memory_bytes: 2048
from collections import defaultdict,Counter
import queue

N=int(input())
ab=defaultdict(list)
for i in range(N-1):
    a,b=map(int,input().split())
    ab[a].append(b)
    ab[b].append(a)

q1=queue.Queue()
qN=queue.Queue()

dist=[None for i in range(N)]
dist[0]=1
dist[N-1]=-1

phase=1
F=0
S=0
for i in ab[1]:
    q1.put((i,phase))
    F+=1
for g in ab[N]:
    qN.put((g,phase))
    S+=1

while not (q1.empty() and qN.empty()):
    while True:
        if q1.empty():
            break
        next1,p=q1.queue[0]
        if p==phase:
            if dist[next1-1]==None:
                F+=1
                dist[next1-1]=1
            next1,p=q1.get()
            for i in ab[next1]:
                if dist[i-1]==None:
                    q1.put((i,phase+1))
        else:
            break


    while True:
        if qN.empty():
            break
        nextN,p=qN.queue[0]
        if p==phase:
            if dist[nextN-1]==None:
                S+=1
                dist[nextN-1]=-1
            nextN,p=qN.get()
            for i in ab[nextN]:
                if dist[i-1]==None:
                    qN.put((i,phase+1))
        else:
            break
    phase+=1

c=Counter(dist)
if c[-1]<c[1]:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 29912
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair <int,int> pii;
typedef vector <pii> vpii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef long long int lli;
typedef vector <lli> vlli;
typedef vector <vlli> vvlli;
typedef vector <string> vs;
typedef vector <bool> vb;

#define rep(i, n) for( i = 0; i < (n); ++i)
#define repA(i, a, n) for( i = a; i <= (n); ++i)
#define repD(i, a, n) for( i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sortr(x) sort(x.begin(),x.end(),greater <int> ())
#define mod 1000000007
#define ff first
#define ss second
#define fill(a,c)  memset(a, c, sizeof (a))
#define formap(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.first<<" , "<<it.second<<endl;} cerr<<endl
#define PI  3.14159265358979323846
#define pb push_back


int main() {
	cin.sync_with_stdio(0);cin.tie(0);
    cin.exceptions(cin.failbit);
    
    int i,j,k,n;
    vs val= {"AC","WA","TLE","RE"};
    vi ans(4,0);
    string s;
    cin>>n;
    rep(i,n){
        cin>>s;
        rep(j,4){
            if (s==val[j])ans[j]++;
        }
    }
    rep(i,4){
        cout<<val[i]<<" "<<'x'<<" "<<ans[i]<<endl;
    }
    
    
    
    
    
    
   
   
   
   
   
   
	return 0;
}


Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {


        static void Main(string[] args)
        {
            string[] lines = Console.ReadLine().Split(' ');
            int a = int.Parse(lines[0]);
            int b = int.Parse(lines[1]);

            int d = a / b;
            int r = a % b;
            double f = (double)a / b;
            Console.WriteLine("{0} {1} {2:f5}",
                d, r, f);

        }
    }
}

Measured memory_bytes: 9204
#include <iostream>
using namespace std;
int main(){
	int a,b,c;
	while(cin >> a >> b >> c){
		a = a%b;
		int d = 0;
		for(int i=0;i<c;i++){
			d += a*10/b;
			a = a*10%b;
		}
		cout << d << endl;
	}
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; char c; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int N, M, S, T;
		cin >> N >> M >> S >> T;
		if (!N) break;
		int n = N;
		vector<edge> E;
		while (M--) {
			int x, y; string s;
			cin >> x >> y >> s;
			vector<int> a;
			a.push_back(x);
			for (int i = 0; i < s.length() - 1; i++)
				a.push_back(n++);
			a.push_back(y);
			for (int i = 0; i < s.length(); i++)
				E.push_back(edge{a[i], a[i + 1], s[i]});
		}
		int m = E.size();
		vector<bool> pos(n);
		pos[T] = true;
		for (int t = 0; t < n; t++)
			for (int i = 0; i < m; i++)
				if (pos[E[i].v])
					pos[E[i].u] = true;
		if (!pos[S]) {
			cout << "NO" << endl;
			continue;
		}
		string s;
		vector<bool> a(n);
		a[S] = true;
		int t;
		for (t = 0; t < n; t++) {
			if (a[T]) break;
			vector<bool> _a(n);
			char c;
			for (c = 'a'; c <= 'z'; c++) {
				bool ok = false;
				for (int i = 0; i < m; i++)
					if (E[i].c == c && a[E[i].u] && pos[E[i].v]) {
						_a[E[i].v] = true;
						ok = true;
					}
				if (ok) break;
			}
			s.push_back(c);
			a = _a;
		}
		if (t == n) cout << "NO" << endl;
		else cout << s << endl;
	}
}

Measured memory_bytes: 3088
fun main(arr: Array<String>) {
    val s = readLine()!!.toMutableList()
    var k = readLine()!!.toLong()
    for(i in s.indices) {
        if(s[i] == 'a') {
            continue
        }
        val toA = ('z' - s[i]) + 1
        if(toA <= k) {
            s[i] = 'a'
            k-=toA
        }
    }
    k %= ('z' - 'a' + 1)
    s[s.lastIndex] = s[s.lastIndex]+k.toInt()
    println(s.joinToString(""))
}


Measured memory_bytes: 39828
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <map>
#include <unordered_map>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define umap unordered_map
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

int main() {
  int A, B;
  cin >> A >> B;
  cout << (A + B) % 24 << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
//😂
bool check(int n){
  bool ok = false;
  for(ll i=2;i*i<=n;i++){
    if(n%i==0){
      ok = true;
    }
  }
  return ok;
}

int main(){
  int n;
  cin >> n;
  while(check(n))n++;
  
  cout << n << endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {

	static int testN=3;
	static long mod = 1000000007;
	//static long mod =998244353; 
	static System.IO.StringReader sr;
	static void Main(string[] args) {
		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";
		//int res = -1 ;

		int n = int.Parse(Console.ReadLine());
		int[] vals = new int[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

		Console.WriteLine(vals[n-1]);
		return;

	}



	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

Measured memory_bytes: 11092
fun main(args: Array<String>) {
  val m = 998244353L
  val N = readLine()!!.toInt()
  val D = readLine()!!.split(" ").map { it.toInt() }
  val maxD = D.max() ?: 0
  val DMap = D.groupBy { it }

  if (D[0] != 0) {
    println(0)
    return
  }

  if (DMap[0]!!.size != 1) {
    println(0)
    return
  }

  var result = 1L
  for (i in 1..maxD) {
    val prev = DMap[i - 1]?.size ?: 0
    val current = DMap[i]?.size ?: 0
    // result *= prev^current
    for (i in 0 until current) {
      result = (result * prev) % m
    }
  }
  println(result)
}


Measured memory_bytes: 74524
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
ii0 = lambda: ii() - 1
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def divs_gen(n):
    for i in range(1, int(m**.5)+1):
        if n%i == 0:
            yield i
            if i != n//i:
                yield n//i


def main():
    A, B = mis()
    from fractions import gcd
    G = gcd(A, B)
    fs = set()
    for i in range(2, int(G**0.5)+2):
        if G%i == 0 and all(i%f != 0 for f in fs):
            fs.add(i)
            while G%i == 0:
                G //= i
    if G > 1:
        fs.add(G)
    print(len(fs)+1)


main()


Measured memory_bytes: 5076
#include <iostream>
#include<vector>
#define inf 1e9
using namespace std;

int frog(vector<int> v, int n){
    vector<int> dp(n+1);
    dp[1] = 0;
    for(int i=2;i<=n;i++){
        int op1 = dp[i-1] + abs(v[i] - v[i-1]);
        int op2 = (i==2) ? inf : (dp[i-2] + abs(v[i] - v[i-2])) ;
        dp[i] = min(op1,op2);

    }
    return dp[n];
}
int main() {
    int n;
    cin>>n;
    vector<int> ar(n+1);
    for(int i=1;i<=n;i++){
        cin>>ar[i];
    }cout<<frog(ar,n)<<endl;

}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n,m,x,y,d,nx,ny;
  char c;
  while(1){
    cin >> n;
    if(n==0) return 0;
    vector<vector<int>> field(21,vector<int>(21,0));
    for(int i=0;i<n;i++){
      cin >> x >> y;
      field[y][x]=1;
    }
    cin >> m;
    nx=ny=10;
    for(int i=0;i<m;i++){
      cin >> c >> d;
      switch(c){
      case 'N':
        for(int i=1;i<=d;i++){
          if(field[ny+i][nx]){
            field[ny+i][nx]=0;
            n--;
          }
        }
        ny=ny+d;
        break;
      case 'E':
        for(int i=1;i<=d;i++){
          if(field[ny][nx+i]){
            field[ny][nx+i]=0;
            n--;
          }
        }
        nx=nx+d;
        break;
      case 'S':
        for(int i=1;i<=d;i++){
          if(field[ny-i][nx]){
            field[ny-i][nx]=0;
            n--;
          }
        }
        ny=ny-d;
        break;
      case 'W':
        for(int i=1;i<=d;i++){
          if(field[ny][nx-i]){
            field[ny][nx-i]=0;
            n--;
          }
        }
        nx=nx-d;
        break;
      }
    }
    if(n==0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3048
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define deb1(x) cout << #x <<"="<< x <<endl;
#define deb2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define deb3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define deb4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define debarr(x) cout << #x<<"::"<<endl;for(int i : x){cout << i <<" ";} cout <<endl;

inline void add(int& a, int b){a = (a+b); if(a>=mod)a-=mod;}
inline void sub(int& a, int b){a = a-b; if(a<0)a+=mod;}
inline void mul(int& a, int b){a = (a*b)%mod;}

int d;
vector<vi> dp(101,vi(2));
string k;


void mymain(){
    cin >> k >> d;
    int n = k.size();

    dp[0][0] = 1;

    for(int i=0;i<n;i++){
        vector<vi> ndp(101,vi(2));
        for(int s=0;s<d;s++){
            for(int kk=0;kk<10;kk++){
                if(kk<k[i]-'0'){
                    add(ndp[(s+kk)%d][1] ,(dp[s][0]+dp[s][1])%mod);

                }else if(kk == k[i]-'0'){
                    add(ndp[(s+kk)%d][0], dp[s][0]);
                    add(ndp[(s+kk)%d][1], dp[s][1]);
                }else{
                    add(ndp[(s+kk)%d][1], dp[s][1]);
                }
            }
        }
        //deb3(i,ndp[0][0],ndp[0][1])
        dp = ndp;
    }

    add(dp[0][0],dp[0][1]);
    int ans = dp[0][0];
    sub(ans,1);
    cout << ans << endl;

}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


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

using namespace std;

ll pw(ll a, ll b){
  ll ret = 1;
  for(ll i = 0; i < b; i++)
    ret = ret * a % 1000000;
  return ret;
}

int main(){

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

  if(m == 1){
    cout << pw(2,n) << endl;
    return 0;
  }
  
  ll a[101], b[101], c[101];
  a[0] = b[0] = c[0] = 1;
  a[1] = 4;
  b[1] = c[1] =3;

  for(int i = 2; i <= n; i++){
    a[i] = b[i] = c[i] = a[i-1] + b[i-1] + c[i-1];
    for(int j = i - 2; j >= 0; j--)
      a[i] += c[j];
    a[i]++;
    for(int j = i - 2; j >= 0; j--)
      c[i] += a[j];
    a[i] %= 1000000;
    b[i] %= 1000000;
    c[i] %= 1000000;
  }

  cout << a[n] << endl;

}

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

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;}

const long long INF = 1LL << 60;
const long long mod = 1000000007;

int main(void){
    ll k,n;cin >> k >> n;
    vector<ll> a(n+1);
    for(ll i=0;i<n;i++){
	cin >> a[i];
    }
    ll ans = 100000000;
    a[n] = k+a[0]; 
    for(ll i=0;i<n;i++){
	ans = min(ans,k-(a[i+1]-a[i]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
N = int(input())

def F(N):
  if N == 0:
    return ''
  if N%2 == 0:
    return F(N//(-2)) + '0'
  return F((N-1)//(-2)) + '1'

answer = F(N)
if N == 0:
  answer = '0'
print(answer)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;

    int ans;
    if ( a<=b )ans = a;
    else ans = a-1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
ll a[10000000], d[10000000];
int main() {
    
    long double i,j,k, l, test, n, m, x;
    cin>>i>>j>>k>>l;
    
    printf("%llf ", (i*j)/2.0);
    if(k==i/2.0 && l==j/2.0) cout<<1;
    else cout<<0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	if(llabs(a-b)<=t*(v-w))
	{
		cout<<"YES"<<endl;
		return 0;
	} 
	cout<<"NO"<<endl;
	return 0; 
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <numeric>
#include <stack>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

const int MOD = 1000000007;

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, M;
    cin >> N >> M;
    VEC(bool) broke(N + 1, false);
    FOR(i, 0, M) {
        int s;
        cin >> s;
        broke[s] = true;
    }

    VEC(int) dp(N + 1, 0);
    FORD(i, N, -1) {
        if (i == N) {
            dp[i] = 1;
            continue;
        }

        if (broke[i])
            continue;

        dp[i] = dp[i + 1];
        if (i + 2 <= N)
            dp[i] = (dp[i] + dp[i + 2]) % MOD;
    }

    cout << dp[0] << endl;
    return 0;
};


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

long long int prefix[500];
int a[500];

long long int sum(int i, int j)
{
  auto sub = i ? prefix[i-1] : 0;
  return prefix[j] - sub;
}


long long int f(int i, int j, vector<vector<long long>>& dp)
{
  auto S = sum(i,j);
  if (i == j)
    return a[i];
  auto& res = dp[i][j];
  if (res != numeric_limits<long long>::max())
    return res;
  for (int k = i; k < j; ++k)
  {
    res = min(res, S + f(i, k, dp) + f(k+1, j, dp));
  }
  return res;
}


int main()
{
  int n, k;
  cin >> n ;
  vector<int> a(n);
  vector<vector<long long>> dp(n, vector<long long>(n,numeric_limits<long long>::max()));
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  prefix[0] = a[0];
  for (int i = 1; i < n; ++i)
    prefix[i] = (prefix[i-1] + a[i]);


  cout << f(0, n-1, dp) <<'\n';


  return 0;
}


Measured memory_bytes: 1536
import sys
input = sys.stdin.readline

N, H = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort(reverse = True)
B.sort(reverse = True)

ans = 0

maxA = A[0] #複数回使える最大ダメージ
for b in B:
    if b <= maxA:
        break
    else:
        H -= b
        ans += 1
        if H <= 0:
            print (ans)
            exit()
        
ans += (H + maxA - 1) // maxA

print (ans)


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

int main(){
  int rooms[4][3][10];

  int n;
  
  cin>>n;
  for(int i=0;i<4;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<10;k++){
        rooms[i][j][k]=0;
      }
    }
  }
  
  for (int i=0;i<n;i++){
    int b,f,r,v;
    cin>>b>>f>>r>>v;
    rooms[b-1][f-1][r-1]+=v;
  }

  for(int i=0;i<4;i++){
    for (int j=0;j<3;j++){
      for(int k=0;k<10;k++){
        cout<<" "<<rooms[i][j][k];
        if(k==9)cout<<endl;
      }
    }
    if (i!=3)cout<<"####################"<<endl;
  }
}


Measured memory_bytes: 3088
#include<stdio.h>

int main(void){
  int N;
  scanf("%d",&N);
  int L[N];
  for(int i = 0;i < N;i++)
    scanf("%d",&L[i]);
  for(int i = 0;i < N - 1;i++){
    for(int j = i + 1;j < N;j++){
      if(L[i] > L[j]){
	int t = L[i];
	L[i] = L[j];
	L[j] = t;
      }
    }
  }
  int h = 0;
  for(int a = 0;a < N - 2;a++){
    for(int b = a + 1;b < N - 1;b++){
      for(int c = b + 1;c < N;c++){
	if((L[a] < L[b] + L[c]) && (L[b] < L[c] + L[a]) && L[c] < L[a] + L[b]){
	  h++;	  
	}
	else
	  break;
      }      
    }
  }
  printf("%d\n",h);
  return 0;
}	

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

using namespace std;

int main() 
{
    int n, m, i;
    scanf("%d", &n);
    
    set<int> A;
    set<int> B;
    set<int> C;
    
    for(i = 0; i < n; i++)
    {
        scanf("%d", &m);
        A.insert(m);
    }
    
    scanf("%d", &m);
    
    for(i = 0; i < m; i++)
    {
        scanf("%d", &n);
        B.insert(n);
    }
    
    set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(C, C.begin()));
    
    for(auto x : C)
        printf("%d\n", x);
    
    return 0;
}


Measured memory_bytes: 40704
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#include<sstream>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } //t=min
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } //t=max
using namespace std;


int N;
int puzzle[5][11];

int deletePuzzle()
{
	int get_p = 0;

	/*
	cout << "---- remove start ----" << endl;
	rep(y,N) {
		rep(x,5) { 
			cout << puzzle[x][y] << " ";
		}
		cout << endl;
	}
	cout << endl;
	*/

	rep(y,N) {
		int back_p = 0;
		int the_p = 0;
		set<int> remove_xs;

		//3つ以上一致しているかを見る
		rep(x,5)
		{
			if (puzzle[x][y] == back_p && puzzle[x][y] > 0)
			{
				/*
				cout << "---------------" << endl;
				for (set<int>::iterator iti = remove_xs.begin(); iti != remove_xs.end(); iti++) { cout << *iti; }
				cout << endl;
				*/

				remove_xs.insert(x-1); //重複していたら挿入しない
				remove_xs.insert(x);
				if (remove_xs.size() >= 3) { //3回以上
					the_p = puzzle[x][y];
				}
			}
			else {
				//玉が異なっていて，既に3つ以上揃っているとき，これ以上は揃わないのでbreak;
				if (remove_xs.size() >= 3) {
					break;
				}
				else {
					remove_xs.clear();
				}
			}
			back_p = puzzle[x][y];
		}

		if (remove_xs.size() >= 3)
		{ 
			get_p += the_p * remove_xs.size(); //ポイント換算
			for (set<int>::iterator it = remove_xs.begin(); it != remove_xs.end(); it++) {
				puzzle[(*it)][y] = 0;
			}
		} 

	}

	/*
	cout << "---- remove end ----" << endl;
	rep(y,N) {
		rep(x,5) { 
			cout << puzzle[x][y] << " ";
		}
		cout << endl;
	}
	cout << endl;
	*/


	return get_p;
}

void dropPuzzle()
{
	rep(x,5) {
		vector<int> real_ps;
		rep(y,N) {
			if (puzzle[x][y] > 0) { real_ps.push_back(puzzle[x][y]); } //点数を吸い取る
			puzzle[x][y] = 0; //全部一回削除
		}
		int the_N = real_ps.size();
		rep(y,the_N) { //the_N分たどる
			puzzle[x][y+(N-the_N)] = real_ps[y];
		}
	}
	
	//デバッグ
	/*
	rep(y,N) {
		rep(x,5) { 
			cout << puzzle[x][y] << " ";
		}
		cout << endl;
	}
	*/
}

int main()
{
	int all_p;
	while(true) {
		cin >> N;
		all_p = 0;

		if (N == 0) { break; }
		rep(y,11) {
			rep(x,5) {
				puzzle[x][y] = 0;
			}
		}

		rep(y,N) {
			rep(x,5) {
				cin >> puzzle[x][y];
			}
		}

		/*
		rep(y,N) {
			rep(x,5) {
				cout << puzzle[x][y];
			}
			cout << endl;
		}
		cout << endl;
		*/

		//while get_p=0まで
		while(true) {
			int get_p = deletePuzzle();
			if (get_p == 0) { break; }
			all_p += get_p;
			dropPuzzle();
			//cout << endl;
		}

		cout << all_p << endl;
		//cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
int t[100010];
int x[100010];
int y[100010];

int main(){ _;
  int n;cin>>n;
  t[0]=x[0]=y[0]=0;
  for(int i=1;i<=n;i++) cin>>t[i]>>x[i]>>y[i];
  REP(i,n){
    int d=abs(x[i]-x[i+1])+abs(y[i]-y[i+1]);
    int td=t[i+1]-t[i];
    if(d>td||(td-d)%2==1){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 1408
<?php
$str = str_split(fgets(STDIN));
$n =3;
$i=0;
while($i<$n){
  if ((int)$str[$i]==1){
    $str[$i]=9;
  }elseif ((int)$str[$i]==9) {
    $str[$i]=1;
  }
  echo $str[$i];
  $i++;
}


Measured memory_bytes: 3576
var n,i,j,k:longint;
s,c:ansistring;
begin
  readln(s);
  j:=length(s);
  i:=j;
  while ((i>=1) and (j-i<7)) do
    begin
      c:='';
      for k:=i to j do c:=c+s[k];
      if c='dream' then
        begin
          j:=i-1;
          i:=j;
        end
      else if c='erase' then
        begin
          j:=i-1;
          i:=j;
        end
      else if c='dreamer' then
        begin
          j:=i-1;
          i:=j;
        end
      else if c='eraser' then
        begin
          j:=i-1;
          i:=j;
        end
      else dec(i);
    end;
  if j=0 then writeln('YES') else writeln('NO');
end.



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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

int dx[4] = { 1, 0, -1, 0 },
    dy[4] = { 0, 1, 0, -1 };

int solve(int H,int W,vector<string>& s) {
    vvi dis(H, vi(W, 9999));
    queue<pair<int,ii>> q;
    q.push(cons(0,ii(0,0)));
    int distance = 9999;
    while (!q.empty()) {
        auto t = q.front(); q.pop();
        int d=t.first, r=t.second.first, c=t.second.second;
        if (d >= dis[r][c]) continue;
        if (r == H-1 && c == W-1) {
            distance = d; break;
        }
        dis[r][c] = d;
        rep(i,4){
            int ri = r + dx[i], ci = c + dy[i];
            if (!IN(ri,0,H-1) || !IN(ci,0,W-1)) continue;
            if (s[ri][ci] == '#') continue;
            if (dis[ri][ci] <= d+1) continue;
            q.push(cons(d+1, ii(ri,ci)));
        }
    }
    if (distance == 9999) return -1; ////
    
    int consumed = distance + 1;
    int rest = H*W - consumed;
    rep(r,H)rep(c,W){
        if (s[r][c] == '#') rest--;
    }
    return rest;
}

int main() {
    int H,W; cin >> H >>W;
    vector<string> s(H);
    rep(i,H) cin >> s[i];
    cout << solve(H,W,s) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		sc.close();
		
		for(int i=0; i<s.length()-1; i++){
			if(s.subSequence(i, i+2).equals("AC")){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	int n;
	cin >> n;
	if (n == 3 || n == 5 || n == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		//int n = Integer.parseInt(as.next());
		String st = as.next();
      if(st.equals("AAA") || st.equals("BBB")){
		System.out.println("No");
      }else{System.out.println("Yes");
      }
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define int long long int
#define mpp make_pair
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MOD 1000000007
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
const int MAXN = 1e6+1;
#define MAXI 2e18+3
#define all(v) v.begin(), v.end()
#define endl "\n"
# define PI 3.14159265358979323846


signed main(){
 
    fast;
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int x, i;
    int sum=100;
    double d = 1;
    cin>>x;
    for(i=1;i<4000;i++){
    	sum+=sum/100;
    	if(sum>=x)
    		break;
    }
    cout<<i<<endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>//   28 March 2020
using namespace std;
int main()
{
    int i,flag=0;
    string str;
    cin>>str;

       if(str[2]==str[3] &&str[4]==str[5])
    {
        flag=1;
    }
    if(flag)
    {
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;

    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

int calc(int N)
{
    if(N==1) return 300000;
    if(N==2) return 200000;
    if(N==3) return 100000;
    return 0;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int X,Y; cin>>X>>Y;
    int ans=0;
    ans+=calc(X); ans+=calc(Y);
    if(X==1 and Y==1) ans+=400000;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int n;

int dp[2][1000010], adp[2][1000010];
int INF = 1e9;
int add[200], oadd[200];

void solve() {
	for (int i=0; i<2; i++) {
		fill(dp[i], dp[i]+1000010, INF);
		fill(adp[i], adp[i]+1000010, INF);
	}
	
	dp[0][0] = 0;
	for (int i=0; i<200; i++) {
		int nw = i%2, nx = (i+1)%2;
		for (int j=0; j<=1000000; j++) {
			if (add[i] <= j) {
				dp[nx][j] = min(dp[nw][j], dp[nx][j-add[i]] + 1);
			} else {
				dp[nx][j] = dp[nw][j];
			}
		}
	}
	
	adp[0][0] = 0;
	for (int i=0; i<200; i++) {
		int nw = i % 2, nx = (i+1)%2;
		
		for (int j=0; j<=1000000; j++) {
			if (oadd[i] <= j) {
				adp[nx][j] = min(adp[nw][j], adp[nx][j-oadd[i]] + 1);
			} else {
				adp[nx][j] = adp[nw][j];
			}
		}
	}
}

void qer() {	
	int ans1 = INF, ans2 = INF;
	for (int i=0; i<2; i++) {
		ans1 = min(ans1, dp[i][n]);
		ans2 = min(ans2, adp[i][n]);
	}
	cout << ans1 << " " << ans2 << endl;
}

int main() {
	int p = 0;
	for (int i=0; i<200; i++) {
		add[i] = i * (i+1) * (i+2) / 6;
		if (add[i] % 2 == 1) oadd[p++] = add[i];
	}
	solve();
	
	while (1) {
		cin >> n; if (n==0) break;
		qer();
	}
	
	return 0;
}

Measured memory_bytes: 16784
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>

typedef unsigned long long LL;

using namespace std;

int main() {
	int N;
	vector<int>a;
	cin >> N;
	for (int i = 0; i < N * 3; i++) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end(), greater<int>());
	LL answer=0;
	for (int i = 0; i < N * 2; i++) {
		if (i % 2 == 1) {
			answer += a[i];
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 2420
#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;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  string a, b;
  cin >> a >> b;

  int test = stoi(a + b);
  for (int i = 1; i <= 1000; i++){
    if (i * i == test){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3568
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "OK" : "NG")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    int K, A, B;
    cin >> K;
    cin >> A >> B;
    cout << YN((A/K != B/K) || (A%K == 0) || (B%K == 0)) << endl; 
}

// Main

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

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 3652
n, l = map(int, input().split())
ans = 0

if l <= 0 and n+l > 0:
  for i in range(n):
    ans += l+i 
elif n+l <= 0:
  for i in range(n-1):
    ans += l+i 
else:
  for i in range(1, n):
    ans += l+i 
  
print(ans)

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

int main() {
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>>v(n);
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		v[i]={a,b};
	}
	sort(v.begin(),v.end());
	long long ans=0;
	priority_queue<int>pq;
	auto it = v.begin();
	 for(int i = 1; i <= m; ++i)
    {
        while(it != v.end() && it->first <= i)
        {
            pq.push(it->second);
            ++it;
        }
        if(!pq.empty())
        {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans;
	return 0;
}

Measured memory_bytes: 1660