akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string A1 = Console.ReadLine();
            string A2 = Console.ReadLine();
            string A3 = Console.ReadLine();
            string A4 = Console.ReadLine();
            string A5 = Console.ReadLine();
            string A6 = Console.ReadLine();
            string A7 = Console.ReadLine();
            string A8 = Console.ReadLine();
            string A9 = Console.ReadLine();
            string A10 = Console.ReadLine();
            int a1 = int.Parse(A1);
            int a2 = int.Parse(A2);
            int a3 = int.Parse(A3);
            int a4 = int.Parse(A4);
            int a5 = int.Parse(A5);
            int a6 = int.Parse(A6);
            int a7 = int.Parse(A7);
            int a8 = int.Parse(A8);
            int a9 = int.Parse(A9);
            int a10 = int.Parse(A10);
            
            var A = new List<int>();
            A.Add(a1);
            A.Add(a2);
            A.Add(a3);
            A.Add(a4);
            A.Add(a5);
            A.Add(a6);
            A.Add(a7);
            A.Add(a8);
            A.Add(a9);
            A.Add(a10);
            A.Sort();
            Console.WriteLine(A[9]);
            Console.WriteLine(A[8]);
            Console.WriteLine(A[7]);
            Console.ReadKey();
        }
    }
}

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


int main() {

  int n;
  cin >> n;

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

  int q;
  cin >> q;

  while(0 < q) {

    int com, b, e;
    cin >> com >> b >> e;

    long long ans = 1LL<<60;
    if (com == 1) {
      ans = 0 - ans;
    }

    for (int i = b; i < e; i++) {
      if (com == 0) {
        ans = min(ans, (long long) a[i]);
      } else {
        ans = max(ans, (long long) a[i]);
      }
    }

    cout << ans << endl;

    q--;

  }
  
  return 0;

}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long double PI = 3.14159265358979323846;
const int maxSize = 2e5 + 3;

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

    ll a, b, n, x;
    cin >> a >> b >> n;
    x = min(b - 1, n);
    cout << (a * x / b) - a * (x / b) << '\n';

    return 0;
}


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

using namespace std;

const int MX = 200005;

template <typename T> void cmin(T &x, const T &y)
{
	if(y < x) x = y;
}

template <typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int val[MX];
int n, m, cur_ans;

void input()
{
	read(n), read(m);
	for(int i=1; i<=n*2; i++) read(val[i]);
}

bool check(int k)
{
	cur_ans = 0;
	for(int i=1; i<=k; i++)
	{
		int sum = val[n*2-k-i+1]+val[n*2-k+i]-m;
		if(sum < 0) return false;
		else cmax(cur_ans, sum);
	}
	for(int i=1; i<=n-k; i++)
		cmax(cur_ans, val[i]+val[n*2-k*2-i+1]);
	return true;
}

void work()
{
	sort(val+1, val+n*2+1);
	int l = 0, r = n, mid, ans = 0;
	while(l < r)
	{
		mid = (l+r+1)/2;
		if(check(mid)) ans = l = mid;
		else ans = r = mid-1;
	}
	check(ans);
	printf("%d\n", cur_ans);
}

int main()
{
	input();
	work();
	return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#define typeof(x) __typeof__(x)
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define ceil(x,m) ((x)+(m)-1)/(m)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) { s << v[i]; if (i < len - 1) s << " "; }
  s << "]";
  return s;
}

signed main()
{
  int n; cin >> n;
  vec<int> v(n);
  rep(i, 0, n) {
    cin >> v[i];
  }

  const int MAX_V = 1e5+1;
  vec< vec<int> > num(2, vec<int>(MAX_V,0));

  rep(i, 0, n/2) {
    num[0][v[2*i  ]]++;
    num[1][v[2*i+1]]++;
  }

  rep(i, 0, MAX_V) {
    num[0][i] = max(num[0][i], num[1][i]);
  }
  RSORT(num[0]);

  int ans = n - num[0][0] - num[0][1];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef pair<int,int> pii;
typedef vector<int> vi;
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){

  int n,m,p;
  cin>> n>> m>> p;
  vi d(m);
  for(int i=0;i<m;i++){
    cin>> d[i];
    d[i]=(d[i]-p+n)%n;
  }

  sort(d.begin(),d.end());
  int ret=min(n-d[0],d[m-1]);
  for(int i=0;i<m;i++){
    if(i) ret=min(ret,2*(n-d[i])+d[i-1]);
    if(i<m-1) ret=min(ret,2*d[i]+n-d[i+1]);
  }

  cout<< ret*100<< endl;
}

Measured memory_bytes: 1256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

x=II()
print(10-x//200)


Measured memory_bytes: 9204
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int maxn=20000050;
map<int ,int> a; 
int main()
{
	int n,x,m,y;
	ll ans=0;
	cin>>n;
	for(int i=1;i<=n;++i)
	  {
	  	  cin>>x;
	  	  a[x]++;
	  	  ans+=x;
	  }
	cin>>m;
	for(int i=1;i<=m;++i)
	  {
	  	  cin>>x>>y;
	  	  ans+=(y-x)*a[x];
	  	  a[y]+=a[x];a[x]=0;
	  	  cout<<ans<<endl;
	  }  
	  
}


Measured memory_bytes: 7996
#include <bits/stdc++.h>
          
using namespace std;
          
typedef long long ll;
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define db long double

int n;
char a[603][603];

const int p = 37;
const int mod = (int)1e9 + 7;

int h1[603][603];
int h2[603][603];
int pref[603];

int main(){
  //  freopen("input.txt", "r", stdin);
    //freopen("output1.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++){
    	for (int j = 1; j <= n; j++){
    		cin >> a[i][j];
    		a[i + n][j] = a[i][j];
    		a[i][n + j] = a[i][j];
    		a[i + n][j + n] = a[i][j];
    	}
    }
    int ans = 0;

    for (int i = 1; i <= 2 * n; i++){
    	for (int j = 1; j <= 2 * n; j++){
    		h1[i][j] = ((ll)h1[i][j - 1] * p + a[i][j] - 'a' + 1) % mod;
    	}
    }
    for (int j = 1; j <= 2 * n; j++){
    	for (int i = 1; i <= 2 * n; i++){
    		h2[i][j] = ((ll)h2[i - 1][j] * p + a[i][j] - 'a' + 1) % mod;
    	}
    }

    pref[0] = 1;
    for (int i = 1; i < 603; i++) pref[i] = pref[i - 1] * (ll)p % mod;

    for (int i = 1; i <= n; i++){
    	for (int j = 1; j <= n; j++){
    		int dd = n - 1;
    		int ok = 1;
    		for (int s = 0; s < n; s++){
    			if (dd){
    				int val1 = (h1[i + s][j + s + dd] - h1[i + s][j + s] * (ll)pref[dd]) % mod;
    				if (val1 < 0) val1 += mod;
    				int val2 = (h2[i + s + dd][j + s] - h2[i + s][j + s] * (ll)pref[dd]) % mod;
    				if (val2 < 0) val2 += mod;

    				if (val1 != val2){
    					ok = 0;
    					break;
    				}
    			}
    			dd--;
    		}
    		ans += ok;
    	}
    }

    cout << ans;
}

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

#define lli long long int
#define pb push_back
#define f first
#define sec second

lli dp[3001][3001], arr[3001];

lli solve(lli start, lli end)
{
    lli a,b,i,j;
    if(start>end)
    {
        return 0;
    }

    if(dp[start][end] != 0)
    {
        return dp[start][end];
    }
    a = arr[start] + min(solve(start+1,end-1) ,solve(start+2,end));
    b = arr[end] + min(solve(start,end-2), solve(start+1,end-1) );

    dp[start][end] = max(a,b);

    return (dp[start][end]);
}

main()
{
    lli n,i,a,t,b,c,j,k,x,y,sum=0;

    cin>>n;

    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        sum += arr[i];
    }

    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            dp[i][j] = 0;
        }
        dp[i][i] = arr[i];
    }
    for(i=0;i<n-1;i++)
    {
        dp[i][i+1] = max(arr[i],arr[i+1]);
    }

    a = solve(0,n-1);
    sum -= a;
    a -= sum;

    cout<<a;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;



int main() {
    int n;
    scanf("%d", &n);
    vector<int> even(100009), odd(100009);
    rp(i, 0, n/2) {
        int noweven, nowodd;
        scanf("%d%d", &noweven, &nowodd);
        even.at(noweven) ++;
        odd.at(nowodd) ++;
    }
    int ans = 0;
    int a = max_element(even.begin(), even.end()) - even.begin();
    int b = max_element(odd.begin(), odd.end()) - odd.begin();
    if (a != b) {
        ans += even.at(a) + odd.at(b);
    } else {
        int x = even.at(a);
        int y = odd.at(b);
        even.at(a) = 0;
        odd.at(b) = 0;
        int c = *max_element(even.begin(), even.end());
        int d = *max_element(odd.begin(), odd.end());
        ans = max(x+d, y+c);
    }
    printf("%d", n - ans);
} 

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

vector<int> ans;

int main(){
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		int a[1000];
		for(int i = 0;i < n;i++){
			cin >> a[i];
		}
		sort(a,a+n);
		int minn = 1e9;
		for(int i = 0;i < n-1;i++){
			int dif = abs(a[i] - a[i+1]);
			minn = min(minn,dif);
		}
		ans.push_back(minn);
	}
	for(int i = 0;i < ans.size();i++)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3108
#include<cstdio>
#include<algorithm>
using namespace std;
int a[100005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	int ans=0;
	int s=1;
	for(int i=0;i<n;i++){
		if (a[i+1]==a[i]){
			s++;
		}
		else{
			if (s%2==1) ans++;
			s=1;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 512
import math
s = input().split()
a = int(s[0])
b = int(s[1])
x = int(s[2])
if x < a**2*b/2:
    deg = math.degrees(math.atan2(a*b**2, 2*x))
else:
    deg = math.degrees(math.atan2(2*a**2*b-2*x, a**3))
print(deg)

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

int n;

void CountingSort(int A[],int B[],int k){
  int C[k+1];
  int i,j;
  for(i=0;i<k+1;i++){
    C[i] = 0;
  }
  for(i=1;i<=n;i++){
    C[A[i]]++;
  }
  for(i=1;i<k+1;i++){
    C[i] = C[i] + C[i-1];
  }
  for(j=n;j>0;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}

int main(){
  int i,max = -100000;
  int *A,*B;

  scanf("%d",&n);
  A = malloc(sizeof(int)*(n+1));
  B = malloc(sizeof(int)*(n+1));

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(max<A[i])max = A[i];
  }
  CountingSort(A,B,max);

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i<n)printf(" ");
  }
  puts("");
  free(A);
  free(B);

  return 0;
}

Measured memory_bytes: 16124
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define MaxN 100000+100
int a[MaxN];
int b[MaxN];
int main()
{
	int N;
	int len=0;
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==i)
			b[len++]=i;
	}
	int now=0;
	int sum=0;
	while(now<len)
	{
		int end=now;
		while(b[end+1]==b[end]+1 && end<len)
			end++;
		sum+=(end-now+1)/2+(end-now+1)%2;
		now=end+1;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 896
(let ((x (read))
      (y (read)))
  (format t "~A~%"
          (if (and (<= 1 x 100)
                   (<= 1 y 100)
                   (evenp y)
                   (<= (* 2 x)
                       y
                       (* 4 x)))
              "Yes"
              "No")))


Measured memory_bytes: 24196
n, m = map(int, input().split())

sc = []
flag = 1

for i in range(m):
  if flag != 1:
    break
  s, c = map(int, input().split())
  for x in sc:
    if s == x[0] and c != x[1]:
      flag = 0
      break
  sc.append((s,c))
  
if n != 1 and (1, 0) in sc:
  flag = 0
            
sc = list(set(sc))
ans = 0

for x in sc:
  ans += x[1] * (10 ** (n - x[0]))
  
if flag == 0:
  print(-1)
elif n > 1 and ans < 10 ** (n-1):
  print(ans + 10 ** (n-1))
elif flag == 1:
  print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
//C - Monsters Battle Royale
int main(void){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        int ai;
        std::cin >> ai;
        a[i]=ai;
    }
    int x=a[0],y=a[1],r;
    for(int i=1;i<n;i++){
        if(x<y)swap(x,y);
        while((r=x%y)!=0){
            x=y;
            y=r;
        }
        x=a[i];
    }
    std::cout << y << std::endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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 gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n,m; cin >> n >> m;
  vi a(n), b(n);
  vvi G(100001);
  rep(i, n){
    cin >> a[i] >> b[i];
    G[a[i]].push_back(b[i]);
  }

  int ans = 0;
  priority_queue<int> q;
  for (int i = 1; i < m+1; i++) {
    if(G[i].size() > 0){
      for(int j : G[i]) q.push(j);
    }
    if(q.size() > 0){
      ans += q.top();
      q.pop();
    }
  }

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


Measured memory_bytes: 6400
#include <iostream>
#include <stdio.h>
#include <queue>
#include <vector>

int main() {
  int q;
  scanf("%d", &q);
  std::priority_queue<long long, std::vector<long long>, std::less<long long>> first_heap;
  std::priority_queue<long long, std::vector<long long>, std::greater<long long>> second_heap;
  long long sum = 0, first_sum = 0, second_sum = 0;
  while (q--) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
        long long a, b;
        scanf("%lld%lld", &a, &b);
        sum += b;
        if (first_heap.empty() || first_heap.top() >= a) {
          first_heap.push(a);
          first_sum += a;
        } else {
          second_heap.push(a);
          second_sum += a;
        }
        if (first_heap.size() > second_heap.size() + 1) {
            first_sum -= first_heap.top();
            second_sum += first_heap.top();
            second_heap.push(first_heap.top());
            first_heap.pop();
        } else if (second_heap.size() > first_heap.size()) {
            first_sum += second_heap.top();
            second_sum -= second_heap.top();
            first_heap.push(second_heap.top());
            second_heap.pop();
        }
    } else {
        long long ans = sum, value = first_heap.top();
        ans = ans - first_sum + second_sum;
        if (first_heap.size() != second_heap.size()) {
            ans += first_heap.top();
        }
        printf("%lld %lld\n", first_heap.top(), ans);
    }
  }
  return 0;
}


Measured memory_bytes: 3828
#include<stdio.h>

int main(void){
    int a,b,ans;
    char op;

    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '?')
            break;
        else if(op == '+')
            ans = a + b;
        else if(op == '-')
            ans = a - b;
        else if(op == '*')
            ans = a * b;
        else
            ans = a / b;
        printf("%d\n",ans);
    }

    return 0;
}


Measured memory_bytes: 2104
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		
		int ans = 0;
		if(s == null || s.isEmpty() || s.length() == 1) {
			ans = 0;
		} else {
			char[] org = s.toCharArray();
			char[] temp = Arrays.copyOf(org, org.length);
			
			for(int i = 1; i < temp.length; i++) {
				if(temp[i - 1] == temp[i]) {
					temp[i]= changeValue(temp[i]);
					ans++;
				}
			}
			
		}
		
		String reString = "" + ans;
		System.out.println(reString);
	}
	public static char changeValue(char value) {
		if (value == '0') return '1';
		if (value == '1') return '0';
		return '0';
	}
}

Measured memory_bytes: 29748
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int P[1010];
ll Q[2010];

int f(int n) {
	if (P[n] == n) return n;
	int m = f(P[n]);
	P[n] = m;
	return m;
}

void unite(int a, int b) {
	int A = f(a);
	int B = f(b);
	if (A != B) {
		P[A] = B;
	}
	return;
}

struct edge {
	int u;
	int v;
	ll w;
};

bool operator < (edge a, edge b) {
	return a.w < b.w;
}

ll MOD = 1E9 + 7;

ll power(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
			res %= MOD;
		}
		a *= a;
		a %= MOD;
		b /= 2;
	}
	return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    ll X;
    cin >> N >> M >> X;
    vector<edge> E, F;
    for (int i = 0;i < M;i++) {
    	int u, v, w;
    	cin >> u >> v >> w;
    	edge e;
    	e.u = u;
    	e.v = v;
    	e.w = w;
    	E.push_back(e);
    }
    sort(E.begin(), E.end());
    for (int i = 0;i < M;i++) {
    	for (int j = 1;j <= N;j++) P[j] = j;
    	ll tol = E[i].w;
        unite(E[i].u, E[i].v);
        for (int j = 0;j < M;j++) {
        	if (j == i) continue;
        	if (f(E[j].u) != f(E[j].v)) {
        		tol += E[j].w;
        		unite(E[j].u, E[j].v);
        	}
        }
        Q[i] = tol;
    }
    ll sm = 0, eq = 0, lg = 0;
    for (int i = 0;i < M;i++) {
    	if (Q[i] < X) sm++;
    	if (Q[i] == X) eq++;
    	if (Q[i] > X) lg++;
    }
    if (eq == 0) {
    	cout << 0 << endl;
    	return 0;
    }
    ll res = 1;
    if (sm > 0) res *= 2;
    res *= power(2, lg);
    res %= MOD;
    ll cr = power(2, eq);
    if (sm == 0) cr += MOD - 2;
    else cr += MOD - 1;
    cr %= MOD;
    res *= cr;
    res %= MOD;
    cout << res << endl;
    return 0;
}

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

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

    int order = floor(log10(n) + 1);
    int num = n;
    int sn = 0;
    for (int i = 0; i < order; i++) {
        sn += num % 10;
        num /= 10;
    }

    if (n % sn == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
main () {
	int n,k=1,ans=0;
	cin>>n;
	for (int i=1; i<=n; i++) {
		int x;
		cin>>x;
		if (x==k) k++;
			else ans++;
	}
	if (ans==n) ans=-1;
	cout<<ans<<endl;
}

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

constexpr long long int mod = 1e9 + 7;

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

	vector<int> vec(60);
	for (int i = 0; i < n; i++) {
		long long int x;
		cin >> x;
		bitset<60> bs(x);
		for (int j = 0; j < 60; j++) {
			if (bs[j]) {
				vec.at(j)++;
			}
		}
	}

	long long int sum = 0;
	long long int base = 1;
	for (int i = 0; i < 60; i++) {
		sum += (base * (n - vec.at(i))) % mod * vec.at(i) % mod;
		sum %= mod;
		base *= 2;
		base %= mod;
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn chmin<T>(x: &mut T, y: T) -> bool
where
    T: PartialOrd + Copy,
{
    *x > y && {
        *x = y;
        true
    }
}

#[allow(dead_code)]
fn chmax<T>(x: &mut T, y: T) -> bool
where
    T: PartialOrd + Copy,
{
    *x < y && {
        *x = y;
        true
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:usize,d:usize
    }
    let d2 = d * 2 + 1;
    let mut ans = 1;
    loop {
        if ans * d2 >= n {
            println!("{}", ans);
            break;
        }
        ans += 1;
    }
}


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

int main()
{
ll n , k ;
cin >> n >> k ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
  a[i]%=k;
}
vector<ll> sum;
sum.push_back(0);
rep(i, n)
{
  sum.push_back(a[i] + sum[i]);
}
rep(i,n+1){
  sum[i]-=i;
}
rep(i,n+1){
  sum[i]%=k;
  sum[i]+=k;
  sum[i]%=k;
}
map<ll,ll> m;
rep(i,k-1){
  if(i>=n+1)break;
  m[sum[i]]++;
  ans+=m[sum[i]]-1;
}
for (ll i = k-1; i < n+1; i++)
{
  m[sum[i]]++;
  ans+=m[sum[i]]-1;
  m[sum[i-k+1]]--;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 16356
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>

using namespace std;

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

  vector<int> X(N);
  int sum_x = 0;
  for (int i = 0; i < N; ++i)
  {
    cin >> X[i];
    sum_x += X[i];
  }
  int ave_up   = ceil (sum_x / (float)N), ave_down = floor(sum_x / (float)N);
  int sum_up = 0, sum_down = 0;

  for (int i = 0; i < N; ++i)
  {
    sum_up   += (X[i] - ave_up)  *(X[i] - ave_up);
    sum_down += (X[i] - ave_down)*(X[i] - ave_down);
  }

  int min_sum = sum_up > sum_down ? sum_down : sum_up;

  cout << min_sum << endl;
}

Measured memory_bytes: 256
n=int(input())

flag,length=0,0
for i in range(1,10**3):
    if n==i*(i+1)//2:
        flag,length=1,i
        break
if not flag:print("No");exit()

A=[]
for i,j in enumerate(range(1,length+1)):
    num=j*(j+1)//2
    B=[]
    for k in range(i):
        B.append(num-(k+1))
    point=i+1
    B.append(num)
    for k in range(length-(i+1)):
        B.append(B[-1]+point)
        point +=1
    A.append(B)
A.append([i*(i+1)//2 for i in range(1,length+1)])

print("Yes")
print(len(A))
for i in A:
    print(length,*i)

Measured memory_bytes: 47452
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <time.h>

using namespace std;
typedef long long int ll;

int main()
{
	int n;
	scanf("%d", &n);
	int a1=0, a2=n/2, e1, e2;
	printf("%d\n", 0);
	fflush(stdout);
	string str;
	cin>>str;
	if(str=="Vacant") return 0;
	if(str=="Male"){
		e1=0;
	}else{
		e1=1;
	}
	printf("%d\n", n/2);
	fflush(stdout);
	cin>>str;
	if(str=="Vacant") return 0;
	if(str=="Male"){
		e2=0;
	}else{
		e2=1;
	}
	if((e1==e2 && (a2-a1)%2==0) || (e1!=e2 && (a2-a1)%2!=0)){
		a1=n;
	}
	while(1){
		int amid=(a1+a2)/2;
		printf("%d\n", amid);
		fflush(stdout);
		string str;
		cin>>str;
		int e;
		if(str=="Vacant") return 0;
		if(str=="Male"){
			e=0;
		}else{
			e=1;
		}
		if((e==e1 && (amid-a1)%2!=0) || (e!=e1 && (amid-a1)%2==0)){
			a2=amid;
			e2=e;
		}else{
			a1=amid;
			e1=e;
		}
	}
	return 0;
}

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

#define foreach(i,v) for(auto&& i: v)
#define all(x) (x).begin(), (x).end()

typedef std::vector< std::string > VS;
typedef std::vector<int> VI;
typedef long long ll;

template <class C> C& mini(C& a, C b) { if (b < a) a = b; return a; }
template <class C> C& maxi(C& a, C b) { if (a < b) a = b; return a; }

using namespace std;

template <typename T> void read(T& x) { x.read(); }
template <typename T> void read(vector<T>& v) { for (T& x: v) read(x); }
template <typename X, typename Y> void read(pair<X, Y>& p) { read(p.first); read(p.second); }
template <> void read(int& x) { scanf("%d", &x); }
template <> void read(unsigned int& x) { scanf("%u", &x); }
template <> void read(long long& x) { scanf("%lld", &x); }
template <> void read(unsigned long long& x) { scanf("%llu", &x); }
template <typename T> void readv(vector<T>& v) { int N; read(N); v.resize(N); read(v); }
template <typename T, typename ...Ts> void read(T& x, Ts&... args) { read(x); read(args...); }

int main(int argc, const char* argv[]) {
    vector<ll> A;
    readv(A);
    foreach(a, A)
        a *= 2;
    ll b = 0;
    ll s = 1;
    foreach(a, A) {
        b += a * s;
        s = -s;
    }

    vector<ll> B;
    B.reserve(A.size());
    B.push_back(b/2);
    for (int i = 0; i < A.size()-1; i++)
        B.push_back(A[i] - B.back());

    foreach(b, B)
        printf("%lld ", b);
    printf("\n");

    return 0;
}


Measured memory_bytes: 2944
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
long long x[200002],d[200002],c[200002];

int lis(int n){
	int i,j,I;
/*
	for(i=-1;I=0,++i<n;d[i]=I+1)
		for(j=i-1;~j;j--)
			if(x[j]<x[i]&&I<d[j])I=d[j];
*/
	// http://stackoverflow.com/questions/6129682/longest-increasing-subsequenceonlogn
	int sz = 1;
	c[1] = x[0];
	d[0] = 1;
	for(i=0;++i<n;){
		if(x[i] < c[1]){
			c[1] = x[i];
			d[i] = 1;
		}else if(x[i] > c[sz]){
			c[sz+1] = x[i];
			d[i] = sz+1;
			sz++;
		}else{
			int k = lower_bound(c,c+sz,x[i])-c;
			c[k] = x[i];
			d[i] = k;
		}
	}
	for(i=j=0;i<n;i++)
		if(d[i]>d[j])j=i;
	return d[j];
}

int main(){
	long long x1,y1,x2,y2;
	int n,xf=1,yf=1;
	scanf("%lld%lld%lld%lld%d",&x1,&y1,&x2,&y2,&n);
	if(x1>x2)swap(x1,x2),xf=-1;
	if(y1>y2)swap(y1,y2),yf=-1;
	vector<pair<long long,long long>>v;
	for(int i=0;i<n;i++){
		long long x,y;
		scanf("%lld%lld",&x,&y);
		if(x1<=x&&x<=x2 && y1<=y&&y<=y2)v.emplace_back(x*xf,y*yf);
	}
	sort(v.begin(),v.end());
	n=0;
	for(auto &e:v)x[n++]=e.second;
	n=n?lis(n):0;
	printf("%.15f\n",100LL*(x2-x1+y2-y1)-20*n+5*(n+(n>=min(x2-x1,y2-y1)+1))*3.14159265358979323846);
}

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

void Main()
{
    string s, t;
    cin >> s >> t;
    int ans = 10000;
    for (int i = 0; i < s.size()-t.size()+1; i++)
    {
        int ne = 0;
        for (int j = 0; j < t.size(); j++)
        {
            if (s[i+j] != t[j]) ne++;
        }
        ans = min(ans, ne);
    }
    
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
  if(a == 0) return b;
  if(b == 0) return a;
  return gcd(b,a%b);
}
ll fac(ll n) {
  int ct = 0;
  for(ll i=2;i*i<=n;i++) {
    if(!(n%i)) {
      ct++;
    	while(!(n%i)) {n /= i;}
    }                 
  }
  if(n > 1) {ct++;}
  return ct+1;
}
int main() {
  ll a,b;
  cin >> a >> b;
  cout << fac(gcd(a,b)) << '\n';
}

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

int main() {
  ll h,ans=0;
  cin >> h;
  if (h == 1) { cout << 1 << endl; return 0; }
  ll height = log2(h);
  REP(i,height+1) { ans += pow(2,i); }
  cout << ans << endl;
}

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

public class Main {

	public static void main(String[] args) {
	
		Scanner in = new Scanner(System.in);
		int counter= 0;
		int n = in.nextInt();
		int[] ara = new int[n];
		int[] temp_array = new int[n];
		
		for(int i = 0;i<ara.length;i++) {
			ara[i] = in.nextInt();
			temp_array[i] = ara[i];
		}
		Arrays.sort(temp_array);
		
		
		for(int i = 0;i<ara.length;i++) {
			if(temp_array[i] != ara[i]) {
			 counter++;
			}
		}
	
		
		if(counter<=2) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		

	}

}


Measured memory_bytes: 27084
#include<cstdio>

int main(){
	int dice[6];
	int pre[6];
	int pt[5][6] = {	{5,1,3,4,6,2}, 
				 	{0,0,0,0,0,0},
					{4,2,1,6,5,3},
					{2,6,3,4,1,5},
					{3,2,6,1,5,4}};
	char c;
	scanf("%d %d %d %d %d %d", &dice[0], &dice[1], &dice[2], &dice[3], &dice[4], &dice[5]);
	scanf("%c", &c);
	scanf("%c", &c);
	int x;
	while(c - 10){
		for(int i = 0; i < 6; i++){
			pre[i] = dice[i];
		}
		for(int i = 0; i < 6; i++){
			x = pt[(c - 3) % 8][i];
			dice[i] = pre[x - 1];
		}
		scanf("%c", &c);
	}
	printf("%d\n", dice[0]);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
//#define MD 1
#define MD 1000000007
 
int main(){
    int d,n;
    cin>>d>>n;
    if(d==0){
        if(n==100){
            cout<<101<<endl;
        }else{
        cout<<n<<endl;
        }
    }else if(d==1){
        if(n==100){
            cout<<10100<<endl;
        }else{
            cout<<n*100<<endl;
        }
    }else{
        if(n==100){
            cout<<1010000<<endl;
        }else{
            cout<<n*10000<<endl;
        }
    }
    
    return 0;
}
/*#include <bits/stdc++.h>
 
using namespace std;
 
//#define MD 1
#define MD 1000000007
 
int main(){
    long long int n;
    cin>>n;
    vector<long long int> v(10002);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    long long int ans=0;
    int cnt=0,flag=0;
    while(1){
        for(int i=0;i<n;i++){
            if(v[i]%2==0 && flag==0 && v[i]>1){
                v[i]/=2;
                flag=1;
            }else{
                v[i]*=3;
                cnt++;
            }
        }
        if(cnt!=n){
                ans++;
                flag=0;
                cnt=0;
        }else{
            cout<<ans<<endl;
            break;
       }
    }
                
                
    return 0;
}*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin>>n>>s;
  vector<int> R,G,B;
  rep(i,s.size() ){
    if(s[i]=='R') R.push_back(i);
    if(s[i]=='G') G.push_back(i);
    if(s[i]=='B') B.push_back(i);
  }
  int ans=0;
  rep(i,R.size() ){
    rep(j,G.size() ){
      int X=R[i]+G[j];
      if(X%2==1) X=-1;
      else X/=2;
      int Y,Z;
      if(R[i]>G[j]){Y=R[i]+(R[i]-G[j]);Z=G[j]-(R[i]-G[j]);}
      else{Y=G[j]+(G[j]-R[i]);Z=R[i]-(G[j]-R[i]);}
      int num=0;
      if(binary_search(B.begin(),B.end(),X)) num++;
      if(binary_search(B.begin(),B.end(),Y)) num++;
      if(binary_search(B.begin(),B.end(),Z)) num++;
      ans+=B.size()-num;
    }
  }
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 3680
import math
a,b = map(int,input().split())
ans = 10000000000000000000000
inf = 10000000000000000000000

an = [math.ceil(a*(100/8)) , math.floor((a+1)*(100/8))-1]
bn = [math.ceil(b*(100/10)) , math.floor((b+1)*(100/10))-1]
    
ax = []
bx = []
    
for i in range(an[0],an[1]+1):
    ax.append(i)
    
for i in range(bn[0],bn[1]+1):
    bx.append(i)
    
for i in range(len(ax)):
    for j in range(len(bx)):
        if ax[i] == bx[j]:
            ans = min(ans,ax[i])
    
if ans != inf:
    print(ans)
else:
    print("-1")

Measured memory_bytes: 38256
h,w=map(int,input().split())

ans=0
ch=0

if h==1 or w==1:
    ch=1

if h%2==0:
    ans=w*int(h/2)
if h%2==1:
    if w%2==0:
        ans=int(h/2)*w +int(w/2)
    if w%2==1:
         ans=int(h/2)*w +int(w/2)+1

if ch==1:
    print(1)
else:
    print(ans)

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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel";
  }
  else {
    cout <<  "consonant";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,a; cin >> n >> a;
    cout << n*n - a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll n;
  cin>>n;
  
  ll a[n+1][n];
  
  for(ll i=1;i<=n;i++){
      for(ll j=1;j<n;j++)
      cin>>a[i][j];
  }
  
  ll ptr[n+1];
  
  for(ll i=1;i<=n;i++)
  ptr[i]=1;
  
  ll ans=0;
  
  while(true){
      ll cnt=0;
      
      bool mark[n+1];
      
      memset(mark,false,sizeof(mark));
      
      for(ll i=1;i<=n;i++){
        if(mark[i])
        continue;
        
        if(ptr[i]<n&&ptr[a[i][ptr[i]]]<n&&mark[i]==false&&mark[a[i][ptr[i]]]==false&&(i==a[a[i][ptr[i]]][ptr[a[i][ptr[i]]]]))
        {
            cnt++;
            //ptr[i]++;
            //if(i==1)
            //cout<<i<<" "<<a[i][ptr[i]]<<endl;
            mark[i]=true;
            mark[a[i][ptr[i]]]=true;
            
            ptr[a[i][ptr[i]]]++;
            ptr[i]++;
            
            
        }
        
      }
      
      
     // cout<<cnt<<endl;
      if(cnt==0)
      break;
      
      ans++;
  }
  
  for(ll i=1;i<=n;i++){
      if(ptr[i]<n){
          cout<<"-1\n";
          return;
      }
  }
  
  cout<<ans<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 11484
N,K = map(int,(input().split()))
A = list(map(int,input().split()))

def f(X):
    return sum([X ^ a for a in A])

if K==0:
    print(f(0))
else:
    l = len(bin(K)[2:])
    a_bit = [N - 2*sum([(a>>i) & 1 for a in A]) for i in range(l)]
    k_bit = [a > 0 for a in a_bit]
    ans = f(0)
    for j in range(l+1):
        k=0
        for i,b in enumerate(k_bit[::-1],1):
            if i==j:continue
            if b and (k + (1<<(l-i)) <= K):
                k += (1<<(l-i))
        ans = max(ans,f(k))
    print(ans)

Measured memory_bytes: 14712
#include <iostream>

using namespace std;

int n, k;
int arr[105];
bool dp[100005];

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

	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}

	for (int i = 1; i <= k; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (arr[j] > i) break;

			dp[i] = dp[i] | (!dp[i - arr[j]]);
		}
	}


	if (dp[k])
		cout << "First" << endl;
	else
		cout << "Second" << endl;
	

	return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(4100000)
import fractions
a,b,c,d = [int(i) for i in input().split()]
lcm = (c * d) // fractions.gcd(c, d)
# a = 9-9//2-9//3+9//lcm
# b = 4-4//2-4//3+4//lcm
a -= 1
e = b-b//c-b//d+b//lcm
f = a-a//c-a//d+a//lcm
print(e-f)

Measured memory_bytes: 5048
#include <stdio.h>

int main()
{
  int r[200000];
  int n, i, j, max, min;
  
  scanf("%d", &n);
  
  for( i = 0; i < n ; i++ )
  {
    scanf("%d\n", &r[i] );
  }
  
  min = r[0];
  max = r[1] - r[0];
  for (j = 1; j <= n-1 ; j++)
  {
  
    if ( max < r[j] -min )
    {
      max = r[j] - min;
    }
    if ( min > r[j] )
    {
      min = r[j];
    }
    
  }
   printf("%d\n", max);
  
  return 0;
}

Measured memory_bytes: 1384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

template< class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd<T>(b, a%b) : a);
}
template< class T > T lcm(T a, T b)
{
    return (a / gcd<T>(a, b) * b);
}
const int N = 200200;

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    string x,y,z;
    cin>>x>>y;
    deque<char>v;
    if(x.size()!=y.size())
    {
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=0; i<x.size(); i++)
    {
        v.push_back(x[i]);
    }
    for(int i=0; i<x.size(); i++)
    {
        int flag=0;
        for(int j=0; j<x.size(); j++)
        {
            if(v[j]==y[j])
            {
                flag=0;
            }
            else
            {
                flag=1;
                break;
            }
        }
        if(flag)
        {
            v.push_front(v[v.size()-1]);
            v.pop_back();
        }
        else
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

import com.sun.org.apache.xpath.internal.functions.FuncFalse;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int[] ans = new int[N];
		for(int i=0;i<N;i++){
			a[i] = sc.nextInt();
		}
		List<Integer> list = new ArrayList<>();
		for(int i=N-1;i>=0;i--){
			if(N/2<i+1){
				if(a[i]==1){list.add(i+1);ans[i]=1;}
			}else{
				int count = 0;
				for(int j=2;j*(i+1)<=N;j++){
					if(ans[j*(i+1)-1]==1)count++;
				}
				if(a[i]==1){
					if(count%2==0){
						list.add(i+1);ans[i]=1;
					}
				}else{
					if(count%2==1){
						list.add(i+1);ans[i]=1;
					}
				}
			}
		}
		if(list.size()==0){
			System.out.println(0);
		}else{
			System.out.println(list.size());
			for(int i=0;i<list.size();i++){
				if(i > 0)System.out.print(" ");
	      System.out.print(list.get(i));
			}
		}
	}
}

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

using namespace std;

int RED = 0;
int BLUE = 1;

int ask(int p, int n) {
	cout << "? ";
	for (int i = 0; i < n; i++) {
		cout << p + i << " ";
	}
	cout << "\n";
	cout.flush();

	string ans;
	cin >> ans;
	int res = (ans == "Red") ? RED:BLUE;
	return res;
}


string ask2(int j, int p, int n) {
	cout << "? " << j << " ";
	for (int i = 1; i < p; i++) {
		cout << i << " ";
	}
	for (int i = p + n + 1; i <= 2 * n; i++) {
		cout << i << " "; 
	}
	cout << "\n";
	cout.flush();
	string ans;
	cin >> ans;
	string res = (ans == "Red") ? "R":"B";
	return res;
}

string ask3(int j, int p, int n) {
	cout << "? " << j << " ";
	for (int i = p + 1; i < p + n; i++) {
		cout << i << " ";
	}
	cout << "\n";
	cout.flush();
	string ans;
	cin >> ans;
	string res = (ans == "Red") ? "R":"B";
	return res;
}

int bs(int l, int r, int n) {
	int ans;
	int x = ask(l, n);
	while (l <= r) {
		int m = (l + r) / 2;
		int y = ask(m, n);
		if (x == y) {
			ans = m;
			l = m + 1;
		} else {
			r = m - 1;
		}
 	}
	return ans;
}

int main()
{
	int n;
	cin >> n; 
	vector<string> col(2 * n + 1, "");
	int pos = bs(1, n, n);
	// cout << pos << " ";
	int y = ask(1, n);
	if (y == 0) {
		col[pos] = "R";
		col[pos + n] = "B";
	} else {
		col[pos] = "B";
		col[pos + n] = "R";
	}

	for (int i = pos + 1; i < pos + n; i++) {
		col[i] = ask2(i, pos, n);
	}

	for (int i = 1; i < pos; i++) {
		col[i] = ask3(i, pos, n);
	}

	for (int i = pos + n + 1; i <= 2 * n; i++) {
		col[i] = ask3(i, pos, n);
	}

	cout << "! ";
	for (int i = 1; i <= 2 * n; i++) {
		cout << col[i];
	}
	cout << "\n";
	cout.flush();
	return 0;
}




Measured memory_bytes: 724
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;

int main(){
    int n;
    cin >> n;
    vector<int> ans;
    while(n != 0){
        ans.push_back(abs(n%2));
        if(n%2) n--;
        n /= -2;
    }
    reverse(all(ans));
    if(ans.size() == 0) ans.push_back(0);
    rep(i, ans.size()) cout << ans[i];
    cout << endl;

}


Measured memory_bytes: 256
from collections import deque

import sys
sys.setrecursionlimit(1000000)

N=int(input())
graph = [[] for _ in range(N)] # 隣接リスト

for _ in range(N):
    v,c,*l = map(int,input().split())
    for i in l:
        graph[v-1].append(i-1)
        # graph[i-1].append(v-1)

dist=[-1]*N
dist[0]=0

d=deque()
d.append(0)

while d:
 # print(d)
 v = d.popleft()
 for i in graph[v]:
   if dist[i] != -1:
     continue
   dist[i] = dist[v] + 1
   d.append(i)
for i in range(len(dist)):
    print(i+1,dist[i])


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

const long long md=1e9+7;//mod
const int maxn=300100;
long long fac[maxn],inv[maxn];

// cal x^y in logy order
long long powd(long long x,long long y){
	long long res=1;
	while(y){
		if(y&1) res=res*x%md;
		x=x*x%md;
		y>>=1;
	}
	return res;
}
// calc n! by fermat's little theory
void csh(){
	fac[0]=1;
	for(int i=1;i<=300000;i++)
		fac[i]=fac[i-1]*i%md;
	inv[300000]=powd(fac[300000],md-2);
	for(int i=300000;i>=1;i--)
		inv[i-1]=inv[i]*i%md;
}
//calc combination in xlonx
long long C(int x,int y){
	return fac[x]*inv[y]%md*inv[x-y]%md;
}


int main(){
  csh();
  int N, M;
  cin >> N >> M;
  int sqM = (int)sqrt(M);
  vector<bool> check(sqM+1,true);
  vector<int> pr;
  map<int, int> mp;
  for (int i=2; i<=sqM+1; i++){
    if (check[i]){
      pr.push_back(i);
      for (int j=i; j<=sqM; j+=i) check[j] = false;
    }
  }
  for (auto k: pr){
    while (true){
      if (M%k != 0) break;
      M /= k;
      mp[k]++;
    }
  }
  if (M != 1) mp[M]++;
  long long ans = 1;
  for (auto k: mp){
    int m = k.second;
    // cout << m << endl;
    ans *= C(N+m-1, m);
    ans %= md;
  }
  cout << ans << endl;
}


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

#define PB push_back
#define X first
#define Y second
#define ws asdnasdkns
#define LL long long
#define PI acos(-1.0)
const LL mod = 1000 * 1000 * 1000 + 7;
const LL MAX = 200005;
int cnt[25];
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   //	freopen("In.txt" , "r" , stdin);
	srand(time(NULL));
	int n , a , b;
	cin >> n >> a >> b;
	for(int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		cnt[x]++;
	}
	int e = 0;
	for(int i = 1; i <= a; i++)
		e += cnt[i];
	int z = 0;
	for(int i = a + 1; i <= b; i++)
		z += cnt[i];
	int y = 0;
	for(int i = b + 1; i <= 20; i++)
		y += cnt[i];
	cout << min(min(e , z) , y);
}

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

int g[15][15] ; 

int main() {
  int n ; 
  cin >> n ; 
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      g[i][j] = -1 ; 
    }
  }
  
  for(int i = 0 ; i < n ; i++){
    int m ;
    cin >> m ; 
    for(int j = 0 ; j < m ; j++){
      int a , x ; 
      cin >> a >> x ; 
      --a ; 
      g[i][a] = x ; //入力でiがjについてなんて言っているか
    }
  }
  
  int ans = 0 ; 
  for(int i = 0 ; i < (1<<n) ; i++){//bit演算子でiを2進数にする ex) 00000,00001,00010...
    vector<int> d(n) ; 
    for(int j = 0 ; j < n ; j++) if(i >>j&1){//1が何桁目にあるかをみる
      d[j] = 1 ; //1があった桁は1にする
    }
    
    bool ok = true ; 
    for(int j = 0 ; j <n ; j++){
      if(d[j]){
        for(int k = 0 ; k <n ; k++){
          if(g[j][k] == -1) continue ; //jがkについて何も言っていない =>　飛ばす
          if(g[j][k] != d[k]) ok = false ; //jがkについて言っていること!=d[k]　=>false        
        }
      }
    }
    if(ok) ans = max(ans , __builtin_popcount(i)) ; 
  }
  cout << ans << endl ; 
  return 0 ; 
}

Measured memory_bytes: 3520