akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3","sse2","sse")
#pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#include "bits/stdc++.h"
//#include "ext/pb_ds/tree_policy.hpp"
//#include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) (x&(-x))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9+7;
const ll inf = 1e9+7;
const ld eps = 1e-9;
const db PI = atan(1)*4;
template<typename T>
inline int sign(const T&a) {
    if(a<0)return -1;
    if(a>0)return 1;
    return 0;
}

template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}

template<typename T> inline void in(T &x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (isdigit(ch))  {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    x *= f;
}

ll twop(int x) {
    return 1LL<<x;
}

template<typename A,typename B > inline void in(A&x,B&y) {
    in(x);
    in(y);
}
template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) {
    in(x);
    in(y);
    in(z);
}
template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) {
    in(x);
    in(y);
    in(z);
    in(d);
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
namespace SOLVE {
    void main(){
    }
}

int n,a[100010];
int cnt[100010];
int main() {
    
    
    
    
    
    
    
    VI v(3);
    REP(i,0,3)in(v[i]);
    sort(all(v));
    cout<<(v == vector<int>({5,5,7})?"YES":"NO");
    
    
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 10000000

int dfs(int n,int num,int *res){
	if(n==0){
		REP(i,num){
			cout<<res[i];
			if(i==num-1)cout<<endl;
			else cout<<" ";
		}
		return 0;
	}
	int temp;
	if(num==0)temp=n;
	else temp=res[num-1];
	for(int i=min(temp,n);i>=1;i--){
		res[num]=i;
		dfs(n-i,num+1,res);
	}
	
	return 0;
}

int main(){
	std::ios::sync_with_stdio(false);
	int n;int res[31];
	while(cin>>n){
		if(n==0)break;
		dfs(n,0,res);
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int peo[n];
    int ce[n];
    int cw[n];
    int e = 0; int w = 0;
    for(int i = 0; i < n; i++){
        ce[i]=0; cw[i]=0;
    }
    for(int i = 0; i < n; i++){  
        if(s[i]=='E' && i==0){
            ce[i]+=1; e++;
        }
        if(s[i]=='W' && i==0){
            cw[i]+=1; w++;
        }
        if(s[i]=='E' && i > 0){
            ce[i]=ce[i-1]+1; cw[i]=cw[i-1]; e++;
        }
        if(s[i]=='W' && i > 0){
            cw[i]=cw[i-1]+1; ce[i]=ce[i-1]; w++;
        }
    }
    int ans=e-ce[0];
    int check;
    for(int i = 0; i < n; i++){
        check = cw[i-1]+(e-ce[i]);
        ans = min(ans, check);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
import java.util.*;
import java.lang.*;



public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        int Q = sc.nextInt();

        long[] point = new long[N];
        Arrays.fill(point, K-Q);
        for(int q=0; q<Q; q++){
            int A = sc.nextInt()-1;
            point[A]++;
        }
        for(int n=0; n<N; n++) System.out.println(point[n]>0 ? "Yes" : "No");
    }
}


Measured memory_bytes: 61832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef pii point;
using namespace std;
const ll INF = (1ll<<32);
const ll MOD = 1000000007;

int main() {
  ll n,m; cin>>n>>m;
  vi x(n),y(m); REP(i,n) cin>>x[i]; REP(i,m) cin>>y[i];
  vi w(n-1),h(m-1);
  REP(i,n-1) w[i]=x[i+1]-x[i];
  REP(i,m-1) h[i]=y[i+1]-y[i];
  ll a=0,b=0;
  FOR(i,1,n) a=(a+w[i-1]*i*(n-i))%MOD;
  FOR(i,1,m) b=(b+h[i-1]*i*(m-i))%MOD;
  cout<<(a*b)%MOD<<endl;
}

// 7565


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

typedef long long ll;

const int M = (int)1e5;
const int N = (int)1e4;
const int inf = 0x3f3f3f3f;
const ll mod = (ll)1e9 + 7;

map <ll, int> cnt;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int n; scanf("%d", &n);
    ll res = 0;
    for(int i = 1; i <= n; ++i)
    {
        int h; scanf("%d", &h);
        if(cnt.count(i - h)) res += cnt[i - h];
        ++cnt[i + h];
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 16120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		/**
		 * ?????°,???????????£?¨?
		 */
		int x = 0, n = 0; // ??\????????°
		int count = 0;
		ArrayList<Integer> answer = new ArrayList<Integer>();
		String tmpbox[] = new String[2];

				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		/**
		 * ??°????§£?????????
		 */
		while (true) {
			String str = br.readLine();
			tmpbox = str.split(" ");
			n = Integer.parseInt(tmpbox[0]);
			x = Integer.parseInt(tmpbox[1]);

			if (n == 0 && x == 0) { // x,n??±???0????????????
				break;
			}
			if(n < 3 || n > 100){
				System.exit(0);
			}

			for (int i = 1; i <= n-2; ++i) {
				for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				}
			}
			answer.add(count); // ???????????¢??¨????????????????????°????´???????
			count = 0;
		}
		int answer_length = answer.size();
		for(int t = 0; t < answer_length; ++t){
			System.out.println(answer.get(t));
		}
	}

}

Measured memory_bytes: 25108
#include <bits/stdc++.h>
using namespace std;
int h,k,mp[10][10];
int main(){
	scanf("%d%d",&h,&k);
	for (int i=0;i<10;++i){
		for (int j=0;j<10;++j)
		scanf("%d",&mp[i][j]);
	}
	for (int k1=0;k1<10;++k1){
		for (int i=0;i<10;++i){
			for (int j=0;j<10;++j){
				if (mp[i][k1]+mp[k1][j]<mp[i][j])mp[i][j]=mp[i][k1]+mp[k1][j];
			}
		}
	}
	int cnt=0;
	for (int i=0;i<h;++i){
		for (int j=0;j<k;++j){
			int s;
			scanf("%d",&s);
			if (s == (-1))continue;
			cnt+=mp[s][1];
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  long N, D;
  cin >> N >> D;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    long x, y;
    cin >> x >> y;
    long d = x * x + y * y;
    ans += (d <= D * D);
  }
  cout << ans << endl;
} 

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

int main (){
	int n;
	cin >> n;
	
	vector<int> v;
	v.reserve(n);
	
	for(int i=0; i<n; i++){
		cin >> v[i];
	}
	
	for(int i=n-1; i>=0; i--){
		cout << v[i];
		if(i==0) break;
		cout << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 3072
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using vll = vector<long long>;

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {
	ll j,n,cnt=0;
	string s;
	in(n);
	vector<string> vecS(n);
	rep(i, 0, n) {
		in(s);
		sort(s.begin(), s.end());
		vecS[i] = s;
	}
	sort(vecS.begin(), vecS.end());
	
	rep(i, 0, n - 1) {
		for (j = i + 1; j < n;j++) {
			if (vecS[i] == vecS[j]) {
				cnt += j - i;
			}
			else {
				break;
			}
		}
		i = j-1;
	}
	outn(cnt);

	return 0;
}



Measured memory_bytes: 5760
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    ll n=s.size();
    vector<ll> alp(26);
    rep(i,n) ++alp[s[i]-'a'];
    ll ans=n*(n-1)/2+1;
    rep(i,26) ans-=alp[i]*(alp[i]-1)/2;
    cout << ans << endl;
    
    return 0;  
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
bool isplaindrome(string s)
{
    ll i=0, j = s.length() - 1;
    while (j > i)
    {
        if (s[i] != s[j])
        {
            return false;
        }
        i++;
        j--;
    }
    return true;
}
int main()
{
    string s;
    cin >> s;
    ll n = s.length();
    //cout << isplaindrome(s) << "\n";
    //cout << isplaindrome(s.substr(0, (n - 1) / 2)) << "\n";
    //cout << isplaindrome(s.substr((n + 1) / 2, (n - 3) / 2 + 1))<<"\n";

    if(isplaindrome(s) && (isplaindrome(s.substr(0, (n - 1) / 2))) && (isplaindrome(s.substr((n + 1) / 2, (n - 3) / 2 + 1))))
    {
        cout << "Yes";
        exit(0);
    }
    cout << "No";

    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi x(n);
    int64_t res = 100000000;
    rep(i,n) cin >> x.at(i);
    for(int i=1; i<=100; i++){
        int64_t sum = 0;
        rep(j,n){
            sum += (x.at(j) - i) * (x.at(j) - i);
        }
        res = min(res, sum);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,s) for (int i = (s); i < (n); i++)
#define SIZE 50
using namespace std;
typedef long long int LL;

LL MOD;
int H, W, N, C, m[SIZE][SIZE];

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

	cin >> H >> W >> N >> MOD;

	memset(m, 0, sizeof(m));
	int idx = 0;
	while (N) {
		int i = idx/W, j = idx%W;
		cout << "? " << i << " " << j << " " << i << " " << j << endl;
		cin >> m[i][j];
		if (m[i][j] > 0) {
			N--;
		}
		idx++;
	}

	LL res = 0, p = 1;
	REP(i, H, 0) {
		REP(j, W, 0) {
			res = (res + p * m[i][j] % MOD) % MOD;
			p = p * 2 % MOD;
		}
	}
	cout << "! " << res << endl;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int l,q[200010],k;
char s[200010];
int main()
{
	cin>>s;
	l=strlen(s);
	for (int i=0;i<l;i++)
	{
		if (s[i]=='T' && k && !q[k])
		{
			k--;
		}
		else
		{
			if (s[i]=='S')
			{
				q[++k]=0;
			}
			else
			{
				q[++k]=1;
			}
		}
	}
	cout<<k<<endl;
	return 0;
}


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

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

	vector<vector<int64_t>> next(n + 1, vector<int64_t>(10, -1));
	for (int64_t i = n; i; i--)
	{
		for (int64_t j = 0; j < 10; j++)
		{
			next[i - 1][j] = next[i][j];
		}
		next[i - 1][s[i - 1] - '0'] = i;
	}

	int64_t ans = 0;

	for (int64_t i = 0; i < 1000; i++)
	{
		vector<int64_t> as = {i / 100, i / 10 % 10, i % 10};

		bool f = true;

		for (int64_t j = 0, k = 0; j < 3; j++)
		{
			k = next[k][as[j]];
			if (k == -1)
			{
				f = false;
				break;
			}
		}

		if (f)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, m, p[100000], pp[100000], y[100000];
	cin >> n >> m;
	map<int, int> mp;
	map<int, int> mpp;
	map<int, int> mppp;
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> y[i];
		mp[y[i]] = i;
		mppp[y[i]] = p[i];
	}
	memcpy(pp, p, sizeof(p));
	int f[100000];
	sort(y, y+m);

	for (int i = 0; i < m; i++) {
		mpp[mppp[y[i]]]++;
		f[mp[y[i]]] = mpp[mppp[y[i]]];
	}

	for (int i = 0; i < m; i++) {
		printf("%06d", pp[i]);
		printf("%06d\n", f[i]);
	}

	return 0;
}

Measured memory_bytes: 17152
W, H, N = map(int, input().split())

w_min = 0; w_max = W
h_min = 0; h_max = H
curr_area = W * H

for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1 and x > w_min:
        if x >= w_max:
            curr_area = 0
            break
        else:
            w_min = x

    elif a == 2 and x < w_max:
        if x <= w_min:
            curr_area = 0
            break
        else:
            w_max = x
    elif a == 3 and y > h_min:
        if y >= h_max:
            curr_area = 0
            break
        else:
            h_min = y
    elif a == 4 and y < h_max:
        if y <= h_min:
            curr_area = 0
            break
        else:
            h_max = y
    curr_area = (w_max - w_min) * (h_max - h_min)
print(curr_area)


Measured memory_bytes: 3064
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    //vector<string> a(n);
    //set<string> x;
    unordered_map<string, int> x;
    ll cnt=0;
    for(int i=0;i<n;i++){
        string a;
        cin>>a;
        //cout<<"Original string: "<<a<<endl;
        sort(a.begin(), a.end());
        //cout<<"Sorted string: "<<a<<endl;
        if(x[a]){
          //  cout<<a<<" appeared "<<x[a]<<" times before\n";
            cnt += x[a];
            //cout<<"New count: "<<cnt<<endl;
            x[a]++;
           // cout<<"Current value: "<<x[a]<<endl;
        }
        else{
           // cout<<"First appearance\n";
            x[a]=1;
           // cout<<"Current value: "<<x[a]<<endl;
        }
    }
    cout<<cnt<<endl;
    /*
    ll c=0;
    for(int i=0;i<n;i++){
        string x = a[i];
        //cout<<"For string: "<<x<<endl;
        vector<int> cnt(26,0);
        for(int j=0;j<x.length();j++)   cnt[x[j]-'a']++;   
        //cout<<"Count array: \n";
        //for(int j=0;j<26;j++)   cout<<cnt[j]<<" ";
        //cout<<"\n";
        for(int j=0;j<n;j++){
            if(i==j)    continue;
            //cout<<"--- Checking for: "<<a[j]<<endl;
            string y = a[j];
            vector<int> res(26,0);
            bool flag=true;
            for(int k=0;k<y.length();k++){
                if(cnt[y[k]-'a']==0) {
                //    cout<<"---- No such char\n";
                    flag = false;
                    break;
                }
                if(res[y[k]-'a'])   res[y[k]-'a']--;
                else                res[y[k]-'a'] = cnt[y[k]-'a']-1; 
            }
            if(flag){ 
                //cout<<"Res array: \n";
                //for(int k=0;k<26;k++)   cout<<res[k]<<" ";
                //cout<<"\n";
            
                for(int k=0;k<26;k++){
                    if(res[k]!=0){
                  //      cout<<"----Extra or Less chars\n";
                        flag = false;
                        break;    
                    }
                }
            }
            if(flag){
                c++;
            }
        }
    }
    cout<<c/2<<endl;
    */
    return 0;
}



Measured memory_bytes: 10660
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
#define MAX_L 1000
int h, w, ch, cw, dh, dw;
int M[MAX_L][MAX_L];

ll d[MAX_L][MAX_L];

void dijkstra() {
    typedef pair<ll, pair<int, int>> P;
    priority_queue<P, vector<P>, greater<P>> pq;
    rep(y, h) rep(x, w) { d[y][x] = linf; }
    d[ch][cw] = 0;
    pq.push(make_pair(0, make_pair(ch, cw)));
    while (!pq.empty()) {
        auto u = pq.top();
        int cur_y = u.second.first, cur_x = u.second.second;
        pq.pop();
        rep(i, 4) {
            int nxt_y = cur_y + dy[i], nxt_x = cur_x + dx[i];
            if (0 <= nxt_y && nxt_y < h && 0 <= cur_x && cur_x <= w) {
                if (M[nxt_y][nxt_x] == 0 && d[nxt_y][nxt_x] > d[cur_y][cur_x]) {
                    d[nxt_y][nxt_x] = d[cur_y][cur_x];
                    pq.push(make_pair(d[nxt_y][nxt_x], make_pair(nxt_y, nxt_x)));
                }
            }
        }
        repc2(nxt_y, max(0, u.second.first - 2), min(u.second.first + 2, h - 1))
            repc2(nxt_x, max(0, u.second.second - 2), min(u.second.second + 2, w - 1)) {
            // for (const auto &eg : G[u.second]) {
            if (M[nxt_y][nxt_x] == 0 && d[nxt_y][nxt_x] > d[cur_y][cur_x] + 1) {
                d[nxt_y][nxt_x] = d[cur_y][cur_x] + 1;
                pq.push(make_pair(d[nxt_y][nxt_x], make_pair(nxt_y, nxt_x)));
            }
        }
    }
}
int main() {
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--, cw--, dh--, dw--;
    rep(y, h) rep(x, w) {
        char c;
        cin >> c;
        M[y][x] = c == '#' ? 1 : 0;
    }
    dijkstra();
    // rep(y, h) {
    //     rep(x, w) { printf("%lld\t", d[y][x]); }
    //     puts("");
    // }
    cout << ((d[dh][dw] == linf) ? -1 : d[dh][dw]) << endl;
    return 0;
}

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

int main()
{
  int A, B;
  int cnt = 0;
  
  cin >> A >> B;
  
  for(int i=A; i<=B; i++)
  {
    if(i / 10000 == i % 10 && (i % 10000 / 1000) == (i % 100 - i % 10)/10)
    {
      cnt += 1;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3580
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    int N,M; cin >> N >> M;
    if (M%2 == 1){cout << "-1"; rn 0;}
    vector<vector<int>> g(N);
    rep(i,M){
        int x,y;
        cin >> x >> y; x--;y--;
        g[y].emplace_back(x);
        g[x].emplace_back(y);
    }
    
    vector<pair<int,int>> ans;
    vector<int> degree(N,0);
    vector<int> depth(N,-1);
    
    function<void(int,int)> DFS=[&](int v, int pr){
        for(int u:g[v]){
            if (depth[u] == -1){
                depth[u] = depth[v] + 1;
                DFS(u,v);
            }
            else if(depth[u]>depth[v]) {
                degree[v]++;
                ans.emplace_back(v,u);
            }
        }
        if (degree[v]%2 == 1){
            ans.emplace_back(v,pr);
            degree[v]++;
        }
        else{
            if(pr!=-1){
                ans.emplace_back(pr,v);
                degree[pr]++;
            }
        }
    };
    

    
    depth[0] = 0;
    DFS(0,-1);
    
    for (auto& p:ans){
        cout << p.first + 1 << " " << p.second + 1 << endl;
    }
    rn 0;
}



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

#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);


int main(void) {

	int    N,X,L,i,d=0;

	i_cin2(N,X);
	for (i = 0; i < N; i++) {
		i_cin(L);
		d += L;
		if (d >X) break;
		if (d == X) { i++; break; }
	}
	i_cout(i+1);
	return 0;
}
	
//降順
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
//
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}

	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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 (b<a) { a=b; return 1; } return 0; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int K; cin >> K;
    int odd = K / 2;
    int even = K - odd;
    cout << odd * even << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int a,b,c; cin>>a>>b>>c;
    cout<<max({10*a+b+c,10*b+a+c,10*c+a+b})<<endl;
    return 0;
}


Measured memory_bytes: 256
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val ans = mu.ListBuffer.empty[Long]
  (n.toLong * (n-1) / 2L) +=: ans
  val uft = new UnionFindTree(n)

  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt - 1))
    .toArray
    .reverse
    .init
    .foreach { e => {
      val a = e(0)
      val b = e(1)
      if(uft.root(a) != uft.root(b)) {
        (ans.head - uft.size(a).toLong * uft.size(b).toLong) +=: ans
        // println(uft.size(a) + " " + uft.size(b))
        uft.unite(a, b)
      }
      else ans.head +=: ans
    }}

  println(ans.mkString("\n"))

  class UnionFindTree(n:Int) {
    val par  = Array.range(0, n)
    val rank = Array.fill(n)(1)
    val _size = Array.fill(n)(1)

    def root(x:Int):Int = {
      if(par(x) == x) x
      else { par(x) = root(par(x)); par(x) }
    }

    def size(x:Int):Int = {
      _size(root(x))
    }

    def same(x:Int, y:Int):Boolean = root(x) == root(y)

    def unite(x:Int, y:Int):Unit = {
      val rx = root(x)
      val ry = root(y)
      if(rx == ry) return

      if(rank(rx) < rank(ry)) {
        par(rx) = ry
        _size(ry) += _size(rx)
      }
      else {
        par(ry) = rx
        _size(rx) += _size(ry)
        if(rank(rx) == rank(ry)) rank(rx) += 1
      }
    }
  }
}

Measured memory_bytes: 63024
n, k = list(map(int, input().split(' ')))

hs = list(map(int, input().split(' ')))

dp = [float('inf')] * (n + k + 1)
dp[0] = 0

for i in range(n - 1):
    for j in range(1, k + 1):
        if i + j < n:
            dp[i + j] = min([
                dp[i + j],
                dp[i] + abs(hs[i] - hs[i + j])
            ])

print(dp[n - 1])


Measured memory_bytes: 56084
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
int n;
/**********************************/

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

    int ans = 128;
    while(ans > n) {
        ans /= 2;
    }
    cout << ans;
}


Measured memory_bytes: 256
#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

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

int sum, n;

int main(){
	while (cin >> sum&&sum){
		REP(i, 9){
			cin >> n;
			sum -= n;
		}
		cout << sum << endl;
	}
}

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

int main()
{
  vector<string> s(3);
  for(auto&& e: s) 
  {
    cin>>e;
  }
  cout<<s[0][0]<<s[1][1]<<s[2][2]<<endl;
}

Measured memory_bytes: 256
N,X,Y=map(int,input().split())
A=[0]*(N-1)
for i in range(1,N):
  for j in range(i+1,N+1):
    A[min(j-i,abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))-1]+=1
for a in A:
  print(a)

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

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a <= b) {
        rep(i, b) {
            ans *= 10;
            ans += a;
        }
    } else {
        rep(i, a) {
            ans *= 10;
            ans += b;
        }
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000
#define MOD 1000000007

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

int main()
{
    set<string> ss;
    ll n;
    cin >> n;
    rep(i, n) {
        string s;
        cin >> s;
        ss.insert(s);
    }
    cout << ss.size() << endl;
    return 0;
}

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


int main(){
	int n,f[10];
	while(cin>>n&&n){
		fill_n(f,10,0);
		for(int i=0;i<n;i++){
			int id;
			cin>>id;
			f[id]++;
		}
		for(int i=0;i<10;i++){
			if(!f[i])cout<<"-\n";
			else{
				for(int j=0;j<f[i];j++){
					cout<<'*';
				}
				cout<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

void solve(){
	ll n,k;
	cin>>n>>k;

	vector<ll> a(n,0);
	for(ll i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
	}

	vector<bool> seen(n,false);
	ll t=0;
	ll s_0=0;
	ll next=a[0];
	ll v=0;
	
	vector<ll> r;

	vector<ll> s(n,0);

	ll minus=0;

	while(true){
		seen[v]=true;
		s[v]=s_0;
		s_0++;
		t++;
		if(seen[next]){
			//cout<<"true"<<endl;
			minus=s[next];
			r.push_back(v);
			break;
		}
		else{
			//cout<<"false"<<endl;
			r.push_back(v);
			v=next;
			next=a[next];
		}
	}

	if(k>minus){
		t-=minus;
		cout<<r[(k-minus)%t+minus]+1<<endl;
	}
	else{
		cout<<r[k]+1<<endl;
	}

}


int main(){
	
	solve();
	
    return 0;
}


Measured memory_bytes: 8460
#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(){
	string s;
	cin>>s;
	ll ans = 0;
	int b=0;
	for(char c:s){
		if(c=='B') b++;
		else ans += b;
	}
	cout<<ans<<endl;
}

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

using namespace std;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M), C(M, 0);
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    for (int j = 0; j < B[i]; j++) {
      int c;
      cin >> c;
      c--;
      C[i] += (1 << c);
    }
  }

  vector<vector<int>> dp(M + 1, vector<int>(1 << N, 1 << 28));
  dp[0][0] = 0;

  for (int i = 0; i < M; i++) {
    for (int j = 0; j < (1 << N); j++) {
      chmin(dp[i + 1][j], dp[i][j]);
      chmin(dp[i + 1][j | C[i]], dp[i][j] + A[i]);
    }
  }

  cout << (dp[M][(1 << N) - 1] < (1 << 28) ? dp[M][(1 << N) - 1] : -1) << '\n';
  return 0;
}


Measured memory_bytes: 16384
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second

using namespace std;

int main(){

    int n,a,b;
    cin >>n>>a>>b;
    if((b-a)%2) cout << "Borys";
    else cout << "Alice";

    return 0;
}

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

using namespace std;

using ll = long long;

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

const double EPS = 1e-5;
const int MOD = 1e9+7;

int main(){
  int a;
  string s;

  cin >> a;
  cin >> s;

  if(a >= 3200){
    cout << s;
  }else{
    cout << "red";
  }

  return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
name = Array.new()
(0..N-1).each do |i|
    name.push(gets.chomp)
end

perm_min_letter_freq = {
    "a"=>51,
    "b"=>51,
    "c"=>51,
    "d"=>51,
    "e"=>51,
    "f"=>51,
    "g"=>51,
    "h"=>51,
    "i"=>51,
    "j"=>51,
    "k"=>51,
    "l"=>51,
    "m"=>51,
    "n"=>51,
    "o"=>51,
    "p"=>51,
    "q"=>51,
    "r"=>51,
    "s"=>51,
    "t"=>51,
    "u"=>51,
    "v"=>51,
    "w"=>51,
    "x"=>51,
    "y"=>51,
    "z"=>51
}

name.each do |i|
    temp_min_letter_freq = {
        "a"=>0,
        "b"=>0,
        "c"=>0,
        "d"=>0,
        "e"=>0,
        "f"=>0,
        "g"=>0,
        "h"=>0,
        "i"=>0,
        "j"=>0,
        "k"=>0,
        "l"=>0,
        "m"=>0,
        "n"=>0,
        "o"=>0,
        "p"=>0,
        "q"=>0,
        "r"=>0,
        "s"=>0,
        "t"=>0,
        "u"=>0,
        "v"=>0,
        "w"=>0,
        "x"=>0,
        "y"=>0,
        "z"=>0
    }
    
    i.split("").each do |j|
        temp_min_letter_freq[j] += 1
    end
    
    temp_min_letter_freq.keys.each do |j|
        if temp_min_letter_freq[j] < perm_min_letter_freq[j]
            perm_min_letter_freq[j] = temp_min_letter_freq[j]
        end
    end
end

perm_min_letter_freq.keys.each do |i|
    if perm_min_letter_freq[i] == 51 || perm_min_letter_freq[i] == 0
        perm_min_letter_freq.delete(i)
    end
end

perm_min_letter_freq.keys.each do |i|
    begin
        print i
        perm_min_letter_freq[i] -= 1
    end while perm_min_letter_freq[i] > 0
end

Measured memory_bytes: 2044
def main():
    n = int(input())
    has_answered = False
    for x in range(1, 3501):
        if has_answered:
            break
        for y in range(x, 3501):
            if 4 * x * y - n * y - n * x > 0 and (n * x * y) % (4 * x * y - n * y - n * x) == 0:
                print(x, y, (n * x * y) // (4 * x * y - n * y - n * x))
                has_answered = True
                break


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    long long ans = 0;
    for(int i=1;i<=n;i++){
        long long j = n/i;
        ans += j * (j+1) / 2 * i;
    }
    cout << ans << endl;
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int n;
	string s,t="";
	cin>>n>>s;
	for(int i=0;i<n/2;++i){
		t.push_back(s[i]);
	}
	t+=t;
	if(t==s)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int64_t a = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    }
    else {
    a += i;
    }
  }
    cout << a << endl;
}


Measured memory_bytes: 3632
import collections

def prime_decomposition(n):
    prime_factors = []
    if n < 2:
        return prime_factors
    while n >= 2 and n % 2 == 0:
        prime_factors.append(2)
        n //= 2
    i = 3
    while i * i <= n:
        if n % i == 0:
            prime_factors.append(i)
            n //= i
        else:
            i += 2
    if n > 1:
        prime_factors.append(n)
    return prime_factors

n = int(input())
freq = collections.Counter(prime_decomposition(n))
ans = n
for k,v in freq.items():
    ans *= (1-1/k)
print(int(ans))

Measured memory_bytes: 8048
/*
Author: Vishesh Gupta
E mail: visheshguptavgr@gmail.com
*/
#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;
#define newline ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)

#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(1);
    //start coding here

    string s, t;
    cin >> s >> t;
    int ss = s.size();
    int ts = t.size();
    int mn = ts;
    for (int i = 0; i < ss - ts + 1; i++)
    {
        int cost = 0;
        int x = i;
        for (int j = 0; j < ts; j++)
        {
            if (s[x] != t[j])
            {
                cost++;
            }
            x++;
        }
        // deb(cost);
        mn = min(cost, mn);
    }
    cout << mn << newline;
    return 0;
}


Measured memory_bytes: 3640
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

N,M = map(int,input().split())
L = []
for i in range(N):
  tmp = list(map(int,input().split()))
  L.append(tmp[1:])
#print(L)

# 人(0~N-1)と言語(N~N+M-1)の間で二部グラフを作る
E = [set() for _ in range(N+M)]
for i in range(N):
  for l in L[i]:
    E[i].add(l+N-1)
    E[l+N-1].add(i)
#print(E)

# 人のノードすべてに到達可能であればYES
Visited = [0 for _ in range(N+M)]
def dfs(v):
  Visited[v] = 1
  for u in E[v]:
    if Visited[u] == 0:
      dfs(u)
dfs(0)
print('YES' if sum(Visited[:N]) == N else 'NO')


Measured memory_bytes: 75644
class Node:
    def __init__(self, key):
        self.key = key
        self.left = left
        self.right = right

H = int(input())
heap = [0] * (H+1)
for i, num in enumerate(map(int, input().split())):
    heap[i+1] = num

# print(*heap)

def get_parent(heap, i):
    if i // 2 > 0:
        return heap[i // 2]
    else:
        return None

def get_left_child(heap, i):
    if 2 * i <= H:
        return heap[2 * i]
    else:
        None

def get_right_child(heap, i):
    if 2 * i + 1 <= H:
        return heap[2 * i + 1]
    else:
        return None
for i in range(1, H+1):
    msg = 'node ' + str(i) + ': key = ' + str(heap[i]) + ', '
    parent_key = get_parent(heap, i)
    # print(parent_key)
    if parent_key:
        msg += 'parent key = ' + str(parent_key) + ', '

    left_key = get_left_child(heap, i)
    if left_key:
        msg += 'left key = ' + str(left_key) + ', '

    right_key = get_right_child(heap, i)
    if right_key:
        msg += 'right key = ' + str(right_key) + ', '
    print(msg)


Measured memory_bytes: 5632
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999


int main() {
	int a[10];
	string s[10];
	cin >> s[0] >> s[1] >> s[2];
	cout << s[0][0] << s[1][0] << s[2][0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define reg register
#define ll long long
#define ull unsigned long long
using namespace std;
const int MAXN = 1e5 + 10;
int n, a[MAXN], cnt[MAXN];
struct Node {
  int cc, id;
  bool operator <(const Node &rhs) const {
    return cc > rhs.cc;
  }
} b[MAXN], ans1[4];
void work() {
  scanf("%d", &n);
  for(reg int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for(reg int i = 1; i <= n; i += 2) ++cnt[a[i]];
  int tot = 0;
  for(reg int i = 1; i <= MAXN - 10; ++i) b[++tot].cc = cnt[i], b[tot].id = i;
  sort(b + 1, b + tot + 1);
  ans1[0] = b[1], ans1[1] = b[2];
  memset(cnt, 0, sizeof(cnt)), tot = 0;
  for(reg int i = 2; i <= n; i += 2) ++cnt[a[i]];
  for(reg int i = 1; i <= MAXN - 10; ++i) b[++tot].cc = cnt[i], b[tot].id = i;
  sort(b + 1, b + tot + 1);
  ans1[2] = b[1], ans1[3] = b[2];
  int mx = 0;
  for(reg int i = 0; i <= 1; ++i) {
    for(reg int j = 2; j <= 3; ++j) {
      if(ans1[i].id != ans1[j].id) mx = max(mx, ans1[i].cc + ans1[j].cc);
    }
  }
  printf("%d\n", n - mx);
}
signed main() {
  int _ = 1;
  // scanf("%d", &_);
  while(_--) {
    work();
  }
  return 0;
}


Measured memory_bytes: 5376
N = int(input())
f = (-1, -1)
s = (-1, -1)
for n in range(N):
    A = int(input())
    if f[1] <= A:
        s = f
        f = (n, A)
    elif s[1] <= A:
        s = (n, A)
for n in range(N):
    print(f[1] if n != f[0] else s[1])

Measured memory_bytes: 55640
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  string s; cin >> s;
  rep(i, s.size()) {
    cout << s[i];
    if(i == 3) cout << ' ';
  }
  cout << '\n';
  return 0;
}


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


int main(){
  ll n; cin >> n; vl high(n);
  rep(i,n){ ll x; cin >> x; high[i] = x; }
  
  vl cost(n); cost[0] = 0; cost[1] = abs(high[1]-high[0]);
 
  for(ll i=0; i < n-2; i++){
    cost[i+2] = min(cost[i+1]+abs(high[i+2]-high[i+1]),
                    cost[i]+abs(high[i+2]-high[i]));
  }
  
  cout << cost[n-1] << endl;
}

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

int main() {
    int n,m;
    cin >> n >> m;
    long long sum=0;
    vector<int> a(n);
    vector<pair<int,int>> b(m);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    for(int i=0;i<m;i++){
        cin >> b.at(i).second >> b.at(i).first;
    }

    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    reverse(a.begin(),a.end());
    int aind=0,bind=0,limit=n;
    bool che = true;
    while(limit>0){
        limit--;
        if(b.at(bind).first>a.at(aind)&&bind<m&&che==true){
            sum += b.at(bind).first;
            b.at(bind).second--;
            if(b.at(bind).second==0&&bind<m){
                if(bind==m-1){
                    che = false;
                }else{
                    bind++;
                }
            }
        }else if(aind<n){
            sum += a.at(aind);
            aind++;
        }
        //cout << bind << endl;
        /*for(int i=0;i<n;i++){
            cout << "," <<a.at(i);
        }
        cout << endl;*/
    }
    /*for(int i=0;i<n;i++){
        //cout << a.at(i) << endl;
        sum += a.at(i);
    }*/
    cout << sum << endl;
}

Measured memory_bytes: 4472