akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

const int MAXN=200005;
const int MAXTREE=(MAXN<<2);

typedef long long lld;

lld n, a[MAXN], st[MAXTREE];

void init_tree(int i, int l, int r){
    if(l==r){
        st[i]=a[l];
        return;
    }
    int mid=(l+r)/2;
    init_tree(2*i,l,mid);
    init_tree(2*i+1,mid+1,r);
    st[i]=st[2*i]^st[2*i+1];
}

lld query(int i, int ql, int qr, int l, int r){
    if(ql<=l && r<=qr)return st[i];
    int mid=(l+r)/2;
    lld ret=0;
    if(ql<=mid)ret=ret^query(2*i,ql,qr,l,mid);
    if(qr>mid)ret=ret^query(2*i+1,ql,qr,mid+1,r);
    return ret;
}

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    init_tree(1,1,n);
    for(int i=1;i<=n;i++){
        lld ans=0;
        int l=i-1, r=i+1;
        if(l>=1){
            ans^=query(1,1,l,1,n);
        }
        if(r<=n){
            ans^=query(1,r,n,1,n);
        }
        cout<<ans<<" ";
    }
    return 0;
}

Measured memory_bytes: 9284
n,k = map(int,input().split())

al = list(map(int,input().split()))

ansl = []
used = [0 for i in range(n+1)]
now = 0
while True:
    if used[now] == 1:
        break
    ansl.append(now)
    used[now] = 1
    now = al[now] - 1

l = len(ansl)
last = ansl.index(now)
loop = ansl[last:]

if k < len(ansl):
    print(ansl[k] + 1)
else:
    k -= len(ansl)
    print(loop[k % len(loop)] + 1)




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


bool iskaibun(string s) {
    bool ans = true;
    for (int i = 0; i < s.length() / 2; i++){
        if(s.at(i) != s.at(s.length() - i - 1))
            ans = false;
    }
    return ans;
}

string sub(string s, int a, int b){
    string ret;
    a -= 1;
    b -= 1;
    for(int i = a; i <= b; i++){
        ret += s.at(i);
    }
    return ret;
}

int main() {
    string S;
    cin >> S;
    bool ans = true;
    int N = S.length();
    if(!iskaibun(S)) ans = false;
    if(!iskaibun(sub(S, 1, (N - 1) / 2))) {
        ans = false;
    }
    if(!iskaibun(sub(S, (N + 3) / 2, N))) {
        ans = false;
    }

    if (ans) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
def foo(infile, outfile):
    import math
    n, m, r=infile.readline().split()
    n=int(n)
    m=int(m)
    r=int(r)
    if r-n*m >= 0:
        print math.factorial(r-n*m+n-1)/math.factorial(r-n*m)/math.factorial(n-1)
    else :
        print 0

if __name__ == "__main__":
    import sys
    foo(sys.stdin, sys.stdout)

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  while (true) {
    int r0, w0, c, r;
    cin >> r0 >> w0 >> c >> r;
    if (r0 == 0 && w0 ==0 && c == 0 && r == 0) break;
    for (int i = 0; ; ++i) {
      if (r0 + i * r >= c * w0) {
        cout << i << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3072
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, A, X[50];
i64 dp[52][2502];

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

	dp[0][0] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = N; j >= 1; --j) {
			for (int k = 2500; k >= X[i]; --k) {
				dp[j][k] += dp[j - 1][k - X[i]];
			}
		}
	}

	i64 ret = 0;
	for (int i = 1; i <= N; ++i) {
		ret += dp[i][i * A];
	}
	printf("%lld\n", ret);
	return 0;
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7, N = 1e6 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

bool arr[1000005] ;

int main()
{
    ll n, sum = 0 ;
    cin >> n ;
    for (int i = 3; i <= n; i += 3) {
        arr[i] = true ;
    }
    for (int i = 5; i <= n; i += 5) {
        arr[i] = true ;
    }
    for (int i = 1; i <= n; i++) {
        if (!arr[i])    sum += i ;
    }
    cout << sum ;

    return 0 ;
}


Measured memory_bytes: 4596
#include <iostream>

int main(int argc, const char * argv[]) {
    std::string s, t;
    bool flag = true;
    std::cin >> s >> t;
    if (s.length() + 1 == t.length()) {
        for (int i = 0 ; i < s.length() ; ++i) {
            if (s[i] != t[i]) {
                flag = false;
                break;
            }
        }
    } else {
        flag = false;
    }
    if (flag) {
        std::cout << "Yes\n";
    } else {
        std::cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) sort(v.begin(), v.end())
typedef long long ll;
using Graph = vector<vector<int>>;

int main()
{
  int n;
  cin >> n;
  vector<int> v(n), c(n);
  rep(i, n)
  {
    cin >> v.at(i);
  }
  rep(i, n)
  {
    cin >> c.at(i);
  }
  int ans = 0;
  int max = 0;
  for (int bit = 0; bit < (1 << n); bit++)
  {
    bitset<50> s(bit);
    rep(i, n)
    {
      if (s.test(i))
      {
        ans += (v.at(i) - c.at(i));
      }
    }
    if (max < ans)
    {
      max = ans;
    }
    ans = 0;
  }
  cout << max << endl;
}


Measured memory_bytes: 3600
import numpy as np
import itertools

H, W, K = map(int, input().split())

bw_map = []
row_list = []
for _ in range(H):
    tmp = list(input())
    bw_map.append(tmp)

bw_map = np.array(bw_map)
score = np.sum(bw_map=="#")


result = 0
"""
if score==K:
    hs = []
    for h in range(H):
        tmph = np.sum(bw_map[h, :]==".")
        if tmph == W:
            hs.append(h)
    ws = []
    for w in range(W):
        tmpw = np.sum(bw_map[w, :]==".")
        if tmpw == H:
            ws.append(w)
    print(1)
"""
if score==K:
    result+=1
if score<K:
    print(0)
else:
    score = 100000
    for h in range(H):
        for w in range(W):
            if h==0 and w==0:
                continue
            h_args = list(itertools.combinations(list(range(H)), h))
            w_args = list(itertools.combinations(list(range(W)), w))
            for hs in h_args:
                for ws in w_args:
                    tmphs=hs
                    tmpws=ws
                    hs = list(hs)
                    ws = list(ws)
                    hs = list(set(list(range(H)))-set(hs))
                    ws = list(set(list(range(W)))-set(ws))
                    if len(hs)==0:
                        score = np.sum(bw_map[:, ws]=="#")
                    elif len(ws)==0:
                        score = np.sum(bw_map[hs, :]=="#")
                    else:
                        tmp = bw_map[hs]
                        tmp = tmp[:, ws]
                        score = np.sum(tmp=="#")

                    if score == K:
                        result+=1
    print(result)




Measured memory_bytes: 27240
#include <stdio.h>

int keta();
int kuriagari();
int maxKeta();

int main(void)
{	//statusツつェEOFツづーツ陛板つオツつスツづァツ、ツ禿シツ療債終ツ猟ケ(ctrl+z)
	int a,b,status,digit,temp;
	do{
		status=scanf("%d%d",&a,&b);
		if (status!=EOF){
			printf("%d\n",keta(a+b));
		}
	}while(status!=EOF);
	return 0;
}

int keta(int a){
	int i=1,b=10;
	while (a/10>0 || b/10>0){
		a/=10;
		b/=10;
		i++;
	}
	return i;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,ans=0,sum=0,aa,bb,cc;
bool B=true;
int main(){
  cin >> a >> b >> c;
  int MAX=max({a,b,c});
  int aa=MAX-a;
  int bb=MAX-b;
  int cc=MAX-c;
  if(aa==0){
    if(bb%2==cc%2){
      cout << (bb+cc)/2 << endl;
    }else{
      if(bb%2==0){
        cout << bb/2+(cc+1)/2+1 << endl;  
      }else{
        cout << cc/2+(bb+1)/2+1 << endl;
      }
    }
  }else if(bb==0){
    if(aa%2==cc%2){
      cout << (aa+cc)/2 << endl;
    }else{
      if(aa%2==0){
        cout << aa/2+(cc+1)/2+1 << endl;
      }else{
        cout << cc/2+(aa+1)/2+1 << endl;
      }
    }    
  }else if(cc==0){
    if(aa%2==bb%2){
      cout << (aa+bb)/2 << endl;
    }else{
      if(aa%2==0){
        cout << aa/2+(bb+1)/2+1 << endl;
      }else{
        cout << bb/2+(aa+1)/2+1 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
typedef long long int lli;
int main() {
	// your code goes here
	lli n,i,ans=0;
	cin>>n;
	for(i=1;i<=n;i++){
	    if(i%3!=0 && i%5!=0){
	        ans+=i;
	    }
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3624
n,h=map(int,input().split())

#a>bだったらaを振り続ければいい
#aの最大になるまで、bを投げ続けて、aが最大になったらあとはaの最大を振る
#順番は無視していいので、
#bを1回、aを無限回触れる問題に帰着する？

ba=[]
max_a=0
for _ in range(n):
    a,b=map(int,input().split())
    max_a=max(max_a,a)
    ba.append([-1*b,a])

ba.sort()
cnt=0


#print(ba)
for item in ba:
    b=item[0]*(-1)
    a=item[1]

    if b>=max_a:
        h-=b
        cnt+=1
    else:
        break

    if h<=0:
        break

if h>0:
    cnt-=(-1*h)//max_a

print(cnt)





Measured memory_bytes: 63704
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define push push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
int main(){
    int n;
    ll ans=0;
    cin >> n;
    vector<ll>a(n+1,0LL);
    int r=0;
    rep(i,n){
        cin>>a[i];
        ans+=(a[i]+r)/2;
        r=(a[i]+r)%2;
        if(a[i]==0){
            r=0;
        }

    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int x = 0;
        int max = x;
        for(int i = 0; i < N; i++){
        	char c = S.charAt(i);
        	if(c == 'I') x++;
        	else if(c == 'D') x--;
        	if(max < x) max = x;
        }
        System.out.println(max);
	}

}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {

	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final String s = sc.next();
			
			for(int i = 0; i < s.length(); i++) {
				System.out.print("x");
			}
			System.out.println();
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21332
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  int h,w;
  cin >> h >> w;
  int ans = H*W - (h * W + w * (H-h));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> numA(105);
  vector<int> numB(105);
  for(int i = 0;i < N;i++){
    cin >> numA.at(i);
    cin >> numB.at(i);
  }
  int count = 0;
  int judge = 0;
  for(int i = 0;i < N;i++){
    if(numA.at(i) == numB.at(i)){
      count++;
    }else{
      count = 0;
      judge = 0;
    }
    if(count == 3){
      judge = 1;
      break;
    }
  }
  if(judge == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
while True:
    (n, m) = list(map(int, input().split()))
    if n == 0:
        break
    sec = []
    for j in range(n):
        sec.append(list(map(int, input().split())))
    sec.sort(key=lambda x: x[1], reverse=True)
    res = 0
    for e in sec:
        if e[0] <= m:
            m -= e[0]
        elif m == 0:
            res += e[0] * e[1]
        else:
            res += e[1] * (e[0] - m)
            m = 0
    print(res)



Measured memory_bytes: 7136
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

d = defaultdict(int)
for i in a:
  d[i] += 1

a.sort()
mx = max(a)

chk = [False for i in range(mx+1)]
cnt = 0
for i in range(n):
  if d[a[i]] >= 2:
    for j in range(a[i],mx+1,a[i]):
      chk[j] = True
    continue
  if chk[a[i]] == False:
    cnt += 1
  for j in range(a[i],mx+1,a[i]):
    chk[j] = True
print (cnt)


Measured memory_bytes: 43124
{-# OPTIONS_GHC -O2 #-}
import qualified Data.ByteString.Char8 as BSC8
import qualified Data.Maybe            as Maybe

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

main :: IO ()
main = do
  [n, m] <- readInts
  print $ (n * n - n + m * m - m) `div` 2


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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (long long)1e18 + 1;

class UnionFind {
public:
    struct Node {
        long long parent;
        long long rank;
        Node() = default;
        Node(const long long& _parent,
             const long long& _rank) :
            parent(_parent),
            rank(_rank) { }
    };

    std::vector<Node> node;

    UnionFind(const long long& num_node) :
        node(num_node) {
        for(long long i = 0; i < num_node; i++) {
            node[i].parent = i;
        }
    }

    long long getRoot(const long long& x) {
        return (node[x].parent == x) ?
            x : node[x].parent = getRoot(node[x].parent);
    }

    void unite(const long long& x,
               const long long& y) {
        auto rx = getRoot(x);
        auto ry = getRoot(y);
        if(rx != ry) {
            if(node[rx].rank < node[ry].rank) {
                node[rx].parent = ry;
            }
            else {
                node[ry].parent = rx;
                if(node[rx].rank == node[ry].rank) {
                    node[rx].rank++;
                }
            }
        }
    }

    template<class... A>
    bool checkWhetherRootIsSame(const A&... nodes) {
        auto node_list = std::initializer_list<long long>{nodes...};
        if(node_list.size() == 0) {
            return false;
        }
        auto v = getRoot(*node_list.begin());
        for(size_t i = 1; i < node_list.size(); i++) {
            if(v != getRoot(*(node_list.begin() + i))) {
                return false;
            }
        }
        return true;
    }
};

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

    int N, M;
    std::cin >> N >> M;

    vector<int> P(N);
    REP(i, N) {
        int p;
        std::cin >> p;
        P[i] = p - 1;
    }

    UnionFind tree(N);
    REP(i, M) {
        int x, y;
        std::cin >> x >> y;
        tree.unite(x - 1, y - 1);
    }

    int ans = 0;
    REP(i, N) {
        if(tree.checkWhetherRootIsSame(i, P[i])) {
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 2176
# coding: utf-8
N = int(input())
H = list(map(int, input().split()))
ans = []
cnt = 0
for i in range(N):
    if i == 0:
        tmp = H[i]
    else:
        if tmp >= H[i]:
            cnt += 1
        else:
            ans.append(cnt)
            cnt = 0
        tmp = H[i]
ans.append(cnt)
print(max(ans))

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int q;
	cin>>q;
	vector<ll> A(q),B(q);
	rep(i,q)cin>>A[i]>>B[i];
	rep(i,q){
		ll a=A[i];
		ll b=B[i];
		// cin>>a>>b;
		if(a>b){
			ll tmp = b;
			b=a;
			a=tmp;
		}
		ll ans = 0;

		if(a==b) ans=2*a-2;
		else if(a+1==b) ans=2*a-2;
		else{

			ll c = floor(sqrt(a*b));
			// cout<<c<<endl;
			if(c*c==a*b)c--;
			if(c*(c+1)>=a*b) ans = 2*c-2;
			else ans = 2*c-1;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

a_min = min(a)
a_max = max(a)

costSum = [0] * (a_max - a_min + 1)
k = 0

for i in range(a_min, a_max + 1):
    for j in range(len(a)):
        costSum[k] += (i - a[j]) ** 2

    k += 1

print(min(costSum))


Measured memory_bytes: 3060
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;
bool ym, my;
int main(){
    cin >> s;
    int a = (s[0] - '0')*10 + (s[1] - '0'), b = (s[2] - '0')*10 + (s[3] - '0');
    if((1 <= b && b <= 12))ym = true;
    if((1 <= a && a <= 12))my = true;

    if(ym && my){
        cout << "AMBIGUOUS" << endl;
    }else if(ym){
        cout << "YYMM" << endl;
    }else if(my){
        cout << "MMYY" << endl;
    }else{
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 384
import bisect
import math
N = int(input())
A = list(map(int,input().split()))

S = [0] * (N+1)
for i in range(1,N+1):
    S[i] = S[i-1]+A[i-1]

L = S[-1]

pre_s = 0
for s in S:
    if s > L/2:
        break
    pre_s = s

l = L - 2*pre_s
r = 2*s-L
print(min(l,r))


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

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

int main() {
  ll n;
  cin >> n;
  ll g = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    g = gcd(g, a);
  }
  cout << g << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<ll>
#define vpi vector<pair<ll,ll> >
#define mpi map<ll,ll>
#define  si set<ll>
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define reP(i,a,n) for(ll i=a;i<=n;i++)
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define st string
#define sz size()
#define case(i,n) Case<<" "<<i<<": "<<n<<endl;
#define tc ll t;cin>>t;while(t--)
int main()
{
    ll n,m;cin>>n;
    ll x,y;
    ll mi=1000000000000;
    ll d=sqrt(n);
    for(ll i=1;i<=d;i++)
    {
        if(n%i==0)
        {
            ll m=abs(i-(n/i));
            if(m<mi)
            {
                x=i;
                y=n/i;
            }
        }
    }
    cout<<(x-1)+(y-1)<<endl;
}


Measured memory_bytes: 3580
L,R=map(int, input().split())

mod=2019
if L//mod != R//mod:
    print(0)
else:
    ans=2018
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans=min(ans,(i*j)%mod)
            if ans==0:
                break
        else:
            continue
        break
    print(ans)


Measured memory_bytes: 3060
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.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public 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(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			for(int i = 0; i < 3; i++) {
				String S = in.next();
				for(int j = 0; j < 3; j++) {
					if(i == j) {
						out.print(S.charAt(i));
					}
				}
			}
			out.println();
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

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

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

	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
int n;
ll a,b,x[100010],cost;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n>>a>>b;
    for(int i=1;i<=n;i++) cin>>x[i];
    for(int i=2;i<=n;i++){
        cost += (min ((x[i]-x[i-1])*a , b));
    }
    cout<<cost<<newl;


}


Measured memory_bytes: 1024
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var h = o.l();
  var ans = 0, r = h[n-1], t = 0;
  for(var i = n-2; i >= 0; i--){
    if(r <= h[i])t++; else t = 0;
    if(ans < t)ans = t;
    r = h[i];
  }
  return ans;
}

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

int main()
{
  int *A,*C;
  int N,M,X,min_price,max_price=1,com,tmp,*tmp_A,tmp_p,count;
  cin>>N>>M>>X;
  com=pow(2,N);
  A=new int[N*M];
  tmp_A=new int[M];
  C=new int[N];
  
  for(int i=0;i<N;i++)
  {
    cin>>C[i];
    max_price+=C[i];
    for(int j=0;j<M;j++)
      cin>>A[i*M+j];
  }   
  min_price=max_price;
  for(int i=1;i<com;i++)
  {
    count=0;
    tmp=i;
    tmp_p=0;
    for(int k=0;k<M;k++)
      tmp_A[k]=0;
    
    for(int j=0;j<N;j++)
    {
      if(tmp%2!=0)
      {
       tmp_p+=C[j];
       for(int k=0;k<M;k++)
         tmp_A[k]+=A[j*M+k];
      }
      tmp=tmp/2;
    }
    for(int j=0;j<M;j++)
      if(tmp_A[j]>=X)
        count++;
    if(count==M && min_price>tmp_p)
      min_price=tmp_p;
      
  }
  if(min_price==max_price)
    cout<<-1;
  else
    cout<<min_price;
   
  delete[] tmp_A;
  delete[] C;
  delete[] A;
}

Measured memory_bytes: 3204
n = int(input())
p = input()
q = input()
r = input()
res = 0
for (a,b,c) in zip(p,q,r):
    if a == b == c:
        pass
    elif a == b or b == c or c == a:
        res += 1
    elif a != b and b != c and c != a:
        res += 2
    # print(res)
print(res)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N;
llint C;
llint x[100010];
int v[100010];
llint dp[2][100010];


void makeDP(){
	llint cal = 0;
	dp[0][0] = cal = v[0]-x[0];
	rep(i, 1, N){
		cal += v[i]-(x[i]-x[i-1]);
		dp[0][i] = max(dp[0][i-1], cal);
	}
	dp[1][N-1] = cal = v[N-1]-(C-x[N-1]);
	reper(i, N-2, 0){
		cal += v[i]-(x[i+1]-x[i]);
		dp[1][i] = max(dp[1][i+1], cal);
	}
}


llint solve(){
	llint ans = 0;
	rep(i, 0, N) ans = max({ ans, dp[0][i], dp[0][i]-x[i]+dp[1][i+1] });
	reper(i, N-1, 0) ans = max({ ans, dp[1][i], dp[1][i]-(C-x[i])+dp[0][i-1] });
	return ans;
}


signed main(){
	cin >> N >> C;
	rep(i, 0, N) cin >> x[i] >> v[i];

	makeDP();

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a!=1&&b!=1) cout<<1<<endl;
	if(a!=2&&b!=2) cout<<2<<endl;
	if(a!=3&&b!=3) cout<<3<<endl;
	return 0;
}


Measured memory_bytes: 256
# coding:utf-8

import sys
from collections import deque

INF = float('inf')
MOD = 10 ** 9 + 7
dy, dx = (0, -1, 0, 1), (1, 0, -1, 0)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    h, w = LI()
    B = [list(SI()) for _ in range(h)]

    D = deque()
    for i, row in enumerate(B):
        for j, c in enumerate(row):
            if c == '#':
                D.append((i, j, 0))

    while D:
        y, x, cnt = D.popleft()
        for i in range(4):
            yy = y + dy[i]
            xx = x + dx[i]

            if 0 <= yy < h and 0 <= xx < w:
                if B[yy][xx] == '#':
                    continue
                B[yy][xx] = '#'
                D.append((yy, xx, cnt + 1))

    print(cnt)




if __name__ == '__main__':
    main()


Measured memory_bytes: 161628
#include <iostream>
using namespace std;
int main() {
    long long n;
    cin >> n;
    int result = 0;
    while (n > 0) {
        if ((n%10 != 9) && n>9) {
            result += 9;
            n = (n/10) - 1;
        } else {
            result += n%10;
            n /= 10;
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define MAXN 1005
#define MAXM 1000005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,m;
int a[MAXN],b[MAXN];
bool row[MAXM],col[MAXM];
int main()
{
    memset(row,false,sizeof(row));
    memset(col,false,sizeof(col));
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(row[a[i]])
        {
            puts("0");
            return 0;
        }
        row[a[i]]=true;
    }
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&b[i]);
        if(col[b[i]])
        {
            puts("0");
            return 0;
        }
        col[b[i]]=true;
    }
    if(!row[n*m]||!col[n*m])
    {
        puts("0");
        return 0;
    }
    int ans=1;
    int c=1,r=1,rem=0;
    for(int i=n*m-1;i>=1;i--)
    {
        if(col[i]&&row[i])
        {
            rem+=c+r;
            c++;r++;
            if(r>n||c>m) {ans=0; break;}
        }
        else if(col[i])
        {
            ans=1LL*r*ans%MOD;
            c++; rem+=r-1;
            if(r>n||c>m) {ans=0; break;}
        }
        else if(row[i])
        {
            ans=1LL*c*ans%MOD;
            r++; rem+=c-1;
            if(r>n||c>m) {ans=0; break;}
        }
        else
        {
            ans=1LL*rem*ans%MOD;
            rem--;
            if(rem<0) {ans=0; break;}
        }
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 2176
N = STDIN.gets.to_i

An = STDIN.gets.split.map(&:to_i)
Bn = STDIN.gets.split.map(&:to_i)

Pair = Struct.new(:a, :b, :dirty, :diff)

zipped = An.zip(Bn).map do |array|
  Pair.new(array[0], array[1], false, array[0] - array[1])
end

grouped = zipped.group_by {|pair| pair.a >= pair.b }

satisfied = grouped[true].sort_by {|pair| -(pair.a - pair.b)}
not_satisfied = grouped[false]

# p satisfied, not_satisfied

if not_satisfied.nil?
  puts 0
else
  shortage = not_satisfied.inject(0) {|sum, pair| sum + pair.diff}

  # p shortage

  num = 0

  satisfied.each do |pair|
    shortage += pair.diff
    pair.dirty = true
    num += 1
    if shortage>= 0
      break;
    end
  end

  if shortage < 0
    puts -1
  else
    puts not_satisfied.size + num
  end
end


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


int findcost(int n,int k,vector<int> h){
    int dp[n+1];

    dp[1] = 0;

    for(int i=2;i<=k;i++){
        dp[i] = abs(h[i]-h[1]);
    }

    for(int j=1+k;j<=n;j++){
        int mindp = INT_MAX;
        for(int i=1;i<=k;i++){
            mindp =min(mindp,dp[j-i]+abs(h[j-i]-h[j]));
        }
        dp[j] = mindp;
    }
    return dp[n];
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<int> h(n+1);
    for(int i=1;i<=n;i++)
        cin>>h[i];

    if(n == 1){
        cout<<0<<endl;
        return 0;
    }
    if(k>=n-1){
        cout<<abs(h[n]-h[1])<<endl;
        return 0;
    }
    cout<<findcost(n,k,h)<<endl;


    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;
using P = pair<int, int>;


ull E = 1000000007;

int main() {
    int K, S;
    cin >> K >> S;
    int ans = 0;
    for (int X = 0; X <= K; ++X) {
        if (X > S) break;
        for (int Y = 0; Y <= K; ++Y) {
            if (X + Y > S) break;
            if (S - (X + Y) <= K) ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;
typedef long long lld;
const int RED = 1;
const int GREEN = 2;
const int COLORLESS = 3;
struct apple {
	lld delicious;
	int color;
	bool operator<(const apple &o) const {
		return delicious > o.delicious;
	}
};

vector<apple> colorless;
vector<apple> red;
vector<apple> green;
vector<apple> ans;

bool cmp(const apple &a, const apple &b)
{
	return a.delicious < b.delicious;
}
int main(void)
{
	cin.tie(0);	ios_base::sync_with_stdio(0);
	int x, y, a, b, c;	cin >> x >> y >> a >> b >> c;
	for(int i=0; i<a; i++)
	{
		int t;	cin >> t;
		red.push_back({t, RED});
	}
	for(int i=0; i<b; i++)
	{
		int t;	cin >> t;
		green.push_back({t, GREEN});
	}
	for(int i=0; i<c; i++)
	{
		int t;	cin >> t;
		colorless.push_back({t, COLORLESS});
	}
	sort(red.begin(), red.end());
	sort(green.begin(), green.end());
	sort(colorless.begin(), colorless.end());
	for(int i=0; i<x; i++)
		ans.push_back(red[i]);
	for(int i=0; i<y; i++)
		ans.push_back(green[i]);
	
	sort(ans.begin(), ans.end(), cmp);
	for(int i=0; i<min(x+y, c); i++)
		if(ans[i].delicious < colorless[i].delicious)
			ans[i] = colorless[i];
	
	lld tot = 0;
	for(const apple &co: ans)
	{
		tot += co.delicious;
	}
	cout << tot;
	return 0;
}


Measured memory_bytes: 10864
INF = 10 ** 20
 
N = int(input())
coin_list = [1] + [6**i for i in range(1, 7)] + [9**i for i in range(1, 6)]
dp = [INF]*(N+1)
dp[0] = 0

for coin in coin_list:
	for amount in range(1,N+1):
		if amount-coin >= 0: dp[amount] = min(dp[amount], dp[amount-coin]+1)
 
print(dp[N])

Measured memory_bytes: 49244
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#include<cstdlib>
#include <queue>
#include <cmath>
#include <iomanip>
#include<list>
#include <utility>
#include <functional>
#include <tuple>
#define T long long
T pow5(T n){
	return n*n*n*n*n;
}

int main(){
	T x;
	std::cin >> x;
	T window = std::pow(x,0.3)+1;
	for(T i=-window;i<=window;i++){
		for(T j=-window;j<=window;j++){
			if(pow5(i)-pow5(j)==x){
				std::cout << i <<" "<<j<<std::endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 4060
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
 
 ll N;
  cin >>N;
  
  vl a(N);
  rep(i,N) {
cin >>a.at(i);
  }
vl vec(201);
  rep(i,201) {
    vec.at(i)=-100+i;
  }
  vl sa(201);
  rep(i,201) {
    sa.at(i)=0;
  }
  
  rep(i,201) {
    rep(j,N) {
      sa.at(i)+=(vec.at(i)-a.at(j))*(vec.at(i)-a.at(j));
    }
  }
  sort(all(sa));
  cout<<sa.at(0)<<endl;
}

  
 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();

		int answer=1;

		for(int i=2;i<x;i++) {
			answer=Math.max(answer, bekijou(i, x));
		}

		System.out.print(answer);
	}

	public static int bekijou(int b, int x) {

		int i=b;
		while(i*b<=x) {
			i=i*b;
		}
		if(i!=b) {
			return i;
		}
		else {
			return 0;
		}


	}

}


Measured memory_bytes: 23764
def length(xa, ya, xb, yb)
  Math.sqrt((xa - xb)*(xa - xb) + (ya - yb)*(ya - yb))
end

n = gets.to_i
n.times do
  xa, ya, ra, xb, yb, rb = gets.split(' ').map(&:to_f)
  len = length(xa, ya, xb, yb)

  if ra > rb + len
    puts 2
  elsif rb > ra + len
    puts -2
  elsif ra + rb < len
    puts 0
  else
    puts 1
  end
end

Measured memory_bytes: 6116
#include <bits/stdc++.h>
using namespace std;
const int N=3e5+10;
int n,m,bomb;
int row[N],col[N];
map<pair<int,int>,bool> mp;
vector<int> cntr,cntw;
int maxh,maxw;
int main() {
    cin>>n>>m>>bomb;
    for(int i=0;i<bomb;i++) {
        int x,y;
        cin>>x>>y;
        x--;y--;
        mp[{x,y}]=true;
        row[x]++;
        col[y]++;
        maxh=max(maxh,row[x]);
        maxw=max(maxw,col[y]);
    }
    for(int i=0;i<n;i++) if(row[i]==maxh) cntr.push_back(i);
    for(int i=0;i<m;i++) if(col[i]==maxw) cntw.push_back(i);
    for(int i=0;i<(int)cntr.size();i++) {
        for(int j=0;j<(int)cntw.size();j++) 
            if(!mp[{cntr[i],cntw[j]}]) {
                cout<<maxh+maxw<<endl;
                return 0;
            }
    }
    cout<<maxh+maxw-1<<endl;
    return 0;
}

Measured memory_bytes: 28484
S = input()
str = "abcdefghijklmnopqrstuvwxyz"
l1 = list(str)
l2 = list(S)
l3 = list(set(l1)-set(l2))
l3.sort()
if len(l3)==0:
    print("None")
else:
    print(l3[0])


Measured memory_bytes: 3956
# gcdと逆元
def inv_gcd(a, b):
  a = a % b
  if a == 0: return (b, 0)
  s, t = b, a
  m0, m1 = 0, 1
  while t:
    u = s // t
    s -= t * u
    m0 -= m1 * u
    s, t = t, s
    m0, m1 = m1, m0
  if m0 < 0: m0 += b // s
  return (s, m0)

import math
def prime(x):
  p = {}
  last = math.floor(x ** 0.5)
  if x % 2 == 0:
    cnt = 1
    x //= 2
    while x & 1 == 0:
      x //= 2
      cnt += 1
    p[2] = cnt
  for i in range(3, last + 1, 2):
    if x % i == 0:
      x //= i
      cnt = 1
      while x % i == 0:
        cnt += 1
        x //= i
      p[i] = cnt
  if x != 1:
    p[x] = 1
  return p

N = int(input())

N *= 2
p = prime(N)
L = []
for key in p.keys():
  L.append(key)

M = len(L)
ans = N - 1
for i in range(1, (1 << M) - 1):
  x = 1
  cnt = 0
  while i:
    if i & 1:
      key = L[cnt]
      x *= pow(key, p[key])
    i >>= 1
    cnt += 1
  y = N // x
  iv = inv_gcd(x, y)[1]
  if iv == 0: continue
  ans = min(ans, iv * x - 1)

print(ans)

Measured memory_bytes: 68952
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int s,w;
	 cin>>s>>w;
	 if(w>=s)
	 cout<<"unsafe";
	 else
	 cout<<"safe";
	 return 0;
}

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

const int INF = 1000000000;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    vector<vector<int>> C(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        for (int j = 0; j < B[i]; j++) {
            int c;
            cin >> c;
            C[i].push_back(c - 1);
        }
    }

    vector<int> dp(4096, INF);
    dp[0] = 0;
    for (int i = 0; i < M; i++) {
        int mask = 0;
        for (int j = 0; j < B[i]; j++) {
            mask |= (1 << C[i][j]);
        }
        for (int bit = 0; bit < (1 << N); bit++) {
            dp[bit | mask] = min(dp[bit | mask], dp[bit] + A[i]);
        }
    }

    if (dp[(1 << N) - 1] == INF) {
        cout << -1 << endl;
    } else {
        cout << dp[(1 << N) - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(){

	int A,B,C;

	scanf("%d %d %d",&A,&B,&C);

	int X=A%B;

	int i;

	int flag=0;

	for(i=0;i<B;i++){
		if((X*i)%B==C){flag=1;}
	}

	if(flag==1){
	printf("YES\n");
	}
	else{
	printf("NO\n");
	}

	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll mod = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N;
    cin >> N;
    ll ans = 0;
    ll tmp = 0;

    for(ll i = 0; i < N; i++){
        ll A; cin >> A;
        vec.push_back(A);
    }
    vec.push_back(0);

    if(N == 1){
        cout << vec[0] / 2 << endl;
        return 0;
    }

    for(ll i = 0; i < N; i++){
        if(vec[i] == 0) continue;
        if(i > 0 && vec[i - 1] == 1){
            ans++;
            vec[i]--;
        }
        ans += vec[i] / 2;
        vec[i] %= 2;
    }

    cout << ans << endl;

}

Measured memory_bytes: 1400
from math import sin,cos,pi,sqrt
a,b,d=map(float,input().split())
S=a*b*sin(d*pi/180)/2
c=sqrt(a**2+b**2-2*a*b*cos(d*pi/180))
h=2*S/a
print(S)
print(a+b+c)
print(h)



Measured memory_bytes: 5696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b;
  c = a * b;
  if (c % 2 == 0) {
    cout << "Even" << endl;
  }
  
  if (c % 2 == 1) {
    cout << "Odd" << endl;
  }
}

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

int main() {
  string s;
  cin >> s;
  int zero = 0;
  int ichi = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      zero++;
    } else {
      ichi++;
    }
  }
  cout << 2 * min(zero, ichi) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;

int main(){

    int n;
    cin >> n;

    vector<int> count(100001);

    rep(i,n){
        int tmp;
        cin >> tmp;

        count[tmp]++;
    }

    int one = 0;
    int modzero = 0;
    int modone = 0;

    rep(i, 100001){
        if(count[i] == 1){
            one++;
        }else if(count[i] != 0){
            if(count[i] % 2 == 0){
                modzero++;
            }else{
                modone++;
            }
        }
    }

    int ans = one + modzero + modone;

    if(modzero % 2 == 1){
        ans--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
s = list(input())
n = int(input())
for i in range(n):
    l = [j for j in input().split()]
    if l[0] == "print":
        print("".join(s[int(l[1]):int(l[2])+1]))
    elif l[0] == "reverse":
        r = s[int(l[1]):int(l[2])+1]
        s = s[:int(l[1])] + r[::-1] + s[int(l[2])+1:] 
    elif l[0] == "replace":
        s = s[:int(l[1])] + list(l[3]) + s[int(l[2])+1:] 
    

Measured memory_bytes: 7720
n,m = (int(i) for i in input().split())
number = [0] * n
number[0] = 1
numberFlag = [0] * n
answer = ""
if m == 0 and n == 1:
	print(0)
	exit(0)
elif m > 0:
	for i in range(m):
		s,c = (int (i) for i in input().split())
		if s == 1 and c == 0 and n > 1:
			print(-1)
			exit(0)
		elif number[s-1] != c and numberFlag[s-1] == 1:
			print(-1)
			exit(0)
		elif numberFlag[s-1] == 0:
			number[s-1] = c
			numberFlag[s-1] = 1

for i in range(n):
	answer += str(number[i])
print(answer)

Measured memory_bytes: 38384