akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

const int INIT = 0;
std::vector<int> dp, ans, used;
std::vector<std::vector<int>> G, UG;

int sol(int n) {
  if ( dp[n] != INIT ) return dp[n];
  for(auto&& g : UG[n]) dp[n] = std::max(dp[n], sol(g)+1);
  return dp[n];
}

void tsort(int v) {
  used[v] = true;
  for(auto&& g : G[v]) {
    if ( used[g] ) continue;
    tsort(g);
  }
  ans.push_back(v);
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, M; std::cin >> N >> M;
  G.resize(N); UG.resize(N);
  rep(i,M) {
    int x, y; std::cin >> x >> y; x--,y--;
    G[x].push_back(y);
    UG[y].push_back(x);
  }
  
  used.resize(N);
  rep(i,N) if(!used[i]) tsort(i);
  std::reverse( all(ans) );

  // dp
  dp.resize(N, INIT);
  int res = -1e9;
  for(int i=N-1; i>=0; i--) res = std::max(res, sol(ans[i]));
  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 17148
#include <bits/stdc++.h>
using namespace std;
int N;vector< pair<int, int> > vec;vector<int> dust;
int cnt[505];int ans[250005];
int main(void){
	cin >> N;
	int x;
	for(int i = 1; i <= N; i++){cin >> x;vec.push_back( make_pair(x, i) );}
	sort(vec.begin(), vec.end());
	int nid = 0, tid = 0, set;
	for(int i = 1; i <= N*N; i++){
		if(nid < vec.size() && i >= vec[nid].first){
			if(cnt[vec[nid].second] < vec[nid].second-1){
				cout << "No" << endl;
				return 0;
			}
			ans[i] = vec[nid].second;
			cnt[vec[nid].second]++;
			for(int j = 0; j < N - vec[nid].second; j++) dust.push_back(vec[nid].second); 
			nid++;
			continue;
		}
		while(tid < vec.size() &&cnt[vec[tid].second] >= vec[tid].second-1) tid++;
		if(tid >= vec.size()){
			if(dust.size() == 0){
				cout << "No" << endl;
				return 0;
			}
			set = dust.back();
			dust.pop_back();
		}
		else set = vec[tid].second;
		ans[i] = set;
		cnt[set]++;
	}
	cout << "Yes" << endl;
	for(int i = 1; i <= N*N; i++){
		cout << ans[i];
		if(i != N*N) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    int N, M;
    cin >> N >> M;

    vector<vector<char>> A(N, vector<char>(N));
    vector<vector<char>> B(M, vector<char>(M));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < M; j++)
        {
            cin >> B[i][j];
        }
    }

    bool exist = false;

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i + M - 1 >= N || j + M - 1 >= N)
            {
                continue;
            }

            bool match = true;
            for (int k = 0; k < M; k++)
            {
                for (int l = 0; l < M; l++)
                {
                    if (A[i + k][j + l] != B[k][l])
                    {
                        match = false;
                    }
                }
            }
            if (match == true)
            {
                exist = true;
            }
        }
    }

    if (exist == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return (0);
}

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

using namespace std; 

#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 
#define clr(x) memset(x, 0, sizeof(x)) 
#define cpy(x,y) memcpy(x, y, sizeof(y)) 
#define sz(x) (int)x.size() 

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;

template<class T> bool uin(T &a, T b){ return (a > b ? a = b, true : false); }
template<class T> bool uax(T &a, T b){ return (a < b ? a = b, true : false); }

char __buffer[100000]; 

int limit = 1000; 

void err(const char *format, ... ) { 
  if (limit-- <= 0) return;   
  va_list ap; 
  va_start(ap, format); 
  vsprintf(__buffer, format, ap); 
  va_end(ap); 
   
  printf("%s", __buffer); 
} 
////////////////////////////////////////

class LadderPermutation {
	public:
		vi createLadder(int n, int m, int k) {
			if (n + 1 < m + k) return vi();
			if ((ll) m * k < n) return vi();
			int i = 1;
			vi ans;
			int cur = 0;
			while(i <= n) {
				int c = (n - i + k - 1) / k;
				if (cur + 1 + c <= m) {
					ans.pb(i);
					i++;
					cur++;
					continue;
				}
				int rem = (n - i + 1) % k;
				if (rem == 0) {
					rem = k;
				}
				fj(0, rem - 1) {
					ans.pb(i + rem - 1 - j);
				}
				i += rem;
				cur++;
			}
			return ans;			
		};
};

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
	int n, m, k;
	scanf("%d %d %d", &n, &m, &k);
	LadderPermutation A;
	vi ans = A.createLadder(n, m, k);
	if (sz(ans) == 0) {
		printf("-1\n");
	} else {
		for(int z : ans) {
			printf("%d ", z);
		}
	}

	return 0;
}










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

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

#define minimum(a)					*min_element(a.begin(), a.end())
#define maximum(a)					*max_element(a.begin(), a.end())
#define fo(i,a,b)                   for(int i=a;i<=b;i++)
#define fo2(i, a, b)                for(int i = a; i>=b; i--)
#define foreach(x, v)               for(auto x : v)
#define all(v)                      v.begin(), v.end()
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define mp make_pair

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin>>a>>b;
    if(a <= 5){
        cout<<0<<endl;
    }else if(a >=6 && a<=12){
        cout<<b/2<<endl;
    }else cout<<b<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int n, a, b, c, d;
	int okay = 1;
	int flag;
	char arr[200001];

	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	scanf("%s", arr);

	flag = 0;
	for (int i = a - 1; i < c; i++)
	{
		if (arr[i] == '#')
			flag++;
		else
			flag = 0;
		if (flag == 2)
			okay = 0;
	}
	flag = 0;
	for (int i = b - 1; i < d; i++)
	{
		if (arr[i] == '#')
			flag++;
		else
			flag = 0;
		if (flag == 2)
			okay = 0;
	}

	if (c > d && okay == 1)
	{
		for (int i = b - 1; i < d  ; i++)
		{
			if (arr[i - 1] == arr[i] && arr[i] == arr[i + 1] && arr[i] == '.')
			{
				printf("Yes");
				return 0;
			}
		}
		printf("No");
	}
	else if(okay == 1)
		printf("Yes");
	else
		printf("No");	

	return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
#include <math.h>
 
int main(){
    double r;
    double c;
    double area;
 
    scanf("%lf",&r);
    c = r*2*M_PI;
    area = r*r*M_PI;
    printf("%f %f\n",area,c);
 
  return 0;
}

Measured memory_bytes: 648
#include <stdio.h>
int main(void){
  long long A;
  double B;
  long long s;
  scanf("%lld %lf",&A,&B);
  long long ib=B*100+0.5;
  s=(A*ib)/100;
  
  printf("%lld",s);
  
  return 0;
}

Measured memory_bytes: 1748
N,M=map(int,input().split())
cakes=[]
for i in range(N):
  x,y,z=map(int,input().split())
  cakes.append([x,y,z])
if M==0:
  print(0)
  quit()
score=[0]*8
score[0]=sum(sorted(map(lambda c: c[0]+c[1]+c[2], cakes))[-M:])
score[1]=sum(sorted(map(lambda c: c[0]+c[1]-c[2], cakes))[-M:])
score[2]=sum(sorted(map(lambda c: c[0]-c[1]+c[2], cakes))[-M:])
score[3]=sum(sorted(map(lambda c: c[0]-c[1]-c[2], cakes))[-M:])
score[4]=sum(sorted(map(lambda c:-c[0]+c[1]+c[2], cakes))[-M:])
score[5]=sum(sorted(map(lambda c:-c[0]+c[1]-c[2], cakes))[-M:])
score[6]=sum(sorted(map(lambda c:-c[0]-c[1]+c[2], cakes))[-M:])
score[7]=sum(sorted(map(lambda c:-c[0]-c[1]-c[2], cakes))[-M:])
print(max(score))


Measured memory_bytes: 3300
#include <iostream>
using namespace std;
int main()
{
string s;cin>>s;
int x=0,y=0;
int n=s.length();
for(int i=0;i<n;i++){
    if(isupper(s[i])){
  x++;}
  }
for(int i=2;i<n-1;i++){
    if(s[i]=='C')
    y=1;
}
if(s[0]=='A'&& x==2 && y==1)
    cout<<"AC";
    else
    cout<<"WA";
}







Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n, m; cin >> n >> m;
	vector<int> a(m);

	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}

	sort(a.rbegin(), a.rend());


	vector<int> num = {-1,2,5,5,4,5,6,3,7,6 };
	vector<LL> digit(10000,-1000000);

	digit[0] = 0;

	for (int i = 1; i < n+1; i++) {

		for (int j = 0; j < m; j++) {

			int from = i - num[a[j]];
			if (from< 0)continue;

			digit[i] = max(digit[i], digit[from]+1);
		}
		
	}

	while (n > 0) {
		for (int i = 0; i < m; i++) {
			if (n - num[a[i]] < 0)continue;

			if (digit[n-num[a[i]]]==(digit[n]-1)) {
				cout << a[i];
				n -= num[a[i]];
				break;
			}
		}
	}
	
	cout << endl;

	return 0;
}

Measured memory_bytes: 384
def main():
    LRm = open(0).read().split()[2:]
    max_L = max(map(int, LRm[::2]))
    min_M = min(map(int, LRm[1::2]))
    print(min_M - max_L + 1 if max_L <= min_M else 0)
    return


main()


Measured memory_bytes: 18292
n = int(input())
a = [int(i) for i in input().split()]
a.append(0)
a = [0] + a
hani = []

count = 0
def gen(x):
    return x-min(a)

a = list(map(gen, a))

for i in range(len(a)):
    b = [i for i,x in enumerate(a) if x == 0]
    
def gen(x):
    return x-min(hani)


while sum(a) != 0:
    for i in range(len(a)):
        b = [i for i,x in enumerate(a) if x == 0]
    for i in range(len(b)-1):
        
        hani = a[b[i]+1:b[i+1]]
        if len(hani) != 0:
            count += min(hani)
            a[b[i]+1:b[i+1]] = list(map(gen, hani))
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    bool chk = false;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            chk = true;
            break;
        }
    }
    if(chk)
        cout<<"OK\n";
    else
        cout<<"NG\n";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
    using namespace std;
        
    typedef long long ll;
    typedef unsigned long long ull;
    typedef long double db;
        
    #define MOD 1000000007
    #define mi 18446744073709551615
    #define ff first
    #define ss second
    #define pb push_back
    #define vii vector<int>
    #define pii pair<int,int>
    #define vpii vector<pii>
     
    int main()
    {
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	int T=1;
    	// cin>>T;
    	while(T--)
    	{
            ll n,d,ans=0;
			cin>>n>>d;
			ll x,y;
			for(int i=0;i<n;i++)
			{
				cin>>x>>y;
				if(x<0)
					x=-x;
				if(y<0)
					y=-y;
				if(((ull)d*(ull)d)>=((ull)x*(ull)x+(ull)y*(ull)y))
				{
					ans++;
					//cout<<i+1<<" "<<d*d<<" "<<x*x+y*y<<"\n";
				}
			}
			cout<<ans;
    	}  
    	return 0;
    }

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int main()
{
//f<<":"<<endl;
     long long int n,i,j=1,c=0,f=1000000007,l,k,x=0,y,z,m,b,a=0;
     string s,w="",s1;
     char o;
     set <int, greater <int> > st;
     stack<string>sta,backk,forwardd;
     //int a[5];
    //long long  int arr[n+2][n+2];
     vector<char>ch(27);
     vector<string>str;
     vector<int>vect,vect3;
     map<long long int ,long long int>mp;
      cin>>n;
      for(i=0;i<n;i++)
      {
          cin>>k;
          vect.push_back(k);
          c+=k;
      }
      for(i=0;i<n;i++)
      {
          x+=vect[i];
         a=(a+((c-x)%f*(vect[i]%f)))%f;
      }
      cout<<a<<endl;
      }



Measured memory_bytes: 4276
def gcd(a, b):
  while b:
    a, b = b, a%b
  return a

def lcm(a, b):
  return a*b // gcd(a, b)

def run():
  A, B = map(int, input().split())
  ans = lcm(A, B)
  print(ans)
  
if __name__ == '__main__':
  run()

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {

    vvl c(3, vl(3));
    rep(i, 3) {
        rep(j, 3) {
            cin >> c[i][j];
        }
    }

    ll b0 = c[0][0];
    ll b1 = c[0][1];
    ll b2 = c[0][2];
    ll a1 = c[1][0] - b0;
    ll a2 = c[2][0] - b0;

    if(a1+b1 == c[1][1] && a1+b2 == c[1][2] && a2+b1 == c[2][1] && a2+b2 == c[2][2]) {
        out("Yes");
    }
    else {
        out("No");
    }

    re0;
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar (char ch)
{
	if (ch=='A') return 1;
	else if (ch=='C') return 2;
	else if (ch=='G') return 3;
	else if (ch=='T') return 4;
	else return 0;
}

long long getKey(char str[])
{
	long long sum=0,p=1,i;
	for (i=0;i<strlen(str);i++)
	{
		sum+=p*(getChar(str[i]));
		p*=3;
	}
	return sum;
} 

int h1(int key)
{
	return key%M;
}

int h2(int key)
{
	return 2+(key%(M-1));
}

int find (char str[])
{
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++)
	{
		h=(h1(key)+i*h2(key))%M;
		if (strcmp(H[h],str)==0) return 1;
		else if (strlen(H[h])==0) return 0;
	} 
	return 0;
}

int insert (char str[])
{
	long long key,i,h;
	key=getKey(str);
	for (i=0;;i++)
	{
		h=(h1(key)+i*h2(key))%M;
		if (strcmp(H[h],str)==0) return 1;
		else if (strlen(H[h])==0)
		{
			strcpy(H[h],str);
			return 0;
		}
	}
}
int main ()
{
	int i,n,h;
	char str[L],com[9];
	for (i=0;i<M;i++) H[i][0]='\0';
	scanf ("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf ("%s %s",com,str);
		if (com[0]=='i')
		{
			insert(str);
		}
		else {
			if (find(str)) printf ("yes\n");
			else printf ("no\n");
		}
	}
	return 0;
}


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

#define rep(i, n) for (int i=0; i< (n); ++i)
typedef long long ll;
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; }

using namespace std;

int main() {
    int n;

    cin >> n;

    int min_x = 100;
    int max_x = 1;
    int x[n];
    rep(i, n) {
        cin >> x[i];
        chmin(min_x, x[i]);
        chmax(max_x, x[i]);
    }

    int min_cost = -1;
    for (int i=min_x; i<=max_x; i++) {
        int cost = 0;
        rep(j, n) {
            cost += (x[j] - i) * (x[j] - i);
        }

        if (min_cost == -1) {
            min_cost = cost;
        } else {
            chmin(min_cost, cost);
        }
    }

    cout << min_cost << endl;
}


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

double total_length = 0;

int n;

struct Point
{
	int x;
	int y;
	Point() {}
	Point(int _x, int _y) {}
};


long F(int i)
{
	if (i == 1)
	{
		return i;
	}
	else
	{
		return i * F(i - 1);
	}
}

double distance(Point& p1, Point& p2)
{
	double t = std::sqrt(std::pow(p1.x - p2.x, 2) + std::pow(p1.y - p2.y, 2));
	return t;
}

void totalDistance(Point* a, int beg, int end)
{
	if (end - beg == 1)
	{
		for (int i = 0; i < end - 1; i++)
		{
			total_length += distance(a[i], a[i + 1]);
		}
	}
	else
	{
		for (int i = beg; i < end; i++)
		{
			std::swap(a[beg], a[i]);
			totalDistance(a, beg + 1, end);
			std::swap(a[beg], a[i]);
		}
	}
}

int main()
{
	Point a[8];
	
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		int x, y;
		std::cin >> x >> y;
		a[i].x = x;
		a[i].y = y;
	}
	long t = F(n);
	totalDistance(a, 0, n);

	printf("%.11g", total_length / t);

	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    if (((n / 10) % 111) == 0)
        cout << "Yes" << endl;
    else if (((n % 1000) % 111) == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3616
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		double a = Double.parseDouble(sc.next());
		double b = Double.parseDouble(sc.next());
		double x = Double.parseDouble(sc.next());

		if(a*a*b/2>=x) {
			double ins = (a*b*b) / (2*x);
			double theta = Math.atan(ins);
			theta = Math.toDegrees(theta);
			out.println(theta);
		}
		else {
			double ins = (2*a*a*b - 2*x) / (a*a*a);
			double theta = Math.atan(ins);
			theta = Math.toDegrees(theta);
			out.println(theta);
		}

		out.flush();
	}
}

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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    string s;
    int k;
    cin>>k>>s;
    int slen=s.size();
    if(slen<=k)cout<<s<<endl;
    else{
        cout<<s.substr(0,k)<<"..."<<endl;
    }
    return 0;
}

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

namespace AOJ
{
  class Program
  {
    public static void Main(string[] args)
    {
      Console.ReadLine();
      foreach (var edges in ReadNumbers())
        Console.WriteLine(IsTriangle(edges) ? "YES" : "NO");
    }

    static bool IsTriangle(int[] edges)
    {
      var tmp = edges.OrderBy(x => x).Reverse();
      var hypotenuse = tmp.First();
      return tmp.Skip(1).Select(x => x * x).Sum() == (hypotenuse * hypotenuse);
    }

    static IEnumerable<int[]> ReadNumbers()
    {
      string line;
      while ((line = Console.ReadLine()) != null)
        yield return line.Split(' ').Select(s => int.Parse(s)).ToArray();
    }
  }
}

Measured memory_bytes: 6380
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define lld long long int
int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
string s;
cin>>s;
int max=0;
if(s[0]=='R')
{
    max++;
}
if(s[1]=='R')
max++;
if(s[2]=='R')
max++;
if(max==2)
{
    if(s[1]!='R')
    cout<<1<<"\n";
    else
    cout<<max<<"\n";
}
else
cout<<max<<"\n";
	return 0;
}



Measured memory_bytes: 3640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};
using T=tuple<in,in,in>;

in n;
vector<in> a(0),b(0);
vector<bool> seen(0);


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    cin>>n;
    a.resize(n);
    b.resize(n);
    seen.resize(n,0);
    rep(i,n) cin>>a[i]>>b[i];
    vector<T> x(n);
    rep(i,n) x[i]=T(a[i]+b[i],a[i],b[i]);
    sort(all(x));
    reverse(all(x));
    in ans=0ll;
    rep(i,n){
        if(i%2ll==0) ans +=get<1>(x[i]);
        else ans -=get<2>(x[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N;
int a[100010];


bool solve(){
	sort(RNG(a, 0, N));
	int win;
	if(a[0]%2 == 0) win = 0;
	else win = N;
	int d = a[0];
	rep(i, 1, N){
		if((a[i]-d)%2 != 0) win ^= (N-i);
		d += a[i];
	}
	return win;
}


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> a[i];

	if(solve()) cout << "first" << endl;
	else cout << "second" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

void solve() {
    string S;
    cin >> S;
    int ans = 700;
    for (int i = 0; i < 3; i++) if (S.at(i) == 'o') ans += 100;
    cout << ans << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
A_array = [list(map(int, input().split())) for _ in range(N)]

# print(A_array)

s_index = [0] * N

ans_date = 1
finish_player = 0
match_count = 0
M = N * (N-1) // 2
first_flag = 1
while(1):
    flag = 0
    match_array = [0] * N
    if first_flag:
        match_candidate = [i for i in range(N)]
        first_flag = 0
    next_match = []
    for i in match_candidate:
        if match_array[i] == 1 or s_index[i] == N - 1:
            continue
        vs = A_array[i][s_index[i]] - 1
        # print(i,vs)
        if match_array[vs] != 1 and A_array[vs][s_index[vs]] - 1 == i:
            match_count += 1
            match_array[i] = 1
            s_index[i] += 1
            match_array[vs] = 1
            s_index[vs] += 1
            flag = 1
            next_match.append(i)
            next_match.append(vs)
    if flag == 0:
        print(-1)
        exit()
    if match_count == M:
        break
    ans_date += 1
    match_candidate = next_match
print(ans_date)


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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> v;
    for(int i=1; i<=A; i++) {
        if(A % i == 0 && B % i == 0) {
            v.push_back(i);
        }
    }
    reverse(v.begin(),(v.begin(),v.end()));
    cout << v[K-1] << endl;
}



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

#define int long long

const int N=2e5+5;
const int MOD=998244353;

int fact[N], invfact[N];

int pw(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1LL)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pw(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}

void solve(int tt)
{
    int n,m,k;
    cin>>n>>m>>k;
    int t=n-k;
    int ans=0;
    for(int i=t;i<=n;i++)
    {
        int temp=nCr(n-1,i-1)*m;
        temp%=MOD;
        temp*=pw(m-1,i-1,MOD);
        temp%=MOD;
        ans+=temp;
        ans%=MOD;
        //cout<<ans<<endl;
    }
    cout<<ans;    
}

int32_t main()
{
    precompute();
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
        solve(i);
}

Measured memory_bytes: 6752
n = int(input())
li = []
for i in range(n):
    li.append(input())
print('AC x {}'.format(li.count('AC')))
print('WA x {}'.format(li.count('WA')))
print('TLE x {}'.format(li.count('TLE')))
print('RE x {}'.format(li.count('RE')))


Measured memory_bytes: 16156
def get_four_int():
    four_int = input().split()
    for i, v in enumerate(four_int):
        four_int[i] = int(v)
    return four_int

def get_min_roux_num(initial_roux, initial_water, ideal_concentration, min_unit):
    roux = initial_roux
    min_roux_num = 0
    min_required_roux = initial_water * ideal_concentration
    while True:
        if roux >= min_required_roux:
            return min_roux_num
        roux += min_unit
        min_roux_num += 1


if __name__ == "__main__":
    while True:
        initial_roux, initial_water, ideal_concentration, min_unit = get_four_int()
        if initial_roux == 0:
            break
        min_roux_num = get_min_roux_num(initial_roux, initial_water, ideal_concentration, min_unit)
        print(min_roux_num)





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

using namespace std;

string judge(int m, int f, int r) {
    string ret;

    if (m == -1 || f == -1) {
        ret = "F";
    } else if (m + f >= 80) {
        ret = "A";
    } else if (m + f >= 65) {
        ret = "B";
    } else if (m + f >= 50) {
        ret = "C";
    } else if (m + f >= 30) {
        if (r >= 50) {
            ret = "C";
        } else {
            ret = "D";
        }
    } else {
        ret = "F";
    }

    return ret;
}

int main(void){
    vector<string> list;
    while (true) {
        int m, f, r;
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
    
        list.push_back(judge(m, f, r));
    }

    for (auto &rank : list) {
        cout << rank << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3128
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i=1;i<=a[0];i++){
        int cnt=0;
        for(int j=0;j<n;j++){
            if(a[j]%i==0){
                cnt++;
            }
        }
        if(cnt==n){
            cout << i << endl;
        }
    }
    return 0;
}



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

int main()
{
    int test, kase;
    double xa, ya, ra, xb, yb, rb, check;
    scanf("%d", &test);
    for(kase=1; kase<=test; kase++)
    {
        scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb);

        check = sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));

        if(check>=0 && check <fabs(rb-ra))
        {
            if(ra>rb)
                printf("2\n");
            else if(ra<rb)
                printf("-2\n");
            else
                printf("1\n");
        }
        else if ((check>=fabs(rb-ra))&&(check<=ra+rb))
            printf("1\n");

        else
            printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif
const int MAXN=1000000;

int main(){
  fastIO();
  vector<vector<int>>prime(MAXN+5);
  for(int i=2;i<=MAXN;i++){
    for(int j=i;j<=MAXN;j+=i){
      prime[j].push_back(i);
    }
  }
  int n,val,g=0;
  cin>>n;
  map<int,int>rep;
  bool pairwise=true,setwise=false;
  for(int i=0;i<n;i++){
    cin>>val;
    g=__gcd(g,val);
    for(int j=0;j<prime[val].size()&&pairwise;j++){
      if(rep[prime[val][j]]>0)pairwise=false;
      rep[prime[val][j]]++;
    }
  }
  setwise=(g==1);
  if(pairwise){
    cout<<"pairwise coprime"<<endl;
  }else if(setwise){
    cout<<"setwise coprime"<<endl;
  }else{
    cout<<"not coprime"<<endl;
  }
  return 0;
}


Measured memory_bytes: 117360
#include <stdio.h>
#include <math.h>
typedef long long ll;

int compare_ll(const void *a, const void *b){
    return *(ll*)a - *(ll*)b;
}

int main(){
  int	n, k;
  scanf("%d %d", &n, &k);
  
  ll	h[200000+1]={0};
  for(int i=0; i<n; i++){ scanf("%lld", &h[i]); }
  qsort( h, n, sizeof(ll), compare_ll );
  
  //必殺技で強い方から倒す
  if( n <= k ){ printf("0\n"); return 0; }
  n -= k;
  
  //残党狩り
  ll	cnt=0;
  for(int i=0; i<n; i++){
  	cnt += h[i];
  }
  printf("%lld\n", cnt);
  
  return 0;
}

Measured memory_bytes: 4628
if True:
    n= int(input())
    hn= list(map(int, input().split()))
else:
    import sys
    args = sys.argv
    set_flg = False
    if len(args) == 2:
        set_flg = True
        if args[1] == "2":
            n=5
            hn=[3,1,2,3,1]
        elif args[1] == "3":
            n=8
            hn=[4,23,75,0,23,96,50,100]
        else:
            set_flg = False

    if set_flg == False:
        n=4
        hn=[1,2,2,1]


# print(n)
# print(hn)

water = 0
target_idx = 0

for i in range(0,len(hn)):
    while hn[i] > 0:
        if hn[i] == 0:
            break

        for j in range(i+1,len(hn)):
            # print(hn)
            if hn[j] > 0:
                hn[j] -=1
            else:
                break
        hn[i] -= 1
        water += 1

print(water)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ii=long long;
#define all(x) x.begin(), x.end()
int main()
{
    ii s;
    cin >> s;
    cout << "0 0 ";

    // A = |x_1*y_2-y_1*x_2 + x_2*y_3 - x_3*y_2| * 1 / 2

    // x_1 = 0
    // y_1 = 0

    // A = |x_2 * y_3 - x_3 * y_2| * 1 / 2

    // s = |x_2 * y_3 - x_3 * y_2|, x_2,y_3,x_3,y_2>=0
    // s = x_2y_3-x_3y_2

    // x_2 * y_3 - x_3 * y_2 = s

    ii x_2, y_2, x_3, y_3;

    // x_2 * y_3 = s + x_3 * y_2
    
    // ad = s + cb
        
        
        
    // ad - cb = s
    
    // ad >= s
    
    
    
    
    // a, b, c, d <= 1e9
    
    // a, b, c, d >= 0
    
    // s <= 1e18
    
    
    // ad <= 1e18
    
    
    // bc <= 1e18
    
    
    
    
    
    
    
    // x_2 * y_3 > x_3 * y_2 , koska s > 0
    
    
    
    
    
    
    ii a, b, c, d;
    
    // s = ad - cb
    
    const ii N = (ii) 1e9;
    c = 1;
    a = s / N + ((s % N) != 0);
    d = N;
    b = a * d - s;
    cout << a << " " << b << " " << c << " " << d << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int counter = 0;
  for (int i = 0; i<3; i++){
    if(s[i]=='1'){
      counter++ ;
    }
  }
  
    cout << counter << endl;
  }
  
    

Measured memory_bytes: 256
import sys,math,copy,queue,itertools,bisect,collections
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 2019
DD = ((1,0),(0,1),(-1,0),(0,-1))

s = [int(x) for x in sys.stdin.readline().rstrip()]
amari = {0:1}
m = 0
t = 1
for i in range(len(s)-1,-1,-1):
    m = (t *s[i] + m) % MOD
    if m in amari:
        amari[m] += 1
    else:
        amari[m] = 1
    t = (t * 10) % MOD

ans = 0
for x in amari.values():
    ans += x * (x-1) // 2

print (ans)




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

int main(void){
  int a,b,c;
  while(cin>>a>>b>>c,a||b||c){
    int n;cin>>n;
    vector<int> v[3];
    set<int> correct,broken,all;
    for(int x=0,i,j,k,r;x<n;++x){
      cin>>i>>j>>k>>r;
      v[0].push_back(i);v[1].push_back(j);v[2].push_back(k);
      all.insert(i);all.insert(j);all.insert(k);
      if(r){correct.insert(i);correct.insert(j);correct.insert(k);}
    }
    for(int i=0;i<n;++i){
      int cnt=0;
      cnt+=(correct.find(v[0][i])!=correct.end())<<0;
      cnt+=(correct.find(v[1][i])!=correct.end())<<1;
      cnt+=(correct.find(v[2][i])!=correct.end())<<2;
      if(cnt==3){
        broken.insert(v[2][i]);
      }else if(cnt==5){
        broken.insert(v[1][i]);
      }else if(cnt==6){
        broken.insert(v[0][i]);
      }
    }
    for(int i=1;i<=a+b+c;++i){
      if(correct.find(i)!=correct.end()) cout<<1<<endl;
      else if(broken.find(i)!=broken.end()) cout<<0<<endl;
      else cout<<2<<endl;
    }
    
  }
  return 0;
}

Measured memory_bytes: 1252
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,k;
int main()
{
	cin>>n>>k;
	if(k==1)
	{
		cout<<0<<endl;
	}
	else
	{
		cout<<n-k<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

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

	vector<int> d(N);
	for(int i=0; i<N; i++)
	{
		cin>>d[i];
	}
	int sum = 0;
	for(int i=0; i<N; i++)
	{
		for(int j=i+1; j<N; j++)
		{
			sum += d[i] * d[j];
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int N;
	scanf("%d", &N);
	int d[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", &d[i]);
	}
	int sum=0;

	for (int i = 0; i < N-1; i++) {
		for (int j = i+1; j < N; j++) {
			sum += d[i] * d[j];
		}
	}
	printf("%d", sum);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	set<int> s;
	int n = 3;
	rep(i, n)
	{
		int tmp;
		cin >> tmp;
		s.insert(tmp);
	}
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int compare_long(const void *a, const void *b){if(*(long*)a - *(long*)b > 0){return -1;}else if(*(long*)a - *(long*)b < 0){return 1;}else{return 0;}}
int min(int a, int b){return a>b?b:a;}

int x, y, z, w, k, i, j;
long a[1000], b[1000], c[1000], d[1000000], e[3000000];

int main(void){
  scanf("%d%d%d%d", &x, &y, &z, &k);
  for(i=0; i<x; i++){
    scanf("%ld", a+i);
  }
  for(i=0; i<y; i++){
    scanf("%ld", b+i);
  }
  for(i=0; i<z; i++){
    scanf("%ld", c+i);
  }
  for(i=0; i<x; i++){
    for(j=0; j<y; j++){
      d[i*y+j] = a[i]+b[j];
    }
  }
  qsort(d, x*y, sizeof(long), compare_long);
  w=min(x*y, k);
  for(i=0; i<w; i++){
    for(j=0; j<z; j++){
      e[i*z+j] = d[i]+c[j];
    }
  }
  qsort(e, w*z, sizeof(long), compare_long);
  for(i=0; i<k; i++){
    printf("%ld\n", e[i]);
  }
}


Measured memory_bytes: 54908
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <cmath>
#include <random>
#include <bitset>
#include <complex>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define pb(a) push_back(a)
#define ALL(a) a.begin(),a.end()
#define sqr(x) (x) * (x)
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int &
#define SZ(a) ((int)(a.size()))
#define f(cnt) (((cnt) + 1) * (cnt) / 2)
#define watch(x) cout << (#x) << " = " << x << endl;

const double PI = 2 * acos(0.0);

template<typename T>
struct edge {
    int from, to;
    T w;
    edge(int from, int to, T w): from(from), to(to), w(w) { }
    edge() { }
};

template<class T, class C>
void show(C a) {
//    FIXME: it doesn't work
    for (T x : a)
        cout << x << " ";
    cout << endl;
}


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

    int n, k;
    cin >> n >> k;
    vi x(n);
    fori (i, n)
    cin >> x[i];

    int ind = n;
    for (int i = 0; i < n; ++i) {
        if (x[i] >= 0) {
            ind = i;
            break;
        }
    }
    int ans = 1e9;
    for (int i = 1; i < k; ++i) {
        int l = ind - i;
        if (l >= n || l < 0) continue;
        int rest = k - i;
        int r = ind + rest - 1;
        if (r < n && r >= 0) mmin(ans, x[r] - x[l] + min(-x[l], x[r]));
    }
    int r = ind + k - 1;
    if (r < n) mmin(ans, x[r]);
    int l = ind - k;
    if (l >= 0) mmin(ans, -x[l]);
    cout << ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define debug(x) cerr<<"\tDEBUG: "<<#x<<" = "<<(x)<<endl
#define debug2(a,b) cerr<<#a<<"\t"<<#b<<" = "<<(b)<<endl
using namespace std;
const int maxn=2e5+100;
bool cur1;
int n,A[maxn];
int q,C[maxn];
struct BIT{
	int C[maxn];
	void add(int x,int d){
		while(x){
			C[x]=max(C[x],d);
			x&=x-1;
		}
	}
	int sum(int x){
		int res=0;
		while(x<=n){
			res=max(res,C[x]);
			x+=x&-x;
		}
		return res;
	}
}bit;
bool cur2;
int main(){
//	double sz=&cur1-&cur2;
//	cout<<sz/1024/1024<<endl;
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&A[i]);
		C[i]=A[i];
	}
	sort(C+1,C+1+n);
	q=unique(C+1,C+1+n)-C-1;
	for(int i=1;i<=n;i++)
		A[i]=lower_bound(C+1,C+1+q,A[i])-C;
	int ans=0;
	for(int i=1;i<=n;i++){
		int x=bit.sum(A[i])+1;
		ans=max(ans,x);
		bit.add(A[i],x);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N), y(N);
  rep(i, N) cin >> x[i] >> y[i];
  ll ans = 4*1e18+1;
  rep(i, N) rep(j, N) rep(k, N) rep(l, N) {
    if(x[i] < x[j] && y[k] < y[l]) {
      int cnt = 0;
      rep(m, N) {
        if(x[m] >= x[i] && x[m] <= x[j] && y[m] >= y[k] && y[m] <= y[l])
          cnt++;
      }
      if(cnt >= K)
        chmin(ans, (ll)(x[j]-x[i])*(y[l]-y[k]));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

        if (n == m) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }

        return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007

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

   ll N,A,B;
   cin>>N>>A>>B;
   vector<ll>h(N);
   for(int i=0;i<N;i++)cin>>h[i];
   ll left = 0;
   ll right = (1<<30);
   ll midle;
   while(right-left>1){
      midle = (right+left)/2;
      vector<ll>h_ = h;
      for(int i=0;i<N;i++)h_[i] = max(h_[i]-midle*B,(ll)0);
      ll a = 0;
      for(int i=0;i<N;i++)a+=(h_[i]+(A-B)-1)/(A-B);
      //cout<<a<<" "<<midle<<endl;
      if(midle<a)left=midle;
      else right=midle;
   }
   cout<<right<<endl;
   return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
	int N, M;//N<=8なので全探索できる
	int a[40], b[40];
	cin >> N >> M;
	REP(i, M) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;//0-indexed
	}

	//N!とおりの順列を生成して，それが可能か調べる
	//next permutation
	int perm[10];
	REP(i, N) {
		perm[i] = i;
	}

	bool flag;
	int ans = 0;
	do {
		if (perm[0] != 0) continue;

		for (int i = 0;i < N - 1;i++) {

			flag = 0;
			for (int j = 0;j < M;j++) {
				if (((perm[i] == a[j]) && (perm[i + 1] == b[j])) || ((perm[i] == b[j]) && (perm[i + 1] == a[j]))) {//方向なしの結合なのでこれではだめ
					flag = 1;
					break;
				}
			}

			if (flag == 0) break;//そのパスがなかったらbreak

			if (i == N - 2) ans++;//最後まで回ったらans++
		}

		//REP(i, N) {
		//	cout << perm[i] << endl;
		//}

	} while (next_permutation(perm, perm + N));

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

Measured memory_bytes: 256