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

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

#define loop(i, n) for(int i = 0;i < n;i++)

int main(void){

    string a, b;
    cin >> a >> b;

    b.pop_back();

    if(a == b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

int main(){
	int len[ 10 ], vel[ 2 ];
	char c;

	while ( cin >> len[ 0 ] >> c >> len[ 1 ] >> c >> len[ 2 ] >> c >> len[ 3 ] >> c
				>> len[ 4 ] >> c >> len[ 5 ] >> c >> len[ 6 ] >> c >> len[ 7 ] >> c
				>> len[ 8 ] >> c >> len[ 9 ] >> c >> vel[ 0 ] >> c >> vel[ 1 ] ){
		int length = 0;
		for ( int i = 0; i < 10; ++i ){
			length += len[ i ];
		}
		double location = static_cast< double >( vel[ 0 ] * length ) / static_cast< double >( vel[ 0 ] + vel[ 1 ] );
		length = 0;
		for ( int i = 0; i < 10; ++i ){
			length += len[ i ];
			if ( location <= length ){
				cout << i + 1 << endl;
				break;
			}
		}
	}


	return 0;
}

Measured memory_bytes: 0
n,m,q=map(int,input().split())
a=[[0 for _ in range(n)] for _ in range(n)]

for i in range(m):
  x,y=map(int,input().split())
  a[x-1][y-1]+=1
  
for j in range(n):
  for k in range(1,n):
    a[j][k]=a[j][k]+a[j][k-1]
    
for l in range(q):
  ans=0
  L,R=map(int,input().split())
  for g in range(L-1,R):
    ans+=a[g][R-1]
  print(ans)

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

int main(){
	int a, b, c, d, e, max;
	cin >> a >> b;
	c=a+(a-1);
	d=b+(b-1);
	e=a+b;
	max=c;
	if(max<d) max=d;
	if(max<e) max=e;
	cout << max << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define Fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define deb(x) cout<<#x<<" "<<x<<endl;
#define all(v) v.begin(),v.end()
#define endl '\n'
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void judge() {
#ifndef ONLINE_JUDGE
	FILE_READ_IN
	FILE_READ_OUT
#endif
}

int main() {
	Fast;
	int t = 1;
	judge();
	// cin >> t;
	while (t--) {
		int n;
		cin >> n;
		string a;
		cin >> a;
		int r = 0, w = 0;
		for (auto i : a) {
			if (i == 'R')r++;
			else
				w++;
		}
		if(!r || !w){
			cout<<0<<endl;
			return 0;
		}
		int ans = 0;
		for (int i = 0; i < r; i++) {
			if (a[i] != 'R') {
				ans++;
			}
		}
		cout << ans << endl;
	}
}

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

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

const long long MOD = 1000000007;

ll modPow(int a, int p) {
    if (p == 0) return 1;
    if (p%2==0) {
        ll half = modPow(a, p/2);
        return half * half % MOD;
    }
    else return a * modPow(a, p-1) % MOD;
}

ll calcComb(int a, int b) {
    if (b > a-b) return calcComb(a, a-b);
    ll num = 1, den = 1;
    rep(i, b) num = num * (a-i) % MOD;
    rep1(i, b) den = den * i % MOD;
    return num * modPow(den, MOD-2) % MOD;
}

int main(){
    int n, m;
    cin >> n >> m;
    int mt = m;
    vi b;
    for (int i=2; i*i<=m; ++i) {
        int cnt = 0;
        while (mt%i==0) {
            mt /= i;
            ++cnt;
        }
        if (cnt > 0) b.pb(cnt);
    }
    if (mt != 1) b.pb(1);
    ll ans = 1;
    for (int a : b) {
        ans = ans * calcComb(a+n-1, n-1) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n;
    cin>>n;
    vi a(n),ans(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int cur = 0;
    for(int i=1;i<n;i++) cur ^= a[i];
    ans[0] = cur;
    for(int i=1;i<n;i++){
        cur ^= (a[i]^a[i-1]);
        ans[i] = cur;
    }
    for(int i : ans) cout<<i<<" ";
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6312
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;

int main(){


  ll N;
  cin>>N;
  vector<ll> a(N);

 ll mc=0;
 ll zc=0;
 ll mmax=10000000000000;
  for(ll i=0;i<N;i++){
  cin>>a[i];
  }

  for(ll i=0;i<N;i++){
    if(a[i]==0){
      zc=1;
      break;
    }
    else if(a[i]<0){
    mc++;
    }

    if(mmax>abs(a[i])){
      mmax=abs(a[i]);
    }
  }

  ll ans=0;


  for(ll i=0;i<N;i++){
  ans+=abs(a[i]);
  }

if(zc==1||mc%2==0){

}
else
{
 ans-=2*mmax;
}


cout<<ans<<endl;
}
  


Measured memory_bytes: 1024
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

import itertools
l = list(itertools.permutations(range(1, n+1)))
#permutations:順列 combinations:組み合わせ (list, 数字)rCnのnが「数字」で決まる
print(abs(l.index(p) - l.index(q)))


Measured memory_bytes: 8052
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int x[101], y[101], h[101];
	int maxx = 0, maxy = 0, maxh = 0;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i] >> h[i];
		if(h[i] > maxh){
			maxx = x[i];
			maxy = y[i];
			maxh = h[i];
		}
	}
	for(int cx = 0; cx <= 100; cx++){
		for(int cy = 0; cy <= 100; cy++){
			int ansh = maxh + abs(maxx - cx) + abs(maxy - cy);
			bool isAnswer = true;
			for(int i = 0; i < n; i++){
				int tmp = max(ansh - abs(x[i] - cx) - abs(y[i] - cy), 0);
				if(tmp != h[i]){
					isAnswer = false;
					break;
				}
			}
			if(isAnswer){
				cout << cx << " " << cy << " " << ansh << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  uint32_t X = 0, N = 0;
  std::cin >> X >> N;
  std::vector<uint32_t> P(N);

  bool included = false;
  for (auto &&p : P){
    std::cin >> p;
    if(p == X) included = true;
  }

  uint32_t ans = 0;
  if(!included){
    ans = X;
  }else{
    std::sort(P.begin(), P.end());
    uint32_t X_ind = std::lower_bound(P.begin(), P.end(), X)-P.begin();
    uint32_t max_diff = std::min(X_ind+1, N-X_ind);
    bool solve = false;
    for (size_t d = 1; !solve && d <= max_diff; d++)
    {
      if(X_ind >= d && P[X_ind-d] != X-d) ans = X-d, solve = true;
      else if(X_ind + d < N && P[X_ind+d] != X+d) ans = X+d, solve = true;
    }
    if(!solve){
      ans = (X_ind + 1 == max_diff) ? X-max_diff : X+max_diff;
    }    
  }
  

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >>d;
    int x = c - a;
    int y = d - b;
    printf("%d %d %d %d\n", c - y, d + x, a - y, b + x);
}

Measured memory_bytes: 256
t = int(input())
for i in range(t):
    n = int(input())
    li = [int(x) for x in input().split()]
    a, b = 0, 0
    for j in range(1, n):
        a = max(a, li[j]-li[j-1])
        b = min(b, li[j]-li[j-1])
    print(a, -b)


Measured memory_bytes: 5612
import functools as ft

h,w = map(int, input().split())
mat = [[True] * (w+2)]
for _ in range(h):
    mat.append([True] + [a == '#' for a in input()] + [True])
mat.append([True]*(w+2))

prev = []
for i in range(1,h+1):
    for j in range(1,w+1):
        if mat[i][j]:
            prev.append((i,j))



round = -1
while prev:
    round += 1
    #print(prev)
    #print(mat)
    def calc(next, tup):
        x = tup[0]
        y = tup[1]
        if not mat[x-1][y]:
            next.append((x-1,y))
            mat[x-1][y] = True
        if not mat[x][y-1]:
            next.append((x,y-1))
            mat[x][y-1] = True
        if not mat[x+1][y]:
            next.append((x+1,y))
            mat[x+1][y] = True
        if not mat[x][y+1]:
            next.append((x,y+1))
            mat[x][y+1] = True
        return next
    next = ft.reduce(calc, prev, [])

    prev = next

print(round)


Measured memory_bytes: 106456
#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 INF = 1001001001;


int main() {
    int h, n;
    cin >> h >> n;
    int sum = 0;
    rep(i,n) {
        int a;
        cin >> a;
        sum += a;
    }
    if (h <= sum) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<iostream> 
using namespace std; 
int main(){
    int a,b,d,r;
    double f;
    cin>>a>>b;
    d=a/b;
    r=a%b;
    f=double(a)/double(b);
    cout<<d<<" "<<r<<" "<<fixed<<f<<endl;
}    


Measured memory_bytes: 3284
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <cmath>

#define ll long long int
#define loop(v,n) for(ll v=0;v<n;v++)

using namespace std;

#define MAXN 100000

priority_queue<ll> s,t;

vector<pair<pair<string,ll>,int>> r;

int main() {
    unsigned int n,m;
    cin >> n >> m;
    vector<vector<int>> s;
    for(int i = 0;i < m;i++) {
        int k;
        cin >> k;
        s.emplace_back(vector<int>());
        for(int j = 0;j < k;j++) {
            int ss;
            cin >> ss;
            s[s.size()-1].push_back(ss);
        }
    }
    vector<int> p;
    for(int  i=0;i < m;i++) {
        int pp;
        cin >>pp;
        p.push_back(pp);
    }
    int res = 0;
    for(unsigned int i = 0;i < 1<<n;i++) {
        bool ok = true;
        for(int j = 0;j < s.size();j++) {
            auto& e = s[j];
            int count = 0;
            for(auto& f:e) {
                if(i & 1<<(f-1)) {
                    count++;
                }
            }
            if(count % 2 != p[j]) ok = false;
        }
        if(ok) res++;
    }
    cout << res << endl;
}

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

public class Main {
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int d=sc.nextInt();
		int e=sc.nextInt();
		int f=sc.nextInt();
		
		double water=0;
		double suger=0;
		double max_w=0;
		double max_s=0;
		double max_d=0;
		for(int i=0;100*a*i<=f;i++) {
			for(int j=0;100*(a*i+b*j)<=f;j++) {
				water=100*(a*i+b*j);
				
				for(int k=0;k*c<=f-water;k++) {
					for(int l=0;k*c+l*d<=f-water;l++) {
						suger=k*c+l*d;
						
						if(water/100>=suger/(double)e && max_d<=suger/(water+suger)) {
							max_w=water;
							max_s=suger;
							max_d=suger/(water+suger);
						}
					}
				}
			}
		}
		System.out.println((int)(max_w+max_s)+" "+(int)max_s);
	}
}

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

int main(int argc, char const *argv[])
{
	int h,n,a;
	cin>>h>>n;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		h-=a;
	}
	if (h<=0)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,m,a[maxn];

int main() {
    read(n),read(m);for(int i=1;i<=n*2;i++) read(a[i]);
    sort(a+1,a+n*2+1);
    int l=0,r=n,ans=n;
    while(l<=r) {
        int mid=(l+r)>>1;int mn=m;
        for(int i=1;i<=n-mid;i++)
            mn=min(mn,a[mid*2+i]+a[2*n-i+1]);
        if(mn<m) l=mid+1;
        else ans=mid,r=mid-1;
    }
    int res=0;
    for(int i=1;i<=ans;i++) res=max(res,a[i]+a[ans*2-i+1]);
    for(int i=1;i<=n-ans;i++) res=max(res,a[ans*2+i]+a[n*2-i+1]-m);
    write(res);
    return 0;
}


Measured memory_bytes: 1024
N,M,X = map(int,input().split())
books = [list(map(int,input().split())) for _ in range(N)]
digit = "0"+str(N)+"b"
ans = float("INF")
for i in range(2**N):
    flags = list(format(i,digit))
    rikaid = [0]*(M)
    cost = 0
    for j in range(N):
        if flags[j] == "1":
            cost += books[j][0]
            for k in range(M):
                rikaid[k] += books[j][k+1]
    for r in rikaid:
        if r < X:
            break
    else:
        ans = min(ans,cost)
if ans == float("INF"):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 74160
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    var rCount = 0L
    var gCount = 0L
    var bCount = 0L

    s.forEach {
        when (it) {
            'R' -> rCount++
            'G' -> gCount++
            'B' -> bCount++
        }
    }

    var patternCount = rCount * gCount * bCount

    for (i in 0 until (n - 2)) {
        for (j in ((i + 1) until (n - 1))) {
            val k = (2 * j) - i
            if (k >= n) continue

            if (s[i] == s[j]) continue
            if (s[i] == s[k]) continue
            if (s[j] == s[k]) continue
            patternCount--
        }
    }

    println(patternCount)
}


Measured memory_bytes: 36080
import java.util.*;
import java.io.BufferedInputStream;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner (new BufferedInputStream(System.in));
    String s = sc.next();
    if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 23252
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep2(i,a,b)for(int i=a;i<b;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define ll long long

int n,k;
int x[111111],y[111111];

int rui[4001][4001];

int q(int x1,int y1,int x2,int y2){//半開区間での中のruiを返す
	
	if(x1>x2||y1>y2)return 0;
	int ret=0;
	ret=rui[y2][x2]-rui[y2][x1-1]-rui[y1-1][x2]+rui[y1-1][x1-1];

	return ret;
}

int main(){
	cin>>n>>k;
	rep(i,n){
	char c;
	cin>>x[i]>>y[i]>>c;
		if(c=='B')y[i]+=k;
		x[i]%=2*k;
		y[i]%=2*k;
		x[i]++;y[i]++;
	}



	rep(i,n){
		int ny=y[i],nx=x[i];
		rui[ny][nx]++;
	}


rep2(i,1,2*k+1){
		rep2(j,2,2*k+1)rui[i][j]+=rui[i][j-1];
	}
	
	rep2(i,1,2*k+1){
		rep2(j,2,2*k+1)rui[j][i]+=rui[j-1][i];
	}
	


	int ans=0;
	rep2(i,1,k+1){
		rep2(j,1,k+1){
			int tmp=q(i,j,i+k-1,j+k-1)+q(1,1,i-1,j-1)+q(i+k,1,2*k,j-1)+q(1,j+k,i-1,2*k)+q(i+k,j+k,2*k,2*k);
			ans=max(ans,max(n-tmp,tmp));
		}
	}
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 33280
#include<bits/stdc++.h>
    using namespace std;
    #define pb push_back
    #define N 100000
    int n,k;
    long long a[N];
    int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    } 
    vector<long long> dp(n,INT_MAX);
    dp[0] = 0;
    for(int i=1;i<n;i++){
        int j= i-1;
        while(j>=0 && i-j<=k){
            dp[i] = min(dp[i],abs(a[i]-a[j])+dp[j]);
            j--;
        }
    }
    cout<<dp[n-1];

    }

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

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    int prev;
    cin >> prev;
    ll ans = 1000, cnt = 0;
    bool is_increasing = false;
    for(int i = 1; i < N; ++i){
        int A;
        cin >> A;
        if(prev == A)   continue;
        if(is_increasing){
            if(prev > A){
                ans += cnt * prev;
                cnt = 0;
                is_increasing = false;
            }
            prev = A;
        }
        else{
            if(prev < A){
                cnt = ans / prev;
                ans -= cnt * prev;
                is_increasing = true;
            }
            prev = A;
        }
    }
    if(is_increasing)   ans += cnt * prev;
    cout << ans << endl;
}

Measured memory_bytes: 3620
n, m = map(int, input().split())
inf = 10**10
G = [{} for i in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    G[l-1][r-1] = d
    G[r-1][l-1] = -d
V = [False for i in range(n)]
D = [inf for i in range(n)]
for i in range(n):
    if V[i]:
        continue
    #hii 
    Q = [i]
    D[i] = 0
    while Q:
        j = Q.pop()
        V[j] = True
        for k in G[j].keys():
            if not V[k]:
                Q.append(k)
            if D[k] == inf:
                D[k] = D[j]+G[j][k]
            elif D[k] != D[j]+G[j][k]:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 67576
s = input()
A, B, C, D = s[0], s[1], s[2], s[3]
op = ["+++", "+-+", "++-", "+--", "-++", "--+", "-+-", "---"]


for i in range(8):
    op1 = op[i][0]
    op2 = op[i][1]
    op3 = op[i][2]
    e = A + op1 + B + op2 + C + op3 + D
    if eval(e) == 7:
        ans = e + "=7"
        break


print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;



int main() {
	int N; cin >> N;
	vector<int>ls(2*N);
	for (int i = 0; i < 2*N; ++i) {
		cin >> ls[i];
	}
	sort(ls.begin(), ls.end());
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		ans += ls[2*i];
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    long int f[10010]={0};
    int i,j,k;
    long int v;

    for(i=1; i<110; i++){
        for(j=1; j<=i; j++){
            for(k=1; k<=j; k++){
                v=i*i+j*j+k*k+i*j+j*k+k*i;
                if(v>n) break;
                if(i==j && j==k) f[v]+=1;
                else if(i==j || j==k) f[v]+=3;
                else if(i!=j && i!=k && j!=k) f[v]+=6;
            }
        }
    }
    
    for(i=1; i<=n; i++){
        cout << f[i] << endl;
    }
}

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		int a = A+B;
		int b = A-B;
		int c = A*B;
		if(a >=b && a >= c) {
			System.out.println(a);
		}else if(b>=c) {
			System.out.println(b);
		}else {
			System.out.println(c);
		}
	}

}

Measured memory_bytes: 21844
fun main() {
    val (s, t) = readLine()!!.split(" ")
    var (a, b) = readLine()!!.split(" ").map { it.toInt() }
    val u = readLine()!!
    if (s == u) {
        a--
    } else {
        b--
    }
    println("$a $b")
}

Measured memory_bytes: 36220
#include<stdio.h>

int main(void)
{
int a,b,c;
int t,result;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
if(a>=b&&a>=c)
{
}
else if(b>=a&&b>=c)
{t=b;
b=a;
a=t;}
else if(c>=b&&c>=a)
{t=c;
c=a;
a=t;}
if((a-b)%2==0&&(a-c)%2==0)
{result=(2*a-b-c)/2;
}
else if((a-b)%2==1&&(a-c)%2==1)
{b+=1;
c+=1;
result=1+(2*a-b-c)/2;
}
else if((a-b)%2==1&&(a-c)%2==0)
{a+=1;
c+=1;
result=1+(2*a-b-c)/2;
}
else if((a-b)%2==0&&(a-c)%2==1)
{a+=1;
b+=1;
result=1+(2*a-b-c)/2;
}
printf("%d",result);
return 0;}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
        int n,a,b,c;
        scanf("%d",&n);
        a=n/100;
        b=(n/10)%10;
        c=n%10;
        if((b<a)||((b==a)&&(c<=a))) printf("%d%d%d\n",a,a,a);
        else printf("%d%d%d\n",a+1,a+1,a+1);
        return 0;
}


Measured memory_bytes: 128
N = int(input())
P = [int(_) - 1 for _ in input().split()]
Q = sorted([(P[i], i) for i in range(N)])

A = [1]
B = [10**9]

for i in range(1, N):
    d = Q[i][1] - Q[i - 1][1]
    if d > 0:
        A += [A[-1] + d + 1]
        B += [B[-1] - 1]
    else:
        A += [A[-1] + 1]
        B += [B[-1] + d - 1]
print(*A, sep=" ")
print(*B, sep=" ")


Measured memory_bytes: 8376
import re

n = int(input())
p = [int(i) for i in re.split(" ", input())]
count = 0
for i in range(n - 2):
    if p[i + 1] > p[i] and p[i + 1] > p[i + 2]:
        pass
    elif p[i + 1] < p[i] and p[i + 1] < p[i + 2]:
        pass
    else:
        count += 1

print(count)

Measured memory_bytes: 3188
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define slow ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define set_bits(x) __builtin_popcount(x)
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007

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

#define int long long

int32_t main(){
    string n;
    cin >> n;
    int num = 0;
    for( auto it : n ){
        num = num * 10 + (it-'0');
        num %= 9;
    }
    if( num == 0 )cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N, A, B;
    cin >> N >> A >> B;

    ll sum = 0;
    repd(i, 1, N + 1) {
        ll ct = 0;
        ll tmp = i;
        while (tmp) {
            ct += tmp % 10;
            tmp /= 10;
        }
        if ((ct >= A) && (ct <= B)) sum += i;
    }

    cout << sum << endl;
    return 0;
}

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

int main() {
  int n;
  string ans = "";
  cin >> n;
  vector<vector<int>>data(n,vector<int>(26,0));
  for(int i = 0;i < n;i++){
    string s;
    cin >> s;
    for(int j = 0;j < s.size();j++){
      int k;
      k = s.at(j)-'a';
      data[i][k]++;
    }
  }
  for(int i = 0;i < 26;i++){
    int min;
    min = data[0][i];
    if(n != 1){
      for(int j = 1;j < n;j++){
        if(data[j][i] <= min){
          min = data[j][i];
        }
      }
    }
    for(int j = 0;j < min;j++){
      ans += 'a'+i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sonic ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define fi first
#define se second
#define pb push_back
using namespace std;

const ll INF=1e18;
const int N=1e5+17;
int ans,cal,sum,cnt;

int main(){
	sonic
	string a,b;
	cin>>a>>b;
	for(int i=0;i<a.size();i++)if(a[i]!=b[i])cnt++;
	cout<<cnt;
}


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

int main() {
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  long double pi = 3.141592653589793238;
  long double arg = (h / 6.0 - 11.0* m / 360.00) * pi;
  long double x = cos(arg);
  cout << setprecision(10) << sqrtl(a * a + b * b - 2 * a * b * x) << endl;
}

Measured memory_bytes: 4100
N = int(input())
sqrt_N = int(N ** 0.5)

dividers_for_N = set()
ans_set = set()

for i in range(1, sqrt_N + 1):
    if (N - 1) % i == 0:
        ans_set.add(i)
        ans_set.add((N - 1) // i)

    if N % i == 0:
        dividers_for_N.add(i)
        dividers_for_N.add(N // i)

dividers_for_N -= {1}
ans_set -= {1}

for i in dividers_for_N:
    num = N
    while num % i == 0:
        num //= i
    if num % i == 1:
        ans_set.add(i)

ans = len(ans_set)

print(ans)

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)


// Write From This Line
int main()
{
	ll n;
	cin >> n;
	if(n%2){
		cout << 0 << endl;
		return 0;
	}
	ll ans = 0;
	n/=2;
	ll five = 5;
	while(n){
		ans += n / five;
		n /= 5;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << "[DBG] " << #X << "=" << (X) << '\n';
	#define SAY(X) cout << "[SAY] " << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)2e5 + 7;
int a[MAXN], n;
int cur[MAXN];

int check(int sigma) {
	memset(cur, 0, sizeof(cur));
	set<int> st;
	for(int i = 1; i < n; ++i) {
		int sz = a[i];
		while(!st.empty()) {
			auto iter = prev(st.end());
			int pos = *iter;
			if(pos >= sz) {
				cur[pos] = 0;
				st.erase(iter);
			} else {
				break;
			}
		}
		if(sz > a[i - 1]) continue;
		int j = min(sz, a[i - 1]) - 1;
		while(j >= 0 && cur[j] == sigma - 1) {
			cur[j] = 0;
			--j;
		}
		if(j < 0) {
			return 0;
		} else {
			++cur[j];
			st.insert(j);
		}

		/*cout << "@cur=";
		for(int i = 0; i < n; ++i) cout << ' ' << cur[i];
		cout << '\n';*/
	}
	return 1;
}

void solve() {
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		if(a[i] > MAXN - 1) a[i] = MAXN - 1;
	}
	if(n == 1) {
		cout << "1\n";
		return;
	}
	/*int r = check(2);
	DBG(r);
	return;*/
	int low = 1, high = n + 17;
	if(check(low)) {
		cout << low << '\n';
	} else {
		while(high - low > 1) {
			int mid = (low+high)/2;
			if(check(mid)) {
				high = mid;
			} else {
				low = mid;
			}
		}
		cout << high << '\n';
	}
}

int main() {
	fast_io();
	solve();

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int toint(string a){
  return atoi(a.c_str());
}
string tostr(int a){
  string ret = "";
  REP(_,4){
    ret = (char)(a%10+'0') + ret;
    a /= 10;
  }
  return ret;
}

int main(){
  while(true){
    string n;
    cin>>n;
    if(n == "0000")break;
    if(n[0]==n[1] && n[1]==n[2] && n[2]==n[3]){
      cout<<"NA"<<endl;
      continue;
    }
    int step = 0;
    while(n != "6174"){
      string l,s;
      sort(ALL(n));
      s = n;
      reverse(ALL(n));
      l = n;
      n = tostr(toint(l)-toint(s));
      ++step;
    }
    cout<<step<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
struct UnionFind{
    vector<int> d;
    UnionFind(int n): d(n,-1){}
    int root(int x){
        if(d[x] <0)return x;
        return d[x] = root(d[x]);
    }
    int unite(int x,int y){
        x = root(x),y = root(y);
        if(x == y) return false;
        if(d[x] < d[y])swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    int size(int n){
        return -d[root(n)];
    }

};
int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> p(n);
    rep(i,n)cin >> p[i];
    UnionFind uf(n);
    rep(i,m){
        //xとyを結ぶ
        int x,y;
        cin >> x >> y;
        x--;y--;
        uf.unite(x,y);

    }
    int ans = 0;
    rep(i,n){
        
        if(uf.root(i) == uf.root(p[i]-1))ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	char a[1010];
	int i,flag=0;
	scanf("%s",a);
	//printf("%d\n",strlen(a));
	for(i=0;i<strlen(a);i++){
		//printf("%c aaa%c]\n",a[i],a[strlen(a)-i-1]);
		if(a[i]!=a[strlen(a)-i-1]){
			flag=1;
			break;
		}
		else;
	}
	
	if(flag==1)printf("No");
	else printf("Yes");
	return 0;
}


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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long ll;

int L[MAX/2+2], R[MAX/2+2];

ll merge(int A[], int n, int left, int mid, int right){
  int i, j, k;
  ll cnt = 0;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ){

    if ( L[i] <= R[j] ){
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
      cnt += mid + j - k -1;
    }
  }
  return cnt;
}

ll mergeSort(int A[], int n, int left, int right ){
  int mid;
  ll v1, v2, v3;
  if ( left+1 < right ){
    mid = (left + right)/2;
    v1 = mergeSort(A, n, left, mid);
    v2 = mergeSort(A, n, mid, right);
    v3 = merge(A, n, left, mid, right);
    return v1 + v2 + v3;
  } else return 0;
}

int main(){
  int A[MAX], n, i;

  cin >> n;
  for ( i = 0; i < n; i++ ) {
    cin >> A[i];
  }

  ll ans = mergeSort(A, n, 0, n);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 4644
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let q: usize = read();
    let string: Vec<char> = read::<String>().chars().collect();

    //累積和 前処理 Aの隣にCがある要素をカウントする
    let mut s = vec![0; n + 1];
    for i in 0..n {
        if i + 1 < n {
            if string[i] == 'A' && string[i + 1] == 'C' {
                s[i + 1] = s[i] + 1;
            } else {
                s[i + 1] = s[i];
            }
        } else {
            s[i + 1] = s[i];
        }
    }

    for _ in 0..q {
        let l = read::<usize>() - 1;
        let r = read::<usize>() - 1;
        println!("{}", s[r] - s[l]);
    }
}


Measured memory_bytes: 4860
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v: Vec<i64> = read_vec();
    let n = v[0] as usize;
    let k = v[1];
    let a = (0..n).map(|_| read::<i64>() - k).collect::<Vec<_>>();
    let mut sums = vec![-k; n + 1];
    for i in 1..n + 1 {
        sums[i] = sums[i - 1] + a[i - 1];
    }

    let indexes = argsort(&sums);
    let mut c = vec![0; n + 1];
    for i in 0..n + 1 {
        c[indexes[i]] = n + 1 - i;
    }

    let mut bt = BinaryIndexTree::new(indexes.len());
    let mut ans = 0;
    for i in 0..indexes.len() {
        ans += i - bt.sum(c[i]) as usize;
        bt.add(c[i], 1);
    }
    println!("{:?}", ans);
}

fn argsort<T: std::cmp::Ord + std::marker::Copy>(v: &Vec<T>) -> Vec<usize> {
    let mut sort_v = Vec::new();
    for i in 0..v.len() {
        sort_v.push((v[i], i));
    }
    sort_v.sort();
    sort_v.iter().map(|x| x.1).collect::<Vec<usize>>()
}

struct BinaryIndexTree {
    bit: Vec<i64>,
    n: usize,
}

impl BinaryIndexTree {
    fn new(n: usize) -> BinaryIndexTree {
        BinaryIndexTree {
            bit: vec![0; n + 1],
            n: n,
        }
    }

    fn sum(&self, i: usize) -> i64 {
        let mut i = i;
        let mut s = 0i64;
        while i > 0 {
            s += self.bit[i];
            i -= (i as i64 & -(i as i64)) as usize;
        }
        s
    }

    fn add(&mut self, i: usize, x: i64) {
        let mut i = i;
        while i <= self.n {
            self.bit[i as usize] += x;
            i += (i as i64 & -(i as i64)) as usize;
        }
    }
}


Measured memory_bytes: 15472
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef vector< vector<ll> > table;
int main()
{
    int n,W;
    cin>>n>>W;
    table dp(n+1,vector< ll >(W+1));
    vector<ll> w(n+1,0),v(n+1,0);
    for (int i = 1; i < n+1; i++) cin>>w[i]>>v[i];
    
    rep(i,W+1) dp[0][i]=0;
    for (int i = 1; i < n+1; i++)
    {
        for (int j = 0; j <=W; j++)
        {
            if(w[i]<=j) dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][W];

    return 0;
}

Measured memory_bytes: 80256
sx,sy,tx,ty = map(int,input().split())
x=tx-sx
y=ty-sy
ans = "R"*x + "U"*y + "L"*x + "D"*y\
        +"D" + "R"*(x+1) + "U"*(y+1) + "L"\
        +"U" + "L"*(x+1) + "D"*(y+1) + "R"
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int H, W;
int field[100][100];
int dp[100][100];

string s;

int main(){
	cin >> H >> W;
	REP(i, H){
		cin >> s;
		REP(j, W){
			field[i][j] = s[j] - '0';
		}
	}
	dp[0][0] = field[0][0];
	REP(i, H){
		REP(j, W){
			if (i + j == 0){
				continue;
			}
			if (i == 0)dp[i][j] = dp[i][j - 1] + field[i][j];
			else if (j == 0)dp[i][j] = dp[i - 1][j] + field[i][j];
			else dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + field[i][j];
		}
	}
	cout << dp[H - 1][W - 1] << endl;
}

Measured memory_bytes: 1248
import java.util.*;

public class Main{
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = new char[s.length()];
        char d = c[0];
        int min = 100000;
        
        for (int i = 0; i < s.length(); i++) c[i] = s.charAt(i);
        int count = 0;
        for (int l = 0; l < s.length(); l++) {
            if (c[l] == c[0]) count++;
        }
        if (count == s.length()) {
            System.out.println(0);
        } else {
            for (int k = 0; k < s.length(); k++) {
                for (int i = 0; i < s.length(); i++) c[i] = s.charAt(i);
                for (int i = 0; i < s.length() - 1; i++) {
                    for (int j = 0; j < s.length() - i - 1; j++) {
                        if (c[j + 1] == c[k]) c[j] = c[k];
                    }
                    int a = 0;
                    for (int j = 0; j < s.length() - i - 1; j++) {
                        if (c[j] == c[k]) a++;
                    }
                    if (a == s.length() - 1 - i) {
                        if (i + 1 < min) {
                            min = i + 1;
                        }
                        break;
                    } else {
                        continue;
                    }
                }
            }
            System.out.println(min);
        }
    }    
}


Measured memory_bytes: 22100
#include <stdio.h>

int main(){
    int m, f, r;
    
    while(scanf("%d %d %d", &m, &f, &r), m > -1 || f > -1 || r > -1){
        if(m < 0 || f < 0){
            putchar('F');
        }
        
        else if(m + f >= 80){
            putchar('A');
        }
        
        else if(m + f >= 65){
            putchar('B');
        }
        
        else if(m + f >= 50){
            putchar('C');
        }
        
        else if(m + f >= 30){
            
            if(r >= 50){
                putchar('C');
            }
            
            else {
                putchar('D');
            }
        }
        
        else {
            putchar('F');
        }
        
        putchar('\n');
    }
    
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
const int inf = 1e9;
typedef pair<int,int> pii;

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> adj(n);
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    vector<bool> used(n, false);
    used[0] = true;
    queue<int> wait;
    wait.push(0);
    vector<int> ans(n);
    while(!wait.empty()){
        int p = wait.front();
        wait.pop();
        for(int next: adj[p]){
            if(!used[next]){
                used[next] = true;
                ans[next] = p;
                wait.push(next);
            }
        }
    }
    cout << "Yes" << endl;
    for(int i=1; i<n; i++){
        cout << ans[i]+1 << endl;
    }
    return 0;
}

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

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

int main(){
	int a, b;
	while (cin >> a >> b)
	{
		cout << gcd(a, b) << endl;
	}

	return 0;
}

Measured memory_bytes: 2956
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <utility>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstring>
using namespace std;
using ll = long long;

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

int main(){
  int n, X; cin >> n >> X;
  int x[n];

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

  ll g = abs(X - x[0]);

  for(int i=1; i<n; i++){
    g = gcd(g, abs(X - x[i]));
  }

  cout << g << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll r,d,x;
  cin >> r >> d >> x;
  rep(i,10){
    x=r*x-d;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
def main():
    D, G, *pc = map(int, open(0).read().split())
    p = pc[::2]
    c = pc[1::2]
    # コンプリート
    comp = [c[i] + 100 * (i + 1) * p[i] for i in range(D)]

    def dfs(G, i):
        # G 総合スコア
        # i 問題 1-based indexing
        if i <= 0:
            # 目標の 総合スコア に到達しなかった
            return 1e9 + 7
        score = 0
        num = min(G // (100 * i), p[i - 1])
        if num == p[i - 1]:
            # コンプリートする
            score = comp[i - 1]
        else:
            # コンプリートしない
            score = 100 * i * num
        if score < G:
            # 目標の 総合スコア に到達しない時 さらに問題を解く
            num += dfs(G - score, i - 1)
        # 問題を解いた、解かなかったの最小
        return min(num, dfs(G, i - 1))
    print(dfs(G, D))


main()


Measured memory_bytes: 3188
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define si set<int>
#define msi map<string, int>
#define rsz(a) resize(a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;
int digits(int n) {
  n = abs(n);
  if(n < 10) return 1;
  elif(n < 100) return 2;
  elif(n < 1000) return 3;
  elif(n < 10000) return 4;
  elif(n < 100000) return 5;
  elif(n < 1000000) return 6;
  elif(n < 10000000) return 7;
  elif(n < 100000000) return 8;
  elif(n < 1000000000) return 9;
  else return 10;
}


int main() {
  io();
  
  int n, r;
  cin >> n >> r;
  
  if (n >= 10) cout << r;
  else {
    int k = (10 - n) * 100;
    cout << r + k;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int n,a,b,c;
vector<int> l;
int ans = 1<<30;

int cal(vector<int> g){
  int aa = 0, bb = 0, cc = 0, p = 0;
  for(int i = 0; i < n; i++){
    if(g[i] == 0) aa += l[i];
    else if(g[i] == 1) bb += l[i];
    else if(g[i] == 2) cc += l[i];
    if(g[i] != 3) p += 10;
  }
  if(aa == 0 || bb == 0 || cc == 0) return 1<<30;
  p += abs(a - aa);
  p += abs(b - bb);
  p += abs(c - cc);
  p -= 30;
  return p;
}

void dfs(vector<int> g){
  if(g.size() == n){
    int now = cal(g);
    ans = min(ans,now);
    return;
  }
  for(int i = 0; i < 4; i++){
    g.push_back(i);
    dfs(g);
    g.pop_back();
  }
}


int main(){
  cin >> n >> a >> b >> c;
  l.resize(n);

  for(int i = 0; i < n; i++) cin >> l[i];

  vector<int> g;
  dfs(g);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#知っている情報の中での最高得点者と最低得点者を考える。
#最高得点者がM番目であるなら、上には高々M-1人しかいない。
#最低得点者がL点であるなら、下には高々L人しかいない。
#よって、回答は、
#(M-1)+{(最低得点者の席次)-M+1}+(L-1)=(最低得点者の席次) + L
#最低得点者の情報だけ分かればよい。
n = gets.to_i
b_min = (10 ** 9) + 1
i = 0
x = (10 ** 9) + 1 
while i < n
  a,b = gets.chomp.split(' ').map(&:to_i)
  if b < b_min
    b_min = b
    x = a
  end
  i += 1
end
puts x + b_min



Measured memory_bytes: 14420