akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int N, A, B;
    cin >> N >> A >> B;

    vector<int> P;
    inputVector(P, N);

    int cnt[3] = { 0, 0, 0 };

    rep(i, N) {
        if (P[i] <= A) cnt[0]++;
        else if (P[i] <= B) cnt[1]++;
        else cnt[2]++;
    }

    cout << min({cnt[0], cnt[1], cnt[2]}) << endl;

    return 0;
}


Measured memory_bytes: 256
import itertools
n = input()
m = len(n)

cn = 0
for i in range(3,m+1):
    for l in itertools.product(["5","7","3"],repeat = i):
        l = "".join(l)
        if int(l) > int(n): continue
        cn += 1 if "3" in l and "5" in l and "7" in l else 0
print(cn)

Measured memory_bytes: 3060
import java.util.*;

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

        for(int i = 1;i <= num;i++){
            int cnt = 0;
            if(i%2 != 0){
                for(int j = i;j > 0;j--){
                    if(i % j == 0){
                        cnt++;
                    }
                }
                if(cnt == 8)
                ans++;
            }
        }

        System.out.println(ans);
        
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<ll> a(N);
  for(int i=0;i<N;i++)  cin >> a.at(i);

  vector<vector<pair<ll,ll>>> dp(N+1,vector<pair<ll,ll>>(N+1,mp(1e18,1e18)));
  for(int i=0;i<N+1;i++)  dp.at(i).at(i)=mp(0,0);
  for(int i=0;i<N;i++)  dp.at(i).at(i+1)=mp(0,a.at(i));
  for(int length=0;length<N+1;length++){
    for(int l=0;l+length<N+1;l++){
      int r=l+length;
      for(int m=l+1;m<r;m++){
        ll tmp1=dp.at(l).at(m).fi+dp.at(m).at(r).fi;
        ll tmp2=dp.at(l).at(m).se+dp.at(m).at(r).se;
        if(dp.at(l).at(r).fi>tmp1+tmp2){
          dp.at(l).at(r).fi=tmp1+tmp2;
          dp.at(l).at(r).se=tmp2;
        }
      }
    }
  }
  cout << dp.at(0).at(N).fi << endl;

  return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>

using namespace std;

int main(){

    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    S[K - 1] = tolower(S[K - 1]);

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt(), b= in.nextInt();
        int c = b - a;
        int sum = (c * (c - 1)) / 2;
        System.out.println(sum - a);
    }
}


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

typedef long int32;
typedef unsigned long uint32;
typedef long long int64;
typedef unsigned long long uint64;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rFOR(i,a,b) for(int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x,n) FOR(i,0,n) cout << x[i] << " "; cout << endl

// Custom global variable 



// ----------------------
auto main() -> int
{
  #ifdef DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
  #endif
  // Fast I/O
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  // Code starts here ---


  int n;
  cin >> n;

  vi arr(n);
  for(auto &i:arr) cin >> i;
  int res = 0;
  for(int i = 1; i < n-1; i++) {
    if( arr[i] != min(arr[i], min(arr[i+1], arr[i-1])) && arr[i] != max(arr[i], max(arr[i+1], arr[i-1])))
        res++;
  }
  cout << res;

  // ---------------------
  #ifdef DEBUG
    cerr << endl << "Time:" << double(clock())/CLOCKS_PER_SEC << " secs" << endl;
  #endif
}


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

int main(){
	int a[3], x=0, y=0, z=0;
	while( scanf(" %d %d %d", &a[0], &a[1], &a[2]) != EOF ){
		sort(a, a+3);
		if(a[2]>=a[0]+a[1]) break;
	
		if(a[2]*a[2] == a[0]*a[0]+a[1]*a[1]) ++x;
		else if(a[2]*a[2] < a[0]*a[0]+a[1]*a[1]) ++y;
		else ++z;
	
	}
	
	printf("%d %d %d %d\n", x+y+z, x, y, z);

	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) REP(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
typedef long long ll;

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




Measured memory_bytes: 256
n,x0 = map(int, input().split())
xs = map(int, input().split())
ys = [abs(x-x0) for x in xs]


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

for i,y in enumerate(ys):
  if i==0:
    y0 = y
  else:
    y0 = gcd(y,y0)
print(y0)

Measured memory_bytes: 14252
A, B = gets.split.map(&:to_i)
outlet = 1
ans = 0

# 差込口がB以上になるまで
while outlet < B do
  # 差込口を1口使ってA口増やす
  outlet += (A - 1)
  # 電源タップを増やす
  ans += 1
end

puts ans


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long W = scn.nextLong();
		long[] weight = new long[100*100+1];
		for(int i = 0;i <= 100*100;i++) {
			weight[i] = Long.MAX_VALUE;
		}
		weight[0] = 0;
		for(int i = 0;i < N;i++) {
			int v = scn.nextInt();
			long w = scn.nextLong();
			for(int j = 10000;j >= v ;j--) {
				if(weight[j-v]!=Long.MAX_VALUE)weight[j] = Math.min(weight[j], weight[j-v] + w);
			}
		}

		for(int i = 10000;i>=0;i--) {
			if(weight[i] <= W) {
				System.out.println(i);
				break;
			}
		}
		scn.close();
	}
}



Measured memory_bytes: 27448
import itertools
N=int(input())
d=list(map(int,input().split()))
ls=[]
for i in range(N):
    ls.append(i)
lsp=list(itertools.permutations(ls,2))
#print(lsp)
ans=0
#print(lsp[])
for i in range(len(lsp)):
    ans += d[lsp[i][0]]*d[lsp[i][1]]
print(ans//2)


Measured memory_bytes: 64120
use std::io;


/// https://beta.atcoder.jp/contests/abc084/tasks/abc084_b
fn main() {
    let (a, b) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let s = read_one::<String>().chars().collect::<Vec<char>>();
    let mut flg = true;
    if s[a] != '-' { flg = false; }
    for i in 0..(a + b + 1) {
        if i == a { continue; }
        if !('0' <= s[i] && s[i] <= '9') { flg = false; }
    }

    if flg { println!("Yes"); }
    else { println!("No"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
int main() {
	int H1, M1, H2, M2, K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;
	int fast = H1 * 60 + M1;
	int second = H2 * 60 + M2;
	cout << second - fast - K << endl;
	return 0;
}



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

map<char, bool> mp;

int main() {
  int N, ans = 0;
  char c;
  
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> c;
    if (!mp[c]) {
      ans++;
      mp[c] = true;
    }
  }
  
  if (ans == 3) cout << "Three" << endl;
  else cout << "Four" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 99999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long  int ll;

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

ll h,w;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >>s;
  ll m[26];
  REP(i,26) m[i]=0;
  REP(i,s.length()){
    if(m[int(s[i]-'a')]!=0){
      cout <<"no" <<endl;
      return 0;
    }else{
      m[int(s[i]-'a')]++;
    }
  }
  cout <<"yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <limits>

template <typename T>
void vc(T t) {
    std::cout << t << " ";
}

template<typename T, typename... Args>
void vc(T t, Args... args) {
// recursive variadic function
    std::cout << t << " ";
    vc(args...) ;
}

const int N = 100000;
long long dp[101][100001];
long long dpf(const std::vector<int>& vw, const std::vector<long long>& vv, int w, int r, int n) {
  for (int wi = 0; wi <= w; ++wi) {
    for (int i = n; i > 0; --i) {
      if (i == n) {
        if (wi >= vw[i]) {
          dp[i][wi] = vv[i];
        } else {
          dp[i][wi] = 0;
        }
        // vc("+1 ", i, wi, dp[i][wi], "\n");
      } else {
        if (wi >= vw[i]) {
          dp[i][wi] = std::max(dp[i + 1][wi], dp[i + 1][wi - vw[i]] + vv[i]);
        } else {
          dp[i][wi] = dp[i + 1][wi];
        }
        // vc("+2 ", i, wi, dp[i][wi], "\n");
      }
    }
  }
  return dp[1][w];
}

void once() {
  int n, w;
  std::cin >> n >> w;
  std::vector<int> vw(n + 1);
  std::vector<long long> vv(n + 1);
  for (int i = 1; i <= n; ++i) {
    std::cin >> vw[i] >> vv[i];
  }
  // vc("return , r, w, dp[r][w], \n");
  std::cout << dpf(vw, vv, w, 1, n) << std::endl;
}

int
main() {
  int n = 1;
  std::ios::sync_with_stdio(false);
  // std::cin >> n;
  while (n--) {
    once();
  }
}

Measured memory_bytes: 78336
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int n;
    cin>>n;
    vll v(n);
    rep(i,n)cin>>v[i];
    
    int _;
    cin>>_;
    while(_--){
        int b,e,k;
        cin>>b>>e>>k;
        int ans=0;
        for(int i=b;i<e;i++)if(v[i]==k)ans++;
        fin(ans);
    }
}




Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	vi points;
	int N,sum = 0;
	cin>>N;
	for(int i = 0; i < N; i++){
		int k;
		cin>>k;
		sum += k;
		points.push_back(k);
	}
	sort(points.begin(),points.end());
	//for(auto& s:points)cout<<s<<endl;
	int i = 0;
	while(sum % 10 == 0){
		while(points[i] % 10 == 0){
			i++;
			if(i >= points.size())break;
		}
		if(i >= points.size())break;
		sum -= points[i];
		i++;
	}

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


Measured memory_bytes: 256
N, T = map(int, input().split())
ntlist = []
for i in range(N):
	ntlist.append(list(map(int, input().split())))

route = []
cnt = 0
for i in range(N):
	if ntlist[i][1] <= T:
		route.append(ntlist[i][0])
	else:
		cnt += 1

if cnt == N:
	print("TLE")
	exit()
	
print(min(route))


Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.HashSet;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n;
        String x, y;
        n = sc.nextInt();
        HashSet<String> hs = new HashSet<String>();
        for(int i=0;i<n;i++){
            x = sc.next();
            if(x.equals("insert")){
                y = sc.next();
                hs.add(y);
            }else if(x.equals("find")){
                y = sc.next();
                if(hs.contains(y)){
                    System.out.println("yes");
                }else{
                    System.out.println("no");
                }
            }
        }
    }
}


Measured memory_bytes: 216284
use std::cmp;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let ab = (0..n)
        .map(|_| (sc.read::<usize>(), sc.read::<usize>()))
        .collect::<Vec<_>>();
    let left_sum = ab.iter().map(|&(a, _)| a).sum::<usize>();
    let right_sum = ab.iter().map(|&(_, b)| b).sum::<usize>();

    let mut v = vec![];
    for i in 0..n {
        let (a, b) = ab[i];
        v.push((a, i, true));
        v.push((b, i, false));
    }
    v.sort();

    let mut count = vec![0; n];
    let mut sum = 0;
    for i in 0..n {
        let (v, i, _) = v[i];
        sum += v;
        count[i] += 1;
    }

    let mut ans = cmp::min(left_sum, right_sum);
    if count.iter().any(|&x| x == 2) {
        ans = cmp::min(ans, sum);
    } else if v[n - 1].1 != v[n].1 {
        ans = cmp::min(sum - v[n - 1].0 + v[n].0, ans);
    } else {
        if v[n - 2].1 != v[n].1 {
            ans = cmp::min(ans, sum - v[n - 2].0 + v[n].0);
        }
        if v[n - 1].1 != v[n + 1].1 {
            ans = cmp::min(ans, sum - v[n - 1].0 + v[n + 1].0);
        }
    }

    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 14588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String str = sc.next();
		int cnt=0;

		for(int i=0; i<n-2;i++) {
			char ch = str.charAt(i);
			if(ch == 'A' ) {
				if(str.charAt(i+1)=='B') {
					if(str.charAt(i+2) == 'C') {
						cnt++;
					}
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23892
#include <stdio.h>

void insertionSort(int a[],int N){
  int i,j,k,temp;

  for(i=1;i<N;i++){
    temp=a[i];
    for(j=i;j>0&&a[j-1]>temp;j--){
      a[j]=a[j-1];
    }
    a[j]=temp;
    for(k=0;k<N;k++){
      if(k>0)printf(" ");
      printf("%d",a[k]);
    }
    printf("\n");
  }
}

int main(void){
  int n,a[1000],i;

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

  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");

  insertionSort(a,n);

  return 0;
}

Measured memory_bytes: 1756
#include <stdio.h>

#define N_MAX 10000000

char is_sosuu[N_MAX+1];
int query_answer_num;
int query_answer[N_MAX+1];

void make_sosuu_list(void) {
	int i,j;
	for(i=0;i<=N_MAX;i++)is_sosuu[i]=1;
	is_sosuu[0]=is_sosuu[1]=0;
	for(i=2;i<=N_MAX;i++) {
		if(is_sosuu[i]) {
			for(j=i+i;j<=N_MAX;j+=i)is_sosuu[j]=0;
		}
	}
}

void make_query_answer(void) {
	int i;
	for(i=13;i<=N_MAX;i++) {
		if(is_sosuu[i] && is_sosuu[i-2] &&
				is_sosuu[i-6] && is_sosuu[i-8]) {
			query_answer[query_answer_num++]=i;
		}
	}
}

int get_query_answer(int input) {
	int left,right,mid;
	left=0;right=query_answer_num-1;
	while(left<=right) {
		mid=(left+right)/2;
		if(query_answer[mid]==input)return query_answer[mid];
		else if(query_answer[mid]<input)left=mid+1;
		else right=mid-1;
	}
	return left>0?query_answer[left-1]:0;
}

int main(void) {
	int input;
	make_sosuu_list();
	make_query_answer();
	while(1) {
		scanf("%d",&input);
		if(input==0)break;
		printf("%d\n",get_query_answer(input));
	}
	return 0;
}

Measured memory_bytes: 9000
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
		int r;
	cin >> r;
	if(r < 1200)cout << "ABC" << endl;
	else if(r < 2800)cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> P;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

string s,t;
cin >> s >> t;
fin(t+s);

//////////////////////////////////////////////////////
return 0;}

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

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

	int N, K;
	cin >> N >> K;

	int* X1 = new int[N];
	int* Y1 = new int[N];
	int* D1 = new int[N];
	int* X2 = new int[N];
	int* Y2 = new int[N];
	int* D2 = new int[N];

	for (int i = 0; i < N; i++){
		cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];
	}
	
	//ソート用vector
	vector<int> X(2*N);
	vector<int> Y(2*N);
	vector<int> D(2*N);
	for (int i = 0; i < N; i++){
		X[2 * i]     = X1[i];
		X[2 * i + 1] = X2[i];
		Y[2 * i]     = Y1[i];
		Y[2 * i + 1] = Y2[i];
		D[2 * i]     = D1[i];
		D[2 * i + 1] = D2[i];
	}
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	sort(D.begin(), D.end());

	long long int ans = 0;
	int kasanari;
	for (int i = 0; i < 2*N-1; i++){ //X
		for (int j = 0; j < 2*N-1; j++){ //Y
			for (int k = 0; k < 2*N-1; k++){ //D
				kasanari = 0;
				for (int l = 0; l < N; l++){ //実際の直方体
					if ((X1[l]<=X[i] && X[i+1] <= X2[l]) &&
						(Y1[l]<=Y[j] && Y[j+1] <= Y2[l]) &&
						(D1[l]<=D[k] && D[k+1] <= D2[l]))
						kasanari++;
				}
				if (kasanari >= K){
					ans += (long long int)(X[i + 1] - X[i]) * (Y[j + 1] - Y[j]) * (D[k + 1] - D[k]);
				}
			}
		}
	}

	cout << ans << "\n";

	delete[] X1;
	delete[] Y1;
	delete[] D1;
	delete[] X2;
	delete[] Y2;
	delete[] D2;

	return 0;
}

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(M);
  for (int i=0; i<M; i++) cin >> A.at(i);
  int to0, toN;
  for (int i=0; i<M; i++) {
    if (A.at(i) < X) to0++;
    else toN++;
  }
  if (to0 < toN) cout << to0 << endl;
  else cout << toN << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    ll arr[n+5]={0};
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll cur=arr[0];
    ll ans=0;
    for(int i=1;i<n;i++)
    {
        if(arr[i]<=cur)
        {
            ans++;
            cur=arr[i];
        }
    }
    cout<<ans+1<<endl;
}



Measured memory_bytes: 5108
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

int gcd(int x, int y) {
    if(!y) return x;
    return gcd(y, x%y);
}

int main() {
    int n, k, t, M=0, g=0;
    scanf("%d%d", &n, &k);
    while(n--) {
        scanf("%d", &t);
        M=max(M, t);
        g=gcd(g, t);
    }
    printf(k>=0 && k<=M && (M-k)%g==0?
        "POSSIBLE\n":"IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define vl vector
#define ll long long
#define fast std::ios::sync_with_stdio(false)
using namespace std;

int main()
{
    fast;
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC";
    else cout<<"ABC";
}

Measured memory_bytes: 3608
_encode={
    " ":"101",
    "'":"000000",
    ",":"000011",
    "-":"10010001",
    ".":"010001",
    "?":"000001",
    "A":"100101",
    "B":"10011010",
    "C":"0101",
    "D":"0001",
    "E":"110",
    "F":"01001",
    "G":"10011011",
    "H":"010000",
    "I":"0111",
    "J":"10011000",
    "K":"0110",
    "L":"00100",
    "M":"10011001",
    "N":"10011110",
    "O":"00101",
    "P":"111",
    "Q":"10011111",
    "R":"1000",
    "S":"00110",
    "T":"00111",
    "U":"10011100",
    "V":"10011101",
    "W":"000010",
    "X":"10010010",
    "Y":"10010011",
    "Z":"10010000"
}

def encode(c):
    return _encode[c]

def decode(s):
    num=0
    for i,c in enumerate(s):
        if c=="1":
            num+=2**(4-i)
    if num<26:
        return chr(ord('A')+num)
    elif num==26:
        return " "
    elif num==27:
        return "."
    elif num==28:
        return ","
    elif num==29:
        return "-"
    elif num==30:
        return "'"
    else:
        return "?"


while True:
    try:
        s=input()
        encoded=""
        for c in s:
            encoded+=encode(c)
        while(len(encoded)%5!=0):
            encoded+="0"
        decoded=""
        for i in range(len(encoded)//5):
            decoded+=decode(encoded[5*i:5*i+5])
        print(decoded)
    except EOFError:
        break



Measured memory_bytes: 5588
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(int i = 0; i < n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int digit_sum(int n){
   if(n < 10)  return n;
   return digit_sum(n/10) + n%10;
}

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  int ans = 0;
  
  rep(i, n+1){
    if(digit_sum(i) >= a && digit_sum(i) <= b){
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
    ll n;
    cin>>n;
    ll sum=0;
    vec(a,n);
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    sort(all(a));
    if(sum%10){
        op(sum);
        return 0;
    }
    rep(i,n){
        if(a[i]%10){
        sum-=a[i];
        if(sum%10){
            
        op(sum);
        return 0;
        }
        }
    }
    op(0);
    return 0;
}

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

vector<long long int> wt;
vector<long long int> val;
long long int n,w;
long long int mem[105][100005];

long long int dp(long long int i,long long int x){
	if(i>=n)
	return 0;
	if(mem[i][x]!=-1)
	return mem[i][x];
	long long int ans = 0;
	ans = max(dp(i+1,x),ans);
	if(x+wt[i]<=w)
	ans = max(ans,dp(i+1,x+wt[i])+val[i]);
	mem[i][x]=ans;
	return ans;
}

int main(){
	cin>>n>>w;
	memset(mem,-1,sizeof(mem));
	for(long long int i=0;i<n;i++)
	{
		long long int x,y;
		cin>>x>>y;
		wt.push_back(x);
		val.push_back(y);
	}
	cout<<dp(0,0);
}

Measured memory_bytes: 85552
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;


int main(){

    int A,B,C;
    cin >> A >> B >> C;

    if(A==B){
        cout << C << endl;
    }else if(A==C){
        cout << B << endl;
    }else{
        cout << A << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  while (( A > 0 ) && ( C > 0 )) {
     C -= B;
    
    if ( C <= 0 ){
      cout << "Yes" << endl;
    }    
    
    else{
      A -= D;
    
    if ( A <= 0 ){
      cout << "No" << endl;
    }
    
        }
	
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)


ll dp[3000][3000][4];

int main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt	
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	 #endif

    FAST
	//PRECISE


ll n,m,k;
cin>>n>>m>>k;
ve <ve <ll> > v(n,ve <ll> (m));
FOR(i,0,k){
	ll x,y,z;
	cin>>x>>y>>z;
	x--;y--;
	v[x][y]=z;
}

FOR(i,0,n){
	FOR(j,0,m){
		FOR(k,0,4){
			dp[i][j][k]=0;
			if(k>0)
				dp[i][j][k]=v[i][j];
			if(i-1>=0){
				if(k>0)
				dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][3]+v[i][j]);
			else
				dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][3]);
			}
			if(j-1>=0){
				dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
				if(k>0)
					dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+v[i][j]);
			}
		}
	}
}


cout<<dp[n-1][m-1][3];

return 0;
 }
 

Measured memory_bytes: 354728
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <cctype>

typedef long long int ll;
using namespace std;


int main(){
    int a, b;
    cin >> a >> b;
    if (a + b < 10) {
        cout << a + b << endl;
    } else {
        cout << "error" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math
a,b,h,m=map(int,input().split())
x1=30*h+0.5*m
x2=6*m
x=x1-x2
cosx=math.cos(math.radians(x))
c=math.sqrt(a**2 + b**2 -2 * a * b * cosx)
print(c)

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
  int N;
  int ans;
  cin >> N;
  vector<int> a(N);
  REP(i,N) {
    int b;
    cin >> b;
    a[b-1] = i+1;
  }
  REP(i,N) {
    cout << a[i] << " ";
  }
  cout << endl;
}


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

int n, s[100] , sum = 0;

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

	sort(s, s + n);
	if (sum % 10 == 0) {
		for (int i = 0; i < n; i++) {
			if (s[i] % 10 != 0) {
				sum -= s[i];
				break;
			}

			if (i == n - 1) {
				sum = 0;
			}
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    
    if(n%2==0){
      System.out.println(n/2);
    }else{
      System.out.println((n+1)/2);
    }
  }
}

Measured memory_bytes: 23892
# Problem C - Multiplication 3

import math

# input
A, B = input().split()
A = int(A)

# initialization
b_1 = int(B[0])
b_2 = int(B[2])
b_3 = int(B[3])
tmp_1 = A * b_1 * 100
tmp_2 = A * b_2 * 10
tmp_3 = A * b_3
ans = math.floor((tmp_1 + tmp_2 + tmp_3) // 100)

# output
print(ans)


Measured memory_bytes: 61896
#include <bits/stdc++.h>
using namespace std; 
string s;
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>s;
	if(s[0]=='7' || s[1]=='7' || s[2]=='7')cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
    return 0; 
}/*
*/

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,k;
pair<int,int>g[11];
inline int read(){register int x=0;register char ch=getchar();while(ch<'0'||ch>'9'){ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x;}
int c[200001];
int mod=998244353;
inline int lowbit(int x){
	return x&-x;
}
inline void add(int p,int x){
	while(p<=n){
		c[p]=(c[p]+x)%mod;
		p+=lowbit(p);
	}
}
inline int sum(int k){
	int ans=0;
	while(k){
		ans=(ans+c[k])%mod;
		k-=lowbit(k);
	};
	return ans;
}
inline int ask(int l,int r){
	return (sum(r)-sum(l-1)+mod)%mod;
}
signed main(){
	n=read();
	k=read();
	register int i,j,p;
	for(i=1;i<=k;++i){
		g[i].first=read();
		g[i].second=read();
	}
	add(1,1);
	sort(g+1,g+k+1);
	for(i=1;i<=n;++i){
		//cout<<"s:";
		for(j=1;j<=k&&((i-g[j].first)>0);++j){
			//cout<<i<<" "<<j<<" "<<max(1ll,i-g[j].second)<<" "<<i-g[j].first<<" "<<ask(max(1ll,i-g[j].second),i-g[j].first)<<endl;
			add(i,ask(max(1ll,i-g[j].second),i-g[j].first));
		}
		//cout<<endl;
		//cout<<dp[i]<<endl;
	}
	cout<<ask(n,n);
}

Measured memory_bytes: 5196
//2020-06-03
#include <bits/stdc++.h>
using namespace std;
#define loop(v, st, en) for (int v = st; v < en; v++)
#define loopdesc(v, st, en) for (int v = st; v >= en; v--)
#define INF 1E9
#define clr(v, d) memset(v, d, sizeof(v))
#define pb push_back
#define MP make_pair
#define P(x) cout << #x << " = { " << x << " }\n"
#define PI acos(-1)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const int M = 2e5 + 5;
const double eps = 10e-9;
double my_sqr(double n){
double st =0,en =n , mid ;
    while (st<en)
    {
        mid= (st+en)/2;
        if( abs (n - mid*mid ) < eps)return mid ;
        else if(mid *mid > n)en = mid ;
        else st = mid ;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double angelh, angel, c;
    angelh = 0.5*(60*h + m );
    angel = abs (angelh - m * 6);
   // angel = min(angel, abs(360 - angel));
   // P(angel);
    //P(cos(angel *PI/180));
    c = a * a + b * b - 2 * a * b * cos(angel * PI / 180);
    printf("%.12f\n", sqrt(c));
    return 0;
}

Measured memory_bytes: 4032
MOD = 10**9+7

def kake(x,y):
    return (x*y)%MOD

N = int(input())

ans = 1 if N >=3 else 0
tmp = 1
for i in range(2,(N//3)+1):
    tmp = kake(tmp,N-3*(i-1))
    tmp = kake(tmp,N-3*(i-1)-1)
    tmp = kake(tmp,N-3*(i-1)-2)
    tmp = kake(tmp,pow(i-1,MOD-2,MOD))
    tmp = kake(tmp,pow(N-2*(i-1)-1,MOD-2,MOD))
    tmp = kake(tmp,pow(N-2*(i-1)-2,MOD-2,MOD))

    ans = (ans+tmp)%MOD


    

print(ans)



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

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

    int prime[100001]={0};
    prime[0]=1;
    prime[1]=1;
    long int len=sqrt(100001);
    
    for(int i=2;i<=len;i++){
        if(prime[i]==0){
            for(int j= 2*i;j<100001;j += i){
                prime[j]=1;
            }
        }
    }
	int ans[100001]={0};
	for(int i=1;i<100001;i+=2){
		if( prime[i]==0 && prime[(i+1)/2]==0) ans[i]=1;
	}
	for(int i=1;i<100001;i++) ans[i] += ans[i-1];

	int q,l,r; cin>>q;
	int res=0;
	while(q--){
		cin>>l>>r;
		res = ans[r]-ans[l];

		if(prime[l]==0 && prime[(l+1)/2]==0) res += 1;
		cout<<res<<endl;
	} 
	return 0;
}

Measured memory_bytes: 1408
n = int(input())

words = []
for i in range(n):
    words.append(input())

ans = 'Yes'
if len(words) != len(set(words)):
    ans = 'No'
else:
    for i in range(1,len(words)):
        if words[i-1][-1] != words[i][0]:
            ans = 'No'
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
int main(){
	int N,M;
	scanf("%d %d",&N,&M);
	int A[1000];
	int Ai;
	int Bj;
	int count[1000];
	for(int i=0;i<N;i++){
		scanf("%d",&Ai);
		A[i]=Ai;
		count[i]=0;
	}
	for(int j=0;j<M;j++){
		scanf("%d",&Bj);
		for(int i=0;i<N;i++){
			if(A[i]<=Bj){count[i]++;break;}
		}
	}
	int max_count=0;
	int max_game=-1;
	for(int i=0;i<N;i++){
		if(max_count<count[i]){
			max_count=count[i];
			max_game=i;
		}
	}

	printf("%d\r\n",max_game+1);
}


Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005;
const ll INF=1LL<<60;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,M;cin>>N>>M;
    vector<ll> A(N),S(N+1);
    for(int i=0;i<N;i++) cin>>A[i];
    sort(all(A));
    
    for(int i=1;i<=N;i++){
        S[i]=S[i-1]+A[i-1];
    }
    
    ll left=0,right=INF;
    
    while(right-left>1){
        ll mid=(left+right)/2;
        
        ll cnt=0;
        
        for(int i=0;i<N;i++){
            auto it=lower_bound(all(A),mid-A[i]);
            cnt+=A.end()-it;
        }
        
        if(cnt>=M) left=mid;
        else right=mid;
    }
    ll cnt=0;
    
    for(int i=0;i<N;i++){
        auto it=lower_bound(all(A),left-A[i]);
        cnt+=A.end()-it;
    }
    ll ans=0;
    
    for(int i=0;i<N;i++){
        auto it=lower_bound(all(A),left-A[i]);
        ans+=S[N]-S[N-(A.end()-it)]+ll(A.end()-it)*A[i];
        
        //cout<<ans<<endl;
    }
    
    ans-=left*(cnt-M);
    
    cout<<ans<<endl;
    
    
}




Measured memory_bytes: 1920
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[100];
int main()
{
	for(int i=1;i<=5;i++){
		scanf("%d",&a[i]);
		if(a[i]==0){
			printf("%d",i);
			return 0;
		}
	}
}


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

const long long M = 1000000007;

bitset<30> b;

long long my_pow(long long x, long long y) {
    b = y;
    long long p = x;
    long long ans = 1;
    for (int i = 0; i < b.size(); i++) {
        if (b.test(i)) {
            ans = (ans * p) % M;
        }
        p = (p * p) % M;
    }
    return ans;
}

long long inv(long long n) {
    return my_pow(n, M-2);
}

int main() {
    long long s, c;
    cin >> s;
    vector<long long> invs(2001);
    for (int i = 0; i < invs.size(); i++) {
        invs[i] = inv(i);
    }
    long long ans = 0;
    for (long long k = 1; k < s/3+1; k++) {
        c = 1;
        for (long long i = 1; i < k; i++) {
            c = ((c * invs[i]) % M) * (s - 2 * k - i) % M;
        }
        ans = (ans + c) % M;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
	long long n,d;cin>>n>>d;
	long long a[n+1],b[n+1];
	long long i,j,k;
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	long long count=0;double m;
	for(i=0;i<n;i++)
	{
		m=sqrt(1.0*(a[i]*a[i]+b[i]*b[i]));
		
		if(m<=d)
		count++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 6708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main() {
    ll a, b;
    cin >> a >> b;
    for (ll i = 0;i<100000; i++) {
        if (i * 8 / 100 == a && i * 10 / 100 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans = 1e9;
  int W[n+1];
  int E[n+1];
  memset(W, 0, n+1);
  memset(E, 0, n+1);
  for (int i = 0; i < n; i++){
    if (s[i] =='E'){
      W[i+1] = W[i];
      E[i+1] = E[i]+1;
    } else {
      W[i+1] = W[i]+1;
      E[i+1] = E[i];
    }
  }

  for (int i = 0 ; i < n; i++){
    ans = min(ans, W[i] + E[n] - E[i+1]);
  }
  cout << ans << endl;
  return 0;
}

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

	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		String s = in.next();

		boolean isOdd = false;
		for(int i=0; i < s.length(); i++) {
			isOdd = !isOdd;
			char c = s.charAt(i);
			if( c == 'U' || c == 'D') continue;
			if( isOdd && c == 'L') {
				System.out.println("No");
				return;
			}else if(!isOdd && c == 'R') {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}

	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
	}

}

Measured memory_bytes: 23124
#include <iostream>
int main(){
    using namespace std;
    int n;
    cin>>n;
    int b[n-1];
    for(int i=0;i<n-1;i++){
        cin>>b[i];
    }
    if(n==2){
        cout<<2*b[0];
        return 0;
    }
    int ans =b[0];
    for(int i=1;i<n-1;i++){
        if(b[i-1]<=b[i]){
            ans+=b[i-1];
        } else{
            ans+=b[i];
        }
    }
    if(n>=3){
        ans+=b[n-2];
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa; cin>>nyaa;


void solve() {
	int n;
	cin >> n;
	vector<int> isprime(33333, 1);
	isprime[0] = isprime[1] = 0;
	vector<int> prime;
	rep(i, 33333) {
		if (!isprime[i])continue;
		prime.push_back(i);
		for (int j = 2 * i; j < 33333; j += i) {
			isprime[j] = 0;
		}
	}
	map<int, long long> mp;
	rep(i, n) {
		int x;
		cin >> x;
		int y = x;
		for (auto p : prime) {
			if (y%p)continue;
			mp[p] += x;
			while (y%p == 0)y /= p;
			
		}
		if (y > 1)mp[y] += x;
	}
	long long ans = 0;
	for (auto e : mp) {
		ans = max(ans, e.second);
	}
	cout << ans << endl;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n; cin >> n;
  vector<int> t(n+1), x(n+1), y(n+1);
  rep(i,n) cin >> t[i+1] >> x[i+1] >> y[i+1];

  string ans;
  for (int i=1;i<=n;i++) {
    int dt = t[i] - t[i-1];
    int dx = abs(x[i] - x[i-1]);
    int dy = abs(y[i] - y[i-1]);
    int d = dx + dy;
    //printf("%d %d %d %d\n",dt, dx, dy, d);
    if (d <= dt && (dt - d) % 2 == 0) {
      ans = "Yes";
    } else {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

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


int main()
{
    int x;
    cin>>x;
    int sum=0;
    vector<int>a(x);
    for(int i=0;i<x;i++)
    {
        cin>>a.at(i);
        sum=sum+a.at(i);

    }
/*for(int i=0;i<x-2;i++)
{
    sum=sum+a.at(i);
}*/
sort(a.begin(),a.end());
cout<<sum-a.at(x-1)/2;
//cout<<sum+a.at(x-2)/2+a.at(x-1);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b;
  cin>>a>>b;
  cout<<max(a+b,max(a-b,a*b))<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
struct node{   
  int key;
  struct node *parent;
  struct node *right;
  struct node *left;
};
typedef struct node *Node;
Node T;
#define NIL NULL;
void Insert(int);
void Preorder(Node);
void Inorder(Node);
int main()
{
  int n,i,key;
  char S[7];  

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",S);
    if(S[0]=='i'){
      scanf("%d",&key);
      Insert(key);
    }
    else{
      Inorder(T);
      printf("\n");
      Preorder(T);
      printf("\n");
      
    }
  }
  return 0;
}

void Insert(int key)
{
  Node y,x,z;
  y=NIL;
  x=T;
  z=malloc(sizeof(struct node));
  z->key=key;
  z->left=NIL;
  z->right=NIL;
  while(x!=NULL){
    y=x;
    if( z->key < x->key )x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NULL){
    T=z;
  }
  else if(z->key<y->key){
      y->left=z;
  }
  else{
    y->right=z;
  }
}

void Preorder(Node T)
{
  printf(" %d",T->key);
  if(T->left!=NULL){
    Preorder(T->left);
  }
  if(T->right!=NULL){
    Preorder(T->right);
  }
   
}
void Inorder(Node T)
{
  if(T->left!=NULL && T->right!=NULL){
    Inorder(T->left);
    printf(" %d",T->key);
    Inorder(T->right);
  
  }
  if(T->left!=NULL && T->right==NULL){
   Inorder(T->left);
     printf(" %d",T->key);  
  }
  
  if(T->right!=NULL && T->left==NULL){
  printf(" %d",T->key);
 Inorder(T->right); 
  
  }
  if(T->left==NULL && T->right==NULL)printf(" %d",T->key);
 
}

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

int main()
{
    int n;
    cin >> n;
    int a[n] = {};
    for(int i=0; i<n; i++) cin >> a[i];
    int d[n] = {};
    for(int i=1; i<n; i++){
        if(a[i] <= a[i-1])
            d[i] = d[i-1] + 1;
        else
            d[i] = 0;
    }
    cout << *max_element(d, d+n) << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  ll n, a, b, tmp, m, ans;
  cin >> n >> a >> b;
  tmp = n%(a+b);
  m = n/(a+b);
  if(tmp == 0) {
    ans = m*a;
  }
  else {
    ans = m*a+min(tmp,a);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256