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

const int maxn = 1e5 + 3;
int n, a[maxn];

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
		scanf("%d", a + i);
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		if(a[i] == i + 1) {
			if(i + 1 < n)
				std::swap(a[i], a[i + 1]);
			else
				std::swap(a[i], a[i - 1]);
			++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 640
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


#define forn(t, i, n) for (t i = 0; i < (n); ++i)


#define all(c) c.begin(), c.end()


using namespace std;

// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


template<class T>
inline T mx(T arg) {
    return arg;
}

template<class T, class... Ts>
inline typename common_type<T, Ts...>::type mx(T arg, Ts... args) {
    auto arg1 = mx(args...);
    return arg > arg1 ? arg : arg1;
}


// Section with adoption of array and vector algorithms.


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vector(istream& in, size_t n) {
    vector<T> ret(n);
    for (size_t i = 0; i < n; ++i) {
        ret[i] = next<T>(in);
    }
    return ret;
}


void solve(istream& in, ostream& out) {
    int n = next<int>(in);
    int64_t k = next<int64_t>(in);
    auto a = next_vector<int64_t>(in, n);
    auto b = next_vector<int64_t>(in, n);
    sort(all(a));
    sort(all(b));
    reverse(all(b));
    int64_t l = -1, r = 1000000000000LL;
    while (l + 1 < r) {
        int64_t mid = (l + r) / 2;
        int64_t sum = 0;
        forn (int, i, n) {
            sum += mx(0, a[i] - mid / b[i]);
        }
        if (sum <= k) {
            r = mid;
        } else {
            l = mid;
        }
    }
    out << r << "\n";
}


int main() {
  solve(cin, cout);
  return 0;
}



Measured memory_bytes: 3456
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define all(x) x.begin(),x.end()
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
lli a[100005];
int main()
{
	int n;
	cin>>n;
	lli sum=0;
	lli currnode=1;
	lli ans=0;
	for(int i=0;i<=n;i++)
	{cin>>a[i];sum+=a[i];}
	for(int i=0;i<=n;i++)
	{
		//cout<<currnode<<"\n";
		ans+=currnode;
		currnode-=a[i];
		sum-=a[i];
		if(currnode>sum || (currnode<=0 && i!=n) || (i==n && currnode!=0))
		{cout<<-1;return 0;}
		currnode=min(currnode*2,sum);
	}
	cout<<ans;
}



Measured memory_bytes: 4416
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e9;
using namespace std;

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

struct Node{
	int dis;
	bool used;
	Node() : dis(INF), used(false) { }
	Node(int d, bool f) : dis(d), used(f) { }
};

typedef vector<vector<Edge>> graph;

int dijkstra(graph g, int s, int n){
	vector<Node> node(n);
	priority_queue<int, vector<pair<int, int>>, greater<pair<int, int>>> q;

	q.push(make_pair(0, s));
	node[s] = Node{0, true};

	while(not q.empty()){
		int dis, pos;
		tie(dis, pos) = q.top(); q.pop();
		node[pos].used = true;

		for(auto e : g[pos]){
			if(node[e.to].used == true) continue;
			if(node[e.to].dis > dis + e.cost){
				node[e.to].dis = dis + e.cost;
				q.emplace(node[e.to].dis, e.to);
			}
		}
	}
	rep(i,n){
		cout << i << ' ' << node[i].dis << endl;;
	}
	return node[0].dis;
}

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

	vector<vector<Edge>> a(n);
	rep(i,n){
		int from;
		int m;
		cin >> from >> m;
		rep(j,m){
			int to, cost;
			cin >> to >> cost;
			a[from].emplace_back(to, cost);
		}
	}
	dijkstra(a, 0, n);
}



Measured memory_bytes: 11704
#include <stdio.h>
#include <string.h>
int main(){
	char s[1000];
	int n,k;

	scanf("%d",&n);
	scanf("%d",&k);

	scanf("%s",s);
	
	for(int i=0;i<n;i++){
		if(i == k-1){
			if(s[i] == 'A'){
				s[i] = 'a';
			}else if(s[i] == 'B'){
				s[i] = 'b';
			}else if(s[i] == 'C'){
				s[i] = 'c';
			}
 		}
	}	
	printf("%s\n",s);
}

Measured memory_bytes: 128
N = int(raw_input())
A = map(int, raw_input().split())
print ' '.join(map(str, A))
for i in xrange(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j-=1
    A[j+1] = v
    print ' '.join(map(str, A))

Measured memory_bytes: 4220
import numpy as np

N = int(input())
a = [input() for _ in range(N)]

a = np.sort(np.array(a))

unique_elements, index_elements = np.unique(a, return_index = True)
l = []
for i in range(index_elements.size -1):
  m = index_elements[i + 1] - index_elements[i]
  l.append(m)
l.append(a.size - index_elements[-1])    
elements = unique_elements[l == max(l)]


for i in elements:
	print(i)


Measured memory_bytes: 49976
#!/usr/bin/env python3

N = int(input().split()[0])
lr_table = []

for _ in range(N):
    l, r = list(map(int, input().split()))
    lr_table.append((l, r))

# 都度都度判定すると効率が悪いので、
# 1 - 10 ** 5まで全部判定する


def get_prime_number_flag_list(n):
    # エラストネスのふるいを使用
    # 指定されたn以下の数について、素数か素数でないかのリストを返す
    pn_flag_list = [True] * (n + 1)
    pn_flag_list[0] = False
    pn_flag_list[1] = False
    for i in range(2, n + 1):
        if pn_flag_list[i]:
            for j in range(i + i, n + 1, i):
                # 素数ではない
                pn_flag_list[j] = False
    return pn_flag_list


pn_flag_list = get_prime_number_flag_list(10 ** 5)

cumsum_list = []
for i in range(10 ** 5 + 1):
    if i in [0, 1]:
        cumsum_list.append(0)
        continue
    if pn_flag_list[i] and pn_flag_list[(i + 1) // 2]:
        cumsum_list.append(cumsum_list[i - 1] + 1)
    else:
        cumsum_list.append(cumsum_list[i - 1])

count_list = []
for lr_set in lr_table:
    l, r = lr_set
    # l_idx, r_idx = l - 1, r - 1
    count_list.append(cumsum_list[r] - cumsum_list[l - 1])

ans = "\n".join([str(c) for c in count_list])
print(ans)



Measured memory_bytes: 27372
#include"bits/stdc++.h"
using namespace std;

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/
	
	ll k;
	 cin>>k;
	 ll a,b;
	  cin>>a>>b;

	  ll tempa = a/k;
	  ll tempb= b/k;

	  if(a%k==0 or b%k==0)
	  	cout<<"OK\n";
	  else if(tempa==tempb)
	  	cout<<"NG\n";
	  else
	  	cout<<"OK\n";

	
	return 0;
}

Measured memory_bytes: 3692
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        if(a<=b && b<=c){
            System.out.printf("%d %d %d\n",a,b,c);
        }else if(a<=c && c<=b){
            System.out.printf("%d %d %d\n",a,c,b);
        }else if(b<=a && a<=c){
            System.out.printf("%d %d %d\n",b,a,c);
        }else if(b<=c && c<=a){
            System.out.printf("%d %d %d\n",b,c,a);
        }else if(c<=a && a<=b){
            System.out.printf("%d %d %d\n",c,a,b);
        }else if(c<=b && b<=a){
            System.out.printf("%d %d %d\n",c,b,a);
        }else{
            System.out.printf("%d %d %d\n",a,b,c);
        }
    }
}



Measured memory_bytes: 26336
import math
mod=1000000007
n=int(input())
iwashi_group={}
count=0

#傾きを第1象限(True)と第4象限(False)の座標で管理する
for i in range(n):
    a,b=map(int,input().split())
    
    if a*b>0:
        GCD=math.gcd(abs(a),abs(b))
        iwashi=(abs(a)//GCD,abs(b)//GCD)
        flag=True
    
    elif a*b<0:
        GCD=math.gcd(abs(a),abs(b))
        iwashi=(abs(b)//GCD,abs(a)//GCD)
        flag=False

    elif a==0 and b==0:
        count+=1
        continue

    elif a==0:
        iwashi=(0,1)
        flag=True
    
    elif b==0:
        iwashi=(0,1)
        flag=False
  
    if iwashi in iwashi_group:
        if flag:
            iwashi_group[iwashi][0]+=1
        else:
            iwashi_group[iwashi][1]+=1
    else:
        if flag:
            iwashi_group[iwashi]=[1,0]
        else:
            iwashi_group[iwashi]=[0,1]

ans=1
for a,b in iwashi_group.values():
    ans=ans*(2**a+2**b-1)%mod

print((ans+count-1)%mod)

Measured memory_bytes: 134588
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    for(int i=0;str[i];i++)
    {
      str[i] =   (i == 3) ? '8':str[i];
      cout<<str[i];
    }
     return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}


const int N_MAX = 100000;
const int M_MAX = 200000;
int N, M;
int L[M_MAX];
int R[M_MAX];
int D[M_MAX];
int x[N_MAX];
vector<pii> edge[M_MAX];

int main(void)
{
    cin >> N >> M;
    REP(i, M) {
        cin >> L[i] >> R[i] >> D[i];
        L[i]--;
        R[i]--;
        edge[L[i]].push_back(pii(R[i], D[i]));
        edge[R[i]].push_back(pii(L[i], -D[i]));
    }
    REP(i, N) x[i] = N_MAX; // undefined
    queue<int> q;
    REP(i, N) {
        if (x[i] == N_MAX) {
            x[i] = 0;
            //printf("x[%d] = %d\n", i, x[i]);
            q.push(i);
            //printf("push %d\n", i);
            while(!q.empty()) {
                int u = q.front();
                q.pop();
                for (auto e: edge[u]) {
                    int v = e.first;
                    int d = e.second;
                    if (x[v] == N_MAX) {
                        x[v] = x[u] + d;
                        //printf("x[%d] = %d\n", v, x[v]);
                        q.push(v);
                        //printf("push %d from %d\n", v, u);
                    } else if (x[v] == x[u] + d) {
                        // OK
                    } else {
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    //REP(i, N) cout << x[i] << endl;
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 14080
import java.util.*;

class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String s = scan.next();
        char[] c = new char[n];
        for(int i = 0; i < n; i++) c[i] = s.charAt(i);
        int out1 = 0;
        int cw = 0;
        for(int i = 0; i < n; i++) if(c[i] == 'W') cw++;
        out1 = Math.min(cw, n - cw);
        int out2 = 0;
        int w = 1;
        for(int i = 1; i < n; i++){
            if(c[i - 1] == 'W' && c[i] == 'W') w++;
            else{
                if(c[i - 1] != 'W') continue;
                int r = 0;
                for(int j = n - 1; j >= i; j--){
                    if(c[j] == 'R'){
                        r++;
                        c[j] ='W';
                        c[i - 1] = 'R';
                        if(r >= w) break;
                    }
                }
                out2 += r;
                w = 1;
            }
        }
        System.out.println(Math.min(out1, out2));
        scan.close();
    }
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 31772
#include <algorithm>
#include <iostream>

bool is_symmetric(int num)
{
    int a = (num % 100000) / 10000;
    int b = (num % 10000) / 1000;
    int d = (num % 100) / 10;
    int e = (num % 10);
    return (a == e) && (b == d);
}

int main(void)
{
    int a, b;
    std::cin >> a >> b;
    int count = 0;
    for (int i = a; i <= b; ++i)
    {
        if (is_symmetric(i))
        {
            ++count;
        }
    }
    std::cout << count << std::endl;
}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))

dic = defaultdict(int)
for a in A:
    n = a//400
    if n > 7:
        dic[8] += 1
    else: dic[n] += 1

m = len(dic.keys())
if dic[8] > 0:
    m -= 1
    mi = max(1,m)
    ma = m+dic[8]
else:
    mi = ma = m
print(mi,ma)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define rb(x) ((x)&(-(x)))
using namespace std;
typedef long long ll;

struct NOD {
	NOD() : l(NULL), r(NULL) {}
	NOD *l, *r;

	void make(char *S) {
		if('0' == S[0]) {
			if(NULL == l) l = new NOD();
			if(S[1]) l -> make(S+1);
		} else {
			if(NULL == r) r = new NOD();
			if(S[1]) r -> make(S+1);
		}
	}

	void get(vector<ll> &V, ll L) {
		if((NULL == l) != (NULL == r)) V.eb(L);
		if(NULL != l) l -> get(V, L-1);
		if(NULL != r) r -> get(V, L-1);
	}
} *rt;

ll L;
int N;

int main() {
	rt = new NOD();

	scanf("%d%lld", &N, &L);
	for(char str[100055]; N--;) {
		scanf(" %s", str);
		rt -> make(str);
	}

	vector<ll> V;
	rt -> get(V, L);

	ll ret = 0;
	for(ll v : V) {
		v = rb(v);
		ret ^= v;
	}

	puts(ret ? "Alice" : "Bob");
	return 0;
}

Measured memory_bytes: 8692
import sys
input=sys.stdin.readline

def main():
    N = int(input())
    a1,b1,c1 = 0,0,0
    for _ in range(N):
        a,b,c = map(int, input().split())
        a0,b0,c0 = a1,b1,c1
        a1 = max(b0, c0) + a # b or c => a
        b1 = max(a0, c0) + b # a or c => b
        c1 = max(a0, b0) + c # a or b => c

    print(max(a1,b1,c1))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MMS(x, y) memset((x), (y), sizeof(x))
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define EPS 1e-9
#define EPSS 1e-10
 
#define MAXN 3010
#define SEGN 300030
using namespace std;
 
 
bitset<MAXN> water, suger;
int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    water[0] = suger[0] = 1;
    for (int i = 100 * A; i < MAXN; i++)
        water[i] = water[i] | water[i - 100 * A];
    for (int i = 100 * B; i < MAXN; i++)
        water[i] = water[i] | water[i - 100 * B];
    for (int i = C; i < MAXN; i++) {
        suger[i] = suger[i] | suger[i - C];
    }
    for (int i = D; i < MAXN; i++) {
        suger[i] = suger[i] | suger[i - D];
    }
    long double ans = -INF, ca;
    int a1, a2;
    for (int i = 1; i <= F; i++) {
        for (int j = 0; j <= F; j++) {
            if ((i + j <= F) && water[i] && suger[j] && (j * 100 <= (E * i) )) {
                ca = (100.0 * j) / (double)(i + j);
                if (ca > ans) {
                    ans = ca;
                    a1 = i + j, a2 = j;
                }
            }
        }
    }
    cout << a1 << " " << a2 << "\n";
}

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

int main(void)
{
  int n, m, x;
  std::cin >> n >> m >> x;
  int left = 0;
  int right = 0;
  for (int i = 0; i < m; ++i)
  {
    int a;
    std::cin >> a;
    if (a < x) { ++left; }
    if (a > x) { ++right; }
  }
  std::cout << std::min(left, right);
}

Measured memory_bytes: 256
S = input()
P = 2019
N = len(S)
num = [0] * P
num[0] = 1
c = 0
ans = 0
dgt = 1
for i in range(N-1, -1, -1):
    c = (c + int(S[i]) * dgt) % P
    dgt *= 10
    dgt %= P
    ans += num[c]
    num[c] += 1

print(ans)

Measured memory_bytes: 9204
import java.util.Scanner;
import java.util.Stack;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        d = new int[n + 1];
        f = new int[n + 1];
        m = new int[n + 1][n + 1];
        color = new int[n + 1];
        for(int i = 1 ; i <= n ; i ++){
            int u = sc.nextInt();
            int k = sc.nextInt();
            for(int j = 1; j <= k ; j ++){
                int v = sc.nextInt();
                m[u][v] = 1;
            }
        }

        for(int i = 1; i <= n ; i ++){
            if(color[i] == 0){
                dfs2(i);
            }
        }

        for(int i = 1; i <= n ; i ++){
            System.out.println(i + " " + d[i] + " " + f[i]);
        }
    }
    static Stack<Integer> s = new Stack<>();
    static int[] d;
    static int[] f;
    static int[][] m;
    static int[] color;
    static int time = 0;
    static int n;

    static void dfs2(int u){
        d[u] = ++ time;
        color[u] = 1;
        for(int i = 1; i <= n ; i++){
            if(m[u][i] == 1 && color[i] == 0){
                dfs2(i);
            }
        }
        color[u] = 2;
        f[u] = ++ time;
    }
}


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

// 円周率：M_PI（STLのライブラリの中に含まれている）

int main()
{
    double r;
    cin >> r;
    printf("%.5f %.5f\n", r*r*M_PI, 2*r*M_PI);
}


Measured memory_bytes: 3200
h,w = map(int, input().split())
S = [list(input()) for i in range(h)]
for i in range(h):
  S[i] = ["."] + S[i] + ["."]
S.insert(0, ["."]*(w+2))
S.append(["."]*(w+2))

for i in range(1,h+1):
  for j in range(1,w+1):
    if S[i][j] == ".":
      pass
    else:
      if [S[i-1][j],S[i+1][j],S[i][j-1],S[i][j+1]] == ["."]*4:
        print("No")
#        print(i,j)
        exit()
      
print("Yes")

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)


typedef pair<li, li> PI;

PI edges[5050];
vector<li> graph[55];
li n, m;

inline void dfs(vector<bool>& visited, li now, li from) {
	if (visited[now]) {
		return;
	}
	visited[now] = true;
	for (auto& next : graph[now]) {
		if (next == from) {
			continue;
		}
		dfs(visited, next, now);
	}
}

inline bool check(li idx) {
	vector<bool> visited(n, false);
	dfs(visited, edges[idx].first, edges[idx].second);
	rep(i, n) {
		if (!visited[i]) {
			return true;
		}
	}
	return false;
}

int main(void)
{
	cin >> n >> m;
	rep(i, m) {
		li a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
		edges[i] = {a, b};
	}

	li res = 0;
	rep(i, m) {
		if (check(i))++res;
	}
	cout << res << endl;


	return 0;
}

Measured memory_bytes: 256
/*
 * FileName:     lexicographical_comparison
 * CreatedDate:  2020-05-24 15:45:16 +0900
 * LastModified: 2020-05-24 15:56:26 +0900
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
    int n;
    scanf("%d",&n);
    int *a = malloc(n*sizeof(int));
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
    }
    int m;
    scanf("%d",&m);
    int *b = malloc(m*sizeof(int));
    for(int i=0;i<m;i++){
        scanf("%d",b+i);
    }
    int tmp;
    if(n<m){tmp=n;}
    else{tmp=m;}
    for(int i=0;i<tmp;i++){
        if(a[i]<b[i]){
            printf("1\n");
            free(a);
            free(b);
            return 0;
        }
        else if(a[i]>b[i]){
            printf("0\n");
            free(a);
            free(b);
            return 0;
        }
    }
    if(tmp==m){
        printf("0\n");
    }
    else{
        printf("1\n");
    }
    free(a);
    free(b);
    return 0;
}



Measured memory_bytes: 2100
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
  int to,cost;
};

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){

}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> S;
	for (int i = 0; i < S.size(); ++i)
	{
		if(i == 3){
			cout << '8';
		}else{
			cout << S[i];
		}
	}
	cout << endl;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	// answer();

	return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())

S = [input() for _ in range(H)]
M = [[""]*W for _ in range(H)]

def bomb_cnt(i,j):
  min_h = max(0,i-1)
  max_h = min(i+2,H)
  min_w = max(0,j-1)
  max_w = min(j+2,W)
  cnt = 0
  for k in range(min_h,max_h):
    for g in range(min_w,max_w):
      if (S[k][g] == "#"):
        cnt += 1
        
  return str(cnt)

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      M[i][j] = "#"
    else:
      M[i][j] = bomb_cnt(i,j)
      
      
for i in range(H):
  print(*M[i],sep="")

Measured memory_bytes: 9276
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

template <class I>
void radix_sort(I first, I last) {
    using T = typename iterator_traits<I>::value_type;
    static_assert(is_integral<T>::value, "");
    constexpr int L = 8, M = 1 << L, K = (sizeof(T) * 8 + L - 1) / L;

    size_t n = last - first;
    T *p[2] = { &*first, (T *)malloc(n * sizeof(T)) };
    size_t m[M];

    for (int k = 0; k < K; k++) {
        fill_n(m, M, 0);
        for (size_t i = 0; i < n; i++) {
            m[p[0][i] >> (L * k) & M - 1]++;
        }
        for (int j = M - 1; j > 0; j--) {
            m[j] = m[j - 1];
        }
        m[0] = 0;
        for (int j = 2; j < M; j++) {
            m[j] += m[j - 1];
        }
        for (size_t i = 0; i < n; i++) {
            T t = p[0][i];
            p[1][m[t >> (L * k) & M - 1]++] = t;
        }
        swap(p[0], p[1]);
    }
    if (K % 2 == 1) {
        swap(p[0], p[1]);
        copy_n(p[1], n, p[0]);
    }
    if (is_signed<T>::value) {
        T *q = upper_bound(p[0], p[0] + n, 0, greater<>());
        rotate(p[0], q, p[0] + n);
    }
    free(p[1]);
}

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

    int n;
    cin >> n;

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

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

    int r = 0, b = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b) {
            r--;
            b = 0;
        } else {
            b = a[i];
        }
    }

    cout << r * 2 + n << endl;

    return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 998244353;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n,s; cin >> n >> s;
    vi a(n);
    rep(i,n) cin >> a[i];
    vvi dp(n+1, vi(s+1));
    dp[0][0] = 1;
    rep(i,n){
        rep(j,s+1){
            dp[i+1][j] = 2*dp[i][j] % mod;
            if(j - a[i] >= 0) dp[i+1][j] += dp[i][j-a[i]];
            dp[i+1][j] %= mod;
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

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

int main() {
    int i;
    string read;
    getline(cin, read);
    for(i=0;i<read.length();i++){
        char r = (char)read[i];
        if(isupper(read[i])){
            cout << (char)tolower(read[i]);
        }else if (islower(read[i]))
        {
            cout << (char)toupper(read[i]);
        }else{
            cout << read[i] ;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
bool f[105];
int main(){
	int x,n;
	cin>>x>>n;
	int p[n];
	fill(f,0);
	rep(i,n){
		cin>>p[i];
		f[p[i]]=1;
	} 
	rep(i,100){
		if(!f[x-i]){
			cout<<x-i;
			break;
		}
		else if(!f[x+i]){
			cout<<x+i;
			break;
		}
	}
	re 0;
}

Measured memory_bytes: 3640
s = list(input())
n = int(input())
for i in range(n):
    order = input().split()
    a, b = int(order[1]), int(order[2])+1
    if order[0] == "replace":
        # s = s.replace(s[a:b],order[3])
        s[a:b] = order[3]
    elif order[0] == "reverse":
        t = s[a:b]
        # s = s.replace(s[a:b],t[::-1])
        s[a:b] = t[::-1]
    else:
        t = "".join(s[a:b])
        print(t)

Measured memory_bytes: 7732
/*****Enigma_27*****/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<ll,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll i,j,k,l,t=1,ans=0,flag=0,n,b,r,w,d,a[55],dp[100][2];
ll f(int x,ll sum)
{
    if(x==n) return sum==k;
    if(dp[x][sum]!=-1) return dp[x][sum];
    return dp[x][sum]=(f(x+1,sum%2)+f(x+1,(sum+a[x])%2));
}
int main()
{   ios
    cin>>n>>k;
    for(i=0;i<=55;i++) for(j=0;j<2;j++) dp[i][j]=-1;
    for(i=0;i<n;i++) cin>>a[i];
    cout<<f(0,0)<<endl;
	return 0;
}


Measured memory_bytes: 256
program sample
	implicit none
    integer(16) :: A,B,C,K,i,D,E,F,count,count1
    
    read(*,*) A,B,C,K
    
    !countでA,B,Cをそれぞれ何回足すかがわかる。(count回足す)
    count = (K+1)/2
    count1 = K/2
    
    if (K==0) then
    	write(*,*) A-B
    else if(A==B) then
    	write(*,*) 0
    else if (count == count1) then
		write(*,*) A-B
    else
    	write(*,*) B-A
        
	end if
     
    stop
end program sample

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
int main(){
	FASTIO
	int n;
	cin>>n;
	//vector<ll> arr(n);
	ll mx=-1,sum=0;
	FOR(i,0,n){
		ll temp;
		cin>>temp;
		if(temp>mx){
			mx=temp;
		}else{
			sum+=mx-temp;
		}
	}
	cout<<sum<<"\n";
	return 0;
}


Measured memory_bytes: 3616
import math
from collections import defaultdict

def prime_factorize(n: int):
    prime_factors = defaultdict(int)

    for i in range(2, int(math.sqrt(n)) + 1):
        while True:
            div, mod = divmod(n, i)
            if mod == 0:
                prime_factors[i] += 1
                n = div
            else:
                break
        if n == 1:
            break
    if n != 1:
        prime_factors[n] = 1

    return prime_factors


def main():
   n = int(input())
   primes = prime_factorize(n)

   ret = 1
   for k, v in primes.items():
      ret *= pow(k, v) - pow(k, v-1)
   print(ret)
   return



main()


Measured memory_bytes: 6052
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;


int main(void){
  int n;
  cin>>n;
  string s;
  for(int i=0;i<n;i++){
    cin>>s;
    vector<char> c;
    for(int j=0;j<8;j++){
      c.push_back(s[j]);
    }
    sort(c.begin(),c.end());
    int Max=0;
    int Min=0;
    for(int j=0;j<8;j++){
      Max+=(int)(c[j]-'0')*pow(10,j);
      Min+=(int)(c[j]-'0')*pow(10,7-j);
    }
    cout<<Max-Min<<endl;
  }
  return 0;
}



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

int main(){
    string str;
    cin >> str;
    bool n=0,s=0,w=0,e=0;

    for(int i=0; i<str.size(); i++){
        if(str.at(i)=='N') n=true;
        if(str.at(i)=='S') s=true;
        if(str.at(i)=='E') e=true;
        if(str.at(i)=='W') w=true;
    }
    if(s==n && e==w) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)


int main(){
   int n,k;
  cin >>n >>k;
   VI a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  map<int,int> num;
  for(int x:a){
    if(num.count(x)){
     num.at(x)++;
    }
    else{
      num[x]=1;
    }
  }
  if(num.size()<=k) cout << 0 << endl;
  else{
    vector<pair<int ,int>>  p(num.size());
    int j=0;
    for(pair<int,int> pp :num){
     int key=pp.first;
     int value=pp.second;
      p.at(j)=make_pair(value,key);
      j++;
    }
   sort(p.begin(),p.end());
    reverse(p.begin(),p.end());
    int sum=0;
    rep(i,k){
		int a,b;
      tie(a,b)=p.at(i);
      sum+=a;
    }
    cout << n-sum << endl;
  }
}
  

Measured memory_bytes: 11904
class Dice:
    def __init__(self,s1,s2,s3,s4,s5,s6):
        self.s1 = s1
        self.s2= s2
        self.s3= s3
        self.s4= s4
        self.s5 = s5
        self.s6= s6
    def east(self):
        prev_s1 = self.s1           #prev_s1を固定していないと以前の値が後述でs1に値を代入するとき変わってしまう。
        prev_s3 = self.s3
        prev_s4 = self.s4
        prev_s6 = self.s6
        self.s1 = prev_s4
        self.s3 = prev_s1
        self.s4 = prev_s6
        self.s6 = prev_s3
    def west(self):
        prev_s1 = self.s1
        prev_s3 = self.s3
        prev_s4 = self.s4
        prev_s6 = self.s6
        self.s1 = prev_s3
        self.s3 = prev_s6
        self.s4 = prev_s1
        self.s6 = prev_s4
    def south(self):
        prev_s1 = self.s1
        prev_s2 = self.s2
        prev_s5 = self.s5
        prev_s6 = self.s6
        self.s1 = prev_s5
        self.s2 = prev_s1
        self.s5 = prev_s6
        self.s6 = prev_s2
    def north(self):
        prev_s1 = self.s1
        prev_s2 = self.s2
        prev_s5 = self.s5
        prev_s6 = self.s6
        self.s1 = prev_s2
        self.s2 = prev_s6
        self.s5 = prev_s1
        self.s6 = prev_s5
    def top(self):
        return self.s1
s1,s2,s3,s4,s5,s6 = map(int,input().split())
dice = Dice(s1,s2,s3,s4,s5,s6)
order = input()
for c in order:
    if c =='N':
        dice.north()
    elif c =='S':
        dice.south()
    elif c =='E':
        dice.east()
    elif c == 'W':
        dice.west()
print(dice.top())


Measured memory_bytes: 5608
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
string st;
int ks;
int main()
{
	cin>>st;
	for(int i=0;i<st.size();i++)
	{
		string t=st.substr(i,1);
		if(t=="C")
			ks=1;
		if(st.substr(i,1)=="F"&&ks==1)
			{cout<<"Yes\n";return 0;}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

struct sqnode{int to,nxt;}sq[110];
int all=0,head[N];
void addedge(int u,int v)
{
    all++;sq[all].to=v;sq[all].nxt=head[u];head[u]=all;
}

int val[60],n,D,X,m,id[60],tot;
ll w[60],f[100100];
struct node{ll w,v;}p[1010];

void dfs(int u)
{
    val[u]=1;
    go(u,i)
    {
        dfs(v);
        val[u]+=val[v];w[u]+=w[v];
    }
    m+=val[u]*n;
}

bool cmp(int x,int y) {return 1ll*val[x]*w[y]>1ll*val[y]*w[x];}

int main()
{
    n=read();X=read();D=read();
    w[1]=read();
    rep(i,2,n)
    {
        w[i]=read();int fa=read();
        addedge(fa,i);
    }
    dfs(1);
    //rep(i,1,n) cout << w[i] << " ";cout << endl;
    rep(i,1,n) id[i]=i;
    sort(id+1,id+1+n,cmp);
    rep(i,1,n)
    {
        int len=1,lim=min(n,D);
        while (len<=lim)
        {
            p[++tot]=(node){w[id[i]]*len,val[id[i]]*len};
            lim-=len;len<<=1;
        }
        if (lim) {p[++tot]=(node){w[id[i]]*lim,val[id[i]]*lim};
        }
    }
    memset(f,0x3f,sizeof(f));f[0]=0;
    rep(i,1,tot)
    {
        per(j,m,p[i].v) 
            f[j]=min(f[j],f[j-p[i].v]+p[i].w);
    }
    ll ans=0;
    rep(i,0,m)
    {
        if (f[i]>X) continue;
        int rst=X-f[i];ll nowans=i;
        rep(j,1,n)
        {
            int k=id[j];ll now=rst/w[k];
            if (k!=1) now=min((ll)max(D-n,0),now);
            rst-=w[k]*now;nowans+=val[k]*now;
        }
        ans=max(ans,nowans);
    }
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){
        int n;
    int a[210];
    cin >> n;
    rep(i,n) cin >> a[i];

    int cnt = 0;
    bool err = 0;
    while(1){
      rep(i,n){
          if(a[i]%2==0){
              a[i]=a[i]/2;
        }else{
            err=1;
        }
      }
      if(err)break;
        cnt++;
    }

    cout << cnt << 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);
		int N = sc.nextInt();
		int maxv = -2000000000;
		ArrayList<Integer> numbers = new ArrayList<Integer>();
		for(int i =0;i<N;i++){
			numbers.add(sc.nextInt());
		}
		int minv = numbers.get(0);
		for(int i =1;i<N;i++){
			maxv = Math.max(maxv, numbers.get(i)-minv);
			minv = Math.min(minv, numbers.get(i));
		}
		System.out.println(maxv);

	}

}



Measured memory_bytes: 105584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  map<pair<int, int>, int> cnt;
  rep2(i, 1, n + 1) {
    int x = i;
    int first = 0;
    while(x) {
      first = x;
      x /= 10;
    }
    int end = i % 10;
    cnt[make_pair(first, end)]++;
  }
  int ans = 0;
  for(auto p : cnt) {
    int i = p.first.first;
    int j = p.first.second;
    ans += p.second * cnt[make_pair(j, i)];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
            int.TryParse(Console.ReadLine(), out x);
            
            Console.WriteLine(Calc(x));
        }

        static double Calc(int x)
        {
            return Math.Pow(x, 3);
        }
    }
}



Measured memory_bytes: 9452
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[4];
    for(int i = 0; i < 4; i++) {
      a[3 - i] = n % 10;
      n /= 10;
    }
    String[] op = new String[3];
    int flg = 0;
    for(int i = 0; i < 2; i++) {
      for(int j = 0; j < 2; j++) {
        for(int k = 0; k < 2; k++) {
          int f = a[0];
          if(i == 0) {
            f += a[1];
            op[0] = "+";
          } else {
            f -= a[1];
            op[0] = "-";
          }
          if(j == 0) {
            f += a[2];
            op[1] = "+";
          } else {
            f -= a[2];
            op[1] = "-";
          }
          if(k == 0) {
            f += a[3];
            op[2] = "+";
          } else {
            f -= a[3];
            op[2] = "-";
          }
          if(f == 7) {
            flg = 1;
            break;
          }
        }
        if(flg == 1) break;
      }
      if(flg == 1) break;
    }
    String ans = a[0] + op[0];
    for(int i = 1; i < 3; i++) {
      ans += (a[i] + op[i]);
    }
    ans += (a[3] + "=7");
    System.out.println(ans);
  }
}

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

int main()
{
    ll a, b, c; cin >> a >> b >> c;
    vector<ll> cost(3, 0);
    cost[0] = abs(b - a);
    cost[1] = abs(c - a);
    cost[2] = abs(c - b);
    sort(cost.begin(), cost.end());
    ll ans = cost[0] + cost[1];
    cout << ans << endl;
    

}


Measured memory_bytes: 3628
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>

int main(){
  int A, B, K;
  scanf("%d", &K);
  scanf("%d", &A);
  scanf("%d", &B);
  bool ok = false;
  for (int i=A; i<=B; i++){
    if (i%K==0) {
      ok = true;
      break;
    }
  }
  printf("%s\n", ok?"OK":"NG");
  return 0;
}


Measured memory_bytes: 3184
function Main(input) {
    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);
    var c = parseInt(input[2], 10);

    var utusu = a - b;
    console.log((c - utusu) < 0 ? 0 : (c - utusu));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 21064
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    set<pair<int, int> > pr;
    if (n % 2 == 0){
        for (int i=0; i < n/2; i++) pr.insert({i, n-i-1});
    }
    else{
        for (int i=0; i < n/2; i++) pr.insert({i, n-i-2});
    }
    vector<pair<int, int> > ans;
    for (int i=0;i<n;i++){
        for (int j=i+1; j < n; j++){
            if (!pr.count({i,j})) ans.push_back({i,j});
        }
    }
    cout << ans.size() << endl;
    for (int i=0; i < ans.size(); i++) cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    ll N;
    ll sum=0;
    cin >> N;
    

    for(ll i=2; i*i<=N; i++){
        if(i*i==N){
            ll m=i-1;
            ll x=N/i;
            if(x<m){
                sum+=m;
            }
        }else if(N%i==0){
            ll m=i-1;
            ll x=N/i;
            if(x<m){
                sum+=m;
            }
            
            m=N/i-1;
            x=N/(m+1);
            if(x<m){
                sum+=m;
            }
        }
        

    }
    
    if(N>2){
        sum+=N-1;
    }
    
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
def judge(t,x,y,t0,x0,y0):
  minT=abs(x-x0)+abs(y-y0)
  if (t-t0-minT)>=0 and (t-t0-minT)%2==0:
    return True
  else:
    return False
n=int(input())
lst=[tuple(int(i) for i in input().split()) for i in range(n)]
t0=0;x0=0;y0=0
for i in range(n):
  t,x,y=lst[i]
  if judge(t,x,y,t0,x0,y0):
    t0=t;x0=x;y0=y
    ans=True
  else:
    ans=False
    break
if ans:
  print('Yes')
else:
  print('No')
    

Measured memory_bytes: 17312
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static final long HUGE_NUM = 99999999999999999L;
	public static final double EPS = 0.000000001;

	public static final int SIZE = 21;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int POW[] = new int[SIZE];
		POW[0] = 1;
		for(int i = 1; i < SIZE; i++){

			POW[i] = POW[i-1]*2;
		}

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int M = scanner.nextInt();

		//種類の個数を記録
		int table[] = new int[M];
		for(int i = 0; i < table.length; i++){

			table[i] = 0;
		}

		//移動するぬいぐるみの個数を求めるための累積和テーブル
		int ruisekiwa[][] = new int[M][N];
		for(int row = 0; row < M; row++){
			for(int col = 0; col < N; col++){

				ruisekiwa[row][col] = 0;
			}
		}


		int tmp;

		for(int i = 0; i < N; i++){

			tmp = scanner.nextInt();
			tmp--;
			table[tmp]++;
			ruisekiwa[tmp][i] += 1;
		}

		for(int row = 0; row < M; row++){
			for(int col = 1; col < N; col++){

				ruisekiwa[row][col] += ruisekiwa[row][col-1];
			}
		}

		int dp[] = new int[POW[M]];

		dp[0] = 0;
		for(int state = 1; state < POW[M]; state++){

			dp[state] = BIG_NUM;
		}

		int left,right;
		int tmp_sum,next_state,add,loc;

		for(int state = 0; state < POW[M]-1; state++){

			tmp_sum = 0;

			//配置済のぬいぐるみの個数を求める
			for(int loop = 0; loop < M; loop++){
				if((state & POW[loop]) != 0){
					tmp_sum += table[loop];
				}
			}

			left = tmp_sum;

			for(int loop = 0; loop < M; loop++){
				if((state & POW[loop]) == 0){ //次に置くぬいぐるみ

					right = tmp_sum+table[loop]-1;

					//範囲より左
					if(left == 0){

						add = 0;
					}else{

						add = ruisekiwa[loop][left-1];
					}
					//範囲より右
					add += (ruisekiwa[loop][N-1]-ruisekiwa[loop][right]);

					next_state = state+POW[loop];
					dp[next_state] = Math.min(dp[next_state],dp[state]+add);
				}
			}
		}

		System.out.println(dp[POW[M]-1]);
    }
}


class UTIL{

    //String→intへ変換
    public static int getNUM(String tmp_str){

        return Integer.parseInt(tmp_str);
    }

    //文字が半角数字か判定する関数
    public static boolean isNumber(String tmp_str){

        if(tmp_str == null || tmp_str.length() == 0){

            return false;
        }

        Pattern pattern = Pattern.compile("\\A[0-9]+\\z");
        Matcher matcher = pattern.matcher(tmp_str);
        return matcher.matches();
    }
}


Measured memory_bytes: 80324
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

void solve() {
  ll n;
  cin >> n;
  set<ll> s;

  for(ll i = 1; i * i <= n; i++) {
    if(n/i == n%i) s.insert(i);
  }
  for(ll goalR = 1; goalR * goalR <= n; goalR++) {
    ll currN = n-goalR;
    for(ll a = goalR; a * a <= currN; a++) {
      ll q = currN / a;
      if(n / q > goalR) break;
      if(currN % a) continue;
      if(n / q == n % q) {
        s.insert(q);
        break;
      }
    }
  }

  ll ret = 0;
  for(ll out: s) ret += out;
  cout << ret << "\n";
}

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


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,c,d; cin >> a >> b >> c >> d;
    if((a <= 0 && b >= 0) || (c <= 0 && d >= 0)){
        cout << max({a*c, a*d, b*c, b*d, 0LL});
    }else{
        cout << max({a*c, a*d, b*c, b*d});
    }
}

Measured memory_bytes: 3648