akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int S=s.size(),T=t.size();
  vector<vector<int>> dp(S+1,vector<int>(T+1,0));
  for(int i=1;i<S+1;i++){
    for(int j=1;j<T+1;j++){
      if(s[i-1]==t[j-1])
        dp[i][j]=dp[i-1][j-1]+1;
      else
        dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
    }
  }
  /*for(int i=0;i<S+1;i++){
    for(int j=0;j<T+1;j++){
      cout << dp[i][j];
      if(j==T-1)
        cout << endl;
      else
        cout << ' ';
    }
  }*/
  string ans="";
  vector<int> da(dp[S][T]);
  int a=S,b=T,x=dp[S][T]-1;
  while(a>0&&b>0){
    if(s[a-1]==t[b-1]){
      da[x]=a-1;
      x--;
      a--;b--;
    }
    else{
      if(dp[a][b-1]<dp[a-1][b])
        a--;
      else
        b--;
    }
  }
  for(int i=0;i<dp[S][T];i++){
    ans+=s[da[i]];
  }
  cout << ans << endl;
  //cout << dp[S][T] << endl;
}
        

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[100005];
bool ok(int p){
	int cnt=0;
	int s=0;
	for(int i=0;i<n;i++){
		s+=a[i];
		if(s>p){
			s=a[i];cnt++;
			if(s>p)return 0;
		}
	}
	if(s>0)cnt++;
	if(s>p)return 0;
	return cnt<=k;
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	int l=0,r=1000000001;
	int m;
	while(l<r-2){
		m=(l+r)/2;
		if(ok(m))r=m;
		else l=m;
	}
	for(int i=l;i<=r;i++)
		if(ok(i)){cout<<i<<endl;break;}
	
	return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    IOS;
    //ll t;cin>>t;while(t--)
    {
        ll a,b,c,d,i,j,k,l,m,n,sum=0,temp=0,f=0,cnt=0;
        cin>>n;
        ll arr[n];
        for(i=0;i<n;i++)cin>>arr[i];
        for(i=0;i<n-2;i++)
        {
            for(j=i+1;j<n-1;j++)
            {
                for(k=j+1;k<n;k++)
                {
                    a=arr[i];
                    b=arr[j];
                    c=arr[k];
                    if((a+b>c) && (b+c>a) && (a+c>b) &&(a!=b && b!=c && a!=c))
                        cnt++;


                }
            }
        }
        cout<<cnt<<endl;



    }
}




Measured memory_bytes: 3632
#include <sstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>

using namespace std;

#define fto(i,a,b) for (int i = (a); i <= b; i++)
#define fdw(i,a,b) for (int i = (a); i >= b; i--)
#define rep(i,a) for(int i = 0; i < a; i++) 
#define read(a) cin >> a
#define read2(a, b) cin >> a >> b
#define read3(a, b, c) cin >> a >> b >> c
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define write(a, b) cout << a << b
#define writeln(a) cout << a << "\n"

#define PI 3.14159265
#define oo 1000000000
#define ooLL 100000000000000000
#define log(a) cerr << #a << " = " << a << endl

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define next thongdeptrai
#define prev thongbachuthegioi
#define y1 thongsieucapvutru
#define y0 thongnotgay

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

#define maxn 100005

ll x, t;

using namespace std;

int main() {
//	#ifndef ONLINE_JUDGE
  //  	freopen("in.inp", "r", stdin);
  //  #endif

    read2(x, t);
    cout << max(0LL, x - t) << endl;

 	#ifndef ONLINE_JUDGE
    	cout << endl;
    	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using lnd = long double;
using std::cin;
using std::cout;
using std::endl;

int main()
{
    lnd x1, y1, x2, y2 ;
    cin >> x1 >> y1 >> x2 >> y2;
    //dis=(y2-y1)+(x2-x1);
    cout << std::fixed;
    cout << std::sqrt( std::pow(y2-y1, 2.0) + std::pow(x2-x1,2.0) ) << endl; //sqrt float, sqrtf double, sqrtl long double,
    
    return 0;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ff first
#define ss second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;


int32_t main()
{
    fast

   int test=1;
   //cin>>test;

  while(test--)
  {
  int h,w;
  cin>>h>>w;
  char a[h][w];
  for(int i=0;i<h;i++)
  {
    for(int j=0;j<w;j++)cin>>a[i][j];
  }
vvi dp(h,vi (w,0));
dp[0][0]=1;

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
    {
      if(i+1<h&&a[i+1][j]=='.')dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
      if(j+1<w&&a[i][j+1]=='.')dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
    }

    cout<<dp[h-1][w-1];

  //while loop ending 
  }



return 0;
}

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

int main(){
  
  int x, ans = 1;
  
  cin >> x;
  
  for(int i = 2;i <= 100;i++){
    for(int j = 2;(int)pow(i, j) <= x;j++){
      ans = max(ans, (int)pow(i , j));
    }
  }
  
  cout << ans << endl;
  
  return 0;
}





Measured memory_bytes: 256
#include<cstdio>
char tile[101][101];
int stat[101][101];
int main(void)
{
	int x,y;
	
	while(scanf("%d %d",&y,&x)!=EOF)
	{
		if(x==0||y==0)break;
		int now_x=0,now_y=0;
		fflush(stdin);
		for(int f1=0;f1<y;f1++)
		{
			scanf("%s",tile[f1]);
		}
		while(1){
			switch(tile[now_y][now_x])
			{
			case '>':
				now_x++;
				break;
			case '<':
				now_x--;
				break;
			case '^':
				now_y--;
				break;
			case 'v':
				now_y++;
				break;
			case '.':
				printf("%d %d\n",now_x,now_y);
				goto G;
			}
		//	printf("now->%d %d\n",now_x,now_y);
			if(stat[now_y][now_x])
			{
				printf("LOOP\n");
				goto G;
			}
			stat[now_y][now_x]=1;
		}
		G:;
		for(int f1=0;f1<101;f1++)
		{
			for(int f2=0;f2<101;f2++)
			{
				tile[f1][f2]='\0';
				stat[f1][f2]=0;
			}
		}
		now_x=0;now_y=0;
	}
	/*
	fflush(stdin);
	getchar();
	*/
	return 0;
}

Measured memory_bytes: 1096
h, i = map(int, input().split())
k, l = map(int, input().split())
a, b, c, d = map(int, input().split())
p = h * a + h // 10 * c + i * b + i // 20 * d
q = k * a + k // 10 * c + l * b + l // 20 * d
if p == q:print("even")
else:print("hiroshi" if p > q else "kenjiro")


Measured memory_bytes: 5596
import java.util.Arrays;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] v = new int[N];
    for (int i = 0; i < N; i++) v[i] = scanner.nextInt();
    for (int i = 0; i < N; i++) v[i] = v[i] - scanner.nextInt();
    Arrays.sort(v);
    int vmax = 0;
    for (int i = N - 1; i >= 0; i--) {
      if (v[i] > 0) vmax += v[i];
      else break;
    }
    System.out.println(vmax);
  }
}


Measured memory_bytes: 23764
import java.util.*;

public class Main { 

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a, b;
		a = sc.nextInt();
		b = sc.nextInt();
		
		System.out.println(a * b % 2 == 0 ? "Even" : "Odd");

	}

}


Measured memory_bytes: 21716
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	string s;
	cin>>s;
	int n=s.size();
	vi t(n);
	rep(i,n)if(s[i]=='R')t[i]=i+1;else t[i]=i-1;
	rep(i,100){
		vi nt(n);
		rep(j,n)nt[j]=t[t[j]];
		t=nt;
	}
	vi c(n);
	rep(i,n)c[t[i]]++;
	show1d(c);
}


Measured memory_bytes: 2116
A, B, C, D, E, F = map(int, input().split())

W = set()
for a in range(0, F+1, 100 * A):
    for b in range(0, F - a+1, 100 * B):
        W.add(a + b)

S = set()
for c in range(0, F+1, C):
    for d in range(0, F - c+1, D):
        S.add(c + d)

mx = -1
for w in W:
    for s in S:
        if 0 < w + s <= F and s <= w * E // 100:
            if mx < s/(w+s):
                ans = w+s, s
                mx = s/(w+s)
print(ans[0], ans[1])


Measured memory_bytes: 3188
// Let Go Your Earthly Tether , Enter The Void , Empty And Become Wind

#include<bits/stdc++.h>

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

#define PB push_back
#define F first
#define S second
#define _sz(x) (int)x.size()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std ;
using ll = long long ;
using ld = long double ;
using pll = pair<ll , ll> ;

const ll MAXN = 100 * 100 + 10 ;
const ll inf = 1e18 + 19 ;

ll a[MAXN] , b[MAXN] , dp[MAXN][MAXN] , h , n ;

int main() {
        ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;
        cin >> h >> n ;
        for (int i = 1 ; i <= n ; i ++)
                cin >> a[i] >> b[i] ;
        for (int i = 0 ; i <= n ; i ++)
                for (int j = 0 ; j <= h ; j ++)
                        dp[i][j] = inf ;
        for (int i = 0 ; i <= n ; i ++)
                dp[i][0] = 0 ;
        for (int i = 1 ; i <= n ; i ++)
                for (int j = 1 ; j <= h ; j ++) {
                        dp[i][j] = min(dp[i - 1][j] , dp[i][max(j - a[i] , (ll)0)] + b[i]) ;
                }
        cout << dp[n][h] ;
        return (0) ;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  ll n, d;
  cin >> n >> d;
  ll ans = 0;
  //vector<ll> a(n);  
  rep(i, 0, n) {
    ll x, y;
    cin >> x >> y;
    if(x*x + y*y <= d*d) ans++;
  }
  
  cout << ans << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";

}

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

namespace AtCorder
{
	public class Program
	{
		public static int max = 5001;

		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			string s = cin.Next();

			int ans = 0;
			int[,] dp = new int[n + 1, n + 1];
			for (int i = n - 1; i >= 0; --i) {
				for (int j = n - 1; j >= 0; --j) {
					if (j <= i) {
						dp[i, j] = 0;
					} else {
						if (s[i] == s[j]) {
							int length = dp[i + 1, j + 1] + 1;
							if (j <= i + length - 1) {
								length = 0;
							}

							ans = Math.Max(ans, length);
							dp[i, j] = length;
						}
					}
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 108640
#include<iostream>
using namespace std;
 
int main()
{
    int H, W;
    int i, j;
     
    do{
        cin >> H >> W;
        if((H == 0) && (W == 0)) break;
        for(i = 0; i < H; i++){
            for(j = 0; j < W; j++){
                cout << "#";
            }
            cout << endl;
        }
		cout << endl;
 
    }while(1);
 
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    size_t n, m;
    cin >> n >> m;

    auto p = vector<pair<uint32_t, uint32_t>>();

    for (size_t i = 0; i < m; ++i) {
        uint32_t _a, _b;
        cin >> _a >> _b;
        p.emplace_back(_a, _b);
    }

    sort(p.begin(), p.end(), [](auto &lhs, auto &rhs) {
        return lhs.second < rhs.second;
    });

    uint32_t prev = 0;
    uint32_t count = 0;

    for (auto &_p : p) {
        auto l = _p.first;
        auto r = _p.second;
        if (l < prev) {
            continue;
        }
        ++count;
        prev = static_cast<uint32_t>(r);
    }

    cout << count << endl;

    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    vector<int> height(10);
    rep(i, 10) cin >> height[i];

    sort(ALL(height), greater<int>());

    rep(i, 3)
    {
        OP(height[i])
    }

    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>

using namespace std;

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  int ans = 1;
  for (int i=1; i<S.size(); i++){
    if (S[i - 1] != S[i]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
n = int(input())
s = list(input())
n %= 26
alphabets = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

m = len(s)

for i in range(m):
	for j in range(26):
		if s[i] == alphabets[j]:
			s[i] = alphabets[j+n]
			break
s = ''.join(s)
print(s)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#define ll long long
using namespace std;

ll leng[32];
int r;

void fill_leng(){
    leng[30]=leng[31]=1;
    for(int i=29; i>=0; --i){
        leng[i]=leng[i+1]*2;
    }
}

string solve(ll X, ll Y){
    string res="";
    if(r==0) --Y;
    ll xnow=0, ynow=0;
    for(int i=0; i<31; ++i){
        ll dx=X-xnow, dy=Y-ynow;
        if(dx>dy){
            if(-dx<dy){
                res += "R";
                xnow += leng[i];
            }
            else{
                res += "D";
                ynow -= leng[i];
            }
        }
        else{
            if(-dx<dy){
                res += "U";
                ynow += leng[i];
            }
            else{
                res += "L";
                xnow -= leng[i];
            }
        }
    }
    if(r==0) res += "U";
    return res;
}

int main() {
	int N;
	cin >> N;
	vector<ll> x(N), y(N);
	for(int i=0; i<N; ++i){
	    cin >> x[i] >> y[i];
	}
	r=abs(x[0]+y[0])%2;
	for(int i=1; i<N; ++i){
	    if(abs(x[i]+y[i])%2!=r){
	        cout << -1 << endl;
	        return 0;
	    }
	}
	fill_leng();
	cout << 32-r << endl;
	cout << leng[0];
	for(int i=1; i<32-r; ++i) cout << ' ' << leng[i];
	cout << endl;
	for(int i=0; i<N; ++i) cout << solve(x[i], y[i]) << endl;
	return 0;
}


Measured memory_bytes: 256
/*<----------------------------------------------------------------------->

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
int parent[mxN] ,size[mxN],n,m,k,a,b,ans[mxN];
void make_set(int v){
    parent[v]=v ;
    size[v]=1 ;
}
int find_set(int v){
    if(parent[v]==v)
        return v ;
    return parent[v]=find_set(parent[v]) ;
}
void union_sets(int a,int b){
    a=find_set(a) ;
    b=find_set(b) ;
    if(a==b)
        return ;
    if(size[b]>size[a])
        swap(a,b) ;
    parent[b]=a ;
    size[a]+=size[b] ;
}
void solve(){
    mems(ans,-1) ;
    cin >> n >> m >> k ;
    for(int i=1;i<=n;i++)
        make_set(i) ;
    For(i,m){
        cin >>a>> b ;
        ans[a]--;ans[b]-- ;
        union_sets(a,b) ;
    }
    for(int i=1;i<=n;i++)
        ans[i]+=size[find_set(i)] ;
    For(i,k){
        cin >> a >>  b;
        if(find_set(a)==find_set(b)){
            ans[a]-- ;ans[b]-- ;
        }
    }
    for(int i=1;i<=n;i++)
        pff(ans[i]) ;
     
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 10;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n;
string s;
bool check(){
	if(n < 2 || n % 2) return 0;
	for(int i = 0,j = n/2;j < n;i++,j++){
		if(s[i] != s[j]) return 0;
	}
	return 1;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> s;
	if(check()) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0; 
}
//do smt instead of nothing! never give up!

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lf long double
#define INF 1000000000
#define MAX 200001
#define M 1000000007
using namespace std;
 
int main() {
    ll one = 1;
    ll n;
    cin >> n;
    ll a[n];
    for (int i=0;i<n;i++) cin >> a[i];
    ll bt[60];
    for (int i=0;i<60;i++) bt[i] = 0;

    for (ll i=0;i<n;i++) {
        for (ll j=0;j<60;j++) {
            if ((one<<j)&a[i]) bt[j]++;
        }
    }
    ll res = 0;
    for (ll i=0;i<60;i++) {
        ll k = (bt[i]*(n-bt[i]))%M;
        ll p = (one<<i);
        p%=M;
        res+=(p*k)%M;
        res%=M;
    }
    cout << res << endl;
    return 0;
}

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

#define X first
#define Y second
#define mp make_pair
#define sz(v) (int) v.size()
#define all(v) v.begin(), v.end()

using namespace std;

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

/*#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
                         tree_order_statistics_node_update>;*/

const int N = 2e5 + 5;

int n, k, c;
string s;
pii fenw[N];

void update(int pos, pii value) {
	for (int i = pos; i < n; i |= (i + 1)) {
		fenw[i] = max(fenw[i], value);
	}
}

pii get(int r) {
	pii ans = mp(0, 0);
	for (int i = r; ~i; i = (i & (i + 1)) - 1) {
		ans = max(ans, fenw[i]);
	}
	return ans;
}

pii dp[N];
int cnt[N], mx[N];
bool can[N];

void solve() {
	cin >> n >> k >> c >> s;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'x') {
			continue;
		}
		if (i - c - 1 < 0) {
			dp[i] = mp(0, -1);
		} else {
			dp[i] = get(i - c - 1);
		}
		dp[i].first++;
		update(i, mp(dp[i].first, i));
	}
	int i = max_element(dp, dp + n) - dp;
	if (dp[i].first > k) {
		return;
	}
	assert(dp[i].first == k);
	while (i > -1) {
		mx[dp[i].first] = i;
		i = dp[i].second;
	}
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'x') {
			continue;
		}
		if (dp[i].first == k || i + c < mx[dp[i].first + 1]) {
			can[i] = true;
			cnt[dp[i].first]++;
		}
	}
	for (int i = 0; i < n; ++i) {
		if (can[i] && cnt[dp[i].first] == 1) {
			cout << i + 1 << "\n";
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int tt = 1;
	// cin >> tt;
	while (tt--) solve();
	return 0;
}


Measured memory_bytes: 6676
#include<bits/stdc++.h>
#define pii pair<int, int>
#define LL long long
#define mp make_pair
#define pb push_back
using namespace std;
const int maxn = 2e5 + 10;
vector<int> G[maxn];
int n, m, cnt, vis[maxn];

void dfs(int u) {
	if (vis[u]) return ;
	++cnt;
	vis[u] = 1;
	for (int v : G[u])
		dfs(v);
}

int main() {
	#ifdef DEBUG
	freopen("text.in", "r", stdin);
	#endif
	scanf("%d%d", &n, &m);
	int ans = 0;
	for (int i = 1, u, v; i <= m; ++i) {
		scanf("%d%d", &u, &v);
		G[u].pb(v); G[v].pb(u);
	}
	for (int i = 1; i <= n; ++i) if (!vis[i]) {
		cnt = 0;
		dfs(i);
		ans = max(ans, cnt);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 21724
#include <bits/stdc++.h>
   using namespace std;
   using pii = pair<int, int>;
   using ll = long long;
   #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
   const ll MOD = 1000000007;
   const ll INFL = (1LL << 60);
   const int INFI = (1 << 30);

   int main() {
     int N; cin >> N;
     if (N % 10 == 3) cout << "bon" << endl;
     else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) cout << "pon" << endl;
     else cout << "hon" << endl;
   }


Measured memory_bytes: 3632
package main

import "fmt"

func main() {
	// Code for B - Making Triangle
	var N int
	fmt.Scanf("%d", &N)

	L := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &L[i])
	}

	var count int
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			for k := j + 1; k < N; k++ {
				if L[i]+L[j] > L[k] && L[j]+L[k] > L[i] && L[k]+L[i] > L[j] {
					if L[i] != L[j] && L[j] != L[k] && L[k] != L[i] {
						count++
					}
				}
			}
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 1840
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

VL primes(int n){
    vector<bool> a(n+1, 1);
    VL p;
    FOR(x,2,n){
        if (!a[x]) continue;
        p.push_back(x);
        for (int y = 2 * x; y <= n; y += x) a[y] = 0;
    }
    return p;
}

int main() {
    ll n = in();
    VL p = primes(100);
    int m = p.size();
    VL cnt(m);
    REP(i,m){
        FOR(x,1,n){
            ll y = x;
            while (y % p[i] == 0){
                cnt[i]++;
                y /= p[i];
            }
        }
    }

    ll ans = 0, ans2 = 0;
    REP(i,m) if (cnt[i] >= 74) ans++;
    REP(i,m) REP(j,m){
        if (i == j) continue;
        if (cnt[i] >= 2 && cnt[j] >= 24) ans++;
        if (cnt[i] >= 4 && cnt[j] >= 14) ans++;
        REP(k,m){
            if (i == k || j == k) continue;
            if (cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4) ans2++;
        }
    }
    ans += ans2 / 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
X, Y = [], []
for i in range(N):
    X.append(i + 1 + A[i])
    Y.append(i + 1 - A[i])
XL = Counter(X)
c = 0
for y in Y:
    c += XL.get(y, 0)
print(c)

Measured memory_bytes: 140672
// *
// *
// *  Created By :hozaifa wahid
// * "mai maut ko takia aur kafan ko chadar banakar sota hu" 
// *------------------------------------
// *  OS : Ubuntu 16.04
// *  Language : CPP14
// *  Editor : Sublime Text 3
// *  C++ compiler : g++
// *
// *
//https://www.geeksforgeeks.org/find-the-point-where-maximum-intervals-overlap/
#include<bits/stdc++.h>
#define pb push_back
//#define mp make_pair
#define inf 1000000007
#define fr first
#define sc second
#define eps 1e-9
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define sni(x) scanf("%d",&x)
#define snl(x) scanf("%lld", &x)
#define snc(x) scanf("%c", &c);
#define rep(n) for(int i = 0 ; i < n ;i ++)
#define repc(i, n) for(int i = 0 ; i < n ; i ++)
#define FOR(i, x, y) for(int i = x ; i < y ; i ++)
#define DEC(i, x, y) for(int i = x ; i >= y ; i --)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b,c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a+n
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
ll MOD=1000000007;
vector<ll>v[100055];
void sieve()
{
for(int n=1;n<=100055;n++)
{
for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (n/i == i) 
               v[n].push_back(i);
  
            else // Otherwise print both 
               {
                   v[n].push_back(i);
                   v[n].push_back(n/i);
               }
        } 
    } 
}

}
ll pw(ll a,ll b){
    if(b==0) return 1;
    ll x=pw(a,b/2);
    x=(x*x)%MOD;
    if(b%2) x=(x*a)%MOD;
    return x;
}
ll n,s;
ll a[100005][3];
int ok=0;
//ll res=0;
ll dp[100005];
ll mpi[100005][3];
ll go(ll i,ll prev)
{
if(i==n-1)
{
//s=0;
return a[i][prev];
}
if(mpi[i][prev])
return mpi[i][prev];

else if(prev==0)
{
s=a[i][prev]+(max(go(i+1,2),go(i+1,1)));
mpi[i][prev]=s;
}
else if(prev==1)
{
s=a[i][prev]+(max(go(i+1,2),go(i+1,0)));
mpi[i][prev]=s;
}
else if(prev==2)
{
s=a[i][prev]+(max(go(i+1,0),go(i+1,1)));
mpi[i][prev]=s;
}

return s;
}


void solve()
{
 ll t;
 t=1;
while(t--)
{
//ll n;
cin>>n;
//ll a[n];
FOR(i,0,n)
FOR(j,0,3)
cin>>a[i][j],mpi[i][j]=0;
ll res=max(go(0,0),max(go(0,1),go(0,2)));
cout<<res;
}
}



int main(){
    std::ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int start = clock();
    #ifdef ONLINE_JUDGE
    #else
      //freopen("input.in" , "r" , stdin);
      // freopen("output.txt", "w", stdout);
    #endif
    solve();
    int stop = clock();
    #ifdef ONLINE_JUDGE
    #else
        // cout << setprecision(6) << fixed << (stop - start) * 1000.00 / double(CLOCKS_PER_SEC)<< endl;
    #endif
}









Measured memory_bytes: 12800
H, N = gets.split.map(&:to_i)
ABs = readlines.map{|l| l.split.map(&:to_i)}

dp = Array.new(H + 1, 1<<60)
dp[0] = 0
ABs.each do |a, b|
  (0 .. H).each do |x|
    y = x + a > H ? H : x + a
    dp[y] = dp[x] + b if dp[y] > dp[x] + b
  end
end
puts dp[H]

Measured memory_bytes: 2044
#include <algorithm>
#include <iostream>
#include <vector>

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

  int max = *std::max_element(a.begin(), a.end());
  int min = *std::min_element(a.begin(), a.end());
  std::cout << max - min << std::endl;

  return 0;
}


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

using namespace std;

using ll = long long;


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int k, n;

	cin >> n >> k;

	cout << n + 1 - k << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	ifstream fin("../input.txt");

	solve(fin);

	cout << setprecision(4) << "clock: " << clock() / (double) CLOCKS_PER_SEC << endl;
#else
	cout << setprecision(20);

	solve();
#endif

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using i64 = long long;

int main() {
    std::string s, t;
    std::cin >> s >> t;
    const int n = s.size(), m = t.size();

    int ret = n;
    for (int i = 0; i + m <= n; i++) {
        int c = 0;
        for (int j = 0; j < m; j++) if (s[i + j] != t[j]) c++;
        if (ret > c) ret = c;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll IMF = 1LL << 60;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);

  for(int i = 0; i < N; i++) cin >> h[i];


  ll dp[N];
  for(int i = 0; i < N; i++) {
    dp[i] = IMF;
  }
  dp[0] = 0;

 for(int i = 0; i < N; i++) {
   for(int k = 1; k <= K; k++) {
     if(i + k < N)
     chmin(dp[i + k], dp[i] + abs(h[i + k] - h[i]));
   }
 }



  cout << dp[N - 1];
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	int ans[100]={};
	for(int i=1;i<n;i++){
		int a[26]={},b[26]={};
		for(int j=0;j<i;j++){
			a[s[j]-'a']=1;
		}
		for(int j=i;j<n;j++){
			b[s[j]-'a']=1;
		}
		for(int j=0;j<26;j++){
			if((a[j]==1)&&(b[j]==1))ans[i]++;
		}
	}
	sort(ans,ans+n);
	cout<<ans[n-1]<<endl;
}	

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int ans=0;
int n,A[100],B[100];
void dfs(int k1,int k2){
	if (k2<=ans) return;
	if (k1>n){
		ans=k2; return;
	}
	B[k1]=A[k1]; int k3=k2;
	for (int i=1;i<k1;i++) k3=min(k3,min(24-abs(B[k1]-B[i]),abs(B[k1]-B[i])));
	dfs(k1+1,k3);
	k3=k2; if (A[k1]) B[k1]=24-A[k1];
	for (int i=1;i<k1;i++) k3=min(k3,min(24-abs(B[k1]-B[i]),abs(B[k1]-B[i])));
	dfs(k1+1,k3);
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&A[i]);
	n++; A[n]=0;
	if (n>24){
		printf("0\n"); return 0;
	}
	random_shuffle(A+1,A+n+1);
	dfs(1,1e9);
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
};
int main(){
    ll k;cin>>k;
    string s;cin>>s;
    ll n=sz(s);
    combination c(n+k);
    mint ans=0;
    for(int i=0;i<=k;i++){
        mint res=1;
        res*=mint(26).pow(k-i);
        res*=mint(25).pow(i);
        res*=c(i+n-1,n-1);
        ans+=res;
    }
    cout<<ans.x<<endl;
    return 0;
}

Measured memory_bytes: 35644
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define RB rbegin()
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define MD 1000000007
#define PPF pop_front()
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>u,uc;
map<LL,LL>ww,cc;
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
LL vv[20000001];
void veve(LL n)
{
    LL i,j;
    for(i=1; i<=n; i++)
    {
        if(i%2==1)
        {
            vv[i]=i;
        }
        else
        {
            vv[i]=2;
        }
    }
    for(i=3; i<=sqrt(n); i+=2)
    {
        if(vv[i]==i)
        {
            for(j=i*i; j<=n; j+=2*i)
            {
                if(vv[j]==j)
                {
                    vv[j]=i;
                }
            }
        }
    }
}
int main()
{
    FAST;
    char ch;
    string a,b,c,str;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
    veve(10000000);
    while(tt--)
    {
        UOSMOY;
        cin>>n;
        k=0;
        for(i=1; i<=n; i++)
        {
            if(i==1)
            {
                k+=1;
                continue;
            }
            j=i;
            l=1;
            while(j!=1)
            {
                u[vv[j]]++;
                j/=vv[j];
            }
            for(auto it=u.B;it!=u.E;it++)
            {
                l*=(it->SE+1);
            }
            k+=(l*i);
            u.C;
        }
        cout<<k<<endl;
 
    }
    return 0;
 
}

Measured memory_bytes: 81808
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
struct octa {
	int v[8];
	bool operator<(const octa &a) const {
		rep(i, 7) {
			if (a.v[i] != v[i])return a.v[i] > v[i];
		}
		return a.v[7] > v[7];
	}
};
octa turnright(octa x) {
	octa res;
	rep(i, 4) {
		res.v[i] = x.v[(i + 1) % 4];
		res.v[i + 4] = x.v[(i + 1) % 4 + 4];
	}
	return res;
}
octa rev(octa x) {
	octa res;
	res.v[0] = x.v[4];
	res.v[1] = x.v[7];
	res.v[2] = x.v[6];
	res.v[3] = x.v[5];
	res.v[4] = x.v[0];
	res.v[5] = x.v[3];
	res.v[6] = x.v[2];
	res.v[7] = x.v[1];
	return res;
}
octa turn2(octa x) {
	octa res;
	res.v[0] = x.v[0];
	res.v[1] = x.v[4];
	res.v[3] = x.v[1];
	res.v[4] = x.v[3];
	res.v[2] = x.v[5];
	res.v[5] = x.v[7];
	res.v[7] = x.v[2];
	res.v[6] = x.v[6];
	return res;
} 
int main() {
	string s;
	while (cin>>s) {
		map<octa, bool> mp;
		map<string, int> memo;
		int b[8];
		int id = 1;
		memo[s] = id;
		b[0] = id;
		rep1(i, 7) {
			cin >> s;
			if (!memo[s]) {
				id++;
				memo[s] = id;
				b[i] = id;
			}
			else {
				b[i] = memo[s];
			}
		}
		sort(b, b + 8);
		int out = 0;
		while (true) {
			octa y;
			octa y1, y2;
			rep(i, 8) {
				y.v[i] = b[i];
			}
			if(!mp[y]) {
				out++;
				y1 = turn2(y);
				y2 = turn2(y1);
				mp[y] = mp[y1] = mp[y2] = true;
				rep(i, 3) {
					y = turnright(y);
					y1 = turn2(y);
					y2 = turn2(y1);
					mp[y] = mp[y1] = mp[y2] = true;
				}
				y = rev(y);
				y1 = turn2(y);
				y2 = turn2(y1);
				mp[y] = mp[y1] = mp[y2] = true;
				rep(i, 3) {
					y = turnright(y);
					y1 = turn2(y);
					y2 = turn2(y1);
					mp[y] = mp[y1] = mp[y2] = true;
				}
			}
			if (!next_permutation(b, b + 8))break;
		}
		cout << out << endl;
	}
	return 0;
}


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


int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    std::map<int,int> map;
    for(int i = 0; i < n; i++)std::cin >> a[i];
    for(int i = 0; i < n; i++)map[a[i]]++;
    for(auto& i : map)while(i.second >= 3)i.second -= 2; // iは1または2である
    //2のとき次の2を探すもしなければ1つ引く
    int res = 0;
    int cnt = 0;
    for(auto i : map){
        res += i.second;
        if(i.second == 2)cnt++;
        std::cerr << i.first << " : " << i.second <<std::endl;
    }
    res -= 2 * ((cnt + 2 - 1) / 2);
    std::cout << res << std::endl;
}

Measured memory_bytes: 5376
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a)
	fmt.Scan(&b)
	var n int
	if b < 10 {
		n = a*10 + b
	} else if b < 100 {
		n = a*100 + b
	} else {
		n = a*1000 + b
	}
	for i := 1; i*i <= n; i++ {
		if i*i == n {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
def main():
    A,B,C,K = [int(x) for x in input().split()]
    v = 0
    if A<K:
        K -= A
        v += A*1
    else:
        v += K*1
        print(v)
        return
    if B<K:
        K -= B
        v += B*0
    else:
        v += K*0
        print(v)
        return
    if C<K:
        K -= C
        v += C*(-1)
    else:
        v += K*(-1)
        print(v)

if __name__ == '__main__':
    main()

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> S;

    bool flag = true;

    for (int i = 0; i <= ('z' - 'a'); i++)
    {
        char tmp=(char)('a' + i);
        ll count = 0;

        REP(j,S.size()){
            if(tmp==S.at(j)){
                count++;
            }
        }

        //cout << tmp << count << endl;

        if(count%2==1){
            flag = false;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<unordered_map>
#include<string>
using namespace std;

typedef long long ll;

int dp[100000];
int h[100000];

int main(){
	int n;
	cin>>n;
	for(auto &i:dp){
		i=1e9;
	}
	dp[0]=0;
	for(int i=0;i<n;i++)cin>>h[i];
	for(int i=0;i<n-1;i++){
		for(int k=1;k<=2;k++){
			dp[i+k]=min(dp[i]+abs(h[i+k]-h[i]),dp[i+k]);
		}
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 1024;

int main(void) {
	// in = fopen("A.in", "rt");
	
	long long A, B, C;
	fscanf(in, "%lld %lld %lld", &A, &B, &C);
	
	long long ans = 0;
	if (C > A + B)
	   ans = A + B + 1 + B;
	else ans = B + C;
	fprintf(out, "%lld\n", ans);
	
	return 0;
}

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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;

  if ((B - A) % 2 == 0) {
    cout << (B - A) / 2 << endl;
  }
  else {
    if (A - 1 < N - B) {
      cout << (A - 1) + (B - A + 1) / 2 << endl;
    }
    else {
      cout << (N - B) + (B - A + 1) / 2 << endl;
    }
  }
}

Measured memory_bytes: 256
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for h in range(H):
        if h == 0 or h == H-1:
            print("#"*W+"\n",end="")
        else:
            print("#"+"."*(W-2)+"#"+"\n",end="")
    print()


Measured memory_bytes: 5620
program main
    implicit none
    integer a,b,c,k,p
    read(*,*) a,b,c,k
    if(a>=k) then
        p=k 
    else if((a+b)>=k) then
        p=a 
    else
        p=a-(k-a-b)
    end if
    1 write(*,*) p
end program main

Measured memory_bytes: 2800
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	998244353//1000000007

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

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

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

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

struct p
{
	ll a;
	int b;
	int c;
};

inline int func(int a, int b)
{
	if (a > b)
		return a - b;
	else
		return b - a;
}

ll r = 0;
int tar = 0;
ll cur = 1;

bool solve(int head, int keta)
{
	if (keta == 0)
	{
		tar--;
		if (tar == 0)
		{
			r = 0;
			r += head;
			cur *= 10;
			return true;
		}
		return false;
	}

	if (head == 9)
	{
		if (solve(8, keta - 1))
		{
			r += head * cur;
			cur *= 10;
			return true;
		}

		if (solve(9, keta - 1))
		{
			r += head * cur;
			cur *= 10;
			return true;
		}
		return false;
	}
	else if (head == 0)
	{
		if (solve(0, keta - 1))
		{
			r += head * cur;
			cur *= 10;
			return true;
		}

		if (solve(1, keta - 1))
		{
			r += head * cur;
			cur *= 10;
			return true;
		}
		return false;
	}
	else
	{
		if (solve(head - 1, keta - 1))
		{
			r += head * cur;
			cur *= 10;
			return true;
		}

		if (solve(head, keta - 1))
		{
			r += head * cur;
			cur *= 10;
			return true;
		}

		if (solve(head + 1, keta - 1))
		{
			r += head * cur;
			cur *= 10;
			return true;
		}
		return false;
	}
}

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

	int k = 0;
	int h = sum / (4 * m);
	if (sum % (4 * m) != 0)
		h++;
	for (int i = 0; i < n; i++)
		if (h <= a[i])
			k++;
	if (k >= m)
		printf("Yes");
	else
		printf("No");

	return 0;
}

Measured memory_bytes: 256