akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;
 
int32_t main(){
	IOS;
	int n;
	cin>>n;
	string s1,s2;
	cin>>s1>>s2;
	for(int i=0;i<n;i++){
		cout<<s1[i]<<s2[i];
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}

void solve() {	
	int n;
	cin >> n;
	vector<pair<int, int>> arr(n);
	for (int i = 0; i < n; ++i) {
		int x, l;
		cin >> x >> l;
		arr[i].first = x + l;
		arr[i].second = x;
	}
	sort(all(arr));
	int mx = -1e18;
	int can = 0;
	for (int i = 0; i < n; ++i) {
		int lft = arr[i].second - (arr[i].first - arr[i].second);
		if (lft >= mx) {
			can++;
			mx = arr[i].first;
		}
	}
	cout << can;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<cmath>

using namespace std;

typedef long long ll;
#define INF 1000000007

int main(){
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<int> l(q), r(q);
    for(int i = 0; i < q; i++)
    {
        cin >> l[i] >> r[i];
    }

    vector<int> sum(n + 1, 0);
    for(int i = 1; i < n; i++)
    {
        if(s[i - 1] == 'A' && s[i] == 'C'){ //累積和
            sum[i + 1] = sum[i] + 1;
        }
        else sum[i + 1] = sum[i];
    }
    
    for(int i = 0; i < q; i++)
    {
        int ans = sum[r[i]] - sum[l[i]];
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 2176
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	cin >> N >> K;
	long long int num[100000] = {};
	for (int i = 0; i < N; i++) {
		cin >> num[i];
	}
	L = -1;
	for (int i = 0; i < N - 1; i++) {
		if (num[i] + num[i + 1] >= K) {
			L = i;
			R = i + 1;
			break;
		}
	}
	if (L == -1) {
		cout << "Impossible\n";
		return 0;
	}
	list<int>ret;
	for (int i = 0; i < L; i++) {
		ret.push_back(i + 1);
	}
	for (int i = N - 1; i > L; i--) {
		ret.push_back(i);
	}

	cout << "Possible\n";
	for (auto i : ret)cout << i << " ";
	cout << endl;
	return 0;
	return 0;
}

Measured memory_bytes: 4736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;


public class Main{
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	
	static class Pair
	{
		int p;
		int q;
		Pair(int p,int q)
		{
			this.p = p;
			this.q = q;
		}
	}
	
	static int gcd(int a,int b)
	{
		if(a == 0) return b;
		if(b == 0) return a;
		
		return gcd(b,a%b);
	}
	static long gcd(long a,long b)
	{
		if(a == 0) return b;
		if(b == 0) return a;
		
		return gcd(b,a%b);
	}
	static void preCompute(long fact[])
	{
		fact[0] = 1;
		for(int i = 1; i < fact.length; i++)
		{
			fact[i] = i*fact[i-1]%rem;
		}
	}
	static long power(long x, long y, long p) 
    { 
        long res = 1; 
        x = x % p; 
                      
        while (y > 0) 
        {
            if (y % 2 == 1) 
                res = (res * x) % p; 
 
            y = y >> 1; 
            x = (x * x) % p; 
        }
        return res; 
    } 
	static long modInverse(long n, long p) 
    { 
        return power(n, p-2, p); 
    }
	
	static long nCrModPFermat(int n, int r, long p) 
	{ 

		if (r == 0) 
			return 1; 

		return (fact[n]* modInverse(fact[r], p) % p * modInverse(fact[n-r], p) % p) % p; 
	}
	static long rem = (long)(1e9)+7;
	static long fact[];
	static int n,k;
	
	
	public static void main(String[] args) 
	{
		OutputStream outputStream = System.out;
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(outputStream);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        long ans = ((long)n*(n-1))/2;
        
        ans += ((long)m*(m-1))/2;
        out.println(ans);
        out.close();
	}

}


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

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,t;
  cin >> s >> t;
  ll ans = 100000;

  rep(i,s.size()){
    ll tmp = 0;
    if(i+t.size() > s.size()){
      break;
    }
    rep(j,t.size()){
      if(s[i+j]!=t[j]){
        tmp ++;
      }
    }
    ans = min(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	S = input()
	S = S[:-1]
	T = input()
	T = T[:-1]

	ans = 0
	if S[0] == T[0]:
		ans += 1
	if S[1] == T[1]:
		ans += 1
	if S[2] == T[2]:
		ans += 1

	print(ans)

if __name__ == "__main__":
	main()


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

#define fti(i, x, y) for(int i = (x), _y = (y); i <= _y; ++ i)
#define ftd(i, x, y) for(int i = (x), _y = (y); i >= _y; -- i)

using namespace std;

const int N = 2002;
int n, a[N], b[N], m;
long long res, s[2002], cnt[1002];

void inp()
{
    scanf("%d", &n);
    fti(i, 1, n) scanf("%d", &a[i]), ++ s[a[i]], ++ cnt[a[i]];
    fti(i, 0, 1000) if(cnt[i]) b[++ m] = i;
}

void proc()
{
    fti(i, 1, 1000) s[i] += s[i - 1];
    fti(i, 1, m) {
        if(b[i] == 0) continue;
        if(cnt[b[i]] >= 3) res += (cnt[b[i]] - 2) * (cnt[b[i]] - 1) * cnt[b[i]] / 6;
        if(cnt[b[i]] >= 2) res += (s[min(1000, b[i] * 2 - 1)] - s[b[i]]) * cnt[b[i]] * (cnt[b[i]] - 1) / 2;
        fti(j, i + 1, m) {
            res += (s[min(1000, b[i] + b[j] - 1)] - s[b[j]]) * cnt[b[i]] * cnt[b[j]];
            res += cnt[b[j]] * (cnt[b[j]] - 1) / 2 * cnt[b[i]];
        }
    }
    printf("%lld\n", res);
}

int main()
{
    inp();
    proc();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000

int Tree[MAX];
int n;

void maxHeapify(int i){
  int largest ,exchange, l, r;
  l = getLeft(i);
  r = getRight(i);
  
  if( ( n >= l ) && ( Tree[l] > Tree[i] ) ){
    largest = l;
  }else{
    largest = i;
  }
  if( ( n >= r ) && ( Tree[r] > Tree[largest] ) ){
    largest = r;
  }
  if (largest != i){
    exchange =  Tree[i];
    Tree[i] = Tree[largest];
    Tree[largest] = exchange;
    maxHeapify(largest);
  }  
}

void buildMaxHeap(){
  int i;
  for (i = (n/2); i >= 1; i--){
    maxHeapify(i);
  }
}

void heapIncrease(int i, int key){
  int exchange;
  if(key < Tree[i])printf("new key is smallar than current key\n");
  
  Tree[i] = key;

  while(( i > 1 ) && ( Tree[getParent(i)] <  Tree[i] )){
    exchange = Tree[i];
    Tree[i] = Tree[getParent(i)];
    Tree[getParent(i)] = exchange;
    i = getParent(i);
  }

}
void maxHeapInsert( key ){
  n = n + 1;
  Tree[n] = -2000000;
 heapIncrease(n, key);
}



int heapExtractMax(){
  int max;
  if( n < 1 )return -1;
  max = Tree[1];
  Tree[1] = Tree[n];
  --n;
  maxHeapify(1);
  return max;
}

int getParent( int i ){
  return i/2;
}

int getLeft(int i){
  return (2*i);
}

int getRight(int i){
  return (2*i + 1);
}


main()
{
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  while(1){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      maxHeapInsert(x);
    } else if ( com[0] == 'e' && com[1] == 'x'){
      scanf("%d", &x);
      printf("%d\n",heapExtractMax());
    } else if ( com[0] == 'e' && com[1] == 'n'){
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 4692
#include <iostream>
#include <map>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
const int dx[9] = {-2, -2, -2, -1, -1, -1, 0, 0, 0}, dy[9] = {-2, -1, 0, -2, -1, 0, -2, -1, 0};
ll cnt[10];
int main() {
	ll h, w, n;
	cin >> h >> w >> n;
	map<pair<int, int>, int> mp;
	rep(i, n) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		rep(i, 9) {
			int nx = x + dx[i], ny = y + dy[i];
			if (nx < 0 or h - 2 <= nx or ny < 0 or w - 2 <= ny) continue;
			mp[{nx, ny}]++;
		}
	}
	for (auto p : mp) cnt[p.second]++;
	cnt[0] = (h - 2) * (w - 2) - mp.size();
	rep(i, 10) cout << cnt[i] << endl;
	return 0;
}

Measured memory_bytes: 56448
A,B,K = map(int,input().split(' '))

def cf(x1,x2):
    cf=[]
    for i in range(1,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
print(cf(A,B)[len(cf(A,B)) - K ])

Measured memory_bytes: 38384
#include <iostream>
#include <set>
#include <vector>
#include <iomanip>

#include <cfenv>
#include <cmath>
typedef long long int ll;

using namespace std;

int main()
{


    ll A, B, C, K;


    cin >>A >> B >> C >> K;


    if(K>A){


        if(K-A>B){


            cout << A-(K-A-B) << endl;



        }
        else{


            cout << A << endl;


        }





    }
    else{

        cout << K << endl;

    }


    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")

const int MAX = 1e6;
const ll MOD = 1e9 + 7;

using ll = long long;
ll fac[MAX], finv[MAX], inv[MAX];

void Comb_init()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

long long Comb(int n, int k)
{
	if (fac[0] == 0)
		Comb_init();
	if (n < k)
		return 0;
	if (n < 0 || k < 0)
		return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	int N, K;
	cin >> N >> K;

	for (int i = 1; i <= K; i++)
	{
		cout << (Comb(K - 1, i - 1) * Comb(N - K + 1, i)) % MOD << "\n";
	}
}

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

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

    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    
    cout << (s < t ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

vector<pair<int, int>> primeFactorization(int n) {
    int k = n;
    vector<pair<int, int>> ret;
    for (int i = 2; i <= sqrt(n); i++) {
        int cnt = 0;
        while(k % i == 0) {
            k /= i; // 重複を許さないならここを while に
            cnt++;
        }
        if (cnt) ret.push_back({i, cnt});
    }
    if(k > 1) ret.push_back({k, 1});
    return ret;
}

const int MAX = 210000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

long long int comb(int n, int r) {
    if(r < 0 || n < r) return 0;
    return fac[n] * finv[n-r] % MOD * finv[r] % MOD;
}

int main(){
    cin.tie(0);
    
    COMinit();
    int N, M;
    cin >> N >> M;
    Int ans = 1;
    auto factor = primeFactorization(M);
    for (int i = 0; i < factor.size(); i++){
        int cnt = factor[i].second;
        Int tmp = comb(N+cnt-1, cnt);
        tmp %= MOD;
        ans = (ans * tmp) % MOD;
    }
    cout << ans << endl;
} 


Measured memory_bytes: 5120
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 100005
#define TRUE 1
#define FALSE 0

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[MAX+1];
P Q2[MAX+1];
//init
int head, tail, ass;

void enqueue(P x)
{
  if(head == (tail + 1) % MAX) exit(0);
  else
  {
    Q[tail] = x;
    if(tail + 1==MAX) tail = 0;
    else tail++;
  }
}

P dequeue()
{
  P x;
    x = Q[head];
    if(head + 1==MAX) head = 0;
    else head++;
    return x;
}

int main()
{
  int lsa = 0, ms = 0;

  int n, q;
  //input
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; i++)
  {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    if(tail + 1==MAX) tail = 0;
    else tail++;
  }

  while(ass==0)
  {
    if(q - Q[head].t <0)
    {
      Q[head].t -= q;
      enqueue(dequeue());
      ms+=q;
    }
    else
    {
      ms+=Q[head].t;
      Q2[lsa] = dequeue();
      Q2[lsa].t = ms;
      lsa++;
    }
    if(tail==head) ass = 1;
  }
  //output
  for (int i = 0; i < n; i++)
  {
    printf("%s ", Q2[i].name);
    printf("%d\n", Q2[i].t);

  }

  return 0;
}


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

//GCD,LCM
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(){
    ll n;
    cin>>n;
    ll a[100010];
    int ans=0;
    for(int i=0;i<n;++i)cin>>a[i];
    // sort(a,a+n-1);
    // ll l=lcm(a[0],a[1]);
    // for(int i=2;i<n;++i){
    //     l=lcm(l,a[i]);
    // }
    // ll m=l-1;
    // for(int i=0;i<n;++i){
    //     ans+=m%a[i];
    // }
    for(int i=0;i<n;++i)ans+=a[i]-1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

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 prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k) {
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= MOD;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= MOD;
    }
    return x * modinv(y, MOD) % MOD;
}

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

    int n;
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        if (a % 2 == 0) {
            if (a % 3 != 0 && a % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N, X;
    cin >> N >> X;
    
    int mn = X + 1;
    FOR(i, 0, N) {
        int a;
        cin >> a;
        mn = min(mn, a);
        X -= a;
    }

    cout << (N + X / mn) << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
import Control.Monad
import Data.List

main=do
    [n,t]<-map read.words<$>getLine::IO[Int]
    print =<< fst.foldl (f t) (0,0).map read.words<$>getLine

f::Int->(Int,Int)->Int->(Int,Int)
f t (c,s) x
    | s<x  = (c+t,x+t)
    | True = (c+x+t-s, x+t)


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

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int64_t> dp(N+1);
    dp[0] = 1;
    dp[1] = 1;
    while(M--) {
        int A;
        cin >> A;
        dp[A] = -1;
    }

    for(int i=2; i<=N; i++) {
        if(dp[i] < 0) continue;
        if(dp[i-1] >= 0) dp[i] += dp[i-1];
        if(dp[i-2] >= 0) dp[i] += dp[i-2];
        dp[i] %= MOD;
    }

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


Measured memory_bytes: 1024
import sys

N=int(input())
S=[int(input()) for _ in range(N)]
S.sort()
ans=sum(S)

if ans%10!=0:
  print(ans)
  sys.exit()
else:
  for i in range(N):
    if S[i]%10!=0:
      print(ans-S[i])
      sys.exit()
  else:
    print(0)

Measured memory_bytes: 9008
/*  ex7_3
    B30095    */
#include <stdio.h>
#include <stdlib.h>

void print_compressed(char ** grid, int rows, int cols);

int main(void){
    int rows, cols, isRowEmpty, isColEmpty, i, j;
    char ** grid;
    
    scanf("%d %d", &rows, &cols);
    
    // memory allocation
    grid = (char **)malloc(rows * sizeof(char *));
    if(grid == NULL){
        fprintf(stderr, "memory allocation error");
        return -1;
    }

    for(i = 0; i < rows; i++){
        grid[i] = (char *)malloc(cols * sizeof(char));
        if(grid[i] == NULL){
            fprintf(stderr, "memory allocation error");
            return -1;
        }
    }

    // input grid
    for(i = 0; i < rows; i++){
        for(j = 0; j < cols; j++){
            scanf(" %c", &(grid[i][j]));
        }
    }

    print_compressed(grid, rows, cols);

    // memory deallocation
    for(i = 0; i < rows; i++){
        free(grid[i]);
    }
    free(grid);

    return 0;
}


void print_compressed(char ** grid, int rows, int cols){
    int isRowEmpty, isColEmpty, i, j;

        // substitue empty rows with whitespaces
    for(i = 0; i < rows; i ++){
        isRowEmpty = 1;
        
        // check if the row is empty
        for(j = 0; j < cols; j++){
            if(grid[i][j] == '#') {
                isRowEmpty = 0;
            }
        }

        // fill in empty rows with whitespaces
        if(isRowEmpty){
            for(j = 0; j < cols; j++){
                grid[i][j] = ' ';
            }
        }
    }

    // substitue empty columns with whitespaces
    for(j = 0; j < cols; j ++){
        isColEmpty = 1;
        
        // check if the column is empty
        for(i = 0; i < rows; i++){
            if(grid[i][j] == '#') {
                isColEmpty = 0;
            }
        }

        // fill in empty columns with whitespaces
        if(isColEmpty){
            for(i = 0; i < rows; i++){
                grid[i][j] = ' ';
            }
        }
    }


    // print compressed result
    for(i = 0; i < rows; i++){
        isRowEmpty = 1;

        for(j = 0; j < cols; j++){
            if(grid[i][j] == '#') isRowEmpty = 0;
            if(grid[i][j] != ' ') printf("%c", grid[i][j]);
            
        }

        if(!isRowEmpty) printf("\n");  // new line should not be printed when the row is empty
    }
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define rep(i, ns, ne) for (int i = ns; i <= ne; ++i)
using namespace std;

int main() {
  int K, S, chk, ans = 0;
  cin >> K >> S;
  rep(x, 0, K) {
    if (x <= S) {
      rep(y, 0, K) {
        if (y <= S) {
          chk = S - x - y;
          if (0 <= chk and chk <= K) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
  getchar();
}

Measured memory_bytes: 3516
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	int N,Q;
	cin >> N >> Q;
	string T;
	cin >> T;
	int count = 0;
	bool finda = false;
	vector<int> memo;
	for (int i = 0; i < T.length(); ++i) {
		if (T[i] == 'A') {
			finda = true;
		}
		else {
			if (finda && T[i] == 'C') {
				++count;
				memo.push_back(i);
			}
			finda = false;
		}
	}

	int now,ind;
	now = ind = 0;
	vector<int> left(T.length(),count);
	vector<int> right(T.length(),-count);
	for (int i = 0; i < T.length(); ++i) {
		if (ind < memo.size() && memo[ind] == i) {
			++now;
			++ind;
		}
		left[i] -= now;
		right[i] += now;
	}

	for (int q = 0; q < Q; ++q) {
		int l,r;
		cin >> l >> r;
		cout << left[l-1]+right[r-1] << endl;
	}
	return 0;
}

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

int main() {
  int a,b,k;
  cin >> a >> b >> k;
  
  for(int i=min(a,b); i>=1; --i) {
    if(a%i==0&&b%i==0) --k;
    if(k==0) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
using namespace std;

int main(){    
    int n ;
    cin >> n ;
    vector<int> a(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    vector<int64_t> num(n+1,0) ;
    for (size_t i = 0; i < n; i++)
    {
        num.at(a.at(i)) ++ ;
    }
    int64_t ans = 0 ;
    for (size_t i = 1; i < n+1; i++)
    {
        ans += num.at(i)*(num.at(i)-1)/2 ;
    }
    for (size_t i = 0; i < n; i++)
    {
        cout << ans - ( num.at(a.at(i)) - 1 ) << endl ;
    }
    
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <stdlib.h>
int N;
int fact[] = { 1,1,2,6,24,120,720,5040,40320 };
int lefta[10];
int leftb[10];
using namespace std;
int main()
{
	cin >> N;
	int i;
	int a=1, b=1;
	for (i = 0; i < N; i++)
	{
		int x;
		cin >> x;
		int ord = x - 1;
		int l;
		for (l = 1; l < x; l++)
		{
			if (lefta[l])
				ord--;
		}
		lefta[x] = 1;
		a += fact[N - i - 1] * ord;
	}
	for (i = 0; i < N; i++)
	{
		int x;
		cin >> x;
		int ord = x - 1;
		int l;
		for (l = 1; l < x; l++)
		{
			if (leftb[l])
				ord--;
		}
		leftb[x] = 1;
		b += fact[N - i - 1] * ord;
	}
	cout << abs(b - a);
}

Measured memory_bytes: 256
N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]

t = txy[0][0]
d = abs(txy[0][1] + abs(txy[0][2]))
if t < d or t % 2 != d % 2:
    print('No')
    exit()

for i in range(1, N):
    t = txy[i][0] - txy[i - 1][0]
    d = abs(txy[i][1] - txy[i - 1][1]) + abs(txy[i][2] - txy[i - 1][2])
    if t < d or t % 2 != d % 2:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 27324
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

pair<int, int> intervals[10000];

int main() {
  int N, M;
  while (scanf("%d%d", &N, &M) != EOF) {
    vector<int> sum(M + 10);

    for (int t : range(N)) {
      int lt, rt;
      scanf("%d%d", &lt, &rt);
      const int th = 400;
      int iptr = 0;
      for (int x = 1; ; ++x) {
        int now_lptr = (lt + x - 1) / x,
            now_rptr = rt / x;
        if (now_rptr < th) break;
        now_lptr = max(th + 1, now_lptr);
        if (now_lptr <= now_rptr) {
          intervals[iptr++] = {now_lptr, now_rptr};
        }
      }

      for (int d = th; d >= 1; --d) {
        int y = d * (rt / d);
        if (y >= lt) {
          intervals[iptr++] = {d, d};
        }
      }

      reverse(intervals, intervals + iptr);
      for (int i : range(iptr)) {
        auto p = intervals[i];
        if (i == 0) {
          sum[p.first]++;
          sum[p.second + 1]--;
        } else {
          auto p2 = intervals[i - 1];
          if (p.first <= p2.second) {
            sum[p2.second + 1]++;  // cancel
            sum[p.second + 1]--;
          } else {
            sum[p.first]++;
            sum[p.second + 1]--;
          }
        }
      }
    }

    // take partial sum
    for (int i : range(M)) sum[i + 1] += sum[i];
    for (int i : range(M)) {
      printf("%d\n", sum[i + 1]);
    }
  }
}


Measured memory_bytes: 1280
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    cout << n * n * n << endl;
    return 0;

}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=5e5+5;
int n,t,opt,tree[maxn<<2],pos,x,y;
char s[maxn],ch;
void build(int node,int l,int r){
    if(l==r){
        tree[node]=1<<(s[l]-'a');
        return ;
    }
    int mid=(l+r)>>1;
    build(node<<1,l,mid);
    build(node<<1|1,mid+1,r);
    tree[node]=tree[node<<1]|tree[node<<1|1];
}
void change(int node,int l,int r,int pos){
    if(l==r&&l==pos){
        tree[node]=1<<(ch-'a');
        return ;
    }
    int mid=(l+r)>>1;
    if(mid>=pos)    change(node<<1,l,mid,pos);
    else            change(node<<1|1,mid+1,r,pos);
    tree[node]=tree[node<<1]|tree[node<<1|1];
}
int query(int node,int L,int R,int l,int r){
    if(L<=l&&R>=r){
        return tree[node];
    }
    int mid=(l+r)/2,ans=0;
    if(mid>=L) ans=ans|query(node<<1,L,R,l,mid);
    if(mid<R)  ans=ans|query(node<<1|1,L,R,mid+1,r);
    return ans;
}
int main(){
    scanf("%d %s %d",&n,s+1,&t);
    build(1,1,n);
    while(t--){
        scanf("%d",&opt);
        if(opt==1){
            scanf("%d %c",&pos,&ch);
            if(s[pos]!=ch){
                change(1,1,n,pos);
                s[pos]=ch;
            }
        }else{
            scanf("%d %d",&x,&y);
            printf("%d\n",__builtin_popcount(query(1,x,y,1,n)));
        }
    }
    return 0;
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define Rep(i,s,f) for(int i=(int)s;i<(int)f;i++)
using ll=long long;
using namespace std;


int main()
{
	ll N;
	cin>>N;
	N--;
	vector<char> ans;
	while(N>=0)
	{
		ans.push_back((char)('a'+N%26));
		N/=26;
		N--;
	}
	reverse(ans.begin(),ans.end());
	rep(i,ans.size())
	{
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}


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

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

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

int main(){
	char str[1000005];
	cin >> str;
	int n = strlen(str);
	
	typedef pair<char, int> pci;
	vector<pci> list(n);
	pci cur = pci(str[0],1);
	Rep(i, 1, n){
		if(str[i]==cur.first){
			cur.second++;
		}else{
			list.push_back(cur);
			cur=pci(str[i],1);
		}
	}
	list.push_back(cur);
	
	int j = 0, o = 0, ans = 0;
	for(int i=0;i<list.size();i++){
		if(list[i].first=='J' && list[i+1].first == 'O' && list[i+2].first == 'I'){
			if(list[i].second >= list[i+1].second && list[i+1].second <= list[i+2].second){
				ans = max(ans, list[i+1].second);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 19548
def resolve():
    ss = input()

    dp = [0] * 13
    dp[0] = 1

    mod = 10 ** 9 + 7
    mul = 1

    # 後ろから解く
    for s in ss[::-1]:
        next_dp = [0] * 13

        if s == '?':
            for num in range(10):
                for i in range(13):
                    next_dp[(num * mul + i) % 13] += dp[i]
                    next_dp[(num * mul + i) % 13] %= mod
        else:
            num = int(s)
            for i in range(13):
                next_dp[(num * mul + i) % 13] += dp[i]
                next_dp[(num * mul + i) % 13] %= mod

        mul *= 10
        mul %= 13
        dp = next_dp

    print(dp[5])
    
resolve()

Measured memory_bytes: 43500
def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))
    A = [0] + A

    seen = {}
    find_cnt = {}
    cnt = 0
    dst = 1
    while K:
        if dst in seen:
            cycle = cnt - seen[dst]
            K %= cycle
            print(find_cnt[seen[dst]+K])
            return

        else:
            seen[dst] = cnt
            find_cnt[cnt] = dst

        dst = A[dst]
        cnt += 1
        K -= 1

    print(dst)


if __name__ == "__main__":
    main()


Measured memory_bytes: 127436
using System;
using System.Linq;

namespace Next_Prime
{
    class Program
    {
        static void Main(string[] args)
        {
            const int MAX_PRIME = 100004;
            var input = long.Parse(Console.ReadLine());
            var primeArray = Enumerable.Repeat<bool>(true, MAX_PRIME + 1).ToArray();
            primeArray[0] = false;
            primeArray[1] = false;
            for(var i = 2; i < input; i++)
            {
                if(primeArray[i])
                {
                    var maxJ = MAX_PRIME / i;
                    for (var j = 1; j <= maxJ; j++)
                    {
                        primeArray[i * j] = false;
                    }
                }
            }
            var minPrime = primeArray.ToList().IndexOf(true);
            Console.WriteLine(minPrime);
        }
    }
}

Measured memory_bytes: 13664
#最大公約数
def gcd(a,b):
    while b != 0:
        a, b = b, a%b
    return a
    # print(gcd(a,b))

#最小公倍数
def lcm(a,b):
    return a*b // gcd(a,b)
    # print(lcm(a,b))

def main():
    A, B, C, D = list(map(int, input().split()))

    count_c = B // C
    count_d = B // D
    count_union = B // lcm(C, D)

    total1 = B - count_c - count_d + count_union

    count_c = (A - 1) // C
    count_d = (A - 1) // D
    count_union = (A - 1) // lcm(C, D)

    total2 = A - 1 - count_c - count_d + count_union

    print(total1 - total2)

if __name__ == '__main__':
    main()

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	set<int> a;
	for(int i=0; i<3; i++){
		int t;
		cin >> t;
		a.insert(t);
	}

	cout << a.size() << endl;


	

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		List<Integer> a = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			a.add(Integer.parseInt(sc.next()));
		}

		Iterator<Integer> it = a.iterator();
		int total = 0;
		int index = 1;
		while (it.hasNext()) {

			int i = it.next();
			if (i == index) {
				index++;
			} else {
				total++;
			}
		}
		if (total == n) {
			System.out.println(-1);
		} else {
			System.out.println(total);
		}

	}

}


Measured memory_bytes: 63800
#include<iostream>
#include<string>
#include<stack>
using namespace std;
int main(){
  string s;
  while(getline(cin,s) ){
    if( s== ".")break;
    stack<char> st;
    int flg =0;
    for(int i=0;i<s.size();i++){
      char c = s[i];
      if( c=='(' || c=='['){
	st.push(c);
      }else if( c==')'){
	if( st.empty() || st.top() == '[' ){
	  flg=1;
	  break;
	}else if( st.top()=='('){
	  st.pop();
	}
      }else if( c==']'){
	if( st.empty() || st.top() == '(' ){
	  flg=1;
	  break;
	}else if( st.top()=='['){
	  st.pop();
	}
      }
    }
    if(st.empty() && flg==0){
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1176
#include<stdio.h>
#include<iostream>
using namespace std;

string n;
int main (){
    cin >> n;
    int l = n.length();
    for(int i=0; i<l; i++){
        if( n[i] == '9') cout << 1 ;
        else if( n[i] == '1') cout << 9;
        else cout << n[i] ;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 251
 
main(){

  int A[N];
  int i,n;

  scanf("%d",&n);

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

  for(i=1;i<=n;i++){
    
    if(i==1){
      printf("node %d: key = %d, ",i,A[i]);
      if(left(i)<=n)printf("left key = %d, ",A[left(i)]);
      if(right(i)<=n)printf("right key = %d, ",A[right(i)]);
    }

    else {
      printf("node %d: key = %d, parent key = %d, ",i,A[i],A[parent(i)]);
      if(left(i)<=n)printf("left key = %d, ",A[left(i)]);
      if(right(i)<=n)printf("right key = %d, ",A[right(i)]);
    }
    printf("\n");
    
  }

  return 0;
}

int parent(int i){
  return i/2;
 
}
int left(int i){
  return 2*i;
 
}
 
int right(int i){
  return 2*i+1;
 
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e;
  int s=0;
  cin >>a>>b>>c>>d>>e;
  if(a<0){
    s+=a*c*(-1)+d;
    a=0;
  }
  s+=(b-a)*e;
  cout <<s<<endl;
  return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int resultb = 0;
    int flag = 0; 
    int tmp;
    for(int i = 0; i < 1250; i++){
        tmp = i * 0.08;
        if(a == tmp){
            resultb = i;
            tmp = resultb * 0.1;
            if(tmp == b){
                flag = 1;
                break;
            }
        }
    }

    if(flag == 1){
        cout << resultb << endl;
    }else{
        cout << -1 << endl;
    }

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
bool solve(vector<int> v, int x, int y)
{
    map<lli, bool> b[2];
    b[0][0] = true;
    int nxt = 1, cur = 0;
    rep(i, v.size())
    {
        b[nxt].clear();
        for (auto s : b[cur]) {
            //cout << s.first << endl;
            b[nxt][s.first + v[i]] = true;
            if (i != 0 or y)
                b[nxt][s.first - v[i]] = true;
        }
        swap(nxt, cur);
    }
    return b[cur][x];
}
int main()
{
    string s;
    cin >> s;
    s += "T";
    int n = s.size();
    int x, y;
    int l[2];
    cin >> l[0] >> l[1];
    int cnt = 0;
    int h = 0;
    vector<int> v;
    while (cnt < n) {
        if (s[cnt] == 'F') {
            h++;
        } else {
            v.push_back(h);
            h = 0;
        }
        cnt++;
    }
    n = v.size();
    vector<int> vv[2];
    rep(i, n)
    {
        vv[i % 2].push_back(v[i]);
        //cout << v[i] << endl;
    }
    bool flag = true;
    rep(i, 2)
    {
        flag &= solve(vv[i], l[i], i);
    }
    cout << (flag ? "Yes" : "No") << endl;
}


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

#define ll long long
#define ii pair<ll, ll>
#define dd pair<double, double>
#define pb(i) push_back(i)
const double PI = 3.14159265359;
const ll inf = 1e18;
const int mod = 1e9+7;
const double eps = 1e-7;
//int dir1[8] = {0, 0, 1, -1, 1, -1, 1, -1};
//int dir2[8] = {1, -1, 0, 0, 1, 1, -1, -1};
int dir1[4] = {0, 0, 1, -1};
int dir2[4] = {1, -1, 0, 0};

const int N = 1<<22;

int mat[20][20];
ll val[1<<17];
ll dp[1<<17];

int main()
{
    int i, j, k;

    int n;
    cin >> n;

    for(i = 0; i < n; i++)
        for(j = 0; j < n; j++)
            cin >> mat[i][j];

    memset(val, 0, sizeof(val));
    memset(dp, 0, sizeof(dp));

    for(i = 0; i < (1<<n); i++)
    {
        for(j = 0; j < n; j++)
            if( (1<<j)&i )
                for(k = j+1; k < n; k++)
                    if( (1<<k)&i )
                        val[i] += mat[j][k];
    }

    //for(i = 0; i < (1<<n); i++)
    //    cout << val[i] << '\n';

    for(i = 0; i < (1<<n); i++)
    {
        //not yet selected. Let's form another group with it.
        vector<int> pos;
        for(j = 0; j < n; j++)
            if(!( (1<<j)&i ))
                pos.pb(j);
        
        int tam = (int)pos.size();
        for(j = 0; j < (1<<tam); j++)
        {
            int mask = 0;
            for(k = 0; k < tam; k++)
                if( (1<<k)&j )
                    mask |= (1<<pos[k]);
        
            dp[mask|i] = max(dp[mask|i], dp[i] + val[mask]);
        }
    }

    cout << dp[(1<<n)-1] << '\n';

}




Measured memory_bytes: 5600
#include <iostream>

using namespace std;

int main() {
	int n, id, k, v, matrix[100][100] = { 0 };
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> id >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			matrix[id - 1][v - 1] = 1;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - 1; j++) {
			cout << matrix[i][j] << " ";
		}
		cout << matrix[i][n - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int n;

	
	while(cin >> n && n){
	int a[33];
	a[0] = a[1] = 0;
	a[2] = 1;
	for(int i = 3;i < n+3;i++){
		a[i] = a[i-3] + a[i-1] + a[i-2];
	}
	int res = a[n+2]/10/365;
	if(a[n+2]% 3650 != 0)
		res ++;
	cout << res << endl;
	}
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 x;
    cin >> x;
    if((x % 100 + 4) / 5 > x / 100){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, K; cin >> N >> K;
  vector<int> xs(N); for (auto &x : xs) cin >> x;
  int ans = 1e9;
  for (int l = 0, r; (r = l + K - 1) < N; ++l) ans = min({ans, abs(xs[l]) + abs(xs[r] - xs[l]), abs(xs[r]) + abs(xs[r] - xs[l])});
  cout << ans << endl;}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++)cin>>d[i];
  sort(d.begin(),d.end());
  cout<<d[n/2]-d[n/2-1]<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int v[1000][2];
int main(){
  int n;
  cin>>n;
  rep(i,n)cin>>v[i][0];
  rep(i,n)cin>>v[i][1];
  int ans = 0;
  rep(i,n){
    int tmp = 0;
    bool top = true;
    rep(j,n){
      if(i == j){
        tmp += v[j][0];
        tmp += v[j][1];
        top = false;
      }
      else if(top){
        tmp += v[j][0];
      }
      else{
        tmp += v[j][1];
      }
    }
    ans = max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  bool can = false;
  
  for(int i=1; i<=B; i++){
    if ( (i*A)%B == C) {
      can = true;
      break;
    }
  }
  
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
//map<key,value>

int main(){
  string s;
  bool flag = 0;
  cin >> s;
  for(int i=0;i<s.length();i++){
    if(s[i] == s[i+1])flag = 1;
  }
  if(flag == 1)cout << "Bad";
  else cout << "Good";
  return 0;
}


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


//A sieve to effectivelly factorise numbers in a range(= size)
// A number is a prime if sieve[i] == i;

vector<	ll> sieve(N);
void factor_sieve()
{
	iota(sieve.begin(),sieve.end(),0);
 
	for(ll i=2;i*i<=N;++i)
	{
		if(sieve.at(i) == i)
		{
			for(ll j = i*2;j<N;j+=i)
				if(sieve.at(j) == j)sieve.at(j) = i;
		}
	}
}


int main(){

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

	ll t=1;
	// cin>>t;

	while(t--){
		ll n;
		cin>>n;
		vector<ll> v(n);
		for(ll i=0;i<n;++i) cin>>v[i];

		factor_sieve();
		bool ok = true;
		vector<ll> hash(N);
		for(auto x : v){

			while(x != 1){
				ll f = sieve[x];
				if(hash[f]) {ok = false; break;}
				else hash[f]++;
				while(x%f == 0) x /= f;
			}
		}

		if(!ok){
			ll gg = 0;
			for(auto &x : v) gg = __gcd(gg,x);
			if(gg == 1) cout<<"setwise coprime\n";
			else cout<<"not coprime\n";
		}
		else cout<<"pairwise coprime\n";



	}	

	return 0;
}	

Measured memory_bytes: 26612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=105;
char s[max_n];
int main(){
    scanf("%s",s+1);
    int n=strlen(s+1);
    int ans=0;
    for(int i=1;i<=n/2;i++)if(s[i]!=s[n+1-i])ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256