akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	String a = sc.next();
      	String b = sc.next();
      	String c = sc.next();
      	
      	if ((a.charAt(a.length() - 1) == b.charAt(0)) && 
            (b.charAt(b.length() - 1) == c.charAt(0))) {
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21204
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    /*
    vector<pii> v;
    int n; cin >> n;
    rep(i, n) {
        int a; cin >> a;
        v.push_back({a, i});
    }
    sort(v.begin(), v.end());
    int ans[n];
    rep(i, n) {
        if (v[i].second < n / 2) {
            
        }
    }
    */
    vector<int> v;
    int n; cin >> n;
    int a[n];
    rep(i, n) {
        cin >> a[i];
        v.push_back(a[i]);
    }
    sort(v.begin(), v.end());
    int medleft = v[n / 2 - 1];
    int medright = v[n / 2];
    int ans = 0;
    rep(i, n) {
        //小さいの引っこ抜く
        //medは大きい方
        if (a[i] <= medleft) {
            cout << medright << endl;
        } else {
            cout << medleft << endl;
        }
    }
}


Measured memory_bytes: 3956
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <algorithm>
#include <functional>
#include <utility>
#define typeof(x) __typeof__(x)
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

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

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


signed main()
{
  int N; cin >> N;
  vec<int> a(N);
  rep(i, 0, N) {
    cin >> a[i];
  }

  vec<P> x(N+1);
  rep(i, 0, N) {
    x[i] = MP(a[i], i);
  }
  x[N] = MP(0, -1);
  RSORT(x);

  vec<int> ans(N);
  int MIN = 1e9;
  rep(i, 0, N) {
    MIN = min(MIN, x[i].second);
    ans[MIN] += (i+1)*(x[i].first - x[i+1].first);
  }

  rep(i, 0, N) {
    cout << ans[i] << endl;
  }

  return 0;
}


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

const string numbers[10] = {
    "0111111",
    "0000110",
    "1011011",
    "1001111",
    "1100110",
    "1101101",
    "1111101",
    "0100111",
    "1111111",
    "1101111"
};

string convert( int k, string prev )
{
    string answer;
    for ( int i = 0; i < 7; i++ ) {
        if ( numbers[k][i] == prev[i] ) {
            answer += '0';
        } else {
            answer += '1';
        }
    }
    return answer;
}

int main( void )
{
    int n;
    while ( cin >> n && n != -1 ) {
        string prev = "0000000";
        for ( int i = 0; i < n; i++ ) {
            int k;
            cin >> k;
            cout << convert( k, prev ) << endl;
            prev = numbers[k];
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m,k;
  cin>>n>>m>>k;
  vector<int> a(n),b(m);
  rep(i,n){
    cin>>a[i];
    if(i!=0) a[i]+=a[i-1];
  }
  rep(i,m){
    cin>>b[i];
    if(i!=0) b[i]+=b[i-1];
  }
  int ans=0;
  int num=0;
  int aaa=0;
  rep(i,n){
    num=k-a[i];
    if(num<0) break;
    auto itr=upper_bound(b.begin(),b.end(),num);
    ans+=i+1;
    ans+=(itr-b.begin());
    //cout<<(itr-b.begin())<<endl;
    aaa=max(aaa,ans);
    ans=0;
  }
  auto itr=upper_bound(b.begin(),b.end(),k);
  ans+=(itr-b.begin());
  aaa=max(aaa,ans);
  cout<<aaa<<endl;

  return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> v;
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    int cnt = 0;
    for (int i = 0; i < N && cnt < M; i++) {
        int m = min(M - cnt, v[i].second);
        cnt += m;
        ans += (ll)m * v[i].first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4320
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define amari (x) x % 1000000007;

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end());
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>());
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin();
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin();

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

int N, M;
int sx, sy;
int gx, gy;
char maze[500][500];
int d[500][500];

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

  int N, Q;
  string S;
  cin >> N >> Q;
  cin >> S;

  vector<int> lr(Q*2);
  for (int i = 0; i < Q; i++) {
    scanf("%d %d", &lr[i*2], &lr[i*2+1]);
  }
  vector<int> ac(0); 

  bool a = false;
  for (int i=0; i < N; i++) {
    if (S[i] == 'A') {
      a = true;
    } else {
      if (a && S[i] == 'C') {
        ac.push_back(i-1);
      }
      a = false;
    }
  }
  ac.push_back(INF);

  // rep(i, ac.size())
  // {
  //   printf("%d\n", ac[i]);
  // }

  for (int i=0; i < Q; i++) {
    int l = lr[i*2];
    int r = lr[i*2+1];
    int lb1 = ubv(ac, l-2);
    int lb2 = lbv(ac, r-1);
    printf("%d\n", max(lb2 - lb1, 0));
  }

  return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
#define test ll t;cin>>t;while(t--)
#define f first
#define s second
#define pb push_back
#define pop pop_back
#define int long long int
#define mod 1000000007
#define inf 1LL<<60

int dp[3001][3001];
int sum[3001][3001];

int solve(vector<int> &v,int i,int j)
{
    if(i==j)
    return 0;

    if(dp[i][j]!=-1)
        return dp[i][j];
        
    int mincost = inf;
    
    for(int k=i;k<j;k++)
    {
        mincost =  min(mincost, sum[i][j]+solve(v,i,k)+solve(v,k+1,j));
    }
    
      return dp[i][j] = mincost;
      
}


void presolve(vector<int> &v,int n)
{

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            sum[i][j]=v[j]+((i==j)?0:sum[i][j-1]);
        }
    }
}

int32_t main()
{
	fast;
	int n;
    cin>>n;
    vector<int>v(n+1);

    memset(dp,-1,sizeof dp);

    for(int i=1;i<=n;i++)
        cin>>v[i];

    presolve(v,n);
    
    cout<<solve(v,1,n);


	return 0;
}





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

int main() {
  int H,W,K,Ans=0;
  cin>>H>>W>>K;
  char X;
  
 vector<vector<int>> data(H, vector<int>(W));
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> X;
      if(X=='#'){data.at(i).at(j)=1;}
    }
  }

  for (int bit = 0; bit < (1<<H); ++bit){
    for (int bit2 = 0; bit2 < (1<<W); ++bit2){
        int sum = 0;
        for (int i = 0; i < H; ++i) {
          for(int j = 0; j < W; ++j){
            if (bit & (1<<i)){
              if(bit2 & (1<<j)){
                sum += data.at(i).at(j);
              }
            }
          }
        }
      if(sum==K){Ans++;}
    }
  }
  cout<<Ans<<endl;
}


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

using namespace std;

const int MAXM = 1005;
const int MAXN = 12;
const int oo = 1000000007;

int n, m, a[MAXM], b[MAXM], dp[MAXM][1<<MAXN];

int main() {
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; ++i) {
        int k;
        scanf("%d%d", &a[i], &k);
        for(int j = 0; j < k; ++j) {
            int x; scanf("%d", &x);
            b[i] |= 1 << (x-1);
        }
    }

    for(int i = 0; i <= m; ++i)
        for(int j = 0; j < (1<<n); ++j)
            dp[i][j] = oo;

    dp[0][0] = 0;
    for(int i = 0; i < m; ++i) {
        for(int mask = 0; mask < (1<<n); ++mask) {
            dp[i+1][mask] = min(dp[i+1][mask], dp[i][mask]);
            dp[i+1][mask | b[i]] = min(dp[i+1][mask | b[i]], dp[i][mask] + a[i]);
        }
    }

    int ans = dp[m][(1<<n)-1];
    if (ans == oo)
        ans = -1;
    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 16256
h, w = map(int, input().split())
a = []
delcol = []
cnt = 0

for i in range(h):
    b = list(input())
    if set(b) == {"."}:
            continue
    a.append(b)

for i in range(w):
    for j in range(len(a)):
        if a[j][i] != ".":
            break
        else:
            cnt += 1
        if cnt == len(a):
            delcol.append(i)
    cnt = 0

for i in delcol [::-1]: #列を削除
    for j in range(len(a)):
        del a[j][i]

for i in range(len(a)):
    print(*a[i], sep="")

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string str;
    while (cin >> str) {
        bool flag = false;
        for (const char &c : str)
            if (c == '7') flag = true;
        cout << (flag ? "Yes\n" : "No\n");
    }
    return 0;
}

Measured memory_bytes: 3596
void main() {
	auto N = ri;
	auto tmp_t = 0;
	auto tmp_x = 0, tmp_y = 0;
	foreach(i; 0..N) {
		auto ip2 = readAs!(int[]), t = ip2[0], x = ip2[1], y = ip2[2];
		auto d = abs(x - tmp_x) + abs(y - tmp_y);
		if(d <= t - tmp_t && (t & 1) == (d & 1)) {
			continue;
		} else {
			"No".writeln;
			return;
		}
	}
	"Yes".writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

T[] deepcopy(T)(T[] a) {
	static if(isArray!T) {
		T[] res;
		foreach(i; a) {
			res ~= deepcopy(i);
		}
		return res;
	} else {
		return a.dup;
	}
}

Measured memory_bytes: 1276
//Swarina Jaiswal

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

#define ll long long
#define ld long double
#define endl "\n"
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout); 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
void solve() {
   ll a,b,c,d;
   cin>>a>>b>>c>>d;

   ll temp1 = a*c, temp2 = a*d, temp3 = b*c, temp4 = b*d;
   cout<< max(max(temp1, temp2), max(temp3, temp4)) <<endl;
}


int main() {
  #ifndef ONLINE_JUDGE
  OJ
  #endif
  fast;
    int t=1;
    //cin>>t;

    while(t--)
    solve();
 
return 0;  

}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        while (true) {
            String line = reader.readLine();
            if (line == null) {
                break;
            }
            if (line.isEmpty()) {
                continue;
            }
            int beginIndex = 0;
            int count = 0;
            for (int i = 0; i < 8; i++) {
                if (count < 4) {
                    for (int j = 0; j < 8; j++) {
                        if (line.charAt(j) == '1') {
                            count++;
                            if (count == 1) {
                                beginIndex = i * 8 + j;
                            } else if (count == 4) {
                                int length = i * 8 + j - beginIndex + 1;
                                out.println(chars[length]);
                                break;
                            }
                        }
                    }
                }
                line = reader.readLine();
            }
        }
    }

    private static final char[] chars = { 0, 0, 0, 0, 'C', 0, 0, 0, 0, 'G',
            'A', 'E', 0, 0, 0, 0, 'D', 0, 'F', 0, 0, 0, 0, 0, 0, 'B' };
}

Measured memory_bytes: 10000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	vector<char>a;
	for(char i='a';i<='z';i++)
	{
		a.push_back(i);
	}
//	cout<<a[0];
	string res="";
	ll n; cin>>n;
//	cout<<475254%26;
  int turn=0;
	while(n>0)
	{
		//cout<<a[0];
		n--;
		int to=(n)%26;
		//cout<<to<<" ";
	
		res+=a[to];
		n/=26;
		turn++;
	}
reverse(res.begin(),res.end());
		cout<<res;
		
		
}

Measured memory_bytes: 3612
from collections import defaultdict, deque
h, w = map(int, input().split())
table = [list(map(int, input().split())) for _ in range(10)]
dd = defaultdict(int)
for _ in range(h):
    for x in map(int, input().split()):
        if x == -1:
            continue
        dd[x] += 1

INF = 10**9
scores = [INF]*10
decided = [0]*10
queue = deque()
trans_table = list(zip(*table))
for i in range(10):
    x = trans_table[1][i]
    scores[i] = x

MIN = min(set(scores) ^ {0})

while 0 in decided:
    for idx, score in enumerate(scores):
        if score <= MIN:
            decided[idx] = 1

    for i in range(10):
        if i == 1:
            continue
        if decided[i]:
            for j in range(10):
                if not decided[j]:
                    queue.append((i, j))

    while queue:
        i, j = queue.popleft()
        x = trans_table[i][j]
        scores[j] = min(scores[j], scores[i]+x)

    MIN += 1



ans = 0
for k, v in dd.items():
    ans += scores[k]*v
print(ans)


Measured memory_bytes: 3316
#include<stdio.h>
int main(void)
{
	int i,n,e,cnt;
	long long sum;
	scanf("%d",&n);
	sum=1;
	e=1000000000+7;
	for(i=1;i<=n;i++){
		cnt++;
		sum=(sum*cnt)%e;
	}
	printf("%d\n",sum%e);
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath> 
#include <tuple>
#include <bitset>
//pair sort firstに揃う

#define int long long
#define double long double
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define PairV vector<pair<int , int> >
#define F first
#define S second
#define Vector1 vector<int>
#define VectorS vector<string>
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define incin2(n,m) int (n),(m); cin >> (n)>>(m);
#define stcin(s) string (s); cin>>(s);
#define all(v) (v).begin() , (v).end()
namespace Mathf
{
    const int INF = 1000000000000;
    const double PI = 3.14159274;
    const double Rad2Deg = 57.29578;
    const double log2(double a,double b);
    const double log2(double a,double b){
        return log(b)/log(a);
    }
} // namespace Mathf

using namespace std;

int MD(pair<int,int> a,pair<int,int> b){//ManhattanDisRance
    return abs(a.first-b.first) + abs(a.second-b.second);
}
int MOD(int a,int b){
    return abs(a%b);
}
template <typename T1,typename T2> bool Comp (pair<T1,T2> a,pair<T1,T2> b){
    if(a.first!=b.first){
        return a.first<b.first;//first昇順
    }
    if(a.second!=b.second){
        return a.second > b.second;//second降順
    }else{
        return  true;
    }
}
signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    incin(r);
    Pr(r*r);
    return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int n;
vvi in;
vip out;
int dx[]={-1,0,0,0,1,1,1,-1,-1,2,0,0,-2};
int dy[]={0,-1,0,1,0,1,-1,1,-1,0,2,-2,0};
int co[4]={5,9,13};
bool f(int x,int y,int c){
	if(c==0){
		bool h=true;
		rep(i,10)rep(j,10)if(in[i][j])h=false;
		if(!h)return false;
		rep(i,n)cout<<out[i].first<<" "<<out[i].second.first<<" "<<
			out[i].second.second<<endl;
		return true;
	}
	int lx=inf;
	rep(i,10)rep(j,10)if(in[i][j]){lx=i;goto e;}
	e:;
	rep(i,10)rep(j,10){
		if(i+j==0)i=x,j=y;
		if(lx+2<i)return false;
		if(in[i][j]){
			rep(k,3){
				bool h=true;
				rep(l,co[k])if(i+dx[l]<0||j+dy[l]<0||i+dx[l]>=10||j+dy[l]>=10||in[i+dx[l]][j+dy[l]]==0)h=false;
				if(!h)break;
				out[c-1]=pip(j,pii(i,k+1));
				rep(l,co[k])in[i+dx[l]][j+dy[l]]--;
				if(f(i,j,c-1))return true;
				rep(l,co[k])in[i+dx[l]][j+dy[l]]++;
			}
		}
	}
	return false;
}
int main(){
	cin>>n;
	in=vvi(10,vi(10));
	out=vip(n);
	rep(i,10)rep(j,10)cin>>in[i][j];
	f(0,0,n);
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	int64_t A[300][300];
	int64_t B[300][300];
	cin >> N;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			cin >> A[i][j];
			B[i][j] = 1;
			if(i == j) B[i][j] = 0;
		}
	}
	// inversed warshall floyd
	for (int i = 0; i < N; i++) { // via
		for(int j = 0; j < N; j++) { // start
			for(int k = 0; k < N; k++) { // goal
				if(A[j][k] > A[j][i] + A[i][k]) { // invalid
					cout << -1 << endl;
					return 0;
				}
				if(A[j][k] == A[j][i] + A[i][k] && i != j && i != k) {
					B[j][k] = 0;
				}
			}
		}
	}
	int64_t L = 0;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			L += A[i][j] * B[i][j];
		}
	}
	cout << (L / 2) << endl;
	return 0;
}

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

using namespace std;

int main(int argc, char const* argv[])
{
    int a, b, c;
    cin >> a >> b >> c;

    if((b - a) == (c - b)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll N,M;cin>>N>>M;
    ll info[N];
    rep(i,N)cin>>info[i];
    sort(info,info+N);
    ll sum[N];
    sum[N-1]=info[N-1];
    lper(i,N-1,0)sum[i]=sum[i+1]+info[i];
    ll l=0,r=info[N-1]*2+1;
    ll now,ans;
    while(r-l>1){
        ll middle=(l+r)/2;
        now=0;ans=0;
        rep(i,N){
            ll p=info+N-lower_bound(info,info+N,middle-info[i]);
            now+=p;
            ans+=sum[N-1-p];
        }
        if(now>=M)l=middle;
        else r=middle;
    }
    now=0,ans=0;
    rep(i,N){
            ll p=info+N-lower_bound(info,info+N,l-info[i]);
            now+=p;
            if(p)ans+=info[i]*p+sum[N-p];
    }
    ans-=(now-M)*l;
    cout<<ans<<endl;
    return 0;
}

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

int main(int argc, char const *argv[])
{
    int64_t N, A, B;
    cin >> N >> A >> B;

    int64_t sum = 0;
    int64_t times = N / (A + B);

    // cout << times << endl;
    int64_t ans = 0;
    int64_t all_balls = (A + B) * times;
    ans = A * times;
    // cout << ans << endl;

    int64_t leftover = N - (times * (A + B));
    // cout << leftover << endl;
    if (leftover <= A)
        ans += leftover;
    else
        ans += A;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# codinf:utf-8

N, A, B =  [int(i) for i in input().split()]

A_B = A + B

def small(a, b):
    if a > b:
        return b
    else:
        return a

if A_B > N:
    print(small(A, B), A_B-N)
else:
    print(small(A, B), 0)

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}

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

  ll lcm = 1;
  for(int i = 0; i < N; ++i) {
    ll t; scanf("%lld", &t);
    lcm *= t / gcd(t, lcm);
  }
  printf("%lld\n", lcm);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define loop_from_to(from, to, i) for(int i=from;i<=to;i++)
#define repeat(n) for(int i__=0;i__<n;i__++)
#define multi_cin(n, array) loop(n,i){cin>>array[i];}
#define assign_if_smaller(var, val) if(var>val)var=val;
#define assign_if_larger(var, val) if(var<val)var=val;
#define each(itr, c) for(__typeof((c).begin()) itr=(c).begin(); itr!=(c).end(); itr++)
#define r_each(itr, c) for(__typeof((c).rbegin()) itr=(c).rbegin(); itr!=(c).rend(); itr++)

using namespace std;

int main(int argc, char const* argv[])
{
  while(1)
  {
    int n,a,b; cin>>n>>a>>b;
    if(!n && !a && !b) break;

    bool c[n];
    fill(c,c+n,false);
    if(a-1<n) c[a-1]=true;
    if(b-1<n) c[b-1]=true;

    int count=0;
    loop(n,i) {
      if(!c[i]) count++;
      else {
        if(i+a<n) c[i+a]=true;
        if(i+b<n) c[i+b]=true;
      }
    }
    cout<<count<<endl;
  }

  return 0;
}

Measured memory_bytes: 2136
#include <iostream>


void printAscending(int x, int y) {
	if (x < y)
		std::cout << x << " " << y << "\n";
	else
		std::cout << y << " " << x << "\n";
}

int main()
{
	int x, y;
	std::cin >> x;
	std::cin >> y;

	while (x != 0 || y != 0) {
		printAscending(x, y);
		std::cin >> x;
		std::cin >> y;
	}
    return 0;
}




Measured memory_bytes: 3108
a,b,h,m=map(int,input().split())
from math import pi,cos,radians
time=h*60+m
bst=m/30
ast=(h*60+m)/360
st=abs(bst-ast)
if st>=1:
  st=2-st
elif st==0:
  print(abs(a-b))
  exit(0)
#print(bst,ast,st)
#print(cos(radians(st*180)))
print((a**2+b**2-2*a*b*cos(radians(st*180)))**0.5)


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

ll sum(ll l, ll r) {
  return (l+r)*(r-l+1)/2;
}

int main() {
  int n, k;
  cin >> n >> k;
  mint ans;
  for (int i = k; i <= n+1; ++i) {
    ll l = sum(0,i-1), r = sum(n-i+1,n);
    ans += r-l+1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    int x=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        x^=a[i];
    }
    for(int i=0;i<n;i++)cout<<int(x^a[i])<<endl;
    return 0;
}

Measured memory_bytes: 4368
import java.util.Scanner;

public class Main 
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n,total_t;
		n=sc.nextInt();
		total_t=sc.nextInt();
		int c[] = new int[n];
		int t[] = new int[n];
		for(int i=0;i<n;i++)
		{
			c[i]=sc.nextInt();
			t[i]=sc.nextInt();
		}
		int min=1001;
		int flag=0;
		for(int i=0;i<n;i++)
		{
			if(t[i]<=total_t)
			{
				if(c[i]<min)
				{
					min=c[i];
					flag=1;
				}
			}
		}
		if(flag==1)
			System.out.println(min);
		else
			System.out.println("TLE");
	}
}


Measured memory_bytes: 22740
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        if(a<b && b<c){
             System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26204
#include <stdio.h>


int main(void) {
    int t, p, i, r, point[101], rank[31] = {};

    while (scanf("%d,%d", &t, &p) == 2 && (t || p)) {
        point[t] = p;
        rank[p]++;
    }
    for (i = 30, r = 1; i >= 0; i--) {
        if (rank[i] > 0) {
            rank[i] = r++;
        }
    }
    while (scanf("%d", &t) == 1) {
        printf("%d\n", rank[point[t]]);
    }
    return 0;
}

Measured memory_bytes: 600
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
struct edge
{
    int y;
    edge * next;
};
edge * li[100005];
edge * new_edge()
{
    static edge a[200005];
    static int top=0;
    return &a[top++];
}
void inserts(int x,int y)
{
    edge * t=new_edge();
    t->y=y;
    t->next=li[x];
    li[x]=t;
}
void insert_edge(int x,int y)
{
    inserts(x,y);
    inserts(y,x);
}
bool vis[100005];
int dfs(int x)
{
    vis[x]=true;
    edge * t;
    int ans=0;
    for (t=li[x];t!=0;t=t->next)
    {
        if (vis[t->y]) continue;
        int x=dfs(t->y);
        ans^=(x+1);
    }
    return ans;
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    int i;
    for (i=1;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        x--;
        y--;
        insert_edge(x,y);
    }
    if (dfs(0)) puts("Alice"); else puts("Bob");
    return 0;
}


Measured memory_bytes: 7424
#include<iostream>
using namespace std;
int main(){
  int K,S,count = 0;
  cin >> K >> S;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(S-i-j<=K && i+j <= S){
        count++;
      }
    }
  }
  cout << count;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long D;
  cin >> n >> D;
  D *= D;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    long long x, y;
    cin >> x >> y;
    long long d = x * x + y * y;
    cnt += d <= D;
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    //String str = "101";
    int count = 0;
    for(int i = 0; i < 3; i++){
      if(str.charAt(i) == '1'){
        count ++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 21204
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,ans=10000000000000,tmp;
  cin >> n;
  vector<ll> x(n);
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  sort(x.begin(),x.end());
  for(int p=0;p<=101;p++){
    tmp = 0;
    for(int i=0;i<n;i++){
      ll v = abs(x[i]-p);
      v *= v;
      tmp += v;
    }
    ans = min(ans,tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

const int N = 10;
ll cost[N][N];

int main() {
	vector<vector<int>> xr = {
	{1},
	{1,2},
	{1,2,4},
	{1,2,4,7},
	{1,2,4,7,12},
	{1,2,4,8,13,18},
	{1,2,4,8,14,19,24},
	{1,2,4,8,15,24,29,34},
	{1,7,10,13,21,26,41,43,45}
	};

	int n;
	cin >> n;
	ll b = 1;
	for (int i = 0; i+1 < n; ++i) {
		int ln = n-1-i;
		for (int j = i+1; j < n; ++j) {
			cost[i][j] = b * xr[ln-1][j-1-i];
			cost[j][i] = cost[i][j];
		}
		if (ln >= 2) b *= (1+xr[ln-1][ln-1]+xr[ln-1][ln-2]);
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			cout << cost[i][j] << ' ';
		}
		cout << '\n';
	}
}







Measured memory_bytes: 256
#include<stdio.h>

long uf[200000];

long root(long i){
    if(uf[i] == i)return i;
    else return uf[i] = root(uf[i]);
}

void merge(long a,long b){
    a = root(a);
    b = root(b);
    if(a == b) return;
    uf[a] = b;
}

int main(void){
    register long i;
    for(i = 0;i < 200000;i++)uf[i] = i;
    long n,m;
    scanf("%ld%ld",&n,&m);
    long a[m],b[m];
    for(i = 0;i < m;i++)scanf("%ld%ld",&a[i],&b[i]);
    for(i = 0;i < m;i++)merge(a[i],b[i]);
    static long bucket[200000];
    for(i = 0;i < 200000;i++)uf[i] = root(i);
    for(i = 0;i < 200000;i++)bucket[uf[i]]++;
    long ans = 0;
    for(i = 0;i < 200000;i++)ans = bucket[i] < ans ? ans : bucket[i];
    printf("%ld",ans);
}

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

int main(){
    ll h; cin >> h;
    ll a = 1, i = 0;
    while(a < h){
        a*=2;
        i++;
    }
    if(a != h) i--;
    ll ans = 1;
    for(ll j = 0; j < i; j++){
        ans += (ll) pow(2,j+1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

    ll ans = 0;
    string s;
    ll q;
    cin >> s >> q;

    ll t, mode = 0, ctl = 0, ctr = 0;
    for (ll i = 0; i < q; i++) {
        cin >> t;
        if (t == 1) {
            mode = (mode+1) % 2;
            ctl = 0; ctr = 0;
        } else if (t == 2) {
            ll f;
            string c;
            cin >> f >> c;
            f = ((f-1) + mode) % 2;
            if (f == 0) {
                s.insert(0, c);
                ctl++;
            }
            else {
                s.append(c);
                ctr++;
            }
        }
    }

    if (mode) reverse(ALL(s));
    cout << s << endl;
}

Measured memory_bytes: 912
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

#define MOD (1000000007LL)

lli n,K;

lli dp[105][2005];



lli dat[10];

lli td[10];
lli greed(int no){
	lli res=0;
	if(no==n){
		rep(i,n)td[i]=dat[i];
		for(;;){
			bool fd=false;
			rep(i,n){
				if(td[i]==i+1){
					fd=true;
					td[i]=0;
					rep(j,i)td[j]++;
					break;
				}
			}
			if(!fd)break;
		}
		rep(i,n)res += td[i];
	}
	else{
		reg(i,0,K){
			dat[no]=i;
			res += greed(no+1);
		}
	}
	return res;
}

int nps[105]={};

lli solve(){
	//printf("%lld\n",greed(0));
	//return 0;
	
	nps[n]=0;
	ireg(i,1,n-1){
		nps[i] = 1+nps[i+1]+nps[i+1]/(i+1);
		//printf("%d %d\n",i,nps[i]);
	}
	
	//return 0;
	
	lli nk=1;
	reg(i,1,n){
		reg(p,0,nps[i]){
			lli s=0;
			reg(t,0,K){
				lli ds;
				if(i==1){
					if(t<=1){
						ds=0;
					}
					else ds=t+p;
				}
				else{
					lli tn=p;
					lli c=t+p;
					if(t<=i){
						tn += (t+p)/i;
						c = (t+p)%i;
					}
					//printf("%lld ",c);
					if(c<0 || nk<0)return -1;
					ds = ((c*nk)%MOD+dp[i-1][tn])%MOD;
					//printf("(%d %lld %lld) ",tn,c,ds);
				}
				s = (s+ds)%MOD;
			}
			dp[i][p]=s;
			//printf("%d %d : %lld\n",i,p,s);
		}
		nk = (nk*(K+1))%MOD;
	}
	
	printf("%lld\n",dp[n][0]);
	return dp[n][0];
}


int main(){
	scanf("%lld%lld",&n,&K); solve();
	/*
	reg(i,1,100){
		printf("%d\n",i);
		reg(j,1,i){
			n=i; K=j;
			if(solve()<0){
				printf("%d %d\n",n,K);
				return 0;
			}
		}
	}
	*/
	return 0;
}





Measured memory_bytes: 768
N,A,B = gets.split(" ").map(&:to_i)

res = 0
val = 0
cal = 0
dig = Math.log10(N).to_i

for n in 1..N
  data = n
  # 各桁の値を取得
  (0..dig).reverse_each do |i|
    cal = data / 10**i
    val += cal
    data = n % 10**i
  end

  if val >= A && B >= val then
    res += n
  end
  val = 0
end
puts res

Measured memory_bytes: 2044
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
 
//using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define null 0
#define pi 3.14159265358979323846
#define all(x) x.begin(), x.end()
#define d0(x) cout<<x<<" ";
#define d1(x) cout<<x<<"\n";
#define d2(x,y) cout<<x<<" "<<y<<"\n";
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n";
 
//#define ordered_set tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
template<typename T, typename U> static inline void amin(T &x, U y){if (y < x)x = y;} 
template<typename T, typename U> static inline void amax(T &x, U y){if (y > x)x = y;} 
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const  ll mod= 1000000007  ; 
const long long inf = (ll)1e18+17;
const int inff = 1500000000;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int test_case=0;
void solve(){ 
    ll n;cin>>n;
    int dp[n+10][3];
    cin>>dp[0][0]>>dp[0][1]>>dp[0][2];
    for(int i=1;i<n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c;
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}
 
int main()
{  
    clock_t tt;tt = clock(); 
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    if(test_case==1)
    cin>>t;
    //pre();
    for(int i=1;i<=t;i++){
       //cout<<"Case #"<<i<<": ";
       solve();
    }
    tt = clock() - tt; double time_taken = ((double)tt)/CLOCKS_PER_SEC;   
    //printf("code took %f seconds to execute \n", time_taken); 
    return 0;
}
 
// ============== Notes =============== //
// common bugs
// - remove ios_base for interactive problems
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?)
// - special cases (n=1? graph not connected?)
// - re-initialize efficiently between test cases

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

#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define logarr(arr) for(auto i : arr) {cout << i << " ";} cout << "\n";
#define ll long long
#define sc(a) scanf("%d", &a);
#define scl(a) scanf("%lld", &a);



void solve() {
	
	string a, b;
    cin >> a >> b;
    int ans = 0;
    FOR(i, 0, a.size()) {
        if (a[i] != b[i])
            ans++;
    }
    cout << ans << "\n";

}

int main() {

	
	int t = 1;
	// sc(t);

	while(t--) {
		solve();
	}
	
	return 0;
}
// g++ -std=c++17 -o b bcpp


Measured memory_bytes: 3856
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSumOfThreeIntegers solver = new BSumOfThreeIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSumOfThreeIntegers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt(), s = in.nextInt();
            long ans = 0;
            for (int x = Math.max(0, s - 2 * k); x <= Math.min(k, s); x++) {
                for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
                    ans++;
                }
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 21588
import copy
H,W,K=map(int,input().split())
C=[]
for _ in range(H):
    c=list(input())
    C.append(c)
U=copy.deepcopy(C)
a=2**H
b=2**W
ans=0
for i in range (a):
    C=copy.deepcopy(U)
    for j in range(H):
        if ((i>>j)&1):
            C[j]=['a']*W
    E=copy.deepcopy(C)
    for h in range(b):
        C=copy.deepcopy(E)
        for k in range(W):
            if ((h>>k)&1):
                for q in range(H):
                    C[q][k]='a'
        count=0
        for d in range(H):
            for e in range(W):
                if C[d][e]=='#':
                    count+=1
        if count==K:
            ans+=1

print(ans)
        

Measured memory_bytes: 9348
from collections import defaultdict
N = int(input())

head_tail = defaultdict(int)
for i in range(1, N + 1):
    tail = i % 10
    head = int(str(i)[0])
    head_tail[(head, tail)] += 1

answer = 0
for i in range(1, N + 1):
    head = int(str(i)[0])
    tail = i % 10
    answer += head_tail[(tail, head)]
print(answer)

Measured memory_bytes: 9444
import java.io.*;
import java.util.*;

public class Main {

	void submit() {
		int n = nextInt();
		int l = 0;
		out.println(l);
		out.flush();
		String sl = nextToken();
		if (sl.equals("Vacant")) {
			return;
		}
		
		int r = n - 1;
		out.println(r);
		out.flush();
		String sr = nextToken();
		if (sr.equals("Vacant")) {
			return;
		}
		
		while (true) {
			int m = (l + r) >> 1;
			out.println(m);
			out.flush();
			String sm = nextToken();
			if (sm.equals("Vacant")) {
				return;
			}
			if ((m % 2 == l % 2) != (sl.equals(sm))) {
				r = m;
				sr = sm;
			} else {
				l = m;
				sl = sm;
			}
		}
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 21796
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;
    vector<ll> d(n);
    REP(i, n) cin >> d[i];

    ll ans = 0;
    REP(i, n) REP(j, n) if(i != j) {
        ans += d[i] * d[j];
    }
    cout << ans / 2 << endl;
    
}

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

int main(){
  int N;  cin >> N;
  string c; cin >> c;
  int count_R = 0;
  int count_W = 0;
  for(int i=0;i<c.size();i++){
    if(c.at(i) == 'R')  count_R++;
    else  count_W++;
  }
  if(count_R == N || count_R == 0){
    cout << '0' << endl;
    return 0;
  }
  int index_R = 0;
  int index_W = N-1;
  int count = 0;
  while(1){
    if(index_R == index_W)  break;
    if(c.at(index_R) == 'R'){
      index_R++;
      continue;
    }
    if(c.at(index_W) == 'W'){
      index_W--;
      continue;
    }
    c.at(index_R) = 'R';
    c.at(index_W) = 'W';
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3728
import sys
from collections import defaultdict

S = input()
T = input()
L = len(S)

# 置換辞書
# 一対一対応になっているか走査する
dds = defaultdict(int)
ddt = defaultdict(int)
for i in range(L):
    # i文字目
    s = S[i]
    t = T[i]
    if dds[s] == 0:
        dds[s] = t
    else:
        if dds[s] != t:
            print("No")
            sys.exit()
    if ddt[t] == 0:
        ddt[t] = s
    else:
        if ddt[t] != s:
            print("No")
            sys.exit()
print("Yes")



Measured memory_bytes: 4016
#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
    long long int a,b;
};
bool compare(node m,node n)
{
    return m.a+m.b<n.a+n.b;
}
int main()
{
    long long int N,i,check=0,sum1=0,sum2=0;
    scanf("%lld",&N);
    node x[100000];
    for(i=0;i<N;i++)
        scanf("%lld%lld",&x[i].a,&x[i].b);
    sort(x,x+N,compare);
    for(i=N-1;i>=0;i--)
    {
        if(check==0)
            {
                sum1+=x[i].a;
                check=1;
            }
            else
            {
                sum2+=x[i].b;
                check=0;
            }
    }
    printf("%lld",sum1-sum2);
}


Measured memory_bytes: 1664