akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,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;}

int main(){
  string S;
  cin>>S;
  
  if(S=="zyxwvutsrqponmlkjihgfedcba"){
    co(-1);
    return 0;
  }
  
  int A[26];
  char L='a';
  REP(i,26) A[i]=0;
  REP(i,S.size()){
    if(A[S.at(i)-'a']>0){
      L=S.at(i);
      S.erase(i);
      break;
    }
    A[S.at(i)-'a']++;
  }
  if(S.size()<26){
    REP(i,26){
      if(A[i]==0 && 'a'+i>=L){
        S+='a'+i;
        break;
      }
    }
  }
  else{
    char T=S.at(S.size()-1);
    A[T-'a']--;
    for(int i=24; i>=0; --i){
      if(T>S.at(i)){
        T=S.at(i);
        S.erase(i);
        break;
      }
      else{
        T=S.at(i);
        A[T-'a']--;
      }
    }
    REP(i,26){
      if(A[i]==0 && 'a'+i>=T){
        S+='a'+i;
        break;
      }
    }
  }
  
  co(S);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main() {
	int N, M; cin >> N >> M;
	vector<pair<int, int> > A(N);

	for(int i = 0; i < N; i++) {
		cin >> A[i].first;
		A[i].second = 0;
	}

	for(int i = 0; i < M; i++) {
		int tmp; cin >> tmp;
		for(int j = 0; j < N; j++) {
			if(A[j].first <= tmp) {
				A[j].second += 1;
				break;
			}
		}
	}

	int max = 0;
	int res = 0;

	for(int i = 0; i < N; i++) {
		if(max < A[i].second) {
			max = A[i].second;
			res = i;
		}
	}
	cout << res + 1 << endl;

	return 0;
}

Measured memory_bytes: 1200
def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    else:
        return gcd(b % a, a)

try:
    while 1:
        a,b = list(map(int,input().split()))
        c = gcd(a, b)
        print('{} {}'.format(c,int(c * (a/c) * (b/c))))

except Exception:
    pass

Measured memory_bytes: 7668
# ABC065 B - Trained?
N = int(input())
# A = [[int(input()),int(i+1),False] for i in range(N)]
A = [[int(input()),False] for i in range(N)]
idx = 0
A[0][1] == True
cnt = 1

while cnt != 2*N:
    if A[idx][1]:
        print(-1)
        exit()
    if A[idx][0] == 2:
        print(cnt)
        exit()
    A[idx][1] = True
    idx = A[idx][0]-1
    cnt += 1

Measured memory_bytes: 16372
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [a,b,c,d] = next().split("").map(el => Number(el))
    if(a + b + c + d == 7 ) console.log(`${a}+${b}+${c}+${d}=7`)
    else if(a + b + c - d == 7 ) console.log(`${a}+${b}+${c}-${d}=7`)
    else if(a + b - c + d == 7 ) console.log(`${a}+${b}-${c}+${d}=7`)
    else if(a - b + c + d == 7 ) console.log(`${a}-${b}+${c}+${d}=7`)
    else if(a + b - c - d == 7 ) console.log(`${a}+${b}-${c}-${d}=7`)
    else if(a - b - c + d == 7 ) console.log(`${a}-${b}-${c}+${d}=7`)
    else if(a - b + c - d == 7 ) console.log(`${a}-${b}+${c}-${d}=7`)
    else if(a - b - c - d == 7 ) console.log(`${a}-${b}-${c}-${d}=7`)
    

}
Main()



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

int main() {
  long long N;
  cin >> N;
  long long A[N+10];
  long long B[N+10];
  for (long long i = 0; i < N+1; i++) {
    cin >> A[i];
  }
  for (long long i = 0; i < N; i++) {
    cin >> B[i];
  }
  long long sum = 0;
  for (long long i = 0; i < N ; i++) {
    sum += min(A[i],B[i]);
    if (A[i] < B[i]) {
      if (A[i + 1] > (B[i] - A[i])){
         sum += B[i] - A[i];
         A[i+1] = A[i+1] - (B[i] - A[i]);
      }
      else {
        sum += A[i+1];
        A[i + 1] = 0;
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  string u[10];
  double x[10],sum;
  
  cin >> n;
  
  for(int i=0;i<n;i++){
    cin >> x[i] >> u[i];
    if(u[i]=="BTC") sum = sum + x[i] * (double)380000;
    else sum = sum + x[i];
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  ll n, m, k;
  cin >> n >> m >> k;
  vecll a(n, 0);
  vecll b(m, 0);
  REPe(e, a) cin >> e;
  REPe(e, b) cin >> e;
  vecll suma(n, 0);
  vecll sumb(m, 0);
  suma[0] = a[0];
  sumb[0] = b[0];
  REP(i, n - 1) suma[i + 1] = suma[i] + a[i + 1];
  REP(i, m - 1) sumb[i + 1] = sumb[i] + b[i + 1];
  auto itr1 = upper_bound(all(sumb), k);
  ll ans = itr1 - sumb.begin();
  REP(i, n) {
    ll tota = suma[i];
    ll totb = k - tota;
    if (totb < 0) continue;
    auto itr = upper_bound(all(sumb), totb);
    if (itr == sumb.begin()) {
      ans = max(ans, (ll)i + 1LL);
      continue;
    }
    // cout << tota << " " << totb << " " << *itr << " " << itr - sumb.begin()
    //  << endl;
    ans = max(ans, (ll)i + 1LL + (ll)(itr - sumb.begin()));
//    cout << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 9524
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

int main(){
    int R, G;
    cin >> R;
    cin >> G;
    cout << 2 * G - R << endl;
    return 0;
}


Measured memory_bytes: 384
N,y = [int(x) for x in input().split()]
y = y // 1000
for i in range(y//5+1):
  nokori = i*5
  kosuu = y - i*5
  if kosuu > N:
    continue
  if kosuu == N and nokori == 0:
    print("0 0 " + str(y-i*5))
    exit()
  for j in range(nokori//10+1): 
    if kosuu + j + (nokori-10*j)//5 == N:
      print(str(j)+" "+str((nokori-10*j)//5)+" "+str(y-i*5))
      exit()
print("-1 -1 -1")

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

int main(){
  int n,k; cin>>n>>k;
  int x[n];
  int a=0;
  for(int i=0;i<n;i++){
    cin>>x[i];
    if(x[i]<k-x[i]){
      a+=2*x[i];
    }else{
      a+=2*(k-x[i]);
    }
  }
  cout<<a<<endl;
}


Measured memory_bytes: 256
program main
  implicit none
  integer :: i, idx, num, first=10, time(5), total = 0

  do i = 1, 5
    read *, time(i)
    num = mod(time(i), 10)
    if ((num > 0) .and. (num < first)) then
      first = num
      idx = i
    end if
  end do

  do i = 1, 5
    if (i == idx) cycle
    total = total + time(i) 
    if (mod(time(i), 10) /= 0) then
      total = total - mod(time(i), 10) + 10
    end if
  end do

  if (first < 10) then
    total = total + time(idx)
  end if

  print '(i0)', total

end program

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <utility>

using ll = long long;
using namespace std;

int main() {
  ll a, b, c;
  cin >> a, cin >> b, cin >> c;

  for (ll i = 1; i <= b; i++) {
    if (c == i * a % b) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
  
  return 0;
}

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

const int MAX_N = 10002;

int N, P;
string S;

void solve()
{
	if(P==2 || P==5){
		ll ans = 0;
		for(int i=0;i<N;++i){
			int c=S[i]-'0';
			if(c%P==0) ans+=i+1;
		}
		cout << ans << '\n';
	}else{
		vector<int> d(N+1);
		int ten=1;
		for(int i=N-1;i>=0;--i){
			int c=(S[i]-'0')*ten%P;
			d[i]=(c+d[i+1])%P;
			(ten*=10)%=P;
		}
		ll ans = 0;
		vector<int> cnt(P);
		for(int i=N;i>=0;--i){
			ans+=cnt[d[i]];
			cnt[d[i]]++;
		}
		cout << ans << '\n';
	}
}

/* TLE
ll dp[2][MAX_N];

void solve()
{
	ll ans = 0;
	dp[0][0]=1;
	for(int i=0;i<N;++i){
		int pr=i%2,cur=(i+1)%2;
		memset(dp[cur],0,sizeof(dp[cur]));
		int rem = (s[i]-'0')%P;
		dp[cur][rem]+=1;
		if(!rem) ans++;
		for(int j=0;j<P;++j)if(dp[pr][j]){
			int nrem = (j*10+(s[i]-'0'))%P;
			dp[cur][nrem]+=dp[pr][j];
			if(!nrem)ans+=dp[pr][j];
		}
		for(int j=0;j<P;++j)dp[pr][j]=dp[cur][j];
	}
	cout << ans << '\n';
}
*/

int main()
{
	cin >> N >> P;
	cin >> S;
	solve();
	return 0;
}

Measured memory_bytes: 1412
k, n = map(int, input().split())
a = list(map(int, input().split()))

dis_max = 0
for i in range(n):
    if i == n - 1:
        dis = abs(k - a[i] + a[0])
    else:
        dis = abs(a[i] - a[i + 1])
    if dis > dis_max:
        dis_max = dis

print(int(k - dis_max))

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

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

    string a; cin >> a;
    
    if (s == a) {
        cout << n-1 << ' ' << m << endl;
        return 0;
    } else {
        cout << n << ' ' << m-1 << endl;
        return 0;
    }

    return 0;
}

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

bool is_palindrome(string s) {
  string t(s.rbegin(), s.rend());
  return s == t;
}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if (is_palindrome(s) && is_palindrome(s.substr(0, (n - 1) / 2)) &&
      is_palindrome(s.substr((n + 1) / 2)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char[] S = sc.next().toCharArray();
		char[] T = sc.next().toCharArray();
		int sl = S.length;
		int tl = T.length;
		int ans = tl;
		for(int i=0; i+tl<=sl; i++) {
			int match = 0;
			for(int j=0; j<tl; j++) {
				if(S[i+j]==T[j])
					match++;
			}
			ans = Math.min(ans, tl-match);
		}
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 27052
#include<iostream>
using namespace std;
const int e[] = { 1867,1911,1925,1988 };
const char c[] = { 'M','T','S','H' };
int main() {
	int mode, y; cin >> mode >> y;
	if (mode == 0) {
		for (int i = 3; i >= 0; i--) {
			if (y > e[i]) {
				cout << c[i] << y - e[i] << endl;
				goto end;
			}
		}
	}
	else cout << y + e[mode - 1] << endl;
end:;
}

Measured memory_bytes: 3088
//#pragma comment(linker, "/STACK:102400000,102400000")
//#include <initializer_list>
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define slla(n) scanf("%lld", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); repp(i,1,___T)

const int dx44[5] = { 0,-1,-1,1,1 };
const int dy44[5] = { 0,-1,1,-1,1 };

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 1e5 + 50;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

void solve()
{
    ll x,y;
    cin>>x>>y;
    int ans = 0;
    while(x<=y)
    {
        x=x*2;
        ans++;
    }
    cout<<ans;
}

int main()
{

    solve();
    // system("pause");
    return 0;
}

Measured memory_bytes: 256
K,T = map(int,input().split())
A = sorted(list(map(int,input().split())))
a = A.pop()
for i in range(1,T):
    a = abs(a-A.pop())
    A = sorted(A)
if a==0:
    cnt = a
else:
    cnt = a-1
print(cnt)

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

int main(){
    int N;
    int H_list[100];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> H_list[i];   
    }
    int cnt = 0;
    for(int i=0;i<N;i++){
        bool flg = true;
        for(int j=0;j<=i-1;j++){
            if(H_list[j] > H_list[i]){
                flg = false;
                break;
            }
        }
        if(flg){
            cnt++;
        }
    }
    cout << cnt;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
get_string(String) :-
  current_input(Input),
  read_string(Input, ' \n', '', _, String).
 
get_number(Number) :-
  get_string(String),
  number_string(Number, String).

comp([],[_]).
comp([H1|S],[H1|T]) :- comp(S,T).
    
main :-
  get_string(S),
  get_string(T),
  string_chars(S,L1),
  string_chars(T,L2),
  (comp(L1,L2) -> writeln('Yes');writeln('No')).

Measured memory_bytes: 8020
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <queue>
#define pb push_back
#define mp make_pair
using namespace std;

typedef pair<int,int> pii;
const int MAX=100005;

struct UFS
{
	int fa[MAX];
	
	UFS()
	{
		for(int i=0;i<MAX;i++)
			fa[i]=i;
	}
	
	inline int Find(int a)
	{
		if(fa[a]!=a)
			return fa[a]=Find(fa[a]);
		return a;
	}
	
	inline void Union(int a,int b)//Add Edge a->b
	{
		a=Find(a);
		b=Find(b);
		if(a!=b)
			fa[a]=b;
	}
}rowl,rowr,coll,colr;

int n;
int x[MAX],y[MAX];

vector<pii> row,col;
int xp[MAX],yp[MAX];

priority_queue<pii> Q;
bool vis[MAX];

inline void Update(int cur)
{
	int p;
	int left,right;
	
	p=xp[cur];
	left=rowl.Find(p-1),right=rowr.Find(p+1);
	if(left>=1)
	{
//		printf("Case 1:%d %d\n",p,left);
		rowl.Union(p,left);
		Q.push(mp(-row[p].first+row[left].first,row[left].second));
	}
	if(right<=n)
	{
//		printf("Case 2: %d %d\n",p,right);
		rowr.Union(p,right);
		Q.push(mp(-row[right].first+row[p].first,row[right].second));
	}
	
	p=yp[cur];
	left=coll.Find(p-1),right=colr.Find(p+1);
	if(left>=1)
	{
//		printf("Case 3: %d %d\n",p,left);
		coll.Union(p,left);
		Q.push(mp(-col[p].first+col[left].first,col[left].second));
	}
	if(right<=n)
	{
//		printf("Case 4: %d %d\n",p,right);
		colr.Union(p,right);
		Q.push(mp(-col[right].first+col[p].first,col[right].second));
	}
}

int main()
{
//	freopen("input.txt","r",stdin);
	
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
		row.pb(mp(x[i],i));
		col.pb(mp(y[i],i));
	}
	
	row.pb(mp(-1,0));
	col.pb(mp(-1,0));
	sort(row.begin(),row.end());
	sort(col.begin(),col.end());
	for(int i=1;i<=n;i++)
	{
		xp[row[i].second]=i;
		yp[col[i].second]=i;
	}
	
/*	for(int i=1;i<=n;i++)
		printf("%d(%d) ",row[i].first,row[i].second);
	printf("\n");
	for(int i=1;i<=n;i++)
		printf("%d(%d) ",col[i].first,col[i].second);
	printf("\n");*/
	
	long long ans=0;
	Q.push(mp(0,1));
	while(!Q.empty())
	{
		int cur=Q.top().second,cost=-Q.top().first;
		Q.pop();
		
		if(vis[cur])
			continue;
//		printf("cost=%d cur=%d\n",cost,cur);
		vis[cur]=true;
		ans=ans+cost;
		
		Update(cur);
	}
	
	printf("%I64d\n",ans);
	return 0;
}

Measured memory_bytes: 11112
def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = "APPROVED"
    for ai in A:
        if ai%2 == 0:
            if ai%3 > 0 and ai%5 > 0:
                ans = "DENIED"
                break
    print(ans)

    return

if __name__ == "__main__":
    main()

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

int main() {
  string S, T, U; cin >> S >> T;
  int A, B; cin >> A >> B;
  cin >> U;
  if(S == U) {
    cout << A-1 << " " << B << endl;
  } else if(T == U) {
    cout << A << " " << B-1 << endl;
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
typedef long long ll;
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 main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    s += s;
    vector<int> v[26];
    rep(i, 2*n) v[s[i]-'a'].pb(i);
    /*
    rep(i, 26) {
        rep(j, v[i].size()) {
            cout << i << "  " << v[i][j] << ' ';
        }
        cout << endl;
    }*/
    
    int idx = -1;
    ll ans = 0;
    rep(i, t.size()) {
        if (v[t[i]-'a'].empty()) {
            cout << -1 << "\n";
            return 0;
        }
        int nxt = *upper_bound(all(v[t[i]-'a']), idx);
        if (nxt >= n) {
            ans += n;
            nxt -= n;
        }
        idx = nxt;
    }
    ans += idx;
    cout << ans + 1 << "\n";
    return 0;
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;

int main()	
{
	#ifdef SANS
		freopen("C:\\Users\\ASUS\\Documents\\Sublime\\input_output\\inputf.txt","r",stdin);
		freopen("C:\\Users\\ASUS\\Documents\\Sublime\\input_output\\outputf.txt","w",stdout);
	#endif
	fast
	int t=1;
	// cin>>t;
	while(t--)
	{
		string s1, s2;
		cin>>s1>>s2;
		s2=s2.substr(0,s2.length()-1);
		// cout<<s2;
		if(s1==s2)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	#ifdef SANS
		cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
	#endif
}

Measured memory_bytes: 3652
s = input()
fir = int(s[:2])
sec = int(s[2:])

if (0 < fir <= 12 and 0 < sec <= 12):
  print('AMBIGUOUS')
elif ((fir == 0 or fir > 12)  and 0 < sec <= 12):
  print('YYMM')
elif (0 < fir <= 12 and (sec == 0 or sec > 12)):
  print('MMYY')
else:
  print('NA')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
template <typename T> string to_string(const vector<T> &xs) {string s="["; for(int i=0;i<xs.size();i++) s += (i>0 ? " " : "") + to_string(xs[i]); return s + "]";}



ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}






int main(void){
	int n; cin >> n;
	string s; cin >> s;
	cout << ((n%2==0 && s.substr(0, n/2) == s.substr(n/2, n/2)) ? "Yes" : "No") << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A,B,C;
    cin>>A>>B>>C;
    int a=1,b=0,c=0;
    char turn = A[0];
    while(a<=A.size() && b<=B.size() && c<=C.size()){
        if(turn == 'a'){
            turn = A[a];
            a++;
        }
        else if(turn == 'b'){
            turn = B[b];
            b++;
        }
        else{
            turn = C[c];
            c++;
        }
    }
    if(a>A.size()) cout<<'A';
    else if(b>B.size()) cout<<'B';
    else cout<<'C';
    cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x) 
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
int F[105];
int main()
{
    int n = read<int>(),p,ans = INF,sum = 0;
    for(int i = 0; i < n; i++) F[i] = read<int>();

    for(int j = 1; j <= 100; j++)
    {
        for(int i = 0; i < n ; i++)
        {
            sum += (F[i] - j)*(F[i] - j);
        }
        ans = min(ans,sum);
        sum = 0;
    }
    write(ans);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		long k = fs.nextLong();
		
		int[] teleArr = new int[n];
		for(int i = 0 ; i < n; i++) {
			teleArr[i] = fs.nextInt() - 1;
		}
		
		int[] spaceArr = new int[n];
		
		int nowIndex = 0;
		spaceArr[0]++;
		
		ArrayList<Integer> pathList = new ArrayList<>();
		while(spaceArr[nowIndex] < 2) {
			pathList.add(nowIndex);
			int nextTown = teleArr[nowIndex];
			spaceArr[nextTown]++;
			nowIndex = nextTown;
//			System.out.println(Arrays.toString(spaceArr));
		}
		
//		System.out.println(pathList);
		
		if((long)pathList.size() >= k+1) {
			System.out.println(pathList.get((int)k)+1);
			return;
		}
		
		int loopStart = nowIndex;
		int loopStartDistance = 0;
		
		for(int i = 0; i < pathList.size(); i++) {
			if(pathList.get(i) == loopStart) {
				break;
			}
			loopStartDistance++;
		}
		
		int nonLoop = loopStartDistance;
		int loop = pathList.size() - loopStartDistance;
		
//		System.out.println(nonLoop);
//		System.out.println(loop);
		
		int destination = (int) ((k - (long)nonLoop) % (long)loop);
		System.out.println(pathList.get(destination + nonLoop)+1);
		
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

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

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

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

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


}


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

int main() {
  int n; cin >> n;
  int res = 0;

  for(int i = 1; i <= n; i++) {
    int cnt = 0;
    if(i%2 != 0) {
      for(int j = 1; j <= i; j++) {
        if(i%j == 0) cnt++;
      }
      if(cnt == 8) res++;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5 + 10;

int N, M;
vector<int> g[MAX];
int ans[MAX], vis[MAX];
queue<int> q;

bool bfs() {
    q.push(1); vis[1] = 1;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (auto &v: g[u])
            if (!vis[v]) {
                ans[v] = u;
                q.push(v); vis[v] = 1;
            }
    }
    for (int i = 1; i <= N; i++)
        if (!vis[i]) return false;
    return true;
}

int main() {
#ifdef ACM_LOCAL
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
#endif
    scanf("%d%d", &N, &M);
    for (int i = 1; i <= M; i++) {
        int u, v; scanf("%d%d", &u, &v);
        g[u].push_back(v), g[v].push_back(u);
    }
    if (bfs()) {
        printf("Yes\n");
        for (int i = 2; i <= N; i++)
            printf("%d\n", ans[i]);
    }
    else printf("No\n");



    return 0;
}


Measured memory_bytes: 11032
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 100005
#define trace(x) cout<<#x<<" = "<<x<<'\n'
#define trace2(x, y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<'\n'
#define trace3(x, y, z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<" "<<#z<<" = "<<z<<'\n'
#define sz(x) (int)(x).size()
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};
int TC, N, M, K, Q, x, y, z;
long long mod(long long n) { return (n%MOD + MOD)%MOD; }
long long kali(long long a, long long b, long long c = 1, long long d = 1) { return mod(mod(a*b)*mod(c*d)); }

long long arr[MAXN], ps[MAXN];

bool bisa(int pos) {
	long long now = ps[pos];
	while (1) {
		int target = upper_bound(arr+1, arr+N+1, 2*now)-arr-1;
		if (target == N) return 1;
		if (ps[target] == now) return 0;
		now = ps[target];
	}
	return 0;
}

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) scanf("%lld", &arr[i]);
	sort(arr+1, arr+N+1);
	ps[0] = 0;
	for (int i = 1; i <= N; i++) ps[i] = ps[i-1]+arr[i];
	
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (bisa(i)) ans++;
	}
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;

int main() {
	string S;
	cin >> S;
	int budget = 700;
	for (int i = 0;i < 3;++i) {
		if (S[i] == 'o') {
			budget += 100;
		}
	}
	cout << budget << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int Q;
	cin >> Q;
	set<lint>S;
	lint a, x;
	rep(i, Q) {
		cin >> a >> x;
		if (a == 0) {
			S.insert(x);
			cout << S.size() << endl;
		}
		else if (a == 1) {
			cout << S.count(x) << endl;
		}
	}
}




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

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

using namespace std;

typedef pair<int,int> ii;

struct Data{
  int id,stamp;
  bool operator < ( const Data& data ) const {
    if( stamp != data.stamp ) return stamp > data.stamp;
    return id > data.id;
  }
};

vector<ii> cycle[110];
int n,m,run_time[110],indices[110],charger,charge_id;
bool inQueue[110];

//char debug[110][1000000];

int simulate(){

  //rep(i,110) rep(j,1000000) debug[i][j] = '?';

  rep(i,n) run_time[i] = cycle[i][0].first, indices[i] = 0, inQueue[i] = false;
  charger = 0, charge_id = -1;
  priority_queue<Data> Q;
  int ret = 0;
  rep(_,m){

    rep(i,n) {
      if( run_time[i] <= 0 && !inQueue[i] ) {
        Q.push((Data){i,_});
        inQueue[i] = true;
      }
      run_time[i]--;
    }

    if( charger == 0 && !Q.empty() ) {
      charge_id = Q.top().id; Q.pop();
      charger = cycle[charge_id][indices[charge_id]].second;
    } 

   if( charger ) {
      --charger;
      if( charger <= 0 ) {
        inQueue[charge_id] = false;
        ( indices[charge_id] += 1 ) %= (int)cycle[charge_id].size();
        run_time[charge_id] = cycle[charge_id][indices[charge_id]].first;
        charge_id = -1;
      }
    } 

   /*
    rep(i,n) if( inQueue[i] ) {
      debug[i][_] = '-';
      if( i == charge_id ) debug[i][_] = '.';
    } else debug[i][_] = '*';
   */

    ret += (int)Q.size();

  }
  /*
  rep(i,n){
    rep(j,m){
      cout << debug[i][j];
    }
    cout << endl;
  }
  */

  return ret;
}

int main(){
  while( cin >> n >> m, n | m ){
    rep(i,n) {
      int a,b;
      cycle[i].clear();
      while( cin >> a , a ){
        cin >> b;
        cycle[i].push_back(ii(a,b));
      }
    }

    cout << simulate() << endl;

  }
  return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 

const ll large_P = 1e9 + 7;


int main(){
  ll K, N;
  cin >> K >> N;
  
  vector<ll> A(N);
  rep(i, N) cin >> A.at(i);
  
  vector<ll> dis(N);
  for(int i=1; i<=N-1; i++) dis.at(i) = abs(A.at(i) - A.at(i-1));
  dis.at(0) = A.at(0) + K - A.at(N-1);
  
  sort(dis.begin(), dis.end());
  
  ll res = 0;
  rep(i, N-1) res += dis.at(i);
  
  //rep(i, N) cout << dis.at(i) << endl;
  cout << res;
  
}

Measured memory_bytes: 3456
n = int(input())
cards = {}
for i in range(n):
     card = input()
     cards[card] = 1
     
# print(cards)

for c in ['S','H','C','D']:
     for n in range(1, 14):
          key = c + ' ' + str(n)
          if not key in cards:
               print(key)


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

int main () {
  long long x,p;
  double ans;
  cin >> x >> p;
  if (x % 2 == 0) {
    x /= 2;
    ans = x;
    ans *= 100;
    ans /= p;
  }
  else {
    x /= 2;
    ans = x*p + (x+1)*(100-p);
    ans /= p;
    ans += 1;
  }
  
  cout << fixed << setprecision(10) << ans << endl;
    
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  string s;
  cin >> s;
  rep(i, 3){
  if(s[i]=='1')
    cout << '9';
  else
    cout << '1';
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e+9
#define debug(x) cerr << #x << ": " << x << "\n";
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void){
    ll K;
    cin >> K;

    int N = 50;
    ll a = K / N;
    ll b = K % N;

    debug(a);debug(b);

    ll res[N];
    for(int i = 0; i < N; i++){
        res[i] = i;
    }
    for(ll i = 0; i < b; i++){
        res[i] += N+1;
        for(int j = 0; j < N; j++){
            res[j] += -1;
        }
    }

    for(auto& x: res) x += a;

    cout << N << "\n";
    cout << res[0];
    for(int i = 1; i < N; i++){
        cout << " " << res[i];
    }
    cout << endl;
    return 0;
}

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

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if N < 2:
    base = 0
else:
    base = comb(N,2)
    
if M < 2:
    base2 = 0
else:
    
    base2 = comb(M,2)

print(base+base2)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define pb push_back
#define AA first
#define BB second
#define ONES(x) __builtin_popcount(x)
#define _ <<" "<<
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
const double eps=1e-6;
const int mod=1e9+7;
const double PI=acos(-1.0);
inline int read(){ int num;    scanf("%d",&num);   return num;}
const int maxn=1e5+7;
int main()
{
	int a,b,c,d;
	a=read();b=read();getchar();//c=read();d=read();
	string s;cin>>s;
	s[b-1]+=32;
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
class nfloor {
public:
	int sell;
	int buy[5];
	int dp[1<<5];
};

int inf = 200000;
int H, W;
int movex[]{ 1,0,-1,0,0 }, movey[]{ 0,1,0,-1,0 };
nfloor **map;

int search(int, int);

int main() {
	cin >> H >> W;
	map = new nfloor*[W + 2];
	for (int i = 0; i < W + 2; ++i) {
		map[i] = new nfloor[H + 2];
		for (int j = 0; j < H + 2; ++j) {
			map[i][j].sell = 0;
			for (int k = 0; k < 5; ++k) {
				map[i][j].buy[k] = 0;
			}
			for (int k = 0; k < 1<<5; ++k) {
				map[i][j].dp[k] = inf;
			}
		}
	}
	char dummy;
	for (int y = 1; y <= H; ++y) {
		for (int x = 1; x <= W; ++x) {
			cin >> dummy;
			map[x][y].sell = dummy == '.' ? 0 : dummy - '0';
		}
	}

	cout << search(1, 1) << endl;

	return 0;
}

int search(int x, int y) {
	if (x > W || y > H)return inf;
	else if (x == W&&y == H)return 0;
	int slide = 0;
	if (map[x][y - 1].sell == 0)slide += 1 << 2;
	if (map[x - 1][y].sell == 0)slide += 1 << 1;
	if (map[x - 1][y + 1].sell == 0)slide += 1 << 3;
	if (map[x + 1][y - 1].sell == 0)slide += 1 << 4;
	if (map[x][y].sell == 0)slide += 1;
	if (map[x][y].dp[slide] != inf)return map[x][y].dp[slide];
	int stock = 0;
	for (int i = 0; i < 5; ++i) {
		stock += map[x + movex[i]][y + movey[i]].sell;
		swap(map[x][y].buy[i], map[x + movex[i]][y + movey[i]].sell);
	}
	for (int i = 0; i < 4; ++i) {
		stock -= map[x][y].buy[i];
		swap(map[x][y].buy[i], map[x + movex[i]][y + movey[i]].sell);
		for (int j = 0; j < 2; ++j) {
			map[x][y].dp[slide] = min(map[x][y].dp[slide], search(x + movex[j], y + movey[j]) + stock);
		}
		swap(map[x][y].buy[i], map[x + movex[i]][y + movey[i]].sell);
		stock += map[x][y].buy[i];
	}
	for (int i = 0; i < 5; ++i) {
		swap(map[x][y].buy[i], map[x + movex[i]][y + movey[i]].sell);
	}
	return map[x][y].dp[slide];
}

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

int main(){
  long n,i,j,ans=0;
  cin >> n;
  vector<long> a(n);
  for(i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  while(true){
    i=0;
    while(a[i]==0){
      i++;
    }
    if(i==n-1) break;
    for(j=i+1; j<n; j++){
      a[j]%=a[i];
    }
    sort(a.begin(), a.end());
  }
  cout << a[i];
  
}

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


int main()
{
    int a, b, c, count;
    count = 0;
    
    cin >> a >> b >> c;

    for( ; a <= b; a++){
        if(c % a == 0)
            count++;
    }
    cout << count << endl;
    return 0;    
}

Measured memory_bytes: 3104
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;

class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int N;
	int[] a;
	void Solve()
	{
		N = F();
		a = G();
		Init();
		var max = new long[3 * N];
		for (var i = 0; i < N; i++)
		{
			max[N - 1] += a[i];
			Add(a[i]);
		}
		for (var i = N; i < 3 * N; i++)
		{
			max[i] = max[i - 1];
			if (a[i] > Min())
			{
				max[i] += a[i] - Min();
				Add(a[i]);
				Remove(Min());
			}
		}
		var b = new int[3 * N];
		for (var i = 0; i < 3 * N; i++) b[i] = a[3 * N - i - 1];
		Init();
		var min = new long[3 * N];
		for (var i = 0; i < N; i++)
		{
			min[N - 1] += b[i];
			Add(b[i]);
		}
		for (var i = N; i < 3 * N; i++)
		{
			min[i] = min[i - 1];
			if (b[i] < Max())
			{
				min[i] += b[i] - Max();
				Add(b[i]);
				Remove(Max());
			}
		}
		var ans = max[N - 1] - min[2 * N - 1];
		for (var i = N + 1; i <= 2 * N; i++) ans = Math.Max(ans, max[i - 1] - min[3 * N - i - 1]);
		WriteLine(ans);
	}
	SortedSet<int> key;
	SortedDictionary<int, int> good;
	void Init()
	{
		key = new SortedSet<int>();
		good = new SortedDictionary<int, int>();
	}
	int Max() => key.Max;
	int Min() => key.Min;
	void Add(int x)
	{
		if (!key.Contains(x)) { key.Add(x); good[x] = 1; }
		else good[x]++;
	}
	void Remove(int x)
	{
		if (good[x] == 1) { key.Remove(x); good.Remove(x); }
		else good[x]--;
	}
}

Measured memory_bytes: 51220
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=5e5+1;
int main()
{
    FASTINOUT;
    char c;
    cin>>c;
    cout<<(char)(c+1)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int count = 1;
        for(int i = 1; i < s.length(); i++){
            if(s.charAt(i) == s.charAt(i - 1)) count++;
            else count = 1;
            if(count >= 3){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 35760
/*
ID: ramil-p1
PROG: sprime
LANG: C++11
*/
#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5 + 100, inf = 2e9 + 100;



int main(){
    ios::sync_with_stdio(0);
    int k, s;
    cin >> k >> s;
    int answer = 0;
    for (int a = 0; a <= k; a++)
    for (int b = 0; b <= k; b++){
        int c = s - a - b;
        if (c >= 0 && c <= k)
            answer++;
    }
    cout << answer;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
cnt4 = 0
cnt2 = 0
a.each do |x|
  if x % 4 == 0
    cnt4 += 1
  elsif x % 2 == 0
    cnt2 += 1
  end
end
if cnt4 + cnt2/2 >= n/2
  puts "Yes"
else
  puts "No"
end

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

ll f(ll n){
    return n*(n+1)/2;
}

int main(){
    ll n;cin >> n;
    cout << f(n-1) << endl;
}

Measured memory_bytes: 3560
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

int main()
{
  int a,b,t;
  cin>>a>>b>>t;

  cout<<(t/a)*b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#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
  #define MAXN 100005
using namespace std;
int arr[MAXN];
int main()
{
	std::ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0; i<s.length(); i++) {
		if(s[i]=='2') cnt++;
	}

	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
# read (a, b)
A = []
B = []
for n in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)
    
# read (c, d)
C = []
D = []
for m in range(M):
    c, d = list(map(int, input().split()))
    C.append(c)
    D.append(d)

def manhattan(n, m):
    return abs(A[n]-C[m]) + abs(B[n]-D[m])

# calculate and output
for n in range(N):
    ind = 0
    dis = manhattan(n, 0)
    for m in range(M):
        dis_m = manhattan(n, m)
        if dis > dis_m:
            ind = m
            dis = dis_m
    print(ind+1)

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = input().split()

if A[-1] == B[0] and B[-1] == C[0]:
	print("YES")
else:
	print("NO")
	

Measured memory_bytes: 5144
import java.io.*;
class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader r =
         new BufferedReader(new InputStreamReader(System.in), 1);
         
        String line = r.readLine();    
        String[] w = line.split(" ",0); 
        int a=Integer.parseInt(w[0]);
        int b=Integer.parseInt(w[1]);
        
        if((-1000 <= a) & (b <= 1000)){
            if (a == b) {
                System.out.println("a == b");
            } else if (a < b) { 
                System.out.println("a < b");
            } else {
                System.out.println("a > b");
            }
        }
        r.close();
    }
}

Measured memory_bytes: 24416
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb(x) push_back(x)

ll power(int x, unsigned int y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = res * x;
        y >>= 1;
        x *= x;
    }
    return res;
}

void solve(){
    int k, a, b;
    cin >> k >> a >> b;
    if( (b/k) * k >= a ) cout << "OK";
    else cout << "NG";
}

int main(){

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

    solve();

}

Measured memory_bytes: 3660