akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC123_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var num = new int[5];
            num[0] = int.Parse(Console.ReadLine());
            num[1] = int.Parse(Console.ReadLine());
            num[2] = int.Parse(Console.ReadLine());
            num[3] = int.Parse(Console.ReadLine());
            num[4] = int.Parse(Console.ReadLine());
            var k = int.Parse(Console.ReadLine());
            Console.WriteLine(num.Max()-num.Min() <=k ?"Yay!":":(");
        }
    }
}


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

int main() {
    int n,k;
    unsigned int bitNum = 0,maxNum = 0;
    cin >> n >> k;
    vector<int> vec(k),vec2;
    for(int i = 0;i < k;++i){
        cin >> vec[i];
        maxNum |= 1 << vec[i];
    }
    
    if(vec.size() == 0){
        cout << "0:" << endl;
        return 0;
    }
   
    for(int i = 0;i < (1 << n);++i){
        if(i > maxNum){
            return 0;
        }
        for(int j = 0;j < vec.size();++j){
            int bit = 1 << vec[j];
            if(i & bit){
                bitNum |= bit;
                vec2.push_back(vec[j]);
                if(bitNum == i){
                    j = vec.size();
                }
            }
        }
        if(bitNum == i){
            cout << i << ":";
            for(int j = 0;j < vec2.size();++j){
                cout << " " << vec2[j];
            }
            cout << endl;
        }
        vec2.clear();
        bitNum = 0;
    }
}



Measured memory_bytes: 3164
#include <cstdio>
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;

ll N, A, B;

void input() {
    cin >> N >> A >> B;
//        N = 4;
//        A = 0b0001;
//        B = 0b1100;
}

void bitshow(ll x) {
    for (ll i = N; i > 0; i--) {
        cerr << (x >> (i - 1) & 1);
    }
    cerr << endl;
}

vector<ll> path;

void rec(ll d, ll f) {
    if (f == 0)
        return;
    ll x = d & -d; // mrb
    ll nd = d ^ x, nf = f ^ x;
    
    if (nd == 0) {
        rec(nf & -nf, nf);
        path.push_back(x);
        rec(nf & -nf, nf);
    } else {
        ll y = nd & -nd;
        ll z = nd ^ y;
        rec(y, nf);
        path.push_back(x);
        rec(z, nf);
    }
}

void solve() {
    ll haminglen = A ^ B;
    ll eo = 0;
    for (ll i = 0; i < N; i++) {
        if ((haminglen >> i) & 1)
            eo ^= 1;
    }
    if (eo == 0) {
        cout << "NO" << endl;
        return;
    }
    cout << "YES" << endl;
//    bitshow(A);
    cout << A << endl;
    
    path.reserve(1ull << N);
    rec(A ^ B, (1ull << N) - 1);
    
    for (auto p : path) {
//        bitshow(A ^= p);
        cout << (A ^= p) << endl;
    }
    
}

int main() {
    input();
    //    cout << solve() << endl;
    solve();
    
    return 0;
}



Measured memory_bytes: 2048
N,M=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(M)]
l_1=[]
l_n=set()
for l in A:
    if 1 in l:
        l_1.append(sum(l)-1)
for l in A:
    if N in l:
        l_n.add(sum(l)-N)
for x in l_1:
    if x in l_n:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 61580
#! /usr/bin/env python3
import sys
sys.setrecursionlimit(10**9)


INF=10**20
class Counter:
    def __init__(self):
        self.dict = {}

    def add(self,x):
        if x in self.dict: self.dict[x] += 1
        else: self.dict[x] = 1

    def decrement(self,x):
        self.dict[x] -= 1
        if self.dict[x] <= 0:
            del self.dict[x]

    def get_dict(self):
        return self.dict


def solve(S):
    N = len(S)

    v1 = [0] * (N+1)
    v1[0] = 0

    for i in range(N):
        v1[i+1] = v1[i] * 10 + int(S[i])
        v1[i+1] %= 2019

    counter = Counter()
    for i in range(N+1):
        u = v1[i] * pow(10,201900-i,2019) % 2019
        counter.add(u)

    
    ans = 0
    # print(counter.get_dict())
    for _,count in counter.get_dict().items():
        ans += count * (count-1) // 2
    
    print(ans)

    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = list((next(tokens)))  # type: int
    solve(S)



if __name__ == "__main__":
    main()


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

constexpr long long mod = 1000000007;
vector<long long> denom;
constexpr int sz = 22;

void init() {
    // (1-x^2)^5 (1-x)^(2*5+1)
    denom.assign(sz, 0); denom[0] = 1;
    for (int _ = 0; _ < 5; _++) {
        for (int i = sz-1; i >= 2; i--) {
            denom[i] += mod - denom[i-2];
            denom[i] %= mod;
        }
    }
    for (int _ = 0; _ < 2*5+1; _++) {
        for (int i = 22; i >= 1; i--) {
            denom[i] += mod - denom[i-1];
            denom[i] %= mod;
        }
    }
}

using Mat = array<array<long long, sz>, sz>;
using Vec = array<long long, sz>;

Vec mul(const Mat &m, const Vec &v) {
    Vec res;
    for (int i = 0; i < sz; i++) {
        res[i] = 0;
        for (int j = 0; j < sz; j++) {
            res[i] += m[i][j] * v[j] % mod;
        }
        res[i] %= mod;
    }
    return res;
};

Mat mul(const Mat &a, const Mat &b) {
    Mat res;
    for (int i = 0; i < sz; i++) {
        for (int j = 0; j < sz; j++) {
            res[i][j] = 0;
            for (int k = 0; k < sz; k++) {
                res[i][j] += a[i][k] * b[k][j] % mod;
            }
            res[i][j] %= mod;
        }
    }
    return res;
};

long long solve() {
    long long N; cin >> N;
    N -= 5;
    if (N < 0) return 0;
    Mat m; Vec v;
    v.fill(0); m.fill(v);
    v[0] = 1;
    for (int i = 0; i < sz-1; i++) {
        m[i][0] = (mod - denom[i+1]) % mod;
        if (i+1 < sz) m[i][i+1] = 1;
    }
    while (N) {
        if (N & 1) v = mul(m, v);
        m = mul(m, m);
        N >>= 1;
    }
    return v[0];
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int T; cin >> T;
    init();
    while (T--) cout << solve() << "\n";
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
template<typename T1, typename T2>
inline bool cmn (T1& a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  int N = 2 * n;
  std::vector<char> c(N);
  std::vector<int> a(N);
  for (int i = 0; i < N; i++){
    std::cin >> c[i] >> a[i];
    a[i]--;
  }
  auto cum = [&](char d){
    std::vector<std::vector<int>> cum(n + 1, std::vector<int>(N + 1, 0));
    for (int i = 0; i <= n; i++) {
      for (int j = 1; j <= N; j++) {
        cum[i][j] = cum[i][j - 1] + (c[j - 1] == d && a[j - 1] >= i);
      }
    }
    return cum;
  };
  auto cnt_w = cum('W');
  auto cnt_b = cum('B');
  auto count = [&] (int i, int j, int pos) {
    assert(0 <= i && i <= n);
    assert(0 <= j && j <= n);
    assert(0 <= pos && pos < N);
    return cnt_w[i][pos] + cnt_b[j][pos];
  };
  std::vector<int> w(n), b(n);
  for (int i = 0; i < N; i++) {
    (c[i] == 'W' ? w : b).at(a[i]) = i;
  }
  constexpr int inf = 1 << 30;
  std::vector<std::vector<int>> dp(n + 1, std::vector<int>(n + 1, inf));
  dp[0][0] = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (i < n) cmn(dp[i + 1][j], dp[i][j] + count(i, j, w[i]));
      if (j < n) cmn(dp[i][j + 1], dp[i][j] + count(i, j, b[j]));
    }
  }
  std::cout << dp[n][n] << std::endl;
  return 0;
}

Measured memory_bytes: 78720
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {

    int N;
    string S;

    cin >> N >> S;

    int B[N] = {0};
    int W[N] = {0};

    int i, j = 0;

    int b = 0, w = 0;

    //累積和
    for(i = 0; i < N - 1; i++) {
        if(S[i] == '.') {
            w++;
        } else {
            b++;
        }
        B[j] = b;
        W[j] = w;

        if(S[i] != S[i + 1])j++;
    }

    if(S[i] == '.') {
        w++;
    } else {
        b++;
    }
    B[j] = b;
    W[j] = w;


    int min = w;
    int num = 0;

    for(i = 0; i <= j; i++) {
        num = B[i] + (w - W[i]);

        if(num < min)
            min = num;
    }

    cout << min << endl;
}


Measured memory_bytes: 2180
a=[]
b=[]
sa=[]
weitone=0
weittwo=0
i=1
t=1
for x in input().split():
	a.append(int(x))

for x in input().split():
	a.append(int(x))

while t<=a[0]:
    while i<=t:
        weitone+=a[i]
        i+=1
    while i<=len(a)-1:
        weittwo+=a[i]
        i+=1
    sa.append(abs(weitone-weittwo))
    t+=1
    i=1
    weitone=0
    weittwo=0
    
sa.sort()
print(sa[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,a,b; cin>>N;
  for(int i=0; i<N; i++){
    cin>>a;
    b^=a;
  }
  if(b==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
int main()
{
	cin >>n>>m;
	cout <<(n+m-1)/m;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<(a+b+1)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 long int A, B, C, K,a,b;
  cin >> A >>B>>C>>K;

  a = K-A;
  b = a-B;

  if(a<=0){
    cout << K <<endl;
  }
  else if(a<B){
   cout << A << endl;
 }
 else if(a>= B){
   cout << A-b << endl;
 }

}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>

using namespace std;

bitset < 10 > v;
char w;

int main(){
	v.reset();
	for(int i=1;i<=3;i++){
		cin>>w;
		if(w=='o')v[i]=1;
		else v[i]=0;
	}
	cout<<v.count()*100+700;
	return 0;
}

Measured memory_bytes: 256
import itertools as it

N=int(input())
P=[int(i) for i in input().split()]
Q=[int(i) for i in input().split()]

L=[int(i) for i in range(1,N+1)]
A=[]
for v in it.permutations(L):
    A.append(v)

a=0
for i in range(len(A)):
    flag=True
    a=a+1
    for j in range(N):
        if A[i][j]!=P[j]:
            flag=False
            break
    if flag:
        break
b=0
for i in range(len(A)):
    flag=True
    b=b+1
    for j in range(N):
        if A[i][j]!=Q[j]:
            flag=False
            break
    if flag:
        break

print(abs(a-b))

Measured memory_bytes: 8052
n, k = map(int, input().split())
a = tuple(map(int, input().split()))

#dp[i] := 残りがi個の時に手番が回ってきた方の勝敗
#0: 負け,
#1: 勝ち
#当然残り0個は負け
dp = [0] * (k+1)
#aの要素だけ残っている時，それを全てとってしまい，相手に0を渡すことができるので，1になる
for i in a:
    dp[i] = 1

#数字が小さい方からチェックしていき，aのいずれかの要素だけ小さくなったとき勝ちなら勝ち
#そうでなければ負け
for i in range(1, k+1):
    for e in a:
        #まず取れないとダメ
        if i > e:
            #その上で遷移後の状態を調べる
            if not dp[i-e]:
                dp[i] = 1

if dp[k]:
    print("First")
else:
    print("Second")

Measured memory_bytes: 39920
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> V(N), C(N);
  for (int i = 0; i < N; i++) cin >> V.at(i);
  for (int i = 0; i < N; i++) cin >> C.at(i);
  int answer = 0;
  for (int i = 0; i < N; i++) {
    if (V.at(i) > C.at(i)) answer += V.at(i) - C.at(i);
  }
  cout << answer << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ll gcd(ll x,ll y)
{
	if(y==0)
		return x;
	return gcd(y,x%y);
}
bool comp(int x,int y)
{
	return x>y;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

void swap(int &a,int &b)
{
	a=a+b;
	b=a-b;
	a=a-b;
}

void solve()
{
	string s,t;
	cin>>s;
	cin>>t;
	if(s.length()!=t.length()-1)
	{
		cout<<"No";
		return;
	}	
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i]){
			cout<<"No";
			return;
		}
	}
	cout<<"Yes";
	return;

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

}


Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
  
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    
    --a; --b; --c; --d;
    
    string s;
    cin >> s;
    
    vector<ll> obstacle;
    vector<ll> room;
    
    for ( ll i = 0; i < n; i++ ){
        if ( i < n - 1 && s[i] == '#' && s[i+1] == '#' )
            obstacle.push_back(i);
        if ( i < n - 2 && s[i] == '.' && s[i+1] == '.' && s[i+2] == '.' )
            room.push_back(i);
    }
    
    auto itr1 = lower_bound(obstacle.begin(), obstacle.end(), a);
    auto itr2 = lower_bound(obstacle.begin(), obstacle.end(), b);
    
    if ( c < d ) {
        if ( (itr1 == obstacle.end() || *itr1 > c) && (itr2 == obstacle.end() || *itr2 > d) ){
            cout << "Yes" << endl;
            return 0;
        }
    } else {
        if ( itr1 == obstacle.end() || *itr1 > c ){
            auto itr3 = lower_bound( room.begin(), room.end(), b-1);
            if ( itr3 != room.end() && *itr3 < d ){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
    
    return 0;
}


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

using ll = long long;

int main(){
	
	int n;
	cin >> n;
	vector<int> a(n);
	ll ans=0;
	cin >> a[0];
	for(int i=1;i<n;i++){
		cin >> a[i];
		if(a[i]<a[i-1]){
			ans+=a[i-1]-a[i];
			a[i]+=a[i-1]-a[i];
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 4040
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)2e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

int main(){
	int n;
	cin >> n;
	int a = n;
	int b = 0;
	repa(i, n+1)if(i&1)++b;
	printf("%.8lf\n", (double)b/a);

	return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

#define putchar(c) putc_unlocked((c), stdout)
#define getchar() getc_unlocked(stdin)
char nextchar(void){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); return c; }
int32_t nextint(void){ char c=getc_unlocked(stdin); while(c!='-'&&(c<'0'||'9'<c)) c=getc_unlocked(stdin); int s=0; if(c=='-'){s=1;c=getc_unlocked(stdin);} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return s?-x:x; }
int64_t nextlong(void){ char c=getc_unlocked(stdin); while(c!='-'&&(c<'0'||'9'<c)) c=getc_unlocked(stdin); int s=0; if(c=='-'){s=1;c=getc_unlocked(stdin);} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return s?-x:x; }
uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint64_t nextplong(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint32_t nextstr(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }
uint32_t nextstrln(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }

void printint(int x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); putc_unlocked('\n', stdout); }
void printlong(long x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[20]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); putc_unlocked('\n', stdout); }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

int gcd2(int a, int b){
	int t;
	if(a>b) t=a, a=b, b=t;
	t = b % a;
	while(t!=0){
		b = a;
		a = t;
		t = b % a;
	}
	return a;
}
int k[201][201];
int main(void){
	int n=nextpint();
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			k[i][j]=gcd2(i,j);
		}
	}
	long ans=0;
	for(int a=1; a<=n; a++){
		for(int b=1; b<=n; b++){
			int d=k[a][b];
			for(int c=1; c<=n; c++){
				ans+=k[d][c];
			}
		}
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 1684
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

int main(){
    ll N,M,L;cin>>N>>M>>L;
    ll dist[N][N];
    rep(i,N)rep(j,N){
        if(i==j)dist[i][j]=0;
        else dist[i][j]=INF;
    }
    rep(i,M){
        int a,b,c;cin>>a>>b>>c;
        dist[a-1][b-1]=c;
        dist[b-1][a-1]=c;
    }
    rep(k,N)rep(i,N)rep(j,N)dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
    rep(i,N)rep(j,N){
        if(i==j)dist[i][j]=0;
        else if(dist[i][j]<=L)dist[i][j]=1;
        else dist[i][j]=INF;
    }
    rep(k,N)rep(i,N)rep(j,N)dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
    ll Q;::cin>>Q;
    rep(i,Q){
        ll s,t;cin>>s>>t;
        if(dist[s-1][t-1]-INF)cout<<dist[s-1][t-1]-1<<endl;
        else ::cout<<-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
/* Uncomment only if you are not using GNU compiler->
*/
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
/**/ 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()

//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

void solve()
{
    int n, k;
    cin>>n>>k;
    vi v(n);
    rep(i,n)
        cin>>v[i];
    sort(all(v));
    int ans=0;
    rep(i,k)
        ans+=v[i];
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3772
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;
long long gcd(long long a,long long b){
	if(b==0)return a;
	return gcd(b,a%b);
}

long long lcm(long long a,long long b){
	long long g=gcd(a,b);
	return a/g*b;
}


int main(){
  LL a,b;
  cin>>a>>b;
  cout<<lcm(a,b);
}


Measured memory_bytes: 256
// Author : Radhesh Sarma
   #include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("unroll-loops")
    using namespace std;
  using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define int long long
    #define all(v) v.begin(),v.end()
    #define rep(i,a,b) for(int i = a; i <=b; i++)
    #define rep2(i,a,b) for(int i = a; i>=b; i--)
    #define f first
    #define s second
    #define PB push_back
    #define MP make_pair
    #define db long double
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define cases int testcases;cin>>testcases; while(testcases--)
    #define INF 2000000000
    const double PI = acos(-1);
    const int N =  200005;

  int32_t main() 
  {
    IOS

    
    int a,b,k;
    cin >> a >> b >> k;

     if(a >= k)
     {
      cout << a - k << " " << b;
     }
     else if(a < k and k >= a+b) 
     {
      cout <<"0 0";
     }
     else
      { 
        cout <<"0 " << a + b - k;
      }

    return 0;
  }

Measured memory_bytes: 256
from math import factorial
def comb(n,k):
    if n>=k:
        return int(factorial(n)/(factorial(k)*factorial(n-k)))
    else:
        return 0

n = int(input())
k = int(input())
number = []
while n:
    number.append(n%10)
    n//=10

t = len(number)
t1 = len(number) - 1

if t>=k:
    ans = 0
    def calc(a,k):
        t = len(a)
        t1 = len(a) - 1
        if k<1 or t == 0:
            return 0
        else:
            if a[t1]>0:
                ans = (9**k)*comb(t1,k) + (9**(k-1))*(a[t1]-1)*comb(t1,k-1)
                ans+=calc(a[:(t-1)],k-1)
            else:
                ans = 0
                ans+=calc(a[:(t-1)],k)
            if a[-k]>=1 and k == 1:
               ans+=1
            return ans
    ans += calc(number,k)
else:
    ans = 0
print(ans)

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int K;
    cin >> K;

    queue<ll> q;
    for (int i = 1; i <= 9; i++) {
        q.push(i);
    }
    ll ans;
    for (int i = 0; i < K; i++) {
        ans = q.front();
        q.pop();
        int d = ans % 10;
        if (d == 0) {
            q.push(ans * 10);
            q.push(ans * 10 + 1);
        }
        else if (d == 9) {
            q.push(ans * 10 + 8);
            q.push(ans * 10 + 9);
        }
        else {
            q.push(ans * 10 + d - 1);
            q.push(ans * 10 + d);
            q.push(ans * 10 + d + 1);
        }
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

ll fact(ll n)
{
    ll ret=1;
    for(ll i=2; i<=n; ++i) ret*=i;
    return ret;
}

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

    int ct[26]={0};
    rep(i,s.size()) ++ct[s[i]-'a'];

    int odd=0;
    int o_idx=-1;
    rep(i,26)
    {
        if(ct[i]%2==1)
        {
            ++odd;
            o_idx=i;
        }
    }

    if(odd>1) printf("0\n");
    else
    {
        int S=s.size();
        if(odd==1)
        {
            --ct[o_idx];
            --S;
        }

        ll ans=fact(S/2);
        rep(i,26) ans/=fact(ct[i]/2);

        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3320
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;



int main()
{
ll k;
cin>>k;
string s;
cin>>s;
if(s.length()<=k)
	cout<<s<<endl;
else
{
	for(ll i=0;i<k;i++)
	{
		cout<<s[i];
	}
	cout<<"..."<<endl;
	
}
return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, k;
    cin >> n >> k;
    ll p, cnt;
    double res = 1.0, tmp;
    REP(i, n){
        p = i + 1;
        cnt = 0;
        while(p < k){
            p *= 2;
            cnt++;
        }
        tmp = 1.0 / (double)n;
        REP(j, cnt) tmp /= 2.0;
        res *= exp(tmp);
    }
    res = log(res);
    printf("%.11lf\n", res);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), std::make_pair(-1, 0), std::make_pair(0, 1), std::make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



int main(void){
  int n, tt, aa; lli t = 1, a = 1;
  scanf("%d", &n);
  REP(_, n){
    scanf("\n%d %d", &tt, &aa);
    lli CHIMPO = 1 + max((t-1) / tt, (a-1) / aa);
    t = CHIMPO * tt;
    a = CHIMPO * aa;
  }
  printf("%lld\n", t + a);
  return 0;
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#define LL long long
#define il inline
#define re register
#define db double
#define eps (1e-5)

using namespace std;
const int N=100000+10;
il LL rd()
{
    re LL x=0,w=1;re char ch;
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return x*w;
}
int n,ans;
char cc[N];

int main()
{
  scanf("%s",cc+1);
  n=strlen(cc+1);
  for(int i=1;i<=(n+1)>>1;i++) ans-=(cc[i]=='p');
  for(int i=(n+1)/2+1;i<=n;i++) ans+=(cc[i]=='g');
  printf("%d\n",ans);
  return 0;
}


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

using namespace std;
using ll = long long int;

int main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    double area = (W / 2.0) * H;
    cout << setprecision(10) << area << " ";
    if (x == W / 2.0 and y == H / 2.0) {
        cout << "1" << endl;
    }else{
        cout << "0" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
(puts 1; exit(0)) if h==1 || w==1
hh, ww = h/2*2, w/2*2

r = hh*ww/2

r += (w+(w.odd? ? 1 : 0))/2 if h.odd?
r += (h+(h.odd? ? 1 : 0))/2 if w.odd?
r -= 1 if w.odd? && h.odd?

puts r


Measured memory_bytes: 1788
import sys, re, os
from collections import deque, defaultdict, Counter
from math import gcd, ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
# from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
K = INT()
 
ans = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            ans += gcd(gcd(i, j), k)
print(ans)
 

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

using namespace std;

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

    int ans = 0;
    for (int i=0; i<n-2; i++) {
        if (s[i] == 'A')
            if (s[i+1] == 'B' && s[i+2] == 'C')
                ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    int v[n];
    forn(i, 0, n) {
        cin >> v[i];
    }
    int ans = 0;
    forn(i, 0, n) {
        int c;
        cin >> c;
        ans += max(0, v[i]-c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

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

const ll INF = 1e11+1;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }


template<class T>
int former(const vector<T> &v, T x) {
    return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}

template<class T>
int latter(const vector<T> &v, T x) {
    return lower_bound(v.begin(), v.end(), x) - v.begin();
}



int main(){
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a, 0), t(b, 0), x(q, 0);

    rep(i, a) cin >> s[i];
    rep(i, b) cin >> t[i];
    rep(i, q) cin >> x[i];

    s.push_back(INF);
    s.push_back(-INF);
    t.push_back(INF);
    t.push_back(-INF);
    sort(all(s));
    sort(all(t));

    for(auto xx: x) {
        ll res = INF;
        // 最初にsに行く
        rep(i, 2) {
            ll first = (i ? s[former(s, xx)] : s[latter(s, xx)]);
            rep(j, 2) {
                ll second = (j ? t[former(t, first)] : t[latter(t, first)]);
                res = min(res, abs(xx - first) + abs(first - second));
            }
        }
        rep(i, 2) {
            ll first = (i ? t[former(t, xx)] : t[latter(t, xx)]);
            rep(j, 2) {
                ll second = (j ? s[former(s, first)] : s[latter(s, first)]);
                res = min(res, abs(xx - first) + abs(first - second));
            }
        }
        cout << res << endl;
    }

}

Measured memory_bytes: 5600
import itertools
from math import sqrt, factorial
N = int(input())
city_list = []
for i in range(N):
    city = list(map(int, input().split()))
    city_list.append(city)
num = [i for i in range(N)]
length = 0
for i in itertools.permutations(num):
    for j in range(N-1):
        length += sqrt((city_list[i[j]][0]-city_list[i[j+1]][0])**2+(city_list[i[j]][1]-city_list[i[j+1]][1])**2)
print(length/factorial(N))

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

int main(){
    string s;
    bool state;
    cin >> s;
    vector<int> retsu(s.size() + 1, 1);
    vector<int> retsu2(s.size() + 1, 1);
    vector<int> ans(s.size() + 1, 0);
    
    if(s.at(0)=='>'){
        retsu.at(0) = -1;
    }else{
        retsu.at(0) = 0;
    }
    if(s.at(s.size() -1)=='>'){
        retsu.at(retsu.size()-1) = 0;
    }else{
        retsu.at(retsu.size()-1) = -1;
    }
    for(int i=0; i<retsu.size() -2; i++){
        if(s.at(i)=='<' && s.at(i+1)=='>'){
            retsu.at(i+1) = -1;
        }else if(s.at(i)=='>' && s.at(i+1)=='<'){
            retsu.at(i+1) = 0;
        }
    }
    if(s.at(s.size() -1)=='>'){
        retsu.at(retsu.size()-1) = 0;
    }else{
        retsu.at(retsu.size()-1) = -1;
    }
    //for(int i=0; i<retsu.size(); i++){
    //cout << retsu.at(i);
    //}
    //cout << endl;    
    
retsu2 = retsu;
    int counter = 0;
    int tmp = 0;
    for(int i=0; i<retsu.size()-1; i++){//last igai
        counter = 0;
        if(retsu.at(i)==0){
            for(int j=0; j<retsu.size(); j++){
                if(retsu.at(i+j+1)==1){
                    
                    counter++;
                }else if(retsu.at(i+j+1)==-1){break;}
            }
            tmp = counter;
            for(int j=0; j<tmp+1; j++){
                //cout << "output" << counter + 1 << endl;
                if(retsu.at(i+counter+1) < counter+1){
                    retsu.at(i+counter+1) = counter +1;
                    }
                counter--;
            }
            i += tmp;
        }
    }
    //for(int i=0; i<retsu.size(); i++){
    //cout << retsu.at(i) << ' ';
    //}
    //cout << endl;
    
    reverse(retsu2.begin(), retsu2.end());
    for(int i=0; i<retsu2.size()-1; i++){//last igai
        counter = 0;
        if(retsu2.at(i)==0){
            for(int j=0; j<retsu2.size(); j++){
                if(retsu2.at(i+j+1)==1){
                    
                    counter++;
                }else if(retsu2.at(i+j+1)==-1){break;}
            }
            tmp = counter;
            for(int j=0; j<tmp+1; j++){
                //cout << "output" << counter + 1 << endl;
                if(retsu2.at(i+counter+1) < counter+1){
                    retsu2.at(i+counter+1) = counter +1;
                    }
                counter--;
            }
            i += tmp;
        }
    }
    reverse(retsu2.begin(), retsu2.end());
    //for(int i=0; i<retsu2.size(); i++){
      //  cout << retsu2.at(i);
    //}
    //cout << endl;
    
    for(int i=0; i<retsu.size(); i++){
        if(retsu.at(i) < retsu2.at(i)){
            ans.at(i) = retsu2.at(i);
        }else{
            ans.at(i) = retsu.at(i);
        }
    }
    long int cou;
    cou = 0;
    for(int i=0; i<ans.size(); i++){
      //  cout << ans.at(i) << ' ';
        cou += ans.at(i);
    }
    //cout << endl;
    cout << cou << endl;
    return 0;
}

Measured memory_bytes: 6788
from math import *

pi = acos(-1)
a, b, c, d = [float(x) for x in input().split()]
x1 = a * cos(c * pi / 6 + d * pi / 360)
y1 = a * sin(c * pi / 6 + d * pi / 360)
x2 = b * cos(d * pi / 30)
y2 = b * sin(d * pi / 30)
a1 = (x2 - x1) ** 2
a2 = (y2 - y1) ** 2
print(sqrt(a1 + a2))


Measured memory_bytes: 9260
=begin
1, まずは中間期末で欠席を見る(F)
2, 次は中間期末の合計を見る(A~C)
3, 30 <= 合計 < 50 なら 50 <= 再試験 ? C : D
4, 合計 < 30 (F)
=end

while (m, f, r = gets.split.map(&:to_i)) != [-1, -1, -1] do
  if m == -1 || f == -1
    puts "F"
    next
  end
  
  sum = m + f
  if sum >= 80 then puts "A"
  elsif sum >= 65 then puts "B"
  elsif sum >= 50 then puts "C"
  elsif sum >= 30
    puts (r >= 50) ? "C" : "D"
  else puts "F" end
end


Measured memory_bytes: 6868
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<vector<int>> v(N, vector<int>(D));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) cin >> v[i][j];
	}

	int cnt = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i+1; j < N; j++) {
			int s = 0;
			for (int k = 0; k < D; k++) {
				int n = abs(v[i][k] - v[j][k]);
				s += n * n;
			}
			int m = sqrt(s);
			if (m * m == s) cnt++;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int c[21];
  int v[21];
  int m;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &m);
    c[i] = m;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &m);
    v[i] = m;
  }

  int total = 0;
  int i;
  for (i = 0; i < n; ++i) {
    if (c[i] > v[i]) {
      total += (c[i] - v[i]);
    }
  }
  printf("%d\n", total);

  return 0;
}


Measured memory_bytes: 256
/*
Dont BLUNDER
*/
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define l first
#define r second
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */



int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
bool comp(pii a, pii b) {
	return a.second < b.second;

}



signed main()
{
	haha
// #ifndef ONLINE_JUDGE

// 	freopen("inp.txt", "r", stdin);

// 	freopen("out1.txt", "w", stdout);
// #endif
	string s;
	cin >> s;
	int t = 0;
	for (int i = 0; i < s.size(); i++) {
		t += (s[i] - '0');
	}
	if (t % 9 == 0)
		cout << "Yes" << endl;
	else
		cout << "No";




















}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    ll k;
    cin >> k;
    ll ans = 7 % k;
    for (int i = 1; i <= k; i++) {
        if (ans == 0) {
            cout << i;
            return 0;
        }
        ans = (ans * 10 + 7) % k;
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N;
vector<long long> L;

int main(){
	cin >> N;
	for(long long i = 0; i < 2*N; i++){
		long long tmp;
		cin >> tmp;
		L.push_back(tmp);
	}
	sort(L.begin(), L.end());
	long long ans = 0;
	for(int i = 0; i < N; i++){
		ans += L[i*2];
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll d = 0;
  cin >> d;
  vector<ll> c(26);
  for(int i = 0;i < 26;i++){
    cin >> c[i];
  }
  vector<vector<ll>> s(d,vector<ll>(26));
  for(int i = 0;i < d;i++){
    for(int j = 0;j < 26;j++){
      cin >> s[i][j];
    }
  }
  vector<ll> last(26);
  for(int i = 0;i < 26;i++)last[i] = -1;
  ll res = 0;
  for(int i = 0;i < d;i++){
    ll nowin = 0;
    cin >> nowin;
    nowin--;
    last[nowin] = i;
    res += s[i][nowin];
    for(int j = 0;j < 26;j++){
      res -= c[j] * (i - last[j]);
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3688