akhauriyash/Code-Regression huggingface dataset:
const MOD: i64 = 1_000_000_007;

fn pow(a: i64, b: i64) -> i64 {
    if b == 0 {
        1
    } else {
        let t = pow(a, b/2);
        let t = t * t % MOD;
        if b % 2 == 0 {
            t
        } else {
            t * a % MOD
        }
    }
}

fn solve(h: Vec<i64>) -> (i64, i64) {
    //println!("{:?}", h);
    let hmin = *h.iter().min().unwrap();
    let mut dp0 = 1;
    let mut dp1 = 1;
    let mut k = Vec::new();
    let mut cnt = 0;
    for i in 0..(h.len()) {
        let hi = h[i];
        if i + 1 < h.len() && (hi == hmin || h[i+1] == hmin) {
            cnt += 1;
        }
        if hi == hmin {
            if k.len() >= 1 {
                let (mut tmp0, mut tmp1) = solve(k.clone());
                tmp0 += tmp1;
                tmp1 *= 2;
                dp0 *= tmp0;
                dp0 %= MOD;
                dp1 *= tmp1;
                dp1 %= MOD;
                k.clear();
            }
        } else {
            k.push(hi - hmin);
        }
    }
            if k.len() >= 1 {
                let (mut tmp0, mut tmp1) = solve(k.clone());
                tmp0 += tmp1;
                tmp1 *= 2;
                dp0 *= tmp0;
                dp0 %= MOD;
                dp1 *= tmp1;
                dp1 %= MOD;
                k.clear();
            }

    //println!("{:?} {:?}", dp0, dp1);
    let ans1 = dp1 * pow(2, hmin - 1) % MOD;
    let ans0 = dp0 * pow(2, cnt) - dp1 + ans1;
    let ans0 = (ans0 % MOD + MOD) % MOD;
    //println!("{:?} {:?}", ans0, ans1);
    return (ans0, ans1);
}

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());
    let n = sc.read();
    let h = (0..n).map(|_| sc.read()).collect();
    println!("{}", solve(h).0 * 2 % MOD);
}


// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 4352
using System;
class Program
{
    static void Main(string[] args)
    {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
        int counter = 0;
        while (true)
        {
            if(c%a==0) counter++;
            if (a == b) break;
         	a++;
        }
        Console.WriteLine(counter);

    }
}


Measured memory_bytes: 17892
import sys

N = int(input())
line = list(map(int,input().split()))

ans = 1
mx = line[0]


for i in range(1,line.index(max(line))):
	if line[i] >= mx:
		ans += 1
		mx = line[i]

for i in range(line.index(max(line)),len(line)):
	if i != 0 and line[i] == max(line):
		ans += 1

print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int s = in.nextInt() + in.nextInt() + in.nextInt() + in.nextInt();
		int t = in.nextInt() + in.nextInt() + in.nextInt() + in.nextInt();
		System.out.println(Math.max(s, t));
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define clear(x) memset(x, 0, sizeof(x))
using namespace std;

const int maxn = 50;
int T, n, a[maxn + 3][maxn + 3], b[maxn + 3][maxn + 3], c[maxn + 3], d[maxn + 3], deg[maxn + 3];
bool vis[maxn + 3];
vector<int> G[maxn + 3];

void add(int u, int v) {
	G[u].push_back(v), deg[v]++;
}

void dfs(int u) {
	vis[u] = true;
	for (int v = 1; v <= n; v++) {
		if (a[u][v] && b[u][v] && !vis[v]) {
			dfs(v);
		}
	}
}

void dfs_1(int u, int pa = 0) {
	for (int v = 1; v <= n; v++) {
		if (a[u][v] && v != pa) {
			if (!vis[u]) {
				add(v, u);
			}
			dfs_1(v, u);
		}
	}
}

void dfs_2(int u, int pa = 0) {
	for (int v = 1; v <= n; v++) {
		if (b[u][v] && v != pa) {
			if (!vis[u]) {
				add(u, v);
			}
			dfs_2(v, u);
		}
	}
}

bool check() {
	queue<int> Q;
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (!deg[i]) {
			Q.push(i);
		}
	}
	while (!Q.empty()) {
		int u = Q.front();
		Q.pop(), cnt++;
		for (int i = 0, v; i < G[u].size(); i++) {
			v = G[u][i];
			if (!--deg[v]) {
				Q.push(v);
			}
		}
	}
	return cnt == n;
}

int solve(int u) {
	clear(vis);
	dfs(u);
	for (int i = 1; i <= n; i++) {
		vector<int>().swap(G[i]);
	}
	clear(deg);
	dfs_1(u);
	dfs_2(u);
	if (!check()) {
		return -1;
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		cnt += vis[i];
	}
	return cnt;
}

int main() {
	scanf("%d", &T);
	while (T --> 0) {
		scanf("%d", &n);
		clear(a), clear(b), clear(c), clear(d);
		for (int i = 1, u, v; i < n; i++) {
			scanf("%d %d", &u, &v);
			a[u][v] = a[v][u] = 1;
			c[u]++, c[v]++;
		}
		for (int i = 1, u, v; i < n; i++) {
			scanf("%d %d", &u, &v);
			b[u][v] = b[v][u] = 1;
			d[u]++, d[v]++;
		}
		int ans = -1;
		for (int i = 1; i <= n; i++) {
			ans = max(ans, solve(i));
		}
		for (int i = 1; i <= n; i++) if (c[i] == 1) {
			for (int j = 1; j <= n; j++) if (a[i][j]) {
				a[i][j] = a[j][i] = 0;
				for (int k = 1; k <= n; k++) if (k != i && k != j) {
					a[i][k] = a[k][i] = 1;
					ans = max(ans, solve(i) - 1);
					a[i][k] = a[k][i] = 0;
				}
				a[i][j] = a[j][i] = 1;
			}
		}
		printf("%d\n", ans == -1 ? -1 : n - ans);
	}
	return 0;
}

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

int count;

void swap(int *a, int *b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;

    count += 1;
}

void bubbleSort(int A[], int N)
{
    int flag;
    int j;

    flag = 1;
    while(flag) {
        flag = 0;
        for(j = N-1; j >= 1; j--) {
            if(A[j] < A[j-1]) {
                swap(&A[j], &A[j-1]);
                flag = 1;
            }
        }
    }
}

int main()
{
    int N;
    int *A;
    int i;

    scanf("%d", &N);
    A = (int *)malloc(sizeof(int) * N);
    for(i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    count = 0;
    bubbleSort(A, N);

    for(i = 0; i < N-1; i++) {
        printf("%d ", A[i]);
    }
    printf("%d\n", A[N-1]);
    printf("%d\n", count);


    return 0;
}


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

int a[10];
unsigned long long dp[10000][10];

int main()
{
	int n;
	scanf("%d", &n);
	
	int ast = 0;
	int f = 0;
	char id[500000];
	for (int i = 0; i < n; i++){
		scanf(" %c", &id[i]);
		
		if (id[i] == '*'){
			ast++;
		}
		else {
			int tw = ((id[i] - '0') * (1 + ((n - i) % 2 == 0))) / 10 + 
			         ((id[i] - '0') * (1 + ((n - i) % 2 == 0))) % 10;
			f = (f + tw) % 10;
		}
	}
	
	int m;
	scanf("%d", &m);
	for (int i = 0; i < m; i++){
		scanf("%d", &a[i]);
	}
	
	dp[0][f] = 1;
	int i = 0;
	for (int p = 0; p < n; p++){
		if (id[p] == '*'){
			for (int j = 0; j <= 9; j++){
				for (int k = 0; k < m; k++){
					int tw = (a[k] * (1 + ((n - p) % 2 == 0))) / 10 +
					         (a[k] * (1 + ((n - p) % 2 == 0))) % 10;
					int t = (j + tw) % 10;
					dp[i + 1][t] += dp[i][j];
				}
			}
			i++;
		}
	}
	
	printf("%llu\n", dp[ast][0]);
	
	return 0;
}

Measured memory_bytes: 1300
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  string s;
  cin >> s;
  ll n = s.length(); 
  ll ans = 0;
  for(ll i = 0; i < n/2; i++) {
    if(s[i] != s[n-1-i]) ans++;
  }
  cout << ans << endl;
  return 0;
} //good night.

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int min(int a,int b,int c) {
  int x;
  x = min(a, b);
  x = min(x, c);
  return x;
}

int main() {
  int k;
  cin >> k;
  int gcd = 1, sum = 0;
  for(int a = 1; a <= k; a++) {
    for(int b = 1; b <= k; b++) {
      for(int c = 1; c <= k; c++) {
        for(int i = 2; i <= min(a, b, c); i++) {
          if(a % i == 0 && b % i == 0 && c % i == 0) gcd = i;
        }
        sum += gcd;
        gcd = 1;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3628
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int k = scan.nextInt();
		String s = scan.next();
		String ans = "";
		
		if(s.length() <= k) {
			System.out.println(s);
		}else {
			for(int i=0;i<k;i++) {
				ans += s.charAt(i);
			}
			ans += "...";
			System.out.println(ans);
		}
		
	}	
	
	
	//�ŏ�����
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
	//����ւ�
	/*
	static int swap (int a, int b) {
		int swap_arr[] = new int[2];
		
		swap[0] = b;
		swap[1] = a;
		
		return swap_arr;
	}
	*/
	
}



Measured memory_bytes: 39716
def main():
    sx, sy, tx, ty = map(int, input().split())
    ans = solve(sx, sy, tx, ty)
    print(ans)


def solve(sx, sy, tx, ty):
    dx = tx - sx
    dy = ty - sy
    st = 'U' * dy + 'R' * dx
    ts = 'D' * dy + 'L' * dx
    rt1 = st + ts
    rt2 = 'L' + 'U' + st + 'R' + 'D' + 'R' + 'D' + ts + 'L' + 'U'
    ans = rt1 + rt2
    return ans


if __name__ == '__main__':
    main()

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

int main(){
  int n;
  cin >> n;
  vector<int> mnst(n+1);
  vector<int> hero(n);
  for(int i=0; i<n+1; i++){
    cin >> mnst.at(i);
  }
  for(int i=0; i<n; i++){
    cin >> hero.at(i);
  }
  int64_t ans =0;
  for(int i=0; i<n; i++){
    if(mnst.at(i)>=hero.at(i)){ans += hero.at(i);}
    else{ans += mnst.at(i);
         int amari;
         amari = hero.at(i) - mnst.at(i);
         if(mnst.at(i+1)<=amari){ans += mnst.at(i+1);mnst.at(i+1) = 0;}
         else{ans += amari;mnst.at(i+1) = mnst.at(i+1) - amari;}
        }
    //cout << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
/*
  ->->->->->-> Vora Mahammadasim <-<-<-<-<-<-
*/
#include<bits/stdc++.h>
#include<stdio.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k == 0){
            cout<<"OK"<<"\n";
            return 0;
        }
    }
    cout<<"NG\n";
}


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

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U> void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1LL<<30;
const LL MOD = 1e9+7;

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

   map<int,int> cnt;
   for (auto d : D) {
      ++cnt[d];
   }

   if (cnt[0] >= 1) {
      cout << 0 << endl;
      return 0;
   }

   for (int i = 1; i <= 11; ++i) {
      if (cnt[i] >= 3) {
         cout << 0 << endl;
         return 0;
      }
   }

   if (cnt[12] >= 2) {
      cout << 0 << endl;
      return 0;
   }

   char prev = '$';
   vector<bool> used(25, false);
   used[0] = used[24] = true;
   for (int i = 1; i <= 11; ++i) {
      if (cnt[i] == 2) {
         used[i] = true;
         used[24-i] = true;
         prev = '$';
      } else if (cnt[i] == 1) {
         if (prev == 'l') {
            prev = 'r';
            used[i] = true;
         } else {
            prev = 'l';
            used[24-i] = true;
         }
      }
      if (cnt[12] == 1) {
         used[12] = true;
      }
   }

   int count = 0, ans = 24;
   for (int i = 1; i <= 24; ++i) {
      if (used[i]) {
         chmin(ans, count+1);
         count = 0;
      } else {
         ++count;
      }
   }
   cout << ans << endl;

   return 0;
}


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

int main() {
	string S;
	cin >> S;
	int dmin = 999;
	for (int i=0; i<S.size()-2; i++) {
		int n = stoi(S.substr(i,3));
		if (dmin>abs(753-n)) {
			dmin = abs(753-n);
		}
	}
	cout << dmin << endl;

	return 0;
}

Measured memory_bytes: 256
from sys import stdin
input = stdin.readline

n, m, k = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
cnt = 0
idx = 0
res = [0]

na, nb = [0, a[0]], [0, b[0]]

for x in range(1, n):
    na.append(na[-1] + a[x])

for x in range(1, m):
    nb.append(nb[-1] + b[x])

a.insert(0, 0)
b.insert(0, 0)

for x in range(n, -1, -1):
    if na[x] > k:
        continue

    while True:
        if idx + 1 <= m and na[x] + nb[idx + 1] <= k:
            idx += 1
        else:
            break

    res.append(x + idx)

print(max(res))

Measured memory_bytes: 50748
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<string, int> mp;
#define ll long long

int main() {
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    cout << n - (a + b - c) << endl;
    return 0;
}


Measured memory_bytes: 3088
n, m = map(int, input().split())
text = ""

if (n > m):
    for i in range(n):
        text += str(m)
elif (m > n):
    for i in range(m):
        text += str(n)
elif (n == m):
    for i in range(n):
        text += str(m)

print(text)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
	int main(){
		int x,y;
		while ( 1 ){
			cin >> x >> y;
		if ( x == 0 && y == 0 ) break;
			if ( x > y )
				swap ( x , y );
			cout << x <<" " << y << endl;
		}
	}

Measured memory_bytes: 1160
a = int(input())
b = list(map(int, input().split()))
c = [0] * a
e = 0
f = []
for i in range(a - 1, -1, -1):
    d = 0
    for j in range(i, a, i + 1):
        d += c[j]
    if d % 2 != b[i]:
        c[i] = 1
        e += 1
        f.append(str(i + 1))
print(e)
if e > 0:
    f.sort()
    print(" ".join(f) if e > 1 else f[0])


Measured memory_bytes: 17212
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
##############################

from collections import deque

N, M = map(int, input().split())
cost = [ [] for _ in range(N) ]
visited = [False] * N

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    cost[a].append(b)

#print(cost)

def bfs(node, dist):
    d = deque()
    d.append( (node, dist) )

    while d:
        (node, dist) = d.popleft()
        if visited[node] != False:
            continue

        visited[node] = dist

        for i in cost[node]:
            d.append((i, dist+1))

    return visited[N-1]


if bfs(0, 0) == 2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

int main(){
	int n;
	long long c;

	std::cin>>n;
	std::cin>>c;

	std::vector<long long> xList(n);
	std::vector<long long> vList(n);

	for(int i=0; i<n; i++)
		std::cin>>xList[i]>>vList[i];

	std::vector<long long> cumSumFwClock(n+1, 0);
	std::vector<long long> cumSumBkClock(n+1, 0);

	for(int i=0; i<n; i++){
		cumSumFwClock[i+1]= cumSumFwClock[i] + vList[i];
		cumSumBkClock[i+1]= cumSumBkClock[i] + vList[n-i-1];
	}

	for(int i=0; i<n; i++){
		cumSumFwClock[i+1]= cumSumFwClock[i+1] - xList[i];
		cumSumBkClock[i+1]= cumSumBkClock[i+1] - (c- xList[n-i-1]);
	}

	std::vector<long long> dpFwClock(n+1, 0);
	std::vector<long long> dpBkClock(n+1, 0);		

	for(int i=1; i<n+1; i++){
		if(dpFwClock[i-1]<cumSumFwClock[i])
			dpFwClock[i]= cumSumFwClock[i];
		else
			dpFwClock[i]= dpFwClock[i-1];

		if(dpBkClock[i-1]<cumSumBkClock[i])
			dpBkClock[i]= cumSumBkClock[i];
		else
			dpBkClock[i]= dpBkClock[i-1];
	}

	for(int i=0; i<n; i++){
		cumSumFwClock[i+1]= cumSumFwClock[i+1] - xList[i];
		cumSumBkClock[i+1]= cumSumBkClock[i+1] - (c- xList[n-i-1]);
	}


	long long ans= 0;

	for(int i=0; i<n+1; i++){
		if(ans< dpFwClock[i] + cumSumBkClock[n-i])
			ans= dpFwClock[i] + cumSumBkClock[n-i];

		if(ans< dpBkClock[i] + cumSumFwClock[n-i])
			ans= dpBkClock[i] + cumSumFwClock[n-i];
	}


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

	return 0;
}

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

int main() {
	ll n,ans=0,cnt=0,MIN=1<<30;
	cin>>n;
	for(int i=0;i<n;i++){
		ll m;
		cin>>m;
		if(m<0){
			cnt++;
		}
		m=abs(m);
		ans+=m;
		MIN=min(MIN,m);
	}
	cout << (cnt%2==0 ? ans:ans-2*MIN);
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		long N = I.nextLong();
		long M = I.nextLong();
		long ans = 0;
		if (N==1&&M==1)ans=1;
		else if (N==1||M==1) ans=Math.max(N, M)-2;
		else ans=(N-2)*(M-2);
		ans=Math.max(ans, 0);
		O.pln(ans);
	}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25504
#include <stdio.h>

int main(void){
  unsigned long int a, b, n, r, tmp;
  scanf("%ld", &a);
  scanf("%ld", &b);

  n=a*b;//あとで最大公約数で割ると最小公倍数になる

  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  n /= b;
  printf("%ld\n", n);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x))
#define vec1(a,n) vector<in> a(n);rep(i,n)cin>>a[i]

int main(){
  int n,k;
  cin>>n>>k;
  vec1(p,n);
  
  int sum=0;
  int maxi=0;
  vector<int> dp(n-k+1,0);
  rep(i,k){dp[0]+=p[i];}
  
  for(int i=1;i<n-k+1;i++){
    dp[i]=dp[i-1]-p[i-1]+p[i+k-1];
  }
  
  rep(i,n-k+1) maxi=max(maxi,dp[i]);
  
  double ans =((double)maxi+(double)k)/2.0;
  cout << fixed << setprecision(7);
  cout<<ans<<endl;
  
}

Measured memory_bytes: 2560
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
  ll cum[2000004];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,m;
    cin>>n>>m;
    ll a=2*n-m;
    if(a<0 || a%3!=0)
    {
        cout<<"0"<<'\n';
        return 0;
    }
    a/=3;
    ll b=n-2*a;
    if(b<0)
    {
        cout<<"0"<<'\n';
        return 0;
    }
  
    cum[0]=1;
    for (int i = 1; i <=2000000; ++i)
    {
        cum[i]=(i*cum[i-1])%M;
    }
    ll z=modinver(cum[a+b],cum[a]);
    cout<<modinver(z,cum[b])<<'\n';
}


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

using namespace std;
typedef long long ll;
int main(){

	char   s[101];
	cin >> s;

	for (int i = 0; i < strlen(s); i++){
		if (s[i] == 'R'&&(i+1) % 2 == 0){
			cout << "No" << endl;
			return 0;
		}
		else if (s[i] == 'L' && i % 2 == 0){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


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

int main(){
int N, D, X;
  cin >> N >> D >> X;
int sum = 0;  
  
  for(int i = 0;i < N;i++){
    int a;
    cin >> a;
    sum++;
    sum += (D - 1) / a;
  }

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

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

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;



int main() {
	ll n; cin >> n;
	vector<ll> v(n);
	rep(i, n) cin >> v[i];
	ll pow2[201];
	rep (i, 201) {
		pow2[i] = pow(i, 2);
	}
	ll ans = INF;
	for (ll i = -100; i <= 100; i++) {
		ll k = 0;
		for (auto a : v) {
			k += pow2[abs(a - i)];
		}
		ans = min(ans, k);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._


  val Array(n, m, c) = readLine.trim.split(' ').map(_.toInt)
  val fields = Array.tabulate(n){_ ⇒ new Field }
  var rest = 0L
  for (_ ← 0 until m){
    val Array(a, b, d) = readLine.trim.split(' ').map(_.toInt)
    fields(a - 1).addRoute(b - 1, d)
    fields(b - 1).addRoute(a - 1, d)
    rest += d
  }
  val popped = Array.tabulate(n){_ ⇒ false}
  val distance = minDistance(fields).zipWithIndex.sortBy(_._1)
  var minCost = Long.MaxValue
  for ((x, f) ← distance) {
    popped(f) = true
    for (Route(to, d) ← fields(f).route){
      if (popped(to)) {
        rest -= d
      }
    }
    if (minCost > x * c + rest) minCost = x * c + rest
  }
  println(minCost)

  def minDistance(fields: Array[Field]): Array[Long] = {
    val queue = mutable.PriorityQueue((0, 0L): (Int, Long))(Ordering.by[(Int, Long), Long](_._2).reverse)
    val res = Array.tabulate(fields.length){_ ⇒ Long.MaxValue}.also{_(0) = 0L}
    while (queue.nonEmpty){
      val (top, distance) = queue.dequeue()
      if (res(top) == distance){
        for (Route(to, d) ← fields(top).route) {
          if (res(to) > distance + d) {
            res(to) = distance + d
            queue.enqueue((to, res(to)))
          }
        }
      }
    }
    res
  }
  class Field{
    private var mRoute: List[Route] = Nil
    def addRoute(to: Int, distance: Int): Unit = mRoute ::= Route(to, distance)
    def route: List[Route] = mRoute
  }
  case class Route(to: Int, distance: Int)
  implicit class ScopeFunc[T](val value: T) {
    def let[A](func: T ⇒ A): A = func(value)
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}

/*
 */


Measured memory_bytes: 481892
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
const int INF_INT = 2147483647;
const long long INF_LONG = 9223372036854775807;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
int main() {
  int x, n;  cin >> x >> n;
  set<int> set;
  rep (i, n) {
    int k;  cin >> k;
    set.insert(k);
  }

  rep (i, 100000) {
    if (!set.count(x - i)) {
      cout << x - i << endl;
      return 0;
    } 
    if (!set.count(x + i)) {
      cout << x + i << endl;
      return 0;
    } 
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    sort(l.begin(),l.end()); //にぶたんが使えるようにする

    long long cnt = 0;

    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int border;
            border = lower_bound(l.begin(),l.end(), l[i]+l[j]) - l.begin();
            //lower_boundではkeyより大きい最初の要素の位置を表す
            //これから最初の値を引くことで最大の数の右端を求めることができる
        
            cnt += max(border - (j+1),0);
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    ll n;
    cin >> n;
    for (int k = n; n < INF; ++k) {
        bool ans = true;
        for (int i = 2; i * i <= k; i++) {
            if (k % i == 0) {
                ans = false;
                continue;
            }
        }
        if (ans) {
            cout << k << endl;
            break;
        }
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;

int main(){
    ll T = 1;
    //cin >> T;
    while (T--){
       int a;
       cin >> a;
       int a2 = pow(a, 2);
       int a3 = pow(a, 3);
       int ans = a + a2 + a3;
       cout << ans << endl;
       
    }
}

Measured memory_bytes: 3976
#include <iostream>
#include <cmath>
#include <algorithm>
#include <deque>
#include <vector>
#include <map>
#include <set>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
// #define mp make_pair
// #define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define show(x) cout << #x << " = " << x << endl;

ll modpow(ll x, ll y){
  ll tmp;
  if(y == 0)return 0;
  else if(y == 1)return x;
  else if(y % 2 == 0){
    tmp = pow(modpow(x,y/2),2);
    return tmp % MOD;
  }else{
    tmp = pow(modpow(x,y/2),2) * x;
    return tmp % MOD;
  }
}

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



int main(){
  string s;
  cin >> s;
  int ans = s.size(), tmp;
  int si = s.size();
  char m = s[si/2];
  bool flag1 = true;
  bool flag2 = true;
  REP(i,si){
    if(s[i] == '1'){
      flag1 = false;
    }else{
      flag2 = false;
    }
  }
  if(flag1||flag2){
    cout << si << endl;
    return 0;
  }

  if(si % 2 == 0){
    FORD(i,si/2-1,0){
      ans = si/2 - i - 1;
      if(s[i] != m){
        break;
      }
    }
    FOR(i,si/2, si){
      tmp = i - si/2;
      if(s[i] != m){
        break;
      }
    }
    ans = min(tmp,ans);
    cout << ans + si/2 << endl;
  }else{
    FORD(i,si/2,0){
      ans = si/2 - i;
      if(s[i] != m){
        break;
      }
    }
    FOR(i,si/2, si){
      tmp = i - si/2;
      if(s[i] != m){
        break;
      }
    }
    ans = min(tmp,ans);
    cout << ans + si/2 << endl;
  }


  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

long long t1,t2;
cin>>t1>>t2;

long long a1,a2;
cin>>a1>>a2;

long long b1,b2;
cin>>b1>>b2;

//相対速度:=二人の距離の差で考える。
long long p=t1*(a1-b1);
long long q=t2*(a2-b2);

if(p>0){
    p*=-1;
    q*=-1;
}
if(p+q<0){
    cout<<"0"<<endl;

}
else if(p+q==0){
    cout<<"infinity"<<endl;
}
else {
    long long s=(-p)/(p+q);
    long long t=(-p)%(p+q);

    if(t !=0){
        cout<<s*2+1<<endl;
    }
    else{
        cout<<s*2<<endl;
    }


}



 return 0;
}
/*
1 2
10 10
12 4

1

100 1
101 101
102 1

infinity


12000 15700
3390000000 3810000000
5550000000 2130000000

113

*/

Measured memory_bytes: 256
N = int(input())
S = input()
first = S.count("E")
Ecount = 0 
Wcount = 0
count = first
for i in range(N):
    if S[i] == "E":
        Ecount += 1
    else:
        Wcount += 1
    count = min(count , first - Ecount + Wcount)
print(count)

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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b;
  cin >> a >> b;
  if (a * b % 2 == 0) {
    cout << "Even\n";
  } else {
    cout << "Odd\n";
  }
  
  return 0;
}


Measured memory_bytes: 3592
a, b = input().split() # a = result * 0.08, b = result * 0.1
a, b = int(a), int(b)
 
result_a = int(a / 0.08)
result_b = int(b / 0.1)
 
if result_a > result_b:
  if int(result_a * 0.08) != a:
    result_a += 1
  c = int(result_a * 0.1)
  if b == c:
    print(result_a)
  else:
    print(-1)
else:
  c = int(result_b * 0.08)
  if a == c:
    print(result_b)
  else:
    print(-1)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

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

	if (N * A > B) {
		cout << B << endl;
	}
	else if (N * A < B) {
		cout << N * A << endl;
	}
	else {
		cout << N * A << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#define MAX_N 1001

int solve(std::string s,std::string t){
        int dp[MAX_N][MAX_N]={0};
        int n,m;
        n=s.size();
       m=t.size();
        for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                        if(s[i]==t[j])
                                dp[i+1][j+1]=dp[i][j]+1;
                        else
                                dp[i+1][j+1]=std::max(dp[i][j+1],dp[i+1][j]);
                }
        }
        return dp[n][m];
}

int main(){
        int q;
        std::cin>>q;
        for(int i=0;i<q;i++){
                std::string s,t;
                std::cin >> s>>t;
                std::cout<<solve(s,t)<<std::endl;
        }
        return 0;
}

Measured memory_bytes: 7080
#include <stdio.h>
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <list>
#include <map>

#define FORi(N) for(ll i=0;i<N;++i)
#define FORj(N) for(ll i=0;i<N;++i)
#define FABi(a,b) for(ll i=a;i<=b;++i)

using namespace std;
using ll = long long;
using ld = long double;
int main(){
  ll N;
  cin>>N;
  list<ll> Avec(N);
  map<ll,ll> Amap;
  ll num = 0;
  FORi(N){
    ll tmp;
    cin>>tmp;
    Avec.push_back(tmp);
    if(Amap.find(tmp)!=Amap.end()){
      Amap[tmp]++;
    }else{
      Amap[tmp]=1;
    }
  }
  Avec.sort(greater<ll>());
  for(auto i = Avec.begin();i!=Avec.end();i++){
    ll c=*i;
    auto it = Amap.find(c);
    if(it==Amap.end())continue;
    it->second-=1;
    if(it->second == 0)Amap.erase(it);
    ll _2n = pow(2,(int)log2(c)+1);
    auto itr = Amap.find(_2n-c);
    if(itr != Amap.end()){
      itr->second-=1;
      if(itr->second == 0)Amap.erase(itr);
      num++;
    }
  }
  cout<<num<<endl;
  return 0;
}

Measured memory_bytes: 25216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int t = scan.nextInt();

		if (x - t > 0) {
			System.out.println(x - t);
		} else {
			System.out.println(0);
		}
	}

}


Measured memory_bytes: 23252
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int s[31]={0};
  int a;
  while(cin>>a)
    s[a]=1;

  for(int i=1;i<=30;i++)
    if(s[i]==0)
      cout<<i<<endl;
  
  return 0;
}

Measured memory_bytes: 1160
#include "iostream"

using namespace std;

int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	if(n==1)
	{
		if(a==b)
			cout<<1<<endl;
		else
			cout<<0<<endl;
	}
	else 
	{
		if(a>b)
			cout<<0<<endl;
		else
			cout<<(long long)(b-a)*(n-2)+1<<endl;
	}
	system("pause");
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
int a[51];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k,s=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n,greater<int>());
	for(int i=0;i<k;i++)
	s+=a[i];
	cout<<s;
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,K;
int a[100000];


int main()
{
    while(scanf("%d%d",&N,&K),N||K){
        for(int i=0;i<N;i++)scanf("%d",&a[i]);

        int sum=0;
        for(int i=0;i<K;i++)sum+=a[i];

        int ma=sum;
        for(int i=K;i<N;i++){
            sum-=a[i-K];
            sum+=a[i];
            ma=max(ma,sum);
        }
        printf("%d\n",ma);
    }
    return 0;
}

Measured memory_bytes: 1576
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    lint M;
    cin >> N >> M;
    lint LCM = 1;
    lint a[N];
    cins(a, a + N);
    for(int i = 0; i < N; i++){
        LCM = lcm(LCM, a[i] / 2);
        if(LCM > M){
            cout << 0 << endl;
            return 0;
        }
    }
    for(int i = 0; i < N; i++){
        if((LCM * 2 / a[i]) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    M /= LCM;
    cout << (M + 1) / 2 << endl;
}



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

if ( 0 < int(s[0]+s[1])) and (int(s[0]+s[1]) <= 12) and ( 0 < int(s[2]+s[3])) and  (int(s[2]+s[3]) <= 12) :
  print("AMBIGUOUS") 
elif ( 0 < int(s[0]+s[1])) and (int(s[0]+s[1]) <= 12):
  print("MMYY")
elif ( 0 < int(s[2]+s[3])) and  (int(s[2]+s[3]) <= 12):
  print("YYMM")
else :
  print("NA")
  

Measured memory_bytes: 8884
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  
  vector<int> ans(N+1);
  
  FOR(x,1,sqrt(N)+1){
    FOR(y,1,sqrt(N)+1){
      FOR(z,1,sqrt(N)+1){
        int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        if(tmp <= N)
          ans.at(tmp)++;
      }
    }
  }
  FOR(i,1,N)    cout << ans.at(i) << endl;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline

n,m=map(int,input().split())
C = [list(map(int,input().split())) for _ in range(m)]

for i in range(1000):
    S = str(i)
    if len(S)==n:
        for s,c in C:
            s-=1
            if S[s]==str(c):
                True
            else:
                break
        else:
            print(i)
            sys.exit()
print(-1)



Measured memory_bytes: 62820
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.Scanner;

class Main{
    private static final Scanner sc = new Scanner(System.in);
    private static final DecimalFormat fmt = new DecimalFormat("0.########");
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args) throws IOException{
        final int n = Integer.parseInt(sc.next());
        final int x[] = new int[n];
        for(int i = 0; i<n; i++)
            x[i] = Integer.parseInt(sc.next());
        int d1 = 0, d2 = 0, di = 0;
        long d3 = 0;
        for(int i = 0; i<n; i++){
            final int y = Math.abs(Integer.parseInt(sc.next())-x[i]);
            d1 += y;
            d2 += y*y;
            d3 += y*y*y;
            di = Math.max(di, y);
        }
        out.println(d1);
        out.println(fmt.format(Math.sqrt(d2)));
        out.println(fmt.format(Math.pow(d3, 1.0/3.0)));
        out.println(di);
        out.flush();
    }
}

Measured memory_bytes: 26460
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

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

  string abc = "ATGC";

  int max = 0;
  int count = 0;
  for (int i = 0; i < S.length(); i++) {
    if (abc.find(S[i]) != string::npos) {
      count++;
    } else {
      if (count > max) max = count;
      count = 0;
    }
  }

  if (count > max) max = count;

  cout << max << endl;
}

Measured memory_bytes: 256
# include <cstdio>
# include <iostream>
# define R register int
# define ll long long

using namespace std;

const int N=1003;
int n,f0,f1,m;
int x[N],y[N];
ll c[N];

ll ab (ll a)
{
    if(a<0) return -a;
    return a;
}

void write (int x,int y)
{
    printf("\n");
    ll nx=0,ny=0;
    for (R i=1;i<=m;++i)
    {
        if(ab(nx-x)>ab(ny-y))
        {
            if(nx>x) printf("L"),nx-=c[i];
            else printf("R"),nx+=c[i];
        }
        else
        {
            if(ny>y) printf("D"),ny-=c[i];
            else printf("U"),ny+=c[i];
        }
    }
    if(nx!=x||ny!=y) puts("WA"); 
}

int main()
{
    scanf("%d",&n);
    for (R i=1;i<=n;++i)
    {
        scanf("%d%d",&x[i],&y[i]);
        if((x[i]+y[i])%2) f1=1;
        else f0=1;
    }
    if(f0&&f1) { puts("-1"); return 0; }
    if(f0) c[++m]=1;
    for (R i=0;i<=38;++i) c[++m]=1ll<<i;
    printf("%d\n",m);
    for (R i=1;i<=m/2;++i) swap(c[i],c[m-i+1]);
    for (R i=1;i<=m;++i) printf("%lld ",c[i]);
    for (R i=1;i<=n;++i) write(x[i],y[i]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP std::make_pair
#define FI first
#define SE second
#define M 1000005
#define INF 1000000000
typedef long long ll;
ll n,D[M],size[M],sum;
std::multiset <std::pair <ll,ll> > Set;
std::pair <ll,ll> Edge[M];
ll read(){
	char c=getchar();ll ans=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=ans*10+c-'0',c=getchar();
	return ans;
}
void Write(ll x){
	if (x<10) putchar(x+'0');
	else Write(x/10),putchar(x%10+'0');
	return;
}
int main(){
	n=read();
	for (ll i=1;i<=n;i++) size[i]=1,Set.insert(MP(D[i]=read(),i));
	for (ll i=1;i<n;i++){
		auto it=Set.end();--it;ll X=it->FI,Y=it->SE;Set.erase(it);
		auto nxt=Set.lower_bound(MP(X+size[Y]-(n-size[Y]),0));
		if (nxt==Set.end()||nxt->FI>X+size[Y]-(n-size[Y])) return !printf("-1");
		Edge[i]=MP(Y,nxt->SE),size[nxt->SE]+=size[Y]; 
	}
	for (int i=1;i<=n;i++) sum+=size[i]-1;
	if (sum!=Set.begin()->FI) return !printf("-1");
	for (int i=1;i<n;i++) Write(Edge[i].FI),putchar(' '),Write(Edge[i].SE),putchar('\n');
	return 0;
}


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

//Optional FAST

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

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

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

//Required typedefs

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

//Required Constants

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

//Required Functions

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

//Work

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

    cout<<fixed<<setprecision(10);
    READV(N);
    pld points[N];
    FORI(i,0,N)
    {
        READ(points[i].fi);
        READ(points[i].se);
    }
    ld ans=0;
    FORI(i,0,N)
    {
        FORI(j,0,N)
        {
            ans+=sqrt((points[i].fi-points[j].fi)*(points[i].fi-points[j].fi)+(points[i].se-points[j].se)*(points[i].se-points[j].se));
        }
    }
    ans=ans/((ld)N);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 

int main()
{
	int n,a;
	cin>>n;
	if(n<600)a=8;
	else if(n<800)a=7;
	else if(n<1000)a=6;
	else if(n<1200)a=5;
	else if(n<1400)a=4;
	else if(n<1600)a=3;
	else if(n<1800)a=2;
	else if(n<2000)a=1;
	printf("%d\n",a);
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	ll n, k;
	cin >> n >> k;
	Vec a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i]--;
	}
	Vec distance(n, -1);
	distance[0] = 0;
	Vec b(n, -1);
	b[0] = 0;
	int prev = 0;
	int pos = a[0];
	k--;
	while (k > 0)
	{
		if (distance[pos] < 0)
		{
			distance[pos] = ++prev;
			b[prev] = pos;
			pos = a[pos];
			k--;
		}
		else
		{
			int len = ++prev - distance[pos];
			k %= len;
			pos = b[distance[pos] + k];
			break ;
		}
	}
	cout << pos+1 << endl;
}


Measured memory_bytes: 5636
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
using namespace std;

int main() {
  int n,a;
  cin >> n >> a;
  while(n>=500){
    n=n-500;
  }
  if(n>a){
    cout << "No" << endl;
  }
    else
      cout << "Yes" << endl;
}
  

Measured memory_bytes: 256