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

using namespace std;

#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()

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

	string s;
	cin >> s;
	bool ans = false;
	for(int i = 0; i < s.size() - 1; i++) {
		if(s[i] == s[i + 1]) {
			ans = true;
			break;
		}
	}
	if(ans) {
		cout << "Bad";
	} else {
		cout << "Good";
	}
}		



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=2e5+5;

int n;
int A[M];

int main(){
	scanf("%d",&n);
	int fir=0,sec=0;
	for(int i=1;i<=n;i++){
		int &x=A[i];scanf("%d",&x);
		if(x>fir)sec=fir,fir=x;
		else if(x>sec)sec=x;
	}
	for(int i=1;i<=n;i++)printf("%d\n",A[i]==fir?sec:fir);
	return 0;
}

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

int main()
{
	int i;
	long long int n;
	int time, total;
	int *a, *b;

	scanf("%lld %d", &n, &time);

	a = (int*)malloc(n * sizeof(int));
	b = (int*)malloc(n * sizeof(int));

	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 1; i < n; i++) {
		b[i - 1] = a[i] - a[i - 1];
	}
	total = time;
	for (i = 0; i < n-1; i++) {
		if (b[i] >= time)total += time;
		else total += b[i];
	}
	printf("%d", total);
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll INF = numeric_limits<ll>::max()/2;

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

    int n,m;cin>>n>>m;
    vector<ll> x(n),y(n),z(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>z[i];
    }
    ll res=0;
    for(int i=0;i<(1<<3);i++){
        vector<ll> v(n);
        for(int j=0;j<n;j++){
            if(i & (1<<2)) v[j] += x[j];
            else v[j] -= x[j];

            if(i & (1<<1)) v[j] += y[j];
            else v[j] -= y[j];

            if(i & (1)) v[j] += z[j];
            else v[j] -= z[j];
        }
        sort(v.rbegin(),v.rend());
        ll tmp=0;
        for(int i=0;i<m;i++) tmp += v[i];
        res=max(res,tmp);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s1,t;cin>>s1>>t;
    int n=s1.length(),tn=t.length();
    bool abc=0;
    for(int i=n-tn;i>=0;i--){
        bool yn=1;
        for(int j=i;j<=i+tn-1;j++){
            if(!(s1[j]==t[j-i]||s1[j]=='?')){
                yn=0;
                break;
            }
        }
        if(yn==1){
            abc=1;
            for(int j=i;j<=i+tn-1;j++){
                s1[j]=t[j-i];
            }
            for(int j=0;j<n;j++){
                if(s1[j]=='?')s1[j]='a';
            }
            cout<<s1<<endl;
            return 0;
        }
        
    }
    if(abc==0)cout<<"UNRESTORABLE"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> matrix;

int actualR[1005];
int actualC[1005];
int row[1000005];
int col[1000005];
bool rowUsed[1005];
bool colUsed[1005];
const int MOD = 1000000007;

void die() {
  cout << "0\n";
  exit(0);
}

void solve() {
  int r, c;
  cin >> r >> c;
  ll ret = 1;
  for(int i = 1; i <= r; i++) {
    int curr;
    cin >> curr;
    if(row[curr]) {
      die();
    }
    row[curr] = i;
    actualR[i] = curr;
  }
  for(int j = 1; j <= c; j++) {
    int curr;
    cin >> curr;
    if(col[curr]) {
      die();
    }
    col[curr] = j;
    actualC[j] = curr;
  }
  int rr = 0;
  int cc = 0;
  for(int x = r*c; x > 0; x--) {
    int numAvail = rr*cc - (r*c-x);
    if(row[x] == 0 && col[x] == 0) {
      ret *= numAvail;
      ret %= MOD;
    }
    else if(row[x] && col[x] == 0) {
      int g = 0;
      for(int j = 1; j <= c; j++) {
        if(x < actualC[j]) g++;
      }
      ret *= g;
      ret %= MOD;
    }
    else if(col[x] && row[x] == 0) {
      int g = 0;
      for(int i = 1; i <= r; i++) {
        if(x < actualR[i]) g++;
      }
      ret *= g;
      ret %= MOD;
    }
    else {
      //
    }
    if(row[x] && !rowUsed[row[x]]) {
      rowUsed[row[x]] = true;
      rr++;
    }
    if(col[x] && !colUsed[col[x]]) {
      colUsed[col[x]] = true;
      cc++;
    }
  }
  cout << ret << endl;
}

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


Measured memory_bytes: 2304
#include <iostream>
#include <string>
using namespace std;
int main()
{
    // 入力
    string s;
    cin >> s;

    char text1;
    char text2;
    text1 = s[0];
    for (int i = 1; i < 4; i++) {
        if (s[i] != text1) {
            text2 = s[i];
            break;
        }
    }

    int count1 = 0;
    int count2 = 0;
    for (int i = 0; i < 4; i++) {
        if (s[i] == text1) {
            count1++;
        } else if(s[i] == text2) {
            count2++;
        }
    }
    string result = "No";
    if (count1 == 2 && count2 == 2) {
        result = "Yes";
    }

    // 出力
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
   "bufio"
   "fmt"
   "os"
)

func solution(s string) int {
   out := 0
   b := []byte{}
   p := ""
   for i := 0; i < len(s); i++ {
        b = append(b, s[i])
        if string(b) == p {
                continue
        }
        p = string(b)
        b = []byte{}
        out++
   }
   return out
}

func main() {
   r := bufio.NewReader(os.Stdin)
   var s string
   fmt.Fscan(r, &s)
   fmt.Println(solution(s))
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  int n,k,ans = 0;
  cin >> n >> k;
  vector<int> l(n);
  REP(i,n) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  for (int i = n -1;i >= 0;i--) {
    if (k != 0) {
      ans += l[i];
      k--;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;

fn conv(ss: &[char]) -> Vec<u32> {
    let mut m = HashMap::new();
    for s in ss {
        *m.entry(s).or_insert(0) += 1;
    }
    ss.iter().map(|s| m[s]).collect()
}

fn main() {
    input! {
        ss: chars,
        tt: chars,
    }
    let s = conv(&ss);
    let t = conv(&tt);
    println!("{}",
        if s == t {"Yes"} else {"No"});
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define what_is(x) cerr << #x <<" is " << x << endl;
typedef long long ll;
const int MOD = 998244353;
const double PI = 3.141592653589793;
const int INF =  1e9 + 7;
const int nax = 100005;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc = 1;
	// cin >> tc;
	while (tc--) {
		ll a, b, c, k;
		cin >> a >> b >> c >> k;

		ll ans = 0;
		if (a <= k) {
			ans += a;
			k -= a;
		}
		else {
			ans += k;
			k = 0;
		}
		if (b <= k) {
			k -= b;
		}
		else {
			k = 0;
		}
		if (c <= k) {
			ans -= c;
			k -= c;
		}
		else {
			ans -= k;
			k = 0;
		}
		cout << ans;
	}
	return 0;
}




















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

ll n,q;
vector<ll> G[200010];
bool used[200010];
ll p[200010];
ll ans[200010];
void dfs(int k, int x) {
    used[k] = 1;
    x = x + p[k];
    ans[k] = x;

    for (int i = 0; i < G[k].size(); i++) {
        if (used[G[k][i]]) continue;
        dfs(G[k][i], x);
    }
}

int main() {
    cin >> n >> q;
    for (int i = 0; i < n - 1; i++) {
        int a,b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for (int i = 0; i < q; i++) {
        ll pp,x;
        cin >> pp >> x;
        pp--;
        p[pp] += x;
    }

    dfs(0,0);

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

Measured memory_bytes: 25856
x,y=map(int,input().split())

a = [1,3,5,6,7,8,10,12]
b = [4,6,9,11]
c = [2]
if (x in a and y in a) or(x in b and y in b) or(x in c and y in c):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <stdio.h>
 
int main()
{
  /* 数値（整数） */
  int A = 0;
  int B = 0;
 
  /* 変数 */
  int reverse = 0;
  int remaind = 0;
  int tmp = 0;
  int num = 0;
  int count = 0;
 
  /* 数値（整数）の入力 */
  scanf("%d %d", &A, &B);
  
  if(10000 <= A <= B <= 99999)
  {
    for(int i = A; i <= B; i++)
    {
      tmp = i;
      num = i;
      reverse = 0;
      while(tmp!=0)
      {
        /* 1桁ずつ数値を切り出す */
        remaind = tmp % 10;
        /* 数値を反転 */
        reverse = reverse * 10 + remaind;
        /* 次の桁へシフト */
        tmp /= 10;
      }
      /* 反転した数値と元の数値を比較 */
      if( reverse == num )
      {
        count += 1;
      }
    }
  } 
  printf("%d", count);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
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;
}
long long dp[110][110][2];

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

int main()
{
  int H,W;
  cin >> H >> W;
  vector<string> A(H);
  REP(i, H) cin >> A[i];
  REP(i,H){
    REP(j,W){
      REP(k,2){
        dp[i][j][k]=INF;
      }
    }
  }
  if(A.at(0).at(0)=='#'){
    dp[0][0][1]=1;
  }
  if(A.at(0).at(0)=='.'){
    dp[0][0][0]=0;
  }
  REP(i,H){
    REP(j,W){
      REP(k,2){
        if(i+dy[k]>=H||j+dx[k]>=W) continue;
        if(A.at(i+dy[k]).at(j+dx[k])=='.'&&A.at(i).at(j)=='.'){
          chmin(dp[i+dy[k]][j+dx[k]][0],dp[i][j][0]);
        }
        if(A.at(i+dy[k]).at(j+dx[k])=='#'&&A.at(i).at(j)=='.'){
          chmin(dp[i+dy[k]][j+dx[k]][1],dp[i][j][0]+1);
        }
        if(A.at(i+dy[k]).at(j+dx[k])=='.'&&A.at(i).at(j)=='#'){
          chmin(dp[i+dy[k]][j+dx[k]][0],dp[i][j][1]);
        }
        if(A.at(i+dy[k]).at(j+dx[k])=='#'&&A.at(i).at(j)=='#'){
          chmin(dp[i+dy[k]][j+dx[k]][1],dp[i][j][1]);
        }
      }
    }
  }

  if(A.at(H-1).at(W-1)=='#'){
    cout << dp[H-1][W-1][1] << endl;
  }else if(A.at(H-1).at(W-1)=='.'){
    cout << dp[H-1][W-1][0] << endl;
  }
}

Measured memory_bytes: 384
import sys
import math
n = int(input())
#s, t = map(str, input().split())
#a, b = map(int, input().split())
#s = input()
a = list(map(int, input().split()))

a.sort()
for i in range(n-1):
  if a[i] == a[i+1]:
    print("NO")
    sys.exit()

print("YES")


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

#define ll long long
#define ar array

const int mxN=1e7;
int n, c[mxN+1];

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

	cin >> n;
	for(int i=1; i<=n; ++i)
		for(int j=0; (j+=i)<=n; )
			++c[j];
	ll ans=0;
	for(int i=1; i<=n; ++i)
		ans+=(ll)i*c[i];
	cout << ans;
}


Measured memory_bytes: 42652
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>(b);i--)
using namespace std;

int main(void) {
	int k, s,p,q;
	int count = 0;
	cin >> k >> s;
	p = s - k - k;
	if (p < 0) {
		p = 0;
	}
	FOR(i, p, k) {
		if (i + k + k < s) {
			continue;
		}
		if (i> s) {
			break;
		}
		FOR(t, p, k) {
			if (i + t + k < s) {
				continue;
			}
			if (i + t> s) {
				break;
			}
			if (s - i - t <= k) {
				count++;
				continue;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
a,b,k = map(int,input().split())
A=[]
B=[]
for i in range(a,min(a+k,b+1)):
    A.append(i)
for j in range(b,max(b-k,a-1),-1):
    A.append(j)
B=list(set(A))
B.sort(reverse=False)
for p in range(len(B)):
    print(B[p])

Measured memory_bytes: 9196
void main() {
  problem();
}

void problem() {
  const N = scan!long;
  const K = scan!long;

  long solve() {
    long ans;

    long[long] counts;
    long minimal = 0;
    long maximam = N;
    foreach(i; 1..N+2) {
      counts[i] = maximam - minimal + 1;
      minimal += i;
      maximam += (N - i);
    }

    foreach(n; K..N+2) {
      ans = (ans + counts[n]) % MOD;
    }

    return ans;
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

const MOD = 100_000_000_7;

// -----------------------------------------------


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

int main()
{
ll n ;
cin >> n ;
ans=(n+1)/2-1;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
A = []
B = []
N = len(S)
for s in range(len(S)):
    A.append(S[s])
for t in range(len(T)):
    B.append(T[t])
cnt = 0
for n in range(N):
    if A[n] != B[n]:
        cnt += 1
print(cnt)

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

#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

void solve(){

	string s;
	cin>>s;

	int n = s.size();
	vector<int> ans(n);
	int odd = 0 , even = 0;
	int id = 0;
	for(int i = 0 ; i < n ; ++i){

		if(i&1)
			odd++;
		else even++;
		id = i-1;
		if(s[i]=='L'){

			int j = i+1;
			while(j < n && s[j]=='L'){
				if(j&1)
					odd++;
				else even++;
				j++;
			}

			if(id&1)
				ans[id] = odd , ans[i] = even;
			else ans[id] = even , ans[i] = odd;

			even = 0;
			odd = 0;
			i = j-1;

		}
	}

	for(int it : ans)
		cout<<it<<" ";
	cout<<endl;

}

signed main(int argc , char *argv[]){
	fast;
	
	int t = 1;
	// cin>>t;
	while(t--)
		solve();

}

Measured memory_bytes: 1104
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    ll a,b;
    while(cin>>a>>b){
        if(a<b)swap(a,b);
        int count=0;
        if(a==0 && b==0)break;
        while(b!=0){
            a=a%b;
            swap(a,b);
            count++;
        }
        cout<<a<<" "<<count<<endl;
    }
    return 0;
}

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

using namespace std;

int main() {
   int n;
   cin >> n;
   bool good = true;
   for (int i = 0; i < n; ++i) {
      int a;
      cin >> a;
      if ((a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0))) {
         good = false;
      }
   }
   if (good) {
      cout << "APPROVED" << endl;
   } else cout << "DENIED" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<ll> A;
  map<ll, int> amap;
  ll tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(amap[tmp]==0) A.push_back(tmp);
    amap[tmp]++;
  }
  int ans = 0;
  for(int i=0;i<A.size();++i) {
    if(amap[A[i]]%2==1) ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 10200
n, m = [int(x) for x in input().split(' ')]
x = sorted([int(x) for x in input().split(' ')])

if n >= m:
    print(0)
    exit()

diff = sorted([abs(x[i] - x[i-1]) for i in range(1, m)])
for i in range(n-1):
    diff.pop()

print(sum(diff))


Measured memory_bytes: 13832
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 10e9+7;
ll mod2 = 998244353;

int main(){
    int n;cin>>n;
    vector<int> a(n);
    rep(i,0,n) cin>>a[i];
    int ma = *max_element(a.begin(),a.end());
    vector<int> x(ma+10,1);
    rep(i,0,n){
        if (x[a[i]]==2 || x[a[i]]==3){
            x[a[i]] = 3;
            continue;
        }
        if (x[a[i]]==1) x[a[i]] = 2;
        for (int j=2*a[i];j<ma+10;j+=a[i]){
            x[j] = 0;
        }
    }
    int cnt = 0;
    rep(i,0,n){
        if(x[a[i]]==1 || x[a[i]]==2) cnt++;
    }
    cout << cnt <<endl;
}

Measured memory_bytes: 7904
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
#include<bitset>
using namespace std;

int a,b;
int main(){
  cin>>a>>b;
  if((a*b)%2==1)cout<<"Odd"<<endl;
  else cout<<"Even"<<endl;
  
  return 0;
}



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

int main()
{
    int W, H, N;
    cin >> W >> H >> N;
    int *x = new int[N];
    int *y = new int[N];
    int *a = new int[N];
    for (int i = 0; i < N; ++i)
    {
        cin >> x[i] >> y[i] >> a[i];
    }
    int right = W;
    int left = 0;
    int top = H;
    int bottom = 0;
    for (int i = 0; i < N; ++i)
    {
        switch (a[i])
        {
        case 1:
            left = max(left, x[i]);
            break;
        case 2:
            right = min(right, x[i]);
            break;
        case 3:
            bottom = max(bottom, y[i]);
            break;
        case 4:
            top = min(top, y[i]);
            break;
        default:
            break;
        }
    }
    if (right - left > 0 && top - bottom > 0)
    {
        cout << (right - left) * (top - bottom) << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1,1,-1,-1,2,2,-2,-2}; //knight moves
///int ky[]={2,-2,2,-2,1,-1,1,-1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};  //eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};  //eight direction
 
///using namespace __gnu_pbds;
using namespace std;
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif
   	int n;
   	while(sf("%d",&n)==1)
   	{
   		string s;
   		cin>>s;

   		string t;
   		for(int i=0;i<n;i++)
   		{
   			if(t.size()==0)t+=s[i];
   			else if(t.back()!=s[i])t+=s[i];
   		}
   		pf("%d\n",t.size());
   	}
    return 0;
}
 









 




























Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> cnt(n, 1), red(n);
	red[0] = 1;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		cnt[a]--, cnt[b]++;
		if (red[a]) red[b] = 1;
		if (cnt[a] == 0) red[a] = 0;
	}
	int ans = 0;
	rep(i, n) if (red[i]) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <vector>

const int kN = (1 << 18) + 5;
const int MOD = (int)1e9 + 7;
const int kLog = 18;
int n;
std::vector<int> edges[kN];
int plca[kLog][kN], depth[kN];
int dfn[kN], dfl[kN], stmp;
std::vector<int> level[kN];
int f[kN][3];

inline void add(int &a, int b)
{
    a += b;
    if (a >= MOD) a -= MOD;
}

int power(int a, int b, int p)
{
    int ret = 1;
    for ( ; b; b >>= 1, a = a * 1LL * a % p)
        if (b & 1)
            ret = ret * 1LL * a % p;
    return ret;
}

int get_lca(int u, int v)
{
    if (depth[u] < depth[v]) std::swap(u, v);
    for (int i = 0; i < kLog; ++ i)
        if (depth[u] - depth[v] >> i & 1)
            u = plca[i][u];
    if (u == v)
        return u;
    for (int i = kLog - 1; i >= 0; -- i)
        if (plca[i][u] != plca[i][v])
            u = plca[i][u], v = plca[i][v];
    return plca[0][u];
}

void dfs(int u)
{
    level[depth[u]].emplace_back(u);
    for (int i = 1; i < kLog; ++ i)
        plca[i][u] = plca[i - 1][u] == -1 ? -1 : plca[i - 1][plca[i - 1][u]];

    dfn[u] = stmp ++;
    for (int v : edges[u]) {
        depth[v] = depth[u] + 1;
        plca[0][v] = u;
        dfs(v);
    }
    dfl[u] = stmp - 1;
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i) {
        int x;
        scanf("%d", &x);
        edges[x].emplace_back(i);
    }
    plca[0][0] = -1;
    dfs(0);
    int result = 0;
    for (int d = 0; d <= n; ++ d) {
        int native = level[d].size();
        if (native == 0) break;

        for (int i = 0; i + 1 < native; ++ i)
            level[d].emplace_back(get_lca(level[d][i], level[d][i + 1]));

        std::sort(level[d].begin(), level[d].end(), [&](int a, int b) {
            return dfn[a] < dfn[b];
        });
        level[d].erase(std::unique(level[d].begin(), level[d].end()), level[d].end());
        std::vector<int> stack;
        for (int i = (int)level[d].size() - 1; i >= 0; -- i) {
            int u = level[d][i];
            f[u][0] = 1;
            f[u][1] = depth[u] == d;
            f[u][2] = 0;
            while (!stack.empty()) {
                int v = stack.back();
                if (dfn[v] > dfl[u]) break;
                stack.pop_back();
                int tmp[3] = {};
                for (int r = 0; r < 3; ++ r)
                    for (int w = 0; w < 3; ++ w)
                        add(tmp[std::min(r + w, 2)], f[u][r] * 1LL * f[v][w] % MOD);

                std::copy(tmp, tmp + 3, f[u]);
            }
            stack.emplace_back(u);
            add(f[u][0], f[u][2]);
            f[u][2] = 0;
            // printf("u = %d, %d %d %d\n", u, f[u][0], f[u][1], f[u][2]);
        }
        add(result, power(2, n + 1 - native, MOD) * 1LL * f[level[d][0]][1] % MOD);
        // printf("result = %d\n", result);
    }
    printf("%d\n", result);
}


Measured memory_bytes: 59008
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
template<class T> istream& operator>>(istream &is,vector<T> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> istream& operator>>(istream &is,vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> ostream& operator<<(ostream &os, const vector<T> &st){
  for(size_t i=0;i<st.size();++i){
    if(i==st.size()-1) os << st[i];
    else os << st[i] << " ";
  }
  return os;
}
template<class T> ostream& operator<<(ostream &os, const vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i){
    os << st[i];
    if(i!=st.size()-1) os << endl;
  }
  return os;
}
signed main(){
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int n;
  while(cin >> n,n){
    V<char> c(n);
    cin >> c;
    vi bc(26,0);
    int mx = 0;
    int id = -1;
    int ans = -1;
    REP(i,n){
      int a = c[i];
      a -= 'A';
      bc[a]++;
      if(mx<bc[a]){
        mx = bc[a];
        id = a;
      }
      REP(j,26){
        if(j!=id)if(bc[j]+n-i-1>=mx){
          break;
        }
        if(j==25) ans = i;
      }
      if(ans!=-1) break;
    }
    if(ans!=-1) cout << char(id+'A') << " " << ans+1 << endl;
    else puts("TIE");
  }
}




Measured memory_bytes: 3092
function Main(input) {
	input = input.trim().split(" ").map((a)=>Number(a));
  var N = input[0];
  var A = input[1];
  var B = input[2];
  console.log(Math.min(N * A,B))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
#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>;
int dx[9]={-1,0,1,-1,0,1,-1,0,1};
int dy[9]={-1,-1,-1,0,0,0,1,1,1};
int main() {
    ll h, w, n; cin >> h >> w >> n;
    map<P, int> mp;
    rep(i, n) {
        int a, b; cin >> a >> b;
        a--; b--;
        rep(j, 9) {
            int na = a + dy[j];
            int nb = b + dx[j];
            if(na<=0 || nb<=0 || na>=h-1 || nb>=w-1) continue;
            mp[P{na, nb}]++;
        } 
    }
    ll all = (h-2)*(w-2);
    vector<ll> ans(10, 0);
    ll sum = 0;
    for(auto it=mp.begin();it!=mp.end();it++) {
        ans[it->second]++;
        sum++;
    }
    ans[0] = all - sum;
    rep(i, 10) {
        cout << ans[i] << endl;
    }
}


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


int main(){
    long long n,a,b,c=0,a1=0,max=0;
    cin>>n;
    long long l[n+1];
    for (int i=1; i<=n; i++) {
        cin>>l[i];
        if (max<l[i]) max=l[i];
        a1+=l[i];
    }
    
    
        if(a1-max>max)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
}


Measured memory_bytes: 888
#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>;

int main() {
  int x;
  cin >> x;
  for (int a = 1; a < 1000; ++a) {
    ll a5 = 1;
    rep(i,5) a5 *= a;
    for (int b = -1000; b < 1000; ++b) {
      ll b5 = 1;
      rep(i,5) b5 *= b;
      if (a5-b5 == x) {
        printf("%d %d\n", a, b);
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int x;
	cin >> x;
	cout << 1-x;
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3644
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>

#define INF (long long)1000000000
#define MOD 1000000007
#define EPS 1e-8

#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

__int128 gcd(__int128 a, __int128 b) {		// ユークリッドの互除法
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	int n;
	cin>>n;
	vector<ll> t(n);
	REP(i,n) cin>>t[i];
	vector<__int128> ta(n);
	REP(i,n) ta[i]=t[i];
	__int128 res = 1;
	REP(i,n) {
		res=res*t[i]/gcd(res,t[i]);
	}
	ll ans = res;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String station = sc.next();
    String word = "No";
    for (int i = 1; i < 3; i++) {
      if (station.charAt(i-1) != station.charAt(i))
        word = "Yes";
    }
    System.out.println(word);
  }

}

Measured memory_bytes: 24020
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int D;
vector<int> c(26);
int ss[365][26];
vector<int> ans(0);

double powyabai = 1.2;
double cyabaipow = 1.2;

double evaluate(int day, int kind){

    double yabasa = 0;
    int s = ans.size();
    int idx;
    for(idx = s - 1; 0 <= idx; idx--){
        if(ans[idx] == kind) break;
    }
    yabasa = pow(day - idx, powyabai) * pow(c[kind], cyabaipow);
    double uresisa = ss[day][kind];
    return yabasa + uresisa;
}

int main(){
    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D)rep(j, 26) cin >> ss[i][j];
    rep(i, D){
        double max_eva = -inf;
        double choice = 0;
        rep(j, 26){
            if(chmax(max_eva, evaluate(i, j))) choice = j;
        }
        ans.push_back(choice);
    }
    rep(i, D) pt(ans[i] + 1);
    return 0;
}

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

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

    for(int i = 0; i < n; i++){
        if(s[i] != s[t-1]){
            s[i] = '*';
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define nl '\n'
typedef long long ll;
typedef long double ld;
//////////////////////////////////////////////////////////////////////

int main(){
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  
  int n;cin>>n;
  map<int,int> mp;
  for(int i=0;i<n;i++){
    int v;cin>>v;
    mp[v]++;
  }
  int ans=0;
  for(auto&it:mp)
    if(it.ss%2==1)ans++;
  cout<<ans<<nl;
  
  return 0;
};


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios	      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main(){
      
      ios
      ll n,m;
      cin >> n >> m;
      vll a(m);
      for(ll i=0;i<m;i++)cin >> a[i];
      ll sum = accumulate(a.begin(),a.end(),0);
      if(n-sum<0)cout << "-1" << "\n";
      else cout << n- sum << "\n";
      
      return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		int a=0,b=0;
		rep(i,n){
			int c,d;
			cin>>c>>d;
			if(c>d)
				a+=c+d;
			else if(c<d)
				b+=c+d;
			else{
				a+=c;
				b+=d;
			}
		}
		cout<<a<<" "<<b<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;

//#include "atcoder.hpp"

int main() {
    int N, r = 0;
    string S;
    
    cin >> S;


    for (auto i : S)
        if (i == '2')
            r++;
    cout << r << endl;
    return 0;
}


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

int main(){
	long long int x,y;
	cin >> x >> y;

	if(x%y==0){
		cout << "-1" <<endl;
	}else if(y==2){
		cout << x*3 <<endl;
	}else{
		cout << (y-1)*x <<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
int main()
{
  string str;
  cin>>str;
  ll r=0;

  if(str=="RSR")
  {
      cout<<1<<endl;
  }
  else{

  for(ll i=0;i<3;i++)
  {
      if(str[i]=='R')r++;
  }

  cout<<r<<endl;

  }
}


Measured memory_bytes: 3624
h=Hash[15,2244,12,1870,10,1520,5,850,3,550,2,380]
m={0=>0}
50.times{|i|
  m.update(h.map{|k,v|[k+i,v+m[i]]}.to_h){|_,*t|t.min} if m[i]
}

puts $<.map{|l|m[l.to_i/100]}[0..-2]

Measured memory_bytes: 8692
#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; }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n, m; cin >> n >> m;
    vector<vector<pair<int, int>>> edge(n);
    FOR(i, 0, m) {
        int l, r, d; cin >> l >> r >> d;
        l--, r--;
        edge[l].push_back(make_pair(r, d));
        edge[r].push_back(make_pair(l, -d));
    }

    VI x(n, INF);
    FOR(i, 0, n) {
        if (x[i] != INF)continue;
        x[i] = 0;
        queue<int> bfs;
        bfs.push(i);
        while (!bfs.empty()) {
            int from = bfs.front(); bfs.pop();
            for (auto to : edge[from]) {
                if (x[to.first] != INF) {
                    if (x[to.first] != x[from] + to.second) {
                        cout << "No\n";
                        return 0;
                    }
                    else continue;
                }
                x[to.first] = x[from] + to.second;
                bfs.push(to.first);
            }
        }
    }
    cout << "Yes\n";
}


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

using namespace std;

int main() {
	int k, a, b;
	ignore = scanf("%d %d %d", &k, &a, &b);
	
	long long ans = 1;
	{
		int f = min(a - 1, k);
		k -= f;
		ans += f;
	}
	if (b - a > 2) {
		int f = k / 2;
		ans += f * 1ll * (b - a);
		k %= 2;
	}
	ans += k;
	
	printf("%lld\n", ans);
	
	return 0;
}


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

using namespace std;

int main() {
    vector<int> v(3);
    for (int i = 0; i < 3; ++i)
        cin >> v[i];

    sort(v.begin(), v.end());

    cout << v[0] + v[1] << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;

    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string input;
        cin >> input;
        if (mp.find(input) != mp.end()) {
            mp[input] += 1;
        } else {
            mp[input] = 1;
        }
    }

    int m;
    cin >> m;
    rep(i, m) {
        string input;
        cin >> input;
        if (mp.find(input) != mp.end()) {
            mp[input] -= 1;
        } else {
            mp[input] = -1;
        }
    }

    int maxv = 0;
    for (const auto el : mp) {
        if (el.second > 0) {
            maxv = max(maxv, el.second);
        }
    }
    cout << maxv << endl;
}

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

int main()
{
    long long n, p;
    cin >> n >> p;

    long long ans = 1;
    for (int i = 2; 1LL * i * i <= p; i++) {
        int cnt = 0;
        while (p % i == 0) {
            p /= i;
            cnt++;
        }

        if (cnt >= n) {
            for (int j = 0; j < cnt / n; j++) {
                ans *= 1LL * i;
            }
        }
    }
    if (n == 1) ans *= p;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)

list_a = []
i = 1
while True:
    tmp1 = a % i
    tmp2 = b % i
    if tmp1 == 0 and tmp2 == 0:
        list_a.append(i)
    i += 1
    if a < i or b < 0:
        break
print(list_a[-1*(c)])


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>

using namespace std;


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

  if(K>N) K=N;

  cout << K*X + (N-K)*Y << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	int res=0;
	for(int i=1;i<=50000;i++) if(i*108/100==n){
		res=i;
	}
	if(res==0) cout<<":("<<endl;
	else cout<<res<<endl;
}

Measured memory_bytes: 256
#template
def inputlist(): return [int(j) for j in input().split()]
#template
#issueから始める
N = input()
n = len(N)
dp = [[0,0] for _ in range(len(N)+1)]
dp[1][0] = int(N[0])-1
dp[1][1] = int(N[0])
for i in range(2,len(N)+1):
    if int(N[i-1]) != 0:
        dp[i][0] = max(dp[i-1][0]+9,dp[i-1][1]+int(N[i-1])-1)
        dp[i][1] = dp[i-1][1] + int(N[i-1])
    if int(N[i-1]) == 0:
        dp[i][1] = dp[i-1][1]
        dp[i][0] = dp[i-1][0]+9
print(max(dp[n][0],dp[n][1]))

Measured memory_bytes: 3064