akhauriyash/Code-Regression huggingface dataset:
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7
INF = float("inf")

N,M,P = map(int,(input().split()))
line = []
for i in range(M):
    a,b,c = map(int,(input().split()))
    line.append([a-1,b-1,-c+P])

min_distance = [INF]*N # min_distance[i] は始点から街iまでの最短距離
min_distance[0] = 0 # 始点から始点への最短距離は0とする

def Bellman_Ford(S,V,E,distance):
    flag = 0
    for _ in range(V):
        update = False
        for s,g,d in distance: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
            if min_distance[s] != INF and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
                min_distance[g] = min_distance[s] + d # 最短距離を上書きする
                update = True
        if not update:
            flag = 1
            break
    return min_distance,flag

def Bellman_Ford2(S,V,E,distance):
    for _ in range(V):
        for s,g,d in distance: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
            if min_distance[s] != INF and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
                min_distance[g] = -INF
                if g == N-1:
                    break
        else:
            continue
        break
    return min_distance

min_distance,flag = Bellman_Ford(1,N,M,line)

if flag == 1:
    ans = min_distance[N-1]
    print(max(-ans,0))
else:
    min_distance = Bellman_Ford2(1,N,M,line)
    ans = min_distance[N-1]
    if ans == -INF:
        print(-1)
    else:
        print(max(-ans,0))

#print(min_distance)

Measured memory_bytes: 70304
var s1,s2:ansistring;
var n,i,j:longint;
var c1,c2:char;
function max(s1,s2:ansistring):ansistring;
var i:longint;
var s3:ansistring;
begin
  if length(s1)>length(s2) then begin s3:=s1;s1:=s2;s2:=s3;end;
  for i:=1 to length(s1) do if s1[i]>s2[i] then exit(s1) else
  if s1[i]<s2[i] then exit(s2);
  exit(s2);
end;
procedure qsort(l,r:longint;var s:ansistring);
var i,j:longint;
var c,mid:char;
begin
  i:=l;j:=r;mid:=s[(l+r)>>1];
  repeat
    while s[i]>mid do inc(i);
    while s[j]<mid do dec(j);
    if i<=j then begin
      c:=s[i];s[i]:=s[j];s[j]:=c;
      inc(i);dec(j);
    end;
  until i>j;
  if l<j then qsort(l,j,s);
  if i<r then qsort(i,r,s);
end;
procedure qsort1(l,r:longint;var s:ansistring);
var i,j:longint;
var c,mid:char;
begin
  i:=l;j:=r;mid:=s[(l+r)>>1];
  repeat
    while s[i]<mid do inc(i);
    while s[j]>mid do dec(j);
    if i<=j then begin
      c:=s[i];s[i]:=s[j];s[j]:=c;
      inc(i);dec(j);
    end;
  until i>j;
  if l<j then qsort1(l,j,s);
  if i<r then qsort1(i,r,s);
end;
begin
  readln(s1);readln(s2);{c2:=chr(1);c1:=chr(ord('z')+1);
  for i:=1 to length(s1) do if c1>s1[i] then c1:=s1[i];
  for i:=1 to length(s2) do if c2<s2[i] then c2:=s2[i];
  writeln(c1,' ',c2);q
  if c1<c2 then writeln('Yes') else if c1>c2 then writeln('No')
  else if (c1=c2) and (max() then writeln('Yes')
  else writeln('No');    }
  qsort1(1,length(s1),s1);qsort(1,length(s2),s2);
  if (max(s1,s2)=s2) and (s1<>s2) then writeln('Yes') else writeln('No');
end.

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

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

int main(){
  int a, b, c, k;
  
  scanf("%d %d %d", &a, &b, &c);
  scanf("%d", &k);
  
  int ans = 0;
  rep(i,100){
    if(a<b)break;
    else{
      b*=2;
      ans++;
    }
  }
  rep(i,100){
    if(b<c)break;
    else{
      c*=2;
      ans++;
    }
  }
  
  if(ans>k)printf("No");
  else printf("Yes");
  
  return 0;
}


Measured memory_bytes: 3728
n=int(input())
v=list(map(int,input().split()))

dE={};dO={}
for i in range(n):
    dX=dE if i%2==0 else dO
    if v[i] in dX:
        dX[v[i]]+=1
    else:
        dX[v[i]]=1

lE=sorted(list(dE.items()),key=lambda x:x[1],reverse=True)
lO=sorted(list(dO.items()),key=lambda x:x[1],reverse=True)

me=lE[0][1];mo=lO[0][1]
ae=lE[0][0];ao=lO[0][0]

se=0 if len(lE)==1 else lE[1][1]
so=0 if len(lO)==1 else lO[1][1]

if ae==ao:
    ans=n-max(me+so,mo+se)
else:
    ans=n-(me+mo)

print(ans)

Measured memory_bytes: 64748
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll n;
    cin >> n;
    vector<string> A(n);
    rep(i, n) {
        cin >> A[i];
        sort(ALL(A[i]));
    } 
    sort(ALL(A));
    ll ans = 0;
    rep(i, n - 1) {
        ll cnt = 1;
        if(A[i] == A[i + 1]) {
            while(i < n - 1 && A[i] == A[i + 1]) {
                cnt++;
                i++;
            }
            ans += cnt * (cnt - 1) / 2;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int n, m;
vector<int> g[51];
pair<int, int> rcd[51];
bool vis[51];

void dfs(int f, int vr1, int vr2)
{
	vis[f] = 1;
	for (int i = 0; i < g[f].size(); i++)
	{
		if ((f == vr1 && g[f][i] == vr2) || (f == vr2 && g[f][i] == vr1) || vis[g[f][i]] == 1) continue;
			dfs(g[f][i], vr1, vr2);
	}
}

int main()
{
	cin >> n >> m;
	int f, t;
	for (int i = 1; i <= m; i++)
	{
		cin >> f >> t;
		g[f].push_back(t);
		g[t].push_back(f);
		rcd[i] = make_pair(f, t);
	}
	
	int cnt = 0;
	for (int i = 1; i <= m; i++)
	{
		memset(vis, 0, sizeof(vis));
		
		bool s = 0;
		int a = rcd[i].first, b = rcd[i].second;
		for (int i = 1; i <= n; i++)
		{
			if (vis[i] == 0)
			{
				if (s == 0)
				{
					dfs(1, a, b);
					s = 1;
				}
				else 
				{
					cnt++;
					break;
				}
			}
		}
	}
	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
char s[50][51];
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
int main() {
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> s[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '.') continue;
			bool ok = 0;
			for (int k = 0; k < 4; k++) {
				int ni = i + dy[k];
				int nj = j + dx[k];
				if (ni<0 || ni>H || nj<0 || nj>W) continue;
				if (s[ni][nj] == '#') {
					ok = 1;
					break;
				}
			}
			if (!ok) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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 gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n,m,R; cin>>n>>m>>R;
  vi r(R); rep(i, R){cin >> r[i]; r[i]--;}
  ll G[n][n];
  rep(i, n) rep(j, n) G[i][j] = INF;
  rep(i, m){
    int a,b,c; cin>>a>>b>>c;
    a--; b--;
    G[a][b] = c; G[b][a] = c;
  }

  rep(k, n) rep(i, n) rep(j, n) chmin(G[i][j], G[i][k] + G[k][j]);

  sort(all(r));
  ll ans = INF;
  do {
    ll sum = 0LL;
    rep(i, R-1) sum += G[r[i]][r[i+1]];
    chmin(ans, sum);
  } while(next_permutation(all(r)));

  std::cout << ans << '\n';
}


Measured memory_bytes: 512
import java.util.Scanner;

//Frequency Distribution of Height
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] s = new int[6];
		int n = sc.nextInt();
		while(n--!=0){
			double x = sc.nextDouble();
			for(int i=0;i<6;i++)if(x<165+5*i||i==5){s[i]++;break;}
		}
		for(int i=0;i<6;i++){
			System.out.print((i+1)+":");
			while(s[i]--!=0)System.out.print('*');
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
main :: IO ()
main = do
    [a,b,c,d] <- map read . words <$> getLine
    putStrLn . toAnswer $ balance a b c d

toAnswer :: Ordering -> String
toAnswer GT = "Left"
toAnswer EQ = "Balanced"
toAnswer LT = "Right"

balance :: Int -> Int -> Int -> Int -> Ordering
balance a b c d = left `compare` right
  where
    left  = a + b
    right = c + d


Measured memory_bytes: 508
A, B = map(int, input().split())

def XORACC(a):
    if a % 4 == 0:
        return a
    elif a % 4 == 1:
        return 1
    elif a % 4 == 2:
        return a + 1
    else:
        return 0

print(XORACC(A - 1) ^ XORACC(B))

Measured memory_bytes: 3064
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    long long a, b, c, d;
    cin >> a >> b >> c >> d;

    auto gcd = [&](long long a, long long b) {
        while (a != 0) {
            b %= a;
            swap(a, b);
        }
        return b;
    };
    auto lcm = [&](long long a, long long b) {
        return a / gcd(a, b) * b;
    };

    auto count = [&](long long n, long long a, long long b) {
        if (n <= 0) {
            return 0LL;
        }
        long long res = n - n / a - n / b + n / lcm(a, b);
        return res;
    };

    long long res = count(b, c, d) - count(a - 1, c, d);
    
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 100005;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
    ll N;
    cin>>N;
    ll T=pow(4, 9);
    ll Count=0;
    for(ll i=0; i<T; i++){
      	//cout<<'A'<<endl;
       ll Num=0;
      	ll TT=i;
      	vector<bool> ZTFS(4, false);
      	bool OK=true;
      	for(int i=0; i<9; i++){
          	int K=TT%4;
          	TT/=4;
          	ZTFS[K]=true;
          	Num+=pow(10, i)*(K==0?0:(K+1)*2-1);
          	if(ZTFS[0]&&K>0){
              	OK=false;
              	break;
            }
        }
      	if(OK&&ZTFS[1]&&ZTFS[2]&&ZTFS[3]&&Num<=N){
          	Count++;
          	//cout<<T<<" "<<Num<<endl;
        }
    }
    cout<<Count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9 + 5;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}




using namespace std;
int main(){
    ll n,W;
    cin >> n >>W;
    vector<vector<ll>> dp(n+1,vector<ll>(110000));
    
    ll w[110],v[110];

    for(int i=1;i<=n;i++){
        cin >> w[i] >> v[i];
    }
    for(int j = 1; j< 110000; j++){
        dp[0][j] = INF;
    }
    for(int i = 1;i<=n;i++){
        for(int j = 0;j < 110000;j++){
            dp[i][j] = dp[i-1][j];
            if(j-v[i] >= 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
            }
        }
    }
    int  ans = 0;
    for(int i = 0;i < 110000;i++){
        if(dp[n][i] <= W){
            ans = max(ans, i);
        }
    }

    cout << ans <<endl;

}





Measured memory_bytes: 90856
n = int(input())
k = int(input())
xs = list(map(int, input().split()))

min_list = []
for x in xs:
    min_ = min(abs(x), abs(x-k))
    min_list.append(min_)

total = 0
for m in min_list:
    total += 2*m
print(total)

Measured memory_bytes: 38384
// C - Attack Survival

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int point[100000];

int main(){
	int N, K, Q;
	cin >> N >> K >> Q;

	int start = K - Q;
	for (int i=0; i<N; i++) {
		point[i] = start;
	}

	int A;
	for (int i=0; i<Q; i++) {
		cin >> A;
		point[A-1]++;
	}

	for (int i=0; i<N; i++) {
		if (point[i] > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}

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

int main() {

	const ll mod = 1000000007;
	ll n; cin >> n;
	ll ans = 1;
	for (ll i = 1; i <= n; i++) {
		ans *= i;
		ans %= mod;
	}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String[] str = s.split("");
        int rCount = 0;
        int bCount = 0;
        for (int i = 0; i < n; i++) {
            if ("B".equals(str[i])) {
                bCount++;
                continue;
            }
            rCount++;
        }
        if (rCount > bCount) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout<<fixed<<setprecision(y)<<x;
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define endl            "\n"
#define f(i,n)          for(int i=0 ; i<n ; i++)
#define SIZE            200000
#define mod             1000000007


void ish_8()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}

bool prime(int n)
{
  if(n<2)
    return false;
  for(int i=2 ; i<=sqrt(n) ; i++)
  {
    if(n%i == 0)
      return false;
  }
  return true;
}

int  power(int a, int b) {
 int rs = 1;
 while(b>0) {
  if(b & 1) rs *= a;
  a = a*a;
  b >>= 1;
}
return rs;
}


int log_a_to_base_b(int a, int b) 
{ 
  if(b==1)
    return 0;
  return log(a) / log(b); 
} 


double kthRoot(double n, int k) {
  return pow(k, (1.0 / k) * (log(n) / log(k))); 
}

int factorial(int n)
{
  if(n==0)
  {
    return 1;
  }
  return n*factorial(n-1);
}

void solve()
{
 int x;
 cin>>x;
 if(x==0)
  cout<<"1"<<endl;
else
  cout<<"0"<<endl;
}

int32_t main()
{
  ish_8();
  //w(t)
  //{
    solve();
  //}
}



Measured memory_bytes: 3696
n=int(input())
l=list(map(int,input().split()))
mod=1000000000000000000
ans=1
p=1
if(l.count(0)>=1):
    ans=0
else:
    for i in range(0,n):
        x=l[i]
        p=p*x
        if(p>mod):
            ans=-1
            break
if(ans!=0 and ans!=-1):
    ans=p
print(ans)
  
  


Measured memory_bytes: 84688
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

ans=0
for i in range(n):
  if a[i]<=b[i]:
    ans=ans+a[i]
    a[i],b[i]=a[i]-a[i],b[i]-a[i]
  else:
    ans=ans+b[i]
    a[i],b[i]=a[i]-b[i],b[i]-b[i]

  if a[i+1]<=b[i]:
    ans=ans+a[i+1]
    a[i+1],b[i]=a[i+1]-a[i+1],b[i]-a[i+1]
  else:
    ans=ans+b[i]
    a[i+1],b[i]=a[i+1]-b[i],b[i]-b[i] 
    
print(ans)
             
    
  

Measured memory_bytes: 24204
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
    int n, A = 0;
    cin >> n;
    vector<int> a(n), s(n);
    for (int& i : a) cin >> i, A ^= i;
    for (int i : a) cout << (A ^ i) << " ";
    return 0;
}


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

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    if (N*A<B){
        cout << N*A << endl;
    }
    if (N*A>B){
        cout << B << endl;
    }
    if (N*A==B){
        cout << B << endl;
    }
}

Measured memory_bytes: 256
def b():
    red, green, blue = map(int, input().split())
    k = int(input())

    for i in range(k):
        if green <= red:
            green *= 2
        elif blue <= green:
            blue *= 2
        else:
            print('Yes')
            return

    if blue > green > red:
        print('Yes')
    else:
        print('No')


##########
if __name__ == "__main__":
    b()


Measured memory_bytes: 9168
N = int(input())
sum = 1000
A = list(map(int, input().split()))
pre = A[0]
greater = False
less = False
for a in A[1:]:
  if greater:
    if pre > a:
      less = True
      greater = False
      sum = sum % i + (sum // i) * pre
  elif less:
    if pre < a:
      greater = True
      less = False
      i = pre
  else:
    if pre > a:
      less = True
    elif pre < a:
      greater = True
      i = pre
  pre = a
if greater:
  sum = sum % i + (sum // i) * pre
print(sum)

Measured memory_bytes: 9208
#include <iostream>

int N, A, B;

bool is_ok(int num, int A, int B) {
    bool flag=false;
    int res = 0;

    while (num > 0) {
        res += num%10;
        num /= 10;
    }
    if (A<=res && res<=B) flag = true;
    return flag;
}

int main() {
    int res=0;
    std::cin >> N >> A >> B;
    for (int num=1; num<=N; num++) {
        if ( is_ok( num, A, B ) ) res += num;
    }
    std::cout << res << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    int back = 0;
    int l = 0;
    for (int i = 0; i < n; ++i)
    {
        if (s[i] == '(')
            l++;
        else
            l--;
        if (l < 0)
            back++, l++;
    }
    for (int i = 0; i < back; ++i)
        cout << '(';
    cout << s;
    for (int i = 0; i < l; ++i)
        cout << ')';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  if(a.size()==b.size()){
    if(a>b)cout<<"GREATER"<<endl;
    else if(a==b)cout<<"EQUAL"<<endl;
    else cout<<"LESS"<<endl;
  }
  else{
    if(a.size()>b.size())cout<<"GREATER"<<endl;
    else cout<<"LESS"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
//const ll MOD = 1000000007ll;
const ll MOD = 998244353ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう

int main(){
    itn n;
    std::cin >> n;
    std::vector<int> x(n),l(n);
    rep(i,n)std::cin >> x[i]>>l[i];
    std::vector<P> a(n);
    rep(i,n){
        a[i].fi=x[i]-l[i];
        a[i].se=x[i]+l[i];
    }
    sort(all(a),gre(P));
    int ans=1;
    int p=a[0].fi;
    rrep(i,1,n){
        if(p<a[i].se)continue;
        else{
            ans++;
            p=a[i].fi;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 1792
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)

    while(true) {
      val s = scanner.next
      if(s.equals("-")) System.exit(0)
      val m = scanner.nextInt
      val l = Seq.fill(m)(scanner.nextInt).sum % s.length
      println(s.substring(l, s.length) + s.substring(0, l))
    }
  }
}



Measured memory_bytes: 45252
import java.util.*;
import java.lang.Character;

class Main {
  public static void main(String[] args) {
    Map<Integer, String> map = new HashMap<Integer, String>();
    Scanner scanner = new Scanner(System.in);
    int length = scanner.nextInt();
    int target = scanner.nextInt();
    String line = scanner.next();
    for (int i = 0; i < length; i++) {
      if (i == target - 1) {
        System.out.print(Character.toLowerCase(line.charAt(i)));
      }
      else {
        System.out.print(line.charAt(i));
      }
    }
  }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5 && b==5 && c==7)
        cout<<"YES"<<endl;

    else if(a==7 && b==5 && c==5)
        cout<<"YES"<<endl;

    else if(a==5 && b==7 && c==5)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

biggest = max(a)
base = biggest / 2

res = None
diff = float("inf")
for elem in a:
    if diff > abs(base - elem):
        diff = abs(base - elem)
        res = elem
if biggest != res:
    print(biggest, res)
else:
    print(biggest, 0)

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


int main() {
	int n,q;
	string s;
	int l[100001], r[100001];
	cin >> n >> q;
	cin >> s;
	for (int i = 1; i <= q; i++) {
		cin >> l[i] >> r[i];
	}
	int flag[100002];
	for (int i = 0; i <= n; i++) {
		flag[i] = 0;
	}
	for (int i = 0; i < n - 1; i++) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			flag[i]++;
		}
	}
	int num[100002];
	int sum = 0;
	for (int i = 0; i < n - 1; i++) {
		sum += flag[i];
		num[i] = sum;
	}




	for (int i = 1; i <= q; i++) {
		int ans;
		if (l[i] == 1) {
			ans = num[r[i] - 2];
		}
		else {
			ans = num[r[i] - 2] - num[l[i] - 2];
		}
		cout << ans << endl;
	}

	return 0;

}

Measured memory_bytes: 2560
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	LL N;
	cin >> N;
	LL NN = N+1;
	deque<int> bits;
	deque<int> Rans;
	LL temp = NN;
	while( temp ){//NNの2進数表現を計算
		bits.push_front( temp&1 );
		temp >>= 1;
	}

	Rans.push_back(1);
	int num = 2;//次にRansへ追加する数
	//LL X = 2;
	int size = bits.size();
	for(int i=1;i<size;++i){
		if( bits[i] == 1 ){
			Rans.push_front( num );
			++num;
		}
		if( i+1 < size ){
			Rans.push_back( num );
			++num;
		}
	}
	size = Rans.size();
	cout << 2*size << endl;
	for(int i=0;i<size;++i){
		if( i ) cout << " ";
		cout << i+1;
	}
	for(int i=0;i<size;++i){
		cout << " ";
		cout << Rans[i];
	}
	cout << endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if (a-b == b-c) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

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

      String a = sc.nextLine();
      char c;
      int sum = 700;

      for(int i = 0;i<3;i++){
        c = a.charAt(i);
        if(c=='o'){
          sum = sum + 100;
        }
      }

        System.out.println(sum);

  }
}


Measured memory_bytes: 23764
def main():
    
    A, B = map(int, input().split())

    bit_num = calc_bit_num(B)

    xor = [0] * bit_num
    ret = 0
    for k in range(bit_num):
        period = 2 ** k
        if (num_1_until(B, period) - num_1_until(A-1, period)) % 2 == 1:
            xor[k] = 1
            ret += period

    print(ret)
    return ret

def calc_bit_num(n):

    q = n
    count = 0
    
    while q > 0:
        q = q // 2
        count += 1    

    return count

def num_1_until(num, period):

    if period == 1:
        if ((num+1) // 2) % 2 == 0:
            return 0
        else:
            return 1

    q, r = (num+1) // period, (num+1) % period

    if q % 2 == 1 and r % 2 == 1:
        return 1
    else:
        return 0


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
using namespace std;

string s,t;

int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	
	cin>>s;
	cin>>t;
	int l = s.length();
	int count = 0;
	rep(i, 0, l-1)
	{
		if(s[i] != t[i])
			count ++;
	}
	cout<<count;
}

Measured memory_bytes: 3872
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cini(n);
	cinai(p, n);
	int mi = n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		mi = min(mi, p[i]);
		if (p[i] <= mi)
			ans++;
	}
	cout << ans << endl;
}

int main() {
	cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	solve();
}



Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <map>
const int MAXN = 1E5+5;
std::map<int,int> chain;
int array[MAXN]{ };
int Ans=0, N;

int main()
{
	scanf("%d", &N);
	for(int i = 0; i < N; ++i)
	{
		scanf("%d", &array[i]);
		chain[array[i]] = i&1;
	}
	std::sort(array, array+N);
	for(int i = 0; i < N; ++i)
		if((i&1) != chain[array[i]])
			++Ans;
	printf("%d\n", Ans>>1);
	return 0;
}

Measured memory_bytes: 5248
package main

import (
	"fmt"
)

func main() {
	var (
		H, W, A, B int
	)
	fmt.Scanf("%d %d %d %d", &H, &W, &A, &B)
	res := make([][]rune, H)
	for i := 0; i < H; i++ {
		res[i] = make([]rune, W)
	}
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if i < B {
				if j < A {
					res[i][j] = '1'
				} else {
					res[i][j] = '0'
				}
			} else {
				if j < A {
					res[i][j] = '0'
				} else {
					res[i][j] = '1'
				}
			}
		}
	}
	for i := 0; i < H; i++ {
		fmt.Println(string(res[i]))
	}
}


Measured memory_bytes: 6784
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($H,$W,$M) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));
$bomb=array();
for($i=0;$i<$M;$i++) {
  list($h,$w) = array_map('intval',explode(" ",trim(fgets(STDIN))));
  $h--;
  $w--;
  $bomb[$h][$w]=1;
  if (isset($hbomb[$h])) {
    $hbomb[$h]++;
  }
  else {
    $hbomb[$h]=1;
  }
  if (isset($wbomb[$w])) {
    $wbomb[$w]++;
  }
  else {
    $wbomb[$w]=1;
  }
}
$hmax=max($hbomb);
$ih=array();
//設置可能行数
foreach($hbomb as $h=>$v) {
  if ($v==$hmax) {
    $ih[]=$h;
  }
}
//設置可能列数
$wmax=max($wbomb);
$iw=array();
foreach($wbomb as $w=>$v) {
  if ($v==$wmax) {
    $iw[]=$w;
  }
}
$ans=$hmax+$wmax;
foreach($ih as $hh) {
  foreach($iw as $ww) {
    if (isset($bomb[$hh][$ww])) continue;
    printf("%d\n",$ans);
    exit;
  }
}
$ans--;
printf("%d\n",$ans);


Measured memory_bytes: 193532
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define se second
#define endl "\n"
#define pii pair<int, int>

#define PI 3.14159265358979323846
const int N = 1e5 + 10;
const int INF=2e9;

int maxi,cnt;

int q,h[N],n;

void solve() {
    cin>>n>>q;
     string s;
      cin>>s;
      int len=s.size();
      
      for(int i=0;i<len;i++) {
		      if(s[i]=='A' && s[i+1]=='C') {
				     h[i+1]=cnt;
				    cnt++;
				  }
			  else
			      h[i+1]=cnt;	  
				   
		  }
		  
		   
		 // for(int i=1;i<=len;i++)
		   //   cout<<h[i]<<" "; 
		      
		      cout<<endl;
		  
		  for(int i=0;i<q;i++) {
			       int x,y;
			       cin>>x>>y;
			       if(x==1) {
					    cout<<h[y]<<endl;
					   }
					   
			     else
			       cout<<h[y]-h[x]<<endl;			  
			  }
		 
     
}


int32_t main() {
  fast;
  int t = 1;
  while (t--)
	solve();

  return 0;
}


Measured memory_bytes: 1872
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5;
struct Element
{
    int u,v,opt;
} p[N+3];
int fa[N+3];
ll n,q,c,m;

int find(int u) {return fa[u]==u?u:fa[u]=find(fa[u]);}

int main()
{
    cin>>n>>m>>q;
    for(int i=1; i<=n; i++) fa[i] = i;
    for(int i=1; i<=q; i++)
    {
        scanf("%d%d%d",&p[i].u,&p[i].v,&p[i].opt); p[i].u++; p[i].v++;
        if(p[i].opt==0)
        {
            int uu = find(p[i].u),vv = find(p[i].v);
            if(uu!=vv) {fa[uu] = vv;}
        }
    }
    ll huan = 0; c = 0;
    
    for(int i=1; i<=n; i++) {if(i==find(i)) c++;}
    for(int i=1;i<=q;i++){
        if(p[i].opt==1){
            huan++;
            if(find(p[i].u)==find(p[i].v)){
                printf("No\n");
                return 0;
            }
        }
    }
    
    ll temp=m-(n-c);
    ll l,r;
    l = huan?max(3ll,(ll)c):c-1ll,r = 1ll*c*(c-1ll)/2ll;
    if(l<=temp&&temp<=r)
        printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 1792
n, m = map(int, raw_input().split())
A = map(int, raw_input().split())
S = 0
for i in xrange(n-1):
    S += (m + A[i+1] - A[i]) % m

T = 2*m
D = [0]*(T+10)
data = [0]*(T+1)
def get(i):
    s = 0
    while i:
        s += data[i]
        i -= i & -i
    return s
def add(i, x):
    while i <= T:
        data[i] += x
        i += i & -i

for i in xrange(n-1):
    x = A[i]; y = A[i+1]
    if y < x:
        y += m
    k = y-x
    if k > 1:
        D[x+2] += 1
        D[y+1] -= k
        D[y+2] += k-1
for i in xrange(1, 2*m+5):
    D[i] += D[i-1]
    add(i, D[i])
res = min(S - (get(a) + get(a+m)) for a in A)
print res


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

int main(){
    string S="MARCH";
    vector <ll> c(5,0);
    int N; cin >> N;
    rep(i,N){
        string T; cin >> T;
        rep(j,5){
            if (T[0]==S[j]) c[j]++;
        }
    }
    
    ll ans=0;
    for (int i=0; i<5; i++){
        for (int j=i+1; j<5; j++){
            for (int k=j+1; k<5; k++){
                ans+=c[i]*c[j]*c[k];
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int h, w;
  cin >> h >> w;
  vector<string> orig(h);
  for (int i = 0; i < h; i++) {
    cin >> orig[i];
  }
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (orig[i][j] == '#') {
        cout << '#';
        continue;
      }
      
      bool has_left = j != 0;
      bool has_right = j != w - 1;
      bool has_up = i != 0;
      bool has_down = i != h - 1;
      int cnt = 0;
      cnt += has_up && orig[i - 1][j] == '#';
      cnt += has_down && orig[i + 1][j] == '#';
      cnt += has_right && orig[i][j + 1] == '#';
      cnt += has_left && orig[i][j - 1] == '#';  
      cnt += has_up && has_left && orig[i - 1][j - 1] == '#';
      cnt += has_up && has_right && orig[i - 1][j + 1] == '#';
      cnt += has_down && has_left &&  orig[i + 1][j - 1] == '#';
      cnt += has_down && has_right && orig[i + 1][j + 1] == '#';
      cout << cnt;
    }
    
    cout << '\n';
  }
  return 0;
}

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

int main(){
  const int Ndata= 5;
  vector<int> data(Ndata);
  for(int i=0; i<Ndata; i++){
    cin >> data.at(i);
  }
  int K;
  cin >> K;

  string ans= (data.at(Ndata-1)- data.at(0) > K) ? ":("
                                                 : "Yay!";

  cout << ans << endl;
}

Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = [int(i) for i in input().split()]
a = []
for i in range(n):
    a_in = [int(i) for i in input().split()]
    a.append(a_in)
#ここまで入力
count = 0
for i in a:
    daisyo = 0
    for j in range(m):
        daisyo += b[j]*i[j]
    if daisyo+c > 0:
        count += 1
print(count)

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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

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

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }

int main(){
    int H, W;
    cin >> H >> W;
    REP(i, H)REP(j, W) {
        string S;
        cin >> S;
        if(S == "snuke") cout << (char)('A' + j) << (i + 1) << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char [] c = s.toCharArray();
    char c2 ='a';
    char []alphabet = new char[26];
    for (int i = 0; i < 26; i++){
        alphabet[i] = c2++;
    }
    for(int i=0;i<26;i++){
      if(c[0]==(alphabet[i])){
        System.out.println(alphabet[i+1]);
        return;
      }
    }
         
  }
  

  
}

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

int main()
{
	stack<int> S1;
	stack<pair<int, int>> S2;
	vector<int> ans;
	string s;
	getline(cin, s);
	int A = 0, j, a;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == '\\')
			S1.push(i);
		if (s[i] == '/' && !S1.empty())
		{
			j = S1.top();
			S1.pop();
			A += i - j;
			a = i - j;
			while (!S2.empty() && S2.top().first > j)
			{
				a += S2.top().second;
				S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}
	while (!S2.empty())
	{
		ans.push_back(S2.top().second);
		S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << A << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size(); i++)
		cout << " " << ans[i];
	cout << endl;
	return 0;
}



Measured memory_bytes: 3320
#include<stdio.h>

int main(){
	
	int Y1 = 500, Y2 = 5, amount, H1, H2, H3, H4, H5, H6;
	
	scanf("%d",&amount);
	H1 = amount/Y1;
	H2 = 1000*H1;
	H3 = amount%Y1;
	H4 = H3/Y2;
	H5 = 5*H4;
	H6 = H2 + H5;
	printf("%d\n",H6);
	return 0;
}

Measured memory_bytes: 128
def solve():
    x,n=map(int,input().split())
    if not n==0:
        p=list(map(int,input().split()))
    else:
        print(x)
        return
    
    for i in range(0,100):
        
        if not (x-i) in p:
            print(x-i)
            return
        
        if not (x+i) in p:
            print(x+i)
            return
        
        
solve()

Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  ll x;
  cin>>x;

  cout<<(x^1)<<endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

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

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

const ll L = 1e5+5;

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

bool cmp(pll f, pll s)
{
    if(f.ss == s.ss)
    {
        return f.ff > s.ff;
    }

    return f.ss > s.ss;
}

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

    ll N, M;
    cin >> N >> M;

    map <ll, vector <ll>> m;

    for(ll i=0; i<N; i++)
    {
        ll a, b;
        cin >> a >> b;

        if(a <= M)
        {
            m[M-a].pb(b);
        }
    }

    multiset <ll> s;

    ll reward = 0;

    for(ll i=M; i>=0; i--)
    {
        for(auto j: m[i])
        {
            s.insert(j);
        }

        if(!s.empty())
        {
            ll temp = *--s.end();

            // cout << temp << endl;
            reward+=temp;

            s.erase(s.lower_bound(temp));
        }
    }

    cout << reward << endl;

    return 0;
}

Measured memory_bytes: 13540
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let s: Vec<char> = read::<String>().chars().collect();
  let n: usize = s.len();
  println!("{}{}{}", s[0], n-2, s[n-1]);
}


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

int main()
{
    int n,m;
    cin >> n >> m;
    int x[m];
    for(int i=0;i<m;++i) cin >> x[i];
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    sort(x,x+m);
    int y[m-1];
    int sum=0;
    for(int i=0;i<m-1;++i){
        y[i] = x[i+1] - x[i];
        sum += y[i];
    }
    sort(y,y+m-1,greater<int>());
    for(int i=0;i<n-1;++i) sum -= y[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18
const int N = 100010;//10^5+10

const int MAX_N = 2000;
int a[MAX_N], n, x;
int f[MAX_N][MAX_N];

int main() {
	
	//入力
	int n; cin >> n;

	vector<int> a(n);
	vector<int> b(n);

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

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

	//高さの変更があった点、確定点を記録。
	vector<int> pat(n, 0);

	int L = -INF;
	//高さの変更があった点は、確定のはず。
	for (int i = 0; i < n; i++) {
		if (L < a[i]) {
			pat[i] = 1;
			L = a[i];
		}
	}

	//青木くんの記録を調べる。
	int R = -INF;

	//後ろから見ていって
	for (int i = n - 1; i >= 0; i--) {

		//前回より大きい場所がみつかった
		if (R < b[i]) {

			//高橋くん側からみても確定点だったら等しくないと矛盾。
			if (pat[i] && a[i] != b[i]) { cout << 0 << endl; return 0; }
			pat[i] = 1; R = b[i];
		}
		else {

			//青木くん側で更新がなくても、高橋くん側からみて更新があった点
			//なら青木くんからみた高さは低くないといけない。
			//これは過去の履歴なので、青木くんが高くても矛盾しない。(1WA)
			if (pat[i] && a[i] > b[i]) { cout << 0 << endl; return 0; }
		}
	}

	LL ans = 1;

	//確定してない点のうち、低いほうの積をとっていけば答え。
	for (int i = 0; i < n; i++) {
		if (!pat[i])pat[i] = min(a[i], b[i]);
		(ans *= pat[i]) %= MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
import sys
input = lambda: sys.stdin.readline().rstrip()

N, M, Q = map(int, input().split())

l = []

for i in range(Q):
    a,b,c,d = map(int, input().split())
    l.append((a,b,c,d))

ans = 0
stack = [[1]]

while stack:
    a = stack.pop()
    if len(a) == N:
        score = 0
        for j in l:
            if a[j[1]-1] - a[j[0]-1] == j[2]:
                score += j[3]   
        ans = max(score, ans)
    else:
        for k in range(a[-1], M+1):
            s = a[:]
            s.append(k)
            stack.append(s)
print(ans) 

Measured memory_bytes: 73956
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n=inp()
    s=list(input())
    for i in range(len(s)):
        x = ord(s[i])
        x+=n
        if x>=91:
            x-=26
        s[i]=chr(x)
    print(''.join(s))

if __name__ == "__main__":
    main()

Measured memory_bytes: 4336