akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N , sum=0,Max=0,A;
  cin>>N;
  vector<int> ans(N);
  for(int i=0;i<N;i++){
    cin>>ans[i];
    sum+=ans[i];
  }
  A=sum;
  if(A%10!=0) cout<<A<<endl;
  else{
  for(int i=0;i<N;i++){
    sum=A;
    sum-=ans[i];
    if(sum%10!=0){
      Max=max(Max,sum);
    }
  }
  cout<<Max<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
using namespace std;

ll N, M;

int main()
{
    cin >> N >> M;

    if(M <= 2*N){
        cout <<  M / 2 << '\n';
    }
    else{
        cout << N + (M - 2*N)/4 << '\n';
    }

    return 0;
}



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

long long h, w, st[200005 << 2], lazy[200005 << 2], inf = 0x3F3F3F3F3F;

void push(int x, int l, int mid){
    if (!lazy[x]) return;
    st[x<<1] = lazy[x];
    lazy[x<<1] = lazy[x];
    st[x<<1|1] = lazy[x]+(mid-l+1);
    lazy[x<<1|1] = lazy[x]+(mid-l+1);
    lazy[x] = 0;
}
void update(int x, int l, int r, int ul, int ur, long long u){
    if (ul <= l && r <= ur){
        st[x] = u;
        lazy[x] = u;
        return;
    }
    int mid = (l+r) >> 1;
    push(x, l, mid);
    if (ul <= mid) update(x<<1, l, mid, ul, ur, u);
    if (mid < ur) update(x<<1|1, mid+1, r, ul, ur, u+max(0, (mid-max(ul,l)+1)));
    st[x] = min(st[x<<1], st[x<<1|1]);
}
int query(int x, int l, int r, int q){
    if (q == 0) return inf;
    if (l == r) return st[x];
    int mid = (l+r) >> 1;
    push(x, l, mid);
    if (q <= mid) return query(x<<1, l, mid, q);
    else return query(x<<1|1, mid+1, r, q);
}

int main() {
    cin >> h >> w;
    for (int i = 1, a, b; i <= h; i++){
        cin >> a >> b;
        update(1, 1, w, a, b, query(1, 1, w, a-1)+1);
        if (st[1] > w) cout << -1 << "\n";
        else cout << st[1]+i << "\n";
    }
}


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

using namespace std;
#define lint long long

int main() {
    int N;
    cin >> N;
    
    lint A[N];
    
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    
    lint cnt = A[0] - 1;
    A[0] = 1;
    
    lint P = 2;
  
    
    for(int i = 1; i < N; ++i){
        if(A[i] > P){
            lint num = (A[i] - 1) / P;
//            cout << num << " " << P << " ";
            cnt += num;
            if(A[i] % P == 0 && num >= 1){
                A[i] -= P * num + 1;
            } else {
                A[i] -= P * num;
            }
//            cout << A[i] << endl;
        }
        if(A[i] == P){
            ++P;
        }
        
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }




void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    map<string,int> map;
    
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        if(map.count(s)){
            map[s]++;
        }else{
            map.emplace(s,1);
        }
    }
    
    cout << map.size() << endl;
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 19148
cards = {
        'S': [0 for _ in range( 13)],
        'H': [0 for _ in range( 13)],
        'C': [0 for _ in range( 13)],
        'D': [0 for _ in range( 13)],
        }

n = int( input())
for _ in range( n):
    (s, r) = input().split()
    r = int(r)
    cards[s][r - 1] = r

for s in ( 'S', 'H', 'C', 'D'):
    for r in range( 13):
        if cards[s][r] == 0:
            print( '{0:s} {1:d}'.format( s, r+1))

Measured memory_bytes: 6724
import sys
N = int(input())
result = ""
if N == 0:
    print(0)
    sys.exit()
while N != 1:
    if N == -2:
        N = 10
        break
    result += str(N%2)
    if N%2:
        N = N//(-2) +1
    else:
        N = N//(-2)
print(str(N) + result[::-1])

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

int main(void)
{
	int n;
	char buf[256];
	
	
	while (fgets(buf, 256, stdin) != NULL){
		int ans;

		n = atoi(buf);
		ans = 0;
		for (int i = 0; i < 10; i++){
			for (int j = 0; j < 10; j++){
				for (int k = 0; k < 10; k++){
					for (int l = 0; l < 10; l++){
						if (i + j + k + l == n){
							ans++;
						}
					}
				}
			}
		}
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define pb push_back 

using namespace std;

typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n ;
	cin >> n;
	int p =n %10;
	string q;
	switch(p){
		case 0:q="pon";break;
		case 1:q="pon";break;
		case 3:q="bon";break;
		case 6:q="pon";break;
		case 8:q="pon";break;
		default: q ="hon";break;
		
	}
	cout << q <<"\n";


	return 0;
}




Measured memory_bytes: 3620
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main{
	private void solve(){
		String v=s.next();
		
		if(v.charAt(0)==v.charAt(1)) {
			System.out.println("1 2");
			return;
		}
		
		int f=REPS(v.length()-2)
		.filter(i->v.substring(i,i+3).chars().distinct().count()==2)
		.findFirst()
		.orElse(-1);
		
		System.out.println(f==-1?"-1 -1":(f+1)+" "+(f+3));
	}


	public static void main(String[]$){
		new Main().solve();
	}

	static Scanner s=new Scanner(System.in);


	static int gInt(){
		return s.nextInt();
	}
	static long gLong(){
		return s.nextLong();
	}
	static long gDouble(){
		return s.nextLong();
	}


	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

	static class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{

		int to,cur,d;

		Range(int from,int to,int d){
			this.cur=from-d;
			this.to=to;
			this.d=d;
		}

		Range(int n){
			this(0,n-1,1);
		}

		@Override
		public Iterator<Integer> iterator(){
			return this;
		}

		@Override
		public boolean hasNext(){
			return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
		}

		@Override
		public int nextInt(){
			return cur+=d;
		}
	}


	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}

	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}


	static IntStream ints(int n){
		return REPS(n).map(i->gInt());
	}

	static Stream<String> strs(int n){
		return REPS(n).mapToObj(i->s.next());
	}

}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    vector<int> a(3);
    for(int i = 0; i < 3; i++)
    {
        cin>>a[i];
    }
    sort(all(a));

    cout<<a[0]*a[1]/2<<endl;
    return 0;
}

Measured memory_bytes: 256
import Data.List

solve :: Int -> Int -> Int -> Int -> String -> Bool
solve a b c d s
  | c < d     = chk1 (part a c s) && chk1 (part b d s) 
  | otherwise = chk1 (part a c s) && chk1 (part b d s) && chk2 (part (b-1) (d+1) s)
  where
    part p q = take (q-p+1) . drop (p-1)
    chk1 = all (\g -> (head g == '.') || ((head g == '#') && length g < 2)) . group 
    chk2 = any (\g -> (head g == '.') && length g >= 3) . group 

main :: IO ()
main = do
    [_,a,b,c,d] <- map read . words <$> getLine :: IO [Int]
    s <- getLine :: IO String
    putStrLn $ if solve a b c d s then "Yes" else "No"

Measured memory_bytes: 13692
#include<stdio.h>
#include<ctype.h>

int main(void){
	char a;
	while(1){
		scanf("%c",&a);
		if(isalpha(a)){
			if(islower(a)){
				printf("%c",toupper(a));
			}
			else{
				printf("%c",tolower(a));
			}
		}
		else{
			printf("%c",a);
		}
		if(a=='\n')break;
	}
	return 0;
}

Measured memory_bytes: 524
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from typing import Iterable
import sys
def main(N, XY):
    uf = UnionFindTree(N)
    miny = []
    for x, y in sorted(XY, key=lambda x: x[0]):
        if not miny:
            miny.append(y)
            continue
        if y < miny[-1]:
            miny.append(y)
            continue
        t = 10**10
        while miny:
            if y > miny[-1]:
                py = miny.pop()
                uf.union(py, y)
                t = min(t, py)
            else:
                break
        miny.append(t)
    for x, y in XY:
        print(uf.size(y))

class UnionFindTree:
    def __init__(self, n: int) -> None:
        self.parent = [-1] * n

    def find(self, x: int) -> int:
        p = self.parent
        while p[x] >= 0: x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x: int, y: int) -> bool:
        x, y, p = self.find(x), self.find(y), self.parent
        if x == y: return False
        if p[x] > p[y]: x, y = y, x
        p[x], p[y] = p[x] + p[y], x
        return True

    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)

    def size(self, x: int) -> int:
        return -self.parent[self.find(x)]

    def same_all(self, indices: Iterable[int]) -> bool:
        f, v = self.find, self.find(indices[0])
        return all(f(i) == v for i in indices)

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    XY = [tuple(map(lambda x:int(x) - 1, input().split())) for _ in range(N)]
    main(N, XY)


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

int main(void) {
  long double A, B, H, M;
  cin >> A >> B >> H >> M;
  long double PI = 3.14159265358979;
  long double rad = 2.0*PI*((H+M/60.0)/12.0 - M/60.0);
  cout << fixed << setprecision(10);
  cout << pow(A*A + B*B - 2*A*B*cosl(rad), 0.5) << endl;
}

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


void solve(long long A, long long B){
    for(int i=1;i<5000;i++){
        if(floor(i*0.08) ==A && floor(i*0.1)==B){
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
require "date"
baseDate = Date.new(2012, 12, 21)
while input = gets
	if input.chomp! == "#"
		break
	end
	input = input.split(".").map(&:to_i)
	if input.length == 3
		days = ((Date.new(input[0], input[1], input[2]) - baseDate) % (20 * 18 * 20 * 20 * 13)).to_i
		output = [days / 20 / 18 / 20 / 20, days / 20 / 18 / 20 % 20, days / 20 / 18 % 20, days / 20 % 18, days % 20]
	else
		date = baseDate + (input[4] + input[3] * 20 + input[2] * 20 * 18 + input[1] * 20 * 18 * 20 + input[0] * 20 * 18 * 20 * 20)
		output = [date.year, date.month, date.day]
	end
	puts output.join(".")
end

Measured memory_bytes: 9016
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,m,a,b,ch[10000],L[10000],ans,cnt;
vector<ll> v[10000];
void dfs(ll x){
    ch[x]=L[cnt];
    cnt++;
    for(ll y:v[x]){
        if(ch[y]==0){
            dfs(y);
        }
    }
    return ;
}
int main(void){
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=0;i<n;i++){cin>>L[i];ans+=L[i];}
    sort(L,L+n);
    ans-=L[n-1];
    reverse(L,L+n);
    dfs(0);
    cout<<ans<<endl;
    for(int i=0;i<n;i++){
        cout<<ch[i]<<" ";
    }
    cout<<endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, k;
  cin >> n >> k;

  int digit = log(n) / log(k) + 1;

  cout << digit << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    string s;
    cin >> s;
    int q; cin >> q;
    bool r = false;
    string m,u;
    for(int i = 0; i < q; i++){
        int n;
        cin >> n;
        if(n == 2){
            int f;    cin >> f;
            string c; cin >> c;
            if(!r){
                if(f == 1) m = c + m;
                else u = u + c;
            }else{
                if(f == 2) m = c + m;
                else u = u + c;
            }
        }else{
            if(r) r=false;
            else r = true;
        }
    }
    s = m + s + u;
    if(r){
        for(int i = s.size()-1; i >= 0; i--){
            cout << s[i];
        }
    }else{
        cout << s;
    }
}

Measured memory_bytes: 1512
#include<bits/stdc++.h>
using namespace std;
int main(){

  int ans = 0;
  int x = 0;
  string s;

  cin >> s;

  for(int i=0;i<s.size();i++){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      x++;
      if(ans<x){
        ans = x;
      }
    }
    else{
      x = 0;
    }
  }

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


Measured memory_bytes: 256
# なんか問題文とサンプル読んでいくと「Pを素因数分解してN個で割り振る」みたいな感じかと思う
# なんかしらんけど5個くらいのケースでWA

# それぞれの掛け算だしpowなのが正解？？

n, p = map(int, input().split())


def div_primes(x):
    ret = {}
    for i in range(2, int(x**0.5) + 1):
        tmp = 0
        while x % i == 0:
            tmp += 1
            x //= i
        if tmp > 0:
            ret[i] = tmp

    if x > 1:
        ret[x] = 1
    return ret


ans = 1
for k, v in div_primes(p).items():
    if v // n >= 1:
        ans *= k**(v // n)
print(ans)

Measured memory_bytes: 63240
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
    int n,k;
    while(cin >> n >> k) {
        if(n == 0 && k == 0) break;

        vector<int> v(k);
        rep(i,k) cin >> v[i];

        bool flag = true;
        rep(i,n) {
            rep(j,k) {
                int x;
                cin >> x;
                v[j] -= x;

                if(v[j] < 0) {
                    flag = false;
                }
            }
        }

        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int H,W;
		
		H = in.nextInt();
		W = in.nextInt();
		
		while(H!=0 || W!=0){
			for(int i=0; i<H; i++){
				for(int j=0; j<W; j++){
					if(i==0 || i==H-1){
						System.out.print('#');
					}else{
						if(j==0 || j==W-1){
							System.out.print('#');
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println();
			}
			
			System.out.println();
			H = in.nextInt();
			W = in.nextInt();
		}
	}
}

Measured memory_bytes: 24668
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N;
	cin >> N;
	
	int min = N;
	for( int n1 = 0; n1 < 9 && n1 <= N/9 && min > n1; n1++ ) {
	//	cout << "n1=" << n1 << endl;
	for( int n2 = 0; n2 < 9 && n2 <= (N-9*n1)/81 && min > (n1+n2); n2++ ) {
	//	cout << "n2=" << n2 << endl;
	for( int n3 = 0; n3 < 9 && n3 <= (N-9*n1-81*n2)/729 && min > (n1+n2+n3); n3++ ) {
	//	cout << "n3=" << n3 << endl;
	for( int n4 = 0; n4 < 9 && n4 <= (N-9*n1-81*n2-729*n3)/6561 && min > (n1+n2+n3+n4); n4++ ) {
	//	cout << "n4=" << n4 << endl;
	for( int n5 = 0; n5 < 9 && n5 <= (N-9*n1-81*n2-729*n3-6561*n4)/59049 && min > (n1+n2+n3+n4+n5); n5++ ) {
	//	cout << "n5=" << n5 << endl;
		int z = (N-9*n1-81*n2-729*n3-6561*n4-59049*n5);
		//cout << "z=" << z << endl;
		int s6 = (z / 46656); z -= s6*46656;
		int s5 = (z / 7776); z -= s5*7776;
		int s4 = (z / 1296); z -= s4*1296;
		int s3 = (z / 216); z -= s3*216;
		int s2 = (z / 36); z -= s2*36;
		int s1 = (z / 6); z -= s1*6;
		int t = n1+n2+n3+n4+n5+s1+s2+s3+s4+s5+s6+z;
		if( t < min ) min = t;
	}
	}
	}
	}
	}
	cout << min << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  char t;
  int w=0,l=0;
  for(int i=0;i<s.size();i++){
    if(i%2==0)
      t='g';
    else
      t='p';
    if(s[i]=='g'&&t=='p')
      w++;
    else if(s[i]=='p'&&t=='g')
      l++;
  }
  cout<<w-l;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define     siii(a,b,c)       scanf("%d%d%d",&a,&b,&c)
#define     si(a)             scanf("%d",&a)
#define     sii(a,b)          scanf("%d%d",&a,&b)
#define     sl(a)             scanf("%lld",&a);
#define     sll(a,b)          scanf("%lld%lld",&a,&b);
#define     slll(a,b,c)       scanf("%lld%lld%lld",&a,&b,&c);
#define     sd(a)             scanf("%lf",&a);
#define     sdd(a,b)          scanf("%lf%lf",&a,&b);
#define     pb(a)             push_back(a)
#define     deb(a)            printf("### %d ###\n",a)
#define     mp                make_pair
#define     pf                printf
#define     fl(a, b, c)       for(int a= b ;a<c;a++)
#define     mx                100000 //10^5
#define     fread             freopen("input.txt","r",stdin)
#define     CLR(a,b)          memset(a,b,sizeof(a))
#define     ll                long long
#define     D(x)              cout<<#x" = "<<x<<endl;
#define     sz                10000
#define     bl                printf("\n")
#define     spc               printf(" ")

int main()
{
    int n, v[25], cost[25],ans=0;
    si(n);
    fl(i,0,n) si(v[i]);
    fl(i,0,n) si(cost[i]);
    fl(i,0,n){
        if(v[i] - cost[i]>0) ans+=(v[i]-cost[i]);
    }
    cout<<ans<<endl;
    





    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

long int func(long int n,long int a){
  long int ans=0,t,flag1=0,flag2=0,flag3=0;
  t=n;

  if(n>a) return 0;
  
  while(t>0){
    if(t%10==7) flag1=1;
    else if(t%10==5) flag2=1;
    else if(t%10==3) flag3=1;
    if((flag1+flag2+flag3)==3){
      ans=1;
      break;
    }
    t/=10;
  }
  ans+=func(10*n+3,a);
  ans+=func(10*n+5,a);
  ans+=func(10*n+7,a);
  
  return ans;
}

int main(void){
  long int ans,n;    
  scanf("%ld",&n);
  ans = func(0,n);
  printf("%ld",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200002 ;
ll  power(ll  i,ll  j)
{
    if(j==0)
    return 1 ;
    ll t=power(i,j/2)%maa ;
    if(j%2==0)
    return (t%maa*t%maa)%maa ;
    else
    return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
}
int main()
{
   fast ;
   ll a,b,c ;
   cin>>a>>b>>c ;
   ll cnt[10] ;
   memset(cnt,0,sizeof(cnt)) ;
   cnt[a]++ ;
   cnt[b]++ ;
   cnt[c]++ ;
   if(cnt[5]==2&&cnt[7]==1)
    cout<<"YES" ;
   else
    cout<<"NO" ;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;

long long pow_mod(long long x, long long n){
    long long ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

int main(){
    long long n,k;
    cin >> n >> k;
    long long cnt[k+1];
    long long ans = 0;
    for(long long i=k; i>=1; i--){
        long long t = k/i;
        long long u = pow_mod(t,n);
        for(long long j=2*i; j<=k; j+=i){
            u -= cnt[j];
            u %= mod;
        }
        cnt[i] = u;
        ans += i*u;
        ans %= mod;
    }
    cout << (ans+mod)%mod << endl;
    return 0;
}


Measured memory_bytes: 4344
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,W;
ll w[105],v[105];
ll dp[105][305][105]={};
int main(){
    cin>>N>>W;
    for(ll i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }

    for(ll i=0;i<N;i++){
        for(ll j=0;j<=3*N;j++){
            for(ll k=0;k<N;k++){
                ll ni=i+1;
                ll nj=j+w[i]-w[0];
                dp[ni][nj][k+1]=max(dp[ni][nj][k+1],dp[i][j][k]+v[i]);
                dp[ni][j][k]   =max(dp[ni][j][k],dp[i][j][k]);
            }
        }
    }
    ll ans=0;
    for(ll j=0;j<=3*N;j++){
        for(ll k=1;j+w[0]*k<=W;k++){
            ans=max(ans,dp[N][j][k]);
        }
    }
    cout<<ans<<endl;
    

    return 0;
}

Measured memory_bytes: 25216
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

//Union-Find
const int MAX_N=1000000;
int par[MAX_N];//親
int Rank[MAX_N];//木の深さ
int size[MAX_N];//子と自身の合計数（自身が根の時には集合のサイズを表す）


void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        Rank[i]=0;
        size[i]=1;
    }
}

//木の根を求める
int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)    return ;
    if(Rank[x]<Rank[y]){
        par[x]=y;
        size[y]+=size[x];
    }else{
        par[y]=x;
        size[x]+=size[y];
        if(Rank[x]==Rank[y])    Rank[x]++;
    }
}

bool same(int x,int y){
    return find(x)==find(y);
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m),y(m),z(m);
    for(int i=0;i<m;i++){
        cin >> x[i] >> y[i] >> z[i];
        x[i]--;
        y[i]--;
    }
    init(n);
    for(int i=0;i<m;i++){
        unite(x[i],y[i]);
    }
    set<int> st;
    for(int i=0;i<n;i++){
        if(st.find(find(i))==st.end()){
            st.insert(find(i));
        }
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 14592
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        String mae = "";
        String usiro = "";
        while(!word.equals("-")){
            int n = sc.nextInt();
            for(int i=0;i<n;i++){
                int a  = sc.nextInt();
                usiro = word.substring(a);
                mae = word.substring(0,a);
                word = usiro + mae;
            }
            System.out.println(word);
            word = sc.next();
        }
        sc.close();
    }
}


Measured memory_bytes: 26444
package main

import (
	"fmt"
)

func main() {
	var N int
	var X string
	fmt.Scan(&N, &X)
	f := make([]int, N)
	for n := range f {
		res := 0
		tmp := n
		for tmp != 0 {
			if f[tmp] != 0 {
				res += f[tmp]
				break
			}
			res++
			tmp %= pop(tmp)
		}
		f[n] = res
		// fmt.Printf("f[%d] = %d\n", n, f[n])
	}
	p := 0
	x := []rune(X)
	for _, b := range x {
		if b == '1' {
			p++
		}
	}
	sub := 0
	add := 0
	subPow := 1
	addPow := 1
	for i := N - 1; i >= 0; i-- {
		if x[i] == '1' {
			if p > 1 {
				sub = (sub + subPow) % (p - 1)
			}
			add = (add + addPow) % (p + 1)
		}
		if p > 1 {
			subPow *= 2
			subPow %= p - 1
		}
		addPow *= 2
		addPow %= p + 1
	}
	// fmt.Printf("p = %d, sub = %d, add = %d\n", p, sub, add)
	subPow = 1
	addPow = 1
	res := make([]int, N)
	for i := N - 1; i >= 0; i-- {
		if x[i] == '1' {
			if p == 1 {
				res[i] = 0
			} else {
				res[i] = f[(sub-subPow%(p-1)+p-1)%(p-1)] + 1
			}
		} else {
			res[i] = f[(add+addPow)%(p+1)] + 1
		}
		if p > 1 {
			subPow *= 2
			subPow %= p - 1
		}
		addPow *= 2
		addPow %= p + 1
	}
	for _, r := range res {
		fmt.Println(r)
	}
}

func pop(x int) int {
	res := 0
	for i := 1; i <= x; i *= 2 {
		if x&i != 0 {
			res++
		}
	}
	return res
}


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

constexpr int kDirections = 4;
constexpr int kDx[kDirections] = {-1, +1, 0, 0};
constexpr int kDy[kDirections] = {0, 0, -1, +1};

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

  int n;
  cin >> n;

  vector<int> p(n * n);
  for (int& e: p) {
    cin >> e;
  }

  vector<vector<int>> used(n, vector<int>(n, 0)), value(n, vector<int>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      value[i][j] = min({i, j, n - i - 1, n - j - 1});
    }
  }

  long long result = 0;
  for (int e: p) {
    --e;
    int x = e / n;
    int y = e % n;

    result += value[x][y];

    queue<pair<int, int>> q;
    q.push({x, y});
    used[x][y] = 1;
    while (!q.empty()) {
      int x = q.front().first;
      int y = q.front().second;
      q.pop();
      int cost = value[x][y] + (!used[x][y] ? 1 : 0);
      for (int dir = 0; dir < kDirections; ++dir) {
        int nx = x + kDx[dir];
        int ny = y + kDy[dir];
        if (nx < 0 || ny < 0 || nx >= n || ny >= n) continue;
        if (value[nx][ny] <= cost) continue;
        value[nx][ny] = cost;
        q.push({nx, ny});
      }
    }
  }

  cout << result << '\n';
}

Measured memory_bytes: 6064
def main():
    n = int(input())
    a_lst = list(map(int, input().split()))

    a_lst.insert(0, 0)
    a_lst.append(0)
    lst = []
    for i in range(n + 1):
        lst.append(abs(a_lst[i + 1] - a_lst[i]))

    tmp = sum(lst)
    tmp1 = sum(lst)
    answer_lst = []
    for i in range(n):
        for j in range(2):
            tmp1 -= lst[i + j]

        tmp1 += abs(a_lst[i + 2] - a_lst[i])
        answer_lst.append(tmp1)
        tmp1 = tmp

    for i in range(n):
        print(answer_lst[i])


if __name__ == '__main__':
    main()

Measured memory_bytes: 21176
from sys import stdin
rs = stdin.readline
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    N, K = ril()
    A = ril()
    l = 1
    r = 1000000000
    while l < r:
        m = (l + r) // 2
        k = 0
        for a in A:
            k += (a - 1) // m
        if k <= K:
            r = m
        else:
            l = m + 1
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 30888
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
	int a, b;
	int d, r;
	double f;

	cin >> a >> b;

	d = a / b;
	r = a % b;
	f = (double)a / (double)b;

	printf("%d %d %.5lf\n", d, r, f);

	return 0;
}

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

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;

int main(){
	int n; cin >> n; vector<int> v;
	Rep(i, n){ int t; cin >> t; v.pb(t-i-1); }
	sort(v.begin(), v.end());
	int b = 0;
	if(n%2 == 0){
		b = (v[n/2] + v[n/2 - 1]) /2;
	}else{
		b = v[n/2];
	}
	ll ans = 0;
	Rep(i, n){ ans += abs(v[i] - b); }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
a, b = map(int, input().split())
a1 = a/0.08
a2 = (a+1)/0.08

b1 = b/0.1
b2 = (b+1)/0.1


if a1.is_integer():
  x1 = a1
else:
  x1 = a1 + 1
if a2.is_integer():
  x2 = a2
else:
  x2 = a2 + 1
if b1.is_integer():
  y1 = b1
else:
  y1 = b1 + 1
if b2.is_integer():
  y2 = b2
else:
  y2 = b2 + 1
  
s1 = set([i for i in range(int(x1), int(x2))])
s2 = set([i for i in range(int(y1), int(y2))])
s = s1 & s2
if len(s) == 0:
  print(-1)
else:
  print(min(s1 & s2))

Measured memory_bytes: 9164
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    K=ii()
    A,B=mis()
    for i in range(A, B+1):
        if i%K == 0:
            print('OK')
            return
    print('NG')

main()



Measured memory_bytes: 9988
n = int(input())
l = len(str(n))
if l == 1:
    print(n)
if l == 2:
    print(9)
if l == 3:
    print(9 + (n - 99))
if l == 4:
    print(909)
if l == 5:
    print(909 + (n - 9999))
if l == 6:
    print(90909)

Measured memory_bytes: 3060
# input
n = int(input())

# 1. make validate graph fragment (all index are includede completely)
fragments = []
if n % 2 == 0:
    # even case: (1, n), (2, n-1), ..., (n//2, n//2+1)
    fragments = [(i + 1, n - i) for i in range(n // 2)]
else:
    # odd case: (1, n-1), (2, n-2), ..., (n//2-1, n//2+1), (n)
    fragments = [(i + 1, n - i - 1) for i in range(n // 2)]
    fragments.append((n,))

# 2. each vertex connect all vertex excepy for one's belonging graph's element
edges = []
for i, frag in enumerate(fragments):
    for vtx in frag:
        other_frags = fragments[:i] + fragments[i + 1:]
        edges.extend([(vtx, o_vtx) for o_frag in other_frags for o_vtx in o_frag])

# 3. delete duplicated edge (remain (a, b) edge for a < b)
for edge in edges[:]:
    if edge[0] > edge[1]:
        edges.remove(edge)


print(len(edges))
for edge in edges:
    print(' '.join(str(i) for i in edge))


Measured memory_bytes: 3976
#include<iostream>
using namespace std;
int main(){
    int x, y;
    int i = 1;
    
    while(i <= 3000){
        cin >> x >> y;
        if((x == 0) && (y == 0)) break;
        else if(x <= y) cout << x << " " << y << endl;
        else cout << y << " " << x << endl;
        i += 1;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
     
    int main() {
        std::ios_base::sync_with_stdio(false);
        std::cin.tie(nullptr);
        std::cout.tie(nullptr);
     
        int a, b;
      	std::cin >> a >> b;
        if (a > 9 || b > 9) {
            std::cout << "-1\n";
        } else {
            std::cout << a * b << '\n';
        }
        return 0;
    }

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


int main(){
	vector<int> nos(4);
	for(int i=0;i<4;i++) cin>>nos[i];
	sort(nos.begin(),nos.end());
	if(nos[0] == 1 && nos[1] == 4 && nos[2] == 7 && nos[3] == 9) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#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>;
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int x = 0, y = 0;
    for(int i = 1; i <= n; i++){
        x += 800;
        if(i%15 == 0) y += 200;
    }
    cout << x - y << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 root (x1-x2)^2 + (y1-y2)^2 = ((x1-x2) + (y1-y2))^2 - 2*(x1-x2)*(y1-y2)

 (x1-x2)*(y1-y2) = 0
 x1 = x2  
 or
 y1 = y2

 a = (x1 == x2)

 b = (y1 == y2)

 c = (x1==x2 && y1 == y2)

 c = c*(c-1)/2;


 a * b - c;
*/

#include<bits/stdc++.h>
using namespace std;
#define int int64_t
signed main(void)
{
    int n,w;
    cin>>n>>w;
    int we[n+1];
    int val[n+1];
    for (int i = 0; i <n; ++i)
    {
        cin>>we[i]>>val[i];	
    }
    int dp[n+1][w+1];

    for(int  i = 0;i<=n;i++)
    {
    	for(int j =0;j<=w;j++)
    	{
    		if(i==0 || j==0)
    			dp[i][j]=0;
    		else if(we[i-1]<=j)
    			dp[i][j] = max(dp[i-1][j-we[i-1]]+val[i-1],dp[i-1][j]);
    		else
    			dp[i][j]=dp[i-1][j];
    	}
    }

  cout<<dp[n][w]<<endl;

}



Measured memory_bytes: 79104
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
d=[0]*M
for i in range(M):
  x,y,c=map(int,input().split())
  d[i]=a[x-1]+b[y-1]-c
print(min(min(a)+min(b),min(d)))

Measured memory_bytes: 18736
#include <iostream>

int main()
{
	long long int l[100];
	l[0] = 2;
	l[1] = 1;
	
	int n;
	std::cin >> n;
	for (int i = 2; i <= n; ++i)
	{
		l[i] = l[i - 1] + l[i - 2];
	}
	
	std::cout << l[n];
}

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

int main(void){
    long long int n=0,n0=0,k=0;
    scanf("%lld %lld", &n,&k);
    long long int i=0,t=0;
	/*
    while(1){
      n0=labs(n-k);
      if(labs(n)<=labs(n0)){
        break;
      }
      i++;
      n = n0;
    }
    */
  t=n%k;
  if(t<k-t) printf("%lld", t);
  else printf("%lld", k-t);
    //printf("%lld\n", n);
    return 0;
}

Measured memory_bytes: 1704
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    while True:
        h, w = ZZ()
        if h == 0 and w == 0: break
        print('#' * w)
        for _ in range(h-2): print('#' + ('.' * (w-2)) + '#')
        print('#' * w)
        print('')

    return

if __name__ == '__main__':
    main()



Measured memory_bytes: 5628
import java.util.*;

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

        int N = sc.nextInt();
        int h[] = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }

        boolean mizuyari = true;
        int count = 0;
        int nowh[] = new int[N];
        while (mizuyari) {
            mizuyari = false;
            for (int i = 0; i < N; i++) {
                if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                }
            }
            if (mizuyari) {
                count++;
            }
        }

        System.out.println(count);
        sc.close();
    }
}

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

using L = std::vector<long long>;
using A = std::vector<std::vector<long long>>;
#define sorted(vector) sort(vector.begin(),vector.end())
#define vmin(vector) *min_element(vector.begin(),vector.end())
#define vmax(vector) *max_element(vector.begin(),vector.end())
#define vsum(vector) accumulate(vector.begin(),vector.end(),0)
#define append(a) push_back(a)
#define int(a) stoi(a)
#define str(a) to_string(a)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())

using namespace std;

int main(void) {
    int n,k;
    cin>>n>>k;
    L a(n+1,0);
    for(int i=1  ;i<n+1  ;i++){
        cin>>a[i];
    }
    sorted(a);
    cout<<n+1-bisect_left(a,k)<<endl;
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll maxn = 200005;
const ll N = 500005;
char s[200005];
ll dp[10005],n,p,ans=0;
int main(){  
	cin.tie(0); 
    ios::sync_with_stdio(false);
    cin>>n>>p>>(s+1);
    if(p==2||p==5){
        for(int i=1;i<=n;i++){
            if((s[i]-'0')%p==0){
                ans+=i;
            }
        }
    }
    else {
        ll tmp=0,base=1;
        for(int i=n;i>=1;i--){
            tmp=(tmp+(s[i]-'0')*base)%p;
            base=(base*10)%p;
            dp[tmp]++;  
        }
        ans+=dp[0]+1ll*dp[0]*(dp[0]-1)/2;
        for(int i=1;i<=p-1;i++) ans+=(dp[i]-1)*dp[i]/2;
    }
    cout<<ans;
	return 0;
}


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

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

    char skey = s[k-1];
    for (int i = 0; i < n; i++) {
        if (skey != s[i]) {
            cout << '*';
        }
        else cout << s[i];
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;cin>>a>>b>>c;
    if (c<b&&c>a)
    {
        /* code */
        cout<<"Yes"<<endl;
    }
    else if (c<a&&c>b)
    {
        /* code */
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define MOD 1000000007
#define pii pair<int,int>
#define unmap unordered_map<int,int>
#define ll long long int
#define mod 1000000007
using namespace std;

void solve() {
    int n, k;
    cin >> n >> k;
    ll shortSum = 0, longSum = 0;
    vector<ll> temp(n + 1);
    vector<ll> v(n + 2, 0);
    for (int i = 0; i <= n; i++)
    {
        temp[i] = (100 + i);
    }

    int i = 0, j = n;
    while (j >= 0)
    {
        shortSum += temp[i];
        longSum += temp[j];
        v[i + 1] = (longSum - shortSum) + 1;
        i++;
        j--;

    }
    ll ans = 0;

    for (int i = k; i <= n + 1; i++)
        ans = (ans % mod + v[i] % mod) % mod;

    cout << ans << "\n";





}





int main()
{


    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 6356
#include<stdio.h>
void swap(int *, int *);

int main(){
  
  /* iは未ソートの先頭
   * jは未ソートの隣合う要素の比較
   * flagは逆の隣接要素があるかないか
   */
  int  A[100],N,i,j,k,flag,cnt=0;

  //入力
  scanf("%d",&N);
  for(k=0; k<N; k++){
    scanf("%d",&A[k]);
  }

  //bubble sort
  flag = 1;
  i = 0;
  while(flag){
    flag = 0;
    for(j=N-1; j>=i+1; j--){
      if(A[j] < A[j-1]){
	swap(&A[j],&A[j-1]);
	flag = 1;
	cnt++;
      }
    }
    i++;
  }

  //出力
  for(k=0; k<N; k++){
    if(k>0) printf(" ");
    printf("%d",A[k]);
  }
  printf("\n");
  printf("%d\n",cnt);
  
  return 0;
}

void swap(int *a, int *b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
  return;
}
  



Measured memory_bytes: 2144
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		for(int i = 1; i <= n; i++){
			int x = i;
			if(x % 3 == 0){
				System.out.print(" " + i);
			}else{
				do{
                    if(x % 10 == 3){
                        System.out.printf(" %d",i);
                        break;
                    }
                    x /= 10;
                }while(x != 0);
			}
		}
		System.out.println();
	}
}


Measured memory_bytes: 34068
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()

    ans = (1 if N == 1 else N - 2) * (1 if M == 1 else M - 2)
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10048
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }


long long gcd(long long a, long long b){
    if(a == 0) return b;
    return gcd(b%a, a);
}
long long lcm(long long a, long long b){
    return a*b/gcd(a, b);
}


int main(){
    long long N, M;
    cin >> N >> M;
    vector<long long> a(N);
    REP(i, N) cin >> a[i];
    REP(i, N) a[i] = a[i] / 2;


    int ev = a[0]&(-a[0]);
    REP(i, N) if((a[i]&(-a[i]))!=ev){
        cout << 0 << endl;
        return 0;
    }

    long long l = 1;
    REP(i, N){
        l = lcm(l, a[i]);
        if(l > M){
            cout << 0 << endl;
            return 0;
        }
    }

    long long cnt = M / l;
    long long ans = (1+cnt)/2;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int a, b, c; cin >> a >> b >> c;
	int ans = -1; int ab = a + b;
	rep(i, 0, 60) {
		int arrive = i * 60 + c;
		if (arrive%ab <= a) {
			ans = arrive;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	int dp[n];
	dp[0] = 0;
	for(int i=1;i<n;i++){
	    dp[i] = INT_MAX;
	    for(int j=1;j<=k;j++){
	        if(i>=j){
	            dp[i] = min(dp[i], abs(arr[i] - arr[i - j]) + dp[i - j]);
	        }else break;
	    }
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S;
	cin >> S;
	if (S.size() == 3) reverse(S.begin(), S.end());
	cout << S << endl;
}


Measured memory_bytes: 256
/*
  0202 何人で行っても奢らせる
  どんな人数でも奢ってもらえる = 合計が素数のとき

  簡易ザックで合計以下の時の最大を出して、上から順に素数判定
*/
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, max;
    boolean[] knap;
    boolean[] prime;
    int[] price;

    void run(){
	prime = new boolean[1000001];
	setP();
	while(sc.hasNext()){
	    n = sc.nextInt();
	    max = sc.nextInt();
	    if(n==0 && max==0) break;


	    price = new int[n];
	    for(int i=0; i<n; i++)
		price[i] = sc.nextInt();

	    knap = new boolean[max+1];
	    knap[0] = true;


	    // ナップザックすたーと
	    for(int i=0; i<n; i++){
		for(int k=price[i]; k<knap.length; k++)
		    if(knap[k-price[i]]){
			knap[k] = true;
		    }
	    }
    
	    int x = knap.length-1;
	    while(x>0 && !(prime[x] && knap[x])) x--; 

	    System.out.println(x>0 ? x:"NA");
	}
    }

    void setP(){
	Arrays.fill(prime, true);
	prime[0] = prime[1] = false;
	for(int i=2; i<prime.length; i++)
	    if(prime[i])
		for(int k=i+i; k<prime.length; k+=i)
		    prime[k] = false;
    }
}

Measured memory_bytes: 61432