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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    vector<int> v;
    int N; cin >> N;
    vector<int> A;
    vector<int> B;
    int a = -1;
    int b = -1;
    int cnt = 0;
    REP(i,N) {
        int tmp; cin >> tmp;
        A.push_back(tmp);
        v.push_back(tmp);
    }
    REP(i,N) {
        int tmp; cin >> tmp;
        B.push_back(tmp);
    }
    sort(v.begin(),v.end());
    do {
        cnt++;
        REP(i, N) {
            if (v[i] != A[i]) break;
            if (i == N-1) a = cnt;
        }
        REP(i, N) {
            if (v[i] != B[i]) break;
            if (i == N-1) b = cnt;
        }

    } while (std::next_permutation(v.begin(), v.end()));
    cout << abs(a-b) << endl;
    return 0;
}


Measured memory_bytes: 256
ref = "23456789TJQKA"
def judge(hand,leader):
    led = hand[leader][1]
    mx = tx = winner = -1
    for i in xrange(4):
        num,suit = ref.index(hand[i][0]),hand[i][1]
        if suit == trump:
            if num > tx:
                tx = num
                winner = i
        elif tx == -1:
            if suit == led and num > mx:
                mx = num
                winner = i
    return winner
    
while 1:
    trump = raw_input()
    if trump == "#": break
    hands = [raw_input().split() for i in xrange(4)]
    hands = zip(hands[0],hands[1],hands[2],hands[3])
    leader = ns = ew = 0
    for hand in hands:
        leader = judge(hand, leader)
        if leader in [0,2]: ns += 1
        else: ew += 1
    if ns > ew: print "NS",ns-6
    else: print "EW",ew-6

Measured memory_bytes: 4260
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;
string a,b,c;

ll mod(ll a)
{
	if(a<inf)return a;
	else 
	return a%inf;
}
 void test_cases()
{


ll sx,sy,tx,ty;
cin>>sx>>sy>>tx>>ty;


	for(ll i=0;i<abs(sx-tx);i++)cout<<"R";
	for(ll i=0;i<abs(sy-ty)+1;i++)cout<<"U";
	for(ll i=0;i<abs(sx-tx)+1;i++)cout<<"L";
	for(ll i=0;i<abs(sy-ty)+1;i++)cout<<"D";
	cout<<"R";
		for(ll i=0;i<abs(sy-ty);i++)cout<<"U";
	for(ll i=0;i<abs(sx-tx)+1;i++)cout<<"R";
	for(ll i=0;i<abs(sy-ty)+1;i++)cout<<"D";
	for(ll i=0;i<abs(sx-tx)+1;i++)cout<<"L";

	cout<<"U";	

 
}


int main()
{
    fast;
  ll t;
 // cin>>t;
 t=1;
  while(t--)
  test_cases();

  	
}

		
	
	
	
	


Measured memory_bytes: 3536
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define int long long

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

    int a,b,k; cin >> a >> b >> k;
    if(a >= k){
        a -= k;
        k = 0;
    }else{
        k -= a;
        a = 0;
    }

    if(b >= k){
        b -= k;
        k = 0;
    }else{
        k -= b;
        b = 0;
    }

    cout << a << " " << b << endl;

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
//      String[] t=sc.nextLine().split("");
//    String nyuA=sc.nextLine();
   String nyu=sc.nextLine();

//int n=Integer.parseInt(nyu);

//int A=Integer.parseInt(t[0]);
//int B=Integer.parseInt(t[1]);

HashSet<String> list=new HashSet<>();

String[] t=nyu.split("");

for(String tem:t)list.add(tem);

ArrayList<String> list2=new ArrayList<>(list);
int flag=0;
for(String temptemp:list2){
int count=0;
for(String temptemps:t){
if(temptemp.equals(temptemps))count++;
}//fort
if(count%2!=0)flag=1;
}//for

if(flag==0)
System.out.println("Yes");
else
System.out.println("No");


	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {

  ll n;
  vector<ll> a;
  cin >> n;
  a.resize(n);
  for(int i=0; i<n; ++i) cin >> a[i];

  ll ans = 0;
  ll max = 0;

  for(int i=0; i<n; ++i) {
    if(max<=a[i]) {
      max = a[i];
    }else {
      ans += max-a[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  map<int,int> a;
  for (int i = 0; i < n; ++i)
  {
    int tmp;
    cin>>tmp;
    a[tmp]++;
  }

  bool table[(int)1e6+30]={};
  for(const auto& f: a) 
  {
    int e=f.first;
    if(f.second!=1) table[e]=true;
    int i=2;
    while(e*i<=1e6+20)
    {
      table[e*i]=true;
      i++;
    }
  }
  int ans=0;
  for(const auto& e: a) 
  {
    if(!table[e.first]) ans++;
  }
  cout<<ans<<endl;
}

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

const int maxn = 5e5 + 10;

int n;
int a[maxn];
int ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
}

void solve(){
    int mina = maxn;
    for(int i = 0; i < n; i++){
        if(mina > a[i]){
            ans++;
            mina = a[i];
        }
    }
}

void out(){
    cout << ans;
}


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

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	bool ok = 1;
	int H,W,N,x,y;
	string A,B;
	cin >> H >> W >> N;
	cin >> x >> y;
	cin >> A;
	cin >> B;
	x--;y--;
	//まずは横方向に出す事を考える
	//left,right
	int left = 0,right = W; //[left,r-1]の範囲にyが存在すると横方向生存
	for(int i=N-1;i>=0;i--){
		if(B[i]=='L')right = min(right+1,W);
		else if(B[i]=='R') left = max(0,left-1);
		
		if(A[i]=='L')left = left + 1;
		else if(A[i]=='R') right = right - 1;
		
		if(left>=right)ok = 0;
	}
	if(y<left || y>=right)ok = 0;
	//up,down
	left = 0,right = H;
	//xを反転させる まず右端までの距離を出す 
	x = H-1-x;
	for(int i=N-1;i>=0;i--){
		if(B[i]=='D')right = min(right+1,H);
		else if(B[i]=='U')left = max(left-1,0);
		if(A[i]=='D')left++;
		else if(A[i]=='U')right--;
		if(left>=right)ok = 0;
	}
	if(x<left || x>=right)ok = 0;
	if(ok)cout << "YES" << endl;
	else cout << "NO" << endl;
	
}


Measured memory_bytes: 920
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int local = a + b;
        int nowA = 0;
        int nowB = 0;

        String[] s = sc.next().split("");

        for (int i = 0; i < s.length; i++) {
            switch (s[i]) {
                case "a":
                    if (nowA + nowB < local) {
                        nowA++;
                        System.out.println("Yes");
                    } else {
                        System.out.println("No");
                    }
                    break;
                case "b":
                    if (nowA + nowB < local && nowB < b) {
                        nowB++;
                        System.out.println("Yes");
                    } else {
                        System.out.println("No");
                    }
                    break;
                case "c":
                    System.out.println("No");
                    break;
            }
        }
    }
}

Measured memory_bytes: 47304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    vector<int> a(3);
    rep(i,3)cin >> a[i];

    sort(ALL(a));

    cout << (a[0]+a[1] == a[2]?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
int one = min(b,d);
int zero = max(a,c);
if(c>=b){cout<<0;}
else {
	
	cout<<max(0,one-zero);
}

	
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll ans = 1000;
    int pos = 0;
    while(pos < n)
    {
        while(pos < n-1 && a[pos] >= a[pos+1]) pos++;
        if(pos == n-1) break;
        int s = a[pos];
        pos++;
        while(pos < n-1 && a[pos] <= a[pos+1]) pos++;
        ans = (ans / s) * a[pos] + ans % s;
        pos++;
    }
    cout << ans << endl;
}




        


Measured memory_bytes: 3620
#include<stdio.h>
int main (){
  int n,i;
  int A[100001];
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&A[i]);
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2>=1) printf("parent key = %d, ",A[i/2]);
    if(i*2<=n) printf("left key = %d, ",A[i*2]);
    if(i*2+1<=n) printf("right key = %d, ",A[i*2+1]);
    printf("\n");
  }
  return 0;
}





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

int main(void)
{
	int n;
	while (cin >> n, n){
		int x, y, h, w;
		int ret = 0;
		for (int i = 0; i < n; ++i)
		{
			cin >> x >> y >> h >> w;
			int max_type = 0, sum = x + y + h;
			if (sum <= 60) max_type = 1;
			else if (sum <= 80) max_type = 2;
			else if (sum <= 100) max_type = 3;
			else if (sum <= 120) max_type = 4;
			else if (sum <= 140) max_type = 5;
			else if (sum <= 160) max_type = 6;
			else max_type = 7;

			if (w <= 2) max_type = max(max_type, 1);
			else if (w <= 5) max_type = max(max_type, 2);
			else if (w <= 10) max_type = max(max_type, 3);
			else if (w <= 15) max_type = max(max_type, 4);
			else if (w <= 20) max_type = max(max_type, 5);
			else if (w <= 25) max_type = max(max_type, 6);
			else max_type = 7;

			if (max_type == 1) ret += 600;
			else if (max_type == 2) ret += 800;
			else if (max_type == 3) ret += 1000;
			else if (max_type == 4) ret += 1200;
			else if (max_type == 5) ret += 1400;
			else if (max_type == 6) ret += 1600;
		}

		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
PROGRAM averageLength
      IMPLICIT NONE
      integer :: n
      real(8),allocatable :: x(:),y(:)
      integer :: i,a,b
      real(8) :: ans,counter
      
      
      read*,n
      ALLOCATE( x(n),y(n) )
      DO i = 1,n
        read*,x(i),y(i)
      END DO
      
      
      ans = 0
      counter = 0
      DO a = 1,n-1
        DO b = a+1,n
          ans = ans + sqrt( (x(a)-x(b))**2+(y(a)-y(b))**2 )
          counter = counter + 1
        END DO
      END DO
      
      ans = ans / counter * real(n-1)
      
      print*,ans
      
      
      END PROGRAM

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

#define INF 1000000000
using namespace std;

struct edge {
    int from;
    int to;
    int w;
};
struct node {
    node() : id {-1}, d {INF}, ns {} {};
    node(int i, vector<edge>& vec) : id {i}, d {INF}, ns {vec} {};
    int id;
    int d;
    vector<edge> ns;
};

struct node_s {
    int id;
    int d;
};

vector<int> dijkstra(node* graph, int n, int st){
    auto ds = vector<int>(n, INF);
    auto comp = [](node_s* x, node_s* y){return x->d > y->d;};
    priority_queue<node_s*, vector<node_s*>, decltype(comp)> que(comp);
    node_s* start = new node_s {graph[st].id, 0};
    que.push(start);
    while(que.size()){
        node_s* n = que.top();
    //    cout << n->id << ' ' << n->d << endl;
        que.pop();
        if(n->d < ds[n->id]){
            ds[n->id] = n->d;
            for(auto e : graph[n->id].ns){
                if(ds[e.to] < INF){
                    continue;
                }
                node_s* next_n = new node_s {graph[e.to].id, ds[n->id] + e.w};
                que.push(next_n);
            }
        }
        delete n;
    }
    return ds;
}

int main(){
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    int n;
    cin >> n;
    node graph[n];
    for(int i = 0; i < n; ++i){
        int id;
        int m;
        cin >> id >> m;
        auto vec = vector<edge>(m);
        int v, c;
        for(int j = 0; j < m; ++j){
            cin >> v >> c;
            vec[j] = edge {id, v, c};
        }
        graph[id] = node(id, vec);
    }
    auto ds = dijkstra(graph, n, 0);
    for(int i = 0; i < n; ++i){
        cout << i << ' ' << ds[i] << endl;
    }
}

Measured memory_bytes: 16672
n = int(input())
a = [int(i) for i in input().split()]
ans = -1
true = 1

while true == 1:
    for i in range(n):
        if a[i]%2 != 0:
            true = 0
            break
        else:
            a[i] /= 2
    ans += 1

print(ans)

Measured memory_bytes: 9092
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 5e5 + 5;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int x, n, v;
	cin >> x >> n;
	set<int> S;
	for (int i = 0; i < n; i++) {
		cin >> v;
		S.insert(v);
	}
	for (int i = 0; i <= n; i++) {
		if (S.find(x - i) == S.end()) {
			cout << x - i << endl;
			return 0;
		}
		if (S.find(x + i) == S.end()) {
			cout << x + i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x)
{
    x=0;
    static int p;p=1;
    static char c;c=getchar();
    while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
    while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0');c=getchar();}
    x*=p;
}
int n,m;
int a[60];
long long dp[60][3010],sum[60];
int main()
{
    read(n);read(m);
    for(int i=1;i<=n;i++) read(a[i]),sum[i]=sum[i-1]+a[i];
    long long ans=0;
    dp[0][0]=1;
    for(int j=1;j<=n;j++)
        for(int i=j;i>=1;i--)
            for(int k=sum[j];k>=a[j];k--)
                dp[i][k]+=dp[i-1][k-a[j]];
    for(int i=1;i<=n;i++)
        ans+=dp[i][i*m];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1408
a=input()
if a=="SUN":
    print(7)
elif a=="MON":
    print(6)
elif a=="TUE":
    print(5)
elif a=="WED":
    print(4)
elif a=="THU":
    print(3)
elif a=="FRI":
    print(2)
else :
    print(1)


Measured memory_bytes: 2940
//-----------------------
// author : xyqkoala
// time : 2020-09-14
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


int dfs(vector<int> &dp,int x){
	if(x<0) return 0;
	if(dp[x] != -1) return dp[x];
	if(x==0) return dp[x];
	if(x<3) return 0;
	dp[x] = 0;
	for(int i=3;i<=x;i++){
		dp[x] = (dp[x]+dfs(dp,x-i))%MOD;
	}
	return dp[x];
}
void solve(){
	int n;
	cin>>n;
	vector<int> dp(n+1,-1);
	dp[0] = 1;
	cout<<dfs(dp,n)<<endl;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

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

  ll ans = a * d;
  ans = max(ans, a * c);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  cout << ans << endl;
}


Measured memory_bytes: 3636
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)
#define IINF ((int)1e9)


MY_NAMESPACE(testbed)
int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll n;
	cin >> n;
	string res;
	while (n != 0)
	{
		n--;
		ll reminder = n % 26;
		n -= reminder;
		n /= 26;
		char c = 'a' + (char)reminder;
		res = string{ c } + res;
	}
	cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define data_type int

int main()
{

   ios_base::sync_with_stdio(false),cin.tie(nullptr);
    data_type n,m,w,a,b;
    cin>>n>>w>>m;
    map<pair<int,int>,int>pai;
    vector<data_type>row(n+1,0),col(w+1,0);
    vector<pair<data_type,data_type>>ro,co;
    for(int i=0; i<m; i++)
        {
            cin>>a>>b;
            pai[{a,b}]++;
            row[a]++,col[b]++;
        }
    ro.push_back({0,0});
    co.push_back({0,0});
    for(int i=1; i<=n; i++)
            ro.push_back({i,row[i]});
for(int i=1; i<=w; i++)
            co.push_back({i,col[i]});

    sort(ro.begin(),ro.end(),[](auto i,auto j){if(i.second==j.second) return i.first<j.first; return i.second>j.second;});
    sort(co.begin(),co.end(),[](auto i,auto j){if(i.second==j.second) return i.first<j.first; return i.second>j.second;});
    data_type ans=0;
    for(int i=0; i<=n; i++)
        {

            ans=max(ans,ro[i].second+co[0].second-pai[{ro[i].first,co[0].first}]);
            ans=max(ans,ro[i].second+co[1].second-pai[{ro[i].first,co[1].first}]);
        }

  for(int i=0; i<=w; i++)
        {

            ans=max(ans,co[i].second+ro[0].second-pai[{ro[0].first,co[i].first}]);
            ans=max(ans,co[i].second+ro[1].second-pai[{ro[1].first,co[i].first}]);
        }

        cout<<ans<<endl;





    return 0;

}


Measured memory_bytes: 103920
#include <cstdio>
#include <cstring>

using namespace std;
const int Max_N(305);
const int MOD(1000000000 + 7);
typedef long long int LL;

constexpr int Mult(int a, int b)
{
	return a * 1LL * b % MOD;
}

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

inline void update(int &a, int b)
{
	a = Add(a, b);
}

int N, F[2][Max_N << 1][Max_N << 1], Ans;
bool sure[Max_N << 1], app[Max_N << 1];

int main()
{
	scanf("%d", &N);
	int allempty(0);
	for (int i = 1, x, y;i <= N;++i)
	{
		scanf("%d%d", &x, &y);
		if (x != -1 && y != -1)
			sure[x] = sure[y] = true;
		else
			if (x != -1 || y != -1)
				app[x + y + 1] = true;
			else
				++allempty;
	}
	F[1][0][0] = 1;
	for (int i = 2 * N, now = 1, lst = 0, a = 0, b = 0;i >= 1;--i)
	{
		if (sure[i])
			goto loop;
		now ^= 1, lst ^= 1, memset(F[now], 0, sizeof(F[now]));
		for (int j = 0;j <= 2 * N;++j)
			for (int k = 0;k <= 2 * N;++k)
			{
				if (!F[lst][j][k])
					continue;
				int p = allempty - ((a - j) - (b - k)) / 2;
				if (app[i])
				{
					update(F[now][j][k + 1], F[lst][j][k]);
					if (j)
						update(F[now][j - 1][k], F[lst][j][k]);
				}
				else
				{
					update(F[now][j + 1][k], F[lst][j][k]);
					if (k)
						update(F[now][j][k - 1], Mult(F[lst][j][k], k));
					if (j && p)
						update(F[now][j - 1][k], Mult(F[lst][j][k], p));
				}
			}
		if (app[i])
			++b;
		else
			++a;
		loop :
		if (i == 1)
			printf("%d", F[now][0][0]);
	}
	return 0;
}

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

typedef long long ll;

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

    pair<int, int> T=make_pair(0, N);
    cout << 0 << endl;
    string s;
    cin >> s;
    if (s == "Vacant") return 0;

    map<int, string> mp;
    mp[0] = s;
    mp[N] = s;

    for (int i = 0; i < 19; i++) {
        int q = (T.second-T.first)/2 + T.first;
        cout << q << endl;
        string s;
        cin >> s;
        if (s == "Vacant") return 0;

        mp[q] = s;
        if ((q-T.first)%2) {
            if (s==mp[T.first]) T.second=q;
            else T.first=q;
        } else {
            if (s!=mp[T.first]) T.second=q;
            else T.first = q;
        } 
    }
}


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

using namespace std;

typedef long long ll;

constexpr int M = 1000 * 1000 * 1000 + 7;

vector<int> g[100000];

int dist[100000][3];

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[--u].push_back(--v);
    }
    int s, t;
    cin >> s >> t;
    --s;
    --t;
    queue<pair<int, pair<int, int>>> q;
    q.push({s, {0, 1}});
    while (!q.empty()) {
        pair<int, pair<int, int>> cur = q.front();
        q.pop();
        int point = cur.first;
        int dd = cur.second.first;
        int dst = cur.second.second;
        if (dist[point][dd]) {
            continue;
        }
        dist[point][dd] = dst;
        ++dd;
        dd %= 3;
        for (int to: g[point]) {
            if (dist[to][dd]) continue;
            q.push({to, {dd, dst + 1}});
        }
    }
    if (dist[t][0] == 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << (dist[t][0] - 1) / 3 << endl;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int N;
vector<vector<pair<int,int>>> tr;
vector<int> ans;

void DFS(int v,int p,int c){
    ans[v] = c;
    for(auto nv:tr[v]){
        if(nv.first == p) continue;
        if(nv.second%2==1){
            DFS(nv.first,v,(c+1)%2);
        }else{
            DFS(nv.first,v,c);
        }
    }
}

int main(){
    cin >> N;
    tr.assign(N,vector<pair<int,int>>());
    rep(i,N-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        tr[u].push_back(make_pair(v,w));
        tr[v].push_back(make_pair(u,w));
    }
    ans.assign(N,0);
    DFS(0,-1,0);
    rep(i,N) cout << ans[i] << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    int n = s.size();
    for(int i = 0; i < n; i++) {
        if (s[i] == 'S') {
            cnt++;
        } else {
            if (cnt > 0) {
                cnt--;
                ans+=2;
            }
        }
    }
    cout << n - ans << endl;
    return 0;
}


Measured memory_bytes: 3756
import java.util.*
 
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val d = sc.nextInt()
    var n = sc.nextInt()
    if (n == 100) {
        n++
    }
    println(n.toString() + (1..d).map { "00" }.joinToString(""))
}

Measured memory_bytes: 31396
n = int(input())
edgeList = []
rootList = [-1 for i in range(n)]
parent = [-1 for i in range(n)]
lenList = [0 for i in range(n)]
sumLength = 0
for i in range(n):
    a = list(map(int, input().split()))
    for j in range(a[1]):
        edgeList.append([a[2*j+3], i, a[2*j+2]])


rootList = [-1 for i in range(n)]
parent = [0 for i in range(n)]
lenList = [float("inf") for i in range(n)]
lenList[0] = 0
def getRoot(x):
    r = rootList[x]
    if r < 0:
        rootList[x] = x
    elif r != x:
        rootList[x] = getRoot(r)
    return rootList[x]

flag = True
while flag:
    flag = False
    edgeList.sort(key=lambda x: (x[0] + lenList[x[1]]))
    for e in edgeList:    # weight:e[0], e[1]->e[2]
        if e[2] == 0:
            continue
        x = getRoot(e[1])
        y = getRoot(e[2])
        if x == 0 != y:
            parent[e[2]] = e[1]
            lenList[e[2]] = lenList[e[1]] + e[0]
            rootList[y] = 0
            flag = True
            break

for i, j in zip(range(n), lenList):
    print(i, j)

Measured memory_bytes: 6436
a,b=map(int,input().split())
if a == 0 or b == 0:
    print('Zero')
elif a < 0 and b > 0:
    print('Zero')
elif a > 0:
    print('Positive')
else:
    d = b - a + 1
    if d % 2 == 0:
        print('Positive')
    else:
        print('Negative')


Measured memory_bytes: 61692
from collections import Counter
from itertools import product

def solve():
    N = int(input())
    As = list(map(int, input().split()))

    def getMinPFs(n):
        isPrimes = [False]*2 + [True]*(n-1)
        minPFs = [1] + list(range(1, n+1))
        for d in range(2, int(n**0.5)+1):
            if isPrimes[d]:
                minPFs[d] = d
                for x in range(d*d, n+1, d):
                    isPrimes[x] = False
                    if minPFs[x] == x:
                        minPFs[x] = d
        return minPFs

    def getPrimeFactors(x, minPFs):
        anss = []
        while minPFs[x] > 1:
            anss.append(minPFs[x])
            x //= minPFs[x]
        return anss

    maxA = max(As)
    minPFs = getMinPFs(maxA)
    As.sort()

    cntA = Counter(As)

    ans = 0
    setA = set()
    for A in As:
        if cntA[A] == 1:
            PFs = getPrimeFactors(A, minPFs)
            cnt = Counter(PFs)
            ps = list(cnt.keys())
            es = [range(cnt[p]+1) for p in ps]
            L = len(ps)
            for nums in product(*es):
                d = 1
                for i in range(L):
                    d *= ps[i]**nums[i]
                if d in setA:
                    break
            else:
                ans += 1

        setA.add(A)

    print(ans)


solve()


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

int main(){
  int n, m;
  cin >> n >> m;
  int val = (n-m)*100 + m*1900;
  int p = 1;
  for(int i = 0; i < m; i++)
    p *= 2;
  cout << val*p << "\n";
  return 0;
}


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

// limit
#define mod1 22439423LL
#define mod2 42342432LL
#define mod3 56454765LL
#define mod4 66867574LL
#define oo 1000000007LL
#define OO 1000000000000000007LL

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
// structure
#define ii pair<int, int>
#define iii pair<ii, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vi>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const ii& a, const ii& b) {return (a.FF > b.FF || (a.FF == b.FF && a.SS >= b.SS));}
ll GCD(ll a, ll b) {return (a%b) ? GCD(b, a%b) : b;}

const string namePro = "tmp";
#define maxN 1000007

bool check[maxN];

int main(){

    string s;
    cin >> s;

    fto (i, 0, (int)s.size()-1) {
    	check[s[i]] = 1;
    }

    fto (i, 'a', 'z') {
    	if (!check[i]) {
    		cout << (char)i << endl;
    		return 0;
    	}
    }

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

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


int main()
{
    string a;
    int ans=0;
    cin>>a;
    for(int i=0;i<a.size();++i) {
        ans=ans*10+a[i]-'0';
        ans%=9;
    }
    if(!ans) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3748
color = input().rstrip("\n")

l1 = [str(i % 2) for i in range(len(color))]
l2 = [str((i + 1) % 2) for i in range(len(color))]

s1 = s2 = 0
for c, n1, n2 in zip(color, l1, l2):
    s1 += (c != n1)
    s2 += (c != n2)

print(min(s1, s2))

Measured memory_bytes: 15860
#include <iostream>

int main() {
    
    int i = 0;
    
    while (true) {
        
        int x = 0;
        std::cin >> x;
    
        if (x == 0) {
            break;
        } 
        
        i++;
        std::cout << "Case " << i << ":" << " " << x << std::endl; 
    }
}


Measured memory_bytes: 3112
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  int i,j,n,tmp,ans,a[5000];

  while(scanf("%d",&n) && n){
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    
    ans = a[0];
    for(i=0;i<n;i++){
      for(j=i;j<n;j++){
	if(i==j)tmp = 0;
	tmp += a[j];
	ans = max(tmp,ans);
      }
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int A, B;
  while (cin >> A >> B) {
    int res = A * B - A - B + 1;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
list_num = list([] for i in range(n))
test = [input().split() for i in range(m)]
for i in test:
  list_num[int(i[0]) - 1].append(i[1])
count = 0
count_ac = 0
count_wa = 0
check = 0
for i in list_num:
  for j in range(len(i)):
    if(i[j] =='WA'):
      count += 1
    elif(i[j] == 'AC'):
      count_ac += 1
      check = 1
      break
  if(check == 1):
    count_wa += count
    check = 0 
  count = 0
print(count_ac , count_wa)


Measured memory_bytes: 43980
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */
/* main */
int main(){

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

    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        int c; cin >> c;
        int b, e; cin >> b >> e;
        auto first = A.begin() + b;
        auto last = A.begin() + e;
        vector<int> v(first, last);

        if (c) {
            cout << *max_element(first, last) << '\n';
        }
        else {
            cout << *min_element(first, last) << '\n';
        }
    }

}



Measured memory_bytes: 3160
N=[]
time=0
tmp=10
for i in range(5):
    N.append(int(input()))

for i in N:
    if i%10==0:
        time += i


    else:
        if i%10<tmp:
            tmp=i%10
        time += i+(10-i%10)

if tmp ==10:
    tmp==0

print(time+tmp-10)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> h(n);
	int mx = 0;
	for(int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	
	if( n == 1 ) { 	
		cout << "Yes" << endl;
		return 0;
	}
	
	bool yes = true;
	for(int i = 0; i < n; ++i) {
		
		if( mx > h[i] + 1 ) {
			yes = false;
			break;
		}
		
		mx = max(mx, h[i]);
	}
	
	if( yes ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
  char moji[100];
  int x=0,n,max=0;
  scanf("%d",&n);
  scanf("%s",moji);
  for(int i=0;i<n;i++){
    if(moji[i]=='I')
      x++;
    else
      x--;
    if(x>max)
      max=x;
  }
  printf("%d",max);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);

int main(){
	ll n;cin>>n;
    rep(i,3600){
        if(i==0)continue;
        rep(j,3600){
            if(j==0)continue;
            ll mo = 4*i*j-n*i-n*j,ki=n*i*j;
            if(mo>0&&ki%mo==0){
                cout<<i<<' '<<j<<' '<<ki/mo<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#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 pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string s;
  cin >> s;
  int K;
  cin >> K;
  v(string) strs;
  rep(i,sz(s)) {
    string tmp = "";
    for(int k = i;k < min(i + K,sz(s));k++) {
      tmp = tmp + s[k];
      strs.push_back(tmp);
    }
  }
  sort(rng(strs));
  strs.erase(unique(rng(strs)),strs.end());
  cout << strs[K-1] << endl;
  return 0;
}

Measured memory_bytes: 1660
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int x, y;
  cin >> x >> y;
  for (int i = 0; i <= x; i++) {
    int total = i * 2 + (x - i) * 4;
    if (total == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

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

int f[10000];

int main() {
  int n;
  cin >> n;
  rep(i, n) f[i] = 0;
  for (int i = 1; i <= 100; i++) for (int j = 1; j <= 100; j++) for (int k = 1; k <= 100; k++) {
    int x = i * i + j * j + k * k + i * j + j * k + k * i;
    if (x <= n) {
      f[x - 1]++;
    }
  }

  rep(i, n) {
    cout << f[i] << endl;
  }

  return 0;
}
/*
*/


Measured memory_bytes: 3508
#include <stdio.h>
#include <string.h>
int main()
{
	char str[201];
	int l, m, h, i, j, k;
	while(1){
		scanf("%s", str);
		l=strlen(str);
		if(str[0]=='-' && l==1){
			break;
		}
		scanf("%d", &m);
		for(i=0; i<m; i++){
			scanf("%d", &h);
			for(j=0; j<h; j++){
				str[l]=str[l-1];
				str[l-1]=str[0];
				str[0]=str[l];
				str[l]='\0';
				for(k=1; k<l-1; k++){
					str[l]=str[k];
					str[k]=str[k-1];
					str[k-1]=str[l];
					str[l]='\0';
				}
			}
		}
		printf("%s\n", str);
	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cmath>

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

    std::vector<int> vec(n, 0);
    for(int i = 1; i < n; ++i){
        vec.at(i) = 1 + vec.at(i - 1);
    }

    std::vector<std::pair<double, double>> pos(n);
    for(int i = 0; i < n; ++i){
        double x, y;
        std::cin >> x >> y;
        pos.at(i) = std::make_pair(x, y);
    }

    int count = 0;
    bool flg = true;
    std::vector<double> dists;
    while(flg){
        double dist = 0;
        for(int i = 0; i < n - 1; ++i){
            int start = vec.at(i), end = vec.at(i + 1);
            double x = pos.at(start).first - pos.at(end).first; 
            double y = pos.at(start).second - pos.at(end).second; 
            dist += std::sqrt(std::pow(x, 2) + std::pow(y, 2));
        }
        dists.push_back(dist);

        flg = std::next_permutation(vec.begin(), vec.end());
    }

    std::cout << std::fixed << std::setprecision(7);
    std::cout << std::accumulate(dists.begin(), dists.end(), 0.0) / dists.size();
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 892
import bisect

while 1:
    n,m = map(int, input().split())
    if n == m == 0:
        break
    h = [int(input()) for i in range(n)]
    w = [int(input()) for j in range(m)]
    for i in range(n-1):
        h[i+1] += h[i]
    for i in range(m-1):
        w[i+1] += w[i]
    h.insert(0,0)
    w.insert(0,0)
    a = [0 for i in range(n*(n+1)//2)]
    b = [0 for i in range(m*(m+1)//2)]
    k = 0
    for i in range(1,n+1):
        for j in range(i):
            a[k] = h[i]-h[j]
            k += 1

    k = 0
    for i in range(1,m+1):
        for j in range(i):
            b[k] = w[i]-w[j]
            k += 1

    ans = 0
    b.sort()
    for i in a:
        l = bisect.bisect_left(b,i)
        r = bisect.bisect_right(b,i)
        ans += r-l
    print(ans)



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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  multiset<int> pos, neg;
  rep(i, n) {
    int a;
    cin >> a;
    if (a >= 0)
      pos.insert(a);
    else
      neg.insert(a * -1);
  }

  vector<pii> vp;
  rep(i, n - 1) {
    int x, y;
    if (pos.size() == 0) {
      x = *neg.begin();
      neg.erase(neg.begin());
      y = *neg.begin();
      neg.erase(neg.begin());
      vp.eb(mp(x * -1, y * -1));
      pos.insert(y - x);
    } else if (neg.size() == 0) {
      x = *pos.begin();
      pos.erase(pos.begin());
      y = *pos.begin();
      pos.erase(pos.begin());
      vp.eb(mp(x, y));
      neg.insert(y - x);
    } else {
      x = *pos.begin();
      pos.erase(pos.begin());
      y = *neg.begin();
      neg.erase(neg.begin());

      if (pos.size() > neg.size()) {
        vp.eb(mp(y * -1, x));
        neg.insert(x + y);
      } else {
        vp.eb(mp(x, y * -1));
        pos.insert(x + y);
      }
    }
  }

  int ans = pos.size() == 0 ? *neg.begin() : *pos.begin();
  cout << ans << endl;
  rep(i, vp.size()) cout << vp[i].F << ' ' << vp[i].S << endl;
}


Measured memory_bytes: 7284
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,q;
  cin >> n >> k >> q;
  vector<int> ans(n,k-q);
  for(int i=0;i<q;i++){
    int a;
    cin >> a;
    ans.at(a-1)+=1;
  }
  for(int x:ans){
    if(x>0){
      cout << "Yes" <<endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}
    

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
map<ll, ll> primefactor(ll n)
{
  map<ll, ll> div;
  ll nn = n;
  for (int i = 2; i * i <= nn; i++)
  {
    if (n % i == 0)
    {
      div[i]++;
      n /= i;
      i--;
    }
  }
  if(n!=1)div[n]++;
  return div;
}
int main()
{
  ll n;
  cin >> n;
  map<ll, ll> m = primefactor(n);
  cout << n << ":";
  for (auto i = m.begin(); i != m.end(); ++i)
  {
    rep(j, i->second) cout << " " << i->first;
  }
cout << endl;
  return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define int long long
int ans;

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

int lcm(int x,int y){
	return x*y/gcd(x,y);
}
 
signed main(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2==1)cout<<b-a<<endl;
	else cout<<a-b<<endl;
}

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

using namespace std;
int kt(vector<int> &a)
{
    int n = a.size();
    int mid = a.size()/2;
    {
        int a2 = a[mid], a1 = a[mid-1], a3 = a[mid+1];
        if(a1==a2||a2==a3)
            return a2;
    }
    int l = mid, r = mid;
    while(l>0)
    {
        if(a[l]==(1-a[l-1]))
        l--;
        else
        break;
    }
    while(r<(n-1))
    {
        if(a[r]==(1-a[r+1]))
        r++;
        else
        break;
    }
    int x = r-mid;
    int y = mid-l;
    if(x>y) return a[l];
    return a[r];
}
int main()
{
    //freopen("input","r",stdin);
    int n;
    cin >> n;
    vector<int> a(2*n-1);
    for(int i = 0;i<2*n-1;i++)
    cin >> a[i];
    int l = 1;
    int r = 2*n-1;
    int soll = -1;
    while(l<=r)
    {
        int mid = (l+r)/2;
        vector<int> b;
        for(int i = 0;i<2*n-1;i++)
        b.push_back((a[i]>=mid));
        int sol = kt(b);
        if(sol==0)
            r = mid-1;
        if(sol==1)
        {
            l = mid + 1;
            soll = mid;
        }
    }
    cout << soll;
    return 0;
}


Measured memory_bytes: 2896