akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
//int table[100][100];
int main(){
  int n,x,y,s,t;
  int w,h;
  while(cin >> n,n){
    //memset(table, 0, sizeof(table));
    cin >> w >> h;
    int table[w*2][h*2]={};
    rep(i,n) {
      cin >> x >> y;
      x--; y--;
      table[x][y]=1;
    }
    cin >> s >> t;
    int ans = 0;
    rep(i,w-s+1){
      rep(j,h-t+1){
        int count=0;
        for(int a=i; a<s+i; a++){
          for(int b=j; b<t+j; b++){
            if(table[a][b]==1) count++;
          }
        }
        ans = max(count,ans);
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3228
import           Control.Exception (assert)
import           Data.List         (group)

main :: IO ()
main = do
  n <- readLn
  colors <- map read . words <$> getLine
  assert (length colors == n) $ print $ f colors
  -- if length colors /= n
  --   then error "データの長さが違う"
  --   else print $ f colors

f :: [Int] -> Int
f = sum . map (flip div 2 . length) . group


Measured memory_bytes: 892
using System;

namespace ITP1_10_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str);
            string[] str1 = Console.ReadLine().Split(' ');
            string[] str2 = Console.ReadLine().Split(' ');

            double[] x = new double[n];
            double[] y = new double[n];

            for(int i = 0; i < n; ++i)
            {
                x[i] = double.Parse(str1[i]);
                y[i] = double.Parse(str2[i]);
            }

            PrintDistance(n, x, y, 1);
            PrintDistance(n, x, y, 2);
            PrintDistance(n, x, y, 3);

            double Distance = 0;
            for(int i = 0;i<n;++i)
            {
                if (x[i] - y[i] > Distance)
                    Distance = x[i] - y[i];
                else if (y[i] - x[i] > Distance)
                    Distance = y[i] - x[i];
            }
            Console.WriteLine("{0}", Distance);
        }

        static void PrintDistance(int n,double[] x, double[] y,double p)
        {
            double Distance;
            double temp = 0;

            for (int i = 0; i < n; ++i)
            {
                if (x[i] > y[i])
                    temp += Math.Pow(x[i] - y[i], p);
                else
                    temp += Math.Pow(y[i] - x[i], p);
            }
            Distance = Math.Pow(temp, 1 / p);
            Console.WriteLine("{0}", Distance);
        }
    }
}

Measured memory_bytes: 20056
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int AB = line[0];
            int BC = line[1];
            Console.WriteLine(BC * AB / 2);
        }
    }
}

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

using lli = long long int;

#define repi(i, a, b) for(lli i = (lli)(a); i < (lli)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

const lli MAX_N = 10e5;
const lli MAX_A = 10e9;
const lli MIN_RES = -1 * MAX_N * MAX_A;
const bool DEBUG = false;

lli N, x, y, res, t;
lli A[3 * MAX_N];
lli sA1[MAX_N + 1] = {0}, sA2[MAX_N + 1] = {0};
priority_queue<lli, vector<lli>, greater<lli>> A1;
priority_queue<lli> A2;

inline void input() {
  cin >> N;
  rep(i, 3 * N) cin >> A[i];
}

inline void prepare() {
  input();

  res = MIN_RES;

  if(DEBUG) cout << "A1 / A2" << endl;

  rep(i, N) {
    t = i;
    A1.push(A[t]);
    sA1[0] += A[t];
    if(DEBUG) cout << A[t] << "  /  ";

    t = 3*N-1-i;
    A2.push(A[t]);
    sA2[0] += A[t];
    if(DEBUG) cout << A[t] << endl;
  }
}

inline lli solveA1(lli i) {
  A1.push(A[i]);
  lli ax = A[i];
  lli ay = A1.top();
  A1.pop();

  if(DEBUG) cout << "(+)" << ax << ", (-)" << ay;
  return ax - ay;
}

inline lli solveA2(lli i) {
  A2.push(A[i]);
  lli ax = A[i];
  lli ay = A2.top();
  A2.pop();

  if(DEBUG) cout << " / (+)" << ax << ", (-)" << ay << endl;
  return ax - ay;
}

inline void solve() {
  prepare();

  if(DEBUG) cout << endl << "A1         / A2        " << endl;

  rep(i, N) {
    // N ~ 2*N-1
    sA1[i+1] = sA1[i] + solveA1(N + i);

    // 2*N-1 ~ N
    sA2[i+1] = sA2[i] + solveA2(2 * N - 1 - i);

    if(DEBUG) if((lli)A1.size() != N || (lli)A2.size() != N)
      cout << "ERROR" << endl;
  }

  rep(i, N + 1) {
    res = max(res, sA1[i] - sA2[N - i]);
  }
}

inline void Main() {
  // code
  solve();
  cout << res << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


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

int main() {
	int n;
	cin >> n;
	map<pair<int,int>, int> f;
	for (int i = 1; i <= n; i++) {
		double x;
		scanf("%lf", &x);
		long long y = llround(x * 1e9);
		int cnt1, cnt2;
		cnt1 = cnt2 = 0;
		while (y % 2 == 0) {
			y /= 2;
			cnt1++;
		}
		while (y % 5 == 0) {
			y /= 5;
			cnt2++;
		}
		f[make_pair(cnt1, cnt2)]++;
	}
	long long ans = 0;
	for (auto p1 : f)
		for (auto p2 : f) {
			if (p1.first.first + p2.first.first >= 18 && p1.first.second + p2.first.second >= 18) {
				if (p2 < p1) ans += (long long) p1.second * p2.second;
				if (p1 == p2) ans += ((long long) p1.second * p2.second - p1.second) / 2;
			}
		}
	cout << ans << endl;
}

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

using namespace std;

int main ()
{
	int n;
	scanf ("%d", &n);
	int f1 = (n + 1) >> 1, f2 = n >> 1;
	printf ("%lf\n", (double)f1 / (double)(f1 + f2));
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
long long int Inv(long long int a, long long int m) {
  int c[50];
  long long int e[50];  
  c[0] = (m-2) % 2, e[0] = (m-2) / 2; 
  for (int i = 0; i < 49; ++i){
     c[i+1] = e[i] % 2;
     e[i+1] = e[i] / 2;  
  }
  long long int d[50]; 
  d[0] = a; 
  for (int j = 0; j < 49; ++j){
     d[j+1] = (d[j] * d[j]) % m; 
  }
  long long int Q; 
  Q = 1; 
  for(int k = 0; k < 49; ++k){
  if (c[k] == 0) Q = Q; 
  if (c[k] == 1) Q = (Q * d[k]) % m; 
  }
 return Q;
}

int main() {
int N, M; 
cin >> N >> M;
long long int p = 1000000007;  
long long int A[33000] = {};
long long int B[33000] = {};
for(int i = 2; i * i <= 1000000000; i++){
while(M % i == 0){
A[i] ++; 
M /= i; 
}
}
if(M != 1){
A[32000] = 1; 
}
long long int Fac[200000] = {}; 
Fac[0] = 1; 
for(int i = 1; i < 199999; i++){
Fac[i] = (Fac[i-1] * i) % p; 
}
long long int ans = 1; 
for(int i = 2; i < 32010; i++){
B[i] = (((Fac[N + A[i] - 1] * Inv(Fac[A[i]], p)) % p) * Inv(Fac[N-1], p)) % p;
ans = (ans * B[i]) % p; 
}
cout << ans << endl; 
}

Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>

int prime(int N){
  int x = 1;
  for(int j = 2;j*j<=N;j++)
    if(N%j==0) x = 0;
  return x;
}

using namespace std;
int main(){
  int l[111111],r[111111];
  int Q,i;
  cin >> Q;
  for(i=0;i<=Q-1;i++)
    cin >> l[i] >> r[i];
  int num[111111] = {0};
  num[1] = 0;
  for(i=3;i<=111111;i+=2)
    num[i] = num[i-2] + prime(i)*prime((i+1)/2);
  for(i=0;i<=Q-1;i++)
    cout << num[r[i]] - num[l[i]-2] << endl;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.length();
    if(s[n-1]=='s'){
        s = s + "es";
        cout << s << endl;
    }
    else{
        s = s + "s";
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define foi(i,k,n) for (int i = (int)k; i < (int)n; ++i)

using namespace std;
using ii = pair<int,int>;
using ll = long long;

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  ll x; cin >> x;
  ll ans = 0;
  while (x >= 500) {
    ans += 1000;
    x -= 500;
  }
  while (x >= 5) {
    ans += 5;
    x -= 5;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int A, B; cin >> A >> B;
    cout << (1 ^ 2 ^ 3 ^ A ^ B) << endl;
    return 0;
}


Measured memory_bytes: 256
N = 26
d = int(input())
c = list(map(int,input().split()))
#print(sum(c))
s = [[] for i in range(d)]
for i in range(d):
    line = list(map(int,input().split()))
    s[i] = line
cost_list = [0 for i in range(N)]
#print(c)
#print(s)

last_di = [0 for i in range(N)]

def todays_cost(day,contest):
    cost = 0
    for i in range(N):
        cost += c[i] * (day - last_di[i])
    #print(cost)
    cost -= c[contest] * (day - last_di[contest])
    #print(s[day - 1][contest])
    cost -= s[day - 1][contest]
    #print(cost)
    return  cost * (-1)

def greedy():
    m = 0
    for i in range(1,d+1):
        for j in range(N):
            cost_list[j] = todays_cost(i,j)
        #print(cost_list)
        max_value = max(cost_list)
        #print(cost_list)
        max_index = cost_list.index(max_value)
        last_di[max_index] = i
        #print(last_di)
        m += max_value
        print(max_index + 1)
    #print(m)

greedy()
#print(m)


Measured memory_bytes: 9496
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) cin >> d[i];

	set<int> s;

	for (int i = 0; i < n; i++)
	{
		s.insert(d[i]);
	}

	cout << s.size() << endl;
}


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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<int> V(N), C(N);
    int ans = 0;
    for(auto &i: V)cin >> i;
    for(auto &i: C)cin >> i;
    for (int i = 0; i < N; i++)
    {
        if(V[i] > C[i]) ans += (V[i] - C[i]);
    }
    cout << ans << endl;
    return 0;
}

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

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

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

int main() {
    int m, d;
    constexpr int day[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    const string ans[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
    while(cin >> m >> d, m) {
        int x = 0;
        for(int i = 1; i <= 12; ++i) {
            if(m == i) {
                cout << ans[(x + d - 1) % 7] << endl;
                break;
            } else {
                x = (x + day[i]) % 7;
            }
        }
    }
}


Measured memory_bytes: 3032
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	if (B >= A * C) {
		cout << C << endl;
	}
	else {
		cout << B / A << endl;
	}

}


Measured memory_bytes: 3644
#include <stdio.h>

int main(){
  int n=0,m=0,i=0,L=0,M=0,R=0,c=0;

  scanf("%d",&n);

  int S[n];

  for(i=0; i < n; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&m);

  int T[m];

  for(i=0; i < m; i++){
    scanf("%d",&T[i]);
  }

  for(i=0; i < m; i++){
    L = 0;
    R = n;
    while(L < R){
      M = (L + R)/2;
      if(S[M] == T[i]){
	T[i] = -1;
	c++;
	break;
      } else if(T[i] < S[M]){
	R = M;
      } else {
	L = M + 1;
      }
    }
  }

  printf("%d\n",c);

  return 0;
}



Measured memory_bytes: 2316
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M;cin>>N>>M;long long K=0;
  vector<int>V(M);
  vector<int>I(M-1);
  for(int X=0;X<M;X++){
    cin>>V[X];
  }
  sort(V.begin(),V.end());
  for(int X=0;X<M-1;X++){
    I[X]=V[X+1]-V[X];
  }
  sort(I.begin(),I.end());
  for(int X=0;X<M-N;X++){
    K+=I[X];
  }
  cout<<K<<endl;
}

Measured memory_bytes: 3996
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    n = n % 1000;

    n = (1000 - n) % 1000;

    System.out.println(n);

  }
}

Measured memory_bytes: 35788
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define rep(i,s,e) for (int64_t i=s; i<e; i++)
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int x;
  cin >> x;
  cout << 1-x << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(int argc,char** argv){
  int a,b,c;
  cin >> a >> b >> c;
  if( min(a,b) < c && max(a,b) > c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


vector<vector<li>> ans = {
    {},
    {6},
    {6, 12},
    {2, 4, 6},
    {2, 3, 4, 9},
    {2, 3, 4, 6, 9},
    {2, 3, 4, 8, 9, 10},
    {2, 3, 4, 6, 8, 9, 10},
    {2, 3, 4, 6, 8, 9, 10, 12}
};

vector<vector<li>> ans_small = {
    {},
    {},
    {},
    {2, 5, 63},
    {2, 3, 4, 9},
    {2, 3, 4, 6, 9},
    {2, 3, 4, 8, 9, 10},
    {2, 3, 4, 6, 8, 9, 10},
    {2, 3, 4, 6, 8, 9, 10, 12}
};


int main() {
    li n;
    cin >> n;
    if (n < 8) {
        for (auto v : ans_small[n]) {
            cout << v << " ";
        }
        cout << endl;
        return 0;
    }
    li nn = n / 8;
    rep(i, nn) {
        for (auto v : ans[8]) {
            cout << i * 12 + v << " ";
        }
    }
    li amari = n % 8;
    for (auto v : ans[amari]) {
        cout << nn * 12 + v << " ";
    }
    cout << endl;

    return 0;
}

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

int main(void){
    int n,t,ans=INF;
    cin >> n >> t;
    for(int i=0;i<n;i++){
        int c,tm;
        cin >> c >> tm;
        if (tm <= t){
            ans=min(ans,c);
        }    
    }
    if (ans==INF)
        cout << "TLE" << endl;
    else 
        cout << ans << endl;
}

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

int main()
{
    //入力
    int h, n;
    cin >> h >> n;
    vector<int>a(n);
    vector<int>b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    //DP[i-1][d]はi番目までのスキルでｄダメージを与えるときの最小マナ。０で初期化している
    vector<vector<int>> dp(n + 1, vector<int>(h + 100100));
    for (int i = 0; i < h + 100100; i++)
    {
        if (i % a[0] == 0)
        {
            dp[0][i] = (i / a[0]) * b[0];
        }
        else
        {
            dp[0][i] = (((i - i % a[0]) / a[0]) + 1) * b[0];
        }
    }

    //漸化式
    for (int i = 0; i < n; i++)
    {
        for (int d = 0; d <= h+100000; d++)
        {
            dp[i + 1][d] = dp[i][d];
            if (a[i] <= d)
            {
                dp[i + 1][d] = min(dp[i][d], dp[i + 1][d - a[i]] + b[i]);
            }
        }
    }
    int ans = 100000000;
    for (int i = h; i < h + 100000; i++)
    {
        if (ans > dp[n][i])
        {
            ans = dp[n][i];
        }
    }

    cout << ans<< "\n";

    return 0;
}

Measured memory_bytes: 435696
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

string s,t;
int n,result;
ll a,b;

int main () {
  ios::sync_with_stdio(false);
  cin >> n >> s;
  t = "Yes";
  if (n%2) t = "No";
  else {
    rep(i,n/2) {
      if(s[i] != s[i+n/2]) t = "No";
    }
  }
  cout << t << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
char ca[100007];
int main(){
	int n[3]={0};
	int i,j,k;
	cin>>ca;
	for(i=0;i<strlen(ca);i++){
		j=(int)ca[i]-(int)'a';
		n[j]++;
	}
	if(n[0]>n[1])swap(n[0],n[1]);
	if(n[1]>n[2])swap(n[1],n[2]);
	if(n[0]>n[1])swap(n[0],n[1]);
	if(n[2]-n[0]<=1)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 384
m, k = map(int, input().split())

if k >= 2 ** m:
    print(-1)
    exit()

if m == 0:
    print(0, 0)
    exit()
elif m == 1:
    if k == 0:
        print(0, 0, 1, 1)
    else:
        # k == 1
        print(-1)
else:
    t = list(range(0, k)) + list(range(k + 1, 2 ** m))
    ans = [k] + t + [k] + t[::-1]
    print(*ans)


Measured memory_bytes: 17000
#include<stdio.h>

int main(int argc, char const *argv[]){
	long n,i,a,ans=0,f=0,p;
	scanf("%ld",&n);
	for(i=0;i<n;i++){
		scanf("%ld",&a);
		if(f==0){
			f=1;
			ans++;
			p=a;
		}else if(f==1){
			if(p>a){
				f=2;
				p=a;
			}else if(p<a){
				f=3;
				p=a;
			}
		}else if(f==2){
			if(p<a){
				f=1;
				ans++;
			}
			p=a;
		}else if(f==3){
			if(p>a){
				f=1;
				ans++;
			}
			p=a;
		}
	}
	printf("%ld\n",ans);
	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	vector<long long> v(n+1,0);
	for(int i=1;i<=n;i++)
	{
		cin>>v[i],v[i]+=v[i-1];
	}
	vector< vector<long long> >dp;
	dp.assign(n+1,vector<long long>(n+1,1e16) );
	for(int i=1;i<=n;i++) dp[i][i]=0;		
	for(int i=1,j=2;i<=n,j<=n;j++,i++) dp[i][j]=v[j]-v[i-1];
	for(int len=3;len<=n;len++)
	for(int i=1, j=len; j<=n; i++, j++)
	{
		long long tot=v[j]-v[i-1];
		for(int k=i;k<j;k++)
		{
			dp[i][j] = min(dp[i][j], tot+dp[i][k]+dp[k+1][j]);
		}
	}
	cout<<dp[1][n]<<endl;
} 

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string K;
  IN(K);
  ll D;
  IN(D);

  vll dp2(D, 0);
  vll dp2_copy(D, 0);
  ll d_sum = 0;

  REP(i,K.size()){
    int N = K[i]-'0';
    REP(d,D) dp2_copy[d] = 0;
    REP(d1,D){
      REP(d2,10){
        dp2_copy[(d1+d2)%D] += dp2[d1];
        dp2_copy[(d1+d2)%D] %= MOD;
      }
    }
    REP(n,N){
      dp2_copy[(d_sum+n)%D] += 1;
    }
    d_sum += N;
    d_sum %= D;
    dp2 = dp2_copy;

    vec_print(dp2);
  }

  OUT((dp2[0]+(d_sum%D==0)+MOD-1)%MOD);

  return 0;
}

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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int H, W, bomb;
	
	cin >> H >> W;
	
	char S[H][W];
	
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++)
			cin >> S[i][j];
	}	
	
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			bomb = 0;
			if(S[i][j] == '.'){
				for(int x = -1; x<=1; x++){
					for(int y=-1; y<=1; y++){
						if(0 <= i+x && i+x < H && 0 <= j+y && j+y < W && S[i+x][j+y] == '#')
							bomb++;
					}
				}
				cout << bomb;
			}else
				cout << '#';
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import numpy as np
n=int(input())

ans=0
for a in range(1,n+1):
  for b in range(1,n+1):
    d=np.gcd(a,b)
    if d==1:
      ans+=n
      continue
    if d==2:
      ans+=n//2*3+n%2
      continue
    if d==3:
      ans+=n//3*5+n%3
      continue
    if d==5:
      ans+=n//5*9+n%5
      continue
    for c in range(1,n+1):
      ans += np.gcd(c,d)

print(ans)

Measured memory_bytes: 27036
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[4];
        int keep = 0;
        a[0] = 0;
        a[1] = sc.nextInt();
        a[2] = sc.nextInt();
        a[3] = sc.nextInt();
        if(a[1]>a[2]){
            keep = a[1];
            a[1] = a[2];
            a[2] = keep;
        }
        if(a[2]>a[3]){
            keep = a[2];
            a[2] = a[3];
            a[3] = keep;
        }
        if(a[1]>a[2]){
            keep = a[1];
            a[1] = a[2];
            a[2] = keep;
        }
        System.out.println(a[3]-a[1]);
    }
}

Measured memory_bytes: 21844
from itertools import product

def main():
    n, k = [int(i) for i in input().split()]
    a = [int(i) for i in input().split()]
    res = 10e10
    for t in product([0,1], repeat=n):
        if sum(t) < k:
            continue
        a_tmp = list(a)
        score = 0
        t_height = 0
        cnt = 0
        for i, h in enumerate(a_tmp):
            if t_height < h:
                t_height = h
                cnt += 1
            elif t[i]:
                t_height += 1
                score += t_height - h
            if cnt >= k:
                break
        res = min(res, score)
    print(res)
if __name__ == '__main__':
    main()



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

int main() {
  int N;
  std::cin >> N;
  std::vector<int> H(N);
  for(auto &h:H)
    std::cin >> h;
  int cnt = 0;
  int max_h = H[0];
  for(auto &h:H){
    if(h >= max_h){
      max_h = h;
      cnt++;
    }
  }
  std::cout << cnt << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[110];
int cnt;
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=1; i<=len/2; i++)
		if(s[i]!=s[len-i+1])
			cnt++;
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define df 0
int dectob(int n,int b,vector<int> &v){
  int i=0,s=0;
  while(n){
    v.at(i)=n%b;
    s+=v.at(i);
    n/=b;
    i++;
  }
  return s;
}

int  next9(vector<int> &v,int &rcnt,int &rmny){
  int i=0,temp=1;
  while(i<7 && v.at(i)==0){
    i++;
    temp*=9;
  }
  if(i==7)return 0;
  v.at(i)--;
  rcnt++;
  rmny+=temp;
  i--; temp/=9;
  while(i>=0 && rcnt>0){
    int a=min(rcnt,8);
    v.at(i)=a;
    rcnt-=a;
    rmny-=temp*a;
    i--; temp/=9;
  }
  return 1;
}

int main(){
  int n; cin >> n;
  vector<int> v9(7,0),v6(7,0);
  int ans=dectob(n,9,v9);
  if(df){
    for(int i=0;i<7;i++){
      cout << v9.at(i) << " ";
    }
    cout << "\n";
  }
  int rcnt=0,rmny=0,flag=next9(v9,rcnt,rmny);
  while(flag) {
    if(df){
      for(int j=0;j<7;j++){
	cout << v9.at(j) << " ";
      }
      printf(":rcnt:%d, rmny:%d\n",rcnt,rmny);
    }
    int cnt6=dectob(rmny,6,v6);
    if(df){
      for(int j=0;j<7;j++){
	cout << v6.at(j) << " ";
      }
      printf(":v6 (%d)\n",cnt6);
    }
    if(cnt6<rcnt){
      ans-=rcnt-cnt6;
      rcnt=cnt6;
      if(df) printf("update!! ans:%d\n",ans);
    }
    flag=next9(v9,rcnt,rmny);
  }
  cout << ans;
}


Measured memory_bytes: 256
def lsum(x):
    return A[x[0]] + B[x[1]] + C[x[2]]

def nextlist():
    global lx
    idx = 0
    m = lsum(lx[0])
    for i in range(len(lx)):
        s = lsum(lx[i])
        if m < s:
            m = s
            idx = i
    p = lx.pop(idx)
    wa.append(lsum(p))
    if p[0] > 0:
        if not [p[0]-1, p[1], p[2]] in lx:
            lx.append([p[0]-1, p[1], p[2]])
    if p[1] > 0:
        if not [p[0], p[1]-1, p[2]] in lx:
            lx.append([p[0], p[1]-1, p[2]])
    if p[2] > 0:
        if not [p[0], p[1], p[2]-1] in lx:
            lx.append([p[0], p[1], p[2]-1])

l1 = list(map(int, input().split(" ")))

X,Y,Z,K = l1[0],l1[1],l1[2],l1[3]
A = sorted(list(map(int, input().split(" "))))
B = sorted(list(map(int, input().split(" "))))
C = sorted(list(map(int, input().split(" "))))

wa = []
lx = [[X-1,Y-1,Z-1]]

for i in range(K):
    nextlist()

for l in wa:
    print(l)


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

int main() {
  string s, t, ans;
  int n, tmp;
  cin >> n;
  tmp = n % 10;
  if(tmp == 2 || tmp == 4 || tmp ==  5 || tmp ==  7 || tmp ==  9) {
    ans = "hon";
  } else if(tmp == 0 || tmp == 1 || tmp ==  6 || tmp ==  8) {
    ans = "pon";
  } else {
    ans = "bon";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <cstdio>

#include <cmath>

#include <cstring>

#include <iostream>

#include <algorithm>

#include <queue>

#include <vector>

#include <map>



using namespace std;



typedef long long LL;


int n,m,x,y;
vector<int> v[1005];
int a[1005];
int ans,dq,len,nxt;

int main()

{

	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i) 
	{	
		scanf("%d%d",&x,&y);
		v[x].push_back(y);		
	}
	for (int i=1;i<=n;++i) a[i]=i;
	for (int i=n;i>=1;--i)
	{
		for (int j=0;j<v[i].size();++j)
		{
			a[i]=max(a[i],a[v[i][j]]);
		}
	}
	ans=1;dq=1;
	while (dq<=n)
	{
		nxt=a[dq];len=0;
		for (int i=dq+1;i<=nxt;++i)
		{
			len++;nxt=max(nxt,a[i]);
		}
		ans+=3*len;
		ans++;
		dq=nxt+1;
	}
	printf("%d\n",ans);

	return 0;

}

Measured memory_bytes: 1252
# include <iostream>
# include <cstring>
# include <string>
# include <vector>
# include <cmath>
# include <sstream>
# include <iomanip>
# include <algorithm>
using namespace std;

# define repl(i, a, b)	for(int i=(int)(a);i<(int)(b);i++)
# define rep(i, n)	repl(i, 0, n)
typedef long long ll;

int main(){
	int n, sum=0;
	cin >> n;

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

	for(int i=0;i<n;i++){
		if(i+1 == v[v[i]-1])
			sum++;
	}
	cout << sum / 2 << endl;
	return 0;
}

Measured memory_bytes: 768
#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.at(i);
  long long res = 0;
  int keep = a.at(0);
  for(int i = 1; i<n; i++){
    if(a.at(i) < keep)
      res += keep - a.at(i);
    else keep = a.at(i);
  }
  cout << res << endl;
}

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

long inf = 1000000007;


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

	int count = 0;
	int p = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] == p) {
			count++;
			p++;
		}
	}
	if (count == 0) {
		cout << -1 << endl;
	}
	else {
		cout << n - count << endl;
	}
}


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

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++){
        if(i%k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
def yakusu(x):
    ya = []
    for i in range(1,int(x**0.5)+1):
        if x % i == 0:
            ya.append(i)
            if i != x//i:
                ya.append(x //i)
    return ya

n = int(input())
l,m,ans = yakusu(n),yakusu(n-1),0
for i in range(1,len(l)):
    a = n
    while a % l[i] == 0:
        a = a // l[i]
    if (a-1) % l[i] == 0:
        ans += 1
ans += len(m)
print(ans-1)

Measured memory_bytes: 3188
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

class Combination {
public:
    vector <ll> fac, inv, fiv;

    Combination(int N) : fac(N + 1), inv(N + 1), fiv(N + 1) {
        fac[0] = inv[0] = fiv[0] = fac[1] = inv[1] = fiv[1] = 1;
        for (ll i = 2; i <= N; i++) {
            fac[i] = fac[i - 1] * i % MOD; // n!
            inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; // n^-1
            fiv[i] = fiv[i - 1] * inv[i] % MOD; // (n!)^-1
        }
    }

    ll C(ll n, ll k) {
        if (k < 0 || n < k) return 0;
        return fac[n] * fiv[k] % MOD * fiv[n - k] % MOD;
    }
};

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

    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    Combination com(2000005);

    ll ans = 0;
    ans += com.C(r2 + c2 + 2, r2 + 1);
    ans += MOD - com.C(r2 + c1 + 1, r2 + 1);
    ans += MOD - com.C(r1 + c2 + 1, r1);
    ans += com.C(r1 + c1, r1);

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

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

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

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

using namespace std;

int main() {
  // a + b + c = N
  // 10000a + 5000b + 1000c = Y
  // 10000(N-b-c) + 5000b + 1000c = Y
  //

  int N, Y; cin >> N >> Y;

  bool f = false;
  for (int i = 0; i < N+1; i++) {
    for (int j = 0; j < N+1-i; j++) {
      if(10000*(N-i-j) + 5000*i + 1000*j == Y) {
        f = true;
        cout << N-i-j << " " <<  i << " " << j << endl;
        break;
      }
    }
    if(f) break;
  }

  if(!f) cout << "-1 -1 -1" << endl;
}



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

int main(){
  	int n;
  cin>>n;
  int ans = 0,x;
  int minn = INT_MAX;
  for(int i=0;i<n;i++){
    cin>>x;
    minn = min(minn,x);
    if(minn==x) 
      ans++;
  }
  
  cout<<ans;
	return 0;  
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, q = map(int, input().split())

class UnionFind(object):
    def __init__(self, n = 1):
        self.link = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.link[x] == x:
            return x

        # re-connect union find to make the height of tree lower
        # you can use while, but recursion makes it easier to reconnect
        self.link[x] = self.find(self.link[x])
        return self.link[x]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.size[x] < self.size[y]:
            x, y = y, x
        self.link[y] = x
        self.size[x] += self.size[y]
    
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

u = UnionFind(n)
for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        u.unite(x, y)
    else:
        print(1 if u.is_same(x, y) else 0)



Measured memory_bytes: 6516
#include<iostream>
#include<math.h>
using namespace std;


void S(double *teihen,double *takasa);
int main(){
	double a,b;
	cin >> a >> b;
	S(&a,&b);
}
void S(double *teihen,double *takasa){
	cout<<(*teihen)*(*takasa)<<" "<<2*(*teihen)+2*(*takasa)<<endl;
}


Measured memory_bytes: 3288
#include <cstdio>

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

using namespace std;

typedef long long ll;

int main(){
	static ll dp[102][1001][10]; // [next number][sum][# of used numbers]
	dp[0][0][0]=1;
	rep(i,101) rep(s,1001) rep(n,10) {
		// use i
		if(s+i<=1000 && n+1<=9) dp[i+1][s+i][n+1]+=dp[i][s][n];
		// don't use i
		dp[i+1][s][n]+=dp[i][s][n];
	}

	for(int n,s;scanf("%d%d",&n,&s),n;) printf("%lld\n",dp[101][s][n]);

	return 0;
}

Measured memory_bytes: 8928
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

typedef long long ll;

int gcd(int a, int b);
int lcm(int a, int b);

int main(){
    int N;
    cin >> N;
    vector<int> T(N), A(N);
    for(int i = 0; i < N; i++){
        cin >> T[i] >> A[i];
    }
    
    ll t_vote = 0, a_vote = 0;
    
    for(int i = 0; i < N; i++){
        if(i == 0){
            t_vote = (ll)T[i];
            a_vote = (ll)A[i];
            continue;
        }
        
        ll temp, t_option, a_option;
        if(t_vote % T[i] == 0){
            t_option = t_vote / T[i];
        }
        else{
            t_option = t_vote / T[i] + 1;
        }
        if(a_vote % A[i] == 0){
            a_option = a_vote / A[i];
        }
        else{
            a_option = a_vote / A[i] + 1;
        }
        temp = max(t_option, a_option);
        
        t_vote = temp * T[i];
        a_vote = temp * A[i];
    }
    
    cout << t_vote + a_vote << endl;
}

int gcd(int a, int b){
    if(b == 0)      return 0;
    
    return gcd(b, a % b);
}

int lcm(int a, int b){
    return a / gcd(a, b) * b;
}

Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("C:\\Users\\BOG\\Desktop\\ICPC\\b1.txt");ofstream out("C:\\Users\\BOG\\Desktop\\ICPC\\b1_out.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main(){
    fast;
    str x,y; cin>>x>>y;
    int o = 0;
    for(int q=0; q<x.size(); q++) o += x[q]!=y[q];
    cout<<o;
}

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

D = []

for i in range(N):
    if i != N - 1:
        D.append(A[i + 1] - A[i])
    else:
        D.append(A[0] + (K - A[i]))

D = sorted(D)

m = max(D)

print(K - m)

Measured memory_bytes: 25840
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(auto &t:a)cin>>t;return i;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
 

  auto calc=[&](int a){
    return a ^ ((1<<7)-1);
  };
  
  int T;
  cin>>T;
  while(T--){
    int n,D;
    cin>>n>>D;
    int ans = 0;
    for(int i=1;i<n;i++) D = calc(D), ans += 127;
    ans += D;
    cout<<ans<<endl;
  }
  
  
  return 0;
}


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

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

int main(void) {
    int r, d;
    vector<int> x(11);

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> r >> d >> x[0];
    REP(i, 10) {
        x[i + 1] = r * x[i] - d;
        cout << x[i + 1] << "\n";
    }

    return 0;
}

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

int main(){
	int a[10];

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

	for(int i=9;i>6;i--){
		cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1176
def prime_factors(n):
    res = set()
    while n % 2 == 0:
        res.add(2)
        n //= 2
    i = 3
    while i * i <= n:
        if n % i == 0:
            res.add(i)
            n //= i
        else:
            i += 2
    if n != 1:
        res.add(n)
    return res

a, b = map(int, input().split())
a = prime_factors(a)
b = prime_factors(b)
print(len(a & b) + 1)


Measured memory_bytes: 38512
// srt: 2017年03月13日 23時52分10秒
// 《村行》 王禹偁（９５４－１００１）
// 马穿山径菊初黄，信马悠悠野兴长。
// 万壑有声含晚籁，数峰无语立斜阳。
// 棠梨叶落胭脂色，荞麦花开白雪香。
// 何事吟余忽惆怅，村桥原树似吾乡。
// end: 2017年03月14日 00時50分25秒

#include<cstdio>

struct BIGINT
{
	int a[500002],sum,l;
	void read()
	{
		char c;
		while((c=getchar())>='0'&&c<='9')
			sum+=a[l++]=c-'0';
		for(int i=0;i<l>>1;i++)
			a[i]^=a[l-i-1]^=a[i]^=a[l-i-1];
	}

	void mul(int k)
	{
		for(int i=0,c=0;i<l||c;i++)
		{
			sum-=a[i];
			a[i]=a[i]*k+c;
			c=a[i]/10;
			sum+=a[i]%=10;
		}
	}

	void add(int c)
	{
		for(int i=0;c;i++)
		{
			sum-=a[i];
			a[i]+=c;
			c=a[i]/10;
			sum+=a[i]%=10;
		}
	}
}N;

int main()
{
	N.read(),N.mul(9);
	int k=0;
	do N.add(9),k++;
	while(N.sum>k*9);
	printf("%d\n",k);
}

Measured memory_bytes: 2176
#include <cstdio>
using namespace std;
long long x,y,z;
int main() {
	scanf("%lld %lld",&x,&y);
	z=x-y;
	if (z==1||z==-1||z==0)
		printf("Brown\n");
	else printf("Alice\n");
	return 0;
}

Measured memory_bytes: 128
n=int(input())
s=[input() for _ in range(n)]
print('AC x', end=' ')
print(s.count('AC'))
print('WA x', end=' ')
print(s.count('WA'))
print('TLE x', end=' ')
print(s.count('TLE'))
print('RE x', end=' ')
print(s.count('RE'))


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


int main() {
  vector<int>a(5);
  rep(i,5){
    cin>>a.at(i);
  }
  rep(i,5){
    if(i+1!=a.at(i)){
      cout<<i+1<<endl;
    }
  }
  
}



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

#define LL long long

using namespace std;

LL gcd(LL a, LL b){
    if(a % b == 0){
        return b;
    }
    return gcd(b, a % b);
}

int main(void){


    vector<long long> monster;
    LL n, gcdV = 0;
    LL tmp, equal;

    cin >> n;
    cin >> tmp;
    equal = tmp;
    gcdV = tmp;

    for(LL i = 1; i < n; i++){
        cin >> tmp;
        if(equal != tmp){
            gcdV = gcd(gcdV, tmp);
        }
    }

    // cout << "equal " << equal << endl;
    // cout << "gcdV  " << gcdV << endl;
    if(gcdV == 0){
        cout << equal << endl;
    }else{
        cout << gcdV << endl;
    }

    return 0;
}


Measured memory_bytes: 256
line1 = input().split()
k = int(line1[0])
n = int(line1[1])
line2 = input().split()
a = [int(i) for i in line2]
dist_list = [a[i] - a[i - 1] for i in range(1, len(a))]
dist_list.append(k-a[-1] + a[0])
max_dist = max(dist_list)
index = len(dist_list) - dist_list[::-1].index(max_dist) - 1
start_index = (index + 1) % len(dist_list)
ans = 0
for i in range(start_index, start_index + n - 1):
  ans += dist_list[i % len(dist_list)]
print(ans)

Measured memory_bytes: 28524
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace AtCoder.ABC068
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var list = new List<int> { 2, 4, 8, 16, 32, 64 };
            for (int i = list.Count - 1; i >= 0; i--)
            {
                if (n >= list[i])
                {
                    Console.WriteLine(list[i]);
                    return;
                }
            }
            Console.WriteLine(1);
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int sl=s.length();
        int sum=0;

        for(int i=0; i<sl/2; i++){
            String a=s.substring(i,i+1);
            String b=s.substring(sl-(1+i),sl-i);
                if(!a.equals(b)){
                    sum+=1;
                }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
    long long int i,j,k,sum1=0,sum2=0,min,n,t;
    scanf("%lld",&n);
    long long int array[n];
    for(i=0;i<n;i++){
        scanf("%lld",&array[i]);
        if(i!=0){
            sum2=sum2+array[i];
        }
        else
            sum1=sum1+array[i];
    }
    if(sum1<sum2)
        min=sum2-sum1;
    else
        min=sum1-sum2;
    for(i=1;i<n-1;i++){
        sum1=sum1+array[i];
        sum2=sum2-array[i];
        if(sum2>sum1){
            if((sum2-sum1)<min)
                min=sum2-sum1;
        }
        else{
            if((sum1-sum2)<min)
                min=sum1-sum2;
        }
    }
    printf("%lld\n",min);
    return 0;
}


Measured memory_bytes: 3268
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    int x = (N+1) / 2;
    cout << 1.0 * x / N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1000005;
const int mod=998244353;
int n,a[maxn],cnt[maxn],pri[maxn],mu[maxn],tot;
bool vis[maxn];
ll sum[maxn],inv[maxn];
inline void sieve(int n)
{
	mu[1]=1;
	for(int i=2;i<=n;i++)
	{
		if(!vis[i]) pri[++tot]=i,mu[i]=-1;
		for(int j=1;j<=tot && i*pri[j]<=n;j++)
		{
			vis[i*pri[j]]=1;
			if(i%pri[j]==0) break;
			mu[i*pri[j]]=-mu[i];
		}	
	}
	inv[0]=inv[1]=1;
	for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
}
int main()
{
	scanf("%d",&n);
	int mx=0;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),cnt[a[i]]++,mx=max(mx,a[i]);
	sieve(mx);
	for(int i=1;i<=mx;i++)
		for(int j=i;j<=mx;j+=i)
			(sum[i]+=(ll)j*cnt[j])%=mod;
	ll ans=0;
	for(int d=1;d<=mx;d++)
	{
		ll val=0;
		for(int x=d;x<=mx;x+=d)
			(val+=mu[x/d]*sum[x]*sum[x])%=mod;
		(ans+=val*inv[d])%=mod;
	}
	for(int i=1;i<=n;i++) (ans-=a[i])%=mod;
	ans=(ans*((mod+1)>>1)%mod+mod)%mod;
	printf("%lld\n",ans);
	return 0;
}

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


int main(){
  int n;
  cin >> n;
  map<char,int> mp;
  for(int i=0;i<n;++i){
    char s;
    cin >> s;
    mp[s]++;
  }
  if(mp.size()==4){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
  return 0;
}


Measured memory_bytes: 256