akhauriyash/Code-Regression huggingface dataset:
import numpy as np
N, M = map(int, input().split())
A = np.zeros([N, 2], dtype = np.int)
if N == 1:
    A[0, 0] = 0
else:
    A[0, 0] = 1
for i in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and N != 1:
        print('-1')
        exit()
    if A[s - 1, 1] == 0:
        A[s - 1, 0] = c
        A[s - 1, 1] = 1
    elif A[s - 1, 1] == 1 and A[s - 1, 0] == c:
        continue
    else:
        print('-1')
        exit()
else:
    print(*A[:, 0], sep='')

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

int main() {
    long long k, a, b, tmp1, tmp2, ans1, ans2;
    scanf("%lld%lld%lld", &k, &a, &b);
    tmp1 = k - a - 1;
    if (tmp1 <= -1) {
        printf("%lld\n", k + 1);
        return 0;
    }
    tmp2 = 2;
    ans1 = k + 1;
    ans2 = (tmp1 / tmp2) * (b - a) + b + tmp1 % tmp2;
    printf("%lld\n", max(ans1, ans2));
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int x[2000];
signed main(){
	int n,ans=0;
	cin>>n;
	f(i,n)cin>>x[i];
	sort(x,x+n);
	f(i,n){
		for(int j=i+1;j<n;j++){
			ans+=lower_bound(x,x+n,x[i]+x[j])-x-j-1;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    vector<int> p(n);
    int ans = 0;
    rep(i, n)
    {
        cin >> p[i];
        ans += p[i];
    }

    sort(rALL(p));
    cout << ans - p[0]/2 << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
bulbs = []
for i in range(M):
    k, *s = map(int, input().split())
    bulbs.append((k, s))
p = list(map(int, input().split()))

ans = 0
for i in range(1 << N):
    on_cnt = [0] * M
    for j in range(N):
        if i >> j & 1:
            for k in range(M):
                if j + 1 in bulbs[k][1]:
                    on_cnt[k] = (on_cnt[k] + 1) % 2
    if on_cnt == p:
        ans += 1
print(ans)

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    long long n,y;
    cin>>n>>y;
    for(long long i=0;i*1e4<=y;i++){
        for(long long k=0;y-i*1e4>=k*5*1e3;k++){
            long long j=n-i-k;
                if(i*1e4+k*5*1e3+j*1e3==y){
                    cout<<i<<" "<<k<<" "<<j<<endl;
                    return 0;
                }
            
        }
    }
    rep(i,3)cout<<"-1 ";
    cout<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 256
#include <stdio.h>
   
int main(void)
{
char str[1001], p[1001], cmd[10];
int a, b, q;
   
scanf("%s", str);
   
scanf("%d", &q);
   
while (q > 0)
{
scanf("%s", cmd);
scanf("%d", &a);
scanf("%d", &b);
if (cmd[0] == 'p')
{
 while (a <= b)
 {
 putchar(str[a]);
 a++;
 }
 putchar('\n');
   
} else if (cmd[2] == 'v')
{
 while (a < b)
 {
  p[0] = str[a];
  str[a] = str[b];
  str[b] = p[0];
  a++;
  b--;
 }
} else {
 scanf("%s", p);
 while (a <= b)
 {
  str[b] = p[b - a];
  b--;
 }
}
q--;
}
   
return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M; cin >> N >> M;
    vector<int> a(M);
    for(int i = 0; i < M; i++) cin >> a[i];
    int sum = 0;
    for(int i = 0; i < M; i++) sum += a[i];
    if(sum<=N) cout << N - sum << endl;
    else cout << "-1" << endl;
    return 0;
}

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

#define endl '\n'

void solve(){
    long long n; cin >> n;
    long long x = n, ans = 0;
    for (long long i=2; i*i <= n; i++){
        if (x % i == 0){
            long long cur = 0, qtd = 0;
            while(x % i == 0){
                x /= i;
                qtd++;
            }
            for (long long j = 1, sum = 0; ; j++){
                sum += j;
                if (sum == qtd){
                    cur = j;
                    break;
                } else if (sum > qtd){
                    cur = j - 1;
                    break;
                }
            }
            ans += cur;
        }
    }
    if (x > 1) ans++;
    cout << ans << endl;
}

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

Measured memory_bytes: 3640
N,M=map(int, input().split())
S = [0] * M
C = [0] * M
for i in range(M):
    S[i],C[i] = map(int, input().split())

if N == 1:
    st = 0
    fin = 10
elif N == 2:
    st = 10
    fin = 100
elif N == 3:
    st = 100
    fin = 1000

if M == 0 :
    print(st)
    exit()
    
for i in range(0,1000):
    moji = str(i)
    if (len(moji)!=N):
        continue
    for j in range(M):
        if (int(moji[S[j]-1]) != C[j]):
            break
        if j == M-1:
            print(i)
            exit()


print(-1)


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
import sys
sys.setrecursionlimit(1000000)

n, q = map(int, input().split())
g = [[] * n for i in range(n)]

par = [-1]*n
for i in range(n-1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)

chk = [0]*n
for i in range(q):
    x, y = map(int, input().split())
    chk[x-1] += y

def dfs(now, prev):
    # リストはglobal宣言の必要がない？
    # 今いる頂点から行ける頂点を順に next に入れてループ
    for next in g[now]:
        if next != prev:
            chk[next] += chk[now]
            dfs(next, now)

dfs(0,-1)
print(*chk)

Measured memory_bytes: 232496
#include<bits/stdc++.h>
using namespace std;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f) return x;else return -x;
}
int t;
int main(){
	t=read();
	while(t--){
		int n=read(),d=read();
		if(n%2) printf("%d\n",(n-1)*127+d);
		else printf("%d\n",n*127-d);
	}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  for(int i = sx; i < tx; i++){
    cout << 'R';
  }
  for(int i = sy; i < ty; i++){
    cout << 'U';
  }
  for(int i = tx; i > sx; i--){
    cout << 'L';
  }
  for(int i = ty; i > sy; i--){
    cout << 'D';
  }
  cout << 'D';
  for(int i = sx; i < tx + 1; i++){
    cout << 'R';
  }
  for(int i = sy; i < ty + 1; i++){
    cout << 'U';
  }
  cout << 'L';
  cout << 'U';
  for(int i = tx; i > sx - 1; i--){
    cout << 'L';
  }
  for(int i = ty; i > sy - 1; i--){
    cout << 'D';
  }
  cout << 'R';
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

# Generated by AtcoderGreedy on 2018-04-22
# ABC095 C
# Your code here

$A, $B, $C, $X, $Y = gets.chomp.split(' ').map(&:to_i)

def min(a, b)
  a < b ? a : b
end

def min_3(a, b, c)
  min(min(a, b), c)
end

res = if $X < $Y
        min_3($Y * 2 * $C, $A * $X + $B * $Y, $X * 2 * $C + ($Y - $X) * $B)
      else
        min_3($X * 2 * $C, $A * $X + $B * $Y, $Y * 2 * $C + ($X - $Y) * $A)
      end

puts res


Measured memory_bytes: 1788
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll n, v[100010],ct=0;
int main() {
	cin >> n;
	rep(i, n) cin >> v[i];
	sort(v, v + n);
	rep(i,n)if (i > 0 && v[i - 1] == v[i])++ct;
	if (ct % 2 == 1)++ct;
	cout << n - ct << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                                #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<int,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };

int n,h;
int a[100030],b[100030];
           signed main(){
   	//	int pr[3];
  int y;
           	cin>>n>>y;
           	
           	for(int i=0;i<=n;i++)for(int j=0; i+j<=n;j++){
           		int k=n-i-j;
           		if(10000*i+5000*j+1000*k==y){
           	cout<<i<<" "<<j<<" "<<k<<endl;
           			return 0;
           		}
           	
           	}
           	
           	cout<<"-1 -1 -1"<<endl;
           }
             

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A, B) << " ";
  if (A+B<=N) cout << 0 << endl;
  else cout << A+B-N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
/*using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define mr  make_pair

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int k;
       cin>>k;
       queue<string> q;
       for(int i=1;i<=9;++i)
       q.push(to_string(i));
       int ct = 0;
       while(!q.empty())
       {
       	    ct++;
       		string s = q.front();
       		q.pop();
       		if(ct==k)
       		{
       			cout<<s;
       			return 0;
       		}
       		int x = (s.back()-'0');
       		if(x!=0)
       		{string s1 = s+ to_string(x-1);q.push(s1);}
       		string s2 = s+ to_string(x);
       		q.push(s2);
       		if(x!=9){
       		string s3 = s+  to_string(x+1);
       		q.push(s3);
       		}
       		
       }
    }
    return 0;
}


Measured memory_bytes: 10752
// 2014/11/12 Tazoe

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int D, N;
	cin >> D >> N;

	int T[200];
	for(int i=0; i<D; i++){
		cin >> T[i];
	}

	int A[200], B[200], C[200];
	for(int i=0; i<N; i++){
		cin >> A[i] >> B[i] >> C[i];
	}

	int DP[200][200];

	for(int j=0; j<N; j++){
		if(A[j]<=T[0] && T[0]<=B[j]){
			DP[0][j] = 0;
		}
		else{
			DP[0][j] = -1;
		}
	}

	for(int i=1; i<D; i++){
		for(int j=0; j<N; j++){
			if(!(A[j]<=T[i] && T[i]<=B[j])){
				DP[i][j] = -1;
				continue;
			}

			DP[i][j] = 0;
			for(int k=0; k<N; k++){
				if(DP[i-1][k]==-1)
					continue;

				DP[i][j] = max(DP[i][j], DP[i-1][k]+abs(C[j]-C[k]));
			}
		}
	}

	int DP_max = -1;
	for(int j=0; j<N; j++){
		DP_max = max(DP_max, DP[D-1][j]);
	}

	cout << DP_max << endl;

	return 0;
}

Measured memory_bytes: 1320
/* Author: Jason L.(int3xccATgmailDOTcom), Mon Sep 18 00:50:49 CST 2017 */
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pll = pair<ll, ll>; using dd = long double;
//=========================================================================
namespace {
static bool constexpr dbg =
#ifdef INT3XCC_DEBUG
        1;
#else
        0;
#endif
#define Dprintf(fmt, ...) do{if(dbg) printf(fmt, ##__VA_ARGS__);}while(0)
#define REP0(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
//=========================================================================
ll constexpr N = 300;
ll n, cnt[N+9];
string s;
//=========================================================================
void init() {
    cin>>s; n = s.size();
}
void solve() {
    for (auto ch: s) ++cnt[ch];
    ll sum = 0;
    for (char c = 'a'; c <= 'z'; ++c) sum += cnt[c]*(cnt[c]-1)/2;
    cout<<(n*(n-1)/2 - sum + 1);
}}
//=========================================================================
int main() {
    if (!dbg) { std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
    cout<<fixed<<setprecision(20); init(); solve(); return 0;
}


Measured memory_bytes: 720
#include <stdio.h>

int main(void)
{
	int seisu[3];
	int x;
	
	scanf("%d %d %d",&seisu[0],&seisu[1],&seisu[2]);
	
	if(seisu[0]>seisu[1])
	{
	x=seisu[0];
	seisu[0]=seisu[1];
	seisu[1]=x;
	}
	
	if (seisu[0]>seisu[2])
	{
	x=seisu[0];
	seisu[0]=seisu[2];
	seisu[2]=x;
	}
	
	if(seisu[1]>seisu[2])
	{
	x=seisu[1];
	seisu[1]=seisu[2];
	seisu[2]=x;
	}
	
	printf("%d %d %d\n",seisu[0],seisu[1],seisu[2]);
		
	return 0;
}


Measured memory_bytes: 2744
H,W=map(int,input().split())
numbers=[list(map(int,input().split())) for _ in range(10)]
A=[list(map(int,input().split())) for _ in range(H)]
cost=[[1001 for _ in range(10)] for _ in range(10)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            cost[i][j] = min(cost[i][j] , numbers[i][j] , numbers[i][k] + numbers[k][j] ,
                             cost[i][k] + cost[k][j] , numbers[i][k] + cost[k][j],
                             numbers[i][k] + cost[k][j])
ans=0
for a in A:
    for a_ in a:
        if a_ == 1 or a_ == -1:
            pass
        else:
            ans+=cost[a_][1]
print(ans)


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

#define int long long

vector<pair<int, int> > graph1[100010];
vector<pair<int, int> > graph2[100010];

int n;

void dijkstra(vector<pair<int, int> > graph[100010], int st, int dist[100010]){
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;

    for(int i = 0;i < n;i++){
        if(i == st){
            dist[i] = 0;
            que.push(make_pair(0, st));
        }else{
            dist[i] = LLONG_MAX;
        }
    }

    while(!que.empty()){
        int cost = que.top().first;
        int idx = que.top().second;
        que.pop();

        for(int i = 0;i < graph[idx].size();i++){
            int next = graph[idx][i].first;
            int ncost = graph[idx][i].second + cost;
            if(dist[next] > ncost){
                dist[next] = ncost;
                que.push(make_pair(ncost, next));
            }
        }
    }

    return;
}

signed main(){
    int m, s, t;
    cin >> n >> m >> s >> t;
    s--, t--;

    int a, b, c, d;
    for(int i = 0;i < m;i++){
        cin >> a >> b >> c >> d;
        a--, b--;
        graph1[a].push_back(make_pair(b, c));
        graph1[b].push_back(make_pair(a, c));
        graph2[a].push_back(make_pair(b, d));
        graph2[b].push_back(make_pair(a, d));
    }

    int dist1[100010], dist2[100010];

    dijkstra(graph1, s, dist1);
    dijkstra(graph2, t, dist2);

    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
    for(int i = 0;i < n;i++){
        que.push(make_pair(dist1[i]+dist2[i], i));
    }

    for(int i = 0;i < n;i++){
        while(i > que.top().second) que.pop();
        cout << 1000000000000000ll - que.top().first << endl;
    }

    return 0;
}


Measured memory_bytes: 19900
N, Y = map(int, input().split())
ans = [-1,  -1,  -1]
for x in range(N+1):
    for y in range(N+1):
        z = N - (x+y)
        if 10000*x + 5000*y + 1000*z == Y and (0<= z <= N):
            ans = [x, y, z]
            break
print(*ans)

Measured memory_bytes: 41836
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void OUT(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void OUT(T t,Ts... ts){cout<<t<<" ";OUT(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type FILL(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type FILL(T&t,const V&v){for(auto &e:t)FILL(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int N;
	cin>>N;
	auto a = mv(N);
	cin>>a;
	int ans = 1;
	FOR(i,1,N){
		if(a[i-1]>=a[i])ans++;
	}
	OUT(ans);
	OUT(N);
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  static const double pi = 3.141592653589793;
//cin>>str;
//cout<<str<<endl;
  int A, B, H, M;
  double angleA, angleB, angle;
  cin>>A>>B>>H>>M;
  angleA = 2 * pi/60.0 * M;
  angleB = 2 * pi/12.0 * H + pi/360.0 * M;
  angle = angleA - angleB;
  double C = sqrt(A * A + B * B - 2 * A * B * cos(angle));
  cout << fixed << setprecision(10) << C << endl;
  //cout<<double(C);
}

Measured memory_bytes: 4136
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n, a;
    int cnt2=0, cnt4=0;
    cin >> n;
    rep(i, n){
        cin >> a;
        if(a%4==0) cnt4++;
        if(a%4!=0 && a%2==0) cnt2++;
    }

    if(cnt4+cnt2/2 >= n/2) ans(true);
    else ans(false);

    return 0;
}

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

int main() {
	long long d; cin >> d;
	long long ans = 1e9;
	while (d > 100) {
		ans = min(abs(d % 1000 - 753), ans);
		d /= 10;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
arr = []
for i in range(N):
  l = list(input().split())
  l[1] = int(l[1])
  l.append(i+1)
  arr.append(l)

arr = sorted(arr, key=lambda x:(x[0],-x[1]))

for j in range(N):
  print(arr[j][2])

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res*a;
		a = a*a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

///////////////////////////////////////////////////////////////////////////////////////

ll N, C, D[31][31];
ll g[3][31], sum[3][31]; // g:各グループがもとの色をいくつずつ持っているか, sum:各グループをある色に書き換えたときのスコアの和
ll ans = MAX_10p18;

int main() {
	cin >> N >> C;
	repi(i, 1, C + 1) {
		repi(j, 1, C + 1) {
			rd(D[i][j]);
		}
	}
	repi(i, 0, N) {
		repi(j, 0, N) {
			ll t;
			rd(t);
			g[(i + j) % 3][t]++;
		}
	}

	repi(i, 0, 3) {
		repi(j, 1, C + 1) {
			repi(k, 1, C + 1) {
				// 各iをjにしたときの和（k→jの総和）
				sum[i][j] += g[i][k] * D[k][j];
			}
		}
	}

	repi(i, 1, C + 1) {
		repi(j, 1, C + 1) {
			if (i == j) continue;
			repi(k, 1, C + 1) {
				if (j == k || k == i) continue;
				ans = min(ans, sum[0][i] + sum[1][j] + sum[2][k]);
			}
		}
	}

	wrln(ans);

	return 0;
}


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

int main(){
  long long int N;
  while(cin >> N, N){
    long long int ans = 0, t = ceil(sqrt(N/2.0));
    for(long long int i = 1; i < t; ++i){
      ans += (long long)ceil((double)N/2/i)*2;
    }
    ans += N;
    ans -= t*t;
    ans *= 8;
    ans += 8*N;
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
m = 10000000000
count = 0
for i in range(n):
    if a[i] < 0:
        count += 1
        a[i] = -a[i]
if count % 2 == 1:
    print(sum(a)-2*min(a))
else:
    print(sum(a))

Measured memory_bytes: 14412
#define min(a,b)a<b?a:b
N,M,L,Q;
D[301][301];
i,j,k;
a,b,c;
main()
{
	scanf("%d%d%d",&N,&M,&L);
	for(i=0;i<N;i++)for(j=0;j<N;j++)D[i][j]=1000000001;
	for(i=0;i<M;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		--a;
		--b;
		D[a][b]=D[b][a]=c;
	}
	for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)
		D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
	for(i=0;i<N;i++)for(j=0;j<N;j++)
	{
		D[i][j]=D[i][j]>L?1000000000:1;
	}
	for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)
		D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
	scanf("%d",&Q);
	for(i=0;i<Q;i++)
	{
		scanf("%d%d",&a,&b);
		--a;
		--b;
		printf("%d\n",D[a][b]<1000000000?D[a][b]-1:-1);
	}
}

Measured memory_bytes: 768
def resolve():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    for i in range(K, N):
        if A[i-K] < A[i]:
            print("Yes")
        else:
            print("No")


    
if '__main__' == __name__:
    resolve()

Measured memory_bytes: 31436
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define ff fflush(stdout)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	int n,m,a,b;
	cin>>n>>m>>a>>b;
	string s="";
	rb(i,1,a) s+='1';
	rb(i,a+1,m) s+='0';
	rb(i,1,b){
		cout<<s<<endl;
	}
	rep(i,m) {
		if(s[i]=='1') s[i]='0';
		else s[i]='1';
	}
	rb(i,b+1,n) cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>

int main(){
	while(1){
		char ch;
		bool con=true;
		int cou=0;
		int m,n;
		int i,j;
		int ans=0;
		scanf("%d",&n);
		if(n==0)return 0;
		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf(" %c",&ch);
			if(ch=='I'){
				if(!con){
					cou++;
					if(cou==n+1){
						ans++;
						cou--;
					}
				}
				else cou=1;
				con=true;
			}
			if(ch=='O'){
				if(!con)cou=0;
				con=false;
			}
		}
		printf("%d\n",ans);
	}
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  string s;cin>>s;
  ll k;cin>>k;
  ll n=s.size();
  vector<ll>v;
  ll cnt=1;
  rep(i,0,n-1){
    if(s[i]==s[i+1])cnt++;
    else{
      v.PB(cnt);
      cnt=1;
    }
  }
  v.PB(cnt);
  if(v.size()==1){
    res=(v[0]*k)/2;
  }
  else if(s[0]==s[n-1]){
    rep(i,1,v.size()-1){
      res+=v[i]/2*k;
    }
    res+=v[0]/2;
    res+=v[(ll)v.size()-1]/2;
    res+=(v[0]+v[(ll)v.size()-1])/2*(k-1);
  }
  else{
    for(auto z:v){
      res+=z/2*k;
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe
import qualified Data.Sequence         as Seq

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
  n <- getInt
  s <- Seq.fromList <$> getLine
  t <- Seq.fromList <$> getLine

  let solve i | i == n    = 2*n
              | otherwise =
                 let bs = Seq.drop i s
                     bt = Seq.take (n-i) t
                 in if bs == bt
                    then n+i
                    else solve (i+1)

  print $ solve 0

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

typedef long long ll;
const int MAX_N = 100030;    // Change as necessary
const ll  MODD = 1000000009; //

int A[MAX_N];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;
  int T; cin >> T;
  
  for(int i=0;i<n;i++) cin >> A[i];
  
  int mini = A[0];
  int diff = A[1] - A[0];
  for(int i=1;i<n;i++){
    if(mini < A[i] && A[i] - mini > diff) diff = A[i] - mini;
    if(A[i] < mini) mini = A[i];
  }
  
  map<int,long long> M;
  long long ans = 0;
  
  for(int i=0;i<n;i++){
    ans += M[A[i]-diff];
    M[A[i]]++;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 13184
# coding: utf-8

import sys
input = sys.stdin.readline

# N = int(input())
N, K = map(int, input().split())
D = [int(x) for x in input().split()]
# S = input()

ans = 0
for l in range(N + 1):
    if l > K:
        break

    for r in range(N - l + 1):
        if l + r > K:
            break

        value_list = D[0 : l] + D[N - r : N]
        value_list.sort()
        
        for i in range(K - (l + r) + 1):
            ans = max(ans, sum(value_list[i:]))
        
print(ans)


Measured memory_bytes: 43356
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main (){
  char S[110];
  cin >> S;
  for (int i = 0; S[i] != '\0'; ++i) {
    S[i] = 'x';
  }
  cout << S << endl;
  return 0;
}




Measured memory_bytes: 256
from itertools import combinations_with_replacement
def score_check(A,L):
    point = 0
    for a, b, c, score in L:
        temp = A[b - 1] - A[a - 1]
        if temp == c:point += score

    return point

n, m, q = map(int,input().split())
l = [list(map(int,input().split())) for i in range(q)]

num = 0
nums = list(range(1, m + 1))
for i in combinations_with_replacement(nums, n):
    #print(i)
    temp = score_check(i, l)
    if num < temp:num = temp
print(num)

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

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int sumsum=0;
    for (int i = 1; i <= N; i++){
        int sum=0;
        sum += i/10000;
        sum += (i%10000)/1000;
        sum += (i%1000)/100;
        sum += (i%100)/10;
        sum += i%10;
        if(sum>=A){
            if(sum<=B){
                sumsum += i;
            }
        }
    }
    cout << sumsum << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
// C
fscanf(STDIN, '%d', $n);
if ($n === 0) {
    echo 0;
    exit;
}
$b = '';
while ($n !== 0) {
    $n = $n / (-2);
    if ($n !== (int) $n) {
        $b .= '1';
        $n = (int) ($n + 1 / 2);
    } else {
        $b .= '0';
    }
}
echo strrev($b);

Measured memory_bytes: 4728
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;
    vector<string> s(n);
    rep(i,n)cin>>s[i];
 
    ll cnt=0,acnt=0,bcnt=0,abcnt=0;
    rep(i,n){
        if(s[i][s[i].size()-1]=='A')++acnt;
        if(s[i][0]=='B')++bcnt;
        if(s[i][s[i].size()-1]=='A'&&s[i][0]=='B')++abcnt;
        rep(j,s[i].size()-1){
            if(s[i][j]=='A'&&s[i][j+1]=='B')++cnt;
        }
    }
 
    ll add=min(acnt,bcnt);
    if(add&&acnt==abcnt&&bcnt==abcnt)--add;
    cout<<cnt+add<<endl;
}

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

string S;
ll X, Y;

vector<string> split(string s, string p) {
  vector<string> ret;
  int h = 0;

  REP(i, 0, s.size() - p.size() + 1) if(s.substr(i, p.size()) == p) {
    ret.push_back(s.substr(h, i - h));
    h = i + p.size();
    i += (signed) p.size() - 1;
  }
  ret.push_back(s.substr(h, (signed) s.size() - h));

  return ret;
}

bool solve(vector<ll> vec, ll t) {
  vector< vector<bool> > dp(vec.size() + 1, vector<bool>(40000, false));

  dp[0][20000] = true;
  REP(i, 0, vec.size()) {
    REP(j, 0, 40000) if(dp[i][j]) {
      if(j + vec[i] >=     0) dp[i + 1][j - vec[i]] = true;
      if(j + vec[i] <  40000) dp[i + 1][j + vec[i]] = true;
    }
  }

  return dp[vec.size()][20000 + t];
}

int main(void) {
  cin >> S >> X >> Y;

  vector<string> s = split(S, "T");
  vector<ll> vx, vy;
  X -= s[0].length();
  REP(i, 1, s.size()) {
    if(i % 2 == 0) vx.push_back(s[i].length());
    if(i % 2 == 1) vy.push_back(s[i].length());
  }

  cout << (solve(vx, X) && solve(vy, Y) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 19968
# ABC 090 B - Palindromic Numbers
a, b = map(int, input().split())

def kaibun(x):
    l = str(x)
    r = str(x)[::-1]
    if l == r:
        return True
    else:
        return False
    
count = 0
for i in range(a, b+1):
    if kaibun(i):
        count += 1
    else:
        continue
        
print(count)

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

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {

		
		int n = sc.nextInt();
		int a[]  =new int[n];
		
		for(int i = 0 ; i< n ;i++){
			a[i] = sc.nextInt() - i;
		}
		
		Arrays.sort(a);
		
		int b = a[n/2];
		
		long sum  =0 ;
		for(int i  =0 ; i < n ;i++){
			sum += Math.abs(a[i] - b);
		}
		System.out.println(sum);
		
	}
}


Measured memory_bytes: 66680
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int[] a=new int[3];
			for(int i=0;i<3;i++) a[i]=sc.nextInt();
			Arrays.sort(a);
			if(a[0]+a[1]==a[2]) System.out.println("Yes");
			else System.out.println("No");
		}
	}
}			

Measured memory_bytes: 22608
#pragma GCC optimize("O3")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>ll(b);i--)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
#define INF 1000000000000 
#define MOD 1000000007 
#define MAXR 100000 
#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 
#define Umap unordered_map
#define Uset unordered_set


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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N) cin >> A.at(i);

    FOR(i, K, N) {
        if (A.at(i-K) < A.at(i)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

vector<int> g[1000001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  cin>>a>>b>>c;
  if((c<=b && c>=a) || (c>=b && c<=a)) cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 23680
#include "bits/stdc++.h"
using namespace std;
 
int main() {
    int n,k;
    cin >> n >> k;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int h;
        cin >> h;
        if(h >= k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int N,M;
    int t[1000];
    int p[1000],x[1000];
    cin >> N;

    int sumT=0;

    for (int i=0;i<N;i++){
      cin >> t[i];
      sumT+=t[i];
    }

    cin >> M;

    for (int i=0;i<M;i++){
      cin >> p[i] >> x[i];
    }

    //cout << sumT << endl;

    // cout << c << endl;
    for (int i=0;i<M;i++){
      int c = sumT -t[p[i]-1]  + x[i];
      cout << c << endl;
    }

    //cout << "c" << endl;

    return 0;
}


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

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int a;
	int num=0;
	int i;

	scanf("%d",&a);
	for(i=3;i<=a;i++){
		if(i%3==0)
		printf(" %d",i);
		else{
			num = i;
			while(1){
			if(num==0)
			break;
			if(num%10==3){
			printf(" %d",i);
			break;
			}else{
			num=num/10;
			}
		}
	}
}
			printf("\n");

	return 0;
}

Measured memory_bytes: 600
s=input()
t=input()
sdic={}
tdic={}
for i in range(len(s)):
    if s[i] in sdic:
        if sdic[s[i]]!=t[i]:
            print("No")
            exit()
    if t[i] in tdic:
        if tdic[t[i]]!=s[i]:
            print("No")
            exit()
    sdic[s[i]]=t[i]
    tdic[t[i]]=s[i]
print("Yes")


Measured memory_bytes: 41968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=200005;
int f[N],n,k;
ll ans;
signed main(){
	cin>>n>>k;
	for(int i=1;i<=k;i++)f[i]=n/k+(i<=n%k);
	f[0]=f[k];
	for(int i=0;i<k;i++)if((i+i)%k==0)ans+=(ll)f[i]*f[(k-i)%k]*f[(k-i)%k];
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, a, b = map(int, input().split())
if abs(a - b) % 2 == 0:
    print(abs(a - b) // 2)
else:
    small, big = min(a, b), max(a, b)
    print(min(
        (small - 1) + 1 + ((big - (small - 1) - 1 - 1) // 2),
        (n - big) + 1 + ((n - (small + (n - big) + 1)) // 2)
    ))


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

int main() {
    int N, X;
    cin >> N >> X;
    int M[N];
    int min_ = 10000;
    int c = 0;
    for (int n = 0; n < N; n++) {
        cin >> M[n];
        if (M[n] < min_) {
            min_ = M[n];
        }
        X -= M[n];
    }
    c += N;
    c += X / min_;
    cout << c;
}


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

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

    long long D = B - A;

    if (D < 0) cout << 0;
    else if (N == 1) {
        if (D == 0) cout << 1;
        else cout << 0;
    }
    else {
        cout << (1 + (N - 2) * D);
    }
    return 0;
}


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

m = re.match(r'^(\d+)\-(\d+)$', S)

if m:
    if len(m.groups()[0]) == A and len(m.groups()[1]) == B:
        print('Yes')
    else:
        print('No')
else:
    print('No')


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

int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  if(a%(b+c)==0) cout << a/(b+c)*b << endl;
  else if(a%(b+c)>=b) cout << (a/(b+c)+1)*b << endl;
  else cout << a/(b+c)*b+a%(b+c) << endl;
}

Measured memory_bytes: 256
l,r = gets.split(' ').map(&:to_i)

min = 2019
if l-r >= 2019
    puts 0
    exit
else
    (l..(r-1)).each do |i|
        ((i+1)..r).each do |j|
            result = (i*j).modulo(2019)
            min = result if result < min
            if min == 0
                puts 0
                exit
            end
        end
    end
end

puts min

Measured memory_bytes: 1788
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;


const int N = 2e5+50;
int n, a[N], k;
int main(int argc, char const *argv[]) {
    // code
    scanf("%d%d", &n, &k);
    for (int i=0; i<k; ++i) {
        scanf("%d", &a[i]);
    }
    int mx = 0;
    a[k] = n + a[0];
    for (int i=0; i<k; ++i)
        mx = max(mx, a[i+1]-a[i]);
    cout << n - mx << endl;
    return 0;
}


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

int main(void){
  string s;
  cin >> s;
  bool flag = true;
  if(s[0] != 'A') flag = false;
  if('A' <= s[1] && s[1] <= 'Z') flag = false;
  int Ccount = 0;
  int count = 0;
  for(int i = 2; i < s.length() - 1; i++){
    if(s[i] == 'C') Ccount++;
    if('A' <= s[i] && s[i] <= 'Z') count++;
  }
  if(Ccount != 1) flag = false;
  if(count >= 2) flag = false;
  if('A' <= s[s.length() - 1] && s[s.length() - 1] <= 'Z') flag = false;
  if(flag) cout << "AC" << endl;
  else cout << "WA" << endl;
  return 0;
}


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

def primes(n):
  is_prime=[True]*(n+1)
  is_prime[0]=False
  is_prime[1]=False
  for i in range(2,int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2,n+1,i):
      is_prime[j]=False
  return [i for i in range(n+1) if is_prime[i]]

l=primes(10000)
x=0;i=0
while x<n:
  if l[i]%10==1:
    print(l[i])
    x+=1
  i+=1

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    int64_t ans=N/(A+B)*A,remain=N-N/(A+B)*(A+B);
    ans+=min(remain,A);

    cout<<ans<<endl;
}

Measured memory_bytes: 256