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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > vec_start(n), vec_goal(n);
  for (int i = 0; i < n; i++) {
    vec_start[i].second = i;
    cin >> vec_start[i].first;
  }
  for (int i = 0; i < n; i++) {
    vec_goal[i].second = i;
    cin >> vec_goal[i].first;
  }
  sort(vec_start.begin(),vec_start.end());
  sort(vec_goal.begin(),vec_goal.end());

  bool flag = false;
  int arr_index_check[n];
  for (int i = 0; i < n; i++) {
    if (vec_start[i].first > vec_goal[i].first) {
      cout << "No" << endl;
      return 0;
    }
    arr_index_check[vec_start[i].second] = vec_goal[i].second;
    if (i == 0) continue;
    if (vec_start[i].first <= vec_goal[i - 1].first) {
      flag = true;
    }
  }

  if (flag) {
    cout << "Yes" << endl;
    return 0;
  }
  int next_index = 0;
  for (int i = 0; i < n - 1; i++) {
    next_index = arr_index_check[next_index];
    if (next_index == 0) {
      flag = true;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
using namespace std;

int main(){
	int n, sum = 0;
	cin >> n;
	int x = n;
	while (x > 0) {
		sum += x % 10;
		x /= 10;
	}
	if (n%sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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


int dp__[100];

//最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp__[n] = 1;
  if(dp__[n] != -1) return dp__[n];
  return dp__[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


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

  s[k-1] = s[k-1] -'A' + 'a';

  cout << s << endl;

}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N,R;
		N= sc.nextInt();
		R=sc.nextInt();
		if (N<=10) {
			System.out.println(R+100*(10-N));
		} else {
			System.out.println(R);
		}
	}

}

Measured memory_bytes: 25044
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define LL long long
using namespace std;

LL dp[55][55][2550];
LL x, ans;

int main()
{
	int n, aver;
	cin >> n >> aver;
	dp[0][0][0] = 1;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> x;
		for(int j = 0; j <= i; j++)
			for(int k = 0; k <= 2500; k++)
			{
				dp[i][j][k] += dp[i - 1][j][k];
				if(k >= x && j >= 1) dp[i][j][k] += dp[i - 1][j - 1][k - x];
			}
	}
	
	for(int i = 1; i <= n; i++)
		ans += dp[n][i][i * aver];
	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 54144
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll dp[n+1];
    for(ll i=0;i<=n;i++)
        dp[i]=INT_MAX;
    dp[0]=0;
    for(ll i=0;i<n;i++)
    {
        if(i+1<n)
            dp[i+1]=min(dp[i+1],dp[i]+abs(a[i+1]-a[i]));
        if(i+2<n)
            dp[i+2]=min(dp[i+2],dp[i]+abs(a[i+2]-a[i]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
            cerr<<"\x1b[7m"<<"'int' is 'long long'"<<"\x1b[m"<<endl;
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

struct RMQ {
    int n;
    vector<int> dat;
    RMQ(int n_=0) {
        n=1;
        while(n<n_) n*=2;
        dat=vector<int>(n*2-1,2147483647);
    }
    void update(int i,int x) {
        i+=n-1;
        dat[i]=x;
        while(i>0) {
            i=(i-1)/2;
            dat[i]=min(dat[i*2+1],dat[i*2+2]);
        }
    }
    int query(int a,int b) {
        return query(a,b,0,0,n);
    }
    int query(int a,int b,int k,int l,int r) {
        if(r<=a or b<=l) return 2147483647;
        if(a<=l and r<=b) return dat[k];
        int ml=query(a,b,k*2+1,l,(r+l)/2);
        int mr=query(a,b,k*2+2,(r+l)/2,r);
        return min(ml,mr);
    }
};
signed main() {
    int n,q;
    cin>>n>>q;
    RMQ segtree(n);
    while(q--) {
        int com,x,y;
        cin>>com>>x>>y;
        if(com==0) {
            segtree.update(x,y);
        }
        else {
            cout<<segtree.query(x,y+1)<<endl;
        }
    }
    return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int l,r; cin>>l>>r;
  int cnt=0;
  ll ans=2018;
  for(int i=l; i<r; i++){
    if(cnt>=2019) break;
    cnt++;
    
    int icnt=0;
    for(int j=i+1; j<=r; j++){
      if(icnt>=2019) break;
      icnt++;
      
      chmin(ans, (ll)i*j%2019);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int num;
    double p1,p2,bmi;
    for(;scanf("%d,%lf,%lf",&num,&p1,&p2) != EOF;){
        bmi=p1/(p2*p2);
        if(bmi >= 25)
            printf("%d\n",num);
    }
    return 0;
}

Measured memory_bytes: 628
import java.util.Scanner;
public class Main {
     
    static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
     
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int L = 0;
        int R = 0;
        for(int i = 0; i < n; i++) {
            String s1 = stdIn.next();
            String s2 = stdIn.next();
             
            if(s1.compareTo(s2) == 0) {
                L++;
                R++;
            }
            else if(s1.compareTo(s2) < 0) {
                L += 3;
            }
            else {
                R += 3;
            }
        }
         
        System.out.println(R + " " + L);
    }
}


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

long long keta(long long n){
    string s = to_string(n);
    long long sum = 0;

    for(long long i = 0; i < s.size(); i++){
        sum += s[i] - '0';
    }
    return sum;
}

int main(){
    long long n;
    cin >> n;

    long long sn = keta(n);
    if(n % sn == 0) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    int ans = 0;
    for(int i = 0; i < 4; i++) {
      if(n.charAt(i) == '2')
        ans++;
    }
    System.out.println(ans);
  }
  

}


Measured memory_bytes: 21972
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

type UnionFind struct {
	Par []int
}

func NewUnionFind(n int) *UnionFind {
	uf := &UnionFind{
		Par: make([]int, n),
	}
	uf.Init(n)
	return uf
}

func (uf *UnionFind) Init(n int) {
	for i := 0; i < n; i++ {
		uf.Par[i] = -1
	}
}

func (uf *UnionFind) Find(x int) int {
	if uf.Par[x] < 0 {
		return x
	}
	uf.Par[x] = uf.Find(uf.Par[x])
	return uf.Par[x]
}

func (uf *UnionFind) Unite(x, y int) {
	x, y = uf.Find(x), uf.Find(y)
	if x == y {
		return
	}

	if uf.Par[x] > uf.Par[y] {
		x, y = y, x
	}
	uf.Par[x] += uf.Par[y]
	uf.Par[y] = x
}

func (uf *UnionFind) Same(x, y int) bool {
	return uf.Find(x) == uf.Find(y)
}

// xの属する集合の要素数
func (uf *UnionFind) Size(x int) int {
	return -uf.Par[uf.Find(x)]
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m := nextInt(), nextInt()

	uf := NewUnionFind(n)
	for i := 0; i < m; i++ {
		x, y, _ := nextInt()-1, nextInt()-1, nextInt()
		uf.Unite(x, y)
	}

	ans := 0
	for i := 0; i < n; i++ {
		if uf.Par[i] < 0 {
			ans++
		}
	}
	puts(ans)
}


Measured memory_bytes: 3072
import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  solve
  def solve:Unit = {
    val n = readLine.trim.toInt
    if (n == 0) return
    val stores = Array.tabulate(n) { _ ⇒
      val goods = readLine.trim.split(' ')
      (1 until goods.size by 2).map { it ⇒ (goods(it), goods(it + 1).toInt) }.toMap
    }
    val q = readLine.trim.toInt
    val needs = Array.tabulate(q) { _ ⇒ readLine.trim }
    val storesWithCanBuy = Array.tabulate(n + 1) { _ ⇒ 0 }
    var sum: Option[Int] = Some(0)
    for ((name, i) ← needs.zipWithIndex) {
      val prices = stores.zipWithIndex.flatMap { case (m, id) ⇒ m.get(name).map{(_, id)}}
      if (sum.isEmpty || prices.length == 0) {
        sum = None
      } else {
        val min = prices.map(_._1).min
        sum = sum.map {
          _ + min
        }
        for (s ← prices.withFilter(_._1 == min).map(_._2)) {
          storesWithCanBuy(s + 1) += 1 << i
        }
      }
    }
    val minRoute = Array.tabulate(n + 1) { f ⇒ Array.tabulate(n + 1) { t ⇒ if (f != t) Int.MaxValue else 0: Int } }
    for (_ ← 0 until readLine.trim.toInt) {
      val Array(s, t, d) = readLine.trim.split(' ').map(_.toInt)
      minRoute(s)(t) = d
      minRoute(t)(s) = d
    }
    for {k ← 0 to n
         i ← 0 to n
         j ← 0 to n} {
      if (minRoute(i)(j) - minRoute(i)(k) > minRoute(k)(j)) {
        minRoute(i)(j) = minRoute(i)(k) + minRoute(k)(j)
      }
    }
    val minMemo = Array.tabulate(n + 1) { _ ⇒ Array.tabulate(1 << q) { _ ⇒ Int.MaxValue } }.also(a ⇒ a(0)(0) = 0)
    val queue = mutable.PriorityQueue()(Ordering.by[(Int, Int, Int), Int](_._3).reverse).also(a ⇒ a.enqueue((0, 0, 0)))
    while (queue.nonEmpty) {
      val (current, goods, distance) = queue.dequeue()
      if (minMemo(current)(goods) == distance) {
        for (i ← 0 to n) {
          if (minMemo(i)(goods | storesWithCanBuy(i)) - distance > minRoute(i)(current)) {
            minMemo(i)(goods | storesWithCanBuy(i)) = minRoute(i)(current) + distance
            queue.enqueue((i, goods | storesWithCanBuy(i), minMemo(i)(goods | storesWithCanBuy(i))))
          }
        }
      }
    }
    println(
      sum match {
        case Some(s) ⇒ s"$s ${ minMemo(0).last }"
        case None ⇒ "impossible"
      }
    )
    solve
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    vector<int> Y(N);
    for(int i=0;i<N;i++){
        cin >> X[i] >> Y[i];
    }
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    vector<int> D(N);
    for(int i=0;i<N;i++){
        A[i] = X[i]+Y[i];
        B[i] = X[i]-Y[i];
        C[i] = -X[i]+Y[i];
        D[i] = -X[i]-Y[i];
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    sort(D.begin(),D.end());
    int m = A[N-1]-A[0];
    m = max(m,B[N-1]-B[0]);
    m = max(m,C[N-1]-C[0]);
    m = max(m,D[N-1]-D[0]);
    
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 8004
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
ans = 0
for i in range(N):
    a = int(input())
    if i==0:
        base = 2
        ans += a-1
        continue
    if a<base:
        continue
    if a==base:
        base+=1
    elif a%base==0:
        ans += (a-1)//base
    else:
        ans += a//base
print(ans)

Measured memory_bytes: 73836
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    /*
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    */
    
    cout << (ll)(n - 1) * n / 2 << endl;
}


Measured memory_bytes: 256
n = int( raw_input( ) )
minv = int( raw_input( ) )
maxv = 0 - 1000000000
 
for j in range( n-1 ):
  num = int( raw_input( ) )  
  diff = num - minv
  if maxv < diff:
    maxv = diff
  if num < minv:
    minv = num
 
print maxv

Measured memory_bytes: 12628
n = int(input())
s = input()

cnt = 0
tmp = ""
for elem in s:
  if "A" == elem:
    tmp += elem
  elif "B" == elem and tmp != "":
    if tmp[-1] == "A":
	    tmp += elem
    else:
      	tmp = ""
  elif "C" == elem and tmp != "":
    if tmp[-1] == "B":
    	cnt += 1
    tmp = ""
  else:
    tmp = ""
print(cnt)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static List<int>[] li;
	static bool[] b;
	static int kr=0,kc=0;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		if(n==1){Console.WriteLine("First");return;}
		li=new List<int>[n+1];
		b=new bool[n+1];
		for(int i=1;i<=n;i++){li[i]=new List<int>();}
		for(int i=0;i<n-1;i++){
			int[] e=sc.Ia;
			li[e[0]].Add(e[1]);
			li[e[1]].Add(e[0]);
		}
		Fu(1,1,0);
		b=new bool[n+1];
		kr=0;
		Fu(kc,kc,0);
		bool[] h=new bool[kr+2];
		h[1]=true;
		for(int i = 3;i<=kr+1;i++) {
			if(!h[i-1]||!h[i-2]){h[i]=true;}
		}
		Console.WriteLine("{0}",h[kr+1]?"First":"Second");
	}
	static void Fu(int a,int g,int k){
		b[a]=true;
		if(kr<k){kr=k;kc=a;}
		for(int i=0;i<li[a].Count;i++){
			if(!b[li[a][i]]){Fu(li[a][i],g,k+1);}
		}
	}
}
public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split(new string[]{" ","　","	"},StringSplitOptions.RemoveEmptyEntries);}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split(new string[]{" ","　","	"},StringSplitOptions.RemoveEmptyEntries);}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split(new string[]{" ","　","	"},StringSplitOptions.RemoveEmptyEntries);}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split(new string[]{" ","　","	"},StringSplitOptions.RemoveEmptyEntries);}n++;return a[n];}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(new string[]{" ","　","	"},StringSplitOptions.RemoveEmptyEntries),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(new string[]{" ","　","	"},StringSplitOptions.RemoveEmptyEntries),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(new string[]{" ","　","	"},StringSplitOptions.RemoveEmptyEntries),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(new string[]{" ","　","	"},StringSplitOptions.RemoveEmptyEntries),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(new string[]{" ","　","	"},StringSplitOptions.RemoveEmptyEntries),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split(new string[]{" ","　","	"},StringSplitOptions.RemoveEmptyEntries);}}
}

Measured memory_bytes: 51496
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
int main()
{
    ll n,m;
    cin >> n >> m;
    vector<vector<ll>> vec(10,vector<ll> (10));
    for(ll i=0;i<10;++i){
        for(ll j=0;j<10;++j){
            cin >> vec[i][j];
        }
    }
    vector<vector<ll>> hoge(200,vector<ll>(200));
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            cin >> hoge[i][j];
        }
    }
  //  vector<vector<int>> dis(10,vector<int>(10,1e9))
    for(ll k=0;k<10;++k){
        for(ll j=0;j<10;++j){
            for(ll i=0;i<10;++i){
                if(vec[i][k]+vec[k][j]<vec[i][j]){
                    vec[i][j]=vec[i][k]+vec[k][j];
                }
            }
        }
    }
    ll death=0;
    for(ll i=0;i<n;++i){
        for(ll j=0;j<m;++j){
            if(hoge[i][j]!=-1){
                death += vec[hoge[i][j]][1];
            }
        }
    }
    cout<<death<<endl;
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**9)
N, M, Q = map(int, input().split())
l = []
for _ in range(Q):
    l.append(list(map(int, input().split())))
ans = 0
def dfs(n):
    if len(n) == N+1:
        global ans
        tmp = 0
        for i in range(Q):
            abi = n[l[i][1]]
            aai = n[l[i][0]]
            c = l[i][2]
            d = l[i][3]
            if abi -aai == c:
                tmp += d
        ans = max(ans, tmp)
    else:
        for i in range(n[-1], M+1):
            tmp2 = n[:]
            tmp2.append(i)
            dfs(tmp2)
dfs([1])
print(ans)


Measured memory_bytes: 76528
import math
import copy

n = int(input())
# k, x = [int(i) for i in input().split()]
# table = [[int(i) for i in input().split()] for j in range(n)]
# table = [list(input()) for n in range(h)]
# s = [int(i) for i in input().split()]
# num = [int(i) for i in range(n)]
# s = [input() for i in range(n)]
# s = input()
# list = list(s)
# dp = [[0 for _ in range(2)] for _ in range(13)]
s = [input() for i in range(n)]

for i in range(n):
    moji = list(map(lambda x: x, s[i]))
    moji.sort()
    s[i] = moji

s.sort()

count = 0
i = 0
j = 1
temp = 0
while (j < n):
    if (s[i] == s[j] and j < n - 1):
        j += 1
    elif (s[i] != s[j] and j < n - 1):
        count += (j - i) * (j - i - 1) / 2
        i = j
        j = i + 1
    elif (s[i] == s[j] and j == n - 1):
        count += (j - i) * (j - i + 1) / 2
        i = j
        j = i + 1
    else:
        count += (j - i) * (j - i - 1) / 2
        i = j
        j = i + 1

print(int(count))

Measured memory_bytes: 22100
def solve(n, H):
    m = H[0]
    for i in range(1, n):
        if m - H[i] > 1:
            return 'No'
        if m < H[i]:
            m = H[i]
    return 'Yes'

_n = int(input())
_H = list(map(int, input().split()))
print(solve(_n, _H))

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

int main() {
    int n;
    cin >> n;
    if (n / 10 == 9) {
        cout << "Yes";
    } else if (n % 10 == 9) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

const LL INF = 1LL << 61;

int N;
LL A[5145];
vector<int> es[5145];
vector<LL> dp[5145];
vector<char> pos[5145];

void Dfs(int v, int p) {
  dp[v].resize(1, A[v]);
  pos[v].resize(1, A[v] > 0);

  for (int u : es[v]) {
    if (u == p) continue;
    Dfs(u, v);

    vector<LL> tmp(dp[v].size() + dp[u].size(), INF);
    vector<char> npos(dp[v].size() + dp[u].size());
    rep(i, dp[v].size()) {
      rep(j, dp[u].size()) {
        if (dp[u][j] < 0 || pos[u][j]) {
          MN(tmp[i+j+1], dp[v][i]);
          npos[i+j+1] |= pos[v][i];
        }
        MN(tmp[i+j], dp[v][i] + dp[u][j]);
        npos[i+j] |= pos[v][i] && pos[u][j];
      }
    }
    dp[v].swap(tmp);
    pos[v].swap(npos);
  }
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  cin >> N;
  rep(i, N) {
    cin >> A[i];
  }

  rep(i, N-1) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    es[u].eb(v);
    es[v].eb(u);
  }

  Dfs(0, 0);
  rep(i, N) {
    if (dp[0][i] < 0 || pos[0][i]) {
      cout << i << endl;
      return 0;
    }
  }
  assert(0);
}


Measured memory_bytes: 93056
#include <stdio.h>

int main(void)
{
	int bus[11] = {0};
	int n, bush = 0;
	
	while (scanf("%d", &n), 1){
		
		if (n != 0){
			bus[bush] = n;
			bush++;
		}
		else {
			bush--;
			if (bush < 0)break;
			
			printf("%d\n", bus[bush]);
		
		}
		
	//	printf("bush=%d\n", bush);
	}
	
	return (0);
}

Measured memory_bytes: 600
#define scanf_s scanf
#include <stdio.h>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <iostream>
using namespace std;

#define MAX 100000

int main()
{
	while (1) {
		int n, max, maxi = 0, p, d1, d2, d;
		scanf_s("%d", &n);
		if (n == 0)break;
		for (int i = 0; i < n; ++i) {
			scanf_s("%d %d %d", &p, &d1, &d2);
			d = d1 + d2;
			if (i == 0 || max < d) {
				max = d;
				maxi = p;
			}
		}
		printf("%d %d\n", maxi, max);
	}
}

Measured memory_bytes: 1188
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}

ll dp[200005];
ll dpwa[200005];
ll mod = 998244353;
int main() {
	dp[0] = 0;
	dpwa[0] = 0;
	ll N,K;
	cin >> N>>K;
	vector<ll> L(K);
	vector<ll> R(K);
	rep(i, K) {
		cin >> L[i] >> R[i];
	}
	dp[1] = 1;
	dpwa[1] = 1;
	for (ll i = 2; i <= N; i++) {
		rep(j, K) {
			if (i - L[j] > 0) {
				if (i - R[j] - 1 >= 0) {
					dp[i] += dpwa[i - L[j]] - dpwa[i - R[j] - 1];
				}
				else {
					dp[i] += dpwa[i - L[j]];
				}
				}
		}
		dp[i] += 2e5 * mod;
		dp[i] %= mod;
		dpwa[i] = dpwa[i - 1] + dp[i];
		dpwa[i] += 2e5 * mod;
		dpwa[i] %= mod;
	}

	cout << dp[N] << endl;
}

Measured memory_bytes: 6692
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
vector<bool> seen;
vector<vector<int>> G;
ll tt=0;
vector<ll> A[200001];

void dfs(int v) {
  A[tt].push_back(v);
  seen[v] = true;
  for (auto next : G[v]) {
    if (seen[next]) continue;
    dfs(next);
  }
}

int main() {
  int n, m; cin >> n >> m;
  G.resize(n+1);
  for (int i=0;i<m;i++) {
    int a,b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  seen.assign(n+1, false);
  for (int v = 0; v < n; ++v) {
     if (seen[v]) continue;
     dfs(v);
     tt++;
  }
  ll ans=0;
  for(int i=0;i<200001;i++)ans=max(ans,(ll)A[i].size());
  cout<<ans<<endl;
}


Measured memory_bytes: 29956
a=[]
for i in range(5):
    a.append(int(input()))

zako=9
switch=0
for i in range(5):
    b=a[i]%10
    if b<=zako and b!=0:
        zako=b
        memory=i
        switch=1

if switch==0:
    memory=1
x=a.pop(memory)

lst=[]

for i in range(4):
    c=a[i]//10
    c=c*10
    if a[i]%10!=0:
        c+=10
    lst.append(c)

print(x+sum(lst))

Measured memory_bytes: 9144
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll n; cin >> n;
  const int m = 1e5+1;
  
  V cnt(m);
  ll sum = 0;
  rep(i, n) {
    int x; cin >> x;
    cnt[x]++;
    sum += x;
  }

  int q; cin >> q;

  rep(_, q) {
    int b, c; cin >> b >> c;

    int &y = cnt[b];
    sum += (c - b) * y;
    cnt[c] += y;
    y = 0;
    cout << sum << "\n";
  }

  return 0;
}


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



int main() {
int a,b,sum=0;
cin>>a>>b;
vector<int>v(a);
for(int i=0;i<a;i++)
cin>>v[i];
sort(v.begin() ,v.end());
for(int i=a-1;i>=a-b;i--){
sum+=v[i];
}
cout<<sum<<endl;
return 0;
}

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

int main(){
  vector<int> backet(110,0);
  for(int i = 0; i < 3; i++){
    int a; cin >> a;
    backet.at(a)++;
  }
  int count = 0;
  for(int i = 0; i < 110; i++){
    if(backet.at(i) > 0) count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
def modinv(a, mod):
    return pow(a, mod - 2, mod)

MOD = 10**9+7
class Factorial:
    def __init__(self, n, mod):
        # O(n + log mod)
        self.f = f =[0] * (n + 1)
        f[0] = b = 1
        for i in range(1, n + 1):
            f[i] = b = b * i % mod
        self.inv = inv = [0] * (n + 1)
        inv[n] = b = modinv(self.f[n], mod) # pow(self.f[n], -1, mod) が Google Colab, Python ver. が低く Error
        for i in range(n, 0, -1):
            inv[i - 1] = b = b * i % mod
        self.mod = mod
    
    def __call__(self, n, k):  # self.C() と同じ
        return self.C(n, k)

    def factorial(self, i):
        return self.f[i]

    def ifactorial(self, i):
        return self.inv[i]

    def C(self, n, k):
        if not 0 <= k <= n: return 0
        return self.f[n] * self.inv[n - k] * self.inv[k] % self.mod

    def P(self, n, k):
        if not 0 <= k <= n: return 0
        return self.f[n] * self.inv[n - k] % self.mod

    def H(self, n, k):
        if (n == 0 and k > 0) or k < 0: return 0
        return self.f[n + k - 1] * self.inv[k] % self.mod * self.inv[n - 1] % self.mod

def factorize(n) -> list:
    b, e = 2, 0
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e:
            fct += (b, e), # b,
        b += 1
        e = 0
    if n > 1:
        fct += (n, 1), # n,
    return fct

n, m = map(int, input().split())
F = Factorial(n + 30, MOD)
c = 1
for _, E in factorize(m):
    c = c * F.H(n, E) % MOD
print(c)

Measured memory_bytes: 16780
#include <bits/stdc++.h>
using namespace std;
const int OO = 0x3f3f3f3f;
const int MAX = 1e6;
const int MOD = 1000000007LL;

int n, m;
char grid[1005][1005];
int dp[1005][1005];

int solve(int i, int j)
{
	if(i >= n or j >= m or grid[i][j] == '#') return 0;
	if(i == n - 1 and j == m - 1)
		return 1;
	if(dp[i][j] != -1)
		return dp[i][j];
	return dp[i][j] = (solve(i + 1, j) + solve(i, j + 1)) % MOD;
	
}

int main()
{
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			cin >> grid[i][j];
	memset(dp, -1, sizeof(dp));
	cout << solve(0, 0) % MOD << '\n';

	return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int k,n;
    cin >> k >> n;
    int a[n];
    REP(i,n) cin >> a[i];
    int ab=-1;
    REP(i,n-1){
        chmax(ab,a[i+1]-a[i]);
    }
    chmax(ab,a[0]+k-a[n-1]);
    cout << k-ab;

    return 0;
}

Measured memory_bytes: 4408
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int x;
  cin >> x;
  cout << !x << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);


ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}

ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}

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

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

    ll q=1;
    //cin>>q;
    while(q--)
    {
        string s;
        cin>>s;
        ll n=s.size();
        ll r=1;
        ll x=0;
        VLL v;
        REPI(i,0,n)
        {
            if(s[i]=='?')
            {
                v.PB(r);
            }
            else
            {
                x+=r*(s[i]-'0');
                x%=13;
            }
            r*=10;
            r%=13;
        }
        ll nv=v.size();
        ll dp[13][nv+1];
        REP(i,0,13) REP(j,0,nv+1) dp[i][j]=0;
        dp[x][0]=1;
        REP(i,0,v.size())
        {
            REP(j,0,10)
            {
                REP(k,0,13)
                {
                    dp[(j*v[i]+k)%13][i+1]+=dp[k][i];
                    dp[(j*v[i]+k)%13][i+1]%=M;
                }
            }
        }
        cout<<dp[5][nv];
    }

    return 0;
}


Measured memory_bytes: 11460
from itertools import combinations
import copy
H, W, K=list(map(int,input().split()))
def conv(m):
    if m=='#':
        return 1
    else:
        return 0
c=[]
for i in range(H):
    c.append([conv(s) for s in input()])
items = [(0,i) for i in range(H)]+[(1,j) for j in range(W)]
subsets=[]
for i in range(len(items) + 1):
    for e in combinations(items, i):
        subsets.append(e)
count=0
for e in subsets:
    M=copy.deepcopy(c)
    for p in e:
        if p[0]==0:
            for j in range(W):
                M[p[1]][j]=0
        else:
            for i in range(H):
                M[i][p[1]]=0
    if sum([sum(u) for u in M])==K:
        count+=1
print(count)

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int s;
  cin >> s;
  
  int ind = 1;

  set<int> st;
  st.insert(s);

  while(true)
  {
    ind++;
    s = ((s & 1) ? 3 * s + 1 : s / 2);
    if (st.find(s) != st.end())
    {
      cout << ind;
      return;
    }
    st.insert(s);
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main(){
	int n,m,l;
	cin>>n>>m>>l;
	long long a[n][m],b[m][l],c[n][l]={};
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>a[i][j];
	for(int i=0;i<m;i++) for(int j=0;j<l;j++) cin>>b[i][j];
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
			for(int k=0;k<m;k++) c[i][j]+=a[i][k]*b[k][j];
			cout<<c[i][j];
			if(j!=l-1) cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 3308
a = list(input())
x = a[0]+a[1]
y = a[2]+a[3]


if x == "01" or x == "02"  or x == "03" or x == "04"  or x == "05"  or x == "06"  or x == "07"  or x == "08"  or x == "09"  or x == "10"  or x == "11"  or x == "12":
    if y == "01" or y == "02"  or y == "03" or y == "04"  or y == "05"  or y == "06"  or y == "07"  or y == "08"  or y == "09"  or y == "10"  or y == "11"  or y == "12":
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif y == "01" or y == "02"  or y == "03" or y == "04"  or y == "05"  or y == "06"  or y == "07"  or y == "08"  or y == "09"  or y == "10"  or y == "11"  or y == "12":
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  string s;
  cin>>s;
  for(int i = s.size() - 1 ; i >= 0 ; i --)
    cout<<s[i];
  cout<<endl;
}

Measured memory_bytes: 1172
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

int main(){
	const char oct[] = {'0','1','2','3','5','7','8','9'};
	ll n;
	while(~scanf("%lld",&n)){
		if(n==0) break;
		char buf[11];
		sprintf(buf,"%llo",n);

		for(int i=0;i<=10;i++){
			if(buf[i]=='\0') break;
			buf[i] = oct[buf[i]-'0'];
		}
		printf("%s\n",buf);
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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












 
int main(){
    ll n, m, L;
    cin >> n >> m >> L;
    vector<vector<ll>> g(n, vector<ll>(n, INF));
    REP(i, n){
        g[i][i] = 0;
    }
    REP(i, m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        if(c > L) continue;
        g[a][b] = c;
        g[b][a] = c;
    }
    REP(k, n){
        REP(i, n){
            REP(j, n){
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
    vector<vector<ll>> g2(n, vector<ll>(n, INF));
    REP(i, n){
        g2[i][i] = 0;
    }
    REP(i, n){
        REP(j, n){
            if(g[i][j] <= L){
                g2[i][j] = 1;
            }
        }
    }
    REP(k, n){
        REP(i, n){
            REP(j, n){
                g2[i][j] = min(g2[i][j], g2[i][k] + g2[k][j]);
            }
        }
    }
    ll q;
    cin >> q;
    REP(i, q){
        ll s, t;
        cin >> s >> t;
        s--; t--;
        cout << ((g2[s][t] != INF)? g2[s][t] - 1 : -1)  << endl;
    }
}

Measured memory_bytes: 1920
#include<stdio.h>

#define N 100

int main()
{
  int a,i,j;
  int A[N][N] = {0};
  int s,t,u;
  
  scanf("%d", &a);
  
  for (i=0;i<a;i++){
    scanf("%d%d",&s,&t);
    for (j=0;j<t;j++) {
      scanf("%d",&u);
      A[s-1][u-1]=1;
    }
  }
  
  for (i=0;i<a;i++){
    for (j=0;j<a-1;j++){
      printf("%d ",A[i][j]);
    }
    printf("%d\n",A[i][j]);
  }

  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
const int64_t MAXN = 100010;
int64_t N, A, B;
vector<int64_t> H(MAXN);

bool ok(int64_t n)
{
  int64_t a = 0;
  for (int i = 0; i < N; i++)
  {
    if (B * n >= H[i])
      continue;
    a += ((H[i] - B * n) + (A - B - 1)) / (A - B);
  }
  return a <= n;
}

int main()
{
  int64_t mx = 0;
  cin >> N >> A >> B;
  for (int i = 0; i < N; i++)
  {
    cin >> H.at(i);
    mx = max(H.at(i), mx);
  }
  int64_t l = -1, r = (mx + (B - 1)) / B;
  while (r - l > 1)
  {
    int64_t m = (r + l) / 2;
    if (ok(m))
      r = m;
    else
      l = m;
  }
  cout << r << endl;
}


Measured memory_bytes: 3892
n = int(input())
a = sorted(list(map(int, input().split())))

import bisect
m = a[-1] / 2
b = bisect.bisect_left(a, m)
if abs(a[b]-m) < abs(a[b-1]-m):
  res = a[b]
else:
  res = a[b-1]

print(a[-1], res)

Measured memory_bytes: 14428
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

int main() {
  int n;
  cin >> n;
  vector<int> a(n), l(n + 1), r(n + 1);
  for (int& x : a) cin >> x;

  rep(i, 0, n) l[i + 1] = gcd(l[i], a[i]);
  rrep(i, 1, n) r[i - 1] = gcd(r[i], a[i]);

  int ans = 0;
  rep(i, 0, n) { ans = max(ans, gcd(l[i], r[i])); }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4564
//***Wherever you are, and whatever you do, be in love.***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[100002];
int main(){
    ll n,p=1,f=0;
    cin>>n;

    forn(i,n){
        cin>>a[i];
        if(a[i]==0) f=1;
    }
    if(f==1){
        cout<<"0";
        return 0;
    }
    forn(i,n){
        if((long double)a[i]>(long double)(1e18)/(long double)p){
            f=1;
            break;
        }
        p=p*a[i];
    }
    if(f==1) cout<<"-1";
    else
    cout<<p;
}

Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int>PII;
const double eps=1e-6;
const double pi=acos(-1.0);
const int mod=1e4+7;
const int inf=0x3f3f3f3f;
//ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll a[100010],d[100010];
int main(){
//    freopen("in.in","r",stdin);
//    freopen("out.out",";w",stdout);
    ll n;
    while(cin>>n){
        ll sum=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            sum+=a[i];
        }
        ll b=(1+n)*n/2;
        if(sum%b){
            puts("NO");
            continue;
        }
        sum/=b;
        for(int i=1;i<n;i++) d[i]=a[i]-a[i-1]-sum;
        d[0]=a[0]-a[n-1]-sum;
        ll f=1,cnt=0;
        for(int i=0;i<n&&f;i++){
            if(d[i]%n||d[i]>0) f=0;
            else cnt-=d[i]/n;
        }
        if(f&&cnt==sum) puts("YES");
        else puts("NO");
    }
    return 0;
}


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

using namespace std;
using ll = long long;

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

  int ma{};
  int len{};
  for (size_t i =0; i != S.size(); ++i) {
    switch(S[i]) {
      case 'A':
      case 'T':
      case 'G':
      case 'C':
        ++len;
        break;
      default:
        len = 0;
    }
    ma = max(ma,len);
  }

  cout << ma << endl;
  
  return 0;
}


Measured memory_bytes: 256