akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define N 3
using namespace std;

int main(){
  int n,a[N],mina=(1e9);
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    mina=min(mina,a[i]);
  }
  for(int i=1;i<=mina;i++){
    bool f=true;
    for(int j=0;j<n;j++)
      if(a[j]%i)f=false;
    if(f)cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main()
{
     int n,m;
  cin>>n>>m;
  int dp[n][m];
  char c[n][m];
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      {cin>>c[i][j];dp[i][j]=0;}

  for(int i=1;i<n;i++)
  { if(c[i][0]=='.')dp[i][0]=1;else break;}

  for(int i=1;i<m;i++){if(c[0][i]=='.')dp[0][i]=1;else break;}

  for(int i=1;i<n;i++)
  {
    for(int j=1;j<m;j++)
    {
      if(c[i][j]=='.')dp[i][j]=(dp[i][j-1]%mod+dp[i-1][j]%mod)%mod;
    }
  }

        cout<<dp[n-1][m-1]%mod<<endl;
}


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

using namespace std;
#define ll long long

int main(){
	int n;
	double k;
	cin>>n>>k;
	vector<double> p(n);
	for(int i=0;i<n;i++){
		double x;
		cin>>x;
		p[i]=(x+1)/2; 
		//cout<<p[i]<<" ";
	}
	double res=0,sum=0;
	for(int i=0;i<k;i++)
		sum+=p[i];
	res=sum;
	for(int i=k;i<n;i++){
		sum+=p[i];
		sum-=p[i-k];
		res=max(res,sum);
		//cout<<sum<<" ";
	}
	cout<<setprecision(9)<<res<<"\n";
}


Measured memory_bytes: 1792
a,b = gets.chomp.split(' ').map(&:to_i)
s = []

if a >= b
  a.times do
    s.push(1)
  end
  puts s.join.to_i * b
else
  b.times do
    s.push(1)
  end
  puts s.join.to_i * a
end

Measured memory_bytes: 1788
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
//#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(int a,int b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll N;
 // 最大 100 個ですが余裕をもたせます
    cin >> N;
	ll A[N];
	FOR(i,0,N-1){
		cin>>A[i];
	}
	ll tmp=gcd(A[0],A[1]);
	FOR(i,2,N-2){
		tmp=gcd(A[i],tmp);
	}

	cout<<tmp<<endl;


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define _GLIBCXX_DEBUG
const int MOD = 1000000007;

int main() {
  int N, M;
  cin >> N;
  vector<int> T(N);
  for (int i=0; i<N; i++) cin >> T[i];
  cin >> M;
  vector<pair<int, int>> PX(M);
  for (int i=0; i<M; i++) cin >> PX[i].first >> PX[i].second;
  int sum = accumulate(T.begin(), T.end(), 0);
  for (int i=0; i<M; i++) {
    cout << sum+PX[i].second-T[PX[i].first-1] << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  int N,M,ans=0,s;cin>>N>>M;
  vector<int> K(M),P(M);
  vector<vector<int>> vec(M,vector<int>(N));
  REP(i,0,M){
    cin>>K[i];
    REP(k,0,K[i]){cin>>s;s--;vec[i][k]=s;}
  }
  REP(i,0,M)cin>>P[i];
  for (int bit = 0; bit < (1<<N); ++bit) {
    bool flg=true;
    for (int m = 0; m < M; ++m) {
      int tmp=0;
      REP(k,0,K[m]){
        if (bit & (1<<vec[m][k])) { 
          tmp++;
        }
      }
      if(tmp%2!=P[m]){
        flg=false;
        break;
      }
    }
    if(flg){ans++;}
  }
  print(ans)
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

/*********************************************************************
長さmの列X_(m)と長さnの列Y_(n)の最長共通部分列LCSは、
	(1)X[m] == Y[n]ならば、X_(m-1)とY_(n-1)のLCSにX[m]を繋げたもの
	(2)X[m] != Y[n]ならば、X_(m-1)とY_(n)のLCSもしくはX_(m)とY_(n-1)のLCS
	のいずれかのうち長い方

c[m+1][n+1]：c[i][j]にX_(i)とY_(j)のLCSの長さを格納する二次元配列
*********************************************************************/

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		s1 := scanner.Text()
		scanner.Scan()
		s2 := scanner.Text()
		s1, s2 = " " + s1 , " " + s2
		c := make([][]int, len(s1))
		for i := range c {
			c[i] = make([]int, len(s2))
		}

		LCS := 0

		for i := 1; i < len(s1); i++ {
			for j := 1; j < len(s2); j++ {
				if s1[i] == s2[j] {
					c[i][j] = c[i-1][j-1] + 1
				} else {
					c[i][j] = max(c[i-1][j], c[i][j-1])
				}
				LCS = max(LCS, c[i][j])
			}
		}
		fmt.Println(LCS)
	}
}


Measured memory_bytes: 18968
#include<stdio.h>

int bubbleSort(int A[], int N);

int main(){
  int N,i,cnt;
  int A[100];
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  cnt=bubbleSort(A,N);

  for(i=0;i<N;i++){
    if(i>0 && i<N) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  
  return 0;
}

int bubbleSort(int A[],int N){
  int flag=1,j,a,cnt=0;
  while(flag){
    flag=0;
    for(j=N-1;j>=1;j--){
      if(A[j]<A[j-1]){
	a=A[j];
	A[j]=A[j-1];
	A[j-1]=a;
	flag=1;
	cnt++;
      }
    }
  }
  return cnt;
}


Measured memory_bytes: 2068
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);

        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h==0 && w==0)    break;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }


        sc.close();
    }
}


Measured memory_bytes: 35100
import math
import sys
import collections

def main():
    #N,M=map(int,input().split())
    N=int(input())
    A=list(map(int,input().split()))
    B=[0]*(N)
    for i in range(N-1):
        B[A[i]-1]+=1
    for i in range(N):
        print(B[i])





if __name__ == '__main__':
    main()

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




using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;
const ll INF=1e9;

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

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll n_ac,n_ad,n_acd;
  ll n_bc,n_bd,n_bcd;



  n_ac=(a-1)/c;//aより小さい数で，cで割り切れる数
  n_bc=b/c;

  n_ad=0; n_acd=0;
  n_bd=0; n_bcd=0;

  if(c!=d){
    n_ad=(a-1)/d;
    n_acd=(a-1)/(lcm(c,d));

    n_bd=b/d;
    n_bcd=b/(lcm(c,d));
  }
  ll ans=(b-n_bc-n_bd+n_bcd)-(a-1-n_ac-n_ad+n_acd);
  cout<<ans<<endl;



}


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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

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

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

vector<vector<long long>> matdot(vector<vector<long long>>& A, vector<vector<long long>>& B){
    int n = A.size(), m = B.size(), l = B[0].size();
    vector<vector<long long>> ret(n, vector<long long>(l,0));

    for(int i=0; i<n; i++)
        for(int j=0; j<l; j++)
            for(int k=0; k<m; k++)
                ret[i][j] = (ret[i][j] + A[i][k]*B[k][j])%MOD;

    return ret;
}

void matpow(vector<vector<long long>>& dp, vector<vector<long long>>& mat, long long k){
    int N = mat.size();
    vector<vector<long long>> res(N, vector<long long>(N,0));
    
    while(k){
        if(k & 1) dp = matdot(mat, dp);
        mat = matdot(mat, mat);
        k >>= 1;
    }
}

int main(void){
    ll N,K; cin >> N >> K;
    vector<vector<ll>> a(N, vector<ll>(N)); REP(i,N)REP(j,N) cin >> a[i][j];

    vector<vector<ll>> dp(N,vector<ll>(N,0)); REP(i,N) dp[i][i] = 1;
    matpow(dp, a, K);
    ll ans = 0;
    REP(i,N)REP(j,N) ans = (ans + dp[i][j])%MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    A = map(int, input().split())

    b = [0] * 20
    last = [-1] * 20
    ans = 0
    l = 0
    for r, a in enumerate(A):
        for i in range(20):
            if a & 1:
                if b[i] == 1: l = max(l, last[i] + 1)
                b[i] = 1
                last[i] = r
            a >>= 1
        ans += r-l+1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 68720
def merge(array, left, mid, right):
  cnt = 0
  n1 = int(mid - left)
  n2 = int(right - mid)

  l = array[left:mid]
  r = array[mid:right]

  l.append(9999999999)
  r.append(9999999999)

  i, j = 0, 0

  for k in range(left, right):
    if l[i] <= r[j]:
      array[k] = l[i]
      i += 1
    else:
      array[k] = r[j]
      cnt += n1 - i
      j += 1
  
  return cnt

def mergeSort(array, left, right):
  if left + 1 < right:
    mid = int((left + right) / 2)
    v1 = mergeSort(array, left, mid)
    v2 = mergeSort(array, mid, right)
    v3 = merge(array, left, mid, right)
    return v1 + v2 + v3
  else:
    return 0

n = int(input())
array = [int(i) for i in input().split()]
print(mergeSort(array, 0, n))



Measured memory_bytes: 27480
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
    fastIO;
    int n;
    cin >> n;
    int x;
    vector<pii> res;
    for(int i = 1; i <= n; i ++ ){
        for(int j = i + 1; j <= n; j ++ ){
            if(i + j == n + (1-n%2)){
                continue;
            }
            res.push_back(mp(i,j));
        }
    }
    cout << res.size() << "\n";
    for(auto x : res)
        cout << x.fi << " " << x.se << "\n";
    return 0;
}

Measured memory_bytes: 384
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n; R(n);
    VI a(n),b(n);
    REP(i,n){
        R(a[i]);
        b[i]=a[i];
    }
    sort(ALL(b));
    REP(i,n){
        W(a[i]<b[n/2]?b[n/2]:b[n/2-1]);
    }
    return 0;
}


Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());

        long[] B = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        long[] A = B.Concat(new long[] { 0 }).ToArray();

        long[] L = new long[N + 1];
        L[0] = 0;
        long[] R = new long[N + 1];
        R[N] = 0;

        //答となる数値
        long ans = 0;

        //計算
        //[0, i)の最大公約数を計算する
        for (int i = 0; i < N; i++) {
            L[i + 1] = GCD(L[i], A[i]);
        }

        //(i, N]の最大公約数を計算する
        for (int i = N - 1; i >= 0; i--) {
            R[i] = GCD(R[i + 1], A[i]);
        }

        //M[i]を求める
        for (int i = 0; i < N; i++) {
            ans = Math.Max(ans, GCD(L[i], R[i + 1]));
        }

        //M[i]の中で最大のものをこたえる
        Console.WriteLine(ans);
    }

    //ユークリッドの互除法
    public static long GCD(long a, long b) {
        if (b == 0) {
            return a;
        }
        if (a == 0) {
            return b;
        }

        if (a < b) {
            return GCD(b, a);
        }

        //計算時の余りを格納する変数
        long remainder = 0;

        while (true) {
            remainder = a % b;
            a = b;
            b = remainder;

            if (remainder == 0) break;

        }
        return a;
    }
}

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

constexpr int64_t mod = 1000000007;
char *code;

bool consume(char c){
    if(*code != c) return false;
    ++code;
    return true;
}

int64_t expr();
int64_t term();
int64_t num();

int64_t expr(){
    int64_t value = term();
    while(true){
        if(
            strncmp(code, ">>", 2) == 0
        &&  ( *(code+2) == 'S' || isdigit(*(code+2)) )
        ){
            code += 2;
            int64_t rhs = term();
            if(rhs >= 64) value = 0;
            else value >>= rhs;
        }else break;
    }
    return value;
}

int64_t term(){
    if(consume('S')){
        assert(consume('<'));
        int64_t value = expr();
        assert(consume('>'));
        return value * value % mod;
    }else return num();
}

int64_t num(){
    int64_t value = 0;
    while(isdigit(*code)){
        value = value * 10 + (*code - '0');
        ++code;
    }
    return value;
}

int main(){
    string s;
    while(true){
        getline(cin, s);
        if(s[0] == '#') break;
        code = new char[s.size()+1];
        size_t j = 0;
        for(size_t i=0;i<s.size();++i){
            if(s[i] != ' ') code[j++] = s[i];
        }
        code[j] = '\0';
        cout << expr() << endl;
    }
    
    return 0;
}


Measured memory_bytes: 6052
A,B,C,D = [int(i) for i in input().split()]

"""
もし B < Dなら、 C - B
もし B > Dなら、 D - B

A < x < B
と
C < x < D
の共通範囲

"""

A_B_time = []
C_D_time = []

for i in range(A,B):
    A_B_time.append(i)
for i in range(C,D):
    C_D_time.append(i)


def calc_common_range(time1, time2):
    common_range = []
    for i in time1:
        if i in time2:
            common_range.append(i)
    return common_range


print(len(calc_common_range(A_B_time, C_D_time)))



Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC033_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int h = int.Parse(strs[0]);
            int w = int.Parse(strs[1]);
            int n = int.Parse(strs[2]);

            string[] strs_ = Console.ReadLine().Split(' ');
            int y = int.Parse(strs_[0]);
            int x = int.Parse(strs_[1]);

            string s = Console.ReadLine();
            string t = Console.ReadLine();

            int tkR = w, tkL = 1, tkU = 1, tkD = h;

            bool tkRflag = false;
            bool tkLflag = false;
            bool tkUflag = false;
            bool tkDflag = false;

            bool flag = true;

            for (int i = n - 1; i >= 0; --i)
            {
                char ao = t[i];

                if (tkLflag && ao == 'R') { if (tkL > 1) --tkL; }
                else if (tkRflag && ao == 'L') { if (tkR < w) ++tkR; }
                else if (tkDflag && ao == 'U') { if (tkD < h) ++tkD; }
                else if (tkUflag && ao == 'D') { if (tkU > 1) --tkU; }

                char tk = s[i];

                if (tk == 'R') { tkRflag = true; --tkR; if (tkR < tkL) flag = false; }
                else if (tk == 'L') { tkLflag = true; ++tkL; if (tkL > tkR) flag = false; }
                else if (tk == 'U') { tkUflag = true; ++tkU; if (tkU > tkD) flag = false; }
                else if (tk == 'D') { tkDflag = true; --tkD; if (tkD < tkU) flag = false; }
            }

            if (flag)
            {
                flag = (tkL <= x && x <= tkR && tkU <= y && y <= tkD);
            }

            Console.WriteLine("{0}", flag ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 14560
S=input()
r='AC'
if S[0]!='A':
    r='WA'
count=0
for s in S:
    if str(s).isupper():
        count+=1
if count!=2:
    r='WA'
if 'C' not in S[2:-1]:
    r='WA'
print(r)

Measured memory_bytes: 38256
#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,k; cin >> n >> k;
    int ans = 0;
    rep(i,n) {
        int h; cin >> h;
        if (h >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//limit is inclusive
function printMultiplicationsTable(start, limit) {
	for(var i = start; i <= limit; i++) {
  	for(var k = start; k <= limit; k++) {
    	console.log(i + "x" + k + "=" + (i*k));
    }
  }
}

printMultiplicationsTable(1, 9);

Measured memory_bytes: 15476
#include <iostream>
#include <bits/stdc++.h>
#define mod 998244353
typedef long long ll;

using namespace std;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) ;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

long double  NCR(int n, int m){
    long double res = 1;
    m = min(m, n - m);
    for(int i = 0; i < m; i++){
        res = res * ( n - i) / (i + 1);
 }
    return res;
}
ll tol(string a){
    ll res=0;
    while(a[0]=='0'){
        a.erase(a.begin());
    }
    if(a=="")a="0";
    for(int i=0; i<a.size(); i++){
        res*=10; res+=a[i]-'0';
    }
    return res;
}
int check(string a, string b){
    for(int i=0; i<a.size(); i++){
        if(a[i]>b[i])return 1;
        if(b[i]>a[i])return -1;
    }
    return 0;
}
class data{
public:
    ll v,d,p;
    data(){}
    data(ll vv, ll dd, ll pp){
        v=vv;  d=dd; p=pp;
    }
};

int primeFactors(int n)
{
    ll c=0;
    while (n % 2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i*i <= n; i = i + 2)
    {
        while (n % i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}
int n,m, counter;
vector<int>arr[200005];
int vis[200005];
void dfs(int node){
    vis[node]=1; counter++;
    for(int i=0; i<arr[node].size(); i++){
        if(!vis[arr[node][i]])dfs(arr[node][i]);
    }
}
int main()
{
    Fastio();
    int n; cin>>n;
    ll arr[n+1];
    pair<ll,ll> a[n+1];
    memset(a,0,sizeof(a));
    ll res=0;
    for(int i=0; i<=n; i++){cin>>arr[i];}
    for(int i=0; i<n; i++){cin>>a[i].first;}
    for(int i=0; i<=n; i++){
        ll tmp=min(arr[i],a[i].second);
        res+=tmp; arr[i]-=tmp;
        tmp=min(arr[i],a[i].first);
        res+=tmp; a[i].first-=tmp;
        a[i+1].second+=a[i].first;
    }
    cout<<res<<'\n';

    return 0;
}



Measured memory_bytes: 7936
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
from queue import PriorityQueue
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)
N, K = LI()
H = LI()
ans=0
for h in H:
    if h >= K:
        ans +=1

print(ans)


Measured memory_bytes: 90524
#include <stdio.h>

int main(){
  int K,S;
  scanf("%d %d",&K,&S);
  
  int i,j;
  int x,y,z;
  int sum,count = 0;
  
  for(j=0;j<=K;j++){
    for(i=0;i<=K;i++){
      x = i;
      y = j;
      z = S - x - y;
      
      if(z>=0 && z<=K) count++;
    }
  }
  
  printf("%d\n",count);
}
    

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

bool isPalindrome(string s, int i, int j) {
	while(i < j) {
		if(s[i] != s[j]) {
			return false;
		}
		i++;
		j--;
	}
	return true;
}
int main() {
	string s;
	cin >> s;

	int a = (s.length() - 1 ) / 2;
	int b = (s.length() + 3 ) / 2;

	if(isPalindrome(s, 0, s.length()-1) && isPalindrome(s, 0, a-1) && isPalindrome(s, b-1, s.length()-1)) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  if(n%2==1) n *= 2;
  cout << n << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb(a) push_back(a)
#define pbp(a,b) push_back({a,b})
#define rep(p,a,b)    for(int p=a;p<b;p++)
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define INF 0x3f3f3f3f

ll nextPowerOf2(ll n)   
{ 
    n--; 
    n |= n >> 1ll; 
    n |= n >> 2ll; 
    n |= n >> 4ll; 
    n |= n >> 8ll; 
    n |= n >> 16ll; 
    n++; 
    return n; 
}

bool cmp(ll a,ll b)
{
    return (a>b);
}

int main() {
    
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,i,j;

    int x,y;
    cin>>x>>y;
    if(y%2==0 && y/2>=x && 2*x>=y/2)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define ran 101111

int n;
char s[ran];

int main() {
	scanf("%s", s);
	n = strlen(s);
	
	int l = (n-1)/2, r = n/2;
	while(l>0 && s[l]=='1') l--;
	while(r<n-1 && s[r]=='1') r++;
	if (s[l]=='0') l++;
	if (s[r]=='0') r--;
	
	if (l>r) {
		l = (n-1)/2, r = n/2;
		while(s[l]=='0' && s[r]=='0') {
			l--; r++;
			if (l<0 || r>=n) {
				printf("%d\n", n);
				return 0;
			}
		}
		l = r;
	}

	// ...l...r...
	//printf("%d %d\n", l, r);
	int ans = max(
			min(r+1, max(l, n-l)),
			min(n-l, max(r+1, n-r-1))
		);
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<pll> ps(N);
    for(auto & in:ps) cin >> in.first >> in.second;
    if(N == 1) return 1;
    sort(ps.begin(),ps.end());
    res = INF;
    for(int i = 0; i < N;i++){
        for(int j = 0; j < N;j++){
            if(i == j) continue;
            ll p = ps[j].first - ps[i].first;
            ll q = ps[j].second - ps[i].second;
            
            ll C = 0;
            for(int ii = 0; ii < N;ii++){
                for(int jj = 0; jj < N; jj++){
                    if(ii == jj) continue;
                    ll pp = ps[jj].first - ps[ii].first;
                    ll qq = ps[jj].second - ps[ii].second;
                    
                    if(pp == p && qq == q) C++;
                }
            }
            res = min(res,N-C);
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
use std::collections::HashMap;

fn poll() -> Result<(), &'static str> {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input)
        .map_err(|_| "input error")?;
    let n = input.trim_right().parse::<usize>()
        .map_err(|_| "parse error")?;

    let mut sn: HashMap<String, u32> = HashMap::with_capacity(n);

    for _ in 0..n {
        let mut input = String::new();
        std::io::stdin().read_line(&mut input)
            .map_err(|_| "input error")?;
        let input = input.trim_right().to_string();
        let num = sn.entry(input).or_insert(0);
        *num += 1;
    }

    let mut max = 0_u32;
    for v in sn.values() {
        if max < *v {
            max = *v;
        }
    }

    let mut snv:Vec<&String> = 
        sn.iter()
        .filter_map(
            |(k, v)|
            if *v == max {
                Some(k)
            }
            else
            {
                None
            }).collect();
    snv.sort();
    for s in snv {
        println!("{}", s);
    }
    Ok(())
}

fn main() {
    poll().unwrap();
}


Measured memory_bytes: 20348
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n,c;
    cin>>n>>c;
    
    vector<vector<pii>> segs(c);
    rep(i,n){
        int s,t,b;
        cin>>s>>t>>b;
        segs[b-1].pb(pii(s,t));
    }
    
    vector<vector<pii>> segs2(c);

    rep(i,c){
        sort(all(segs[i]));
        if(segs[i].size()==0)continue;
        int l = segs[i][0].first;
        int r = segs[i][0].second;
        
        for(int j=1;j<segs[i].size();j++){
            if(r==segs[i][j].first){
                r = segs[i][j].second;
            }else{
                segs2[i].pb(l,r);
                l = segs[i][j].first;
                r = segs[i][j].second;
            }
        }
        segs2[i].pb(l,r);
    }
    
    vector<int> im(300000,0);
    rep(i,c){
        rep(j,segs2[i].size()){
            im[2*segs2[i][j].first-1]++;
            im[2*segs2[i][j].second]--;
        }
    }
    rep(i,300000-1)im[i+1]+=im[i];
    
    cout<<*max_element(all(im))<<endl;
 }


Measured memory_bytes: 3584
#include<iostream>
#include<string>
using namespace std;
bool ans[100001];
bool start[4][2] = {{true,true},{true,false},{false,true},{false,false}};
int main(){
    int N;
    string s;
    cin >> N >> s;
    for(int i=0;i<4;i++){
        ans[0] = start[i][0];
        ans[1] = start[i][1];
        if(ans[0]){
            if(s[0] == 'o') ans[N+1] = ans[1];
            else ans[N+1] = !ans[1];
        }
        else{
            if(s[0] == 'o') ans[N+1] = !ans[1];
            else ans[N+1] = ans[1];
        }
        for(int j=1;j<N;j++){
            if(ans[j]){
                if(s[j] == 'o') ans[j+1] = ans[j-1];
                else ans[j+1] = !ans[j-1];
            }
            else{
                if(s[j] == 'o') ans[j+1] = !ans[j-1];
                else ans[j+1] = ans[j-1];
            }
        }
        if(ans[N+1] != ans[N-1]||ans[N] != ans[0]) continue;
        for(int i=0;i<N;i++){
            if(ans[i]) cout << 'S';
            else cout << 'W';
        }
        cout << endl;
        return 0;;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <set>

using namespace std;

int main() {
	int n;
	cin >> n;
	
	set<string> set;
	string word;
	char c;
	bool ng = false;
	for (int i = 0; i < n; ++i) {
		cin >> word;
		
		if (set.find(word) != set.end()) {
			ng = true;
			break;
		}
		
		set.insert(word);
		
		if (i != 0 && c != word.front()) {
			ng = true;
			break;
		}
		
		c = word.back();
	}
	
	if (ng) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;



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

    vector<int> cnt_w(n + 1), cnt_b(n + 1);
    rep(i, n){
        if(s[i] == '#')cnt_b[i + 1]++;
        if(s[i] == '.')cnt_w[i + 1]++;
        cnt_b[i + 1] += cnt_b[i];
        cnt_w[i + 1] += cnt_w[i];
    }
    int res = INF;
    rep(i, n + 1){
        res = min(res, cnt_b[i] + cnt_w[n] - cnt_w[i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 2180
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            if( h==0 && w==0 ) break;
            for(int i=0;i<h;i++){
                if(i==0||i==h-1){
                for(int j=0;j<w;j++){
                    System.out.print("#");
                }
                }else{
                        System.out.print("#");
                        for(int j=0;j<w-2;j++){
                            System.out.print(".");
                        }
                            System.out.print("#");
                        
                    }
                        System.out.println("");
                    }
                    System.out.println();
                }
    }
}
    


Measured memory_bytes: 32836
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    string s; cin >> s;
    int n = s.size();


    vector<int> ans(n, 0);

    int r_cnt = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') r_cnt++;
        else {
            ans[i] += r_cnt / 2;
            ans[i - 1] += (r_cnt + 1) / 2;
            r_cnt = 0;
        }
    }

    int l_cnt = 0;
    for(int i = n - 1; i >= 0; i--) {
        if(s[i] == 'L') l_cnt++;
        else {
            ans[i + 1] += (l_cnt + 1) / 2;
            ans[i] += l_cnt / 2;
            l_cnt = 0;
        }
    }

    for(int i = 0; i < n; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1408
import math

def digit(n):
    return len(str(n))

def digitsum(n):#nは正の整数、各位の和、許容は１０＾１０００
    if n<10:
        return n
    else:
        m=n//10
        return n%10+digitsum(m)

def maxdigit(N):
    if digit(N)==1:
        return N
    else:
        return max([9*(digit(N)-1)+int(str(N)[0])-1,digitsum(N)])

N=int(input())
print(maxdigit(N))


Measured memory_bytes: 3060
N = int(input())
ans = ''

for i in range(1,99):
    if N <= 26**i: #名前の長さが分かる
        N-=1
        for j in range(i):
            ans += chr(ord('a')+ N%26)
            # ord()の引数に文字を指定するとそのユニコードがintで帰ってくる，
            # chr()に整数を指定すると文字がstrで返ってくる
            N //= 26
        break
    else:
        N -= 26 **i


print(ans[::-1]) #stepが-1つまり後ろから表示

Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
#define MOD 100000000;
#define EPS 0.001
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    int n;
    cin>>n;
    cout<<fixed<<setprecision(6);
    double ans= (n-n/2)/(double)n;
    cout<<ans;
    return 0;
}


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

#define INF 1e9
#define MAX 100005
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define ull long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
#define zai <<' '<<
#define all(a) a.begin(),a.end()
#define pc __builtin_popcount
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int visin[MAX],visout[MAX];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,m;
	cin >> n >> m;
	int minl=INF,maxr=0;
	for(int i=0;i<m;i++){
		int l,r;
		cin >> l >> r;
		if(l<minl)minl=l;
		if(r>maxr)maxr=r;
		visin[l]+=1;
		visout[r]-=1;
	}
	int res=0;
	int ans=0;
	for(int i=minl;i>=1 && i<=n && i<=maxr;i++){
		res+=visin[i];
		if(res==m)ans++;
		res+=visout[i];
		if(visout[i]!=0){
			if(res+visout[i]==m)ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pll pair<ll, ll>
#pragma GCC optimize ("O3")
using namespace std;
int main () {
    #ifdef LOCAL
        freopen ("input.txt", "r", stdin);
        freopen ("output.txt", "w", stdout);
        freopen ("error.txt", "w", stderr);
    #else
        ios::sync_with_stdio(false);
        cin.tie (NULL);
    #endif
    int a; cin>>a;
    string s; cin>>s;
    if (a<3200) cout<<"red";
    else cout<<s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* nichijou */
template<class T,class U>
bool cmax(T & a, const U & b) {return a < b ? a = b, 1 : 0;}
template<class T,class U>
bool cmin(T & a, const U & b) {return b < a ? a = b, 1 : 0;}
/* data type */
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second
/* STL container */
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)(a).size())
#define ALL(a) begin(a), end(a)
#define CLR(a) (a).clear()
#define BK(a) ((a).back())
#define FT(a) ((a).front())
#define DB(a) (a).pop_back()
#define DF(a) (a).pop_front()
#define PB push_back
#define EB emplace_back
/* I gave you my heart and then you turned around. */
void _BG(const char * s) {cerr<<s<<endl;}
template<class T, class ... TT>
void _BG(const char * s,T a, TT...b)
{
    for (size_t c = 0; *s && (c || *s != ','); cerr << *s++)
        c += count(ALL("([{"),*s) - count(ALL(")]}"),*s);
    cerr << " = " << a;
    if (*s) {
        cerr << ", ";
        ++s;
    }
    _BG(s,b...);
}
#ifdef PR3PONY
#define BG(...) do { \
    cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
    _BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)
#else
#define BG(...)
#endif
/* Good Luck && Have Fun ! */
const int N = 2e5 + 87;
ll a[N], c[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll tot = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        tot += c[a[i]]++;
    }
    for (int i = 0; i < n; ++i) {
        cout << tot - c[a[i]] + 1 << '\n';
    }
}


Measured memory_bytes: 4736
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

bool solve() {
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    map<ll, ll> mp;
    rep(i, n) ++mp[a[i]];

    if(mp.size() == 1) {
        if(mp.begin()->first == 0) return true;
        else return false;
    }
    else if(mp.size() > 3) return false;

    if(n % 3 != 0) return false;

    vll b;
    for(auto i = mp.begin(); i != mp.end(); ++i) {
        if(i->second == n / 3) {
            b.push_back(i->first);
        }
        else if(i->second == 2 * n / 3) {
            b.push_back(i->first);
            b.push_back(i->first);
        }
        else return false;
    }

    for(ll i = 0; i < 35; i++) {
        ll cnt = 0;
        for(ll j = 0; j < 3; j++) {
            if((1ll << i) & b[j]) ++cnt;
        }
        if(cnt == 1 || cnt == 3) return false;
    }
    return true;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cout << (solve() ? "Yes" : "No") << endl;
}

Measured memory_bytes: 8592
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        int[] values = new int[N];
        int[] costs = new int[N];

        for (int i = 0; i < N; i++) {
            values[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            costs[i] = sc.nextInt();
        }

        int result = 0;
        for (int i = 0; i < N; i++) {
            if (values[i] > costs[i]) {
                result += (values[i] - costs[i]);
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll n;
  cin >> n;
  vll a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  ll minm, maxm;
  if(n%2==0) {
    minm = a[n/2-1]+a[n/2];
    maxm = b[n/2-1]+b[n/2];
  }
  else {
    minm = a[(n+1)/2-1];
    maxm = b[(n+1)/2-1];
  }
  cout << maxm-minm+1 << endl;
  return 0;
}

Measured memory_bytes: 6360
import itertools
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
l=[]
for i in range(1,n+1):
    l.append(i)
l=list(itertools.permutations(l))
l=sorted(l)
k=1
for i in range(1,n+1):
    k*=i
pp=0
qq=0
if p==q:
    print(0)
else:
    for j in range(k):
        if l[j]==p:
            pp=j+1
        elif l[j]==q:
            qq=j+1
    print(abs(pp-qq))

Measured memory_bytes: 8308
#include<bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main()
{
  string s;
  //scanf("%s", &s);
  cin >> s;
 int l = s.length();
  if (s.length() <= 1)
  {
    cout << 0;
	return 0;
  }
  //int a[s.length];
 // try{s.stoi(a)}
 // catch(std::run_time_error e)
  int z,count = 0;  
  for(int i = 0; i < s.length(); i++)
  {
    int p = 1;
    int ti = s[i] - '0';
   p^=ti;
    if (p)
      z++;
  }
  if(z >= l)
    cout << 0; 
  else{ 
    z =  min(z, l-z);
    cout <<2*z;
	}
}

Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int H = sc.nextInt();
		
		NodeCBT[] nod = new NodeCBT[H+1];
		for(int i=1; i<=H; i++) {
			int key = sc.nextInt();
			nod[i] = new NodeCBT(i, key, H);
		}
		
		for(int i=H/2; i>=1; i--) {
			nod[i].maxHeapify(nod);
		}
		
		StringBuilder ans = new StringBuilder();
		for(int i=1; i<=H; i++) {
			ans.append(" ");
			ans.append(nod[i].key);
		}
		System.out.println(ans);
	}

	static class NodeCBT {
		int id;
		int key;
		int parent;
		int left;
		int right;
		
		NodeCBT(int id, int key, int H) {
			this.id = id;
			this.key = key;
			if(id != 1) {
				parent = id / 2;
			} else {
				parent = -1;
			}
			if(2 * id <= H) {
				left = 2 * id;
			} else {
				left = -1;
			}
			if(2 * id + 1 <= H) {
				right = 2 * id + 1;
			} else {
				right = -1;
			}
			
		}
		
		void maxHeapify(NodeCBT[] nod) {
			int largest = key;
			if(left != -1 && nod[left].key > key && nod[left].key > largest) {
				largest = nod[left].key;		
			}
			if(right != -1 && nod[right].key > largest) {
				largest = nod[right].key;
				
			}
			
			if(left != -1 && largest == nod[left].key) {
				int temp = key;
				key = nod[left].key;
				nod[left].key = temp;
				nod[left].maxHeapify(nod);
			} else if(right != -1 && largest == nod[right].key) {
				int temp = key;
				key = nod[right].key;
				nod[right].key = temp;
				nod[right].maxHeapify(nod);
			}
		}
	} 

	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	    public int nextInt(){
	    	return Integer.parseInt(next());
	    }
	}
}

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

int main(){
  long long n,k,m=1e9+7,dp[1002][1002]={};
  cin>>n>>k;
  dp[0][0]=1;
  for(int i=0;i<n;i++){
    for(int j=0;j<=k;j++){
      ( dp[i+1][j]+=dp[i][j]*j )%=m;
      ( dp[i+1][j+1]+=dp[i][j]*(k-j) )%=m;   
    }
  }
  cout<<dp[n][k]<<endl;
  return 0;
}


  



Measured memory_bytes: 10928
#!/mnt/c/Users/moiki/bash/env/bin/python
# import math
from functools import reduce
def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

N,X = map(int, input().split())
A = list(map(int, input().split()))
A = [ abs(a-X) for a in A]

print( reduce(gcd, A) )



Measured memory_bytes: 14748