akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
inline int in(){ int x; scanf("%d",&x); return x;}

typedef pair<int,int> P;

P data[10000];

int main(){
  int i,j,k;
  int a,b;

  for(i = 0; ; i++){
    scanf("%d,%d",&a,&b);
    if(a == 0 && b == 0) break;
    data[i] = P(b,a);
  }

  int n = i;
  sort(data,data+n,greater<P>());
//  rep(i,n) cout << data[i].second << "," << data[i].first << endl;

  int team;
  while(scanf("%d",&team) != EOF){
    int res = 1;
    for(i = 0; i < n; i++){
      if(i-1 >= 0 && data[i].first < data[i-1].first) res++;
      if(data[i].second == team){
        printf("%d\n",res);
        break;
      }
    }
  }

  return 0;
}

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

namespace E
{
    class Program
    {
        static List<int> min_factor = new List<int>();
        static void Main(string[] args)
        {
            var n = Int32.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(" ").Select(s => Int32.Parse(s)).ToList();

            min_factor = new List<int>();
            for(var i=0;i<=1000000;i++){
                min_factor.Add(i); 
            }
            for(int i=2; i*i<=1000000; i++){
                if(min_factor[i] < i) continue;
                for(int j=i*i; j<=1000000; j+=i){
                    if(min_factor[j] == j) min_factor[j] = i;
                }
            }
            var p = new List<List<int>>();
            var values = new Dictionary<int, int>();
            foreach (var val in a)
            {
                p.Add(new List<int>());
                var facts = PrimeFactors(val);
                foreach (var hoge in facts.Distinct())
                {
                    if(!values.ContainsKey(hoge)) values[hoge] = 0;
                    values[hoge]++;
                    //p.Last().Add(hoge);
                }
            }



            bool flag1 = true;
            var f2 = true;
            foreach(var v in values){
                if(v.Key == 1) continue;
                if(v.Value > 1) {
                    flag1 = false;
                }
                if(v.Value >= n) {
                    f2 = false; 
                }
            }
            if(flag1) {
                Console.WriteLine("pairwise coprime");
                return;
            }
            else if(f2) {
                Console.WriteLine("setwise coprime");
                return;
            }
            Console.WriteLine("not coprime");
        }
        public static IEnumerable<int> PrimeFactors(int n)
        {
            int tmp = n;

            while (tmp > 1)
            {
                yield return min_factor[tmp];
                tmp = tmp / min_factor[tmp];
            }
            yield return 1;
        }
    }
}

Measured memory_bytes: 124472
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                             \
  cerr << __LINE__ << ": " << #x << " = {";          \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) { \
    cerr << ((hoge) ? "," : "") << x[hoge];          \
  }                                                  \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long L;
  cin >> L;
  double ans = double(L * L * L) / 27;
  cout << fixed << setprecision(12) << ans << endl;
  return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, d;
    int l, r;
    cin >> a >> b >> c >> d; 
    l = a + b;
    r = c + d;
    if (l > r){
        cout << "Left" << endl;
    }else if (l == r){
        cout << "Balanced" << endl;
    }else if (l < r){
        cout << "Right" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
import bisect
mod=10**9+7
AA=[]
ans1=0
for i in range(n):
  ans1+=i-bisect.bisect_right(AA,A[i])
  AA.append(A[i])
  AA.sort()
ans2=0
for i in range(n-1):
  ans2+=n-bisect.bisect_right(AA,AA[i])

ans=(ans1*k)%mod
ans=(ans+ans2*k*(k-1)//2)%mod
print(ans)

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

const int inf=1e9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};	

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

	bool ok=true;
	for (int i = 0; i < n; i++){
		int a;
		cin>>a;
		if(a%2==0 and !(a%3==0 or a%5==0))
			ok=false;
	}

	if(ok){
		cout<<"APPROVED"<<endl;;
	}else{
		cout<<"DENIED"<<endl;
	}


	return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n, d;

int main() {
    cin >> n >> d;
    d = d * 2 + 1;
    int res = n / d + (n % d ? 1 : 0);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
vector<ll>adj[100005];
ll power(ll x, ll y,ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        ll w=(p*p)%z;
        if(y%2==0)
         return w;
        else
        return (x*w)%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
void dfs(ll x,vector<bool>& visit)
{
    visit[x]=true;
    for(auto it=adj[x].begin();it!=adj[x].end();it++)
    {
        if(visit[*it]==false)
        {
            dfs(*it,visit);
        }
        
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
  ll n,m,c=0;
  cin>>n>>m;
  vector<bool> visit(n + 1, false);
  for(int i=0;i<m;i++)
  {
      ll x,y;
      cin>>x>>y;
      adj[x].push_back(y);
      adj[y].push_back(x);
  }
  for(ll i=1;i<=n;i++)
  {
      if(visit[i]==false)
      {
          c++;
          dfs(i,visit);
      }
  }
  cout<<c-1;}
 

Measured memory_bytes: 10740
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int aBuried = sc.nextInt();
        int bBuried = sc.nextInt();
        
        int difference = bBuried - aBuried;
        int realB = difference * (difference + 1) / 2;
        int piledSnow = realB - bBuried;
        
        System.out.println(piledSnow);
    }
}


Measured memory_bytes: 21972
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)

int32_t a,b;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> a >> b; if((a*b)%2){
		out<<"Odd"<<endl;
	}
	else{
		out << "Even" << endl;
	}
	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)

int32_t N;
int32_t x,y,t=0;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	while (N--)
	{
		int32_t x2, y2, t2;
		in >> t2 >> x2 >> y2 ;

		int32_t xd = x2 - x,yd=y2-y,td=t2-t;

		if (((std::abs(xd) + std::abs(yd)) & 1) != (td & 1)) {
			out << "No\n"; return 0;
		}
		if ((std::abs(xd) + std::abs(yd)) > td) {
			out << "No\n"; return 0;
		}

		x = x2; y = y2; t = t2;
	}
	out << "Yes\n";

	return 0;
}
#endif


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000
  
int main(){
  int *A,*B;
  
  int C[VMAX+1];
  int n,i,j;
  scanf("%d",&n);
  
  A=malloc(sizeof(int)*n+1);
  B=malloc(sizeof(int)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i]=0;
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i]+=C[i-1];
  
  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  
  
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 16272
import itertools

N, K = map(int, input().split())
X = 0

grid = []
for i in range(K*2):
    array = list(map(int, input().strip().split()))
    grid.append(array)

grid2 = []

for j in range(K):
    grid2.append(grid[j*2+1])

grid2 = list(itertools.chain.from_iterable(grid2))

for k in range(1, N+1):
    if k in grid2:
        pass
    else:
        X += 1

print(X)

Measured memory_bytes: 9104
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int t = sc.nextInt();
		int ans = X - t;
		if (ans < 0) {
			ans = 0;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = (1 << 30);

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

    ll n,k;
    cin>>n>>k;
    vector<ll> vec(100001);
    ll a,b;
    rep(i,n){
        scanf("%lld %lld", &a,&b);
        vec[a]+=b;
    }
    REP(i,1,100001){
        if(k<=vec[i]){
            cout<<i<<endl;
            break;
        }
        k-=vec[i];
    }

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
  string s;
  int k = 0;
  cin >> s;
  if(s[0] == '1')
    k++;
  if(s[1] == '1')
    k++;
  if(s[2] == '1')
    k++;
    cout << k;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int N; cin>>N;
    long long int count=0;
    int k=0;
    long long int c=0;
    for(long long int i=1;i<=N;i++){
        c=i;
        while(c!=0){//桁数求める
            k++;
            c=c/10;
        }
        if(k%2==0){//偶数桁
            continue;
        }
        else if(k%2!=0){//奇数桁
            count++;
        }
        k=0;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define REP(i,n) for(int i=0;i<signed(n);i++)
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
const ll MOD = 1000000007;
const ll INF = 9e9;
ll N, M, ans = INF;
ll A[300010], S[301000];
using namespace std;
int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        S[i]+=A[i];
        S[i+1]=S[i];
    }
	//a:右半分の区切り i:真ん中 b:左半分
	//s:右の和 t:左の和
	ll a = 0, b = 2, s, t;
	REP(i, N - 1) {
		if (i == b)b++;
		s = (S[i] - S[a]) - S[a];
		t = (S[N - 1] - S[b]) - (S[b] - S[i]);
		bool f = true;
		if (i == 0)continue;
		while (f) {
			f = false;
			if (a + 1 == i)continue;
			if (abs(s)>abs(s - A[a + 1] * 2)) {
				s -= A[a + 1] * 2;
				a++; f = true;
			}
		}
		f = true;
		while (f) {
			f = false;
			if (b + 1 == N - 1 || b == N - 1)continue;
			if (abs(t)>abs(t - A[b + 1] * 2)) {
				t -= A[b + 1] * 2;
				b++; f = true;
			}
		}
		ans = min(ans, (max({ S[a],S[i] - S[a],S[b] - S[i],S[N - 1] - S[b] })
			- min({ S[a],S[i] - S[a],S[b] - S[i],S[N - 1] - S[b] })));
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int,a,b);
	OUT(b%a==0?a+b:b-a)BR;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	int N,K;
	cin>>N>>K;
	V<int> a(N);
	rep(i,N) cin>>a[i];
	int inf = 1e9;
	V<int> dp(N+1,inf);
	dp[0] = 0;
	rep(i,N){
		rep1(t,K){
			int j = i+t;
			if(j<N) chmin(dp[j],dp[i] + abs(a[i]-a[j]));
		}
	}
	cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1024
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};
  
#include <iostream>
#include <vector>
#include <string>
#include <functional>
using namespace std;
const int INF = 1e9;
 
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj(n);
    for(int _ : in(m)) {
        int u, v;
        cin >> u >> v;
        adj[u].emplace_back(v);
        adj[v].emplace_back(u);
    }
    vector<int> depth(n, INF), ub(n, INF);
    vector<bool> isArt(n, false);
    function<void(int, int, int)> dfs = [&](int v, int p, int d) {
        depth[v] = d;
        ub[v] = d;
        int k = 0;
        for(int nv : adj[v]) {
            if(nv == p) continue;
            if(depth[nv] == INF) {
                ++k;
                dfs(nv, v, d + 1);
                ub[v] = min(ub[v], ub[nv]);
                if(d && ub[nv] >= depth[v]) isArt[v] = true; // ???????????????
            }
            else {
                ub[v] = min(ub[v], depth[nv]);
            }
        }
        if(!d && k > 1) isArt[v] = true;
    };
    dfs(0, -1, 0);
    for(int i : in(n)) if(isArt[i]) cout << i << '\n';
    return 0;
}

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

int main(){
    int N;
    vector<int> a(400000),ans(400000);
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
        ans[i]=a[i];
    }

    sort(ans.begin(),ans.begin()+N);

    int num=0;
    for(int i=0;i<N;i++) num+=(ans[i]==a[i]);
    if(num==N){
        cout<<0<<endl;
        return 0;
    }

    int Q;
    cin>>Q;

    for(int i=0;i<Q;i++){
        int x,y;
        cin>>x>>y;

        if(ans[x-1]==a[x-1]) num--;
        if(ans[y-1]==a[y-1]) num--;
        swap(a[x-1],a[y-1]);
        if(ans[x-1]==a[x-1]) num++;
        if(ans[y-1]==a[y-1]) num++;

        if(num==N){
            cout<<i+1<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 5828
#include <iostream>

using namespace std;

double high,low,m;
int main() {
	cin >> m;
	high = low = m;
	while(cin >> m){
		if(m>high){
			high = m;
		}else if(m<low){
			low = m;
		}
	}
	cout << high-low << endl; 
	return 0;
}

Measured memory_bytes: 0
A = input()
B = input()
if len(A) > len(B):
    ans = 'GREATER'
elif len(A) < len(B):
    ans = 'LESS'
elif len(A) == len(B):
    ans = 'EQUAL'
    for i in range(len(A)):
        if int(A[i]) > int(B[i]):
            ans = 'GREATER'
            break
        elif int(A[i]) < int(B[i]):
            ans = 'LESS'
            break
print(ans)

Measured memory_bytes: 9148
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>





using namespace std;
int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a*c > b)cout << b /a << endl;
	else cout << c << endl;


	return 0;
}

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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

int main(){
	int n;
	double ans=0;
	
	cin >> n;
	
	double a[n];
	
	for(int i=0; i<n; i++)	cin >> a[i];
	
	for(int i=0; i<n; i++)	ans+=1/a[i];
	
	printf("%.14f\n",1/ans);
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<functional>
#include<set>
using namespace std;
#define MAX 10000000

int main(){
    int h,w;
    string s[51];
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    for(int y=0;y<h;y++){
        for(int x=0;x<w;x++){
            if(s[y][x]=='#'){
                for(int dx=-1;dx<=1;dx++){
                    for(int dy=-1;dy<=1;dy++){
                        int nx=x+dx,ny=y+dy;
                        if(0<=nx&&nx<w&&0<=ny&&ny<h){
                            if(s[ny][nx]=='.')s[ny][nx]='1';
                            else if(s[ny][nx]=='#')continue;
                            else s[ny][nx]++;
                        }
                    }
                }
            }
        }
    }
    for(int y=0;y<h;y++){
        for(int x=0;x<w;x++){
            if(s[y][x]=='.')cout<<0;
            else cout<<s[y][x];
        }
        cout<<endl;
    }
    cout<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007
#define ff first
#define ss second
#define pb push_back
#define inf 10000000000

							
									//nestedcode

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,i,d,j,a,ans;
    cin>>n;
    map<ll,ll> m;
    for(i=2;i*i<=n;i++){
    	while(n%i == 0){
    		m[i]++;
    		n/=i;
		}
	}
	if(n>1)	m[n]++;
	ans = 0;
	for(auto x: m){
		d = x.ss;
		j = 1;
		a = 1;
		while(1){
			if(j*(j+1)/2 <= d){
				a = j;
				j++;
			}else{
				break;
			}
		}
		ans += a;
	}
	cout<<ans;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)


constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;



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

	int n, m; ll k; cin >> n >> m >> k;
	ll* a = new ll[n];
	ll* b = new ll[m];
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, m) cin >> b[i];

	vector<ll> s(n + 1);
	vector<ll> t(m + 1);

	rep(i, 0, n) s[i + 1] = s[i] + a[i];
	rep(i, 0, m) t[i + 1] = t[i] + b[i];

	ll ans = 0;
	rep(i, 0, n + 1) {
		if (s[i] > k) break;
		ll u = k - s[i];
		ll idx = upper_bound(t.begin(), t.end(), u) - t.begin();
		--idx;
		ans = max(ans, i + idx);
	}
	cout << ans;
	return 0;
}

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

signed main(){

  int n; cin >> n;

  int cnt = 0;
  for(int i = 6; i <= 55555; i++){
    if(i%5 == 1){
      int flag = 1;
      for(int j = 2; j*j <= i; j++){
        if(i%j == 0) flag = 0;
      }
      if(flag){
        cout << i << " ";
        cnt++;
      }
    }
    if(cnt == n) break;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import java.awt.Point;
import java.util.*;
public class Main {
	static Scanner s = new Scanner(System.in);
	public static void main(String __[]){
		int n=s.nextInt(),m=s.nextInt();
		Point students[] = new Point[n];
		for(int i=0;i<n;i++)
			students[i]=new Point(s.nextInt(), s.nextInt());
		CheckPoint[] checkPoints = new CheckPoint[m];
		for(int i=0;i<m;i++)
			checkPoints[i]=new CheckPoint(i+1, s.nextInt(), s.nextInt());

		for(Point st:students) {
			System.out.println(
					Arrays.stream(checkPoints)
					.min(((a,b)->
					  Math.abs(st.x-a.p.x)+Math.abs(st.y-a.p.y)
					-(Math.abs(st.x-b.p.x)+Math.abs(st.y-b.p.y)))).get().id
					);
		}
	}
}
class CheckPoint{
	Point p;
	int id;
	CheckPoint(int id,int x,int y) {
		p=new Point(x, y);
		this.id=id;
	}
}

Measured memory_bytes: 26836
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

// #define ANS  //for answer
#define CMP  //for compe
#ifdef CMP
using namespace std;
#else
#endif

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x, (x)
#define ncv(x) #x, ":", (x)
#define ncvc(x) #x, ":", (x), ","
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>
void pPRINT(std::ostream& ost, const T t, const U... u) {
  ost << t << " ";
  pPRINT(ost, u...);
}
template <class... T>
void PRINT(const T... t) { pPRINT(std::cout, t...); }
template <class... T>
void PRINTl(const T... t) {
  pPRINT(std::cout, t...);
  std::cout << "\n";
}
template <class T>
void PRINTa(const T* const t, const ll size) {
  REP(i, size)
  PRINT(t[i]);
  PRINTl();
}
template <class T>
void PRINTal(const T* const t, const ll size) {
  REP(i, size)
  PRINTl(i, ":", t[i]);
}
#ifndef DBG
#define DEBUG(...)
void init() {}
#else
#define DEBUG(...)                                                     \
  {                                                                    \
    PRINT("##DEBUG##", "file :", __FILE__, ", line :", __LINE__, "["); \
    PRINT(__VA_ARGS__);                                                \
    PRINTl("]");                                                       \
  }
void init() {
  DEBUG("INIT");
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

void solve();

int main(int argc, char* argv[]) {
  DEBUG("MAIN");
  init();
  solve();

  return 0;
}

void solve() {
  DEBUG("SOLVE START");

  string s, t;
  int n;
  cin >> n;
  cin >> s >> t;
  REP(i, n) {
    cout << s[i] << t[i];
  }

  return;
}

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

int main(){
    int n, i=0;
    cin >> n;
    if(n%1000==0)
        cout << 0 << endl;
    else
    {
        while(++i){
            if(i*1000>n)
                break;
        }
        cout << i * 1000 - n << endl;
        
    }
    
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//printf("%.12lf\n",mid);
//const long long sze = 2*(2^(long long)(ceil(log(100000)/log(2))));
/*
// get part of decimal
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
const long long mod = 1000000007;
const double eps = .0000000001;
inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
};


int main(){
    prep();
    int x, y;
    cin >> x >> y;
    cout << x+y/2;
    
    return 0;
}      

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int read() {
    char cc = getchar(); int cn = 0, flus = 1;
    while(cc < '0' || cc > '9') {  if( cc == '-' ) flus = -flus;  cc = getchar();  }
    while(cc >= '0' && cc <= '9')  cn = cn * 10 + cc - '0', cc = getchar();
    return cn * flus;
}
const int N = 1000 + 5 ; 
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
int n, m, book[N], w[N][N], vis[N], can[N];   
bool check( int x ) {
    memset( book, 0, sizeof(book) ), memset( can, 0, sizeof(can) ) ;
    int flag ; rep( i, 1, n ) vis[i] = 1, ++ book[w[i][vis[i]]] ; 
    rep( i, 1, m ) {
        flag = 1 ; 
        rep( j, 1, n ) {
            int u = w[j][vis[j]] ; 
            if( book[u] > x ) {
                can[u] = 1; flag = 0 ; 
                while( vis[j] <= n && can[w[j][vis[j]]] ) ++ vis[j] ; 
                if( vis[j] > n ) return 0; 
                ++ book[w[j][vis[j]]] ; 
            }
        }
        if( flag ) return 1; 
    }
    return 0 ; 
}
signed main()
{
    //freopen( "sport.in", "r", stdin ) ;
    //freopen( "sport.out", "w", stdout ) ; 
    n = read(), m = read() ; 
    rep( i, 1, n ) rep( j, 1, m ) w[i][j] = read() ; 
    int l = 1, r = n, ans = 0, mid ; 
    while( l <= r ) {
        mid = ( l + r ) >> 1 ; 
        if( check(mid) ) ans = mid, r = mid - 1 ; 
        else l = mid + 1 ; 
    }
    printf("%d\n", ans ) ; 
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>
 
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
 
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;
 
//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい
 
 
/////////////2
 
 
int pow(int b,int p){
	if(p==0) return 1;
	else if(p%2==0) return pow(b,p/2)*pow(b,p/2);
	else return b*pow(b,p-1);
}
 
 
int main(){
	int X;
	cin>>X;
	for(int i=X;i>=0;i--){
		for(int j=1;j<=35;j++){
			for(int k=2;k<=10;k++){
				if(i==pow(j,k)){
					cout<<i<<endl;
                  return 0;
				}
			}
		}
	}
	
	
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
two_ad = 0
four_ad = 0
other = 0
for a in A:
  if a % 4 == 0:
    four_ad += 1
  elif a % 2 == 0:
    two_ad += 1
  else:
    other += 1

ans = "No"
if four_ad >= other:
  ans = "Yes"
elif four_ad == other - 1 and not two_ad:
  ans = "Yes"
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,a[100];
    cin>>n;
    for(int i=0; i<=n; i++){
        cin>>a[i];
    }  
    sort(a,a+n);
    long ans = fabs(a[n-1]-a[0]);
    cout<<ans<<endl;

    
}


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

int solve(int a, int b, int c)
{
  return std::max(0, c - (a - b));
}

int main()
{
  int a, b, c;
  std::cin >> a >> b >> c;

  std::cout << solve(a, b, c) << std::endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(ll& x, ll y) {
	x = min(x, y);
}

void chmax(ll& x, ll y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

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

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

ll X;
ll ans;

void solve() {
	cin >> X;
	ans += X / 500 * 1000;
	X %= 500;
	ans += X / 5 * 5;
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N, K;
    cin >> N >> K;
    ll init = (N - 1) * (N - 2) / 2;
    if(init < K) {
        cout << -1 << endl;
        return 0;
    }

    VV<ll> edges(N);
    for(ll i = 1; i < N; i++) edges[i].push_back(0);
    ll a = 1, b = 2;
    while(init > K) {
        edges[a].push_back(b);
        b++;
        if(b == N) {
            a++;
            b = a + 1;
        }
        init--;
    }
    ll sum = 0;
    for(const auto &ele : edges) sum += ele.size();
    cout << sum << endl;
    for(ll i = 0; i < N; i++) {
        for(ll j : edges[i]) {
            cout << i + 1 << ' ' << j + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
/*
 * 0307.cc: Nisshinkan Marathon Club
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_R = 1000;
const int MAX_T = 1000;

/* typedef */

/* global variables */

int ps[MAX_N], rps[MAX_N], btls0[MAX_R], btls1[MAX_R];

/* subroutines */

/* main */

int main() {
  int n, r, t;
  cin >> n >> r >> t;
  for (int i = 0; i < n; i++) cin >> ps[i];

  int ans = 0;

  for (int t0 = 0; t0 < t; t0++) {
    // fill water to bottles
    for (int i = 0; i < r; i++)
      btls0[i] += btls1[i], btls1[i] = 0;

    for (int i = 0; i < n; i++) {
      // run to next point
      int &rpi = rps[i] = (rps[i] + ps[i]) % r;

      // return empty bottle (exept first point)
      if (t0 > 0) btls1[rpi]++;

      // get new bottle
      if (btls0[rpi] == 0) ans++;
      else btls0[rpi]--;
    }
  }

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

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define REP(i, a, n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lwb lower_bound
#define N 100010
#define M 200010
#define endl "\n"

ll gcd(ll a_,ll b_){if(b_>a_)swap(b_,a_);return (b_==0?a_:gcd(b_,a_%b_));}

bool c(int a, int b) {
	return a > b;
}

int arr[M];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n, k, x;
	
	cin >> n >> k;
	REP(i, 0, n){
		cin >> x;
		arr[x]++;
	}
	
	sort(arr, arr + 200010, c);
	
	int sum = 0;
	for(int i = 0; i < k; i++){
		sum += arr[i];
	}
	
	cout << n - sum << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
long long N,i,a=0;
cin>>N;
for(i=1;i<=N;i++)
{
    if(i%3==0||i%5==0)
    {
      a=a;
    }
    else
    {
        a+=i;
    }
}
cout<<a;

    return 0;
}


Measured memory_bytes: 3636
#include <chrono>
#include <vector>
#include <iostream>

using namespace std;
using namespace std::chrono;

void fill_used(vector<bool>& used, int a, int b) {
  const int n = used.size();
  used.assign(n, false);
  used[0] = true;
  for (int i = 0; i < n; ++i) {
    if (!used[i])
      continue;

    int ni = i + a;
    if (ni <= n)
      used[ni] = true;
    ni = i + b;
    if (ni <= n)
      used[ni] = true;
  }
}

int main() {
  auto start = high_resolution_clock::now();

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

  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  vector<bool> can_water(f + 1);
  fill_used(can_water, 100 * a, 100 * b);
  vector<bool> can_sugar(f + 1);
  fill_used(can_sugar, c, d);

  int ans_sugar_water = -1;
  int ans_sugar = -1;

  for (int water = 0; water <= f; ++water) {
    if (!can_water[water])
      continue;
    for (int sugar = 0; sugar + water <= f && sugar * 100 <= water * e; ++sugar) {
      if (!can_sugar[sugar])
        continue;
      if (ans_sugar == -1 || (sugar * ans_sugar_water >= ans_sugar * (sugar + water))) {
        ans_sugar = sugar;
        ans_sugar_water = sugar + water;
      }
    }
  }

  cout << ans_sugar_water << " " << ans_sugar << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 256
#素因数分解(1に対しては空のリストを返す)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import collections

n=int(input())

x=prime_factorize(n)
x=collections.Counter(x)
x=x.most_common()
ans=0

for i in range(len(x)):
    v=0
    for j in range(1,31):
        v+=j
        if x[i][1]>=v:
            ans+=1
        else:
            break
print(ans)

Measured memory_bytes: 65836
#include<iostream>
#include<cmath>
#include<stdio.h>

using namespace std;

int main(){
    double x1,x2,y1,y2,x;
    cin>>x1>>y1>>x2>>y2;
    x=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
    printf("%f\n",sqrt(x));

    return 0;
}


Measured memory_bytes: 3284
#include <iostream>

using namespace std;

int X, Y;

int main() {
  cin >> X >> Y;

  int s = 4*X - Y, t = Y - 2*X;
  if (s >= 0 && s % 2 == 0 && t >= 0 && t % 2 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

#define File(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
const int N = 55, M = 105;

const int mod = 1000000007;
inline int add(int x, int y){return x+y>=mod ? x+y-mod : x+y;}
inline int sub(int x, int y){return x-y<0 ? x-y+mod : x-y;}
inline int mul(int x, int y){return 1LL * x * y % mod;}
inline void inc(int &x, int y=1){x = x+y>=mod ? x+y-mod : x+y;}
inline void dec(int &x, int y=1){x = x-y<0 ? x-y+mod : x-y;}
inline int power(int x, int y){
	int res = 1;
	for(; y; y>>=1, x = mul(x, x)) if(y & 1) res = mul(res, x);
	return res;
}
inline int inv(int x){return power(x, mod - 2);}

vector<int> G[N];
int dfn[N], low[N], idx = 0;
int stke[M], tope = 0, eid = 0;
int stkv[M], topv = 0;
int n, m, k, res = 1;
int ex[M], ey[M];
bool vis[N][N];
bool cyclePt[N];

int C[M*2][M*2];
void preC(int n){
	C[0][0] = 1;
	for(int i=1; i<=n; i++){
		C[i][0] = 1;
		for(int j=1; j<=i; j++)
			C[i][j] = add(C[i-1][j], C[i-1][j-1]);
	}
}

int gcd(int x, int y){
	int t;
	while(y) t = x, x = y, y = t % y;
	return x;
}

void dfs(int x){
	// printf("DFS %d\n", x);
	dfn[x] = low[x] = ++idx;
	stkv[++topv] = x;
	for(int v : G[x]){
		if(vis[x][v]) continue;
		stke[++tope] = ++eid;
		ex[eid] = x; ey[eid] = v;
		vis[x][v] = vis[v][x] = true;
		if(!dfn[v]){
			int eidNow = eid;
			dfs(v);
			low[x] = min(low[x], low[v]);
			if(low[v] >= dfn[x]){
				int ce = 0, cv = 0;
				bool cycle = true;
				// printf("eidNow = %d\n", eidNow);
				// printf("Stack : (from top) ");
				// for(int i=tope; i>=1; i--) printf("%d ", stke[i]);
				// puts("");
				for(int i=tope; stke[i] != eidNow; --i){
					if(cyclePt[ey[stke[i]]]) cycle = false;
					cyclePt[ey[stke[i]]] = true;
					++ce;
				}
				++ce;
				// printf("BCC of %d edges. (is cycle : %d)\n", ce, (int)cycle);
				for(; stke[tope] != eidNow; --tope)
					cyclePt[ey[stke[tope]]] = false;
				--tope;
				while(stkv[topv] != x) --topv, ++cv;
				++cv;
				if(cycle){
					int sum = 0;
					for(int i=0; i<ce; i++){
						int d = gcd(ce, i);
						inc(sum, power(k, d));
					}
					res = mul(res, mul(sum, inv(ce)));
				}
				else
					res = mul(res, C[ce+k-1][k-1]);
			}
		}
		else low[x] = min(low[x], dfn[v]);
	}
}

int main(){
	// File("4131");
	// setbuf(stdout, nullptr);
	scanf("%d%d%d", &n, &m, &k);
	preC(m + k);
	for(int i=1; i<=m; i++){
		int u, v; scanf("%d%d", &u, &v);
		G[u].push_back(v); G[v].push_back(u);
	}
	for(int i=1; i<=n; i++)
		if(!dfn[i]) dfs(i);
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define en end()
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+7;
int t,j,cs=0,n,a,b,i,dxx[]={1,0,0,-1},dyy[]={0,-1,1,0},k,m;
string s;

int main()
{
cin>>n;
    ll ar[n+1],sum[n+1]={};
    rep(i,n-1) cin>>ar[i];
    for(i=n-1;i>=0;i--)
        sum[i]=sum[i+1]+ar[i];

    ll cnt=0;
    for(i=0;i<n;i++){
        ar[i]%=mod;
        sum[i+1]%=mod;
        cnt+=(ar[i]*sum[i+1])%mod;
        cnt%=mod;
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 6736
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var S = NextString();
        var cnt = 0;
        var j = S.Length - 1;

        var dreams = new string[] { "dream", "dreamer", "erase", "eraser" };
        for (var i = S.Length - 1; i >= 0; i--)
        {
            if (j - i > "dreamer".Length)
            {
                break;
            }
            foreach (var dd in dreams)
            {
                if (S.Substring(i, j - i + 1) == dd)
                {
                    j = i - 1;
                    cnt += dd.Length;
                }
            }
        }
        var ans = "YES";
        if (S.Length != cnt)
        {
            ans = "NO";
        }
        Console.WriteLine(ans);
    }

    static int diff(int[] a, int[] b)
    {
        return Math.Abs(a[0] - b[0]) + Math.Abs(a[1] - b[1]);
    }

    static string NextString()
    {
        var result = new List<char>();
        while (true)
        {
            int next = Console.Read();
            if (next < 0)
            {
                break;
            }
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
            {
                result.Add(nextChar);
            }
            else if (nextChar != '\r')
            {
                break;
            }
        }
        return string.Join("", result);
    }
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


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

    string ans = "";
    rep(i, s.size()) {
        int tmp = s[i]-'A';
        if(tmp + n >= 26) {
            ans += 'A' + (tmp+n-26);
        }else {
            ans += s[i]+n;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
import numpy as np
def resolve():
    N = int(input())
    Nlist = np.zeros(N + 1,dtype =  int)
    for i in range(1,100):
        for j in range(1,100):
            for k in range(1,100):
                num = i*i + j*j + k*k + i*k + i*j + j*k
                if num > N :
                    break
                else:
                    Nlist[num] += 1
    for i in range(1,N+1):
        print(Nlist[i])
resolve()

Measured memory_bytes: 27128
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

int main()
{
	while (1)
	{
		vector<int> GAP;
		priority_queue<int> PQ;
		int m, n_min, n_max;
		cin >> m >> n_min >> n_max;
		if (m == 0)break;
		for (int i = 0; i < m; i++)
		{
			int k;
			cin >> k;
			PQ.push(k);
		}
		for (int i = n_min; i <= n_max; i++)
		{
			priority_queue<int> tPQ = PQ;
			for (int l = 0; l < i-1; l++)
			{
				tPQ.pop();
			}
			int temp = tPQ.top();
			tPQ.pop();
			GAP.push_back(temp - tPQ.top());
		}
		int max_gap = 0;
		int index = 0;
		int max_index;
		for (auto itr = GAP.begin(); itr != GAP.end(); itr++)
		{
			if (max_gap <= *itr)
			{
				max_gap = *itr;
				max_index = index;
			}
			index++;
		}
		cout <<n_min+max_index << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O30")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << (x) << "\n")
using ll = long long; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(
6
3 14 159 2 6 53
58 9 79 323 84 6
2643 383 2 79 50 288
)X";
stringstream iss{text};
#endif 

class Festival
{
	ll N{0};
	vector<vector<ll>> A;
	void inp( ) {
		iss >> N; A.resize(3, vector<ll>(N));
		for (auto &abc : A) {
			for (auto &a : abc)  iss >> a;
		}		
		sort(begin(A[0]), end(A[0]));
		sort(begin(A[2]), end(A[2]));
	}
	void biSearch( ) {
		ll cnt{0};
		for (auto &b : A[1]) {
			cnt = cnt + (end(A[2]) - upper_bound(begin(A[2]), end(A[2]), b))
				* (lower_bound(begin(A[0]), end(A[0]), b) - begin(A[0]));
		}
		p(cnt);
	}
public:
	void procedures( ) {
		inp( );	biSearch( );
	}
};
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	class Festival a; a.procedures( );
}

Measured memory_bytes: 6392
import sys
di = {1:".,!? ",2 :"abc",3:"def",4:"ghi",5:"jkl",6:"mno",7:"pqrs",8:"tuv",9:"wxyz"}
b = input()

for j in range(b):
    a = raw_input()
    count = 0
    le = 999
    for letter in a:
        if(letter == "0"):
            if(le == 999):
                pass
            else:
                sys.stdout.write(di[le][(count-1)%len(di[le])])
                count = 0
                le = 999
        else:
            le = int(letter)
            count += 1
    print ""

Measured memory_bytes: 6216
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
S = sum(A)
C = Counter(A)
Q = int(input())
for i in range(Q):
    Bi, Ci = map(int, input().split())
    S += (Ci - Bi) * C[Bi]
    C[Ci] += C[Bi]
    C[Bi] = 0
    print(S)

Measured memory_bytes: 24016
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int r;

void solve()
{
    cin >> r; nout(r*r);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256