akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    static int n;
    static boolean[] a;
    static Boolean[] memo;
    static int count = 0;
    public static void main(String[]$) {
        n = scanner.nextInt();
        a = new boolean[n];
        memo = new Boolean[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt() == 1;
        }
        for (int i = 1; i <= n; i++) {
            f(i);
        }
        System.out.println(count);
        for (int i = 0; i < n; i++) {
            if (memo[i]) {
                System.out.println(i + 1);
            }
        }
    }

    static boolean f(int i) {
        if (memo[i - 1] != null) {
            return memo[i - 1];
        }
        boolean b = a[i - 1];
        int j = 2;
        while (i * j <= n) {
            if (f(i * j)) {
                b = !b;
            }
            j++;
        }
        if (b) {
            count++;
        }
        return memo[i - 1] = b;
    }
}

Measured memory_bytes: 82508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<vector<char>> A(6,vector<char>(6));
  long long H,W,K;
  cin >>H>>W>>K;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>A.at(i).at(j);
    }
  }
  
  vector<vector<char>> copy =A;
  
  long long maincount=0;
  
  for (int tmp = 0; tmp < (1 << (H+W)); tmp++) {
    bitset<12> p (tmp);
    long long count=0;
    A=copy;
     
    for(int a=0;a<H;a++){
      if(p.test(a)){
        A.at(a)=vector<char>(6);
      }
    }
    for(int b=H;b<H+W;b++){
      if(p.test(b)){
        for(int c=0;c<H;c++){
          A.at(c).at(b-H)='0';
        }
      }
    }    
    
    for (int x = 0; x < H; x++) {
      for (int y = 0; y < W; y++) {
        if (A.at(x).at(y) =='#') {
            count++;
          }
       }
    }   
    
    if(count==K){
      maincount++;
    }
  }
  
  
  cout << maincount;
}

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

struct Edge{
  int to;
  int id;
};
vector<vector<Edge>>G;
vector<bool>seen;
vector<int>ans;

void dfs(int v,int p=-1,int p_color=-1){
  seen[v]=true;
  int tmp=1;
  for(auto a:G[v]){
    int next_v=a.to;
    int ID=a.id;//辺のID
    if(next_v==p)continue;
    if(seen[next_v])continue;
    if(tmp==p_color)tmp++;
    ans[ID]=tmp;
    tmp++;
    dfs(next_v,v,ans[ID]);
  }
}
int main(){
  int n;
  cin>>n;
  G.resize(n);
  seen.assign(n,false);
  ans.resize(n-1);
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G[a].push_back(Edge{b,i});
    G[b].push_back(Edge{a,i});
  }

  dfs(0);
  int max_deg=0;
  for(int i=0;i<n-1;i++){
    max_deg=max(max_deg,ans[i]);
  }
  cout<<max_deg<<endl;
  for(int i=0;i<n-1;i++){
    cout<<ans[i]<<endl;
  }

}

Measured memory_bytes: 11008
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>

#include <cstdio>
using namespace std;


int a1();
void a2();
int a3();
int a4();
int a5();
int a6();
int a7();
int a8();
int a9();
int a10();
int main()
{
	//cout << a1() << endl;
	//a2();
	//a3();
	//a4();
	a10();
	return 0;
}
//******************************10
//最小成本排序
int a10()
{
	int Max = 10001;//元素最大值
	int Max1 = 1000;//元素数最大值
	int n;
	cin >> n;
	vector<int> vn;
	int temp;
	for (int i = 0; i < n; i++)//原始vn
	{
		cin >> temp;
		vn.push_back(temp);

	}
	vector<int> bn;
	for (int i = 0; i < n; i++)//
	{
		bn.push_back(vn[i]);
	}
	sort(bn.begin(), bn.end());//排序bn

	//for (int i = 0; i < n; i++)//打印调试
	//{
	//	cout << bn[i] << " ";
	//}
	//cout << endl;

	vector<int> cn(Max,0);
	
	for (int i = 0; i < n; i++)//排序后数的索引
	{
		
		cn[(bn[i])] = i;
		//cout << cn[(bn[i])] << " kk " << endl;
	}
	/*
	for (int i = 0; i < Max; i++)//打印调试
	{
		if (cn[i])
			cout << cn[i] << " hh ";
	}
	cout << endl;
	*/
	vector<int> dn(Max1,0);
	vector<bool> f(Max1,0);
	for (int i = 0; i < n; i++)
	{
		dn[i] = cn[vn[i]];//vn的i位置变为bn的dn[i]位置
	}
	/*
	for (int i = 0; i < n; i++)//打印调试
	{
		cout << dn[i] << " hh1 ";
	}
	cout << endl;
	*/
	int s = 0;//总和
	int s1 = 0;//每个环的和
	
	for (int i = 0; i < n; i++)
	{
		if (f[i] == true)continue;//如果被遍历过就下一个元素
		int y = 0;//每个环元素个数
		int x = 0;//每个环的和
		int m = 10000;//每个环的最小值
		int t=i;
		while (1)
		{
			//cout << t << "tt" << endl;
			y++;
			x = x + vn[t];
			m = min(m, vn[t]);
			//cout << y << " " << x << " " << m << " " << endl;
			f[t] = true;
			t = dn[t];
			

			if (f[t] == true) break;
		}
		s1 = min((x + (y - 2)*m), (x + m + (y + 1)*bn[0]));
		//cout << s1 << "nn" << endl;
		s += s1;
	}
	cout << s << endl;
	return 0;
}


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

unsigned euclidean_gcd(unsigned a, unsigned b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main(void){
    ll n;
    cin >> n;
    ll a,b;
    cin >> a;
    for(int i=0;i<n-1;i++){
        cin >> b;
        a = euclidean_gcd(a,b);
    }
    cout << a<<endl;

    
    return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  int X, A; cin >> X >> A;

  //main
  
  
  // output
  if(X<A){cout << 0 << endl;}
  else{cout << 10 << endl;}

  return 0;
}

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

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

    if(a<3200) cout << "red" << endl;
    else cout << s << endl;
}


Measured memory_bytes: 256
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,a[1000005]={},cnt=0;
  cin >> n >> m;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    cnt+=a[i];
  }
  if(n-cnt>=0) {
    cout << n-cnt << endl;
  }
  else {
    cout << -1 << endl;
  }
}

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

typedef long long ll;

int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> a(N);
    rep(i, N) {
        cin >> a[i];
        a[i]--;
    }
    rep(i, N) {
        if (a[a[i]] == i) ans++;
    }
    cout << ans / 2 << "\n";
}

Measured memory_bytes: 640
s = raw_input()
q = input()
l = [raw_input().split() for _ in range(q)]

for i in l:
    op = i[0]
    a = int(i[1])
    b = int(i[2])
    if op == "replace" :
        p = i[3]
        s = s[:a] + p + s[b+1:]
    elif op == "reverse" :
        tmp = s[a:b+1]
        s = s[:a] + tmp[::-1] + s[b+1:]
    elif op == "print" :
        print s[a:b+1]

Measured memory_bytes: 6456
li = input().split()
count = int(li[0])
price = int(li[1]) / 1000
errorText = '-1 -1 -1'
ans = True
flag = False
for a in range(count+1):
    for b in range(count+1 - a):
        c = count - a-b
        fee = a*10 + b*5 + c*1
        if fee == price and a+b+c == count:
            print(str(a) + " " + str(b) + " " + str(c))
            ans = False
            flag = True
            break
    if flag:
        break

if ans is not False:
    print(errorText)

Measured memory_bytes: 40300
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	int N, sA, sB, gA, gB;
	cin >> N >> sA >> sB >> gA >> gB;
	sA -= 1;
	sB -= 1;
	gA -= 1;
	gB -= 1;

	string S;
	cin >> S;

	if (sA > gA || sB > gB) {
		cout << "No";
		return 0;
	}

	for (int i = sA; i < gA; i++) {
		if (S[i] == '#' && S[i] == S[i + 1]) {
			cout << "No";
			return 0;
		}
	}
	for (int i = sB; i < gB; i++) {
		if (S[i] == '#' && S[i] == S[i + 1]) {
			cout << "No";
			return 0;
		}
	}

	// Aがはじめ左にいるようにする
	if (sA > sB) {
		int tmp = sB;
		sB = sA;
		sA = tmp;

		tmp = gB;
		gB = gA;
		gA = tmp;
	}

	if (gA < sB) {
		cout << "Yes";
		return 0;
	}

	if (gB < gA) {

		for (int i = sB - 1; i <= gB + 1; i += 1) {
			int sec = 0;
			for (int j = i; j <= gB + 1; j++) {
				if (S[j] == '.') {
					sec++;
				}
				else {
					break;
				}

				if (sec >= 3) {
					cout << "Yes";
					return 0;
				}
			}
			
		}
		cout << "No";
		return 0;

	}
	else {

		cout << "Yes";



	}

}


Measured memory_bytes: 592
#include <iostream>
#include <bitset>
#include <string>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string str;
  cin >> str;
  bitset<100000> bs;
  for (size_t i = 0, size = str.size() - 1; i < size; ++i) {
    if (str[i] == 'A' && str[i+1] == 'C') {
      bs.set(i);
      ++i;
    }
  }
//  cout << bs << endl;
  for (int i = 0; i < Q; ++i) {
    int S, E;
    cin >> S >> E;
    bitset<100000> q = bs >> (S - 1);
    q = q << (S + 100000 - E);
//    cout << q << endl;
    cout << q.count() << endl;
  }

  return 0;
}


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

int main(void){
    int cost = 0;
    int a[3];
    int i,j,temp;
    int x;
    for(i = 0; i < 3; i++){
        scanf("%d",&a[i]);
    }
    for(i = 0; i < 3; i++){
        for(j = i + 1; j < 3; j++){
            if(a[i] > a[j]){
                temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
    }
    for(i = 0; i < 2; i++){
        j = i + 1;
        cost += abs(a[j]-a[i]);
    }
    printf("%d\n",cost);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int dp[8001];
int dp2[8001];
int dp3[8001];
int main(){
    int n;
    cin >> n;
    vector<int> r(n),a(n),w(n),t(n);
    vector<pair<int,int> > p;
    rep(i,n){
        cin >> r[i] >> a[i] >> w[i] >> t[i];
        p.push_back(MP(-(r[i]+t[i]),i));
    }
    sort(p.begin(),p.end());
    rep(id,n){
        int i = p[id].second;
        rep(j,t[i]+1){
            dp2[j] = -inf;
            dp3[j] = -inf;
        }
        rep(j,t[i]+1){
            dp2[j] = a[i] + dp[r[i]+j];
        }
        for(int j = t[i]-r[i];j>=0;j--){
            dp3[j] = max(max(dp2[j+r[i]]+w[i],dp3[j+r[i]]+w[i]),dp2[j]);
        }
        rep(j,t[i]+1){
            dp[j] = max(dp[j],max(dp2[j],dp3[j]));
        }
        
        // rep(j,12){
        //     cerr <<  dp[j] << " " ;
        // }
        // cerr << endl;
        // rep(j,12){
        //     cerr << dp2[j] << " " ;
        // }
        
        // cerr << endl;
        // rep(j,12){
        //     cerr << dp3[j] << " " ;
        // }
        // cerr << endl;
    }
    int mx = 0;
    rep(i,4001){
        mx = max(mx,dp[i+1]);
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    int k,x; cin>>k>>x;
    for(int i = max( -1000000LL,x-k+1);i<=x;i++)
        cout<<i<<" ";
    for(int i=x+1;i<=min(1000000LL,x+k-1);i++)
        cout<<i<<" ";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
        cin>>s;

         int n=s.length();
         int n1=(s.length()-1)/2;
         int n2=(s.length()+3)/2;

        int c=0,c1=0,c2=0;

           for(int i=0;i<=n/2 -1;i++)
           {
               if(i>=0 && i<=n1-1)
              {if(s[i]!=s[n1-1-i]) c1++;}

               if(i>=n2-1 && i<=n-1)
              {  if(s[i]!=s[n2-1-i]) c2++;}

                if(s[i]!=s[n-1-i])
                 c++;
           }


           if(c==0 && c1==0 && c2==0)
           cout<<"Yes";

           else
           cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline A abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
struct UnionFind {
  vector < int > par;
  vector < int > siz;
   
  UnionFind(int n): par(n), siz(n, 1) {
    for(int i = 0; i < n; i++) par[i] = i;
  }
  int root(int x){ 
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
  }
  int size(int x){ return siz[root(x)];}
  bool same(int x, int y){ return root(x) == root(y); }//判定
  bool unite(int x, int y){//連結
    if((x=root(x))==(y=root(y))) return false;
    if( siz[y] > siz[x] ) swap(x,y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }
};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >>n>>m;
  UnionFind uf(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    uf.unite(a-1,b-1);
  }
  lol ans=1;
  for(int i=0;i<n;i++){
    chmax(ans,uf.size(i));
  }
  cout <<ans<<'\n';

  return(0);
}

Measured memory_bytes: 4792
#include <iostream>
#include <queue>

typedef struct _masu {
  int i;
  int j;
} Masu;

int main(void) {
  int h = 0, w = 0;
  int map[22][22] = {0};
  
  std::cin >> h;
  std::cin >> w;
  
  // outer edges of map are #
  for(int i = 0; i < h+2; i++) {
    map[i][0] = -1;
    map[i][w+1] = -1;
  }
  for(int j = 0; j < w+2; j++) {
    map[0][j] = -1;
    map[h+1][j] = -1;
  }
  for(int i = 1; i < h+1; i++) {
    for(int j = 1; j < w+1; j++) {
      map[i][j] = 0;
    }
  }
  
  // read stdin
  for(int i = 1; i < h+1; i++) {
    for(int j = 1; j < w+1; j++) {
      char ch;
      std::cin >> ch;
      if(ch == '.') map[i][j] = 0;
      else if(ch == '#') map[i][j] = -1;
      else printf("error: wrong input %c at %d %d\n", ch, i, j);
    }
    scanf(" ");
  }
  
  int max_of_step = 0;
  
  // BFS for each (i, j)
  for(int i = 1; i < h+1; i++) {
    for(int j = 1; j < w+1; j++) {
      if(map[i][j] == -1) continue;
      int bfs_map[22][22];
      
      // init
      for(int i = 0; i < h+2; i++) {
        for(int j = 0; j < w+2; j++) {
          bfs_map[i][j] = -1;
        }
      }
      
      std::queue<Masu> que;
      
      que.push(Masu{i, j});
      bfs_map[i][j] = 0;
      
      while(!que.empty()) {
        Masu m = que.front();
        que.pop();
        if(map[m.i-1][m.j] == 0 && bfs_map[m.i-1][m.j] == -1) {
          bfs_map[m.i-1][m.j] = bfs_map[m.i][m.j]+1;
          if(bfs_map[m.i-1][m.j] > max_of_step) max_of_step = bfs_map[m.i-1][m.j];
          que.push(Masu{m.i-1, m.j});
        }
        if(map[m.i+1][m.j] == 0 && bfs_map[m.i+1][m.j] == -1) {
          bfs_map[m.i+1][m.j] = bfs_map[m.i][m.j]+1;
          if(bfs_map[m.i+1][m.j] > max_of_step) max_of_step = bfs_map[m.i+1][m.j];
          que.push(Masu{m.i+1, m.j});
        }
        if(map[m.i][m.j-1] == 0 && bfs_map[m.i][m.j-1] == -1) {
          bfs_map[m.i][m.j-1] = bfs_map[m.i][m.j]+1;
          if(bfs_map[m.i][m.j-1] > max_of_step) max_of_step = bfs_map[m.i][m.j-1];
          que.push(Masu{m.i, m.j-1});
        }
        if(map[m.i][m.j+1] == 0 && bfs_map[m.i][m.j+1] == -1) {
          bfs_map[m.i][m.j+1] = bfs_map[m.i][m.j]+1;
          if(bfs_map[m.i][m.j+1] > max_of_step) max_of_step = bfs_map[m.i][m.j+1];
          que.push(Masu{m.i, m.j+1});
        }
      }
    }
  }
  
  printf("%d\n", max_of_step);
  
  return 0;
}

Measured memory_bytes: 384
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

quickSortVec l u arr
  | l >= u    = return ()
  | otherwise = do
      VM.unsafeSwap arr l ((u+l)`div`2)
      t <- VM.unsafeRead arr l
      let i = l
          j = u + 1
      nj <- loopVec t u i j arr
      VM.unsafeSwap arr l nj
      quickSortVec l (nj-1) arr
      quickSortVec (nj+1) u arr

loopVec !t !u !i !j arr = do
  ni <- doWhile i (+1)         (< t)
  nj <- doWhile j (subtract 1) (> t)
  if ni > nj
    then return nj
    else do VM.unsafeSwap arr ni nj
            loopVec t u ni nj arr
              where
                {-# INLINE doWhile #-}
                doWhile k op p
                  | nk > u    = return nk
                  | otherwise = do
                      x <- VM.unsafeRead arr nk
                      if p x then
                        doWhile nk op p
                        else
                        return nk
                        where
                          nk = op k

main = do
  [n, k] <- getIntList
  d <- VM.new n
  forM_ [0..(n-1)] $ \i -> do
    [a, b] <- getIntList
    VM.write d i (a, b)
  quickSortVec 0 (n-1) d

  let findKth :: Int -> Int -> IO Int
      findKth j ct = do
        (a, b) <- VM.read d j
        if k - ct <= b
          then return a
          else findKth (j+1) (ct+b)

  ans <- findKth 0 0
  print ans

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

struct edge{int to,cost;};

bool used[110000];
int V;
vector<edge> g[210000];
int dista[110000];
int inf = 2000000007;

void numbering(int x,int y){
  if(used[x] == true){
    return;
  }
  else{
    used[x] = true;
    for(int i = 0;i < g[x].size();i++){
      if(used[g[x][i].to] == false){
        dista[g[x][i].to] = y + g[x][i].cost;
        numbering(g[x][i].to,dista[g[x][i].to]);
      }
    }
  }
}


int main(){
  int n,m;
  cin >> n >> m;
  vector<int> l(m),r(m),d(m);
  for(int i = 0;i < n;i++){
    used[i] = false;
  }
  for(int i = 0;i < m;i++){
    int a;
    edge e,f;
    cin >> a >> e.to >> e.cost;
    l.at(i) = a;
    r.at(i) = e.to;
    d.at(i) = e.cost;
    f.to = a;
    f.cost = -e.cost;
    g[a].push_back(e);
    g[e.to].push_back(f);
  }
  for(int i = 0;i < n;i++){
    numbering(i,0);
  }
  bool result = true;
  for(int i = 0;i < m;i++){
    if(d.at(i) != dista[r.at(i)] - dista[l.at(i)]){
      result = false;
    }
  }
  if(result == true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 17024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	ll n, a, b;
	cin >> n >> a >> b;
	cout << n/(a+b)*a + min(n%(a+b), a) << endl;
	return 0;
}


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

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

  vector<int> l(N);
  for (int i = 0; i < N; i++) {
    cin >> l.at(i);
  }
  sort(l.begin(), l.end(), greater<int>());

  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += l.at(i);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
  int n;
  int k, l, mod=0, ans=0, era;
  int a[256] ={}, a_ho = 0;
  while(scanf("%d", &n)!=EOF)
    {
      for(k=2; k<=n; k++)
        {
          era = sqrt(k);
          if(era==1)
            {
              ans++;
              a[a_ho] = k;
              a_ho++;
            }
          else
            {
              for(l=0; a[l]<=era; l++)
                {
                  if(k % a[l] ==0)
                    {
                      mod++;
                      break;
                    }
                }
              if(mod==0)
                {
                  ans++;
                  if(a_ho < 256)
                    {
                      a[a_ho] = k;
                      a_ho++;
                    }
                }
              mod = 0;
            }
        }
      printf("%d\n", ans);
      ans = 0;
      a_ho = 0;
    }
  return 0;
}

Measured memory_bytes: 596
N,M = gets.split.map &:to_i
Ways = {}
M.times{
  a,b = gets.split.map &:to_i
  Ways[a] ||= {}; Ways[b] ||= {}
  Ways[a][b] = Ways[b][a] = 1
}
Visited = Array.new(N+1, nil)
Visited[1] = 1
cluster = [1]
while cluster.size > 0 do
  nc = []
  cluster.each{ |a|
  	Ways[a].keys.each{ |b|
      next if Visited[b]
      nc << b
      Visited[b] = a
    }
  }
  cluster = nc
end
puts "Yes", Visited[2..-1]

Measured memory_bytes: 45160
import java.util.Scanner;

class A {
    public static void main(String...args) {
        final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int K = sc.nextInt();
        System.out.println(N >= 2 * K - 1 ? "YES" : "NO");
    }
}
public class Main {
    public static void main(String...args) {
        A.main();
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX 1000000
#define pb push_back

using namespace std;

int prime[MAX];

int main()
{
	prime[0] = prime[1] = 0;

	REP(i,2,MAX)
	{
		prime[i] = 1;
	}

	REP(i,2,MAX)
	{
		if(prime[i])
		{
			for(int j = i*2;j < MAX;j += i)
			{
				prime[j] = 0;
			}
		}
	}

	int n;
	while(cin >> n && n)
	{
		int count = 0;
		rep(i,(n/2)+1)
		{
			if(prime[i] == 1 && prime[n - i] == 1)
			{
				count++;
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 5068
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, m, x, y = na()
xs = na()
ys = na()

zmin = max(xs) + 1
zmax = min(ys)
if zmin <= zmax and x < zmin and zmax <= y: 
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
   int a,b;
   char x;
   cin>>a>>x>>b;
   if(x=='+')
    a+=b;
   else
    a-=b;
   cout<<a<<endl;

    return 0;
}


Measured memory_bytes: 3580
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	map<string, ll> a;
	for (int i = 0; i < n; i++)
	{
		int q;
		cin >> q;

		string s;
		cin >> s;

		switch (q)
		{
			case 0:
				ll x;
				cin >> x;
				a[s] = x;
				break;

			case 1:
				if (a.count(s))
				{
					println(a[s]);
				}
				else
				{
					println(0);
				}
				break;

			case 2:
				if (a.count(s))
				{
					a.erase(s);
				}
		}
	}
}



Measured memory_bytes: 27744
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define int long long
#define MOD 1000000007
#define mod 998244353
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define endl "\n"
using namespace std;

int colour[100005];
int vis[100005];
void solve1();
void solve()
{
    int T=10;cin>>T;
    for(int z=1;z<=T;z++)
    {
        solve1();
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve1();
    return 0;
}
void solve1()
{
    string str;cin>>str;
    int p=0,ans=0;
    for(int i=0;i<3;i++)
    {
        if(str[i]=='R'){while(str[i]=='R'){p++;i++;ans=max(ans,p);}
        i--;}
        else {p=0;}
    }
    ans=max(ans,p);
    cout<<ans<<endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int x,y,z;
    cin >> x>> y>>z;
    /*
    int a[n];
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a[i] = tmp;
    }
    */
    int ans = 0;
    cout << z << " " << x << " "<< y << endl;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;


ll N, a[111], sum = 0;
ll cost(ll idx){
    return abs(N * a[idx] - sum);
}

int main(){

    cin >> N;
    rep(i, N){
        cin >> a[i];
        sum += a[i];
    }
    ll ans = 0;
    rep(i, N)if(cost(ans) > cost(i))ans = i;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	vector<int> a(3); cin >> a[0] >> a[1] >> a[2];
	sort(ALL(a));
	if (a[0] < a[1] && a[1] < a[2])cout << 3 << endl;
	else if ((a[0] == a[1] && a[1] != a[2]) || (a[0] != a[1] && a[1] == a[2])) cout << 2 << endl;
	else cout << 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int len,n;
	char str[20]="";
	scanf("%s", &str);
	len=0;
	while (str[len]!='\0'){
		len++;
	}
	for (n=len-1;n>=0;n--){
		printf("%c", str[n]);
	}
        printf("\n");
	return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s;cin >> s;
    lint ans=0;
    REP(i, SZ(s)/2) {
        ans+=(s[i]!=s[SZ(s)-i-1]);
    }

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    if (Integer.valueOf(S.substring(0, 4)) <= 2019) {
      if (Integer.valueOf(S.substring(5, 6)) != 0) {
        System.out.println("TBD");
        return;
      }
      if (Integer.valueOf(S.substring(6, 7)) < 5 && (int) Integer.valueOf(S.substring(8, 10)) < 31) {
        System.out.println("Heisei");
        return;
      }
    }
    System.out.println("TBD");
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

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

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

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

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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 COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {int n;
cin>>n;
n%=10;

if(n==3){
	cout<<"bon"<<endl;
	return 0;
}
if(n==0 || n==1 || n==6 || n==8){
	cout<<"pon"<<endl;
	return 0;
}

cout<<"hon"<<endl;
return 0;



}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N, K;
  std::cin >> N >> K;

  std::vector<ll> H(N);
  rep(i, N) {
    std::cin >> H[i];
  }
  std::sort(H.begin(), H.end());

  for(int i = N - 1; i >= N - K; --i) {
    if(i < 0) break;
    H[i] = 0;
  }

  ll ans = 0;
  rep(i, N) {
    ans += H[i];
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 1792
MODULE intQsortMod
! 整数型のクイックソート
! precisionで整数の精度を定める．
! インデックスの小さいほうが値も小さい(昇順)．

! 参考
! https://t.doujin-constant.net/post/143374686394/fortranをより使いこなしたquick-sort

      implicit none
      integer,parameter,private :: precision = 16
      
      interface qSort
        module procedure :: intQsort
      end interface
      
      contains
      pure recursive function intQsort( a ) result( r )
        implicit none
        integer(precision), intent(in) :: a(:)
        integer(precision) :: r( size(a) )
        integer(precision) :: sample(3), len, i,j
        
        len = size( a(:) )
        if( len<=1 )then
          r = a
        else
          !select pivot
          sample(1:3) = [a(1), a(len/2), a(len)]
          do i = 1,2
            do j = 2,3
              if( sample(i)>sample(j) )then
                len = sample(i) !len is buffer
                sample(i) = sample(j)
                sample(j) = len
              end if
            end do
          end do
          
          r = [ qSort( pack(a(:), a(:)< sample(2) ) ), &
                       pack(a(:), a(:)==sample(2) )  , &
                qSort( pack(a(:), a(:)> sample(2) ) ) ]
        end if
      end function intQsort
      END MODULE intQsortMod

      PROGRAM Alchemist
      use intQsortMod
      IMPLICIT NONE
      integer(16) :: n,ans
      integer(16),allocatable :: v(:)
      integer(16) :: i
      real(16),allocatable :: reV(:)
      
      read*,n
      allocate( v(n),rev(n) )
      read*,v(1:n)
      
      v = Qsort( v )
      !print*,v
      
      reV = real( v )
      
      do i = 2,n
        reV(i) = (reV(i)+reV(i-1)) / 2_16
      end do
      
      print*,reV(n)
      
      
      END PROGRAM

Measured memory_bytes: 512
#include<cstdio>
#include<unordered_map>
using namespace std;
using ull = unsigned long long;

int main(){
    ull N, M;
    scanf("%llu %llu", &N, &M);
    unsigned ruiseki[N+1];
    ruiseki[0] = 0;
    for (unsigned i = 0; i < N; i++){
        unsigned tmp;
        scanf("%u", &tmp);
        ruiseki[i+1] = (ruiseki[i] + tmp) %M;
    }
    unordered_map<unsigned, ull> mod;
    for (unsigned i = 0; i <= N; i++){
        mod[ruiseki[i]]++;
    }
    ull answer = 0;
    for(auto i : mod) answer += i.second*(i.second - 1)>>1;
    printf("%llu\n", answer);
	return 0;
}

Measured memory_bytes: 6424
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    for (int h = 1; h < 3501; ++h) {
        for (int w = 1; w < 3501; ++w) {
            if (((-n * (h + w) + 4 * h * w)) > 0 && (h * w * n) % (-n * (h + w) + 4 * h * w) == 0) {
                cout << h << " " << h * w * n / (-n * (h + w) + 4 * h * w) << " " << w << "\n";
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	long long int a[10000], min, max, sum;
	int i;
	scanf("%d", &n);
	scanf("%lld", &a[0]);
	min=max=sum=a[0];
	for(i=1; i<n; i++) {
		scanf("%lld", &a[i]);
		if(a[i]<min) min=a[i];
		if(a[i]>max) max=a[i];
		sum+=a[i];
	}
	printf("%lld %lld %lld\n", min, max, sum);
	
	return 0;
}


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

int main(){
	int64_t x,count;
	cin >> x;
	count=0;
	int p=x%11;
	if(p<=6 && p>0){
		cout<<(x/11)*2+1<<endl;
	}
  	else if(p==0){
		cout<<(x/11)*2<<endl;
    }
	else{
		cout<<(x/11)*2+2<<endl;
	}
	
	
}



Measured memory_bytes: 256
inp = input()

#print(inp.startswith("A"))
#print(inp[2:len(inp)-1].count("C") ==  1)
#print(inp[1:inp.find("C", 0, len(inp) - 1)] == inp[1:inp.find("C", 0, len(inp) - 1)].lower())
#print(inp[inp.find("C", 0, len(inp) - 1) + 1:len(inp)] == inp[inp.find("C", 0, len(inp) - 1) + 1:len(inp)].lower())

if inp.startswith("A") and inp[2:len(inp)-1].count("C") ==  1 and inp[1:inp.find("C", 0, len(inp) - 1)] == inp[1:inp.find("C", 0, len(inp) - 1)].lower() and inp[inp.find("C", 0, len(inp) - 1) + 1:len(inp)] == inp[inp.find("C", 0, len(inp) - 1) + 1:len(inp)].lower():
  print("AC")
else:
  print("WA")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
 
using namespace std;
using namespace __gnu_pbds;
 
// template<typename T>
using o_set=tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define M 1000010


int main(){
	IOS;
	ll a,b;cin>>a>>b;
	string s1,s2;
	rep(i,0,a)s1+=(b+'0');
	rep(i,0,b)s2+=(a+'0');
	if(s1<s2)cout<<s1;
	else cout<<s2;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  map<char, int> mp;
  rep(i, 4) mp[s[i]]++;
  if(sz(mp)==2 &&  mp[s[0]]==2 && mp[s[1]]==2 && mp[s[2]]==2 && mp[s[3]]==2)
    puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 3592
def main():
    H, W = map(int, input().split())
    matrix = [list(input()) for _ in range(H)]
    for r in matrix:
        r.insert(0, ".")
        r.append(".")
    matrix.insert(0, ["."] * (W + 2))
    matrix.append(["."] * (W + 2))

    count_matrix = [[0] * W for _ in range(H)]
    for r in range(1, H + 1):
        for c in range(1, W + 1):
            if matrix[r][c] == "#":
                count_matrix[r-1][c-1] = "#"
                continue
            for p_r in range(r-1, r+2):
                for p_c in range(c-1, c+2):
                    if matrix[p_r][p_c] == "#":
                        count_matrix[r-1][c-1] += 1
    print("\n".join(["".join([str(v) for v in r]) for r in count_matrix]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 41328
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int K = 30;

int main(){
    fastIO;
    int n;
    cin >> n;
    int x;
    vector<int> tt;
    for(int i = 0 ; i < n; i ++ ){
        cin >> x;
        tt.push_back(x);
    }
    int res = 0;
    sort(tt.begin(), tt.end());
    int ff;
    int z;
    for(int bb = K ; bb >= 0 ;bb -- ){
        ff = (1 << bb);
        vector<int> nw;
        z = (int)tt.size() - 1;
        for(int i = 0 ; i < tt.size(); i ++ ){
            while(z > 0 && ff - tt[i] < tt[z]){
                z -- ;
            }
            if(i >= z)
                break;
            if(tt[i] + tt[z] == ff){
                tt[i] = -1;
                tt[z] = -1;
                res ++ ;
                z -- ;
            }
        }
        for(auto p : tt)
            if(p != -1)
                nw.push_back(p);
        tt = nw;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 2924
#include <bits/stdc++.h>
#define N 100010
using namespace std;
int main(){
	int i,k,n,a[N],ans;
	cin>>n>>k;
	for(i=0;i<n;i++)
		cin>>a[i];
	ans=(n-1)/(k-1);
	if((n-1)%(k-1)!=0)
		ans++;
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);


int main() {
	cin.sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	cout << abs(n*m - n * 2 - m * 2 + 4) << endl;

	return 0;
}


Measured memory_bytes: 256
///#pragma GCC optimize("Ofast")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
///#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
///#include<ext/pb_ds/assoc_container.hpp>
///#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vii> vvii;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<bool> vbb;

const ll N = 1000001;
const ll MOD = 1000000007;
const ll INF = LLONG_MAX;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rev(a) reverse(all(a))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl
#define space ' '
#define nl '\n'
#define PI acos(-1)
#define Case(x) cout<<"Case "<<x<<": "
#define strtoint(a) atoi(a.c_str())
#define inttostr(n) to_string(n)

#define coutv(v) for(auto it:v)cout<<it<<space;cout<<nl;
#define cinv(v) for(auto &it:v)cin>>it;

ll f(ll x)
{
    return (x*x*x*x*x);
}

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int tc=1,cs=0;
    //cin>>tc;
    while(tc--)
    {
        ll n,i,j;
        cin>>n;
        ///cout<<f(n)<<nl;
        for(i=-1000; i<1000; i++)
        {
            for(j=-1000; j<1000; j++)
                if(f(i)-f(j)==n)
                {
                    cout<<i<<space<<j<<nl;
                    return 0;
                }
        }
    }
}


Measured memory_bytes: 3640
#if 0
?????????X[0]???????????????????????\???????????¨??§???X[1],Y[1]???????????????????????????????????????
#endif

#include <iostream>
#include <string>
using namespace std;

int main(){
	int q;
	cin >> q;
	for(int a=0;a<q;++a){
		string X,Y;
		int L[1000+10][1000+10];
		cin >> X >> Y;
		for(int i=0;i<1000;++i) //???????????\????????????L????????????
			for(int j=0;j<1000;++j)
				L[i][j]=0;
	
		for(int j=1;j<X.size()+1;++j)
			for(int k=1;k<Y.size()+1;++k){
				if(X[j-1]==Y[k-1])
					L[j][k]=1+L[j-1][k-1];
				else
					L[j][k]=max(L[j-1][k],L[j][k-1]);
			}
		cout << L[X.size()][Y.size()] << endl;
	}
}

Measured memory_bytes: 7084
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Aman
 */


#include<bits/stdc++.h>

using namespace std;

#include <iostream>

void __print(int x) { cout << x; }

void __print(long x) { cout << x; }

void __print(long long x) { cout << x; }

template<typename T, typename V>
void __print(const pair<T, V> &x) {
    cout << '{';
    __print(x.first);
    cout << ',';
    __print(x.second);
    cout << '}';
}

template<typename T>
void __print(const T &x) {
    int f = 0;
    cout << '{';
    for (auto &i: x) cout << (f++ ? "," : ""), __print(i);
    cout << "}";
}

void _print() { cout << "]\n"; }

template<typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cout << ", ";
    _print(v...);
}


#define ll   long long
#ifdef LOCAL
#else
#define dbg(x...)
#endif

ll m = 1e9 + 7;

class DRedistribution {
public:

    void solve2(std::istream &cin, std::ostream &cout) {
        ll s;
        cin >> s;

        vector<ll> dp(s + 1, 0);
        dp[0] = 1;
        for (ll i = 1; i <= s; i++)
            for (ll j = 3; j <= s and i - j >= 0; j++)
                dp[i] = (dp[i] + dp[i - j]) % m;

        cout << dp[s];

    }

    void solve(std::istream &cin, std::ostream &cout) {
        ll t = 1;
//            cin >> t;
        while (t--) {
            solve2(cin, cout);
        }
    }

};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    DRedistribution solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3652
import java.util.*;

public class  Main{
	public static void main(String args[]){
	  Scanner sc = new Scanner(System.in);
  	  String str = sc.next();
      if(str.equals("Sunny")) System.out.println("Cloudy");
      else if(str.equals("Cloudy")) System.out.println("Rainy");
      else if(str.equals("Rainy")) System.out.println("Sunny");
	}
}

Measured memory_bytes: 19796