akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n = INT()
a = LIST()
ans = 0
for i in range(n):
    if a[a[i] - 1] == i + 1:
        ans += 1
ans //= 2
print(ans)

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

typedef long long int ll;
const ll mod = 1e9 + 7;

ll power(ll a, ll b) {
  ll res = 1LL;
  while(b) {
    if(b&1)
      res = (res*a)%mod;
    b/=2;
    a = (a*a)%mod;
  }
  return res;
}

int main() {
  long long int n;
  cin >> n;
  
  ll res = power(10LL, n);
  res = (res - power(9LL,n) + mod)%mod;
  res = (res - power(9LL,n) + mod)%mod;
  res = (res + power(8LL, n))%mod;
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
using namespace std;
long long solve(long long a,long long b){
    int w,max=a,min=b;
    if(a<b){
        max=b;
        min=a;
    }
    while(max%min!=0){
        max-=min;
        if(max<min){
          w=min;
          min=max;
          max=w;
        }
    }
    return min;
}
int main(void){
    long long a,b;
    while(cin>>a>>b){
        cout<<solve(a,b)<<" "<<a*b/solve(a,b)<<endl;
    }
    return 0;
}

Measured memory_bytes: 2980
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val d = scanner.nextInt()
    val array = Array(n, {Array(d, {0})})
    for(i in 1..n){
        for(j in 1..d)
            array[i-1][j-1] = scanner.nextInt()
    }
    var sum = 0.0
    var count = 0
    for(k in 1..n) {
        for (i in k+1..n) {
            for (j in 1..d) {
                var temp = Math.pow(Math.abs(array[k - 1][j - 1] - array[i-1][j - 1]).toDouble(), 2.0)
                sum += temp
            }
            if (Math.sqrt(sum) - Math.sqrt(sum).toInt().toDouble() === 0.0) count++;
            sum = 0.0
        }
    }
    println(count)

}

Measured memory_bytes: 29604
#include <bits/stdc++.h>
#define int long long int

using namespace std ;

const int N = 2e6 + 100 ;
int n , k , a[N] ;
bool bb[N] ;

int32_t main(){
	cin >> n >> k ;
	for(int i = 0 ; i < n ; i++){
		cin >> a[i] ;
	}
	for(int i = 0 ; i <= k ; i++){
		bool is = false; 
		for(int j = 0 ; j < n ; j++){
			if(i < a[j])break ;
			is |= bb[i - a[j]] == 0 ;
		}
		bb[i] = is ;
	}
	cout << (bb[k] ? "First" : "Second") ;
	return 0 ; 
}
/*
#include <radman/roderc++.h>
                     ....._____
                 .~~~~~////////\\                                                                                           ...
              .:::::////////////\\                                          ....::////////..                              (/\\\\...
           .::::://////   \\\\///\\              .:::://                ..:::::///////////////.                           \\\\\$$$$$$
         \\\\\//////      \\\\///\\           //\\\//////             \\\\\////////////////////.                           ""\\$$$$$$$
         \\\\\////         \\\\////         |||||////////.            \\\\\/////     ~~~~~//////          ...                  "\$$$$
         \\\\\//\         ////|||/          \\\\\/////////            \\\\\//\       ~~~~~//////        (/\\\\...                   .
         \\\\\//\        ////|||/          |||||////*\\///.           \\\\\//\       ~~~~~//////        \\\\\$$$$$$                 .@@@@@.
         \\\\\//\       ////|||/           \\\\\///|\\\////           \\\\\//\       ~~~~~//////         ""\\$$$$$$$               @@@@////\
         \\\\\//\ ____---/|||/            |||||///|\\\\\///.          \\\\\//\       ~~~~~//////             "\$$$$                @@@@\///\
         \\\\\//\--|||||||_-'             \\\\\///|\\\\\////          \\\\\//\       ~~~~~//////                                  ,@@@@|///|
         \\\\\//\|||||_"-\\\\\           |||||///|  ~~~~~///.         \\\\\//\      ~~~~~//////     .@@@@.                    /@@@@@|/////
         \\\\\//\///"""\\\\\\\\          \\\\\///|~~~~[[[////.        \\\\\//\     ~~~~~//////      @@@@@@@@                ..@@@@@.//////
         \\\\\//\    \"""\\\\\\\        |||||///|~~[[[[["\////.       \\\\\//\    ~~~~~//////      '@@@@/////\       .:;@@@@@@@..///////"
         \\\\\//\      \"""\\\\\\       \\\\\///|[[[[*\\\\\////.      \\\\\//\   ~~~~~//////        *@@@\//////\@@@@@@@@..//////////"
         \\\\\//\       \:::\\\\/      |||||///|[[[*   \\\\\\///      \\\\\//\~~~~~///////'            *@@\/////////////////////"
         \\\\\//\        \___\\/       \\\\\///|*       \\\\\/"       \\\\\//\~~////////'                 **"///////////"""
         \\\\\//\                     |||||///|                       \\\\\//\///////"
         \\\\\//\                     \\\\\///|                       \\\\\//\////"
         \\\\\///                    |||||////|                       \\\\\////"
         \\\\\/"                     \\\\\///*                        \\\\\/"
                                     """""*
*/


Measured memory_bytes: 384
n = int(input())
dim = [0 for _ in range(n+1)] #次数のカウント
parent = [0 for _ in range(n+1)] #頂点iの親
col = [ 0 for _ in range(n+1)]  #頂点iの親からiに伸びる枝が使っている色
using = [[] for _ in range(n+1)]
AB = []
for i in range(n-1):
    a, b = map(int, input().split())
    AB.append([a, b, i])
    parent[b] = a
    dim[a] += 1
    dim[b] += 1
#幅優先探索のためにソート
AB_sorted = sorted(AB)
prev_a = -1
for j in range(n-1):
    a = AB_sorted[j][0]
    b = AB_sorted[j][1]
    index = AB_sorted[j][2]
    if a != prev_a:
        paint = 1
    
    while paint == col[a] or paint in using[a]:#親から自分に伸びてる枝以外の色にする
        paint += 1
    
    col[b] = paint
    using[a].append(paint)
    AB[index].append(paint) #辺の色を追加
    prev_a = a

print(max(dim))
for i in range(n-1):
    print(AB[i][3])

Measured memory_bytes: 86704
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n; cin >> n;
	string s; cin >> s;
	vector<int> v(n);
	rep(i,s.size()){
		int count = 0;
		for (char a = 'a'; a <= 'z'; a++){
			bool first = false;
			bool second = false;
			for(int j = 0; j < i; j++){
				if (s[j] == a) {
					first = true;
				}
			}

			for(int j = i; j < s.size(); j++){
				if (s[j] == a) {
					second = true;
				}
			}
			if (first && second){
				count++;
			}
		}
		v[i] = count;
	}
	print(*max_element(all(v)));
}

Measured memory_bytes: 256
#include<stdio.h>

void makeAns(char*, int, int);

int main()
{
  int a, b;
  scanf("%d %d", &a, &b);
  
  char ans[10];
  if (a <= b) {
    makeAns(ans, a, b);
  } else {
    makeAns(ans, b, a);
  }
  
  printf("%s", ans);
  
  return 0;
}

void makeAns(char* ans, int num, int count)
{
  for (int i = 0; i < count; i++) {
    sprintf(&ans[i], "%d", num);
  }
}

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

int main() {
	int n,ans;
	string s;
	cin >> n >> s;
	ans = n;
	for(int i=1;i<n;i++)
	{
		if(s.at(i-1)==s.at(i))
		{
			ans--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
string s;
vl A;

ll fact[ARRAY];
ll inv_fact[ARRAY];
ll inv[ARRAY];

//準備
void combiInit() {
  fact[0] = fact[1] = 1;
  inv_fact[0] = inv_fact[1] = 1;
  inv[1] = 1;
  FOR(i, 2, ARRAY) {
    fact[i] = fact[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    inv_fact[i] = inv_fact[i-1] * inv[i] % MOD;
  }
}

//combiInitを実行した後はこれでnCrが取れる
ll combi(ll n, ll r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fact[n] * (inv_fact[r] * inv_fact[n-r] % MOD) % MOD;
}

void input() {
  IN(N);
  IN(K);
  REP(i, N) {
    IN(t);
    A.pb(t);
  }
}

void solve() {
  sort(ALL(A));
  combiInit();
  FOR(l, 0, N-K+1) {
    ll m = A[l];
    ll cnt = combi(N-l-1, K-1);
    ret -= (m * cnt) % MOD;
    ret %= MOD;
  }
  FOR(r, K-1, N) {
    ll m = A[r];
    ll cnt = combi(r, K-1);
    ret += (m * cnt) % MOD;
    ret %= MOD;
  }
  while(ret < 0) ret += MOD;
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


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

int main(){
  int n;
  scanf("%d", &n);
  vector<vector<pair<int, int>>> g(n);
  for(int i = 1; i < n; i++){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    a--; b--;
    g[a].emplace_back(b, c);
    g[b].emplace_back(a, c);
  }
  int q, k;
  scanf("%d %d", &q, &k);
  k--;
  vector<long> dist(n);
  auto dfs = [&](int from, int at, long d, const auto& dfs) -> void {
    dist[at] = d;
    for(auto i : g[at]) if(i.first != from){
      dfs(at, i.first, d + i.second, dfs);
    }
  };
  dfs(-1, k, 0, dfs);
  for(int i = 0; i < q; i++){
    int a, b;
    scanf("%d %d", &a, &b);
    a--; b--;
    printf("%lld\n", dist[a] + dist[b]);
  }
}

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=998244353;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

#include <functional>
#include <climits>

//SegmentTree<int> seg(N,[](int a,int b){return min(a,b);},INT_MAX);
template< typename T>
class SegmentTree{
public:

  using F = function<T(T,T)>;

  int n;
  vector<T> tree;
  F operation;
  T def;

  SegmentTree(int size,F _operation,T _def):operation(_operation),def(_def){
    n=1;
    while(n<size) n*=2;
    tree.resize(2*n-1,def);
  }

  SegmentTree(){}

  void embody(int size,F _operation,T _def){
    operation=_operation;
    def=_def;
    n=1;
    while(n<size) n*=2;
    tree.resize(2*n-1,def);
  }

  void initialize(vector<T> v){
    int vSize=v.size();
    n=1;
    while(n<vSize) n*=2;
    tree.resize(2*n-1,def);

    for(int i=0;i<vSize;i++) tree[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--) tree[i]=operation(tree[2*i+1],tree[2*i+2]);
  }

  void update(int index,T value){
    index+=n-1;

    tree[index]=value;
    while(index>0){
      index=(index-1)/2;
      tree[index]=operation(tree[2*index+1],tree[2*index+2]);
    }
  }

  T query(int a,int b,int k=0,int l=0,int r=-1){//[a,b),getMin(a,b,0,0,-1)
    if(r<0) r=n;

    if(r<=a||b<=l) return def;
    else if(a<=l&&r<=b) return tree[k];
    else{
      T lval=query(a,b,2*k+1,l,(l+r)/2);
      T rval=query(a,b,2*k+2,(l+r)/2,r);
      return operation(lval,rval);
    }
  }

  int find(int x,int k=0,int l=0,int r=-1){// a[0]+...+a[i]>=x (i:minimal)
    if(r<0) r=n;
    if(r-l==1) return k-(n-1);
    if(tree[2*k+1]>=x) return find(x,2*k+1,l,(l+r)/2);
    else return find(x-tree[2*k+1],2*k+2,(l+r)/2,r);
  }
};

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

  int N;
  cin>>N;
  vector<ll> X(N),D(N);
  rep(i,N) cin>>X[i]>>D[i];

  vector<pair<ll,int>> v(N);
  rep(i,N) v[i]=mkp(X[i],i);
  sort(v.begin(),v.end());

  vector<int> nex(N,0);
  for(int i=0;i<N;i++) nex[i]=i+1;
  SegmentTree<int> seg(N,[](int a,int b){return max(a,b);},0);
  seg.initialize(nex);
  for(int i=N-2;i>=0;i--){
      int now=v[i].second;
      int z=lower_bound(v.begin(),v.end(),mkp(X[now]+D[now],-1))-v.begin();
      if(i<z){
          int val=seg.query(i,z);
          seg.update(i,val);
      }
  }

  //for(int i=0;i<N;i++) cout<<i<<" "<<seg.query(i,i+1)<<endl;

  vector<ll> dp(N+1,0);
  dp[0]=1;
  for(int i=0;i<N;i++){
      int ne=seg.query(i,i+1);
      add(dp[i+1],dp[i]);
      add(dp[ne],dp[i]);
  }

  cout<<dp[N]<<endl;

  return 0;
}


Measured memory_bytes: 10864
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 1145141919
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)

using namespace std;

int main(void){
  int a;
  string s;
  cin >> a >> s;
  if(a>=3200) cout << s << endl;
  else cout << "red" << endl;
}

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

int main(void) {
    int N, M;
    int sum = 0;
    int i;
    
    cin >> N >> M;
    
    vector<int>A(N);
    for (i = 0; i < N; i ++) {
        cin >> A[i];
        sum += A[i];
    }
    
    double th = (double)sum / (double)(4 * M);
    int count = 0;
    
    for (i = 0; i < N; i ++) {
        if (A[i] >= th) {
            count ++;
        }
    }
    
    if (count >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    
    return 0;
}


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

int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int cnt = 0;
  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
        if(500 * i + 100 * j + 50 * k == X){
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
K = int(input())

if (K%10) % 2 == 0:
    print(-1)

elif (K%10) % 5 == 0:
    print(-1)
else:
    num = 7
    for i in range(K):
        if num % K == 0:
            print(str(i+1))
            break
        num = (num *10 + 7) %K
    else:
        print(-1)


Measured memory_bytes: 9180
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();
        List<Integer> li = new ArrayList<>();

        for (int i = 0; i < N; ++i) {
            li.add(fs.nextInt());
        }

        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < N; ++i) {
            int tmp1 = 0;
            for (int j = 0; j <= i; ++j) {
                tmp1 += li.get(j);
            }
            int tmp2 = 0;
            for (int k = i+1; k < N; ++k) {
                tmp2 += li.get(k);
            }
            ans = Math.min(ans, Math.abs(tmp1 - tmp2));
        }

        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() { return Double.parseDouble(next());}
}




Measured memory_bytes: 32432
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> hoge(n);
    for(int i=0;i<n;i++) cin>>hoge.at(i);
    
    int maxc=-1;
    
    for(int i=0;i<n-1;i++){
        for(int j=i;j<n;j++){
            maxc=max(maxc,abs(hoge.at(i)-hoge.at(j)));
        }
    }
    
    cout<<maxc<<endl;
    
    return 0;
}

Measured memory_bytes: 256
S = input()

flg1 = S == S[::-1]

s1 = S[:(len(S) - 1) // 2]
flg2 = s1 == s1[::-1]

s2 = S[(len(S) + 3) // 2 - 1:]
flg3 = s2 == s2[::-1]

if flg1 and flg2 and flg3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<climits>
using namespace std;

#define NONE INT_MAX>>1

int n,m,a,b,c,d,x1,x2,y1,y2;
vector< vector<int> >M;

int WarshallFloyd(int start,int goal)
{
  vector< vector<int> >A(n,vector<int>(n,NONE));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      if(M[i][j]!=NONE)A[i][j]=M[i][j];
  for(int k=0;k<n;k++)
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
  return A[start][goal];
}

int main()
{
  cin>>n>>m;
  M.resize(n);
  for(int i=0;i<n;i++)M[i].resize(n,NONE);
  for(int i=0;i<m;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    a--;b--;
    M[a][b]=c;
    M[b][a]=d;
  }
  scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
  x1--;x2--;
  cout<<(y1-y2-WarshallFloyd(x1,x2)-WarshallFloyd(x2,x1))<<endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  
  int ans=0;
  
  for(int i=1;i<n-1;i++){
    if((p.at(i-1)<p.at(i) && p.at(i)<p.at(i+1)) || (p.at(i-1)>p.at(i) && p.at(i)>p.at(i+1))){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
int main()
{
  ll sum=0;
  ll N,M,A;
  cin>>N>>M;
  rep(i,M){
    cin>>A;
    sum+=A;
  }
  ll B=-1;
  cout<<max(B,N-sum)<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  int ans = 0;
  if(s=="SUN") ans = 7;
  if(s=="MON") ans = 6;
  if(s=="TUE") ans = 5;
  if(s=="WED") ans = 4;
  if(s=="THU") ans = 3;
  if(s=="FRI") ans = 2;
  if(s=="SAT") ans = 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let h, w, k = Scanf.sscanf (read_line ()) "%d %d %d" @@ fun h w k -> (h, w, k)
let c = Array.init h @@ fun _ -> read_line () |> split_string |> Array.of_list

let rec pow x n = if n = 1 then x else x * pow x (n - 1)

let rec to_array acc n = function
  | 0 -> Array.of_list acc
  | i -> to_array ((n mod 2 = 1) :: acc) (n / 2) (i - 1)
let to_array =  to_array []

let count rows columns =
  let cnt = ref 0 in
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      if (not rows.(i)) && (not columns.(j)) && c.(i).(j) = "#" then
        incr cnt
    done
  done;
  !cnt

let () =
  let ans = ref 0 in
  let a, b = pow 2 h, pow 2 w in
  for i = 0 to a - 1 do
    for j = 0 to b - 1 do
      if count (to_array i h) (to_array j w) = k then
        incr ans
    done
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 5784
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  deque<int> b;
  rep(i,n) cin >> a[i];
  
  rep(i,n){
    if(n%2){
      if(i%2){
        b.push_back(a[i]);        
      }else{
        b.push_front(a[i]);
      }
    }else{
      if(i%2){
        b.push_front(a[i]);        
      }else{
        b.push_back(a[i]);
      }
    }

  }
  
  for(auto c:b){
    printf("%d ",c);
  }
  return 0;
}

Measured memory_bytes: 3840
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int gcd(int a, int b)
{
    if (a > b)
        std::swap(a, b);

    while (true)
    {
        auto mod = b % a;
        b = a;
        a = mod;

        if (mod == 0)
            return b;
    }
}

int main()
{
    using namespace std;

    int n;
    cin >> n;
    vec<int> a(n);
    for (auto &e : a)
    {
        cin >> e;
    }

    auto ans = accumulate(a.cbegin() + 1, a.cend(), a.front(),
               [](int init, int i) { return gcd(init, i); });

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    string a,b;
    cin>>a>>b;
    int l=sz(a),ll=sz(b);
    for (int i=0;i<l;i++){
        if (i==ll){
            cout << a[i];
        }
        else cout <<a[i]<<b[i];
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, sum, last, cnt, ans = 0;
Pll a[110] = {};
LL d[1010][1010] = {};
int dd[4][2] = { {1,0},{0,1},{ -1,0 },{ 0,-1 } };
string str,ss;
struct Edge { LL cost, from, to; };
vector<Edge>vec;
bool f;
char c[10000][10000];
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
LL bfs(Pll s,Pll t) {
	queue<Ppll>qu;
	d[s.fir][s.sec] = 0;
	qu.push(Ppll(d[s.first][s.second], s));
	while (!qu.empty()) {
		Ppll pp = qu.front();
		Pll pos = pp.second;
		qu.pop();
		if (pos == t)break;
		if (pp.fir > d[pos.fir][pos.sec])continue;
		rep(i, 4) {
			LL X = pos.first + dd[i][0], Y = pos.second + dd[i][1];
			if (X < h&&Y<w&&X>=0&&Y>=0&&d[X][Y]>d[pos.fir][pos.sec] + 1&&c[X][Y]== '.') {
				d[X][Y] = d[pos.first][pos.second] + 1;
				qu.push(Ppll(d[X][Y], Pll(X, Y)));
			}
		}
	}
	return d[t.fir][t.sec];
}
int main() {
	cin >> h >> w >> n;
	rep(i, h)rep(j, w) {
		cin >> c[i][j];
		if (c[i][j] == 'S' || (c[i][j] > '0'&&c[i][j] <= '9')) {
			if (c[i][j] == 'S')
				a[0] = Pll(i, j);
			else
				a[c[i][j] - '0'] = Pll(i, j);
			c[i][j] = '.';
		}
	}
	rep(i, n) {
		rep(j, 1010)rep(k, 1010)d[j][k] = INF/2;
		ans += bfs(a[i],a[i+1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16104
#include<bits/stdc++.h>
#define p_ pair<int,int>
#define mp_ make_pair
#define ll long long
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int cnt[maxn];
int main()
{
    fastio();
    int n,k;
    cin>>n>>k;
    rep(i,1,k){
        int t;
        cin>>t;
        while(t--){
            int u;
            cin>>u;
            cnt[u]++;
        }
    }
    int ans = 0;
    rep(i,1,n) if(cnt[i]==0) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3656
using System;

namespace Master
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split();
            int a = int.Parse(data[0]);
            int b = int.Parse(data[1]);
            if (b % a == 0) {
                Console.WriteLine(a + b);
            } else {
                Console.WriteLine(b - a);
            }
        }
    }
}


Measured memory_bytes: 13140
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  vector<vector<int>> a(6,vector<int>(6));
  rep(i,3) rep(j,3) {
    cin >>a[i][j];
    a[i+3][j]=a[i][j];
    a[i][j+3]=a[i][j];
    a[i+3][j+3]=a[i][j];
  }
  int all=0;
  rep(i,3) rep(j,3) all+=a[i][j];
  all/=3;
  rep(i,3){
    rep(j,3){
      if(all!=a[i][j]+a[i+1][j+1]+a[i+2][j+2]){
        cout <<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
# EDPC Q - Flowers
# 重み付きのLISと言って良いような問題
# これは、LISのdpを少し改造すれば解ける

## test data
# 4
# 3 1 4 2
# 10 20 30 40
## ans=60

import bisect

class SegTree:
	"""
	1-indexed
	"""
	def __init__(self,size,func,init_val,undef):
		self.specSize = size
		self.datSize = 1
		self.compareFunc = func		# suppose to min or max
		self.INIT_VAL = init_val	# 0 etc
		self.UNDEFINED_VAL = undef	# 1e18 -1e18 etc
		# num:size以上の最小の2のべき乗
		# self.datSize = 2**(size-1).bit_length()
		self.datSize = 2**size.bit_length()
		# while self.datSize < size: self.datSize *= 2

		# the tree is implemented by sequencial list
		# (1-indexed, 0 is not use.)
		self.datTree = [self.INIT_VAL for _ in range(2*self.datSize+1)]

	def update(self, i, val ):
		"""
		i: index(1-ordered)
		"""
		# i -= 1	# 1-orderで指定され、内部では0-Order想定?
		# i += (self.datSize - 1)
		i += self.datSize
		# print("upd",i,val)
		self.datTree[i] = val
		while 1 < i:
			# i = (i-1) >> 1	# (i-1)//2
			i >>= 1
			self.datTree[i] = self.compareFunc( self.datTree[i<<1|0], self.datTree[i<<1|1] )
			# print("upd",i,self.datTree[i])
			# self.printTree()

	def query(self,a,b):
		return self.query_(a,b,1,0,self.datSize)

	def query_(self,a,b,i,l,r):
		""" get minimun/maximum value of range[a,b)
		all 1-indexed
		i is the root vertex of search 
		l,r is range of the root vertex(not use)
		"""
		ret = self.UNDEFINED_VAL

		a += self.datSize
		b += self.datSize
		while a < b:
			if b & 1:
				b -= 1
				ret = self.compareFunc(ret, self.datTree[b])

			if a & 1:
				ret = self.compareFunc(ret, self.datTree[a])
				a += 1

			a >>= 1; b >>= 1

		return ret
	def query_recursive(self,a,b,i,l,r):
		""" get minimun/maximum value of range[a,b)
		all 1-indexed
		i is the root vertex of search 
		l,r is range of the root vertex
		"""
		if r <= a or b <= l:
			# (a,b) and (l,r) is not intersected
			return self.UNDEFINED_VAL

		if a <= l and r <= b:
			# i is index required
			return self.datTree[i]
		else:
			# search children
			m = (l+r) >> 1 #(l+r) // 2
			# vl = self.query_(a, b, i*2 + 1, l, m )
			# vr = self.query_(a, b, i*2 + 2, m, r )
			vl = self.query_(a, b, (i>>1) + 1, l, m )
			vr = self.query_(a, b, (i>>1) + 2, m, r )
			return self.compareFunc(vl,vr)

	def printTree(self):
		print(self.datTree)
		# print("root")



def LongestIncreaseSeaquence(H,A):
	# === Coordinate compression ===
	# unique and sort asc
	N = len(H)
	# sortedA = sorted(list(set(A)))
	lis = 0

	# === Range Maximum Query ===
	# ここでは、各要素iに、最後の値がiの時のLISを登録
	tree = SegTree(N,max,0,-1e18)
	for n in range(N):

		# i=bisect.bisect_left(sortedA,A[n])

		maxValOfCurrentRange = tree.query(0,H[n])
		# valOfNext = tree.query(H[n],H[n]+1)

		# # i+=1

		# if valOfNext < maxValOfCurrentRange + A[n]:
		# print( H[n], maxValOfCurrentRange + A[n] )
		# tree.debugPrint()
		tree.update( H[n], maxValOfCurrentRange + A[n] )

	# tree.printTree()
	lis = tree.query(0,N+1)
	return lis


def main():
	N = int(input())
	# 高さは、N以下で全部違うらしい
	H = list(map(int, input().split()))
	A = list(map(int, input().split()))
	# A = [ int(input()) for _ in range(N)]
	print(LongestIncreaseSeaquence(H,A))



if __name__ == "__main__":
	main()


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


using namespace std;
double pi=3.14159265358979323846264338;


inline void ex(){cout<<"Yes"<<endl;exit(0);}
long long a,b,c,d;


long long n,k,ind;
bool ok[1000001];
long long arr[11][3];
map<long long,long long>ma;
long long arr3[200001];
long long N;
long long T(long long t){
	if(t<0)return t+N;
	else return t%N;
}
long long calc(long long a,long long b){
	long long cnt=1;
	while(b%a==0){
		b=b/a;
		cnt++;
	}
	return cnt;
}
long long ca(long long x,long long y){
	if(ma.find(x%y)!=ma.end()){
		b=0;
		for(int i=0;i<ma[x%y];i++)b+=arr3[i];
		c=0;
		d=ma[x%y];
		for(int i=ma[x%y];i<ind;i++)c+=arr3[i];
		return ind;
	}

	arr3[ind]=x%y;
	ma[x%y]=ind;
	ind++;
	
	
	//cout<<x%y<<endl;
	
	if(x%y==0){b=0;return ind;}
	return ca(T(x*x),y);
	
}

int main(){
	ind=1;
	cin>>n>>a>>N;
	c=0;
	arr3[0]=a;
	ma[a]=0LL;
	ok[a]=true;
	ca(T(a*a),N);
	long long cnt=0;
	//cout<<ind<<endl;
	if(c==0){
		cnt=0;
		for(int i=0;i<min(n,ind);i++)cnt+=arr3[i];
		cout<<cnt<<endl;
		return 0;
	}
	cnt=((n-d)/(ind-d))*c;
	if(n<d){
		for(int i=0;i<n;i++)cnt+=arr3[i];
	}else cnt+=b;
	//cout<<d<<" "<<ind<<endl;
	for(int i=0;i<(n-d)%(ind-d);i++)cnt+=arr3[d+i];
	cout<<cnt<<endl;
	return 0;

}

Measured memory_bytes: 12508
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int a[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        int sum = 0;
        int ans1 = 0;
        for(int i = 0; i < n; i++){
            if(i % 2){
                sum += a[i];
                if(sum >= 0){
                    ans1 += sum + 1;
                    sum = -1;
                }
            }else{
                sum += a[i];
                if(sum <= 0){
                    ans1 += 1 - sum;
                    sum = 1;
                }
            }
        }
        int ans2 = 0;
        sum = 0;
        for(int i = 0; i < n; i++){
            if(i % 2){
                sum += a[i];
                if(sum <= 0){
                    ans2 += 1- sum;
                    sum = 1;
                }
            }else{
                sum += a[i];
                if(sum >= 0){
                    ans2 += sum + 1;
                    sum = -1;
                }
            }
        }
        cout << min(ans1, ans2) << '\n';
    }
}

Measured memory_bytes: 32256
#include <iostream>
#include <cmath>


using namespace std;

int main(){
    int A, B, C, D;
    scanf("%d %d %d %d", &A, &B, &C, &D);
    while(A >= 0 || C >= 0){
        C = C - B;
        if(C <= 0){
            printf("Yes\n");
            break;
        }
        A = A - D;
        if(A <= 0){
            printf("No\n");
            break;
        }
        
    }



}

Measured memory_bytes: 3164
def main():
    R = int(input())

    print(2 * 3.141592 * R)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()


Measured memory_bytes: 61796
#include<bits/stdc++.h>
const int MIN=-1e9;
const int INF=1e9;
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
bool visited[100005];
const int max_N=1e5+10;
int N,K;
ll a[100005];
ll b[100005];
ll ans=0;
int main(void)
{
  cin >> N >> K;
  for(int i=1;i<=N;i++)
    {
      cin >> a[i];
      b[i]=max(a[i],0LL);
    }
  for(int i=1;i<N;i++)
    {
      a[i+1]+=a[i];
      b[i+1]+=b[i];
    }
  for (int i = 1; i <= N-K+1; ++i)
    {
      ll tmp=a[i+K-1]-a[i-1];
      ll tmp2=0;
      
      tmp+=b[i-1];
      //tmp2+=b[i-1];
	
      if(N!=i+K-1)
	{
	  tmp+=(b[N]-b[i+K-1]);
	  tmp2+=(b[N]-(b[i+K-1]-b[i-1]));
	}
      //cout << tmp << ' ' << tmp2 << endl;
      ans=max(ans,tmp);
      ans=max(ans,tmp2);
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(string s) {
    int n = cast(int)s.length;
    assert(n % 2 == 0);

    // 末尾から i 文字分だけ削る
    for (int i = 1; i < n; i++) {
        int m = (n - i) / 2;
        auto a = s[0..m];
        auto b = s[m..m * 2];
        if (a == b) return m * 2;
    }
    assert(false);
}

void main() {
    string s = read!string;
    writeln(calc(s));
}


Measured memory_bytes: 256
s = input()
if s[0] != 'A':
  print('WA')
  exit()
sho = ord('a')
ok = 0
for i in s[2: len(s) - 1]:
  if ord(i) < sho:
    if ord(i) == ord("C"):
      ok += 1
    else:
      print("WA")
      exit()
if ord(s[1]) < sho or ord(s[len(s) - 1]) < sho:
  print("WA")
  exit()
if ok == 1:
  print("AC")
else:
  print("WA")

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int w,h;
  scanf("%d%d",&w,&h);
  int *p=(int *)calloc(w,sizeof(int));
  int *q=(int *)calloc(h,sizeof(int));
  int i,j;
  for(i=0;i<w;i++) scanf("%d",p+i);
  for(i=0;i<h;i++) scanf("%d",q+i);
  qsort(p,w,sizeof(int),cmp);
  qsort(q,h,sizeof(int),cmp);
  int64 ans=0;
  i=j=0;
  while(i<w && j<h){
    if(p[i]<=q[j]){
      ans+=(int64)p[i++]*(h+1-j);
    } else {
      ans+=(int64)q[j++]*(w+1-i);
    }
  }
  while(i<w) ans+=p[i++];
  while(j<h) ans+=q[j++];
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = 1e18;
const lint MOD = 1e9 + 7;
const lint inv = MOD - 2;

int main(){
    string s;
    cin >> s;
    vector<int> n(4);
    rep(i, 4){
        n[i] = s[i] - '0';
    }
    string ans = "       =7";
    rep(i, 4){
        ans[2*i] = s[i];
    }
    for(int i = 0 ; i < (1 << 3) ; i++){
        int tmp = n[0];
        for(int j = 0 ; j < 3 ; j++){
            if(i >> j & 1){
                tmp += n[3-j];
                ans[2*(3-j)-1] = '+';
            }else{
                tmp -= n[3-j];
                ans[2*(3-j)-1] = '-';
            }
        }
        if(tmp == 7){
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# Your code here!
gets.chop
arr = []
while(str = gets) do
    arr.push str.chop
end
str_hash = Hash.new(0)
arr.map{|str|
  str_hash[str] += 1
}
count_hash = Hash.new{[]}
max_count = 0
str_hash.map{|k, v|
  max_count = v > max_count ? v : max_count
  count_hash[v] = count_hash[v].push(k)
}
print count_hash[max_count].sort.join("\n")

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

using namespace std;

int main() {
    long double a,b,h,m;
    cin>>a>>b>>h>>m;
    if(h==12)
    h=0;
    if(m==60)
    m=0;
    long double x=0.5*(h*60+m);
    long double y=6*(h*60+m);
    long double z=abs(x-y);
    z=min(z,360-z);
    //cout<<z;
    double pi=2*acos(0.0);
    long double r=sqrt((a*a)+(b*b)-(2*a*b*cos(z*pi/180)));
    cout << fixed << setprecision(15) << r<<endl;
    
    
}

Measured memory_bytes: 4168
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	if(c^'-')k=1,x=c&15;else k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
int n,a,b,ans;
signed main(){
	Rd(n),Rd(a),Rd(b);
	ans=n/(a+b)*a,ans+=min(n%(a+b),a);
	wr(ans),exit(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int flag[10];

int jud(int i){
    while(i){
        if(flag[i%10]) return 0;
        i /= 10;
    }
    return 1;
}

int main()
{
    int n,k;
    cin >> n >> k;
    for(int i = 0; i < k; i++){
        int d; cin >> d;
        flag[d]++;
    }

    for(int i = n; ; i++){
        if(jud(i)){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int n,a,b;

int main(){
    int max = 2000000000;
    scanf("%lld", &n);
    for(int i = 0; i < n; i++){
        scanf("%lld %lld", &a,&b);
		if(a+b < max) {
			max = a+b;
		}
    }
    printf("%lld", max);
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC172F
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main(int argc, const char * argv[]) {
    int n;
    cin>>n;
    ll a[303]={};
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    ll s=a[1]+a[2];
    ll c=0;
    for(int i=3;i<=n;i++){
        c^=a[i];
    }
    if(s<c||(s-c)%2==1){ // cが大きい時、不可能
        cout<<-1<<endl;
        return 0;
    }
    ll d=s-c;
    if(d<0||d%2==1){
        cout<<-1<<endl;
        return 0;
    }
    d/=2;
    if(d>a[1]||d&c){
        cout<<-1<<endl;
        return 0;
    }
    bitset<40> d40,ap40,c40;
    d40=bitset<40>(d);
    c40=bitset<40>(c);
    vector<ll>free;
    rep(i,40){
        if(c40[i]==0) {
            ap40.set(i,d40[i]);
        }else{
            free.push_back(i);
            /*if(d40[i]==1){
                cout<<-1<<endl;
                return 0;
            }*/
        }
    }
    sort(free.rbegin(),free.rend());
    ll r_ans=ap40.to_ullong();
    ll cand=0;
    for(auto& x:free){
        if(ap40.set(x,1).to_ullong()>a[1]){
            ap40.set(x,0);
        }
        cand=(ll)ap40.to_ullong();
        r_ans=max(r_ans,cand);
    }
    if(r_ans==0){ // 山１を全て移動させることはできない
        cout<<-1<<endl;
    }else{
        cout<<a[1]-r_ans<<endl;
    }
    return 0;
}


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

int main(){
  unsigned long int n,m,l;
  cin >> n >> m >> l;
  unsigned long int a[100][100],b[100][100],c[100][100];

  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      a[i][j] = 0;
      b[i][j] = 0;
      c[i][j] = 0;
    }
  }

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

  for(int i=0;i<m;i++){
    for(int j=0;j<l;j++){
      cin >> b[i][j];
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      for(int k=0;k<m;k++){
        c[i][j] += a[i][k] * b[k][j];
      }
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      cout << c[i][j];
      if(j==l-1) cout << endl;
      else cout << " ";
    }
  }

  return 0;
}

Measured memory_bytes: 1392
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

#include <random>
#include <chrono>



struct RandNum {

	mt19937 mt;
	RandNum() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

	lint operator()(lint a, lint b) {
		uniform_int_distribution<lint> dist(a, b);
		return dist(mt);
	}
	lint operator() (lint b) { return (*this)(0LL, b); }

	template<class Ite>
	void shuf(Ite first, Ite last) { shuffle(first, last, mt); }

};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, L;
	cin >> N >> L;

	RandNum ran;

	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	DMP(a);

	bool ok = false;
	int memo = -1;
	for (int i = 0; i < N; i++) {
		if (a[i] + a[i + 1] >= L) {
			ok = true;
			memo = i;
			break;
		}
	}

	if (ok) {
		cout << "Possible" << "\n";
		for (int i = 0; i < memo; i++) cout << i + 1 << "\n";
		for (int i = N - 1; i > memo + 1; i--) cout << i << "\n";
		cout << memo + 1 << "\n";
	}
	else cout << "Impossible" << "\n";

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    deque<char> list;
    string str, fin="";
    cin >> str;
    long long num=str.length(), sze;
    char chr;
    for (long long i=0; i<num; i++) {
        chr=str[i];
        sze=list.size();
        if (chr=='B' && sze>0) {list.pop_back();}
        else if (chr!='B') {list.push_back(chr);}}
    long long finsz=list.size();
    for (long long i=0; i<finsz; i++) {
        chr=list[i];
        fin+=chr;}
    cout << fin;}

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

void solve()
{
	ll n;
	cin >> n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin >> a[i];
	ll ans=0;
	for(ll i=1;i<n;i++)
	{
		if(a[i]<a[i-1])
		{
			ans=ans+(a[i-1]-a[i]);
			a[i]=a[i-1];
		}
	}
	cout << ans ;
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("ouput.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 5208
#include<bits/stdc++.h>
using namespace std;
int w[55],l;
int ans;
int main() {
	cin>>l;
	for(int i=1;i<=l;i++) cin>>w[i];
	for(int i=1;i<=l;i++) 
		if(w[i]!=i) ans++;
	if(ans==2||ans==0) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256