akhauriyash/Code-Regression huggingface dataset:
#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int n;
int A[2000];


bool find(int m, int i){
  if (m==0) {
    return true;
  }else if (i>=n || m<0) {
    return false;
  }
  bool res = find(m, i+1) || find(m-A[i], i+1);
  return res;
}


int main(int argc, char const *argv[]) {
  std::cin >> n;
  for (size_t i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  int q; std::cin >> q;

  for (size_t i = 0; i < q; i++) {
    int val;
    scanf("%d", &val);
    if (find(val, 0)) {
      std::cout << "yes" << '\n';
    }else{
      std::cout << "no" << '\n';
    }
  }

  return 0;
}



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

int main() {
  string s;
  cin >> s;
  int sum = 0;
  rep(i,4){
    if(s.at(i) == '-') sum--;
    else sum++;
  }
  cout << sum << endl;
}
  


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

using namespace std;

#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    vector<int> dp(n, 0);
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; ++i) {
        int next = inf;
        for (int j = 1; j <= k; ++j) {
            if (i - j < 0) continue;
            next = min(next, dp[i - j] + abs(h[i] - h[i - j]));
        }
        dp[i] = next;
    }

    cout << dp[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int a , b , c;

int main ()  {

	scanf ("%d %d %d" , &a , &b ,&c);
	
	if (a<=b && b<=c) {
		
		printf ("%d %d %d\n" , a , b , c );
		
	}	else  if (a<=c && c<=b) {
		
		printf ("%d %d %d\n" , a , c , b );
		
	}   else if (b<=a && a<=c) {
		
		printf ("%d %d %d\n" , b , a , c );
		
	}   else if (b<=c && c<=a) {
		
		printf ("%d %d %d\n" , b , c , a );
		
	}	else if (c<=a && a<=b) {
		
		printf ("%d %d %d\n" , c , a , b );
		
	}
		else if (c<=b && b<=a) {
			
		printf ("%d %d %d\n" , c , b , a );
		
	}	
	return 0;
	
}



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

#define ll long long int
#define endl '\n'
ll const mod = 1e9 + 7;

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    double r;
    cin>>r;
    
    cout<<fixed;
    cout<<setprecision(10)<<2*3.1415926535*r;
    
	// your code goes here
	return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

    ll ans = 0;
    REP(i, 1, N + 1) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans = ans + i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int main(){
  ll x,y,a,b,c; cin>>x>>y>>a>>b>>c;
  priority_queue<ll> p,q,r,ans;
  rep(i,0,a){
    ll ex;  cin >> ex;
    p.push(ex);
  }
  rep(i,0,b){
    ll ex;  cin >> ex;
    q.push(ex);
  }
  rep(i,0,c){
    ll ex;  cin >> ex;
    r.push(ex);
  }
  ll sum = 0;
  rep(i,0,x){
    ans.push(p.top());
    p.pop();
  }
  rep(i,0,y){
    ans.push(q.top());
    q.pop();
  }
  while(r.size()){
    ans.push(r.top());
    r.pop();
  }
  rep(i,0,x+y){
    sum += ans.top();
    ans.pop();
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(2e6) + 17;

int n, k;
ll a[MAXN];

bool read() {
    if (!(cin >> n >> k))
        return false;
    
    forn (i, n)
        cin >> a[i];

    return true;
}

void solve() {
    vector<ll> vec;

    forn (i, n) {
        ll sum = 0;

        for (int j = i; j < n; ++j) {
            sum += a[j];
            vec.pb(sum);
        }
    }

    ll ans = 0;

    for (int bit = 60; bit >= 0; --bit) {
        ans += (1ll << bit);
        int cnt = 0;

        forn (i, sz(vec))
            if ((ans & vec[i]) == ans)
                ++cnt;

        if (cnt < k)
            ans -= (1ll << bit);
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >>W;
  vector<string>A(H);//string型の配列変数Aを宣言
  for(int j = 0; j < W + 2; j++) cout << '#';//一行目はすべて#
  cout << endl;
  
  for(int i = 0; i < H; i++){
    cin >> A.at(i);//Aを出力
    cout << '#' << A.at(i) << '#' << endl;//前後に#を挟む
  }

  for(int j = 0; j < W + 2; j++) cout << '#';//最終行もすべて#
  cout << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int a[100010];
int b[100010];
int c[100010];
int gcd(int x,int y)
{
	return y==0?x:gcd(y,x%y);
}
int main(void)
{
	int i,j,k,n,m;
	int k1=0,s;
	scanf("%d%d",&n,&m);
	k=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		k=max(k,a[i]);
		if(m==a[i])
		k1=1;
	}
	if(m>k)
	printf("IMPOSSIBLE\n");
	else
	{
		if(k1==1)
		printf("POSSIBLE\n");
		else
		{
			sort(a,a+n);
			s=gcd(a[0],a[1]);
			for(i=1;i<n;i++)
			{
				s=gcd(a[i],s);
			}
			if(m%s==0)
			printf("POSSIBLE\n");
			else
			printf("IMPOSSIBLE\n");
		}
	}
	return 0;
}

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

int main(){
  int N = 0;
  string S;
  bool t = false;
  
  cin >> N;
  
  for(int i = 0;i < N;i++){
    cin >> S;
    if(S == "Y"){
      cout << "Four";
      t = true;
      break;
    }
  }
  if(!t){
    cout << "Three";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

const unsigned long long div_mode = 1e9+7;


unsigned long long stairs (int steps, vector<bool> &A, vector<unsigned long long> &memo)
{
  if (steps < 0) {
    return 0;
  }
  
  if (!A[steps]) {
    return 0;
  }

  if (memo[steps] != -1) {
    return memo[steps];
  }

  memo[steps] = (stairs(steps-1, A, memo) + stairs(steps-2, A, memo)) % div_mode;
  
  return memo[steps];
}

int main(int argc, char* argv[])
{
  int N, M; cin >> N >> M;

  vector<bool> A(N+1, true);
  for(int i = 0; i < M; i++) {
    int a; cin >> a;
    A[a] = false;
  }

  vector<unsigned long long> memo(N+1, -1);
  memo[0] = 1;
  cout << stairs(N, A, memo) << endl;
  return 0;
}


Measured memory_bytes: 7296
N,T = map(int,input().split(" "))
list1 = []
count = 0
for i in range(N):
    c,t = map(int,input().split(" "))
    if t <= T:
        list1.append(c)
        count += 1

if count == 0:
    print("TLE")
else:
    print(min(list1))


Measured memory_bytes: 2940
/*
**    Author : Dhiraj Govindvira
**      Date : 09-Sep-2020 ~ Wednesday
**      Time : 07:50:37 PM
*/

#ifdef Dhiraj
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define FOR(i, a, b, s)     for(ll i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define FOR1(b)             FOR(i, 0, b, 1)
#define FOR2(i, b)          FOR(i, 0, b, 1)
#define FOR3(i, a, b)       FOR(i, a, b, (a) <= (b) ? 1 :-1)
#define FOR4(i, a, b, s)    FOR(i, a, b, s)
#define GET5(a, b, c, d, e, ...) e
#define FORC(...)           GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)
#define loop(...)           FORC(__VA_ARGS__)(__VA_ARGS__)
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename... T> 
inline void inp(T&... args) {
    ((cin >> args), ...);
}
// scan vector
template <typename T> 
inline istream& operator >>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream& operator >>(istream &in, pair<T, U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(int &T)
{
    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);
    cin >> a;

    auto ok = [&](ll m)
    {
        ll ans = 0;
        loop(i, n)  {
            ans += ((a[i] + m - 1) / m - 1);
        }
        return ans <= k;
    };

    ll l = 1, r = 1e9, ans = -1;
    while(l <= r)
    {
        ll m = (l + r) / 2;
        if(ok(m)) {
            ans = m;
            r = m - 1;
        }
        else l = m + 1;
    }
    cout << ans << endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
        freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
        // freopen("D:/dhiraj/Programming/e1.txt", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    for(int i = 1; i <= t; i++) {
        cerr << "Case #" << i << "\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 4760
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll r, d, x, y;
    cin >> r >> d >> x;
    rep(i, 10){
        y = r*x - d;
        x = y;
        cout << x << "\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  ll n, m;
  cin >> n >> m;
  if (n>9 || m>9) {
    cout << -1 << endl;
  } else {
    cout << n*m << endl;
  }
}

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

namespace ConsoleApplication59
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                List<int> m = new List<int>();
                int a = int.Parse(Console.ReadLine());
                if (a == 0) break;
                int[] s = new int[4001];
                for (int b = 0; b < a; b++)
                {
                    int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    s[c[0]] += c[1] * c[2];
                    foreach(int q in m)
                    {
                        if (q == c[0]) goto k;
                    }
                    m.Add(c[0]);
                k:;
                }
                List<int> e = new List<int>();
                for(int d = 0; d < m.Count; d++)
                {
                    if (s[m[d]] >= 1000000) e.Add(m[d]);
                }
                if (e.Count == 0)
                {
                    Console.WriteLine("NA");
                }
                else
                {
                    foreach(int o in e)
                    {
                        Console.WriteLine(o);
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 9832
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	if(a + b + c <= 21){
			System.out.println("win");
        }else{
			System.out.println("bust");
        }
     }
}

Measured memory_bytes: 35820
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long n,cnt[60];
    for(long long i = 0 ; i < 60 ; i += 1){
        cnt[i] = 0;
    }
    cin >> n;
    long long val1=0,val2=0,sum;
    for(long long i = 0 ; i < n ; i += 1){
        long long a;
        cin >> a;
        if(i == 0){
        	val1 = a;
        	continue;
        }else if(i == 1){
        	val2 = a;
        	continue;
        }
        long long tag=0;
        while(a){
            if(a % 2 == 1){
                cnt[tag] += 1;
            }
            a /= 2;
            tag += 1;
        }
    }

    // fact ---> a+b = a^b + 2*(a&b)
    // fact ---> a|b = a^b + a&b
    sum = val1+val2;
    long long val3 = 0;
    for(long long i = 0 ; i < 60 ; i += 1){
    	if(cnt[i] % 2 == 1){
    		val3 += (1ll<<i);
    	}
    }
    if(val3 > sum){
    	cout << -1 << endl;
    	return 0;
    }
    if((sum-val3)%2 == 1){
    	cout << -1 << endl;
    	return 0;
    }
    long long val4 = (sum-val3)/2;
    // this value --> (a&b) & (a^b) is always zero , we want to achieve (a^b) = 'some value', than that value must satisfy this fact
    if(val4 & val3){
    	cout << -1 << endl;
    	return 0;
    }
    long long ans = val4;
    for(long long i = 59 ; i >= 0 ; i -= 1){
    	if(ans + (1ll << i) <= val1 && (val3 & (1ll<<i))){
    		ans += (1ll<<i);
    	}
    }

    // ans -> how many stones will remain in first pile, so they cannot be more than initial because
    // we are not allowed to borrow stones from other pile, and it cannot be zero as well according to question.

    if(ans == 0 || ans > val1){
    	cout << -1 << endl;
    	return 0;
    }
    cout << val1-ans << endl;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	string a;
	cin>>a;
	if(a[0]=='Y'&&a[1]=='A'&&a[2]=='K'&&a[3]=='I')cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
typedef long long ll;

int main(){
    ll N;
    ll r=0;
    cin >> N;
    vector<ll> v(N);
    map<ll,ll> mp;
    for (int i=0;i<N;++i) {
        cin >> v[i];
        if (i>0) v[i] += v[i-1];
        mp[v[i]] += 1;
    }


    for (auto it=mp.begin();it!=mp.end();++it) {
        if (it->first==0) r += it->second;
        r += (it->second)*(it->second-1)/2;
    }
    cout << r << endl;    
}

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

#define int long long 
const int mxN = 1e5+10;
int a[mxN], b[mxN], c[mxN], n;
int dp[4][mxN];

int points(int i, int prev) {
    if(i == n)
        return 0;
    
    if(dp[prev][i] != -1)
        return dp[prev][i];

    int ans = 0;
    if(prev != 1) {
        ans = max(ans, a[i] + points(i+1, 1));
    } 
    if(prev != 2) {
        ans = max(ans, b[i] + points(i+1, 2));
    } 
    if(prev != 3) {
        ans = max(ans, c[i] + points(i+1, 3));
    }
    dp[prev][i] = ans;
    return dp[prev][i];
}

void solve() {
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> a[i] >> b[i] >> c[i];
    memset(dp, -1, sizeof(dp));
    cout << points(0, 0) << endl;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
}


Measured memory_bytes: 10368
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    String s = sc.next();
	    String S[] = s.split("");
	    if(N % 2 == 1) {
	        System.out.println("No");
	    }else {
	        for(int i = 0; i < N / 2; i++) {
	            if(S[i].equals(S[N / 2 + i])) {
	                if(i < N / 2 - 1) {
	                    continue;
	                }
	                System.out.println("Yes");
	            }else {
	                System.out.println("No");
	                break;
	            }
	        }
	    }
	}
}

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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var D = vals[1];

        var result = (int)Math.Ceiling(N / (double)(D * 2 + 1));

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 11220
a = list(map(int, input().split()))
ans = 0
def digit_sum(x):
    l = [int(i) for i in str(x)]
    return sum(l)

for i in range(a[0]):
    tmp = digit_sum(i+1)
    if (tmp >= a[1]) and (tmp <= a[2]):
        ans+= i+1

print(ans)


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

int main(){
  int H,A;
  cin >> H >> A;
  cout << ceil(H*1.0/A)<< endl;
  return 0; 
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
 
int ans=0;
int a[10][10];
 
int func(vector<int> &t){
  int res= a[ 0 ][ t[0] ];
  for(int i=1;i<(int)t.size();i++){
    res=a[ res ][ t[i] ];
  }
  return res;
}
 
int main(){
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      cin>>a[i][j];
 
  map< vector<int> ,int > mp;
  for(int i=0;i<10000;i++){
    int p=i;
    vector<int> t(4);
    for(int j=0;j<4;j++){
      t[j]=p%10;
      p/=10;
    }
    reverse(t.begin(),t.end());
    t.push_back( func(t) );
    bool flg=false;
    int base=func(t);
 
 
    //    cout<<t[0]<<' '<<t[1]<<' '<<t[2]<<' '<<t[3]<<' '<<t[4]<<' '<<base<<endl;
       
    vector<int> u;
    for(int j=0;j<5;j++){
      for(int k=0;k<10;k++){
        u=t;
        if(u[j]==k)continue;
        u[j]=k;
        if( func(u) == 0 )flg=true;
      }
    }
 
    for(int j=0;j<4;j++){
      u=t;
      if(u[j]==u[j+1])continue;
      swap(u[j],u[j+1]);
      if( func(u) == 0 )flg=true;
    }
    if(flg)ans++;
  }
 
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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 long long INF = 1LL << 60;
#define PI 3.14159265359 
long long MOD = 1000000007;


template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

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

long long dp[200100];

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

    cout << (A-1) * (B-1) << endl;
}



Measured memory_bytes: 3640
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
                Scanner scan = new Scanner(System.in);
               int n=scan.nextInt();
               int[] arr=new int[n];
               for(int i=0;i<n;i++){
                   arr[i]=scan.nextInt();
               }
           Arrays.sort(arr);
               int count=0;
               for(int i=0;i<n;i++){
                   for(int j=i+1;j<n;j++){
                       for(int k=j+1;k<n;k++){
                           if(arr[i]+arr[j]>arr[k] && arr[i]!=arr[j] && arr[j]!=arr[k]){
                               count++;
                           }
                       }
                   }
               }
               System.out.print(count);
    }
}


Measured memory_bytes: 27532
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    string s;
    long long cnt=0,i,a=0,j,k;
    cin>>s;
    if(s.size()<3)
    {
        cout<<0;
        return 0;
    }
    for(i=0; i<s.size(); i++)
    {
        if(s[i]=='A')
        {
            a++;
        }
        else if(s[i]=='B' && s[i+1]=='C' && i+1<s.size())
        {
            cnt=cnt+a;
            i++;
        }
        else
        {
            a=0;
        }
    }
    cout<<cnt;
    return 0;
}



Measured memory_bytes: 720
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

class Main
{

	public static void main(String[] args)throws IOException
	{
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] h=new int[3];
		int max=0;
		String[] ans=new String[N];
		for(int i=0;i<N;i++)
		{
			for(int j=0;j<3;j++)
			{
				h[j]=(int)Math.pow(sc.nextInt(),2);
			}
			Arrays.sort(h);
			ans[i]=(h[0]+h[1]==h[2])?"YES":"NO";
		}
		for(String disp:ans)
		{
			System.out.println(disp);
		}
	}

}

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

using namespace std;

int main() {
  const int MOD = 1e9 + 7;
  int N;
  cin >> N;
  vector<long long> A(N);
  for (auto &a : A) {
    cin >> a;
  }
  long long ans = 0;
  for (int place = 0; place <= 60; place++) {
    long long count[2] = {0, 0};
    for (auto a : A) {
      count[(a >> place) & 1]++;
    }
    long long c = 1LL << place;
    c %= MOD;
    c *= (count[0] * count[1]) % MOD;
    ans += c;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
n = gets.to_i
num = gets.split(' ').map(&:to_i)
count = 0
(0..n-1).each do |a|
    if a+1 != num[a]
        count +=1
    end 
end
if count == 2 || count == 0
    puts 'YES'
else 
    puts 'NO'
end

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

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

    vector<int> H(N);
    vector<bool> B(N, true);
    rep(i, N) cin >> H[i];

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        if (B[a]) {
            if (H[a] <= H[b]) B[a] = false;
        }

        if (B[b]) {
            if (H[b] <= H[a]) B[b] = false;
        }
    }

    int ans = 0;
    rep(i, N) if (B[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3728
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main() {
string S;
cin>>S;
repr3(i,S.size()-1){
    
    if(i%2==0){
        string s2="";
        rep(j,i/2){
            s2+=S[j];

        }
        string s3="";
        rep2(j,i/2,i){
            s3+=S[j];
        }
        if(s2==s3){
            cout<<i<<endl;
            return 0;
        }
    }
}
return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int> > list(N, vector<int>(N,0));
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b; a--; b--;
        list[a][b] = 1;
        list[b][a] = 1;
    }

    vector<int> v(N-1);
    for(int i=0;i<N-1;i++){
        v[i] = i+1;
    }
    sort(v.begin(), v.end());

    int ans = 0;
    do{
        int pos = 0;
        for(int i=0;i<v.size();i++){
            if(list[pos][v[i]] == 0) break;
            pos = v[i];
            if(i == v.size()-1) ans++;
        }
    }while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

#define FENWICK_NMAX 200010
struct fenwick_tree{
    ll N;
    ll bit[FENWICK_NMAX];
    fenwick_tree(ll n){
        N = n;
        for(ll x = 1; x <= N; x++){
            bit[x] = 0;
        }
    }
    void add(ll a, ll w){
        for(ll x = a; x <= N; x += x & -x){
            bit[x] += w;
        }
    }
    ll sum(ll a){
        ll ret = 0;
        for(ll x = a; x > 0; x -= x & -x){
            ret += bit[x];
        }
        return ret;
    }
};

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> s(N,0), a(N,0), b(N);
    ll ans = 0;
    rep(i, 0, N){
        cin >> a[i];
        if(i != 0) s[i] = a[i] + s[i-1];
        else s[i] = a[i];
        b[i] = s[i] - K * (i+1);
        if(b[i] >= 0) ans++;
    }
    auto c = b;
    sort(c.begin(), c.end());
    c.erase(unique(c.begin(), c.end()), c.end());
    fenwick_tree t(N+1);
    rep(i, 0, N){
        auto itr = lower_bound(c.begin(), c.end(), b[i]);
        ll tmp = itr - c.begin() + 1;
        ans += t.sum(tmp);
        t.add(tmp, 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

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

int main()
{
	double p[6], q[6], x[6];
	for(int i=0; i<6; i++){
		cin>>p[i];
	}
	for(int i=0; i<6; i++){
		cin>>q[i];
		x[i]=q[i]/(p[i]+q[i]);
	}
	double ans=1.0;
	for(int k=0; k<6; k++){
		double ans1=0;
		for(int i=0; i<6; i++){
			ans1+=max(x[k]*p[i], (1.0-x[k])*q[i])/100.0;
		}
		if(ans>ans1) ans=ans1;
	}
	printf("%.10lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
m,M=min(a),max(a)
min_cost=4000000
for i in range(m,M+1):
    cost=sum(map(lambda x:(x-i)*(x-i),a))
    min_cost=cost if cost<min_cost else min_cost
print(min_cost)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    

    int ans = INF;
    int cost;
    for (int i = -102; i < 102; i++)
    {
        cost = 0;
        for(auto&& j : a){
            cost += abs(j-i)*abs(j-i);
        }
        ans = min(ans, cost);
    }
    pr(ans);
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))

for i in range(1,n):
  print(*A)
  v=A[i]
  j=i-1
  while j>=0 and A[j]>v:
    A[j+1]=A[j]
    j-=1
  A[j+1]=v
print(*A)



Measured memory_bytes: 5980
import os
import numpy as np

class getStdin(object):
    @classmethod
    def get_int(cls):
        return int(input())

    @classmethod
    def get_ss_int(cls):
        return list(map(float, input().split()))

    @classmethod
    def get_na_int(cls):
        return np.array(sorted(list(map(int, input().split()))))

    @classmethod
    def get_na_intr(cls):
        return np.array(sorted(list(map(int, input().split())))[::-1])


class funcCls(object):
    @classmethod
    def done(cls, a, b, x):
        import math
        mm = x / a
        if mm <= (a * b / 2):
            th = math.degrees(math.atan(b ** 2 / (2 * mm)))
        else:
            th = math.degrees(math.atan((-2*mm + 2*a*b) / a ** 2))

        return th


if __name__ == '__main__':
    a, b, x = getStdin.get_ss_int()
    y = funcCls.done(a, b, x)

    print(y)
    os.sys.exit(0)

Measured memory_bytes: 12500
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;
char a[101];
char b[101];
int main()
{
    while(scanf("%s%s",&a,&b)!=EOF){
        int la=strlen(a);
        int lb=strlen(b);
        sort(a,a+la);
        sort(b,b+lb);
        if(a[0]<b[lb-1]) cout<<"Yes"<<endl;
        else if(a[0]>b[lb-1]) cout<<"No"<<endl;
        else{
            if(a[0]==a[la-1]&&b[0]==b[lb-1]&&a[0]==b[0]){
                if(lb>la) cout<<"Yes"<<endl;
                else cout<<"No"<<endl;
                continue;
            }
            int k=0;
            for(int i=0;i<la;i++){
                for(int j=0;j<lb;j++){
                    if(b[j]>a[i]){
                        k++;
                        break;
                    }
                }
            }
            if(k==la) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod

int main(){
	ll n,r;
	cin>>n>>r;
	if(n>=10)cout<<r<<endl;
	else cout<<r+100*(10-n)<<endl;
}



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

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for (int i=0; i<N; i++) {
    for (int j=0; j<D; j++) {
      cin >> X.at(i).at(j);
    }
  }
  
  int ans = 0;
  for (int i=0; i<N; i++) {
    for (int j=i+1; j<N; j++) {
      int n2 = 0;
      for (int k=0; k<D; k++) {
        n2 += (X.at(i).at(k) - X.at(j).at(k))*(X.at(i).at(k) - X.at(j).at(k));
      }
      for (int l=1; l<130; l++) {
        if (n2 == l*l) {
          ans++;
          break;
        }
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n;
  cin >> n;
  vector<ll> d(n);
  REP(i, n)
  {
    cin >> d[i];
  }
  sort(ALL(d));
  cout << d[n / 2] - d[n / 2 - 1] << endl;
  return 0;
}


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

int n, p, Circle, Cnt = 2, a[Maxn], vis[Maxn];
long long k;

int main()
{
	scanf("%d%lld", &n, &k);
	for (int i=1; i<=n; i++) scanf("%d", &a[i]);
	if (k <= n)
	{
		int Res = 1;
		for (; k>0; k--) Res = a[Res];
		printf("%d\n", Res);
		return 0;
	}
	vis[a[1]] = 1;
	for (p=a[1]; !vis[a[p]]; p=a[p], Cnt++) vis[a[p]] = Cnt;
	// printf("%d %d\n", vis[a[p]], Cnt);
	// for (int i=1; i<=n; i++) printf("%d ", vis[a[i]]); puts("");
	Circle = Cnt - vis[a[p]];
	k -= (vis[a[p]] - 1ll);
	k %= Circle; if (!k) k = Circle; int Res = a[p];
	k--;
	// printf("k = %lld\n", k);
	for (; k>0; k--) Res = a[Res];
	printf("%d\n", Res);
}

Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    int s; cin >> s;
    int up, dwn;
    up = s/100;
    dwn = s%100;
    string ans;
    if(up>=13||up==00){
        if(dwn>=01&&dwn<=12){
            ans = "YYMM";
        }else {
            ans = "NA";
        }
    }else{
        if(dwn>=13||dwn==00){
            ans = "MMYY";
        }else{
            ans = "AMBIGUOUS";
        }
    }
    
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long 
#define pb push_back
#define fo(i,N) for(int i = 0 ; i < N ; i++)
#define foo(i,x,N) for (int i = x; i < N ; i++)
#define fill(a,val) memset(a,val,sizeof(a))
#define fastio()  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define MAX 1234567
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define inf 1e14+1
#define all(a) a.begin(),a.end()

int n;
vector <int> v(401);
ll pre[401] = {0};
ll dp[401][401];


ll solve(int i,int j)
{
  if ( i == j)
  {
    return 0;
  }

  if ( dp[i][j] != -1)
    return dp[i][j];

  ll ans = inf;
 
  for(int k = i; k < j ; k++)
  {
    ans = min(ans,solve(i,k)+solve(k+1,j)+pre[j]-pre[i-1]);
  }

  return dp[i][j] = ans;
}

int main()
{  
  cin >> n;

  foo(i,1,n+1)
  { 
    cin >> v[i]; 
    pre[i] = pre[i-1]+v[i];
  }
  fill(dp,-1);


  cout << solve(1,n) << endl;



 
}

Measured memory_bytes: 1536
import numpy

W, H, N = map(int, input().split())
info = []
for _ in range(N):
    x, y, a = map(int, input().split())
    info.append([x,y,a])

plane = numpy.ones((H, W))

for x, y, a in info:
    if a == 1:
        plane[:, :x] = 0
    elif a == 2:
        plane[:, x:] = 0
    elif a == 3:
        plane[:y, :] = 0
    else:
        plane[y:, :] = 0
    
        
print(int(numpy.sum(plane)))

Measured memory_bytes: 26516
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L

int main() {
	string s; cin >> s;
	int len, len2, len3;
	len = (s.length()-1)/2;
	for (int ii = 0; ii < len; ii++) {
		if (s[ii] != s[s.length()-1-ii]) goto NOT_KAI;
	}
	if (s.length()==3) goto KAI;
	len2 = (len - 1)/2;
	if (len2 == 0) {
		if ( s[0] != s[1] ) goto NOT_KAI;
	}
	for (int ii = 0; ii < len2; ii++) {
		if (s[ii] != s[len-1-ii]) goto NOT_KAI;
	}
	if (len2 == 0) {
		if(s[s.length()-1] != s[s.length()-2]) goto NOT_KAI;
	}
	for (int ii = len+1; ii < len+1+len2; ii++) {
		if (s[ii] != s[s.length()-1-ii]) goto NOT_KAI;
	}

KAI:
	cout << "Yes" << endl;
	return 0;

NOT_KAI:
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3628
def lrs(str):
    n = len(str)
    LCSRe = [[0 for x in range(n + 1)]
             for y in range(n + 1)]
    res = ""
    res_length = 0
    index = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            if (str[i - 1] == str[j - 1] and
                    LCSRe[i - 1][j - 1] < (j - i)):
                LCSRe[i][j] = LCSRe[i - 1][j - 1] + 1

                if (LCSRe[i][j] > res_length):
                    res_length = LCSRe[i][j]
                    index = max(i, index)

            else:
                LCSRe[i][j] = 0


    if (res_length > 0):
        for i in range(index - res_length + 1,
                       index + 1):
            res = res + str[i - 1]

    return res


if __name__ == "__main__":
    a = int(input())
    s = input()

    print(len(lrs(s)))

Measured memory_bytes: 247176
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>PP;
const ll MOD = 1000000007;
int main(){
  int n;cin>>n;
  cout<<180*(n-2)<<endl;
}


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

using namespace std;
typedef long long ll;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
const ll mod = 1e9 + 7;
#define REP(i, o, n) for (ll i = o; i < n; i++)
#define rep(i, n) REP(i, 0, n)

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

ll lcm(ll a, ll b) { return a / gcd(b, a % b) * b; }

void actual() {
    ll n, d, ans = 0;
    cin >> n >> d;
    vector <vector<ll>> x(n, vector<ll>(d));

    rep(i, n) rep(j, d) cin >> x[i][j];
    rep(i, n) {
        REP(j, i + 1, n) {
            ll norm = 0;
            rep(k, d) {
                ll diff = abs(x[i][k] - x[j][k]);
                norm += diff * diff;
            }

            bool flag = false;
            for (ll k = 0; k <= norm; k++) if (k * k == norm) flag = true;
            if (flag) ans++;
        }
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    actual();
    return 0;
}


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


//AKIBAHARA

int main(){
	string S;
	cin>>S;
	
	size_t KIH_pos = S.npos;
	size_t B_pos;
	size_t B_pos1 = S.npos;
	size_t B_pos2 = S.npos;
	
	if(S.size()>9){
		cout<<"NO";
	}
	else if((KIH_pos=S.find("KIH"))==S.npos||KIH_pos>1||(KIH_pos==1&&S[0]!='A')){
		cout<<"NO";
	}else if((((B_pos1=S.find("BAR",KIH_pos+3))==S.npos)&&((B_pos2=S.find("BR",KIH_pos+3))==S.npos))||(((B_pos=B_pos1==S.npos?B_pos2:B_pos1)-KIH_pos-2)>2)||(S[B_pos-1]!='A'&&S[B_pos-1]!='H')){
//		cerr<<"B_POS - K POS "<<B_pos<<" "<<KIH_pos<<" "<<B_pos-KIH_pos-2<<"\n";
//		if((S[B_pos-1]!='A'&&S[B_pos-1]!='H')) cerr<<" FAIL LAST\n";
		cout<<"NO";
	}else{
		cerr<<"B_POS - K POS "<<B_pos<<" "<<KIH_pos<<"\n";
		cout<<"YES";
	}
	cout<<"\n";
	return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;

V<V<int> > g;
V<int> ans;

void dfs(int v, int i = -1){
    for(auto next_v : g[v]){
        if(next_v == i) continue;
        ans[next_v] += ans[v];
        dfs(next_v, v);
    }
}

int main() {
    int n, q; cin >> n >> q;
    g.resize(n);
    for(int i = 0; i < n - 1; i++){
        int a, b; cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ans.resize(n);
    for(int i = 0; i < q; i++){
        int p, x; cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    for(int i = 0; i < n; i++){
        if(i != n - 1) cout << ans[i] << " ";
        else cout << ans[i] << endl;
    }
}


Measured memory_bytes: 23552
n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))

a_set = set(a)
a_counts = {}

for elem in a:
    if not elem in a_counts:
        a_counts[elem] = 0
    a_counts[elem] += 1

a_counts = sorted(a_counts.items(), key=lambda x: x[1])

ball_to_replace = len(a_set) - k

result = 0
if ball_to_replace > 0:
    for i in range(ball_to_replace):
        result += a_counts[i][1]
print(result)


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

int main()
{
    string S; cin >> S;
    ll ans = 0;
    for(int bit = 0; bit < (1<<(S.size()-1)); bit++)
    {
        int scnt = 0;
        for(int i = 0; i < S.size() - 1; i++)
        {
            if(bit & (1 << i))
            {
                ans += stoll(S.substr(scnt,i - scnt + 1));
                scnt = i + 1;
            }
        }
        ans += stoll(S.substr(scnt,S.size()-scnt));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
int N, C;
const int MX = 1e5;
int s[MX], t[MX], c[MX];
int sm[2*MX + 2];
int tt[2*MX + 2];
int main()
{
    scanf("%d %d", &N, &C);
    for(int i = 0; i < N; ++i) 
        scanf("%d %d %d", &s[i], &t[i], &c[i]);
    for(int i = 1; i <= C; ++i) {
        for(int j = 0; j <2*MX + 2; ++j) tt[j] = 0;
        for(int j = 0; j < N; ++j) if(c[j] == i) tt[s[j]*2 - 1]++, tt[t[j]*2]--; //時刻sを含み、時刻tを除くと問題文にある
        for(int j = 1; j < 2*MX + 2; ++j) tt[j] += tt[j-1]; //累積和
        for(int j = 0; j < 2*MX + 2; ++j) if(tt[j] > 0) sm[j]++;
    }
    int mx = 0;
    for(int j = 0; j < 2*MX + 2; ++j) if(mx < sm[j]) mx = sm[j];
    printf("%d\n", mx);
}

Measured memory_bytes: 2944
n = int(input())
r = 100
s = [0] * (r+1)
w = 0
for i in range(r+1):
    mod = 2 ** (i+1)
    if n % mod == w % mod:
        s[i] = 0
    else:
        s[i] = 1
    w += s[i] * (-2)**i
    if w == n:
        break

print(int("".join(map(str, reversed(s)))))


Measured memory_bytes: 3060