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

int N;
string S;
int A, B, C, D;

bool ok (int x, int y){
    for(int i=x-1; i<=y-2; i++){
        if(S.at(i)=='#' && S.at(i+1)=='#'){
            return false;
        }
    }
    return true;
}

bool ok1 (int x, int y){
    for(int i=x-2; i<=y-2; i++){
        if(S.at(i)=='.' && S.at(i+1)=='.' && S.at(i+2)=='.'){
            return true;
        }
    }
    return false;
}

int main(){
    cin >> N >> A >> B >> C >> D >> S;
    if(C < D){
        if(ok(A,C) && ok(B,D) ){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
    else{
        if(ok(A,C) && ok(B,D) && ok1(B,D) ){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 640
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>

#pragma region _define

#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n,option) f(i,0,n)cout<<v[i]<<option;
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INF 1<<29

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b)*b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion

/************************************************************************/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
 
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c);
	return 0;
}

Measured memory_bytes: 892
c = ["3","5","7"]
sl = {"3","5","7"}
def cal(n):
    f   = True
    while f:
        cnt =0
        sl_c = sl.copy()
        for i in sl_c:
            if int(i) > n:
                f = False
            elif "3" in i and "5"  in i and "7" in i :
                #print(i)
                cnt+=1
            for j in c:
                sl.add(i+j)
    return cnt
n  = int(input())
print(cal(n))


Measured memory_bytes: 32216
s=input()
l=[0]*26
for i in s:
    l[ord(i)-ord("a")]=1
if len(s)<26:
    for i in range(26):
        if l[i]==0:
            print(s+chr(i+ord("a")))
            exit()
else:
    for i in range(26):
        l[ord(s[-i-1])-ord("a")]=0
        for j in range(26):
            if l[j]==0 and ord(s[-i-1])-ord("a")<j:
                print(s[:-i-1]+chr(j+ord("a")))
                exit()
print(-1)


Measured memory_bytes: 38384
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int l;
  cin >> l;
  int r;
  for(r=1;r<=19;r++){
    if(l < pow(2,r)){
      break;
    }
  }
  r--;
  vector<tuple<int,int,int>> ans;
  for(int i=1;i<=r;i++){
    ans.push_back(make_tuple(i,i+1,0));
    ans.push_back(make_tuple(i,i+1,pow(2,i-1)));
  }
  
//  for(auto ans1:ans){
//    int a,b,c;
//    tie(a,b,c) = ans1;
//    printf("%d %d %d\n",a,b,c);
//  }
  
//  puts("----------------------------");
  
  for(int i=r;i>=1;i--){
    if(l-pow(2,i-1) >= pow(2,r)){
      ans.push_back(make_tuple(i,r+1,l-pow(2,i-1)));
      l -= pow(2,i-1);
    }
  }
  
  printf("%d %d\n",r+1,ans.size());
  for(auto ans1:ans){
    int a,b,c;
    tie(a,b,c) = ans1;
    printf("%d %d %d\n",a,b,c);
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    boolean tmp = true;

    while(tmp){
      int h = sc.nextInt();
      int w = sc.nextInt();

      if(h == 0 && w == 0){
        tmp = false;
        break;
      }

      for(int i = 0; i < w; i++){
        System.out.print("#");
      }
      System.out.println();

      for(int i = 0; i < h - 2; i++){
        System.out.print("#");
        for(int j = 0; j < w - 2; j++){
          System.out.print(".");
        }
        System.out.print("#");
        System.out.println();
      }

      for(int i = 0; i < w; i++){
        System.out.print("#");
      }

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



Measured memory_bytes: 35340
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <bitset>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)
#define RPA(i,s,e) for(int i=s; i<=e; i++)
#define RPD(i,s,e) for(int i=s; i>=e; i--)
#define PB(a) push_back(a)
#define MP(i,s) make_pair(i,s)
#define SZ(a) (int)(a).size()
#define ALL(a) (a).begin(), (a).end()
#define PRT(a) cout << (a) << endl
#define PRT2(a,b) cout << (a) << " " << (b) << endl
#define PRT3(a,b,c) cout << (a) << " " << (b) << " " << (c) << endl

typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> P;

int n, m, x, y;
string dir;
int dist;
int field[21][21];

void coding() {
	while(scanf("%d", &n)!=EOF) {
		if(n == 0) break;
		memset(field, 0, sizeof(field));
		REP(i,n) {
			scanf("%d%d", &x, &y);
			field[x][y] = 1;
		}

		int cx = 10;
		int cy = 10;
		scanf("%d", &m);
		REP(i,m) {
			cin >> dir;
			cin >> dist;
			for(int d=0; d<dist; d++) {
				if(dir == "N") {
					cy++;
				} else if(dir == "S") {
					cy--;
				} else if(dir == "E") {
					cx++;
				} else if(dir == "W") {
					cx--;
				}

				if(field[cx][cy] == 1) {
					field[cx][cy] = 0;
				}
			}
		}

		bool ok = true;
		REP(i,20) {
			REP(j,20) {
				if(field[i][j] == 1) {
					ok = false;
				}
			}
		}
		printf("%s\n", ok ? "Yes" : "No");
	}
}

// #define _LOCAL_TEST

int main() {
#ifdef _LOCAL_TEST
	clock_t startTime = clock();
	freopen("a.in", "r", stdin);
#endif

	coding();

#ifdef _LOCAL_TEST
	clock_t elapsedTime = clock() - startTime;
	cout << endl;
	cout << (elapsedTime / 1000.0) << " sec elapsed." << endl;
	cout << "This is local test" << endl;
	cout << "Do not forget to comment out _LOCAL_TEST" << endl << endl;
#endif
}

Measured memory_bytes: 1224
N = input()
a = map(int, raw_input().split())

c1 = 0
c2 = 0
c4 = 0
for x in a:
  if x%4==0:
    c4 += 1
  elif x%2==0:
    c2 += 1
  else:
    c1 += 1

if c1>0:
  p = 1
  c1 -= 1
elif c2>0:
  p = 2
  c2 -= 1
else:
  p = 4
  c4 -= 1

while c1+c2+c4>0:
  if p==1:
    if c4>0:
      c4 -= 1
      p = 4
    else:
      print "No"
      break
  elif p==2:
    if c2>0:
      c2 -= 1
      p = 2
    elif c4>0:
      c4 -= 1
      p = 4
    else:
      print "No"
      break
  else:
    if c1>0:
      c1 -= 1
      p = 1
    elif c2>0:
      c2 -= 1
      p = 2
    else:
      c4 -= 1
      p = 4
else:
  print "Yes"


Measured memory_bytes: 11320
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import qualified Data.IntMap           as IM
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- readInts
  print $ solve n as

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve n as = IM.foldrWithKey' folder 0 counter where
  counter = foldr (IM.alter countup) IM.empty as
  countup Nothing  = Just 1
  countup (Just x) = Just $ x + 1
  folder k v s
    | k < v = s + (v - k)
    | k > v = s + v
    | otherwise = s


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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,int>>
#define pb push_back
#define mod 1000000007
using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

vector<ll> dp(100005, 1000000000000000000);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, w;
    cin >> n >> w;
    int weight[n + 1], value[n + 1];
    for (int i = 1; i <= n; i++) cin >> weight[i] >> value[i];
    int sum = 0;
    for (int i = 1; i <= n; i++) sum += value[i];
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = sum - value[i]; j >= 0; j--)
            dp[j + value[i]] = min(dp[j + value[i]], dp[j] + weight[i]);
    }
    int ans = 0;
    for (int i = 0; i <= sum; i++) if (dp[i] <= w) ans = max(ans, i);
    cout << ans;
    return 0;
}


ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

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


Measured memory_bytes: 1024
x, y, z, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort_by{|e| -e}
b = gets.split.map(&:to_i).sort_by{|e| -e}
c = gets.split.map(&:to_i).sort_by{|e| -e}

M = 1 << 35
@h = Array.new(k+1, M)
@l = 0

def enque(v)
    i = @l += 1
    @h[i] = v

    while i > 1 && @h[i] < @h[i/2]
        @h[i], @h[i/2] = @h[i/2], @h[i]
        i /= 2
    end
end

def deque
    x = @h[1]
    @h[1] = @h[@l] if @l > 1
    @h[@l] = M
    @l -= 1
    i = 1

    while i * 2 <= @l
        j = @h[i*2] < @h[i*2+1] ? i*2 : i*2+1
        break if @h[i] <= @h[j]
        @h[i], @h[j] = @h[j], @h[i]
        i = j
    end

    x
end

x.times do |xx|
    fy = y.times do |yy|
        fz = z.times do |zz|
            break zz if @l == k && a[xx] + b[yy] + c[zz] <= @h[1]
            deque if @l == k
            enque(a[xx] + b[yy] + c[zz])
        end

        break yy if fz == 0
    end

    break if fy == 0 
end

ans = []
k.times {ans << deque}
puts ans.reverse


Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
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 (a>b) { a=b; return true; } return false; }

int main(){
    ll h, n;
    cin >> h >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) h-=a[i];
    if (h <= 0) {
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	string sa,sb;
	int i;
	cin>>sa;
	cin>>sb;
	for(i=0;i<sa.size();i++){
		cout<<sa[i];
		if(i<sb.size())
			cout<<sb[i];
	}
	return 0;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin>>s;
int n=s.size();
int ans=0;
reps(i,n,1){
    int subst_size = n-i;
    if(subst_size%2!=0)continue;
    string t=s.substr(0,subst_size);
    string t1=t.substr(0,subst_size/2);
    string t2=t.substr(subst_size/2,subst_size/2);
    if(t1==t2){
        ans=subst_size;
        break;
    }
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	string s; cin >> s;
	int a = 0;
	REP(i,N) if(s[i]=='R') a++;
	int b = N - a;
	Yn(a>b);
	return 0;
}


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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    for(int i=1;i<=9;i++)for(int j=1;j<=9;j++){
        if(i*j == n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}



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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

int DP(vector<vector<bool>> Gragh)
{
    vector<vector<int>> DP(Gragh.size(),vector<int>(Gragh[0].size(),1e9));
    if(Gragh[0][0]) DP[0][0] = 0; // 白ならば
    else DP[0][0] = 1; // 黒ならば

    for(int i=0;i<Gragh.size()-1;i++)
    {
        if(Gragh[i+1][0] && Gragh[i][0])
        {
            DP[i+1][0] = DP[i][0];
        }
        if(Gragh[i+1][0] && !Gragh[i][0])
        {
            DP[i+1][0] = DP[i][0];
        }
        if(!Gragh[i+1][0] && Gragh[i][0])
        {
            DP[i+1][0] = DP[i][0] + 1;
        }
        if(!Gragh[i+1][0] && !Gragh[i][0])
        {
            DP[i+1][0] = DP[i][0];
        }
    }
    for(int i=0;i<Gragh[0].size()-1;i++)
    {
        if(Gragh[0][i+1] && Gragh[0][i])
        {
            DP[0][i+1] = DP[0][i];
        }
        if(Gragh[0][i+1] && !Gragh[0][i])
        {
            DP[0][i+1] = DP[0][i];
        }
        if(!Gragh[0][i+1] && Gragh[0][i])
        {
            DP[0][i+1] = DP[0][i] + 1;
        }
        if(!Gragh[0][i+1] && !Gragh[0][i])
        {
            DP[0][i+1] = DP[0][i];
        }    
    }

    for(int i=0;i<Gragh.size()-1;i++)
    {
        for(int j=0;j<Gragh[0].size()-1;j++)
        {
            if(Gragh[i+1][j] && Gragh[i][j+1])
            {
                if(Gragh[i+1][j+1])
                {
                    DP[i+1][j+1] = min(DP[i+1][j],DP[i][j+1]);
                }
                else
                {
                    DP[i+1][j+1] = min(DP[i+1][j],DP[i][j+1])+1;
                }
            }
            if(Gragh[i+1][j] && !Gragh[i][j+1])
            {
                if(Gragh[i+1][j+1])
                {
                    DP[i+1][j+1] = min(DP[i+1][j],DP[i][j+1]);
                }
                else
                {
                    DP[i+1][j+1] = min(DP[i+1][j]+1,DP[i][j+1]);
                }
            }
            if(!Gragh[i+1][j] && Gragh[i][j+1])
            {
                if(Gragh[i+1][j+1])
                {
                    DP[i+1][j+1] = min(DP[i+1][j],DP[i][j+1]);
                }
                else
                {
                    DP[i+1][j+1] = min(DP[i+1][j],DP[i][j+1]+1);
                }
            }
            if(!Gragh[i+1][j] && !Gragh[i][j+1])
            {
                if(Gragh[i+1][j+1])
                {
                    DP[i+1][j+1] = min(DP[i+1][j],DP[i][j+1]);
                }
                else
                {
                    DP[i+1][j+1] = min(DP[i+1][j],DP[i][j+1]);
                }
            }
        }
    }

    return DP[Gragh.size()-1][Gragh[0].size()-1];
}

int main()
{
    int H,W;
    cin >> H >> W;

    vector<vector<bool>> Gragh(H,vector<bool>(W));
    // 白ならばtrue; 黒ならばfalse;
    for(int i=0;i<H;i++)
    {
        for(int j=0;j<W;j++)
        {
            char s;
            cin >> s;

            if(s=='#') Gragh[i][j]=false;
            if(s=='.') Gragh[i][j]=true;
        }
    }

    int ans = DP(Gragh);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final long x = scanner.nextLong();
        long tmp = 100;
        for (int i = 1; i < 5000; i++) {
            tmp = (long) ((double) tmp * 1.01d);
            if(tmp >=x){
                System.out.println(i);
                return;
            }
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

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

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

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


Measured memory_bytes: 32740
n, m = map(int, input().split())
n_l = [i for i in range(0,n*2,2)]
m_l = [i for i in range(1,m*2,2)]
hoge = n_l + m_l
count = 0
for i in hoge:
    for j in hoge:
        if (i!=j)&((i+j)%2==0):
            count+=1
print(int(count/2))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[M];
		for(int i = 0 ; i < M ; i++){
			A[i] = sc.nextInt();
		}
		sc.close();

		long INF = 1000000007;
		long[] dp = new long[N+1];

		dp[0] = 1;
		dp[1] = 1;

		for(int i = 0 ; i < M ;i++){
			dp[A[i]] = -1;
		}

		for(int j =2 ; j <= N ; j++){
			if(dp[j] != -1 && dp[j-1]!=-1 && dp[j-2] != -1){
				dp[j] = (dp[j-1] + dp[j-2])%INF;
			}
			else if(dp[j] != -1 && dp[j-1] == -1){
				dp[j] = (dp[j-2]);
			}
			else if(dp[j] != -1 && dp[j-2] == -1){
				dp[j] = (dp[j-1]);
			}
			//System.out.println(dp[j]);

		}
			if(dp[N] == -1){
				System.out.println("0");
			}
			else{
				System.out.println(dp[N]%INF);
			}

	}
}


Measured memory_bytes: 48288
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  map<string, int> data;
  cin >> N;
  vector<string> keys = {"AC", "WA", "TLE", "RE"};
  for (int i = 0; i < N; i++) {
  	string S;
    cin >> S;
    data[S] += 1;
  }
  int size = keys.size();
  for (int i = 0; i < size; i++) {
  	string key = keys[i];
    if (data[key]) {
    	cout << key << " x " << data[key] << endl;
    } else {
    	cout << key << " x " << 0 << endl;
    }
  }
  
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int N, M, K, Q, H, W;

vector<vector<int>> S;

int solve(vector<int> const &grp) {
    int ret = 0;
    int h_num = (int)grp.size() - 1;
    int w2 = 0;
    for (int w1 = 0; w1 < W;) {
        //cout << w1 << " " << w2 << " " << ret << endl;
        bool flag = false;
        vector<int> cnt(h_num);
        while (w2 < W) {
            vector<int> cnt_tmp(h_num);
            for (int i = 0; i < h_num; i++) {
                int h1 = grp[i];
                int h2 = grp[i + 1];
                for (int h = h1; h < h2; h++) {
                    cnt_tmp[i] += S[h][w2];
                    if (cnt[i] + cnt_tmp[i] > K) {
                        flag = true;
                        break;
                    }
                }
            }
            if (flag) break;
            for (int i = 0; i < h_num; i++) {
                cnt[i] += cnt_tmp[i];
            }
            w2++;
        }
        if (w1 == w2) {
            return INF;
        }
        ret++;
        w1 = w2;
    }
    return ret;
}

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

    cin >> H >> W >> K;

    S.assign(H, vector<int>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char a;
            cin >> a;
            S[i][j] = (int)(a - '0');
        }
    }

    int ans = INF;
    for (int bit = 0; bit < (1 << (H - 1)); bit++) {
        vector<int> grp;
        grp.push_back(0);
        for (int i = 0; i <= H - 1; i++) {
            int mask = (1 << i);
            if ((bit & mask) > 0 || i == H - 1) {
                grp.push_back(i + 1);
            }
        }
        chmin(ans, solve(grp) + (int)grp.size() - 3);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n ,ok,a[28];
string s;
int main()
{

    cin >> s;
    n =s.size();
    for (int i= 0; i< n ; i++)
    {
        a[s[i] -'a']++;
    }
    for (int i = 0; i < 27 ;i++)
    {
        if (a[i] % 2 == 1)ok = 1;
    }
    if (ok)cout <<"No";
    else
        cout << "Yes";

}




Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define gcd(a,b) __gcd(a,b)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define pb(n) push_back(n)
#define pp pop_back()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define type(a) typeid(a).name();
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define console(arr) cout << "["<<endl; for(ll i=0;i<(ll)arr.size();++i){cout << " [";for(ll j=0;j<(ll)arr[i].size();++j){(j==(int)arr[i].size()-1)?cout << arr[i][j]:cout << arr[i][j] << ",";}cout << "]"<<endl;} cout << "]"<<endl
#define starting() auto start = high_resolution_clock::now()
#define ending() auto stop = high_resolution_clock::now();auto duration = duration_cast<microseconds>(stop - start);cout << endl << endl << "Execution Time : "<<duration.count()/1000 << " ms" << endl
 
template <typename T1,typename T2>
void mapped(map<T1,T2>m){for(auto ite=m.begin();ite!=m.end();++ite){cout << "'" << ite->first << "'"<<" : "<<ite->second <<endl;}}
 
template <typename T1 , typename T2>
void mappedArr(map<T1,vector<T2>>m){for(auto ity=m.begin();ity!=m.end();++ity){cout << "'"<< ity->first <<"'"<<" : "<<"[";
for(int i=0;i<(int)ity->second.size();++i){(i==(int)ity->second.size()-1)?cout << ity->second[i]:cout << ity->second[i] << ",";}cout << "]"<<endl;}}
 
string int_to_string(int x){ stringstream ss; ss << x; string ni = ss.str(); return ni;}
int char_to_int(char c){ int n = (int)c - 48; return n; }
int string_to_int(string x){ int n; stringstream s(x); s >> n; return n; }
 
template <typename T1,typename T2>
void ArrPair(vector<pair<T1,T2>>vp){for(int i=0;i<(int)vp.size();++i){
cout << "(" << vp[i].first << "," << vp[i].second << ")"<<endl ;}}
 
const int MOD = 1e9 + 7;
const ll INF = 1e18L + 5;

int main(){
  string s;
  cin >> s;
  int start = -1;
  int end = -1;
  for (int i = 0; i < (int)s.size() - 1; ++i){
	  if(s[i] == s[i+1]){
		  start = i + 1;
		  end = i + 2;
		  break;
	  }
	  if(i < (int)s.size() - 2){
		  if(s[i] == s[i+2]){
			  start = i + 1;
			  end = i + 3;
			  break;
		  }
	  }
  }
  cout << start << " " << end;
}








Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
ll gcd(ll a,ll b){
    if(!b)return a;
    return gcd(b,a%b);
}
main(){
    int N;
    ll ans,T;
    cin >> N >> ans;
    for(int i = 1;i < N;i++){
        cin >> T;
        ans = ans / gcd(ans,T) * T; 
    }
    cout << ans << endl;
}

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

int main() {
	int n; string s, t; cin >> n >> s >> t;
	for (int i = t.size(); i >= 0; i--) {
		string S = s + t.substr(i);
		if (~(int)S.find(t)) {
			printf("%d\n", max(n, (int)s.size() + (int)t.size() - i));
			break;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;

ll mmin(ll a, ll b) {
  return a < b ? a : b;
}

int main(void) {
  ll i, j, k, n, ans = 0, t;
  scanf("%lld", &n);
  pair<ll, ll> a[n];
  for(i = 0; i < n; ++i) {
    scanf("%lld%lld", &a[i].first, &a[i].second), a[i].first--;
    if(ans < a[i].second - a[i].first) ans = a[i].second - a[i].first;
  }
  sort(a, a + n);
  ll f[n], l[n];
  f[0] = a[0].second, l[n - 1] = a[n - 1].second;
  for(i = 1; i < n; ++i) f[i] = mmin(f[i - 1], a[i].second);
  for(i = n - 1; i; --i) l[i - 1] = mmin(l[i], a[i - 1].second);
    ans -= mmin(a[n - 1].first - f[n - 1], 0);
  for(i = 1; i < n; ++i) {
    t = -mmin(a[i - 1].first - f[i - 1], 0) - mmin(a[n - 1].first - l[i], 0);
    if(ans < t) ans = t;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 3328
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll mod = 1000000007;

inline ll take_mod(ll a) { return (a % mod + mod) % mod; }

inline ll mul(ll a, ll b) { return take_mod(a * b); }

int main() {
  ll N, M;
  cin >> N >> M;

  vector<ll> lst;
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    lst.emplace_back(tmp);
  }

  vector<ll> summod;
  summod.emplace_back(0);
  for (int i = 1; i <= N; i++) {
    summod.emplace_back((summod[i - 1] + lst[i - 1]) % M);
  }

  ll ans = 0;
  map<ll, ll> m;
  for (int i = 0; i <= N; i++) {
    ans += m[summod[i]];
    m[summod[i]]++;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0; i<s.size(); i++){
        if(i%2==0){
            if(s[i]=='p') ans--;
        }else{
            if(s[i]=='g') ans++;
        }
    }
    cout << ans << endl;


	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  vector<int> E(N), W(N);

  for (int i = 1; i < N; i++) {
    // i番がリーダーとしたときの方向転換が必要な人数の累積和
    W.at(i) = W.at(i - 1);
    E.at(N - 1 - i) = E.at(N - i);

    // 隣がリーダーからメンバーに戻ったときの増分
    if (s.at(i - 1) == 'W') {
      W.at(i)++;
    }
    if (s.at(N - i) == 'E') {
      E.at(N - 1 - i)++;
    }
  }
  //   cout << s << endl;

  //   for (int i = 0; i < N; i++) {
  //     cout << W.at(i);
  //   }
  //   cout << endl;
  //   for (int i = 0; i < N; i++) {
  //     cout << E.at(i);
  //   }
  //   cout << endl;

  int res = N;
  for (int i = 0; i < N; i++) {
    int c = W.at(i) + E.at(i);
    res = min(res, c);
  }
  cout << res << endl;
}

Measured memory_bytes: 3076
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int len = Integer.parseInt(sc.nextLine());
		String[] nums = sc.nextLine().split(" ");
		StringBuilder sb = new StringBuilder();
		
		for(int i = 0; i < len; i++){
			sb.append(nums[len - (i + 1)]).append(i < len - 1 ? " " : "");
		}

		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 17132
N, K = map(int, input().split())
child = [0 for i in range(N)]
d = []
trick = []

for i in range(K):
    d.append(int(input()))
    trick.append(input().split())

for i in range(K):
    tmp = d[i]
    for j in range(tmp):
        child[int(trick[i][j]) - 1] += 1
        
print(child.count(0)) 

Measured memory_bytes: 9460
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        h: usize, w: usize,
        s: [chars; h],
    }
    let mut sum = vec![vec![0; w]; h];
    for i in 0..h {
        let mut cnt = 0;
        for j in 0..w {
            if s[i][j] == '#' {
                cnt = 0;
            } else {
                cnt += 1;
            }
            sum[i][j] += cnt;
        }
        cnt = 0;
        for j in (0..w).rev() {
            if s[i][j] == '#' {
                cnt = 0;
            } else {
                cnt += 1;
            }
            sum[i][j] += cnt;
        }
    }
    for j in 0..w {
        let mut cnt = 0;
        for i in 0..h {
            if s[i][j] == '#' {
                cnt = 0;
            } else {
                cnt += 1;
            }
            sum[i][j] += cnt;
        }
        cnt = 0;
        for i in (0..h).rev() {
            if s[i][j] == '#' {
                cnt = 0;
            } else {
                cnt += 1;
            }
            sum[i][j] += cnt;
        }
    }
    let mut ma = 0;
    for i in 0..h {
        for j in 0..w {
            ma = max(ma, sum[i][j]);
        }
    }
    puts!("{}\n", ma - 3);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 41212
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

ll MODP = 998244353;

ll N,M,Q;
vector<ll> A,B,C,D;
ll ans;

void dfs(vector<ll> num, vector<ll> A,vector<ll> B,vector<ll> C,vector<ll> D){
  if(num.size() == N+1){
    ll add = 0;
    rep(i,Q){
      if(num[B[i]] - num[A[i]] == C[i])add += D[i];
    }
    if(ans < add)ans = add;
    return;
  }
  num.push_back(num.back());
  while(num.back() <= M){
    dfs(num,A,B,C,D);
    num.back()++;
  }
}



int main(){
  cin >> N >> M >> Q;
  vector<ll> A(Q),B(Q),C(Q),D(Q);
  rep(i,Q)cin >> A[i] >> B[i] >> C[i] >> D[i];
  ans = 0;
  vector<ll> num(1,1);
  dfs(num,A,B,C,D);
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>

using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
int a[212345];
int b[212345];
int kuai[212345];
void print(int n) {
	for (int i = 1; i <= n; ++i)cout << a[i] << " ";
	cout << endl;
}
signed main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	int n, k, i, j, t, left, right;
	t = 0;
	cin >> n >> k;
	int N = int(sqrt(n));
	for (i = 1; i <= n; ++i)cin >> a[i];
	while (k--) {
		t = 0;
		for (i = 1; i <= n; ++i) {
			left = max(1, i - a[i]);
			right = min(n, i + a[i]);
			if (left == 1 && right == n)++t;
			else {
				if (right / N - left / N <= 1) {
					for (j = left; j <= right; ++j)++b[j];
				}
				else {
					for (j = left / N + 1; j < right / N; ++j) {
						++kuai[j];
					}
					for (j = left; j < (left / N + 1) * N; ++j)++b[j];
					for (j = (right / N) * N; j <= right; ++j)++b[j];
				}
			}
		}
		for (i = 1; i <= n; ++i) {
			a[i] = b[i] + t + kuai[i / N];
			b[i] = 0;
		}
		for (i = 0; i < N + 5; ++i)kuai[i] = 0;
		if (t == n)break;
	}
	print(n);
	return 0;
}

Measured memory_bytes: 5144
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void yes(bool c) { if (c)print("Yes"); else print("No"); };

int ans[200020];
vector<int>G[200020];
int A[200020];
int dp[200020];
void dfs(int n, int pre) {
	int ok = 0, ng = 200000;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if (A[n] > dp[mid]) {
			ok = mid;
		}
		else ng = mid;
	}
	int pos = ng;
	int val = dp[ng];
	if (dp[ng] > A[n]) {
		dp[ng] = A[n];
	}
	ok = 0, ng = 200000;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if (dp[mid] < INF) {
			ok = mid;
		}
		else ng = mid;
	}
	ans[n] = ok;
	for (auto nxt : G[n]) {
		if (nxt == pre)continue;
		dfs(nxt, n);
	}
	dp[pos] = val;
}
void solve() {
	int N; cin >> N;
	REP(i, 200001)dp[i] = INF;
	dp[0] = 0;
	REP(i, N) {
		cin >> A[i];
	}
	REP(i, N - 1) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(0, 0);
	REP(i, N) {
		print(ans[i]);
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
		solve();
}



Measured memory_bytes: 33584
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define biu (puts("-1"), exit(0))
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, siz[100005], tope = 0;
struct disData {ll d; int id;} D[100005];
struct Edge {int np; Edge *nxt;} E[100005], *V[100005];

inline bool operator < (const disData &d1, const disData &d2) {return d1.d < d2.d;}
inline void addedge(const int &u, const int &v) {E[++tope].np = v, E[tope].nxt = V[u], V[u] = E + tope;}

ll getdis(const int &u, const int &dis = 0){
	register ll res = dis;
	for(register Edge *ne = V[u]; ne; ne = ne->nxt) res += getdis(ne->np, dis + 1);
	return res;
}

int main(){
	getint(N);
	for(register int i = 1; i <= N; i++) getint(D[i].d), D[i].id = i, siz[i] = 1;
	sort(D + 1, D + N + 1);
	for(register int i = N; i > 1; i--){
		if((siz[i] << 1) >= N) biu;
		const ll d = D[i].d - N + (siz[i] << 1);
		const int fa = lower_bound(D + 1, D + i, (disData){d, 0}) - D;
		if(D[fa].d != d) biu; siz[fa] += siz[i], addedge(fa, i);
	}
	if(getdis(1) != D[1].d) biu;
	for(register int i = 1; i <= N; i++)
		for(register Edge *ne = V[i]; ne; ne = ne->nxt) printf("%d %d\n", D[i].id, D[ne->np].id);
	return 0;
}

Measured memory_bytes: 8064
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;

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

    int xmax = 0;
    int x = 0;
    rep(i, N) {
        if ('I' == S.at(i)) {
            x++;
        } else {
            x--;
        }
        xmax = max(xmax, x);
    }

    cout << xmax << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			int e=sc.nextInt();
			if(e==0) break;
			grab:{
				for(int m=1; m<=e; m++ ){//mを小さい順に見つけるまで全探索
					for(int x=0; x<=m; x++){
						for(int y=m-x; 0<=y; y--){
							int z=m-x-y;
							//System.out.println(x+" "+y+" "+z);
							if(x+(y*y)+(z*z*z) == e){
//								System.out.println(x+" "+y+" "+z);
								System.out.println(m);
								break grab;
							}
						}
					}
				}
			}//grab
		}
	}
}

Measured memory_bytes: 25544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        int gcd(int a, int b) {
            if (a < b) {
                int tmp = a;
                a = b;
                b = tmp;
            }
            if (b == 0) {
                return a;
            } else {
                return gcd(b, a % b);
            }
        }
        void solve(InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int[] A = in.nextIntArray(N);

            int[] preGcd = new int[N];
            int[] postGcd = new int[N];

            for (int i = 0; i < N; i++) {
                if (i == 0) {
                    preGcd[i] = A[i];
                } else {
                    preGcd[i] = gcd(preGcd[i - 1], A[i]);
                }
            }

            for (int i = N - 1; i >= 0; --i) {
                if (i == N - 1) {
                    postGcd[i] = A[i];
                } else {
                    postGcd[i] = gcd(postGcd[i + 1], A[i]);
                }
            }

            int ans = Integer.MIN_VALUE;
            for (int i = 0; i < N; i++) {
                if (i == 0) {
                    ans = Math.max(ans, postGcd[i + 1]);
                } else if (i == N - 1) {
                    ans = Math.max(ans, preGcd[i - 1]);
                } else {
                    ans = Math.max(ans, gcd(preGcd[i - 1], postGcd[i + 1]));
                }
            }
            out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        int[] nextIntArray(int n) {
        	int[] arr = new int[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextInt();
        	}
        	return arr;
        }
    }
}


Measured memory_bytes: 40212
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a = itr.next().unwrap();
    let b = itr.next().unwrap();
    let mut c: String = "".to_string();
    c += a;
    c += b;
    let d: u64 = c.parse().unwrap();

    for i in 1..500 {
        if i * i == d {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


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

int main() {
	int N;
	cin >> N;
	bool ans = false;
	while (N  >= 0) {
		if (N % 4 == 0) {
			ans = true;
			break;
		}
		N -= 7;
	}
	if (ans) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append([int(j) for j in input().split()])

table=[0]*(n+2)
for i in range(m):
    table[a[i][0]]+=1
    table[a[i][1]+1]-=1

for i in range(1,n+1):
    table[i]+=table[i-1]

ans=0
for i in table:
    if i==m:
        ans+=1

print(ans)

Measured memory_bytes: 25032
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x=2019*10000+4*100+30,a,b,c;
    scanf("%d/%d/%d",&a,&b,&c);
    a=a*10000+b*100+c;
    if(a<=x) cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
}


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

using namespace std;

#define MOD 1000000007

int main() {
	int h, w; cin >> h >> w;
	vector<vector<char> > a(h + 2, vector<char>(w + 2));
	for (int i = 1; i <= h; ++i)
		for (int j = 1; j <= w; ++j)
			cin >> a[i][j];
	vector<vector<long long> > cnt(h + 2, vector<long long>(w + 2));
	cnt[1][1] = 1;
	for (int i = 1; i <= h; ++i)
		for (int j = 1; j <= w; ++j)
			if (a[i][j] == '.') (cnt[i][j] += cnt[i - 1][j] + cnt[i][j - 1]) %= MOD;
	cout << cnt[h][w] << endl;

	return 0;
}

Measured memory_bytes: 9216
#include <stdio.h>

int main()
{
  char s[6];
  int c1,c2;
  scanf("%s",s+1);
  c1 = (s[1]-'0')*10 + s[2]-'0';
  c2 = (s[3]-'0')*10 + s[4]-'0';
  if(c1<=12&&c1>=1&&c2<=12&&c2>=1)
    printf("AMBIGUOUS\n");
  else if (c1<=12&&c1>=1)
    printf("MMYY\n");
  else if (c2<=12&&c2>=1)
    printf("YYMM\n");
  else
    printf("NA\n");
}

Measured memory_bytes: 128