akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;
 
int main() {
int n;
cin>>n;
vector<int> a(200010);
for(int i=0;i<n;i++){
cin>>a[i];
}
deque<int> b;
for(int i=0;i<n;i++){
if(i%2==0)b.push_back(a[i]);
else b.push_front(a[i]);
}
if(n%2==1)reverse(b.begin(),b.end());
for(int i=0;i<n;i++){
cout<<b[i]<<" ";
}
cout<<endl;
}

Measured memory_bytes: 3840
S = "0b" + input()

N = len(S) - 2

A = "0b" + "10" * (N // 2) + "1" * (N % 2)
B = "0b" + "01" * (N // 2) + "0" * (N % 2)

s = int(S, 2)
a = int(A, 2)
b = int(B, 2)

num_a = bin(s ^ a).count("1")
num_b = bin(s ^ b).count("1")

print(min([num_a, num_b]))

Measured memory_bytes: 3444
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    a,b,c,k=MI()
    ans =0
    if k>=a:
        ans+=a
        k-=a
    elif k<a:
        ans+=k
        k=0
    if k>=b:
        ans+=0
        k-=b
    elif k<b:
        ans+=0
        k=0
    # print(ans,k)
    if k>=c:
        ans-=c
        k-=c
    elif k<c:
        ans-=k
        k=0
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9608
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, a[100100][3];
ll dp[100100][3];

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

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j == k) continue;
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    ll res = 0;
    for(int i = 0; i < 3; i++){
        res = max(res, dp[n][i]);
    }

    cout << res << endl;
}

Measured memory_bytes: 4992
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(S: int, W: int):
    if W >= S:
        print("unsafe")
    else:
        print("safe")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(S, W)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
h = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

#ans_L = [0] * (10**12 + 1)

i = 0
ans_L = [1]
while h!=1:
    h = h//2
    i += 1
    ans_L.append(2**i)

print(sum(ans_L)) 

Measured memory_bytes: 2940
/* به نام یزدان */
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 3000 + 3;
long long n, a[MAX_N], dp[MAX_N][MAX_N][2];

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

void solve() {
	for (int dif = 0; dif < n; dif++)
		for (int i = 0; i + dif < n; i++) {
			int j = i + dif;
			dp[i][j][0] = max(dp[i + 1][j][1] + a[i], dp[i][j - 1][1] + a[j]);
			dp[i][j][1] = min(dp[i + 1][j][0] - a[i], dp[i][j - 1][0] - a[j]);
		}
}

void print_output() {
	cout << dp[0][n - 1][0];
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
	print_output();
}


Measured memory_bytes: 139648
#include <bits/stdc++.h>
using namespace std;
using P = pair<string, string>;
using ll = long long;

int main() {
  int N; cin >> N;
  string S; cin >> S;
  map<P, int> mp;
  for (int i = 0; i < 1 << N; ++i) {
    string s1, s2;
    for (int j = 0; j < N; ++j) {
      ( (i >> j & 1) ? s1 : s2 ) += S[j];
    }
    ++mp[P{s1, s2}];
  }
  ll ans = 0;
  for (int i = 0; i < 1 << N; ++i) {
    string s1, s2;
    for (int j = 0; j < N; ++j) {
      ( (i >> j & 1) ? s2 : s1 ) += S[N + j];
    }
    reverse(begin(s1), end(s1));
    reverse(begin(s2), end(s2));
    ans += mp[P{s1, s2}];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 87040
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;
cin>>x>>y>>z;
if(y>=z)cout << "delicious ";
else if(z-y<=x)cout<<"safe";
else cout <<"dangerous";
}


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

int main() {
    int N, a, i, c=0, odd=0;
    cin >> N;
    int t[N];


    for(i=0; i<N; i++) {
        cin >> a;
        t[i] = a;
    }
    while (!odd) {
        for (i=0; i<N; i++) {
            if (t[i]%2 != 0) {
                odd++;
                break;
            }
            t[i] /=2;
        }
        c++;
    }
    cout << c-1 << endl;
}

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

# define C continue;

# define ll long long
# define ld long double

# define pb push_back
# define I insert
# define PQ priority_queue

# define vi vector < int >
# define vll vector < ll >
# define vc vector < char >
# define vb vector < bool >
# define vs vector < string >

# define vvi vector < vector < int > >
# define vvll vector < vector < ll > >
# define vvc vector < vector < char > >
# define vvb vector < vector < bool > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >

# define vpii vector < pair < int , int > >
# define vpll vector < pll >

# define F first
# define S second

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .
/// Start using lower bound !!

const int N = 1e5 + 3 ;
int dp[N] ;

void solve ( int test_case )
{
    int n , w ;
    cin >> n >> w ;

    /// dp[i] is, what is the minimum weight, we may have, for having the sum of values equals i

    memset ( dp , 63 , sizeof ( dp ) ) ;
    const int inf = dp[0] ;

    dp[0] = 0 ;

    for ( int i=0 ; i < n ; i ++ )
    {
        int weight , value ;
        cin >> weight >> value ;

        for ( int prev_values = N - 1 ; prev_values > -1 ; prev_values -- )
        {
            if ( dp[prev_values] == inf )
                C ;

            int new_value = prev_values + value ;

            if ( new_value >= N )
                break ;

            int new_weight = dp[prev_values] + weight ;

            if ( new_weight > w )
                C ;

            dp[new_value] = min ( dp[new_value] , new_weight ) ;
        }
    }

    for ( int i = N - 1 ; i > -1 ; i -- )
    {
        if ( dp[i] > 0 && dp[i] <= w )
        {
            cout << i ; line ;
            return ;
        }
    }

    cout << 0 ; line ;
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 3900
#include <bits/stdc++.h>
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool isPrime(int num){
    for(int i=2;i*i<=num;i++){
        if(num % i == 0){
            return false;
        }
    }
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int p;
    int ans = 0;
    for(int i=0;i<n;i++){
        cin >> p;
        if(isPrime(p))ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    if (s == "Y") {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}

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

int main()
{
	string s, p;
	cin >> s >> p;
	s += s;
	auto found = s.find(p);

	if (found != std::string::npos)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

long long int k;

void solve() {
	string s, s1;
	cin >> k >> s;
	int l = s.length();
	if (l > k) {
		s1 = s.substr(0, k);
		s1 += "...";
	}
	else
		s1 = s;
	cout << s1;

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	solve();

	return 0;
}

Measured memory_bytes: 3656
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int f=0;
  if(s[0]=='7'||s[1]=='7'||s[2]=='7') {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
	static long [][]dp;
	static int []w,v;
	static int n;
	public static long ans(int idx ,int rw) {
		if(rw<0)
			return -(int )1e9;
		if(idx==n)
			return 0;
		if(dp[idx][rw]!=-1)
			return dp[idx][rw];
		long take=v[idx]+ans(idx+1,rw-w[idx]);
		long leave=ans(idx+1,rw);
		if(take>leave)
		   return dp[idx][rw]=take;
		else 
		   return dp[idx][rw]=leave;
			
		
	}
	public static void main(String[] args) throws IOException {
        Scanner sc=new Scanner(System.in);
        PrintWriter pw =new PrintWriter(System.out);
        n=sc.nextInt();
        int rw=sc.nextInt();
        dp=new long[n][rw+1];
        v=new int[n];
        w=new int [n];
        for(long x[]:dp)
            Arrays.fill(x,(long) -1);
        for(int i=0;i<n;i++)
        {
          w[i]=sc.nextInt();
          v[i]=sc.nextInt();
        }
        
        pw.println(ans(0,rw));
        pw.flush();
		
		
	}
	
	static class Scanner {
		 
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}

}


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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  int nsubmit = 1;
  for (int i = 0; i < M; i++) {
    nsubmit *= 2;
  }
  int ans = (1900 * M + 100 * (N - M)) * nsubmit;
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

bool pq1(pair<int,int> p1,pair<int,int> p2) {
    return p1.second < p2.second;
}

int main(void)
{
    IOS
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> v1;
    priority_queue<int> v2;
    REP(i,n) {
        int a,b;
        cin >> a >> b;
        v1.emplace_back(make_pair(b,a));
    }

    sort(ALL(v1),pq1);
  
    int ans = 0;
    int cnt = 0;
    FOR(i,1,m+1) {
        while(v1[cnt].second <= i && cnt < n) {
            v2.push(v1[cnt].first);
            cnt++;
        }
        if (!v2.empty()) {
            ans += v2.top();
            v2.pop();
        }

    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i, 0, N) { cin >> h[i]; }
  int ans = INF;
  sort(all(h));
  rep(i, K - 1, N) { chmin(ans, h[i] - h[i - (K - 1)]); }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
h,w = map(int, input().split())
S = [input() for i in range(h)]
for r in range(h):
    l = ''
    for c in range(w):
        if S[r][c] == '#':
            l += '#'
        else:
            l += str(sum([x[max(0,c-1):min(c+2,w)].count('#') for x in S[max(0,r-1):min(r+2,h)]]))
    print(l)

Measured memory_bytes: 3064
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1e15+7;
const ll mod = 1e9 + 7;
const int MAX_N = 1e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

vector<vector<int>> kake(vector<vector<int>> &tim1,vector<vector<int>> &tim2) {
	vector<vector<int>> res = vector<vector<int>>(tim1.size(),vector<int>(tim1[0].size(),0));
	REP (i,tim1.size()) {
		REP (j,tim1[0].size()) {
			REP (k,tim2[0].size()) {
				res[i][k] += tim1[i][j] * tim2[j][k];
				res[i][k] %= mod;
			}
		}
	}
	return res;
}

class UnionFind {
private:
	vector<int> par;
public:
	vector<int> color;
	UnionFind(int N) { par = vector<int>(N, -1LL); color = vector<int>(N,-1);}
	int find(int x);
	ll size(int x);
	bool unite(int x, int y);
	bool same(int x, int y);
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

bool UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
	if (color[x] != -1 && color[y] != -1 && color[x] != color[y]) return false;
	else if (color[x] == -1 && color[y] != -1) color[x] = color[y];
	return true; 
}

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

signed main() {
	int s; cin >> s;
	int a = s /100;
	int b = s % 100;
	if (0 < a && a < 13 && 0 < b && b < 13) {
		cout << "AMBIGUOUS" << endl;
	} else if (0 < a && a < 13) {
		cout << "MMYY" << endl;
	} else if (0 < b && b < 13) {
		cout << "YYMM" << endl;
	} else {
		cout << "NA" << endl;
	}
}


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

int main()
{
    char a, b;
    cin >> a >> b;
    if (a=='H') {
        if (b=='H') {
            cout << 'H' << endl;
        } else {
            cout << 'D' << endl;
    }
    } else {
        if (b=='H') {
            cout << 'D' << endl;
        } else {
            cout << 'H' << endl;
        }    
    }
    return 0;
}

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

namespace Task {

const int MAXN = 100010;
const int MOD = 1e9 + 7;

#define long long long

int fac[MAXN];

inline void solve() {
    register int n, m;
    std::cin >> n >> m;
    if (std::abs(n - m) > 1) {
        std::cout << 0;
        return;
    }
    if (n > m) std::swap(n, m);
    register int max = m;
    fac[0] = 1;
    for (register int i = 1; i <= max; i++) fac[i] = (long)fac[i - 1] * i % MOD;
    if (n == m) {
        std::cout << 2 * (long)fac[n] * (long)fac[m] % MOD;
    } else {
        std::cout << (long)fac[n] * (long)fac[m] % MOD;
    }
}
}

int main() {
#ifdef DBG
    freopen("in.in", "r", stdin);
#endif
    Task::solve();
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <numeric>

using namespace std;
int main() {
    int N;
    cin >> N;

    vector<int> count[5];

    int digit = 0;
    int temp = N;
    while (temp != 0) {
        temp /= 10;
        digit++;
    }
    // cout << digit << endl;

    if (digit == 1) {
        cout << N << endl;
    } else if (digit == 2) {
        cout << 9 << endl;
    } else if (digit == 3) {
        cout << 9 + (N - 100) + 1 << endl;
        // cout << 9 + N%100 + (N/100 - 1) + 1 << endl;
    } else if (digit == 4) {
        cout << 900 + 9 << endl;
    } else if (digit == 5) {
        cout << 900 + 9 + (N - 10000) + 1 << endl;
    } else if (digit == 6) {
        cout << 90000 + 900 + 9 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll L, R; cin >> L >> R;
    ll D; cin >> D;
    int ans = 0;
    for(int i=L; i<=R; i++) if(i % D == 0) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
N, Q = map(int,input().split())
S = input()
T = [0]*N

for n in range(1,N):
  T[n] = T[n-1]
  if S[n-1] == "A" and S[n] =="C":T[n] += 1

for q in range(Q):
  l, r = map(int,input().split())
  print(T[r-1]-T[l-1])


Measured memory_bytes: 6188
n,m,r=map(int,input().split())

ans=3000000000

def permu(ju,now,su,co):
    if now==0:
        global ans
        ans=min(ans,su)
        return
    else:
        for i in range(r):
            if ju[i]:
                ju[i]=False
                su+=dp[co][rute[i]-1]
                permu(ju,now-1,su,rute[i]-1)
                ju[i]=True
                su-=dp[co][rute[i]-1]
    return

rute=list(map(int,input().split()))
dp=[[30000000 for i in range(n)] for i in range(n)]
for i in range(n):
    dp[i][i]=0
for i in range(m):
    a,b,c=map(int,input().split())
    dp[a-1][b-1]=c
    dp[b-1][a-1]=c
for i in range(n):
    for j in range(n):
        for k in range(n):
            dp[j][k]=min(dp[j][i]+dp[i][k],dp[j][k])


ju=[True for i in range(r)]
for i in range(r):
    ju[i]=False
    permu(ju,r-1,0,rute[i]-1)
    ju[i]=True
print(ans)

Measured memory_bytes: 50776
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
    string s;
    cin >> s;
    string ans = "Good";
    for(int i = 1; s[i] != '\0'; ++i){
        if(s[i] == s[i - 1]){
            ans = "Bad";
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int maxn = 1e3+2;

int n;
int a[maxn];
ll sum[3];
vector<int>answer;
vector<int>q;
int main()
{
    scanf("%d", &n);
    bool flag=true;
    sum[2]=-1000000002;
    int p;
    for(int i=1;i<=n;i++)
    {
        scanf("%d", &a[i]);
        if(a[i]>0)
        {
            flag=false;
            int h=i%2;
            sum[h]+=a[i];
        }
        else if(flag)
        {
            if(a[i]>sum[2])
            {
                p=i;
                sum[2]=a[i];
            }
        }
    }
    if(flag)
    {
        printf("%lld\n%d\n", sum[2],n-1);
        for(int i=n;i>p;i--)
        {
            printf("%d\n",i);
        }
        for(int i=1;i<p;i++)
        {
            printf("%d\n", 1);
        }
    }
    else
    {

        printf("%lld\n", max(sum[0],sum[1]));
        if(sum[0]>sum[1])
        {
            for(int i=2;i<=n;i+=2)
            {
                if(a[i]>0)
                {
                    q.push_back(i);
                }
            }
        }
        else
        {
            for(int i=1;i<=n;i+=2)
            {
                if(a[i]>0)
                {
                    q.push_back(i);
                }
            }
        }

        for(int i=n;i>q.back();i--)
        {
            answer.push_back(i);
        }
        for(int i=int(q.size())-1;i>0;i--)
        {
            int mid=(q[i]+q[i-1])/2;
            int sz=(q[i]-q[i-1])/2;
            for(int j=0;j<sz;j++)
            {
                answer.push_back(mid-j);
             //   cout<<mid-j<<endl;
            }
        }
        for(int i=1;i<int(q[0]);i++)
        {
            answer.push_back(1);
        }
        printf("%d\n", int(answer.size()));
        for(int i=0;i<int(answer.size());i++)
        {
            printf("%d\n", answer[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>

intmax_t digits(intmax_t n) {
  intmax_t res = 0;
  for (intmax_t i = n; i; i /= 10) ++res;
  return res;
}

int main() {
  intmax_t N;
  scanf("%jd", &N);

  intmax_t res = 20;
  for (intmax_t A = 1; A*A <= N; ++A) {
    if (N % A != 0) continue;

    intmax_t B = N / A;
    res = std::min(res, std::max(digits(A), digits(B)));
  }
  printf("%jd\n", res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void init_ios() {ios_base::sync_with_stdio(false); cin.tie(nullptr);}

long long N, C;

int main() {
    cin >> N >> C;
    vector<pair<long long, long long>> xv(N);
    for (auto& p : xv) cin >> p.first >> p.second;

    auto res = 0LL;

    vector<long long> cw(N), ccw(N);

    // clockwise
    {
        auto pos = 0LL, col = 0LL, mx = -(1LL << 62);
        for (int i = 0; i < N; ++i) {
            col += -(xv[i].first - pos) + xv[i].second;
            pos = xv[i].first;
            mx = max(mx, col);
            cw[i] = mx;
        }
        res = max(res, mx);
    }

    // counterclockwise
    {
        auto pos = C, col = 0LL, mx = -(1LL << 62);
        for (int i = N - 1; 0 <= i; --i) {
            col += -(pos - xv[i].first) + xv[i].second;
            pos = xv[i].first;
            mx = max(mx, col);
            ccw[i] = mx;
        }
        res = max(res, mx);
    }

    // counterclockwise -> clockwise
    {
        auto pos = C, col = 0LL;
        for (int i = N - 1; 1 <= i; --i) {
            col += -(pos - xv[i].first) + xv[i].second;
            pos = xv[i].first;
            res = max(res, col - (C - pos) + cw[i - 1]);
        }
    }

    // clockwise -> counterclockwise
    {
        auto pos = 0LL, col = 0LL;
        for (int i = 0; i < N - 1; ++i) {
            col += -(xv[i].first - pos) + xv[i].second;
            pos = xv[i].first;
            res = max(res, col - pos + ccw[i + 1]);
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3328
from sys import stdin
n = int(stdin.readline().rstrip())
a = [stdin.readline().rstrip().split() for _ in range(n)]
x = [stdin.readline().rstrip() for _ in range(n)][0]

k = 0
for i in range(len(a)):
  name = a[i][0]
  time = a[i][1]
  if name == x:
    k = i
  else:
    pass
s = 0 
for i in range(len(a)):
  if i <= k:
    pass
  else:
    s = s + int(a[i][1])
print(s)

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

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}
 
const int MAX = 510000;
const int MOD = 1000000007;
 
ll 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;
    }
}
 
// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;
  ll d = pow(10, 9) + 7;
  COMinit();
  int a = N - K;
  for (int i = 1; i <= K; i++) {
    if (a + 1 < i) {
      cout << 0 << "\n";
    } else {
      ll t = COM(K - 1, i - 1);
      ll k = a - (i - 1);
      ll b = COM(k + i, i) * t;
      b %= d;
      cout << b << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 12160
#include<iostream>
using namespace std;
long double x[4], y[4];
int main() {
	while (cin >> x[0] >> y[0]) {
		cin >> x[1] >> y[1];
		cin >> x[2] >> y[2];
		cin >> x[3] >> y[3];
		if (x[0] > x[1])swap(x[0], x[1]);
		if (x[2] > x[3])swap(x[2], x[3]);
		if (y[0] > y[1])swap(y[0], y[1]);
		if (y[2] > y[3])swap(y[2], y[3]);
		int OK = 1;
		if (x[1]<x[2] || x[0]>x[3])OK = 0;
		if (y[1]<y[2] || y[0]>y[3])OK = 0;
		if (OK == 0) { cout << "NO" << endl; }
		if (OK == 1) { cout << "YES" << endl; }
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
#define V 100001
vector<int> G[V],rG[V],v;bool u[V];int n,cmp[V];
  
void add_edge(int x,int y){G[x].push_back(y);rG[y].push_back(x);}
void dfs(int x){u[x]=1;rep(i,G[x].size())if(!u[G[x][i]])dfs(G[x][i]);v.push_back(x);} 
void rdfs(int x,int k){u[x]=1;cmp[x]=k;rep(i,rG[x].size())if(!u[rG[x][i]])rdfs(rG[x][i],k);}
int scc() {
  mem(u);v.clear();rep(i,n)if(!u[i])dfs(i);mem(u);
  int k=0;rrep(i,v.size())if(!u[v[i]])rdfs(v[i],k++);return k;
}

void Main() {
  int m;
  cin >> n >> m;
  while(m--) {
    int x,y;
    cin >> x >> y;
    add_edge(x,y);
  }
  scc();
  int q;
  cin >> q;
  while(q--) {
    int x,y;
    cin >> x >> y;
    pr(cmp[x]==cmp[y]);
  }
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 7268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }


int main() {
    int n,k; cin >> n >> k;
    vector<bool> ans(n, false);
    rep(i, k) {
        int d; cin >> d;
        rep(i, d) {
            int a; cin >> a;
            ans[a-1] = true;
        }

    }

    int ret = 0;
    rep(i, n) {
        if(!ans[i]) ret++;
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sd second
#define ft first
#define pr pair
#define vl vector<ll>
#define vs vector<string>
#define vmp vector<pair<ll,ll>>
#define en "\n"
#define lb lower_bound
#define ub upper_bound
#define vll vector<vector<ll>>
#define vmpl vector<vector<pair<ll,ll>>>
#define st size()
#define al(v) v.begin(),v.end()
#define cast static_cast<char>
#define ins insert
#define fata_fat ios_base::sync_with_stdio(false); cin.tie(NULL);
ll M=1e9+7,MAX=1e18,MIN=-1e18;
void bhaag()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
int main()
{   
     bhaag(); fata_fat;
     ll n; cin>>n;
     if(n>=400&&n<=599)cout<<8;
     else if(n>=600&&n<=799)cout<<7;
     else if(n>=800&&n<=999)cout<<6;
     else if(n>=1000&&n<=1199)cout<<5;
     else if(n>=1200&&n<=1399)cout<<4;
     else if(n>=1400&&n<=1599)cout<<3;
     else if(n>=1600&&n<=1799)cout<<2;
     else if(n>=1800&&n<=1999)cout<<1;
}


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


int main(){
    int a,b;
    char A;
    cin >> A;
    a = (int)(A);
    b = (int)('Z');
    if(a <= b){
        cout << 'A' << endl;
    }
    else{
        cout << 'a' << endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  
  int min_count;
  
  for (int i = 0; i < N; i++) {
    int A;
    int count = 0;
    cin >> A;
    for (int j = 0; A > 1; j++) {
      if (A % 2 != 0) {
        break;
      }
      A /= 2;
      count++;
    }
    if (i == 0) {
      min_count = count;
    }
    else if ((i > 0)&&(min_count > count)) {
      min_count = count;
    }
  }
  cout << min_count << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    void calc()
    {
        cin = new Scanner();
        int N=cin.nextInt();
        var  x= new Dictionary<string, long>();
        long ans=0;
        for(int i=0;i<N;i++)
        {
            char[] s= cin.next().ToCharArray();
            Array.Sort(s);
            string s2=new String(s);
          if(x.ContainsKey(s2)){ans+=x[s2];x[s2]++;}
          else x.Add(s2,1);
        }
        Console.WriteLine(ans);
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}


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

int main(){
  int s,s1,s2,s3;
  cin >> s;
  s3 = s/100;
  s2 = s/10 - s3*10;
  s1 = s - s3*100 - s2*10;
  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a=[]
for _ in range(m):
    a.append(list(map(int,input().split())))
    a[-1].pop(0)
p = list(map(int,input().split()))
res = 0

for i in range(0,2**n):
    flag = 0
    bis = bin(i)
    bi = bis[2:]
    bi = '0' * (n-len(bi)) + bi
    for k in range(0,len(a)):
        sumk = 0
        for j in range(0,len(a[k])):
            sumk += int(bi[a[k][j]-1])
        if sumk %2 == p[k]:
            flag += 1
    if flag == len(a):
        res += 1

print(res)

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

int main(int argc, char** argv)
{
	int n;
	scanf("%d", &n);
	for(int i=0; i<n; i++)
	{
		int a;
		scanf("%d", &a);
		if(a % 2 == 0 && a % 3 != 0 && a % 5 != 0)
		{
			puts("DENIED");
			return 0;
		}
	}
	puts("APPROVED");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(void)
{
	int n;
	int a[101]={0};
	while(cin>>n)
	{
		a[n]++;
	}
	int max=0;
	for(int i=0;i<101;i++)
	{
		if(a[i]>max)
		{
			max=a[i];
		}
	}
	for(int i=0;i<101;i++)
	{
		if(a[i]==max)
		{
			cout<<i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int top=0;
int S[1000000];

void push(int x)
{
	top++;
	S[top] = x;
}

int pop()
{
	top--;
	return S[top+1];
}

int main(void)
{
	int a, b;
	char s[100];
	
	while(scanf("%s", s) != EOF){
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a+b);
		}
		else if(s[0] == '-'){
			a = pop();
			b = pop();
			push(b - a);
		}
		else if(s[0] == '*'){
			a = pop();
			b = pop();
			push(a*b);
		}
		else{
			push(atoi(s));
		}
	}
	
	printf("%d\n", pop());
	
	return 0;
}


Measured memory_bytes: 2092
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll N,A,B;
    cin >> N >> A >> B;
    cout << max(0LL, ((N-1) * B + A) - ((N-1) * A + B)  + 1 )<< endl;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

n, m, k = map(int, input().split())
fr = UnionFind(n)
bl = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    bl[a-1].append(b-1)
    bl[b-1].append(a-1)
    fr.union(a-1, b-1)

for _ in range(k):
    c, d = map(int, input().split())
    if fr.same(c-1, d-1):
        bl[c-1].append(d-1)
        bl[d-1].append(c-1)

ans = []
for i in range(n):
    s = fr.size(i) - len(bl[i]) - 1
    ans.append(s)

print(*ans)

Measured memory_bytes: 39588
#include<bits/stdc++.h> 
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(s.length()<=n)
  	cout<<s;
  else
  {
    string str=s.substr(0,n);
    str+="...";
    cout<<str;
  }
    
  
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#define mod 1000000007
typedef long long ll;

int main(void) {
  ll i, j = 0, n, m, a;
  scanf("%lld%lld", &n, &m);
  ll dp[n + 5];
  for(i = 0; i < n; ++i) dp[i + 1] = 0;
  dp[0] = 1;
  for(i = 0; i < m; ++i) {
    scanf("%lld", &a);
    for(; j < a; ++j) 
      dp[j + 1] += dp[j], dp[j + 2] += dp[j], dp[j + 1] %= mod, dp[j + 2] %= mod;
    j = a + 1;
  }
  for(; j < n; ++j) 
    dp[j + 1] += dp[j], dp[j + 2] += dp[j], dp[j + 1] %= mod, dp[j + 2] %= mod;
  printf("%lld", dp[n]);
  return 0;
}

Measured memory_bytes: 896
// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

vector < ll > g[3];
string str;
map < char, ll > mp;

ll solve(ll id, ll id1, ll id2)
{
	ll cnt = upper_bound(g[id1].begin(), g[id1].end(), id) - g[id1].begin();

	ll ret = 0;

	for(auto it: g[id2])
	{
		if(it < id) continue;

		ret += cnt;

		ll minuss = 2 * id - it;

		auto jt = lower_bound(g[id1].begin(), g[id1].end(), minuss);

		if(jt == g[id1].end()) continue;

//		cout << *jt << " " << minuss << endl;

		if(*jt < id && *jt == minuss) ret--;
	}

//	cout << id1 << " " << id2 << " " << cnt << " " << ret << endl;

	return ret;
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n >> str)
    {
		ans = 0;

		for(ll i = 0; i < 3; i++) g[i].clear();

		mp['R'] = 0;
		mp['G'] = 1;
		mp['B'] = 2;

		for(ll i = 0; i < str.size(); i++)
		{
			g[mp[str[i]]].pb(i);
		}

		for(ll i = 1; i + 1 < str.size(); i++)
		{
			ll idx = mp[str[i]];

			ll idx1 = (idx + 1) % 3;
			ll idx2 = (idx + 2) % 3;

			ans += solve(i, idx1, idx2);
			ans += solve(i, idx2, idx1);
		}

		cout << ans << "\n";
    }
}





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

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

dis = [0] * n

for _ in range(m):
    x,y = map(int,input().split())
    edges[y-1].append(x-1)
    edges2[x-1].append(y-1)
    dis[x-1] = -1

q = []

for i in range(n):
    if dis[i] == 0:
        q.append(i)

while q:
    l = q.pop(0)
    for i in edges[l]:
        dis[i] = max(dis[i], dis[l] + 1)
        edges2[i].remove(l)
        if not edges2[i]:
            q.append(i)

print(max(dis))


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

int main(){
  int n,j=0,ba=0;
  string c;
  int total[11]={};
  cin >> n;
  while(n!=0){
    cin >> c;
    for(int i=0;i<100;i++){
      if(c[i]=='M'){
	total[j]++;
      }else if(c[i]=='S'){
	ba+=total[j]+1;
	total[j]=0;
      }else{
	total[j]+=ba+1;
	ba=0;
      }
      j++;
      if(j==n){
	j=0;
      }
    }
    
    sort(total,total+n);
    for(int i=0;i<n;i++){
      cout << total[i] << ' ';
    }
    cout << ba << '\n';
    cin >> n;
    j=0;
    ba=0;
    memset(total,0,sizeof(total));
  }
  return 0;
}



Measured memory_bytes: 3164
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,d,e,n;
  cin >> a >> b >> c >> d >> e >> n;
  cout << ((max({a,b,c,d,e})-min({a,b,c,d,e}) <= n) ? "Yay!":":(") << endl;
}

Measured memory_bytes: 256
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val a = cin.nextInt()
    val b = cin.nextInt()
    if (a >= 13) {
        println(b)
    } else if (a >= 6) {
        println(b/2)
    } else {
        println(0)
    }
    
}

Measured memory_bytes: 31264