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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    int s[100];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> s[i];

    int sum = 0;
    for (int i = 0; i < n; i++)
        sum += s[i];

    if (sum % 10)
    {
        cout << sum << endl;
        return 0;
    }

    int tmp = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] % 10)
        {
            tmp = max(tmp, sum - s[i]);
        }
    }
    cout << tmp << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){   
    int r,c,i,j,a[200][200];   
    cin >> r >> c;   
    for(i=0;i<r;i++){       
        for(j=0;j<c;j++){           
            cin >> a[i][j];       
            
        }   
        
    }   
    for(i=0;i<r;i++){       
        for(j=0;j<c;j++){           
            a[i][c]+=a[i][j];       
            
        }   
        
    }   
    for(j=0;j<c;j++){       
        for(i=0;i<r;i++){           
            a[r][j]+=a[i][j];           
            a[r][c]+=a[i][j];       
            
        }   
        
    }   
    for(i=0;i<=r;i++){       
        for(j=0;j<=c;j++){           
            cout << a[i][j];
            if(j==c){
                cout << endl;
            }else{
                cout << " ";
            }
            
        }  
        
    }
    
}


Measured memory_bytes: 3156
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        sc.close();
        if (k >= s.length()) {
            System.out.println(s);
        } else {
            System.out.println(s.substring(0, k) + "...");
        }
    }
}


Measured memory_bytes: 27032
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long ll;
const int MAXN = 600005;

int dp[MAXN];
int main()
{
//	freopen("input.in", "r", stdin);
    int n;
    cin >> n;
    string s;
    cin >> s;

    int zero2 = 0, zero1 = 1;
    int i;
    s = "00" + s;
    dp[0] = 0;
    dp[1] = 0;
    for (int i = 2; i < s.length(); i++)
    {
        dp[i] = dp[i-1];

        if (s[i] == '0')
        {
            zero2 = zero1;
            zero1 = i;
        }
        else
        {
            if (s[i-1] == '0')
            {
                dp[i] = max(dp[i], dp[zero2] + i - zero2 - 2);
                dp[i] = max(dp[i], dp[zero2+1] + i - (zero2+1) - 2);
            }
            else if (s[zero1-1] == '1')
                dp[i] = max(dp[i], dp[zero1-2] + i - (zero1-2) - 2);
        }
    }
    cout << dp[s.length()-1];
	return 0;
}


Measured memory_bytes: 2840
import heapq
n,m = map(int,input().split())
a = list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a) #aを優先度付きキューにする
for _ in range(m):
    tmp = heapq.heappop(a)
    heapq.heappush(a,(-1)*(-tmp//2))
print((-1)*sum(a))

Measured memory_bytes: 20364
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n, cnt, i, j, inpt, sousa_cnt;
	vector<int> S, P;
	vector<int> *Sp, *Pp, *tmpp;
	Sp=&S;
	Pp=&P;
	while(true){
		cin>>n; if(n==0)break;
		Pp->resize(n, 0);
		Sp->resize(n, 0);
		for(i=0;i<n;i++){
			cin>>inpt;
			(*Sp)[i] = inpt;
		}
		for(sousa_cnt=0; true; sousa_cnt++){
			for(i=0;i<n;i++){
				cnt = 0;
				for(j=0;j<n;j++){
					if((*Sp)[i] == (*Sp)[j]) cnt++;
				}
				(*Pp)[i] = cnt;
			}
			for(i=0;i<n;i++){
				if((*Pp)[i] != (*Sp)[i]) break;
			}
			if(i==n) break;
			tmpp = Sp; Sp = Pp; Pp = tmpp;
		}
		cout<<sousa_cnt<<endl;
		cout<<(*Pp)[0];
		for(i=1;i<n;i++){
			cout<<" "<<(*Pp)[i];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>

void print(vector<int> arr){for(auto i:arr){printf("%d ",i);}cout<<endl;}

int main()
{
    int n;scanf("%d",&n);
   	string st;cin>>st;
   	int count=0;
   	for(int i=0;i<n-2;i++){
   	    if(st[i]=='A'&&st[i+1]=='B'&&st[i+2]=='C')count++;
   	}
   	printf("%d",count);
    return 0;
}

Measured memory_bytes: 256
def f(s):
	for i in range(len(s)/2):
		if s[i] != s[len(s)-i-1]:
			return False
	return True
s = raw_input()
n = len(s)
if(f(s) and f(s[:(n-1)/2]) and f(s[(n+3)/2 - 1:]) ):
	print "Yes"
else:
	print "No"


Measured memory_bytes: 2568
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

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

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll a[123][10][10],dp[123][10],f[10]={1ll,2ll,3ll,5ll,8ll,13ll,21ll,34ll,55ll};

int main(void){
	int h,w,p,i,j,k,s=0,t=0,m;
	scanf("%d%d%d",&h,&w,&p);
	for(i=0; i<w; ++i){
		dp[0][i] = ((i)?0ll:1ll);
		for(j=i; j<w; ++j){
			if(abs(i-j)>1){
				a[0][i][j] = 0ll;
				continue;
			}
			if(i==0 && w-j==1){
				a[0][i][j] = 1ll;
			}else if(i==0){
				a[0][i][j] = f[w-j-2];
			}else if(w-j==1){
				a[0][i][j] = f[i-1];
			}else{
				a[0][i][j] = (f[i-1]*f[w-j-2])%MOD;
			}
			a[0][j][i] = a[0][i][j];	
		}
	}
	while(h){
		if(h%2){
			for(i=0; i<w; ++i){
				dp[s+1][i] = 0ll;
			}
			for(i=0; i<w; ++i){
				for(j=0; j<w; ++j){
					add_mod(dp[s+1][j],(dp[s][i]*a[t][i][j])%MOD);
				}
			}
			++s;
		}
		for(i=0; i<w; ++i){
			for(j=0; j<w; ++j){
				a[t+1][i][j] = 0ll;
				for(k=0; k<w; ++k){
					add_mod(a[t+1][i][j],(a[t][i][k]*a[t][k][j])%MOD);
				}
			}
		}
		++t;
		h /= 2;
	}
	printf("%lld\n",dp[s][p-1]);
	return 0;
}


Measured memory_bytes: 256
# Title: count all Shichi-Go numbers in N!
# Link: https://abc114.contest.atcoder.jp/tasks/abc114_d

import sys
import collections

sys.setrecursionlimit(10 ** 6)


read_single_int = lambda: int(sys.stdin.readline().strip())


def add_power(n: int, ps: list):
    i = 2
    while n != 1:
        if n % i == 0:
            n = n // i
            ps[i] += 1
        else:
            i += 1


def solution(n: int):
    ps = [0 for _ in range(n+1)]

    for i in range(2, n+1):
        add_power(i, ps)

    powers = collections.defaultdict(lambda: 0)

    for p in range(2, n+1):
        powers[p] = len(list(filter(lambda x: x >= p, ps)))

    return powers[74] + powers[24] * (powers[2]-1) + powers[14] * (powers[4]-1) + powers[4] * (powers[4]-1) * (powers[2]-2)//2


def main():
    n = read_single_int()
    print(solution(n))


if __name__ == '__main__':
    main()

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class ATransfer {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int a, b, c;
    cin >> a >> b >> c;

    cout << max(0, c - (a - b)) << endl;

}
};

int main() {
	ATransfer solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#define MAXN 100010
int head[MAXN], to[MAXN << 1], next[MAXN << 1], tot = 0;
inline void $(int u, int v) {
    next[tot] = head[u], to[tot] = v, head[u] = tot++;
    next[tot] = head[v], to[tot] = u, head[v] = tot++;
}
int n, dis[MAXN], fa[MAXN];
std::queue<int> Q;
int bfs(int x) {
    Q.push(x);
    dis[x] = fa[x] = 0;
    int ans = x;
    while (Q.size()) {
        int x = Q.front();
        Q.pop();
        for (int i = head[x]; ~i; i = next[i]) {
            if (to[i] == fa[x]) continue;
            fa[to[i]] = x;
            if ((dis[to[i]] = dis[x] + 1) > dis[ans]) ans = to[i];
            Q.push(to[i]);
        }
    }
    return ans;
}
int h, t, body[MAXN], k[MAXN], p[MAXN], m;
int ans0[MAXN], ans1[MAXN];
int main() {
    memset(head, -1, sizeof(head));
    scanf("%d", &n);
    for (int i = 1, x, y; i < n; i++) {
        scanf("%d%d", &x, &y);
        $(x, y);
    }
    t = bfs(h = bfs(1));
    // printf("H : %d, T : %d\n", h, t);
    for (int x = t;; x = fa[x]) {
        body[x] = 1;
        p[++m] = x;
        // printf("%d ", x);
        if (x == h) break;
    }
    // puts("");
    for (int i = 1; i <= n; i++) {
        if (!body[i]) {
            if (!body[fa[i]]) return puts("-1"), 0;
            k[fa[i]]++;
        }
    }
    for (int i = 1, x = 1; i <= m; i++) {
        for (int j = 1; j <= k[p[i]]; j++) ans0[x + j - 1] = x + j;
        ans0[x + k[p[i]]] = x;
        x += k[p[i]] + 1;
    }
    std::reverse(p + 1, p + m + 1);
    for (int i = 1, x = 1; i <= m; i++) {
        for (int j = 1; j <= k[p[i]]; j++) ans1[x + j - 1] = x + j;
        ans1[x + k[p[i]]] = x;
        x += k[p[i]] + 1;
    }
    for (int i = 1; i <= n; i++) {
        if (ans0[i] > ans1[i]) {
            std::swap(ans0, ans1);
            break;
        } else if (ans0[i] < ans1[i])
            break;
    }
    for (int i = 1; i <= n; i++) printf("%d%c", ans0[i], " \n"[i == n]);
    return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;


int main() {
	int N;
	cin >> N;
	VI C(N-1), S(N-1), F(N-1);
	REP(i, N - 1) cin >> C[i] >> S[i] >> F[i];

	REP(i, N - 1) {
		int t = 0;
		FOR(j, i, N - 1) {
			int k = 0;
			if (t <= S[j]) t = S[j];
			else {
				while (t > S[j] + F[j] * k) k++;
				t = S[j] + F[j] * k;
			}
			t += C[j];
		}
		cout << t << endl;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// It's something that is not good
// & i'm trying right just nothing
// dont't know what god is upto
// but i shall tryna make it come.
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define el "\n"

ll tests=1;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    //cin>>tests;
    while(tests--){
        ll n,d; cin>>n>>d;
        vector<pair<ll,ll>> v;
        for(int i=0;i<n;i++){
        	ll x,y; cin>>x>>y;
        	v.push_back({x,y});
        } 
        ll cnt=0;
        for(auto i:v){
        	if(sqrt(i.first*i.first + i.second*i.second)<=d) cnt++;
        }
        cout<<cnt<<el;
    }
}

Measured memory_bytes: 7428
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val as = in.readLine().split("\\s+").map(_.toInt)

    System.out.println(
      if (as.sum >= 22) {
        "bust"
      } else {
        "win"
      }
    )
  }
}


Measured memory_bytes: 27312
package main

import "fmt"

func main() {
        var x int
        fmt.Scanf("%d", &x)

        fraction := x % 100
        if fraction == 0 {
                fmt.Println("1")
                return
        }
        num := x / 100

        for one := 0; one < 100; one++ {
                for two := 0; two < 50; two++ {
                        for three := 0; three < 34; three++ {
                                for four := 0; four < 25; four++ {
                                        for five := 0; five < 20; five++ {
                                                if fractionCount(one, two, three, four, five) == fraction && one+two+three+four+five <= num {
                                                        fmt.Println("1")
                                                        return
                                                }
                                        }
                                }
                        }
                }
        }
        fmt.Println("0")
}

func fractionCount(one, two, three, four, five int) int {
        return one + two*2 + three*3 + four*4 + five*5
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <utility>
#include <cmath>
using namespace std;
#define MAXSIZE 100005
#define PI 3.141592653589793
#define MOD_CONST 1000000007
using lli = long long int;
using PII = pair<int, int>;

int main(){
    lli x;
    cin >> x;
    lli ans = ceil((sqrt(1 + 8 * x) - 1) * 0.5);
    cout << ans << endl;
    return 0;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//

int N;
vector<int> a;

void solve() {
    vector<int> res;
    for (int i = 0; i < N; ++i) {
        int pivot = -1;
        // 最大のa[j] == j 探索
        for (int j = a.size() - 1; j >= 0; --j) {
            if (a[j] == j) {
                pivot = j;
                break;
            }
        }
        if (pivot == -1) {
            cout << -1 << endl;
            return;
        }
        res.push_back(pivot + 1);
        a.erase(a.begin() + pivot);
    }
    
    // 逆順につめたため、反転
    reverse(res.begin(), res.end());

    for (auto v : res) cout << v << endl;
}


int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; ++i){
        cin >> a[i];
        --a[i];
    }
    solve();
    return 0;
}


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

ll cnt = 0;
int n,m;
int* a;
int* s;
ll* dp;

int main(void) {

    cin >> n >> m;
    
    a = new int[m];
    s = new int[n+10];
    dp = new ll[n+10];

    for(int i = 0; i < m; ++i) {
        cin >> a[i];
        s[a[i]] = -1;
    }

    dp[0] = 1;

    for(int i = 0; i < n; ++i) {
        for(int d = 1; d < 3; ++d) {
            if(s[i+d] != -1) {
                dp[i+d] += dp[i];
                dp[i+d] %= 1000000007;
            }
        }
    }

    cout << dp[n] << endl;

    return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
void insertionSort(int A[], const int n, const int g, int *cnt) {
    for (int i = g; i < n; ++i) {
        int tmp = A[i];
        int j   = i - g;
        while (-1 < j && tmp < A[j]) {
            // cout << A[j+g] << "<-->" << A[j] << endl;
            A[j + g] = A[j];
            j        = j - g;
            ++*cnt;
        }
        A[j + g] = tmp;
    }
}

void shellSort(int A[], const int n) {
    int cnt = 0;
    int m;
    int G[100];
    for (int i = 0; i < 100; ++i) {
        if (i == 0)
            G[i] = n / 2 + 1;
        else
            G[i] = G[i - 1] / 2 - 1;
        if (G[i] < 0) {
            G[i - 1] = 1;
            G[i]     = 0;
            m        = i;
            break;
        }
    }

    for (int i = 0; i < m; ++i) insertionSort(A, n, G[i], &cnt);

    //出力
    printf("%d\n", m);
    for (int i = 0; i < m; ++i) {
        if (i) printf(" ");
        printf("%d", G[i]);
    }
    printf("\n%d\n", cnt);
    for (int i = 0; i < n; ++i) printf("%d\n", A[i]);
}

int main() {
    //入力
    int n;
    scanf("%d", &n);
    int A[n];
    for (int i = 0; i < n; ++i) scanf("%d", &A[i]);

    //シェルソート
    shellSort(A, n);

    return 0;
}



Measured memory_bytes: 7128
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

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


const int BIG_NUM = 1e8;
const ll INF = 1000000000000000000;

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

	int t = (y - 2 * x) / 2;
	int c = x - t;

	if (c < 0 || t < 0) {
		cout << "No" << endl;
		return 0;
	}

	if (2 * c + 4 * t != y) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>
using ll = long long;
using namespace std;
vector<int> v;
int main(void)
{
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; ++i)
    {
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    int ans = 1e9;
    for (int i = 0; i <= N - K; ++i)
    {

        ans = min(ans, v[i + K - 1] - v[i]);
    }
    cout << ans << endl;
    return 0;
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint x; cin >> x;

  lint ans;
  ans = x/11*2;

  if(0 < x%11 && x%11 <= 6) { ans++; }
  else if(x%11 >= 7) { ans += 2; }

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

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		String inputStr = sc.nextLine();
		sc.close();
		
		ArrayList<int[]> zArrList = new ArrayList<>();
		for(int i = 0 ; i < inputStr.length(); i++) {
			zArrList.add(zAlgorithm(inputStr.substring(i)));
		}
		
		int maxLen = 0;
		for(int i = 0; i < zArrList.size(); i++) {
			int[] intArr = zArrList.get(i);
			for(int j = 0; j < intArr.length; j++) {
				int zArrValue = intArr[j];
				if(zArrValue <= j && maxLen < zArrValue) {
					maxLen = zArrValue;
				}
			}
		}
		
		System.out.println(maxLen);
	}
	
	public static int[] zAlgorithm(String str) {
		
		int n = str.length();
		int[] zArr = new int[n];
		int L,R,k;
		
		L = R = 0;
		for(int i = 1; i < n;i++) {
			if(i > R) {
				L = R = i;
				while(R < n && str.charAt(R - L) == str.charAt(R)) {
					R++;
				}
				zArr[i] = R - L;
				R--;
			}else {
				k = i - L;
				if(zArr[k] < R - i +1) {
					zArr[i] = zArr[k];
				}else {
					L = i;
					while(R < n && str.charAt(R - L) == str.charAt(R)) {
						R++;
					}
					zArr[i] = R - L;
					R--;
				}
			}
		}
		
		return zArr;
	}
}


Measured memory_bytes: 108568
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << H * W - h * W - w * H + h * w << endl;

    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
Rel = [tuple(map(int,input().split())) for _ in range(m)]
q = int(input())
Que = [tuple(map(int,input().split())) for _ in range(q)]

class UF:
    def __init__(self):
        self.roots = [i for i in range(n)]
        self.rank = [1 for _ in range(n)]

    def same(self,a,b):
        if self.find(a) == self.find(b):
            return True
        else:
            return False

    def find(self,a):
        if self.roots[a] == a:
            return a
        else:
            self.roots[a] = self.find(self.roots[a])
            return self.roots[a]

    def union(self,a,b):
        a,b = self.find(a),self.find(b)
        if a != b:
            if self.rank[a] >= self.rank[b]:
                self.roots[b] = a
                if self.rank[a] == self.rank[b]:
                    self.rank[b] += 1
            else:
                self.roots[a] = b

uf = UF()

for i in range(m):
    uf.union(Rel[i][0],Rel[i][1])

for i in range(q):
    if uf.same(Que[i][0],Que[i][1]):
        print("yes")
    else:
        print("no")



Measured memory_bytes: 25688
import java.util.Scanner;

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

        while (sc.hasNext()) {
            int i = 0;
            int w = sc.nextInt();
            int n = sc.nextInt();
            String rem;
            int[] array;
            array = new int[w];

            for (i = 0; i < w; i++) {
                array[i] = i + 1;
            }

            for (i = 0; i < n; i++) {
                rem = sc.next();
                String[] swap = rem.split(",");
                int a = Integer.parseInt(swap[0]) - 1;
                int b = Integer.parseInt(swap[1]) - 1;
                int temp = 0;
                temp = array[a];
                array[a] = array[b];
                array[b] = temp;
            }
            for (i = 0; i < w; i++) {
                System.out.println(array[i]);
            }
        }
    }
}



Measured memory_bytes: 25752
#include <stdio.h>
int main(){
  int a,b;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='?')break;
    switch(op){
    case '+':
      printf("%d\n",a+b);
      break;
    case '-':
      printf("%d\n",a-b);
      break;
    case '*':
      printf("%d\n",a*b);
      break;
    case '/':
      printf("%d\n",a/b);
      break;
    }
  }
  return 0;
}

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

int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s==u){
    cout << a-1 << " " << b << endl;
  }else{
    cout << a << " " << b-1 << endl;
  }
}

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


int main(){
    int64_t n, k, ans, t;

    cin >> n >> k;

    t = n / k;
    ans = min(n - t * k, (t + 1) * k - n );

    cout << ans << endl;
    
}

Measured memory_bytes: 3628
s=input()
while 0<len(s):
    if s[-5:]=='erase' or s[-5:]=='dream':
        s=s[0:-5]
    elif s[-6:]=='eraser':
        s=s[0:-6]
    elif s[-7:]=='dreamer':
        s=s[0:-7]
    else:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 3188
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>

// just implement simple stack
typedef struct StkKey {
    int b4;
    int area;
} StkKey;
typedef struct StkDat {
    StkKey key;
    struct StkDat *next;
} StkDat;
typedef struct Stack {
    size_t len;
    StkDat *top;
} Stack;
#define stk_init(s) ((s) ? ((s)->len = 0, (s)->top = NULL) : 0)
#define stk_len(s) ((s) ? (s)->len : 0)
#define stk_top(s) ((s)->top->key)
StkKey stk_pop(Stack *stk_hdr) {
    assert(stk_hdr->len != 0);
    stk_hdr->len--;
    StkKey key = stk_hdr->top->key;
    StkDat *old_head = stk_hdr->top;
    stk_hdr->top = stk_hdr->top->next;
    free(old_head);
    return key;
}
void stk_push(Stack *stk_hdr, const StkKey key) {
    StkDat *new_dat = (StkDat *)malloc(sizeof(StkDat));
    new_dat->key = key;
    new_dat->next = stk_hdr->top;
    stk_hdr->top = new_dat;
    stk_hdr->len++;
}
// <- stack

int main(int argc, char **argv) {
    // stack for '\' index
    Stack stk_index;
    stk_init(&stk_index);
    // stack for area size and its index
    Stack stk_area;
    stk_init(&stk_area);
    char c;
    // StkKey: {index, area size}
    StkKey key;
    for(int i = 0; ~scanf("%c", &c); ++i) {
        switch(c) {
        case '\\':
            stk_push(&stk_index, (StkKey){i, 0});
            break;
        case '/':
            // stack is empty -> do nothing
            if(stk_len(&stk_index) == 0) break;
            key = stk_pop(&stk_index);
            // if larger index exist, combine
            while(stk_len(&stk_area) && key.b4 < stk_top(&stk_area).b4) {
                key.area += stk_pop(&stk_area).area;
            }
            // combined ? key.area has value : key.area is 0
            stk_push(&stk_area, (StkKey){key.b4, i - key.b4 + key.area});
            break;
        default:
            break;
        }
    }
    int rstack[10000];
    int area = 0;
    int stk_len = (int)stk_len(&stk_area);
    for(size_t i = 0; i < stk_len; ++i) {
        rstack[i] = stk_pop(&stk_area).area;
        area += rstack[i];
    }
    printf("%d\n", area);
    printf("%d", stk_len);
    for(int i = stk_len - 1; i >= 0; --i) {
        printf(" %d", rstack[i]);
    }
    printf("\n");
}



Measured memory_bytes: 2320
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define REP(i,n) for (int i=1;i<=n;i++)
 
int ketasu(int n,int m) {
	int count = 1;
	while (n >= m) {
		n /= m;
		count++;
	}
	return count;
}
 
int main() {
  int n,m;cin>>n>>m;
  cout<<ketasu(n,m)<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        if((a == 1 && b == 2) || (a == 2 && b == 1)){
            System.out.println(3);
        }else if((a == 1 && b == 3) || (a == 3 && b == 1)){
            System.out.println(2);
        }else{
            System.out.println(1);
        }
    }
}

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
signed main()
{
	int s,w;
	cin>>s>>w;

	if(w>=s)
	{
		cout<<"unsafe";
	}
	else
	{
		cout<<"safe";
	}
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;
#define mod 1000000007;

int main (void) {
	int n,x[101],y[101],h[101],i,j,k,flag,good;
	cin >> n;
	for(i=1;i<=n;i++) cin >> x[i] >> y[i] >> h[i];
	for(i=0;i<=100;i++){
		for(j=0;j<=100;j++){
			good=0;
			for(k=1;k<=n;k++){
				if(h[k]!=0){
				flag=h[k]+abs(i-x[k])+abs(j-y[k]);
				break;
				}
			}
			for(k=1;k<=n;k++){
				if(h[k]!=0){
					if(flag!=h[k]+abs(i-x[k])+abs(j-y[k])){
						good=1;
						break;
					}
				} else {
					if(flag>h[k]+abs(i-x[k])+abs(j-y[k])){
						good=1;
						break;
					}
				}
			}
			if(good==0){
				cout << i << " " << j << " " << flag;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<iostream>
#include <string>
#include <set>
#include<algorithm>
#include<map>
#include <vector>
#include <iterator>
#include<stack>
int a[100001];
int b[100001];
int c[100001];
int x[100001][3];
void func(int n){
    x[n-1][0]=a[n-1];
    x[n-1][1]=b[n-1];
    x[n-1][2]=c[n-1];
    for(int i=n-2; i>=0; i--){
        if(x[i+1][1]>x[i+1][2]){
            x[i][0]=a[i]+x[i+1][1];
        }
        else{
            x[i][0]=a[i]+x[i+1][2];
        }
        if(x[i+1][0]>x[i+1][2]){
            x[i][1]=b[i]+x[i+1][0];
        }
        else{
            x[i][1]=b[i]+x[i+1][2];
        }
        if(x[i+1][1]>x[i+1][0]){
            x[i][2]=c[i]+x[i+1][1];
        }
        else{
            x[i][2]=c[i]+x[i+1][0];
        }
    }
    return;
}
int main(){
   int n;
   cin>>n;
   for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
   }
   func(n);
   int  maxi=0;
   for(int j=0; j<3; j++){
    if(x[0][j]>maxi){
        maxi=x[0][j];
    }
   }
   cout<<maxi;
}














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

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define fr(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define gf(i,n) for (int i=0 ; i<n ; i+=1)
#define rfor(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define prarr(a,n) gf(i,n){printf("%d ", a[i]);}printf("\n");
#define sumarr(a,n) int zserkd=0;gf(i,n){zserkd+=a[i];}cout<<zserkd<<endl;
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

/****** Template of some basic operations *****/
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }


void solve()
{
	string s;
	cin >>s;
	if(s == "ABC")
	{
		cout<<"ARC";
	}
	else{
		cout<<"ABC";
	}
}
int main(){
	
	// int t;
	// cin>>t;
	// while(t--)
	// {
		// cout<<solve()<<endl;
		solve();
	// }

	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int h,w,n;
int a[10000], ans[10000];

int main(){
    cin >> h >> w >> n;
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    int num = 0, direct = 1;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < a[i]; j++){
                ans[num] = i+1;

                num += direct;
                if(num%w == 0 && direct == 1){
                    direct *= -1;
                    num += w-1;
                }
                else if(num%w == w-1 && direct == -1){
                    num += w+1;
                    direct *= -1;
                }
            }
        }

    num = 0;
    direct = -1;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            printf("%d ", ans[i*w+j]);
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  while(1){
    int d, n, m;
    scanf("%d%d%d", &d, &n, &m);
    if(d==0) return 0;
  
    vector<int> s(n);
    s[0]=0;
    FOR(i, 1, n) scanf("%d", &s[i]);
    VSORT(s);
    REP(i, n) s.push_back(s[i]+d);

    int ans=0;
    REP(i, m){
      int k;
      scanf("%d", &k);
      int u=upper_bound(s.begin(), s.end(), k)-s.begin();
      if(abs(s[u]-k)<abs(s[u-1]-k)){
	ans+=abs(s[u]-k);
      }
      else{
	ans+=abs(s[u-1]-k);
      }
    }

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

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

int par[100010];
int rank_[100010];

void init(int n){
  for(int i=0; i<n; i++){
    par[i] = i;
    rank_[i] = 0;
  }
}

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

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x==y) return;
  if(rank_[x]<rank_[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(rank_[x]==rank_[y]) rank_[x]++;
  }
}

bool same(int x, int y){
  return find(x)==find(y);
}
 
int main(){
  int n, m;
  cin >> n >> m;
  init(n);
  vector<int> s(n);
  for(int i=0; i<n; i++){
    cin >> s[i];
    s[i]--;
  }
  for(int i=0; i<m; i++){
    int x, y;
    cin >> x >> y;
    x--; y--;
    unite(x,y);
  }
  int ans = 0;
  for(int i=0; i<n; i++){
    if(same(i, s[i])) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

struct SegmentTree {
  int siz;
  vector<ll> node;
  SegmentTree(int n, ll init) {
    siz = 1;
    while (siz < n) siz <<= 1;
    node.assign(2 * siz, init);
  }

  void update(int k, ll x) {
    k += siz - 1;
    node[k] = x;
    while (k > 0) {
      k = (k - 1) / 2;
      node[k] = max(node[2 * k + 1], node[2 * k + 2]);
    }
  }

  ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = siz;
    if (r <= a || b <= l) return -LINF;
    if (a <= l && r <= b) return node[k];
    ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return max(vl, vr);
  }
};

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c, d, tmp, m, h, w, x, y;
ll k, q, f[ohara], bit[ohara], bits[ohara];
set<ll> st;
U_MAP mp;
ll nowco[ohara];

ll sum(ll i) {
  ll s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(ll i, ll x) {
  while (i <= n) {
    bit[i] += x;
    i += i & -i;
  }
}

ll sums(ll i) {
  ll s = 0;
  while (i > 0) {
    s += bits[i];
    i -= i & -i;
  }
  return s;
}

void adds(ll i, ll x) {
  while (i <= n) {
    bits[i] += x;
    i += i & -i;
  }
}

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

  cin >> n;
  rep(i, n) cin >> a[i], b[a[i]]++;

  rep(i, n) {
    if (b[a[i]] == 0) continue;
    add(b[a[i]], b[a[i]]);
    adds(b[a[i]], 1);
    cnt++;
    b[a[i]] = 0;
  }

  rrep(i, 1, n + 1) {
    ll cost;
    cost = cnt * i;
    cost = cost - (sums(i) * i - sum(i));
    cost /= i;
    f[i] = cost;
    // cout << f[i] << " " << i << "\n";
  }

  SegmentTree tree(ohara, -LINF);

  rrep(i, 1, n + 1) {
    nowco[f[i]] = max(nowco[f[i]], f[i]);
    tree.update(nowco[f[i]], i);
  }

  rep(i, n) {
    ans = tree.query(i + 1, ohara);
    cout << (ans == -LINF ? 0 : ans) << "\n";
  }
  return 0;
}

Measured memory_bytes: 39936
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<62;
int main(){
    int n,m;
    cin>>n>>m;
    multiset<int> A;
    for(int i=0;i<n;++i){
        int a;
        cin>>a;
        A.insert(-a);
    }
    for(int i=0;i<m;++i){
        auto it = A.begin();
        int ma = *it;
        ma  /= 2;
        A.erase(it);
        A.insert(ma);
    }
    cout << -accumulate(A.begin(),A.end(),0ll) << endl;
    return 0;
}



Measured memory_bytes: 4992
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
typedef pair< int, int > Pi;

bool used[50][50][50][50];
char masL[50][50], masR[50][50];
int W, H;
Pi RinS, LenS; //スタート
const int dy[] = { 1, 0, -1, 0}, dx[] = { 0, 1, 0, -1};

int bfs(){
  queue< Pi > Rin, Len;
  Rin.push(RinS);
  Len.push(LenS);
  used[RinS.first][RinS.second][LenS.first][LenS.second] = true;
  while(!Rin.empty()){
    Pi r = Rin.front(), l = Len.front();
    Rin.pop(), Len.pop();
    if(masL[l.first][l.second] == '%' && masR[r.first][r.second] == '%'){
      return true;
    }
    if(masL[l.first][l.second] != '%' && masR[r.first][r.second] != '%'){
      for(int i = 0; i < 4; i++){
        int rny = min( H - 1, max( 0, r.first + dy[i]));
        int rnx = min( W - 1, max( 0, r.second + dx[i]));
        int lny = min( H - 1, max( 0, l.first + dy[i]));
        int lnx = min( W - 1, max( 0, l.second - dx[i]));
        //めんどい
        if(masL[lny][lnx] == '#'){ //元の位置に戻す！！
          lny = l.first, lnx = l.second;
        }
        if(masR[rny][rnx] == '#'){
          rny = r.first, rnx = r.second;
        }
        
        if(!used[rny][rnx][lny][lnx]){
          used[rny][rnx][lny][lnx] = true;
          Rin.push( Pi( rny, rnx)), Len.push( Pi( lny, lnx));
        }
      }
    }
  }
  return false; //いけない!!
}
int main()
{
  while(cin >> W >> H, W){
    memset( used, false, sizeof(used));
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        cin >> masL[i][j];
        if(masL[i][j] == 'L'){
          LenS = Pi( i, j);
          masL[i][j] = '.';
        }
      }
      for(int j = 0; j < W; j++){
        cin >> masR[i][j];
        if(masR[i][j] == 'R'){
          RinS = Pi( i, j);
          masR[i][j] = '.';
        }
      }
    }
    bool judge = bfs();
    if(judge) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 8244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    string S;
    cin >> S;
    cout << (S[0] == S[1] && S[1] == S[2] ? "No" : "Yes");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

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

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

bool comp(std::string& s, std::string& t) {
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == '?' or t[i] == '?') continue;
		if(s[i] != t[i]) return false;
	}
	return true;
};

int main() {
	std::string a, b, c; cin >> a >> b >> c;

	std::vector<int> B, C;
	std::string s = std::string(4000, '?') + a + std::string(4000, '?');
	for(int i = 0; i < s.size() - b.size() + 1; i++) {
		std::string t = s.substr(i, b.size());
		if(!comp(t, b)) continue;
		B.push_back(i);
	}
	for(int i = 0; i < s.size() - c.size() + 1; i++) {
		std::string t = s.substr(i, c.size());
		if(!comp(t, c)) continue;
		C.push_back(i);
	}

	std::vector<bool> BC(b.size(), false), CB(c.size(), false);
	for(int i = 0; i < b.size(); i++) {
		std::string X = b.substr(i, std::min(b.size() - i, c.size()));
		std::string Y = c.substr(0, std::min(b.size() - i, c.size()));
		if(!comp(X, Y)) continue;
		BC[i] = true;
	}
	for(int i = 0; i < c.size(); i++) {
		std::string X = c.substr(i, std::min(c.size() - i, b.size()));
		std::string Y = b.substr(0, std::min(c.size() - i, b.size()));
		if(!comp(X, Y)) continue;
		CB[i] = true;
	}

	int ans = a.size() + b.size() + c.size();
	for(auto x: B) {
		for(auto y: C) {
			int L = std::min({4000, x, y});
			int R = std::max({4000 + a.size(), x + b.size(), y + c.size()});
			if(x < y) {
				if(x + b.size() <= y) {
					ans = std::min(ans, R - L);
				} else {
					if(!BC[y - x]) continue;
					ans = std::min(ans, R - L);
				}
			} else {
				if(y + c.size() <= x) {
					ans = std::min(ans, R - L);
				} else {
					if(!CB[x - y]) continue;
					ans = std::min(ans, R - L);
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 896
s = input()


for i in range(1 << 3):
    count = int(s[0])
    for j in range(1, 4):
        if i & (1 << j-1):
            count+=int(s[j])
        else:
            count-=int(s[j])
    
    if count == 7:
        ans = s[0] 
        for j in range(1, 4):
            if i & (1 << j-1):
                ans += '+'+s[j]
            else:
                ans += '-'+s[j]

        ans += '=7'
        print(ans)
        exit()

Measured memory_bytes: 9208
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

ll ans(ll x,ll c,ll d){
ll q,w,e;
  q=x/c; w=x/d; e=x/LCM(c,d);
return x-q-w+e ;
}

int main(){
 ll a,b,c,d; cin>>a>>b>>c>>d; 
  cout<< ans(b,c,d)-ans(a-1,c,d) <<endl;
  
}

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

int main(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    bool flag =true;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            flag = false;
        }
    }
    cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3624
def main():
    h,w = map(int, input().split())
    S = ['.'*(w+2)]
    for i in range(h):
        S.append('.'+input()+'.')
    S.append('.'*(w+2))
    for hi in range(1,h+1):
        for wi in range(1,w+1):
            if S[hi][wi]=='#':
                if '#' in [S[hi][wi-1],S[hi][wi+1],S[hi-1][wi],S[hi+1][wi]]:
                    continue
                else:
                    print('No')
                    return
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
import java.io.*;
import java.util.regex.Pattern;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Pattern pattern=Pattern.compile("the|this|that");
		String str;
		try{
			while((str=br.readLine())!=null){
				char[] ch=str.toCharArray();
				while(true){
					for(int i=0;i<ch.length;i++){
						if('a'<=ch[i]&&ch[i]<'z'){	//a〜zでプラスしてループ
							ch[i]++;
						}else if(ch[i]=='z'){
							ch[i]='a';	//zの次はa
						}
					}
					if(pattern.matcher(String.valueOf(ch)).find()){
						break;
					}
				}
				System.out.println(ch);
			}
		}catch(Exception e){
		}
	}
}

Measured memory_bytes: 17848
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let dist x1 y1 x2 y2 = 
        let dx = (x1-x2)|>double
        let dy = (y1-y2)|>double
        sqrt (dx*dx+dy*dy)
    let N = R int
    let x = Array.zeroCreate N
    let y = Array.zeroCreate N
    for i in [0..N-1] do
        let p = RS double
        x.[i] <- p.[0]
        y.[i] <- p.[1]
    [0..N-2]
    |>Seq.sumBy(fun c -> [c..N-1]|>Seq.sumBy(fun d -> dist x.[c] y.[c] x.[d] y.[d]))
    |>fun c ->  c*(2|>double)/(N|>double)
    |>stdout.WriteLine
    0


Measured memory_bytes: 11348
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int num;
	double sx1, sy1, sx2, sy2;
	double ex1, ey1, ex2, ey2;

	cin >> num;

	for(int i = 0; i < num; i++)
	{
		cin >> sx1 >> sy1 >> sx2 >> sy2 >> ex1 >> ey1 >> ex2 >> ey2;

		if( (sy2-sy1)/(sx2 - sx1) == (ey2-ey1)/(ex2-ex1))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1220
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//cin.tie(0);
//ios::sync_with_stdio(false);
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
llint LBI(vector<llint>&ar,llint in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint UBI(vector<llint>&ar,llint in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,ans=0;cin>>n;
	while(n>0){ans+=n%10;n/=10;}
	if(ans==1){ans+=9;}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256