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

int main() {
    string s;
    cin >> s;
    vector<int> v(2019, 0);
    v[0] = 1;
    int n = s.size();
    int dp = 0;
    int p = 1;
    long long sum = 0;
    for(int i = 0; i < n; ++i) {
        dp = (dp + (s[n-i-1]-'0') * p) % 2019;
        p = (p * 10) % 2019;
        sum += v[dp];
        v[dp]++;
    }

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

Measured memory_bytes: 3720
#include "bits/stdc++.h"

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<pair<int, char>> seg;
  {
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
      if (i + 1 < N && s[i] != s[i + 1]) {
        cnt++;
        seg.emplace_back(cnt, s[i]);
        cnt = 0;
      } else if (i + 1 == N) {
        cnt++;
        seg.emplace_back(cnt, s[i]);
        cnt = 0;
      } else {
        cnt++;
      }
    }
  }

  int ans = 0;
  int cur_k = 0;
  int right = 0;
  int pre = 0;
  for (int i = 0; i < (int)seg.size(); i++) {
    while (right < (int)seg.size() && (seg[right].second == '1' || cur_k < K)) {
      pre += seg[right].first;
      if (seg[right].second == '0') cur_k++;
      right++;
    }
    ans = max(ans, pre);
    
    pre -= seg[i].first;
    if (seg[i].second == '0') cur_k--;
  }

  cout << ans << endl;
  
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

const int N = 365 + 7;
const int K = 26 + 7;
int n;
int c[K], s[N][K], t[N], last[K];

int get(int m) {
  for (int j = 1; j <= 26; j++) {
    last[j] = 0;
  }
  int ct = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= 26; j++) {
      ct -= c[j] * i;
    }
  }
  int sol = 0, grow = 0;
  for (int i = 1; i <= m; i++) {
    sol += s[i][t[i]];
    grow += c[t[i]] * (i - last[t[i]]);
    last[t[i]] = i;
    sol += grow;
  }
  return sol + ct;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= 26; i++) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 26; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }
  for (int i = 1; i <= n; i++) {
    cout << get(i) << "\n";
  }
  return 0;
}


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

int main(void){string s,t;cin>>s>>t;
  long long a=0,c=0,n=s.length(),m=t.length(),x;
  bool ok=true;
  vector<set<int>>v(26);
  rep(i,26)v[i].insert(M);
  rep(i,n)v[s[i]-'a'].insert(i+1);
  rep(i,m){
    x=t[i]-'a';
    c=*v[x].upper_bound(c);
    if(c==M)++a,c=*v[x].begin();
    if(c==M)ok=false;
  }
  cout<<(ok?a*n+c:-1)<<endl;
  return 0;
}


Measured memory_bytes: 8540
#include<bits/stdc++.h> 
using namespace std;
int main(){
	int n,k,m,ok=1,num=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>k;
		if(ok){
			m=k;
			ok=0;
		}
		else {
			if(m<=k){
				num++;
			//	cout<<m<<" "<<k<<"\n";
			} 
			m=min(k,m);
		}
	}
	cout<<n-num<<"\n";
	return 0;
}



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

using namespace std;

int main() {
    size_t h, w;
    cin >> h >> w;
    vector<string> grid(h);
    for (size_t i = 0; i < h; ++i) cin >> grid[i];
    bool enable = true;
    for (size_t y = 0; y < h; ++y) {
        for (size_t x = 0; x < w; ++x) {
            if (grid[y][x] == '#') {
                if (!((y != 0 && grid[y - 1][x] == '#') || (x != (w - 1) && grid[y][x + 1] == '#') || (y != (h - 1) && grid[y + 1][x] == '#') || (x != 0 && grid[y][x - 1] == '#'))) {
                    enable = false;
                    break;
                }
            }
        }
        if (!enable) break;
    }
    cout << (enable ? "Yes" : "No") << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);

    while (1)
    {
        if (n == 0)
        {
            printf("No");
            break;
        }
        if (n % 10 == 7)
        {
            printf("Yes");
            break;
        }
        n /= 10;
    }
    return 0;
}

Measured memory_bytes: 1732
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

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

    auto a = vector<large>(n);
    for (auto& a_i : a) {
        cin >> a_i;
        if (a_i == 0)
            goto zero;
    }

    {
        const auto limit = 1'000'000'000'000'000'000LL;
        auto x = large(1);
        for (auto a_i : a) {
            // x * a_i > limit
            if (a_i > limit / x)
                goto fail;
            x *= a_i;
        }

        cout << x << endl;
    }
    return 0;

zero:
    cout << "0" << endl;
    return 0;

fail:
    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 3976
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N;
	ll res=0;
	vector<ll> C(5,0);
	cin>>N;
	for(int i=0;i<N;i++)
	{
		string s;
		cin>>s;
		switch(s[0])
		{
			case 'M':C[0]++;break;
			case 'A':C[1]++;break;
			case 'R':C[2]++;break;
			case 'C':C[3]++;break;
			case 'H':C[4]++;break;
		}
	}
	for(int i=0;i<C.size();i++)
		for(int j=i+1;j<C.size();j++)
			for(int k=j+1;k<C.size();k++)
				res+=C[i]*C[j]*C[k];
	cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin >>a >>b >>c >> k;
  if(a >= k)cout<< k <<endl;
  else if(a+b >= k)cout << a << endl;
  else cout << a-(k-a-b) <<endl;
}

Measured memory_bytes: 3628
program main
  implicit none
  integer :: a, b, i
  character(11) :: s
  logical :: ishyphen, needhyphen
  read(*, *) a, b
  read(*, *) s
  do i = 1, a + b
    ishyphen = (s(i:i) == "-")
    needhyphen = (i == a + 1)
    if (ishyphen .neqv. needhyphen) then
      write(*, "(a)") "No"
      stop 0
    end if
  end do
  write(*, "(a)") "Yes"
end program main


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int N;
	cin >> N;
	if (N % 10 == 9 || N / 10 == 9)print("Yes"); else print("No");





	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        Main instance = new Main();
        instance.solve();
    }

    private void solve() {

        String s = sc.next();

        s = s.replace("eraser","1");
        s = s.replace("erase","1");
        s = s.replace("dreamer","1");
        s = s.replace("dream","1");
        s = s.replace("1","");
        System.out.println(s.equals("") ? "YES":"NO");
    }
}

Measured memory_bytes: 29636
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] a = new int [N];
        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[N-1]-a[0]);
    }
}

Measured memory_bytes: 22736
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int R,C,Q;
	cin >> R >> C >> Q;
	vector< vector< bool> > fld(R,vector<bool>(C,false));
	vector< vector< int > > num(R,vector<int>(C,0));//青ﾏｽ累積
	vector< vector< int > > RR(R,vector<int>(C,0));//縦の辺
	vector< vector< int > > CC(R,vector<int>(C,0));//横の辺
	//横一列の情報
	for(int i=0;i<R;++i){
		string str;
		cin >> str;
		for(int j=0;j<C;++j){
			if( str[j] == '1' ){
				fld[i][j] = true;
			}
		}
	}
	//青マスの累積和
	for(int r=0;r<R;++r){
		num[r][0] = fld[r][0];
		for(int c=1;c<C;++c){
			num[r][c] += num[r][c-1] + fld[r][c];
		}
	}
	for(int c=0;c<C;++c){
		for(int r=1;r<R;++r){
			num[r][c] += num[r-1][c];
		}
	}
	//縦の累積和
	for(int c=0;c<C;++c){
		for(int r=1;r<R;++r){
			RR[r][c] += RR[r-1][c];
			if( fld[r][c] && fld[r-1][c] ){
				++RR[r][c];
			}
		}
	}
	for(int r=0;r<R;++r){
		for(int c=1;c<C;++c){
			RR[r][c] += RR[r][c-1];
		}
	}
	//横の累積和
	for(int r=0;r<R;++r){
		for(int c=1;c<C;++c){
			CC[r][c] += CC[r][c-1];
			if( fld[r][c] && fld[r][c-1] ){
				++CC[r][c];
			}
		}
	}
	for(int c=0;c<C;++c){
		for(int r=1;r<R;++r){
			CC[r][c] += CC[r-1][c];
		}
	}

	int R1,C1,R2,C2;
	while(Q--){
		cin >> R1 >> C1 >> R2 >> C2;
		--R1;--C1;--R2;--C2;
		int res = 0;
		res = num[R2][C2];
		if( C1>0 )res -= num[R2][C1-1];
		if( R1>0 )res -= num[R1-1][C2];
		if( C1>0 && R1>0 ) res += num[R1-1][C1-1];
		
		int ER=0;
		ER = RR[R2][C2];
		if( C1>0 ) ER -= RR[R2][C1-1];
		ER -= RR[R1][C2];
		if( C1>0 ) ER += RR[R1][C1-1];

		int EC=0;
		EC = CC[R2][C2];
		EC -= CC[R2][C1];
		if( R1>0 ) EC -= CC[R1-1][C2];
		if( R1>0 ) EC += CC[R1-1][C1];
		cerr << "\t";
		cout << res-ER-EC << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 50304
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
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 S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,x = LI()
    l = [1]
    p = [1]
    for i in range(n):
        l.append(l[-1]*2+3)
        p.append(p[-1]*2+1)

    def f(n,x):
        if x <= 0:
            return 0
        if n == 0:
            return 1
        nl = l[n]
        if x <= nl // 2:
            return f(n-1,x-1)
        r = p[n-1] + 1
        r += f(n-1, x - nl // 2 - 1)
        return r

    return f(n,x)


print(main())


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

int n, k, cur, t = 0, ma = 0;

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

int main()
{
    scanf("%d%d", &n, &k);
    while (n--)
    {
        scanf("%d", &cur);
        ma = max(ma, cur);
        t = gcd(cur, t);
    }
    if (ma >= k && k % t == 0)
        printf("POSSIBLE");
    else printf("IMPOSSIBLE");
}


Measured memory_bytes: 256
from heapq import heappush,heappop

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

N = int_raw()
Hs = ints_raw()
def ans():

    ans =0
    for i in range(len(Hs)):
        is_v = 1
        for j in range(i):
            if Hs[i]<Hs[j]:
                is_v=0
                break
        ans+=is_v

    return ans

print(ans())



Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		String m = sc.next();
		
		char c[] = m.toCharArray();
		y = y -1;
		if(c[y]=='A'){
			c[y] = 'a';			
		}else if(c[y]=='B'){
			c[y] = 'b';
		}else{
			c[y] = 'c';
		}
		
		for(int i = 0;i < c.length; i++){
			System.out.print(c[i]);
		}
	}
}


Measured memory_bytes: 23124
#include <iostream>
using namespace std;
int main(){
	int x,y,a=0;
	cin >> x >> y;
	for (int i = 0; i <= x;i++)
		if (i * 4 + (x - i) * 2 == y)
			a++;
	if (a == 0)
		cout << "No";
	else
		cout << "Yes";
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  int count=0;
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
      if(a[i]>=k)
        count++;

  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
   int uniquepath(vector<vector<char>>& obstacleGrid) {
        int row=obstacleGrid.size();
        int col=obstacleGrid[0].size();
        int dp[row][col];
        if(obstacleGrid[row-1][col-1]=='#')
        {
            return 0;
        }
        memset(dp,0,sizeof dp);
        for(int i=0;i<row;i++)
        {
            for(int j=0;j<col;j++)
            {
                if(obstacleGrid[i][j]=='#')
                {
                    dp[i][j]=-1;
                }
            }
        }
        for(int i=0;i<col;i++)
        {
            if(dp[0][i]==-1)
            {
                break;
            }
            dp[0][i]=1;
        }
        for(int i=0;i<row;i++)
        {
            if(dp[i][0]==-1)
            {
                break;
            }
            dp[i][0]=1;
        }
        for(int i=1;i<row;i++)
        {
            for(int j=1;j<col;j++)
            {
                if(dp[i][j]==-1)
                {
                    continue;
                }
                if(dp[i-1][j]!=-1)
                {
                    dp[i][j]=dp[i-1][j]%1000000007;
                }
                if(dp[i][j-1]!=-1)
                {
                    dp[i][j]=(dp[i][j]+dp[i][j-1])%1000000007;
                }
            }
        }
    
        return dp[row-1][col-1];
        
    }
int main()
{
    int row,col;
    cin>>row>>col;
    vector<vector<char>>v(row,vector<char>(col));
    for(int i=0;i<row;i++)
    {
        for(int j=0;j<col;j++)
        {
            cin>>v[i][j];
        }
    }
    cout<<uniquepath(v)<<endl;
}

Measured memory_bytes: 8492
n = int(input())
h = list(map(int, input().split()))
cost = [0] * n
cost[1] = abs(h[0] - h[1])
for i in range(2, n):
    one = cost[i - 1] + abs(h[i - 1] - h[i])
    two = cost[i - 2] + abs(h[i - 2] - h[i])
    cost[i] = min(one, two)
print(cost[n - 1])

Measured memory_bytes: 13980
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
double ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n,b,r;
 sc(n);sc(b);sc(r);
 pr(n/(b+r)*b+min(b,n%(b+r)));
return 0;}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int a;
    for(auto i = 0; i < N; i++){
        cin >> a;
        if(a % 2 == 0) {
            if(a % 3 != 0 && a % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
      }
    }
    cout << "APPROVED" << endl;
    return 0;
}

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

class figure{
public:
  	int a, b, c, d, e;
 	 void extract10000(int N){
      	this->a = N/10000;
    }
};

int main(){
  	int A0, B0, temp, counter = 0;
  	
  	cin >> A0 >> B0;
  
  	figure A, B;
  
  	A.extract10000(A0);	B.extract10000(B0);
  
  	for(int j = A.a;j <= B.a; j++){
      	for(int k = 0;k <= 9; k++){
        	for(int l = 0;l <= 9; l++){
            	temp = 10000*j+1000*k+100*l+10*k+j;
              	if(temp >= A0 && temp <= B0)	counter++;
            }
        }
    }
  
  	cout << counter << endl;
  
  	return 0;
}

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

if number>=3600:
    if number>=3660:
        h=number//3600
        m=(number-h*3600)//60
        s=(number-h*3600)-m*60
    else:
        h=number//3600
        m=0
        s=(number-h*3600)
        pass
else:
    if number>=60:
        h=0
        m=number//60
        s=number-m*60
    else:
        h=0
        m=0
        s=number
print(str(h)+":"+str(m)+":"+str(s))









Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main(){
  int n;cin>>n;
  vector<vector<int>>a(3,vector<int>(n));
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>a.at(j).at(i);
    }
  }
  vector<vector<ll>>dp(n,vector<ll>(3,0));
  for(ll i=0;i<3;i++){
    dp.at(0).at(i)=a.at(i).at(0);
  }
  for(ll i=1;i<n;i++){
    for(ll j=0;j<3;j++){
      for(ll k=0;k<3;k++){
        if(k!=j){
          dp.at(i).at(k)=max(dp.at(i).at(k),dp.at(i-1).at(j)+a.at(k).at(i));
        }
      }
    }
  }
  cout <<max(dp.at(n-1).at(0),max(dp.at(n-1).at(1),dp.at(n-1).at(2)))<<endl;
}

Measured memory_bytes: 9840
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;

struct P{
  int x,y;
  bool operator < (const P &a )const{
    if(x!=a.x) return x<a.x;
    return y<a.y;
    
  };
};

int a,b,c,d,i,n,m,e,k,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[222221];
int l[1];
int ss[1];

long long x,y,z,mod=1000000007,hf=(mod+1)/2;

//string r;
char r[1];
vector<int> v;
P u[1];

queue<int> q;
//set<int> s;
stack<int> s;
map<int,int> p;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng()
bool as(P a,P b)
{
  return a.y<b.y;
}

#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384626
typedef complex<double> base;
 
void fft(vector <base> &a, bool invert)
{
    int n = sz(a);
    for (int i=1,j=0;i<n;i++){
        int bit = n >> 1;
        for (;j>=bit;bit>>=1) j -= bit;
        j += bit;
        if (i < j) swap(a[i],a[j]);
    }
    for (int len=2;len<=n;len<<=1){
        double ang = 2*pi/len*(invert?-1:1);
        base wlen(cos(ang),sin(ang));
        for (int i=0;i<n;i+=len){
            base w(1);
            for (int j=0;j<len/2;j++){
                base u = a[i+j], v = a[i+j+len/2]*w;
                a[i+j] = u+v;
                a[i+j+len/2] = u-v;
                w *= wlen;
            }
        }
    }
    if (invert){
        for (int i=0;i<n;i++) a[i] /= n;
    }
}
 
void multiply(const vector<long long> &a,const vector<long long> &b,vector<long long> &res)
{
    vector <base> fa(all(a)), fb(all(b));
    int n = 1;
    while (n < max(sz(a),sz(b))) n <<= 1;
    fa.resize(n); fb.resize(n);
    fft(fa,false); fft(fb,false);
    for (int i=0;i<n;i++) fa[i] *= fb[i];
    fft(fa,true);
    res.resize(n);
    for (int i=0;i<n;i++) res[i] = (long long)(fa[i].real()+(fa[i].real()>0?0.5:-0.5));
}

int main()
{
  scanf("%d",&a);
  mod=200003;
  long long p=2;
  e=1;
  for(int t=0;t<mod-1;t++)
  {
    o[e]=t;
    e*=p;
    e%=mod;
  }
  long long po[444444];
  po[0]=1;
  for(int t=1;t<=mod*2;t++)
    po[t]=po[t-1]*2%mod;
  vector<long long> v1,v2,v;
  v1.resize(mod*2);
  v2.resize(mod*2);
  x=0;
  for(int t=1;t<=a;t++)
  {
    scanf("%d",&n);
    if(n==0) continue;
    v1[o[n]]++;
    v2[o[n]]++;
    //printf("%d ",o[n]);
    //x-=po[o[n]*2];
    x-=(long long)n*n%mod;
  }
  multiply(v1,v2,v);
  for(int h=0;h<v.size()&&h<=mod*2;h++)
  {
    x+=po[h]*v[h];
  }
  printf("%lld",x/2);
}



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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(3*n);
    rep(i, 3*n) cin >> a[i];
    ll tmp = 0;
    priority_queue<ll> pq;
    rep(i,n){
        tmp += a[i];
        pq.emplace(-a[i]);
    }
    vector<pair<ll,ll>> v;
    for(i = n;i < 3*n;++i){
        v.emplace_back(a[i], i);
    }
    sort(all(v));
    vector<bool> ind(3*n, false);
    for(i = 0;i < n;++i){
        tmp -= v[i].first;
        ind[v[i].second] = true;
    }
    priority_queue<pair<ll,ll>> pq2;
    for(i = n;i < 2*n;++i){
        pq2.emplace(-v[i].first, v[i].second);
    }
    ll ans = tmp;
    for(i = n;i < 2*n;++i){
        if(ind[i]){
            while(pq2.top().second <= i) pq2.pop();
            tmp += a[i];
            auto x = pq2.top();
            tmp += x.first;
            ind[x.second] = true;
            pq2.pop();
        }
        if(-pq.top() < a[i]){
            tmp -= -pq.top();
            pq.pop();
            tmp += a[i];
            pq.emplace(-a[i]);
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13164
use v5.18;
use warnings;
use Data::Dumper qw( Dumper );
use List::Util qw( sum );
sub line { chomp(my $str = <STDIN>); $str }
sub split_line { split / /, line }
my $spot_num = line;
my @points = (0, split_line, 0);
my $orig_sum_cost = sum map { abs($points[$_ - 1] - $points[$_]) } 1 .. $#points;
for my $spot (1 .. $#points - 1) {
  my ($cost, $left_cost, $right_cost) = ($points[$spot], $points[$spot - 1], $points[$spot + 1]);
  # 単調減少or増加 
  if ( ($left_cost <= $cost && $cost <= $right_cost) || ($left_cost >= $cost && $cost >= $right_cost) ) {
    say $orig_sum_cost;
  } else {
    my $orig_diff = abs($left_cost - $cost) + abs($cost - $right_cost);
    my $deleted_diff = abs($left_cost - $right_cost);
    say( $orig_sum_cost - ($orig_diff - $deleted_diff) );
  }
}

Measured memory_bytes: 22268
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    Set<Integer> set = new HashSet<>();
    for(int i = 0; i < N; i++){
      int n = Integer.parseInt(sc.nextLine());
      if(set.contains(n)){
        set.remove(n);
      }else{
        set.add(n);
      }
    }
    System.out.println(set.size());
  }
}

Measured memory_bytes: 95416
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int H, W;
int white_count,count = 0;
vector<pair<int, int>> tmp_chenge;

void one_chenge(int h,int w,vector<vector<int>> &v){
    if(h > 0){
      if(v[h - 1][w] == 0){
        v[h - 1][w] = 1;
        white_count--;
        tmp_chenge.push_back(make_pair(h -1, w));        
      }
    }
    if(h < H -1){
      if(v[h + 1][w] == 0){
        v[h + 1][w] = 1;
        white_count--;
        tmp_chenge.push_back(make_pair(h + 1, w));
      }
    }
    if(w > 0){
      if(v[h][w -1] == 0){
        v[h][w - 1] = 1;
        white_count--;
        tmp_chenge.push_back(make_pair(h, w - 1));
      }
    }
    if(w < W -1){
      if(v[h][w + 1] == 0){
        v[h][w + 1] = 1;
        white_count--;
        tmp_chenge.push_back(make_pair(h, w + 1));
      }
    }
}

int main(){
  cin >> H >> W;
  white_count = H * W;
  vector<vector<int>> v(H,vector<int>(W,0));
  
  //入力
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      char tmp;
      cin >> tmp;
      if(tmp == '#'){
        v[i][j] = 1;
        tmp_chenge.push_back(make_pair(i, j));
        white_count--;
      }
    }
  }
  //計算  
  int start_index = 0;
  while(white_count > 0){
    int tmp_size = tmp_chenge.size();
    for(int i = start_index; i < tmp_size; i++){
      one_chenge(tmp_chenge[i].first, tmp_chenge[i].second, v);
    }
    start_index = tmp_size;
    count++;
  }
  
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 14316
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
// Returns LCM of array elements 
ll findlcm(ll arr[],ll n) 
{ 
    // Initialize result 
    ll ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
int main() {
     ios::sync_with_stdio(false);
  cin.tie(0);
ll a;
cin>>a;
ll st=100;

ll cnt=0;
while(st<a)
{
    st+=st/100;
    cnt++;
}
cout<<cnt<<endl;
  
	// your code goes here
	return 0;
}


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

int main(void) {
	int N, X; cin >> N >> X;
	int m[N];
	int i,sum = 0;
	for (i = 0; i < N; i++) {
		cin >> m[i];
	}
	sort(m, m+N);

	for (i = 0; i < N; i++) {
		X = X - m[i];
		sum += 1;
	}
	
	if (m[0] <= X) {
		for (i = 0; m[0] <= X; i++) {
			X = X - m[0];
			sum += 1;
		}
	}

	cout << sum << endl;
	return 0;
}


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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

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

	int x;
	cin >> x;

	auto gcd = [](int a, int b){
		while (a){
			b %= a;
			swap(a, b);
		}
		return b;
	};

	cout << 360 / gcd(360, x) << '\n';

    return 0;
}


Measured memory_bytes: 3592
s = list(input())

ops = ["-", "+"]

for i in range(0, 2**3):
    dig = (bin(i)[2:]).zfill(3)
    #print(dig)
    sum = int(s[0])
    for j in range(0, 3):
        x = -1 if int(dig[j]) == 0 else 1
        sum += int(s[j + 1]) * x
    if (sum == 7):
        print(s[0] + ops[int(dig[0])] + s[1] + ops[int(dig[1])] + s[2] +
              ops[int(dig[2])] + s[3] + "=7")
        break
    #print(sum)


Measured memory_bytes: 3064
def simulator(n, a, b, s):
    print()
    boolean_list = ['No'] * n
    count = 0
    for i in range(n):
        if s[i]=='a' and count < a+b:
            count += 1
            boolean_list[i] = 'Yes'
        if s[i]=='b' and count < a+b and s[:i].count('b') <b :
            count += 1
            boolean_list[i] = 'Yes'
    
    for _ in boolean_list:
        print(_)

n, a, b = map(int,input().split())
s = input()
simulator(n, a, b, s)

Measured memory_bytes: 75732
import java.util.Scanner;

public class Main {

	void run() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n];
			for(int i=0;i<n;i++) {
				a[i] = sc.nextInt();
			}
			
			long sum1 = 0;
			long cnt1 = 0;
			// a[0] > 0
			for(int i=0;i<n;i++) {
				sum1 += a[i];
				if(i%2==0 && sum1 <= 0) {
					cnt1 += (1-sum1);
					sum1 = 1;
				}else if(i%2==1 && sum1 >= 0) {
					cnt1 += (1+sum1);
					sum1 = -1;
				}
			}
			
			long sum2 = 0;
			long cnt2 = 0;
			// a[0] < 0
			for(int i=0;i<n;i++) {
				sum2 += a[i];
				if(i%2==1 && sum2 <= 0) {
					cnt2 += (1-sum2);
					sum2 = 1;
				}else if(i%2==0 && sum2 >= 0) {
					cnt2 += (1+sum2);
					sum2 = -1;
				}
			}
			
			System.out.println(Math.min(cnt1, cnt2));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
	
}


Measured memory_bytes: 50576
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(N);
    ll A[N];
    FORI(i,0,N)
    {
        READ(A[i]);
        A[i]--;
    }
    READAR(B,N);
    READAR(C,N-1);
    ll ans=0;
    FORI(i,0,N)
    {
        ans+=B[A[i]];
        if (i+1<N && A[i]+1==A[i+1])
        {
            ans+=C[A[i]];
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]


K = int(input())
ans = 0

for i in range(1, K+1):
  for j in range(1, K+1):
    temp = gcd(i,j)
    for k in range(1, K+1):
      ans += gcd(temp,k)

print(ans)


Measured memory_bytes: 71112
#include <iostream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int main()
{
  stack<int> s;
  stack<pair<int, int> > t;
  int sum = 0;
  char c;
  
  for (int i = 0; cin >> c; i++) {
    if (c == '\\')
      s.push(i);
    if (c == '/' and s.size()) {
      int temp = i - s.top();
      sum += temp;
      while (t.size() and t.top().first > s.top()) {
        temp += t.top().second;
        t.pop();
      }
      t.push(make_pair(s.top(), temp));
      s.pop();
    }
  }
  
  vector<int> v;
  while(t.size()) {
    v.push_back(t.top().second);
    t.pop();
  }
  
  cout << sum << endl << v.size();
  for (int i = v.size()-1; i >= 0 ; i--)
    cout << ' ' << v[i];
  cout << endl;
}


Measured memory_bytes: 3184
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
ld getdis(const pair<ld, ld>&l, const pair<ld, ld>&r) {
	return sqrt((l.first - r.first)*(l.first - r.first) + (l.second - r.second)*(l.second - r.second));
}
ld getans(const vector<pair<ld, ld>>&ps,int l,int r) {
	if (r-l == 2) {
		return getdis(ps[l], ps[l+1]);
	}
	else if (r-l ==1) {
		return 1e18;
	}
	else {
		int n = (r+l) / 2;
		auto nit = ps.begin() + n;
		ld la = getans(ps,l,n);
		ld ra = getans(ps,n,r);
		ld nans = min(la, ra);
		auto lit = lower_bound(ps.begin()+l, ps.begin()+r, make_pair(ps[n].first - nans, -1e18l));
		auto rit = upper_bound(ps.begin() + l, ps.begin() + r, make_pair(ps[n].first + nans,  1e18l));
		for (auto a = lit; a != nit; ++a) {
			for (auto b =nit; b != rit; ++b) {
				nans = min(nans, getdis(*a, *b));
			}
		}
		return nans;
	}
}

int main() {
	int N; cin >> N;
	vector<pair<ld, ld>>ps;
	for (int i = 0; i < N; ++i) {
		ld x, y; cin >> x >> y;
		ps.emplace_back(x, y);
	}
	sort(ps.begin(), ps.end());
	ld ans = getans(ps,0,ps.size());
	cout << ans*ans << endl;
	return 0;
}

Measured memory_bytes: 19248
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, K;
  cin >> N >> K;
  int64_t x = N/K;
  N -= x*K;
  //cout << N << " " << K;
  int64_t a = abs(N-K);
  int64_t b = abs(a-K);
  cout << min(a,b) << endl;
}

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

int main(){
  int H,N;
  cin >> H >> N;
  
  int A = 0;
  int a;
  for(int i=0;i < N; i++){
    cin >> a;
    A += a;
  }
  
  
  if(H <= A)
  {
  	cout << "Yes";
  }
  else{
  	cout << "No"; 
  }
  return 0;
}



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

bool prime(int x){
  if(x==1) return false;
  for(int i=2;i*i<x;i++){
    if(x%i==0) return false;
  }
  return true;
}

signed main(){
  int x;
  cin>>x;
  int p=x;
  while(!prime(p)) p++;
  cout<<p<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        // print numbers if it :
        // - is multiple of 3, or
        // - has a digit of 3
        for (int i = 1; i <= n; i++) {
            int x = i;
            if (x % 3 == 0) {
                System.out.print(" "+i);
            } else {
                while (x > 0) {
                    if (x % 10 == 3) {
                        System.out.print(" "+i);
                        break;
                    }
                    x /= 10;
                }
            }
        }
        System.out.println("");
    }
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n;
    string s;
    cin>>n>>s;
    
    VVi dp(n,Vi(n));
    REPR(i,n-1,-1){
        REPR(j,n-1,-1){
            if(s[i]==s[j]){
                if(i==n-1 || j==n-1) dp[i][j]=1;
                else{
                    dp[i][j]=dp[i+1][j+1]+1;
                }
            }
        }
    }
    
    int ans;
    REP(i,0,n){
        REP(j,0,n){
            chmax(ans,min(dp[i][j],abs(i-j)));
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 195840
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;

ll Factorial(ll a){
	ll b=1;
	for(ll i=a;i>=1;i--){
		b=b*i;
	}
	return b;
}

int main()
{
	ll n;
	double ANS=0;
	vector<ll>N,x,y;
	cin>>n;
	rep(i,n){
		ll t,u;
		cin>>t>>u;
		x.push_back(t);
		y.push_back(u);
	}
	rep(i,n){
		N.push_back(i);
	}
	rep(i,Factorial(n)){
		double sum=0;
		rep(i,n-1){
			double t;
			t=abs(x[N[i]]-x[N[i+1]])*abs(x[N[i]]-x[N[i+1]])+abs(y[N[i]]-y[N[i+1]])*abs(y[N[i]]-y[N[i+1]]);
			t=sqrt(t);
			sum=sum+t;
		}
		ANS=ANS+sum;
		next_permutation(N.begin(),N.end());
	}
	cout << fixed << setprecision(20) << ANS/Factorial(n) << endl;
}

Measured memory_bytes: 512
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
import itertools
#from scipy.misc import comb

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

c = Counter(A)
ans = len(c.keys())

if ans%2==0:
    ans -= 1
print(ans)

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


int
main (void)
{
    int N;
    int deg;

    scanf("%d", &N);
    // 60*3 = 180 , 90*4=36
    deg = 180 * (N-2);
    printf("%d\n", deg);

    return 0;
}


Measured memory_bytes: 128
N = int(input())
now_x, now_y = 0, 0
time = 0
for i in range(N):
  t, x, y = map(int, input().split())
  board = abs(x - now_x) + abs(y - now_y)
  if board > t - time:
    print("No")
    quit()
  elif ((t - time) - board) % 2 == 1:
    print("No")
    quit()
  else:
    now_x, now_y, time = x, y, t
    
print("Yes")






Measured memory_bytes: 9136
a = []
use = [[False for i in range (3)] for j in range (3)]
ha = {}
cntRow = [0 for i in range (3)]
cntCol = [0 for i in range (3)]

for i in range (3) :
    a.append (list (map (int, input ().split ())))
    for j in range (3) :
        ha[a[i][j]] = (i, j)

n = int (input ())

for i in range (n) :
    b = int (input ())
    if (not b in ha.keys ()) :
        continue
    if (not use[ha[b][0]][ha[b][1]]) :
        use[ha[b][0]][ha[b][1]] = True
        cntRow[ha[b][0]] += 1
        cntCol[ha[b][1]] += 1

flg = False
for i in range (3) :
    if (cntCol[i] == 3 or cntRow[i] == 3) :
        flg = True

if (not flg) :
    if (use[1][1] and (use[0][0] and use[2][2] or use[0][2] and use[2][0])) :
        flg = True

print ("Yes" if flg else "No")




Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

ll ch[55][55];

ll choose(ll n,ll k){
    if(k>n) return 0;
    if(ch[n][k]!=0) return ch[n][k];
    if(n>5 && k>=1) return ch[n][k]=choose(n-1,k)+choose(n-1,k-1);
    if(2*k>n) k=n-k;
    ll res=1;
    rep(i,k){
        res*=n-i;
    }
    rep(i,k){
        res/=(i+1);
    }
    return ch[n][k]=res;
}

int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    vector<double> v(n);
    rep(i,n){
        cin >> v[i];
    }
    sort(v.rbegin(),v.rend());
    double ave=0;
    rep(i,a){
        ave+=v[i];
    }
    ll cnt_sum=0;
    rep(i,a){
        if(v[i]>v[a-1]) cnt_sum++;
    }
    
    ll cnt_val=0;
    rep(i,n){
        if(v[i]==v[a-1]) cnt_val++;
    }
    if(cnt_sum==0){
        cout << setprecision(30);
        cout << v[0] << endl;
        ll ans=0;
        for(ll i=a;i<=b;i++){
            ans+=choose(cnt_val,i);
            //cout <<cnt_val << " " << i << " " <<  choose(cnt_val,i) << endl;
        }
        cout << ans << endl;
        return 0;
    }
    //cout << cnt_sum << " " << cnt_val << endl;
    cout << setprecision(30);
    ave/=a;
    cout << ave << endl;
    ll ans=0;
    
    ans=choose(cnt_val,a-cnt_sum);
    cout << ans << endl;
    
    return 0;
} 

Measured memory_bytes: 384
def solve():
    s_abcd = read()
    result = think(s_abcd)
    write(result)


def read():
    return read_line(n=4)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(s_abcd):
    list_int_abcd = list(map(lambda x: int(x), list(s_abcd)))
    max_patterns = 2 ** 3
    expected_answer = 7

    for _ in range(max_patterns):
        formula_string = generate_formula_string_with(list_int_abcd, _)
        if eval(formula_string) == expected_answer:
            return format_formula_string(formula_string, expected_answer)
    raise RuntimeError()


def generate_formula_string_with(list_int_abcd, bit):
    shift = 3
    operator = ['+', '-']
    formula_string = ''
    for i, elem in enumerate(list_int_abcd):
        formula_string += str(elem)
        if i == len(list_int_abcd) - 1:
            continue
        if bit >> (shift - i - 1) & 1:
            formula_string += operator[0]
        else:
            formula_string += operator[1]
    return formula_string


def format_formula_string(formula_string, expected_answer):
    return '{0:s}={1:s}'.format(formula_string, str(expected_answer))


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
#define ll long long int
# define PI 3.14159265358979323846
#define endl '\n'
using namespace std;

void solve()
{
  double a,b;
  double h,m;
  cin>>a>>b>>h>>m;
  h=0.5*(h*60+m);
  m=m*6;
  double c = abs(h-m);
  c = min(c,360-c);
  c = (c*PI)/180;
  double ans = sqrt(a*a+b*b-2*a*b*cos(c));
  cout<<fixed<<setprecision(20)<<ans<<endl;
}    

int main() 
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int N, K;
    string S;
    cin >> N >> S >> K;
    char c = S[K-1];
    string ans;
    REP(i, N) {
        if(S[i] != c) { ans += '*'; }
        else { ans += c; }
    }
    printf("%s\n", ans.c_str());
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int main() {
	int t; 
	while (cin >> t, t) {
		int Cyc[30];
		rep(i, t) {
			cin >> Cyc[i];
		}
		int cyc[120];
		rep(i, 120) {
			cyc[i] = Cyc[i%t];
		}
		int n; cin >> n;
		int view[100];
		fill(view, view + 100, 24);
		rep(i, n) {
			int d, m; cin >> d >> m; d--;
			view[d] = min(view[d], m);
		}
		int dp[101][101];
		rep(i, 101) {
			rep(j, 101) {
				dp[i][j] = (int)MOD;
			}
		}
		dp[0][0] = 0;
		Rep(i, 1, 100) {
			rep(j, i) {
				if (dp[j][i - 1] == (int)MOD)continue;
				int dif = i - j;
				if (cyc[dif] <= view[i]) {
					dp[j][i] = min(dp[j][i], dp[j][i - 1]);
				}
				dp[i][i] = min(dp[i][i], dp[j][i - 1] + 1);
			}
		}
		int mi = (int)MOD;
		rep(i, 100) {
			mi = min(mi, dp[i][99]);
		}
		cout << mi << endl;
	}
	return 0;
}


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

int main()
{
    int n;
    cin>>n;
    int arr[n],alice = 0,bob = 0;
    for(int i = 0;i<n;i++)
        cin>>arr[i];
    sort(arr , arr+n,greater<int>());
    for(int i = 0;i<n;i++)
        {
            if(i&1)
                bob += arr[i];
            else alice += arr[i];
        }
        cout<<alice - bob<<endl;
    return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3

def calc(N, X):
    if X == 0:
        return 0
    elif X == 2 ** (N + 2) - 3:
        return 2 ** (N + 1) - 1

    Y = 2 ** (N + 1) - 1
    if X == Y:
        return 2 ** N
    elif X == Y - 1:
        return 2 ** N - 1
    elif X < Y - 1:
        return calc(N - 1, X - 1)
    else:
        return 2 ** (N + 1) - 1 - calc(N - 1, 2 ** (N + 2) - 4 - X)

def main():
    [N, X] = list(map(int, input().split()))

    r = calc(N, X)


    print(r)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060