akhauriyash/Code-Regression huggingface dataset:
from math import sqrt

N = int(input())
THRE = 0.0000001
ps = []
for _ in range(N):
    x, y = map(int, input().split())
    ps.append((x,y))

# 2点を直径とする円の中心と半径を求める
def circleThrough2Points(x1, y1, x2, y2):
    if x1 == x2 and y1 == y2:
        return None, None, None
    px = (x1 + x2) / 2
    py = (y1 + y2) / 2
    r = (px - x1)**2 + (py - y1)**2
    return px, py, r


# 3点を通る円の中心と半径を求める
def circleThrough3Points(x1, y1, x2, y2, x3, y3):
    a, b, c, d, e, f = x1, y1, x2, y2, x3, y3
    a2, b2, c2, d2, e2, f2 = a*a, b*b, c*c, d*d, e*e, f*f

    py_1 = 2*(e-a)*(b-d) - 2*(c-a)*(b-f)
    if py_1 == 0:
        return None, None, None
    py_2 = (e-a)*(a2+b2-c2-d2) - (c-a)*(a2+b2-e2-f2)
    py = py_2 / py_1

    if a != c:
        px = (2*(b-d)*py-a2-b2+c2+d2) / (2*(c-a))
    else:
        px = (2*(b-f)*py-a2-b2+e2+f2) / (2*(e-a))

    r = (px - a)**2 + (py - b)**2
    return px, py, r

ans = float('inf')
for i in range(N):
    x1, y1 = ps[i]
    for j in range(i+1, N):
        x2, y2 = ps[j]
        px, py, r = circleThrough2Points(x1, y1, x2, y2)
        if r is not None:
            if all([(px-x)**2 + (py-y)**2 <= r + THRE for x,y in ps]):
                ans = ans if ans < r else r

        for k in range(j+1, N):
            x3, y3 = ps[k]
            px, py, r = circleThrough3Points(x1, y1, x2, y2, x3, y3)
            if r is not None:
                if all([(px-x)**2 + (py-y)**2 <= r + THRE for x,y in ps]):
                    ans = ans if ans < r else r
print(sqrt(ans))


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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var a = input[0];
            var b = input[1];

            var c = (a + b+1) / 2;

            Console.WriteLine(c);

        }

    }

}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N;
    cin >> N;
    vector<ll> D(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> D[i];
    }
    sort(D.begin(), D.end());
    ll ans = D[N/2] - D[N/2-1];
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))
bn = [0]*n
j = 0
for i in range(n):
  bi = b[i]
  while(j<n):
    if bi < c[j]:
      bn[i] = n-j
      break
    j += 1
bnt = sum(bn)
bs = 0
j = 0
ans = 0
for i in range(n):
  ai = a[i]
  while(j<n):
    if ai < b[j]:
      ans += bnt - bs
      break
    bs += bn[j]
    j += 1
print(ans)

Measured memory_bytes: 29292
using System;
using System.Collections.Generic;
using System.Linq;
namespace CsProgramSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> judge = new List<string>();
            while (true)
            {
                short[] inf = (Console.ReadLine().Split(' ').Select(_ => short.Parse(_)).ToArray());
                short m = inf[0], f = inf[1], r = inf[2];
                if (m == -1 && f == -1 && r == -1)
                    break;
                if (m == -1 || f == -1)
                    judge.Add("F");
                else if (m + f >= 80)
                    judge.Add("A");
                else if (m + f >= 65)
                    judge.Add("B");
                else if (m + f >= 50)
                    judge.Add("C");
                else if (m + f >= 30)
                {
                    if (r >= 50)
                        judge.Add("C");
                    else
                        judge.Add("D");
                }
                else
                    judge.Add("F");
            }
            foreach (string s in judge)
                Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 18352
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define each(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vd vector<double>
#define vvd vector<vd>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define out(x) rep(i, 0, x.size()) cout << x[i] << ((i != x.size() - 1) ? " " : "\n")
const double PI = 3.14159265;
const int MAXN = 1 << 15;
const ll LINF = 1LL << 60;
const int INF = 1 << 30;
#define Pr(a) (#a) << "=" << (a) << " "
#define pr(a) cout << Pr(a) << '\n'
///////////////////////////////////////////////////////
int main() {
  int n, q;
  cin >> n;
  vi A(n);
  rep(i, 0, n) cin >> A[i];
  cin >> q;

  while (q--) {
    int ans = 0;
    int b, e, k;
    cin >> b >> e >> k;
    rep(i, b, e) {
      if (A[i] == k) ans++;
    }
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 3080
N=int(input())
a=list(map(int,input().split()))
a.sort()
a.append(0)
ans=0
b=a[0]
c=0
for i in range(N+1):
  if b!=a[i]:
    if c<b:
      ans+=c
    b=a[i]
    c=1
  else:
    if c==b:
      ans+=1
    else:
      c+=1
print(ans)

Measured memory_bytes: 20628
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  ll N; cin >> N;
  ll A[N]; rep(i, N) { cin >> A[i]; A[i] -= i+1; }

  sort(A, A+N);
  ll result = 0;
  rep(i, N) result += abs(A[i]-A[N/2]);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;
const int MAX_N=2*1e5+3;
int A[MAX_N];
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  bool f=true;
  if(A[0]!=0)f=false;
  for(int i=1;i<n;i++){
    if(A[i]>i)f=false;
    if(A[i-1]<A[i]-1)f=false;
  }
  long long ans=0;
  for(int i=n-1;i>0;i--){
    if(A[i]==A[i-1]+1)ans++;
    else ans+=A[i];
  }
  if(f)cout<<ans<<endl;
  else cout<<-1<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<bits/stdc++.h>
#include<unordered_map>

using namespace std;

int main()
{
  int n;
  cin>>n;
  int a[n];
  long long int sum=0;
  unordered_map<int,int> m;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    m[a[i]]++;
    sum=sum+a[i];
  }
	int q;
  	cin>>q;
  	while(q--)
    {
      int search,val;
      cin>>search>>val;
      if(m[search]!=0){
       sum=sum-((search-val)*m[search]);
       m[val]=m[val]+m[search];
       m[search]=0;
      }
      cout<<sum<<"\n";
    }
}


Measured memory_bytes: 7412
#include <iostream>
#define ll long long
using namespace std;
int main(){
	ll n; cin>>n;
	ll ans = n*(n+1)/2;
	ans -= (3*(n/3)*(n/3+1)/2 + 5*(n/5)*(n/5+1)/2);
	ans += (15*(n/15)*(n/15+1)/2);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3628
def resolve():
    s = input()
    t = input()
    ans = 10000
    lens = len(s)
    lent = len(t)
    for i in range(lens - lent + 1):
        x = 0
        for j in range(lent):
            if s[i + j] != t[j]:
                x += 1
        ans = min(ans, x)
    print(ans)


if __name__ == '__main__':
    resolve()


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

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

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

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

int main()
{
    int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    priority_queue<ll> p, q, r, all;
    // ll p[A], q[B], r[C];
    rep(i, A){
        ll Ai; cin >> Ai;
        p.push(Ai);
    }
    rep(i, B){
        ll Bi; cin >> Bi;
        q.push(Bi);
    }
    rep(i, C){
        ll Ci; cin >> Ci;
        r.push(Ci);
    }
    rep(i, X){
        all.push(p.top());
        p.pop();
    }
    rep(i, Y){
        all.push(q.top());
        q.pop();
    }
    rep(i, C){
        all.push(r.top());
        r.pop();
    }
    ll sum = 0;
    rep(i, X+Y){
        sum += all.top();
        all.pop();
    }
    /*
    while(X>0){
        if(p.empty()){
            sum += r.top(); r.pop();
        }else if(r.empty()){
            sum += p.top(); p.pop();
        }else if(p.empty() && r.empty()){
            break;
        }else{
            if(p.top() >= r.top()){
                sum += p.top(); p.pop();
            }else{
                sum += r.top(); r.pop();
            }
        }
        X--;
    }
    while(Y>0){
        if(q.empty()){
            sum += r.top(); q.pop();
        }else if(r.empty()){
            sum += q.top(); q.pop();
        }else if(q.empty() && r.empty()){
            break;
        }else{
            if(q.top() >= r.top()){
                sum += q.top(); q.pop();
            }else{
                sum += r.top(); r.pop();
            }
        }
        Y--;
    }
    */
    cout << sum << endl;
}

Measured memory_bytes: 8560
#include <stdio.h>

int main (void)
{
 int x,h,m,s;

 scanf("%d",&x);
 h = x / 3600;
 x = x % 3600;
 m = x / 60;
 x = x % 60;
 s = x;
 printf("%d:%d:%d\n",h,m,s);

 return 0;
}


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

int main()
{
    int i,n,c=0;
    string s,t;
    cin>>s>>t;
    n=s.size();
    for(i=0;i<n;i++)
    {
        if(s[i]!=t[i])
            c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) 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> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	int ans = 1e9;
	rep(i,n - k + 1){
		if(a.at(i) < 0 && a.at(i + k - 1) >= 0){
			ans = min(ans, min(-a.at(i) * 2 + a.at(i + k - 1), -a.at(i) + a.at(i + k - 1) * 2));
		}
		else if(a.at(i) < 0) ans = min(ans, -a.at(i));
		else ans = min(ans, a.at(i + k - 1));
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int main()
{
  int n, t;
  cin >> n >> t;

  int nmin = 1000000;
  for (int i = 0; i < n; ++i)
  {
    int c, tt;
    cin >> c >> tt;
    if (t < tt)
      continue;
    nmin = min(c, nmin);
  }
  if (nmin == 1000000)
    cout << "TLE" << endl;
  else
    cout << nmin << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n = 0;
  string t;
  cin >> t;
  for (int i = 0; i < 3; i++) {
    if (t[i] == 'o') {
      n = n + 1;
    }
  }
  cout << 700 + n * 100 << endl;
  return 0;
}


Measured memory_bytes: 256
/***************************************************
 * Problem Name : A - Circle.cpp
 * Problem Link : https://atcoder.jp/contests/abc145/tasks/abc145_a
 * OJ           : atCoder
 * Verdict      : Trying
 * Date         : 2019-11-22
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    int r;
    cin >> r ;
    cout << Sqr (r); nl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int Max=0,Max_P;
        for(int i=0;i<n;i++){
            int p,d1,d2;
            cin>>p>>d1>>d2;
            if(Max<d1+d2){
                Max=d1+d2;
                Max_P=p;
            }
        }
        cout<<Max_P<<" "<<Max<<endl;
    }
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
int t[100000];


using namespace std;
	int n,q,ans=0;;

bool binary_serch(int a){
	int l=0,r=n;
	int index;
	while(l<r){
		index=(l+r)/2;
		if(t[index]<a)l=index+1;
		else if(t[index]>a)r=index;
		else return true;
	}
	return false;
}
int main(){


	cin>>n;
	for(int i=0;i<n;i++)cin>>t[i];
	sort(t,t+n);

	
	cin>>q;

	int tmp;
	bool x;
	for(int i=0;i<q;i++){
		cin>>tmp;
		x=binary_serch(tmp);
		ans+=x;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1564
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------

/// problem's variable---------------


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

int main()
{
    Phuong_;
    ll a,b,c;
    cin >> a >> b >> c;
    c=c-a-b;
    if (c<0) cout << "No"; else
    {
        c=c*c;
        if (4*a*b <c) cout << "Yes"; else cout << "No";
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int K; cin >> K;
int A,B; cin >> A >> B;


bool ok = false;
for(int i = A; i <= B; i++) {
    if(i % K == 0) ok = true;
}

if(ok) cout << "OK" << endl;
else cout << "NG" << endl;

return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const long long mod=1e9+7;
int x[100005],y[100005];
int n,m;
ll ax,ay,ans;
int main() {
   cin>>n>>m;
   for(int i=1;i<=n;i++)cin>>x[i];
   for(int i=1;i<=m;i++)cin>>y[i];
     for(int i=1;i<=n/2;i++)
   	   ax+=(n-1-2*(i-1))*((x[n+1-i]-x[i])%mod),
   	   ax%=mod;   
      for(int i=1;i<=m/2;i++)
   	   ay+=(m-1-2*(i-1))*((y[m+1-i]-y[i])%mod),
   	   ay%=mod;   
	ans=(ll)ax*(ll)ay%mod;
   cout<<ans;}
   
   /*for(int i=1;i<=n;i++)
   {
   	   int t=i;
   	   for(int j=t+1;j<=n;j++)
   	     ax+=(x[j]-x[i])% mod,
   	     ax%=mod;
   }
     for(int i=1;i<=m;i++)
   {
   	   int t=i;
   	   for(int j=t+1;j<=m;j++)
   	     ay+=(y[j]-y[i])%mod,
   	     ay%=mod;
   }*/
  



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define vi vector < int >
#define pii pair < int, int >
 
const int N = 2e5 + 7;
const int mod = 1e9 + 7;
 
int t[4 * N], dp[N], a[N], b[N];
int n, m;
 
int get (int v, int l, int r, int ql, int qr){
    if (qr < l || ql > r)
        return 0;
    if (l >= ql && r <= qr)
        return t[v];
    int mid = (l + r) / 2;
    return max(get(v + v, l, mid, ql, qr), get(v + v + 1, mid + 1, r, ql, qr));
}
 
void upd (int v, int l, int r, int pos, int val){
    if (l == r){
        t[v] = val;
    }
    else {
        int mid = (l + r) / 2;
        if (mid >= pos)
            upd(v + v, l, mid, pos, val);
        else
            upd(v + v + 1, mid + 1, r, pos, val);
        t[v] = max(t[v + v], t[v + v + 1]);
    }
}
 
main(){
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        cin >> b[i];
 
    int mx = 0;
    for (int i = 1; i <= n; i++){
        dp[i] = get(1, 1, N, 1, a[i] - 1) + b[i];
        upd(1, 1, N, a[i], dp[i]);
        mx = max(mx, dp[i]);
    }
    cout << mx;
}

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

#define ll long long
#define pp pair<int, int>
#define FOR(i, n) for(int i = 0; i < n; i++)
#define FORU(i, a, b, s) for(int i = a; i < b; i += s)
#define FORD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"

ll INF = 2e18;
ll MOD = 1e9 + 7;
int i, j, k;

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

    vector<int> cnt(M + 1);
    FOR(i, N) {
        int K;
        cin >> K;
        FOR(j, K) {
            int t;
            cin >> t;
            cnt[t] += 1;
        }
    }

    int ans = 0;
    FOR(i, M + 1) {
        if(cnt[i] == N) {
            ans += 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        String S = sc.next();
        
        String[] strArray = S.split("");
        strArray[K-1] = strArray[K-1].toLowerCase();

        for(int i=0; i < strArray.length; i++){
            System.out.print(strArray[i]);
        }
    }
}

Measured memory_bytes: 21716
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
  int i,n,all,j;
  char *x;
 
char str2[100];
  int t[50];
  scanf("%d",&n);
      

char *pstr[50];          /* 1. */
char str[100];          /* 2. */

for(i = 0; i < n; i++){
    scanf("%s %d",str,&t[i]);   
    pstr[i] = (char *)malloc(sizeof(char) * (strlen(str)+1)); /* 4. */
    strcpy(pstr[i],str); 
}
 
  scanf("%s",str2);
  
  x=(char *)malloc(sizeof(char) * (strlen(str2)+1));
  strcpy(x, str2);
  
  all=0;
  
  for(i=0;i<n;i++){
  if(strcmp(pstr[i],x)==0){
    for(j=i+1;j<n;j++){
      all=t[j]+all;
  }
  }
  }
  printf("%d",all);
}
  

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	string s1, s2;
	cin >> s1 >> s2;
	int n = SZ(s1);
	map<char, char> mp;
	FOR(i, 'a', 'z') {
		mp[i] = '?';
	}
	
	FOR(i, 0, n - 1) {
		for (auto obj : mp) {
			if (obj.second == s2[i]) {
				if (obj.first != s1[i]) {
					ps(No);
					return 0;
				}
			}
		}
		if (mp[s1[i]] == '?') {
			mp[s1[i]] = s2[i];
		}
		else {
			if (mp[s1[i]] != s2[i]) {
				ps(No);
				return 0;
			}
		}
	}
	ps(Yes);
	return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int n; cin >> n;
    int mi = 10000000;
    int ans = 0;
    rep(i,n){
        int a; cin >> a;
        if (a <= mi) ans++;
        mi = min(mi,a);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

size_t isort(vector<int> &A, size_t g) {
    size_t count_=0;
    for (size_t i=g; i<A.size(); ++i) {
        int v=A[i], j;
        for (j=i-g; j>=0&&v<A[j]; j-=g) {
            A[j+g] = A[j];
            ++count_;
        }
        A[j+g] = v;
    }
    return count_;
}

size_t shsort(vector<int> &A) {
    size_t count_=0;
    size_t m=A.size();

    vector<size_t> g; g.push_back(1);
    for (size_t h=4; h<=m&&g.size()<100; ++(h*=3))
        g.push_back(h);

    reverse(g.begin(), g.end());

    printf("%zu\n", g.size());
    for (size_t i=0; i<g.size(); ++i)
        printf("%zu%c", g[i], i<g.size()-1? ' ':'\n');

    for (size_t d: g)
        count_ += isort(A, d);

    return count_;
}

int main() {
    size_t N;
    scanf("%zu", &N);

    vector<int> A(N);
    for (size_t i=0; i<N; ++i)
        scanf("%d", &A[i]);

    size_t t=shsort(A);

    printf("%zu\n", t);
    for (size_t i=0; i<N; ++i)
        printf("%d\n", A[i]);

    return 0;
}

Measured memory_bytes: 6304
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define ins insert
#define mk make_pair
#define fr first
#define sc second
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,sum=0;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
    	if(i%3==0 || i%5==0) continue;
    	sum=sum+i;
	}
	cout<<sum;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int 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;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec< int > b(N + 1, INF);
  REP(i, N - 1) { cin >> b[i + 1]; }
  int ans = 0;
  REP(i, N) { ans += min(b[i], b[i + 1]); }
  print(ans);
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
W = []
N.times do |i|
  W[i] = gets.chomp
end

set = Set.new
word = W[0][0]
ok = true
W.each do |w|
  if word[-1] != w[0] || set.include?(w)
    ok = false
    break
  end
  word = w
  set.add(w)
end

puts ok ? 'Yes' : 'No'


Measured memory_bytes: 14460
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <stack>
#define FOR(arg, ini, end) for(int arg = ini; arg < end; arg++)


using namespace std;
int main(int argc, const char * argv[]) {
    
    long l, r;
    cin >> l >> r;
    long m=2020;
    FOR(i, l, min(r+1, l+2019)) {
        FOR(j, i+1, min(r+1, l+2019)) {
            m = min(m, (((long)i*(long)j))%2019);
        }
    }

    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;

signed main(){
    int D,G;
    cin>>D>>G;
    vector<int> p(D),c(D);
    REP(i,D) cin>>p[i]>>c[i];
    int ans=INT_MAX;
    REP(i,1<<D){
        int point=0,count=0;
        REP(j,D)if(i>>j&1){
            point+=100*(j+1)*p[j]+c[j];
            count+=p[j];
        }
        bool ok=true;
        for(int j=D-1;j>=0;--j)if((i>>j&1)==0){
            int c=(G>point)?((G-point-1)/(100*(j+1))+1):0;
            if(c>=p[j]) ok=false;
            else count+=c;
            break;
        }
        //cout<<count<<endl;
        if(ok)ans=min(ans,count);
    }
    cout<<ans<<endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


int C[55][55];

int N,A,B;

signed main(){
    for(int i=0;i<55;i++){
        C[i][i]=C[i][0]=1;
        for(int j=1;j<i;j++)C[i][j]=C[i-1][j-1]+C[i-1][j];
    }

    cin>>N>>A>>B;
    vint v(N);
    rep(i,N)cin>>v[i];
    sort(all(v));reverse(all(v));

    pint ans(0,1);
    int way=0;
    for(int i=A;i<=B;i++){
        int sum=0;
        rep(j,i)sum+=v[j];

        pint p(sum,i);
        int c;

        int x=0,y=0;
        rep(j,i)if(v[j]==v[i-1])y++;
        rep(j,N)if(v[j]==v[i-1])x++;
        c=C[x][y];

        if(ans.fi*p.se<ans.se*p.fi){
            ans=p;
            way=c;
        }
        else if(ans.fi*p.se==ans.se*p.fi){
            way+=c;
        }
    }
    printf("%.20f\n",1.0*ans.fi/ans.se);
    cout<<way<<endl;
    return 0;
}


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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

string s;

int main() {
    bool ok = true;
    cin >> s;
    unordered_map<char,int> mp;
    for (auto c : s) {
        mp[c]++;
    }
    for (auto c : mp) {
        if (c.second != 2) {
            ok = false;
            break;
        }
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000000;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

VVI edge(300, VI(0));
VI colors(300,-1);

bool bipartite_dfs(int v, int c) {
	colors[v] = c;
	for (int i = 0; i < edge[v].size(); i++) {
		if (colors[edge[v][i]] == c) {
			return false;
		}
		if (colors[edge[v][i]] == -1 && !bipartite_dfs(edge[v][i], !c)) {
			return false;
		}
	}
	return true;
}

int main() {
	int n;
	cin >> n;
	string s; int edgec = 0; VVI cost(n, VI(n, INF));
	REP(i, n) {
		cin >> s;
		for(int j = i + 1;j < n;j++) {
			if (s[j] == '1') {
				edgec++;
				edge[i].push_back(j);
				edge[j].push_back(i);
				cost[i][j] = 1;
				cost[j][i] = 1;
			}
		}
		cost[i][i] = 0;
	}
	if (!bipartite_dfs(0, 0)) {
		cout << -1;
	}
	else {
		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				ans = max(ans, cost[i][j]);
			}
		}
		cout << ans + 1;
	}
	return 0;
}

Measured memory_bytes: 640
n = int(input())
arr = list(map(int,input().split()))


money = 1000
stock = 0

for i in range(n-1):
    if arr[i+1] > arr[i]:
        bs = money//arr[i]
        stock += money//arr[i]
        money -= arr[i]*bs
    else:
        money += stock*arr[i]
        stock = 0

    # print(money,stock)

money += stock * arr[-1]

print(money)


Measured memory_bytes: 9192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int result = 0;
		
		switch (str) {
		case "SAT":
			result = 1;
			break;
		case "SUN":
			result = 7;
			break;
		case "MON":
			result = 6;
			break;
		case "TUE":
			result = 5;
			break;
		case "WED":
			result = 4;
			break;
		case "THU":
			result = 3;
			break;

		default:
			result = 2;
			break;
		}
		
		System.out.println(result);
	}

}


Measured memory_bytes: 23252
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int N, ans;
vector<int> A, L, R;
void solve() {
    cin >> N;
    A.resize(N);
    L.resize(N + 1);
    R.resize(N + 1);
    L[0] = 0;
    R[0] = 0; 
    ans = -INF;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        L[i + 1] = __gcd(L[i], A[i]);
    }
    reverse(A.begin(), A.end());
    for (int i = 0; i < N; i++) {
        R[i + 1] = __gcd(R[i], A[i]);
    }
    for (int i = 0; i < N; i++) {
        ans = max(ans, __gcd(L[i], R[N - 1 - i]));
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
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 % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
using namespace std;
int main(){
    int N;
    cin >> N;

    string hntei;
    double sum=0,x;

    REP(i,N){
        cin >> x >> hntei;

        if(hntei == "JPY"){
            sum += x;
        }else{
            sum += x*380000;
        }
    }
    cout << sum <<endl;
}

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

int main(){
	int N; string C; cin>>N>>C;
	int l = 0, r = N-1, c = 0;
	while(l < r){
		if(C[l] != 'W'){ l++; continue; }
		if(C[r] != 'R'){ r--; continue; }
		l++; r--; c++;
	}
	cout<< c <<endl;
}


Measured memory_bytes: 3712
#include <iostream>

using namespace std;

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

    int R=L+N-1;
    int eat;

    if(R<=0)eat=R;
else if(L>=0)eat=L;
 else eat=0;

 int answer=(R+L)*(R-L+1)/2-eat;

 cout<<answer<<endl;
}



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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll X, Y, A, B, C;
  IN(X,Y,A,B,C);
  vll p(A), q(B), r(C);
  REP(i,A) IN(p[i]);
  REP(i,B) IN(q[i]);
  REP(i,C) IN(r[i]);
  sort(ALL(p)); reverse(ALL(p));
  sort(ALL(q)); reverse(ALL(q));
  sort(ALL(r)); reverse(ALL(r));

  vll ans(X+Y);
  REP(i,X) ans[i] = p[i];
  REP(i,Y) ans[i+X] = q[i];

  sort(ALL(ans));
  reverse(ALL(ans));

  ll h1=0, h2=0;
  while(h1+h2<X+Y){
    if(h1==X+Y) h2++;
    else if(h2==C) h1++;
    else if(ans[h1]>r[h2]) h1++;
    else h2++;
  }

  ll hoge = 0;
  REP(i,h1) hoge += ans[i];
  REP(i,h2) hoge += r[i];
  OUT(hoge);

  return 0;
}

Measured memory_bytes: 3968
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int flag = 0;
        for(int i=A;i<=B;i++)
        {
            if(i%K==0)
            {
                flag = 1;
                break;
            }
        }
        if(flag==1)
        {
            System.out.println("OK");
        }
        else
        {
            System.out.println("NG");
        }
    }
}


Measured memory_bytes: 35784
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

int main(void){
  int n; cin >> n;
  vector<ll> l(n);

  rep(i,n) cin >> l.at(i);
  int ans = 0;

  for(int i=0;i<n-2;i++){
    for(int j = i+1;j<n-1;j++){
      for(int k = j+1;k<n;k++){
        if(l.at(i)==l.at(j)) continue;
        if(l.at(j)==l.at(k)) continue;
        if(l.at(k)==l.at(i)) continue;

        if(l.at(i)<l.at(j)+l.at(k) && l.at(j)<l.at(k)+l.at(i) &&
      l.at(k)<l.at(i)+l.at(j)) ans++;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    int[] height = new int[10];
    Scanner s = new Scanner(System.in);
    int temp;

    for(int i = 0;i < height.length;i++){
      height[i] = s.nextInt();
    }

    for(int i = 0;i < height.length;i++){
      for(int j = i;j < height.length;j++){
        if(i != j){
          if(height[i] < height[j]){
            temp = height[i];
            height[i] = height[j];
            height[j] = temp;
          }
        }
      }
    }

    for(int i = 0;i < 3;i++){
      System.out.println(height[i]);
    }
  }
}

Measured memory_bytes: 26188
import sys
input = sys.stdin.readline
N, M, K = map(int, input().split())
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def Find_Root(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]
  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if(x == y):
      return 
    if self.root[x] > self.root[y]:
      x, y = y, x
    self.root[x] += self.root[y]
    self.root[y] = x 
  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)
  def Count(self, x): # xが属するグループのサイズを返す
    return -self.root[self.Find_Root(x)]
  def Members(self, x): # xが属するグループに属する要素をリストで返す
    return [i for i in range(self.n) if self.Find_Root(i)==self.Find_Root(x)]
  def Roots(self): # 全ての根の要素をリストで返す
    return [i for i, x in enumerate(self.root) if x < 0]
  def Group_Count(self): # グループの数を返す
    return len(self.Roots())

uf = UnionFind(N+1)
roots = {i:0 for i in range(1, N+1)}
each_root = [0]*(N+1)
ad = [0]*(N+1)

for _ in range(M):
  a, b = map(int, input().split())
  uf.Unite(a, b)
  ad[a] += 1
  ad[b] += 1

for i in range(1, N+1):
  r = uf.Find_Root(i)
  roots[r] += 1
  each_root[i] = r

for _ in range(K):
  c, d = map(int, input().split())
  if each_root[c] == each_root[d]:
    ad[c] += 1
    ad[d] += 1

for i in range(1, N+1):
  print(roots[each_root[i]]-ad[i]-1, end=" ")

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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    int N, M;
    void solve() {
        cin >> N >> M;
        vector<int> X(N, 0);
        vector<int> S(N, 1);
        X[0] = true;
        for (int i = 0; i < M; i++) {
            int x, y;
            cin >> x >> y;
            x--; y--;
            S[x]--;
            S[y]++;
            if (X[x]) {
                if (S[x] == 0) X[x] = false;
                X[y] = true;
            }
        }
        cout << count(X.begin(), X.end(), 1) << endl;
    }
}

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



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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
const ll MOD = 1e9 + 7;

int main() {
    fastio;

    int n;
    cin >> n;
    int A[n];
    ll sumTotal = 0;
    FOR(i, 0, n) {
        cin >> A[i];
        sumTotal += A[i];
    }
    ll sumA = 0;
    ll minV = 1e12;
    FOR(i, 0, n-1) {
        sumA += A[i];
        ll x = sumTotal - sumA;
        minV = min(minV, abs(sumA - x));
    }
    cout << minV << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
  int P,Q,R;
  cin>>P>>Q>>R;
  int ans=P+Q+R-max(P,max(Q,R));
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3576
n = int(input())
ans = list(map(int, input().split()))

count = 0
while sum(ans) != 0:
    st = -1
    ed = 0
    for i in range(n):
        if (ans[i] != 0) and (st == -1):
            st = i
        if ans[i] == 0 and st != -1:
            ed = i - 1
            break;
        if (st != -1) and (ed == 0) and (i == n-1):
            ed = i
            break;
    for i in range(st, ed+1):
        ans[i] -= 1
    count += 1
    
print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
   	ll n,k;
   	cin >> n >> k;
   	vector <ll> arr(n);
   	for (int z=0;z<n;z++){
   		cin >> arr[z];
   	}
   	vector <ll> dp(n,LLONG_MAX);
   	dp[0] = 0;
   	for (int z=1;z<n;z++){
   		for (int x=1;x<=k;x++){
   			if (z-x < 0) break;
   			dp[z] = min(dp[z-x]+abs(arr[z-x]-arr[z]),dp[z]);
   		}
   	}
   	cout << dp[n-1] << endl;
   	cin >> n;
}


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

int main() {
    ll N;

    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    int cnt = 1, dnum = 0;
    rep(i, N) {
        if(a[i] == cnt) {
            cnt++;
        } else {
            dnum++;
        }
    }
    if(N == dnum) {
        cout << -1 << endl;
    } else {
        cout << dnum << endl;
    }
    return 0;
}


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

int main()
{
	int a, b;
	while (cin >> a >> b)
	{
		if ((a + b) % 3 == 0||a%3==0||b%3==0)
			cout << "Possible" << endl;
		else
			cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,t = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	s = 0
	for i in 2:n
		s += min(a[i]-a[i-1],t)
	end
	println(s+t)
end

main()

Measured memory_bytes: 122924
def main():
    a = list(map(int, list(input())))
    a.reverse()
    n = len(a)
    a += [0]
    b = [i for i in a]
    cnt = 0
    for i in range(len(a)):
        if b[i] > 5 or (b[i] == 5 and b[i+1] >= 5):
            b[i] = 0
            b[i+1] += 1
    cnt = sum(b)
    for i in range(n):
        if a[i] <= b[i]:
            cnt += b[i]-a[i]
        else:
            b[i] += 10
            b[i+1] -= 1
            cnt += b[i]-a[i]
    print(cnt)


main()

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

int main()
{
  int W,H,x,y,r;
  
  cin >> W >> H >> x >> y >> r;
  if (x<r or x+r>W or y<r or y+r > H){
    cout << "No"<<"\n";
  }
  else{
    cout << "Yes"<<"\n";
  }
  return 0;
}


Measured memory_bytes: 3112