akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
struct team{
  int point,penalty,wrong[11],id;
  bool operator<(const team& a)  const{
    return point == a.point ? (penalty == a.penalty ? id < a.id : penalty < a.penalty) : point > a.point; 
  }
};
int main(){
  int t,p,r,i,j,k,b,o,tid,pid,time;
  string str;
  cin >> t >> p >> r;
  while(t!=0||p!=0||r!=0){
    vector <team> teams;
    for(i=1;i<=t;i++){
      team t;
      t.id=i;
      t.point=0;
      for(j=0;j<11;j++)
      t.wrong[j]=0;
      t.penalty=0;
      teams.push_back(t);
    }
    for(i=0;i<r;i++){
      cin >> tid >> pid >> time >> str;
      if(str[0]=='C'){
	teams[tid-1].point++;
	teams[tid-1].penalty+=teams[tid-1].wrong[pid]*1200+time;
      }else{
	teams[tid-1].wrong[pid]++;
      }
    }
    sort(teams.begin(),teams.end());
    for(i=0;i<t;i++){
      cout << teams[i].id << " " << teams[i].point << " " << teams[i].penalty << endl;
    }
    cin >> t >> p >> r;
  }
  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

u64 ans;
void mergeSort(vs32&, int, int);
void merge(vs32&, int, int, int);

void mergeSort(vs32& A, int l, int r)
{
  if (l + 1 < r)
  {
    int m = (l + r) / 2;
    mergeSort(A, l, m);
    mergeSort(A, m, r);
    merge(A, l, m, r);
  }
}

void merge(vs32& A, int l, int m, int r)
{
  int n1 = m - l;
  int n2 = r - m;
  vs32 L(n1 + 1), R(n2 + 1);
  rep (i, n1) L[i] = A[l + i];
  rep (i, n2) R[i] = A[m + i];
  L[n1] = 1e9 + 1; R[n2] = 1e9 + 1;

  int i = 0, j = 0;
  for (int k = l; k < r; ++k)
  {
    if (L[i] <= R[j])
    {
      A[k] = L[i++];
    }
    else
    {
      ans += n1 - i;
      A[k] = R[j++];
    }
  }
}

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

    int n;
    cin >> n;

    vs32 A(n);
    vs32 B(n + 1);
    rep (i, n)
    {
      cin >> A[i];
    }

    mergeSort(A, 0, n);

    cout << ans << "\n";
    return 0;
}



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

public class BinarySearch
{
    public static void Main()
    {
        Console.ReadLine();
        var s = new HashSet<int>(Console.ReadLine().Split(' ').Select(int.Parse));
        Console.ReadLine();
        var t = Console.ReadLine().Split(' ').Select(int.Parse);
    
//        "BinarySearch".Measure(() =>
//        {
            var c = t.Count(x => s.Contains(x));
            Console.WriteLine(c);
//        });
    }
}
// Define other methods and classes here

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

int main() {
    char s[201];
    char t[101];
    char p[101];
    scanf("%s", s);
    scanf("%s", p);

    strcpy(t, s);
    strcat(s, t);

    if (strstr(s, p) == NULL) cout << "No";
    else cout << "Yes";
    cout << endl;
}

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

vector<long long> lunlun;

void dfs(long long cur,int prev){
    if(cur>3234566667) return;
    lunlun.push_back(cur);
    if(prev==0){
        dfs(cur*10,0);
        dfs(cur*10+1,1);
    }else if(prev==9){
        dfs(cur*10+8,8);
        dfs(cur*10+9,9);
    }else{
        dfs(cur*10+prev+1,prev+1);
        dfs(cur*10+prev,prev);
        dfs(cur*10+prev-1,prev-1);
    }
}

int main(){
    int k;
    cin >> k;
    for(long long i=1;i<10;i++){
        dfs(i,i);
    }
    sort(lunlun.begin(),lunlun.end());
    cout << lunlun[k-1] << endl;
}

Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = in.readLine();
    switch (str) {
      case "SUN":
        System.out.println("7");
        break;
      case "MON":
        System.out.println("6");
        break;
      case "TUE":
        System.out.println("5");
        break;
      case "WED":
        System.out.println("4");
        break;
      case "THU":
        System.out.println("3");
        break;
      case "FRI":
        System.out.println("2");
        break;
      case "SAT":
        System.out.println("1");
        break;
    }
  }
}

Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#include <string>

struct TCard;
void InputCards(int& Count,std::vector<TCard>& Cards);
void OutputCards(const std::vector<TCard>& Cards);
int BubbleSortCards(std::vector<TCard>& Cards);
int SelectionSortCards(std::vector<TCard>& Cards);

struct TCard
{
	char Suit;
	int Value;
	
	bool operator==(const TCard& Other)const;
};

int main()
{
	int Count = 0;
	std::vector<TCard> Cards;
	InputCards(Count,Cards);
	std::vector<TCard> CardsCopy = Cards;
	
	BubbleSortCards(Cards);
	OutputCards(Cards);
	std::cout << "Stable" << std::endl;
	
	SelectionSortCards(CardsCopy);
	OutputCards(CardsCopy);
	if(CardsCopy == Cards)
	{
		std::cout << "Stable" << std::endl;
	}else{
		std::cout << "Not stable" << std::endl;
	}
	
	return 0;
}

void InputCards(int& Count,std::vector<TCard>& Cards)
{
	std::cin >> Count;
	for(int i=0;i<Count;i++)
	{
		TCard TempCard;
		char Suit = 0;
		std::cin >> Suit;
		TempCard.Suit = Suit;
		int Value = 0;
		std::cin >> Value;
		TempCard.Value = Value;
		Cards.push_back(TempCard);
	}
}

void OutputCards(const std::vector<TCard>& Cards)
{
	for(unsigned int i=0;i<Cards.size();i++)
	{
		std::cout << Cards[i].Suit << Cards[i].Value << std::flush;
		if(i != Cards.size() - 1)
		{
			std::cout << " " << std::flush;
		}else{
			std::cout << std::endl;
		}
	}
}

int BubbleSortCards(std::vector<TCard>& Cards)
{
	int SwapCount = 0;
	for(unsigned int i = 0;i<Cards.size();i++)
	{
		for(unsigned int j = Cards.size() - 1;j > i;j--)
		{
			if(Cards[j].Value < Cards[j-1].Value)
			{
				std::swap(Cards[j],Cards[j-1]);
				SwapCount++;
			}
		}
	}
	return SwapCount;
}

int SelectionSortCards(std::vector<TCard>& Cards)
{
	int SwapCount = 0;
	for(unsigned int i = 0;i<Cards.size();i++)
	{
		unsigned int Min = i;
		for(unsigned int j = i;j<Cards.size();j++)
		{
			if(Cards[j].Value < Cards[Min].Value)
			{
				Min = j;
			}
		}
		if(i != Min) SwapCount++;
		std::swap(Cards[i],Cards[Min]);
	}
	return SwapCount;
}

bool TCard::operator==(const TCard& Other)const
{
	if(Suit == Other.Suit && Value == Other.Value) return true;
	return false;
}

Measured memory_bytes: 1224
import collections,sys
input=sys.stdin.readline
n=int(input())
l=list(map(int,input().split()))
z=len(format(max(l),'b'))
x=[0]*z
for i in range(n):
  l[i]=format(l[i],'b')
  l[i]='0'*(z-len(l[i]))+l[i]
  for j,y in enumerate(l[i]):
    if y=='0':
      x[j]+=1
for j in range(z):
  x[j]=str(x[j]%2)
x=int(''.join(x),2)
for i in range(n):
  l[i]=int(l[i],2)
  l[i]=l[i]^x
print(*l)


Measured memory_bytes: 121128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll S,W; cin>>S>>W;
  if (S<=W)
    cout<<"unsafe"<<endl;
  else
    cout<<"safe"<<endl;
}


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

int main(){
    long long x, y;
    std::cin >> x >> y;

    std::vector<long long> vec(1, x);
    long long i = 0;
    while(vec.at(i) * 2 <= y){
        vec.push_back(vec.at(i++) * 2);
    }

    std::cout << vec.size() << std::endl;

    return 0;
}

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

vector<int> v[5010];

ll f[5010][5010],c[5010][5010],fac[5010],bin[5010],g[5010],h[5010];
int size[5010],fa[5010],n;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline ll pls(const ll &x,const ll &y) { return (x+y<mod)?x+y:x+y-mod; }
inline ll mns(const ll &x,const ll &y) { return (x-y<0)?x-y+mod:x-y; }
inline ll ksm(ll x,ll y) { ll res=1;for (;y;y>>=1,x=x*x%mod) if (y&1) res=res*x%mod;return res; }

inline void pre_gao()
{
	fac[0]=1;
	for (int i=1;i<=5000;i++) fac[i]=fac[i-1]*i%mod;
	for (int i=0;i<=5000;i++)
	{
		c[i][0]=1;
		for (int j=1;j<=i;j++) c[i][j]=pls(c[i-1][j-1],c[i-1][j]);
	}
	ll inv2=ksm(2,mod-2);
	bin[0]=1;
	for (int i=1;i<=5000;i++) bin[i]=bin[i-1]*inv2%mod;
	for (int j=0;j<=5000;j+=2) g[j]=c[j][j/2]%mod*fac[j/2]%mod*bin[j/2]%mod;
}

inline void dfs(int x)
{
	size[x]=1;f[x][1]=1;
	for (int t:v[x]) if (t!=fa[x])
	{
		fa[t]=x;dfs(t);
		for (int j=2;j<=size[t];j++) f[t][0]=mns(f[t][0],f[t][j]*g[j]%mod);
		memset(h,0,sizeof(h));
		for (int j=1;j<=size[x];j++) for (int k=0;k<=size[t];k++) h[j+k]=pls(h[j+k],f[x][j]*f[t][k]%mod);
		memcpy(f[x],h,sizeof(h));
		size[x]+=size[t];
	}
}

int main()
{
	n=rd();pre_gao();
	for (int i=1;i<n;i++)
	{
		int x=rd(),y=rd();
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1);
	ll ans=0;
	for (int i=2;i<=n;i+=2) ans=pls(ans,f[1][i]*g[i]%mod);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 391168
f = lambda: map(int,input().split())
n,x = f()
import sys
if x == 1 or x == 2*n-1:
    print('No')
    sys.exit()
if n == 2:
    print(*['Yes',1,2,3], sep='\n')
else:
    print('Yes')
    a = list(range(1,x-1))+list(range(x+2,2*n))
    b = [x-1,x,x+1]
    c = a[n-2:]+b+a[:n-2]
    print(*c, sep='\n')


Measured memory_bytes: 18492
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int N,M,A,B;
vector<int> adjList[100001];
int degree[100001], dist[100001];
bool vis[100001];

void dfs(int u)
{
	vis[u]=true;
	for(int i=0;i<adjList[u].size();i++)
	{
		int v=adjList[u][i];
		dist[v]=max(dist[v],dist[u]+1);
		degree[v]--;
		if(degree[v]==0)
			dfs(v);
	}
}

int main()
{
	scanf("%d %d",&N,&M);
	for(int i=1;i<=N;i++)
	{
		adjList[i].clear();
		degree[i]=0;
		vis[i]=false;
		dist[i]=0;
	}
	while(M--)
	{
		scanf("%d %d",&A,&B);
		adjList[A].push_back(B);
		degree[B]++;
	}
	for(int i=1;i<=N;i++)
		if(!vis[i] && degree[i]==0)
			dfs(i);
			
	int ans=0;
	for(int i=1;i<=N;i++)
		ans=max(ans,dist[i]);
	printf("%d\n",ans);
}

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

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

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

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

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

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

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

int cnt[101];
struct pi{
	int num;
	int cnt;
	bool operator<( const pi& right ) const {
        return cnt == right.cnt ? num < right.num : cnt < right.cnt;
    }
};

int main(){
	int n,m;
	while(cin>>n>>m){
		if(n==0&&m==0)break;
		vector<pi>P;
		CLR(cnt);
		REP(i,n){
			REP(j,m){
				int t;
				cin>>t;
				cnt[j]-=t;
			}
		}
		REP(i,m){
			pi p;p.cnt=cnt[i];p.num=i+1;
			P.PB(p);
		}
		sort(ALL(P));
		REP(i,m){
			cout<<P[i].num;
			if(i!=m-1)cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>

int main (){
    int n,min=0,max=0;
    long m=0,sum=0;
    scanf("%d",&n);
    scanf("%ld",&m);
    min = max = m;
    sum = m;
    for (int i = 1; i < n; i++){
        scanf("%ld",&m);
        if(min > m) min = m;
        if(max < m) max = m;
        sum += m;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}



Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	int MAX = 2 * 1e3 + 1;
	vector<int64_t> L(N), C(MAX);
	for (int i = 0; i < N; i++) {
		int64_t n;
		cin >> n;
		C[n]++;
		L[i] = n;
	}
	for (int i = 1; i < MAX; i++) C[i] += C[i - 1];

	//for (int i = 0; i < 10; i++) {
	//	if (i) cout << ' ';
	//	cout << C[i];
	//}

	int64_t ret = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) continue;
			int64_t left, right;
			left = abs(L[i] - L[j]);
			right = L[i] + L[j];

			int64_t a = C[right - 1] - C[left];
			if (L[i] > left && L[i] < right) a--;
			if (L[j] > left && L[j] < right) a--;
			ret += max(a, (int64_t)0);
		}
	}

	cout << ret / 6 << endl;
}

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

int main() {
  int ans = 0;//
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];//v = {a, b, c}
  while(v[0] != v[1] || v[0] != v[2]) {
    sort(v.begin(), v.end());
    int x = v[2] - v[1];
    ans += x;
    v[1] = v[2];
    v[0] += x;
    int y = v[2] - v[0];
    if(y % 2 == 0) {
      ans += y / 2;
      v[0] = v[2];
    }else {//差が奇数
      ans += (y + 1) / 2;
      v[0] += (y + 1);
    }
  }
  cout << ans;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
constexpr int maxn = 2000;
vector<int> G[maxn + 1];
int D[maxn + 1][maxn + 1];
void DFS(int r, int u, int par = 0){
    for(int&v : G[u]) if(v != par){
        D[r][v] = D[r][u] + 1;
        DFS(r, v, u);
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N, K;
    cin >> N >> K;
    for(int i = 1, A, B; i < N; i += 1){
        cin >> A >> B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    for(int i = 1; i <= N; i += 1) DFS(i, i);
    int ans = N;
    for(int i = 1; i <= N; i += 1)
        if(K % 2){
            for(int&j : G[i]) if(i < j){
                int pans = 0;
                for(int k = 1; k <= N; k += 1)
                    if(min(D[i][k], D[j][k]) > K / 2)
                        pans += 1;
                    ans = min(ans, pans);
            }
        }
        else{
            int pans = 0;
            for(int j = 1; j <= N; j += 1)
                if(D[i][j] > K / 2)
                    pans += 1;
            ans = min(ans, pans);
        }
    cout << ans;
    return 0; 
}

Measured memory_bytes: 16128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
//using ll = long long;
using ll = int64_t;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve(){
    int n;
    ll a, c = (1 << 30);

    cin >> n;
    rep(i, n){
        cin >> a;
        int temp = 0;
        while(a%2 == 0){
            a /= 2;
            temp++;
        }
        if(temp < c){
            c = temp;
        }
    }
    cout << c << endl;
}

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


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

int main() {
    using namespace std;


    long long N,K;
    long long A[100000];

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    std::sort(A,A+N);

    long long idxDuplicated[100000];

    idxDuplicated[0] = 0;
    int numDuplicated = 0;
    for (int i = 0; i < N; i++)
    {
        idxDuplicated[i] = 0;
        if (A[i] == A[i-1])
        {
            idxDuplicated[i] = 1;
            numDuplicated += 1;
        }
    }
    //this generates idxDuplicated sequence of 0 and 1
    //111 can be reduced to single 1
    //When 1 are even, all can be removed without loss
    if (numDuplicated % 2 == 1)
    {
        cout << (N - numDuplicated - 1) << endl;
    } else {
        cout << (N - numDuplicated) << endl;
    }
    //When 1 are odd, final one must remove one 0

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<stack>
#include<set>
#include<queue>
#include<algorithm>
using namespace std;
const long long mod=1000000007;
const long long max_=1000000000;
char ch[55][55];
int number[55][55];
int h,w;
int getn(int i,int j){
    int sum=0;
    int next[8][2]={1,0,1,1,1,-1,0,-1,0,1,-1,0,-1,-1,-1,1};
    for(int k=0;k<8;k++)
    {
        int x=i+next[k][0],y=j+next[k][1];
        if(x>=0&&x<h&&y>=0&&y<w&&ch[x][y]=='#')
            sum++;
    }
    return sum;
}
int main()
{
    cin>>h>>w;
     for(int i=0;i<h;i++)
        cin>>ch[i];
        memset(number,-1,sizeof(number));
        for(int i=0;i<h;i++)
            for(int j=0;j<w;j++)
        {
            if(ch[i][j]=='.')
                number[i][j]=getn(i,j);
        }
     for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(number[i][j]==-1)
                   cout<<"#";
                else cout<<number[i][j];}
                cout<<endl;
     }
	return 0;
}


Measured memory_bytes: 256
k, n = map(int, input().split())
A = list(map(int, input().split()))
big = 0

for i in range(n - 1):
    big = max(big, abs(A[i + 1] - A[i]))
b = (k - A[-1]) + A[0]
big = max(big, b)
print(k - big)





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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (s); i <= (t); ++i)
#define repD(i,t,s) for(int i = (t); i >= (s); --i)
#define rep(i,n) repU(i,0,n - 1)
#define rep1(i,n) repU(i,1,n)
#define all(v) begin(v),end(v)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1) / (d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = (1 << 30) - 1;
const ll INF_64 = (1LL << 62) - 1;
const int MOD = 1e9 + 7;

template<class Abel> struct UnionFind {
	vector<int> par;
	vector<int> size;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n) {
		init(n);
	}

	void init(int n) {
		par.resize(n);
		size.assign(n,1);
		rank.resize(n);
		diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i; 
	}

	int root(int x) {
		if (par[x] == x) {
			return x;
		} else { 
			int r = root(par[x]);
			size[x] = size[r];
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}
	
	int scale(int x) {
		return size[root(x)];
	}

	Abel weight(int x) {
		root(x);
		return diff_weight[x];
	} 

	Abel diff(int x, int y) {
		return weight(y) - weight(x);
	} 

	bool is_same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y, int w = 0) {
		w += weight(x);
		w -= weight(y);
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) {
			swap(x,y);
			w = -w;
		}
		if (rank[x] == rank[y]) ++rank[x];
		size[x] += size[y];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}
};

vector<tuple<int,int,int>> pr;
int ans[200010] = {};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,k,l,p,q; cin >> n >> k >> l; 
	UnionFind<int> uf1(n),uf2(n);
	pr.resize(n);
	rep(i,k){
		cin >> p >> q;
		uf1.merge(--p,--q);
	}
	rep(i,l){
		cin >> p >> q;
		uf2.merge(--p,--q);
	}
	rep(i,n) pr[i] = mkt(uf1.root(i),uf2.root(i),i);
	sort(all(pr));
	stack<int> s;
	rep(i,n){
		int j = i - 1;
		while(j + 1 < n && get<0>(pr[j + 1]) == get<0>(pr[i]) && get<1>(pr[j + 1]) == get<1>(pr[i])){
			s.push(get<2>(pr[++j]));
		}
		int t = s.size();
		while(!s.empty()){
			ans[s.top()] = t;
			s.pop();
		}
		i = j;
	}
	rep(i,n) cout << ans[i] << ' ';
	cout << endl;
}





Measured memory_bytes: 10112
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
string S;

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


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;

class Stack{
 
public:
    void push(int x){
        s.push_back(x);
    }
    
    int pop(){
        int v = s[s.size()-1];
        s.pop_back();
        return v;
    }
    
    bool isEmpty(){
        return s.empty();
    }
    
private:
    vector<int> s;
    
};

vector<string> devide(string s, char c){
    
    vector<string> r;
    
    unsigned long sn = s.length();
    
    string str = "";
    for(unsigned long i=0; i<sn; i++){
        if(s[i]==c){
            r.push_back(str);
            str = "";
        }else{
            str += s[i];
        }
    }
    
    r.push_back(str);
    
    return r;
    
}

int calcReversePolish(vector<string> list){
    
    Stack* stack = new Stack();
    
    unsigned long ln = list.size();
    for(unsigned long i=0; i<ln; i++){
        if(list[i]=="+"){
            int a = stack->pop();
            int b = stack->pop();
            stack->push(b+a);
        }else if(list[i]=="-"){
            int a = stack->pop();
            int b = stack->pop();
            stack->push(b-a);
        }else if(list[i]=="*"){
            int a = stack->pop();
            int b = stack->pop();
            stack->push(b*a);
        }else{
            stack->push(stoi(list[i]));
        }
    }
    
    int r = stack->pop();
    
    delete stack;
    
    return r;
    
}

int main() {
    
    string s;
    getline(cin,s);
    
    vector<string> list = devide(s, ' ');
    
    cout << calcReversePolish(list) << endl;
    
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        Console.ReadLine();
        string[] numbers = Console.ReadLine().Split(' ').ToArray();

        var hashset = new HashSet<string>();
        foreach (var num in numbers)
        {
            if (hashset.Add(num) == false)
            {
                Console.Write("NO");
                return;
            }
        }
        Console.Write("YES");
    }
}

Measured memory_bytes: 42960
#include<bits/stdc++.h>
using namespace std;
//<<setprecision(30)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  string s;
  cin>>s;
  int l =s.size();
  int res = 0;
  for(int i = 0; i < l/2; i++){
    if(s.at(i)!=s.at(l-1-i))res++;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<iostream> 
#include<cstdio> 
#include<cstring> 
#include<algorithm> 
#include<map> 
#define File(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
#define re register
#define ri re int
#define gtch() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#define For(i,a,b) for(ri i=a;i<=b;++i) 
#define iFor(i,a,b) for(ri i=a;i>=b;--i) 
using namespace std;
typedef long long ll;
char buf[1<<21],*p1=buf,*p2=buf;
inline ll fr()
{
	re char ch=getchar();re ll res=0;int bl=0;
	while(!isdigit(ch)) bl=(ch=='-'),ch=getchar();
	while(isdigit(ch)) res=(res<<1)+(res<<3)+ch-'0',ch=getchar();
	return bl?-res:res;
}
const int MAXN=100;
const int INF=9e8+5;
string s; 
signed main()
{
//	File("temp")
	cin>>s;
	cout<<s;
	if(s[s.size()-1]=='s')cout<<"es";
	else cout<<"s";
	return 0;
}

Measured memory_bytes: 3676
def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    i = 0
    d = [0, 0]
    while N - 1 > i:
        if A[i] == A[i + 1]:
            d.append(A[i])
            i += 1
        i += 1
    print(d[-1] * d[-2])


main()


Measured memory_bytes: 14252
from math import sqrt as r
from math import floor as f
X = int(input())
going = True

def judge(X):
    for i in range(3, f(r(X)) + 1, 2):
        if X % i == 0:
            return False
    return True

if X == 2 or X == 3:
    print(X)
    going = False
elif X % 2 == 0:
    X += 1

while going:
    if judge(X):
        print(X)
        break
    X += 2


Measured memory_bytes: 8924
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
#define INF int(1e9)

template<class T,class U> ostream& operator<<(ostream& ost, const pair<T,U> &p) { ost << "(" << p.first << ", " << p.second << ")"; return ost; }
#define ostream_container { ost << "{"; for(const auto &t : v) { if (&t != &*v.begin()) ost << ", "; ost << t; } ost << "}"; return ost; }
template<class T> ostream& operator<<(ostream &ost, const vector<T> &v) ostream_container
template<class T> ostream& operator<<(ostream &ost, const set<T> &v) ostream_container
template<class T,class U> ostream& operator<<(ostream &ost, const map<T,U> &v) ostream_container

template<class H> void recursive_debug(string s, H h) {
    cerr << "\033[33m" << s << " = " << h << endl << "\033[m";
}
template<class H,class... T> void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << "\033[33m" << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}
#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)


int main(void) {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    rep(i,n-k){
        cout << ((a[i] < a[i+k]) ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 4812
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
class Seg_Tree{
    private:
    int e=1000000007;
    int n;
    vector<int> node;
    public:
    int process(int left,int right){
        if(left==e)return right;
        if(right==e)return left;
        return left+right;
    }
    Seg_Tree(vector<int> v){
        int num=1;
        int size=v.size();
        while(num<size){
            num*=2;
        }
        n=num;
        node.resize(2*num-1,e);
        for(int i=0;i<size;i++)node[i+num-1]=v[i];
        for(int i=n-2;i>=0;i--)node[i]=process(node[i*2+1],node[i*2+2]);
    }
    void update(int x,int val){
        x+=(n-1);
        node[x]=val;
        while(x>0){
            x=(x-1)/2;
            node[x]=process(node[x*2+1],node[x*2+2]);
        }
    }
    int out(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(a>=r||b<=l)return e;
        if(a<=l&&b>=r)return node[k];
        int vl=out(a,b,k*2+1,l,(l+r)/2);
        int vr=out(a,b,k*2+2,(l+r)/2,r);
        return process(vl,vr);
    }
};
signed main(){  
  string s;cin>>s;
  int n=s.length();
  vector<vector<int>> memo(30);
  rep(i,30){
      memo[i].push_back(1);
  }
  vector<int> char_num(30,0);
  rep(i,n){
      memo[s[i]-'a'].push_back(i);
      char_num[s[i]-'a']+=1;
  }
  bool odd=false;
  char center='.';
  rep(i,30){
      if(char_num[i]%2==1){
          if(!odd){
              center='a'+i;
              odd=true;
          }
          else{
              cout<<-1<<"\n";
              return 0;
          }
      }
  }
  rep(i,30)char_num[i]/=2;
  vector<char> rear;
  int cnt=0;int cur=n-1;
  while(cnt<n/2){
      if(char_num[s[cur]-'a']>0){
          char_num[s[cur]-'a']--;
          ++cnt;
          rear.push_back(s[cur]);
      }
      --cur;
  }
  vector<char> all(rear);
  if(center!='.')all.push_back(center);
  reverse(ALL(rear));
  for(auto& val:rear)all.push_back(val);
  vector<int> hoge(n,0);
  lint res=0;
  Seg_Tree tree(vector<int>(n+10,0));
  rep(i,n){
      int buf=memo[all[i]-'a'][0];
      int pos=all[i]-'a';
      tree.update(memo[pos][buf],1);
      //cout<<res<<"\n";
      res+=tree.out(memo[pos][buf]+1,n+10);
      hoge[memo[pos][buf]]=i;
      memo[all[i]-'a'][0]+=1;
  }
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 8500
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,k,r,s,p,dp[N][3];
char t[N];
bool judge(char x,char y)
{
    return x=='r'&&y=='s'||x=='s'&&y=='p'||x=='p'&&y=='r';
}
int main()
{
    scanf("%d%d",&n,&k);
    scanf("%d%d%d",&r,&s,&p);
    scanf("%s",t+1);
    int ans=0;
    for(int i=1;i<=k;i++)
    {
        if(judge('r',t[i])) dp[i][0]=r;
        if(judge('s',t[i])) dp[i][1]=s;
        if(judge('p',t[i])) dp[i][2]=p;
        int res=max(dp[i][0],max(dp[i][1],dp[i][2]));
        for(int j=i+k;j<=n;j+=k)
        {
            dp[j][0]=max(dp[j-k][1],dp[j-k][2]);
            dp[j][1]=max(dp[j-k][0],dp[j-k][2]);
            dp[j][2]=max(dp[j-k][0],dp[j-k][1]);
            if(judge('r',t[j])) dp[j][0]+=r;
            if(judge('s',t[j])) dp[j][1]+=s;
            if(judge('p',t[j])) dp[j][2]+=p;
            res=max(max(res,dp[j][0]),max(dp[j][1],dp[j][2]));
        }
        ans+=res;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 1536
#include<stdio.h>
int main()
{
    int a,b,c,num;
    scanf("%d%d%d",&a,&b,&c);
    num=(a*100)+(b*10)+c;
    if(num%4==0)
		printf("YES\n");
	else
		printf("NO\n");
    return 0;
}

Measured memory_bytes: 1620
###
### atcorder test program
###

### math class
class math:
    ### pi
    pi = 3.14159265358979323846264338

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

math = math()

### input sample
#i = input()
#A, B, C = [x for x in i.split()]
#templist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))

while True:
    i = input()
    X, Y = [int(x) for x in i.split()]
    if X == 0:
        break
    for n in range(X):
        for m in range(Y):
            if n == 0 or n == X-1 or m == 0 or m == Y-1:
                print("#", end="")
            else:    
                print(".", end="")
        print("")
    print("")



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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  int64_t t, a;
  std::cin >> t >> a;
  int tRate, aRate;
  while (std::cin >> tRate >> aRate) {
    int64_t const factor =
        std::max((t + tRate - 1) / tRate, (a + aRate - 1) / aRate);
    t = factor * tRate;
    a = factor * aRate;
  }
  std::cout << t + a << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main(){
	ll n, dp[2][2300000]={0};
	bool a[25][25];
	vector<ll> bs[25];
	cin >> n;
	rep(i,0,n-1){
		rep(j,0,n-1){
			cin >> a[i][j];
		}
	}
	rep(i,0,(1<<n)-1){
		bs[__builtin_popcountll(i)].push_back(i);
	}
	dp[0][0] = 1;
	rep(i,1,n){
		for(auto bit: bs[i]){
			rep(j,0,n-1){
				if(!(bit & (1<<j))) continue;
				if(a[i-1][j]) dp[1][bit] = (dp[1][bit] + dp[0][bit & ~(1<<j)]) % mod;
			}
		}
		rep(j,0,(1<<n)-1){
			dp[0][j] = dp[1][j];
			dp[1][j] = 0;
		}
	}
	cout << dp[0][(1<<n)-1] << endl;
    return 0;
}


Measured memory_bytes: 60964
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++) if(s[i] == '?') s[i] = 'D';
	cout << s;
	return 0;
}


Measured memory_bytes: 3748
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    const INF: i64 = 1e18 as i64;
    let s = A.iter().sum::<i64>();
    let (ans, _) = A[1..].iter().fold((INF, A[0]), |(res, acc), &a| {
        (std::cmp::min(res, (s - 2 * acc).abs()), acc + a)
    });

    println!("{}", ans);
}


Measured memory_bytes: 10492
import collections

N = int(input())
A = list(map(int,input().split()))

nums = []
roll = [-1,0,1]

for i in range(N):
  for j in range(3):
    d = A[i] + roll[j]
    nums.append(d)

num = collections.Counter(nums).most_common()
print(num[0][1])

Measured memory_bytes: 34012
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N, Y;
    cin >> N >> Y;
    Y /= 1000;

    int x, y, z;
    bool found = false;
    for (x = MIN(Y / 10, N); x >= 0; --x)
    {
        for (y = MIN((Y - x * 10) / 5, N - x); y >= 0; --y)
        {
            z = N - x - y;
            if (z < 0) break;
            if (x * 10 + y * 5 + z == Y)
            {
                found = true;
            }
            if (found) break;
        }
        if (found) break;
    }

    if (!found) x = y = z = -1;
    cout << x << " " << y << " " << z << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include <string>
#include<map>

using namespace std;

int main(void) {
	int dataNum;
	cin >> dataNum;
	map<int, int> data;
	int num, point;

	for (int i = 0; i < dataNum; i++) {
		cin >> num >> point;
		data[num] = point;
	}

	auto itr = data.end();
	itr--;
	num = itr->first;
	point = itr->second;

	cout << num + point << endl;


	return 0;
}

Measured memory_bytes: 4992
from math import gcd
MOD = 10 ** 9 + 7
N = int(input())
d = dict()
zeros = 0
a_zeros = 0
b_zeros = 0
for _ in range(N):
    a, b = tuple(map(int, input().split()))
    if not any((a, b)):
        zeros += 1
        continue
    if not a:
        a_zeros += 1
        continue
    if not b:
        b_zeros += 1
        continue
    g = gcd(a, b) * (a // abs(a))
    p = a // g, b // g
    d[p] = d.get(p, 0) + 1
counts = dict()
for k, v in d.items():
    a, b = k
    if counts.get((b, -a), False) or counts.get((-b, a), False):
        continue
    counts[k] = v, d.get((b, -a), 0) + d.get((-b, a), 0)
total = 1
for k, v in counts.items():
    a, b = v
    total = (total * (pow(2, a, MOD) + pow(2, b, MOD) - 1)) % MOD
total = (total * (pow(2, a_zeros, MOD) + pow(2, b_zeros, MOD) - 1)) % MOD
print((total + zeros + MOD - 1) % MOD)

Measured memory_bytes: 77344
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
#define el '\n'
template<class T> bool rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
typedef long long ll; typedef long double ld; typedef double dd; typedef pair<int, int> pii;
const ll INFLL=0x7f7f7f7f7f7f7f7f, MOD=1e9+9; const int INF=0x7f7f7f7f;

//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';

/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vv<int> vis, color; 
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){if(a<0) a=-a; if(b<0) b=-b; while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}


///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());


int n,m;
cin>>n>>m;
vv<int> b(m,0);
for(int i=0;i<m;++i){
	int k; cin>>k;
	while(k--){
		int t; cin>>t;
		--t;
		b[i]|=(1<<t);
	}
}
auto pops=[](int t){
	int ret=0;
	while(t) ret++,t-=t&-t;
	return ret;
};
vv<bool> p(m);
for(int i=0;i<m;++i) {int t; cin>>t; p[i]=t;}
int ans=0;
for(int i=0;i<(1<<n);++i){
	int l=0;
	for(int j=0;j<m;++j){
		if(pops(i&b[j])%2==p[j]) ++l;
	}
	if(l==m) ++ans;
}
cout<<ans<<el;


return 0;
}


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

using namespace std;

int main() {
	int q;
	cin >> q;
	int count = 0, indexfirst = -1, indexlast = -1;
	vector<int> ar;
	for (int i = 0; i < q; i++) {
		int input;
		cin >> input;
		ar.push_back(input);
		if (i > 0) {
			if (ar[i] < ar[i - 1]) {
				if (indexfirst == -1) {
					indexfirst = (i - 1);
				}
				else {
					indexlast = i;
				}
				count++;
			}
		}
		if (count > 2) {
			break;
		}
	}
	if ((count == 2 && indexfirst != -1 && indexlast != -1 && ar[indexfirst] > ar[indexlast - 1] && ar[indexlast] < ar[indexfirst + 1]) || count == 0) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

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

int N;

struct Point
{
	double x, y;
};
Point operator -(Point a, Point b) {return (Point) {a.x - b.x, a.y - b.y};}
double norm(Point a) {return a.x * a.x + a.y * a.y;}
double abs(Point a) {return sqrt(norm(a));}
Point p[80050];

double ConvexHull(Point * p, int n)
{
	double res = -1;
	for(int i = 0, k = 0; i < n; i++)
	{
		while(norm(p[i] - p[k]) < norm(p[i] - p[(k + 1) % n])) k = (k + 1) % n;
		res = max(res, abs(p[i] - p[k]));
	}
	return res;
}

int main()
{
	scanf("%d", &N);
	for(int i = 0; i < N; i++)
	{
		scanf("%lf%lf", &p[i].x, &p[i].y);
	}
	printf("%.12lf\n", ConvexHull(p, N));
	return 0;
}


Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
bool sme(string s){
    bool ans =true;
    fo(j,s.size()){
        if(s[j]!=s[0]){ans =false;break;}
    }
    return ans;
}
int main(){
    string s;cin >>s;
    int n =s.size(),minc;
    fo(k,26){
        int cnt = 0;
        string p =s;
        char cur(97+k);
        while(!sme(p)){
            tr(it,p){
                if(*it==cur||*(it+1)==cur){
                    *it = cur;
                }
            }
            p.resize(p.size()-1);           
            ++cnt;
        }
        if(k==0){
            minc = cnt;
        }
        else{
            (cnt<minc)?minc =cnt:minc =minc;
        }
    }
    cout << minc;
}

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

int main(void){
    int n;
    cin >> n;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {

	int n, a;
	
	scanf("%d", &n);
	
	a = n % 10;
	
	if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9 )
		printf("hon");
	else if(a == 0 || a == 1 || a == 6 || a == 8)
		printf("pon");
	else if(a == 3)
		printf("bon");

	return 0;
}

Measured memory_bytes: 1728
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
inline void solve(void){
  int A,B,C,D;
  in(A,B,C,D);
  while(1){
    C-=B;
    if(C<=0){
      out("Yes");
      return;
    }
    A-=D;
    if(A<=0){
      out("No");
      return;
    }
  }
}
int main(void){
  BEGIN;
  solve();
  END;
}


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

int main() {
  int N;
  cin >> N;
  int s = 0, n = N;
  rep(i, 8) {
    s += n % 10;
    n /= 10;
    if (n == 0) {
      break;
    }
  }
  if (N % s == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,a,mx,mi=1000000000;

main() {
    cin >> n;
    rep(i,n) {
        cin >> a;
        mi = min(mi,a);
        mx = max(mx,a);
    }
    ct(mx-mi)
}




Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 0;
        for(int i = a;i<=b;i++){
            if(c%i == 0)
                count++;
        }
        sc.close();
        System.out.println(count);
    }
}


Measured memory_bytes: 26336