akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////

void solve(){
  ini(H , W , N);
  int ans = inf;
  rep(i , H + 1) rep(j , W + 1){
    int nya = i * W + j * H - i * j;
    if(nya >= N) amin(ans , i + j);
  }
  out(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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; }

int main () {
  int h, n;
  cin >> h >> n;
  // dp[j] = (モンスターに合計jのダメージを与えるのに必要な魔力)
  vi dp(h+1,INF);
  dp[0] = 0;
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    rep(j,h) {
      int nj = min(j+a, h);
      dp[nj] = min(dp[nj], dp[j]+b);
    }
  }
  cout << dp[h] << endl;
  return 0;
}

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

int main() {
	int n;
	string s;
	cin >> n >> s;
	ll ans = 0;
	vector<ll> r(n), g(n), b(n);
	if(n <= 3) {
		cout << 0 << endl;
		return 0;
	}
	rep(i, n) {
		if(s[i] == 'R') r[i]++;
		if(s[i] == 'G') g[i]++;
		if(s[i] == 'B') b[i]++;
		if(i > 0) {
			r[i] += r[i-1];
			g[i] += g[i-1];
			b[i] += b[i-1];
		}
	}
	// rep(i, n) cout << r[i] << " ";
	// cout << endl;
	// rep(i, n) cout << g[i] << " ";
	// cout << endl;
	// rep(i, n) cout << b[i] << " ";
	// cout << endl;
	rep(i, n-2) {
		for(int j = i+1; j < n-1; j++) {
			if(s[i] == s[j]) continue;
			char now = ((s[i] == 'R' || s[j] == 'R') && (s[i] == 'G' || s[j] == 'G')) ? 'B' : ((s[i] == 'R' || s[j] == 'R') && (s[i] == 'B' || s[j] == 'B')) ? 'G' : 'R';
			int dif = j - i;
			if(now == 'R') {
				ans += r[n-1] - r[min(n-1,j+dif)];
				if(dif>1) ans += r[min(n-1,j+dif-1)] - r[j];
			}
			if(now == 'G') {
				ans += g[n-1] - g[min(n-1,j+dif)];
				if(dif>1) ans += g[min(n-1,j+dif-1)] - g[j];
			}
			if(now == 'B') {
				ans += b[n-1] - b[min(n-1,j+dif)];
				if(dif>1) ans += b[min(n-1,j+dif-1)] - b[j];
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3660
def isPrime(n):
    for i in range(2, n):
        if i * i > n:
            return 1
        if n % i == 0:
            return 0
    return 1
  
ans = 0
n = int(input())
for i in range(n):
    x = int(input())
    ans = ans + isPrime(x)
  
print(ans)


Measured memory_bytes: 5616
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 1e5+4;

int q,l,r,prime[N],pref[N];

void solve(){
	for(int i=2;i<=1e5;++i)prime[i]=1;
	//forn(i,100)cout<<prime[i]<<' ';
	for(int i=2;i<=1e5;++i){
		for(int j=i+i;j<=1e5;j+=i){
			prime[j]=0;
		}
	}
	for(int i=2;i<=1e5;++i){
		pref[i]=pref[i-1];
		//if(prime[i])cout<<i<<' '; 
		if(prime[i] && prime[(i+1)/2]){
			//cout<<i<<' ';
			++pref[i];
		}
	}
	cin>>q;
	while(q--){
		cin>>l>>r;
		cout<<pref[r]-pref[l-1]<<'\n';
	}

}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 4424
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const int inf=1<<29;
const ll Maxn=1e6;
const double pi=3.1415926536;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<=100000;i++){
		if((((i*b)+c)%a)%a==0){
			printf("YES\n");
			break;
		}
		if(i==100000) printf("NO\n");
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m,k;
  string s;
  cin>>n>>m>>k;
  rep(i,n+1)rep(j,m+1){
    if(n*j+m*i-i*j*2==k){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


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

int main()
{
    int n;
    vector<int>a;
    cin>>n;
    int cnt=0;
    a.resize(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=1;i<n;i++)
        for(int j=0;j<n-i;j++){
            if(a[j]>a[j+1]){
                int t=a[j];
                a[j]=a[1+j];
                a[j+1]=t;
                cnt++;
            }
        }
    for(int i=0;i<n;i++){
        if(i>0)
            cout<<" ";
        cout<<a[i];
    }
    cout<<endl<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <fstream>
#include <string>

using namespace std;

struct mondai {
	int suisen;
	int nanido;
	int number;
};
bool hyouka(mondai a, mondai b) {
	if (a.nanido == b.nanido) {
		return a.suisen >= b.suisen;
	}
	else {
		return a.nanido >= b.nanido;
	}
}


int main() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0) {
			break;
		}
		mondai a[1000];
		int d, v;
		for (int i = 0; i < n; i++) {
			cin >> d >> v;
			a[i].suisen = v;
			a[i].nanido = d;
		}
		sort(a, a + n, hyouka);
		int tmpsuisen = 0;
		int tmpnanido = 1;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
		//	cout << "nanido:" << a[i].nanido << "suisen:" << a[i].suisen << endl;
			if (tmpnanido != a[i].nanido) {
			//	cout << "足したよ ; " << tmpsuisen << " " << i << endl;
				tmpnanido = a[i].nanido;
				cnt += tmpsuisen;
				tmpsuisen = 0;
			}
			if (tmpsuisen < a[i].suisen) {
				tmpsuisen = a[i].suisen; 
			}

		}
		cnt += tmpsuisen;
		cout << cnt << endl;
	}
}



Measured memory_bytes: 3132
from collections import deque
N, M, Q = map(int, input().split())
A = [list(map(int, input().split())) for i in range(Q)]

def calc(x):
    ans = 0
    for a, b, c, d in A:
        if int(x[b-1]) - int(x[a-1]) == c:
            ans += d
    return ans

q = deque([[1]])
ans = 0
while q:
    tmp = q.popleft()
    if len(tmp) == N:
        ans = max(ans, calc(tmp))
    else:
        for i in range(tmp[-1], M+1):
            q.append(tmp+[i])

print(ans)

Measured memory_bytes: 16376
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>

using namespace std;

int main(){
    int n;
    cin >> n;
    
    vector<int> v;
    
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    int ans = 0;
    int m = 0;
    
   for(int i = 0; i < n; i++){
       if(i == 0){
           m = v[0];
           ans++;
       }
       else{
           if(v[i] >= m){
               m = v[i];
               ans++;
           }
       }
    }
    cout << ans;
}


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

int main(){
    int s;
    int ans=0;
    cin >> s;
    while(s>0){
        ans+=s%10;
        s/=10;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 100
#define TRUE 1
#define FALSE 0

int IsEmpty(int);
void push(int);
int pop(int);

int top=1,pocky[N];
char s[N];

int main(){
  int x;
  int i,a,b,Sdata;
  
  while( scanf("%s", s) != EOF ){
   
    if ( s[0] == '+' ){
      a=pop(pocky[top]);
      b=pop(pocky[top]);
      Sdata=a+b;
      push(Sdata);
      

    } else if (s[0] == '-' ){
      a=pop(pocky[top]);
      b=pop(pocky[top]);
      Sdata=b-a;
      push(Sdata);

    } else if (s[0] == '*' ){
      a=pop(pocky[top]);
      b=pop(pocky[top]);
      Sdata=a*b;
      push(Sdata);
    } else {
      x = atoi(s);
    
      push(x);
    }
  }

  printf("%d\n",pocky[top]);

  return 0;
}

int IsEmpty(int S){
  if(top==0) return 0;
  else return FALSE;
}
 
void push(int x){
  top = top+1;
  pocky[top] = x;
}

int pop(int S){
   
  if (IsEmpty(S)){
    printf("underflow\n");
  }
  else {
    top = top - 1;
  }
  return S;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,d,x;
  	cin >> n >> d >> x;
	vector<int> v;
  	int temp;
  for(int i=0;i<n;i++)
  {
  	cin >> temp;
    v.push_back(temp);
  }
  d--;
  int answer=0;
  answer+=n;
  answer+=x;
  for(int i=0;i<v.size();i++)
  {
  	answer+=d/v[i];
  }
  cout << answer << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
char s[4010],t[4010];
int d[4010][4010]={0};
int main(){
  int i,j,max;
  while(scanf("%s %s",s,t)!=EOF){
    for(i=max=0;s[i];i++){
      for(j=0;t[j];j++){
	if(s[i]==t[j])d[i+1][j+1]=d[i][j]+1;
	else	      d[i+1][j+1]=0;
	if(max<d[i+1][j+1])max=d[i+1][j+1];
	//printf("%d ",d[i+1][j+1]); 
      }//printf("\n");
    }
    printf("%d\n",max);
  }
  return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	int n=sqrt(N);
	cout <<n*n <<endl;
	return 0;
}



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

int main(){
    int x, n;
    std::cin >> x >> n;
    if(n == 0){
        std::cout << x << std::endl;
        return 0;
    }

    std::vector<bool> canUse(102, true);    
    for(int i = 0; i < n; i++){
        int p;
        std::cin >> p;
        canUse[p] = false;
    }

    int diff = 0;
    while(1){
        if(x - diff >= 0 && canUse[x - diff]){
            std::cout << x - diff << std::endl;
            return 0;
        }
        if(x + diff < 102 && canUse[x + diff]){
            std::cout << x + diff << std::endl;
            return 0;
        }
        diff++;
    }
    return 0;
}


Measured memory_bytes: 3628
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long sum = 0;
		long i = 0;
		while(sum<x){
			sum+=(i+1);
			i++;
		}

		System.out.println(i);
		return;
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<string.h>
#include<algorithm>
#include<vector>
#include<cmath>
#define ll long long 
#define r(i,n) for(ll i=0;i<n;i++)
#define rp(i,a,b) for(ll i=a;i<b;i++)
#define ret return 
#define elif else if
#define p(x) cout<<x<<endl;
ll inf=100001;
using namespace std;
int main(){
	while(1){
	ll n;cin>>n;ll b[n];r(i,n)cin>>b[i];
	ll a=0,s=0,ct=0;
	r(i,n-1){
		if(b[i]<b[i+1]){a=1;}
		elif(b[i]>b[i+1]){s=1;}
		else{continue;}
		if((a+s)==2){ct++;a=s=0;}
	}p(ct+1)
	ret 0;
	}
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		for(int i=0;i<3;i++){
			out.print(ir.next().charAt(0));
		}
		out.println();
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main(void){
	int n;
	int *score;
	double ave, S;

	while (true){
		cin >> n;

		if (n == 0) break;

		score = new int[n];

		S = ave = 0.0;
		for (int i = 0; i < n; i++){
			cin >> score[i];
			ave += score[i];
		}
		ave /= n;
	
		for (int i = 0; i < n; i++){
			S += (score[i] - ave)*(score[i] - ave);
		}

		cout << fixed << setprecision(10) << sqrt(S / n) << "\n";

		delete[] score;
	}

	return 0;
}

Measured memory_bytes: 1272
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
void swap(int &a, int &b)
{
	a = a ^ b;
	b = a ^ b;
	a = a ^ b;
}
bool can_reach(int start, int end, string s)
{
	for (int i = start; i <= end - 1; i++)
	{
		if ((s[i] == '#') && (s[i+1] == '#'))
		{
			return false;
		}
	}
	return true;
}
int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);

	int N, A, B, C, D;
	
	cin >> N >> A >> B >> C >> D;
	A--;
	B--;
	C--;
	D--;
	string s;
	cin >> s;
	/*
	if (A > C)
	{
		swap(A,C);
	}
	if (B > D)
	{
		swap(B, D);
	}
	if (A > B)
	{
		swap(A, B);
		swap(C, D);
	}
	*/
	int nn = 0;
	bool y = false;
	int c = 0;
	int d = 0;
	if ( !can_reach(A,C, s) || !can_reach(B,D, s))
	{
		cout << "No" << endl;
		return 0;
	}
	if (D < C)
	{
		for (int i = B-1; i <= D+1; i++)
		{
			
			if (s[i] == '.')
			{
				c++;
				if (c >= 3)
				{
					y = true;
					break;
				}
			}
			else
			{
				c=0;
			}	
			/*
			if ((s[i] == '.') && (s[i+1] == '.') && (s[i+2] == '.'))
			{
				y = true;
				break;
			}
			*/
		}
		if (!y)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	
	
	
	return 0;
}


Measured memory_bytes: 976
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <unordered_map>
#include <numeric>

using namespace std;

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

const ll mod = 1e9+7;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

ll dp[410][410];

int main(){
    int N;
    ll a[410];
    ll s[410];
    cin >> N;
    s[0] = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        s[i+1] = s[i] + a[i];
        dp[i][i] = 0;
    }



    for(int i = 1; i < N; i++){
        for(int j = 0; j + i < N; j++){
            // dp[j][j+i]を更新
            dp[j][j+i] = dp[j][j] + dp[j+1][j+i];
            dp[j][j+i] += (s[j+1] - s[j]) + (s[j+i+1] - s[j+1]);
            for(int k = 1; j + k + 1 <= j+i; k++){
                ll tmp = dp[j][j+k] + dp[j+k+1][j+i];
                tmp += (s[j+k+1] - s[j]) + (s[j+i+1] - s[j+k+1]);
                dp[j][j+i] = min(dp[j][j+i], tmp);
            }
        }
    }

//    for(int i = 0; i < N; i++){
//        for(int j = 0; j < N; j++){
//            cout << dp[i][j] << " ";
//        }
//        cout << endl;
//    }
    cout << dp[0][N-1] << endl;


    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}

int prime[1000000];bool visprime[10000000];
void sieve(){int k=0;for(int i=2;i*i<=1000000;i++){for(int j=i*i;j<=1000000;j+=i){visprime[j]=true;}}for(int i=2;i<=1000000;i++){if(visprime[i]==false) prime[k++]=i;}}


int main()
{


  int n;
  cin>>n;
  int arr[n];
  int temp[n];
  int mn=INT_MAX;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];

      mn=min(mn,arr[i]);
      temp[i]=mn;
  }
  int cnt=0;

  for(int i=0;i<n;i++)
  {
     if(temp[i]>=arr[i]) cnt++;
  }
  cout<<cnt<<endl;



















}


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

    #define all(v) v.begin(), v.end()
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
    #define intll int long long
    const int INF = 1e9;
    const int MOD = 1e9 + 7;

    int main() {
      int n ;
      cin >> n ;
      int ac=0, wa=0, tle=0, re = 0 ;

      rep(i,n){
        string s ;
        cin >> s ;
        if(s == "AC" ) ac  ++ ;
        if(s == "WA" ) wa  ++ ;
        if(s == "TLE") tle ++ ;
        if(s == "RE" ) re  ++ ;
      }

      cout << "AC x " << ac << endl ;
      cout << "WA x " << wa << endl ;
      cout << "TLE x "<<tle << endl ;
      cout << "RE x " << re << endl ;

    }


Measured memory_bytes: 3608
#include <stdio.h>

int main(){
  long long int n,a,b;
  scanf("%lld%lld%lld", &n, &a, &b);
  long long int ans;
  if(n==1){
    if(a==b){
      ans = 1;
    }else{
      ans = 0;
    }
  }else{
    if(a>b){
      ans = 0;
    }else if(a==b){
      ans = 1;
    }else{
      ans = (n-2) * (b-a) + 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <stack>
#include <string.h>
#include <vector>

using namespace std;

vector<int> tsort(int v, vector<int> g[], bool zero_index = false) {
  vector<int> ret;

  int start = zero_index ? 0 : 1;
  int end = zero_index ? v : v + 1;
  int degree[end];
  memset(degree, 0, sizeof(degree));

  for (int from = start; from < end; from++) {
    for (int i = 0; i < g[from].size(); i++) {
      int to = g[from][i];
      degree[to]++;
    }
  }

  stack<int> root;

  for (int i = start; i < end; i++) {
    if (degree[i] == 0) {
      root.push(i);
    }
  }

  while (!root.empty()) {
    int from = root.top();
    root.pop();

    ret.push_back(from);

    for (int i = 0; i < g[from].size(); i++) {
      int to = g[from][i];
      degree[to]--;

      if (degree[to] == 0) {
        root.push(to);
      }
    }
  }

  return ret;
}

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

  vector<int> g[n + 1];

  int x, y;

  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    g[x].push_back(y);
  }

  vector<int> order = tsort(n, g);

  int dist[n + 1];
  memset(dist, 0, sizeof(dist));

  for (int i = 0; i < n; i++) {
    int from = order[i];

    for (int j = 0; j < g[from].size(); j++) {
      int to = g[from][j];

      dist[to] = max(dist[to], dist[from] + 1);
    }
  }

  int ans = 0;

  for (int i = 1; i <= n; i++) {
    ans = max(ans, dist[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6780
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int MAX = 1e5;

struct Edge {
  ll to, cost;
};

vector<Edge> G[MAX];

void add_edge(ll l, ll r, ll d) {
  G[l].push_back({r, d});
  G[r].push_back({l, -d});
}

vector<ll> x(MAX, 0);
vector<bool> visited(MAX, false);
bool f = true;
ll xmin = 0, xmax = 0;

void dfs(ll from) {
  for (Edge e: G[from]) {
    if (!visited[e.to]) {
      x[e.to] = x[from] + e.cost;
      xmin = min(xmin, x[e.to]);
      xmax = max(xmax, x[e.to]);
      visited[e.to] = true;
      dfs(e.to);
    }
    else if (x[e.to] != x[from] + e.cost) {
      f = false;
      return;
    }
  }
  if (xmax - xmin > inf) {
    f = false;
  }
}



int main() {
  ll n, m;
  cin >> n >> m;
  rep(i, m) {
    ll l, r, d;
    cin >> l >> r >> d;
    l--, r--;
    add_edge(l, r, d);
  }

  rep(i, n) {
    if (visited[i]) continue;
    xmin = 0, xmax = 0;
    visited[i] = true;
    dfs(i);
    if (!f) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;



  
  return 0;
}

Measured memory_bytes: 16512
#include <iostream>
#include <vector> //可変長配列
#include <queue> //キュー
#include <unordered_map> //ハッシュ連想配列
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define ll long long int
#define INFTY (1<<21)

#define unknown -1

using namespace std;

ll dp[86+1];

ll L(ll n){
    if (n==0) return 2;
    else if (n==1) return 1;
    if(dp[n] != -1) return dp[n];
    return dp[n] = L(n-1) + L(n-2);
}

int main(void){
    cin.sync_with_stdio(false);
    for(int i = 1; i < 86+1; i++){
        dp[i] = -1;
    }
    ll N; cin>>N;
    cout<<L(N)<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php
	fscanf(STDIN,'%d%d',$n,$m);
	for($i=0;$i<$n;$i++)
	{
		$a[]=fgets(STDIN);
	}
	for($i=0;$i<$m;$i++)
	{
		$b[]=fgets(STDIN);
	}
	for($i=0;$i<=$n-$m;$i++)for($j=0;$j<=$n-$m;$j++)
	{
		$f=1;
		for($k=0;$k<$m;$k++)for($l=0;$l<$m;$l++)
		{
			if($a[$i+$k][$j+$l]!=$b[$k][$l])
			{
				$f=0;
			}
		}
		$s+=$f;
	}
	echo $s?Yes:No;


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long ll;
#define endl '\n'

struct quad {
    int a, b, c, d;
    quad(int _a, int _b, int _c, int _d) : a(_a), b(_b), c(_c), d(_d) {}
};

vector<quad> constraints;
int compute(vector<int>& arr) {
    int q = constraints.size();
    int ans = 0;
    for (int i = 0; i < q; ++i) {
        int a = constraints[i].a;
        int b = constraints[i].b;
        int c = constraints[i].c;
        int d = constraints[i].d;
        --a;
        --b;
        if (arr[b] - arr[a] == c) {
            ans += d;
        }
    }
    return ans;
}

void checkAll(int cur, int n, int m, vector<int>& a, int &res) {
    if (cur == n) {
        res = max(res, compute(a));
        return;
    }
    int val = 1;
    if (cur - 1 >= 0) {
        val = a[cur - 1];
    }
    for (int next = val; next <= m; ++next) {
        a[cur] = next;
        checkAll(cur + 1, n, m, a, res);
    }
}

void solve() {
    int n, m, q;
    cin >> n >> m >> q;

    int a, b, c, d;
    for (int i = 0; i < q; ++i) {
        cin >> a >> b >> c >> d;
        quad qu(a, b, c, d);
        constraints.push_back(qu);
    }

    int res = 0;
    vector<int> arr(n, 0);
    checkAll(0, n, m, arr, res);
    cout << res << endl;
}

int main() {
    FAST_IO;

    int t;
    // cin >> t;
    t = 1;

    while (t--) {
        solve();
    }
    
    return 0;
}

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

const long long INF = 1LL << 60;
long long h[100010];
long long dp[100010];
long long rec(int i) {
    if(dp[i] != -1) return dp[i];
    if(i == 0) return 0;
    long long res = INF;
    res = min(res, rec(i-1) + abs(h[i] - h[i-1]));
    if(i > 1) res = min(res, rec(i-2) + abs(h[i] - h[i-2]));
    return dp[i] = res;
}

int main() {
    int N; cin >> N;
    for(int i = 0; i < N; ++i) cin >> h[i];
    for(int i = 0; i < N; ++i) dp[i] = -1;
    
    cout << rec(N-1) << endl;
}


Measured memory_bytes: 4864
N, M = map(int, input().split())

l = 1
r = N
flag = False
for i in range(M):
    l_1, r_1 = list(map(int, input().split()))
    if l_1 > l:
        l = l_1
    if r_1 < r:
        r = r_1
    if l > r:
        flag = True
        break
    
if flag:
    print(0)
else:
    print(r - l + 1)

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, K;

signed main() {
    cin >> N >> K;
    if (K == 1) {
        cout << 0 << endl;
        return 0;
    }
    N -= K;
    cout << N << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,t[1000000],x[1000000],y[1000000];
int main(){
	int i,j;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>t[i]>>x[i]>>y[i];
	}
	for(i=1;i<=n;i++){
		int dt=t[i]-t[i-1];
		dt-=abs(x[i]-x[i-1]);
		dt-=abs(y[i]-y[i-1]);
		if(dt<0||dt%2){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 8832
n = int(input())
ans = 0
i = 2
 
while n>1 and i*i<=n:
  if n % i == 0:
    c = 0
    while n % i == 0:
      n = n / i
      c += 1
    j = 1
    while c>=j:
      ans=ans+1
      c -= j
      j += 1
 
  i = i + 1
      
    
if n > 1:
  ans = 1 + ans
 
print(ans)

Measured memory_bytes: 9260
#include<stdio.h>
 
int main(){
  int x[2];
  int a, y, temp;
  scanf("%d %d\n", &a, &y);
 
  if(a>=y){
    x[0]=a;
    x[1]=y;
  }
  else{
      x[0]=y;
      x[1]=a;
  }
   
  while(x[1]!=0){
       temp = x[0];
       x[0] = x[1];
       x[1] = temp%x[0];
  }
   printf("%d\n", x[0]);
 
 return 0;
}

Measured memory_bytes: 596
S = list(input())
count = 0
if S[0] == 'A':
    S[0] = S[0].lower()
else:
    print('WA')
    exit()

count = 0
for i in range(2,len(S)-1):
    if S[i] == 'C' and count == 0:
        count += 1
        S[i] = S[i].lower()

if count == 0:
    print('WA')
    exit()

for i in range(len(S)):
    if S[i] != S[i].lower():
        print('WA')
        exit()
print('AC')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin>>n;
	vector<ll> A,B;
	for(ll i=0;i<=n;i++)
	{
		ll a;
		cin>>a;
		A.push_back(a);
	}
	for(ll i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		B.push_back(a);
	}
	ll sum = 0;
	for(ll i=0;i<n;i++)
	{                      
		if(A[i]&&B[i])              
		{
			ll k = min(A[i],B[i]);
			A[i]-=k;
			sum+=k;   
			B[i]-=k;
		}
		if(A[i+1]&&B[i])
		{
			ll k = min(A[i+1],B[i]);
			A[i+1]-=k;
			sum+=k;
			B[i]-=k;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rvs(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    int l=Y + 2 * Z;
    int n=1;
    while(l <= X){
        n++;
        l += Y + Z;
    }
    cout << n - 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//***** Jai Gurudev *****//
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define all(x) x.begin(),x.end()
#define vii vector<pair<int,int> >
#define vll vector<pair<ll,ll> >
#define pb push_back
#define fi first
#define se second
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI 3.1415926535897932384626433832795
#define inf 1e18+5
#define mod 1000000007
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
bool isprime(ll n) {bool flag=true;for(ll i=2; i<=sqrt(n);i++){if(n%i==0){flag=false;break;}}return flag;}
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	vi a(n);
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(all(a));
	cout<<accumulate(a.begin(),a.begin()+k,0);
	return 0;
}


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

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

	string ans = s;
	int cl = 0, cr = 0;
	for (int i = 0;i < n;i++) {
		if (s[i] == '(') {
			cl++;
		}
		else {
			cr++;
		}
		if (cl < cr) {
			ans = "(" + ans;
			cl++;
		}
	}
	if (cl > cr) {
		ans += string(cl - cr, ')');
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


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

lengthNumberDict = defaultdict(int)
for a in A:
    lengthNumberDict[a] += 1

lengthNumberList = [a for a in list(lengthNumberDict.items()) if a[1] >= 2]
lengthNumberList = sorted(lengthNumberList, key=lambda x: x[0], reverse=True)
if len(lengthNumberList) == 0:
    print(0)
    quit()
if len(lengthNumberList) == 1 and lengthNumberList[0][1] <= 3:
    print(0)
    quit()

if lengthNumberList[0][1] >= 4:
    print(lengthNumberList[0][0] ** 2)
else:
    print(lengthNumberList[0][0] * lengthNumberList[1][0])

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

using namespace std;
typedef long long ll;
const long double pi=3.14159265358979323846;
#define x  first
#define y  second
#define deb(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
bool isPar(string s)
{
    ll n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return 0;
        }
    }
    return 1;
}

ll nOfD(ll n)
{
    ll d=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) d+=2;
        i++;
    }
    if(i * i == n)d++;
    return d;
}
ll sOfD(ll n)
{
    ll sum=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) sum+=i,sum+=n/i;
        i++;
    }
    if(i * i == n)sum+=i;
    return sum;
}
bool isP(ll x)
{
    if(x==2)return 1;
    if(x<2 || x%2==0)return 0;
    for(ll i=3;i * i <= x;i+=2)
    {
        if(x%i==0)return 0;
    }
    return 1;
}
ll lcm(ll a, ll b)
{
    return (a / __gcd(a, b) * b);
}
ll ps[20002]={};
int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    //freopen("op.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        for(int i=1;i<=100;i++)
        {
            if(!i)continue;
            for(int j=1;j<=100;j++)
            {
                if(!j)continue;
                for(int k=1;k<=100;k++)
                {
                    if(!k)continue;
                    if(i*i + j*j + k*k + i*k + j*k + i*j > 10000)break;
                    ps[i*i + j*j + k*k + i*k + j*k + i*j]++;
                }
            }
        }
        int n;
        cin>>n;
        for(int i=1;i<=n;i++)cout<<ps[i]<<'\n';

    }
    return 0;
}


Measured memory_bytes: 3660
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/2/ALDS1_2_C


def BubbleSort(C, N):
    for i in range(N):
        for j in range(N-1, i, -1):
            if int(C[j][1]) < int(C[j-1][1]):
                C[j], C[j-1] = C[j-1], C[j]
    return C


def SelectionSort(C, N):
    for i in range(N):
        minj = i
        for j in range(i, N):
            if int(C[j][1]) < int(C[minj][1]):
                minj = j
        C[i], C[minj] = C[minj], C[i]
    return C


def solve():
    n = int(input())
    l = input().split()
    m = l.copy()

    l = BubbleSort(l, n)
    m = SelectionSort(m, n)

    print(' '.join(l))
    print('Stable')
    print(' '.join(m))
    if l == m:
        print('Stable')
    else:
        print('Not stable')


if __name__ == '__main__':
    solve()



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
long long int i,j,a,b,i2,j2,i3,nums=0,nums2=0;
//21 10
long long lcm(long long x,long long y){
	long long s=x,t=y,st;
	while(t!=0){
		st=s%t;
		s=t;
		t=st;
	}
	return x*y/s;
}

int main(){
//	scanf("%lld %lld %lld %lld",&i,&j,&a,&b);
//	i2=i,j2=j;
//	i3=i;
//	if(i%a!=0){
//		i=(i/a)*a+a;
//	}
//	if(i2%b!=0){
//		i2=(i2/b)*b+b;
//	}
//	nums+=(j-i)/a;
//	nums2+=(j2-i2)/b;
//	long long int allnums=j-i3;
//	
//	printf("%lld",allnums-nums-nums2);
	
	scanf("%lld %lld %lld %lld",&i,&j,&a,&b);
	long long t1=(i-1)/a,t2=(i-1)/b,t3=j/a,t4=j/b;
	//printf("%d\t%d\t%d\t\n",t1,t2,t3,t4);
	t3=t3-t1;
	t4=t4-t2;
	//printf("%d\t%d\t%d\t\n",t1,t2,t3,t4);
	long long lcms=j/lcm(a,b)-((i-1)/lcm(a,b));
	//printf("%d\n",lcms);
	lcms=(j-(i-1))-(t3+t4-lcms);
	cout<<lcms<<endl;
	
	
	return 0;
}



//12 40---28/6=4
//16 40---24=3













Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
  	string s;
	int memos = 0,memot = 0,cnt = 0;
  	cin >> s;
  	rep(i,0,s.size()){
      if(s[s.size()-i-1] == 'T'){
        memot++;
      }
      else if(memot){
        cnt += 2;
        memot--;
      }
      
    }
  
  	cout << (int)s.size() - cnt << endl;
  
	return 0; 
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) { cin >> A.at(i); }
  int min_a = *min_element(A.begin(), A.end());
  int max_a = *max_element(A.begin(), A.end());
  int ans = 1 << 29;
  int cur = 0;
  REPI(i, min_a, max_a + 1) {
    cur = 0;
    REP(j, N) { cur += ((A.at(j) - i) * (A.at(j) - i)); }
    ans = min(ans, cur);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

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

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

  if (a + b == 5) {
    cout << 1 << endl;
  }
  if (a + b == 4) {
    cout << 2 << endl;
  }
  if (a + b == 3) {
    cout << 3 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;

  while(1){
    if(cur == nil) break;
    if(isf++ > 0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;

  scanf("%d", &n);

  init();

  for(i = 0; i < n; i++){
    scanf("%s%d", com, &key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F') deleteFirst();
	else if(com[6] == 'L') deleteLast();
      }
      else{
	deleteKey(key);
	nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}



Measured memory_bytes: 33960
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  int ans = 0;
  for(int i = 0; i < n; ++i){
    if(v[i] == i + 1){
      ans++;
      if(i + 1 == n) swap(v[i], v[i - 1]);
      else swap(v[i], v[i+1]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
#include<stdio.h>
int main()
{
        int v=0,s=0,a[10000+1],b[10000+1],i,n;
        while(1)
        {
                v=0;
                s=0;
                cin>>n;//??\???
                if(n==0)//0?????´???
                {
                        break;
                }
                for(i=0;i<n;i++)//??\???
                {
                        cin>>a[i]>>b[i];
                }
                for(i=0;i<n;i++)
                {
                        if(a[i]>b[i])
                                v=a[i]+b[i]+v;
                        else if(a[i]<b[i])
                                s=a[i]+b[i]+s;
                        else
                        {
                                v=a[i]+v;
                                s=b[i]+s;
                        }
                }
                cout<<v<<" "<<s<<endl;
        }
        return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

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


signed main(){
    ll k;cin>>k;

    ll b=0;

    rep(i,10000000){
        b=(10*b%k+7)%k;
        if(b==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3644
N = input()
A = list(map(int, input().split()))

A.sort(reverse=True)

l = 0
w = 0

while len(A)>=2:
    temp = A.pop(0)
    if temp==A[0]:
        if l==0:
            l = A.pop(0)
        else:
            w = A.pop(0)
            break

print(l*w)

Measured memory_bytes: 14252
import sys
n=int(input())
a,b,c,d,i=list(map(int,input().split())),0,[],1,0
if a[0]!=0:
    print('0')
    sys.exit()
if n==1:
    print('1')
    sys.exit()
a.sort()
if a[1]==0:
    print('0')
    sys.exit()
while True:
    if a[i]==a[i+1]:
        b+=1
    else:
        c.append(b+1)
        b=0
    i+=1
    if i+1>=n:
        c.append(b+1)
        break
if len(c)-1!=max(a):
    print('0')
    sys.exit()
for i in range(len(c)-1):
    d*=c[i]**c[i+1]
print(d%998244353)

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

int main(){
    long int A,B,C,D,ans=0;
    cin >> A >> B >> C >> D;
    if(A<=D){
        ans=A;
        if(D>A+B){
            ans=ans-(D-A-B);
        }
    }else{
        ans=D;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620