akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e5 + 10;
int N;
struct Node {
	int x, y, id;
} A[MAXN], E[MAXN];
int fa[MAXN];
long long ans;

inline int gf(int x) {
	return x == fa[x] ? x : fa[x] = gf(fa[x]);
}

int main() {
	register int i;
	scanf("%d", &N);
	for(i = 1; i <= N; ++i) scanf("%d%d", &A[i].x, &A[i].y), A[i].id = i;
	sort(A + 1, A + N + 1, [&] (Node x, Node y) {return x.x < y.x;});
	for(i = 1; i < N; ++i) E[i] = Node{A[i].id, A[i + 1].id, A[i + 1].x - A[i].x};
	sort(A + 1, A + N + 1, [&] (Node x, Node y) {return x.y < y.y;});
	for(i = 1; i < N; ++i) E[N + i - 1] = Node{A[i].id, A[i + 1].id, A[i + 1].y - A[i].y};
	sort(E + 1, E + 2 * N - 1, [&] (Node x, Node y) {return x.id < y.id;});
	for(i = 1; i <= N; ++i)
		fa[i] = i;
	for(i = 1; i <= 2 * N - 2; ++i)
		if(gf(E[i].x) != gf(E[i].y))
			fa[gf(E[i].x)] = gf(E[i].y), ans += E[i].id;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{

			String strLine = insBR.readLine();

			String strNum = insBR.readLine();
			int intNum = Integer.parseInt(strNum);

			for(int i = 0; i < intNum; i++){

				String[] strOrder = insBR.readLine().split(" ");
				int intFirst = Integer.parseInt(strOrder[1]);
				int intSecond = Integer.parseInt(strOrder[2]);

				if("print".equals(strOrder[0])){
					intSecond += 1;
					String strPrint = strLine.substring(intFirst, intSecond);
					System.out.println(strPrint);

				}else if("reverse".equals(strOrder[0])){

					String[] strReverse = strLine.split("");
					for(int j = intFirst; j < intSecond; j++){
						String strAct = strReverse[j];
						strReverse[j] = strReverse[intSecond];
						strReverse[intSecond] = strAct;
						intSecond--;
					}

					strLine = "";
					for(int j = 0; j < strReverse.length; j++){
						strLine += strReverse[j];
					}
					//System.out.println("reverse = " + strLine);

				}else{
					intSecond += 1;
					String strAct = strLine.substring(intFirst, intSecond);
					//System.out.println("置き換える対象は、" + strAct);
					StringBuilder sb = new StringBuilder();
					sb.append(strLine);
					sb.replace(intFirst, intSecond,strOrder[3]);
					//strLine = strLine.replaceFirst(strAct, strOrder[3]);
					strLine = sb.toString();
					//System.out.println("replace = " + strLine);
				}
			}

		}catch(IOException e){
			e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}

	}

}



Measured memory_bytes: 89460
import java.util.Scanner;

public class Main {

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

		int i = 1;
		while (i < 3001) {
			String line = sc.nextLine();
			String[] array = line.split(" ");
			int x = Integer.parseInt(array[0]);
			int y = Integer.parseInt(array[1]);
			if (x == 0 && y == 0) {
				break;
			} else if (x >= y) {
				System.out.println(y + " " + x);

			} else if (x < y) {
				System.out.println(x + " " + y);

			}
			i++;
		}

	}

}

Measured memory_bytes: 34652
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

def make_primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

def prime_decomposition(n): #素因数分解
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table

def make_divisors(n): #約数列挙
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def Topo_sort(x,y):
    co = cl.Counter(n for m in x.values() for n in m)
    S = cl.deque([i for i in range(y) if co[i] == 0])
    while S:
        n = S.popleft()
        yield n
        for i in x[n]:
            co[i] -= 1
            if co[i] <= 0:
                S.append(i)
    """
    if sum(co.values()) != 0:
        print(1)
        exit()
    else:
        print(0)
        exit()
    """
    #閉路検出(1が存在,0が存在しない)
# g = cl.defaultdict(set)に有向グラフを作成し(g[~] != ~ ,yはノード数) リストが帰ってくる

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

n = onem()

a = l()

po = max(a)

ans = 0

al = 1

for i in range(n):
    al = lcm(al,a[i])
    

al %= mod

for i in range(n):
    ans += al * pow(a[i],mod-2,mod)
    ans %= mod
print(ans)


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main(){
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];
    
    vector<int> T(N);
    rep(i,N) T[i] = i+1;
    
    int p, q, cnt=0;
    do{
        {
            bool f = true;
            rep(i,N) if(P[i]!=T[i]) f=false;
            if(f) p = cnt;
        }
        {
        bool f = true;
        rep(i,N) if(Q[i]!=T[i]) f=false;
        if(f) q = cnt;
        }
        cnt++;
    }while(next_permutation(T.begin(), T.end()));
    
    cout << abs(p-q) << endl;
}


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

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

    if (n == 2) {
	if (s[0] == s[1])
	    cout << 1 << " " << 2 << endl;
	else
	    cout << -1 << " " << -1 << endl;
	return 0;
    }

    bool tf = false;
    for (int i = 0; i < n - 1; i++) {
	if (s[i] == s[i + 1]) {
	    cout << i + 1 << " " << i + 2 << endl;
	    return 0;
	} else if ((s[i] == s[i + 2]) && (i + 1 < n)) {
	    cout << i + 1 << " " << i + 3 << endl;
	    return 0;
	}
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
n = gets.to_i
dn = gets.split.map(&:to_i)

if dn.size % 2 == 1
  p 0
  exit
end
dn.sort!
min = dn[n/2-1]
max = dn[n/2]
if min >= max
  p 0
else
  p max - min
end



Measured memory_bytes: 8832
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define ll long long
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, a, n) for (int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int c[51][51];
int w, h;
void dfs(int x, int y) {
    c[x][y] = 0;
    for (int i = -1; i <= 1; i++) {
        for (int k = -1; k <= 1; k++) {
            int new_x = x + i, new_y = y + k;
            if (0 <= new_x && new_x < h && 0 <= new_y && new_y < w &&
                c[new_x][new_y] == 1) {
                dfs(new_x, new_y);
            }
        }
    }
}

int main() {
    while (true) {
        int ans = 0;
        cin >> w >> h;
        if (w == 0 && h == 0) break;
        rep(i, h) rep(k, w) cin >> c[i][k];
        for (int x = 0; x < h; x++) {
            for (int y = 0; y < w; y++) {
                if (c[x][y] == 1) {
                    ans++;
                    dfs(x, y);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n,y;
    cin >> n >> y;
    bool flag = true;
    for(int i = 0; i <= y/1000; i++){
        for(int j = 0; j <= (y-i*1000)/5000; j++){
            int num = (y-i*1000-j*5000)/10000;
            if(i+j-n == -num && num*10000+i*1000+j*5000 == y){
                flag = false;
                cout << num << " " << j << " " << i << endl;
                break;
            }
            if(!flag) break;
        }
        if(!flag) break;
    }
    if(flag) cout << -1 << " " << -1 << " " << -1 << endl;
}

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

int main()
{
   int N,X; cin>>N>>X;
   int cur=0,ans=1;
   for(int i=0;i<N;i++){
      int a; cin>>a;
      cur+=a;
      if(cur<=X) ans++;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
ans = 0
A, B, AB, X, Y = map(int, input().split())
AB = min(AB * 2, A + B)
m = min(X, Y)
ans += m * AB
X -= m
Y -= m
if X == 0:
    ans += min(B, AB) * Y
else:
    ans += min(A, AB) * X
print(ans)

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

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

  priority_queue<pair<int, int>> sushi;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    sushi.emplace(b, a);
  }

  vector<pair<int, int>> v(k);
  vector<int> type(n + 1);
  int64_t ans = 0;
  int64_t d = 0;
  int64_t t;

  for (int i = 0; i < k; i++) {
    auto p = sushi.top();
    sushi.pop();
    d += p.first;
    type[p.second]++;
    v[i] = {p.first, p.second};
  }

  t = count_if(begin(type), end(type), [](auto a){return a > 0;});
  ans = d + t * t;

  reverse(begin(v), end(v));

  for (int i = 0; i < k; i++) {
    auto p = v[i];
    if (type[p.second] == 1) continue;
    if (sushi.empty()) break;
    bool f = false;
    while (!sushi.empty()) {
      auto s = sushi.top();
      sushi.pop();
      if (type[s.second] == 0) {
        f = true;
        type[s.second]++;
        t++;
        d -= p.first;
        d += s.first;
        break;
      }
    }
    if (f) {
      ans = max(ans, d + t * t);
    }
  }
  cout << ans << endl;
}


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

int main(){
	ll A, B, N;
	cin >> A >> B >> N;

	ll x = min(B-1, N);
	cout << floor(A*x/B)-A*floor(x/B) << endl;


	return 0;	
	
}

Measured memory_bytes: 3772
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int k = sc.nextInt();
	    int r;
	    if(n >= 10){
            r = k;
        }else{
	        r = k + 100 * (10 - n);
        }
        System.out.println(r);
    }
}


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

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int k;
	vector<int>v[n];
	vector<int>dpa(n);
	vector<int>dpb(n);
	vector<int>dpc(n);
	
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=3;j++)
		{
			cin>>k;
			v[i].push_back(k);
		}
		dpa[i]=dpb[i]=dpc[i]=INT_MIN;
		
	}
	
	dpa[0]=v[0][0];
	dpb[0]=v[0][1];
	dpc[0]=v[0][2];
	for(int i=1;i<n;i++)
	{
		dpa[i]=max(dpb[i-1],dpc[i-1])+v[i][0];
		dpb[i]=max(dpa[i-1],dpc[i-1])+v[i][1];
		dpc[i]=max(dpa[i-1],dpb[i-1])+v[i][2];
	//	cout<<dpa[i]<<" "<<dpb[i]<<" "<<dpc[i]<<"\n ";
	}
	//cout<<dpa[n-1]<<" "<<dpb[n-1]<<" "<<dpc[n-1]<<" ";
	int mx=max(dpa[n-1],dpc[n-1]);
		mx=max(mx,dpb[n-1]);
		cout<<mx;
/*		for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			
			cout<<v[i][j]<<" ";
		}
		cout<<"\n";
		
	}*/

	
	return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mk make_pair
#define pb push_back
#define vi vector<int>
#define x first
#define y second
#define ms(a,b)  memset(a, b, sizeof(a))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define M 1000005
int h[M]={0},dp[M]={0};
signed main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>h[i];
    for(int i=0;i<n;i++)dp[i]=INT_MAX;
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
        for(int j=1;j<=min(i,k);j++){
            dp[i]=min(dp[i],abs(h[i]-h[i-j])+dp[i-j]);
        }
    cout<<dp[n-1];
    return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

int main() {
  int N;cin>>N;
  vector<ll> as(N);
  REP(i,N) {
    ll a;cin>>a;
    as[i] = a-(i+1);
  }
  sort(ALL(as));
  
  ll median;
  if (N%2==0) {
    median = (as[N/2-1]+as[N/2])/2;
  } else {
    median = as[N/2];
  }
  OUT(accumulate(ALL(as),0LL,[&](ll a,ll b){ return a+abs(b-median); }));

  return 0;
}

Measured memory_bytes: 1792
import sys
import functools
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
a=[1]*(n+1)
for i in range(m):
    a[int(input())]=0
@functools.lru_cache(maxsize=None)
def count(p):
    if p==0 or p==1:
        return a[p]
    if a[p]==1:
        x=count(p-1)+count(p-2)
        return x
    else:
        return 0
print(count(n)%1000000007)


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

int main() {
  int N;
  cin >> N;
  int x = N % 2;
  
  if (x == 0) {
    cout << N / 2 << endl;
  }
  
  else {
    cout << N / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    int result = numeric_limits<int>::max();
    rep(i, 2)
    {
        int a = 0;
        rep(j, s.size())
        {
            if ((s[j] - '0') != (j + i) % 2) {
                a++;
            }
        }
        result = min(result, a);
    }
    cout << result << endl;

    return 0;
}

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

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  
  int kazu = g * 10 + b;
  
  if(kazu % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "YES"
#define NO  "NO"

using namespace std;

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

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  // flag = true;

  int seven = 0;
  int five = 0;
  for (int i = 0; i < 3; ++i) {
    int m; cin >> m;
    if (m == 7) ++seven;
    if (m == 5) ++five;
  }

  if (seven == 1 && five == 2) flag = true;
  
  // cout << num << endl;
  cout << (flag ? YES : NO) << endl;
  
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& e : a) cin >> e;
    auto minitr = min_element(begin(a), end(a)), maxitr = max_element(begin(a), end(a));
    int imin = *minitr, imax = *maxitr;
    vector<pair<int, int>> ans;

    if (imin < 0 && imax > 0) {
        if (imin + imax > 0) {
            for (int i = 1; i <= n; i++) ans.emplace_back(maxitr - begin(a) + 1, i);
        } else {
            for (int i = 1; i <= n; i++) ans.emplace_back(minitr - begin(a) + 1, i);
        }
    }

    if (imin + imax > 0) {
        for (int i = 1; i + 1 <= n; i++) ans.emplace_back(i, i + 1);
    } else {
        for (int i = n; i - 1 >= 1; i--) ans.emplace_back(i, i - 1);
    }

    cout << ans.size() << endl;
    for (auto& e : ans) cout << e.first << " " << e.second << endl;
}


Measured memory_bytes: 256
import sys
import copy
import math
import fractions

import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
import numpy as np
from decimal import *


if __name__ == '__main__':
    s = input()
    s1 = int(s[0:2])
    s2 = int(s[2:4])
    f1 = 0
    f2 = 0

    if s1 == 0:
        f1 = 0
    elif s1 >0 and 13 > s1:
        f1 = 1
    else:
        f1 =2

    if s2 == 0:
        f2 = 0
    elif s2 >0 and 13 > s2:
        f2 = 1
    else:
        f2 =2

    if f1 == 0 and f2 ==0:
        print("NA")
    elif (f1 ==0 and f2 == 2) or (f1 == 2 and f2 ==2) or (f1 == 2 and f2 ==0) :
        print("NA")
    elif (f1 ==0 and f2 == 1) or (f1 == 2 and f2 ==1) :
        print("YYMM")
    elif (f1 ==1 and f2 == 0) or (f1 == 1 and f2 ==2) :
        print("MMYY")
    else:
        print("AMBIGUOUS")









Measured memory_bytes: 13608
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
								
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//abc065_b
int main(){
  ll N,tmp;
  cin >> N;
  ll res = -1;

  ll a[N+1] = {};

  REP(i,N)
  {
    cin >> a[i];
    --a[i];
  }

  //ボタン0が光っている ボタン1を光らせることは可能か
  ll cnt = 0;
  ll i = 0;
  while(i != 1)
  {
    //どこで不可能と判断するか
    //N-1回の移動?
    if(cnt > N-1)
    {
      cout << res << endl;
      return 0;
    }

    i = a[i];
    ++cnt;
  }

  res = cnt;

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 1152
#include <stdio.h>

typedef long long ll;

/////////////         modの計算
const ll mod = 1000000007LL;

class modlong {
public:
	modlong() { x = 0; }
	modlong(ll num) { x = num; }
	inline operator ll() const { return x; }
	inline void operator = (ll num) { x = num; }
	inline void operator += (ll num) { x = adjust(x + num); }
	inline void operator *= (ll num) { x = adjust(x * num); }
	inline modlong operator * (ll num) { modlong m(adjust(this->x * num)); return m; }
private:
	inline ll adjust(ll a) {
		if (a >= mod) { return a % mod; }
		return a;
	}
	ll x;
};

constexpr int K = 16;

constexpr ll v_e[] = { 0, 765144583, 346175634, 347662323, 5655049, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };
constexpr ll v_o[] = { 539588932, 729548371, 700407153, 404391958, 962779130, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };

int main() {
	int T; scanf("%d", &T);
	for (int _t = 0; _t < T; _t++) {
		ll N; scanf("%ld", &N);
		modlong ans = 0;
		modlong x = 1;

		if (N & 1) {// odd
			for (int i = 0; i < K; i++) {
				ans += x * v_o[i];
				x *= N;
			}
		}
		else {// even
			for (int i = 0; i < K; i++) {
				ans += x * v_e[i];
				x *= N;
			}
		}
		printf("%ld\n", ans);
	}

	return 0;
}


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

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

    vector<int> ans(n);
    int cum = 0;
    for (int i = 0; i < n-1; i++) {
        if (s[i] == '<') cum++; else cum = 0;
        ans[i+1] = max(ans[i+1], cum);
    }
    cum = 0;
    for (int i= n-1; i >= 0; i--) {
        if (s[i] == '>') cum++; else cum = 0;
        ans[i] = max(ans[i], cum);
    }
    long long res = 0;
    for (auto x : ans) res += x;
    cout << res << endl;
}


Measured memory_bytes: 2820
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

typedef pair<int, int> pii;
int main(){
    int n;
    while(cin >> n && n){
        vector<pii> v(n);
        rep(i,n) v[i].second = i;
        int game = n * (n-1) / 2;

        rep(i,game){
            int a,b,c,d;
            cin >> a >> b >> c >> d;
            if(c>d) v[a-1].first += 3;
            else if(c < d) v[b-1].first += 3;
            else v[a-1].first++, v[b-1].first++;
        }

        sort(v.rbegin(), v.rend());
        int score = -1;
        int rank = 1;
        rep(i,n){
            if (v[i].first == score) v[i].first = rank;
            else {
                score=v[i].first;
                v[i].first=i+1;
                rank=i+1;
            }
        }
        sort(v.begin(), v.end(), [](pii l,pii r){
                return l.second < r.second;
            });
        rep(i,n)cout<<v[i].first<<endl;
    }
}

Measured memory_bytes: 1200
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<limits>
#include<stdio.h>
using namespace std;
typedef long long ll;

int N;

void warshall_floyd(double **d) {
	for (int k = 0; k < N; k++) {       // 経由する頂点
		for (int i = 0; i < N; i++) {    // 始点
			for (int j = 0; j < N; j++) {  // 終点
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

void solve(){
	
	int M, L,Q;
	int A,B,s,t;
	double C;
	double INF = 1e100;
	double **d, **d2;
	cin >> N >> M >> L;
	
	d = new double*[N];
	d2 = new double*[N];
	for (int i = 0;i < N;i++) {
		d[i] = new double[N];
		d2[i] = new double[N];
	}
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < N;j++) {
			if (i == j) {
				d[i][j] = 0;
				d2[i][j] = 0;
			}
			else {
				d[i][j] = INF;
				d2[i][j] = INF;
			}
			
		}
	}
	for (int i = 0;i < M;i++) {
		cin >> A>> B>>C;
		A--;
		B--;
		d[A][B] = C;
		d[B][A] = C;
	}
	warshall_floyd(d);
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < N;j++) {
			if (i != j && d[i][j] <= L)d2[i][j] = 1;
		}
	}
	warshall_floyd(d2);
	cin >> Q;
	
	for (int i = 0;i < Q;i++) {
		cin >> s >> t;
		double ans = d2[s - 1][t - 1] - 1;
		if (ans < INF) {
			cout << ans << endl;
		}
		else {
			cout << -1 << endl;
		}

	}

}


int main() {
	solve();

}

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

typedef long long ll;
const int MAXN=2005;
const ll INF=1e18;

ll n,m;
ll a[MAXN];
ll d[MAXN][MAXN];

int main(){

    scanf("%lld%lld",&n,&m);
    for(ll i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(ll i=1;i<=n;i++)
        for(ll j=0;j<n;j++)
            d[i][j]=INF;
    d[1][0]=a[1];
    for(ll i=2;i<=n;i++){
        d[i][0]=a[i];
        for(ll j=1;j<n;j++)
            d[i][j]=min(d[i][j],min(d[i-1][j-1],d[i][j-1]));
    }
    for(ll j=1;j<n;j++)
        d[1][j]=min(d[1][j],min(d[n][j-1],d[1][j-1]));
    for(ll i=2;i<=n;i++){
        d[i][0]=a[i];
        for(ll j=1;j<n;j++)
            d[i][j]=min(d[i][j],min(d[i-1][j-1],d[i][j-1]));
    }
    ll ans=INF;
    for(ll j=0;j<n;j++){
        ll res=m*j;
        for(ll i=1;i<=n;i++)
            res+=d[i][j];
        ans=min(res,ans);
    }
    printf("%lld",ans);

    fclose(stdin);
    fclose(stdout);
}


Measured memory_bytes: 31488
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String ns = sc.next();
    String[] s = ns.split("");
    int sum = 700;
    for (int i = 0; i < s.length; i++) {
      if (s[i].equals("o")) {
        sum += 100;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 35544
#define _USE_MATH_DEFINES 
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <math.h>
#include <unordered_set>
#include <iomanip>
#include <cmath>
#include <set>
#include <locale>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;
//cout << fixed << setprecision(6);
//cout << setfill('0') << right << setw(2);

int main() {
  int n, a, ans;
  cin >> n;
  rep(i, n){
    cin >> a;
    if(!i) ans = a;
    ans = gcd(ans, a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			int N = Integer.parseInt(str);
			str = br.readLine();
			int A = Integer.parseInt(str);

			System.out.println(N*N-A);
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}

}


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

using namespace std;

#define ZERO_IQ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

string lcs(string x, string y) {
    int m = x.length();
    int n = y.length();
    vector<vector<long long >> v(m + 1, vector<long long>(n + 1));
    for (int i = 0; i <= x.length(); i++) {
        for (int j = 0; j <= y.length(); j++) {
            if (i == 0 || j == 0)
                v[i][j] = 0;
            else if (x[i - 1] == y[j - 1])
                v[i][j] = v[i - 1][j - 1] + 1;
            else
                v[i][j] = max(v[i - 1][j], v[i][j - 1]);
        }
    }
    int index = v[m][n];
    string ans;
    int i = m, j = n;
    while (i > 0 && j > 0) {
        if (x[i - 1] == y[j - 1]) {
            ans.push_back(x[i - 1]);
            i--;
            j--;
            index--;
        } else if (v[i - 1][j] > v[i][j - 1])
            i--;
        else
            j--;
    }
    return ans;
}

int main() {
    ZERO_IQ
    string s,ss;
    cin>>s>>ss;
    string ans=lcs(s,ss);
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

Measured memory_bytes: 70784
use itertools::Itertools as _;
use proconio::{input, marker::Usize1};

fn main() {
    input! {
        n: usize,
        m: usize,
        abcds: [(Usize1, Usize1, usize, u64)],
    }

    let ans = (0..m)
        .combinations_with_replacement(n)
        .map(|array| {
            abcds
                .iter()
                .filter(|&&(a, b, c, _)| array[b] - array[a] == c)
                .map(|(_, _, _, d)| d)
                .sum::<u64>()
        })
        .max()
        .unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 2196
// 25/05/2020  @ 10:47:49
// *****************************************************************
// *****************************************************************
#include <bits/stdc++.h>
// *****************************************************************
// *****************************************************************
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fr(i,n) for(llu i=0;i<n;i++)
#define fl(j,a,b) for(llu j=a;j<=b;j++)
#define pi 3.14159265
#define mod 1e9+7
#define MID(a,b) ((a + b) >> 1)
#define MAX(a,b) ((a) > (b) ? (a): (b))
#define MIN(a,b) ((a) < (b) ? (a) :(b))
// *****************************************************************
// *****************************************************************
typedef long long unsigned int llu;
typedef long long int ll;
// *****************************************************************
// *****************************************************************
using namespace std;
// *****************************************************************
// *****************************************************************

                   // Dream it. Wish it. Do it.

                         // tannatsri //

              // Without tact you can learn nothing.

// *****************************************************************
// *****************************************************************
template< class Iterator,  class T>
// template<typename TT>
// *****************************************************************
// *****************************************************************
Iterator search(Iterator start, Iterator end, T key) {
    while(start != end) {
        if(*start == key){
            return start;
        }
        ++start;
    }
    return end;
}
bool rev(int a, int b) {
    return a > b;
}






// *****************************************************************
// *****************************************************************
int main() {
    IOS;
    int n, k;
    cin >> n >> k;
    ll a[n + 1];
    fl(i,1,  n) cin >> a[i];
    ll dp[100005] = {0};
    dp[1] = 0;
    dp[2] = abs(a[1] - a[2]);
    fl(i, 3, k) {
        int mm = INT_MAX;
        fl(j, 1, i - 1) {
            int c = dp[j] + abs(a[j] - a[i]);
            mm = MIN(mm, c);
        }
        dp[i] = mm;

    }
    fl(i, k+ 1, n) {
        int mm = INT_MAX;
        fl(j, i - k, i - 1) {
            int c = dp[j] + abs(a[j] - a[i]);
            mm = MIN(mm, c);
        }
        dp[i] = mm;
    }
    cout << dp[n] << "\n";
    
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<climits>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<sstream>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define inf 0x3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0)
#define F(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define CLR(a) memset((a),0,sizeof(a))
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define sz(a) int((a).size())
#define pb push_back
#define fr first
#define sc second
#define M 200010
#define mod 1000000007
ll fact[M];
ll n,m,k,l,r,ans,c,a,b;
ll mpow(ll a, ll b){
    ll res=1;
    while(b!=0){
        if(b%2==1) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}

ll C(ll n,ll r){
    if(n<r) return 0;
    if(n==r) return 1;
    if(r==0) return 1;
    ll x,y,ans=fact[n];
    x=mpow(fact[n-r],mod-2);
    y=mpow(fact[r],mod-2);
    ans=(ans*x)%mod;
    ans=(ans*y)%mod;
    return ans;
}

ll ways(ll n, ll r){
    return C(n+r-2,n-1);
}

int main(){
    fast;
    cin>>n>>m>>a>>b;
    fact[0]=fact[1]=1;
    for(int i=2;i<M;i++){
        fact[i]=(i*fact[i-1])%mod;
    }
    ans=0;
    for(ll i=0;i<n-a;i++){
        ans+=(ways(i+1,b)*ways(n-i,m-b))%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
import qualified Data.ByteString.Char8     as C8
import           Data.Maybe

main :: IO ()
main = do
  [n] <- readInts
  putStrLn $ solve n

solve :: Int -> String
solve = pretty . cmp . show

cmp :: String -> Bool
cmp cs = (cs !! 0) == cs !! 2

pretty :: Bool -> String
pretty b = if b then "Yes" else "No"

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

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

int main(){
  ll D,T,S;cin>>D>>T>>S;
  if(S*T<D) cout<<"No"<<endl;
  else cout<<"Yes"<<endl; 
}

Measured memory_bytes: 3672
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int debt=100000;
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			debt=(int)Math.ceil((debt*1.05)/1000)*1000;
		}
		System.out.println(debt);
		sc.close();
	}
}

Measured memory_bytes: 17164
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

int X, A, res;
int main(int argc, char **argv) {
    cin >> X >> A;
    res = X < A ? 0 : 10;
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    long long n ,m;
    cin >> n>>m;
    int s = 0;
    while(m--)
    {
        int a;
        cin >> a;
        s += a;

    }
    if(n-s<0)
        cout << "-1";
    else
    cout << n - s;
}

Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>

using namespace std;

int n;
int t[3];
int inf = 5000;

int re(int cnt, int a, int b, int c, vector<int> l){
    if(cnt == n){
        if(a != 0 && b != 0 && c != 0){
            return abs(t[0] - a) + abs(t[1] - b) + abs(t[2] - c) - 30;
        }else{
            return inf;
        }
    }
    int A = re(cnt + 1, a, b, c, l);
    int B = re(cnt + 1, a + l[cnt] , b, c, l) + 10;
    int C = re(cnt + 1, a, b + l[cnt], c, l) + 10;
    int D = re(cnt + 1, a, b, c + l[cnt], l) + 10;
    return min({A, B, C, D});
}

int main(){
    cin >> n >> t[0] >> t[1] >> t[2];
    vector<int> lm;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        lm.push_back(x);
    }
    cout << re(0, 0, 0, 0, lm);
}


Measured memory_bytes: 256
use std::io;
use std::io::{Read, BufReader};
use std::cmp;

fn next_token<R: Read>(reader: &mut R) -> Vec<u8> {
    let mut buf: [u8; 1] = [0];
    let mut read_chars = false;
    let mut ret: Vec<u8> = vec![];

    loop {
        if reader.read(&mut buf).unwrap() == 0 {
            break;
        } else {
            if buf[0] == '\r' as u8 || buf[0] == '\n' as u8 || buf[0] == ' ' as u8 {
                if read_chars {
                    break;
                }
            } else {
                read_chars = true;
                ret.push(buf[0]);
            }
        }
    };
    ret
}
fn next_i64<R: Read>(reader: &mut R) -> i64 {
    let token = next_token(reader);
    let mut ret: i64 = 0;
    let mut sgn = false;

    for c in token {
        if '0' as u8 <= c && c <= '9' as u8 {
            ret = ret * 10 + (c - ('0' as u8)) as i64;
        } else if '-' as u8 == c {
            sgn = true;
        }
    };
    ret * if sgn { -1 } else { 1 }
}
fn next_i32<R: Read>(reader: &mut R) -> i32 {
    next_i64(reader) as i32
}

fn main() {
    let buf = &mut BufReader::new(io::stdin());

    let x = next_i32(buf);
    let mut i = 1;
    let mut s = 0;
    loop {
        s += i;
        if s >= x {
            println!("{}", i);
            break;
        }
        i += 1;
    }
}


Measured memory_bytes: 4352
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 100000000)

func readLine() string {
	buf := make([]byte, 0, 100000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	s := readLine()
	t := readLine()

	ss := []byte(s)
	tt := []byte(t)

	c := 0
	for idx, b := range ss {
		if b != tt[idx] {
			c++
		}
	}
	fmt.Printf("%d", c)
}


Measured memory_bytes: 12996
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
int a[105],b[105];
LL f[105][305];
int main(void)
{
	int i,j,k,n,m,a1;LL ans=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)scanf("%d%d",&a[i],&b[i]);
	a1=a[1];
	for(i=1;i<=n;++i)a[i]-=a1;
	for(i=0;i<=n;++i)
	{
		for(j=0;j<=300;++j)f[i][j]=-0x3F3F3F3F3F3F3F3F;
	}
	f[0][0]=0;
	for(i=1;i<=n;++i)
	{
		for(j=i;j>=1;--j)
		{
			for(k=300;k>=a[i];--k)f[j][k]=max(f[j][k],f[j-1][k-a[i]]+b[i]);
		}
	}
	for(i=1;i<=n;++i)
	{
		if(m-1LL*i*a1<0)break;
		for(j=0;j<=min(300,m-i*a1);++j)ans=max(ans,f[i][j]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	static class BreadthFirstSearch {
		public void BFS (InputReader ir) {
			
			//
			int n = ir.nextInt();
			Graph[] graph = new Graph[n + 1];
			
			for (int i = 1; i <= n; i++) {
				int k = ir.nextInt();
				graph[k] = new Graph ();
				int m = ir.nextInt();
				for (int j = 0; j < m; j++) {
					graph[k].u.add(ir.nextInt());
				}
			}
				
			bfs (graph, 1, 0);
			
			StringBuilder sb = new StringBuilder ();
			for (int i = 1; i <= n; i++) {
				if (graph[i].d == null) graph[i].d = -1;
				sb.append(i).append(" ")
				.append(graph[i].d).append("\n");
			}
			
			System.out.print(sb);
			
		}
		
		static void bfs (Graph[] graph, Integer i, Integer count ) {
			
			if (graph[i].d == null || graph[i].d > count) {
				graph[i].d = count++;
				if (!graph[i].u.isEmpty()) {
					for (int j = 0; j < graph[i].u.size(); j++) {
						bfs (graph, graph[i].u.get(j), count);
					}
				}
			}
			
		}
		
	}
	static class Graph {
		List<Integer> u = new ArrayList<> ();
		Integer d;
		Graph () {
			d = null;
		}
	}
	
	static class InputReader {
		BufferedReader br;
		StringTokenizer st;
		
		public String nextString() {
			
			 while (!st.hasMoreTokens()) {
	                try {
	                    st = new StringTokenizer(br.readLine(), " ");
	                } catch (IOException e) {
	                    throw new InputMismatchException();
	                }
	            }
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(nextString());
		}
					
		public InputReader (InputStream inputStream) {
			br = new BufferedReader (new InputStreamReader (inputStream));
			st = new StringTokenizer ("");
		}
		
	}
	
	public static void main (String[] args) {
		InputStream inputStream = System.in;
		InputReader in = new InputReader (inputStream);
		BreadthFirstSearch obj = new BreadthFirstSearch ();
		obj.BFS (in);
	}
	
}



Measured memory_bytes: 24984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
const int MOD = 1e9 + 7;

#ifdef LOCAL
clock_t timer = clock();
#endif

int dp[1005][1005];
char g[1005][1005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int h, w;
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> g[i][j];
		}
	}
	dp[0][0] = 1;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(i > 0 && g[i - 1][j] == '.') dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD; 
			if(j > 0 && g[i][j - 1] == '.') dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
			if(g[i][j] == '#') dp[i][j] = 0;
		}
	}	
	cout << dp[h - 1][w - 1] << endl;
#ifdef LOCAL
        cout << "Total Time: " << (double)(clock() - timer) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 5120
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int popcount(T n) { return n ? 1 + popcount(n & (n - 1)) : 0; }
#endif
#ifdef __GNUC__
template <class T> int popcount(T n);
template <> int popcount(unsigned int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(unsigned long long n) { return n ? __builtin_popcountll(n) : 0; }
template <> int popcount(long long n) { return n ? __builtin_popcountll(n) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

template <class T> void print(T a, int n, int br = 1, const string& deli = ", ") { cout << "{ "; for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } cout << " }"; while (br--) cout << endl; }
template <class T> void print(const vector<T>& v, int br = 1, const string& deli = ", ") { print(v, v.size(), br, deli); }



int main()
{
	int n;
	static ll a[114514];
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%lld", a + i);
	sort(a, a + n);


	ll res = 0;
	int tri = 0;
	for (int i = n - 1; i >= 2 && tri < 2; )
	{
		if (a[i - 1] + a[i - 2] > a[i])
		{
			res += a[i - 1] + a[i - 2] + a[i];
			++tri;
			i -= 3;
		}
		else
			--i;
	}
	if (tri < 2)
		res = 0;

	for (int i = n - 1; i >= 5; --i)
	{
		bool t[6];
		CL(t, 0);
		fill_n(t + 3, 3, true);
		do
		{
			ll x[3], y[3];
			int p = 0, q = 0;
			for (int j = 0; j < 6; ++j)
			{
				if (t[j])
					x[p++] = a[i - j];
				else
					y[q++] = a[i - j];
			}

			if (x[1] + x[2] > x[0] && y[1] + y[2] > y[0])
			{
				max_swap(res, accumulate(a + (i - 5), a + (i + 1), 0LL));
				//goto End;
			}
		} while (next_permutation(t, t + 6));
	}
End:
	printf("%lld\n", res);
}

Measured memory_bytes: 1624
import java.util.Scanner;

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

        int[] n = new int[26];
        while(scan.hasNext()) {
            String S = scan.nextLine();
            String s = S.toUpperCase();
            for(int i = 0; i < s.length(); i++) {
                int k = (int)s.charAt(i) - 65;
                if(k >= 0 && k <= 25) {
                    n[k]++;
                }
            }
        }

        for(int i = 0; i < 26; i++) {
            int ch = i + 97;
            char c = (char)ch;
            System.out.println(c + " : " + n[i]);
        }
    }
}




Measured memory_bytes: 26104
#include <stdio.h>

int main(void)
{
    int h, m, s;
    scanf("%d", &s);
    
    h = s / 3600;
    m = (s % 3600) / 60;
    s = s % 3600 % 60;
    printf("%d:%d:%d\n", h, m, s);


    return 0;
}

Measured memory_bytes: 592
input_str = input()

input_list = input_str.split(' ')
N = int(input_list[0])
D = int(input_list[1])

count = 0
for i in range(N):
    input_str = input()
    input_list = input_str.split(' ')
    X = int(input_list[0])
    Y = int(input_list[1])
    
    dist = (X ** 2 + Y ** 2) ** (1/2)
    
    if dist <= D:
        count += 1

print(count)


Measured memory_bytes: 9524