akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            1e18


void solve()
{
   int n,k,sum=0,x;
   cin>>n>>k;
   vector<int>v;
   FOR(i,1,n) { cin>>x; v.push_back(x); }
   sort(v.begin(),v.end());
   for(int i=0;i<k;i++) sum+=v[i];
   cout<<sum<<endl;
}


int main()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    //int t; cin>>t; while(t--) solve();
    solve();

}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define IO {ios_base::sync_with_stdio(false); cin.tie(0);}
#define ll  long long
#define pi pair<ll,ll>

ll a[300000];
int main()
{
    IO;
    ll i, j, k, cnt=0, n, m, mod=1e18, t, mx,  p=0, l=0, h, x=0;
        cin>>n>>k;
        for(i=1; i<=n; i++){
            cin>>a[i];
        }
        for(i=k+1; i<=n; i++){
            if(a[i]>a[i-k]) cout<<"Yes"<<endl; else cout<<"No"<<endl;
        }
    return 0;
}


Measured memory_bytes: 5212
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main()
{
        ios_base::sync_with_stdio(0);cin.tie(0);
        int k;
        cin>>k;
        int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
        };
        cout<<a[k-1]<<endl;
};


Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
constexpr int MAXN = 100005;
int k;
int dist[MAXN][10];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	scanf("%d", &k);
	deque<pii> q;
	memset(dist, -1, sizeof(dist));
	dist[1][1] = 1;
	q.push_back({1, 1});
	while (!q.empty()) {
		pii x = q.front();
		q.pop_front();
		int by_ten = (x.first * 10) % k;
		if (dist[by_ten][0] == -1) {
			dist[by_ten][0] = dist[x.first][x.second];
			q.push_front({by_ten, 0});
		}
		int add_one = (x.first + 1) % k;
		if (x.second + 1 < 10 and dist[add_one][x.second + 1] == -1) {
			dist[add_one][x.second + 1] = dist[x.first][x.second] + 1;
			q.push_back({add_one, x.second + 1});
		}
	}
	int res = 987654321;
	for (int i = 0; i < 10; ++i) {
		if (dist[0][i] == -1) continue;
		res = min(res, dist[0][i]);
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 double r;
		 r = sc.nextDouble();         
		 System.out.printf("%.6f %.6f\n",r*r*Math.PI,2*r*Math.PI); 
	}

}

Measured memory_bytes: 18924
#include <bits/stdc++.h>
using namespace std;
#define ui unsigned int
#define rui register ui
#define inl inline
#define rep(i,l,r) for(rui i=l,_=r;i<_;i++)
#define mxn 12
ui n,m,x,p[12];
bool f[1<<12],b[12][12];
char a[12][12];
inl ui rnd() {
	x^=x<<13;
	x^=x>>17;
	x^=x<<5;
	return x;
}
inl void rsh() {
	rep(i,1,n)
		swap(p[i],p[rnd()%i]);
}
int main() {
	srand(time(0));
	x=rand();
	scanf("%d%d",&n,&m);
	rep(i,0,n) p[i]=i;
	rep(i,0,n) scanf("%s",a[i]);
	ui y=CLOCKS_PER_SEC*15;
	while((clock()<<3)<=y) {
		rsh();
		memset(b,1,sizeof(b));
		rep(i,0,m) rep(j,i,m) rep(k,0,n)
			if(a[p[k]][i]!=a[p[n-k-1]][j])
				b[i][j]=0;
		memset(f,0,sizeof(f));
		f[0]=1;
		rep(k,0,1<<m)	if(f[k])
			rep(i,0,m)	rep(j,i+1,m)
				if(!(1<<i&k)&&!(1<<j&k)&&b[i][j])
					f[k|(1<<i)|(1<<j)]=1;
		bool chk=0;
		if(!(m&1))
			chk=f[(1<<m)-1];
		else	rep(i,0,m)
			chk|=f[(1<<m)-1-(1<<i)];
		if(chk) {
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}


Measured memory_bytes: 512
/* CODE BY NITIN 
ON 31 MARCH 2020--------------
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
#define mod 1000000007
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPN(i, n) for (int i = 1; i <=(n); i++)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define T(a) ll a;  cin >> a;
#define TT(t) T(t); while (t--)
#define pb push_back
#define mp make_pair
 #define ll long long int
using namespace std;

int solve()
{
	//int t; 
//	cin>>t;
	//while(t--){
		char s[5];
		
		for(int i=0;i<=5;i++){
			cin>>s[i];
		}
		
		(s[3]==s[2]&&s[4]==s[5]) ? cout<<"Yes\n" : cout<<"No\n";
		
		
//	}
}
int main()
{
	
	
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	solve();
	
}

Measured memory_bytes: 384
s = list(input())
len_s = len(s)
half_len_s = len_s // 2 + 1
str_01 = "01" * half_len_s
str_10 = "10" * half_len_s
list_01 = list(str_01[:len_s])
list_10 = list(str_10[:len_s])
count1 = 0
count2 = 0
for v1, v2 in zip(s, list_01):
    if v1 == v2:
        count1 += 1
for v1, v2 in zip(s, list_10):
    if v1 == v2:
        count2 += 1
print(min(count1, count2))


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

int main() {
    int a_1, a_2, a_3;
    cin >> a_1 >> a_2 >> a_3;
    if (a_1 + a_2 + a_3 >= 22) cout << "bust";
    else cout << "win";  
}

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


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

    int t;
    t = Y;
    Y = X;
    X = t;
    t = Z;
    Z = X;
    X = t;

    cout << X << " " <<  Y << " " << Z;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double hpi = (h+m/60)*M_PI/6;
  double mpi = m*M_PI/30;
  double c;
  c = pow(a*a + b*b - 2*a*b* cos(hpi-mpi),0.5);
  cout << setprecision(21) << c;
  return 0;
}

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

int main() {
  int a;
  cin>>a;
  if (a%10==7) {
    cout<<"Yes"<<endl;
  } else if ((a/10)%10==7){
    cout<<"Yes"<<endl;
  } else if (a/100==7) {
    cout<<"Yes"<<endl;
  } else {
   cout<<"No"<<endl;
  }
}



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

int main(){
	int w, g[10];
	vector<int> ans;

	for(int i=0,j=1 ; j<=512 ; j*=2, i++){
		g[i] = j;
	}

	while(cin >> w){
		ans.clear();
		for(int i=9 ; i>=0 ; i--){
			if(w<=1){
				if(w==1)ans.push_back( w ); 
				break;
			}
			else if(g[i]<=w){
				w -= g[i];
				ans.push_back( g[i] ); 
			}
		}
		for(int i=ans.size()-1 ; i>=0 ; i--){
			cout << ans[i] ;
			if(i==0) cout << endl;
			else cout << " ";
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
import scala.io.StdIn._

object Main extends App {


  val s = readLine()

  def solve() = {
    val r = s.reverse
    (0 until s.length/2).foldLeft(0) { (acc, i) =>
      if(s(i) == r(i)) acc else acc+1
    }
  }

  println(solve())

}



Measured memory_bytes: 54852
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>

namespace x_x
{
	const int N=2010000;

	int s[N];
	int n,k;

	void initialize()
	{
		static char str[N];

		int len0,len1;

		scanf("%d%d%d",&len0,&len1,&k);

		scanf("%s",str);
		for(int i=1;i<=len0;i++)
			s[i]|=(str[len0-i]-'0');
		scanf("%s",str);
		for(int i=1;i<=len1;i++)
			s[i]|=(str[len1-i]-'0')<<1;

		n=std::max(len0,len1)+k;
	}

	std::stack<int> A,B;

	void work(int pos)
	{
		if(!k)return;

		int cnt=k-1,x=3,flag=0;

		for(int i=pos;i<=n && x>0;i++)
		{
			if(x==3)
			{
				int fk=std::min(A.top()-i,cnt);
				cnt-=fk,i+=fk;
			}

			int a=s[i]^x,b=s[i]&x;
			s[i]=a,x=b;

			if(s[i]==3)
			{
				if(cnt==0)flag=1;
				else s[i]=0,x=3,cnt--;
			}

			if(s[i]!=0)
			{
				if(A.top()!=i)B.push(i);
				else A.pop(),B.push(i);
			}
			else 
			{
				if(A.top()==i)A.pop();
			}
			
			if(flag)break;
		}
		
		while(!B.empty())A.push(B.top()),B.pop();
	}

	void output()
	{
		bool flag=0;
		for(int i=n;i;i--)
		{
			flag|=s[i]&1;
			if(flag)printf("%d",s[i]&1);
		}
		printf("\n");
		flag=0;
		for(int i=n;i;i--)
		{
			flag|=(s[i]>>1)&1;
			if(flag)printf("%d",(s[i]>>1)&1);
		}
		printf("\n");
	}

	void solve()
	{
		initialize();

		A.push(n+1);

		for(int i=n;i;i--)
		{
			if(s[i]>0)A.push(i);
			if(s[i]==3)work(i);
		}

		output();
	}
}

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


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

using namespace std;

typedef long long ll;

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

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

	string s;
	cin >> s;

	int ans = 0;
	int t = 0;

	rep(i, 3){
		if(s[i] == 'R'){
			t++;
			chmax(ans, t);
		}else{
			t = 0;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
using namespace std;

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; }

const long long INF = 1LL << 60;

int main()
{
	int n,y;
	cin >> n>>y;
	int res = 0;
	int d=-1;
	int e = -1;
	int f = -1;
	for (int i = 0;i <= n;i++) {
		for (int j = 0;j <= n;j++) {
			int a = 10000 * i;
			int b = 5000 * j;
			int c = 1000 * (n - i - j);
			if (a + b + c == y) {
				d = i;e = j;f = n - i - j;
				break;
			}
		}
	}
	if (d < 0 || e < 0 || f < 0) {
		d = -1;
		e = d;
		f = d;
	}
	cout << d << " " << e << " " << f << endl;
}


Measured memory_bytes: 384
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
string to_string(char c) { return string(1,c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
template<class A> string to_string(complex<A> c) { 
	stringstream ss; ss << c; return ss.str(); }
string to_string(vector<bool> v) { 
	string res = "{"; for(int i = 0; i < (int)v.size(); i++) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> string to_string(bitset<SZ> b) {
	string res = ""; for(size_t i = 0; i < SZ; i++) res += char('0'+b[i]);
	return res; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) { // containers with begin(), end()
	bool fst = 1; string res = "{";
	for (const auto& x: v) {
		if (!fst) res += ", ";
		fst = 0; res += to_string(x);
	}
	res += "}"; return res;
}
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.f)+", "+to_string(p.s)+")"; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define wis(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
#else
#define wis(...) 0
#endif
typedef long long ll;
const int MOD = 1e9 + 7, INF = 1e9 + 5;
inline ll powmod(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)res=res*a%MOD;return res;}
inline ll power(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a)if(b&1)res=res*a;return res;}

const int MAXN = 2e5 + 10;

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int d, l, r;
	cin >> l >> r >> d;
	int ans = 0;
	for(int i = l; i <= r; i++){
		if(i % d == 0)
			ans++;
	}
	wis(l, r, d);
	cout << ans << '\n';
}


Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

    void execute() throws IOException {
        char c = ns().charAt(0);
        if (c >= 'a' && c <= 'z') {
            out.println("a");
        } else {
            out.println("A");
        }
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().execute();
    }

    void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }



    boolean input() throws IOException {
        return true;
    }

}


Measured memory_bytes: 25364
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//
//		int a = Integer.parseInt(br.readLine());
//		int b = Integer.parseInt(br.readLine());
//		int c = Integer.parseInt(br.readLine());
//		int d = Integer.parseInt(br.readLine());
//		int e = Integer.parseInt(br.readLine());


		@SuppressWarnings("resource")
		Scanner sc = new Scanner (System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();

		List<Integer> list = new ArrayList<Integer>();
		list.add(a);
		list.add(b);
		list.add(c);
		list.add(d);
		list.add(e);

		Collections.sort (list);
		Collections.reverse(list);

		for (int i = 0; i < 4; i++){
			System.out.print(list.get(i)+ " ");
		}
		System.out.println(list.get(4));

	}

}

Measured memory_bytes: 26008
N=int(input())
A=[]
arr=[]
ans=0

for n in range(N):
  a=int(input())
  A.append(a)
  arr.append([ list(map(int,input().split())) for  _ in range(a)])
  
for i in range(2**N):
  ord =[0]*N
  count=0
  flg=0
  
  for n in range(N):
    if (i >>n)&1:
      count +=1
      ord[n]=1
   
  for n in range(N):
    if ord[n]==1:
      for m in range(A[n]):
        if ord[arr[n][m][0]-1]!= arr[n][m][1]:
          flg=1
          break
   
  if flg==1:
    continue
  ans=max(ans,count)
        
      
      
print(ans)      
      
      

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  string s;cin>>s;
  for(i=0;i<s.size();i++){
    if(s[i]=='A')chmin(res2,i);
    else if(s[i]=='Z')chmax(res1,i);
  }
  cout<<res1-res2+1<<endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long ll;

ll n;

void solve() {
	int five = 0, two = 0;
	for (ll i = 1; i <= n; i++) {
		ll tmp = i;
		while (tmp % 5 == 0) {
			five++;
			tmp /= 5;
		}
		//cout<<i<<"|"<<five<<endl;
	}
	cout<<five<<endl;
}

int main(int argc, const char *argv[]) {
	while (cin>>n, n) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstring>
//#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  queues      priority_queue
#define mod  1000000009
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
#define mem(a,b) memset(a,b,sizeof(a));
typedef long long unsigned ull;
typedef long long ll;
const ll maxn=2000006;
//priority_queue<ll,vector<ll >,greater<ll > >q;
const ll INF=0x3f3f3f3f;
//const double E=exp(1);
//const double PI=acos(-1);
using namespace std;
//__builtin_popcount
//priority_queue
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}
inline char nc()
{
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline ll read()
{
    char ch=nc();
    ll sum=0;
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum;
}
bool cmp(ll a,ll b)
{
    return a>b;
}int n,m;
int dd(int a,int b)
{ int x=a/b;
    if(x<2||b<2)return 0;
    if(b*10+x<=m)return 1;
    return 0;
}
int main()
{
   int sum=0;
   cin>>n>>m;
   for(int i=1;i<=n;i++)
   {
       for(int j=11;j<=m;j++)
       {int x=j%10,y=j/10;
           if(x*y==i&&x>=2&&y>=2)sum++;
       }
   }cout<<sum<<endl;
}



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

int main()
{
  int a,b;
  cin>>a>>b;
  int m=0;
  if(a>=4)
  a=0;
  if(b>=4)
  b=0;

  if(a==1&&b==1)
  m=1000000;
  else{ 
  if(a==1)
  m+=300000;
  if(a==2)
  m+=200000;
  if(a==3)
  m+=100000;
 if(b==1)
  m+=300000;
  if(b==2)
  m+=200000;
  if(b==3)
  m+=100000;
  }
  cout<<m;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int num[10];
int main()
{
    int first,second,third;
    first=second=third=-1;
    int n,m;
    scanf("%d%d",&n,&m);
    bool check=true;
    while(m--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        if(a==1)
        {
            if(first!=-1)
            {
                if(first!=b)
                    check=false;
            }
            else
                first=b;
        }
        if(a==2)
        {
            if(second!=-1)
            {
                if(second!=b)
                    check=false;
            }
            else
                second=b;
        }
        if(a==3)
        {
            if(third!=-1)
            {
                if(third!=b)
                    check=false;
            }
            else
                third=b;
        }
    }
    if(!check)
        puts("-1");
    else if(n==1)
        printf("%d\n",first==-1?0:first);
    else if(first==0)
        puts("-1");
    else if(n==2)
    {
        printf("%d",first==-1?1:first);
        printf("%d\n",second==-1?0:second);
    }
    else if(n==3)
    {
        printf("%d",first==-1?1:first);
        printf("%d",second==-1?0:second);
        printf("%d\n",third==-1?0:third);
    }
    return 0;
}


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


using namespace std;

int main() {

	int h,w;

	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0) { return 0; }
		else {
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if ((i+j)%2==0 ) {
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
				cout << endl;
			}
			cout << endl;
		}
	}

}


Measured memory_bytes: 3096
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let mut c: Vec<Vec<i32>> = vec![];
    let mut a: Vec<i32> = vec![0;3];
    let mut b: Vec<i32> = vec![0;3];

    for _ in 0..3{
        c.push(read_as_vec::<i32>());
    }

    for i in 0..3{
        b[i] = c[0][i];
    }

    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    for i in 0..3{
        for j in 0..3{
            if a[i] + b[j] != c[i][j]{
                println!("No");
                return;
            }
        }
    }

    println!("Yes");
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
using namespace std;
int i,n,tmp,ans,p[100];
main(){
	while(cin>>n){
		for(i=0;cin>>p[i++]&&i<n;);
		sort(p,p+n);
		for(i=tmp=ans=0;i<n;){tmp+=p[i++];ans+=tmp;}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;
//import java.util.stream.*;
//import java.math.*;

public class Main {

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();
        long num = 0;
        if (a % x == 0) {
            num = Math.abs((a / x) - (b / x)) + 1;
        } else {
            num = Math.abs((a / x) - (b / x));
        }
        System.out.println(num);
        bw.flush();
    }
}


Measured memory_bytes: 23124
// time-limit: 2000
#include <bits/stdc++.h>

using namespace std;

#define fo(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define lli long long int
#define all(c) c.begin(),c.end()
#define lower(c) tolower(c)
#define upper(c) toupper(c)
#define MAX(c) *max_element(c.begin(),c.end())
#define MIN(c) *min_element(c.begin(),c.end())
#define len(c) c.size()
const int MOD = 1000000007;
const int MX = 2e5 + 5;
const int INF = 1e9 + 10;
const lli LINF = 1e18;

void solve() {
	string s;
    cin >> s;
    int ans;
    if(s == "SUN")ans = 7;
    else if(s == "MON")ans = 6;
    else if(s == "TUE")ans = 5;
    else if(s == "WED")ans = 4;
    else if(s == "THU")ans = 3;
    else if(s == "FRI")ans = 2;
    else if(s == "SAT")ans = 1;
    cout << ans << endl;
}


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


Measured memory_bytes: 3576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int[] a = fs.nextIntArr(n);
		int[] b = fs.nextIntArr(n);
		int[] c = fs.nextIntArr(n-1);
		
		int ans = 0;
		int before = -100;
		
		for(int i = 0; i < n; i++) {
			int mealNum = a[i] - 1;
			ans += b[mealNum];
			if(before +1 == mealNum) {
				ans += c[before];
			}
			before = mealNum;
		}
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int d;
    cin >> d;
    vector<int> c;
    vector<vector<int>> s;

    for (int i = 0; i < 26; i++) {
        int tmp;
        cin >> tmp;
        c.push_back(tmp);
    }
    for (int i = 0; i < d; i++) {
        vector<int> tmp_v;
        for (int j = 0; j < 26; j++) {
            int tmp;
            cin >> tmp;
            tmp_v.push_back(tmp);

        }
        s.push_back(tmp_v);
    }

    for (int i = 0; i < d; i++)
    {
        cout << (i % 26) + 1 << endl;

    }
    return 0;

}



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

int main() {
	int L, R, d;
	cin >> L >> R >> d;
	int ans = 0;
	FOR(i, L, R + 1) if (i % d == 0) ++ans;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <string.h>
#include <string>
#include <math.h>
#include <time.h>
#include <vector>
#include <queue>
#include<stack>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <bitset>
#include <limits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int M = 1e9 + 7;
const int N = 2e5;
const int oo = 1e9;
const double pi = acos(-1);
int main() {
	//freopen("src.txt", "r", stdin);
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &v[i]);
	int i = 0, ans = 0;
	while (i < n) {
		int mx = 0;
		while (i < n - 1 && v[i] >= v[i + 1]) {
			++mx;
			++i;
		}
		ans = max(mx, ans);
		++i;
	}
	cout << ans << endl;
	return 0;
}

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

bool comparePair(pair<int, int> a, pair<int, int> b) {
  if(a.first!= b.first) return a.first < b.first;
  else return a.second < b.second;
}

int main() {
  int N, ans=0; cin >> N;
  vector<pair<int, int>> red(N);
  vector<pair<int, int>> blue(N);
  for (int i=0; i<N; i++) cin >> red[i].first >> red[i].second;
  for (int i=0; i<N; i++) cin >> blue[i].first >> blue[i].second;
  sort(red.begin(), red.end(), comparePair);
  sort(blue.begin(), blue.end(), comparePair);
  for (int i=0; i<N; i++) {
    int maxy=-1,maxyidx=0;
    for (int j=0; j<N; j++) {
      if (blue[i].first>red[j].first&&blue[i].second>red[j].second) {
        if (red[j].second>maxy) {maxy=red[j].second; maxyidx=j;}
      }
    }
    if(maxy>=0) {ans++; red[maxyidx].second=-1;}
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            var W = Console.ReadLine();
            var line = "";
            var result = 0;
            while ((line = Console.ReadLine()) != "END_OF_TEXT")
            {
                var words = line.ToLower().Split(' ');
                for (int i = 0; i < words.Length; i++)
                {
                    if (words[i] == W)
                    {
                        result++;
                    }
                }
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 15812
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

long long extGCD(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extGCD(b, a%b, y, x);
  y -= a/b * x;
  return d;
}

int main(){
  ll a, b, x, y;
  cin >> a >> b;
  extGCD(a, b, x, y);
  cout << x << " " << y << endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5,MOD=1e9+7;
int n,m,A,B,ans;
int bin[N],inv[N];

inline int pow(int a,int n)
{
	int res=1;
	while (n)
	{
		if (n&1ll) res=res*a%MOD;
		a=a*a%MOD;
		n>>=1ll;
	}
	return res;
}

inline int C(int a,int b)
{
	return bin[a]*inv[a-b]%MOD*inv[b]%MOD;
}

inline int solve(int sx,int sy,int tx,int ty)
{
	return C(tx-sx+ty-sy,tx-sx);
}

signed main(){
	bin[0]=inv[0]=1;
	for (register int i=1; i<=2e5; ++i) bin[i]=bin[i-1]*i%MOD; 
	for (register int i=1; i<=2e5; ++i) inv[i]=pow(bin[i],MOD-2ll);
	scanf("%lld%lld%lld%lld",&n,&m,&A,&B);
	for (register int i=1; i<=n-A; ++i) ans=(ans+solve(1,1,i,B)*solve(i,B+1,n,m)%MOD)%MOD; 
	printf("%lld\n",ans);
return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  R s;
  ll ans=700;
  rep(i,s.size()) {
    if(s[i]=='o') ans+=100;
  }
  pr(ans);
}

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


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable int mod = 10^^9 + 7;

void main()
{
    int n, a, b;
    readVars(n, a, b);

    auto h = new int[](n);
    foreach(i ; 0 .. n) readVars(h[i]);

    int top, btm, mid;
    top = (h.reduce!max + b - 1) / b;
    btm = 0;

    int dif = a - b;

    auto check = (int k) {
        int cnt;

        foreach (hi ; h) {
            if (hi > k * b) {
                cnt += (hi - k*b + dif - 1) / dif;

                if (cnt > k) {
                    return false;
                }
            }
        }

        return true;
    };

    while (top - btm > 1) {
        mid = btm + (top - btm) / 2;

        if (check(mid)) {
            top = mid;
        }
        else {
            btm = mid;
        }
    }

    writeln(top);
}

void readVars(T...)(auto ref T args)
{
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        writeln(line);
        throw new Exception("args num < input num");
    }
}

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

class Program
{
  class Ball
  {
    public int Number;
    public int Index;
    public Ball(int n, int i)
    {
      Number = n;
      Index = i;
    }
  }
  
  static void Main()
  {
    var n = int.Parse(Console.ReadLine());
    var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();     
    
    var balls = new List<Ball>();
    for (int i = 0; i < n; i++)
      balls.Add(new Ball(a[i], i));
    balls.Sort((x, y) => x.Number - y.Number);
    balls.Add(new Ball(0, -1));

    int j = 0;
    int m = balls[0].Number;
    long sum = 0;
    var comb = new Dictionary<int, long>();
    while (m != 0)
    {
      long count = 0;
      while (m == balls[j].Number)
      {
        count++;
        j++;
      }
      comb.Add(m, count);
      sum += count * (count - 1) / 2;
      m = balls[j].Number;
    }    
    
    var result = new long[n];
    for (int i = 0; i < n; i++)
    {
      long k = comb[balls[i].Number];
      result[balls[i].Index] = sum - k + 1;
    }
    for (int i = 0; i < n; i++)
      Console.WriteLine(result[i]);
  }
}


Measured memory_bytes: 50236
/*
        Author: Prokash
                CSE48, JU

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int ara[2005];
int main()
{
    FAST;
    ll t,n,in,d;
    cin>>t;
    ll mn=INT_MAX;
    while(t--)
    {
        cin>>in;
        d=0;
        while(in%2==0)
        {
            in/=2;
            d++;
        }
        mn=min(mn,d);
    }
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque


def main():
    n, k = map(int, input().split())
    a = list(map(lambda x: int(x) - 1, input().split()))
    town = [[] for _ in range(n)]
    for i in range(n):
        town[i].append(a[i])
    checked = [False for _ in range(n)]
    checked[0] = True
    q = deque([0])
    loop_begin = -1
    achieve = [0]
    while q:
        now = q.pop()
        for next in town[now]:
            if not checked[next]:
                checked[next] = True
                achieve.append(next)
                q.append(next)
            else:
                loop_begin = next
    loop_idx = achieve.index(loop_begin)
    if k < loop_idx:
        print(achieve[k] + 1)
    else:
        k -= loop_idx
        achieve = achieve[loop_idx:]
        print(achieve[k % len(achieve)] + 1)


if __name__ == '__main__':
    main()



Measured memory_bytes: 43160
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int i;
	string S, T;
	cin >> S >> T;
	cout << T + S << endl;

	
}



Measured memory_bytes: 256
/* B Binary Search TreeII */

#include<stdio.h>
#include<stdlib.h>

struct Node{
  int key;
  struct Node *parent;
  struct Node *left;
  struct Node *right;
};

struct Node *nil;
struct Node *root;
void init(){
  nil->key=-1;
  nil->parent=nil;
  nil->left=nil;
  nil->right=nil;
}

void Preorder(struct Node *u);
void Inorder(struct Node *u);

void TreeInsert(struct Node *T, struct Node *z);
struct Node *IterativeTreeSearch(struct Node *x, int k);

int main(){
  int n; /* command number */
  int k; 
  char com[6],c;
  int i;
  int j;
  struct Node *T;
  struct Node *z;
  struct Node *x;
  nil=malloc(sizeof(struct Node));
  init();
  /*scan*/
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&k);
      z=malloc(sizeof(struct Node));
      z->key=k;
      z->left=nil;
      z->right=nil;
      if(i==0)root=z;
      TreeInsert(T,z);
      T=z;
    }else if(com[0]=='p'){
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }else{
      scanf("%d",&k);
      x=IterativeTreeSearch(root,k);
      if(x==nil)printf("no\n");
      else printf("yes\n");
      //printf("find %d\n",k);
    }
  }
  free(z);
  free(nil);
  return 0;
}

struct Node *IterativeTreeSearch(struct Node *x, int k){
  while(x!=nil&&x->key!=k){
    if(k<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  return x;
}

void TreeInsert(struct Node *T, struct Node *z){
  struct Node *y;
  struct Node *x;
  y=nil;
  x=root;

  while(x!=nil){
    if(z==x)break;
    y=x;
    if(z->key<x->key){
      x=(x->left);
    }else{
      x=(x->right);
    }
  }
  z->parent=y;     
  if(y==nil){
    root=z; /* if T is empty */
  }else if(z->key<=y->key){
    y->left=z;
  }else{
    y->right=z;
  }
}

void Preorder(struct Node *u){
  if(u!=nil){
    printf(" %d",u->key);
    Preorder(u->left);
    Preorder(u->right);
  }
}

void Inorder(struct Node *u){
  if(u!=nil){
    Inorder(u->left);
    printf(" %d",u->key);
    Inorder(u->right);
  }
}

Measured memory_bytes: 9844
from math import gcd
import random,time

def gcdcount(n,m):
    x,y=min(n,m),max(n,m)
    if x==0:
        return 0
    else:
        return 1+gcdcount(x,y%x)

fibo=[0,1,2]
for i in range(100):
    fibo.append(fibo[-1]+fibo[-2])

gcdfibo=[[],[(1,2)],[(2,3)],[(3,5),(4,7)]]
for i in range(4,101):
    temp=[]
    for a,b in gcdfibo[-1]:
        temp.append((b,a+b))
    b=gcdfibo[-1][1][1]
    a=fibo[i]
    temp.append((b,a+b))
    temp.sort()
    gcdfibo.append(temp)

def solve(x,y):
    if x>y:
        x,y=y,x
    mod=10**9+7
    if x==1:
        return  (1,y%mod)
    if (x,y)==(2,2):
        return (1,3)
    id=1
    t=-1
    while True:
        if fibo[id+1]<=x and fibo[id+2]<=y:
            id+=1
        else:
            if fibo[id+1]>x:
                if fibo[id+2]>y:
                    t=0
                else:
                    t=1
            else:
                t=2
            break

    #print(t)
    if t==0:
        res=0
        for a,b in gcdfibo[id]:
            if a<=x and b<=y:
                res+=1
        return (id,res)
    elif t==1:
        res=0
        for a,b in gcdfibo[id]:
            if a<=x:
                res+=(y-b)//a+1
                res%=mod
        return (id,res)
    else:
        res=0
        for a,b in gcdfibo[id+1]:
            u,v=b-a,a
            if u<=x and v<=y:
                res+=1
                res%=mod
            if u<=y and v<=x:
                res+=1
                res%=mod
        return (id,res)

mod=10**9+7
Q=int(input())
start=time.time()
for _ in range(Q):
    x,y=map(int,input().split())
    id,res=solve(x,y)
    if (x,y)==(2,2):
        res+=1
    print(id,res)

#print(time.time()-start)


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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, ll>a,pair<ll,ll>b)
{
    return a.fi>=b.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}

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

ll n; cin>>n;
string s = "";
int p = 26;
while(n!=0)
{
    int x = n%p;
    if(x==0)x = 26;
    n-=x;
    n/=p;
    char c = 'a'+x-1;
    s.push_back(c);
    //p*=26;
}
reverse(s.begin(),s.end());
cout<<s<<endl;
return 0;
}
/*
50 25
39 99 70 24 49 13 86 43 88 74 45 92 72 71 90 32 19 76 84 46 63 15 87 1 39 58 17 65 99 43 83 29 64 67 100 14 17 100 81 26 45 40 95 94 86 2 89 57 52 91 45
1221 360 459 651 958 584 345 181 536 116 1310 403 669 1044 1281 711 222 280 1255 257 811 409 698 74 838
*/


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#include <vector>
#define MAX_N 100001
#define INF 100001

int main(){
    int N;
    int dp[12][MAX_N];
    vector <int> lists;
    int num = 0;
    cin >> N;
    for (int i = 1; i < 7; i++){
        lists.push_back(pow(6, i));
    }
    for (int i = 1; i < 6; i++){
        lists.push_back(pow(9, i));
    }
    lists.push_back(1);
    sort(lists.begin(), lists.end());

    for (int i = 0; i < 12; i++){
        for (int j = 0; j <= N; j++){
            if (j == 0){
                dp[i][j] = 0;
            }else{
                dp[i][j] = INF;
            }
        }
    }
    for (int i = 0; i < 12; i++){
        for (int j = 0; j <= N; j++){
            if (i == 0){
                dp[i][j] = j;
            }else{
                if (j - lists[i] < 0){
                    dp[i][j] = dp[i - 1][j];
                }else{
                    dp[i][j] = min(dp[i - 1][j], dp[i][j - lists[i]] + 1);
                }
            }
        }
    }
    // for (int i = 0; i < 12; i++){
    //     for (int j = 0; j <= N; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[11][N] << endl;
    return 0;
}

Measured memory_bytes: 4992
from collections import Counter

n = int(input())
si = [input() for i in range(n)]

sorted_si = Counter(si).most_common()
last = -1
names = []
for s in sorted_si:
    if last <= s[1]:
        names.append(s[0])
        last = s[1]

for name in sorted(names):
    print(name)

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

int max(int a, int b) {
  if (a >= b) return a;
  else return b;
}

int main() {
  int N;
  int x[101],y[101],h[101];
  scanf("%d",&N);
  for (int i = 0; i < N; i++) {
    scanf("%d %d %d",&x[i],&y[i],&h[i]);
  }

  int pi;
  for (int i = 0; i < N; i++) {
    if (h[i] != 0) pi = i;
  }

  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      int H;
      H = h[pi] +abs(x[pi] - i) + abs(y[pi] - j);
      int A = 1;
      for (int k = 0; k < N; k++) {
        if (h[k] == max(H - abs(x[k] - i) - abs(y[k] - j), 0)) A = 1;
        else {
          A = 0;
          break;
        }
      }
      if (A == 1) {
        printf("%d %d %d\n",i,j,H);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 128
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n = gif
a = gi
cur = 0
sum = 0
rep n do |i|
  sum += (a[i] - cur).abs
  cur = a[i]
end

cur = 0
rep n do |i|
  tsum = sum
  tsum -= (a[i] - cur).abs
  tsum -= (a[i+1]-a[i]).abs if i < n-1
  tsum += (a[i+1] - cur).abs if i < n-1
  cur = a[i]
  add = i < n-1 ? a[-1] : a[-2]
  puts tsum + add.abs
end


Measured memory_bytes: 12388
import itertools
n, m, q = map(int, input().split())
l = []
for i in range(q):
    a, b, c, d = map(int, input().split())
    l.append([a-1, b-1, c, d])
ll = [i for i in range(1, m+1)]
h = itertools.combinations_with_replacement(ll, n)
ans = 0
for v in h:
    vl = list(v)
    cnt = 0
    for i in range(q):
        ai, bi, ci, di = l[i]
        if vl[bi] - vl[ai] == ci:
            cnt += di
    ans = max(ans, cnt) 
print(ans)

Measured memory_bytes: 9228
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n),b(n);
	ll sa=0,sb=0;
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
		sa+=a[i],sb+=b[i];
	}
	ll ans=min(sa,sb);
	vector<pair<int,int>> v;
	for(int i=0;i<n;i++){
		v.push_back({a[i],i});
		v.push_back({b[i],i});
	}
	sort(v.begin(),v.end());
	vector<ll> cnt(2*n+1,0);
	for(int i=0;i<2*n;i++){
		cnt[i+1]=cnt[i]+v[i].first;
	}
	vector<vector<int>> pos(n);
	for(int i=0;i<2*n;i++){
		pos[v[i].second].push_back(i);
	}
	for(int i=0;i<n;i++){
		int j=n;
		while(1){
			int cc=(pos[i][0]<j)+(pos[i][1]<j);
			if(cc==j-n)break;
			j++;
		}
		ll cur=cnt[j];
		if(pos[i][0]<j){
			cur-=v[pos[i][0]].first;
		}
		if(pos[i][1]<j){
			cur-=v[pos[i][1]].first;
		}
		ans=min(ans,cur);
	}
	cout << ans << endl;
}

Measured memory_bytes: 9712
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a, const void *b){
  return *(int *)b - *(int *)a;
}
int main(int argc, char const *argv[]) {
  int n,k;
  scanf("%d%d", &n, &k);
  int l[n];
  int i;
  for (i = 0;i < n;i++) {
    scanf("%d", &l[i]);
  }
  qsort(l, n, sizeof(int), compare);
  int ans = 0;
  for(i=0;i<k;i++){
    ans += l[i];
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
n = int(input())
s = input()

ans = 0
for i in range(1,n):
    chain = 0
    for j in range(n-i):
        if(s[j]==s[i+j]):
            chain+=1
            if(ans<chain):
                ans = min(chain,i)
                #print(ans,i,j)
        else:
            chain=0

print(ans)

Measured memory_bytes: 42076
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;
 
signed main()
{
    fast;
    string s;
    cin>>s;
    int count = 0;
    for ( int i = 0 ; i < s.length()/2 ; i++ )
    {
        if ( s[i] != s[s.length()-1-i] )
        {
            count++;
        }
    }

    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256