akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    char[] S,T;
    private void solve() {
        S = next().toCharArray();
        T = next().toCharArray();

        int ans = 0;
        for(int i = 0;i < S.length;i++) {
            if (S[i] != T[i]) {
                ans++;
            }
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] x = new int[n];
        for(int i = 0;i < n;i++) {
            x[i] = nextInt();
        }
        return x;
    }

    public long[] nextLongArray(int n) {
        long[] x = new long[n];
        for(int i = 0;i < n;i++) {
            x[i] = nextLong();
        }
        return x;
    }

    public double[] nextDoubleArray(int n) {
        double[] x = new double[n];
        for(int i = 0;i < n;i++) {
            x[i] = nextDouble();
        }
        return x;
    }
}

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

#define REP(i,n) for(decltype(n) i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(c) ((int)((c).size()))
#define st first
#define nd second
#define pb push_back

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef long long ll;

int c[1000][1000];
int b[1000][1000];
int sc[2][1002][1002];
int sb[2][1002][1002];

void solve(){
    int N,K,x,y;
    char t;
    cin>>N>>K;
    REP(i,N){
        cin>>x>>y>>t;
        x %= 2*K;
        y %= 2*K;
        bool k = (t=='B');
        if(x >= K){
            x -= K;
            k = !k;
        }
        if(y >= K){
            y -= K;
            k = !k;
        }
        (k ? b : c)[x][y]++;
    }
    for(int i=1;i<=K;++i)
        for(int j=1;j<=K;++j){
            sc[0][i][j] = sc[0][i-1][j] + sc[0][i][j-1] - sc[0][i-1][j-1] + c[i-1][j-1];
            sb[0][i][j] = sb[0][i-1][j] + sb[0][i][j-1] - sb[0][i-1][j-1] + b[i-1][j-1];
        }
    for(int i=K;i>0;--i)
        for(int j=K;j>0;--j){
            sc[1][i][j] = sc[1][i+1][j] + sc[1][i][j+1] - sc[1][i+1][j+1] + c[i-1][j-1];
            sb[1][i][j] = sb[1][i+1][j] + sb[1][i][j+1] - sb[1][i+1][j+1] + b[i-1][j-1];
        }
    int ans = 0;
    REP(i,K+1)
        REP(j,K+1){
            ans = max(ans, sc[0][i][j] + sc[1][i+1][j+1] + sb[0][i][K] + sb[0][K][j] - 2*sb[0][i][j]);
            ans = max(ans, sb[0][i][j] + sb[1][i+1][j+1] + sc[0][i][K] + sc[0][K][j] - 2*sc[0][i][j]);
        }
    cout<<ans;
}

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


Measured memory_bytes: 23808
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
p = LIST()

acm = 0
for i in range(N):
	if p[i] != i + 1:
		acm += 1

if acm <=2:
	print("YES")
else:
	print("NO")

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

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

  vector<int> A(N), B(N);

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    
    B.at(A.at(i) - 1) = i + 1;
  }

  for (int i = 0; i < N; i++) {
    cout << B.at(i);
    
    if (i != (N - 1)) {
      cout << ' ';
    }
    else {
      cout << endl;
    }
  }
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

double state[301][301][301];

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

    int n; cin >> n;
    vi a(n);
    F0R (i, n) cin >> a[i];
    array<int, 3> count{0};
    F0R (i, n) if (a[i] < 3) count[a[i]]++;
    F0R (i, n + 1) F0R (j, n + 1) F0R (k, n + 1) state[i][j][k] = -1;

    state[n][0][0] = 0;
    queue<array<int, 3>> q;
    q.push({n, 0, 0});
    const int NXT[3][4] = {{-1, 1, 0, 0}, {0, -1, 1, 0}, {0, 0, -1, 1}};
    while (!q.empty()) {
        auto cur = q.front(); q.pop();
        if (cur == count) break;
        F0R (i, 3) {
            auto next = cur;
            F0R (j, 3) next[j] += NXT[i][j];
            if (next[0] < 0 || next[1] < 0 || next[2] < 0) continue;
            if (state[next[0]][next[1]][next[2]] != -1) continue;
            int n3 = n - next[0] - next[1] - next[2];

            double val = 1;
            F0R (j, 3) {
                if ((j < 2 && next[j + 1] == 0) || (j == 2 && n3 == 0)) continue;
                auto tmp = next;
                F0R (k, 3) tmp[k] -= NXT[j][k];
                if (tmp[0] < 0 || tmp[1] < 0 || tmp[2] < 0) continue;
                double look = state[tmp[0]][tmp[1]][tmp[2]];
                if (look != -1) {
                    double coeff = j == 2 ? n3 : next[j + 1];
                    val += look * coeff / n;
                }
            }
            state[next[0]][next[1]][next[2]] = val * ((double)n / (n - next[0]));
            q.push(next);
        }
    }
    cout << fixed << setprecision(9) << state[count[0]][count[1]][count[2]] << endl;

    return 0;
}


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

typedef pair<int, int> P;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  vector<P> a;
  int temp1, temp2;

  for(int i = 0;i < 6;++i){
    cin >> temp1 >> temp2;
    if(temp1 > temp2){
      a.push_back(P(temp1, temp2));
    }else{
      a.push_back(P(temp2, temp1));
    }
  }

  sort(a.begin(), a.end());

  if(a[0] == a[1] && a[2] == a[3] && a[4] == a[5]){
    bool flag = false;
    if(a[0].first == a[2].first && a[0].second == a[4].second && a[2].second == a[4].first) flag = true;
    if(a[0].second == a[2].first && a[0].first == a[4].second && a[2].second == a[4].first) flag = true;
    if(a[0].first == a[2].second && a[0].second == a[4].second && a[2].first == a[4].first) flag = true;
    if(a[0].second == a[2].second && a[0].first == a[4].second && a[2].first == a[4].first) flag = true;
    if(a[0].first == a[2].first && a[0].second == a[4].first && a[2].second == a[4].second) flag = true;
    if(a[0].second == a[2].first && a[0].first == a[4].first && a[2].second == a[4].second) flag = true;
    if(a[0].first == a[2].second && a[0].second == a[4].first && a[2].first == a[4].second) flag = true;
    if(a[0].second == a[2].second && a[0].first == a[4].first && a[2].first == a[4].second) flag = true;

    if(flag){
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }

  }else{
    cout << "no" << endl;
  }

  return 0;
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    vector<int> m(3,0);
    REP(i,3)cin>>m[i];
    int P,ans=0;
    cin>>P;
    sort(m.begin(),m.end(),greater<int>());
    REP(i,P)m[0]=m[0]*2;
    REP(i,3)ans+=m[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		String a = sc.nextLine();
		String b = sc.nextLine();
		int count = 0;
		sc.close();
		for(int i = 0;i < 3;i++){
			if(a.charAt(i)==b.charAt(i)){
				count++;
			}
		}
System.out.println(count);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  char ch;
  while(1){
    scanf("%c", &ch);
    if(ch >= 'A' && ch <= 'Z'){
    printf("%c", ch+32);
    }else if(ch >='a' && ch<= 'z'){
      printf("%c", ch-32);
    }
    else{
      printf("%c", ch);
    }
    if ( ch == '\n' ) break;
  }
}


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

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

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

const int N = 100010 ;
const int MOD = 1000000007;
const int LOG = 20;

int n, h[N], par[N], act[N];
vi G[N];

void DFS(int v, int p = 0){
	for (auto u:G[v]){
		if (u == p) continue;
		h[u] = h[v] + 1;
		par[u] = v;
		act[v] ++;
		DFS(u, v);
	}
}


int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n - 1; i++){
		int v, u;
		cin >> v >> u;
		G[v].pb(u);
		G[u].pb(v);
	}
	if (n == 2) return cout << "Second", 0;
	if (n % 2 == 1){
		cout << "First";
		return 0;
	}
	for (int i = 1; i <= n; i++){
		if (G[i].size() == 1){
			DFS(i);
			break;
		}
	}
	set<pii> st;
	for (int i = 1; i <= n; i++){
		st.insert({-h[i], i});
	}
	while (st.size()){
		int fr = st.begin()->S;
		int v = par[fr];
		if (act[v] > 1) return cout << "First", 0;
		act[par[v]] --;
		st.erase({-h[v], v});
		st.erase({-h[fr], fr});
	}
	cout << "Second";
	return 0;
}

Measured memory_bytes: 11648
#include <stdio.h>
    #include <string.h>
     
    int main(void) {
    	int N,i,A=0,b=0,j,c=0;
    	scanf("%d",&N);
    	int s[100];
    	for(i=1;i<=N;i++){
    		scanf("%d",&s[i-1]);
    	}
    	for(i=1;i<=N;i++){
    		A+=s[i-1];
    	}
     
    	for(j=1;j<=N;j++){
    		for(i=1;i<=N;i++){
    			if(s[i-1]>=s[i]){
    				b=s[i-1];
    				s[i-1]=s[i];
    				s[i]=b;
    			}
    		}
    		i=1;
    	}
    	if(A%10 != 0){
    		printf("%d",A);
                return 0;
    	}
    	else{
    		for(i=1;i<=N;i++){
    			if((A-s[i-1])%10!=0){
    				printf("%d",A-s[i-1]);
    				c=1;
    				goto aaaa;
    			}
    		}
    	}
    	aaaa:
    	if(c==0){
    		printf("0");
    	}
    	return 0;
    }

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct State{
    int at;
    ll cost;
    State(int a, ll c) : at(a), cost(c){}
    bool operator>(const State& s) const{
        return cost > s.cost;
    }
};

struct Edge{
    int to;
    ll cost;
    Edge(int t, ll c) : to(t), cost(c){}
};

using Graph = vector<vector<Edge> >;
const ll INF = 1e15;

ll previ[100005];

void dijkstra(int s, const Graph& G, vector<ll>& minc){
    minc.assign(G.size(), INF);
	rep(i,100005) previ[i] = -1;
    priority_queue<State, vector<State>, greater<State> > pq;
    pq.emplace(s, 0);
    minc[s] = 0;
    while(!pq.empty()){
        State cur = pq.top();
        pq.pop();
        if(minc[cur.at] < cur.cost) continue;
        for(const Edge& e : G[cur.at]){
            ll cost = cur.cost + e.cost;
            if(minc[e.to] <= cost) continue;
            minc[e.to] = cost;
			previ[e.to] = cur.at;
            pq.emplace(e.to, cost);
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    Graph g1(n);
    for(int i = 0; i < m; i++){
        int u, v;
        ll a = 1, b = 1;
        cin >> u >> v;
        u--; v--;
        g1[u].emplace_back(v, a);
        g1[v].emplace_back(u, a);
    }
    vector<ll> minc1(n, INF);
    dijkstra(0, g1, minc1);
	cout << "Yes" << endl;
	for(int i = 1; i < n; i++){
		cout << previ[i] + 1 << endl;
	}
    return 0;
}

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

string s;
int ans = 0;

int main() {
    cin >> s;

    for (int i = 0; i < s.size(); ++i)
    {
        if (s.at(i) == '+')
        {
            ans++;
        }

        if (s.at(i) == '-')
        {
            ans--;
        }     
    }

    cout << ans << endl;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}
template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

struct UF
{
    vi par, sizes;

    UF() {}
    UF(int size) : par(size, -1), sizes(size, 1) {
	rep(i, size) par[i] = i;
    }

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

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

    int size(int x)
    {
	return sizes[root(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];
	sizes[y] = 0;
    }
};

llint n, m;
int a[100001];
int b[100001];

int main()
{
    ci >> n >> m;
    rep(i, m) ci >> a[i] >> b[i];

    vl v;
    
    UF uf(n + 1);
    llint sum = n * (n - 1) / 2;

    for(int i = m - 1; i >= 0; i--) {
	v.push_back(sum);
	
	if(!uf.same(a[i], b[i])) {
	    sum -= uf.size(a[i]) * uf.size(b[i]);
	    uf.unite(a[i], b[i]);
	}
    }

    for(int i = v.size() - 1; i >= 0; i--) co << v[i] << en;

    return 0;
}


Measured memory_bytes: 3828
d = []          # コスト distance

# input
V, E, r = list(map(int, input().split(' ')))
edges = [list(map(int, input().split(' '))) for i in range(E)]

def bellman_ford(s):
    global d
    d = [float('inf') for i in range(V)]
    d[s] = 0

    for i in range(V-1):
        for s, t, w in edges:
            if d[t] > d[s] + w:
                d[t] = d[s] + w

    for s, t, w in edges:
        if d[s] + w < d[t]: return False
    return True

if bellman_ford(r):
    for w in d:
        if w == float('inf'):
            print('INF')
        else:
            print(w)
else:
    print('NEGATIVE CYCLE')


Measured memory_bytes: 6124
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000009
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
 
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
 
 
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

char s[27],t[27];
vector<string>res;
int main(){
    //freopen("atlarge.in","r",stdin);
    //freopen("atlarge.out","w",stdout);
    //cout<<setprecision(9)<<fixed;
    int j,i,k,ca=0,m=0,n;
    scanf("%s",s);
    n=strlen(s);
    int v[26]={0},vis[26]={0};
    strcpy(t,s);
    per(i,0,n){
        j=s[i]-'a';
        memset(v,0,sizeof(v));
        rep(k,0,i)v[s[k]-'a']=1;
        rep(k,j+1,26)if(!v[k]){
            v[k]=1;
            s[i]=k+'a';
            s[i+1]=0;
            res.pb(string(s));
            goto tt;
        }
    }
    tt:;
    if(n<26){
        memset(v,0,sizeof(v));
        rep(i,0,n)v[t[i]-'a']=1;
        rep(i,0,26)if(!v[i]){t[n++]=i+'a';break;}
        t[n]=0;
        res.pb(string(t));
    }
    if(SZ(res)==0)puts("-1");
    else{
        sort(all(res));
        //for(auto &s:res)DBG(s)
        puts(res[0].c_str());
    }
    //cerr<<1.*clock()/CLOCKS_PER_SEC<<"ms"<<"\n";
    return 0;
}   


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

int main(){
    string S;
    cin >> S;
    ll ans = 0,max = 0;
    for(ll i = 0; i < S.size(); i++){
        if(S[i] == 'A'|| S[i] == 'C'|| S[i] == 'G'|| S[i] == 'T'){
            ans++;
            if(max < ans) max = ans;
        }
        else ans = 0;
    }
    cout << max << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> vec1(2);
  cin >> vec1.at(0);
  cin >> vec1.at(1);
  
  vector<int> vec2(2);
  cin >> vec2.at(0);
  cin >> vec2.at(1);
  
  vector<int> vec12(2);
  vec12.at(0) = vec2.at(0) - vec1.at(0);
  vec12.at(1) = vec2.at(1) - vec1.at(1);
  
  vector<int> vec23(2);
  vec23.at(0) = -vec12.at(1);
  vec23.at(1) = vec12.at(0);

  
  vector<int> vec3(2);
  vec3.at(0) = vec2.at(0) + vec23.at(0);
  vec3.at(1) = vec2.at(1) + vec23.at(1);

  
  vector<int> vec34(2);
  vec34.at(0) = -vec23.at(1);
  vec34.at(1) = vec23.at(0); 
  
  vector<int> vec4(2);
  vec4.at(0) = vec3.at(0) + vec34.at(0);
  vec4.at(1) = vec3.at(1) + vec34.at(1);
  cout << vec3.at(0)<<" "<<vec3.at(1)<<" "<< vec4.at(0)<<" " << vec4.at(1) <<endl;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
res = (-1, -1, -1)
for i in range(n + 1):
    for j in range(n + 1 - i):
        if n - i - j >= 0 and 10000*i + 5000*j + 1000*(n - i - j) == y:
            res = (i, j, n - i - j)
print(res[0], res[1], res[2])

Measured memory_bytes: 9140
#include <iostream>
#include <vector>

int main(){
	//加算上限
	const int max = 20;
	
	int num_of_fig;
	std::cin >> num_of_fig;
	std::vector<int> formula(num_of_fig);
	for(int i = 0; i < num_of_fig; ++i){
		std::cin >> formula[i];
	}
	
	//各項までの加算減算による合計値が0~maxならば+1する
	std::vector<std::vector<unsigned long long>> total(num_of_fig);
	for(int i = 0; i < num_of_fig; ++i){
		total[i].resize(max+1, 0);
	}
	total[0][formula[0]] = 1;
	
	for(int i = 0; i < num_of_fig - 2; ++i){
		for(int j = 0; j <= max; ++j){
			//加算して上限以上ならばその数式はアウト
			if(j + formula[i+1] <= max){
				total[i+1][j + formula[i+1]] += total[i][j];
			}
			//減算して0未満ならばその数式はアウト
			if(j - formula[i+1] >= 0){
				total[i+1][j - formula[i+1]] += total[i][j];
			}
		}
	}
	
	std::cout << total[num_of_fig - 2][formula[num_of_fig - 1]] << std::endl;
	
	return 0;
}

Measured memory_bytes: 1212
N = int(input())
LP = list(map(int, input().split()))

cnt = 0
for i in range(N-2):
    LA = []
    LB = []
    LA.append(LP[i])
    LA.append(LP[i+1])
    LA.append(LP[i+2])
    LB = sorted(LA)
    if LA[1] == LB[1]:
        cnt += 1
print(cnt)

Measured memory_bytes: 9200
#include <iostream>
#include <string>

int main()
{
    std::string S, T;
    std::cin >> S >> T;

    if (S.length() + 1 != T.length())
    {
        std::cout << "No" << std::endl;
        return 0;
    }

    if (T.find(S) != 0)
    {
        std::cout << "No" << std::endl;
        return 0;
    }

    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int div(int a)
{
    int d=1;
    for(int i=1; i<(a/2);i++)
    {
        if(a%i==0)
        {
            d++;
        }
    }
    return d;
}

int main(){
    int n;
    cin>>n;
    int k=0;
    for(int i=1;i<=n;i=i+2)
    {
        if(div(i)==8)
        {
        
            k++;
        }
    }
    
    cout<<k;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int x,y,s;
main()
{
	while(cin>>x>>y>>s,s)
	{
		int ans=0;
		for(int i=1;i<s;i++)
		{
			for(int j=i;j<s;j++)
			{
				if(i*(100+x)/100+j*(100+x)/100!=s)continue;
				ans=max(ans,i*(100+y)/100+j*(100+y)/100);
			}
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N;
	cin >> N;

	vector<ll> A(N);
	for (ll i = 0; i < N; ++i) cin >> A[i];
	
	ll ans = 0;
	
	for (ll i = 0; i < N; ++i)
	{
		if ((i+1) % 2 != 0 && A[i] % 2 != 0) ans++;
	}

	cout << ans << endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#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(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

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

const int64 mod = 1e9+7;

int main(void){
	double D, E;
	while(cin >> D >> E && D+E){
		double res = INF;
		REP(i, D+1){
			res = min(res, abs(sqrt(i*i+(D-i)*(D-i))-E));
		}
		cout << fixed << setprecision(10) << res << endl;
	}
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll modPow(ll a, ll n, ll p) {
  if (n == 0) return 1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}
ll choose(ll n, ll r, ll mod){
    ll mul = 1, div = 1;
    for(ll i = 0; i < r; i++){
        mul *= n - i;
        div *= i + 1;
        mul %= mod;
        div %= mod;
    }   
    return mul * modPow(div, mod - 2, mod) % mod;
}
 
int main(){
  int n, m;
  cin >> n >> m;
  vector<int>tree(100100);
  rep(i, 0, m){
    int a, b;
    cin >> a >> b;
    tree[a]++;
    tree[b]++;
  }
  rep(i, 1, n+1){
    if(tree[i]%2==1){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

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

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



int main(){
    cin >> N;
    vector<ll> a(N+1) , b(N);

    REP(i, N+1) cin >> a[i];
    REP(i,N) cin >>b[i];

    ll ans = 0;

    for(int i = 0; i < N; ++i){
        if(b[i] > a[i]){
            ans += min(b[i], a[i] + a[i+1]); 
            a[i + 1] = max(0LL, a[i+ 1] + a[i] - b[i]);
            a[i] = 0;
            
        }
        else {
            ans += b[i];
            a[i] -= b[i];
        }
    }
    //REP(i,N+1) cout << a[i] << " " ;
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    i64 ret = 0;
    int min = 1;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        if (a == min) min++;
        else ret += (a - 1) / min;

        if (min == 1) min++;
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
using namespace std;
struct S{string s;int x1,x2,y1,y2;vector<int>v;};
vector<S>v;
void F(char*&p,int n)
{
	S s;
	char*q;
	int i;
	for(++p;*p-'>';++p)s.s.push_back(*p);
	++p;
	int *a[]={&s.x1,&s.y1,&s.x2,&s.y2};
	for(i=0;i<4;++i)
	{
		*a[i]=strtol(p,&q,10);
		p=q;
		if(i-3)++p;
	}
	v.push_back(s);
	i=v.size()-1;
	v[n].v.push_back(i);
	while(p[1]-'/')F(p,i);
	p+=3+s.s.size();
}
int G(int x,int y)
{
	int r=0,i;
N:
	for(i=0;i<v[r].v.size();++i)
	{
		S&s=v[v[r].v[i]];
		if(s.x1<=x&&x<=s.x2&&s.y1<=y&&y<=s.y2)
		{
			r=v[r].v[i];
			goto N;
		}
	}
	return r;
}
int main()
{
	int n,x,y,i;
	char*t,s[1024];
	S p={"_",0,0,10000,10000};
	while(scanf("%d",&n),n)
	{
		v.clear();
		scanf("%s",s);
		v.push_back(p);
		F(t=s,0);
		while(n--)
		{
			scanf("%d%d",&x,&y);
			i=G(x,y);
			if(i)printf("%s %d\n",v[i].s.c_str(), v[i].v.size());
			else puts("OUT OF MAIN PANEL 1");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>
#include <cstdio>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
//priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

llint n;

void solve(){
  cin >> n;
  llint a[n];
  llint s=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    s+=a[i];
  }
  sort(a,a+n);
  cout << a[0] << " " << a[n-1] << " " << s << endl;
}

int main() {
  solve();
  return 0;
}



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

int main(){
    int n,t,a;
    cin>>n>>t>>a;
    int minv=INT_MAX;
    int ans=0;
    rep(i,n){
        int h;
        cin>>h;
        int c;
        c=t*1000-h*6-a*1000;
        if(c<0) c=-c;
        if(minv>c){
            minv=c;
            ans=i;
        }
    }
    cout<<ans+1<<"\n";
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	int n;
	string s;
	cin >> n >> s;
	
	string ans;
	for (int b = 0; b < 4;b++) {
		vector<bool> isSheep(n, false);

		isSheep[0] = (b & 1);
		isSheep[1] = ((b >> 1) & 1);

		for (int i = 2; i < n;i++) {
			if (isSheep[i - 1] ^ s[i - 1] == 'o') {
				isSheep[i] = !isSheep[i - 2];
			}
			else {
				isSheep[i] = isSheep[i - 2];
			}
		}

		if ((isSheep[n - 2] ^ isSheep[0]) == (isSheep[n - 1] ^ s[n - 1] == 'o') && (isSheep[n - 1] ^ isSheep[1]) == (isSheep[0] ^ s[0] == 'o')) {
			string tmp(n, ' ');
			for (int i = 0; i < n;i++) {
				tmp[i] = isSheep[i] ? 'S' : 'W';
			}
			ans = tmp;
		}
	}

	if (ans.length() == 0) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}

}





Measured memory_bytes: 640
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    n = int(sys.stdin.readline())
    def num2alpha(num):
        if num<=26:
            return chr(64+num)
        elif num%26==0:
            return num2alpha(num//26-1)+chr(90)
        else:
            return num2alpha(num//26)+chr(64+num%26)

    print(num2alpha(n).lower())
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 9468
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << a + b + c + d << endl;
}


Measured memory_bytes: 3084
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()

int main() {
		ll W, H, x, y;
		cin >> W >> H >> x >> y;
		printf("%.9lf ", (double)W*H/2);
		if (W == x*2 && H == y*2) {
				cout << "1" << endl;
		} else {
				cout << "0" << endl;
		}
		return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline

    import math
    N = int(input())

    if N % 2 != 0:
        print(0)
        exit()
    else:
        num_zeros = N // 10
        N_head = N//10
        for i in range(1, 25):
            num_zeros += (N_head)//(5**i)
    print(num_zeros)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef pair<string, int> P;


bool comp(const P& a,const P& b){
    if(a.first != b.first) return a.first < b.first;
    return a.second > b.second;
}


int main(){
    int N; cin >> N;
    P a[110];
    int m[110];

    for(int i=0; i<N; i++){
        P p;
        cin >> p.first >> p.second ;
        m[p.second]=i+1;
        a[i]=p;
    }
    sort(a, a+N, comp);
    for(int i=0; i<N; i++){
        cout <<  m[a[i].second] << endl;
    }

}

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

using namespace std;

using ll = long long;

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

    constexpr ll MOD = 1e9 + 7;

    int n;
    string s;
    cin >> n >> s;

    vector<vector<ll>> dp(2, vector<ll>(n + 1));
    auto &cur = dp[0], &nxt = dp[1];

    for (int i = 1; i <= n; ++i) cur[i] = 1;
    for (int i = 2; i <= n; ++i) {
        for (int j = 1; j <= n - i + 2; ++j) {
            cur[j] += cur[j - 1];
            nxt[j] = 0;
        }

        for (int j = 1; j <= n - i + 1; ++j) {
            if (s[i - 2] == '<') (nxt[j] += (cur[j] - cur[0] + MOD)) %= MOD;
            else (nxt[j] += (cur[n - i + 2] - cur[j] + MOD)) %= MOD;
        }
        swap(cur, nxt);
    }

    cout << cur[1] << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
    int a,b,d,r;
    double f;
    cin >> a >> b;
    r = a % b;
    d = (a - r) / b;
    f = 1.0 * a / b;
    printf("%d %d %.5lf\n",d, r, f);
    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll n; cin >> n;
    vector<ll> plus(n);
    vector<ll> minus(n);

    for (int i = 0; i < n; ++i) {
        ll x, y; cin >> x >> y;
        plus[i] = x + y;
        minus[i] = x - y;
    }
    sort(plus.begin(), plus.end());
    sort(minus.begin(), minus.end());
    cout << max(plus[n - 1] - plus[0], minus[n - 1] - minus[0]) << endl;
}

Measured memory_bytes: 6428
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
#include<list>
#include <stdio.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)
#pragma GCC optimize("Ofast")



int main() {
	int n;
	cin >> n;
	vector<int>d(n);
	rep(i, n)cin >> d[i];
	sort(d.begin(), d.end());
	cout << d[n / 2] - d[n / 2 - 1] << endl;

	return 0;
}


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

public class Main {

    public static void main(String[] args) {
        try {
            BufferedReader stdReader = 
                    new BufferedReader( new InputStreamReader(System.in));
            String sStr = stdReader.readLine();

            String[] inputStr = sStr.split(" ");
            int input1 = Integer.valueOf(inputStr[0]).intValue();
            int input2 = Integer.valueOf(inputStr[1]).intValue();
            int input3 = Integer.valueOf(inputStr[2]).intValue();

            if (input1 < input2 && input2 < input3) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        } 
    }
}

Measured memory_bytes: 24396
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
int a[2200005];
int f[23][2200005],n,k,g[23][2200005],m,len,ans;
char s[2000005];
int main()
{
	n=read();m=read();
	for(int i=0;i<=n;i++)
	{
		scanf("%s",s);
		int x=strlen(s);
		for(int j=0;j<x;j++)
		{
			if(s[j]=='1')
			f[i][j]=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<(1<<i);j++)
		{
			int b=j>>(i-1)&1;int k;
			for(k=0;k<i&&(j>>i-k-1&1)==b;k++);
			g[i][j]=i==k?-1:k;
		}
	}
	for(int i=0;i<=n;i++)
	{
		for(int j=1;i+j<=n;j++)
		{
			for(int k=0;k<1<<i+j;k++)
			{
				f[i][k>>j]+=f[i+j][k];
				int t=g[j][k&(1<<j)-1];
				if (~t)
				{
					f[i+j-t][(k>>j<<j-t)|(k&(1<<j-t)-1)]+=f[i+j][k];
				}
			}
		}
		for(int j=(1<<i)-1;~j;--j)
		{
    		if(f[i][j]>=m)
			{
				len=i,ans=j;
    		}
		}
	}
	for(int i=len-1;~i;--i)
	{
		putchar((ans>>i&1)+'0');
	}
}


Measured memory_bytes: 99712
import java.util.*;

class Main {
    public static void main(String args[]) {
        String boin[] = {"a", "i", "u", "e", "o"};
        Scanner inp = new Scanner(System.in);
        String c = inp.next();
        inp.close();
        for (int i = 0; i < 5; i++) {
            if (boin[i].equals(c)) {
                System.out.println("vowel");
                return;
            }
        }
        System.out.println("consonant");
    }
}

Measured memory_bytes: 22996
//Subhash Suman
//Description :

#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;
const int N = 1e2 + 5;
char arr[N][N];
int dp[N][N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            dp[i][j] = 1e5;
            cin >> arr[i][j];
        }
    }
    dp[0][0] = 0;
    if (arr[0][0] == '#')
    {
        dp[0][0] = 1;
    }
    for (int i = 1; i < h; i++)
    {
        if (arr[i][0] != arr[i - 1][0] && arr[i][0] == '#')
        {
            dp[i][0] = dp[i - 1][0] + 1;
        }
        else
        {
            dp[i][0] = dp[i - 1][0];
        }
    }
    for (int j = 1; j < w; j++)
    {
        if (arr[0][j] != arr[0][j - 1] && arr[0][j] == '#')
        {
            dp[0][j] = dp[0][j - 1] + 1;
        }
        else
        {
            dp[0][j] = dp[0][j - 1];
        }
    }
    for (int i = 1; i < h; i++)
    {
        for (int j = 1; j < w; j++)
        {
            if (arr[i][j] != arr[i][j - 1] && arr[i][j] == '#')
            {
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
            }
            else
            {
                dp[i][j] = min(dp[i][j], dp[i][j - 1]);
            }
            if (arr[i][j] != arr[i - 1][j] && arr[i][j] == '#')
            {
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
            }
            else
            {
                dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            }
        }
    }
    cout << dp[h - 1][w - 1] << '\n';
    return 0;
}

Measured memory_bytes: 256
void main()
{
    int n = readln.chomp.to!int;

    int t, x, y;
    bool ok = true;
    foreach (i; 0 .. n)
    {
        int[] tmp = readln.split.to!(int[]);
        int ti = tmp[0], xi = tmp[1], yi = tmp[2];
        int len = abs(xi - x) + abs(yi - y);

        if (ti - t < len)
        {
            ok = false;
        }
        else if ((ti - t) % 2 != len % 2)
        {
            ok = false;
        }

        t = ti, x = xi, y = yi;
    }

    writeln(ok ? "Yes" : "No");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 1276
let split = Str.split (Str.regexp_string " ");;

let () =
  let word = read_line () in
  let rec read ct =
    let sentence = read_line () in
    let s = sentence |> split in
    let count = List.fold_left (fun x y -> if String.uppercase y = String.uppercase word then x+1 else x) 0 s in
    if String.trim sentence = "END_OF_TEXT"  then (ct+count)
    else read (ct+count)
  in
  Printf.printf "%d\n" (read 0);;

Measured memory_bytes: 2252
#include <cstdio>
#include <cstring>
#define MAXN 1000010
#define LL long long

struct edge{
	int to,next;
	edge(int _to=0,int _next=0):to(_to),next(_next){}
}e[MAXN<<1];

int n,m;
int g[MAXN],nume;
int p[MAXN][5],nump;
int e2[MAXN][2];
int f[MAXN],visit[MAXN];
int cnt[MAXN];

void addEdge(int u,int v){
	e[nume]=edge(v,g[u]);
	g[u]=nume++;
	e[nume]=edge(u,g[v]);
	g[v]=nume++;
}

int getf(int x){
	if(x==f[x]) return x;
	return f[x]=getf(f[x]);
}

void dfs(int x){
	visit[x]=1;
	for(int i=g[x];~i;i=e[i].next)
		if(!visit[e[i].to]){
			f[getf(e[i].to)]=getf(x);
			dfs(e[i].to);
		}
}

int main(){
#ifdef DEBUG
	freopen("F.in","r",stdin);
#endif
	memset(g,-1,sizeof g);
	scanf("%d%d",&n,&m);
	for(int j=0;j<5;j++)
		for(int i=1;i<=n;i++) 
			p[i][j]=++nump;
	for(int i=1;i<=nump;i++) f[i]=i;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&e2[i][0],&e2[i][1]);
		int u=e2[i][0],v=e2[i][1];
		addEdge(p[u][0],p[v][1]);
		addEdge(p[u][1],p[v][2]);
		addEdge(p[u][2],p[v][0]);
		addEdge(p[u][2],p[v][4]);
		addEdge(p[u][3],p[v][2]);
		addEdge(p[u][4],p[v][3]);
	}
	for(int i=1;i<=nump;i++)
		if(!visit[i])
			dfs(i);
	for(int i=1;i<=n;i++) cnt[getf(p[i][3])]++;
	LL ans=0;
	for(int i=1;i<=n;i++)
		ans+=cnt[getf(p[i][0])];
	for(int i=1;i<=m;i++)
		if(getf(p[e2[i][0]][0])!=getf(p[e2[i][1]][3]))
			ans++;
	printf("%lld\n",ans);
}



Measured memory_bytes: 45568
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}

void out(pair<int,char> a[],int n){
  lp(i,n){
    if(i!=0) cout<<" ";
    cout<<a[i].second<<a[i].first;
  }
  cout<<endl;
  return;
}

int main(){
  int n;
  cin>>n;
  pair<int,char> a[40],b[40];
  lp(i,n){
    int memo;
    char memo2;
    cin>>memo2>>memo;
    a[i]=make_pair(memo,memo2);
    b[i]=a[i];
  }
  lp(i,n-1){
    for(int j=n-1;j>i;j--){
      if(a[j].first<a[j-1].first)
	swap(a[j],a[j-1]);
    }
  }
  out(a,n);
  cout<<"Stable"<<endl;
  lp(i,n){
    int minj=i;
    for(int j=i;j<n;j++){
      if(b[j].first<b[minj].first)
	minj=j;
    }
    swap(b[i],b[minj]);
  }
  int check=0;
  lp(i,n){
    if(a[i]!=b[i]){
      check=1;
      break;
    }
  }
  out(b,n);
  if(check==0){
    cout<<"Stable"<<endl;
  }
  else cout<<"Not stable"<<endl;
  return 0;
}



Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int i=1;
		int temp=1;
		
		while((temp=sc.nextInt())!=0)
		{
			System.out.println("Case "+(i++)+": "+temp);
		}
		
		

	}
}



Measured memory_bytes: 41356
from collections import namedtuple

sword = namedtuple('sw', ('wield', 'throw'))


def main() -> None:
    n, h = map(int, input().split())
    cnt = 0

    swords = []
    for i in range(n):
        a, b = map(int, input().split())
        swords.append(sword(wield=a, throw=b))

    swords.sort(key=lambda x: x.throw, reverse=True)
    swords.sort(key=lambda x: x.wield)
    main_sword = swords.pop()
    swords.sort(key=lambda x: x.throw)

    while h > 0:
        cnt += 1
        if main_sword.throw >= h:
            h -= main_sword.throw
        elif len(swords) > 0 and main_sword.wield < swords[-1].throw:
            h -= swords.pop().throw
        else:
            h -= main_sword.throw
            cnt += 1 + (h - 1) // main_sword.wield
            break

    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19244
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, i;
	cin >> n;
	double t=0;
	for (i=1; i<=n; i++)
	{
		double a1;
		string a2;
		cin >> a1 >> a2;
		if (a2=="JPY") t+=a1;
		if (a2=="BTC") t+=(a1*380000);
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
	
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if((a+b+c)>=22){
			System.out.println("bust");
			} else System.out.println("win");
		}
	}

Measured memory_bytes: 21844
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	
	string s[3];
	for(int i=0;i<3;i++) cin >> s[i];
	queue<int> q[3];
	for(int i=0;i<3;i++){
		for(int j=0;j<s[i].length();j++){
			q[i].push((int)(s[i][j] - 'a'));
		}
	}
	
	int now = 0;
	while(true){
		if(q[now].size() == 0){
			cout << (char) ('A' + now) << endl;
			return 0;
		}
		int nxt = q[now].front();
		q[now].pop();
		now = nxt;
	}
	
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv;

void main() {
  auto s = map!(x => x.to!int)(readln.chomp.split);
  int n = s[0], a = s[1], b = s[2];

  int res = 0;
  foreach (i; 1 .. n + 1) {
    auto t = i.to!(dchar[]);
    int sum = 0;
    foreach (j; 0 .. t.length) {
      sum += t[j] - '0';
    }
    if (a <= sum && sum <= b) res += i;
  }
  writeln(res);
}


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int main(){
  int n; cin >> n;
  vector<tii> v;
  rep(i,n){
    int a,b; cin >> a >> b;
    v.pb(tii{b,a});
  }
  sort(ALL(v));
  int now = 0;
  rep(i,n){
    int a,b; tie(b,a) = v[i];
    now += a;
    if(now > b){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 2420