akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N), remain(N);
    REP(i, N) cin >> A[i];

    ll ans = 0;
    REP(i, N) {
        ll r = 0;
        if(i > 0) r = remain[i-1];
        ll tmp = (r + A[i]) / 2;
        ans += tmp;
        // cerr << "i = " << i << " tmp = " << tmp << endl;
        // if(i > 0) remain[i-1] = 0;
        if(tmp > 0)
            remain[i] = max(0ll, (r + A[i] - 2 * tmp));
    }

    // cerr << "debug" << endl;
    // REP(i, N) cerr << remain[i] << endl;
    // cerr << "end of debug" << endl;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i,m) cin >> x[i];
    if (n >= m) { cout << 0 << endl; return 0;}
    ssort(x);
    int ans = x[m-1] - x[0];
    vector<int> d(m-1);
    rep(i,m-1) d[i] = x[i+1] - x[i];
    gsort(d);
    rep(i,n-1) ans -= d[i];
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3920
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

int main() {
	long N, M; cin >> N >> M;

	if (2 * N >= M) cout << M / 2 << endl;
	else cout << N + (M - 2 * N) / 4 << endl;
}

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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, a, b;
  cin >> a >> b;
  for (n = 0; n < 10*b+15; n++)
    if (((n*2)/25 == a) && (n/10 == b))
      return cout << n << ende, 0;
  cout << -1 << ende;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define EPS 1e-10
 
double a,b,c,d,e,f,g,h;
double det(){
    double dx1,dy1,dx2,dy2;
    dx1 = a-c;
    dy1 = b-d;
    dx2 = e-g;
    dy2 = f-h;
    return dx1*dy2 - dy1*dx2;
}
int main(){
    int n;
    cin>>n;
    while(n--){
        cin>>a>>b>>c>>d>>e>>f>>g>>h;
        cout<<(fabs(det())<EPS?"YES":"NO")<<endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define S second
#define F first
#define ll long long
#define ld long double

using namespace std;

const ll N = 1e5 + 5, mod = 1e9 + 7;

int arr[N];

int main()
{
    int n, xx, k;
    scanf("%d%d", &n, &k);
    for(int i = 0 ; i < n ; i++) scanf("%d", arr + i);
    int mn = 1e9;
    for(int i = 0 ; i + k <= n ; i++)
    {
        mn = min(mn, min(abs(arr[i]), abs(arr[i + k - 1])) + abs(arr[i] - arr[i + k - 1]));
    }
    printf("%d\n", mn);
    return 0;
}


Measured memory_bytes: 768
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		String lineString = sc.nextLine();

		// 出力
		System.out.println(lineString.equals("ARC") ? "ABC" : "ARC");
		sc.close();
	}
}


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

int main() {
  string s;
  cin >> s;
  int y, m, d;
  sscanf(s.c_str(), "%d/%d/%d", &y, &m, &d);
  if ((y * 100 + m) * 100 + d <= 20190430)
    cout << "Heisei\n";
  else
    cout << "TBD\n";
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {

    val N = readLine()!!.toInt()
    val sList = (1..N).map { readLine()!! }

    val map = mutableMapOf<String, Int>()
    for(i in sList){
        if(map[i] == null){
            map[i] = 1
        }else{
            map[i] = map[i]!! + 1
        }
    }

    val max = map.maxBy { it.value }!!.value
    val answer = map.filter { it.value == max }.toSortedMap()

    answer.forEach{
        println(it.key)
    }
}


Measured memory_bytes: 104572
#include <iostream>

using namespace std;

int main() {
  
  int h, w;
  cin >> h >> w;

  string str[100];
  for (int i = 0; i < h; i++ ) {
    cin >> str[i];
  }

  for (int i = 0; i < h; i++ ) {
    int a = -1;
    int s = 0;
    for (int j = 0; j < w; j++ ) {
      if (str[i][j] == 'c') {
        s = 1;
        a = -1;
      }
      if (s == 1) {
        a++;
      }
      if (j < w -1) {
        cout << a << ' ';
      }else{
        cout << a;
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3192
#include <iostream>

using namespace std;

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



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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int h, w;
  cin >> h >> w;
  vector<string> mas(h);
  int cnt = 0;
  rep(i, h) cin >> mas[i];
  rep(i, h) rep(j, w) cnt += (mas[i][j] == '#');

  if(mas[0][0] == '#') {
    cout << -1 << endl;
    return 0;
  }

  auto in = [&](int i, int j)->bool{
    return 0<=i&&i<h&&0<=j&&j<w;
  };

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

  queue<Pi> que;
  vector<vint> dist(h, vint(w, inf));
  que.emplace(0, 0);
  dist[0][0] = 0;
  while(!que.empty()) {
    Pi p = que.front(); que.pop();
    int y = p.first, x = p.second;
    if(y == h && x == w) break;
    rep(i, 4) {
      int ny = y+dy[i], nx = x+dx[i];
      if(!in(ny, nx) || mas[ny][nx] == '#') continue;
      if(dist[y][x]+1 < dist[ny][nx]) {
	dist[ny][nx] = dist[y][x]+1;
	que.emplace(ny, nx);
      }
    }
  }
  if(dist[h-1][w-1] == inf) cout << -1 << endl;
  else cout << h*w-dist[h-1][w-1]-cnt-1 << endl;

  return 0;
}


Measured memory_bytes: 256
x = int( input() )

def prime_test( n ):
    if n < 2:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    for k in range( 3, int( n ** 0.5 ) + 1 ):
        if n % k == 0:
            return False
    return True

while True:
    if prime_test( x ) == True:
        print( x )
        break
    x += 1


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int L = A + B;
  int R = C + D;
  if (L > R) {
    cout << "Left" << endl;
  } else if (L == R) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define mod 1000000007
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define MAX 100001

vector <int> adj[MAX];
int deg[MAX];
int vis[MAX];
int par[MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n , m;
    cin >> n >> m;
    int u, v;
    for (int i = 0; i < n + m - 1; i++) {
        cin >> u >> v;
        deg[v]++;
        adj[u].pb(v);
    }
    queue <int> qu;
    for (int i = 1; i <= n; i++) {
        if (!deg[i]) qu.push(i);
    }
    while (!qu.empty()) {
        int s = qu.front();
        vis[s] = true;
        qu.pop();
        for (auto it : adj[s]) {
            deg[it]--;
            if (!deg[it]) {
                par[it] = s;
                qu.push(it);
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << par[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 7424
n1, n2, n3 = [int(i) for i in input().split()]

n4 = [0] * n1

for i1 in range(n3):
    n4[int(input()) - 1] += 1

for i2 in range(n1):
    if n2 - n3 + n4[i2] <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 4680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  bool can = false;
  for (int i = 0; i < B; i++) if (i * A % B == C) can = true;
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int x = 1;
    int count = 0;
    while(pow(2,count) < k && count < n){
        x = x*2;
        count++;
    }
    x += (n-count)*k;
    cout << x << "\n";
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int n;
  string str;
  cin>>n;
  cin>>str;
  
  int index=n-1;
  while(index>0&&str[index]=='W'){
    index--;
  }
  n=index+1;

  int left=0;
  int right=n-1;
  int cnt=0;
  char temp;
  while(left<n&&str[left]=='R'){
    left++;
  }
  while(right>0&&str[right]=='W'){
    right--;
  }
  while(left<right){
    cnt++;
    left++;
    right--;
    while(left<n&&str[left]=='R'){
      left++;
    }
    while(right>0&&str[right]=='W'){
      right--;
    }
  }
  cout<<cnt<<endl;
  return(0);
}

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

int main(){
	ll n,count=0,i;
	int max=0,memo=0;
	cin >> n;
	vector<ll> a(n);
	cin >> a.at(0);

	for(i=1;i<n;i++){
		cin >> a.at(i);
		if(a.at(i-1)>a.at(i)){
			count+=a.at(i-1)-a.at(i);
			a.at(i)=a.at(i-1);
		}
	}
	cout << count<<endl;

}

Measured memory_bytes: 4828
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin>>n;
	vector<int> A;
	vector<int> B;
	vector<int> C;
	for(int i =0;i<n;i++)
	{
		int a; int b; int c;
		cin>>a>>b>>c;
		A.push_back(a);
		B.push_back(b);
		C.push_back(c);
	}
	
	int dp[n][3];
	dp[0][0]= A[0];
	dp[0][1] = B[0];
	dp[0][2]= C[0];
	for(int i =1;i<n;i++)
	{
		dp[i][0]= A[i] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = B[i] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = C[i]+ max(dp[i-1][0], dp[i-1][1]);
	 } 
	 cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
	 return 0;
}

Measured memory_bytes: 2796
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N, K;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;

    int ans = (N - 1 + K - 2) / (K - 1);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<double> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    map<P, ll> cnt;
    for (auto& a : A) {
        ll val = llround(a * 1e9);
        int two = 0;
        int five = 0;
        while (val % 2 == 0) {
            ++two;
            val /= 2;
        }
        while (val % 5 == 0) {
            ++five;
            val /= 5;
        }
        ++cnt[{two, five}];
    }
    ll ans = 0;
    for (auto& p1 : cnt) for (auto& p2 : cnt) {
        if (p1.first.first + p2.first.first >= 18 && p1.first.second + p2.first.second >= 18) {
            if (p1 < p2) {
                ans += p1.second * p2.second;
            } else if (p1 == p2) {
                ans += p1.second * (p1.second - 1) / 2;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4780
def main():
    n = int(input())
    *A, = map(int, input().split())
    a = 1
    if 0 in A:
        print(0)
    else :
        for i in A:
            a*=i
            if a > 10**18:
                print(-1)
                break
        else :
            print(a)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21600
#include <iostream>
using namespace std;
 
const int MAX_N = 110000;
 
int memo[MAX_N]; // memo[i] が i についての答え
 
int rec(int n){
  if(n == 0) return 0;
  if(memo[n] != -1) return memo[n];
  
  int res = n;
  
  for(int i=1; i<=n; i*=6) res = min(res, rec(n-i)+1);
  for(int j=1; j<=n; j*=9) res = min(res, rec(n-j)+1);
  
  return memo[n] = res;
}
 
int main(){
  int N; cin >> N;
  for(int i=0; i<MAX_N; i++) memo[i] = -1;
  cout << rec(N) << endl;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

ll h, w;

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

    cin >> h >> w;

    h -= 2;
    w -= 2;

    cout << abs(w * h) << endl;

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define per(i,n) for (int i = (n)-1; i >=0; --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    map<int,int> m;
    int a;
    rep(i,3){
        cin>>a;
        m[a]++;
    }
    
    for(auto p: m){
        if(p.second%2==1){
            cout << p.first << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

qlen = ni()
q = [0] * (10**5 + 1)

pri = [0]* (10**5 + 1)
for num in range(1, 10**5):
    if is_prime(num):
        pri[num] = 1
for num in range(1, 10**5):
    if pri[(num + 1)//2] ==1 and pri[num] == 1:
        q[num] = q[num-1] + 1
    else:
        q[num] = q[num-1]

l, r = [], []
for i in range(qlen):
    li, ri = na()
    l.append(li)
    r.append(ri)
for li, ri in zip(l, r):
    print(q[ri]- q[li-1])


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

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

  int card[4][13] = {};
  for(int i=0;i<n;i++){
    string suit;
    int num;
    cin>>suit>>num;

    if(suit == "S") card[0][num-1] = 1;
    if(suit == "H") card[1][num-1] = 1;
    if(suit == "C") card[2][num-1] = 1;
    if(suit == "D") card[3][num-1] = 1;
  }

  string str[4] = {"S","H","C","D"};
  for(int i=0;i<4;i++){
     for(int j=0;j<13;j++){
       if(card[i][j] == 1) continue;
       cout<<str[i]<<" "<<j+1<<endl;
     }
  }

  return 0;

}


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

const int MAXN = 1e6+5;
const ll p = 1e9+7;
const ll inv3 = (p+1)/3;

ll fact[MAXN], invfact[MAXN], inv[MAXN], n, m, k, c[MAXN];
ll p3[MAXN], pinv3[MAXN];

ll comb(int x, int y) {
	if (x < 0 || y < 0 || x < y)
		return 0;
	return fact[x]*invfact[y]%p*invfact[x-y]%p;
}

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

ll inve(ll x) { return exp(x, p-2); }

void init() {
	inv[1] = fact[0] = fact[1] = invfact[0] = invfact[1] = 1;
	for (int i = 2; i < MAXN; ++i) {
		inv[i] = (p - (p/i) * inv[p%i] % p) % p;
		fact[i] = i*fact[i-1]%p;
		invfact[i] = inv[i]*invfact[i-1]%p;
	}

	p3[0] = pinv3[0] = 1;
	for (int i = 1; i < MAXN; ++i)
		p3[i] = 3*p3[i-1]%p, pinv3[i] = inv3*pinv3[i-1]%p;
}

int main() {
	cin >> n >> m >> k;
	init();
	for (int i = 0; i <= k; ++i)
		c[0] = (c[0] + pinv3[i])%p;
	for (int i = 1; i < MAXN-300000; ++i)
		c[i] = 3*(p+1)/2%p*(c[i-1]+p-comb(i+k, k)*pinv3[k+1]%p)%p;
	ll ans = 0;
	for (int i = 0; i <= m; ++i)
		ans = (ans + comb(n-1+i, i)*pinv3[i]%p*c[n-1+i]%p)%p;
	cout << ans*p3[m+k]%p << endl;
}

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

int n,x,m;

int a,b;

int cal(int x)
{
	return x*x%m;
}
int ans,s;

signed main()
{
	cin>>n>>x>>m;
	a=x,b=x;
	a=cal(a),b=cal(cal(b));
	while(a!=b)		//aÌøÒ»²½  bÌøÁ½²½ 
	{
		a=cal(a);
		b=cal(cal(b));
	}
	a=x;
	int cnt=1;
	while(a!=b)
	{
		a=cal(a);
		b=cal(b);
	}
	
	s+=b;
	b=cal(b);
	
	while(b!=a)
	{
		cnt++;
		s+=b;
		b=cal(b);
	}
	int cnt2=0;
	for(int i=x;i!=a;)
	{
		cnt2++;
		ans+=i;
		if(cnt2==n)	break;
		i=cal(i);
	}
	if(cnt2==n)
	{
		cout<<ans<<endl;
		return 0;
	}
	int p=n-cnt2;
	ans+=s*(p/cnt);
	p=p%cnt;
	for(int i=1;i<=p;i++)
	{
		ans+=a;
		a=cal(a);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3632
num = 200000
L = [True] * (num+1)
L[0] = False
L[1] = False
for i in range( 2, int(num**0.5)+ 2 ):
    if not L[i]:
        continue
    for j in range(i*2, num+1, i):
        L[j] = False

p = [ x for x in range(num+1) if L[x] ]

while True:
    n = int(input())
    if n == 0:
        break
    print(sum(p[0:n]))



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

int n, t, a, b, e[2], ans;
long long dp[35], ac, INF = 1e9+7;
P s[2][200005];

int main(){
	scanf("%d%d", &n, &t); t++;
	rep(i,n){
		scanf("%d%d", &a, &b);
		s[!a][e[!a]++] = {a+1,b+1};
	}
	sort(s[0], s[0]+e[0], [](P &a, P &b){
		return a.second * (b.first-1) < b.second * (a.first-1);
	});// a.second * (b.first-1) < b.second * (a.first -1)
	sort(s[1], s[1]+e[1]);
	fill(dp,dp+30, INF);
	dp[0] = 1;
	rep(i,e[0]) for(int j=29; j>0; j--){
		dp[j] = min(dp[j], dp[j-1] * s[0][i].first + s[0][i].second);
	}
	rep(i,e[1]+1){
		ans = max(ans,(int)(i+upper_bound(dp, dp+30, t-ac)-dp-1));
		if(i<e[1]){
			ac += s[1][i].second;
			if(t <= ac) break;
		}
	}
	printf("%d\n", ans);
}

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

string s, t;

bool ok(const string& a, const string& b)
{
	for(int i=0;i<a.length();++i){
		if(a[i]!=b[i]&&a[i]!='?') return false;
	}
	return true;
}

void solve()
{
	const int n = s.length();
	const int m = t.length();
	string inf = string(n+1,'z');
	string ans = inf;
	for(int i=0;i+m<=n;++i)if(ok(s.substr(i,m), t)){
		string tmp = s;
		for(int j=0;j<i;++j)if(s[j]=='?')tmp[j]='a';
		for(int j=i;j<i+m;++j)tmp[j]=t[j-i];
		for(int j=i+m;j<n;++j)if(s[j]=='?')tmp[j]='a';
		ans = min(ans, tmp);
	}
	if(ans == inf) cout<<"UNRESTORABLE\n";
	else cout<<ans<<'\n';
}

int main()
{
	cin >> s >> t;
	solve();
	return 0;
}

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


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

  string s;
  string t;
  cin >> s >> t;
  int ans = 0;
  rep(i,s.size()){
    if(s[i]!=t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 3796
import java.util.Scanner;

public class Main {

	public static void main (String[] args)  {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
		System.out.println(Math.max((10-n)*100, 0)+r);
		
 
	}

	
	

}


Measured memory_bytes: 23124
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int Maxn = 100010;
typedef long long ll;
int n,ans,res;
int main()
{
    cin>>n;
    ans = 0;
    res = n;
    while(n)
    {
        ans+=n%10;
        n/=10;
    }
    if(res % ans == 0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
front = [0]
back = [0]
for i in range(len(A)):
    front.append(gcd(A[i], front[i]))
    back.append(gcd(A[len(A) - i - 1], back[i]))
ans = 0
for i in range(len(A)):
    ans = max(gcd(front[i], back[len(A) - i - 1]), ans)
print(ans)


Measured memory_bytes: 94688
/*
Vim shortcuts:
  :pc -> close scratch window
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORR(it,cont) for(auto it=rbegin(cont);it!=rend(cont);++it)
#define FOR(it,cont) for(auto it=begin(cont);it!=end(cont);++it)
#define ALL(cont) begin(cont), end(cont)
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define MODDING(a,b) (a) = AS_MOD(a,b)
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
int N,K;
ll INF=1000ll*1000ll*1000ll*1000ll;
vector<ll> fromL;
vector<ll> fromR;
int main(int argc, char **argv, char **envp) {
  cin >> N >> K;
  fromL.reserve(N);
  fromR.reserve(N);
  fromR.pb(0);
  int m=N;
  REP(i,N) {
    ll x;
    scanf("%lld", &x);
    if (x==0) {--K;continue;}
    if (x>0) fromR.pb(x);
    if (x<0) fromL.pb(-x);
  }
  fromL.pb(0);
  reverse(ALL(fromL));
  ll ans=INF;
  for(int i=0;i<fromL.size();++i) {
    int w=K-i;
    if (w>=fromR.size())continue;
    ans=min(ans,fromR[w]+fromL[i]*2);
    ans=min(ans,fromR[w]*2+fromL[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
void solve(string s)
{
    int count = 0;
    int l = s.length();
    for(int i = 0;i<l;i++)
    {
        if(s[i] == s[l-1-i])
            continue;
        else
        {
            s[l-1-i] = s[i];
            count++;
        }
    }
    cout<<count;
}
int main()
{
    string s;
    cin>>s;
    solve(s);
    return 0;
}

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

int main() {
	int N, M;
	std::vector<int> T, P, X;

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

	std::cin >> M;
	for (int i = 0; i < M; ++i) {
		int p, x;
		std::cin >> p >> x;
		P.push_back(p);
		X.push_back(x);
	}

	for (int j = 0; j < M; ++j) {
		int p = P.at(j)-1;
		int x = X.at(j);
		int sum = 0;
		for (int i = 0; i < N; ++i) {
			if (p == i) {
				sum += x;
			} else {
				sum += T.at(i);
			}
		}
		std::cout << sum << std::endl;
	}
	
}



Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k,c = LI()
s = input()
t = []
for i in range(n):
    if s[i] == 'o':
        t.append(1)
    else:
        t.append(0)

cnt = 0
i = n-1
d = defaultdict(int)
while i >= 0:
    if t[i] == 1:
        cnt += 1
        d[i] = 1
        i -= c+1
        continue
    i -= 1
i = 0
f = defaultdict(int)
while i < n:
    if t[i] == 1:
        f[i] = 1
        i += c+1
        continue
    i += 1
        
if cnt > k:
    print('')
    quit()

lst = []
for i,j in f.items():
    if j == 1 and d[i] == 1:
        lst.append(i+1)
lst.sort()
for i in lst:
    print(i)


     



Measured memory_bytes: 83316
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

int main(){
    ll A, B, C;
    cin >> A >> B >> C;
    ll K;
    cin >> K;
    rep(i,0,K){
        if(A>=B)B*=2;
        else if(B>=C)C*=2;
      
        if(A<B&&B<C){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H!=0&&W!=0){
      for(i=0;i<H;i++){   
	if(i==0||i==H-1){
	  for(j=0;j<W;j++){
	  printf("#");
	}
	}
	if(1<=i&&i<=H-2){
	for(j=0;j<W;j++){
	  if(j==0||j==W-1){
	    printf("#");
	  }
	  else { 
	    printf(".");
	  }
	}   
      }
      printf("\n");
      }
      printf("\n");
    }
    if(H==0&&W==0){
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt=0,ans=0;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='T') {
      cnt++;
    }
    else {
      cnt--;
    }
    if(cnt>ans) {
      ans=cnt;
    }
  }
  cout << ans*2 << endl;
}

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

int main(){
    int test, a, b;
    cin >> test;
    vector<int> num;

    for(int i = 0; i < test; i++){
        cin >> a;
        if(a == 0){
            cin >> b;
            num.push_back(b);
        }
        else if(a == 1){
            cin >> b;
            cout << num[b] << endl;
        }
        else if(a == 2){
            num.pop_back();
        }
    }
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>p(n); for(auto&&i:p)cin>>i;
	int ans=0;
	for(int i=0;i<n-1;++i){
		if(p.at(i)==i+1){
			swap(p.at(i),p.at(i+1));
			++ans;
		}
	}
	cout<<ans+(p.back()==n)<<"\n"s;
}


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

double n, k;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    int res = 0;
    while (n >= 1)
    {
        res++;
        n /= k;
    }
    cout << res;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

int main() {
    int H, W, di[4] = {1, 0, -1, 0}, dj[4] = {0, 1, 0, -1};
    cin >> H >> W;
    vector<string> s(H);
    rep(i, H) cin >> s[i];
    string ans = "Yes\n";
    rep(i, H) {
        rep(j, W) {
            if (s[i][j] == '.') continue;
            ans = "No\n";
            rep(k, 4) {
                int ni = i + di[k], nj = j + dj[k];
                //cout << "ni=" << ni << " nj=" << nj << " s=" << s[ni][nj] << endl;
                if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
                if (s[ni][nj] == '#') ans = "Yes\n";
            }
            if (ans == "No\n") {
                cout << ans;
                return 0;
            }
            //cout << i << j << ans;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
bool fm,lm;
int main(){
	string s;cin>>s;
	int tmp=0;
	tmp+=s[1]-'0';tmp+=10*(s[0]-'0');
	if(tmp<=12&&tmp){
		fm=true;
	}
	tmp=s[3]-'0';tmp+=10*(s[2]-'0');
	if(tmp<=12&&tmp)lm=true;
	if(lm&&fm){
		cout<<"AMBIGUOUS";
	}else if(!lm&&!fm){
		cout<<"NA";
	}else if(lm&&!fm){
		cout<<"YYMM";
	}else{
		cout<<"MMYY";
	}
}

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

int main() {
  // 入力
  int H, W;
  cin >> H >> W;
  vector<vector<string> > s(H, vector<string>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> s[i][j];
    }
  }

  for (int i = 0; i < H; i++) {
    char c = 'A';
    for (int j = 0; j < W; j++, c++) {
      if (s[i][j] == "snuke") {
        cout << c << i + 1 << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 384
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

const int N=110;
int n,a[2*N];
int main() {
    R(n);
    REP(i,2*n) R(a[i]);
    sort(a,a+2*n);
    int ans=0;
    REP(i,n) ans+=a[2*i];
    W(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

string s;

ll dp[100009][13];

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

    cin >> s;
    dp[0][0] = 1;
    rep(i, s.size()) {
        if(s[i] == '?')
            rep(j, 13) rep(k, 10)(dp[i + 1][(j * 10 + k) % 13] += dp[i][j]) %=
                mod;
        else
            rep(j, 13)(dp[i + 1][(j * 10 + s[i] - '0') % 13] += dp[i][j]) %=
                mod;
    }
    cout << dp[s.size()][5] << endl;
}

Measured memory_bytes: 10704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

struct BIT {
    ll n;
    VL dat;
    void init(ll in) {
        n = in + 1;
        dat.resize(n + 1);
        for (int i = 0; i <= n; i++) dat[i] = 0;
    }
    ll sum(ll i) {
        ll s = 0;
        while (i >= 0) {
            s += dat[i];
            i = (i & (i + 1)) - 1;
        }
        return s;
    }
    void add(ll i, ll x) {
        while (i <= n) {
            dat[i] += x;
            i |= i + 1;
        }
    }
};

int main() {
    ll n;
    cin >> n;
    VL a(n), sorted(n);
    FOR(i, 0, n) {
        cin >> a[i];
        sorted[i] = a[i];
    }
    SORT(sorted);
    int ok = 0, ng = n;
    BIT bit;

    ll border = ((n * (n + 1) / 2) + 1) / 2;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        int midnum = sorted[mid];
        bit.init(2 * n + 1);
        int sum = 0;
        bit.add(sum + n, 1);
        ll result = 0;
        FOR(i, 0, n) {
            sum += (a[i] >= midnum ? 1 : -1);
            result += bit.sum(sum + n);
            bit.add(sum + n, 1);
        }
        if (result >= border)ok = mid;
        else ng = mid;
    }
    cout << sorted[ok] << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define LL long Long
using namespace std;

int main()
{
   int n;
   while(scanf("%d",&n)!=EOF)
   {
       int a=n/100;
       int b=n%100;
       if(a<=12&&a>0&&b<=12&&b>0)
        cout<<"AMBIGUOUS"<<endl;
       else if(b<=12&&b>0)
        cout<<"YYMM"<<endl;
       else if(a<=12&&a>0)
        cout<<"MMYY"<<endl;
       else
        cout<<"NA"<<endl;
   }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc132/tasks/abc132_e

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

//------------------------------------------------------------------------------
const int V_MAX = 1e5;

vector<int> G[V_MAX];

void add_edge(int u, int v) {
  G[u].push_back(v);
}

//------------------------------------------------------------------------------
const int N_MAX = 1e5;
const int INF = 1e9;

typedef pair<int, int> P;

int N, M;
int S, T;

int d[N_MAX][3];

void bfs(int s, int t) {
  queue<P> que;
  fill(d[0], d[N], INF);
  d[s][0] = 0;
  que.push(P(S, 0));
  while (!que.empty()) {
    P p = que.front(); que.pop();
    int v = p.first;
    int k = p.second;
    if (v == t && k == 0) break;
    for (int u : G[v]) {
      int k2 = (k + 1) % 3;
      int d2 = d[v][k] + 1;
      if (d[u][k2] < INF) continue;
      d[u][k2] = d[v][k] + 1;
      que.push(P(u, k2));
    }
  }
}

void solve() {
  bfs(S, T);
  // DUMP2D(d, N, 3);
  if (d[T][0] < INF) printf("%d\n", d[T][0] / 3);
  else puts("-1");
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, M) {
    int u, v;
    scanf("%d%d", &u, &v);
    add_edge(u - 1, v - 1);
  }
  scanf("%d%d", &S, &T);
  S--;
  T--;
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
int main(){

  int n,m,p,tmp,result=1145141919;
  vector <int> d;
  cin>>n>>m>>p;
  for(int i=0;i<m;i++){
    cin>>tmp;
    if(tmp-p<0) tmp+=n;
    d.push_back(tmp-p);
  }
  sort(d.begin(),d.end());
  for(int i=0;i+1<d.size();i++){
    result=min(result,d[i]+2*(n-d[i+1]));
    result=min(result,2*d[i]+n-d[i+1]);
  }
  result=min(result,d[d.size()-1]);
  result=min(result,n-d[0]);
  cout<<result*100<<endl;
  
  return 0;
}

Measured memory_bytes: 3236
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

long long pow_mod(long long x, long long n, long long mod_num) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) { res = (res * x) % mod_num; }
        x = (x * x) % mod_num;
        n = (n >> 1);
    }
    return res;
}

class Combi_Num {
    public:
    long long mod_num;
    std::vector<long long> factorial, factorial_inv, inv;
    Combi_Num() {}
    Combi_Num(const int n, const long long mod_num_in) {
        mod_num = mod_num_in;
        factorial.resize(n+1, 0);
        factorial_inv.resize(n+1, 0);
        inv.resize(n+1, 0);
        factorial[0] = 1;
        factorial_inv[0] = 1;
        inv[0] = 1;
        for (int i = 1; i <= n; i++) {
            factorial[i] = (factorial[i-1] * i) % mod_num;
            inv[i] = pow_mod(i, mod_num - 2, mod_num);
            factorial_inv[i] = (factorial_inv[i-1] * inv[i]) % mod_num;
        }
    }

    long long combi(const int n, const int r) {
        return (factorial[n] * ((factorial_inv[r] * factorial_inv[n-r]) % mod_num)) % mod_num;
    }

    long long perm(const int n, const int r) {
        return (factorial[n] * factorial_inv[n-r]) % mod_num;
    }
};

const long long MOD = 1000000007;

const int MAX_N = 100050;
long long N, A, B, C;
Combi_Num combi_num = Combi_Num(MAX_N*3, MOD);

int main(int argc, char **argv) {
    std::cin >> N >> A >> B >> C;

    long long PA = (A * combi_num.inv[A+B]) % MOD;
    long long PB = (B * combi_num.inv[A+B]) % MOD;

    //std::cout << PA << " " << PB << " " << combi_num.inv[2] << " " << 2 * combi_num.inv[4] << " " << (25 * combi_num.inv[50]) % MOD << std::endl;

    long long ret = 0;

    for (int M = N - 1; M <= (N - 1)*2; M++) {
        long long prob = pow_mod(PA, N - 1, MOD) * pow_mod(PB, M - (N - 1), MOD);
        //std::cout << M << " " << prob << std::endl;
        prob = ((prob % MOD) * PA) % MOD;
        ret += (M + 1) * ((prob * combi_num.combi(M, N - 1)) % MOD);
        ret = ret % MOD;

        prob = pow_mod(PB, N - 1, MOD) * pow_mod(PA, M - (N - 1), MOD);
        prob = ((prob % MOD) * PB) % MOD;
        ret += (M + 1) * ((prob * combi_num.combi(M, N - 1)) % MOD);
        ret = ret % MOD;
    }

    if (C != 0) {
        long long tmp = ((A + B + C) * combi_num.inv[A+B]) % MOD;
        ret = (ret * tmp) % MOD;
    }

    std::cout << ret << std::endl;

    return 0;
}

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

int main() {
	// your code goes here
	char str[10001];
	int len, i,n,s,e,w,a1,a2;
	
	cin>>str;
	len = strlen(str);
	n = s = e = w = 0;
	
	for(i=0; i<len; i++){
	    
	    if(str[i]=='N')
	        n=1;
	    else if(str[i]=='S')
	        s=1;
	   else if(str[i]=='W')
	        w=1;
	   else if(str[i]=='E')
	        e=1;
	    
	}
	//cout<<n;
	if(n==1)
	    if(s==0){
	        cout<<"No";
	        return 0;
	    }

    if(s==1)
	    if(n==0){
	        cout<<"No";
	        return 0;
	    }   
        	
    if(w==1)
	    if(e==0){
	        cout<<"No";
	        return 0;
	    }
	if(e==1)
	    if(w==0){
	        cout<<"No";
	        return 0;
	    }
	    
cout<<"Yes";
return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define INF 999999999
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void visit(Graph &h, int v, int s, int r,
  vector<int> &no, vector< vector<int> > &comp,
  vector<int> &prev, vector< vector<int> > &next, vector<Weight> &mcost,
  vector<int> &mark, Weight &cost, bool &found) {
  const int n = h.size();
  if (mark[v]) {
    vector<int> temp = no;
    found = true;
    do {
      cost += mcost[v];
      v = prev[v];
      if (v != s) {
        while (comp[v].size() > 0) {
          no[comp[v].back()] = s;
          comp[s].push_back(comp[v].back());
          comp[v].pop_back();
        }
      }
    } while (v != s);
    FOR(j,comp[s]) if (*j != r) FOR(e,h[*j])
      if (no[e->src] != s) e->weight -= mcost[ temp[*j] ];
  }
  mark[v] = true;
  FOR(i,next[v]) if (no[*i] != no[v] && prev[no[*i]] == v)
    if (!mark[no[*i]] || *i == s)
      visit(h, *i, s, r, no, comp, prev, next, mcost, mark, cost, found);
}
Weight minimumSpanningArborescence(const Graph &g, int r) {
  const int n = g.size();
  Graph h(n);
  REP(u,n) FOR(e,g[u]) h[e->dst].push_back(*e);

  vector<int> no(n);
  vector< vector<int> > comp(n);
  REP(u, n) comp[u].push_back(no[u] = u);

  for (Weight cost = 0; ;) {
    vector<int> prev(n, -1);
    vector<Weight> mcost(n, INF);

    REP(j,n) if (j != r) FOR(e,h[j])
      if (no[e->src] != no[j])
        if (e->weight < mcost[ no[j] ])
          mcost[ no[j] ] = e->weight, prev[ no[j] ] = no[e->src];

    vector< vector<int> > next(n);
    REP(u,n) if (prev[u] >= 0)
      next[ prev[u] ].push_back(u);

    bool stop = true;
    vector<int> mark(n);
    REP(u,n) if (u != r && !mark[u] && !comp[u].empty()) {
      bool found = false;
      visit(h, u, u, r, no, comp, prev, next, mcost, mark, cost, found);
      if (found) stop = false;
    }
    if (stop) {
      REP(u,n) if (prev[u] >= 0) cost += mcost[u];
      return cost;
    }
  }
}

int main(){
	int V,E,r,s,t,w;
	scanf("%d%d%d",&V,&E,&r);
	Graph g(V);
	for(;E--;)scanf("%d%d%d",&s,&t,&w),g[s].push_back(Edge(s,t,w));
	printf("%d\n",minimumSpanningArborescence(g,r));
}

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

char ary[100010];
int main(){
	cin>>ary;
	int N=strlen(ary);
	int a=-1,b=-1;
	for(int i=0;i<N;i++){
		if(ary[i]==ary[i+1]){
			a=i+1;b=i+2;
			break;
		}
		else if(ary[i]==ary[i+2]){
			a=i+1;b=i+3;
		}
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}



Measured memory_bytes: 384