akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

int main()
{
	cout << setprecision(10);
	cin >> n; 
	vector<string> s(n);
	rep(i,n){
		string S ;
		cin >> S;
		SORT(S);
		s[i] = S;
	}
	SORT(s);
	ll ans = 0;
	ll count = 1 ;
	for(int i = 1 ; i < n ; i ++){
		if(s[i] == s[i-1]){
			count ++ ;
		}else {
			ans += count * ( count - 1 ) / 2;
			count = 1;
		}
	}
	ans += count * (count - 1 ) / 2;
	cout << ans << endl;

}


Measured memory_bytes: 5760
#from enum import Enum
#from queue import Queue
#import collections

#import sys
#import math
#import time

#t1=time.time()
#input = sys.stdin.readline
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


S = input().strip()
# S = str('?'*(10**5))
N = 13

dp =[0]*N
dp[0]=1

mul = 1
reversed_S = S[::-1]
for c in reversed_S:
    nextDP = [0]*N
    if c == '?':
        # print('test')
        # print(mul)
        for k in range(10):
            for j in range(N):
                nextDP[(mul*k+j)%N] += dp[j]
                nextDP[(mul*k+j)%N] %= MOD
    else:
        k = int(c)
        for j in range(N):
            nextDP[(mul*k+j)%N] += dp[j]
            nextDP[(mul*k+j)%N] %= MOD

    mul *= 10
    mul %= N
    dp = nextDP[:]
print(dp[5])
#print(time.time()-t1)


Measured memory_bytes: 43884
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

#include<atcoder/math>
using namespace atcoder;

int q;

int main(){
	cin>>q;
	for(int i=0;i<q;i++){
		ll n,m,a,b;
		cin>>n>>m>>a>>b;
		cout<<floor_sum(n,m,a,b)<<endl;
	}
}

Measured memory_bytes: 3600
n,k=map(int,input().split())
s=input()
l=[[],[]]
l[int(s[0])].append(1)
mae=s[0]
for i in range(1,n):
    if s[i]==mae:
        l[int(s[i])][-1]+=1
    else:
        l[int(s[i])].append(1)
        mae=s[i]
if len(l[0])<=k:
    print(sum(l[0])+sum(l[1]))
else:
    if s[0]=="0":
        l[1]=[0]+l[1]
    if s[-1]=="0":
        l[1]=l[1]+[0]
    cnt=[]
    num0=l[1][0]
    for j in range(k):
        num0+=l[0][j]+l[1][j+1]
        mem=j
    cnt.append(num0)
    for x in range(1,len(l[0])-k+1):
        num=cnt[x-1]+(l[0][mem+x]+l[1][mem+1+x])-(l[0][mem+x-k]+l[1][mem+x-k])
        cnt.append(num)
    print(max(cnt))


Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

int cnt[4];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll K,A,B;cin>>K>>A>>B;
  ll ans = 0;
  if(B-A>2&&K>A-1){
    K -= A-1;
    ans = A;
    ans += (B-A)*(K/2);
    if(K&1){
      ans++;
    }
  }else{
    ans = K+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] num = new int[n];
		for (int i = 0; i < n; i++)
			num[i] = scanner.nextInt();
		
		long[][] dp = new long[n][21];
		dp[1][num[0]] = 1;
		for (int i = 1; i < n-1; i++)
			for (int j = 0; j <= 20; j++) {
				int a = j + num[i];
				int b = j - num[i];
				if (a <= 20)
					dp[i + 1][a] += dp[i][j];
				if (b >= 0)
					dp[i + 1][b] += dp[i][j];
			}
		System.out.println(dp[n-1][num[n-1]]);
	}
}

Measured memory_bytes: 18116
#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cstdlib>

using namespace std;

int main() {
    int s;
    int w;
    cin >> s >> w;
    if (w >=s) {
        cout << "unsafe";
    }
    else{
        cout << "safe";
    }
 }


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int Maxn=1005;
int dis[Maxn][Maxn],n,m,ans;
string str;
const int dx[]={0,0,-1,0,1},dy[]={0,-1,0,1,0};
struct point
{
	int x,y,cnt;
};
queue <point> Qu;
void bfs(void)
{
	while(!Qu.empty())
	{
		point now=Qu.front();
		Qu.pop();
		now.cnt++;
		for(int i=1;i<=4;i++)
		{
			now.x+=dx[i],now.y+=dy[i];
			if(now.x==0||now.x==n+1||now.y==0||now.y==m+1) goto A;
			if(dis[now.x][now.y]==-1)
			{
				Qu.push(now);
				dis[now.x][now.y]=now.cnt;
				ans=max(ans,now.cnt);
			}
		A:	now.x-=dx[i],now.y-=dy[i];
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	memset(dis,-1,sizeof(dis));
	for(int i=1;i<=n;i++)
	{
		cin>>str;
		for(int j=1;j<=m;j++)
			if(str[j-1]=='#') Qu.push((point){i,j,0}),dis[i][j]=0;
	}
	bfs();
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 16272
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n,k;
  cin>>n>>k;
  vecint p(n);
  for(auto&& e:p)cin>>e;
  vecint s(n+1);
  boost::partial_sum(p, begin(s)+1);
  int mx = 0;
  for(auto&& i:irange(0,n-k+1)) {
    mx = max(mx, s[i+k] - s[i] + k);
  }
  double res = mx / 2.0;
  cout<<fixed<<setprecision(10)<<res<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=16;
const int M=1<<N;
const int mod=1e9+7;
void add(int &a, int b)
{ a+=b;if(a>=mod) a-=mod;}
void sub(int &a, int b)
{ a-=b;if(a<0) a+=mod;}
void mul(int &a, int b)
{ a=(ll)a*b%mod;}
struct matrix
{
int a[N][N];
matrix()
{
for(int i=0;i<N;i++)
for(int j=0;j<N;j++)
a[i][j]=0;
}
};
matrix operator * (matrix a, matrix b)
{
matrix c;
for(int i=0;i<N;i++)
for(int j=0;j<N;j++)
for(int k=0;k<N;k++)
add(c.a[i][j],(ll)a.a[i][k]*b.a[k][j]%mod);
return c;
}
ll dp[M],cost[M],a[N][N];
int main()
{
int n;
scanf("%i",&n);
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
scanf("%lld",&a[i][j]);
for(int mask=0;mask<1<<n;mask++)
{
for(int i=0;i<n;i++) if((mask>>i)&1)
for(int j=i+1;j<n;j++) if((mask>>j)&1)
cost[mask]+=a[i][j];
}
for(int mask=0;mask<1<<n;mask++)
{
for(int sub=mask;sub;sub=(sub-1)&mask)
dp[mask]=max(dp[mask],dp[mask^sub]+cost[sub]);
}
printf("%lld",dp[(1<<n)-1]);
return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define fr first
#define sc second
#define ll long long

using namespace std;
const int MN = 1e6+7;
const int MD = 1e9+7;
const ll BIG_INF = 1e18+7;
const int INF = 2147483645;

ll n;
string s[2];

int main()
{
    cin >> n;
    if(n < 2){
        cout << 0;
        return 0;
    }
    if(n & 1){
        cout << 0;
        return 0;
    }
    ll t = 1, re = 0;
    n /= 2;
    while(n >= t){
        t *= 5;
        re += n/t;
    }
    cout << re;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <cstring>
#include <list>
#include <queue>
using namespace std;

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

	string s, t;
	cin>>s;
	cin>>t;
	if (s==t) {
		cout<<"Yes"<<endl;
		return 0;
	}
	for (int i=0; i<s.size(); ++i) {
		if (s==t) {
			cout<<"Yes"<<endl;
			return 0;
		}
		string s2;
		char ch=s.back();
		s2.push_back(ch);
		for (int j=0; j<s.length()-1; ++j)
			s2.push_back(s[j]);
		s=s2;
	}
	cout<<"No"<<endl;
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
  string s; cin >> s;
  vector<int> V(4);
  rep (i,4) V[i] = s[i] - '0';
  rep (bit, 1<<3){
    int sum = V[0];
    rep (i,3){
      if (bit & (1<<i)) sum += V[i+1];
      else sum -= V[i+1];
    }
    if (sum == 7){
      cout << V[0];
      rep (i,3){
        if (bit & (1<<i)) cout << "+" << V[i+1];
        else cout << "-" << V[i+1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    ll a[n];   //同じ数が何個ずつ含まれるか調べる配列
    rep(i, n) {
        cin >> a[i];
    }
    sort(a, a+n); 
    reverse(a, a+n);

    ll tate = 0, yoko = 0, ans;
    int t = a[0];
    int cnt = 0;
    rep(i, n) {
        if(a[i] == t) {
            cnt++;
        }
        else {
            t = a[i];
            cnt = 1;
        }

        if(cnt == 2) {
            if(!tate) {
                tate = a[i];
                cnt = 0;
            }
            else {
                yoko = a[i];
                break;
            }
        }
    }

    ans = tate * yoko;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cstring>

// ---------- PBDS -----------------

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
// slow but fast ORZ :)
// ----------------------------------

using namespace std;
using namespace __gnu_pbds; 

#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(a) a.begin(), a.end()
#define MP(a, b) make_pair(a, b)
#define PB(a) push_back(a)
#define EB(a) emplace_back(a) // care when use
#define boost ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0),cout << fixed << setprecision(10);
// #define ll long long int
#define int long long int

#define DEBUG

#ifdef DEBUG

    #define debug(args...)(Debugger()) , args

    class Debugger{
        public:
        Debugger(const std::string& _separator = " | ") :
        first(true), separator(_separator){}

        template<typename ObjectType> Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std::cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std::cerr << std::endl;}

        private:
        
        bool first;
        std::string separator;
    };

#else
    #define debug(args...)
#endif

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

	std::vector<int> v(n);

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

	int ans = 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(v[i] == v[j] or v[i] == v[k] or v[j] == v[k])
					continue;

				if((v[i] + v[j] > v[k]) and (v[i] + v[k] > v[j]) and (v[k] + v[j] > v[i]))
					ans++;

			}
		}
	}

	cout << ans << "\n";
}


int32_t main(){

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



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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N, M, count, ans=0;
	vector<string> s(101), t(101);
	
	cin >> N;
	
	for(int i=0; i<N; i++)
		cin >> s.at(i);
	
	cin >> M;
	
	for(int i=0; i<M; i++)
		cin >> t.at(i);
	
	for(int i=0; i<N; i++){
		count = 0;
		for(int j=0; j<N; j++){
			if(s.at(i) == s.at(j))
				count++;
		}
		for(int j=0; j<M; j++){
			if(s.at(i) == t.at(j))
				count--;
		}
		ans = max(ans, count);
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
x1 = (a1 - b1) * t1
x2 = (a2 - b2) * t2
if (x1 > 0 and x2 > 0) or (x1 < 0 and x2 < 0) or abs(x1) > abs(x2):
  print(0)
elif x1 + x2 == 0:
  print('infinity')
else:
  diff = x1 + x2
  ans = 1 + abs(x1) // abs(diff) * 2
  if abs(x1) % abs(diff) == 0:
    ans -= 1
  print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int a[7];
    int b[7];
    for(int i = 0; i < 7; i++){
        scanf("%d", &a[i]);
        scanf("%d", &b[i]);
    }
    for(int i = 0; i < 7; i++){
        printf("%d\n", a[i] - b[i]);
    }
    return 0;
}


Measured memory_bytes: 2040
#include<stdio.h>

int main()
{
    int n;
    int x[10000];
    int min,max;
    long sum=0;
    scanf("%d\n",&n);
    for(int i=0;i<=n;i++)
        scanf("%d",&x[i]);
    min=x[0];
    max=x[0];
    for(int i=0;i<n;i++){
        sum+=x[i];
        if(min>x[i]){
            min=x[i];
        }else if(max<x[i]){
            max=x[i];
        }
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2772
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RREP(i,n) for(long long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl
#define dump(x)  cerr << #x << " => " << (x) << endl
#define dumpP(p) cerr << "( " << p.first << " , " << p.second << " )" << ends
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m)  (!(m.find(n) == m.end()))
#define ENUM(m) for (auto itr = m.begin(); itr != m.end(); ++itr)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define ROUND(N) setprecision(N)
#define ROUND_PRINT(N,val) cout << fixed;cout << setprecision(N) << val << endl
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

using namespace std;
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
constexpr short shINF = 32767;
constexpr long loINF = 2147483647;
constexpr long long llINF = 9223372036854775807;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<LL,LL> pr;
typedef vector<pr> VP;
struct Order {
	bool operator() (pr const& a,pr const& b) const {
		return a.first > b.first || ((a.first == b.first) && (a.second > b.second));
	}
};

int main(void){
	long n,m;
	cin >> n >> m;
	VI c(m),dp(n+1,loINF);
	dp[0] = 0;
	REP(i,m) cin >> c[i];
	FOR(i,1,n+1) {
		REP(j,m) {
			if (i - c[j] >= 0) dp[i] = min(dp[i],dp[i-c[j]]+1);
		}
	}
	//dump1d_arr(dp);
	cout << dp[n] << endl;

}





Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<P,P>P2;
int n,w,z,a[2001];
main(){
	cin>>n>>z>>w;
	for(int i=0;i<n;i++)cin>>a[i];
	int p1=abs(a[n-1]-w);
  int p2;
  if(n==1)p2=(-1);
  else p2=abs(a[n-2]-a[n-1]);
  cout<<max(p1,p2)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

int H, W, K;
vector<long long> p;
vector<vector<long long>> DP;
int MOD = 1e9 + 7;

int main() {
	cin >> H >> W >> K;
	p.resize(W + 1,1);
	DP.resize(H + 1, vector<long long>(W + 1,0));
	p[1] = 1;
	if(W >= 2)p[2] = 2;
	for (int w = 3; w <= W; w++)p[w] = (p[w - 1] + p[w - 2])%MOD;
	DP[1][1] = p[W - 1]%MOD;
	if(W >= 2)DP[1][2] = p[W - 2] % MOD;
	for (int h = 2; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			long long temp = 0;
			if (w > 1) {
				temp = (DP[h - 1][w - 1] * p[w - 2]) % MOD;
				temp = (temp * p[W - w]) % MOD;
				DP[h][w] += temp;
			}
			temp = (DP[h - 1][w] * p[w - 1]) % MOD;
			temp = (temp * p[W - w]) % MOD;
			DP[h][w] += temp;
			if (w < W) {
				temp = (DP[h - 1][w + 1] * p[w - 1]) % MOD;
				temp = (temp * p[W - w - 1]) % MOD;
				DP[h][w] += temp;
			}
			DP[h][w] %= MOD;
		}
	}
	cout << DP[H][K] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(s,n) for(int i=s;i<n;i++)
#define inf 10000000000 //1e10
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int32_t main(){
    int n,W;
    cin >> n >> W;
    int wt[n],val[n];
    int resp = 0;
    for(int i=0;i<n;i++){
        cin >> wt[i] >> val[i];
    }
    vector<int> dp(100001,inf);
    dp[0] = 0;
    for(int i=0;i<n;i++)
        for(int j=100000;j>=val[i];j--){
            dp[j] = min(dp[j], dp[j-val[i]] + wt[i]);
            if(dp[j]<=W) resp = max(resp,j);
        }
        
    cout << resp << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
   int cnt, num;
   string mk;
    
   cin >> cnt;
   
   // S, H, C, D
   int card[13][4] = {
            {0, 0, 0, 0},
            {0, 0, 0, 0},
            {0, 0, 0, 0},
            {0, 0, 0, 0},
            {0, 0, 0, 0},
            {0, 0, 0, 0},
            {0, 0, 0, 0},
            {0, 0, 0, 0},
            {0, 0, 0, 0},
            {0, 0, 0, 0},
            {0, 0, 0, 0},
            {0, 0, 0, 0},
            {0, 0, 0, 0},
          };
   
   for(int i=0; i < cnt; i++){
       cin >> mk;
       cin >> num;
      
        if(mk=="S") {
            card[num-1][0] = num;
        }else if(mk=="H"){
            card[num-1][1] = num;
        }else if(mk=="C"){
            card[num-1][2] = num;    
        }else if(mk=="D"){
            card[num-1][3] = num;
        }
   }
   
   for(int k=0; k<4; k++){
       for(int m=0; m<13; m++){
           if(card[m][k]==0){
               if(k==0){
                   cout << "S" << " "<< m+1 << endl;
               }else if (k==1){
                   cout << "H" << " "<< m+1 << endl;
               }else if (k==2){
                   cout << "C" << " "<< m+1 << endl;
               }else if (k==3){
                   cout << "D" << " "<< m+1 << endl;
               }
           }
       }
   }
}



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

#define rep(i, n) for(int i = 0; i < (n); i++)

using namespace std;
using lint = long long;

int main(void)
{
    string S;
    cin >> S;
    int num = 0;
    for(int i = 0; i < S.size()/2; i++){
        if(S[i] != S[S.size()-i-1]){
            num++;
        }
    }  

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       mut s: Chars,
    }

    for i in 0..s.len() {
        if s[i] == '?' {
            s[i] = 'D'
        }
    }

    echo!(s.joinToString(""));
}


Measured memory_bytes: 14172
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println((a + b) % 24)
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

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

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

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

func yesOrNo(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

func yesorNO(b bool) {
	if b {
		reply = "YES"
		fmt.Println(reply)
		return
	}
	reply = "NO"
	fmt.Println(reply)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll N, a,b,c,d; cin >> N >> a >> b >> c >> d;

    for(int i=0; i<N; ++i){
        ll right = a+(N-1-i)*d - i*c;
        ll left = a+(N-1-i)*c - i*d;

        if(left <= b && b <= right){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出,オーバーフローする入力を投げるとよい
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
 
    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str,stra="CODEFESTIVAL2016";
    ll k;
    ll w,x;
    cin>>str;
    rep(i,str.length()){
        if(stra[i]!=str[i]) sum++;
    }
    cout<<sum<<endl;

    return 0;
}


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

class Mondai
{
    static void Main()
    {
        var NM = Console.ReadLine().Split(' ').Select(n => Int64.Parse(n)).ToArray();
        var N = NM[0];
        var M = NM[1];
        var S = Console.ReadLine().Split(' ').Select(n => Int64.Parse(n)).ToArray();
        var T = Console.ReadLine().Split(' ').Select(n => Int64.Parse(n)).ToArray();

        var mod = 1000000007L;
        var dp = new long[N + 1, M + 1];
        dp[0, 0] = 1;

        for (int i = 0; i <= N; ++i)
        {
            for (int j = 0; j <= M; ++j)
            {
                if (0 < i && 0 < j && S[i - 1] == T[j - 1]) dp[i, j] = (dp[i, j] + dp[i - 1, j - 1]) % mod;
                if (0 < i) dp[i, j] = (dp[i, j] + dp[i - 1, j]) % mod;
                if (0 < j) dp[i, j] = (dp[i, j] + dp[i, j - 1]) % mod;
                if (0 < i && 0 < j)
                {
                    var value = dp[i, j] - dp[i - 1, j - 1];
                    while (value < 0) value += mod;
                    dp[i, j] = value % mod;
                }
            }
        }
        Console.WriteLine(dp[N, M]);
    }
}


Measured memory_bytes: 44640
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}




signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    bool fl = true;
    for(auto& x : a){
        cin >> x;
        if(x % 2 == 0 && x % 3 != 0 && x % 5 != 0)
            fl = false;
    }
    cout << (fl ? "APPROVED" : "DENIED") << endl;
    return 0;
}


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

using namespace std;

int main(){
    unsigned long long x;
    cin >> x;

    int i =0;
    unsigned long long money = 100;
    
    

    while(1){
        i++;
        money += money*0.01;
        if(money >= x){
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int n;
	cin>>n;
	if(n==111){
		cout<<"999"<<endl;
	}
	if(n==119){
		cout<<"991"<<endl;
	}
	if(n==191){
		cout<<"919"<<endl;
	}
	if(n==199){
		cout<<"911"<<endl;
	}
	if(n==911){
		cout<<"199"<<endl;
	}
	if(n==919){
		cout<<"191"<<endl;
	}
	if(n==991){
		cout<<"119"<<endl;
	}
	if(n==999){
		cout<<"111"<<endl;
	}
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 3e2 + 5;

ll dp[MAXN][MAXN];
ll c[MAXN][MAXN];
ll dp_sum[MAXN][MAXN];

void solve(){
	int n, K, mod;
	cin >> n >> K >> mod;
	c[0][0] = 1;
	REP(i, 1, MAXN){
		c[i][0] = c[i][i] = 1;
		REP(j, 1, i){
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
		}
	}
	for(int j = K; j >= 0; j--){
		dp[1][j] = 1;
		dp_sum[1][j] = (dp_sum[1][j + 1] + dp[1][j]) % mod;
	}
	REPN(i, 2, n + 1){
		for(int j = K; j >= 0; j--){
			REPN(k, 1, i - 1){
				ll tmp = (c[i - 2][k - 1] * dp[i - k][j]) % mod;
				tmp = (tmp * dp_sum[k][j + 1]) % mod;
				dp[i][j] = (dp[i][j] + tmp) % mod;
			}
			//cout << i << " " << j << " " << dp[i][j] << endl;
			dp_sum[i][j] = (dp_sum[i][j + 1] + dp[i][j]) % mod;
		}
	}
	cout << dp[n + 1][0] << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 2432
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]

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

c = [[0] * (n+1) for i in range(m)]

count = 0
for i in range(1, n+1):
    count += 1
    c[0][i] = count


for i in range(1, m):
    loop = True
    count = 0
    
    for j in range(1, n+1):
        if j - l[i] >= 0:
            if c[i-1][j] > c[i][j-l[i]] + 1:
                c[i][j] = c[i][j-l[i]] + 1
            else:
                c[i][j] = c[i-1][j]
        else:
            c[i][j] = c[i-1][j]


print(c[-1][-1])


Measured memory_bytes: 43220
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v,n) reverse(v,v+n)
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix[i]<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define iP pair<int,P>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

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

	int N,ve[100000],value=INF,msmall=0;
	cin>>N;
	REP(i,N) cin>>ve[i];
	SORT(ve,N);
	int mlarge=ve[N-1];

	REP(i,N-1){
		if(abs(mlarge-ve[i]*2)<=value){
			value=abs(mlarge-ve[i]*2);
			msmall=ve[i];
		}
	}

	print(mlarge,msmall);

	return 0;
}


Measured memory_bytes: 640
def eratosthenes(n):
 is_p=[1]*n
 p_list=[]

 is_p[0]=0
 is_p[1]=0

 for i in range(2,n):
  if is_p[i]:
   p_list.append(i)
   for j in range(i*i,n,i):
    is_p[j] = 0

 return is_p, p_list

lim=10**5+1
is_p, p_list=eratosthenes(lim)

q=int(input())

b=[0]
for i in range(1,lim+1):
 if is_p[i-1] and is_p[i//2]:
  b.append(b[i-1]+1)
 else:
  b.append(b[i-1])

for i in range(q):
 l,r=map(int,input().split())
 print(b[r+1]-b[l])

Measured memory_bytes: 5472
// Problem : A - Kth Term
// Contest : AtCoder - Panasonic Programming Contest 2020
// URL : https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#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;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    vi a({1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51});
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> as(n, 0);
    int N = 0;
    rep(i, n){
        cin >>  as[i];
        N = max(N, as[i]);
    }
    int r = 0;
    int ans;
    rep(i, n){
        int tmp = min(as[i], N - as[i]);
        if(r < tmp){
            ans = as[i];
            r = tmp;
        }
    }
    cout << N << " " << ans << endl;
    return 0;
}


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

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<int> x(n+1);
    x[0] = 0;
    for(int i = 1; i <= n; i ++) {
        if(s[i-1]=='I') x[i] = x[i-1] + 1;
        else x[i] = x[i-1] - 1;
    }
    cout << *max_element(x.begin(),x.end()) << endl;
}

Measured memory_bytes: 256
/*
 ____________________________________________________________
|                                                            |
|                   Author: ay2306                           |
|____________________________________________________________|

*/
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ord_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
const ll maxn = 1e5;

int main(){
    string s;
    cin >> s;
    int a = (s[0]-'0')*10 + (s[1]-'0');
    int b = (s[2]-'0')*10 + (s[3]-'0');
    if(a <= 12 && a > 0 && (b == 0 || b > 12)){
        cout << "MMYY";
        return 0;
    }
    if(b <= 12 && b > 0 && (a == 0 || a > 12)){
        cout << "YYMM";
        return 0;
    }
    if(b <= 12 && b > 0 && a <= 12 && a > 0){cout << "AMBIGUOUS";return 0;}
    cout << "NA";
    return 0;
}

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

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

bool ok[200][200][200][200];
int dp[33000];

int main() {
    int n;
    int a[4];
    ll ans=0;
    int sz = 182;
    int ma = pow(2, 15);
    rep(i, sz) rep(j, sz) rep(k, sz) rep(l, sz) {
        if (i*i + j*j + k*k + l*l <= ma) {
            a[0] = i;
            a[1] = j;
            a[2] = k;
            a[3] = l;
            sort(a, a+4);
            if (!ok[a[0]][a[1]][a[2]][a[3]]) {
                ok[a[0]][a[1]][a[2]][a[3]] = true;
                dp[i*i + j*j + k*k + l*l]++;
            }
        }
        else break;
    }
    while (cin >> n, n) {
        cout << dp[n] << endl;
    }
    return 0;
}



Measured memory_bytes: 70900
#include <iostream>
#include<cmath>
using namespace std;
struct Card{char ehuda,value;};
void arraycout(int *arrayy,int n){
    for(int u=0;u<n;u++){//出力
        if(u==n-1){
            cout<<arrayy[u]<<endl;
        }else{
            cout<<arrayy[u]<<' ';
        }
    }
    
}

void Bubble(Card* A,int n){
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(A[j].value<A[j-1].value)swap(A[j],A[j-1]);
        }
    }
    
    
}

void selection(Card* B,int n){
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(B[j].value<B[minj].value){
                minj=j;
            }
        }
        swap(B[i],B[minj]);
    }
    
    
}
void kouzoucout(Card* A,int n){
    for(int i=0;i<n;i++){
      if(i!=n-1)  cout<<A[i].ehuda<<A[i].value<<' ';
      else cout<<A[i].ehuda<<A[i].value;
            
            }
    cout<<endl;
    
}

bool isbool(Card* A,Card *B,int n){
    for(int i=0;i<n;i++){
        if(A[i].ehuda!=B[i].ehuda)return false;
    }
    return true;
    
}
int main(){
    int n;
    cin>>n;
    Card A[n],B[n];
    for(int i=0;i<n;i++){
        cin>>A[i].ehuda>>A[i].value;
    }
    for(int i=0;i<n;i++){
        B[i]=A[i];
    }
    
    Bubble(A,n);
    kouzoucout(A,n);
    cout<<"Stable"<<endl;
    selection(B,n);
    kouzoucout(B,n);
    if(isbool(A,B,n)){
        cout<<"Stable"<<endl;
    }else{
        cout<<"Not stable"<<endl;
    }
    
    
    
    
return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int n;
  cin>>n;
  vector<in> h(n);
  rep(i,n)
    cin>>h.at(i);
  vector<in> a(n+1,0),b(n+1,0);
  rep(i,n){
    if(i+1+h.at(i)<=n)
      a.at(i+1+h.at(i))++;
    if(i+1-h.at(i)>=0)
      b.at(i+1-h.at(i))++;
  }
  in sum=0;
  rep(i,n+1){
    sum+=a.at(i)*b.at(i);
  }
  cout<<sum<<endl;
  
  /*rep(i,n+1){
    cout<<i<<": "<<a.at(i)<<" "<<b.at(i)<<endl;;
  }*/
}

Measured memory_bytes: 7972
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;//998244353;
ll const inf = 1e3+1;

void solve()
{   
    ll d,t,s; cin >> d >> t >> s;

    if(s*t>=d)
        cout << "Yes\n";
    else
        cout << "No\n";
} 

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/ 
        
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
    return 0;
}


Measured memory_bytes: 3632
x = int(input())

if 400 <= x <= 599 :
    ans = '8'
elif 600 <= x <= 799 :
    ans = '7'
elif 800 <= x <= 999 :
    ans = '6'
elif 1000 <= x <= 1199 :
    ans = '5'
elif 1200 <= x <= 1399 :
    ans = '4'
elif 1400 <= x <= 1599 :
    ans = '3'
elif 1600 <= x <= 1799 :
    ans = '2'
else :
    ans = '1'

print(ans)

Measured memory_bytes: 9208
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

double a, b, x;
double PI = 3.1415926535898;

int main() {
    cin >> a >> b >> x;
    double t;
    if (a * a * b > 2 * x) {
        t = a * b * b / x / 2;
    } else {
        t = 2 * (a * a * b - x) / (a * a * a);
    }
    double ans = atan (t) * 180 / PI;
    cout << fixed << setprecision(10) << ans << endl;
}


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

int main(void){
  int A,B,C;
  cin>>A>>B>>C;
  string ans="Yes";
  if(A!=B&&B!=C&&A!=C) ans="No";
  if(A==B&&B==C) ans="No";
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


int main(){
    int N;cin >> N;
    int ans = 0;
    for(int i = 1;i <= N;i++){
        string s = to_string(i);
        if(s.size()%2 == 1)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int n,a[200010],sum1[200010],sum2[200010],all,ans = INF;

signed main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		sum1[i + 1] = sum1[i] + a[i];
		all += a[i];
	}
	for(int i = n - 1;i >= 0;i--){
		sum2[i] = sum2[i + 1] + a[i];
	}
	reverse(sum2,sum2 + n + 1);
	for(int i = 1;i < n;i++){
		int x = INF,y = -INF;
		int ind1 = upper_bound(sum1,sum1 + n + 1,sum1[i] / 2) - sum1 - 1;
		int ind2 = upper_bound(sum2,sum2 + n + 1,(all - sum1[i]) / 2) - sum2 - 1;
		if(abs(sum1[ind1] * 2 - sum1[i]) > abs(sum1[ind1 + 1] * 2 - sum1[i])) ind1++;
		if(abs(sum2[ind2] * 2 - (all - sum1[i])) > abs(sum2[ind2 + 1] * 2 - (all - sum1[i]))) ind2++;
		x = max({sum1[ind1],sum1[i] - sum1[ind1],sum2[ind2],all - sum1[i] - sum2[ind2]});
		y = min({sum1[ind1],sum1[i] - sum1[ind1],sum2[ind2],all - sum1[i] - sum2[ind2]});
		//cout << x << " " << y << endl;
		chmin(ans,x - y);
	}
	cout << ans << endl;
	return 0;
}

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

void kasan(vector<vector<long>>& tree, long* ans, int* check, int p) {
  for (int i = 0; i < (int)tree[p].size(); i++) {
    if (!check[tree[p][i]]) {
      check[tree[p][i]] = 1;
      ans[tree[p][i]] += ans[p];
      kasan(tree, ans, check, tree[p][i]);
    }
  }

  return;
}

int main() {
  int n, q;

  cin >> n >> q;

  vector<vector<long>> tree(n + 1);

  vector<long> ans(n + 1);

  vector<int> check(n + 1);

  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  for (int i = 1; i < n + 1; i++) {
    check[i] = 0;
  }

  for (int i = 0; i < q; i++) {
    int p, x;
    cin >> p >> x;
    ans[p] += x;
  }
  check[1] = 1;
  kasan(tree, ans.data(), check.data(), 1);

  for (int i = 1; i < n + 1; i++) {
    cout << ans[i] << " ";
  }

  return 0;
}


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

int main(){

    long long k, a, b; cin >> k >> a >> b;
    if(k <= a) cout << 1 << endl;
    else if(a <= b) cout << -1 << endl;
    else{
        long long n = (k - a) / (a - b) + 2;
        if((k - a) % (a - b) == 0) n--;
        cout << 2*n - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

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

    long long Aans = 0;
    long long Bans = 0;
    if (A >= K) {
        Aans = A - K;
        Bans = B;
    } else if ( A + B >= K) {
        Aans = 0;
        Bans = B - (K - A);
    } else {
        Aans = 0;
        Bans = 0;
    }
    cout << Aans << " " << Bans << endl;
    return 0;

}

Measured memory_bytes: 256