akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = (ll)1e9+7;
const double PI = 3.141592653589793238463;
const int MAXN = 1000030;
int main() {
    int n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    ll ans=0;
    ll sum=0;
    for(int i=n-2;i>=0;i--){
        sum+=arr[i+1];
        ans=(ans%MOD+(sum*arr[i])%MOD)%MOD;
        sum%=MOD;
    }
    cout<<ans%MOD<<endl;
    return 0;
}

Measured memory_bytes: 5216
//lunchtime june Increasing and Decreasing
//<<  <  ,
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <algorithm>
#include <math.h>
#include <string>
#define pi 3.1415926535897932384626
#include <cmath>
#define test(t) while(t--)
#define MOD 1000000007
#define ll  long long int

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define pb push_back
#define fast()  ios_base::sync_with_stdio(false);cin.tie(0);
#define double long double

using namespace std;
ll form(ll n){
return (n*(n+1))/2;
}
ll exponent(ll base, ll power){
   ll res = 1;
  ll m = 1000000007;
   while(power){
    if(power&1)
        res = (res*base)%m;
    base= (base*base)%m;
    power=power>>1;
   }
return res;}
bool count_one(ll n){
    ll cnt = 0;
    while(n>0){
            cnt+=1;
       n= n&(n-1);

    }
    if(cnt>1)
        return true;
    return false;
}


void solve()
{   ll l,r,d;
    in l>>r>>d;
    while(l%d!=0){
        l+=1;
        if(l%d==0)
            break;

    }
    while(r%d!=0){
        r-=1;
        if(r%d==0)
            break;
    }
        ll n=(r-l)/d;
        out n+1<<en;
}




int main(){ fast()
             //freopen("input.txt","r",stdin);
             //freopen("output.txt","w",stdout);
             ll t=1;
            //cin>>t;
            test(t){
            solve();
            }
return 0;}


Measured memory_bytes: 3588
def resolve():
    s = input()
    a = int(s[0])
    b = int(s[1])
    c = int(s[2])
    d = int(s[3])
    if a + b + c + d == 7:
        print(str(a) + '+' + str(b) + '+' + str(c) + '+' + str(d) + '=7')
    elif a + b + c - d == 7:
        print(str(a) + '+' + str(b) + '+' + str(c) + '-' + str(d) + '=7')
    elif a + b - c + d == 7:
        print(str(a) + '+' + str(b) + '-' + str(c) + '+' + str(d) + '=7')
    elif a + b - c - d == 7:
        print(str(a) + '+' + str(b) + '-' + str(c) + '-' + str(d) + '=7')
    elif a - b + c + d == 7:
        print(str(a) + '-' + str(b) + '+' + str(c) + '+' + str(d) + '=7')
    elif a - b + c - d == 7:
        print(str(a) + '-' + str(b) + '+' + str(c) + '-' + str(d) + '=7')
    elif a - b - c + d == 7:
        print(str(a) + '-' + str(b) + '-' + str(c) + '+' + str(d) + '=7')
    else:
        print(str(a) + '-' + str(b) + '-' + str(c) + '-' + str(d) + '=7')

resolve()

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

int main() {
	long long N, ANS = 0, NOW = -1000000000;
	vector<pair<long long, long long> > V;
	cin >> N;
	V.resize(N);
	for (int i = 0; i < N; i++) {
		long long X, Y;
		cin >> X >> Y;
		V[i].first = X - Y, V[i].second = X + Y;
	}
	sort(V.begin(), V.end());
	for (int i = 0; i < N; i++) {
		if (NOW <= V[i].first) ANS++, NOW = V[i].second;
		else NOW = min(NOW, V[i].second);
	}
	cout << ANS << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vi a(3);
    rep(i,3) cin>>a[i];
    sort(all(a));
    if (a[0]==5&&a[1]==5&&a[2]==7){
        cout<<"YES\n";
    }else{
        cout<<"NO\n";
    }
    return 0;
}


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

using namespace std;

string s, str1 = "", str0 = "";

int cnt1, cnt0;

int main () {
    cin >> s;
    for (int i = 0;i < s.size ();i ++) {
        if (i % 2 == 0) {
            str1 += '1';
            str0 += '0';
        }else {
            str1 += '0';
            str0 += '1';
        }
    }
    for (int i = 0;i < s.size ();i ++) {
        if (s[i] != str1[i])cnt1 ++;
        if (s[i] != str0[i])cnt0 ++;
    }
    cout << min (cnt1, cnt0);
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rer(i, a, b) for(int i = a - 1; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<pi, pi> ppi;
typedef vector<ll> vec;

const int MAX_N = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;

void Debug() {cout << '\n'; }

template<class FIRST, class... REST> 
void Debug(FIRST arg, REST... rest) { cout << arg << " "; Debug(rest...); }

template<class T>
ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";
	if(!v.empty()) {
		rep(i, 0, (int)v.size() - 1) out << v[i] << ", ";
		out << v.back();
	}
	out << "]";
  return out;
}

template<class S, class T>
ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";
	return out;
}

///g++ -g3 -std=c++0x -DLOCAL -Wall -ftrapv -D_GLIBCXX_DEBUG -Wl,-stack,268435456 -o
///g++ -O2 -std=c++0x -DLOCAL -Wall -Wl,-stack,268435456 -o

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

int N, L;
deque<pair<double, int>> que;

void solve() {
	cin >> N >> L;

	double res = 0;
	rep(i, 0, N) {
		double a; int b;
		cin >> a >> b;

		int S = L + b;
		while(!que.empty()) {
			pair<double, int> p = que.front();
			if(S - p.sec <= L) {
				que.front().sec -= S - L;
				res -= que.front().fst * (S - L);
				break;
			}
			else {
				S -= que.front().sec;
				res -= que.front().fst * que.front().sec;
				que.pop_front();
			}
		}

		res += a * b;
		cout << res / L << "\n";

		while(!que.empty() && a < que.back().fst) {
			a = (que.back().fst * que.back().sec + a * b) / (b + que.back().sec);
			b += que.back().sec;
			que.pop_back();
		}
		que.push_back(pair<double, int>(a, b));
	}
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);	
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 23568
#include<stdio.h>

#define MAX 2000000


int H,A[MAX+1];


void maxHeapify(int i){
  int l,r,largest;
  int tmp;
  l = 2*i;
  r=2*i+1;


  if(l<=H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r<=H && A[r] >A[largest]) largest =r;

  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}

int main(){
  scanf("%d",&H);

  for(int i = 1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(int i =H/2;i>=1;i--){
    maxHeapify(i);
  }
  for(int i = 1;i <=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
   
int main()
{
    long long n;
    cin>>n;
    long long a[n],c[n];
    for(long long i=0;i<n;i++)
    {
        cin>>a[i];
        c[i]=a[i]-(i+1);
    }
    sort(c,c+n);
    long long k=n/2;
    long long b=c[k];
    long long ans=0;     
    for(long long i=0;i<n;i++)
    {
        ans+=labs(a[i]-(b+i+1));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << max(A * B, C * D) << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String ans = "";
    if (a>=b){
      for (int i=0;i<a;i++){
        ans = ans + String.valueOf(b);
      }
    } else {
      for (int i=0;i<b;i++){
        ans = ans + String.valueOf(a);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include <stdio.h>

//よくわからんけど最大値-最小値で答えが出る？

int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  
  printf("%d",max(a,b,c)-min(a,b,c));
}

int min(int a,int b,int c){
  int minimum = a;
  if(minimum>b) minimum = b;
  if(minimum>c) minimum = c;
  return minimum;
}

int max(int a,int b, int c){
  int maximum = a;
  if(maximum<b) maximum = b;
  if(maximum<c) maximum =c;
  return maximum;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int i, N, p[11], max = 0, sum = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(p[i]));
	for (i = 1; i <= N; i++) {
		if (p[i] > max) max = p[i];
		sum += p[i];
	}
	printf("%d\n", sum - max / 2);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1692
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n
# a, b = map(int, input().split())
# s = input()

N = int(input())
# A = [0]*(N)
# B = [0]*(N)
C = [0]*(N)

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

C.sort()
ans = "Yes"
cnt = 0
for (b, a) in C:
    cnt += a
    if cnt > b:
        ans = "No"
print(ans)




Measured memory_bytes: 58320
N = int(input())

a = list(map(int, input().split()))

goke = 0
ans = 0

for i in range(len(a)):
    goke += a[i]

ave = goke / N

ans = 0
for i in range(len(a)):
    if abs(ave-a[ans]) > abs(ave - a[i]):
        ans = i


print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast","unroll-loops")

#define ll long long 
#define int ll
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define debug(x) cerr<<#x<<" is "<<x<<endl


using namespace std;

const int maxn = 2002;
const int intinf = 1<<29;
const ll inf = 1ll<<60;


void GG(){cout<<-1<<endl; exit(0);}

 main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, k; cin>>n>>k;
    vector<int> a(n);
    int pos = -1;
    REP(i,n) {cin>>a[i]; if (a[i]==1) pos = i;}
    cout<<(n-1+k-2)/(k-1)<<endl;
    
}

Measured memory_bytes: 1024
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
const int mod = 1000000007;
struct mint {
int64_t x;
mint(int64_t 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 { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(int64_t t) const {if (!t) return 1;mint a = pow(t>>1);a *= a;if (t&1) a *= *this;return a;}
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) {return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n;
    cin>>n;
    vll a(n);
    rep(i,n){
        cin>>a[i];
        a[i]-=i+1;
    }

    sort(all(a));
    
    ll m1 = a[n/2];
    ll m2 = a[n/2-1];

    ll sum=0,num =0;
    rep(i,n){
        sum += abs(a[i] -m1);
        num += abs(a[i] -m2);
    }

    cout<<min(sum,num)<<endl;
}

Measured memory_bytes: 4768
#include<iostream>
using namespace std;
int main()
{
    int a;
    while(cin>>a)
    {
    int sum=0,ans;
    if(a<105)
        cout<<"0"<<endl;
    else
    {
    for(int i=105;i<=a;i++)
    {
        ans=0;
        if(i%2!=0)
        {
            for(int j=1;j<=i;j++)
            {
                if(i%j==0)
                    ans++;
            }
            if(ans==8)
                sum++;
        }
    }
    cout<<sum<<endl;
    }
    }
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  solve <$> replicateM n (getl $ wrds toInt) >>= mapM_ print

solve :: [[Int]] -> [Int]
solve = map f
  where
    f [k, p] = let m = k `mod` p in if m == 0 then p else m

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    vector<int>a(n);
    for (int &x :a)
    {
        scanf("%d",&x);
    }
    vector<bool>dp(k+1);
    for(int stones=0;stones<=k;stones++)
    {
        for(int x:a)
        {
            if(stones>=x && !(dp[stones-x]))
            {
                dp[stones]=true;
            }
        }
    }
    (dp[k])? printf("First") : printf("Second");
    return 0; 

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N / 2; i++) {
            alice += a[2*i];
            bob += a[2*i + 1];
        }
        if (N % 2 == 1) {
            alice += a[N-1];
        }
        System.out.println(alice - bob);
    }
}


Measured memory_bytes: 23764
import sys
from collections import deque
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, readline().split())
graph = [[] for _ in range(N + 1)]
check = set([])

for i in readlines():
    x, y, z = map(int, i.split())
    graph[x].append(y)
    graph[y].append(x)
    check.add(x)
    check.add(y)

answer = N - len(check)
while check:
    queue = deque([check.pop()])
    while queue:
        v = queue.popleft()
        for j in graph[v]:
            if j in check:
                queue.append(j)
                check.remove(j)
    answer += 1

print(answer)

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

using Graph = vector<vector<int> >;
Graph G;

void dfs(int v, vector<bool> &seen, int &res) {
    bool end = true;
    for (int i = 0; i < seen.size(); ++i) if (!seen[i] && i != v) end = false;
    if (end) {
        ++res;
        return;
    }

    seen[v] = true;
    for (auto nv : G[v]) {
        if (seen[nv]) continue;
        dfs(nv, seen, res);
    }
    seen[v] = false;
}

int main() {
    int N, M; cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<bool> seen(N, false);
    int res = 0;
    dfs(0, seen, res);
    cout << res << endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    string S;
    cin >> S;
    
    lint N = S.size();
    vector<int> sa = suffix_array(S);
    lint ans = N * (N + 1) / 2;
    
    vector<int> lcp = lcp_array(S, sa);
    for (int x : lcp) ans -= x;
    cout << ans << endl;
}

Measured memory_bytes: 15644
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = 2 * ( a + b );
        System.out.println(area + " " + length);
        sc.close();
    }
}



Measured memory_bytes: 26132
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

vector<pair<int, int>> prime_factorization(int n) {
    int k = n;
    vector<pair<int, int>> ret;
    for (int i = 2; i <= sqrt(n); i++) {
        int cnt = 0;
        while(k % i == 0) {
            k /= i; // 重複を許さないならここを while に
            cnt++;
        }
        if (cnt) ret.push_back({i, cnt});
    }
    if(k > 1) ret.push_back({k, 1});
    return ret;
}

int main(void) {
    int p, q; cin >> p >> q;
    while (gcd(p, q) != 1) {
        int tmp = gcd(p, q);
        p /= tmp;
        q /= tmp;
    }

    vector<pair<int, int>> qfac = prime_factorization(q);
    int ans = 1;
    for (int i = 0; i < qfac.size(); i++) {
        ans *= qfac[i].first;
    }

    cout << ans << endl;
}   


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const int INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool CompPair(const pint& arg1, const pint& arg2) { return arg1.second < arg2.second; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int h, w;
    cin >> h >> w;

    vector<vector<int>> c(10, vector<int>(10));
    vector<vector<int>> a(h, vector<int>(w));
    for(int in=0;in<10;in++) {
        for(int jn=0;jn<10;jn++) {
            cin >> c.at(in).at(jn);
        }
    }
    for(int ih=0;ih<h;ih++) {
        for(int iw=0;iw<w;iw++) {
            cin >> a.at(ih).at(iw);
        }
    }

    for(int k=0;k<10;k++) {
        for(int i=0;i<10;i++) {
            for(int j=0;j<10;j++) {
                if(c.at(i).at(j)>c.at(i).at(k)+c.at(k).at(j)) {
                    c.at(i).at(j)=c.at(i).at(k)+c.at(k).at(j);
                }
            }
        }
    }

    int ans = 0;
    for(int ih=0;ih<h;ih++) {
        for(int iw=0;iw<w;iw++) {
            if(a.at(ih).at(iw)==-1) continue;
            else ans += c.at(a.at(ih).at(iw)).at(1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{ 
	string S;
	cin >> S;
    if(S.size() == 2) cout << S << endl;
    else{
     reverse(S.begin(), S.end());  
     cout << S << endl;	
    }
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 2123450
#else
#define SIZE 2123450
#endif

int N;
int A[SIZE];

void solve() {
    cin>>N;
    REP1(i,N)cin>>A[i];
    vector<int> ans;
    vector<int> B(N + 1, 0);
    for (int i = N; i >= 1; i--) {
        int sum = 0;
        for (int j = i; j <= N; j += i) sum += B[j];
        
        if ((sum + A[i]) % 2 == 1) {
            B[i]++;
            ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    for(auto x: ans) cout << x << " ";
    cout << endl;
}

Measured memory_bytes: 5108
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <bitset>

using namespace std;

typedef long long int ll;
typedef vector<ll> vl;
typedef vector<string> vs;

#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define ABS(a) ((a)>0 ? (a) : (a * -1))


int main(){
	int a, b, c, ans;
	cin >> a >> b >> c;

	if ((b-a) == (c-b)) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    ll ans = 0;
    vector<int> b(m);
    rep(i, m)cin >> b[i];
    rep(i, n){
        ll now = c;
        rep(i, m){
            int a;
            cin >> a;
            now += a*b[i];
        }
        if(now > 0)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool f[110][110];
bool book[110][110];
char ch;
int main() {
	memset(book,true,sizeof(book));
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++) 
		for(int j=0;j<w;j++) {
			cin>>ch;
			if(ch=='#')
				f[i][j] = true;
			if(ch=='.')
				f[i][j] = false; 
		}
	bool tmp;
	for(int i=0;i<h;i++) {
		tmp = true;
		for(int j=0;j<w;j++) {
			if(f[i][j]==true) {
				tmp = false;
				break;
			}
		}
		if(tmp==true)
			for(int j=0;j<w;j++)
				book[i][j] = false;
	}
	for(int i=0;i<w;i++) {
		tmp = true;
		for(int j=0;j<h;j++) {
			if(f[j][i]==true) {
				tmp = false;
				break;
			}
		}
		if(tmp==true)
			for(int j=0;j<h;j++) {
				book[j][i] = false;
			}
	}
	for(int i=0;i<h;i++) {
		tmp = false;
		for(int j=0;j<w;j++) {
			if(book[i][j]) {
				tmp = true;
				if(f[i][j]==true) cout<<'#';
				else cout<<'.';
			}
		}
		if(tmp)
			cout<<'\n';
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N;
	cin >> N;

	int ret = 0;
	REP(i, 1, N) {
		if (i % 2 == 0) continue;
		int cnt = 0;
		REP(j, 1, i) {
			if (i % j == 0) cnt++;
		}
		if (cnt == 8) ret++;
	}

	cout << ret << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> p;


int main()
{
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s == "abc") {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int sum(int n, int array[]) {

	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += array[i];
	}
	return sum;
}

int main(){
	int n, m, l;
	int a[1000][1000] = { 0 }, b[1000][1000] = { 0 };
	long long c[1000][1000] = { 0 };

	cin >> n >> m >> l;
	for (int i = 0; i < n; i++) {
		for (int k = 0; k < m; k++) {
			cin >> a[i][k];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int k = 0; k < l; k++) {
			cin >> b[i][k];
		}
	}

	for (int i = 0; i < n; i++) {
		for (int k = 0; k < l; k++) {
			for (int p = 0; p < m; p++) {
				c[i][k] += a[i][p] * b[p][k];
			}
		}
	}
	
	for (int i = 0; i < n; i++) {
		for (int k = 0; k < l; k++) {
			cout << c[i][k];
			if (k == l - 1) cout << endl;
			else cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 18716
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,x,ans=1e9,sum;
bool dp[880][880];
main(){
	cin>>n;
	dp[0][0]=1;
	r(i,n){
		cin>>x;
		sum+=x;
		for(int j=879;j>=0;j--)
		  for(int k=879;k>=0;k--)
		    if(dp[j][k]){
		    	if(j+x<810)dp[j+x][k]=1;
		    	if(k+x<810)dp[j][k+x]=1;
		    }
	}
	r(i,880)r(j,880)if(dp[i][j])ans=min(ans,max(i,max(j,sum-i-j)));
    cout<<ans<<endl;
}

Measured memory_bytes: 3788
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		int N = ni();
		
		int ans = 0;
		for (int A = 1; A < N; A++) {
			for (int B = 1; A * B < N; B++) {
				ans++;
			}
		}
		
		out.println(ans);
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static String rl() throws IOException {
		return f.readLine();
	}

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static long nlg(StringTokenizer st) {
		return Long.parseLong(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(rl());
	}

	static long nlg() throws IOException {
		return Long.parseLong(rl());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(rl());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
}


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

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<bool>> boards(h, vector<bool>(w));
  rep(i, h) rep(j, w) {
    char c;
    cin >> c;
    if (c == '.') {
      boards[i][j] = true;
    } else {
      boards[i][j] = false;
    }
  }

  int maxDist = 0;
  rep(i, h) rep(j, w) {
    if (!boards[i][j]) {
      continue;
    }

    queue<P> que;
    vector<vector<int>> dist(h, vector<int>(w, -1));
    que.push(P(i, j));
    dist[i][j] = 0;
    while (!que.empty()) {
      auto p = que.front();
      que.pop();
      int pf = p.first;
      int ps = p.second;

      maxDist = max(maxDist, dist[pf][ps]);

      if (0 <= pf - 1 && boards[pf - 1][ps] && dist[pf - 1][ps] == -1) {
        dist[pf - 1][ps] = dist[pf][ps] + 1;
        que.push(P(pf - 1, ps));
      }
      if (pf + 1 < h && boards[pf + 1][ps] && dist[pf + 1][ps] == -1) {
        dist[pf + 1][ps] = dist[pf][ps] + 1;
        que.push(P(pf + 1, ps));
      }
      if (0 <= ps - 1 && boards[pf][ps - 1] && dist[pf][ps - 1] == -1) {
        dist[pf][ps - 1] = dist[pf][ps] + 1;
        que.push(P(pf, ps - 1));
      }
      if (ps + 1 < w && boards[pf][ps + 1] && dist[pf][ps + 1] == -1) {
        dist[pf][ps + 1] = dist[pf][ps] + 1;
        que.push(P(pf, ps + 1));
      }
    }
  }
  cout << maxDist << endl;
  return 0;
}


Measured memory_bytes: 3644
n,c,k,*t=map(int,open(0).read().split())
t.sort(reverse=1)
a=0
while t:
  h=t.pop()
  i=h
  j=1
  while t and j<c and i-h<k:
    i=t.pop()
    j+=1
  if i-h>k:
    t.append(i)
  a+=1
print(a)

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

int main(){
    int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
    int dx=tx-sx,dy=ty-sy;

    for(int i=0;i<dx;i++){cout<<'R';}
    for(int i=0;i<dy;i++){cout<<'U';}
    for(int i=0;i<dx;i++){cout<<'L';}
    for(int i=0;i<dy;i++){cout<<'D';}

    cout<<'D';
    for(int i=0;i<dx+1;i++){cout<<'R';}
    for(int i=0;i<dy+1;i++){cout<<'U';}
    cout<<'L';

    cout<<'U';
    for(int i=0;i<dx+1;i++){cout<<'L';}
    for(int i=0;i<dy+1;i++){cout<<'D';}
    cout<<'R';

    return 0;
}

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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(std::string S, std::string T) {
  ll cnt = 0;
  rep(i, S.size()) {
    if (S.at(i) != T.at(i)) {
      cnt++;
    }
  }

  cout << cnt << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  solve(S, T);
  return 0;
}


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

int gcd(int x, int y) {
    if (y == 0)
        return (x);
    else
        return (gcd(y, x % y));
}

int gcdary(int a[], int n)
{
    if (n == 1)
        return (a[0]);
    else if (n == 2)
        return (gcd(a[0], a[1]));
    else
        return (gcd(a[0], gcdary(&a[1], n - 1)));
}


int main() {
  
  int N, X;
  std::cin >> N >> X;
  
  int x[N];
  
  for (int i = 0; i < N; i++) {
    std::cin >> x[i];
  }
  
  int diff[N];
  
  for (int i = 0; i < N; i++) {
    diff[i] = abs(X - x[i]);
    // std::cout << diff[i] << '\n';
  }
  
  // int b[4] = {24, 36, 48, 72};
  // std::cout << gcd(48,72) << endl;
  // std::cout << gcdary(b ,4) << endl;
  std::cout << gcdary(diff, N) << endl;
  
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin >> n  >> k;
  int a[n];
  for(int i=0;i<n;i++)cin >> a[i];
  sort(a,a+n);
  long s=0;
  for(int i=0;i<k;i++)s+=a[i];
  cout<<s;


	return 0;
}

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

typedef long long ll;
#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define int ll

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;


void solve() {
	int n, x, t;
	cin >> n >> x >> t;

	cout << (n + x - 1) / x * t;
}

int32_t main() {
	_

#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
	solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> a(1<<n);
	for(int i = 0; i < 1<<n; i++) cin >> a[i];
	multiset<int> has;
	for(int i = 0; i < 1<<n; i++) has.insert(a[i]);
	vector<int> now;
	now.push_back(*prev(has.end()));
	has.erase(prev(has.end()));
	for(int i = 0; i < n; i++){
		sort(now.rbegin(), now.rend());
		vector<int> upd;
		for(int v : now){
			auto it = has.lower_bound(v);
			if(it == has.begin()){
				cout << "No" << endl;
				exit(0);
			}
			it--;
			upd.push_back(*it);
			has.erase(it);
		}
		for(int v : upd){
			now.push_back(v);
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 14908
// AOJ Vol-1 0146: Lupin The 4th
// 2017.9.28 bal4u@uu

#include <stdio.h>
#include <string.h>

#define INF 1.0e20
#define ABS(a) ((a)>=0?(a):-(a))
#define MAX 32768

typedef struct { int s, d, v; } T;		// ????????±?????????????????¢???????????±?????°
T tbl[17];

double dp[16][MAX];			// DP????????¨?????????
int w[16][MAX];				// ????????±????????°
int prev[16][MAX][2];		// ???????????????????????????
int ord[16];				// ???????????????????????????????????????????????´???

int main()
{
	int n, i, j, k, ii, lim;
	double x;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d%d%d", &tbl[i].s, &tbl[i].d, &tbl[i].v);

	memset(dp, 0, sizeof(dp)); memset(w, 0, sizeof(w));
	for (i = 0; i < n; i++) w[i][1<<i] = tbl[i].v, prev[i][1<<i][0] = prev[i][1<<i][1] = -1;

	lim = 1 << n;
	for (k = 0; k < lim; k++) {
		for (i = 0; i < n; i++) {		// ??´????????????
			for (j = 0; j < n; j++) {	// ??´?????????
				if (i == j || w[j][k] == 0) continue;
				ii = k | (1 << i);
				x = dp[j][k] + (ABS(tbl[i].d - tbl[j].d)*(7+2*w[j][k]))/200.0;
				if (dp[i][ii] == 0 || x < dp[i][ii]) {
					dp[i][ii] = x, w[i][ii] = w[j][k] + tbl[i].v;
					prev[i][ii][0] = j;
					prev[i][ii][1] = k;
				}
			}
		}
	}

	// ???????§???????????????????
	for (x = INF, ii = 0, i = 0; i < n; i++) {
			if (dp[i][lim-1] == 0) continue;
			if (dp[i][lim-1] < x) x = dp[i][lim-1], ii = i;
	}

	// ?????£???????????????
	for (ord[0] = ii, i = ii, j = lim-1, k = 1; k < n; k++) {
		ord[k] = prev[i][j][0];
		     j = prev[i][j][1];
		     i = ord[k];
	}

	// ??????
	printf("%d", tbl[ord[n-1]].s);
	for (i = 1; i < n; i++) printf(" %d", tbl[ord[n-i-1]].s);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 11280
from sys import stdin
from math import factorial


def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))


def combinations_with_replacement_count(n, r):
    return combinations_count(n + r - 1, r)


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    S = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    min_ = 1
    max_ = S // 3
    ans = 0
    for i in range(min_, max_ + 1):
        mod = S - i * 3
        ans += combinations_with_replacement_count(mod + 1, i - 1) % (10**9 + 7)
    ans %= (10**9 + 7)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 73480
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, b, h, m = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]
    import math

    minite = h*60 + m
    degmin = math.radians(90 - 6 * minite)
    deghour = math.radians(90 - 0.5 * minite)

    pointmin = [b * math.cos(degmin), b * math.sin(degmin)]
    pointlong = [a * math.cos(deghour), a * math.sin(deghour)]

    print(math.sqrt((pointmin[0] - pointlong[0])**2 + (pointmin[1] - pointlong[1])**2))
 #   print(degmin, deghour)
 #   print(pointmin, pointlong)

resolve()

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

#define ll long long

const int maxn = 1e4+50;

char s[maxn];
int K;

struct node
{
    string str;
    friend bool operator < (const node &a, const node &b)
    {
        return a.str > b.str;
    }
};

priority_queue<node> pq;
set<node> vis;

int main()
{
    scanf("%s", s);
    scanf("%d", &K);
    int n = strlen(s);
    node tmp;
    char t[6];
    for (int i = 0; i < n; ++i)
    {
        memset(t, 0, sizeof t);
        for (int j = i; j < min(n, i+K); ++j)
        {
            t[j-i] = s[j];
            tmp.str = t;
            if (!vis.count(tmp)) pq.push(tmp);
            vis.insert(tmp);
        }
    }
    for (int i = 0; i < K-1; ++i)
    {
        //cout << pq.top().str << endl;
        pq.pop();
    }
    cout << pq.top().str << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pb push_back
#define ii pair<int, int>
#define MAXN int(1e6)
#define qi queue<int>
#define si stack<int>
#define mii map<int, int>
#define msi map<string, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
using namespace std;

ll dp[100][100001], w[100], v[100];
int n;
ll W;

ll kn(int sz, int rw) {
	if (sz == n)
		return 0;

	ll& res = dp[sz][rw];
	if (res != -1)
		return res;

	if (w[sz] > rw)
		return res = kn(sz+1, rw);

	return res = max(kn(sz+1, rw), v[sz]+kn(sz+1, rw-w[sz]));
}

int main(int argc, char** argv) {
	ios::sync_with_stdio(0);
	cin.tie(0);
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	cin >> n >> W;

	memset(dp, -1, sizeof dp);

	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i];

	cout << kn(0, W) << '\n';

	return 0;
}






Measured memory_bytes: 78336
A, B, C, D = input().split()
A = int(A)
B = int(B)
C = int(C)
D = int(D)
i = 0

for i in range(100):
    C = (C - B)
    if C <= 0:
        print('Yes')
        break
    else:
        A = A - D
        if A <= 0:
            print('No')
            break


Measured memory_bytes: 61936
from itertools import accumulate

n = int(input())
a = [int(i) for i in input().split()]
a_ac = [0] + list(accumulate(a))
d = {}
for i in a_ac:
    d.setdefault(i, 0)
    d[i] += 1

ans = 0
for i in d.values():
    ans += i * (i - 1) // 2
print(ans)

Measured memory_bytes: 41488
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

/*-- template --*/

int main() {
    int N; cin >> N;
    ll A[N]; rep(i, N) cin >> A[i], A[i] = A[i] - (i + 1);
    sort(A, A + N);
    ll b;
    if(N%2) {
        b = A[N / 2];
    }else {
        b = (A[N / 2] + A[N / 2 - 1]) / 2;
    }
    ll ans = 0;
    rep(i, N) {
        ans += abs(A[i] - b);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	int a,b;cin>>a>>b;
	if(b%a==0){
		cout<<a+b<<endl;
	}
	else{
		cout<<b-a<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b,c,d,e,f,g,h,i,j,k,l,n,m;
		d=0;
		cin>>a;
		if (a==0)
		{
			break;
		}
		b=1000-a;
		c=b/500;
		d=d+c;
		e=b%500;
		c=e/100;
		d=d+c;
		e=b%100;
		c=e/50;
		d=d+c;
		e=b%50;
		c=e/10;
		d=d+c;
		e=b%10;
		c=e/5;
		d=d+c;
		e=b%5;
		d=d+e;
		cout<<d<<endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	
	vector<int> x(N);
	for (int i = 0; i < N; i++)
	{
		cin >> x[i];
	}
	
	int answer = INT_MAX;
	// N 本のうち連続する K 本のろうそくを選ぶ = N - K + 1 通り
	for (int i = 0; i < N - K + 1; i++)
	{
		int left = x[i];
		int right = x[i + K - 1];
		
		// L→Rの距離
		int LR = abs(left) + abs(left - right);
		// R→Lの距離
		int RL = abs(right) + abs(left - right);
		
		// L→RとR→Lのどちらの値が小さいかを計算
		int minDistance = min(LR, RL);
		
		// 現在の値と算出した距離の値の最小値を代入
		answer = min(answer, minDistance);
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 640
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn string() -> String {
    read()
}
fn int() -> i64 {
    read()
}
fn char() -> char {
    read::<String>().pop().unwrap()
}
fn vecchar() -> Vec<char> {
    string().chars().collect()
}
fn vecint(n: i64) -> Vec<i64> {
    let mut vec = Vec::new();
    for i in 0..n {
        vec.push(int())
    }
    vec
}

fn main() {
    let s = vecchar();
    println!("{}", s.iter().filter(|c| **c == '1').count())
}


Measured memory_bytes: 4352
#include<stdio.h>
 
int main(){
  int N, i, t;  
  scanf("%d", &N);
  for (i=3; i<=N; i++) {
    if (i % 3 == 0) {
      printf(" %d", i);
    } else {
      t = i;
      while (t > 0) {
        if (t % 10 == 3) {
          printf(" %d", i);
          break;
        } else {
          t /= 10;
        }
      }
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> numbers(n);
    for (int i=0;i<n;i++){
        cin >> numbers[i];
    }
    int objective = round(accumulate(numbers.begin(), numbers.end(), 0) / static_cast<float>(n));

    int acc = 0;
    for (auto &i : numbers){
        acc += pow(i - objective, 2.0);
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, i, j, k, x, ans = 13, ct;
	cin >> n;
	vector<int> a(13, 0), xx;
	for (i = 0; i < n; i++) {
		cin >> x;
		a[x]++;
		ans = min(ans, x);
	}
	xx.push_back(0);
	ct = 0;
	for (i = 0; i < 13; i++) {
		if (a[i] == 0) continue;
		if (a[i] >= 2) {
			xx.push_back(i);
			xx.push_back(24-i);
		}
		else {
			ct++;
			if (ct % 2 == 0) xx.push_back(i);
			else xx.push_back(24-i);
		}

		if (a[i] >= 3) ans = 0;
	}
	xx.push_back(24);
	
	//for (i = 1; i < xx.size(); i++) ans = min(ans, xx[i] - xx[i - 1]);
	//for (i = 1; i < yy.size(); i++) ans = min(ans, abs(yy[i] - yy[i - 1]));
	//if (xx[xx.size() - 1] != 12) ans = min(ans, 24 - (xx[xx.size() - 1] - yy[yy.size() - 1]));
	//if (a[12] > 1) ans = 0;

	sort(xx.begin(), xx.end());
	for (i = 1; i < xx.size(); i++) ans = min(ans, xx[i] - xx[i - 1]);

	cout << ans << "\n";

	return 0;
}




Measured memory_bytes: 384