akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

template<std::uint64_t Mod> struct ModInt{
    using u64=uint64_t;
private:
    u64 a;
public:
    constexpr ModInt(){}
    constexpr ModInt(u64 x=0):a(x%Mod){}

    constexpr u64 &value(){return a;}
    constexpr const u64 &value()const{return a;}


    constexpr ModInt &operator+=(const ModInt rhs){
        a+=rhs.value();
        if(a>=Mod){
            a-=Mod;
        }
        return *this;
    }

    constexpr ModInt &operator-=(const ModInt rhs){
        if(a<rhs.value()){
            a+=Mod;
        }
        a-=rhs.value();
        return *this;
    }

    constexpr ModInt &operator*=(const ModInt rhs){
        a=a*rhs.value()%Mod;
        return *this;
    }

    constexpr ModInt &operator/=(ModInt rhs){
        u64 n=Mod-2;
        while(n>0){
        if((n&1)!=0){//n%2==1
            *this*=rhs;
        }
        rhs*=rhs;
        n=n/2;
        }
        return *this;
    }

    constexpr ModInt operator+(const ModInt rhs){
        return ModInt(*this)+=rhs;
    }

    constexpr ModInt operator-(const ModInt rhs){
        return ModInt(*this)-=rhs;
    }

    constexpr ModInt operator*(const ModInt rhs){
        return ModInt(*this)*=rhs;
    }

    constexpr ModInt operator/(const ModInt rhs){
        return ModInt(*this)/=rhs;
    }
    constexpr ModInt &operator++(){
        ++a;
        if(a>=Mod){
            a-=Mod;
        }
        return *this;
    }

    constexpr ModInt &operator--(){
        if(a==0){
            a+=Mod;
        }
        --a;
        return *this;
    }

    constexpr ModInt operator- (){
        if(a==0)return ModInt(0);
        else return ModInt(Mod-a);
    }


};

using Mi=ModInt<1000000007ull>;

Mi operator"" _mi(unsigned long long n){
    return Mi(n);
}

using namespace std;
using ll = long long;

int main() {
    unsigned long long N,M;
    cin>>N>>M;
    if(N==1) {
        cout<<Mi(M+1).value()<<endl;
        return 0;
    }
    Mi n(N),m(M);
    Mi ans(0);

    unsigned long long D;
    D=(M+1)/(N-1);
    Mi d(D);

    ans=(m+1)*d-(n-1)*d*(d+1)/(2_mi);
    ans*=2_mi;
    ans+=Mi(m+1);
    cout<<ans.value()<<endl;


    return 0;
}



Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Linq;

namespace Elementary_data_structures
{
    class AOJ_Queue
    {
        static int quantum;

        static void Main(string[] args)
        {
            var given = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var n = given[0];
            quantum = given[1];

            var queue = new Queue<Process>();

            for (int i = 0; i < n; i++)
                queue.Enqueue(new Process(Console.ReadLine().Split(' ')));

            var time = 0;
            while (queue.Count > 0)
            {
                var p = queue.Dequeue();
                var t = p.Handle();
                if (t == -1)
                {
                    time += quantum;
                    queue.Enqueue(p);
                }
                else
                {
                    time += t;
                    Console.WriteLine(p.name + " " + time);
                }
            }
        }

        struct Process
        {
            public string name;
            public int time;
            public Process(string[] s)
            {
                name = s[0];
                time = int.Parse(s[1]);
            }

            public int Handle()
            {
                if (time <= quantum) return time;
                else
                {
                    time -= quantum;
                    return -1;
                }
            }
        }
    }
}

Measured memory_bytes: 15244
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(a, b, n) for(int i = 0; i < n; i++) b[i] = a[i]

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::pair <ll, ll> pll;
using namespace std;

void solve(){
    int n, m;
    cin >> n >> m;
    map <int, pii> a;
    
    for(int i = 0; i < m; i++){
        int x;
        string y;
        cin >> x >> y;
        if(y == "AC") a[x].second = 1;
        else if(a[x].second != 1) a[x].first += 1;
    }
    
    int ans1 = 0, ans2 = 0;
    for(auto &i : a){
        if(i.second.second == 1){
            ans1 += 1;
            ans2 += i.second.first;
        }
    }
    cout << ans1 << ' ' << ans2;
    
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("file.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}



Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

typedef long long LL;

const int MAXN=400;

LL n, m, ans, cntW, cntB;
bool visited[MAXN][MAXN];
string s[MAXN];

bool avail(int i, int j, char c){
	if(i < 0 || i >= n || j < 0 || j >= m) return false;
	if(s[i][j] == c) return false;
	return true;
}

void dfs(int i, int j){
	if(i < 0 || i >= n || j < 0 || j >= m) return;
	if(visited[i][j]) return;

	visited[i][j] = true;
	if(s[i][j] == '.') cntW++;
	else cntB++;
	if(avail(i, j - 1, s[i][j])) dfs(i, j - 1);
	if(avail(i, j + 1, s[i][j])) dfs(i, j + 1);
	if(avail(i + 1, j, s[i][j])) dfs(i + 1, j);
	if(avail(i - 1, j, s[i][j])) dfs(i - 1, j);
}

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

	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			visited[i][j] = false;

	ans = 0;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			if(!visited[i][j]){
				cntB = 0; cntW = 0;

				dfs(i, j);
				ans += cntB * cntW;
			}
	cout << ans << "\n";
}

Measured memory_bytes: 21428
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    long H,W,minimum,i,k,count;
    
    
    
    cin>>H>>W;
    
    while(H!=0 || W!=0)
    {
        for(k=0;k<W;k++)
            {
                cout<<"#";
            }
            cout<<endl;
        
        for(i=2;i<H;i++)
        {
            cout<<"#";
            for(k=2;k<W;k++)
            {
                cout<<".";
            }
            cout<<"#";
            cout<<endl;
        }
        
        for(k=0;k<W;k++)
            {
                cout<<"#";
            }
            cout<<endl;
        
        
        
        cin>>H>>W;
        cout<<endl;
        
    }
    
    

    

    
    
    
    
    return 0;
    
}



Measured memory_bytes: 3112
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N,Q=mint()
node=[list() for _ in range(N+1)]
done=[0]*(N+1)
X=[0]*(N+1)
for _ in range(N-1):
    a,b=mint()
    node[a].append(b)
    node[b].append(a)
for _ in range(Q):
    p,x=mint()
    X[p]+=x
q=deque([1])
while len(q)>0:
    i=q.popleft()
    done[i]=1
    for j in node[i]:
        if not done[j]:
            X[j]+=X[i]
            q.append(j)
lprint(X[1:],' ')

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

using namespace std;

int G[10010][10010];
int cost[10010],src[10010],dst[10010];

int P[10010];
int root(int a);
int is_same_set(int a,int b);
void unite(int a,int b);

int main() {
	int N,a;
	cin >> N;
	for(int i=0; i<N;i++) {
		for(int j=0;j<N;j++) {
			cin >> a;
			G[i][j] = a;
		}
	}
	int hcon = 1;
	int M = 0;
	pair<int,int> edges[10010];

	for(int r=0;r<N;r++) {
		for (int c=0;c<hcon;c++) {
			if(G[r][c] > -1) {
				cost[M] = G[r][c];
				src[M] = r;
				dst[M] = c;
				edges[M] = make_pair(cost[M],M);
				M+=1;
			}
		}
		hcon++;
	}
	sort(edges,edges+M);



	for(int i=0;i<N;i++) P[i] = i;

	int answer = 0;
	for(int i=0;i<M;i++) {
		if(!is_same_set(src[edges[i].second],dst[edges[i].second])) {
			unite(src[edges[i].second],dst[edges[i].second]);
			answer += edges[i].first;
			//cout << answer << endl;
		}
	}
	cout << answer << endl;;
}

int root(int a) { 
	if (P[a] == a) return a; 
	return (P[a] = root(P[a])); 
}
int is_same_set(int a, int b) { 
	if(root(a) == root(b)) {
		return 1;
	} else {
		return 0;
	}
}
void unite(int a, int b) { 
	P[root(a)] = root(b);
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int w, a, b; cin >> w >> a >> b;

    if (a < b) {
        if (a + w < b) {
            cout << b - a - w << endl;
        } else {
            cout << 0 << endl;
        }
    } else {
        if (b + w < a) {
            cout << a - b - w << endl;
        } else {
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char str[200];
    int i, length=200;
    scanf("%[^\n]", str);
    for(i=0; i<length; i++)
    {
        if(str[i]>=97 && str[i]<=122)
        {
            str[i]='A'+(str[i]-'a');
        }
    }
    printf("%s\n", str);
    return 0;
}



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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define scint(x) scanf("%d", &x)
#define sclng(x) scanf("%ld", &x)
typedef long long ll;

int main(){
    int X;
    scint(X);
    if(X == 7 || X == 5 || X == 3){
        printf("YES\n");
    }else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
s = list(map(int,input().split()))
if n >= m:
    print(0)
else:
    t = []
    s.sort()
    for i in range(m-1):
        t.append(s[i+1]-s[i])
    t.sort()
    r = t[:m-n]
    print(sum(r))

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int i;
    bool flag = true;
    
    
    if(n %2 ==0){
        for(i=0;i<n/2;i++){
            if(s[i] != s[i+n/2]){
                flag = false;
            }
        }
        if(flag){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        
    }else{
        cout << "No" << endl;
    }
    

    
    return 0;
}
    

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int x, y;
    cin >> x >> y;
    if ((4 * x - y) >= 0 && (4 * x - y) % 2 == 0 && (y - 2 * x) >= 0 && (y - 2 * x) % 2 == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	vector<ll>a(4);
	rep(i,4){
		cin>>a[i];
	}
	ll ans=a[0]*a[2];
	rep(i,2){
		rep(j,2){
			ans=max(ans,a[i]*a[j+2]);
		}	
	}
	cout<<ans<<endl;

}

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


Measured memory_bytes: 3652
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
vector<long long> f(1000010);   //f.at(i): i!(をmodで割りながら求めたもの)
vector<long long> rf(1000010);  //rf.at(i): 1/(i!)をmodで割りながら求めたもの
long long n, k;
long long inv(long long x) {//ここでは逆元を求める
    long long res = 1;
    long long k = mod - 2;
    long long y = x;
    while (k) {//繰り返し二乗法を用いている
        if (k & 1) res = (res * y) % mod;//kが存在かつ値 k == 1
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {//ここで
    f.at(0) = 1;
    for(long long i = 1; i < 100010; i++){
        f.at(i) = (f.at(i - 1) * i) % mod;
        rf.at(i) = inv(f.at(i));//逆元も同時にメモ
    }//n!をmodで割っていったものを求めている
}
//---------------------------------------------------------------------------------------------------
long long C(long long n, long long k) {
    long long a = f.at(n); // = n!%mod
    long long b = rf.at(n - k); // = (n-k)!%mod
    long long c = rf.at(k); // = k!%mod

    long long bc = (b * c) % mod;
    if(n == 0 || n == k){
        return 1;
    }

    return (a * bc) % mod;
}
vector<long long>an(100010);
long long INF;
long long ans;
long long tmpmax;
long long tmpmin;
long long tmpc;
void solve(){
    ans = 0;
    for(int i = 0; i < n - k + 1; i++){
        tmpc = C(n - i - 1, k - 1);
        tmpmax = an.at(n - 1 - i) % mod;
        dump(tmpmax);
        tmpmax *= tmpc;
        tmpmax %= mod;
        dump(tmpmax);
        tmpmin = an.at(i) % mod;
        dump(tmpmin);
        tmpmin *= tmpc;
        tmpmin %= mod;
        dump(tmpmin);
        ans += tmpmax;
        ans %= mod;
        ans -= tmpmin;
        ans %= mod;
        dump(ans);
    }
    ans += mod;
    ans %= mod;
    cout << ans << endl;
}
int main(){
    //dbg = true;
    INF = mod;
    cin >> n >> k;
    init();
    for(int i = 0; i < an.size(); i++){
        an.at(i) = INF;
    }
    for(int i = 0; i < n; i++){
        cin >> an.at(i);
    }
    sort(an.begin(),an.end());
    solve();
    return 0;
}



Measured memory_bytes: 16640
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

const int MOD = 1e9 + 7;
int N;
vector<map<string, ll>> cnt;
string S[4] = {"A", "C", "G", "T"};

bool is_valid(string s) {
    REP(i, 4) {
        string t = s;
        if (i > 0) {
            swap(t[i - 1], t[i]);
        }
        if (t.find("AGC") != string::npos) {
            return false;
        }
    }
    return true;
}

ll dfs(int i, string s) {
    if (cnt[i].count(s) > 0) {
        return cnt[i][s];
    }
    if (i == N) {
        return 1;
    }
    ll res = 0;
    REP(j, 4) {
        string t = s + S[j];
        if (is_valid(t)) {
            res = (res + dfs(i + 1, t.substr(1))) % MOD;
        }
    }
    cnt[i][s] = res;
    return res;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    cnt = vector<map<string, ll>>(N + 1);
    cout << dfs(0, "ZZZ") << endl;
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include<string>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <cstdlib>
//#include <vector.h>
//#include <malloc.h>

#include <math.h>
using namespace std;
#include<stdlib.h>
#include<stdio.h>
int main(){
    int b,n;
    string a="";
    char pre[2*100002];
    int pr=0;
    char suf[2*100002];
    int su=0;
    char c;
    cin>>a;
    cin>>n;
    int r=0;
    for(int i=0;i<n;i++){
        cin>>b;
        if(b==1){
            r++;
        }
        else{
            cin>>b>>c;
            if((r&1)==0){
                if(b==1){
                    pre[pr++]=c;
                   // a=c+a;
                }
                else{
                    suf[su++]=c;
                    //a=a+c;
                }
            }
            else{
                if(b==1){
                    suf[su++]=c;
                    //a=a+c;
                }
                else{
                    pre[pr++]=c;
                    //a=c+a;
                }
            }
        }
    }
    pre[pr]=0;
    suf[su]=0;

    //a+="";
    if((r&1)==1){
        for(int i=su-1;i>=0;i--){
            cout<<suf[i];
        }
        for(int i=a.size()-1;i>=0;i--){
            cout<<a[i];
        }
        cout<<pre;
        cout<<"\n";
    }
    else{
        for(int i=pr-1;i>=0;i--){
            cout<<pre[i];
        }
        cout<<a<<suf<<"\n";
    }
    return 0;
}


Measured memory_bytes: 1024
from itertools import product


def main():
    S = input()

    ans = 0
    for op in product(["", "+"], repeat=len(S) - 1):
        op = list(op)
        op.append("")
        ans += eval(''.join(a + b for a, b in zip(S, op)))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39408
#include <iostream>
using namespace std;
int c[3][3];
int main(void){
    // Your code here!
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    bool uso = true;
    int a = c[0][1] - c[0][0], b = c[0][2] - c[0][0];
    for (int i = 1; i < 3; i++) {
        if (c[i][1] - c[i][0] != a || c[i][2] - c[i][0] != b) uso = false; 
    }
    if (uso) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        // 格納
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        String word = scan.next();
        String word1;
        if(a <= word.length()){
            word1 = word.substring(0,a);
            if(word1.length() < word.length()){
                System.out.println(word1 + "...");
            }else{
                word1 = word.substring(0,a);
                System.out.println(word1);
            }
        }else{
            System.out.println(word);
        }
    }
}
        

Measured memory_bytes: 38644
#include<stdio.h>
int main()
{
int a,b,i,j,c;
  c=0;
  scanf("%d %d",&a,&b);
int k[a],sw[b];
  for(i=0;i<b;++i)
  {
  sw[i]=0;
  }
  
  for(i=0;i<a;++i)
  {
  scanf("%d",&k[i]);
    int love[k[i]];
    for(j=0;j<k[i];++j)
    {
    scanf("%d",&love[j]);
      sw[love[j]-1]++;
    }
  }
  
  for(i=0;i<b;++i)
  {
  if(sw[i]==a) c++;
  }
  printf("%d",c);
return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;

void b_good_distance(void) {
	int n, d;
	int x[20][20] = { 0 };
	cin >> n >> d;
	for (int j = 1; j <= n; j++) {
		for (int i = 1; i <= d; i++) {
			cin >> x[j][i];
		}
	}

	int cnt = 0;

	for (int j = 1; j < n; j++) {
		for (int i = j + 1; i <= n; i++) {
			double sum = 0;
			for (int k = 1; k <= d; k++) {
				int diff = x[j][k] - x[i][k];
				sum += pow(diff, 2.0);
			}
			double root = sqrt(sum);
			int root_int = (int)root;
			if (root - root_int == 0)cnt++;
		}
	}

	cout << cnt << endl;
	
}

int main()
{
    b_good_distance();

    return 0;
}

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

int main(){
    int n;
    std::string str;
    std::string fr = "Hoshino";
    std::string to = "Hoshina";
    std::string::size_type pos;
    std::cin >> n;
    std::cin.get();
    
  
        //文字列の読み込み
    while(n > 0 && std::getline(std::cin, str)){
        //"Hoshino"を"Hoshina"に変換
        pos = str.find(fr);
        while(pos != std::string::npos){
            str.replace(pos, fr.size(), to);
            pos = str.find(fr, pos+to.size());
        }
        //表示
        std::cout << str << std::endl;
        str = "";
        std::cin.clear();
        --n;
    }
}



Measured memory_bytes: 3168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class B_167_EasyLinearProgramming
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var nArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long A = nArray[0];
            long B = nArray[1];
            long C = nArray[2];
            long K = nArray[3];

            long result = 0;

            if (K <= A)
            {
                result = K;
            }
            else if (K - A <= B)
            {
                result = A;
            }
            else if (K - A - B <= C)
            {
                result = A - (K - A - B);
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27888
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <functional>
#include <string>
#include <cmath>
using namespace std;
#pragma warning (disable: 4996)

long long N, K, T[1 << 18], D[1 << 18], V[1 << 18]; vector<long long>X[1 << 18];
vector<long long>G, I;

int main() {
	cin >> N >> K;
	for (int i = 1; i <= N; i++) cin >> T[i] >> D[i];
	for (int i = 1; i <= N; i++) X[T[i]].push_back(D[i]);
	for (int i = 1; i <= N; i++) {
		sort(X[i].begin(), X[i].end());
		reverse(X[i].begin(), X[i].end());
	}
	for (int i = 1; i <= N; i++) {
		if (X[i].size() == 0) continue;
		G.push_back(X[i][0]);
		for (int j = 1; j < X[i].size(); j++) I.push_back(X[i][j]);
	}
	sort(G.begin(), G.end()); reverse(G.begin(), G.end());
	sort(I.begin(), I.end()); reverse(I.begin(), I.end());
	for (int i = 1; i <= I.size(); i++) V[i] = V[i - 1] + I[i - 1];

	long long sum = 0, maxn = 0;
	for (int i = 0; i < G.size(); i++) {
		sum += G[i];
		long long A1 = sum;
		long long A2 = -(1LL << 60); if (K - (i + 1) >= 0) A2 = V[min((long long)I.size(), K - (i + 1))];
		long long A3 = 1LL * (i + 1) * (i + 1);
		maxn = max(maxn, A1 + A2 + A3);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 16760
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long m = Long.parseLong(sc.next());
		for (int i = 1; i < n; i++)
			m = lcm(m, Long.parseLong(sc.next()));
		System.out.println(m);
	}
	public static long lcm(long m, long n) {
		BigInteger M = new BigInteger(String.valueOf(m));
		BigInteger N = new BigInteger(String.valueOf(n));
		BigInteger G = new BigInteger(String.valueOf(gcd(m, n)));
		return M.multiply(N).divide(G).longValue();
	}
	public static long gcd(long m, long n) {
		if (m < n) {
			long tem = m;
			m = n;
			n = tem;
		}
		long r = -1;
		while (r != 0) {
			r = m % n;
			m = n;
			n = r;
		}
		return m;
	}
}

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

void show(int* a, int n)
{
    for(int i = 0; i < n - 1; i++) cout << a[i] << " ";
    cout << a[n - 1] << endl;
}

void SelectionSort(int* a, int n)
{
    int i, j, c, minj, count;
    count = 0;

    for(i = 0; i < n; i++){
        minj = i;
        for(j = i; j < n; j++){
            if(a[minj] > a[j]) minj = j;
        }
        if(i < minj){
            c = a[minj];
            a[minj] = a[i];
            a[i] = c;
            count++;
        }
    }
    show(a, n);
    cout << count << endl;
}

int main()
{
    int N, A[100];
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    SelectionSort(A, N);

    return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<int>> a(h + 1, vector<int>(w + 1, 0));
  int strawberry = 1;
  for(int i = 0; i < h; i++) {
    string tmp;
    cin >> tmp;
    for(int j = 0; j < w; j++) {
      if(tmp[j] == '#') {
        a[i][j] = strawberry;
        strawberry++;
      }
    }
  }
  vector<int> nost(h, 0);
  vector<int> sw(w, 0);
  bool ok = false;
  for(int i = 0; i < h; i++) {
    int num = a[i][0];
    int zero = 0;
    while(num == 0 && zero < w) {
      zero++;
      num = a[i][zero];
    }
    if(zero == w) {
      nost[i] = 1;
      continue;
    }
    for(int j = 0; j < w; j++) {
      if(a[i][j] == 0) {
        a[i][j] = num;
      } else {
        num = a[i][j];
      }
    }
    if(!ok) {
      sw = a[i];
      ok = true;
    }
  }
  for(int i = 0; i < h; i++) {
    if(nost[i] == 0) {
      sw = a[i];
      continue;
    } else {
      a[i] = sw;
    }
  }

  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
#include<cstdio>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;


const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i ;
	}

}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (k == 0) return 1;
	return n * COM(n - 1, k - 1) / k;
}



int main() {
	COMinit();
	ll i, j, k, l, m, n, sum, flag, cc,N,M,X,A,B;
	sum = 0;
	flag = 0;
	cin >> N>>A>>B;
	vector<ll>v(N);
	REP(i, 0, N) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	ll max = v[N - 1];
	i = N - 2;
	k = 1;
	while (i >= 0) {
		if (v[i] == max) {
			k++;
			i--;
		}
		else {
			break;
		}
	}
	ll a_value_pos=0;
	ll a_value_num = 0;
	REP(i, 0, N - 1) {
		if (v[i] == v[N - A]) {
			a_value_num++;
			if (i >= N - A) {
				a_value_pos++;
			}
		}
		
	}
	sum = 0;
	double ans;
	for (i = N - 1; i >= N - A; i--) {
		sum += v[i];
	}
	ans = (double)sum / (double)A;
	if (k < A) {
		printf("%.16lf", ans);
		cout << endl;
		output(COM(a_value_num,a_value_pos));
		return 0;
	}
	ll sum1;
	sum1 = 0;
	for (i = A; i <= min(B,k); i++) {
		sum1 += COM(k, i);
	}
	printf("%.16lf", ans);
	cout << endl;
	output(sum1);


	return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
using namespace std;
int func(int a,int b){
	int c=a,d=b;
	while(d){
		c%=d;
		swap(c,d);
	}
	return c;
}
int main(){
	int x,y;
	cin>>x>>y;
	cout<<x+y-func(x,y)+1<<endl;
	return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int n, cnt = 0, maxv = 0;
    string s;
    cin >>n >>s;
    for(int i =0; i < s.length(); i++){
        if(s[i] == 'I'){
            cnt++;
        }else if(s[i] == 'D'){
            cnt--;
        }
        maxv = max(maxv,cnt);
    }
    cout << maxv << endl;
}

Measured memory_bytes: 256
import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]
ans=0
for i in itertools.combinations_with_replacement(range(1,m+1),n):
    total=0
    for j in range(q):
        if i[abcd[j][1]-1]-i[abcd[j][0]-1]==abcd[j][2]:
            total+=abcd[j][3]
        ans=max(ans,total)
print(ans)

Measured memory_bytes: 68268
prev = int(input())
count = 1
found = False
my_dict = {}
my_dict[prev] = 1

while not found:
    prev = int(prev / 2) if 0 == prev % 2 else 3 * prev + 1
    count += 1
    if not prev in my_dict:
        my_dict[prev] = 1
    else:
        print(count)
        break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;++i) 
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vlli vector<long long int>
#define pb push_back
#define mp make_pair
#define all(c)  ((c).begin()), ((c).end())
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	int k;
	cin>>k;
	vi a(n);
	FOR(i,0,n)
		cin>>a[i];
	int mintime=INT_MAX;
	FOR(i,0,n-k+1){
		if((a[i]<0&&a[i+k-1]<0)||(a[i]>0&&a[i+k-1]>0)){
			mintime=min(mintime,max(abs(a[i+k-1]),abs(a[i])));
		}
		else{
			mintime=min(mintime,min(2*abs(a[i])+a[i+k-1],abs(a[i])+2*a[i+k-1]));
		}
	}
	cout<<mintime<<"\n";
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;
    if (A == B)
        cout << "Draw";
        else if ((A > B and B != 1) or (A != B and A == 1))
            cout << "Alice";
        else
            cout << "Bob";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = long long;


int main() {

	int a, b;
	cin >> a >> b;
	cout << a * b << endl;

	return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <math.h>
int main(void) {
    int num,t,i,j,count=0;
    scanf("%d",&num);
    for (i=0; i<num; i++) {
        scanf("%d",&t);
        for (j=2; j<=sqrt(t); j++) {
            if (t%j==0) break;
        }
        if (j>sqrt(t)||sqrt(t)<2) count++;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2072
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto n = readln.chomp.to!int % 500;
  if (readln.chomp.to!int >= n) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


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

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

K=(A+B)/2

def judge(K):
    if is_integer_num(K):
        return (int(K))
    else:
        return('IMPOSSIBLE')

print(judge(K)) 

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @see <a href='http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?lang=jp&id='>??????</a>
 */
public class Main {
	private static Scanner in = new Scanner(System.in);
	private static final String STABLE = "Stable";
	private static final String NOT_STABLE = "Not stable";

	public static void main(String[] args) throws Exception {
		Main main = new Main();
		main.run();
	}

	private void run() {
		int n = in.nextInt();
		String[] vals = Stream.generate(() -> in.next()).limit(n).collect(Collectors.toList()).toArray(new String[]{});

		String[] bubble = bubbleSort(vals);
		String[] selection = selectionSort(vals);
		Arrays.sort(vals, (o1, o2) -> o1.charAt(1) - o2.charAt(1));

		printResult(bubble, vals);
		printResult(selection, vals);
	}

	private void printResult(String[] sorted, String[] stable) {
		System.out.println(Arrays.stream(sorted).collect(Collectors.joining(" ")));
		System.out.println(Arrays.equals(sorted, stable) ? STABLE : NOT_STABLE);
	}

	private String[] bubbleSort(String[] vals) {
		String[] sorted = Arrays.stream(vals).collect(Collectors.toList()).toArray(new String[]{});
		for (int i = 0; i < sorted.length; i++) {
			for (int j = sorted.length - 1; j > i; j--) {
				if (sorted[j].charAt(1) < sorted[j - 1].charAt(1)) {
					swap(j, j - 1, sorted);
				}
			}
		}
		return sorted;
	}

	private String[] selectionSort(String[] vals) {
		String[] sorted = Arrays.stream(vals).collect(Collectors.toList()).toArray(new String[]{});
		for (int i = 0; i < sorted.length; i++) {
			int minj = i;
			for (int j = i; j < sorted.length; j++) {
				if (sorted[j].charAt(1) < sorted[minj].charAt(1)) {
					minj = j;
				}
			}
			swap(i, minj, sorted);
		}
		return sorted;
	}

	private void swap(int i, int j, String[] vals) {
		String temp = vals[i];
		vals[i] = vals[j];
		vals[j] = temp;
	}
}

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

int main()
{
    int a[3];
    for (int& x : a) cin >> x;

    sort(a, a + 3);

    int ans = 0;
    for (int i = 0; i < 2; i++) {
        ans += (a[2] - a[i]) / 2;
        a[i] = ((a[2] - a[i]) % 2 ? a[2] - 1 : a[2]);
    }

    int cnt = 0;
    while (!(a[0] == a[1] && a[0] == a[2] && a[1] == a[2])) {
        for (int i = 0; i < 3; i++) {
            if (a[i] == a[(i + 1) % 3]) {
                a[i]++, a[(i + 1) % 3]++;
                cnt++;
                break;
            }
        }
        for (int i = 0; i < 3; i++) {
            if (abs(a[i] - a[(i + 1) % 3]) == 2) {
                (a[i] < a[(i + 1) % 3] ? a[i] : a[(i + 1) % 3]) += 2;
                cnt++;
                break;
            }
        }
    }
    ans += cnt;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int,input().split()))
sumw = sum(w)
s1 = 0
sa = abs(sumw - s1)
for i in range(n):
    s1 += w[i]
    sumw -= w[i]
    if sa >= abs(sumw-s1):
        sa = abs(sumw-s1)
print(sa)

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    int r; cin>>r;
    cout<<3*r*r<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<ll,ll> pi;

int main(){
    int k,n;
    scanf(" %d %d",&k,&n);
    int nums[n];
    for(int i = 0; i < n;++i) scanf(" %d",&nums[i]);
    int acum1[n];
    acum1[0] = 0;
    for(int i = 1; i < n;++i)
        acum1[i] = acum1[i-1] + (nums[i]-nums[i-1]);
    int sum = nums[0] + k - nums[n-1];
    //cout << sum << "\n";
    int ans = acum1[n-1];
    ans = min(ans,sum + acum1[n-1]-acum1[1]);
    ans = min(ans,sum+acum1[n-2]);
    for(int i = 1; i < n-1;++i){
        int va1 = acum1[i] + sum + (acum1[n-1]-acum1[i+1]);
        int va2 = (acum1[n-1]-acum1[i]) + sum + acum1[i-1];
        va1 = min(va1,va2);
        ans = min(ans,va1);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1792
using System;

class Program
{
	static void Main(string[] args)
	{
		var numbers = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
		var min = numbers[0];
		var max = numbers[1];
		var range = numbers[2];

		if (min + range - 2 >= max - range) {
			for (var i = min; i <= max; ++i) {
				Console.WriteLine(i);
			}
		} else {
			for (var i = min; i < min + range; ++i) {
				Console.WriteLine(i);
			}

			for (var i = max - range + 1; i <= max; ++i) {
				Console.WriteLine(i);
			}
		}
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000007

int main() {
	int n, h, cnt=0;
	cin >> n >> h;
	vector<int>a, b;
	rep(i, n) {
		int t, tt;
		cin >> t >> tt;
		a.push_back(t);
		b.push_back(tt);
	}
	sort(a.begin(), a.end());
	sort(b.rbegin(), b.rend());
	for (auto p : b) {
		if (p > a.back())
		{
			if (h > 0) {
				cnt++;
				h -= p;
			}
		}
	}
	if (h > 0) {
		cnt += h / a.back();
		if (h%a.back())
			cnt++;
	}
	cout << cnt << endl;
	
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr int C=36800;
int d[100][100];
bool dp[100][100][73610];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  ll h, w, a[100][100], b[100][100];
  cin>>h>>w;
  REP(i, h)REP(j, w){
    cin>>a[i][j];
  }
  REP(i, h)REP(j, w){
    cin>>b[i][j];
  }
  REP(i, h)REP(j, w){
    d[i][j]=abs(a[i][j]-b[i][j]);
  }
  REP(i, h)REP(j, w){
    if(i==0 && j==0){
      dp[i][j][d[i][j]+C]=dp[i][j][-d[i][j]+C]=true;
      continue;
    }
    if(i>0){
      REP(k, C*2+1){
        if(dp[i-1][j][k]){
          dp[i][j][k+d[i][j]]=dp[i][j][k-d[i][j]]=true;
        }
      }
    }
    if(j>0){
      REP(k, C*2+1){
        if(dp[i][j-1][k]){
          dp[i][j][k+d[i][j]]=dp[i][j][k-d[i][j]]=true;
        }
      }
    }
  }
  int ans=1e9;
  REP(i, C*2+1){
    if(dp[h-1][w-1][i]){
      CHMIN(ans, abs(i-C));
    }
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 574208
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
const int base = 1000000007;
 
int main()
{ //freopen("in.txt","r",stdin);
 //freopen("out.txt","w",stdout);
  //ll n,t;
 // cin>>t>>n;
  /* ll ar[n];
   f(i,0,n) cin>>ar[i]; */
   int a,b,c;
    cin>>a>>b>>c;
    if(a<=c&&c<=b)
     cout<<"Yes";
    else if(b<=c&&c<=a)
	cout<<"Yes"; 
    else
	 cout<<"No"; 
}


Measured memory_bytes: 256
#include<stdio.h>
int n,w[10],h[10],a[10];
long long min;
void f(int d,int t[10],int c[10],int y[10]){
  int i,j;
  if(!d){
    long long g=0;
    for(i=0;i<n;i++)g+=w[t[i]]*i;
    if(min>g){
      min=g;
      for(i=0;i<n;i++)a[i]=t[i];
    }
    return;
  }
  for(i=0;i<n;i++){
    if(c[i])continue;//printf("%d %d\n",d,i);
    t[n-d]=i;
    c[i]=1;
    y[n-d]=h[i];
    for(j=0;j<n-d;j++){
      y[j]-=w[i];
      if(y[j]<0)break;
    }
    if((n-d)-j==0)f(d-1,t,c,y);
    c[i]=0;
    for(j=0;j<n-d;j++)y[j]+=w[i];      
  }
  return;
}      
int main(){
  char s[10][12];
  int i;
  while(scanf("%d",&n),n){
    min=2100000000;
    int t[10]={0};
    int c[10]={0};
    int y[10]={0};
    for(i=0;i<n;i++){
      scanf("%s %d %d",s[i],&w[i],&h[i]);
      a[i]=0;
    }
    f(n,t,c,y);
    for(i=0;i<n;i++)printf("%s\n",s[a[i]]);
  }
  return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

int64_t extgcd(int64_t a,int b,int64_t&x,int64_t&y){
	int64_t d=a;
	if(b){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	else{
		x=1,y=0;
	}
	return d;
}

int64_t modinv(int64_t base){
	int64_t x,y;
	extgcd(base,mod,x,y);
	x%=mod;
	return (x<0?x+mod:x);
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int64_t>a(n); for(auto&&i:a)cin>>i;
	int64_t base=0;
	for(auto&&i:a)base=(base+i)%mod;
	int64_t ans=0;
	for(auto&&i:a)ans=(ans+1L*i*(mod+base-i)%mod)%mod;
	cout<<ans*modinv(2)%mod<<"\n"s;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n), ans(n), val(1);
    vector<int> pos(1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > a[pos.back()]) {
            pos.emplace_back(i);
            val.emplace_back(a[i]);
        }
    }
    val[0] = a[0];
    vector<ll> cnt(val.size()), d(val.size());
    for (int i = 0; i < n; i++) {
        int j = lower_bound(val.begin(), val.end(), a[i]) - val.begin();
        d[j] += a[i];
        cnt[j]++;
    }
    for (int i = pos.size() - 1; i > 0; i--) {
        ans[pos[i]] = d[i] - cnt[i] * (val[i - 1]);
        cnt[i - 1] += cnt[i];
        d[i - 1] += cnt[i] * val[i - 1];
    }
    debug(pos, val, cnt);
    for (int i = 0; i < n; i++) {
        ans[0] += min(a[0], a[i]);
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 5616
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()

    f = [1]
    r = [1]
    c = 1
    for i in range(1, M + 1):
        c = (c * i) % MOD
        f.append(c)
        r.append(pow(c, MOD - 2, MOD))

    def comb(n, k):
        return (f[n] * r[k] * r[n - k]) % MOD
    def perm(n, k):
        return (f[n] * r[n-k]) % MOD


    ans = 0
    for i in range(N+1):
        ans = (ans + ((-1)**i) * comb(N,i) * perm(M,i) * (perm(M-i,N-i) ** 2)) % MOD
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 149252
import std.conv, std.stdio;
import std.algorithm, std.range, std.string;
import std.container.rbtree;
import std.experimental.logger;

void main()
{
    auto buf = readln.chomp.split.to!(int[]);
    immutable n = buf[0], m = buf[1];
    Job[] jobs;
    foreach (i; 0..n)
    {
        buf = readln.chomp.split.to!(int[]);
        jobs ~= Job(buf[0], buf[1]);
    }
    jobs.sort();
    auto availableJobs = redBlackTree!(true, size_t);
    int totalReward;
    foreach (j; 1..m+1)
    {
        while (!jobs.empty && jobs.front.delay <= j)
        {
            availableJobs.insert(jobs.front.reward);
            jobs.popFront;
        }
        if (availableJobs.empty) continue;
        totalReward += availableJobs.back;
        availableJobs.removeBack;
    }
    totalReward.writeln;
}
struct Job
{
    size_t delay;
    size_t reward;
    int opCmp(in Job rhs)
    {
        if (this.delay  < rhs.delay ) return -1;
        if (this.delay  > rhs.delay ) return +1;
        if (this.reward > rhs.reward) return -1;
        if (this.reward < rhs.reward) return +1;
        return 0;
    }
}


Measured memory_bytes: 11260