akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    
     int n=0,x=0,y=0,ans=0;
     scanf("%d",&n);
       if(n>=15){
	 x=n*800;
     y=((n/15)*200);
     ans=x-y;
     printf("%d",ans);
       }
	   else{
	   x=n*800;
       ans=x;
       printf("%d",ans);
	}


}

Measured memory_bytes: 256
#C - Traveling Salesman around Lake
K,N= map(int, input().split())
A =list(map(int, input().split()))
B =[]
ans = 0
for i in range(N-1):
    B.append(A[i+1]-A[i])
    ans += A[i+1]-A[i]
B.append(abs(K-A[N-1]+A[0]))
ans = K-max(B)
print(ans)

Measured memory_bytes: 26436
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int N, M;
int sumT, sumH;

int taro[200];
int hanako[200];

static const int INF = 1e8;

void solve() {
  int minT = INF;
  int minH = INF;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (sumT - taro[i] + hanako[j] == sumH - hanako[j] + taro[i]) {
        if (minT + minH > taro[i] + hanako[j]) {
          minT = taro[i];
          minH = hanako[j];
        }
      }
    }
  }
  if (minT == INF && minH == INF) {
    cout << -1 << endl;
  } else {
    cout << minT << " " << minH << endl;
  }
}

void init() {
  sumT = 0;
  sumH = 0;
}

int main() {
  while (true) {
    cin >> N >> M;
    if (N == 0 && M == 0) {
      break;
    }
    init();
    for (int i = 0; i < N; i++) {
      cin >> taro[i];
      sumT += taro[i];
    }
    for (int i = 0; i < M; i++) {
      cin >> hanako[i];
      sumH += hanako[i];
    }

    solve();
  }
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    vector<int> ab(102,0), cd(101,0);
    ab[a] = cd[c] = 1;
    ab[b] = cd[d] = -1;

    int cnt = 0;
    for(int i = 0; i < 100; i++){
        ab[i+1] += ab[i];
        cd[i+1] += cd[i];
        if(ab[i] + cd[i] == 2) cnt++;
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll x[51] = {};
ll y[51] = {};
int main() {
	ll n, k; cin >> n >> k;
	repe(i, 1, n)	cin >> x[i] >> y[i];

	ll ans = (ll)1 << 62;
	//sort(x + 1, x + n + 1);
	//sort(y + 1, y + n + 1);

	repe(x1, 1, n) {
		repe(x2, 1, n) {
			repe(y1, 1, n) {
				repe(y2, 1, n) {
					//repe(x1, 1, n) {
					//	repe(x2, x1 + 1, n) {
					//		repe(y1, 1, n) {
					//			repe(y2, y1 + 1, n) {
									//cout << x[x1] << " " << x[x2] << " " << y[y1] << " " << y[y2] << endl;
									//if (x[x1] == 3 && x[x2] == 8 && y[y1] == 1 && y[y2] == 4) {
									//	cout << endl;
									//}
					ll K = 0;
					repe(i, 1, n) {
						if (x[x1] <= x[i] && x[i] <= x[x2]
							&& y[y1] <= y[i] && y[i] <= y[y2]) {
							K++;
						}
						if (k <= K) {
							ll X = abs(x[x1] - x[x2]);
							ll Y = abs(y[y1] - y[y2]);
							ans = min(ans, X*Y);
						}
					}
				}
			}
		}
	}

	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(void) {
  const long long MOD = 1000000007;

  long long n, a, b;
  cin >> n >> a >> b;

  int l = 31, r = 1;
  while (l - r != 1) {
    if (n / (1 << ((l+r) / 2))) {
      r = (l+r) / 2;
    } else {
      l = (l+r) / 2;
    }
  }
  
  int logN = r+1;
  long long C[logN];
  C[0] = 2LL;
  for (int i = 0; i < logN-1; ++i) {
    C[i+1] = C[i] * C[i];
    C[i+1] %= MOD;
  }

  long long combination = 1;
  for (int i = 0; i < logN; ++i) {
    if (n & (1 << i)) {
      combination *= C[i];
      combination %= MOD;
    }
  }
  
  combination = (combination != 0) ? combination-1 : MOD-1;

  /* https://drken1215.hatenablog.com/entry/2018/06/08/210000 */
  /* 逆元テーブル */
  int K = max(a, b)+1;
  long long inv[K];
  inv[1] = 1;
  for (int i = 2; i < K; ++i){
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
  }

  long long nCa, nCb, c = 1;
  for (int i = 0; i < max(a, b); ++i) {
    c *= n-i;
    c %= MOD;
    c *= inv[i+1];
    c %= MOD;

    if (i+1 == a) nCa = c;
    if (i+1 == b) nCb = c;
  }

  long long ans = combination - (nCa + nCb) + 2*MOD;
  ans %= MOD;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
S=input()
m0=0

if int(S[:2])<=12 and int(S[:2])>0:
  m0+=1
if int(S[2:])<=12 and int(S[2:])>0:
  m0+=2

if m0==0:
  print("NA")
elif m0==1:
  print("MMYY")
elif m0==2:
  print("YYMM")
else:
  print("AMBIGUOUS")
  

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		sc.close();

		if (a == 0) {
			System.out.println(b / x + 1);
		} else {
			System.out.println(b / x - (a - 1) / x);
		}
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}


int main() {
    int l,r,d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l;i<=r;i++) {
        if(i%d==0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i,a,b) for(int i = int(a);i<=int(b);i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
using namespace std;
 
typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    string s,a1 = "ABC",a2 = "ARC";
    cin>>s;
    if(s==a1)
    {
        cout<<a2<<"\n";
    }
    else
    {
        cout<<a1<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3608
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b;
	char s[5];
	scanf("%lld%s",&a,&s);
	b=(s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
	printf("%lld\n",a*b/100);
	return 0;
}

Measured memory_bytes: 1728
#include <stdio.h>
int main(void){
	int N,ans=0;
	int a[100],b[100],c[100],d[100];
	scanf("%d",&N);
	int temp,temp2;
	int i,j;
	for(i=0;i<N;i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	for(i=0;i<N;i++){
		scanf("%d %d",&c[i],&d[i]);
	}
	
	for(i=0;i<N;i++){
		for(j=i+1;j<N;j++){	//まずc[100] d[100]をx座標が小さい順にソートしていく。
			if( c[i] > c[j]){
				temp = c[i];
				temp2 = d[i];
				c[i]	= c[j];
				d[i]	= d[j];
				c[j]	= temp;
				d[j]	= temp2;
			}
			if( b[i] < b[j]){	//red側のy座標の大きい順にソートします。
				temp		= b[i];
				temp2	= a[i];
				b[i]		= b[j];
				a[i]		= a[j];
				b[j]		= temp;
				a[j] 		= temp2;
			}
		}
	}
	/*
	//ソートチェック用
	for(i=0;i<N;i++){
		printf("a[%d] = %d b[%d] = %d\n",i,a[i],i,b[i]);
	}
	for(i=0;i<N;i++){
		printf("c[%d] = %d d[%d] = %d\n",i,c[i],i,d[i]);
	}
	*/
	for(i=0;i<N;i++){	//一回ペアを作った赤は捨てていきたい。
		for(j=0;j<N;j++){
			if( c[i] > a[j] && d[i] > b[j]){
				if( a[j] !=-1){//その赤が使われていなかった場合は
			 		ans ++;
			 		c[i]=-1;
			 		a[j]=-1;
			 		b[j]=-1;
			 	}
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.AbstractMap.SimpleEntry;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        SimpleEntry<Integer, Integer>[] data = new SimpleEntry[N];
        for (int i = 0; i < N; i++) {
            data[i] = new SimpleEntry<>(sc.nextInt(), sc.nextInt());
        }
        Arrays.sort(data, (a, b) -> {
            if (a.getKey() != b.getKey()) {
                return Integer.compare(b.getKey(), a.getKey());
            } else {
                return Integer.compare(b.getValue(), a.getValue());
            }
            });
        PriorityQueue<SimpleEntry<Integer, Integer>> pq = new PriorityQueue<>(N, Comparator.comparingInt(SimpleEntry::getValue));
        int result = 0;
        for (int i = 0; i < N; i++) {
            int days = data[i].getKey();
            int reward = data[i].getValue();
            if (pq.size() + days <= M) {
                pq.add(data[i]);
                result += reward;
            } else {
                if (!pq.isEmpty()) {
                    SimpleEntry<Integer, Integer> top = pq.peek();
                    if (reward > top.getValue()) {
                        result -= top.getValue();
                        pq.poll();
                        pq.add(data[i]);
                        result += reward;
                    }
                }
            }
        }
        pw.println(result);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 65560
a,b,K = gets.split.map(&:to_i)
K.times do |i|
  if i.even?
    if a.odd?
      a -= 1
    end
    b += a/2
    a /= 2
  else
    if b.odd?
      b -= 1
    end
    a += b/2
    b /= 2
  end
end
puts "#{a} #{b}"

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

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

  int x = a[0];
  for (int i = 1; i < N; i++) {
    x ^= a[i];
  }
  if (x == 0)
    puts("Yes");
  else
    puts("No");
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, m;
    cin >> n >> m;
    bool e[n][n] = {};
    for (int i = 0, a, b; i < m; i++) {
        cin >> a >> b;
        e[a - 1][b - 1] = true;
        e[b - 1][a - 1] = true;
    }
    int t[n - 1];
    for (int i = 0; i <= n - 2; i++) t[i] = i + 1;
    int ans = 0;
    do {
        bool flag = true;
        int cur = 0;
        for (int i = 0; i <= n - 2; i++) {
            if (e[cur][t[i]]) cur = t[i];
            else flag = false;
        }
        if (flag) ans++;
    } while (next_permutation(t, t+n-1));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 3001
int dp[N][N]={0};


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();

    for(int i=1;i<=n;i++)
    {		
    	for(int j=1;j<=m;j++)
    	{
    		if(s[i-1]==t[j-1])
    		{
    			int ans=dp[i-1][j-1]+1;
    			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    			dp[i][j]=max(dp[i][j],ans);
    		}
    		else
    			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    	}
    }

    stack<char> q;
    int i=n,j=m;

    while(i>0 && j>0)
    {
    	if(s[i-1]==t[j-1])
    	{
    		q.push(s[i-1]);
    		 i--;
    		 j--;
    	}
    	else
    	{
    		if(dp[i-1][j]>dp[i][j-1])
    			i--;
    		else
    			j--;
    	}

    }
    
    while(q.empty()==0)
    {
    	cout<<q.top();
    	q.pop();
    }
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,a=0;
  cin>>n>>k;  
  
  for(int i=0;i<n;i++){
    int x;
    cin>>x;   
    int d;
    if(k-x<0){
      d=x-k;
    }
    else{
      d=k-x;
    }
   
    if(x<d){
      a+=(x*2);
    }
    else{
      a+=(d*2);
    }
  }
  cout<<a<<endl;
    
}

Measured memory_bytes: 3532
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _overload2(_1,_2,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define _repc(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) _overload4(__VA_ARGS__,_repc,_repi,_rep)(__VA_ARGS__)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrep(i,n) _rrepi(i,0,n)
#define _rrepc(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rrep(...) _overload4(__VA_ARGS__,_rrepc,_rrepi,_rrep)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload2(__VA_ARGS__,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <class T>
inline void out(T t){cout<<t<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}

int gcd ( int a, int b ) { int c; while ( a != 0 ) { c = a; a = b%a; b = c; } return b; }
int main(){
    INT(x,y);
    out(x+y+1-gcd(x,y));
}















Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n-1);
    for(int i = 0; i< n; i++) cin >> a[i];
    for(int i = 0; i< n; i++) cin >> b[i];
    for(int i = 0; i< n-1; i++) cin >> c[i];

    int ans = 0;
    for(int i = 0; i< n; i++){
        ans += b[a[i]-1];
        if(i != 0 && a[i-1]+1 == a[i]){
            ans += c[a[i-1]-1];
        }
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main(void){
  int N, M; cin >> N >> M;
  vector<P> dropping(M);
  for(int i = 0; i < M; i++){
    int a, b; cin >> a >> b; a--; b--;
    dropping[i] = P(b, a);
  }
  sort(dropping.begin(), dropping.end());
  int ans = 0;
  int current_right = 0;
  for(auto& d: dropping){
    int left = d.second;
    int right = d.first;
    if(current_right <= left){
      ans++;
      current_right = right;
    }else{

    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[] ary = new int[3];
		
		for ( int i = 0; i < 3; i++ ) {
			ary[i] = in.nextInt();
		}
		in.nextLine();
		int k = in.nextInt();
		
		Arrays.sort(ary);
		
		for ( int i = 1; i <= k; i++ ) {
			ary[2] = ary[2]*2;
		}
		
		int fin = 0;
		for ( int i = 0; i < 3; i++ ) {
			fin += ary[i];
		}
		
		System.out.println(fin);
	}
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

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

    string s; cin >> s;

    int mod10[n];
    rep(i,n){
        if(i == 0) mod10[i] = 1;
        else{
            mod10[i] = mod10[i-1] * (10 % p) % p;
        }
    }
    // rep(i,n) cout << mod10[i] << endl;

    int mod[n];
    rep(i,n){
        int si = s[n-i-1] - '0';
        mod[i] = si * mod10[i] % p;
        
    }

    int modsum[n+1];
    modsum[0] = 0;
    rep(i,n){
        if(i == 0) modsum[i+1] = mod[i];
        else{
            modsum[i+1] = (mod[i] + modsum[i]) % p;
        }
    }

    if(10%p == 0){
        ll res = 0;
        rep(r,n){
            if((s[r]-'0') % p == 0){
                res += r+1;
            }
        }
        cout << res << endl;
    }else{
        int cnt[p];
        rep(i,p) cnt[i] = 0;
        
        ll res = 0;
        rep(i,n+1){
            res += cnt[modsum[i]];
            cnt[modsum[i]]++;
        }

        cout << res << endl;
    }
}

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

int main() {
        int N, Max=0,Min=1000000000;
        int A[110];
        cin >> N;
        for(int i=0; i<N; i++) cin >> A[i];

        for(int i=0; i<N; i++){
                Max = max(Max, A[i]);
                Min = min(Min, A[i]);
        }

        cout << Max-Min << endl;

        return 0;
}

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

int main() {
  string s;
  cin >> s;

  int a = 0;
  for (int i = 0; i < s.size(); i ++) {
    if (i % 2 == 0 && s[i] == '0') a ++;
    if (i % 2 == 1 && s[i] == '1') a ++;
  }

  int b = s.size() - a;
  cout << min(a, b) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
//vector.assign (n,value)... for global vectors
class abc
{
public:
    ll x, y;
};
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
ll binomialCoeff(ll n, ll k)  
{  
    ll res = 1;  
  
    // Since C(n, k) = C(n, n-k)  
    if ( k > n - k )  
        k = n - k;  
  
    // Calculate value of  
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]  
    for (ll i = 0; i < k; ++i)  
    {  
        res *= (n - i); 
        res%=rem; 
        res *= modInverse(i+1, rem);  
        res%=rem;
    }  
    return res;  
}  
int main()
{
    FAST
        // freopen("input1.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
        // ::fac[0] = 1;
        // for (ll i=1 ; i<=1000000001; i++)
        // ::fac[i] = (::fac[i-1])*i%rem;
        ll n,
        a, b;
    cin >> n >> a >> b;
    ll ans = power(2, n, rem);
    ans -= 1;
    if (ans < 0)
    {
        ans += rem;
    }
    ll x1 = binomialCoeff(n, a);
    ll x2 = binomialCoeff(n, b);
    ans -= x1;
    if (ans < 0)
    {
        ans += rem;
    }
    ans -= x2;
    if (ans < 0)
    {
        ans += rem;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
from sys import stdin
n, m = map(int, stdin.readline().split())
G = [-1] * n
def root(x):
    if G[x] < 0: return x
    G[x] = root(G[x])
    return G[x]
def uniteSet(x, y):
    x = root(x)
    y = root(y)
    if x == y : return
    if G[x] > G[y] : x, y = y, x
    G[y] = x
def findSet(x, y): return root(x) == root(y)
for i in range(0, m):
    s, t = map(int, stdin.readline().split())
    uniteSet(s, t)
q = int(stdin.readline())
for i in range(0, q):
    s, t = map(int, stdin.readline().split())
    print("yes" if findSet(s, t) else "no")

Measured memory_bytes: 9960
//#pragma GCC optimize("Ofast")

#ifdef LOCAL
#include "debug.h"
#else
#include <bits/stdc++.h>
#define debug(x...)
#endif

//#define int ll

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define sz(x) int((x).size())

#ifdef ONLINE_JUDGE
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#else
mt19937 rng(1000 - 7);
#endif

const int N = 2e5 + 10;
const int M = 1e6 + 10;
const int MOD = 998244353;
//const int MOD = 1e9 + 7;
const ld eps = 1e-6;
const pii dir[] = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } };



signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cout << fixed << setprecision(9);
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll n, a, b;
    cin >> n >> a >> b;

    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    }
    else {
        cout << (b - a + 1) / 2 + min(a - 1, n - b);
    }

    return 0;
}



Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main()
{
	int n,x=0,max=0;
	cin>>n;
	char s[n];
	cin>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
		x++;
		if(s[i]=='D')
		x--;
		if(x>max)
		max=x;
	}
	cout<<max;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [1 if a == 'o' else 0 for a in list(input())]
S.append(S[0])

def check(a0, a1):
    dp = [None]*(N+2) #TrueならSheep, FalseならWolf
    dp[0] = a0
    dp[1] = a1
    for i in range(2, N+2):
        if dp[i-2] and dp[i-1]:
            dp[i] = True if S[i-1] == 1 else False
        if dp[i-2] and not dp[i-1]:
            dp[i] = True if S[i-1] == 0 else False
        if not dp[i-2] and dp[i-1]:
            dp[i] = True if S[i-1] == 0 else False
        if not dp[i-2] and not dp[i-1]:
            dp[i] = True if S[i-1] == 1 else False
    return dp


def main():
    ok = False
    for a0 in [True, False]:
        for a1 in [True, False]:
            dp = check(a0, a1)
            if (dp[N] == a0) and (dp[N+1] == a1):
                ok = True
                break
        if ok:
            break
    if not ok:
        print(-1)
    else:
        ans = ['S' if dp[i] else 'W' for i in range(N)]
        print(''.join(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 6296
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        aa: [usize; n],
    }

    let mut stock = 0;
    let mut money = 1000;

    for a in aa.windows(2) {
        if a[0] < a[1] {
            stock += money / a[0];
            money %= a[0];
        } else {
            money += stock * a[0];
            stock = 0;
        }
    }

    if stock != 0 {
        money += stock * aa[n-1];
    }

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


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

using namespace std;

int main(void){
 	int n;
  	cin >> n;
  	
  	vector<int> d(n+1);
  
  	d[0] = 0;
  
  	for(int i = 1; i < n+1; i++){
     	cin >> d[i]; 
    }
  
  	sort(d.begin(), d.end());
  
  	cout << d[n/2 + 1] - d[n/2] << endl;
  
  
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
using namespace std;
using Int = long long;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b >= c ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100003
#define what_is(x) cerr << #x << " is " << x << endl;

using namespace std;

int main() {
	// for fast input output using cin cout
	std::ios_base::sync_with_stdio(false);

	// input
	string s, t;
	cin >> s >> t;
	int beg = -1;
	for (int i = 0; i < s.size(); ++i)
	{
		int j;
		for (j = i; j < i+t.size(); ++j)
		{
			if (s[j] != t[j-i] && s[j] != '?')
				break;
		}
		if (j >= i+t.size())
			beg = i;
		// what_is(beg);
	}

	if (s.find(t) != -1) {
		for (int i = 0; i < s.size(); ++i)
		{
			if (s[i] == '?')
				s[i] = 'a';
		}

		cout << s << endl;
	}
	else {
		if (beg != -1) {
			for (int i = 0; i < s.size(); ++i)
			{
				if (i == beg) {
					for (; i < t.size()+beg; ++i)
					{
						s[i] = t[i-beg];
					}
				}
				if (s[i] == '?')
					s[i] = 'a';
			}

			cout << s << endl;
		}
		else
			cout << "UNRESTORABLE\n";
	}
	
	return 0;
}

Measured memory_bytes: 256
package main

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

func solve() {
	n := getInt()
	as := getIntSlice(n)
	bs := getIntSlice(n)
	cs := getIntSlice(n)

	sort.Ints(as)
	sort.Ints(cs)

	fa := func(b int) int {
		l, r := -1, n
		for r-l > 1 {
			if m := (l + r) / 2; as[m] < b {
				l = m
			} else {
				r = m
			}
		}
		return l + 1
	}
	fc := func(b int) int {
		l, r := -1, n
		for r-l > 1 {
			if m := (l + r) / 2; cs[m] > b {
				r = m
			} else {
				l = m
			}
		}
		return n - (l + 1)
	}

	ans := 0
	for _, b := range bs {
		a, c := fa(b), fc(b)
		ans += a * c
	}

	fmt.Fprintln(wr, ans)
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    
    int cnt=0;
    while(b<=a){
        b*=2;
        cnt++;
    }
    while(c<=b){
        c*=2;
        cnt++;
    }
    if(cnt<=k){
        //cout<<cnt<<endl;
        cout<<"Yes"<<endl;
        return 0;
    }
    //cout<<cnt<<endl;
    cout<<"No"<<endl;
    return 0;
}

    


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


int main(){
  bool ok=true;
  string s;
    cin>>s;
  int n=s.size();
  for(int i=0;i<n;i+=2){
    if(s[i]=='L'||s[i+1]=='R')ok=false;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long lnt;
using namespace std;
lnt n,a,b,c,d,l,r;
inline bool range(lnt v,lnt x,lnt y){
	return v>=x&&v<=y;
}
signed main(){
	cin>>n>>a>>b>>c>>d;--n;
	for(int i=0;i<=n;++i){
		l=-i*d+(n-i)*c;
		r=-i*c+(n-i)*d;
		if(range(b-a,l,r))
			return puts("YES"),0;
	}
	return puts("NO"),0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>

using namespace std;

struct Node{
	int data;
	Node* prev;
	Node* next;
};

class List{
public:
	List(){
		motherNode = new Node();
		motherNode->data = -1;
		motherNode->prev = motherNode;
		motherNode->next = motherNode;
		num_of_node = 0;
		current = 0;
	};

	void insertFromLast(int x){
		Node* tmpNode = motherNode->prev;
		if(tmpNode == motherNode){
			motherNode->next = new Node();
			motherNode->next->data = x;
			motherNode->next->next = motherNode;
			motherNode->next->prev = motherNode;
			motherNode->prev = motherNode->next;
			current = motherNode->next;
		}else{
			while(tmpNode != motherNode && tmpNode->data > x){
				tmpNode = tmpNode->prev;
			}
			Node* nextNode = tmpNode->next;
			tmpNode->next = new Node();
			tmpNode->next->data = x;
			tmpNode->next->next = nextNode;
			tmpNode->next->prev = tmpNode;
			nextNode->prev = tmpNode->next;
		}
		num_of_node++;
	}

	int upDist(int a){
		int to_move = a%num_of_node,count = 0,ret;

		if(to_move > num_of_node-(to_move-3)){
			return downDist(num_of_node-to_move);
		}

		Node* tmp = current;
		while(count < to_move){
			tmp = tmp->next;
			if(tmp != motherNode){
				count++;
			}
		}

		ret = tmp->data;
		if(tmp->next == motherNode){
			current = motherNode->next;
		}else{
			current = tmp->next;
		}

		tmp->prev->next = tmp->next;
		tmp->next->prev = tmp->prev;
		delete tmp;
		num_of_node--;
		return ret;
	}

	int downDist(int a){
		int to_move = a%num_of_node,count = 0,ret;

		if(to_move > num_of_node-(to_move-3)){
			return upDist(num_of_node-to_move);
		}

		Node* tmp = current;
		while(count < to_move){
			tmp = tmp->prev;
			if(tmp != motherNode){
				count++;
			}
		}

		ret = tmp->data;
		if(tmp->next == motherNode){
			current = motherNode->next;
		}else{
			current = tmp->next;
		}

		tmp->prev->next = tmp->next;
		tmp->next->prev = tmp->prev;
		delete tmp;
		num_of_node--;
		return ret;
	}

	void showList(){
		Node* tmpNode = motherNode->next;
		printf("%d",tmpNode->data);
		tmpNode = tmpNode->next;
		while(tmpNode != motherNode){
			printf(" %d",tmpNode->data);
			tmpNode = tmpNode->next;
		}
		printf("\n");
	}

private:
	Node* motherNode;
	Node* current;
	int num_of_node;
};

int main(){

	int N,M,Q,a;

	scanf("%d %d %d",&N,&M,&Q);
	int checkTable[N];
	List list;

	for(int i=0; i < N; i++){
		checkTable[i] = 1;
		list.insertFromLast(i);
	}


	for(int i=0; i < M; i++){
		scanf("%d",&a);

		if(a % 2 == 0){
			checkTable[list.upDist(a)] = 0;
		}else{
			checkTable[list.downDist(a)] = 0;
		}
	}

	int query;
	for(int i=0; i < Q; i++){
		scanf("%d",&query);

		printf("%d\n",checkTable[query]);
	}

    return 0;
}

Measured memory_bytes: 9680
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;


signed main(){
    cin >> n;
    vec(a,n);
    input(a,n);
    bool b = true;
    int ans = 0;
    while(b){
        b = false;
        for(int i = n-1; i>0;i--){
            if(a[i]<a[i-1]){
                swap(a[i],a[i-1]);
                b = true;
                ans++;
            }
        }
    }
    REP(i,n){
        cout << a[i];
        if(i != n-1){
            cout << " ";
        }
    }
    cout << endl;
    print(ans);

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 3084
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String day = sc.nextLine();

        if(day.equals("SUN")){
            System.out.println("7");
        }
        if(day.equals("SAT")){
            System.out.println("1");
        }
        if(day.equals("MON")){
            System.out.println("6");
        }
        if(day.equals("TUE")){
            System.out.println("5");
        }
        if(day.equals("WED")){
            System.out.println("4");
        }
        if(day.equals("THU")){
            System.out.println("3");
        }        
        if(day.equals("FRI")){
            System.out.println("2");
        }

    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
int isPrime(int x) {
  for (int i = 2; i * i <= x; i++) if (x % i == 0) return false;
  return true;
}
int main() {
  int n; cin >> n;
  for (;;) {
    if (isPrime(n)) {
      cout << n << endl;
      return 0;
    }
    n++;
  }
}

Measured memory_bytes: 256
from math import sin, cos, pi


class Point:

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __str__(self):
        return f"{self.x:.8f} {self.y:.8f}"


def kock(n, p1: Point, p2: Point):
    if n == 0:
        return
    s = Point(
        x=(2*p1.x + p2.x)/3,
        y=(2*p1.y + p2.y)/3
    )
    t = Point(
        x=(p1.x + 2*p2.x)/3,
        y=(p1.y + 2*p2.y)/3
    )
    u = Point(
        x=(t.x - s.x) * cos(pi / 3) - (t.y - s.y) * sin(pi / 3) + s.x,
        y=(t.x - s.x) * sin(pi / 3) + (t.y - s.y) * cos(pi / 3) + s.y
    )
    kock(n - 1, p1, s)
    print(s)
    kock(n - 1, s, u)
    print(u)
    kock(n - 1, u, t)
    print(t)
    kock(n - 1, t, p2)


def main():
    n = int(input())
    p1 = Point(0.0, 0.0)
    p2 = Point(100.0, 0.0)
    print(p1)
    kock(n, p1, p2)
    print(p2)

main()


Measured memory_bytes: 5776
#include <iostream>
#include <vector>
#define INF 1000000000
using namespace std;

struct edge { int a, b, c; };

int main() {
    int N, M, dp[100][100];
    edge E[1000];
    cin >> N >> M;
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            if(i == j) dp[i][j] = 0;
            else dp[i][j] = INF;
        }
    }
    for(int i=0; i<M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dp[a][b] = dp[b][a] = c;
        E[i] = (edge){a, b, c};
    }
    for(int k=0; k<N; k++) {
        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    int ans = 0;
    for(int i=0; i<M; i++) {
        int a = E[i].a, b = E[i].b, c = E[i].c;
        bool used = false;
        for(int s=0; s<N; s++) {
            for(int t=0; t<N; t++) {
                if(dp[s][t] == dp[s][a]+dp[b][t]+c || dp[s][t] == dp[s][b]+dp[a][t]+c) used = true;
            }
        }
        if(!used) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
 
  int a,b,c,d;
  
  scanf("%d%d%d%d",&a,&b,&c,&d);
  
  while(1)
  {
    c-=b;
    a-=d;
    if(c<=0)
    {
      printf("Yes\n");
        return 0;
    }
    else if(a<=0)
    {
      printf("No\n");
      return 0;
    }
  }
  
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i, j, k, l, n, m;
    cin>>n>>k;
    vector<ll> data(n + 1);
    for (i = 1; i <= n;i++)
        cin >> data[i];
    ll ini = 0;
    ll fina = 1e15;
    ll mid;
    ll p = 100;
    while(p--){
        mid = (ini + fina + 1) / 2;
        ll tot = 0;
        for (i = 1; i <= n;i++){
            if(data[i]%mid==0){
                tot += (data[i] / mid - 1);
            }
            else{
                tot += (data[i] / mid);
            }
        }
        if(tot>k)
            ini = mid;
        else
            fina = mid;
    }
    cout << mid << "\n";
    return 0;
}

Measured memory_bytes: 4776
import java.util.*;

class Main{
   public static void main(String[] args)
   {
      Scanner scan = new Scanner(System.in);
      int     X    = scan.nextInt();
      int     Y    = scan.nextInt();
      int     Z    = scan.nextInt();

      System.out.println((X - Z) / (Y + Z));
   }
}


Measured memory_bytes: 21844
N = int(input())
a, b, c = [0] * N, [0] * N, [0] * N

for i in range(N):
	a[i], b[i], c[i] = map(int, input().split())
 
dp = [[0] * 3 for _ in range(N)]

dp[0] = [a[0], b[0], c[0]]

for i in range(N - 1):
    dp[i + 1][0] = max(dp[i][1] + a[i + 1], dp[i][2] + a[i + 1])
    dp[i + 1][1] = max(dp[i][0] + b[i + 1], dp[i][2] + b[i + 1])
    dp[i + 1][2] = max(dp[i][0] + c[i + 1], dp[i][1] + c[i + 1])
    
print(max(dp[N-1]))

Measured memory_bytes: 34616
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_baccnt
#define mp macnte_pair
#define pi pair<int,int>
#define pii pair<pi,int>
#define sqr(x) ((x)*(x))
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int a[100005];
int main(){
	    int n,m;
	    cin>>n>>m;
	    int asd=0;
	    memset(a,0,sizeof(a));
	    for(int i=1;i<=m;i++){      
		    int x,y;        
		    cin>>x>>y;
		    if(asd>=0)asd=x;
		    int atd=a[x];
		    if(atd==0)a[x]=y; 
		    else if(atd>y)a[x]=y;}
	    int ans=1;
	    int cnt=a[asd];
	    for(int i=1;i<=n;i++){
		    if(a[i]==0)continue;
		    if(i>=cnt){ans++;cnt=a[i];}
		    else if(cnt>a[i])cnt=a[i];}
	    cout<<ans<<endl;
        return 0;}


Measured memory_bytes: 640
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll lc = c*d/__gcd(c,d);
	cout<<b-a+1+(b/lc-a/lc+(a%lc==0?1:0))-(b/c-a/c+b/d-a/d + (a%c==0?1:0)+(a%d==0?1:0));
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#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;
using namespace __gnu_pbds;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef vector<pii> vpii;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
    tree_order_statistics_node_update> ost;

const int N=210000;
char s[N];

int main() {
    int i, n, k, dk, r;
    char c;
    scanf("%d%d%s", &n, &k, s);
    for(r=0; r<n; r++) {
        dk=(r%2==1)^(s[r]=='A');
        dk++;
        if(k>=dk) k-=dk;
        else break;
    }
    if(r==n) {
        if(n%2==0) k=0;
        else k%=2;
    }
    for(i=0; i<n; i++) {
        if(i+r<n) {
            c=s[i+r];
            if(r%2) c='A'+'B'-c;
        }
        else {
            if((n+i)%2) c='A';
            else c='B';
        }
        s[i]=c;
    }
    if(k) s[0]='A'+'B'-s[0];
    printf("%s\n", s);
    return 0;
}

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

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& d: a) cin >> d;
    for (int i=1;i<=n;i++){
        cout << a[a.size()-i];
        if (i!=n){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3100
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var A = Sarray()[0];
            var B = Sarray()[0];
            var C = Sarray()[0];
            var X = Sarray()[0];
            var ans = 0;
            for(var i=0;i<=A;i++)
            {
                for (var j = 0; j <= B; j++)
                {
                    for (var k = 0; k <= C; k++)
                    {
                        if (i * 500 + j * 100 + k * 50 == X) ans++;
                    }
                }
            }
            WriteLine(ans);
        }

    }
}

Measured memory_bytes: 13652
#include<bits/stdc++.h>
using namespace std;
#define trav(a,v) for(auto a:v)
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main() {
	fastIO();
	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;
	}
}
// - VERIFICAR LONG VS INT -
  



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
 *
問題文
日本では、3 月 3 日にひなあられという、色のついたお菓子をお供えする習慣があります。

1 つの袋があり、ひなあられが N 個入っています。

この袋には、桃色、白色、緑色の 3 種類か、桃色、白色、緑色、黄色の 4 種類のひなあられが入っていることが分かっています。

桃色を P、白色を W、緑色を G、黄色を Y と表したとき、袋からひなあられを 1 粒ずつ取り出していったところ、i 番目に取り出したひなあられの色は Si でした。

この袋に 3 種類のひなあられが入っていた場合は Three、4 種類のひなあられが入っていた場合は Four と出力してください。

制約
1≤N≤100
Si は P か W か G か Y
Si=P、Sj=W、Sk=G を満たす i,j,k が必ず存在する
入力
入力は以下の形式で標準入力から与えられる。

N
S1 S2 … SN
 *
 *
 */
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		int N = sc.nextInt();
		List<String> stock = new ArrayList<String>();

		for(int i=0; i < N; i++) {
			String hinaarare = sc.next();
			if (stock.contains(hinaarare) == false) {
				stock.add(hinaarare);
			}
		}
		if (stock.size() == 3) {
			System.out.println("Three");
		} else {
			System.out.println("Four");
		}
	}
}


Measured memory_bytes: 21844
package main

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

var si = bufio.NewScanner(os.Stdin)

func readInt() int {
	si.Scan()
	r, _ := strconv.Atoi(si.Text())
	return r
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func isMinX(x, y int) bool {
	return x < y
}
func main() {
	si.Split(bufio.ScanWords)
	si.Buffer(make([]byte, 0), 10000000)
	N, M := readInt(), readInt()
	var a, b, e, f [50]int
	for i := 0; i < N; i++ {
		a[i], b[i] = readInt(), readInt()
		e[i] = 300000000
	}
	for i := 0; i < M; i++ {
		c, d := readInt(), readInt()
		for j := 0; j < N; j++ {
			if isMinX(abs(a[j]-c)+abs(b[j]-d), e[j]) {
				e[j] = abs(a[j]-c) + abs(b[j]-d)
				f[j] = i + 1
			}
		}
	}
	for i := 0; i < N; i++ {
		fmt.Println(f[i])
	}

}


Measured memory_bytes: 640