akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

const int direction[][2] = {
	 1,  0,
	 0, -1,
	-1,  0,
	 0,  1,
};

bool inside( int x, int y )
{
	return 0 <= x && x < 12 && 0 <= y && y < 12;
}

int bfs( vector<string> &board, unsigned int i, unsigned int j )
{
	if ( board[i][j] == '0' )
	{
		return 0;
	}

	board[i][j] = '0';

	for ( int d = 0; d < 4; d++ )
	{
		if ( inside( (int)i + direction[d][0], (int)j + direction[d][1] ) )
		{
			bfs( board, i + direction[d][0], j + direction[d][1] );
		}
	}

	return 1;
}

int main()
{
	while ( true )
	{
		string buffer;
		vector<string> board;

		for ( int i = 0; i < 12; i++ )
		{
			if ( cin >> buffer )
			{
				board.push_back( buffer );
			}
			else
			{
				return 0;
			}
		}

		int res = 0;

		for ( unsigned int i = 0; i < 12; i++ )
		{
			for ( unsigned int j = 0; j < 12; j++ )
			{
				res += bfs( board, i, j );
			}
		}

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)cout<<'x';
	return 0;
}

Measured memory_bytes: 384
/*package whatever //do not write package name here */

import java.util.*;

public class Main {
	public static void main (String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
 String[] arr=new String[n];
      for(int i=0;i<n;i++)
        arr[i]=sc.next();
  int acc=0,wac=0,tlec=0,rec=0;
      for(int i=0;i<n;i++){
      if(arr[i].equals("AC")){
      acc++;
      }
         else if(arr[i].equals("WA")){
         wac++;
         }
            else  if(arr[i].equals("TLE")){
            tlec++;
            }
                 else{
                 rec++;
                 }
         
      
      }
      System.out.println("AC x "+acc);
        System.out.println("WA x "+wac);
        System.out.println("TLE x "+tlec);
        System.out.println("RE x "+rec);
	}
}

Measured memory_bytes: 64132
#include <iostream>

using namespace std;

int main()
{
  long long n;
  cin>>n;
  int z=0;
  int r=0;
  for(int i=0;i<n;i++)
  {
      long long x;
      cin>>x;
     if(x%2==0)
     {
         if(x%3==0 ||x%5==0)
         {
             z++;
         }
         else
         {

             r++;
         }

     }
  }

 if(r==0)
    cout<<"APPROVED";
 else
    cout<<"DENIED";
}


Measured memory_bytes: 256
#include <iostream>                                                                                             

int main(){
   std::string s, t;
   std::cin >> s >> t;

   if(s.size()<t.size()){
      bool flag = true;
      for(int ch='a'; ch<='z'; ++ch){
         int ns = 0;
         int nt = 0;
         for(int i=0; i<s.size(); ++i){
            if(s[i]==ch) ++ns;
         }
         for(int i=0; i<t.size(); ++i){
            if(t[i]==ch) ++nt;
         }
         if(ns>nt){
            flag = false;
            break;
         }
      }   
      if(flag) {
         std::cout << "Yes" << std::endl;
         return 0;
      }   
   }   
   for(int i=0; i<s.size(); ++i){
      for(int j=0; j<t.size(); ++j){
         if(s[i]<t[j]){
            std::cout << "Yes" << std::endl;
            return 0;
         }
      }
   }
   std::cout << "No" << std::endl;
   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      char[] s = sc.next().toCharArray();
      int y = 700;
      if (s[0] == 'o')
        y += 100;
      if (s[1] == 'o')
        y += 100;
      if (s[2] == 'o')
        y += 100;

      System.out.println(y);
    }
  }
}


Measured memory_bytes: 20948
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int N,M,C;
    int[] B;
    int[][] A;
    private void solve() {
        N = nextInt();
        M = nextInt();
        C = nextInt();
        B = new int[M];
        A = new int[N][M];
        for(int i = 0;i < M;i++) {
            B[i]  = nextInt();
        }

        for(int i = 0;i < N;i++) {
            for(int j = 0;j < M;j++) {
                A[i][j] = nextInt();
            }
        }

        int ans = 0;
        for(int i = 0;i < N;i++) {
            int sum = C;
            for(int j = 0;j < M;j++) {
                sum += A[i][j] * B[j];
            }
            if (sum > 0) {
                ans++;
            }
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21460
///-----Bismillahir Rahmanir Rahim-----///

#include<bits/stdc++.h>
using namespace std;

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///------------Sorting STL----------///
struct func
{
    //this is a sample overloading function for sorting stl
    bool operator()(pii const &a, pii const &b)
    {
        if(a.F==b.F)
            return (a.S<b.S);
        return (a.F<b.F);
    }
};

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        map<int,int>cnt;
        for(int i=1; i<=100; i++)
        {
            for(int j=1; j<=100; j++)
            {
                for(int k=1; k<=100; k++)
                {
                    int tmp=i*i+j*j+k*k+i*j+j*k+k*i;
                    cnt[tmp]++;
                }
            }
        }
        ll n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cout<<cnt[i]<<endl;
        }
        cnt.clear();
    }
    return 0;
}


Measured memory_bytes: 5388
#include <stdio.h>

int main(void) {
  int i, j, h, w;
  scanf("%d%d", &h, &w);
  char a[h][w + 10];
  for(i = 0; i < h; ++i) scanf("%s", a[i]);
  for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) {
    if(a[i][j] == '#' && ((i && j && a[i - 1][j] == '#' && a[i][j - 1] == '#') || (i != h - 1 && j != w - 1 && a[i + 1][j] == '#' && a[i][j + 1] == '#'))) {
      printf("Impossible");
      return 0;
    }
  }
  printf("Possible");
  return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <numeric>
using namespace std;
int main(void){
    vector<int> V,v;
    int N,M;
    cin>>N;
    for(int i=0;i<N;i++){
        int x; cin>>x;
        V.push_back(x);
    }
    cin>>M;
    for(int i=0;i<M;i++){
        v=V;
        int p,t;
        cin >>p>>t;
        v[p-1] = t;
        int sum = accumulate(v.begin(), v.end(), 0);
        cout <<sum<<endl;
    }
}


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

int n, i=0, cnt=0;
int a[50]={};
int main(){
	cin >> n;
	for(i; i < n; i++){
		cin >> a[i];
		if( a[i] != i + 1) cnt++;
	}
	if( cnt == 0 || cnt == 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

#define ALICE cout << "Alice" << endl; return 0;
#define BROWN cout << "Brown" << endl; return 0;

int main()
{
	ll a, b;
	cin >> a >> b;

	if (a + b <= 1)
	{
		BROWN
	}
	else if (abs(a - b) <= 1)
	{
		BROWN
	}
	else
	{
		ALICE
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include <numeric>
#include<list>
using namespace std;
typedef long long ll;

void yes(){
cout<<"Yes"<<endl;
}
void no(){
cout<<"No"<<endl;
}
int main(){
ll x,y;
  cin>>x>>y;
  cout<<x+y/2;
 return 0;
}



Measured memory_bytes: 256
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Light struct {
	Ss []int
	p  int
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	M := nextInt()

	switches := make([]int, 0, N)
	switchMap := make(map[int]int)

	Ls := make([]Light, 0, M)
	for i := 1; i <= M; i++ {
		k := nextInt()
		Ss := make([]int, 0, k)
		for j := 1; j <= k; j++ {
			s := nextInt()
			Ss = append(Ss, s)
			if _, exist := switchMap[s]; !exist {
				switches = append(switches, s)
				switchMap[s] = len(switches) - 1
			}
		}
		ls := Light{Ss: Ss}
		Ls = append(Ls, ls)
	}

	for i := 1; i <= M; i++ {
		p := nextInt()
		Ls[i-1].p = p
	}

	b := len(switches)

	max := 1
	for i := 0; i < b; i++ {
		max = max * 2
	}

	ans := 0
	for i := 0; i < max; i++ {
		fail := false
		for j := 0; j < len(Ls); j++ {
			L := Ls[j]
			c := 0
			for _, s := range L.Ss {
				idx := switchMap[s]
				bit := 1 << uint(idx)
				if bit&i == bit {
					c++
				}
			}
			if c%2 != L.p {
				fail = true
				break
			}
		}
		if !fail {
			ans++
		}
	}
	ans = ans * int(math.Pow(2.0, float64(N-len(switches))))
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
using ll = long long;
using vll = vector<ll>;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int N; cin >> N;
  vll inp(N);
  for(int i = 0; i < N; i++) cin >> inp[i];
  sort(inp.begin(), inp.end());
  ll s1 = -1;
  for(int i = N-1; i - 1 >= 0; i--){
    if(inp[i] == inp[i-1]){
      if(s1 == -1) s1 = inp[i--];
      else{ cout << s1*inp[i]; return 0;} 
    }
  }
  cout << 0;
  return 0;
}

Measured memory_bytes: 3964
# ABC 084: B – Postal Code
characters = '0123456789-'

a, b = [int(s) for s in input().split()]
s = input()

is_postal = 'Yes'

if s[a] != '-' or s.count('-') != 1:
    is_postal = 'No'

for c in s:
    if c not in characters:
        is_postal = 'No'

print(is_postal)

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n ;
	VI p(n), sq(n);
	rep(i, n) cin >>p[i];
	rep(i, n) sq[p[i]-1] = i;
	ll ans =0;
	set<int> st;
	st.insert(-MD); st.insert(MD); st.insert(-MD-1); st.insert(MD+1);
	rep(j, 2){st.insert(-MD-j); st.insert(MD+j);}
	repr(zi, n-1, 0){
		ll z = sq[zi] +1;
		st.insert(z);
		auto it = st.find(z);
		ll l2 = max(0, *next(it, -1));
		ll l1 = max(0, *next(it, -2));
		ll r1 = min(n+1, *next(it,  1));
		ll r2 = min(n+1, *next(it,  2));

		ans += ((z-l2) * (r2-r1) + (l2-l1)*(r1-z) ) * p[z-1];
	}
	cout << ans <<"\n";
	return 0;
	
}


Measured memory_bytes: 5760
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = readline().strip()
    if N % 2 == 0 and S == S[: N // 2] * 2:
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    _PS(Z); _PS(X); _PR(Y);

    return 0;
}

/*



*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n ;
    vector<ll> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if (i % 2 == 0 && arr[i] % 2 == 1) {
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3556
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b)
{
    return (*(int*)a-*(int*)b);
}
int main()
{
    int n,i,a[100000];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),cmp);
    printf("%d\n",a[n/2]-a[(n/2)-1]);
    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vector<ll> h(n);
	rep(i,n){
		cin>>h[i];
	}
	sort(begin(h),end(h),greater<ll>());
	rep(i,k){
		if(i>=n) break;
		h[i]=0;
	}
	ll sum=0;
	rep(i,n) sum+=h[i];
	cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans=0;
    
    if(a>k){
        ans+=k;
        cout<<ans<<endl;
        return 0;
    }else{
        ans+=a;
        k-=a;
    }
    k-=b;
    if(k<=0){
        cout<<ans<<endl;
        return 0;
    }
    ans-=k;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    if(A==1)
        A=14;
    if(B==1)
        B=14;
    if(A>B)
        printf("Alice\n");
    else if(A==B)
        printf("Draw\n");
    else printf("Bob\n");
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char a[2009][2009];
int b[2009][2009];
int dp[2009][2009][4];
int main()
{
    int n,m,ans;
    scanf("%d%d",&n,&m);
    memset(dp,0,sizeof(dp));
    for(int i=0; i<n; i++)
        scanf("%s",a[i]);
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            b[i][j]=a[i-1][j-1]=='.'?0:1;
            //printf("%d",b[i][j]);
        }
        //printf("\n");
    }
    for(int i=1; i<=n; i++)
    {
        ans=0;
        for(int j=1; j<=m; j++)
        {
            dp[i][j][0]=ans;
            if(!b[i][j])
                ans++;
            else
                ans=0;
        }
    }
    for(int i=1; i<=n; i++)
    {
        ans=0;
        for(int j=m; j>=1; j--)
        {
            dp[i][j][1]=ans;
            if(!b[i][j])
                ans++;
            else
                ans=0;
        }
    }
    for(int j=1; j<=m; j++)
    {
        ans=0;
        for(int i=1; i<=n; i++)
        {
            dp[i][j][2]=ans;
            if(!b[i][j])
                ans++;
            else
                ans=0;
        }
    }
    for(int j=1; j<=m; j++)
    {
        ans=0;
        for(int i=n; i>=1; i--)
        {
            dp[i][j][3]=ans;
            if(!b[i][j])
                ans++;
            else
                ans=0;
        }
    }
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
            if(!b[i][j])
            {
                int num=1;
                for(int k=0; k<4; k++)
                {
                    num+=dp[i][j][k];
                    //printf("%d ",dp[i][j][k]);
                }
                //printf("\n");
                ans=max(ans,num);
            }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 82944
def resolve():
    '''
    code here
    '''
    import bisect
    import collections
    N, M = [int(item) for item in input().split()]
    A_list = [int(item) for item in input().split()]
    queries = [[int(item) for item in input().split()] for _ in range(M)]
    queries = sorted(queries, key=lambda x:x[1], reverse=True)
    A_list.sort()

    cnt_b = 0
    D = collections.deque()
    for i in range(M):
        b, c = queries[i]
        cnt_b += b
        for _ in range(b):
            D.append(c)
        if cnt_b >= N:
            break
    D_len = len(D)
    res = 0
    for i in range(N):
        if i < D_len:
            res += max(D[i], A_list[i])
        else:
            res += A_list[i]

    # print(A_list)
    print(res)




if __name__ == "__main__":
    resolve()


Measured memory_bytes: 28148
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int a[575][575];

int main(void){
	int n,i,j,k=1,c=1;
	cin >> n;
	while(k<n){
		for(i=0; i<n; ++i){
			for(j=0; j<i; ++j){
				if(a[j][i]){
					continue;
				}
				if(((i-j)%(k*2))==k){
					a[j][i] = c;
				}
			}
		}
		k *= 2;
		++c;
	}
	for(i=0; i<(n-1); ++i){
		for(j=(i+1); j<n; ++j){
			cout << ((j==(i+1))?"":" ") << a[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define maxn 500010
using namespace std;
typedef long long LL;
char s[maxn];
int cnt[256], n;
LL ans;
//bool check(int i, int j) {
//        for (; i>=0, j<n; ) {
//            if (s[i]==s[j]) {--i, ++j; continue; }
//            if (s[i]!='x'&&s[j]!='x') return 0;
//            if (s[i]=='x') ++ans, --i;
//            else if (s[j]=='x') ++ans, ++j;
//        }
//        if (i==-1) {
//            ans += n-j;
//            for (; j < n; ++j) if (s[j]!='x') {return 0; }
//        }
//        if (j==n) {
//            ans += i+1;
//            for (; i >= 0; --i) if (s[i]!='x') { return 0; }
//        }
//        return 1;
//}
struct node {
    char ch;
    int cnt;
}a[maxn], b[maxn];
bool check(int i, int j) {
    int cnt1 = 0, cnt2 = 0, tot1 = 0, tot2 = 0;
    for (; i >= 0; --i) {
        if (s[i] == 'x') ++cnt1;
        else a[tot1++] = {s[i],cnt1}, cnt1 = 0;
    }
    for (; j < n; ++j) {
        if (s[j] == 'x') ++cnt2;
        else b[tot2++] = {s[j],cnt2}, cnt2 = 0;
    }
    if (tot1 != tot2) return false;
    ans = 0;
    for (int i = 0; i < tot1; ++i) {
        if (a[i].ch != b[i].ch) return false;
        ans += abs(a[i].cnt-b[i].cnt);
    }
    ans += abs(cnt1-cnt2);
    return true;
}
int main() {
    scanf("%s", s);
    n = strlen(s);
    for (int i = 0; i < n; ++i) ++cnt[s[i]];
    char ch; int num=0;
    for (char i = 'a'; i <= 'z'; ++i) if (i!='x'&&(cnt[i]&1)) ++num, ch = i;
    if (num > 1) { printf("-1\n"); return 0; }

    int p;
    if (num == 1) {
        int hf = cnt[ch]/2+1, pst=0;

        int i = 0;
        for (; i < n; ++i) {
            if (s[i] == ch && pst < hf) ++pst;
            if (pst == hf) break;
        }
        if (check(i-1, i+1)) printf("%lld\n", ans);
        else printf("-1\n");
    }
    else {
        int tot = 0;
        for (char i = 'a'; i <= 'z'; ++i) if (i!='x')tot += cnt[i];
        if (tot==0) { puts("0"); return 0; }
        tot /= 2;
        int i = 0, pst = 0;
        for (; i < n; ++i) {
            if (s[i] != 'x' && pst < tot) ++pst;
            if (pst == tot) break;
        }
        int p = i+1;
        while (p<n && s[p]=='x') ++p;
        if (check(i, p)) printf("%lld\n", ans);
        else printf("-1\n");
    }
    return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    int N,cnt,i;
    cin >>N;
    
    while(cnt<N) {
        i++;
        if(isP(i*10+1)==1) {
            cout <<(i*10+1)<<" ";
            cnt++;
        }
    }

    return 0;
}

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

int main()
{
  int A, B; cin >> A >> B;
  int a[10];
  int ans = 0;
  for(int i = A; i <= B; i++){
    a[0] = i / 10000;
    a[1] = (i-a[0]*10000) / 1000;
    a[2] = (i-a[0]*10000-a[1]*1000) / 100;
    a[3] = (i-a[0]*10000-a[1]*1000-a[2]*100) / 10;
    a[4] = i-a[0]*10000-a[1]*1000-a[2]*100-a[3]*10;
    if(a[0] == a[4] && a[1] == a[3]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
int a,b,d,i;
char c;
for(i=0;;i++){
scanf("%d %c %d",&a,&c,&b);

if(c == '+'){
d = a + b;
} else if(c == '-'){
d = a - b;
} else if(c == '*'){
d = a * b;
} else if(c == '/'){
 d = a / b;
}if(c == '?') break;

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

}

return 0;

}



Measured memory_bytes: 2108
using namespace std;

#include <iostream>

#define MOD 1000000007

int N;

int main() {
	cin >> N;
	long long sum = 0;
	long long ans = 0;
	for(int i = 0;i < N;++i) {
		long long cur;
		cin >> cur;
		ans += (cur * sum) % MOD;
		if(ans >= MOD) ans -= MOD;
		sum += cur;
		if(sum >= MOD) sum -= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s1, s2, s3 string
	fmt.Scan(&s1, &s2, &s3)
	s := s1[0:1] + s2[0:1] + s3[0:1]
	fmt.Println(strings.ToUpper(s))

}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int n,r;
    scanf("%d",&n);
    if(n==111 || n==222 || n==333 || n==444 || n==555 || n==666 || n==777 || n==888 || n==999)
    {
        r=n;
    }
    else
    {
        for(r=n;r<=999;r++)
        {
            if(r==111 || r==222 || r==333 || r==444 || r==555 || r==666 || r==777 || r==888 || r==999)
            {
                break;
            }
        }
    }
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 256
def main():
    a,b,c=list(map(int,input().split()))
    ans=0
    if not(a%2==0 or b%2==0 or c%2==0):
        ans=min(a*b,b*c,c*a)
    print(ans)
        
if __name__=="__main__":
    main()

Measured memory_bytes: 2940
N = int(input())

def factorizatio(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ans = 0
for i in factorizatio(N):
    cnt = i[1]
    a = 0
    b = 0
    for j in range(1, cnt+1):
        a += j            
        if a > cnt:
            break
        b += 1    
    ans += b

print(0 if N == 1 else ans)

Measured memory_bytes: 9500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    vector<int> a(5);
    rep(i,5) cin >> a[i];
    rep(i,5){
        if(a[i] == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }
}

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

long long p[105];
long long w[105];
long long dp[105][100005];
long long n, k,ans;

long long f(long long i, long long k){
    if(dp[i][k] != -1) return dp[i][k];
    if(k < 0) return INT_MAX/2;
    if(i == n){ if(k > 0) { return INT_MAX/2; }return 0;}
    dp[i][k] = min(f(i+1, k), f(i+1, k-p[i]) + w[i]);
    return dp[i][k];
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> n >> k;
    for(long long i = 0; i < n; i++){
        cin >> w[i] >> p[i];
    }
    for(int j = 0; j <= 100000; j++){
        if(f(0, j) <= k){
            ans = j;
        }
    }
    cout << ans;
}


Measured memory_bytes: 82432
#include<bits/stdc++.h>
using namespace std;
#define  CIN            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define  ll             long long int
#define  pb             push_back
#define  all(v)         v.begin(),v.end()

vector<ll>r,g,b;
string s1;
ll sum1 , a ;
void fun( vector<ll>&r,vector<ll>&g,vector<ll>&b)
{
    ll i ,j ;
    vector<bool>v(a,0);
    for( i = 0 ; i < b.size() ;i++) v[b[i]]=true;
    for( i = 0 ; i < r.size() ; i++)
    {
        ll x = upper_bound(all(g),r[i])-g.begin();
            for( j = x ; j < g.size() ; j++)
            {
                ll y = upper_bound(all(b),g[j])-b.begin();
                if(y<b.size())
                {
                    ll diff = g[j]-r[i];
                    ll last = g[j]+diff ;
                    sum1+= (b.size()-y);
                    if(last < a && v[last]) sum1--;
                }
            }
    }
}

int main()
{
    CIN;
    ll  i ;
    cin >> a >> s1 ;
    for( i  = 0 ; i < a ; i++)
    {
        if(s1[i]=='R')r.pb(i);
        else if(s1[i]=='G')g.pb(i);
        else b.pb(i);
    }
    fun(r,g,b);
    fun(r,b,g);
    fun(g,r,b);
    fun(g,b,r);
    fun(b,r,g);
    fun(b,g,r);
    cout<<sum1<<endl;
    return 0 ;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define INF 1e18
#define Rep(i, a, n) for (ll i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000000
#define ll long long
#define P pair<int,int>
#define cout_set(n) cout << setprecision(10) << (n) << endl; 
const double PI=3.14159265358979323846;
using namespace std;
const int mod = 1000000007; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 

ll lt[MAX+1]={};

signed main(){
    ll x,y; cin >> x >> y;
    int cnt=1;
    while(1){
        if(x <= y/2){
            cnt++;
            x *= 2;
        } else{
            cout << cnt << endl; 
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		double a = 0;
		double b = 0;

		Scanner in = new Scanner(System.in);

		a = in.nextDouble();
		b = in.nextDouble();

		int d = (int) (a / b);
		int r = (int) (a % b);
		double f = a / b;

		System.out.println(d + " " + r + " " + String.format("%f", f));

	}

}

Measured memory_bytes: 28128
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		String W	 = in.readLine();
//		int num = Integer.parseInt(W.split(" ")[0]);

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

		int idx = 1;
		int ans =0;
		for(int aNum :a) {
			if(idx == aNum) {
				idx++;
				continue;
			}
			ans++;
		}
		if(ans == N) {
			ans = -1;
		}


		System.out.println(ans);

	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}



}


Measured memory_bytes: 61072
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        double k = (double)sc.nextInt();


        if (Math.max(Math.max(a,b), c) == c){
            System.out.println(a+b+c*(int)Math.pow(2, k));
        }else if (Math.max(Math.max(a, b), c) == b){
            System.out.println(a+b*(int)Math.pow(2, k)+c);
        }else{
            System.out.println(b+c+a*(int)Math.pow(2, k));
        }
    }
}

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

	int A,B,C;
  
  	scanf("%d %d %d", &A,&B,&C);
  
  	if(B+C > A)
      printf("%d\n",C-(A-B));
  	else
      printf("0\n");
  
  return 0;
      
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define F first
#define S second
#define ld long double
#define rep(i,n) for (int i =0;i < (n); ++i)
#define vi vector<ll>
#define all(v) (v).begin(),(v).end()
const int inf = 1e9 + 10;

void solve() {
	string s;
	cin >> s;
	if (s == "ABC") cout << "ARC";
	else cout << "ABC";
}
int main() {

	FASTIO;


	cout << fixed << setprecision(25);
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;


struct nCk {
	int n;
	int k;
	int size;
	void next(int* ar);
	nCk(int a, int b, int* ini);
};

void nCk::next(int* ar)
{
	for (int i = 0; i < k; i++) {
		if (ar[k - i - 1] != n - i) {
			ar[k - i - 1]++;
			for (int j = k - i; j < k; j++) {
				ar[j] = ar[j - 1] + 1;
			}
			break;
		}
	}
}

nCk::nCk(int a, int b, int* ini)
{
	n = a;
	k = b;
	size = 1;

	for (int i = 0; i < k; i++) {
		size *= (n - i);
		ini[i] = i + 1;
	}
	for (int i = 0; i < k; i++) {
		size /= (1 + i);
	}
}

int main()
{
	int n;
	cin >> n;
	vector<int>len(n);
	int coise[3];
	nCk ob(n, 3, coise);
	int ans = 0;

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


	for (int i = 0; i < ob.size; i++) {
		if (len[coise[1] - 1] - len[coise[0] - 1] && len[coise[2] - 1] - len[coise[1] - 1] && len[coise[2] - 1] - len[coise[0] - 1]) {
			if (len[coise[0] - 1] + len[coise[1] - 1] > len[coise[2] - 1] && len[coise[2] - 1] > abs(len[coise[1] - 1] - len[coise[0] - 1])) {
				ans++;
				//printf("make->");
			}
		}
		//printf("%d %d %d\n", coise[0], coise[1], coise[2]);
		ob.next(coise);
	}

	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 3744
#include<iostream>

using namespace std;

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

	int n;
	cin >> n;
	int a[n];
	long long ans = 0;
	for(int i=0; i<n; i++)
		cin >> a[i];
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			ans += a[i]*a[j];
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
n,k=map(int,input().split())
x=list(map(int,input().split()))
a=[]
for i in range(n-k+1):
    l=x[i]
    r=x[i+k-1]
    a.append(min(abs(l)+abs(r-l),abs(r)+abs(l-r)))
print(min(a))


Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        int left = 0;
        int right = 0;
        for (int i = 0; i < n; i++) {
            char c = s.charAt(i);
            if (c == '(') {
                left++;
            } else {
                if (left == 0) {
                    right++;
                } else {
                    left--;
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < right; i++) {
            sb.append("(");
        }
        sb.append(s);
        for (int i = 0; i < left; i++) {
            sb.append(")");
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define mod 1000000007
#define pb push_back
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define reps(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) for(int i=0;i<int(b);i++)
#define first ff
#define second ss
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
#define M 998244353
int main()
{
    csl;
    double r;
  cin >> r;
  double c = 3.14159;
  double final = 2*c*r;
  cout << fixed << setprecision(5) << final << endl;
}


Measured memory_bytes: 3780
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
string a,b;
int main()
{
  cin>>a>>b;
  for(int i=0;i<a.size()/2;i++)swap(a[i],a[a.size()-i-1]);
  if(a==b)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

s = [int(ch) for ch in input()]

ans = [0]*2

for t in range(2):
    tmp = s[:]
    if t == 0:
        for i in range(len(s)-1):
            if i == 0 and tmp[i] == tmp[i+1]:
                tmp[i+1] ^= 1
                ans[t] += 1
            elif i == 0 and tmp[i] != tmp[i+1]:
                pass
            elif tmp[i] == tmp[i+1]:
                tmp[i+1] ^= 1
                ans[t] += 1
    if t == 1:
        for i in range(len(s)-1):
            if i == 0 and tmp[i] == tmp[i+1]:
                tmp[i] ^= 1
                ans[t] += 1
            elif i == 0 and tmp[i] != tmp[i+1]:
                tmp[i] ^= 1
                tmp[i+1] ^= 1
                ans[t] += 2
            elif tmp[i] == tmp[i+1]:
                tmp[i+1] ^= 1
                ans[t] += 1
s
print(min(ans))

Measured memory_bytes: 11372
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
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; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  n/=2;
  ll ans=0;
  rep(i,100){
    n/=5;
    ans+=n;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

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

    vector<int> v(n+1);
    REP(i, n){
        if(s[i] == '#')
            v[i+1] = v[i]+1;
        else
            v[i+1] = v[i];
    }

    int ans = INF;
    REP(i, n+1){
        ans = min(ans, v[i]+n-i-(v[n]-v[i]));
    }

    pr(ans);
}

Measured memory_bytes: 1412
#include <stdio.h>

int check(int age){
	if(age<10) return 0;
	else if(age<20) return 1;
	else if(age<30) return 2;
	else if(age<40) return 3;
	else if(age<50) return 4;
	else if(age<60) return 5;
	else return 6;	
}

int main(void){
	int n , i , buf , cnt[7];
	while(1){
		for(i=0;i<7;i++) cnt[i] = 0;
		scanf("%d" , &n);
		if(n==0) break;
		for(i=0;i<n;i++){
			scanf("%d" , &buf);
			cnt[check(buf)]++;
		}
		for(i=0;i<7;i++) printf("%d\n" , cnt[i]);
	}
	
	return 0;
}

Measured memory_bytes: 404
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	long H = sc.nextLong();
	long W = sc.nextLong();
	long count = 0;
	if(H==1 || W==1){
	    count = 1;
	}else if(H%2==0){
	    for(int i=0;i<W;i++){
		count += H/2;
	    }
	}else if(H%2==1){
	    for(int i=1;i<=W;i++){
		if(i%2==1) count += (H/2)+1;
		else count += H/2;
	    }
	}
	System.out.print(count);
    }
}


Measured memory_bytes: 21844
import sys
import math
def input(): return sys.stdin.readline().rstrip()

def isPrime(n):
    m = (n + 1) // 2
    n_sqrt = int(math.sqrt(n))
    for i in range(2, n_sqrt + 1):
        if n % i == 0 or m % i == 0:
            return 0
    else:
        return 1

def main():
    Q = int(input())

    MAX = 10 ** 5
    prime = [0] * MAX
    for i in range(3, MAX):
        prime[i] = prime[i-1] + isPrime(i)

    for _ in range(Q):
        l, r = map(int, input().split())
        print(prime[r] - prime[l-1])
if __name__ == '__main__':
    main()

Measured memory_bytes: 6896
import math
import collections
import sys
sys.setrecursionlimit(500000)

def f(n,i):
    while i * i <= n:
        if n % i == 0:
            a.append(i)
            n //= i
        else:i += 1
    if n != 1:
        a.append(n)
    return a

a = []
n = math.factorial(int(input()))
c = collections.Counter(f(n,2))
d = [i[1]+1 for i in c.items()]
ans = 1
for i in range(len(d)):
    ans = (ans * d[i]) % 1000000007
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, k, a[100010];
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];

    int m = -1;
    for (int i = 0; i < n; i++) m = max(m, a[i]);

    int t = a[0];
    for (int i = 1; i < n; i++) {
        t = __gcd(t, a[i]);
    }

    cout << (k <= m and k % t == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#define N 100
#define WHITE 0
#define BLACK 1
#define GRAY 2
 
int n;
int M[N][N];
int f[N],d[N],color[N],t;
 
 void dfs_visit(int u){
  int v;
 
  color[u] = GRAY;
  d[u] = ++t;
 
  for(v = 0; v < n; v++){
    if(M[u][v]== 0) continue;
    if(color[v] == WHITE){
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++t;
 }

void dfs(){
  int u;
  for(u = 0; u < n; u++) color[u] = WHITE;
  t = 0;

  for(u = 0; u < n; u++){
    if(color[u] == WHITE) dfs_visit(u);
  }
  for(u = 0; u < n; u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}
  

int main(){
  int i,j;
  int u,v,k;
  
  scanf("%d",&n);
 
  for(i = 0 ; i < n ; i++)
    for(j = 0 ; j < n ; j++)
      M[i][j] = 0;
  
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();
  return 0;
}



Measured memory_bytes: 1956