akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
//typedef string S;

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

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}*/

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const int N = 120010;
const long long MOD = 1e9 + 7;
const int INF = 1e9;
const long long rev2 = (MOD + 1) / 2;

int n, lastl, lastr;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    multiset<long long> L, R;
    long long addL = 0, addR = 0;
    long long c = 0;
    L.insert(-INF);
    R.insert(INF);
    for (int i = 0; i < n; i++)
    {
        int l, r;
        cin >> l >> r;
        if (i != 0) addL -= r - l, addR += lastr - lastl;
        lastl = l, lastr = r;
        auto x = L.end();
        x--;
        int Ln = *x + addL;
        auto y = R.begin();
        int R0 = *y + addR;
        if (Ln <= l && l <= R0)
        {
            L.insert(l - addL);
            R.insert(l - addR);
        } else if (l < Ln)
        {
            L.erase(x);
            R.insert(Ln - addR);
            L.insert(l - addL);
            L.insert(l - addL);
            c += Ln - l;
        } else
        {
            R.erase(y);
            L.insert(R0 - addL);
            R.insert(l - addR);
            R.insert(l - addR);
            c += l - R0;
        }
    }
    cout << c;
}


Measured memory_bytes: 9728
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    String s = sc.next();

    sc.close();

    String[] S = s.split("");

    String result = "Yes";

    for (int i = 0; i < S.length; i++) {

      if (S.length != A + B + 1) {
        result = "No";
        break;
      }

      if (i == A && !S[i].equals("-")) {
        result = "No";
        break;
      }

      if (i < A || A < i) {
        if (!S[i].equals("-")) {
          int n_ = Integer.valueOf(S[i]);
          if (n_ < 0 || 9 < n_) {
            result = "No";
            break;
          }
        } else {
          result = "No";
          break;
        }
      }

    }

    System.out.println(result);
  
  }

}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0]!='A'){
    cout << "WA" << endl;
    exit(0);
  }
  if((int)s[1]<97||(int)s[1]>122){
	  cout << "WA" << endl;
	  exit(0);
  }
  int count = 0;
  for(int i = 2; i < s.size()-1; i++){
    if(s[i]=='C')count++;
    if((int)s[1]<97||(int)s[1]>122){
	  cout << "WA" << endl;
	  exit(0);
    }
  }
  if((int)s[s.size()-1]<97||(int)s[s.size()-1]>122){
	  cout << "WA" << endl;
	  exit(0);
  }
  if(count!=1){
    cout << "WA" << endl;
    exit(0);
  }
  cout << "AC" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,a[222],c=0,i;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);

	while(1){
		for(i=0;i<n;i++){
			if(a[i]/2!=a[i]/2.0){
				printf("%d",c);
				return 0;
			}
			a[i]/=2;
		}
		c++;
	}
}

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

Measured memory_bytes: 5196
program next_letter
  implicit none
  integer :: k, n, i, m
  character(100000) :: s
  read(*,*) s
  s = trim(adjustl(s))
  n = len_trim(s)
  read(*,*) k
  do i = 1, n
    m = ichar(s(i:i))-97
    if ((m.eq.0).or.(26-m.gt.k)) cycle
    s(i:i) = 'a'
    k = k - (26-m)
  end do
  if (k.ne.0) then
    m = ichar(s(n:n))-97
    m = mod(k+m,26)
    s(n:n) = achar(m+97)
  end if
  write(*,'(a)') trim(s)
  stop
end program next_letter

Measured memory_bytes: 2596
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,x;
  int i,j,flag=0,flag1=0;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &x);
    if(x%2==0){
      flag++;
      if(x%3==0 || x%5==0)flag1++;
    }
  }
  if(flag==flag1)printf("APPROVED\n");
  else printf("DENIED\n");

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    int num = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0)
        num++;
    }
    if (num == 8)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let tds = Array.init n @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun t d -> t - 1, d in
  Array.sort (fun (_, d) (_, d') -> compare d' d) tds;
  let q = Queue.create () in
  let s = Stack.create () in
  let sum = ref 0 in
  let kind = ref 0 in
  let card = Hashtbl.create n in
  for i = 0 to k - 1 do
    sum := !sum + snd tds.(i);
    Hashtbl.replace card (fst tds.(i))
      (1 + try Hashtbl.find card (fst tds.(i)) with Not_found -> 0);
    if Hashtbl.find card (fst tds.(i)) = 1
    then incr kind
    else Stack.push (snd tds.(i)) s
  done;
  for i = k to n - 1 do
    Hashtbl.replace card (fst tds.(i))
      (1 + try Hashtbl.find card (fst tds.(i)) with Not_found -> 0);
    if Hashtbl.find card (fst tds.(i)) = 1 then Queue.push (snd tds.(i)) q
  done;
  let sat = ref (!sum + !kind * !kind) in
  while not (Stack.is_empty s) && not (Queue.is_empty q) do
    sum := !sum + Queue.pop q - Stack.pop s;
    incr kind;
    sat := max !sat (!sum + !kind * !kind)
  done;
  Printf.printf "%d\n" !sat


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin >> a;
	if(a % 2)
	{
		int temp = 0;
		temp = (a / 2) + 1;
		double ans = (double)temp / (double)a;
		cout << ans << endl;
	}
	else
	{
		cout << 0.5 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import itertools
from scipy.sparse.csgraph import floyd_warshall

n,m,r=map(int,input().split())
r_l=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(m)]

d=[[float('inf')]*n for i in range(n)]
for i in range(n):
    d[i][i]=0
for i in l:
    d[i[0]-1][i[1]-1]=i[2]
    d[i[1]-1][i[0]-1]=i[2]
d=floyd_warshall(d)

ans=10**9
for i in itertools.permutations(r_l):
    t_ans=0
    for j in range(len(i)-1):
        t_ans+=d[i[j]-1][i[j+1]-1]
    ans=min(ans,t_ans)
print(int(ans))

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

int main(void){
    long long N,K,ans;
    cin >> N >> K;
    vector<long long> container(100000);
    // init
    for (long long i = 0; i < 100000;i++){
        container[i] = 0;
    }
    ans = 0;

    for (long long i = 0; i < N; i++){
        long long ai,bi;
        cin >> ai >> bi;
        if (ai >= 1 && ai <= 100000 && bi >= 1 && bi <= 100000){
            container[ai] += bi;
        }
    }

    for (long long i = 0;i < 100000; i++){
        if(0 < K - container[i]){
            ans = i + 1;
        }
        K -= container[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

bool palindromic(int n) {
    int tmp = n;
    int len = 0;
    while (tmp > 0) {
        ++len;
        tmp /= 10;
    }

    string s = to_string(n);
    for (int i = 0; i < len / 2; ++i) {
        if (s[i] != s[len - 1 - i])
            return false;
    }
    return true;
}

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

    int count = 0;
    for (int i = a; i <= b; ++i) {
        if (palindromic(i))
            ++count;
    }
    cout << count << '\n';
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
//↑デフォルト文

int main(){
  int x, a, b;

  cin >> x >> a >> b;
  /*
  x=4 a=3 b=6の場合
  賞味期限4日切れOK
  5日以上はout
  賞味期限3日前に買ってきて,6日後に食べた
  賞味期限きれた三日目に食べたためセーフ
  */

  if(-a + b <= 0) {
    /*if文で一番最初にだすのは'delicious'
    2番目'safe',最後に'dangerous'*/
    cout << "delicious" << endl;
  } else if (-a + b <= x){
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }

}


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

    int main() {
        ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        int n;
        string s;
        cin >> n >> s;
        if (n & 1) {
            cout << "No" << '\n';
            return 0;
        }
        string t = s.substr(0, n / 2);
        if (t + t == s) {
            cout << "Yes" << '\n';
        } else {
            cout << "No" << '\n';
        }
        return 0;
    }

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

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n) 
#define all(a) (a).begin(), (a).end()
#define inf 10000000
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
    int x , y ; cin >> x >> y ;
    cout << ( a [ x ] == a [ y ] ? "Yes" : "No") << endl ;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

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

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

template<typename T>
class Union_Find {
  private:
	vector<T> t, s;

  public:
	explicit Union_Find(T max_length) {
		for (int i = 0; i < max_length + 1; ++i) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(T x, T y) {
		if (same(x, y)) return;
		T tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}
	T Find(T n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(T x, T y) {
		return Find(x) == Find(y);
	}

	T get_Size(size_t a) {
		return s[a];
	}
};

//(ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;
    int n,m;
    cin>>n>>m;
    vector<P> vec(n,{1,false});
    vec[0].second=true;
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        vec[y].first++;
        vec[y].second=max(vec[y].second,vec[x].second);
        vec[x].first--;
        if(vec[x].first==0)vec[x].second=false;
    }
    int ans=0;
    rep(i,n)if(vec[i].second)ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#define ll long long
#define For(i,x,y)  for(ll i=x;i<=y;++i)
#define FOr(i,x,y)  for(ll i=x;i>=y;--i)
#define lf else if
using namespace std;
inline ll read(){   ll 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 void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  } 
inline void writeln(ll x){ write(x);   puts("");   }
const ll N=100100;
ll f[N],a[N],b[N],c[N],n,ans;
int main(){
	n=read();
	For(i,1,n)	a[i]=read();
	For(i,1,n)	b[i]=read();
	For(i,1,n)	c[i]=read();
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	ll p=1;
	For(i,1,n){
		while(c[p]<=b[i]&&p<=n)	++p;
		f[i]=max(n-p+1,0ll);
	}
	FOr(i,n,1)	f[i]+=f[i+1];
	p=1;
	For(i,1,n){
		while(b[p]<=a[i]&&p<=n)	++p;
		ans+=f[p];
	}
	writeln(ans);
}

Measured memory_bytes: 3328
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int ans=0;
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		for(int i=0; i<M; i++) {
			int A = scanner.nextInt();
			ans = ans + A;
		}

		ans = N - ans;
		if(ans >= 0) {
			System.out.println(ans);
		}else {
			System.out.println(-1);
		}

		scanner.close();


	}

}


Measured memory_bytes: 46168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));

		String inputValue = br.readLine();
		String[] inputData = inputValue.split(" ");

		int width = Integer.parseInt(inputData[0]);
		int height = Integer.parseInt(inputData[1]);
		int x = Integer.parseInt(inputData[2]);
		int y = Integer.parseInt(inputData[3]);
		int r = Integer.parseInt(inputData[4]);

		if(r <= x && x <= (width - r) && r <= y && y <= (height - r)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 24372
import numpy as np

n, x = map(int, input().split())
a = np.array(list(map(int, input().split())), dtype=np.int32)

rec = np.zeros((n, n), dtype=np.int32)
for i in range(n):
    a_tmp = np.concatenate([a[i::-1], a[-1:i:-1]])
    np.minimum.accumulate(a_tmp, out=rec[i])

ans = float("inf")
for j in range(n):
    second = rec[:, j].sum() + j * x
    ans = min(ans, second)

print(ans)


Measured memory_bytes: 28012
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scan()
	for i := len(s) - 1; i >= 0; i-- {
		t := s[:i]
		if t[:len(t)/2] == t[len(t)/2:] {
			fmt.Println(i)
			break
		}
	}
}


Measured memory_bytes: 1776
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
//end of libraries ;
#define INF 99999999999
#define N 300003
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n  , x  , c;
int gcd(int x , int y){
	if(x>y) swap(x,y);
	if(x==0) return y;
	else return gcd(y%x,x);
}
vector <int> dif;
int main(){
fcin;

	cin>>n>>x;
	vector<int>a(n);
	for(int i = 0 ; i < n ; i++) cin>>a[i];
	a.pb(x);
	sort(a.begin(),a.end());
	for(int i = 1 ; i < a.size() ; i++){
		dif.pb(a[i]-a[i-1]);
	}
	// sort(dif.begin(),dif.end());
	c = gcd(dif[0],dif[1]);
	for(int i = 2 ; i < dif.size() ; i++){
		c = gcd(c,dif[i]);
	}
	
	cout<<c<<endl;

}

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

using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define dec(i, l, r) for (int i = l; i>=r;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define max(a, b) (((a)<(b))?b:a)
#define min(a, b) ((a>b)?b:a)
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pi 3.141592653589793238
#define inf ((ll)1e18)
#define eps 1e-14
#define mod ((int)1e9+7)
#define maxlg 18
#define maxn 500002
#define left(i) ((i)<<1)
#define right(i) (((i)<<1)+1)
int f[maxn];
vi fre;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
 #endif
    int n,k;
    cin>>n>>k;
    rep (i,0,n) {
        int g;
        cin>>g;
        f[g]++;
    }
    int ans=0;
    rep (i,1,n+1)
    {
        if (f[i]!=0)
            fre.push_back(f[i]),ans+=f[i];
    }
    sort(all(fre));
    reverse(all(fre));
    int t=0;
    rep (i,0,min(fre.size(),k)) {
        ans-=fre[i];
    }
    cout<<ans;
    return 0;
}








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

int main() {
  int N;
  cin >> N;
  int R = 0;

  // ここにプログラムを追記
  for ( int i = 0; i < N; i++ ) {
    int l, r;
    cin >> l >> r;
    R += r - l + 1;
  }
  cout << R << endl;  
}


Measured memory_bytes: 256
//
//  code.cpp
//  Cpp
//
//  Created by Yash Jain on 25/02/20.
//  Copyright © 2020 Yash Jain. All rights reserved.
//

#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int degree[200001];
long long fact[200001];

long long powermod(long long a,long long b){
    if(b == 0)
        return 1;
    if(b%2 == 1)
        return (a*(powermod((a*a)%mod,b/2)))%mod;
    return powermod((a*a)%mod, b/2);
}

long long ncr(long long a,long long b){
    long long temp = (fact[a]*powermod(fact[b],mod-2))%mod;
    temp = (temp*powermod(fact[a-b],mod-2))%mod;
    return temp;
}

int main(){
    
    long long x;
    cin>>x;
    
    cout<<(x/500)*1000+((x%500)/5)*5;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	vector<int> a(n), b(n);
	map<char, int> sm, tm;
	rep(i, n) {
		if(!sm.count(s[i])) {
			sm[s[i]] = sm.size()+1;
		}
		a[i] = sm[s[i]];
	}
	rep(i, n) {
		if(!tm.count(t[i])) {
			tm[t[i]] = tm.size()+1;
		}
		b[i] = tm[t[i]];
	}
	if(a == b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 2312
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

int main(){
    int n;
    cin>>n;
    
    vector<int> a(n);
    int min_,max_;
    long sum;
    REP(i,n){
        cin>>a[i];
        if(i==0){
            min_=a[i];
            max_=a[i];
            sum=a[i];
        }else{
            min_=min(min_,a[i]);
            max_=max(max_,a[i]);
            sum+=a[i];
        }
    }
    
    cout<<min_<<" "<<max_<<" "<<sum<<endl;
    
    
}


Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
int a,b,c,ans;
int main(void){
    cin>>a>>b>>c;
    int x=max(a,max(b,c)),z=min(a,min(b,c)),y=a+b+c-x-z;
    ans=(y-z)/2+x-y;
    if((y-z)%2)ans+=2;
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int n,m,a,b;
    cin>>n>>m;
    int arr[n+1]={0};
    for(int i=1;i<=m;i++)
    {
        cin>>a>>b;
        arr[a]++;
        arr[b]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<arr[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n;cin >> n;
    vector<P> v(n);
    LL lb=0,ra=1e9;
    for (int i = 0; i < n; i++) {
        cin >> v[i].fs >> v[i].sc;
    }
    sort(ALL(v));
    LL a = 0, b = 0;
    LL xx = 0, x = 0;
    for (int i = 0; i < n; i++) {
        if(lb < v[i].fs){
            lb = max(lb,v[i].fs);
            b = i;
        }
        if(ra > v[i].sc){
            ra = min(ra,v[i].sc);
            a = i;
        }
    }
    vector<P> pa(n),pb(n);
    LL aa = 0,bb = 1e9;
    for (int i = 0; i < n; i++) {
        aa = max(aa,v[i].fs);
        bb = min(bb,v[i].sc);
        pa[i] = mp(aa,bb);
    }
    aa = 0,bb = 1e9;
    for (int i = n-1; i >=0; i--) {
        aa = max(aa,v[i].fs);
        bb = min(bb,v[i].sc);
        pb[i] = mp(aa,bb);
    }
    for (int i = 0; i < n; i++) {
        LL ca=0,cb=1e9;
        if(i+1<n) ca = max(ca,pb[i+1].fs);
        if(0<=i-1) ca = max(ca,pa[i-1].fs);
        if(i+1<n) cb = min(cb,pb[i+1].sc);
        if(0<=i-1) cb = min(cb,pa[i-1].sc);
        xx = max(xx,v[i].sc - v[i].fs + 1 + max(0LL,cb-ca+1));
    }
    if(a==b){
        LL t = 0;
        for (int i = 0; i < n; i++) {
            if(i==a) continue;
            t = max(t,v[i].sc - v[i].fs + 1);
        }
        cout << t + v[a].sc - v[a].fs + 1 << endl;
        return 0;
    }
    vector<LL> l(n+1),r(n+1);
    LL ll = v[a].fs;
    l[0] = ll;
    for (int i = 0; i < n; i++) {
        if(i!=b) ll = max(ll,v[i].fs);
        l[i+1] = ll;
    }
    LL rr = v[b].sc;
    r[n] = rr;
    for (int i = n-1; i >= 0; i--) {
        if(i!=a) rr = min(rr,v[i].sc);
        r[i] = rr;
    }
    LL ans = xx;
    for (int i = 0; i < n; i++) {
        ans = max(ans, max(0LL,ra-l[i+1]+1) + max(0LL,r[i+1]-lb+1));
    }
    for (int i = 0; i < n; i++) {
        swap(v[i].fs,v[i].sc);
    }
    ll = v[a].fs;
    l[0] = ll;
    for (int i = 0; i < n; i++) {
        if(i!=b) ll = max(ll,v[i].sc);
        l[i+1] = ll;
    }
    rr = v[b].sc;
    r[n] = rr;
    for (int i = n-1; i >= 0; i--) {
        if(i!=a) rr = min(rr,v[i].fs);
        r[i] = rr;
    }
    for (int i = 0; i < n; i++) {
        ans = max(ans, max(0LL,ra-l[i+1]+1) + max(0LL,r[i+1]-lb+1));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 7040
#include <stdio.h>
#include <assert.h>
int n,i,j,x,a[10][10],list[200][3],size;
void push(int x,int y,int s){list[size][0]=i;list[size][1]=j;list[size][2]=s;size++;}

int check(int x,int y,int s){
	int d;
	if(s<3 && (x<1 || x>9 || y<1 || y>9)) return 0;
	if(s==3 && (x<2 || x>8 || y<2 || y>8)) return 0;
	d=a[x][y];
	if(a[x-1][y]<d)d=a[x-1][y];
	if(a[x+1][y]<d)d=a[x+1][y];
	if(a[x][y-1]<d)d=a[x][y-1];
	if(a[x][y+1]<d)d=a[x][y+1];
	if(s==1 || d==0)return d;
	if(a[x-1][y-1]<d)d=a[x-1][y-1];
	if(a[x+1][y+1]<d)d=a[x+1][y+1];
	if(a[x+1][y-1]<d)d=a[x+1][y-1];
	if(a[x-1][y+1]<d)d=a[x-1][y+1];
	if(s==2 || d==0)return d;
	if(a[x-2][y]<d)d=a[x-2][y];
	if(a[x+2][y]<d)d=a[x+2][y];
	if(a[x][y-2]<d)d=a[x][y-2];
	if(a[x][y+2]<d)d=a[x][y+2];
	return d;
}

void draw(int x,int y,int s,int d){
	if(size==3 && (x<2 || x>8 || y<2 || y>8)) return;
	a[x][y]+=d;
	a[x-1][y]+=d;
	a[x+1][y]+=d;
	a[x][y-1]+=d;
	a[x][y+1]+=d;
	if(s==1)return;
	a[x-1][y-1]+=d;
	a[x+1][y+1]+=d;
	a[x+1][y-1]+=d;
	a[x-1][y+1]+=d;
	if(s==2)return;
	a[x-2][y]+=d;
	a[x+2][y]+=d;
	a[x][y-2]+=d;
	a[x][y+2]+=d;
}

int search(int nn,int from){
	int i,x,y,s,t;
	for(i=from;i>=0;i--){
		x=list[i][0];y=list[i][1];s=list[i][2];
		if(a[x][y]==0 && a[x+1][y]>0)return 0;
		if(x<8){
		if(s<3 && a[x+2][y]>0)return 0;
		if(y==1 && a[x+2][y-1]>0)return 0;
		}
		if(y==1 && s<2 && a[x+1][y-1]>0)return 0;
        if(y==8 && s<2 && a[x+1][y+1])return 0;
		t=check(x,y,s);
		if(t>0){
			draw(x,y,s,-t);
			for(;t>0;t--){
				//if(s==1 && a[x+1][y+1]>0 && check(x-1,y+1,3)==0){draw(x,y,s,+1);return 0;}
				if(nn-t>0){
					if(search(nn-t,i-1)>0){goto answer;}
				}else{
					int p,q;
					for(p=0;p<10;p++)for(q=0;q<10;q++){{if(a[p][q]!=0)goto miss;}}
					goto answer;
					miss:;
				}
				draw(x,y,s,+1);
			}
		}
	}
	return 0;

	answer:
	for(;t>0;t--)printf("%d %d %d\n",y,x,s);
	return 1;
}

int main(void){
	scanf("%d",&n);size=0;
	for(i=0;i<10;i++){for(j=0;j<10;j++){scanf("%d",&a[i][j]);}}
	for(i=1;i<9;i++){
		for(j=1;j<9;j++){
			x=check(i,j,1); if(x==0)continue; push(i,j,1);
			x=check(i,j,2); if(x==0)continue; push(i,j,2);
			x=check(i,j,3); if(x==0)continue; push(i,j,3);
		}
	}
	/*
	 if(a[i][j]>5){
	 fprintf(stderr,"%3d\n",n);
	 for(i=0;i<10;i++){for(j=0;j<10;j++){fprintf(stderr,"%3d",a[i][j]);}fprintf(stderr,"\n");}fprintf(stderr,"\n");
	 assert(0);
	 }*/
	//for(i=0;i<size;i++)printf("%d %d %d\n",list[i][0],list[i][1],list[i][2]);
	search(n,size-1);
	return 0;
}

Measured memory_bytes: 600
S="abcdefghijklmnopqrstuvwxyz"
s=input()
n=len(s)
flag=0
if s[0]!="A":
    flag=1
cut=s[2:n-1]
if cut.count("C")!=1:
    flag=1
else:
    cut=s[1:]
    for c in cut:
        if ((not c in S) and c!="C"):
            flag=1
            break

if flag:
    print("WA")
else:
    print("AC")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,s,n) for(ll i=(s);i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;

vin par(100010);
vin deep(100010);
void init(int n);
int root(int x);
void unite(int x,int y);
bool same(int x,int y);
vector<tuple<int,int,int>> edge(200010);
int n;

int kruskal(){
    sort(all(edge));
    init(n);
    int res=0;
    for(auto hen:edge){
        if(!same(get<1>(hen),get<2>(hen))){
            unite(get<1>(hen),get<2>(hen));
            res+=get<0>(hen);
        }
    }
    return res;
}

int main(){
    cin>>n;
    vpii tmpx(n);
    vpii tmpy(n);
    rep(i,n){
        int x,y;cin>>x>>y;
        tmpx[i]=mp(x,i+1);
        tmpy[i]=mp(y,i+1);
    }
    sort(all(tmpx));
    sort(all(tmpy));
    rep(i,n-1)edge[i]=make_tuple(tmpx[i+1].first-tmpx[i].first,tmpx[i].second,tmpx[i+1].second);
    rep(i,n-1)edge[n-1+i]=make_tuple(tmpy[i+1].first-tmpy[i].first,tmpy[i].second,tmpy[i+1].second);
    cout<<kruskal()<<endl;
}

void init(int n){
    rep(i,n){
        par[i]=i;
        deep[i]=0;
    }
}
int root(int x){
    if(par[x]==x)return x;
    else return par[x]=root(par[x]);
}
void unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y)return;
    if(deep[x]<deep[y])par[x]=y;
    else{
        par[y]=x;
        if(deep[x]==deep[y])deep[x]++;
    }
}
bool same(int x,int y){
    return root(x)==root(y);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 4) if (s[i] == '2') ans++;
    cout << ans << endl;
    return 0;
}


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

int main() {
	long long n, w;
	std::cin >> n >> w;

	std::vector<std::vector<int>> values(4);

	long long w1, v1;
	std::cin >> w1 >> v1;
	values[0].push_back(v1);

	for (int i = 1; i < n; i++) {
		long long w, v;
		std::cin >> w >> v;
		values[w - w1].push_back(v);
	}

	for (int i = 0; i < 4; i++) {
		std::sort(values[i].rbegin(), values[i].rend());
	}

	std::vector<std::vector<long long>> sum(4);
	for (int i = 0; i < 4; i++) {
		sum[i].assign(values[i].size() + 1, 0);
		for (int j = 0; j < values[i].size(); j++) {
			sum[i][j + 1] = sum[i][j] + values[i][j];
		}
	}

	long long ans = 0;
	for (int i = 0; i <= values[0].size(); i++) {
		for (int j = 0; j <= values[1].size(); j++) {
			for (int k = 0; k <= values[2].size(); k++) {
				for (int l = 0; l <= values[3].size(); l++) {
					if (i * w1 + j * (w1 + 1) + k * (w1 + 2) + l * (w1 + 3) <= w) {
						ans = std::max(ans, sum[0][i] + sum[1][j] + sum[2][k] + sum[3][l]);
					}
				}
			}
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	FastIO
	lld a, b, c;
	cin >> a >> b >> c;
	lld x = a-b;
	if (c-x >= 0)
		cout << (c-x);
	else
		cout << "0";
	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

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

  string S;
  cin >> S;
  if (S == "SUN") {
    cout << 7 << endl;
  } else if (S == "MON") {
    cout << 6 << endl;
  } else if (S == "TUE") {
    cout << 5 << endl;
  } else if (S == "WED") {
    cout << 4 << endl;
  } else if (S == "THU") {
    cout << 3 << endl;
  } else if (S == "FRI") {
    cout << 2 << endl;
  } else if (S == "SAT") {
    cout << 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    S = input()

    for i in range(len(S)):
        target = S[i]
        for j in range(i+1, len(S)):
            if target != S[j]:
                continue
            print("no")
            return
    print("yes")


if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int A[100001], B[100000];
	rep(i, N + 1) cin >> A[i];
	rep(i, N) cin >> B[i];

	ll kotae = 0;
	rep(i, N) {
		if (B[i]) {
			int k = min(A[i], B[i]);
			B[i] -= k;
			kotae += k;
		}

		if (B[i]) {
			int k = min(A[i + 1], B[i]);
			A[i + 1] -= k;
			B[i] -= k;
			kotae += k;
		}

	}

	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 1024
x, k, d = map(int, input().split())
x = abs(x)

t = x/d

 
if t >= k:
    print(abs(x - (k*d)))
    
elif (k-int(t))%2==0:
    print(abs(x-abs(int(t)*d)))
    
else:
    print(abs(x-abs(int(t)*d)-d))

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

class Mod{
    static final long MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long adds(long... ar){
        long ans=0;
        for(long x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long mults(long... ar){
        long ans=1;
        for(long x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

}

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

        int allPie = 0;
        int smallApple = 100000000;
        for(int n=1; n<=N; n++){
            int apple = L+n-1;
            allPie += apple;
            if(Math.abs(apple)<Math.abs(smallApple)) smallApple=apple;
        }
        System.out.println(allPie-smallApple);
    }
}

Measured memory_bytes: 23252
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

N = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip().split()

if len(set(S)) == 3:
    print('Three')
else:
    print('Four')


Measured memory_bytes: 15632
//author: zekigurbuz (Zeki Gurbuz) 2020
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;

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

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define all(x) begin(x),end(x)

const int N = 1e5 + 10;
const int M = 1e9 + 7;

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

template<class T>void ckmin(T&a,T b){a=min(a,b);}
template<class T>void ckmax(T&a,T b){a=max(a,b);}

void precomp() {

}


void solve() {
	bool works = false;
	int k, a, b; cin >> k >> a >> b;
	for (int i = a; i <= b; i++) if (i % k == 0) works = true;
	cout << (works ? "OK" : "NG") << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	precomp();
	int t = 1; // cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}



Measured memory_bytes: 3620
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	task(n)
}

func task(x int) {
	for i := -118; i < 120; i++ {
		for j := -119; j < 119; j++ {
			if (i*i*i*i*i)-(j*j*j*j*j) == x {
				fmt.Print(i)
				fmt.Print(" ")
				fmt.Println(j)
				return
			}
		}
	}
}


Measured memory_bytes: 1752
#include<iostream>
#include<cstdio>
#include<ctype.h>
#include<algorithm>
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int main(){
    int a=read();
    for(int i=6;i>=0;--i)
        if((1<<i)<=a){
            cout<<(1<<i)<<endl;
            return 0;
        }
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		while(a[i] % 2 == 0)
		{
			a[i] /= 2;
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))
max = 0
list = [0] * k
evlist = [0] * 1000
for i in range(1000):
    wk = 0
    for j in range(i + 1):
        wk += j + 1
    evlist[i] = float(wk / (i + 1))
wk = 0
start = 0
for i in range(n - (k - 1)):
    if wk == 0:
        for j in range(i, i + k):
            wk += p[j]
    else:
        wk += p[i + k - 1]
        wk -= p[i - 1]
    if max < wk:
        max = wk
        start = i
for i in range(start, start + k):
    list[i - start] = p[i]
ans = 0
for i in range(k):
    ans += evlist[list[i] - 1]
print(ans)

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

int main(){

  int a, b;
  char op;

  while(1){
    cin >> a >> op >> b;
    if(op == '?')
      break;
    else if(op == '+')
      cout << a+b << endl;
    else if(op == '-')
      cout << a-b << endl;
    else if(op == '*')
      cout << a*b << endl;
    else if(op == '/')
      cout << a/b << endl;
  }

  return 0;
}

Measured memory_bytes: 3100
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

def op(i,j,p):
    if p == 0:
        return i + j
    elif p == 1:
        return i - j
def sign(p):
    if p == 1:
        return "-"
    elif p == 0:
        return "+"
for p in range(2):
    x = op(a,b,p)
    for q in range(2):
        y = op(x,c,q)
        for r in range(2):
            if op(y,d,r) == 7:
                break
        else:
            continue
        break
    else:
        continue
    break
print(str(a)+sign(p)+str(b)+sign(q)+str(c)+sign(r)+str(d)+"=7")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const long INF=1000000000000;

//関数



int main() {
    
    
    //入力
    long N;
    cin>>N;
    vector<long> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    
    //計算
    set<long> paper;
    
    for(int i=0;i<N;i++){
        if(paper.count(A.at(i))) paper.erase(A.at(i));
        else paper.insert(A.at(i));
    }
    
    //出力
    cout<<paper.size()<<endl;
}

Measured memory_bytes: 5760
using System;

namespace abc164_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] sw = Console.ReadLine().Split(" ");
            int s = int.Parse(sw[0]);
            int w = int.Parse(sw[1]);

            if(w >= s)
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }
    }
}


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

int main() {
	int N; cin >> N;
	int l[210];
	for(int i=0; i<2*N; ++i) cin >> l[i];
	sort(l, l+2*N);
	int S=0;
	for(int i=0; i<N; ++i) S += l[2*i];
	cout << S << endl;
	return 0;
}


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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 2*(int)1e5+100;
int n, a[maxn];
unordered_map<int, int> cnt;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> n;
    i64 ans = 0;
    for1(i, n) {
        cin >> a[i];
        //cerr << i << ' ' << i-a[i] << ' ' << a[i]+i << endl;
        ans += cnt[i-a[i]];;
        ++cnt[a[i]+i];
    }
    cout << ans << '\n';


#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 19236
program probB
  implicit none
  integer*8 a,b,k
  integer*8 i,j,tmp

  read(*,*) a,b,k
  
  do i=0,k-1
     if ( a+i <= b ) then
        write (*,*) a+i
     end if
  end do

  tmp = a+i-1

  do i = k-1,0,-1
     if(b-i>tmp) write (*,*) b-i
  end do
     
end program probB


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a+b==15)printf("+");
	else if(a*b==15)printf("*");
	else printf("x");
	return 0;
} 

Measured memory_bytes: 256
import math
n, m = map(int, input().split())
kotae=1
for i in range(1,int(math.sqrt(m))+1):
 if m%i==0:
  if i*n<=m:
   kotae=max(kotae, i)
  if (m//i)*n<=m:
   kotae=max(kotae, m//i)
print(kotae)

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);
    if(x%(y+z)>=z){
        x /= (y+z);
    }else{
        x /= (y+z);
        x--;
    }
    printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a+b<a-b){
    if(a-b<a*b)
      printf("%d\n",a*b);
    else
      printf("%d\n",a-b);
  }else{
    if(a+b<a*b)
      printf("%d\n",a*b);
    else
      printf("%d\n",a+b);
  }
    return 0;
}

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

using namespace std;

char a[52],b[52];

int main(){
    cin>>a;
    cin>>b;
    int la=strlen(a),lb=strlen(b);
    int l=min(la,lb),ll=max(la,lb);
    for(int i=0;i<=l-1;i++)
        cout<<a[i]<<b[i];
    if(la>lb)
        for(int i=l;i<=ll-1;i++)
            cout<<a[i];
    else for(int i=l;i<=ll-1;i++)
            cout<<b[i];
    return 0;
}

Measured memory_bytes: 256
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define ff fflush(stdout)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	int n,k;
	cin>>n;
	cin>>k;
	int res=0;
	rb(i,1,n){
		int ai;
		cin>>ai;
		if(ai>=k) res++;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;
template <typename T = vii> 
using vec = vector<T>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    
    int n; cin >> n;
    vii v(n);
    for (auto &e : v) {
        cin >> e;
    }
    vii s(n + 1, 0);
    for (int i = n - 1; i >= 0; i--) {
        s[i] = __gcd(s[i + 1], v[i]);
    }
    int res(s[0]);
    for (int i(0), p(0); i < n; i++) {
        int g = __gcd(p, s[i + 1]);
        res = max(g, res);
        p = __gcd(p, v[i]);
    }
    cout << res << '\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    cout << A[A.size()-1] - A[0] << endl;
}

Measured memory_bytes: 256
import sys


sys.setrecursionlimit(300000)

to = [[] for _ in range(200005)]
ans: list


def dfs(v, p=-1):
    global ans
    for u in to[v]:
        if u == p: continue
        ans[u] += ans[v]
        dfs(u, v)
    return


def main():
    N, Q = map(int, input().split())
    for _ in range(N-1):
        a, b = map(int, input().split())
        to[a-1].append(b-1)
        to[b-1].append(a-1)
    global ans
    ans = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        ans[p-1] += x
    dfs(0)
    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 282932
def main(argv)
  n = gets.chomp.to_i
  v = gets.chomp.split(' ').map(&:to_f)
  
  v.sort!
  x = v[0]
  (1...n).each do |i|
    x = (x + v[i]) / 2
  end
  puts x.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
import collections
N = int(input())
a = list(int(i) for i in input().split())
chk = sum(a)
if a == [0] *N:
	print("Yes")
else:
	if N == 3:
			if (a[0]^a[1]) == a[2]:
				print("Yes")
			else:
				print("No")
	else:
		l = collections.Counter(a)
		if a.count(0) == 0:
			if list(l.values()) ==  [list(l.values())[0]] * len(l.values()) and len(l.keys()) == 3:
				if ((list(l.keys())[0])^(list(l.keys())[1])) == list(l.keys())[2]:
					print("Yes")
				else:
					print("No")
			else:
				print("No")
		else:
			if len(l.values()) == 2 and a.count(0) == N//3:
				print("Yes")
			else:
				print("No")

Measured memory_bytes: 14460
#include <bits/stdc++.h>
#define INF 0x7fffffff
#define MAXN 100010
#define MOD 1000000007
#define int long long
using namespace std;
inline int read(){
	int ret=0,pos=1;char c=getchar();
	while(!isdigit(c) && c!='-' ) c=getchar();
	if(c=='-')	pos=-1,c=getchar();
	while(isdigit(c))ret=(ret<<3)+(ret<<1)+c-48,c=getchar();
	return pos*ret;
}
inline int fst_pow(int a,int b){
	int ret=1;
    for(;b;b>>=1,a=(a*a)%MOD)	if(b&1)	ret=a*ret%MOD;
    return ret;
}
int a[MAXN];
int n,r;
signed main(){
	n=read(),r=read();
	if(n>=10) cout<<r<<endl;
	else{
		cout<<r+100*(10-n)<<endl;
	}
}


Measured memory_bytes: 256