akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
//typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    
    int ans=0;
    rep(i,N){
        if(a[i]==ans+1) ans++;
    }
    if(ans==0) cout << -1 << endl;
    else cout << N - ans << endl;
}


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

const int maxn = 5e5, mod = 998244353;
int n, k, fact[maxn + 3], finv[maxn + 3];

int qpow(int a, int b) {
	int c = 1;
	for (; b; b >>= 1, a = 1ll * a * a % mod) {
		if (b & 1) c = 1ll * a * c % mod;
	}
	return c;
}

void prework(int n) {
	fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = 1ll * fact[i - 1] * i % mod;
	}
	finv[n] = qpow(fact[n], mod - 2);
	for (int i = n; i; i--) {
		finv[i - 1] = 1ll * finv[i] * i % mod;
	}
}

inline int f(int x) {
	return x < mod ? x : x - mod;
}

int C(int n, int m) {
	return 1ll * fact[n] * finv[m] % mod * finv[n - m] % mod;
}

int solve(int r, int c) {
	if (r == c) {
		c--;
	}
	if (r - n < 0) {
		return 0;
	}
	if (r - n >= c) {
		return C(r + c, c);
	}
	int x = r - n + 1;
	return f(C(r + c, c) + mod - C(r + c, c - x));
}

int main() {
	scanf("%d %d", &n, &k);
	prework(k);
	int ans = 0;
	for (int i = k; i * 2 >= k; i--) {
		ans = f(ans + solve(i, k - i));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int a, b, c;
    cin >> a >> b >> c;
    int odp = 0;
    while (true)
    {
        if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
            break;
        int x = a / 2, y = b / 2, z = c / 2;
        a = y + z;
        b = x + z;
        c = x + y;
        ++odp;
        if (odp == 10000000)
        {
            cout << "-1";
            return 0;
        }
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,x[110],y[110],h[110],H,Hinf,hcounter,i,counter=0;
int main(){
  cin >> N;
  for(int j=0;j<N;j++){
    cin >> x[j] >> y[j] >> h[j];
  }

  for(int cx=0;cx<=100;cx++){
    for(int cy=0;cy<=100;cy++){
      counter=0;
      //cin >> x >> y >> h;
      if(h[0]>0){
        H=h[0]+abs(x[0]-cx)+abs(y[0]-cy);
        hcounter=1;
      }
      else{
        Hinf=abs(x[0]-cx)+abs(y[0]-cy);
        hcounter=0;
      }
      for(i=1;i<N;i++){
        //cin >> x >> y >> h;
        if(h[i]==0){
          if(hcounter==1){
            if(H<=abs(x[i]-cx)+abs(y[i]-cy)){
              counter++;
            }
            else break;
          }
          else{
            if(Hinf>=h[i]+abs(x[i]-cx)+abs(y[i]-cy)){
              Hinf = h[i]+abs(x[i]-cx)+abs(y[i]-cy);
              counter++;
            }
            else counter++;
          }
        }
        else{
          if(hcounter==1){
            if(H==h[i]+abs(x[i]-cx)+abs(y[i]-cy)) counter++;
            else break;
          }
          else{
            if(Hinf>=h[i]+abs(x[i]-cx)+abs(y[i]-cy)){
              H=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
              hcounter=1;
              counter++;
            }
            else break;
          }
        }
      }
      //cout << i << endl;
      if(counter==N-1){
        cout << cx << " " << cy << " " << H << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <set>

using namespace std;

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

    set<int> S;
    int cmd, x, L, R;
    while (q--)
    {
        cin >> cmd;
        if (cmd == 0)
        {
            cin >> x;
            S.insert(x);
            cout << S.size() << endl;
        }
        else if (cmd == 1)
        {
            cin >> x;
            // cout << (S.find(x) != S.end()) << endl;
            cout << S.count(x) << endl;
        }
        else if (cmd == 2)
        {
            cin >> x;
            S.erase(x);
            // remove(S.begin(), S.end(), x);
        }
        else
        {
            cin >> L >> R;
            set<int>::iterator it1 = S.lower_bound(L), it2 = S.upper_bound(R);
            while (it1 != it2)
            {
                cout << *it1 << endl;
                it1++;
            }

        }
        
        
    }
}


Measured memory_bytes: 12444
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	
	int grade[5];

	while (cin >> grade[0]) {

		cin >> grade[1] >> grade[2] >> grade[3] >> grade[4];
		int sum = 0;

		for (int i = 0; i < 5; i++) {

			if (grade[i] < 40)
				grade[i] = 40;

			sum += grade[i];

		}
		
		cout << sum / 5 << "\n";

	}

	return 0;

}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001

#define ad(x) int i = 100;
typedef long long ll;
// enum {
//   AST_INT,
//   AST_SYM,
//   AST_STR,
//   AST_FUNCALL,
// };



// double winProb(int Rp, int Rq) {
//     return 1/(1+pow(10, (Rq-Rp)/400.));
// }

// int R[1<<10];
// double dp[12][1<<10];
int k;
string s;

vector<string> a;

// int w[30010];
// int e[30010];

int main() {
    cin >> s >> k;
    // REP(i,)
    // cout << s.length() << endl;
    // if (s.length() == 1) {
    //     cout << s << endl;
    //     return 0;
    // }
    REP(i,0,s.length()) {
        REP(j,1,k+1) {
            a.push_back(s.substr(i,j));
        }
    }
    
    sort(a.begin(),a.end());
    a.erase(unique(a.begin(),a.end()),a.end());
    
    
    // for(auto c: a) {
    //     cout << c << endl;
    // }
    
    cout << a[k-1] << endl;
}

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

using namespace std;


#define PI 3.14159265
#define int long long

const int mod = 1e9 + 7;


main(){


	int n, m;

	cin >> n >> m;




	vector <int> a(m), dp(n);


	for(int i = 0; i < m; i++){
		cin >> a[i];
		dp[a[i] - 1] = -1;
	}

	if(dp[0] != -1) dp[0] = 1;

	if(dp[1] != -1){
		if(dp[0] != -1){
			dp[1] = 2;
		}else{
			dp[1] = 1;
		}
	}


	for(int i = 2; i < n; i++){
		if(dp[i] != - 1){
			if(dp[i - 1] != -1){
				dp[i] += dp[i - 1];
				dp[i] %= mod;
			}
			if(dp[i - 2] != -1){
				dp[i] += dp[i - 2];
				dp[i] %= mod;
			}
		}
	}

	// for(int e : dp){
	// 	cout << e << " ";
	// }
	// cout << endl;

	if(dp[n - 1] == -1){
		cout << 0 << endl;
	}else{
		cout << dp[n - 1] << endl;
	}





	return 0;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
S = input(); T = input()

def gcd(n, m):
    if n < m:
        return gcd(m, n)
    if m == 0:
        return n
    else:
        return gcd(m, n % m)

nm_gcd = gcd(N, M)
n, m = M // nm_gcd, N // nm_gcd
ans = N * M // nm_gcd
for i in range(nm_gcd):
    if S[i * m] != T[i * n]:
        ans = -1
        break

print(ans) 

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#define rep(i, k, n) for (int i = k; i < n; ++i)

using namespace std;

bool chmin(int &a, int b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main(){
  // prepare dp
  const int INF = 1 << 30;
  vector<int> dp(100010);
  rep(i, 0, 100010) dp[i] = INF;
  dp.at(0) = 0;

  // input
  int N;
  cin >> N;
  vector<int> h(N);
  rep(i, 0, N) cin >> h[i];
  rep(i, 1, N) {
    chmin (dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i > 1) chmin (dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  // rep(i,0,N) cout << dp[i] << " ";
  // cout << endl;
  cout << dp[N - 1] << endl;

  return 0;
}


Measured memory_bytes: 1024
def main():
    N = int(input())
    dp = [[0] * 10 for _ in range(10)]
    for i in range(1,N+1):
        tmp = str(i)
        left = int(tmp[0])
        right = int(tmp[-1])
        if left == 0 or right == 0:
            continue
        dp[left][right] += 1

    ans = 0
    for i in range(10):
        for j in range(10):
            ans += dp[i][j] * dp[j][i]

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 67828
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
    cin >> n;
	set<string> s;
	for (int i = 0; i < n; i++) {
		string t;
		cin >> t;
		s.insert(t);
	}
	cout << s.size() << "\n";
	return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;

int main()
{
	scanf("%d",&N);
	vector< vector<int> > A(N,vector<int>(3));
	FOR(i,0,N){
		int A [3];
		scanf("%d%d%d",&A [0],&A [1],&A [2]);
		sort(A,A + 3);
		if(A [0] * A [0] + A [1] * A [1] == A [2] * A [2]){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}

	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mx =1e6;
bool vis[mx];
int n,a[mx],dp[mx];
int solve(int i)
{
    if(i>=n-1)
        return 0;
    if(i==n-2)
        return abs(a[n-1]-a[n-2]);
    if(vis[i])
        return dp[i];
    int ans1,ans2;
    ans1=abs(a[i]-a[i+1]) + solve(i+1);
    ans2=abs(a[i]-a[i+2]) + solve(i+2);
    vis[i]=1;
    return dp[i]=min(ans1,ans2);
}
int main()
{
    memset(dp,0,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    cout<<solve(0)<<endl;
    return 0;

}



Measured memory_bytes: 11520
use proconio::{fastout, input};
use std::cmp::{max};

#[fastout]
#[allow(non_snake_case)]
#[allow(unused)]
fn main() {
    input! {
        N: usize,
        K: usize,
        P: [usize; N],
        C: [i64; N],
    }

    let calc = |startIndex|
    {
        let mut res: Option<i64> = None;
        let mut nodes: Vec<Option<(usize, i64)>> = vec![None; N];

        let mut k: usize = 0;
        let mut index = startIndex;
        let mut score = 0;

        while (k < K && nodes[index] == None)
        {
            nodes[index] = Some((k, score));

            index = P[index] - 1;
            score += C[index];

            k += 1;

            res = Some(max(res.unwrap_or(score), score));
        }

        match nodes[index] {
            Some((kk, ss)) => {
                let dk = k - kk;
                let dn = max(0, ((K - k) / dk) as i64 - 1) as usize;
                let ds = score - ss;

                if ds > 0 { score += ds * (dn as i64); }
                k += dn * dk;
            },
            None => {}
        }

        res = Some(max(res.unwrap_or(score), score));

        while (k < K)
        {
            index = P[index] - 1;
            score += C[index];

            k += 1;

            res = Some(max(res.unwrap_or(score), score));
        }
        return res.unwrap_or_default();
    };

    let ans = ((0..N).map(|i| calc(i))).max();
    println!("{:?}", ans.unwrap_or_default());
}


Measured memory_bytes: 2416
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  vector<int> x(5); rep(i, 5) cin >> x[i];
  rep(i, 5){
    if (x[i] == 0) cout << i + 1 << endl;
  }
}


Measured memory_bytes: 3596
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():

    n,x,MOD = get_nums_l()

    ans = x
    now = x

    known = {x}
    history = [x]

    for i in range(1, n):
        y = now**2 % MOD
        if y in known:
            # ループ長と合計を検出する
            last_known = i-1
            loop_sum = y
            while history[last_known] != y:
                loop_sum += history[last_known]
                last_known -= 1
            loop_len = i - last_known

            ans += (n-i) // loop_len * loop_sum

            # log(loop_len, loop_sum)

            for j in range((n-i) % loop_len):
                if (last_known + j) < len(history):
                    ans += history[last_known + j]
            break

        known.add(y)
        history.append(y)
        ans += y
        now = y
    
    print(ans)


main()

Measured memory_bytes: 78368
#include <stdio.h>
#include <stdlib.h>

int solve(int, int, int, int *);


int main() {
  int i, n, q, *A, m;

  scanf( "%d" , &n );
  A = (int *)malloc(n * sizeof(int));
  for( i=0; i<n; i++ ) scanf( "%d" , &A[i] );
  
  scanf( "%d" , &q );
  for( i=0; i<q; i++ ) {
    scanf( "%d" , &m );
    if ( solve(0, m, n, A) == 1 )printf( "yes\n" );
    else printf( "no\n" );
  }

  return 0;
}


int solve(int i, int m, int n, int *A) {
  int res;
  
  if ( m == 0 ) return 1;
  if ( i >= n ) return 0;
  if ( (solve(i+1, m, n, A)==0) && (solve(i+1, m-A[i], n, A)==0) ) res = 0;
  else res = 1;
  return res;
}



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

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;

const int INF = 1e9;
const int MOD = 1e9+7;

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

bool isKaibun(string s)
{
    for(int i = 0; i < s.length(); i++)
    {
        if(s[i] != s[s.length()-1-i]) return false;
    }
    return true;
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    double L; cin >> L;
    double x = L / 3.0;
    cout << x * x * x << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc152/tasks/abc152_f

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ll;

#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 DUMPLL(a, n) REP(_i, n) printf("%lld%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMPULL(a, n) REP(_i, n) printf("%llu%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 = 50;

struct edge { int id, to; };
vector<edge> G[V_MAX];
int dest;

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

ll dfs(int p, int v, ll s) {
  if (v == dest) return s;
  for (edge e : G[v]) {
    if (e.to == p) continue;
    ll ret = dfs(v, e.to, s | 1ULL << e.id);
    if (ret != 0) return ret;
  }
  return 0;
}

const int N_MAX = 50;
const int M_MAX = 20;
const int S_MAX = 1 << M_MAX;

int N;
// int a[N_MAX-1];
// int b[N_MAX-1];
int M;
int u[M_MAX];
int v[M_MAX];

ll S;
ll fs[N_MAX - 1];
ll dp0[S_MAX];
ll dp1[S_MAX];

void solve() {
  REP(i, M) {
    dest = v[i];
    ll ps = dfs(-1, u[i], 0);
    REP(j, N - 1) {
      fs[j] |= (ps >> j & 1ULL) << i;
    }
  }

  // DUMPULL(fs, N - 1);

  S = 1 << M;
  auto cur = dp0;
  auto nxt = dp1;
  cur[0] = 1;
  REP(i, N - 1) {
    fill(nxt, nxt + S, 0);
    REP(j, S) {
      nxt[j] += cur[j];
      nxt[j | fs[i]] += cur[j];
    }
    swap(cur, nxt);
  }

  // DUMPULL(cur, S);
  printf("%lld\n", cur[S - 1]);
}

void input() {
  scanf("%d", &N);
  REP(i, N - 1) {
    int a, b;
    scanf("%d%d", &a, &b);
    add_edge(i, a - 1, b - 1);
  }
  scanf("%d", &M);
  REP(i, M) {
    scanf("%d%d", u + i, v + i);
    u[i]--; v[i]--;
  }
}

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


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int N, W;
  cin >> N >> W;
  
  vector<vector<int>> dp(N + 10, vector<int>(111111, INF));
  dp.at(0).at(0) = 0;
  for (int i = 0; i < N; i++)
  {
    int w, v;
    cin >> w >> v;
    for (int sumV = 0; sumV < dp.at(0).size(); sumV++)
    {
      if (v + sumV < dp.at(0).size()) 
        chmin(dp.at(i + 1).at(v + sumV), dp.at(i).at(sumV) + w);
      
      chmin(dp.at(i + 1).at(sumV), dp.at(i).at(sumV));
    }
  }

  int ans = 0;
  for (int sumV = 0; sumV < dp.at(0).size(); sumV++)
  {
    int tmp = dp.at(N).at(sumV);
    if (tmp <= W) chmax(ans, sumV);
  }
  
  cout << ans << endl;
}

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

using namespace std;

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
//using namespace std;
  
  int main(){
  int n=0;
  int a[200000]={};

  scanf("%d",&n);
  //cout<<n;
  int count=0;
  int min=n+1;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    char judge=1;

    if(min>a[i]){
      min=a[i];
      count++;
    }
  }
    //cout<<a[2]<<endl;
  

    printf("%d",count);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 1000000100000000000
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define st size_t
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=10005;
const int NN=1000001;
const ll md=998244353;



int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int x,y;
    cin >> x >> y;
    int l=x;
    int m=y-x-1;
    int r=n-l-m;
    int ans[N]={0};
    for (int i=1;i<=n;i++){
        for (int j=i+1;j<=n;j++){
            if (j<=l || i>=y){
                ans[j-i]++;
                continue;
            }else
            if (i<=l && j>=y){
                ans[x-i+1+j-y]++;
                continue;
            }else
            if (j>x && j<y && i<=x){
                ans[min(j-i,(y-j)+1+(x-i))]++;
                continue;
            }else
            if (i>x && i<y && j>=y){
                ans[min(j-i,(i-x)+1+(j-y))]++;
                continue;
            }else{
            //cout << i << " " << j << E;
            //cout << min(j-i,i-x+(y-j)+1) << E;
            ans[min(j-i,i-x+(y-j)+1)]++;
            }
        }
    }

    for (int i=1;i<n;i++){
        if (i==1){
            cout << n << E;
            continue;
        }
        if (i==n-1){
            cout << 0 << E;
            continue;
        }



        cout << ans[i] << E;


    }
    r0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	ll n;
	ll k,x,y;
	cin>>n>>k>>x>>y;
	ll sum=0;
	for(int i=0;i<n;i++){
		if(i<k) sum+=x;
		else{
			sum+=y;
		}
	}
	cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define speed ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n) for(ll i=a;i<n;i++)
#define even(x) (((x)%(2))==(0))
#define odd(x) (((x)%(2))==(1))
#define meme(x) memset(x, 0, sizeof(x))
#define mod 1000000007

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

int main()
{
    speed
    
    ll n,k;
    cin>>n>>k;
    ll a[n];

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

    int x=0;
    int y=a[k-1];

    for(int i=k;i<n;i++)
    {
        if(a[i]>a[x])
        {
            cout<<"Yes\n";
            x++;
        }
        else
        {
            cout<<"No\n";
            x++;
        }
    }
    
        
    
    return 0;
}

Measured memory_bytes: 5180
if __name__ == "__main__":
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    data = []
    for x in range(M):
        p,x = map(int, input().split())
        p -= 1
        data.append([p, x])
    result = 2 ** 60
    for p,x in data:
        res = 0
        for i,t in enumerate(T):
            if (i == p):
                res += x
            else:
                res += t
        print (res)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 924844033;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll d[100000];
ll mov[61][100000];
int main() {
	int n; cin >> n;
	ll x[100000];
	rep(i, n) {
		cin >> x[i];
	}
	rep(i, n - 1) {
		d[i] = x[i + 1] - x[i];
	}
	int m;ll k; cin >> m >> k;
	int a[100000];
	rep(j, n - 1) {
		mov[0][j] = j;
		mov[1][j] = j;
	}
	rep(i, m) {
		cin >> a[i]; a[i] -= 2; swap(mov[1][a[i]], mov[1][a[i] + 1]);
	}
	Rep(i, 2, 61) {
		rep(j, n-1) {
			mov[i][j] = mov[i - 1][mov[i - 1][j]];
		}
	}
	int cnt = 0;
	while (k) {
		cnt++;
		if (k % (ll)2) {
			ll nex[100000];
			rep(j, n - 1) {
				nex[j] = d[mov[cnt][j]];
			}
			rep(j, n - 1) {
				d[j] = nex[j];
			}
		}
		k /= (ll)2;
	}
	ll sum = x[0];
	cout << sum << endl;
	rep(i, n-1) {
		sum += d[i];
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 51584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
//#include <stdio.h>

using namespace std;

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

    int A;
    int B;
    int K;

    int main;
    int count = 0;
    int ans;

    cin >> A >> B >> K;

    if(A >= B){
        main = B;
    }else{
        main = A;
    }

    for(int i = 0; i < main; i++){
        if(A % (main - i) == 0 && B % (main - i) == 0){
            count++;
            if(count == K){
                cout << main - i;
            }
        } 
    }

}

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

int main(){
  string s , p;
  cin >> s >> p;
  s += s;
  if(s.find(p) == -1){ 
  cout << "No" << endl;
    }
  else{
  cout << "Yes" << endl;
    }
  return 0;
}



Measured memory_bytes: 3232
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

signed main()
{
	int m1, d1, m2, d2;
	cin >> m1 >> d1;
	cin >> m2 >> d2;
	if (m1 != m2)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
long long line[1000000] , nul[1000000];
long long INF = 1000000000000 ;
int main () {
  int N , K ;
  cin >> N >> K ;
  for(int i = 0 ; i < N ; i++ ) cin >> line[i] ;
  sort(line,line+N) ;
  long long ans = INF ;
  for(int j = 0 ; j < N - K + 1 ; j++ ){
    long long pre = 0 ;
    pre = line[j+K-1] - line[j] ;
    ans = min(ans,pre) ;
  }
  cout << ans << endl ;
  //for(int i = 0 ; i < N - 1 ; i++ ) cout << nul[i] ;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll X;
    cin >> X;
    ll p = X / 500, q = X % 500, r = q / 5;
    cout << p * 1000 + r * 5;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )

using namespace std;

const int N = 1e5 + 5;

char s[N];

int n, ar[N], sz[N], p[N], sum[N];

int get (int v)
{
    return v == p[v] ? v : p[v] = get(p[v]);
}

void unite (int a, int b)
{
    a = get(a);
    b = get(b);

    if (a == b) return;

    if (sz[a] > sz[b])
        swap(a, b);

    sum[b] += sum[a];
    sum[b] %= 26;

    sz[b] += sz[a];
    p[a] = b;
}

main ()
{
    scanf("%s", s + 1);
    s[0] = 'a';
    n = strlen(s);
    s[n] = 'a';
    for (int i = 0; i < n; i++)
    {
        sz[i] = 1;
        p[i] = i;

        ar[i] = s[i + 1] - s[i];

        if (ar[i] < 0)
            ar[i] += 26;

        sum[i] = ar[i];
    }
    for (int i = 0; i < n; i++)
        unite(i, n - i - 1);

    int m, a, b;
    cin >> m;
    while (m--)
    {
        scanf("%d%d", &a, &b);
        unite(a - 1, b);
    }
    for (int i = 0; i < n; i++)
    {
        if (p[i] == i && sum[i] != 0)
        {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
}


Measured memory_bytes: 2048
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

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

  int n;
  cin >> n;
  map<string, ll> m;
  REP(i, n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    m[s]++;
  }
  ll res = 0;
  for(auto x : m) {
    res += x.second * (x.second-1) / 2;
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 8064
#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/STACK: 2000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define lli long long int
#define ld long double
#define vec vector
#define forn(a) for(lli a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define presicion(x) cout<<fixed<<setprecision(x)
#define deb(x) cerr<<#x<<" = "<<x<<endl
#define PI 3.14159265358979323
#define sen(ang) sin((ang)*PI/180)

using namespace std;

int main(){
    IOS;

    presicion(20);
    ld a, b; cin>>a>>b;
    cout<<a/b<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	static Main instance = new Main();
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
      
        int AC = 0;
        int WA = 0;
        int TLE = 0;
        int RE = 0;
        for(int i = 0; i < n; i++){
          String s = sc.next();
          switch(s){
            case "AC":AC++;break;
            case "WA":WA++;break;
            case "TLE":TLE++;break;
            case "RE":RE++;break;
          }
        }
 
		
		System.out.println("AC"+" "+"x"+" "+AC);
        System.out.println("WA"+" "+"x"+" "+WA);
        System.out.println("TLE"+" "+"x"+" "+TLE);
        System.out.println("RE"+" "+"x"+" "+RE);
        
	}
}

Measured memory_bytes: 59072
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int n = 0;
		
		for(int i=0; i<=2; i++) {
			if(S.charAt(i) == T.charAt(i)) {
				n += 1;
			}
		}
		System.out.println(n);
	}
}

Measured memory_bytes: 25172
#include<stdio.h>

int selectionSort(int A[], int N) {
  int i, j, t, sw = 0, minj;

  for(i = 0; i < N - 1; i++) {
    minj = i;

    for(j = i; j < N; j++) {
      if (A[j] < A[minj]) minj = j;
    }

    t = A[i]; A[i] = A[minj]; A[minj] = t;
    if (i != minj) sw++;
  }

  return sw;
}

int main() {
  int A[100], N, i, sw;

  scanf("%d", &N);

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

  sw = selectionSort(A, N);

  for(i = 0; i < N; i++) {
    if (i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int K_MAX = 1e5+5;
vector<int> dp(K_MAX,1e9);
bool update(int &x,int y){
  if(x>y){
    x = y;
    return true;
  }
  return false;
}

int solve(){
  int K;cin >> K;
  deque<int> dq(1,1);
  dp[1] = 1;
  int u;
  while(!dq.empty()){
    //cout << dq.front().first SP dq.front().second << endl;
    u = dq.front(); dq.pop_front();
    if(u==0) return dp[0];
    if(update(dp[u*10%K], dp[u])) dq.push_front(u*10%K);
    if(update(dp[(u+1)%K], dp[u]+1)) dq.push_back((u+1)%K);
  }
  return dp[0];
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cout << solve() << endl;
  return 0;
}


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

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

int main(){
  int64_t a, b, ans;
  ans = 1;
  cin >> a >> b;
  int64_t g = gcd(a, b);
  for(int64_t i = 2; i * i <= g; i++){
    if(g % i == 0){
      ans++;
      while(g % i == 0){
        g /= i;
      }
    }
  }
  if(g != 1){
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll ans = 0;
  if (K - A < 0)
  {
    ans = K;
    cout << ans << endl;
    return 0;
  }
  if (K - A - B < 0)
  {
    ans = K;
    cout << ans << endl;
    return 0;
  }
  if (K - A - B >= 0)
  {
    ans = A - (K - A - B);
    cout << ans << endl;
    return 0;
  }

  return 0;
}


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

int N;long M;

long gojohou(long a,long b) {
  long _a=max(a,b);long _b=min(a,b);
  if (_a%_b==0) return _b;
  else return gojohou(_b,_a%_b);
}

long ruijo(long a){
  if (a%2L!=0) return 0;
  else {
    return 1L+ruijo(a/2);
  }
}

int main() {
  cin >> N >> M;vector<long> A(N,0L);bool kigu=true;
  for (int i=0;i<N;i++) {
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  long koubaisuu=A.at(0);
  for (int i=1;i<N;i++) {
    if (koubaisuu>2*M || ruijo(A.at(i-1))!=ruijo(A.at(i))) {
      koubaisuu=20000000005L;
      break;
    }
    if (A.at(i)!=A.at(i-1)) {
      long kouyakusuu=gojohou(koubaisuu,A.at(i));
      koubaisuu=(koubaisuu*A.at(i))/kouyakusuu;
    }
  }
  if (koubaisuu<=2*M && kigu) cout << (M+koubaisuu/2)/koubaisuu << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 1024
s=input()
if s=='SUN':
  print('7')
elif s=='MON':
  print('6')
elif s=='TUE':
  print('5')
elif s=='WED':
  print('4')
elif s=='THU':
  print('3')
elif s=='FRI':
  print('2')
else:
  print('1')


Measured memory_bytes: 2940
#include <iostream>
#include <limits>
#include <cmath>

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    int sum_weight = 0;
    int min_weight = numeric_limits<int>::max();
    for (size_t i = 0; i < n; ++i) {
        int m;
        cin >> m;
        sum_weight += m;
        if (m < min_weight) min_weight = m;
    }
    int num = n;
    x -= sum_weight;
    if (x >= min_weight) num += floor(x / min_weight);
    cout << num << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=2e5+7;

int n,m,a[N],b[N];
int comb[N];

int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,m){
		scanf("%d%d",a+i,b+i);
		if(a[i]==1) comb[b[i]]|=1;
		if(b[i]==n) comb[a[i]]|=2;
	}
	rep(i,1,n) if(comb[i]==3) return puts("POSSIBLE"),0;
	puts("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
main(){
  int a,b;
  int i,j;
  int c,d;
  int count;
  char til[1000][1000];
  int mem[1000][1000]={0};
  while(1){
    scanf("%d %d",&a,&b);
    if(a==0&&b==0)break;
    for(i=0;i<a;i++){
      for(j=0;j<b;j++){
	scanf(" %c",&til[i][j]);
      }
    }
    i=0;
    j=0;
    count=0;
    for(c=0;c<1000;c++){
      for(d=0;d<1000;d++){
	mem[c][d]=0;
      }
    }
    while(count!=1){
      if(til[i][j]=='.')break;
      if(til[i][j]=='>'){
	j=j+1;
	if(mem[i][j]==1){
	  count=1;
	}
	mem[i][j]=1;
      }
      if(til[i][j]=='^'){
	i=i-1;
	if(mem[i][j]==1){
	  count=1;
	}
	mem[i][j]=1;
      }
      if(til[i][j]=='<'){
	j=j-1;
	if(mem[i][j]==1){
	  count=1;
	}
	mem[i][j]=1;
      }
      if(til[i][j]=='v'){
	i=i+1;
	if(mem[i][j]==1){
	  count=1;
	}
	mem[i][j]=1;
      }
    }
    if(count==1){
      printf("LOOP\n");
    }
    else{
      printf("%d %d\n",j,i);
    }
  }
  return 0;
}
  

Measured memory_bytes: 4632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
//https://pitsbuffersolution.com/compro/atcoder/arc092c.php
int n;
vector<P>a,b;
ll solve(){
   ll ans=0; 
    int i=0,j=0;
    vector<int>c(2*n,0);
    while(i<n||j<n){
        if(a[i].first<b[j].first){
            c[a[i].second]=1;
            i++;
        }else{
            for(int k=b[j].second-1;k>=0;k--){
                if(c[k]){
                    c[k]=0;
                    ans++;
                    break;
                }
            }
            j++;
        }
    }
   return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n;
    rep(i,n){
        int ai,bi;
        cin>>ai>>bi;
        a.push_back(P(ai,bi));
    }
    rep(i,n){
        int ci,di;
        cin>>ci>>di;
        b.push_back(P(ci,di));
    }
    a.push_back(P(1234567,1234567));
    b.push_back(P(1234567,1234567));
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());    
    cout<<solve()<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int player1 = 0, player2 = 0;

		int round = Integer.parseInt(sc.nextLine());
		for (int i = 0; i < round; i++) {
			String[] cards = sc.nextLine().split("[\\s]+");
			if (cards[0].equals(cards[1])) {
				player1++;
				player2++;
			} else if (VictoryDecision(cards[1], cards[0])) {
				player1 += 3;
			} else {
				player2 += 3;
			}

		}

		System.out.println(player1 + " " + player2);

	}

	static boolean VictoryDecision(String str1, String str2) {
		int looplimit = str1.length();
		boolean defVictory = true;
		if (str1.length() > str2.length()) {
			looplimit = str2.length();
			defVictory = false;
		}
		for (int i = 0; i < looplimit; i++) {
			if (str1.charAt(i) == str2.charAt(i)) {
				continue;
			} else {
				return CharDecision(str1.charAt(i), str2.charAt(i));
			}
		}
		return defVictory;
	}

	static boolean CharDecision(char a, char b) {
		if ((int) a < (int) b) {
			return true;
		} else {
			return false;
		}
	}

}



Measured memory_bytes: 33772
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 長さ3以上は使わないとしてよい

S = '$$' + read().rstrip().decode('utf-8')

# 最後の長さ -> 文字列の個数
N = len(S)
INF = 10 ** 9
one = [-INF] * N; one[1] = 0
two = [-INF] * N; two[1] = 0

for i in range(2,N):
    # 2 -> 1
    x = two[i-1] + 1
    # 1 -> 1
    if S[i] != S[i-1]:
        y = one[i-1] + 1
        if x < y:
            x = y
    one[i] = x
    # 1 -> 2
    x = one[i-2] + 1
    # 2 -> 2
    if S[i-1:i+1] != S[i-3:i-1]:
        y = two[i-2] + 1
        if x < y:
            x = y
    two[i] = x

answer = max(one[-1],two[-1])
print(answer)

Measured memory_bytes: 19184
o,f,i=998244353,[1],1
while i<o>>8:f+=[f[-1]*i%o];i+=1
c=lambda n,k:f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)
n,m=map(int,input().split())
w,u=3*m,n-1
a=c(w+u,u)-n*c(n+m-2,u)
while-~m<min(w,n):m+=2;a-=c(n,m)*c(2*u+w-m>>1,u)
print(a%o)

Measured memory_bytes: 129100
import sys
from scipy.sparse.csgraph import floyd_warshall as f
def main():
  n,m,l,*t=map(int,sys.stdin.buffer.read().split())
  d=[[0]*(n+1)for _ in range(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=f(f(d,0)<=l)-1
  d[d>n]=-1
  print('\n'.join(str(int(d[i]))for i in zip(*[iter(t[m*3+1:])]*2)))
main()

Measured memory_bytes: 36760
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

// ===============================================================

int main() {
	ll n; cin >> n;
	vl a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	map<ll, ll> data;
	ll ans = 0;
	for (int i = 0; i < n; i++)
		data[a[i]]++;
	for (auto p : data) {
		ll x = p.first;
		ll y = p.second;
		if (x > y) ans += p.second;
		if (x < y) ans += y - x;
	}
	cout << ans << endl;
}

Measured memory_bytes: 10092