akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    ll n; cin >> n;
    vector<int> avec(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> avec.at(i);
    }

    vector<int> aans(n, 0);
    ll ans = avec.at(0);
    for(int i = 1; i < n; ++i) {
        ans ^= avec.at(i);
    }

    for(int i = 0; i < n; ++i) {
        aans.at(i) = ans ^ avec.at(i);
    }

    for(int i = 0; i < n; ++i) {
        if(i == n-1) cout << aans.at(i) << endl;
        else cout << aans.at(i) << " ";
    }
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
    int N,v,j;
    cin>>N;
  
  vector<int> A(N+1);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
  
  
  
    for(int i=0;i<N;i++){
        v=A[i];
        j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
    for(int i=0;i<N-1;i++){
        cout<<A[i]<<" ";
    }
    cout<<A[N-1]<<endl;
    }
}


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int num = sc.nextInt(), len = sc.nextInt(), one = 0;
		int[] n = new int[num];
		for(int i = 0; i < num; i++) {
			n[i] = sc.nextInt();
			if(n[i] == 1)one = i;
		}
		int s = one, t = num-1-one, as = s/(len-1), at=t/(len-1);
		int amari = num - (as+at)*(len-1);
		if(amari == 1) {
			System.out.println(as+at);
		} else if(amari <= len) {
			System.out.println(as+at+1);
		} else {
			System.out.println(as+at+2);
		}
	}
}

Measured memory_bytes: 50588
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int cnt[MX];


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin >> n;
	int sum = 0;
	fi(0, n) {
		int x;
		cin >> x;
		cnt[x]++;
		sum += x;
	}   	
	int q;
	cin >> q;
	fi(0, q) {
		int b, c;
		cin >> b >> c;
		sum -= b * cnt[b];
		sum -= c * cnt[c];
		cnt[c] += cnt[b];
		cnt[b] = 0;
		sum += cnt[c] * c;
		cout << sum << '\n'; 
	}
   	
}

Measured memory_bytes: 4432
#include<stdio.h>

int main()
{
	int h, w, i, j;
	char s[300];

	while(1) {
		scanf("%d%d", &h, &w);

		if(h == 0 && w == 0) break;

		for(i = 0; i < h; i++) {
			for(j = 0; j < w; j++) {
				printf("#");
			}
			printf("\n");
		}

		printf("\n");
	}

	return 0;
}



Measured memory_bytes: 2040
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

c = 0
d = 0

n.times{|i|
  c += [a[i]-b[i], 0].max
  d += [b[i]-a[i], 0].max/2
}

puts (c<=d) ? "Yes" : "No"


Measured memory_bytes: 3964
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define CLR2d(x,m,n) memset(x, -1, sizeof(x[0][0]) * m * n)
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
ll po(ll b,ll p){
    ll res=1;
    while(p){
        res*=b;
        p--;
    }
    return res;
}
ll lg2(ll x){
    ll res=0;
    while(x>1){
        res++;
        x/=2ll;
    }
    return res;
}
void solve(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    rep(i,n){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 3612
#include <stdio.h>
#define NMAX 1000000
int main(void) {
     int n[NMAX];
     int num,i,j,m,ntemp,p;
     while(scanf("%d\n",&num)!=EOF){
         if(num<3){
             if(num<2){
                 printf("0\n");
                 continue;
             }
             printf("1\n");
             continue;
         }
         
         p=0;
         j=0;
         for(i=2;i<=num;i++){
             n[j]=i;
             j++;
         }
         
         ntemp=j;
         n[j]=num;
         //printf("j=%d,num=%d\n",j,num);
         do{
             m=n[0];
             //printf("m=%d\n",m);
             //ntemp=num;
             //i=j;
             j=0;
             for(i=0;i<ntemp;i++){
                 if(n[i]%m!=0){
                     n[j]=n[i];
                     //printf("i=%d,j=%d,n[%d]=%d\n",i,j,j,n[j]);
                     j++;
                 }
             }
             ntemp=j;
             p++;
             //printf("m=%d,n[%d]=%d\n",m,j-1,n[j-1]);
        }while(n[j-1]>m*m);
        //printf("p=%d,j+p=%d\n",p,j+p);
        printf("%d\n",j+p);
     }
        return 0;
}

Measured memory_bytes: 4516
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string s;
int n;
vector< vector<int> > vvi;
int maxsize = 0;

int changei(string s){
	int res;
	stringstream ss;
	ss << s;
	ss >> res;
	return res;
}

vector<int> changevi(string s){
	vector<int> vi;
	int res;
	string t;
	REP(i, s.size()){
		if (i == s.size() - 1){
			t += s[i];
			res = changei(t);
			vi.push_back(res);
			t.clear();
		}
		else {
			if (s[i] == ','){
				res = changei(t);
				vi.push_back(res);
				t.clear();
			}
			else{
				t += s[i];
			}
		}
	}
	return vi;
}

int dp[100][100];

int main(){
	while (cin >> s){
		vector<int> vi = changevi(s);
		maxsize = max((int)(vi.size()), maxsize);
		vvi.push_back(vi);
	}
	dp[0][0] = vvi[0][0];
	REP(i, 2 * maxsize - 1){
		REP(j, vvi[i + 1].size()){
			if (i + 1 <= maxsize - 1){
				if (j == 0){
					dp[i + 1][j] = dp[i][j] + vvi[i + 1][j];
				}
				//else if (j == vvi[i + 1].size() - 1){
				//	dp[i + 1][j] = dp[i][j - 1] + vvi[i + 1][j];
				//}
				else {
					dp[i + 1][j] = max(dp[i][j - 1], dp[i][j]) + vvi[i + 1][j];
				}
			}
			else{
				dp[i + 1][j] = max(dp[i][j], dp[i][j + 1]) + vvi[i + 1][j];
			}
		}
		/*REP(j, vvi[i].size()){
			cout << dp[i][j] << " ";
			}
			cout << endl;*/
	}
	//REP(i, 2 * maxsize-1){
	//	REP(j, vvi[i].size()){
	//		cout << dp[i][j] << " ";
	//	}
	//	cout << endl;
	//}
	cout << dp[2 * maxsize - 1 - 1][0] << endl;
}

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

int32_t main(){
	int n, k; cin>>n>>k;
	int ans = 0;
	while(true){
		if(n < k){
			ans++;
			break;
		}
		else{
			ans++;
			n /= k;
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int n;
char s;
long long int ans=0;
long long int ansn=0;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s; 
        if(s=='I'){
            ansn++;
        }
        else if(s=='D'){
            ansn--;
        }
        ans=max(ans,ansn);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000

int main() {
	int n;
	string s;
	cin >> s;
	n = s.size();
	//s = stoi(s);
	int target;
	vector<int> a, b;
	rep(i, n) {
		if (i % 2 == 0) {
			a.push_back(0);
			b.push_back(1);
		}
		else {
			a.push_back(1);
			b.push_back(0);
		}
	}
	int amin = 0,bmin = 0;
	rep(i, n) {
		target = s[i] - '0';
		if (target == a[i]) {
			amin++;
		}

		if (target == b[i]) {
			bmin++;
		}

	}
	cout << min(amin, bmin) << endl;
	return 0;
}

Measured memory_bytes: 1404
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
int main(){
	int s,w;
	cin>>s>>w;
	if(s<=w){
		cout<<"unsafe"<<endl;
	}else{
		cout<<"safe"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
#define mk make_pair
int a,b,c,d,a1,a2;
double p=0,e,f;
int main(){
  cin>>a>>b>>c>>d>>e>>f;
  vector<int>v;
  r(i,3000){
    r(j,3000){
      if(a*j*100+b*i*100<=f)v.push_back(a*j*100+b*i*100);
    }
  }
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  vector<int>v2;
  r(i,3000){
    r(j,3000){
      if(c*j+d*i<=f)v2.push_back(c*j+d*i);
    }
  }
  sort(v2.begin(),v2.end());
  v2.erase(unique(v2.begin(),v2.end()),v2.end());
  r(i,v.size()){
    r(j,v2.size()){
      double b1=v[i],b2=v2[j];
      if(b1){
      if(b1+b2<=f&&(b2/b1<=e/100)){
        if(b2/b1>=p){
          p=b2/b1;
          a1=b1;
          a2=b2;
        }
      }}
      else{
        if(0>=p){
          a1=b1,a2=b2;
        }
      }
    }
  }
  cout<<a1+a2<<' '<<a2<<endl;
}

Measured memory_bytes: 1400
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Main {

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

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);
    int n = cin.nextInt();
    long res = (n-2)*180;
    System.out.println(res);

  }

}

Measured memory_bytes: 23124
N,K = gets.split.map &:to_i
es = (0..N).map{ {} }
(N-1).times{
  a,b = gets.split.map &:to_i
  es[a][b] = es[b][a] = 1
}

ans = K
Mod = 10**9+7
queue = [0, es[1].keys.map{ |n| [1,n] }].flatten
Visited = Array.new(N+1,false)
VisitedCount = Array.new(N+1, 0)
Visited[1] = true
while queue.size > 0 do
  n = queue.pop
  break if n == 0
  VisitedCount[n] += 1
  next if Visited[n]
  Visited[n] = true
  ans = (ans * [K-VisitedCount[queue[-1]]-1, 0].max) % Mod
  es[n].keys.each{ |m|
    next if Visited[m]
    queue << n; queue << m
  }
end

p ans

Measured memory_bytes: 41780
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
x = na()
minx = min(x)
maxx = max(x)
ans = 10 ** 9 + 7
for i in range(minx, maxx+1):
    tmp = 0
    for j in range(n):
        tmp += (i-x[j])**2
    ans = min(tmp, ans)
print(ans)

Measured memory_bytes: 3064
import Control.Applicative ((<$>))
import Control.Monad (unless)

main :: IO ()
main = do
  [a, b, c] <- map read <$> words <$> getLine
  unless (a == 0 && b == 0 && c == 0) $ do
    putStrLn $ solve a b c
    main

solve :: Int -> Int -> Int -> String
solve a b c | d < 0 = "Impossible"
            | d /= srd ^ 2 = "Impossible"
            | otherwise = unwords . map show $ if p' > r' then [p', q', r', s']
                                               else if p' < r' then [r', s', p', q']
                                                    else if q' > s' then [p', q', r', s']
                                                         else [r', s', p', q']
  where d = b ^ 2 - 4 * a * c
        srd = floor . sqrt . fromIntegral $ d
        (p', q') = let g = gcd (2*a) (b-srd) in ((2*a) `div` g, (b-srd) `div` g)
        (r', s') = let g = gcd (2*a) (b+srd) in ((2*a) `div` g, (b+srd) `div` g)



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

int main(){
    ll n; cin >> n;
    ll ans = (n - 1) * n / 2 ;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  ll N;
  cin>>N;
  int len = int(to_string(N).size());
  string s = to_string(N);
  bool flag(true);
  for (int i(0);i<len-1;i++){
    if (to_string(N)[i+1] != '9'){
      flag = false;
    }
  }
  int cnt = int(to_string(N).size()) - 1;
  if (flag) cout << 9*cnt+(to_string(N)[0]-'0') << endl;
  else{
    cout << cnt*9 + (to_string(N)[0]-'1') << endl;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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

int main(){
	//input
	ll H,W,K; cin>>H>>W>>K;
	vector<bool> exist(H+1,false);
	vector<vector<char>> field(H+1,vector<char>(W+1));
	vector<vector<ll>> ans(H+1,vector<ll>(W+1));

	rep1(i,H){
		string tmp; cin>>tmp;
		rep1(j,W) field[i][j]=tmp[j-1];
	}

	rep1(i,H){
		rep1(j,W){
			if(field[i][j]=='#') exist[i]=true;
		}
	}

	ll mem;
	rrep1(i,H){
		if(exist[i]){
			mem=i;
			break;
		}
	}

	vector<ll> copy(H+1);
	rrep1(i,H){
		if(exist[i]){
			mem=i;
			copy[i]=i;
		}
		else{
			copy[i]=mem;
		}
	}

	//output
	ll color=1;
	rep1(i,H){
		if(exist[i]){
			ll tmpc=color;
			rep1(j,W){
				if(field[i][j]=='#'){
					if(color==tmpc) tmpc--;
					else color++;
				}
				ans[i][j]=color;
			}
			color++;
		}
	}
	rep1(i,H){
		if(!exist[i]){
			rep1(j,W){
				ans[i][j]=ans[copy[i]][j];
			}
		}
	}

	rep1(i,H){
		rep1(j,W){
			cout<<ans[i][j]<<" ";
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
void solve(){
    map <string,int> mp;
    int n;
    cin >> n;
    while(n --) {
        string x;
        cin >> x;
        mp[x] ++;
    }
    for(string s : {"AC", "WA", "TLE", "RE"}) {
        cout << s << " x " << mp[s] << "\n";
    }
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s; cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else if(s == "ARC") cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3648
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = (arg[0].split(" ")[0]);
    const N = S.length;
    
    let answer = 0;
    let cnt = [...Array(2020)].fill(0);
    cnt[0] = 1;
    
    let total = 0;
    let p = 1;
    
    for(let i=N-1; i>=0; i--) {
        total = (total + parseInt(S[i]) * p) % 2019;
        
        // console.log("total:" + total);
        // console.log("S[i]:" + S[i]);
        
        answer += cnt[total];
        
        p = (p * 10) % 2019;
        // console.log("p:" + p);
        // console.log("------");
        cnt[total]++;
    }
    
    // console.log(cnt);
    console.log(answer);
    
    // console.log(7121 % 2019)
    // console.log(14 % 2019)
    // console.log(712114 % 2019)
    // console.log(712100 % 2019)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 32656
n,y=map(int,input().split())
y//=1000
for i in range(y//10+1):
    #we are gonna use i 10 notes
    cur=y-10*i
    for j in range(cur//5+1):
        #we are gonna use j 5 notes
        k=cur-5*j
        if k>=0 and i+j+k==n and 10*i+5*j+k==y:
            print(i,j,k)
            import sys
            sys.exit()
print('-1 -1 -1')


Measured memory_bytes: 3060
import math

def p(ws, k, pmin, pmax):
    if pmax - pmin <= 1:
        return pmax

    mid = pmin + math.ceil((pmax - pmin)/2)
    ts = []

    t = 0
    for w in ws:
        if mid < t+w:
            ts.append(t)
            t = 0

        t += w

    if t > 0:
        ts.append(t)

    if len(ts) <= k:
        return p(ws, k, pmin, mid)
    else:
        return p(ws, k, mid, pmax)

def main():
    n, k = [int(x) for x in input().split(' ')]

    pmin = 0
    sumW = 0
    ws = []

    for _ in range(n):
        w = int(input())
        ws.append(w)

        pmin = max(pmin, w)
        sumW += w

    print(p(ws, k, pmin-1, sumW))

if __name__ == '__main__':
    main()



Measured memory_bytes: 22336
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        int[] t = in.ni(n);
        int m = in.ni();
        int[][] p = new int[m][2];
        for (int i = 0; i < m; i++) {
            p[i][0] = in.ni()-1;
            p[i][1] = in.ni();
        }
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += t[i];
        }
        for (int i = 0; i < m; i++) {
            out.println(sum-t[p[i][0]]+p[i][1]);
        }
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

using namespace std;
const int MAX = 200020;

vector<vector<int> > g(MAX);
vector<int> h(MAX);



int main(){
	int n,m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	for(int i = 0; i < m; i++){
		int a,b; cin >> a >> b;
		a--,b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int cnt = 0;
	for(int i = 0; i < n; i++){
		int ok = true;
		for(int j : g[i]){
			if(h[j] >= h[i]){
				ok = false;
			}
		}
		cnt+=(ok==true);
	}	
	cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 11372
N = int(input())
ans = 100000
for A in range(N+1):
    num = 0
    B = N-A
    while A != 0:
        num  += A % 6
        A = A//6
    while B != 0:
        num  += B % 9
        B = B//9
    ans = min(ans,num)
print(ans)

Measured memory_bytes: 9040
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);cerr<<fixed<<setprecision(5);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
/* VARIABLE DECLARATION START */
int globe[int(1e6)];
/*  FUCNTION TEMPLATE STARTS  HERE */
double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   int n,t;cin>>n>>t;
   vector<int>v(n);
   for(auto &x:v)cin>>x;
   vector<int>v2(n);
   int maxm=INT_MIN;
   for(int i=n-1;i>=0;--i)
   {
     v2[i]=maxm;
     maxm=max(maxm,v[i]);
   }
   multiset<int>s;
   for(int i=0;i<n-1;++i)
   {
     s.insert(v2[i]-v[i]);
   }
   int element=*(s.rbegin());
   int cnt=s.count(element);
   cout<<cnt<<endl;
   
}



Measured memory_bytes: 5888
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool up_min(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool up_max(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }

    ll operator"" _64(unsigned long long x){ return ll(x); }
    ull operator"" _64u(unsigned long long x){ return ull(x); }

    template<class T>
    vector<T> make_mdvector(int n, T t){
        return vector<T>(n, t);
    }
    template<class ...Ts>
    auto make_mdvector(int n, Ts ... ts){
        return vector<decltype(make_mdvector(ts...))>(n, make_mdvector(ts...));
    }

    inline ll bit(int x){
        return 1ll << x;
    }

    template<class T>
    istream& operator>>(istream& is, vector<T>& v){
        for (auto &&x : v) { is >> x; } return is;
    }

    template<class T>
    ostream& operator<<(ostream& os, const vector<T>& v){
        for (auto &&x : v) { os << x << ' '; } cout << endl; return os ;
    }
}
using namespace utils;

class solver{
    istream& is;
    ostream& os;

public:
    solver(istream& I, ostream& O) :is(I), os(O) {}
    ll N;
    void run();
};

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef XELMH
    string test_cases = "test_E.txt";
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int loop = 0;
    while(fs) {
        loop++;
        cout << '#' << loop << "#------\n";
        solver(fs, cout).run();
    }
    if(loop <= 1) {
        cout << "===" << endl;
        while(cin) solver(cin, cout).run();
    }
#else
    solver(cin, cout).run();
#endif
    return 0;
}


void solver::run(){
    ll K;
    is >> N >> K;
    if(!is) return;
    vector<ll> A(N); is >> A;
    map<ll, int> dsc;
    dsc[0] = 1;
    ll sum = 0;
    queue<ll> lsum;
    lsum.push(0);
    ll count = 0;
    for (int i = 0; i < N; ++i) {
        if(i >= K-1){
            dsc[lsum.front()]--;
            lsum.pop();
        }
        ll c = (A[i] - 1) % K;
        sum += c;
        sum %= K;
        count += dsc[sum];

        lsum.push(sum);
        dsc[sum]++;
    } // end i
    os << count << endl;
}


Measured memory_bytes: 16000
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
s = input()
t = input()

if s == t:
    res = N
else:
    for i in range(1, N+1):
        if s[i:] == t[:-i]: break
    res = N + i

# 出力
print(res)


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

namespace narabikae4_28
{
    class Program
    {
        static void Main(string[] args)
        {
            string O = Console.ReadLine();
            string E = Console.ReadLine();

            string pass = "";
            for (int i = 0; i < E.Length; i++)
            {
                pass = pass + O[i] + E[i];
                    }
            if (O.Length != E.Length)
            {
                pass = pass + O[O.Length - 1];
            }
            Console.WriteLine(pass);
          
        }
    }
}


Measured memory_bytes: 11092
import math

mod = 10**9+7
n, k = map(int, input().split())

cnt = [0]*(k+1)

for i in range(1, k+1):
    cnt[i] = pow(k//i, n, mod)

for i in range(k+1, 0, -1):
    j = 2
    while i*j <= k:
        cnt[i] -= cnt[i*j]
        cnt[i] %= mod
        j += 1

ans = 0

for i in range(1, k+1):
    ans += cnt[i]*i
    ans %= mod

print(ans)


Measured memory_bytes: 69016
data class Node(var parentNodeNum: Int = -1, var depth: Int = 0, var nodeType: NodeType = NodeType.ROOT, val childMap: MutableMap<Int, Node> = mutableMapOf())
enum class NodeType {
    ROOT {
        override fun toString() = "root"
    },
    INTERNAL_NODE {
        override fun toString() = "internal node"
    },
    LEAF {
        override fun toString() = "leaf"
    }
}

fun main(args: Array<String>) {
    val inputList = List(readLine()?.toInt() ?: return) {
        readLine()?.split(" ".toRegex())?.map(String::toInt) ?: listOf()
    }
    val nodeMap = mutableMapOf<Int, Node>()
    inputList.forEach { input ->
        val nodeNum = input[0]
        nodeMap.putIfAbsent(nodeNum, Node())
        nodeMap[nodeNum]?.let { parentNode ->
            input.subList(2, input.size).forEach { childNum ->
                nodeMap.putIfAbsent(childNum, Node())
                nodeMap[childNum]?.let { childNode ->
                    childNode.parentNodeNum = nodeNum
                    parentNode.childMap[childNum] = childNode
                }
            }
        }
    }
    nodeMap.values.find { it.parentNodeNum == -1 }?.let { rootNode ->
        recDepth(rootNode, 0)
    }
    val stringBuilder = StringBuilder()
    for (i in inputList.indices) {
        nodeMap[i]?.let { node ->
            stringBuilder.append("node $i: parent = ${node.parentNodeNum}, depth = ${node.depth}, ${node.nodeType}, ${node.childMap.keys}\n")
        }
    }
    print(stringBuilder.toString())
}

fun recDepth(node: Node, depth: Int) {
    node.depth = depth
    when {
        node.parentNodeNum == -1 -> node.nodeType = NodeType.ROOT
        node.childMap.isEmpty() -> node.nodeType = NodeType.LEAF
        else -> node.nodeType = NodeType.INTERNAL_NODE
    }
    node.takeIf { it.childMap.isNotEmpty() }?.childMap?.forEach { _, child ->
        recDepth(child, depth + 1)
    }
}


Measured memory_bytes: 168920
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  map<int, int> mp;
  rep(i, 0, n) {
    int a;
    cin >> a;
    if (mp[a])
      mp[a] = 0;
    else
      mp[a] = 1;
  }

  int ans = 0;
  for (auto m : mp) {
    if (m.second)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while( x->left != NIL){
    x = x->left;
  }
  return x;

}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
  while( u != NIL && k != u->key ){
    if (k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;

}

Node treeSuccessor(Node x){
  if( x->right != NIL){
    return treeMinimum(x->right);
  }
  Node y = x->parent;
  while( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if( z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if( y->left != NIL){
    x = y->left;
  }
  else x = y->right;

  if(x != NIL ){
    x->parent = y->parent;
  }

  if( y->parent == NIL ){
    root = x;
  }
  else {
    if(y == y->parent->left){
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if( y != z ){
    z->key = y->key;
  }

  free(y);

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if ( z->key < y->key ){
      y->left = z;
    }else {
      y->right = z;
    }
  }

}

void inorder(Node u){
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N, X;
    cin >> N >> X;
    vector<ll> L(N);
    REP(i, N) cin >> L[i];

    ll res = 1;
    ll now = 0;
    REP(i, N){
    	now += L[i];
    	if(now<=X) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

typedef complex<double> Vec;

double dot(Vec a, Vec b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double cross(Vec a, Vec b) {
	return a.real() * b.imag() - a.imag() * b.real();
}

Vec ver[3];

bool solve(double R) {
	double S = abs(cross(ver[2] - ver[0], ver[1] - ver[0]) / 2.0);
	double edlen[3];
	REP(i, 3) edlen[i] = abs(ver[(i + 1) % 3] - ver[i]);
	double inr = 2*S / accumulate(edlen, edlen + 3, 0.0);
	// inr : inr - R
	if (inr <= R) return false;
	
	double mxlen = *max_element(edlen, edlen + 3);
	
	double aflen = mxlen * (inr - R) / inr;
	return aflen >= 2 * R;
}

int main() {
	REP(i, 3) {
		int x, y;
		scanf("%d %d", &x, &y);
		ver[i] = Vec(x, y);
	}
	
	double l = 0, r = 1000;
	REP(i, 100) {
		double m = (l + r) / 2;
		if (solve(m)) l = m;
		else r = m;
	}
	
	printf("%.15f\n", l);
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<assert.h>
using namespace std;
int n,sz,a[505][505];
int main()
{
	scanf("%d",&n);
	if(n<=500)
	{
		printf("%d\n",n);
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			printf("%d ",i);
			puts("");
		}
	}
	else
	{
		int k=n-500,sz=-1;
		puts("500");
		for(int i=1;i<=k;i++)
		{
			sz+=2;
			for(int j=1,k=i;j<=500;j++,k++,sz^=1)
			{
				if(j>500) j-=500;
				if(k>500) k-=500;
				a[j][k]=sz;
			}
		}
		for(int i=k+1;i<=500;i++)
		{
			++sz;
			for(int j=1,k=i;j<=500;j++,k++)
			{
				if(j>500) j-=500;
				if(k>500) k-=500;
				a[j][k]=sz;
			}
		}
		for(int i=1;i<=500;i++)
		{
			for(int j=1;j<=500;j++)
			printf("%d ",a[i][j]+1);
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 2176
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	ll ans = 1e18;
	cin >> n;
	for (ll i = 1; i*i <= n; i++) {
		if (n%i != 0) continue;
		ll j = n/i;
		ans = min(ans, i+j-2);
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

int main() {
  int n;
  cin >> n;
  int count = 0;
  for (int x = 1; x <= n - 1; ++x) {
    int prime = 0;
    for (int y = 1; y * y <= x; ++y) {
      if (x % y == 0) {
        prime++;
        if (x / y != y) prime++;
      }
    }
    count += prime;
  }
  cout << count << endl;
}


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

bool isPalindrome(string s){
  for(int i=0;i<s.length()/2;i++){
    if(s[i]==s[s.length()-1-i]) continue;
    else return false;
  }
  return true;
}

int main(){
  string s;
  cin >> s;
  if(isPalindrome(s)&&isPalindrome(s.substr(0,s.length()/2))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

main()
{
	
	int i,x,n;
	
	i=1;
	
	scanf("%d",&n);
	while(i <= n){
		x = i;
		if(x % 3 == 0)
		printf(" %d",i);
		else{
			while(x){
			if(x % 10 == 3){
			printf(" %d", i);
			break;
			}
			else
			x /= 10;
			}
			}
			i++;
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a>=b && a>=c) cout << b+c << endl;
    else if(b>=a && b>=c) cout << a+c << endl;
    else cout << a+b << endl;

    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(0));
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];
    return 0;
}

Measured memory_bytes: 3656
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

class Inning{
	int Point;
	int OutCount;
	boolean First;
	boolean Second;
	boolean Third;
	
	public void InitInning(){
		Point = 0;
		OutCount = 0;
		First = false;
		Second = false;
		Third = false;
	}
	
	public void DoHit(){
		if(Third == true){
			Point += 1;
			Third = false;
		}
		if(Second == true){
			Third = true;
			Second = false;
		}
		if(First == true){
			Second = true;
			First = false;
		}
		First = true;
	}
	
	public void DoOut(){
		OutCount += 1;
		if (OutCount==3){
			EndEninng();
		}
	}
	
	public void DoHomerun(){
		if(Third == true){
			Point += 1;
			Third = false;
		}
		if(Second == true){
			Point += 1;
			Second = false;
		}
		if(First == true){
			Point += 1;
			First = false;
		}
		Point += 1;
	}
	
	public void EndEninng(){
		System.out.println(Point);
		InitInning();
	}
}

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int Inning = 0;
		String str;
		
        Inning obj = new Inning();
		obj.InitInning();
		
		while(scan.hasNext()){
        	if (Inning ==0){
        		Inning = scan.nextInt();
        	}else{
        		str = scan.next();
    			if(str.equals("HIT")){
					obj.DoHit();
					//System.out.println("Hit");
				}else if(str.equals("HOMERUN")){
					obj.DoHomerun();
					//System.out.println("Homerun");
				}else if(str.equals("OUT")){
					obj.DoOut();
					//System.out.println("Out");
				}
        	}
        }
	}
}

Measured memory_bytes: 17216
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 1; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    ll H;
    cin >> H;
    
    ll bi = 0;
    ll temp = 1;
    rep(i, H) {
        bi++;
        temp *= 2;
        if(temp > H) {
            bi--;
            break;
        } 
        if(temp==H){
            break;
        }
    }
    ll ans = 1;
    temp = 1;
    FORR(i, 0, bi) {
        temp *= 2;
        ans += temp;
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string c;
    cin >> c;
    int l = 0;
    int r = n-1;
    int ans = 0;
    while(l < r){
        while(l<n && c[l]=='R')l++;
        while(r>=0 && c[r]=='W')r--;
        if(l>=r)break;
        
        ans++;
        l++;
        r--;

    }
    cout << ans << endl;
}

Measured memory_bytes: 3752