akhauriyash/Code-Regression huggingface dataset:
# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# import re
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit,jit
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from fractions import gcd

# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
from networkx import Graph
from networkx.algorithms.traversal.breadth_first_search import bfs_predecessors
G = Graph()
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk

# slist = "abcdefghijklmnopqrstuvwxyz"
N,M = map(int,input().split())
rows = [list(map(int,input().split())) for _ in range(M)]

G.add_edges_from(rows)

# shortestPath = shortest_path(G,target=1)
preds = bfs_predecessors(G,source=1)
# shortestPath = single_target_shortest_path(G,target=1)
# shortestPathLength,shortestPath = single_source_dijkstra(G,source=1)

preds = dict(preds)
if len(preds)+1 != N:
    print("No")
    exit()

print("Yes")
for i in range(2,N+1):
    print(preds[i])


Measured memory_bytes: 229484
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;

int a[100006], b[100006];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i]; rep(i, n)cin >> b[i];
	int sa = 0, sb = 0;
	rep(i, n)sa += a[i]; rep(i, n)sb += b[i];
	if (sa < sb) {
		cout << -1 << endl; return 0;
	}
	int c = 0, dif = 0;
	priority_queue<int>Q;
	rep(i, n) {
		if (a[i] < b[i]) {
			dif += b[i] - a[i];
			c++;
		}
		else {
			Q.push(a[i] - b[i]);
		}
	}
	while (dif > 0) {
		dif -= Q.top(); Q.pop(); c++;
	}
	cout << c << endl;
}


Measured memory_bytes: 2936
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,1);
  var output = 1;
  for(var i = 1; i <= input; i++){
    output = output * i % 1000000007;
  }
  myout(output);
}

Main(myin());


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

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

ll X,Y,A,B,C;
ll p[100005],q[100005],r[100005];

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

    cin >> X >> Y >> A >> B >> C;

    for (int i = 0;i < A;i++){
        cin >> p[i];
    }
    for (int i = 0;i < B;i++){
        cin >> q[i];
    }

    for (int i = 0;i < C;i++){
        cin >> r[i];
    }

    sort(p,p+A);
    sort(q,q+B);
    sort(r,r+C);
    reverse(p,p+A);
    reverse(q,q+B);
    reverse(r,r+C);

    priority_queue<ll,vector<ll>, greater<ll> > qA,qB;
    ll sum = 0;

    for (int i = 0;i < X;i++){
        qA.push(p[i]);
        sum += p[i];
    }
    for (int i = 0;i < Y;i++){
        qB.push(q[i]);
        sum += q[i];
    }
    
    for (int i = 0;i < C;i++){
        if(qA.top() <= qB.top()){
            if(qA.top() > r[i]) break;
            sum -= qA.top();
            qA.pop();
            qA.push(r[i]);
            sum += r[i];
        }else{
            if(qB.top() > r[i]) break;
            sum -= qB.top();
            qB.pop();
            qB.push(r[i]);
            sum += r[i];
        }
    }

    cout << sum << endl;

    return 0;

}

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

using namespace std;

int N, dp[100009];
char col[100009], lg[400009], sml[400009];
vector < int > v[100009];

void dfs (int nod, int tata)
{
    int sau = 0;
    for (auto son : v[nod])
        if (son != tata)
        {
            dfs (son, nod);
            int curr = dp[son] & sau;
            if (curr > 0)
                sau |= ((1 << (lg[curr] + 1)) - 1);
            sau |= dp[son];
        }
    col[nod] = sml[sau];
    dp[nod] = ((sau >> col[nod]) << col[nod]) | (1 << col[nod]);
}


int main ()
{
scanf ("%d", &N);
for (int i=1; i<N; i++)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    v[x].push_back (y);
    v[y].push_back (x);
}
for (int i=2; i<=4 * N; i++)
    lg[i] = lg[i >> 1] + 1;
for (int i=1; i<=4 * N; i++)
    if (i & 1) sml[i] = sml[i >> 1] + 1;
    else sml[i] = 0;
dfs (1, -1);
printf ("%d\n", lg[dp[1]]);
return 0;
}


Measured memory_bytes: 12672
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vi p(n); rep(i,n) cin >> p[i];
    vi q(n); rep(i,n) cin >> q[i];
    vi N(n);
    for(int i=1; i<=n; i++) {
        N[i-1] = i;
    }
    int cnt = 1;
    int a = 0;
    int b= 0;
    do {
        bool ja = true;
        bool jb = true;
        rep(i,n) {
            if (N[i] != p[i]) ja = false;
            if (N[i] != q[i]) jb = false;
        }
        if (ja) a=cnt;
        if (jb) b=cnt;
        cnt++;
    } while(next_permutation(all(N)));
    ct(abs(a-b));
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#define ll long long
#define vel vector<ll>
#define vvel vector<vel>
#define veb vector<bool>
#define pin pair<int,int>
#define ppin pair<pin,pin>
#define mkp make_pair 
const ll ze = 0;
using namespace std;
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
int main() {
	int a, b; cin >> a >> b;
	int k; cin >> k;
	int x = 0;
	int tan = 100;
	while (x < k) {
		if (a%tan == 0 and b%tan == 0) { x++; }
		tan--;
	}
	cout << tan + 1 << endl;
}

Measured memory_bytes: 256
def sarch(i, n):
    ans = i // n * n // 2
    ans += max(0, i % n - n // 2)
    return ans


A, B = map(int, input().split())

originalA = A
originalB = B
A = bin(A)[2::]
B = bin(B)[2::]
while len(A) > len(B):
    B = "0" + B
while len(A) < len(B):
    A = "0" + A
ans = []
for i in range(len(A)):
    if A[i] != B[i]:
        ans.append("1")
    else:
        ans.append("0")

ans = ""
for i in range(1, len(A) + 1):
    if (sarch(originalB + 1, 2 ** i) - sarch(originalA, 2 ** i)) % 2 != 0:

        ans = "1" + ans
    else:
        ans = "0" + ans
print(int(ans, 2))


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

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

  if(x/pow(a,2)>=b/2){
  double anstan1=(2.0*(b-x/pow(a,2)))/a;
  double rasans1=atan(anstan1);
  double y=180.0*rasans1/M_PI;
  cout << setprecision(10) << y << endl;
  }
  else{
  double anstan2=(a*pow(b,2))/(2.0*x);
  double rasans2=atan(anstan2);
  double z=180.0*rasans2/M_PI;
  cout << setprecision(10) << z << endl;
  }
  //cout << M_PI << endl;
}


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

class Participant {
public:
	int point;
	int answer;
};

int main() {
	int N, p, q, a = 0;
	Participant* part;

	cin >> N >> p >> q;

	part = new Participant[N];

	for (int i = 0; i < N; i++) {
		part[i].point = (p - q);
	}

	for (int j = 0; j < q; j++) {
		cin >> a;
		part[a - 1].point += 1;
	}

	for (int l = 0; l < N; l++) {
		if (part[l].point <= 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
	delete[] part;

	return 0;
}

Measured memory_bytes: 1408
import sys
import itertools
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    edge=[[] for _ in range(N)]
    for i in range(M):
        a,b=map(lambda x:int(x)-1,input().split())
        edge[a].append(b)
        edge[b].append(a)
    l=list(range(1,N))
    ps=itertools.permutations(l)
    ans=0
    for p in ps:
        node=0
        for nextnode in p:
            if nextnode in edge[node]:
                node=nextnode
            else:
                break
        else:
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39664
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll sv, gv;
    cin >> sv >> gv;
    sv--;  gv--;
    
    vector<vector<P>> G1(n);  // 円のグラフ
    vector<vector<P>> G2(n);  // スヌークのグラフ
    rep(i, m) {
        ll u, v, cost1, cost2;
        cin >> u >> v >> cost1 >> cost2;
        u--;  v--;
        G1[u].pb(make_pair(v, cost1));
        G1[v].pb(make_pair(u, cost1));
        G2[u].pb(make_pair(v, cost2));
        G2[v].pb(make_pair(u, cost2));
    }
    
    // ダイクストラ法。計算量はO((V+E)*log(V))
    priority_queue<P, vector<P>, greater<P>> prQ1;
    vl dist1(n, INF);  // dist[v] : 頂点svから頂点vへのG1上での最短距離
    dist1[sv] = 0;
    prQ1.push(make_pair(0, sv));  // (頂点svからの最短距離, 頂点番号)
    while(!prQ1.empty()) {
        auto p1 = prQ1.top();
        prQ1.pop();
        ll v = p1.second;
        if(dist1[v] < p1.first) {
            continue;
        }
        for(auto p2 : G1[v]) {
            ll u = p2.first;
            ll cost = p2.second;
            if(dist1[u] > dist1[v] + cost) {
                dist1[u] = dist1[v] + cost;
                prQ1.push(make_pair(dist1[u], u));
            }
        }
    }

    // ダイクストラ法。計算量はO((V+E)*log(V))
    priority_queue<P, vector<P>, greater<P>> prQ2;
    vl dist2(n, INF);  // dist[v] : 頂点gvから頂点vへのG2上での最短距離
    dist2[gv] = 0;
    prQ2.push(make_pair(0, gv));  // (頂点gvからの最短距離, 頂点番号)
    while(!prQ2.empty()) {
        auto p1 = prQ2.top();
        prQ2.pop();
        ll v = p1.second;
        if(dist2[v] < p1.first) {
            continue;
        }
        for(auto p2 : G2[v]) {
            ll u = p2.first;
            ll cost = p2.second;
            if(dist2[u] > dist2[v] + cost) {
                dist2[u] = dist2[v] + cost;
                prQ2.push(make_pair(dist2[u], u));
            }
        }
    }

    vl cost(n);  // cost[v] : 頂点vで両替したときにかかるコスト
    vl ans(n);  // ans[i] : i年後にかかるコストの最小値
    rep(v, n) {
        cost[v] = dist1[v] + dist2[v];
        ans[v] = cost[v];
    }

    for(ll i = n-1; i >= 1; i--) {
        chmin(ans[i-1], ans[i]);
    }
    
    ll money = 1e15;
    rep(i, n) {
        out(money - ans[i]);
    }

    re0;
}

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

vector <string> s;
vector <string> ans; 
int n;
void dfs(int com,int a,int b,int c)
{
    if(a<0 or b<0 or c<0)
        return;
    if(com==n+1){
        cout<<"Yes\n";
        for(int i=1;i<=n;i++)
        {
            cout<<ans[i]<<'\n';
        }
        exit(0);
    }
    if(s[com]=="AB")
    {
        ans[com]="A";
        dfs(com+1,a+1,b-1,c);
        ans[com]="B";
        dfs(com+1,a-1,b+1,c);
    }
    else if(s[com]=="AC")
    {
        ans[com]="A";
        dfs(com+1,a+1,b,c-1);
        ans[com]="C";
        dfs(com+1,a-1,b,c+1);
    }
    else
    {
        ans[com]="B";
        dfs(com+1,a,b+1,c-1);
        ans[com]="C";
        dfs(com+1,a,b-1,c+1);
    }
}


int main()
{
    int i,a,b,c;
    cin>>n>>a>>b>>c;
    s.resize(n+1);
    ans.resize(n+1);
    for(i=1;i<=n;i++)
    {
        cin>>s[i];
    }
    dfs(1,a,b,c);
    cout<<"No";
    return 0;
}


Measured memory_bytes: 17196
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  board = []
  for _ in range(n):
    board.append(input().strip())
    
  def t(mat):
    return ["".join(s) for s in zip(*mat)]
  tboard = t(board)
  
  def judge(board, tboard):
    if all([x==y for x, y in zip(board, tboard)]):
      return True
    return False
  
  cnt = 0 
  for i in range(n):
    if judge(board[i:] + board[:i], t(board[i:] + board[:i])):
      cnt += 1
  print(n * cnt)
  
if __name__=='__main__':
  main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    ll X;
    cin >> X;
    ll now = 100;
    ll ans = 0;
    while(1){
        if(X<=now){
            break;
        }
        now += now/100;
        ans ++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
import sys

count=int(input())
input_list=[ int(i) for i in sys.stdin.readlines() ]

first=0
second=1
maxv=-1000000000
minv=input_list[first]

for i in input_list[second:]:
    if i-minv > maxv:
        maxv=i-minv
    if i < minv:
        minv=i

print(maxv)


Measured memory_bytes: 27832
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	ll N, D, ans;
	cin >> N >> D;
	ans = (N - 1) / (2 * D + 1);
	ans++;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
if N == 1:
	if A == B:
		print(1)
	else:
		print(0)
else:
	if A > B:
		print(0)
	elif A == B:
		print(1)
	else:
		C = (B - A) * (N - 2) + 1
		print(C)

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int h, w, n;
  cin >> h >> w >> n;
  int k = max(w,h);
  cout << (n+k-1)/k << endl;
}


Measured memory_bytes: 256
function Main(input) {
    var N = input.split('\n')[0] - 0;
    var tmp = input.split('\n');
    var cnt = 0;
    var str = new Array(N);
    for (var i = 0; i < N; i++) {
        str[i] = tmp[i + 1].split('').sort().join();
    }

    str.sort();

    var f = 1;
    for (var i = 1; i < N; i++) {
        if (str[i - 1] === str[i]) {
            f++;
        } 
        if (str[i - 1] !== str[i]) {
            cnt += f * (f - 1) / 2;
            f = 1;
        } 
    }

    cnt += f * (f - 1) / 2;

    console.log(cnt);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int calc_digit(ll num){
    int cnt = 0;
    while(num){
        num/=10;
        cnt++;
    }
    return cnt;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];


    if (find(ALL(a), 0)!=a.end()){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    REP(i, n){
        if (LLONG_MAX/a[i]>ans) ans*=a[i];
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    if (ans <= ll(1e18)) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

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


typedef long long LL;


int main(){

    #ifndef ONLINE_JUDGE
    freopen("E:\\Coding\\Programming\\input.txt", "r", stdin);
    freopen("E:\\Coding\\Programming\\output.txt", "w", stdout);
    #endif
    int n;
    cin>>n;
    vector<int> a(n+1);
    vector<int> dp(n+5);
    for(int i=0;i<n;i++) cin>>a[i];


    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n-1]<<endl;
}

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

using namespace std;

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false); cin.tie(0);

    int n;
    vector<int> ap(31, 0);
    cin >> n;

    int i, val = 0;
    for(i=1; i<=n; ++i)
    {
        int x;
        cin >> x;
        val ^= x;

        int cnt = 0;
        while(x%2==0) x/=2, ++cnt;
        ++ap[cnt];
    }

    int ans = 0;

    for(i=29; i>=0; --i)
        if( ((val>>i)&1) ^ ((val>>(i+1))&1) )
        {
            ++ans;
            if(!ap[i])
            {
                cout << -1 << '\n';
                return 0;
            }
        }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import itertools

a = int(input())
ans1=0
ans2=0
b=[]
for i in range(1,a+1):
    b.append(str(i))

p=list(map(str,input().split()))
q=list(map(str,input().split()))
count=0
for v in itertools.permutations(b):
    if list(v)==p:
        ans1=count+1
    if list(v)==q:
        ans2=count+1
    count+=1
print(abs(ans1-ans2))

Measured memory_bytes: 41968
import java.util.*;
	import java.lang.Math;
    public class Main
	{
		public static void numberbase(int n, int base)
		{
			int[] array = new int[100];
			int i=0;
			int count=0;
			while(n>0)
			{
				array[i]=n%base;
				n=n/base;
				i++;
				count++;
			}
			/*for (int j = i - 1; j >= 0; j--) 
            {
				System.out.print(array[j]);
				count++;
			}*/
			System.out.println(count);
		}
		public static void main(String args[])
		{
			Scanner scan = new Scanner(System.in);
			int n = scan.nextInt();
			int base = scan.nextInt();
			numberbase(n,base);
		}
    }

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    int n;
    cin>>n;
    vector <long long> a(n) , b(n);
    for (int i = 0; i < n; i++) 
    {
        cin>>a[i]>>b[i];
    }
    long long ans = 0;
    for (int i = n - 1; i >= 0; i--) 
    {
        a[i] += ans;
        ans += ( b[i] - ( a[i] % b[i] )) % b[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = T.size();
  for (int i = 0; i < (int)S.size() - (int)T.size() + 1; i++){
    int cnt = 0;
    for (int j = 0; j < (int)T.size(); j++){
      if (T[j] == S[i + j]) cnt++;
    }
    ans = min(ans, (int)T.size() - cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    string s;
    cin >> s;
    int len = LEN(s);
    int a = -2,b = -2;
    REP1(i,len-1){
        if(s[i-1]==s[i+1]){
            a = i-1,b = i+1;
            break;
        } else if(s[i-1]==s[i]){
            a = i-1,b = i;
            break;
        } else if(s[i]==s[i+1]){
            a = i,b = i+1;
            break;
        }
    }

    a++,b++;
    printf("%d %d\n",a,b);
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int a[4],b[3],i,m[3];
    char num[5];
    scanf("%s",num);
    for (i=0;i<4;i++)
    {
        a[i]=num[i]-'0';
    }
    for (i=0;i<8;i++)
    {
        m[0]=i%2;
        m[1]=i/2%2;
        m[2]=i/4%2;
        b[0]=pow(-1,m[0])*a[1];
        b[1]=pow(-1,m[1])*a[2];
        b[2]=pow(-1,m[2])*a[3];
        if (a[0]+b[0]+b[1]+b[2]==7) break;
    }
    printf("%d",a[0]);
    for (i=0;i<3;i++)
    {
        if (m[i]) printf("-");
        else printf("+");
        printf("%d",a[i+1]);
    }
    printf("=7");
    return 0;
}


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

char upper(char c);
char lower(char c);

int main(){
  int i=0;
  char s[1201]={},u,l;
  memset(s,'\n',1201);
  fgets(s, 1200, stdin);
  while(1){
    if(s[i]=='\n'){
      printf("\n");
      break;
    }
    u = upper(s[i]);
    l = lower(s[i]);
    if(u != '0'){
      printf("%c",u);
    }
    else if(l != '0'){
      printf("%c",l);
    }
    else{
      printf("%c",s[i]);
    }
    i++;
  }

  return 0;
}


char upper(char c){
  if(c>='a' && c<='z'){
    return c+'A'-'a';
  }
  else{
    return '0';
  }
}
char lower(char c){
  if(c>='A' && c<='Z'){
    return c+'a'-'A';
  }
  else{
    return '0';
  }
}



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

int main(){
  string S,T;
  cin >>S >> T;
  int x=1;
  rep(i, S.size() ){
    if(S.at(i) != T.at(i))
      x=0;
  }
  if (x == 1)
    cout << "Yes" <<endl;
  else
    cout << "No" <<endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    String Tile = sc.next();
    char Tiles[]= new char[Tile.length()];
    int count=0;
    for(int i=0;i<Tile.length();i++){
       Tiles[i]=Tile.charAt(i);
    }
    for(int i=1;i<Tile.length();i++){
         if(Tiles[i]==Tiles[i-1]){
           count++;
         if(Tiles[i]=='0'){
         Tiles[i]='1';
         }else if (Tiles[i]=='1'){
         Tiles[i]='0';
         }
    	}
    }
      System.out.print(count); 
  }
}

Measured memory_bytes: 25708
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int64_t INF = 1LL << 60;


int main() {
 string s;
 cin>>s;
 int countp=0,countm=0;
 for(int i=0;i<s.size();i++){
  if(s[i]=='+'){countp++;}
  else{countm++;}
 }
 cout<<countp-countm<<endl;
 return 0;
}


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

template<class T> inline bool chmin(T &a, T b) {
  if(a>b) {
    a=b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T &a, T b) {
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
const ll LINF = 1LL << 60;
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

int main() {
  string S, T; cin >> S >> T;
  string ans = T+S;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<typeinfo>
#include<functional>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


/*
 O(QlogN+N)
 追加する直線の傾きが狭義単調減少であること
 maxを求めるときは値と傾きに-1をかけること
 */
template<typename T>
class Comvex_Hull_Trick{
private:
    typedef pair<T,T> line; //y切片,傾き
    deque<line> D;
    
    inline T point(const line &L,const T &x) const {return L.F+L.S*x;}
    
    inline bool is_need(const line &A,const line &B,const line &C) const {
        return (C.F-A.F)*(A.S-B.S)>(B.F-A.F)*(A.S-C.S);
    }
    
public:
    Comvex_Hull_Trick(){}
    
    void add_line(const line &L){
        while(!D.empty() && D.back().F>=L.F){D.pop_back();}
        while(D.size()>=2 && !is_need(D[D.size()-2],D.back(),L)){D.pop_back();}
        D.push_back(L);
    }
    
    T search(const T &x) const {
        ll l=0;
        ll r=D.size()-1;
        while(l+1<r){
            ll m=l+(r-l)/2;
            if(point(D[m],x)<point(D[m+1],x)){r=m;}
            else{l=m+1;}
        }
        for(ll i=l;i<r;i++){
            if(point(D[i],x)<point(D[i+1],x)){return point(D[i],x);}
        }
        return point(D[r],x);
    }
    
    pair<T,T> search_line(const T &x) const {
        ll l=0;
        ll r=D.size()-1;
        while(l+1<r){
            ll m=l+(r-l)/2;
            if(point(D[m],x)<point(D[m+1],x)){r=m;}
            else{l=m+1;}
        }
        for(ll i=l;i<r;i++){
            if(point(D[i],x)<point(D[i+1],x)){return D[i];}
        }
        return D[r];
    }
    
    pair<T,T> back() const {return D.back();}
    
    unsigned long size() const {return D.size();}
    
    bool empty() const {return D.empty();}
};





int main(){
    ll n,t;
    cin>>n>>t;
    vector<vector<ll>> dp(n,vector<ll>(t+1,0));
    Comvex_Hull_Trick<ll> C[t+1];
    vector<pair<pll,ll>> S(n);
    for(int i=0;i<n;i++){
        ll t,p,f;
        cin>>t>>p>>f;
        S[i]={{f,p},t};
    }
    sort(S.begin(),S.end());
    ll mx=0;
    for(int i=0;i<n;i++){
        const pair<pll,ll> &W=S[i];
        if(W.S>t){continue;}
        for(ll j=t-W.S;j>=1;j--){
            if(C[j].empty()){continue;}
            ll P=C[j].search(W.F.F);
            P*=-1;
            P-=W.F.F*W.F.F;
            P+=W.F.S;
            dp[i][j+W.S]=max(dp[i][j+W.S],P);
            mx=max(mx,dp[i][j+W.S]);
            C[j+W.S].add_line({(dp[i][j+W.S]-W.F.F*W.F.F)*-1,-2*W.F.F});
        }
        dp[i][W.S]=max(dp[i][W.S],W.F.S);
        mx=max(mx,dp[i][W.S]);
        C[W.S].add_line({(dp[i][W.S]-W.F.F*W.F.F)*-1,-2*W.F.F});
    }
    cout<<mx<<endl;
    
    
    return 0;
}



Measured memory_bytes: 117856
#include <iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b;
	c = a + b;
	if (a % 3 == 0 || b % 3 == 0 || c % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
def solve(n, x, a):
    ans = 0
    for v in sorted(a):
        if v <= x:
            ans += 1
            x -= v
    if (x > 0) and (ans == n):
        ans -= 1
    return ans

n, x = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, x, a))

Measured memory_bytes: 3064
console.log((args=>{
  const [[N],...tmp] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  const r = [];
  for ( let i = 0; i < N; i++ ) {
    const [X,L] = tmp[i];
    r.push([X-L,X+L]);
  }
  r.sort((a,b)=>a[1]-b[1]);
  let last = r[0], c = 1;
  for ( let i = 1; i < N; i++ ) {
    if ( last[1] > r[i][0] ) continue;
    last = r[i];
    c++;
  }
  return `${c}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 71804
using System;
        using System.Linq;
        using System.Collections.Generic;
        using static System.Math;

        public class Program
        {
            public static void Main(string[] args)
            {
            string input = Console.ReadLine();
            int sum = 0;

            foreach (char a in input)
            {
                sum += int.Parse(a.ToString());
            }

            Console.WriteLine(int.Parse(input) % sum == 0? "Yes":"No");
            }
        }

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

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


    int n;
    cin >> n;
    vector <int> height(n);
    vector <ll> cost(n);
    set <pair <int, ll>> s;
    for (int i=0; i<n; ++i)
        cin >> height[i];
    for (int i=0; i<n; ++i)
        cin >> cost[i];

    for (int i=0; i<n; ++i)
    {
        s.insert({height[i], cost[i]});
        auto it = s.find({height[i], cost[i]});

        if (it != s.begin())
        {
            auto _iter = --it;
            ++it;
            pair <int, ll> p = {it->first, it->second + _iter->second};
            s.erase(it);
            s.insert(p);
        }
        auto iter = ++it;
        --it;
        while (iter != s.end() && iter->second < it->second)
        {
            s.erase(iter);
            iter = ++it;
            --it;
        }
    }
    auto it = s.end();
    cout << (--it)->second;
    return 0;
}




Measured memory_bytes: 15104
public class Main {
    public static void main(String[] args)
    {
        int T_num = 0;
        String S = new java.util.Scanner(System.in).nextLine();
        for(int i=0; i<4; i++)
        {
            char testr = S.charAt(i);
            if(testr == '+')
            {
                T_num++;
            }
            else if(testr == '-')
            {
                T_num--;
            }

        }
        System.out.println(T_num);
    }
}


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

char	mae[200001] = { 0 };
char	ato[200001] = { 0 };
char	pr1[200001] = { 0 };
char	pr2[200001] = { 0 };
char	pr3[200001] = { 0 };

int main() {
	int		i,j,n;
	int		a,b,d,k,m,x,y,q,f,ans = 0;
	char	c;
	string	str;
	
	cin >> str >> n;

	int flag = 0;
	int mp = 0;
	int ap = 0;
	for(i=0;i<n;i++) {
		cin >> q;
		if ( q == 1 ) {
			flag++;
			continue;
		}
		cin >> f >> c;
		if ( f == 1 ) {	  // mae
			if ((flag & 1) == 0) {
				mae[mp++] = c;
			} else {
				ato[ap++] = c;
			}
		} else {
			if ((flag & 1) == 1) {
				mae[mp++] = c;
			} else {
				ato[ap++] = c;
			}
		}

	}

	for(i=mp,j=0;i>0;i--,j++) {
		pr1[j] = mae[i-1];
	}
	for(i=ap,j=0;i>0;i--,j++) {
		pr3[j] = ato[i-1];
	}



	if ((flag & 1) == 0) {
		printf("%s",pr1);
		cout << str;
		printf("%s\n",ato);
	} else {
		for(i=str.size(),j=0;i>0;i--,j++) {
			pr2[j] = str[i-1];
		}
		printf("%s",pr3);
		printf("%s",pr2);
		printf("%s\n",mae);
	}
	


	


}


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

int main(){
    int card[4][13] = {{}};
    int n;
    cin >> n;
    for (int i=0;i<n;i++){
        int nm;
        char su;
        cin >> su >> nm;
        if (su =='S'){
            card[0][nm -1] = 1;
        }else if (su =='H'){
            card[1][nm -1] = 1;
        }else if (su =='C'){
            card[2][nm -1] = 1;
        }else if (su =='D'){
            card[3][nm -1] = 1;
        }
    }
    for(int j=0;j<4;j++){
        for(int k=0;k<13;k++){
            int nu = k+1;
            if (card[j][k]==0){
                if (j==0) cout << "S" << " " << nu <<endl;
                else if (j==1) cout << "H" << " " <<nu <<endl;
                else if (j==2) cout << "C" << " " <<nu <<endl;
                else if (j==3) cout << "D" << " " <<nu <<endl;
            }
        }
    }
    return 0;
    
    
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

int N;
string S;

signed main(){
    cin>>N>>S;

    map<pair<string,string>,int>M;

    rep(i,1<<N){
        string s,t;
        rep(j,N){
            if(i>>j&1)s+=S[j];
            else t+=S[j];
        }
        M[pair<string,string>(s,t)]++;
    }

    int ans=0;
    rep(i,1<<N){
        string s,t;
        rep(j,N){
            if(i>>j&1)s+=S[j+N];
            else t+=S[j+N];
        }
        reverse(all(s));reverse(all(t));
        ans+=M[pair<string,string>(t,s)];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 87040
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	rep(i, n) {
		if (s[i] == 'A' && i + 2 < n) {
			if (s[i + 1] == 'B' && s[i + 2] == 'C')
				ans++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x,y;
	cin>>x>>y;
	bool a=false;
	for(int i=0;i<=x;i++){
		for(int j=0;j<=x;j++){
			if((4*i+2*(x-i))==y) a=true;
		}
	}
	if(a) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    int oc = 0;
    int ec = 0;
    for(int i=0;i<n;i++){
        int a;cin >> a;
        if(a%2 == 0){
            ec++;
        }else{
            oc++;
        }
    }

    string ans = "YES";

    if(oc%2 == 1 && ec > 0) ans = "NO";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import math

A = int(input())/10
B = int(input())/10
C = int(input())/10
D = int(input())/10
E = int(input())/10

v = int((math.ceil(A)+math.ceil(B)+math.ceil(C)+math.ceil(D)+E) * 10)
w = int((math.ceil(A)+math.ceil(B)+math.ceil(C)+math.ceil(E)+D) * 10)
x = int((math.ceil(A)+math.ceil(B)+math.ceil(E)+math.ceil(D)+C) * 10)
y = int((math.ceil(A)+math.ceil(E)+math.ceil(C)+math.ceil(D)+B) * 10)
z = int((math.ceil(E)+math.ceil(B)+math.ceil(C)+math.ceil(D)+A) * 10)

print(min(v, w, x, y, z))

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

using namespace std;

int main(void) {
  int A, B, C; cin >> A >> B >> C;
  
  if (A == B) {
    cout << C << endl;
  } else if (B == C) {
    cout << A << endl;
  } else {
    cout << B << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define PII pair<int,int>

int dp[101][10001];
PII p[101];
int main()
{
	int N, W;
	cin >> N >> W;
	REP(i, N)cin >> p[i].first >> p[i].second;
	REP(i, N + 1)REP(j, W + 1)dp[i][j] = -1;
	REP(i, N)dp[i][0] = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j <= W; j++)
		{
			if (dp[i][j] != -1)
			{
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
				int temp = j + p[i].second;
				if (temp <= W)
				{
					dp[i + 1][temp] = max(dp[i + 1][temp], dp[i][j] + p[i].first);
				}
			}
		}
	}
	int ans = 0;
	for (int i = W; i >= 0; i--)
	{
		if (ans < dp[N][i])
		{
			ans = dp[N][i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod = 998244353;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}
const int maxN = 3005;
int c[2 * maxN][2 * maxN];
int x, n;
int f[2 * maxN];
int dp[2 * maxN][2 * maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n >> x;
    c[0][0] = 1;
    for (int i = 1; i < maxN; i++) {
        c[i][0] = 1;
        for (int j = 1; j <= i; j++) {
            c[i][j] = sum(c[i - 1][j], c[i - 1][j - 1]);
        }
    }
    dp[0][0] = 1;
    for (int i = 0; i + 1 <= n; i++) {
        for (int j = 0; j <= 2 * i + 2; j++) {
            dp[i + 1][j + 1] = sum(dp[i + 1][j + 1], dp[i][j]);
            dp[i + 1][j + 2] = sum(dp[i + 1][j + 2], dp[i][j]);
        }
    }
    for (int t = x + 1; t <= 2 * n; t++) {
        int k1 = (t - x + 1) / 2;
        if (t % 2 == x % 2) continue;
        if (x % 2 == 0 && 2 * k1 >= x) continue;
        if (2 * k1 + 2 * k1 >= t) {
            if (x % 2 == 0) continue;
            if (t % 2 != 0) continue;
            f[t / 2] += 1;
            if (f[t / 2] >= mod) f[t / 2] -= mod;
            continue;
        }
        int le = t - 4 * k1;
        for (int j = 0; j <= le; j++) {
            f[j + 2 * k1] = f[j + 2 * k1] + dp[j][le];
            if (f[j + 2 * k1] >= mod) f[j + 2 * k1] -= mod;
        }
    }
    /*if (x % 2 == 1) {
        for (int i = (x / 2 + 1); i <= n; i++) {
            f[i]++;
        }
    }
    else {
        for (int sum = x + 1; sum <= 2 * x - 1; sum += 2) {
            f[sum / 2 + 1]++;
        }
    }*/
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < x; j++) {
            f[i] = sum(f[i], dp[i][j]);
        }
        ans = sum(ans, mult(f[i], c[n][i]));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 144000
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void) {
  string s;
  cin>>s;
  string s1,s2;
  int size=s.size();

  s1.push_back(s[0]);
  for(int i=1;i<size;i++){
    if(s1[i-1]=='0')  s1.push_back('1');
    if(s1[i-1]=='1')  s1.push_back('0');
  }

  for(int i=0;i<size;i++){
    if(s1[i]=='0')  s2.push_back('1');
    if(s1[i]=='1')  s2.push_back('0');
  }

  int count1=0,count2=0;
  for(int i=0;i<size;i++){
    int tmp1=s[i]-'0';
    int tmp2=s1[i]-'0';
    int tmp3=s2[i]-'0';
    count1+=abs(tmp1-tmp2);
    count2+=abs(tmp1-tmp3);
  }

  if(count1<count2){
    cout<<count1<<endl;
  }else{
    cout<<count2<<endl;
  }

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    // 整数の入力
    ll A,B,C;
    cin >> A >> B >> C;
    if (A+B+C <=21 ){
        cout << "win" << endl;
    }else{
        cout << "bust" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    int ret = 0;
    for (int a = 0; a < n; ++a) {
        // for (int b = 0; b < n; ++b) {
        int b = 0;
        auto t = s;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                t[(i + a) % n][(j + b) % n] = s[i][j];
            }
        }
        bool ok = true;
        [&] {
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < n; ++j) {
                    if (t[i][j] != t[j][i]) {
                        ok = false;
                        return;
                    }
                }
            }
        }();
        if (ok)
            ret++;
        //}
    }
    ret *= n;
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



using namespace std;

map<int ,int> mp;
int n;
int a[100000],b[100000],c[100000];
long long int ans = 0;

int main(){
    cin >> n;
    for(int i=0;i<n;i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(a,a+n);
    int q;
    cin  >> q;
    ans =  mp[a[0]]*a[0];
    for(int i=0;i<q;i++) cin >> b[i] >> c[i];
    for(int j=1;j<n;j++){
        if(a[j] == a[j-1]) continue;
        ans += mp[a[j]]*a[j];
    }
    for(int i=0;i<q;i++){
        ans += mp[b[i]]*c[i] - mp[b[i]]*b[i];
        mp[c[i]] += mp[b[i]];
        mp[b[i]] = 0;
        cout << ans << endl;
  
    }
return 0;
}

Measured memory_bytes: 9108
#include <iostream>
#include <sstream>

using namespace std;

void move(int,int,char);
char det_angle(int,int,char);

char perm_angle[4] = {'R','U','L','D'};
int grid[5][5][4] = {0};

int main(){

	int flag;
	for(int i=0;i<9;i++){
		if(i%2 == 0){
			for(int j=0;j<4;j++){
				fscanf(stdin,"%1d",&flag);
				//cout << flag;
				if(flag == 1){
					//cout << "+";
					grid[i/2][j][0]  = 1; //R
					grid[i/2][j+1][2]= 1; //L
				}
			}
		}
		else{
			for(int j=0;j<5;j++){
				fscanf(stdin,"%1d",&flag); 
				//cout << flag;
				if(flag == 1){
					//cout << "-";
					grid[i/2][j][3]  = 1; //D
					grid[i/2+1][j][1]= 1; //U
				}
			}

		}
	}
	int x = 0,y =0;
	char angle = 'R';
	do{
		//		move(x,y,det_angle(x,y,angle));

		cout << angle;

		if(angle == 'R'){
			++y;
		}
		else if(angle == 'U'){
			--x;
		}
		else if(angle == 'L'){
			--y;
		}
		else if(angle == 'D'){
			++x;
		}
		angle = det_angle(x,y,angle);
	}
	while(x != 0 || y!= 0);
	//cout << 'R';
	//move(0,1,'R');
	cout << endl;
}

void move(int x,int y,char angle){
	if(x == 0 && y== 0){
		cout << endl;
		//exit(0);
	}

	cout << angle;

	if(angle == 'R'){
		++y;
	}
	else if(angle == 'U'){
		--x;
	}
	else if(angle == 'L'){
		--y;
	}
	else if(angle == 'D'){
		++x;
	}
	//cout << "test" << x <<" " << y;
	//move(x,y,det_angle(x,y,angle));
	//cout << angle << endl; 
}

char det_angle(int x,int y,char angle){

	//cout << x << y << " " << angle << endl;
	int start;
	if(angle == 'R'){
		start = 5;
	}
	else if(angle == 'U'){
		start = 6;
	}
	else if(angle == 'L'){
		start = 7;	
	}
	else if(angle == 'D'){
		start = 4;
	}
	//cout << start << endl;
	for(int i = start;start - i < 4 ;--i){
		if(grid[x][y][i%4] == 1){
			//cout << "kettei" << i <<endl ;
			return perm_angle[i%4];
		}
	}
	return 'Z';
}

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

int main(void){
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[1] << c[2];
	return 0;
}

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

class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            int a,b;
            a = in.nextInt();
            b = in.nextInt();
            System.out.println((int)Math.log10(a+b)+1);
        }
    }
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

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

  string s;
  cin >> s;
  ll ans = 0;
  rep(i, s.length()/2) {
    if (s[i] != s[s.length()-1-i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#b
S=input()

l = len(S)
ans=0
for i in range(l):
    for j in range(i,l):
        ss = S[i:j+1]
        if all(sss in ["A","G","C","T"] for sss in ss):
            cand = len(ss)
            ans=max(ans,cand)
print(ans)

Measured memory_bytes: 61836
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(x>y){
        for(int i=0;i<x;i++)
            cout<<y;
    }
    else{
        for(int i=0;i<y;i++)
            cout<<x;
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <string>
using namespace std;

#define LEN 100005

typedef struct {
    string name;
    int time;
} Process;

Process Que[LEN];
int head, tail, n;

void enqueue(Process x) {
    Que[tail] = x;
    tail = (tail + 1) % LEN;
}

Process dequeue() {
    Process x = Que[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) {
    return a < b ? a : b;
}

int main() {
    int elaps = 0, c;
    int q;
    Process u;
    cin >> n >> q;
    
    for ( int i = 1; i <= n; i++ ) {
        cin >> Que[i].name >> Que[i].time;
    }
    head = 1;
    tail = n + 1;
    
    while ( head != tail ) {
        u = dequeue();
        c = min(q, u.time);
        u.time -= c;
        elaps += c;
        if ( u.time > 0 ) enqueue(u);
        else {
            cout << u.name << ' ' << elaps << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 7044