akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std; 
 
#define ll long long int
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define V vector<ll>
#define print2(x) cout <<"####"<< #x <<"  =>  "<<x<< endl
#define print1(x) cout <<"****"<< #x <<"  =>  "<<x<< endl
#define N 35005
#define M 55

int main()
{
	fast_io;
	ll e,a,q,h,s,d,ans,n;

	cin>>a;
	q=8*a;
	cin>>a;
	h=4*a;
	cin>>a;
	s=2*a;
	cin>>a;
	d=a;
	cin>>n;
	e=min(q,min(h,min(s,d)));
	ans=0;
	ans+=(n/2)*e;
	n=n%2;
	if(n!=0)
	{
		e=min(s/2,min(q/2,h/2));
		ans+=e;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
ans = 0
a.sort()
cnt = 1
#print(a)
for i in range(n-1):
    if a[i] == a[i+1]: cnt += 1
    else:
        if cnt >= a[i]: ans += cnt-a[i]
        else: ans += cnt
        cnt = 1
        #print(ans,cnt,i)
if cnt >= a[-1]: ans += cnt-a[-1]
else: ans += cnt
print(ans)

Measured memory_bytes: 14692
from sys import stdin
import sys
import itertools as it

A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
K = int(input())
if C > B and B > A:
    print("Yes")
    sys.exit()
for i in range(K+1):
    c1 = C*(2**i)
    b1 = B*(2**(K-i))
    if c1 > b1 and b1 > A:
        print("Yes")
        sys.exit()
print("No")


Measured memory_bytes: 9136
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

from itertools import product

N, M = mi()
ks = []
for i in range(M):
    a = li()
    ks.append(a)
P = li()

cnt = 0

#for i in range(2**N):
    #x = bin(i)[2:].zfill(N)
    #l = list(map(int, list(x)))
for l in product([0, 1], repeat=N):
    for i in range(M):
        num , *switchs = ks[i]
        if sum([l[sw-1] for sw in switchs]) % 2 != P[i]:
            break
    else:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll dg[MAXn][2],c[MAXn],u[MAXn];
vector<ll> v[MAXn];



int main()
{
    IOS();
    ll n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    REP1(i,n)c[i] = (s[i-1] == 'B');
    REP(i,m)
    {
      ll a,b;
      cin>>a>>b;
      v[a].pb(b);
      v[b].pb(a);
      dg[a][c[a]==c[b]]++;
      dg[b][c[a]==c[b]]++;
    }
    queue<ll> q;
    REP1(i,n)if(!min(dg[i][0],dg[i][1]))
    {
      u[i] = 1;
      q.push(i);
    }
    while(SZ(q))
    {
      ll t = q.front();q.pop();
      for(ll k:v[t])if(!u[k])
      {
        dg[k][c[t] == c[k]]--;
        if(!min(dg[k][0],dg[k][1]))
        {
          u[k] = 1;
          q.push(k);
        }
      }
    }
    REP1(i,n)if(!u[i])
    {
      cout<<"Yes"<<endl;
      return 0;
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 18896
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long y = sc.nextLong();
    int ans = 0;
    while (x <= y){
      x *= 2;
      ans += 1;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
using System;

namespace B_011_50
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            new Logic_A().Start();
        }

        public class Logic_A
        {
            public void Start()
            {
                var str = Console.ReadLine().Split(' ');
                var a = Convert.ToInt32(str[0]);
                var b = str[1];
                var c = Convert.ToInt32(str[2]);

                Console.WriteLine(b[0] == '+' ? a + c : b[0] == '-' ? a - c : 0);
            }
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<bitset>
#include<string>
#include<cmath>
#include<vector>
#include<tuple>
using namespace std;
//# Functions for Vector/Matrix
template <typename T>
vector<T> zeros(int length){
    vector<T> vec(length, 0);
    return vec;
}
template <typename T>
vector<vector<T>> zeros(tuple<int, int> dim){
    vector<vector<T>> mat(get<0>(dim), vector<T>(get<1>(dim), 0));
    return mat;
}
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define VARNAME(VariableName) # VariableName
template <typename T>
void show(vector<T> &vec){
    cerr << VARNAME(vec) << ": " << endl;
    for (auto value : vec) {
        cerr << value << " ";
    }
    cerr << endl;
}
template <typename T>
void show(vector<vector<T>> &mat){
    for (auto vec : mat) {
        show(vec);
    }
}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
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; }
bool iseven(int x){ return x % 2 == 0; }
bool isodd(int x){ return !iseven(x); }
int dist(int x, int y) { return abs(x - y);}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
int main(){
	// cin.tie(0);
   	// ios::sync_with_stdio(false);
    int A, B, C; cin >> A >> B >> C;
    dump(A); dump(B); dump(C);
    int max_count = B / A;
    dump(max_count);
    if(max_count < C) cout << max_count;
    else cout << C;
}



Measured memory_bytes: 384
def N():
    return int(input())


def L():
    return list(map(int, input().split()))


def NL(n):
    return [list(map(int, input().split())) for i in range(n)]

def isEven(num):
  if num%2==0:
    return True
  else:
    return False

n=N()

a=list(map(int, input().split()))
even=0
for number in a:
  if isEven(number):
    even +=1
odd=n-even
if odd%2==1:
  print("NO")
else:
  print("YES")


Measured memory_bytes: 20012
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);++i)
#define rep(i,n) REP(i, 0, n)
typedef long long int i64;
typedef pair<int, int> pint;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> L(N * 2);
    rep(i, N * 2) cin >> L[i];
    sort(L.begin(), L.end());
    int ans = 0;
    for(int i = 0; i < 2 * N; i += 2)
      ans += L[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int A, B;
    cin >> A >> B;

    if (A <= 5)
    {
        cout << 0 << endl;
    }
    else if (A >= 6 && A <= 12)
    {
        cout << B / 2 << endl;
    }
    else
    {
        cout << B << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define loop(i, sta, end, inc) for(int i = sta; i <= end; i += inc)
#define itr(it, l)             for(auto it = l.begin(); it != l.end(); it ++)
#define in(a, b, c)            assert( b <= a && a <= c)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define what_is(x) cerr<<#x<<" ="<<x<<" ";
#define error(args...)  { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define LINT_MAX  9223372036854775807
#define LINT_MIN -9223372036854775808
#define EPS 1e-9
#define MOD 1000000007
#define DEBUG 0
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#pragma GCC optimize ("Ofast")
#define endl '\n'
#endif

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
void err(istream_iterator<string> it) { cerr<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    if(DEBUG == 0)return;
	cerr << *it << " = " << a <<" ";
	err(++it, args...);
}
#define range 100010
int n,m;
vi graph[range];
priority_queue <int> gquiz; 
int main(){

	//freopen("input.txt","r",stdin);
	clock_t clk = clock();
    cin>>n>>m;
    forn(i,n){
    	int a,b;cin>>a>>b;
    	graph[a].pb(b);
    }
    ll ans =0;
    forn1(i,m){
    	forn(j,graph[i].size()){
    		gquiz.push(graph[i][j]);
    	}
    	if(gquiz.size()){
    		ans += gquiz.top();
    		gquiz.pop();
    	}
    }
    cout<<ans;
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}





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

int main() {
	// your code goes here
	long long n;
	cin>>n;
	bool flag = false;
	vector<long long> a(n);
	for(int i=0;i<n;i++) {
		cin>>a[i];
		if(a[i]==0)
			flag = true;
	}
	sort(a.begin(),a.end());
	long long prod = 1;
	long long maxp = 1e18;
	for(int i=0;i<n;i++) {
		if(flag) {
			prod = 0;
			break;
		} else if(maxp/prod < a[i]) {
			prod = -1;
			break;
		} else if(maxp/prod == a[i] && maxp%prod!=0) {
			prod = -1;
			break;
		} else {
			prod *= a[i];
		}
	}
	cout<<prod;
	return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

/*
choose integers from factors of gcd_ab
all of them ; disjoint
count correct combinations
*/

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

int main(void) {
	ll a, b;
	cin >> a >> b;
	ll gcd_ab;
	gcd_ab = gcd(a, b);

	ll count = 1;
	if (gcd_ab == 1) {
		cout << 1 << endl;
		return 0;
	}
	for (ll i = 2; i * i <= gcd_ab; i++) {
		if (gcd_ab % i == 0) {
			while (gcd_ab % i == 0)
				gcd_ab /= i;
			count++;
		}
	}
	if (gcd_ab != 1)
		count++;
	cout << count << endl;
	return 0;
}

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

int main(void) {
    int N, K;
    cin >> N >> K;
    double ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (i >= K) {
            ans += 1.0 / N;
        } else {
            int r     = 1;
            int point = i;
            while (point < K) {
                point *= 2;
                r *= 2;
            }
            ans += 1.0 / (N * r);
        }
    }
    printf("%.10f\n", ans);
    return 0;
}


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

int main()
{ 
    int ans[6][6]= {{-1, 3, 5, 2, 4, -1}, {4, -1, 1, 6, -1, 3},
                {2, 6, -1, -1, 1, 5}, {5, 1, -1, -1, 6, 2},
                {3, -1, 6, 1, -1, 4}, {-1,4,2,5,3,-1} };
    int dice[6];
    map<int, int> convertMap;
    
    for(int i = 0; i < 6; ++i) 
    { cin >> dice[i]; convertMap[dice[i]] = i; } 
    
    int c;  cin >> c;
    for(int i=0;i<c; ++i)
    {
        int a, b;cin >> a >> b;
        a = convertMap[a]; 
        b = convertMap[b];
        cout << dice[ans[a][b]-1] << endl;
    }
    return 0;  
} 


Measured memory_bytes: 3096
from typing import TypeVar, Generic, List, Deque

T = TypeVar('T')

class Queue(Generic[T]):
	def __init__(self) -> None:
		self._container: Deque[T] = Deque()

	@property
	def empty(self) -> bool:
		return not self._container # コンテナが空ならば真となる

	def push(self, item: T):
		self._container.append(item)

	def pop(self) -> T:
		return self._container.popleft() # FIFO

	def __repr__(self) -> str:
		return repr(self._container)


if __name__ == "__main__":
	a = list(map(int, input().split()))
	n = a[0]
	q = a[1]
	queue = Queue()
	for _ in range(n):
		b = list(input().split())
		queue.push([b[0], int(b[1])])
	time = 0
	while not queue.empty:
		item = queue.pop()
		if item[1] - q <= 0:
			time += item[1]
			print(f"{item[0]} {time}")
		else:
			item[1] -= q
			queue.push(item)
			time += q


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

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

Measured memory_bytes: 4304
K,N = map(int,input().split())
A = list(map(int,input().split()))

cumsum = [0]
for i in range(N):
  cumsum.append(A[i])
for i in range(N):
  cumsum.append(A[i]+K)

res = 10**14
for i in range(N, 2*N):
  res = min(res, cumsum[i]-cumsum[i-N+1])
print(res)

Measured memory_bytes: 94112
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;
ll gcd(ll x, ll y){
  if(y==0)return x;
  else return gcd(y,x%y);
}
int main() {
  int n;
  cin >> n;
  vector<int>a(n+1);
  vector<int>b(n+1);
  a[0]=0;
  b[0]=0;
  rep(i,n){
    int A;
    cin >> A;
    a[i+1]=a[i]+A;
  }
  rep(i,n){
    int B;
    cin >> B;
    b[i+1]=b[i]+B;
  }
  int ans=0;
  rep(i,n){
    ans=max(ans,a[i+1]-a[0]+b[n]-b[i]);
  }
  
  cout << ans << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    for(int i=0; i<N; ++i) {
        cin >> v[i];
    }
    int cnt4=0, cnt2not4=0, cntother=0;
    for(int i=0; i<N; ++i) {
        if(v[i]%4==0) cnt4++;
        else if(v[i]%4!=0 && v[i]%2==0) cnt2not4++;
    }
    cntother = N - (cnt4 + cnt2not4);

    if(cnt4 >= N/2) cout << "Yes" << endl;
    else if(cnt4 >= cntother-1) {
        if(cnt2not4%2==0) cout << "Yes" << endl;
        else if(cnt4 >= cntother) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 640
A,V=map(int, input().split())
B,W=map(int, input().split())
T=int(input())

if A==B:
    print('YES')
else:
    if V<=W:
        print('NO')
        exit()
    if abs(B-A) - ((V-W)*T) <= 0:
        print('YES')
    else:
        print('NO')






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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &x : a) cin >> x;
  cout << accumulate(begin(a), end(a), 0LL) - a.size() << endl;
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  long long int a[n],b[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  long long int c[n];
  for(int i=0;i<n;i++){
    c[i]=a[i]+b[i];
  }
  sort(c,c+n);
  long long int ans=0;
  for(int i=0;i<n;i++){
    ans=ans+a[i];
  }
  if(n%2==0){
    for(int i=0;i<n;i+=2){
      ans=ans-c[i];
    }
  }
  else{
    for(int i=1;i<n;i+=2){
      ans=ans-c[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
from collections import deque

N = int(input())
E = [[] for _ in range(N)]
for a, b in [[int(i) - 1 for i in input().split()] for _ in range(N - 1)]:
    E[a].append(b)
    E[b].append(a)
C = [int(i) for i in input().split()]
C.sort(reverse=True)

ans = [0] * N

def bfs(i):
    cur = 0
    Q = deque()
    Q.append(0)
    visited = [False] * N
    while Q:
        v = Q.popleft()
        visited[v] = True
        ans[v] = C[cur]
        cur += 1
        for e in E[v]:
            if visited[e]:
                continue
            Q.append(e)

bfs(0)
print(sum(C[1:]))
print(*ans)


Measured memory_bytes: 6792
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while ( left < right ) {
    mid = (left + right) / 2;
    if ( key == A[mid] ) return 1;
    if ( key > A[mid] ) left = mid + 1;
    else if ( key < A[mid] ) right = mid;
  }
  return 0;
}

int main() {
  int i, q, k, sum = 0;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ )
    scanf("%d", &A[i]);

  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &k);
    if ( binarySearch( k ) ) sum++;
  }
  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 2124
n, m = map(int, input().split())
a = list()
for i in range(n):
	a.append(list(map(int, input().split())))
b = list()
for i in range(m):
	b.append(int(input()))
for i in range(n):
	ans = 0
	for j in range(m):
		ans += a[i][j] * b[j]
	print(ans)


Measured memory_bytes: 5984
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	double a;
	double b;
	double c;
	double d;
	double e;
	double f;
	while(cin >> a
		>> b
		>> c
		>> d
		>> e
		>> f){
			double det = 1.0/(a*e-b*d);
			double x = det*(e*c-b*f);
			double y = det*(-d*c+a*f);
			if(x==0)x=0;
			if(y==0)y=0;
			printf("%.3f %.3f\n",x,y);
		}
	return 0;
	}

Measured memory_bytes: 1236
#include <stdio.h>

int main(void) {

  int n;
  scanf("%d", &n);
  int prime_list[100];
  for (int i = 2; i < 100; i++) {
    prime_list[i] = 1;
  }
  for (int i = 2; i < 100; i++) {
    if (prime_list[i] == 1) {
      for (int j = 2; i*j < 100; j++) {
        prime_list[i*j] = 0;
      }
    }
  }
  int factors[100];
  for (int i = 0; i < 100; i++) {
    factors[i] = 0;
  }
  int number;
  for (int i = 2; i <= n; i++) {
    number = i;
    for (int j = 2; j <= n; j++) {
      if (prime_list[j] == 1) {
        while (number%j == 0) {
          factors[j]++;
          number /= j;
        }
        if (number == 1) {
          break;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 2; i < 100; i++) {
    if (prime_list[i] == 1 && factors[i] >= 2) {
      for (int j = 2; j < 100; j++) {
        if (j != i && prime_list[j] == 1 && factors[j] >= 4) {
          for (int k = j+1; k < 100; k++) {
            if (k != i && prime_list[k] == 1 && factors[k] >= 4) {
              ans++;
            }
          }
        }
      }
    }
  }
  for (int i = 2; i < 100; i++) {
    if (prime_list[i] == 1 && factors[i] >= 2) {
      for (int j = 2; j < 100; j++) {
        if (j != i && prime_list[j] == 1 && factors[j] >= 24) {
          ans++;
        }
      }
    }
  }
  for (int i = 2; i < 100; i++) {
    if (prime_list[i] == 1 && factors[i] >= 4) {
      for (int j = 2; j < 100; j++) {
        if (j != i && prime_list[j] == 1 && factors[j] >= 14) {
          ans++;
        }
      }
    }
  }
  for (int i = 2; i < 100; i++) {
    if (prime_list[i] == 1 && factors[i] >= 74) {
      ans++;
    }
  }
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if ((i % 3 == 0) || (i/1000 ==3) || (i/100%10==3) || (i/10%10 ==3) ||(i%10==3)) cout <<" "<<i;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b)
	printf("a < b\n");
	else if(a>b)
	printf("a > b\n");
	else 
	printf("a == b\n");
	
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef deque<ll> di;
typedef pair<ll,ll> pi;
#define pb push_back
#define mp make_pair
#define mh make_heap
#define pf push_front
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define FOR(i,a,b) for(ll i=a;i<b;i++)



int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    ll a,b,c,d;
  	ll max1,min1,max2,min2;
  	cin>>a>>b>>c>>d;
  	max1=a*c;
  	if(max1<a*d)
        max1=a*d;
    if(max1<b*c)
        max1=b*c;
    if(max1<b*d)
        max1=b*d;
    cout<<max1<<endl;

    return 0;
}


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


int main(){
	int n,k;
	string s;
	cin >> n;
	cin >> s;
	cin >> k;
	for(int i=0;i<n;i++){
		if(s.at(i)!=s.at(k-1)){
			s.at(i)='*';
		}
	}
	cout << s << endl;
}


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

    public static void main(String[] args) { 
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer>[] arr = new ArrayList[m+1];
        
        for(int i = 1; i <= m; i++)
            arr[i] = new ArrayList<>();

        for(int i = 0; i < n; i++) {
          int day = sc.nextInt();
          int b = sc.nextInt();
          if(day > m) continue;
          arr[day].add(b);
        }
        
        PriorityQueue<Integer> pq = new PriorityQueue<>((a, b) -> b - a);
        long cnt = 0L;
        for(int i = 1; i <= m; i++) {
          for(int b : arr[i])
            pq.offer(b);
          cnt += pq.size() == 0 ? 0 : pq.poll();
        }
        System.out.println(cnt);
    }
  }  

Measured memory_bytes: 100756
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

template<typename T>
class CumulativeSum {
	vector<T> a;
	public:
	CumulativeSum(vector<T>& x) : a(x.size() + 1,0) {
		rep(i,x.size()){
			a[i + 1] = a[i] + x[i];
		}
	}
	T get(int l, int r){ // [l, r]の区間の合計を求める
		return a[r + 1] - a[l];
	}
	T operator [] (const int i) const {
		return a[i];
	}
};

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

	vector<long long> a(n);
	cin >> a;

	CumulativeSum<long long> sum(a);
	map<long long,long long> m;
	rep(i,n) m[ sum[i + 1] ]++;

	long long ans = 0;
	for(auto i : m){
		if(i.first == 0) ans += i.second;
		ans += i.second * (i.second - 1) / 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
int main()
{
   long long n,k,ans;
   int flag=0;
   scanf("%lld %lld",&n,&k);
   if(n>=k) n=n%k;
   ans=n;
   if(k-n<ans)
   ans=k-n;
   printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>){
    var (h,w,a,b) = readLine()!!.split(" ").map{it.toInt()}
    val mod = 1000000007L
    val c = combination(200010,mod)
    var ans = 0L
    for(i in b .. w){
        ans += c.calc(h - a - 1 + i, i) * c.calc(a - 1 + w - i - 1, w - i - 1) % mod
        ans %= mod
    }
    println(ans)
}

class combination{
    val n : Int
    val mod : Long
    val f : LongArray
    val rf : LongArray
    constructor(n : Int, m : Long){
        this.n = n
        this.mod = m
        this.f = LongArray(n + 1)
        this.rf = LongArray(n + 1)
        init()
    }

    fun inv(x : Long) : Long{
        var ret = 1L
        var k = mod - 2
        var y = x
        while(k > 0){
            if(k and 1L == 1L) ret = (ret * y) % mod
            y = (y * y) % mod
            k /= 2
        }
        return ret
    }

    fun init(){
        f[0] = 1
        for(i in 1 .. n) f[i] = (f[i - 1] * i) % mod
        for(i in 0 .. n) rf[i] = inv(f[i])
    }

    fun calc(n : Int, k : Int) : Long{
        if(n > this.n || n < 0 || k > this.n || k < 0 || n < k) return 0L
        val a = f[n]
        val b = rf[n - k]
        val c = rf[k]
        val bc = (b * c) % mod
        return (a * bc) % mod
    }
}

Measured memory_bytes: 40680
#include<stdio.h>
int main()
{
  int a,b,c,temp,swap;
  scanf("%d %d %d",&a,&b,&c);
  temp=a;
  a=b;
  b=temp;
  swap=a;
  a=c;
  c=swap;
  printf("%d %d %d",a,b,c);
  return 0;
}

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

int main(void) {
  string s;
  cin >> s;
  for (int i = 0; i < 4; i++) {
    int c = 0;
    for (int j = 0; j < 4; j++) {
      if (s[i] == s[j]) {
        c++;
      }
    }
    if (c != 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a, b=[0], [0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
ans, j=0, M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    ans=max(ans, i+j)
print(ans)

Measured memory_bytes: 134052
#include <stdio.h>

int main (void){
  int x , y , z , a , b , c ;
  scanf("%d %d %d",&x,&y,&z);
  a = x + y ;
  b = x + z ;
  c = y + z ;
  if(a <= b && a <= c)
    printf("%d ",a);
  else if(b <= a && b <= c)
    printf("%d ",b);
  else printf("%d",c);
  return 0 ;
}
  


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
pair<int,int> a[100005];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
       cin>>a[i].first;
       a[i].second=i;
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++){
        cout<<a[i].second<<" ";
    }
    
}  

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x) 
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define fo(i, a, b) for (int i = a; i <= b; ++i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    int a[m]; rep(i, m) cin >> a[i];

    if (n >= m) {
        cout << 0 << '\n';
        return 0;
    }
    sort(a, a+m);
    //for (int i = 0; i < m; ++i) cout << a[i] << ' '; cout << endl;
    int sum = a[m-1] - a[0];
    vector<int> v;
    for (int i = 1; i < m; ++i) v.push_back(a[i]-a[i-1]);
    sort(all(v));
    reverse(all(v));
    //cout << sum << endl;
    //for (auto x : v) cout << x << ' '; cout << endl;
    for (int i = 0; i < min(n-1, m); ++i) sum -= v[i];
    cout << sum << '\n';
}



Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define PI acos(-1.0)

typedef long long ll;
const int maxn=1e5+10;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int n;
    if(a<=c&&b>=d)
    {
        n=d-c;
    }
    else if(a>=c&&b<=d)
    {
        n=b-a;
    }
    else if(b<d)
    {
        n=b-c;
    }
    else
    {
        n=d-a;
    }
    if(n<0)
        n=0;
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    k = int(input())
    res = ""
    for _ in range(k):
        res += "ACL"
    print(res)

if __name__ == '__main__':
    resolve()


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

int cnt=0;

void bubbleSort(int *A, int N){
  bool flag=true;
  while(flag){
    flag=false;
    for(int i=N-1;i>0;i--){
      if(A[i]<A[i-1]){
        swap(A[i], A[i-1]);
        flag=true;
        cnt++;
      }
    }
  }
}

int main(){

  int n, a[110];

  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];

  bubbleSort(a, n);

  for(int i=0;i<n;i++){
    cout<<(i?" ":"");
    cout<<a[i];
  }
  cout<<endl<<cnt<<endl;

  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n;
	cin >> n;
	long long nyaw = 0;
	long long cp = n;
	while (cp != 0) {
		nyaw += cp % 10;
		cp /= 10;
	}
	if (n % nyaw == 0) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF =1e9+5;
int main()
{
   int n;
  cin>>n;
  int h[n];
  vector<int>dp(n,INF);
  dp[0]=0;
  for(int i=0;i<n;i++)
    cin>>h[i];
  for(int i=0;i<n;i++)
  {
    for(int j:{i+1,i+2})
    {
       if(j<n)
       {
         dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
       }
    }
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1024
<?php
    
    $N = intval(trim(fgets(STDIN)));
    
    $A = array_map('intval',explode(" ",trim(fgets(STDIN))));
    $B = array_map('intval',explode(" ",trim(fgets(STDIN))));

    $yojo_power=0;
    $enemy=0;
    for($i=0;$i<=$N;$i++){
        if($i!=$N){
            $power = $yojo_power+$B[$i];
            // echo $i." ".$enemy." ".$yojo_power."\n";
        }else{
            $power = $yojo_power;
            // echo $i." ".$enemy." ".$yojo_power."\n";
        }
        if(($power-$A[$i])>0){
            $yojo_power=($power-$A[$i]);;
            $enemy += $A[$i];
        }else{
            $yojo_power=0;
            $enemy += $power;
        }
        
        if($i!=$N){
            if($yojo_power>$B[$i]){
                $yojo_power=$B[$i];
            }
        }
    
    }
    echo $enemy;
    
    
?>

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

int main() {
    vector<int> A(3);
    cin >> A[0] >> A[1] >> A[2];

    sort(A.begin(), A.end());
    cout << A[2] * 10 + A[1] + A[0] << endl;

}

Measured memory_bytes: 3636
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<iterator>
#include<queue>
#include<algorithm>
#include<functional>

typedef long long ll;
typedef std::map<char, int> string_type;
typedef std::map<string_type, int> type_occurences;

struct abc_170_a {
	std::string run(std::vector<int> x) {
		const int n = 5;
		std::stringstream ss;
		for(int i = 0; i < n; ++i) {
			if(x[i] == 0) {
				ss << (i+1) << std::endl;
				return ss.str();
			}
		}
		return "0";
	}
};

int main(void) {
	abc_170_a solver;
	std::vector<int> x;
	int t;

	for(int i = 0; i < 5; ++i) {
		std::cin >> t;
		x.push_back(t);
	}

	std::cout << solver.run(x) << std::endl;

	return 0;
}


Measured memory_bytes: 3588
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll r;
            cin>>r;
            cout<<r*r<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

ll ecd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	else {
		return ecd(b, a % b);
	}
}

ll pow(ll a, ll b) {
	vector<ll> d = vector<ll>((ll)(log(b)) + 2);
	d[0] = a;
	rep(i, 1, d.size()) d[i] = d[i - 1] * d[i - 1];
	ll ret = 1;
	rep(i, 0, log(b) + 1) {
		if (b & 1 << i) ret *= d[i];
	}
	return ret;
}

//I
int main(void) {
	ll n;
	cin >> n;
	vector<vector<long double>> dp = vector<vector<long double>>(n, vector<long double>(n+1,0));
	vector<long double> p = vector<long double>(n);
	rep(i, 0, n) cin >> p[i];
	dp[0][0] = 1 - p[0];
	dp[0][1] = p[0];
	rep(i, 1, n){
		if (i > 0) dp[i][0] = dp[i - 1][0] * (1 - p[i]);
		rep(j, 1, i + 2) {
			dp[i][j] = dp[i-1][j - 1] * p[i] + dp[i-1][j] * (1 - p[i]);
		}
	}
	long double ans = 0;
	rep(i, n / 2 + 1, n + 1) {
		ans += dp[n-1][i];
	}
	cout << fixed << setprecision(10) << ans << endl;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n, a[2][101];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[0][i];
	for(int i = 0; i < n; i++) cin >> a[1][i];
	
	for(int i = n-2; i >= 0; i--){
		a[1][i] += a[1][i+1];
	}
	i64 ans = 0, cnt = 0;
	for(int i = 0; i < n; i++){
		cnt += a[0][i];
		chmax(ans, cnt+a[1][i]);
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    for (int i =0; i < N; i++){
        string s;
        cin >> s;
        if(s == "Y"){
            cout << "Four" << endl;
            break;
        }
        
        if(i == N-1){
            cout << "Three" << endl;
        }
    }
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int cycle_length,interview_num;
  while(~scanf("%d",&cycle_length)){
    if(cycle_length == 0) break;

    int cycle[100];
    map<int,vector<int> > interview;
    
    for(int i=0;i<cycle_length;i++){
      scanf("%d",cycle+i);
    }
    scanf("%d",&interview_num);
  
    int last_day = 0;
    for(int i=0;i<interview_num;i++){
      int day,start_hour;
      scanf("%d %d",&day,&start_hour);
      interview[day].push_back(start_hour);
      last_day = max(day,last_day);
    }

    //dp[day][cycle_idx] = min_cost
    int dp[101][100];
    memset(dp,0x3f,sizeof(dp));

    //init
    dp[1][0] = 0;

    for(int day=1;day<=last_day;day++){
      for(int cycle_idx=0;cycle_idx < cycle_length; cycle_idx++){
	int min_start_hour = INF;
	for(int hour_idx=0;hour_idx<interview[day].size();hour_idx++){
	  int start_hour = interview[day][hour_idx];
	  min_start_hour = min(min_start_hour,start_hour);
	}
	if(cycle[(cycle_idx+1)%cycle_length] <= min_start_hour){
	  dp[day][(cycle_idx+1)%cycle_length]
	    = min(dp[day-1][cycle_idx],dp[day][(cycle_idx+1)%cycle_length]);
	}
	dp[day][0] = min(dp[day-1][cycle_idx]+1,dp[day][0]);
      }
    }
  
    int min_v = INF;
    for(int i=0;i<cycle_length;i++){
      min_v = min(dp[last_day][i],min_v);
    }
    printf("%d\n",min_v);
  }
}

Measured memory_bytes: 1264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
   int A,B,C,X;
   cin>>A>>B>>C>>X;
   int ans=0;
   for(int i=0;i<=A;i++){
       for(int j=0;j<=B;j++){
           for(int k=0;k<=C;k++){
               if(500*i+100*j+50*k==X) ans++;
           }
       }
   }
   cout<<ans;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

int main(){
    int s;
    cin >> s;
    int l = s / 100;
    int r = s % 100;
    // cout << s << endl;
    // cout << l << endl;
    // cout << r << endl;
    bool flag1 = false, flag2 = false;
    if (0 < l && l <= 12) {
        flag1 = true;
    }
    if (0 < r && r <= 12) {
        flag2 = true;
    }
    if (flag1 && flag2) {
        cout << "AMBIGUOUS" << endl;
    }else if (flag1 && !flag2) {
        cout << "MMYY" << endl;
    }else if (!flag1 && flag2) {
        cout << "YYMM" << endl;
    }else if (!flag1 && !flag2) {
        cout << "NA" << endl;
    }
    
    
    
    
    
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm> 
using namespace std;
int a[1005],ans=1e9;
bool vis[1005];
int r,m,cc[1005],f[255][255];
inline int get()
{
	char c;
	int x=0,p=1;
	c=getchar();
	while (c<'0'||c>'9') {if (c=='-') p=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
	return x*p;
}
void hh()
{
	int tmp=0;
	for (int i=2;i<=r;i++)
	    tmp+=f[cc[i]][cc[i-1]];
	ans=min(ans,tmp);
}
void dfs(int step)
{
	if (step>r)
	{
		hh();
	    return ;
	}
	for (int i=1;i<=r;i++)
	if (!vis[a[i]]) 
	{
		cc[step]=a[i];
		vis[a[i]]=1;
		dfs(step+1);
		vis[a[i]]=0;
	}
}
int main()
{
	int n,x,y,z;
	memset(f,127/3,sizeof(f));
	scanf("%d%d%d",&n,&m,&r);
	for (int i=1;i<=r;i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		if (f[x][y]!=0)
			f[x][y]=f[y][x]=min(f[x][y],z);
		else f[x][y]=f[y][x]=z;
	}
	for (int k=1;k<=n;k++)
	for (int i=1;i<=n;i++)
	    for (int j=1;j<=n;j++)
	        		f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	dfs(1);
	printf("%d",ans);
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll x;

ll solve() {
    ll v = 0, i = 1;
    while (v < x) {
        v += i;
        i++;
    }
    return i-1;
}

void input() {
    cin >> x;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back((a))

using namespace std;
 
typedef long long lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;
typedef pair<lld, int> pli;
typedef pair<int, lld> pil;
typedef vector<vector<int>> Matrix;
typedef vector<vector<int>> Adj;
typedef vector<int> Row;
 
const int MOD = 1e9 + 7;
const int INF = 1e9;
const lld LINF = 1e18;
const double PI = 2.0 * acos(0.0);

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  int ans = s.size();
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'T') {
      if (cnt > 0) {
        --cnt;
        ans-=2;
      }
    } else {
      ++cnt;
    }
  }
  cout << ans << endl;
}



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


int main(){
  string x;
  cin >> x;
  int cnt = 0;
  for(int i=0;i<x.size();++i){
    if(x[i] == 'T' && cnt){
      cnt -= 1;
    }else if(x[i] == 'S'){
      cnt += 1;
    }
  }
  cout << 2 * cnt << endl;
}


Measured memory_bytes: 3692
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

//Sort the Panels
public class Main{

	int[][] dist;
	int n, M = 20, INF = 1<<29, S, G;
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt();
			if(n==0)break;
			char[] t1 = sc.next().toCharArray(), t2 = sc.next().toCharArray();
			S = 0; G = 0;
			for(int i=0;i<n;i++){
				S+=t1[i]=='W'?1<<i:0; G+=t2[i]=='W'?1<<i:0;
			}
			dist = new int[1<<n][n];
			for(int[]a:dist)Arrays.fill(a, INF);
			PriorityQueue<Integer> q = new PriorityQueue<Integer>(n, new Comparator<Integer>() {
				public int compare(Integer o1, Integer o2) {
					return dist[o1/M][o1%M]-dist[o2/M][o2%M];
				}
			});
			for(int i=0;i<n;i++){
				dist[S][i] = 0; q.add(S*M+i);
			}
			while(!q.isEmpty()){
				int V = q.poll();
				int s = V/M, p = V%M;
				if(s==G){
					System.out.println(dist[s][p]); break;
				}
				for(int a=0;a<n;a++){
					int pa = s&(1<<a);
					if(pa==(G&(1<<a)))continue;
					for(int b=0;b<n;b++){
						if(a==b||(s&(1<<b))==(G&(1<<b)))continue;
						int w = dist[s][p]+Math.abs(p-a)+Math.abs(a-b);
						int pb = s&(1<<b), ns = s;
						if(pa>0)ns|=1<<b;
						else ns&=~(1<<b);
						if(pb>0)ns|=1<<a;
						else ns&=~(1<<a);
						if(w<dist[ns][b]){
							dist[ns][b] = w; q.add(ns*M+b);
						}
					}
				}
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	long long a[10000], x, y, n, c;
	c = 0;
	while (1) {
		cin >> n;
		if (n == 0) { break; }
		for (int k = 0; k < n; k++) {
			cin >> a[k];
		}
		sort(a,a+n);
		/*for (int j = 0; j < n; j++) {
			for (int i = 0; i < n -1; i++) {
				if (a[i] > a[i + 1]) {
					x = a[i];
					y = a[i + 1];
					a[i] = y;
					a[i + 1] = x;
				}
			}
		}*/
		for (int k = 0; k < n; k++) {
			c = c + a[k] * (n - (k + 1));
		}
		//cout << a[0] << a[1] << a[2] << a[3] << a[4] << endl;
		cout << c << endl;
		c = 0;
	}
	return 0;
}

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

int main()
{
	int n, x;
	std::cin >> n >> x;
	
	std::vector<int> l(n, 0);
	for (int i = 0; i < n; i++)
	{
		std::cin >> l[i];
	}
	int ans=1;
	int c = 0;
	int buf = 0;
	for(int i=0;i<n;i++)
	{
		buf += l[i];
      	if(buf<=x)ans++;
	}
	std::cout << ans << '\n';
	
	return 0;
} 


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

using namespace std;

#define N 500005

int a, b, c, n, X, Y;

long long ans = 0;

struct point
{
	int v, id;

	bool operator < (const point &o) const
	{
		return v > o.v;
	}
}p[N];

int main()
{
	ios::sync_with_stdio(false);
	cin >> X >> Y >> a >> b >> c;
	n = a + b + c;
	for(int i = 1; i <= n; i++)
	{
		cin >> p[i].v;
		if(i <= a) p[i].id = 1;
		else if(i <= a + b) p[i].id = 2;
		else p[i].id = 3; 
	}
	sort(p + 1, p + n + 1);
	int x = 0, y = 0, cnt = 0;
	for(int i = 1; i <= n; i++)
	{
		if(p[i].id == 1)
		{
			if(x == X) continue;
			else x++;
		}
		else if(p[i].id == 2)
		{
			if(y == Y) continue;
			else y++;
		}
		ans += 1ll * p[i].v;
		cnt++;
		if(cnt == X + Y) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int a;
	string s;

	cin>>a;
	cin>>s;
	if(a>=3200)cout<<s<<endl;
	else cout<<"red"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int gcd(int a,int b){
    int r = 1;
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main(){
    int k;
    scanf("%d",&k);

    int ans = 0;

    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                ans += gcd(a,gcd(b,c));
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1732