akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
const int eps = 1e9;

const int MAX = 2e5 + 5;
int wn[MAX];
ll res[10][20][20];
int cnt5[MAX], cnt2[MAX];
int main()
{
	boost;
	int n, i;
	cin >> n;
	string s;
	memset(res, 0, sizeof res);
	fo(i, 0, n) {
		cin >> s;
		int c = 0;
		for(int j = s.size() - 1; j >= 0; j--) {
			if(s[j] == '.') break;
			c++;
		}
		wn[i] = (c == s.size() ? 0 : c); 
		ll x = 0;
		for(char c : s) {
			if(c == '.') continue;
			x = x * 10 + (c - '0');
		}
		
		int c2 = 0, c5 = 0;
		while(x % 2 == 0) {
			c2++;
			x /= 2;
		} 
		while(x % 5 == 0) {
			c5++;
			x /= 5;
		} 
		if(c2 > 19) c2 = 19;
		if(c5 > 19) c5 = 19;
		
		cnt2[i] = c2;
		cnt5[i] = c5; 
		res[wn[i]][c5][c2]++;
	}
	
	for(i = 0; i < 10; i++) {
		for(int j = 0; j < 20; j++) {
			for(int k = 1; k < 20; k++)
			res[i][j][k] += res[i][j][k - 1];
		}
	}
	
	ll ans = 0;
	fo(i, 0, n) {
		for(int j = 0; j < 10; j++) {
			int dec = wn[i] + j;
			int curr5 = cnt5[i], curr2 = cnt2[i];
			
			int st = max(0, dec - curr5);
			int need2 = max(0, dec - curr2);
			for(int k = st; k < 20; k++) {
				if(need2 == 0) ans += res[j][k][19];
				else ans += res[j][k][19] - res[j][k][need2 - 1];
			}
		}
		if(min(2 * cnt2[i], 2 * cnt5[i]) >= 2 * wn[i]) --ans;
	}
	cout << ans / 2;
}


Measured memory_bytes: 6028
#include <stdio.h>

#define Mod 100003

typedef struct List {
	struct List *next;
	int x, y, count;
} list;

int main()
{
	int i, H, W, N, a[100001], b[100001];
	scanf("%d %d %d", &H, &W, &N);
	for (i = 1; i <= N; i++) scanf("%d %d", &(a[i]), &(b[i]));
	
	int h, j, k, m;
	list *hash[Mod] = {}, d[900001], *p;
	for (i = 1, m = 0; i <= N; i++) {
		for (j = -1; j <= 1; j++) {
			if (a[i] + j <= 1 || a[i] + j >= H) continue;
			for (k = -1; k <= 1; k++) {
				if (b[i] + k <= 1 || b[i] + k >= W) continue;
				h = (int)(((long long)(a[i] + j) * 10007 + (long long)(b[i] + k) * 30011) % Mod);
				for (p = hash[h]; p != NULL; p = p->next) if (p->y == a[i] + j && p->x == b[i] + k) break;
				if (p != NULL) p->count++;
				else {
					d[m].y = a[i] + j;
					d[m].x = b[i] + k;
					d[m].count = 1;
					d[m].next = hash[h];
					hash[h] = &(d[m++]);
				}
			}
		}
	}
	
	long long ans[10] = {(long long)(H - 2) * (W - 2)};
	for (i = 0; i < Mod; i++) {
		for (p = hash[i]; p != NULL; p = p->next) {
			ans[0]--;
			ans[p->count]++;
		}
	}
	
	for (i = 0; i < 10; i++) printf("%lld\n", ans[i]);
	fflush(stdout);
	return 0;
}

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

int main() {
	long long x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	long long n=x/d;
	if(n>k) cout<<x-k*d;
	else {
		x=x%d;
		k-=n;
		for(int i=0; i<k%2; i++) {
			x=min(abs(x-d),abs(x+d));
		}
		cout<<x<<endl;
	}
	return 0;
}


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

namespace ConsoleApp15
{
    class Class372
    {
        static void Main()
        {
            string S = Console.ReadLine();
            int Q = int.Parse(Console.ReadLine());

            LinkedList<char> link = new LinkedList<char>(S);

            bool dir = false;
            for (int i = 0; i < Q; i++)
            {
                var query = Console.ReadLine().Split();
                if (query[0] == "1") dir = !dir;
                if (query[0] == "2")
                {
                    if ((query[1] == "1" && !dir) || (query[1] == "2" && dir))
                        link.AddFirst(query[2][0]);
                    else
                        link.AddLast(query[2][0]);
                }
            }

            if (dir) link = new LinkedList<char>( link.Reverse());

            Console.WriteLine(string.Join("",link));
        }
    }
}


Measured memory_bytes: 48664
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
int dp[100000];
int w[100],v[100];
main(){
	int n,weight,total=0;
	cin>>n>>weight;
	for(int i=0;i<n;i++)cin>>w[i]>>v[i];
	for(int i=0;i<n;i++)total+=v[i];
	for(int i=1;i<=total;i++)dp[i]=INF;
	for(int i=0;i<n;i++){
		for(int j=total;j>0;j--){
			if(j<v[i])continue;
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
		}
	}
	for(int i=total;i>0;i--){
		if(dp[i]<=weight){
			cout<<i<<"\n";
			break;
		}
	}
}

Measured memory_bytes: 640
import java.util.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      String temp;
      Scanner sc = new Scanner(System.in);
      temp = sc.nextLine();
      String[] ab = temp.split(" ",0);       
      int a = Integer.parseInt(ab[0]);
      int b = Integer.parseInt(ab[1]);
      
      
      if(a == b){
         System.out.println("a == b");
      }else if(a > b){
         System.out.println("a > b");
      }else{
         System.out.println("a < b");
      }
      
      
      
      
      
           
   }//main method
   
         
}//class

Measured memory_bytes: 26264
# Partition
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/6/ALDS1_6_B

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

def partiton(A, p, r):
	x = A[r]
	i = p - 1
	for j in range(p, r):
		if A[j] <= x:
			i += 1
			A[i], A[j] = A[j], A[i]
	A[i + 1], A[r] = A[r], A[i + 1]
	return i + 1

idx = partiton(A, 0, n - 1)

for i in range(n):
	if i == idx:
		A[i] = '[' + str(A[idx]) + ']'

print(*A)


Measured memory_bytes: 16384
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

const int N=2005;
const int mod=1e9+7;
int n,k,dp[N][N];
int fac[N*N],inv[N*N],infac[N*N];

namespace MATHEMATICS
{
	int add(int x,int y)
	{
		int ret=x+y;
		if(ret>=mod) ret-=mod;
		return ret;
	}
	int mi(int x,int y)
	{
		int ret=x-y;
		if(ret<0) ret+=mod;
		return ret;
	}
	
	void inc(int &x,int y)
	{
		x+=y;
		if(x>=mod) x-=mod;
	}
	void dec(int &x,int y)
	{
		x-=y;
		if(x<0) x+=mod;
	}
	
	int mul(int x,int y)
	{
		return 1LL*x*y%mod;
	}
}
using namespace MATHEMATICS;

int C(int x,int y)
{
	return mul(fac[x],mul(infac[y],infac[x-y]));
}

int main()
{
	int i,j;
	scanf("%d%d",&n,&k);
	if(k==1)
	{
		printf("%d\n",1);
		return 0;
	}
	fac[0]=1;for(i=1;i<=n*k;++i) fac[i]=mul(fac[i-1],i);
	inv[1]=1;for(i=2;i<=n*k;++i) inv[i]=mul(inv[mod%i],mod-mod/i);
	infac[0]=1;for(i=1;i<=n*k;++i) infac[i]=mul(infac[i-1],inv[i]);
	
	dp[0][0]=1;
	for(i=0;i<=n;++i)
		for(j=i;j<=n;++j)
		{
			if(i) inc(dp[i][j],dp[i-1][j]);
			if(j) inc(dp[i][j],mul(dp[i][j-1],C(i+(j-1)*(k-1)+k-2,k-2)));
		}
	printf("%d\n",mul(dp[n][n],fac[n]));
	
	return 0;
}

Measured memory_bytes: 62464
#include <iostream>

#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

#include <cmath>
#include <algorithm>

#include <fstream>

using namespace std;


const long long INF = 1e9;
using LD = long double;
using LL = long long;
vector < LL > w;
vector < vector < int > > g;
bool ok = true;

LL dfs(int v, int p) {
    if (g[v].size() == 1 && p != -1) {
        return w[v];
    }
    LL mx = 0;
    LL ans = 0;
    for (auto to: g[v]) {
        if (to == p) {
            continue;
        }
        auto res = dfs(to, v);
        ans += res;
        mx = max(mx, res);
    }
    if (w[v] * 2 < ans) {
        ok = false;
    }
    LL x = w[v] * 2 - ans;
    if (p == -1 && g[v].size() == 1) {
        x -= w[v];
        return x;
    }
    if ( (ans - x) % 2 != 0) {
        ok = false;
    }
    LL y = (ans - x) / 2;
    if (y < 0) {
        ok = false;
    }
    LL mxy = min(ans/2, ans - mx);
    if (y > mxy) {
        ok = false;
    }
    //cout << v << " " << x << " " << y << " " << mxy << endl;

    return x;
}

int main()
{
    //ifstream cin ("/Users/Roman/ClionProjects/Calculations/input.txt");
    //ofstream cout ("/Users/Roman/ClionProjects/Calculations/output.txt");

    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    cout.setf(ios_base::fixed);
    cout.precision(10);
    srand(179);
    LL n;
    cin >> n;
    w.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i];
    }
    vector < vector < int > > gr(n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        gr[a].push_back(b);
        gr[b].push_back(a);
    }
    g = gr;
    auto ans = dfs(0, -1);
    if (ok && ans == 0) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}

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

//const long double pi = 3.14159265358979323846;
#define pi 3.14159265358979323846264338327950L

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long double a, b, h, m;
    cin >> a >> b >> h >> m;

    long double ang = 0;
    long double ang_hr = 0;
    long double ang_min = 0;

    ang_hr = 30*(h+((long double)m/60));
    ang_min = 6*m;
    ang = (long double)abs(ang_hr - ang_min);

    //if(ang > 180) ang = (long double) (ang - 180);

    long double ans = 0;

    ans = (long double)(a*a + b*b);
    ans= (long double)ans - (long double)(2*a*b*cosl((long double)(ang*pi)/180));
    //ans= (long double)ans - (long double)(2*a*b*cosl((long double)(ang*pi)/(long double)180));

    cout << fixed << setprecision(20) << sqrtl(ans) << endl;
    return 0;
}



Measured memory_bytes: 4116
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    ll a;
    double b;
    ll b_modified;
    ll ans = 1;
    cin >> a >> b;

    b_modified = lround(b*100);

    ans = (a*b_modified) / 100;

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

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

using namespace std;
   
        
      


    void solve(){
         int n, w ;
         cin>>n>>w;
         vector<pair<int,int> >values(n);
         
         for(int i = 0; i < n;++i) cin>>values[i].second>>values[i].first;

        int sum = 0;
        sort(values.begin(),values.end());
         for(pair<int,int> x : values) sum += x.first;
         vector<long long > dp (sum+1,(long long)1e18);
         dp[0] = 0;
         for(int i = 0;i<n;++i){
             for(int temp = sum - values[i].first;temp>=0;--temp){
                    
                        dp[temp + values[i].first ] = min(dp[temp + values[i].first ], dp[temp] + values[i].second);
                    
             }
         }    
         int an = 0;
            for(int i = 0;i<=sum;++i){
                if(dp[i]<=w) an = i;
            }

        
        cout<<an<<'\n';
    }

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int tc = 1;
    //cin>>tc;
    while (tc--)
    {
        solve();
    }
    
    return 0;
}

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

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    if (v.empty()) {
        ostr << "{ }";
        return ostr;
    }
    ostr << "{" << v.front();
    for (auto itr = ++v.begin(); itr != v.end(); itr++) {
        ostr << ", " << *itr;
    }
    ostr << "}";
    return ostr;
}

int main(void){

  int n;
  cin >> n;

  vector<int> p(n);
  for (int i = 0; i < n; i++){cin >> p[i];}

  int res = 0;

  for (int i = 1; i < n - 1; i++){
    if (p[i-1] < p[i] and p[i] < p[i+1]){res++;}
    else if (p[i+1] < p[i] and p[i] < p[i-1]){res++;}
  }


  cout << res << endl;

  return 0;
}



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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  vector<int> a(3);
  cin >> a;
  sort(a);
  cout << (a[0] == a[1] ? a[2] : a[0]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  long long count=0;
  
  cin>>n;
  cin>>k;
  
  if(n<=k){
    cout<<0<<endl;
    return 0;
  }
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  for(int i=0;i<n-k;i++){
    count+=h[i];
  }
    cout<<count<<endl;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] n = new int[a];

		for (int i = 0; i < a; i++) {
			n[i] = sc.nextInt();
		}
		Arrays.sort(n);
		int sum = 0;
		for (int i = 0; i < a - 1; i++) {
			sum += n[i];
		}
		if (n[a - 1] < sum) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 35756
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define fi first
#define se second
#define mem(a, b) memset(a, b, sizeof(a))
#define pi acos(-1)
#define pb push_back
using namespace std;
const int maxn = 1e5+5;
const ll mod = 1e9+7;
int n, m;
int a[maxn];
int f[maxn];
int find(int x){
    return x == f[x] ? x : f[x] = find(f[x]);
}
int main(){
//    freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 0; i < maxn; i++) f[i] = i;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u = find(u);
        v = find(v);
        if(u != v){
            f[u] = v;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(find(i) != find(a[i])) ans++;
    }
    cout <<n- ans << endl;
    return 0;
    
}







Measured memory_bytes: 1024
#include <stdio.h>

int main(void){

  int n, x, y, b, p, a, c;
  int i, xx, yy, co;
  int gokei[365];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d%d%d%d", &x, &y, &b, &p);
    xx = x * 0.8;
    yy = y * 0.8;
    if((b > 4) && (p > 1)){
      co = 1;
    }
    gokei[i] = x * b + y * p;
    a = x * 5 + y * p;
    if(((b < 5) && (p > 1)) && (gokei[i] > a*0.8)){
      gokei[i] = a*0.8;
    }
    c = x * b + y * 2;
    if((p < 2) && (b > 4)){
      if(gokei[i] > c*0.8){
	gokei[i] = c*0.8;
      }
    }
    if(co == 1)gokei[i] = xx * b + yy * p;
    co = 0;
  }

  for(i = 0; i < n; i++){
    printf("%d\n", gokei[i]);
  }
  return 0;
}

Measured memory_bytes: 604
//B

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

int main(){
    int K,X; cin >> K >> X;
    for(int i=X-K+1; i<= X+K-1; i++){
        cout << i;
        if(i != X+K-1) cout << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        string input = Console.ReadLine();
        List<int> list = new List<int>();
        list.Add(1);
        char chainc = input[0];
        input = input.Substring(1);
        foreach (var c in input)
        {
            if (c == chainc)
            {
                list[list.Count - 1]++;
            }
            else
            {
                list.Add(1);
                chainc = c;
            }
        }
        int sum = 0;
        double border = (double)(input.Length + 1) / 2;
        foreach (var i in list)
        {
            if (sum <= border && sum + i >= border)
            {
                int result = Math.Min(input.Length + 1 - sum, sum + i);
                Console.WriteLine(result);
                break;
            }
            sum += i;
        }
    }
}

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

int square(int x){
	int res = -1;
	for(int i=0; i*i<=x; ++i)
		if(i*i == x)
			res = i;
	return res;
}

void solve(int n){
	int ans = 0;
	for(int i=0; i*i<=n; ++i)
		for(int j=i; i*i+j*j<=n; ++j)
			for(int k=j; i*i+j*j+k*k<=n; ++k)
				if(square(n-i*i-j*j-k*k) >= k){
					++ans;
//					cout << i << " " << j << " " << k << "\n";
				}
	cout << ans << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int n;
		cin >> n;
		if(n == 0) return 0;
		solve(n);
	}
}


Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
    int main(){
        int N;cin>>N;
        vector<int> a(N);
        for(int i=0;i<N;i++)cin>>a[i];
        int ans=1;
        int saisyou=a[0];
        for(int i=1;i<N;i++){
            if(a[i]<=saisyou){
                ans++;
                saisyou=a[i];
            }
        }
        cout<<ans<<endl;
    }
        






Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#define US unsigned short
#define UI unsigned int
#define UC unsigned char
#define UL unsigned long
using namespace std;

int main(int argc, char const *argv[])
{
    UL n, out = ULONG_MAX;
    cin >> n;

    for (UL i = 1; i * i <= n; i++)
    {
        UL t = (n / i) + i - 2;
        if (n % i == 0 && out > t)
            out = t;
    }

    cout << out << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <functional>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long lint;

template<class S = lint>
struct Edge {
	int to;
	S cost;
	Edge() {}
	Edge(int to, S cost) : to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T = lint>
vector<T> Dijkstra(vector<vector<Edge<T>>> &edges, int st) {

	int V = (int)edges.size();
	const int INF = numeric_limits<T>::max();
	vector<T> dist(V, INF);
	dist[st] = 0;

	priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> p_que;
	p_que.emplace(dist[st], st);

	while (!p_que.empty()) {

		Edge<T> now(p_que.top().to, p_que.top().cost);
		p_que.pop();

		if (dist[now.to] < now.cost) continue;
		for (const Edge<T> &e : edges[now.to]) {
			T tmp_cost = now.cost + e.cost;
			if (dist[e.to] > tmp_cost) {
				dist[e.to] = tmp_cost;
				p_que.emplace(e.to, dist[e.to]);
			}
		}
	}

	return dist;
}

int main() {

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

	int N;
	cin >> N;

	int u, v, len;
	vector<vector<Edge<int>>> edges(N);
	for (int i = 0; i < N - 1; i++) {
		cin >> u >> v >> len;
		edges[u - 1].emplace_back(v - 1, len % 2);
		edges[v - 1].emplace_back(u - 1, len % 2);
	}

	auto ans = Dijkstra(edges, 0);

	for (const auto& i : ans) {
		if (i % 2) cout << '1' << "\n";
		else cout << '0' << "\n";
	}

	return 0;
}


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

int main(){
    ll n,hoge[5],neck,ans;
    cin >> n;
    for(int i = 0; i < 5;i++){
        cin >> hoge[i];
    }
    neck = 10000000000000001;
    for(int i = 0; i < 5; i++){
        neck = min(neck,hoge[i]);
    }
    ans = 5 + (n-1) / neck;
    cout << ans << endl;

}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

struct ST
{
	vector<int> node;
	int N;

	ST(int sz)
	{
		N = 1;
		while (N < sz)N *= 2;
		node.resize(2 * N - 1, INF);
	}

	ST(int* a, int sz)
	{
		N = 1;
		while (N < sz)N *= 2;
		node.resize(2 * N - 1, INF);

		rep(i, 0, sz)node[N - 1 + i] = a[i];
		rrep(i, 0, N - 1)node[i] = min(node[2 * i + 1], node[2 * i + 2]);
	}

	ST(vector<int> a)
	{
		N = 1;
		while (N < SZ(a))N *= 2;
		node.resize(2 * N - 1, INF);

		rep(i, 0, SZ(a))node[N - 1 + i] = a[i];
		rrep(i, 0, N - 1)node[i] = min(node[2 * i + 1], node[2 * i + 2]);
	}

	void update(int i, int a)
	{
		node[N - 1 + i] = a;
		int k = N - 1 + i;
		while (k > 0)
		{
			k = (k - 1) / 2;
			node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	int query(int a, int b, int k, int l, int r = -1)
	{
		if (r == -1)r = N;
		if (b <= l || r <= a)
		{
			return INF;
		}
		if (a <= l&&r <= b)
		{
			return node[k];
		}
		else
		{
			return min(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));
		}
	}
};

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

	int N;
	cin>>N;
	vector<int> H(N),A(N);
	rep(i,0,N)
	{
		cin>>H[i];
		H[i]--;
	}
	rep(i,0,N)cin>>A[i];
	ST st(N);
	vector<int> DP(N+1,0);

	rep(i,0,N)
	{
		int s=-st.query(0,H[i],0,0);
		if(s==-INF)s=0;
		DP[i]=s+A[i];
		st.update(H[i],-DP[i]);
	}

	int ans=0;
	rep(i,0,N)chmax(ans,DP[i]);

	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 9088
n = int(input())
x = input()

dp = [0] * n
for i in range(1, n-1):
    tmp = i
    cnt = 0
    while tmp > 0:
        cnt += tmp % 2
        tmp //= 2
    dp[i] = dp[i%cnt] + 1

c = x.count('1')

if c == 1:
    dp_2 = [0] * n
    dp_2[0] = 1 % (c + 1)
    for i in range(1, n):
        dp_2[i] = (2 * dp_2[i-1]) % (c + 1)

    mod_2 = 0
    for i in range(n):
        if x[i] == '1':
            mod_2 = (mod_2 + dp_2[n-i-1]) % (c + 1)

    for i in range(n):
        if x[i] == '1':
            print(0)
        else:
            mod = (mod_2 + dp_2[n-i-1]) % (c + 1)
            print(dp[mod] + 1)
else:
    dp_1 = [0] * n
    dp_2 = [0] * n
    dp_1[0] = 1 % (c - 1)
    dp_2[0] = 1 % (c + 1)
    for i in range(1, n):
        dp_1[i] = (2 * dp_1[i-1]) % (c - 1)
        dp_2[i] = (2 * dp_2[i-1]) % (c + 1)

    mod_1 = 0
    mod_2 = 0
    for i in range(n):
        if x[i] == '1':
            mod_1 = (mod_1 + dp_1[n-i-1]) % (c - 1)
            mod_2 = (mod_2 + dp_2[n-i-1]) % (c + 1)

    for i in range(n):
        if x[i] == '1':
            mod = (mod_1 - dp_1[n-i-1]) % (c - 1)
            print(dp[mod] + 1)
        else:
            mod = (mod_2 + dp_2[n-i-1]) % (c + 1)
            print(dp[mod] + 1)

Measured memory_bytes: 78564
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] S = new String[n];
		for(int i=0; i<n; i++){
			S[i]  = sc.next();
		}
		
		for(int i=0; i<n; i++){
			S[i]  = "0" + S[i] +"0";
		}

		String alphabet1 = "abcdefghijklmnopqrstuvwxyz";
		String[] alphabet2 = alphabet1.split("");

		String[] sp;
		int[] min = new int[alphabet2.length];
		int[] count = new int[alphabet2.length];
		for(int j=0; j<alphabet2.length; j++){
			min[j] = 50;
			for(int i=0; i<n; i++){
				sp = S[i].split(alphabet2[j]);
				count[j] = sp.length -1;
				if(min[j]>count[j]){
					min[j] = count[j];
				}
			}
		}
		
		for(int j=0; j<alphabet2.length; j++){
			for(int i=0; i<min[j]; i++){
				System.out.print(alphabet2[j]);
			}
		}
		

	}

}


Measured memory_bytes: 22356
#pragma GCC optimize("O2")
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
#include <iomanip>
#include <bitset>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
 
/////////////////////////////////////////////
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
///////////////////////////////
#define int long long

void solve(){

	int x , n;
	cin>>x>>n;
	set<int> s;
	for(int i = 0 ; i < n ; ++i){
		int x;
		cin>>x;
		s.insert(x);
	}
	int ans = 1e9;
	int val = -1;
	for(int i = -300 ; i <= 300 ; ++i){

		if(s.find(i)!=s.end())
			continue;

		int k = abs(i - x);

		if(k < ans){

			ans = k;
			val = i;
		}
	}

	cout<<val<<endl;


}
 
signed main(){
 
	fast;
	int t = 1;
	//cin>>t;
	for(int i = 1 ; i <= t ; ++i)
		solve();
}

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

int main(){
  string S;
  cin >> S;
  int len = S.length();
  for(int i = 0; i < len; i++){
    int cnt = count(S.begin(), S.end(), S[i]);
    if(cnt == 1) continue;
    else{
      cout << "no";
      return 0;
    }
  }
  cout << "yes";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	scanf("%d",&n);
	ll temp;
	int num3=0;
	int num2=0;
	int num1=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&temp);
		if(temp%4==0)
		{
			num1++;
		}
		else if(temp%2==0)
		{
			num2++;
		}
		else
		{
			num3++;
		}
	}
	if(num2)
	{
		num2=1;
	}
	if(num1>=(num2+num3-1))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

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


Measured memory_bytes: 23764
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    ws = [S() for _ in range(n)]
    s = set(ws)
    if len(s) != n:
        return 'No'
    for i in range(n-1):
        if ws[i][-1] != ws[i+1][0]:
            return 'No'

    return 'Yes'


print(main())


Measured memory_bytes: 7748
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int A = in.nextInt();
			int B = in.nextInt();
			String S = in.next();
			String ans = "Yes";
			if(S.charAt(A) != '-') {
				ans = "No";
			}
			for(int i = 0; i < S.length(); i++) {
				if(!Character.isDigit(S.charAt(i)) && i != A) {
					ans = "No";
					break;
				}
			}
			out.println(ans);
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


Measured memory_bytes: 23380
// Lec10-A Distance
#include<iostream>
#include<cmath>
#include<iomanip>
int main(){
  double x1, y1, x2, y2;
  std::cin >> x1 >> y1 >> x2 >> y2;
  std::cout << std::fixed << std::setprecision(8) << sqrt(pow(x1-x2,2)+pow(y1-y2,2)) << std::endl;
  return 0;
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#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 true;}return false;}

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
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1

max_val = max(dic.values()) 

for w in sorted(dict(filter(lambda x: x[1] == max_val, list(dic.items()))).keys()):
    print(w)

Measured memory_bytes: 66140
# B - Buffet
def main():
    _ = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    cnt = 0
    flg = a[0]

    for i in a:
        if flg == i - 1:
            cnt += c[flg-1]
        cnt += b[i-1]
        flg = i
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9128
let () =
  let rec read () =
    try let l = read_line () |> Str.split (Str.regexp " ")
                   |> List.map float_of_string |> Array.of_list in
        let xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = l.(0),l.(1),l.(2),l.(3),l.(4),l.(5),l.(6),l.(7) in
        if (xb1 > xa2) || (xb2 < xa1) || (yb1 > ya2) || (yb2 < ya1) then
          print_endline "NO"
        else
          print_endline "YES"
        ;read ()
    with End_of_file -> ()
  in read ()
;;

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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
        int x1, y1, x2, y2, x3, y3, x4, y4;
        cin >> x1 >> y1 >> x2 >> y2;
        x4 = (x1 - (y2 - y1));
        y4 = ((x2 - x1) + y1);
        x3 = x4 + (x2 - x1);
        y3 = y4 + (y2 - y1);
        cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}

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


Measured memory_bytes: 3640
a11,a12,a13=map(int,input().split())
a21,a22,a23=map(int,input().split())
a31,a32,a33=map(int,input().split())

if a22!=a21+a12-a11:
    print('No')
elif a23!=a21+a13-a11:
    print('No')
elif a32!=a31+a12-a11:
    print('No')
elif a33!=a31+a13-a11:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,a,b,c,d;
  cin>>N;
  a=N/1000;
  b=N%1000/100;
  c=N%100/10;
  d=N%10;
  if ((a==b && b==c)||(b==c && c==d)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define fr(i,a,b) for (long long int i = (a), _b = (b); i <= _b; i++)
// #define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
 
// #define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
// #define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
// #define fill(ar,val) memset(ar, val, sizeof(ar))
// #define fill0(ar) fill((ar), 0)
// #define fillinf(ar, n) fr(i,0,(n)) ar[i] = INF
// #define debug(x) cout<<#x<<": "<<x<<endl
// #define arr1d(a,n) cout << #a << " : "; fr(,1,n) cout << a[] << ' '; cout << endl;
// #define arr1d0(a,n) cout << #a << " : "; rep(,n) cout << a[] << ' '; cout << endl;
// #define arr2d(a,n,m) cout << #a << " :" << endl; fr(,1,n) {fr(,1,m) cout << a[][__] << ' '; cout << endl;}
// #define arr2d0(a,n,m) cout << #a << " :" << endl; rep(,n) {rep(,m) cout << a[][__] << ' '; cout << endl;}
// #define ull unsigned long long
// #define ll long long int
// #define ld double
// #define ui unsigned int
// #define all(ar) ar.begin(), ar.end()
// #define pb push_back
// #define mp make_pair
// #define ff first
// #define ss second
 
 
// #define PI 3.1415926535897932385
// #define INF 1000111222
// #define EPS 1e-7
// #define MAXN 1000001
// #define MOD 998244353
 
 
//  #include<iostream>
//      #include<vector>
// #include <stdio.h>
// #include<algorithm>
// #include<math.h>
// #include <iomanip>  
// #include <algorithm> 
// #include<bits/stdc++.h>
// #include <iterator>
// using std::string;
// //#include <boost/algorithm/string.hpp> 
#include<bits/stdc++.h>
#include<ratio>
#include <set> 
#include <iterator>
using namespace std;
#define ll long long
#define VV vector
#define vi vector <int>
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 100001
#define eps 0.0000000001
#define prime 1000000007
#define ll long long
using namespace std;
#define S second
#define F first
ll MOD=1e9+7;
#define rep(i,n) for (long long i = 0, _n = (n); i < _n; i++)
long long StringToInteger(string NumberAsString)
{
  long long NumberAsInteger;
  stringstream ss;
  ss << NumberAsString;
  ss >> NumberAsInteger;
  return NumberAsInteger;
}
vi lasta(MAXN);
vi lastb(MAXN);
vi lastc(MAXN);
 int32_t main()
{   
        int n;
        cin>>n;
        vi as(n);
        vi bs(n);
        vi cs(n);
        for(int i=0;i<n;i++)
        {
            cin>>as[i]>>bs[i]>>cs[i];  
        }
        lasta[0]=as[0];
        lastb[0]=bs[0];
        lastc[0]=cs[0];
        for(int i=1;i<n;i++)
        {
            lasta[i]=max(lastb[i-1]+as[i],lastc[i-1]+as[i]);
            lastb[i]=max(lasta[i-1]+bs[i],lastc[i-1]+bs[i]);
            lastc[i]=max(lastb[i-1]+cs[i],lasta[i-1]+cs[i]);
        }
        int maxi=lasta[n-1];
        maxi=max(maxi,lastb[n-1]);
        maxi=max(maxi,lastc[n-1]);
        cout<<maxi;
    return 0;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main(void) {
    double R;
    cin >> R;

    printf("%.10lf\n", 2*R * M_PI);
}

Measured memory_bytes: 3772
#include <iostream>
using namespace std;
int main(){
        int n;
        cin >>n;
        int c[n]; int s[n]; int f[n];
        for(int i=1; i<=n-1; i++) {
                cin >>c[i] >> s[i] >> f[i];
        }
        for(int i=1; i<=n; i++) {
                int ans=0;//時刻
                for(int j=i; j<=n-1; j++) {
                        if(ans<s[j]) ans=s[j]; //時刻が駅の始発より前なら始発の時間を入れる
                        else if(ans%f[j]!=0) {//始発以降で時刻にぴったり次の電車が来ない場合
                                ans=(ans+f[j])-(ans%f[j]);//ans-ans%f[j]で時刻の前に行った最新の列車時刻に戻ってからf[j]を足す
                        }
                        ans+=c[j];//電車の所要時間を時刻に足す
                }
                cout << ans << endl;
        }
}


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

using namespace std;

using ll = long long;

const ll INF = 1e18;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<ll> x(n), l(n);
    vector<int> ids(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> l[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i1, int i2){
        return x[i1] + l[i1] < x[i2] + l[i2];
    });

    ll cur = -INF;
    int ans = 0;
    for (int i : ids) {
        if (x[i] - l[i] >= cur) {
            cur = x[i] + l[i];
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

const int MOD { (int)1e9 + 7 };

int main() {
  int N; cin >> N;
  vector<int> T(N); for (int i = 0; i < N; i++) cin >> T[i];
  vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i];

  vector<int> lt(N, 1), la(N, 1);
  vector<int> rt(N), ra(N);
  for (int i = 0; i < N; i++) {
    rt[i] = T[i];
    ra[N - 1 - i] = A[N - 1 - i];
    if (i == 0) {
      lt[0] = T[0];
      la[N - 1] = A[N - 1];
    } else {
      if (T[i - 1] < T[i]) lt[i] = rt[i];
      if (A[N - 1 - i] > A[N - i]) la[N - 1 - i] = ra[N - 1 - i];
    }
  }
  ll ans { 1 };
  for (int i = 0; i < N; i++) {
    int l { max(lt[i], la[i]) }, r { min(rt[i], ra[i]) };
    if (l > r) ans = 0;
    ans = (ans * (r - l + 1)) % MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
p, g = 998244353, 3
def convolve(a, b):
    def fft(f):
        for l in range(k)[::-1]:
            d = 1 << l
            v = W[k-1-l]
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
                u = u * v % p

    def ifft(f):
        for l in range(k):
            d = 1 << l
            v = iW[k-1-l]
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j+d] *= u
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
                u = u * v % p
 
    n0, n1 = len(a), len(b)
    k = (n0 + n1 - 1).bit_length()
    n = 1 << k
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)
    w = pow(g, (p - 1) // n, p)
    W = [w]
    for i in range(k):
        W.append(W[-1] ** 2 % p)
    invw = pow(w, p-2, p)
    iW = [invw]
    for i in range(k):
        iW.append(iW[-1] ** 2 % p)
    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
print(*convolve(A, B))


Measured memory_bytes: 203264
H, W, K = map(int, input().split())
C = [input() for i in range(H)]

col_black = [0] * H
row_black = [0] * W
num_black = 0
for i in range(H):
    for j in range(W):
        if C[i][j]=='#':
            col_black[i] += 1
            row_black[j] += 1
            num_black += 1

ans = 0
for i in range(2**H):
    I = []
    num_i_black = 0
    for ii in range(H):
        if i>>ii & 1:
            I.append(ii)
            num_i_black += col_black[ii]
    for j in range(2**W):
        J = []
        num_j_black = 0
        for jj in range(W):
            if j>>jj & 1:
                J.append(jj)
                num_j_black += row_black[jj]
        
        num = num_i_black + num_j_black
        for ii in I:
            for jj in J:
                num -= C[ii][jj] == '#'
        
        if num_black - num == K:
            ans += 1

print(ans)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n,a,b,c,d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a--;b--;c--;d--;

    // ##があるかチェック
    int breaker = 0;
    for(int x = a;x <= c; x++){
        if(breaker >= 2) break;
        else if(s[x] == '#') breaker++;
        else breaker = 0;
    }
    for(int x = b;x <= d; x++){
        if(breaker >= 2) break;
        else if(s[x] == '#') breaker++;
        else breaker = 0;
    }

    if(c < d){
        if(breaker >= 2) cout << "No" << endl;
        else cout << "Yes" << endl;
    }else{
        int dots = 0;
        for(int x = b-1;x <= d+1; x++){
            if(dots >= 3) break;
            else if(s[x] == '.') dots++;
            else dots = 0;
        }

        if(breaker >= 2) cout << "No" << endl;
        else{
            if(dots >= 3)
                cout << "Yes" << endl;
            else 
                cout << "No" << endl;
        }
    }
}


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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    if ((g*10 + b)%4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
x = []
y = []
for i in range(N):
    a, b = [int(_) for _ in input().split()]
    x.append(a)
    y.append(b)

nx = np.array(x)
ny = np.array(y)
ns = nx + ny
arr = np.array([nx, ny, ns]).T
arr = arr[np.argsort(arr[:, 2])][::-1, :]
n = np.sum(arr[0::2, 0]) - np.sum(arr[1::2, 1])
print(n)

Measured memory_bytes: 27904
a,b,n = map(int, input().split())
"""
floor(ax/b) - a*floor(x/b)
= (ax-(ax)%b)/b - a*(x-x%b)/b
= (a*(x%b)-(ax)%b)/b
"""
def f(x):
    return (a*(x%b)-(a*b)%b)//b

ans = f(min(n,b-1))
print(ans)

Measured memory_bytes: 9084
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define F first
#define S second
#define MK make_pair
const int E=1e9+7;







int main(){
    string s;
    vector<char> a;
    cin>>s;
    int w;
    cin>>w;
    for(int i=0;i<s.size();i++){
        if(i%w==0){
            a.push_back(s[i]);
        }
    }
    for(int i=0;i<a.size();i++){
        cout<<a[i];
    }
    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 256