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

using namespace std;

int main()
{
    int n;
    cin>>n;
    if (n%10==3)
        cout<<"bon";
    else
        if (n%10==0 || n%10==1 || n%10==6 || n%10==8)
        cout<<"pon";
    else
        cout<<"hon";
    return 0;
}


Measured memory_bytes: 3612
import re

SNAKE_A = re.compile(r">'(=+)#\1~")
SNAKE_B = re.compile(r">\^(Q=)+~~")


def answer(regex, string, output):
    result = regex.fullmatch(string)

    if result is not None:
        print(output)
    else:
        print("NA")


for _ in range(int(input())):

    snake = input()

    if snake[1] == "'":
        answer(SNAKE_A, snake, "A")
    else:
        answer(SNAKE_B, snake, "B")



Measured memory_bytes: 6556
N, K = map(int, input().split())
D = list(map(int, input().split()))
notD = [i for i in range(0, 10)]
for i in D:
    notD[i] = 10
i = 0
while True:
    if i >= len(notD):
        break
    if notD[i] == 10:
        del notD[i]
        i -= 1
    i += 1
i = N
while True:
    ans = 1
    for j in list(str(i)):
        for k in D:
            if int(j) == k:
                ans = -1
                break
        if ans == -1:
            break
    if ans == -1:
        i += 1
    elif ans == 1:
        print(i)
        break


Measured memory_bytes: 3064
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a, b, c;
		boolean flg;
		for(int i = 0; i < n; i++){
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();
			if(a >= b && a >= c){
				flg = pita(a, b, c);
			}else if(b >= a && b >= c){
				flg = pita( b, a, c);
			}else{
				flg = pita( c, a, b);
			}
			if(flg){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
	public static boolean pita(int a, int b, int c){
		if( a * a == b * b + c * c){
			return true;
		}
		return false;
	}
}

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

int main()
{
    int a,b;
    cin >> a >> b;

    int alpha=min(a,b);
    int beta=max(a,b);

    for (int i=0;i<=beta-1;i++)
    {
        cout << alpha;
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
f = sys.stdin

n, r, l = map(int, f.readline().split())

appearance = [0] * n
point = [0] * n

top = 0
pre_t = 0
for line in f:
    d, t, x = map(int, line.split())
    d -= 1 # 0-index?????????
    
    appearance[top] += t - pre_t
    pre_t = t
    
    point[d] += x
    if 0 < x and top != d:
        if point[top] < point[d]:
            top = d
        elif point[top] == point[d] and d < top:
            top = d
    elif x < 0 and top == d:
        top = point.index(max(point))

appearance[top] += l - pre_t

print(1 + appearance.index(max(appearance)))

Measured memory_bytes: 11192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	Vec x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];

	Vec a(n);
	rep(i, n) a[i] = i;
	ld ans = 0;
	ll cnt = 0;
	do {
		ld sum = 0;
		rep(i, n - 1) sum +=
		    sqrt(pow(x[a[i]] - x[a[i + 1]], 2) + pow(y[a[i]] - y[a[i + 1]], 2));
		ans += sum;
		cnt++;
	} while (next_permutation(all(a)));

	ans /= cnt;
	setp(10);
	co(ans);

	return 0;
}


Measured memory_bytes: 3792
package main

import (
	"fmt"
)

func main() {

	var n int
	var a string
	var b string
	var c string

	cnt := 0

	fmt.Scan(&n, &a, &b, &c)

	for index := 0; index < n; index++ {
		matigai := 0
		if a[index] != b[index] {
			matigai++
		}
		if a[index] != c[index] {
			matigai++
		}
		if b[index] != c[index] {
			matigai++
		}
		if matigai == 2 {
			cnt++
		} else if matigai == 3 {
			cnt += 2
		}
	}

	fmt.Println(cnt)
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var nn int
	fmt.Scanf("%d", &nn)
	pp := make([]int, nn)
	for ii:=0;ii<nn;ii++ {
		fmt.Scanf("%d", &pp[ii])
	}

	var result int
	result++
	min := pp[0]
	for ii:=1;ii<nn;ii++ {
		if pp[ii] <= min {
			result++
		}
		if pp[ii] < min {
			min = pp[ii]
		}
	}

	fmt.Printf("%v\n", result)
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
namespace ITP1_6_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int Num = int.Parse(Console.ReadLine());
            List<string> cards = new List<string>();
            int i;
            for(i = 1; i <= 13; ++i)
            {
                cards.Add("S " + i);
            }
            for(i = 1; i <= 13; ++i)
            {
                cards.Add("H " + i);
            }
            for(i = 1; i <= 13; ++i)
            {
                cards.Add("C " + i);
            }
            for(i = 1; i <= 13; ++i)
            {
                cards.Add("D " + i);
            }
            for(i = 0; i < Num; ++i)
            {
                cards.Remove(Console.ReadLine());
            }
            foreach(string taro in cards)
            {
                Console.WriteLine(taro);
            }
        }
    }
}


Measured memory_bytes: 15788
#include <iostream>

using namespace std;

int main(){
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=0;i<10;i++){
        d=a*c-b;
        printf("%d\n",d);
        c=d;
    }
    return 0;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
template<typename T> T pow(T base, T i, T mod){
  T a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
template<typename T> T gcd(T a, T b){
  while(b){
    T c = a % b;
    a = b;
    b = c;
  }
  return a;
}
template<typename T> T lcm(T a, T b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

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

ll calc(ll H){
  ll ans = 0;
  while(H){
    ans++;
    H >>= 1;
  }

  return ans;
}

void solve(){
  ll H;
  cin >> H;

  cout << (1LL << calc(H)) - 1 << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

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

using namespace std;
using ll =long long;
using db = double;

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; }

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
const int mod = 1e9 + 7;

//ここから書き始める
int main()
{
	cout << setprecision(10);
	string s ;
	cin >> s; 
	rep(i,s.size()){
		if(i%2==0) cout << s[i];
	}
	cout << endl;

	
}


Measured memory_bytes: 512
n, m = gets.chomp.split(" ").map(&:to_i);
a = 0
common = 0
ary1 = gets.chomp.split(" ").map(&:to_i)
k1 = ary1.shift

if n == 1
  puts ary1.count
else
  (n - 1).times do |i|
    ary2 = gets.chomp.split(" ").map(&:to_i);
    kn = ary2.shift
    common = ary1 & ary2
    ary1 = common
  end

  puts common.count
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int temp;
    int ans = 0; 
    int v[N];
    for(int i=0;i<N;i++){
        cin >> v[i];
    }
    sort(v,v+N);
    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            for(int k=j+1;k<N;k++){
                //cout << v[i] << " " << v[j] << " " << v[k]<< endl;
                if(v[i]+v[j]>v[k]&&v[k]>v[j]&&v[j]>v[i]){
                    ans++;
                    //cout << "+" <<endl;
                }
            }
        }
    }
    cout << ans;
    return 0;
}

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

int main(){
string s;
  cin>>s;
  string ans="No";
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='C'){
      for(int j=i+1;j<s.size();j++){
        if(s.at(j)=='F'){
          ans="Yes";
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
    string a;
    cin >> a;
    int b;
    b = int(a[0]);
    if(b>=65 && b<=90){
        cout << "A";
    }
    else{
        cout <<"a";
    }
}

Measured memory_bytes: 3624
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

s = S()
if s[0] == 'A' and s[2:-1].count('C') == 1:
    t = list(s[1:])
    t.remove('C')
    if all(x.islower() for x in t):
        print('AC')
        exit()

print('WA')


Measured memory_bytes: 63412
#include<stdio.h>
#include<string.h>


int main(void) {
	char tiles[100000]="";
	int i = 0;
	int n = 0;
	int count = 0;
	
	scanf("%s", tiles);
	n = strlen(tiles);
	
	if (tiles[0]-'0' == 1) {

		for (i = 0; i < n;) {
			if (tiles[i] - '0' == 1 && tiles[i+1] - '0' == 0) {
				i= i + 2;
			}
			else {
				if (tiles[i] - '0' == 0) {
					count++;
				}
				if (tiles[i+1] - '0' == 1) {
					count++;
				}
				i = i + 2;
			}
		}
	}
	else{
		for (i = 0; i < n; ) {
			if (tiles[i] - '0' == 0 && tiles[i+1] - '0' == 1) {
				i = i + 2;
			}
			else {
				if (tiles[i] - '0' == 1) {
					count++;
				}
				if (tiles[i+1] - '0' == 0) {
					count++;
				}
				i = i + 2;
			}
		}
		
	
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
from bisect import bisect_left,bisect_right
l.sort()
a=0
for i in range(n-2):
  for j in range(i+1,n-1):
    a+=bisect_left(l,l[i]+l[j])-j-1
print(a)

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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  array<vector<int>, 26> p;
  for (int i = 0; i < s.size(); ++i) {
    p[s[i] - 'a'].push_back(i);
  }

  int l = -1, r = -1;
  for (int i = 0; i < p.size() && l < 0; ++i) {
    for (int j = 1; j < p[i].size() && l < 0; ++j) {
      if (p[i][j] - p[i][j - 1] <= 2) {
        l = p[i][j - 1] + 1;
        r = p[i][j] + 1;
      }
    }
  }

  cout << l << ' ' << r << '\n';
  return 0;
}

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

public class Test
{
	public static void Main(){
long[] t = Console.ReadLine().Split(' ').Select(s=>long.Parse(s)).ToArray();
long K=t[0],A=t[1],B=t[2];
if(B-A>2)
{
if(A>=K){
Console.WriteLine(K+1);
}
else {
long s;
s=(B-A)*((K+1-A)/2);
Console.WriteLine(s+A+((K+1-A)%2));
}
}
else
Console.WriteLine(K+1);
}
}

Measured memory_bytes: 13396
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int a[n];
    FOR(i,0,n)
        cin >> a[i];
    int ans = 0;
    FOR(i,0,n)
        ans += a[i] - 1;
    cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    int minval = 100001;
    for (int a=1; a<=n-1; a++) {
        int b = n - a;

        int t1 = 0;
        int ta = a;
        while(true) {
            if (ta == 0) break;
            t1 += ta % 10;
            ta /= 10;
        }

        int t2 = 0;
        int tb = b;
        while(true) {
            if (tb == 0) break;
            t2 += tb % 10;
            tb /= 10;
        }

        minval = min(minval, t1+t2);
    }
    cout << minval << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
        new Main().run();
    }

    void run() {

        long n = sc.nextLong();

        long max = 1;

        for (long i=1; i<=Math.sqrt(n)+1; i++) {
            if (n % i == 0) max = Math.max(max, i);
        }

//        System.out.println(max);

        System.out.println(n/max + max - 2);


    }


}


Measured memory_bytes: 35756
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i*=10){
		sum+=n/i%10;
	}
	if(n%sum==0){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

a,b,k=map(int, input().split())

ans =[]

for i in range(1,min(a,b)+1):
    if (a % i == 0 and b % i == 0):
        ans.append(i)

print(ans[-k])




Measured memory_bytes: 9056
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
int main(){
  int **M,**matrix,N,m,n,i,l,j,k,add,min;
  scanf("%d",&N);

  matrix=malloc(sizeof(int*)*2);
  matrix[0]=malloc(sizeof(int)*N);
  matrix[1]=malloc(sizeof(int)*N);
  for(i=0;i<N;i++)scanf("%d %d",&matrix[0][i],&matrix[1][i]);
  
  M = malloc(sizeof(int*)*N);
  for(i=0;i<N;i++){
    M[i]=malloc(sizeof(int)*N);
    if(i+1<N)M[i][i+1]=matrix[0][i]*matrix[0][i+1]*matrix[1][i+1];
    M[i][i]=0;
  }
  
  for(i=2;i<N;i++){
    for(j=i;j<N;j++){
      min = INT_MAX;
      for(k=j-i;k<j;k++){
	if(min > M[j-i][k]+M[k+1][j]+matrix[0][j-i]*matrix[0][k+1]*matrix[1][j]){
	  min = M[j-i][k]+M[k+1][j]+matrix[0][j-i]*matrix[0][k+1]*matrix[1][j];
	}
	M[j-i][j]=min;
      }
    }
  }

  printf("%d\n",M[0][N-1]);

  free(matrix[0]);
  free(matrix[1]);
  free(matrix);
  for(i=0;i<N;i++)free(M[i]);
  free(M);
  return 0;
}



Measured memory_bytes: 2132
# cf16-finalB - Exactly N points
def main():
    # N <= cnt (1 + 2 + ... + ma) -> 1 ~ ma except ex
    N = int(input())
    cnt, ma = 0, 0
    for i in range(1, N + 1):
        cnt += i
        if cnt >= N:
            ma = i
            break
    ex = cnt - N  # exclusion
    ans = [i for i in range(1, ma + 1) if i != ex]
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;



int main()
{
	int n,q,a,m,last,temp=0;
	bool dp[2001]={0};

	scanf("%d", &n);

	dp[0] = true;
	last = 0;

	for(int i = 0; i < n; i++)
	{
		scanf("%d", &a);
		temp = 0;

		for(int j = last; j >= 0; j--)
		{
			if (dp[j])
			{
				temp = max(j+a,temp);
				dp[j + a] = true;
			}
		}

		last = max(temp,last);
	}

	scanf("%d", &q);

	for(int i = 0; i < q; i++)
	{
		scanf("%d", &m);

		if (dp[m])
		{
			printf("yes\n");
		}else
		{
			printf("no\n");
		}
	}

	return 0;
}
	

Measured memory_bytes: 3144
p [*0...gets.to_i**2].product([*$<].map{|x|Complex(*x.split.map(&:to_i))}.sort_by{|x|x.arg}).group_by(&:first).map{|x|
	[*x[0]/x[1].size..x[0]/x[1].size+x[0]%x[1].size].map{|y|x[1][y%x[1].size][1]}.inject(:+).abs
}.max

Measured memory_bytes: 89848
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	string s;
	cin >> s;
	for(int i=0; i<3; i++){
		if(s[i]=='1') cout << "9";
		else cout << "1";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] x = new int[m];

		for(int i = 0;i < m;i++){
			x[i] = sc.nextInt();
		}
		Arrays.sort(x);

		ArrayList<Pair> pairs = new ArrayList<Pair>();
		int[] dis = new int[m];
		for(int i = 0;i < m-1;i++){
			dis[i] = x[i+1]-x[i];
		}
		Arrays.sort(dis);
		long ans = 0;
			for(int i = 0;i <=m-n;i++){

				ans += dis[i];
			}
		
	

		System.out.println(ans);

	}


	static int lowerbond(long k, long[] data){		//kより小さい最小の値をdataの中から探し、返す二分探索
		int min = 0;
		int max = data.length-1;

		while(max-min >= 0){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid-1;
			}else{
				min = mid+1;
			}
		}
		return min;
	}









	class UnionFind{
		int[] parent;
		public UnionFind(int N){
			this.parent = new int[N];
			for(int i = 0; i < N;i++){
				parent[i] = i;
			}
		}
		public int root(int x){			//根要素を取得
			if(parent[x] == x){			//初期状態
				return x;
			}else{
				return parent[x] = root(parent[x]);    	//再帰によって根を取得
			}
		}
		public void unite(int x,int y){ 	//統合メソッド
			if(same(x,y)){					//同じ根なら終了
				return;
			}
			int xroot = root(x);
			int yroot = root(y);
			parent[xroot] = yroot;			//統合
			return;

		}

		public boolean same(int x,int y){			//根が同じか（同じグループに属しているか）を判定
			return(root(x) == root(y));
		}
	}

}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



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

bool formTriangle(ll a, ll b, ll c){
    return abs(a-c)<b && abs(a-b)<c && abs(c-b)<a;
}

int main(){
    int n;
    vector<ll> l;

    cin >> n;
    l.assign(n,0);
    for(int i=0;i<n;i++){
        cin >> l[i];
    }

    int answ = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]!=l[j] && l[i]!=l[k] && l[j]!=l[k])
                    answ+=formTriangle(l[i],l[j],l[k]);
            }
        }
    }
    
    cout << answ <<'\n';

    return 0;
}

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

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

  if (s % 9 == 0) cout << 0 << endl;
  
  else if (s % 9 == 1) cout << 1 << endl;

  else if (s % 9 == 2) cout << 2 << endl;
  
  else if (s % 9 == 3) cout << 3 << endl;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

struct P {
    int w, s, v;
};
bool cf(P a, P b) {
    return min(a.s - b.w, b.s) > min(b.s - a.w, a.s);
}

void solve() {
    int N;
    cin >> N;
    vector<P> A;
    rep(i, N) {
        P p;
        cin >> p.w >> p.s >> p.v;
        A.push_back(p);
    }

    sort(all(A), cf);

    const int W = 20002;
    const ll MI = LLONG_MIN / 3;
    vector<ll> dp(W, MI);
    dp[W - 1] = 0;

    rep(i, N) {
        P p = A[i];
        FOR(j, p.w, W)if (dp[j] != MI) {
            int nj = min(j - p.w, p.s);
            smax(dp[nj], dp[j] + p.v);
        }
    }
    
    ll ans = *max_element(all(dp));
    cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 512
from collections import defaultdict

class LCM_mod:
    """
    最小公倍数の計算を行う
    オーバーフローが発生しないように素因数分解し,
    因数の積を逐次余りに置き換えて最小公倍数を導出する.
    """
    def __init__(self, max_num, p=10**9+7):
        self.max_num = max_num + 1
        self.p = p
        self.prime = [0 for _ in range(self.max_num)]
        self.max_map = defaultdict(int)
        self.sieve()

    def rep_sqr(self, base, k):
        # 繰り返し二乗法
        if k == 0:
            return 1
        elif k % 2 == 0:
            return (self.rep_sqr(base, k / 2) ** 2) % self.p
        else:
            return (self.rep_sqr(base, k - 1) * base) % self.p

    def sieve(self):
        """
        エラトステネスの篩　O(n)
        nまでに含まれる素数を導出
        """
        self.prime[0], self.prime[1] = 1, 1
        for i in range(2, self.max_num):
            if self.prime[i] == 0:
                for j in range(i * 2, self.max_num, i):
                    if self.prime[j] == 0:
                        self.prime[j] = i
                self.prime[i] = i

    def lcm_list_mod(self, arr):
        """
        listのそれぞれの要素について、素因数分解する
        それぞれの因数について最大であれば更新する
        """
        for i in range(len(arr)):
            num = arr[i]
            d = defaultdict(int)

            while num > 1:
                fact = self.prime[num]
                d[fact] += 1
                num //= fact

            for i in d.keys():
                self.max_map[i] = max(self.max_map[i], d[i])

        ans = 1
        for i in self.max_map.keys():
            ans = (ans * self.rep_sqr(i, self.max_map[i])) % self.p
        return ans


class FLT:
    def __init__(self, mod=10**9+7):
        self.mod = mod

    def rep_sqr(self, base, k):
        if k == 0:
            return 1
        elif k % 2 == 0:
            return (self.rep_sqr(base, k // 2) ** 2) % self.mod
        else:
            return (self.rep_sqr(base, k - 1) * base) % self.mod

    def inv(self, a):
        """ 逆元を取る """
        return self.rep_sqr(a, self.mod-2)

n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7

lcm_mod = LCM_mod(max(a), MOD)
lcm_all = lcm_mod.lcm_list_mod(a)
flt = FLT(MOD)

b = list(map(lambda x: lcm_all * flt.inv(x), a))
ans = 0
for i in range(len(b)):
    ans += b[i]
    ans %= MOD
print(ans)


Measured memory_bytes: 15020
N, M = map(int, input().split())
Z = [list(map(int,input().split())) for i in range(M)]

B = [1 for i in range(N)]
R = [0 for i in range(N)]
R[0] = 1 #赤いボールが入っている可能性があるなら１、無いなら０
for i in range(M):
  src = Z[i][0]-1
  dst = Z[i][1]-1
  if B[src] > 1 and R[src] == 1:
    R[dst] = 1
  if B[src] == 1 and R[src] == 1:
    R[src] = 0 
    R[dst] = 1
  B[src] -= 1
  B[dst] += 1
print(sum(R))

Measured memory_bytes: 28512
#include<bits/stdc++.h>
using namespace std;
#define lson root<<1,l,midd
#define rson root<<1|1,midd+1,r
#define pb push_back
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,ans=0;
    cin>>n;
    ans+=(n/500)*1000;
    n%=500;
    ans+=(n/5)*5;
    n%=5;

    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <deque>
using namespace std;
long long n,m,k,sum;
int  main()
{
    while(cin>>n)
    {
        sum=0;
        for(int i=1; i<=n; i++)
        {
           sum+=i*(1+n/i)*(n/i)/2;
        }
        cout<<sum<<endl;
    }

    return 0;
}


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

int main() {
  // 入力部(a,b,c)
  string a, b, c;
  cin >> a >> b >>c;

  cout << (char)(a.at(0)-32) << (char)(b.at(0)-32) << (char)(c.at(0)-32) << endl;
}


Measured memory_bytes: 3604
#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 rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
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 D;
  cin>>D;
  if(D==25) cout<<"Christmas"<<endl;
  else if(D==24) cout<<"Christmas Eve"<<endl;
  else if(D==23) cout<<"Christmas Eve Eve"<<endl;
  else if(D==22) cout<<"Christmas Eve Eve Eve"<<endl;
}



Measured memory_bytes: 3608
import java.util.PriorityQueue;
import java.util.Scanner;

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

			int productCount = sc.nextInt();
			int numOfDiscountTicket = sc.nextInt();

			long[] products = new long[productCount];
			PriorityQueue<Long> queue = new PriorityQueue<>(productCount, (x,y) -> (int)(y - x));

			for(int i = 0 ; i < products.length ; i++ ) {
				//			products[i] = sc.nextInt();
				queue.offer(sc.nextLong());
			}

			for(int i = 0 ; i < numOfDiscountTicket ; i++) {
				Long v = queue.poll();
				queue.offer(v/2);
			}

			long sum = queue.stream().mapToLong(p -> p).sum();

			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 64260
/**Bismillahir Rahmanir Rahim.**/
/*gcd=--gcd(a,b);*/
/*double p =log(a);
    p=p-floor(p);
    int x=pow(10,p);    m s di
 int x =floor(log10(a)) + 1;  d co
 a=ceil(log2(n)) == floor(log2(n)); pow of 2*/

#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
#define nl endl
#define in cin
#define out cout
#define ll long long
int main()
{
    ll a,b,c,d,e,x[100100],y,z,i,j,n,xx,mi;
    char s[100];
    in>>a;
    out<<a*a*a<<nl;


}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

const int MOD = 1e9 + 7;

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int h,w;
  cin >> h >> w;
  vector<VI> ways(h+1, VI(w+1, 0));
  ways[1][1] = 1;
  char c;
  forx(i,h) {
    forx(j,w) {
      cin >> c;
      if (i | j) {
        if (c == '#') {
          ways[i+1][j+1] = 0;
        } else {
          ways[i+1][j+1] = (ways[i][j+1] + ways[i+1][j]) % MOD;
        }
      }
    }
  }
  cout << ways[h][w] << nl;
  
  
  cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl;
  return 0;
}



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

int main() {
  int h,w,k;
  cin>>h>>w>>k;
  vector<vector<char>> a(h,vector<char>(w));
  vector<vector<int>> b(h,vector<int>(w));
  rep(i,h) {
    rep(j,w){
      cin >> a.at(i).at(j);
    }
  }
  int co=0;
  rep(i,h){
    int now=0;
    rep(j,w){
      if(a[i][j]=='#'){
        now++;
      }
      if(now!=0){
        b[i][j]=co+now;
      }
    }
    co+=now;
  }
  rep(i,h){
    rep(j,w){
      if(b[i][j]==0&&b[i][w-1]>0){
        for(int k=w-1;k>=j;k--){
          if(b[i][k]>0){
            b[i][j]=b[i][k];
          }
        }
      }
    }
  }
  rep(i,h){
    if(b[i][0]==0){
      int f=-1;
      for(int j=h-1;j>=i;j--){
        if(b[j][0]>0){
          f=j;
        }
      }
      if(f>=0){
        rep(j,w){
          b[i][j]=b[f][j];
        }
      }
    }
  }
  rep(i,h){
    if(b[i][0]==0){
      rep(j,w){
        b[i][j]=b[i-1][j];
      }
    }
  }
  
  rep(i,h){
    rep(j,w){
      cout<<b[i][j]<<" ";
    }
    cout<<endl;
  }
}

Measured memory_bytes: 4064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

i64 count_same(const string& lhs, const string& rhs, size_t shift) {
    i64 ret{0}, tmp{0};
    for (size_t i=0; i<lhs.size(); ++i) {
        if (lhs[i] == rhs[i]) ++tmp;
        else {
            ret = max(ret, tmp);
            tmp = 0;
        }
        if (tmp >= shift) return shift;
    }
    ret = max(ret, tmp);
    return ret;
}

int main(int argc, char **argv) {
    i64 n;
    cin >> n;

    string s, s2;
    cin >> s;

    s2 = s;

    i64 ans{0};
    for (size_t i=0; i<n-1; ++i) {
        char first = 0;
        s2 = s2.substr(1);
        s2.push_back(first);

        i64 tmp = count_same(s,s2,i+1);
        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <cmath>

#define EPS 1e-10
using namespace std;

bool visited[21];
int n,hx,hy,dx,dy,cx[21],cy[21];

bool dfs(int x , double day , int count){ //xツづ債個サツ催敖づ個暗環置
  bool judge = false;
  visited[x] = true;
  if(count == n) return true;
  count++;
  for(int i= 0;i<=n;i++){
    double t;
    if(visited[i]) continue;
    t = day + sqrt((cx[i] - cx[x])*(cx[i] - cx[x]) + (cy[i] - cy[x])*(cy[i] - cy[x]));
    if((dx - cx[i])*(dx - cx[i]) + (dy - cy[i])*(dy - cy[i]) < t*t + EPS ) return false;
  }    
  for(int i= 0;i<=n;i++){
    double d,t;
    if(visited[i]) continue;
    t = day + sqrt((cx[i] - cx[x])*(cx[i] - cx[x]) + (cy[i] - cy[x])*(cy[i] - cy[x]));
    judge |= dfs(i,t,count);
    visited[i] = false;
    if(judge) break;
  }
  return judge;
}
    
int main(){
  while(1){
    cin >> n >> hx >> hy >> dx >> dy;
    if(!(n|hx|hy|dx|dy)) break;
    dx -= hx;dy -= hy;
    cx[0] = cy[0] = 0;
    for(int i=1;i <= n;i++){
      int tx,ty;cin >> tx >> ty;
      cx[i] = tx - hx;cy[i] = ty - hy;
    }
    hx = hy = 0;
    for(int i=0;i<21;i++) visited[i] = false;
    if(dfs(0,0,0)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 864
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

vector<pii> queenp;

bool func(){
	if(queenp.size()==8)return true;
	rep(x, 8){
		rep(y, 8){
			bool flag = true;
			foreach(i, queenp){
				if(abs(x-i.first)==abs(y-i.second)){
					flag=false;
					break;
				}
				if(x==i.first||y==i.second){
					flag=false;
					break;
				}
			}
			if(!flag)continue;
			queenp.emplace_back(x, y);
			if(func())return true;
			queenp.pop_back();
		}
	}
	return false;
}

int main(){
	int n;
	cin >> n;
	rep(i, n){
		int x, y;
		cin >> x >> y;
		queenp.emplace_back(x, y);
	}

	func();

	vvector<char> ans(8, vector<char>(8, '.'));
	foreach(i, queenp){
		ans[i.first][i.second]='Q';
	}

	foreach(i, ans){
		foreach(j, i){
			cout << j;
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3088
N, K = gets.split.map(&:to_i)
MOD = 10**9 + 7

def mpow(x, n)
  ret = 1
  while n > 0
    if n.even?
      x = x * x % MOD
      n >>= 1
    else
      ret = ret * x % MOD
      n -= 1
    end
  end
  ret
end

def f(i) # K-1 C i
  return 0 if i > K - 1
  @f ||= [1]
  @f[i] ||= @f[i - 1] * (K - i) * mpow(i, MOD - 2) % MOD
end

def g(i) # N-K+1 C i
  return 0 if i > N - K + 1
  @g ||= [1]
  @g[i] ||= @g[i - 1] * (N - K - i + 2) * mpow(i, MOD - 2) % MOD
end

(1 .. K).each{|i| puts f(i - 1) * g(i) % MOD}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000009
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<max(0,c-a+b)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (long long int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
typedef tree<
    long long int,
    null_type,
    less<long long int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;
// find_by_order() and order_of_key()
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n, m, k, ans = 0, sum = 0;
    cin >> n >> m >> k;
    vll a(n), b(m);
    map<ll, ll> M;
    M[1000000000000] = n + 1;
    fr(i, 0, n)
    {
        cin >> a[i];
        sum += a[i];
        M[sum] = i + 1;
    }
    sum = 0;
    fr(i, 0, m)
    {
        cin >> b[i];
        sum += b[i];
        if (sum <= k)
        {
            ans = max(ans, (*M.upper_bound(k - sum)).second + i);
        }
    }
    sum = 0;
    M.clear();
    M[1000000000000] = m + 1;
    fr(i, 0, m)
    {
        sum += b[i];
        M[sum] = i + 1;
    }
    sum = 0;
    fr(i, 0, n)
    {
        sum += a[i];
        if (sum <= k)
        {
            ans = max(ans, (*M.upper_bound(k - sum)).second + i);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 18752
function Main(input) {
  let lines = input.split("\n");
  const count = parseInt(lines[0]);
  lines = lines[1].split(" ");
  let total = 0;
  for(let i = 0; i < count; i++){
  	if((i+1)%2 === 0) continue;
    if(parseInt(lines[i])%2 !== 0) total++;
  }
  console.log(total);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29680
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 25
#define endl "\n"
#define mod 1000000007
ll n,ar[N][N]; ll dp[22][2097160];
ll maxval(ll i,ll mask){
	if(i==n){
		return 1;
	}
	if(dp[i][mask]!=-1){
		return dp[i][mask];
	}

	ll j,k=0;
	for(j=0;j<n;j++){
		if(ar[i][j]==1&&(mask&(1<<j))==0){
			k=k%mod+maxval(i+1,mask|(1<<j))%mod;
			k=k%mod;
		}
	}
	return dp[i][mask]=k%mod;
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cin>>ar[i][j];
		}
	}
	l=maxval(0,0)%mod;
	cout<<l;
	return 0;
}


Measured memory_bytes: 360704
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
string t,s,r,s1,r1,s2,r2;
int main()
{
    cin>>t;
    s=t;
    r=s;
    int size=s.size();
    t="$"+t;
    rep(i,1,(size-1)/2){
        s1+=t[i];
    }
    r1=s1;
    rep(i,(size+3)/2,size){
        s2+=t[i];
    }
    r2=s2;
    reverse(s.begin(),s.end());
    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());
    if(s==r&&s1==r1&&s2==r2)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
from collections import deque


def bfs(si, sj, gi, gj):
    q = deque()
    q.append([si, sj, 0])
    used = [[False for _ in range(W)] for _ in range(H)]
    used[si][sj] = True

    while len(q) > 0:
        prvi, prvj, cost = q.popleft()
        for i, j in [[prvi - 1, prvj], [prvi + 1, prvj], [prvi, prvj - 1], [prvi, prvj + 1]]:
            if i == gi and j == gj:
                return cost + 1

            if i < 0 or j < 0 or i >= H or j >= W:
                continue

            if used[i][j] or C[i][j] == '#':
                continue

            q.append([i, j, cost + 1])
            used[i][j] = True
    return -1


if __name__ == '__main__':
    H, W = map(int, input().split())
    C = [input() for _ in range(H)]
    min_cost = bfs(0, 0, H - 1, W - 1)
    if min_cost == -1:
        print(-1)
    else:
        black_num = sum([row.count('#') for row in C])
        print(H * W - black_num - min_cost - 1)


Measured memory_bytes: 39664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;string s;
    cin>>k>>s;
    int n = s.size();
    if(n<=k)
        cout<<s;
    else
    {
        for(int i=1;i<=k;++i)
            cout<<s[i-1];
        cout<<"...";
    }
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    const string S = "keyence";

    string s;
    cin>>s;
    int n = s.length();

    if (s == S) out("YES");

    for (int i=0; i<n; i++) {
	for (int j=i; j<n; j++) {
	    string cur;
	    for (int k=0; k<n; k++) {
		if (i<=k && k<=j) continue;
		cur += s[k];
	    }
	    if (cur==S) out("YES");
	}
    }

    out("NO");
    
    
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, time, M[MAX][MAX], color[MAX], d[MAX], f[MAX];

void visit (int u) {
  int v;
  color[u] = GRAY;
  d[u] = ++time;
  for (v = 0; v < n; v++) {
    if (M[u][v] == 0) {
      continue;
    }
    if (color[v] == WHITE) {
      visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++time;
}

void dfs() {
  int u;
  for (u = 0; u < n; u++) {
    color[u] = WHITE;
  }
  time = 0;
  for (u = 0; u < n; u++) {
    if (color[u] == WHITE) {
      visit(u);
    }
  }
}

int main() {
  int u, v, k, i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      M[i][j] = 0;
    }
  }
  for (i = 0; i < n; i++) {
    scanf("%d%d", &u, &k);
    for (j = 0; j < k; j++) {
      scanf("%d", &v);
      M[u - 1][v - 1] = 1;
    }
  }
  dfs();
  for (i = 0; i < n; i++) {
    printf("%d %d %d\n", i + 1, d[i], f[i]);
  }
  return 0;
}



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

int main( void ) {
    int n;
    cin >> n;
    vector<int> vt(n);
    for( int i = 0; i < n; ++i ) cin >> vt[i];
    for( int i = n - 1; i >= 0; --i ) cout << vt[i] << ( i == 0 ? '\n' : ' ' );
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
bool f(int m, int M, int cnt, int N)
{
    if (m == M) {
        return N >= m*2 || m == N-1;
    } else if (m + 1 == M) {
        return cnt < M && cnt + (M - cnt) * 2 <= N;
    } else {
        return false;
    }
}

int main()
{
    int N; cin >> N;
    vector<int> A(N); for (auto& a : A) cin >> a;
    sort(begin(A), end(A));
    int m = A[0], M = A[N-1];
    int cnt = count(begin(A), end(A), m);
    cout << (f(m, M, cnt, N) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 640
n = gets.chomp.to_i
score = []
smallnum = 0

n.times do |i|
  score[i] = gets.chomp.to_i
end

score.sort!

sum = score.inject(:+)

if sum % 10 == 0
  score.each do |i|
    if i % 10 != 0
      smallnum = i
      break
    end
  end
end

max = sum - smallnum

if max % 10 == 0
  puts '0'
else
  puts max
end

Measured memory_bytes: 1916
import sys
from operator import itemgetter
import math

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():

    a, b, x = mi()
    V = a**2 * b

    if V // 2 < x:
        X = 2*x / a**2 - b
        Y = b - X
        ans = math.degrees(math.asin(Y/math.sqrt(a**2 + Y**2)))
    else:
        X = 2*x / (a*b)
        ans = math.degrees(math.asin(b/math.sqrt(X**2 + b**2)))

    print(ans)

    return

main()


Measured memory_bytes: 9428
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i]
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    int ans=0;
    while(n){
        ans+=(n%10==2);
        n/=10;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256