akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
using namespace std;
static const int N = 13;
static const int MOD = 1000000007;

int main() {
    string S;
    int dp[N] = {1};
    int next[N] = {};
    int mul = 1;
    cin >> S;

    
    for (int i = S.size() - 1; i >= 0; i--) {
        fill(next, next + N, 0);

        if (S[i] == '?') {
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < N; k++) {
                    next[(k + mul * j) % N] += dp[k];
                    next[(k + mul * j) % N] %= MOD;
                }
            }
        } else {
            int j = (int)(S[i] - '0');
            for (int k = 0; k < N; k++) {
                next[(k + mul * j) % N] += dp[k];
                next[(k + mul * j) % N] %= MOD;
            }
        }

        mul *= 10;
        mul %= N;
        memcpy(dp, next, sizeof dp);
    }

    cout << next[5] << endl;

    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;++i)
#define END(x) (*(x.end()-1))
#define INF (INT_MAX / 2)

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)*b;
}

int main(void){
    int n;
    cin>>n;
    cout<<10-(n/100)/2;
}
/*

*/

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    int X;
    cin >> X;
    if (X >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n,W;
  cin >> n >> W;

  vll w(n), v(n);
  REP(i, n)
    cin >> w[i] >> v[i];

  vector<vll> s(4, vll(1, 0));
  REP(i, n)
    s[w[i]-w[0]].push_back(v[i]);

  for(auto &p : s){
    sort(p.rbegin(), p.rend()-1);
    REP1(i, p.size())
      p[i] += p[i-1];
  }

  ll ans = 0;
  for(ll i=0; i<=s[0].size(); i++){
    for(ll j=0; j<=s[1].size(); j++){
      for(ll k=0; k<=s[2].size(); k++){
        for(ll t=0; t<=s[3].size(); t++){
          if(w[0]*(i+j+k+t)+j+2*k+3*t > W)
            continue;

          ans = max(ans, s[0][i]+s[1][j]+s[2][k]+s[3][t]);

        }
      }
    }

  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
typedef long long ll;
#define rep(i,n) for(int i = 0;i<n;++i)
#define repnc(bit,k,n) for (int bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;

/* next combination */
int next_combination(int sub) {
  int x = sub & -sub, y = sub + x;
  return (((sub & ~y) / x) >> 1) | y;
}

int int_substr(string abcd, int n){
  return abcd[n]-'0';
}

int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
  string abcd;
  cin >> abcd;
  string ans;
  ans = abcd[0];
  rep(bit, 1<<3){
    int calc = int_substr(abcd,0);
    char opt[3];
    rep(i, 3){
      if(bit&1<<i){
        opt[i] = '+';
        calc+=int_substr(abcd,i+1);
      }else{
        opt[i] = '-';
        calc-=int_substr(abcd,i+1);
      }
    }
    if(calc == 7){
      rep(i, 3){
        ans+=opt[i];ans+=abcd[i+1];
      }
      break;
    }
  }
  cout << ans << "=7\n";
        return 0;
}

Measured memory_bytes: 3092
kazulist = []
for i in range(-100,200):
    kazulist.append(i)
 
a = list(input().split(" "))
target = int(a[0])
syokyo = int(a[1])

if syokyo != 0:
    b = list(input().split(" "))
    for i in b:
        kazulist.remove(int(i))
 
saisyosa = 100
kotae = 0
for i in kazulist:
    sa = target - int(i)
    #print(sa)
    if sa < 0:
        sa *= -1
    if sa < saisyosa:
        saisyosa = sa
        kotae = i
 
print(kotae)

Measured memory_bytes: 9208
N = int(input())
A = [int(i) for i in input().split()]
for i in range(N):
    A[i] -= (i+1)

A.sort()

if N % 2 != 0:
    num = A[N//2]
    A = [abs(i - num) for i in A]
    print(sum(A))
else:
    num1 = A[N//2]
    num2 = num1 -1
    A1 = [abs(i - num1) for i in A]
    A2 = [abs(i - num2) for i in A]
    print(min(sum(A1), sum(A2)))

Measured memory_bytes: 27844
#include <bits/stdc++.h>
using namespace std;
bool PN(int x)
{
  if (x <= 1)
    return false;
  if (x == 2)
    return true;
  for (int i = 2; i < sqrt(x) + 1; i++)
    if (x % i == 0)
      return false;
  return true;
}

void solve()
{
  int n, m; cin >> n >> m;
  int a[n], b[n];
  int x[m], y[m];
  for(int i = 0; i < n; ++i){
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < m; ++i){
    cin >> x[i] >> y[i];
  }
  for(int i =0 ; i < n; ++i){
    int mi = 1000500000;
    int ans = -1;
    for(int j = 0; j < m; ++j){
      if(mi > abs(a[i]-x[j]) + abs(b[i]-y[j])){
        ans = j+1;
        mi = abs(a[i]-x[j]) + abs(b[i]-y[j]);
      }
    }

    cout << ans << endl;
  }
}

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

Measured memory_bytes: 3668
#include<stdio.h>
int a[1000010],n;

int binarysearch(int key)
{
    int left=0;
    int right=n;
    int mid;
    while(left<right)
    {
        mid=(left+right)/2;
        if(key==a[mid]) return 1;
        else if(key<a[mid]) right=mid;
        else left=mid+1;
    }
    return 0;
}
int main()
{
    int i,q,k,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++)
    {
        scanf("%d",&k);
        if(binarysearch(k)) sum++;
    }
    printf("%d\n",sum);
    return 0;
}



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

using namespace std;

const int md = (int) 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

int main() {
  int n;
  cin >> n;
  vector<int> dp(n + 1);
  dp[0] = 1; dp[1] = n;

  for (int i = 2, sum = 0; i <= n; i++) {
    dp[i] = dp[i - 1];
    add(dp[i], mul(n - 1, n - 1));
    add(dp[i], sum);
    add(dp[i], (n - 1) - (i - 2));
    add(sum, dp[i - 2]);
  }

  cout << dp[n] << '\n';
  return 0;
}

Measured memory_bytes: 4096
N=int(input())
*V,=map(int,input().split())

from collections import*
C1=Counter(V[::2]).most_common()+[(0,0)]
C2=Counter(V[1::2]).most_common()+[(0,0)]

K1=C1[0][0]
V1=C1[0][1]
K2=C2[0][0]
V2=C2[0][1]
if K1==K2:
    if V1>V2:
        V2=C2[1][1]
    elif V2>V1:
        V1=C[1][1]
    else:
        V2=max(C1[1][1],C2[1][1])

print(N-V1-V2)

Measured memory_bytes: 25264
import statistics

N = int(input())
a = []
b = []
for i in range(N):
    A,B = map(int, input().split())
    a.append(A)
    b.append(B)

a2 = statistics.median(a)
b2 = statistics.median(b)

if N % 2 == 0:
    c = (b2-a2)/0.5 + 1
    print(int(c))
else:
    print(b2-a2+1)

Measured memory_bytes: 28968
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	a = a * 100 + b * 10 + c;
	if(a % 4) printf("NO\n");
	else printf("YES\n");
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << -1; return;}

const int N = 1e5 + 7;

vector <pi> g[N];
int col[N];

void dfs(int v, int p, int c) {
    col[v] = c;
    for (pi u : g[v])
        if (u.F != p)
            dfs(u.F, v, (u.S & 1 ? 3 - c : c));
}

void solve() {
    int n; cin >> n;
    loop(i, n - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        g[u].pb({ v, w });
        g[v].pb({ u, w });
    }
    dfs(1, 1, 1);
    loop1(i, n)
        cout << col[i] - 1 << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 12356
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
    int N;
    cin >> N;
    int P = N;
    bool ok = false;
    if((N*100)%108 == 0){
        cout << N / 1.08 << endl;
      	ok = true;
    }
    else{
        N = N / 1.08;
        int a = N;

        for(int i = 0;i<2;i++){
            int b = (a+i)*1.08;
            if(b==P){
                ok = 1;
            }
            if(ok == 1){
                int ans = a+i;
                cout << ans << endl;
                break;
            }
        }
    }

    
    if (ok == 0){
        cout << ":(" << endl;
    }

    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  string s;
  cin >> s;
  map<char,int> mp;
  rep(i,4){
    if(!mp.count(s.at(i))){
      mp[s.at(i)] = 1;
    }else{
      mp[s.at(i)]++;
    }
  }
  if(mp.size()==2){
    for(auto x: mp){
      if(x.second != 2){
        cout << "No" << endl; return 0;
      }
    }
     cout << "Yes" << endl;
     return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
            b[i] = a[i];
        }
        Arrays.sort(a);
        for(int i =0;i<n;i++){
            if(a[n-1]==b[i]){
                System.out.println(a[n-2]);
            } else {
                System.out.println(a[n-1]);
            }
        }
    }
}

Measured memory_bytes: 90996
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;

#define ALL(v) (v).begin(), (v).end()
#define REP(i,N) for(int i = 0; i < (int)(N); ++i)
double EPS = 1e-8;

struct Person {
  int id;
  int lap;
  double speed;
  double x;
  bool operator < (const Person &t) const {
    if( abs( x - t.x ) > EPS ) return x > t.x; // xÀWªå«¢Ù¤ªO
    return speed > t.speed;                    // ¯¶Èç¬¢Ù¤ªO
  }
  void print() {
    cout << "(" << id << ' ' << lap << ' ' << speed << ' ' << x << ") ";
  }
};

int main() {
  for(int N; cin >> N && N ; ) {
    int T[N], C[N];
    REP(i, N) cin >> T[i] >> C[i];

    vector<Person> v[2];
    REP(i, N) {
      v[0].push_back( (Person){i, 0, 1.0 / T[i], 0}  );
    }
    sort( ALL(v[0]) );
    int time = 0;
    for(; !v[0].empty() || !v[1].empty(); time++) {
      vector<Person> change[2];

      REP(i, v[0].size() ) {
        v[0][i].x += v[0][i].speed;
        if( i > 0 && v[0][i - 1].x < v[0][i].x ) v[0][i].x = v[0][i - 1].x;
        if( v[0][i].x >= 1.0 ) v[0][i].x = 1.0;
      }

      REP(i, v[0].size()) {
        const Person &p = v[0][i];
        if( abs( p.x - 1.0 ) < EPS ) {
          change[1].push_back( (Person){p.id, p.lap, p.speed, 0} );
        }
      }

      REP(i, v[1].size() ) {
        v[1][i].x += v[1][i].speed;
        if( i > 0 && v[1][i - 1].x < v[1][i].x ) v[1][i].x = v[1][i - 1].x;
        if( v[1][i].x >= 1.0 ) v[1][i].x = 1.0;
      }
      REP(i, v[1].size()) {
        const Person &p = v[1][i];
        if( abs( p.x - 1.0 ) < EPS ) {
          if( p.lap + 1 == C[p.id] )
            ;
          else
            change[0].push_back( (Person){p.id, p.lap + 1, p.speed, 0} );
        }
      }

      REP(i, 2) {
        while( v[i].size() && abs(v[i][0].x - 1.0) < EPS ) v[i].erase( v[i].begin() );
        sort( ALL(change[i]) );
        REP(j, change[i].size()) v[i].push_back(change[i][j]);
      }
//       REP(i, v[0].size()) v[0][i].print(); cout << endl;
//       REP(i, v[1].size()) v[1][i].print(); cout << endl;
//       cout << "----" << endl;
    }
    cout << time << endl;
  }
  return 0;
}

Measured memory_bytes: 916
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
vector<int> v;
class Calc
{
    // 宣言
    long long a;

    public:
        // 素因数分解
        void decompositPrime(long long a);
};

/*
 * 素因数分解
 */
void Calc::decompositPrime(long long n)
{
    // 割る数の初期値
    a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            //printf("%d * ", a);
             v.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    v.push_back(n);
    //printf("%d\n", n);
}

int main(){
    //std::stack<int> stack;
    int n;
    cin >> n ;
    vector<long> a(n+1);
    vector<long> b(n+1);
    vector<long> um(n+2);
    for(int i = 0; i <= n; i++){
        cin >> a[i];
    }
    um[n] = a[n];
    for(int i = n-1; i >= 0; i--){
        um[i] = um[i+1] + a[i];
    }
    long ans = 0;
    b[0] = 1-a[0];
    long tmp = 1;
    for(int i = 0; i <= n; i++){
        ans += tmp;
        tmp -= a[i];
        if(tmp < 0){
            cout << -1 << endl;
            return 0;
        }
        tmp = min(tmp*2, um[i+1]);
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 5576
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
  
#define mp make_pair

#define ll long long
#define pb push_back
  
using namespace std;
/*
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  */
const int inf = 2e9+7, mod=1e9+7;
const int N = 2e6;

int ans=0;

int used[N];
 
int xx[8]={1, 1, -1, -1, 2, 2, -2, -2};
int yy[8]={2, -2, 2, -2, 1, -1, 1, -1};

int a[5];

double d[320][320][320];

int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		int b;
		cin >> b;
		a[b]++;	
	}
	for(int k=0; k<=a[3]; k++){
		for(int j=0; j<=a[2]+a[3]; j++){
			for(int i=0; i<=a[1]+a[2]+a[3]; i++){
				double k1=0, j1=0, i1=0, n1=0;
				if(k)
					k1=(double)k/(double)(i+j+k)*d[i][j+1][k-1];
				if(i)
					i1=(double)i/(double)(i+j+k)*d[i-1][j][k];
				if(j)
					j1=(double)j/(double)(i+j+k)*d[i+1][j-1][k];
				if(i+j+k>0)
					n1=(double)n/(double)(i+j+k);
				d[i][j][k]=k1+i1+j1+n1;
//				cout << d[i][j][j] << " " << i<<j<<k<<endl;
			}	
		}
	}
	printf("%.9lf", d[a[1]][a[2]][a[3]]);
	//cout << d[a[1]][a[2]][a[3]];
	return 0;
}



Measured memory_bytes: 243840
import Data.Char

match :: String -> Bool
match s = isInitialA && containsCOneAndOnly && isAllLower
  where isInitialA          = (== 'A') $ head s
        containsCOneAndOnly = (== 1) $ length . filter (== 'C') . init . drop 2 $ s
        isAllLower          = all isLower . filter (/= 'C') . tail $ s

main :: IO ()
main = do
  s <- getLine
  putStrLn $ if match s then "AC" else "WA"

Measured memory_bytes: 380
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,d,c;
    scanf("%d %d",&a,&b);
        c=log10(b)+1;
        d=pow(10,(int)c);
        d=d*a+b;
        c=sqrt(d);
        if((c*c)==d)
            printf("Yes\n");
        else
            printf("No\n");
    return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

vector<int> A, B, B0, B1;

int get_value(int v, int b)
{
	return (1 << b) - (v&((1 << b) - 1)) - 1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N, ans = 0;
	cin >> N;
	A.resize(N);
	B.resize(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int b = 0; b < 29; b++) {
		int MOD = (1 << b) - 1;
		B0.clear();
		B1.clear();
		for (int i = 0; i < N; i++) {
			if (B[i] & (1 << b)) B1.push_back(B[i] & MOD);
			else B0.push_back(B[i] & MOD);
		}
		sort(B0.begin(), B0.end());
		sort(B1.begin(), B1.end());
		for (int i = 0; i < N; i++) {
			int cnt;
			if (A[i] & (1 << b)) {
				cnt = B1.size() - (upper_bound(B1.begin(), B1.end(), get_value(A[i], b)) - B1.begin()) + (upper_bound(B0.begin(), B0.end(), get_value(A[i], b)) - B0.begin());
			}
			else {
				cnt = B0.size() - (upper_bound(B0.begin(), B0.end(), get_value(A[i], b)) - B0.begin()) + (upper_bound(B1.begin(), B1.end(), get_value(A[i], b)) - B1.begin());
			}
			ans ^= (cnt & 1) << b;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3444
#include <iostream>
#include <cmath>
#include <iomanip>

//auto print = [](auto x){ std::cout << x; };
auto println = [](auto x){ std::cout << x << std::endl; };
auto read = [](auto &x){ std::cin >> x; };

int main ()
{
  double x1, y1, x2, y2;

  std::cin >> x1 >> y1 >> x2 >> y2;
  std::cout << std::setprecision(20);
  println(std::sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)));
}


Measured memory_bytes: 3300
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#define ll long long
#define ull unsigned long long

using namespace std;

int a[25], b[25], c[25], n;

inline ll in()
{
	ll Req = 0, wX = 0; char ch;
	while (!isdigit(ch)) {wX |= (ch == '-'); ch = getchar();}
	while (isdigit(ch)) {Req = (Req << 3) + (Req << 1) + (ch ^ 48); ch = getchar();}
	return wX ? -Req : Req;
}

inline void out(ll x)
{
	register short Pxn[20], Ry = 0;
	if (x == 0) putchar('0');
	if (x < 0) putchar('-'), x = -x;
	while (x != 0) Pxn[Ry] = x % 10, x /= 10, Ry++;
	for (int i = Ry - 1; i >= 0; i--) putchar(Pxn[i] + '0');
}

int main()
{

	n = in();
	for (int i = 0; i < n; i++) a[i] = in()-1;
	for (int i = 0; i < n; i++) b[i] = in();
	for (int i = 0; i < n - 1; i++) c[i] = in();
	int ans = b[a[0]];
	for (int i = 1; i < n; i++)
	{
		ans += b[a[i]];
		if (a[i] == a[i - 1] + 1) ans += c[a[i - 1]];
	}
	out(ans);

  return 0;

}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#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;
 
void err(istream_iterator<string> it) {cout << '\n';}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "[" << *it << " = " << a << "] ";
    err(++it, args...);
}
 
#define F first
#define S second
#define ll long long
#define ull unsigned ll
#define pb push_back
#define pf push_front
#define db double
#define ld long double
#define ppb pop_back
#define ppf pop_front
#define br cout << '\n'
#define pll pair<long long, long long>
#define pipii pair<int, pii>
#define ppiii pair<pii, int>
#define piipii pair<pii, pii>
#define here cout << "HERE\n"
#define all(x) (x).begin(),(x).end()
#define __ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define TEST int TT; cin >> TT; for(int T = 1; T <= TT; T++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//#define int ll
#define pii pair<int, int>
 
const int inf = 2e9 + 7;
const ll INF = 3e18 + 7;
int mod = 1e9 + 7;
ll MOD = 1e15 + 7;
 
const bool multiple_tests = 0;
const int N = 2e5 + 7;

int up[N][70];

void solve() {
    ll n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> up[i][0];
    }
    for (int j = 1; j < 70; j++) {
        for (int i = 1; i <= n; i++)
            up[i][j] = up[up[i][j - 1]][j - 1];
    }
    int ans = 1;
    while (k) {
        for (int i = 61; i >= 0; i--) {
            if ((1LL << i) <= k) {
                k -= (1LL << i);
                ans = up[ans][i];
                break;
            }
        }
    }
    cout << ans;
}
 
 
 
signed main() { __
//    freopen("lcm.in", "r", stdin);
//    freopen("lcm.out", "w", stdout);
    int TT = 1;
    if (multiple_tests) cin >> TT;
    for (int T = 1; T <= TT; T++) {
//        cout << "Test Case #" << T << ": ";
        solve();
        cout << '\n';
    }
    
    #ifndef AMIR_MAL
      cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}


Measured memory_bytes: 58476
import itertools
import copy
def bitsuuretu(n):
    tmp = []
    for i in range(2**n):
        ls = [0] * n
        for j in range(len(ls)):
            if (i >> j) & 1:
                ls[j] += 1
        tmp.append(ls)
    
    return tmp

H,W,K = list(map(int, input().split()))

Carray = [input() for _ in range(H)]

CintArray = []
for cs in Carray:
    tmp = []
    for c in cs:
        if(c == "."):
            tmp.append(0)
        else:
            tmp.append(1)
        
    CintArray.append(tmp)

forHbitArray = bitsuuretu(H)
forWbitArray = bitsuuretu(W)

#print(forHbitArray)
#print(forWbitArray)
ans = 0
for Hs in forHbitArray:
    for Ws in forWbitArray:
#        print(Hs, Ws)
#        print(CintArray)
        CarrayChecker = copy.deepcopy(CintArray)
        for Hindex, Hhoge in enumerate(Hs):
            for Windex, Whoge in enumerate(Ws):
#                print(Hhoge, Whoge)

                if(Hhoge == 1 or Whoge == 1):
                    CarrayChecker[Hindex][Windex] = 0
        
#                print(CarrayChecker)
        
#        print(CarrayChecker)
        sumCintArray = 0
        for Cints in CarrayChecker:
            sumCintArray += sum(Cints)

        if(sumCintArray == K):
            ans += 1

print(ans)

Measured memory_bytes: 9332
#include <stdio.h>

int main(void)
{
    int ans = 0;
    int n, a, b;
    int i, tmp, num = 0;
    scanf("%d%d%d", &n, &a, &b);

    for (i = 1; i <= n; i++)
    {
        tmp = i;
        while (tmp)
        {
            num += tmp % 10;
            tmp /= 10;
        }
        if (a <= num && num <= b)
            ans += i;
        num = 0;
    }

    printf("%d\n", ans);

    return 0;
}

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,c=LI()

  if c-a-b<=0:
    return 'No'

  if 4*a*b<(c-a-b)**2:
    return 'Yes'
  return 'No'

# main()
print(main())


Measured memory_bytes: 5072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String S=scan.next();
		char[] c=S.toCharArray();
			if(c[0]==c[1] && c[1]==c[2]){
				System.out.println("No");
			}
			else {
				System.out.println("Yes");
			}
	}
}

Measured memory_bytes: 35760
import sys
from math import gcd


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    c = A[0]
    b = []

    cnt = [0] * (10 ** 6 + 1)

    for a in A:
        c = gcd(c, a)
        cnt[a] += 1

    max_num = 0
    for i in range(2, 10 ** 6 + 1):
        max_num = max(max_num, sum(cnt[i::i]))

    if c == 1 and max_num <= 1:
        print('pairwise coprime')
    elif c == 1:
        print('setwise coprime')
    else:
        print('not coprime')


if __name__ == '__main__':
    main()


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

  int func(int x){
    if(x<10){
      return x;
    }
    else{
      return x%10+func(x/10);
    }
  }

int main(){
  int n;
  cin >> n;
  int s=func(n);
  if(n%s==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < s.Length; i++)
            {
                switch (s[i])
                {
                    case '0':
                        sb.Append("0");
                        break;
                    case '1':
                        sb.Append("1");
                        break;
                    case 'B':
                        if (sb.Length > 0)
                        {
                            sb.Remove(sb.Length - 1, 1);
                        }
                        break;
                    default:
                        break;
                }
            }
            Console.WriteLine(sb.ToString());
        }
    }
}


Measured memory_bytes: 2648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    s[k-1]=towlower(s[k-1]);
    cout<<s<<endl;
    return 0;
}

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

const int N = 1e5 + 10;

int a[N];

int main(){
	int n, c, k, cnt, now, ans;
	scanf("%d %d %d",&n,&c,&k);
	for (int i = 1; i <= n; i++) scanf("%d",&a[i]);
	sort(a + 1, a + n + 1);
	cnt = 1; now = a[1]; ans = 1;
	for (int i = 2; i <= n; i++){
		if (a[i] - now > k || cnt >= c){
			ans++;
			cnt = 1;
			now = a[i];
		}
		else cnt++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
import numpy as np

N = int(input())
A = list(map(int, input().split()))

mod = 1000000007
res = np.cumsum(A, dtype=np.float64)
ans = 0

for i in range(N-1):
    S = (int(res[N-1])-int(res[i])) % mod
    ans += A[i]*S
    ans %= mod

print(int(ans))

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

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int K, S;
  cin >> K >> S;
  int ans = 0;
  for(int x = 0; x <= K; x++) {
    for(int y = 0; y <= K; y++) {
      int z = S - x - y;
      if(0 <= z && z <= K) ans++;
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class p
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string[] input = Console.ReadLine().Split(' ');
    int[] arr = new int[N];
    for (int i = 0; i < N; i++) {
      arr[i] = int.Parse(input[i]);
    }
    int sum = arr.Sum();
    int M = int.Parse(Console.ReadLine());
    for (int i = 0; i < M; i++) {
      input = Console.ReadLine().Split(' ');
      int P = int.Parse(input[0]);
      int X = int.Parse(input[1]);
      Console.WriteLine(sum - (arr[P-1] - X));
    }
  }
}

Measured memory_bytes: 13268
#include<stdio.h>
int main(void)
{
	int S, h, m, s;
	scanf("%d", &S);
	h=S/3600;
	m=(S-3600*h)/60;
	s=S-3600*h-60*m;
	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
}

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

int main() {
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  ll x, y;
  cin >> x >> y;
  y /= x;
  int res = 0;
  while(y){
    res++;
    y /= 2;
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 256
# Input
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def aok_turn(aoki: str, tolow: str, toup: str, lower: int, upper: int, amin: int, amax: int):
    if aoki == tolow:
        upper = min(amax, upper + 1)
    elif aoki == toup:
        lower = max(amin, lower - 1)

    return lower, upper


def tak_turn(taki: str, tolow: str, toup: str, lower: int, upper: int, amin:int, amax: int):
    if taki == tolow:
        lower = min(amax, lower + 1)
    elif taki == toup:
        upper = max(amin, upper - 1)

    return lower, upper


def on_board(lower: int, upper: int, amin: int, amax: int):
    if lower < upper and upper > amin and lower < amax:
        return True
    else:
        return False


def judge(tak: str, aok: str, tolow: str, toup: str, start: int, amin: int, amax: int) -> bool:
    lower = amin
    upper = amax
    for aoki, taki in zip(aok, tak):
        lower, upper = aok_turn(aoki, tolow, toup, lower, upper, amin, amax)
        lower, upper = tak_turn(taki, tolow, toup, lower ,upper, amin, amax)
        if not on_board(lower, upper, amin, amax):
            return False

    return True if lower <= start < upper else False


h,w,n = li()
sr, sc = li_()
tak = ns()[::-1]
aok = ns()[::-1]

L = 'L'
R = 'R'
U = 'U'
D = 'D'

lr = judge(tak, aok, L, R, sc, 0, w)
ud = judge(tak, aok, U, D, sr, 0, h)

print("YES") if lr and ud else print("NO")

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
double get(pair<int,int>a,pair<int,int>b){
	int x=a.ff-b.ff;
	int y=a.ss-b.ss;
	x=x*x;y=y*y;
	return (double)sqrt(x+y);
}
void solve(){
	ll n;cin>>n;
	vector<pair<int,int>>v;
	vi a(n);
	int md=1;
	for(int i=0;i<n;i++){
		ll x,y;cin>>x>>y;
		v.pb({x,y});
		a[i]=i;
		md*=(i+1);
	}
	double ans=0;
	do{
		for(int i=1;i<n;i++){
			ans+=get(v[a[i]],v[a[i-1]]);
		}
	}while(next_permutation(all(a)));
	cout<<sp((double)ans/md,10);
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}

Measured memory_bytes: 3792
n,a,b=map(int, input().split())
x=list(map(int, input().split()))
count=0
for i in range(1,n):
    if (x[i]-x[i-1])*a < b :count+=(x[i]-x[i-1])*a
    else: count+=b
    #print(x[i],count,(x[i]-x[i-1])*a)
print(count)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}//#########################################

bool isPrime(ll n){
    for(ll i = 2; i <= n / i; ++i)
        if(n % i == 0)
            return 0;
    return n > 1;
}


vector<ll> getDivisors(ll n){
    vector<ll> ret;
    for(int i = 1; i <= n / i; ++i){
        if(n % i == 0){
            ret.push_back(i);
            if(n / i != i)
                ret.push_back(n / i);
        }
    }
    return ret;
}



ll GCD(ll a, ll b){
    return b ? GCD(b, a % b) : a;
}

ll LCM(ll a, ll b){
    return a / GCD(a, b) * b;
}

vector<ll> ret;

vector<ll> getFactors(ll n){
    // vector<ll> ret;
    for(ll i = 2; i <= n / i; ++i)
        while(n % i == 0){
            ret.push_back(i);
            n /= i;
        }

    if(n != 1){
        ret.push_back(n);
    }
    return ret;
}
const int N = 1e6 + 5;
int vst[N], cnt[N];
vector<int> primes;
void seive(){
    for(int i = 2; i < N; ++i){
        if(vst[i])
            continue;
        primes.push_back(i);
        for(ll j = 1LL * i * i; j < N; j +=i)
            vst[j] = 1;
    }
}

// Modified sieve for number of divisors
int cnt1[N];
void modSeive(){
    for(int i = 1; i < N; ++i){
        for(int j = i; j < N; j += i)
            ++cnt1[j];
    }
}

// Modified sieve for number of prime factors
int cnt2[N];
void mod2Sieve(){
    for(int i = 2; i < N; ++i){
        if(vst[i])
            continue;
        for(ll j = i; j < N; j +=i){
            vst[j] = 1;
            int cntP = 0;// calculate the power of i exists in j
            int curr = j;
            while (curr % i == 0) {
                ++cntP;
                curr /= i;
            }
            cnt2[j] += cntP;
        }
    }
}
//####################################################################################################
int main() {

int a=D(),b=D(),c=D();
if(a+b>=c) puts("Yes");
else puts("No");

}


Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int max = 0;
		int r = 0;
		for (int i = 0; i < n; i++) {
			int h = in.nextInt();
			if (h >= max) {
				r++;
				max = h;
			}
		}
		System.out.println(r);
	}

}


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

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long[] Ln;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            Ln = new long[N];
            for (int i = 0; i < Ln.length; i++) {
                Ln[i] = sc.nextLong();
            }

        }
        long result = 0;
        Arrays.sort(Ln);

        for (int i = 0; i < Ln.length; i++) {
            for (int j = i + 1; j < Ln.length; j++) {
                int k = Ln.length -1;
                while(k > j){
                    if(Ln[k] < Ln[i]+Ln[j]){
                        result += (k-j);
                        break;
                    }
                    k--;
                }
            }
        }
        System.out.println(result);

    }
}


Measured memory_bytes: 26888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=1;i<=(n);i++)
#define rep3(i,i0,n) for(ll i=i0;i<(n);i++)
#define pb push_back
#define MOD 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}

bool comparex(tuple<ll,ll,ll> a, tuple<ll,ll,ll> b) {

    return get<1>(a) < get<1>(b);
        
}
bool comparey(tuple<ll,ll,ll> a, tuple<ll,ll,ll> b) {

    return get<2>(a) < get<2>(b);
        
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

#define mod 100000
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};




int main() {
    ll N,M,Q;
    cin>>N>>M>>Q;
    vector<ll> L(M);
    vector<ll> R(M);
    vector<ll> p(Q);
    vector<ll> q(Q);
	vector<vector<ll>> tizu(N,vector<ll>(N));
    rep(i,M){
		cin >> L[i]>>R[i];
		L[i]--;
		R[i]--;

		tizu[L[i]][R[i]]++;
	} 
    rep(i,Q) cin >> p[i]>>q[i];

    vector<vector<ll>> sum(N+1, vector<ll>(N+1));
 
    rep(i,N){
		rep(j,N){
			sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] -sum[i][j] + tizu[i][j];
		}
    }


	rep(i,Q){
		cout << sum[q[i]][q[i]] - sum[p[i]-1][q[i]] - sum[q[i]][p[i]-1] + sum[p[i]-1][p[i]-1]<<endl;; 
	}
    
  
    return 0;
    

}


Measured memory_bytes: 11908
#include <stdio.h>

int is_leap_year( int year )
{
	if ( year % 4 == 0 )
	{
		if ( year % 100 != 0 ) return 1;
		else if ( year % 400 == 0 ) return 1;
	}
	return 0;
}

int main( void )
{
	int days_of_month[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	int yy_1, mm_1, dd_1;
	int yy_2, mm_2, dd_2;
	int leap_years;
	int days;
	int i;

	while ( 1 )
	{
		scanf( "%d%d%d", &yy_1, &mm_1, &dd_1 );
		scanf( "%d%d%d", &yy_2, &mm_2, &dd_2 );

		if ( yy_1 == -1 || mm_1 == -1 || dd_1 == -1 || yy_2 == -1 || mm_2 == -1 || dd_2 == -1 ) break;

		leap_years = 0;
		days = 0;

		for ( i = yy_1 + 1; i < yy_2; i++ )
		{
			if ( is_leap_year( i ) ) leap_years++;
		}

		if ( yy_2 - yy_1 > 1 )
		{
			days += ( yy_2 - yy_1 - 1 ) * 365 + leap_years;
		}

		/* yy_1, yy_2ÉÂ¢Ä */
		if ( yy_1 == yy_2 )
		{
			if ( mm_1 == mm_2 )
			{
				days += dd_2 - dd_1;
			}
			else
			{
				if ( is_leap_year( yy_1 ) )
				{
					if ( ( mm_1 == 1 || mm_1 == 2 ) && mm_2 > 2 ) days++;
				}
				for ( i = mm_1 + 1; i <= mm_2 - 1; i++ ) days += days_of_month[i];
				days += days_of_month[mm_1] - dd_1;
				days += dd_2;
			}
		}
		else
		{
			if ( is_leap_year( yy_1 ) )
			{
				if ( mm_1 == 1 || mm_1 == 2 ) days++;
			}
			if ( is_leap_year( yy_2 ) )
			{
				if ( mm_2 > 2 ) days++;
			}
			for ( i = mm_1 + 1; i <= 12; i++ ) days += days_of_month[i];
			for ( i = 1; i <= mm_2 - 1; i++ ) days += days_of_month[i];
			days += days_of_month[mm_1] - dd_1;
			days += dd_2;
		}

		printf( "%d\n", days );
	}

	return 0;
}

Measured memory_bytes: 0
n = int(input())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))

ans = ''
for i in range(101):
    for j in range(101):
        m = 1000000001

        for k in range(n):
            x = abs(l[k][0] - i)
            y = abs(l[k][1] - j)

            if x + y < m:
                m = x + y
                hhh = l[k][2] + x + y

        b = True
        for k in range(n):
            x = abs(l[k][0] - i)
            y = abs(l[k][1] - j)

            if l[k][2] != 0 and x + y + l[k][2] != hhh:
                b = False
                break

        if b:
            ans = str(i) + ' ' + str(j) + ' ' + str(hhh)

print(ans)

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

using ll = long long;

int main()
{
    #ifdef LOCAL_RUN
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int TTT; cin >>TTT;
    while(TTT--){
    #endif // LOCAL_RUN

    ll n, m;
    cin >> n >> m;
    ll t = n*100 + m*1800;
    t<<=m;
    cout << t << "\n";


    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
    return 0;
}


Measured memory_bytes: 764
// ref: https://qiita.com/tubo28/items/e6076e9040da57368845
use std::io::{stdin, Read};
use std::str::FromStr;
use std::collections::BTreeSet;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut s: i32 = read();
    let mut set = BTreeSet::new();
    loop {
        if set.get(&s) != None {
            break;
        }
        set.insert(s);
        s = if s % 2 == 0 {
            s / 2
        } else {
            3 * s + 1
        };
    }

    println!("{}", set.len() + 1);
}

Measured memory_bytes: 4352
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        for(int i = 0; i < m; i++) n-= sc.nextInt();
        System.out.println(n >= 0 ? n : -1);
    }

}


Measured memory_bytes: 38248
/*
 *  Author :: Kattu37
 */

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

#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortallr(x) sort(allr(x))
#define PI 3.1415926535897932384626
#define mod 1000000007

typedef pair<int, int>  pii;
typedef pair<ll, ll>  pll;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pll>   vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;

void solve()
{
	int x;
	cin >> x;

	if (x >= 30)
		cout << "Yes \n";
	else cout << "No \n";
}

int main(void)
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}


Measured memory_bytes: 3648
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define scan(n) scanf("%lld",&n)
#define scan2(a,b) scanf("%lld %lld",&a,&b)
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define print(n) printf("%lld\n",n)
#define scanS(s) scanf("%s",&s)
#define printS(s) printf("%s",s)

#define ff first
#define ss second
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define pb push_back
#define popb pop_back
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};

lli n;
lli h[MAXN], x[MAXN], y[MAXN];

void solve() {
    lli i, cx, cy;
    cin >> n;
    rep(i, n) {
        cin >> x[i] >> y[i] >> h[i];
    }
    rep(cx, 101) {
        rep(cy, 101) {
            lli H = 0;
            rep(i, n) {
                if(h[i] == 0) continue;
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
                if (H >= 1)
                    break;
            }
            if (H < 1) continue;

            bool flag = true;
            rep(i, n) {
                if (max(H - abs(x[i] - cx) - abs(y[i] - cy), 0LL) != h[i]) {
                    //cout << x[i] << " " << y[i] << " " << h[i] << endl;
                    flag = false;
                    break;
                }
            }
            if(flag) {
                cout << cx << " " << cy << " " << H;
                return;
            }
        }
    }
}

int main()
{
    opt;
    lli t = 1;
    //cin >> t;

    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256