akhauriyash/Code-Regression huggingface dataset:
fn main(){
	loop{
		let v = read_vec::<usize>();
		let (h, w) = (v[0], v[1]);
		if h == 0 && w == 0 { break; }
		
		let row = repeat_string("#", w);
		for _ in 0..h {
			println!("{}", row)
		}
		println!("");
	}
}

fn repeat_string(s: &str, n: usize) -> String{
	let mut str = String::new();
	for _ in 0..n {
		str.push_str(s);
	}
	str
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 5032
#include<stdio.h>
int main()
{
  int A1,A2,A3,A;
  scanf("%d %d %d",&A1,&A2,&A3);
  A=A1+A2+A3;
  if(A>=22)
  {
      printf("bust",A);
  }
  else
  {
      printf("win",A);
  }
}


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


int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a * b > c * d) cout << a * b << endl;
  else cout << c * d << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
 
		if ( m >= n ) {
			System.out.println("Yes");
        } else {
          	System.out.println("No");
        }
	}
}

Measured memory_bytes: 22996
n = int(input())
h = list(map(int,input().split()))
count = 0
maxcount = 0
for i in range(n-1):
         if h[i] >= h[i+1]:
                  count += 1
         else:
                  if count > maxcount:
                           maxcount = count
                           count = 0
                  else:
                           count = 0
print(max(count,maxcount))


Measured memory_bytes: 14252
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);	
	
	int N; cin >> N;
	int data[N]; F0R(i, N) cin >> data[i];
	
	multiset<int> used;
	int ans = 0;
	F0Rd(i, N) {
		if (used.upper_bound(data[i]) != used.end()) {
			used.erase(used.upper_bound(data[i]));
			used.insert(data[i]);
		} else {
			used.insert(data[i]);
			ans++;
		}
	}
	
	cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

#define MOD 1000000007

//S[0]から始まる文字列の長さを求める関数
int string_len(char* str){
    int len=0;
    while(str[len]!=0){
        len++;
    }
    return len;
}

int main(void){
    char S[100001];
    scanf("%s",S);

    //数列Sの長さ
    int N=string_len(S);

    long dp[N+1][4];
    dp[N][3]=1;
    dp[N][2]=0;
    dp[N][1]=0;
    dp[N][0]=0;
    for(int i=N-1;i>=0;i--){
        //dp[3]について
        if(S[i]=='?') dp[i][3]=(3*dp[i+1][3])%MOD;
        else dp[i][3]=dp[i+1][3];

        //dp[2]について
        if(S[i]=='?') dp[i][2]=(3*dp[i+1][2]+dp[i+1][3])%MOD;
        else if(S[i]=='C') dp[i][2]=(dp[i+1][2]+dp[i+1][3])%MOD;
        else dp[i][2]=dp[i+1][2];

        //dp[1]について
        if(S[i]=='?') dp[i][1]=(3*dp[i+1][1]+dp[i+1][2])%MOD;
        else if(S[i]=='B') dp[i][1]=(dp[i+1][1]+dp[i+1][2])%MOD;
        else dp[i][1]=dp[i+1][1];

        //dp[0]について
        if(S[i]=='?') dp[i][0]=(3*dp[i+1][0]+dp[i+1][1])%MOD;
        else if(S[i]=='A') dp[i][0]=(dp[i+1][0]+dp[i+1][1])%MOD;
        else dp[i][0]=dp[i+1][0];
    }

    printf("%ld\n",dp[0][0]);

    return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

class Heap {
public:
  typedef long long P;
  int sz = 0;
  vector<P> heap;

  void push(int x) {
    int i = sz++;
    if (heap.size() < sz) heap.pb(0);
    while (i > 0) {
      int p = (i-1) / 2;
      if (heap[p] >= x) break;
      heap[i] = heap[p];
      i = p;
    }
    heap[i] = x;
  }
  P pop() {
    P ret = heap[0];
    P x = heap[--sz];
    int i = 0;
    while (i*2+1 < sz) {
      int a = i*2+1, b = i*2+2;
      if (b < sz && heap[b] > heap[a]) a = b;
      if (heap[a] <= x) break;
      heap[i] = heap[a];
      i = a;
    }
    heap[i] = x;
    return ret;
  }
};

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  Heap heap;
  string s;
  while (cin >> s) {
    if (s == "end") break;
    if (s[0] == 'i') {
      int x; cin >> x;
      heap.push(x);
    }
    else {
      cout << heap.pop() << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 11140
#include<stdio.h>
int main(){



  int N=0,i,j,v,s;
  
  scanf("%d",&N);

  
  int A[N];

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

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

  for(i=1;i<N;i++)
    {
      v=A[i];
      j=i-1;
    
      while(j>=0 && A[j]>v)
	{
	  A[j+1]=A[j];
	  j--;
	  A[j+1]=v;



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




  
    return 0;
}



Measured memory_bytes: 2048
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// }}}
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;

int n;
string s;

int cnt1[1123456];

int range1(int l, int r) {
  int res = cnt1[r];
  if(l - 1 >= 0) res -= cnt1[l-1];
  return res;
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n >> s;
  for(int i = 0; i < n; i++) {
    cnt1[i] = s[i] == 'M';
    if(i) cnt1[i] += cnt1[i-1];
  }
  int q;
  cin >> q;

  int k;
  // DMC
  while(q--) {
    cin >> k;
    deque<int> v;
    ll ans = 0;
    ll now = 0;
    for(int i = 0; i < n; i++) {
      while(v.size() && v.front() <= i - k) now -= range1(v.front(), i - 1), v.pop_front();
      if(s[i] == 'D') {
        v.emplace_back(i);
      }
      if(s[i] == 'M') {
        now += v.size();
      }
      if(s[i] == 'C') {
        ans += now;
      }
    }
    cout << ans << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 9428
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 20:56:06 2020

@author: liang
"""

N = int(input())
L = [int(x) for x in input().split()]

L.sort()
ans = 0
#print(L)
for i in range(N-2):
    #print("1:",i)
    p = i+2
    #以下O(2?N)　定数倍が遅い
    for j in range(i+1,N-1):
        #print("2",i,j)
        while p < N and L[p] < L[i] + L[j] :
            p += 1
            #print("up")
        #print(p)
        #ans += len(L[j+1:p])
        ans += max(0, p - j - 1)
print(ans)

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

const long N=123456;

int main (){
	
	//素数テーブル作成
	bool prime[2*N+1];
	for(long i=0; i<=2*N; ++i) prime[i]=true;
	prime[1]=false;
	prime[2]=true;
	
	for(long i=2; i<=2*N; ++i){
		if(prime[i]){
			for(long j=2; i*j<=2*N; ++j) prime[i*j]=false;	
		}
	}
	
	//処理
	while(1){
		long n, ans=0;
			
		scanf(" %ld", &n);
		if(n==0) break;
		
		for(long i=n+1; i<=2*n; ++i){
			//printf("%ld\n", i);
			if(prime[i]) ans++;
		}
		printf("%ld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1428
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define whln(t) while(t--)
#define whlp(t) while(t++)
ll i=0,j=0;


int main(void){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
	 // int t ;
	 // cin>>t;
	 // whln(t){
  	ll n,k;
  	cin>>n>>k;
  	vector<ll>v(n);
  	rep(i,n)
  		cin>>v[i];
  	sort(v.begin(),v.end());
  	ll sum = 0 ;
  	rep(i,k)
  		sum+=v[i];
  	cout<<sum;
}
//   *****  *******   !
//   *		     *    !
//   ***       *      !
//   *       *        !
//   *****  *******   !

Measured memory_bytes: 3608
const main = (input) => {
  const args = input.trim().split("\n");
  const [x, n] = args[0]
    .trim()
    .split(" ")
    .map((n) => parseInt(n, 10));
 
  const excluded = (() => {
    if (n === 0) {
      return [];
    } else {
      return args[1]
        .trim()
        .split(" ")
        .map((n) => parseInt(n, 10));
    }
  })();
 
  const selection = [...Array(101 + 1).keys()].filter(
    (s) => !excluded.includes(s)
  );
 
  const abs = (n) => {
    if (n < 0) return -n;
    else {
      return n;
    }
  };
  const byAsc = (a, b) => a[1] - b[1];
 
  const answer = selection
    .map((s) => [s, abs(x - s)])
    .sort(byAsc)[0][0];
 
  console.log(answer);
};
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29652
import java.util.*;
import java.util.Map.Entry;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        Map<String,Integer> poll = new HashMap<String,Integer>();
        int max = 0;
        boolean loop = true;

        for(int i = 0;i < n; i++){
            String str = scan.next();
            if(!poll.containsKey(str)) poll.put(str,1);
            else poll.replace(str, poll.get(str), poll.get(str) + 1);
        }
        scan.close();

        List<Entry<String, Integer>> list_entries = new ArrayList<Entry<String, Integer>>(poll.entrySet());
        Collections.sort(list_entries, new Comparator<Entry<String, Integer>>() {
        public int compare(Entry<String, Integer> obj1, Entry<String, Integer> obj2)
            {
                //降順
                return obj2.getValue().compareTo(obj1.getValue());
            }
        });

        ArrayList<String> result = new ArrayList<String>();

        for(Entry<String, Integer> entry : list_entries) {
            if(loop){
                loop = false;
                max = entry.getValue();
                result.add(entry.getKey());
            }
            else{
                if(!(entry.getValue() == max)) break;
                result.add(entry.getKey());
            }
        }

        Collections.sort(result);

        for(String r : result){
            System.out.println(r);
        }
    }
}

Measured memory_bytes: 82660
#include <bitset>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> profs(N);
  for (int n = 0; n < N; ++n) {
    int A;
    cin >> A;
    vector<pair<int, int>> prof(A);
    for (int a = 0; a < A; ++a) {
      int x, y;
      cin >> x >> y;
      prof[a] = {x-1, y};
    }
    profs[n] = prof;
  }

  int res = 0;
  for (int64_t i = 0, end = pow(2, N); i < end; ++i) {
    bitset<15> bs(i);
    int trustful = 0;
    bool success = true;
    for (size_t n = 0; n < N; ++n) {
      if (bs.test(n)) {
        for (const auto& p : profs[n]) {
          if ((p.second == 0 && bs.test(p.first))
              || (p.second == 1 && !bs.test(p.first))) {
            success = false; break;
          } 
        }
        ++trustful;
      }
      if (!success) break;
    }
    if (success) {
      res = max(res, trustful);
    }
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 4064
use std::io::Read;

fn read<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut p = vec![n; n];
    for i in 0..n {
        p[i] = read();
        p[i] -= 1;
    }

    let mut count = 0;
    for i in 0..n {
        if i != p[i] {
            count += 1;
        }
    }

    if count <= 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;



int main() {
	int i, j, n; cin >> n;
	vector<int> a(n);
	ll ans = 0;
	for (i = 0; i < n; i++)cin >> a[i];

	vector<vector<int>> range(100000);
	int pos = 0;
	for (i = 0; i < n; i++) {
		if (a[i]==0) {
			pos++;
			continue;
		}
		range[pos].push_back(a[i]);
	}

	for (i = 0; i <= pos; i++) {
		ll sum = 0;
		for (j = 0; j < range[i].size(); j++) {
			sum += range[i][j];
		}
		ans += sum / 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4608
N, M = list(map(int, input().split()))

ac = [0]*N
pena = [0]*N

for _ in range(M):
    p, s = input().split()
    p = int(p)-1

    if ac[p] == 1:
        continue

    if s == "WA":
        pena[p] += 1
    if s == "AC":
        ac[p] = 1

AC = 0
PENA = 0
for i in range(N):
    AC += ac[i]
    if ac[i]:
        PENA += pena[i]

print(AC, PENA)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
int main()
{
    fastio();
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    ll n;
    cin>>n;
    n = logtwo(n);
    n = powe(2,n+1)-1;
    cout<<n<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from bisect import bisect_left
N = int(input())
A = [int(input()) for _ in range(N)]
L = [A[0]]

for i in range(1, N):
    if L[-1] < A[i]:
        L.append(A[i])
    else:
        L[bisect_left(L, A[i])]  = A[i]
print(len(L))

Measured memory_bytes: 12384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890


int main(){
    ll i,j;
    int s,t,p,q,M,y;
    cin>>s>>t>>p>>q>>M>>y;
    int z=s^t;
    int ans=y^z;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>

int main(){
  int a,b,c,x;
  int i,j,k,ans=0;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&x);
  for(i=0;i<=a;i++){
    for(j=0;j<=b;j++){
      for(k=0;k<=c;k++){
        if(500*i+100*j+50*k==x){
          ans += 1;
        }
      }
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int MAXN=65;
const long long INF=1000000000000000000LL;
int n;
long long k[MAXN];
long long calc(long long A, int x){
    long long mask=1LL<<x; A++;
    long long tmp=A/mask, ans=(tmp/2)*mask;
    if(tmp&1LL) ans+=A&(mask-1);
    return ans;
}
bool check(long long A, long long B){
    for(int i=n-1; i>=0; i--){
        if(calc(B,i)-calc(A-1,i)!=k[i]){
            return false;
        }
    }
    return true;
}
long long solve(long long W){
    long long A=0, B=-1, C=-1;
    for(int i=n-1; i>=0; i--){
        if(k[i]>W) return -1;
        if(k[i]==0){
            A|=0LL<<i;
        }
        else if(k[i]==W){
            A|=1LL<<i;
        }
        else{
            B=A|(1LL<<i);
            C=B+k[i]-1;
            A=C-W+1;
            break;
        }
    }
    if(C==-1) C=A;
    if(A==0||C>INF) return -1;
    if(A+W-1==C&&check(A,C)){
        return A;
    }
    return -1;
}
int main(){
    while(~scanf("%d",&n)&&n){
        for(int i=0; i<n; i++){
            scanf("%lld",&k[i]);
        }
        long long A=-1, B;
        for(long long W=2*k[0]-1; W<=2*k[0]+1; W++){
            if(W<0) continue;
            long long ret=solve(W);
            if(ret!=-1){
                if(A!=-1){
                    puts("Many");
                    goto failed;
                }
                A=ret; B=ret+W-1;
            }
        }
        if(A==-1){
            puts("None");
        }
        else{
            printf("%lld %lld\n",A,B);
        }
        failed:;
    }
    return 0;
}

Measured memory_bytes: 1176
# coding: utf-8
# Your code here!

n,m = map(int,input().split())

a = [input() for i in range(n)]
b = [input() for i in range(m)]

for x in range(n-m+1):
    for y in range(n-m+1):
        f = True
        for i in range(m):
            if a[y+i][x:x+m] != b[i]:
                f = False
                break
        if f:
            break
    if f:
        break

print("Yes" if f else "No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  set<int> st;
  rep(i, 3)
  {
    int a;
    cin >> a;
    st.insert(a);
  }
  Yes(st.size() == 2);

  return 0;
}


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

using namespace std;

int main()
{
    int n,h,w;
    cin>>n>>h>>w;
    int a[n];
    int b[n];
    for(int i=0;i<n;i++)
    {
    cin>>a[i]>>b[i];
    }
    int nb=0;
    for(int i=0;i<n;i++)
    {
        if ((a[i]>=h)and(b[i]>=w))
            nb++;

    }
    cout<<nb;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    int a, b;
    cin >>a >> b;
    rep(i, 1, 4){
        if(a*b*i % 2 == 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

#define H 9


int dp[1<<H][100001];

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> VW(N);
    REP(i, N) cin >> VW[i].first >> VW[i].second;
    int Q;
    cin >> Q;
    vector<pair<int, int>> vL(Q);
    REP(i, Q){
        cin >> vL[i].first >> vL[i].second;
        vL[i].first--;
    }

    dp[0][VW[0].second] = VW[0].first;
    for(int i=1; i<min(N, 1<<H); i++){
        int par = (i-1) / 2;

        for(int j=0; j<=100000; j++) dp[i][j] = dp[par][j];

        for(int j=0; j<=100000; j++){
            int w = j + VW[i].second;
            int v = dp[par][j] + VW[i].first;
            if(w > 100000) break;
            dp[i][w] = max(dp[i][w], v);
        }
    }

    for(int i=0; i<(1<<H); i++)
        for(int j=1; j<=100000; j++)
            dp[i][j] = max(dp[i][j], dp[i][j-1]);


    vector<int> anss(Q);
    REP(q, Q){
        int v = vL[q].first;
        int L = vL[q].second;
        vector<pair<int, int>> z;

        while(true){
            if(v < 1<<H) break;
            z.push_back(VW[v]);
            v = (v-1)/2;
        }

        int sz = z.size();

        int ans = 0;
        for(int i=0; i<(1<<sz); i++){
            int Vtot = 0;
            int Wtot = 0;
            for(int j=0; j<sz; j++){
                if(i&(1<<j)){
                    Vtot += z[j].first;
                    Wtot += z[j].second;
                }
            }
            if(Wtot > L) continue;
            ans = max(ans, Vtot + dp[v][L-Wtot]);
        }
        anss[q] = ans;
    }
    for(auto x : anss)
        cout << x << endl;
    return 0;
}

Measured memory_bytes: 206428
x=[0]*32
x[0]=1
x[1]=-2
for i in range(2,32):
  x[i]=x[i-2]+(-2)**i
n=int(input())
if n==0:
  print(0)
  exit()
ans=''
for i in range(2,33)[::-1]:
  if i%2:
    l=x[i-2]
    r=x[i-1]
  else:
    l=x[i-1]
    r=x[i-2]
  t=n-(-2)**i
  if l<=t and t<=r:
    n=t
    ans=ans+'1'
  else:
    ans=ans+'0'
ls=['10','11','00','01']
ans=ans+ls[n+2]
for i in range(len(ans)):
  if ans[i]=='1':
    re=i
    break
print(ans[re:])

Measured memory_bytes: 9168
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
    static void Main() {
        var N = NextInt();
        var A = new long[N];
        var B = new long[N];
        var ans = 0L;

        for (var i = 0; i < N; i++) {
            A[i] = NextInt();
            B[i] = NextInt();
        }

        for (var i = N - 1; i >= 0; i--) {
            A[i] += ans;
            if (A[i] % B[i] != 0) {
                ans += Math.Abs(A[i] % B[i] - B[i]);
            }
        }
        WriteLine(ans);
    }

    static int NextInt() {
        return int.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}

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

n = int(input())
rw = input()

w = 0

c = [0] * n

for i in range(n):
    if rw[i] == 'W':
        c[i] = 1
        w += 1

r = n - w

left_w = 0
for x in c[0:r]:
    if x == 1:
        left_w += 1

print(left_w)


Measured memory_bytes: 12176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool isN = false, isS = false, isE = false, isW = false;
    rep(i, s.size())
    {
        if (s[i] == 'N')
            isN = true;
        else if (s[i] == 'S')
            isS = true;
        else if (s[i] == 'E')
            isE = true;
        else if (s[i] == 'W')
            isW = true;
    }

    if ((!isN && isS) || ((isN && !isS)))
        cout << "No"
             << "\n";
    else if ((!isE && isW) || ((isE && !isW)))
        cout << "No"
             << "\n";
    else
        cout << "Yes"
             << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val s = (1..n).map { sc.nextInt() }

  if (s.all { it % 10 == 0 }) {
    println(0)
    return
  }

  val min = s.filter { it % 10 != 0 }.min() ?: 0

  var ans = s.sum()
  if (ans % 10 == 0) {
    ans -= min
  }

  println(ans)
}


Measured memory_bytes: 37644
/*
テヲツ鳴ーテ」ツ?療」ツ?湘、ツスツ愿」ツ?」テ」ツ?淌」ツつ「テ」ツつォテ」ツつヲテ」ツδウテ」ツδ暗」ツ?古、ツスツソテ」ツ?暗」ツ?セテ」ツ?崚」ツつ禿」ツ?ァテ」ツ?療」ツ?淌」ツ??

テ、ツコツ古・ツ按?ヲツ篠「テァツエツ「テ」ツ??
*/

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int m,n;
vector<int>v;

bool C(int x){

  int cnt=0,sum=0,i=0;
  while(i<n && cnt<m){
    if(sum+v[i]<=x)sum+=v[i],i++;
    else sum=0,cnt++;
  }
  return i==n && m>cnt;
}

int main(void){

  while(cin >> m >> n,m|n){
    v.clear();

    int l=0,r=100000000,a;
    for(int i=0;i<n;i++){
      cin >> a;
      v.push_back(a);
    }
    
    while(r-l>1){
      int mid=(l+r)/2;
      if(C(mid))r=mid;
      else l=mid;
    }
    cout << r << endl;
  }

  return 0;
}

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

#define int long long

const int N = 1e5 + 10, mod = 1e9 + 7;
int n, mark[N];

int pw(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1)
			res = (res * a) % mod;
		a = (a * a) % mod;
		b /= 2;
	}
	return res;
}

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0, x; i < n; i++)
		cin >> x, mark[x]++;
	
	for (int i = n - 1; i > 0; i -= 2)
		if (mark[i] != 2)
			return cout << 0 << endl, 0;
	if ((n & 1) && mark[0] != 1)
		return cout << 0 << endl, 0;
	cout << pw(2, n / 2) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    int A=a.size(),B=b.size();
    if (a.at(A-1)==b.at(0) && b.at(B-1)==c.at(0)){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int answer = 0;
		for(int i = 0; i <= a; i++) {
			for(int j = 0; j <= b; j++) {
				for(int k = 0; k <= c; k++) {
					if((500 * i) + (100 * j) + (50 * k) == x) {
						answer++;
					}
				}
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 35588
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val ans = 1000 - if (n % 1000 != 0) (n % 1000) else 1000
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 34112
n = int(input())
A = list(map(int, input().split()))
C = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
A_class = []
free_color = 0
from bisect import bisect_right
for a in A:
  cls = bisect_right(C, a)
  if cls == 8:
    free_color += 1
  else:
    A_class.append(cls)
#print(A_class, free_color)
max_class = len(set(A_class)) + free_color
min_class = max(len(set(A_class)), 1)
print(min_class, max_class)
    

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void)
{
  int q, n[105];
  cin >> q;
  REP(i, q) {
    cin >> n[i];
    int cnt = 0;
    while(n[i] > 9) {
      int maxret = -INF;
      string nstr = to_string(n[i]);
      FOR(j, 1, nstr.size()) {
        string left = nstr.substr(0, j), right = nstr.substr(j);
        maxret = max(maxret, stoi(left) * stoi(right));
        //cout << left << " " << right << " " << maxret << endl;
      }
      n[i] = maxret;
      cnt++;
      //cout << "cnt:" << cnt << endl;
      if(cnt > 10000000) {cnt = -1; break;}
    }
    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 3212
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();

		int edge[][] = new int[num - 1][2];
		for(int i = 0; i < num - 1; i ++) {
			edge[i][0] = sc.nextInt() - 1;
			edge[i][1] = sc.nextInt() - 1;
		}

		int point[] = new int[num];
		long sum = 0;
		int max = 0;
		for(int i = 0; i < num; i ++) {
			point[i] = sc.nextInt();
			sum += point[i];
			max = Math.max(max, point[i]);
		}
		sum -= max;
		Arrays.sort(point);

		int ans[] = new int[num];
		for(int i = 0; i < num; i ++) {
			ans[i] = -1;
		}
		ans[0] = point[num - 1];

		for(int i = 1; i < num; i ++) {
			for(int j = 0; j < num - 1; j ++) {
				if(ans[edge[j][0]] >= 0 && ans[edge[j][1]] < 0) {
					ans[edge[j][1]] = point[num - i - 1];
					break;
				}
				if(ans[edge[j][0]] < 0 && ans[edge[j][1]] >= 0) {
					ans[edge[j][0]] = point[num - i - 1];
					break;
				}
			}
		}

		System.out.println(sum);
		for(int i = 0; i < num; i ++) {
			System.out.print(ans[i]+" ");
		}
		System.out.println();
	}
}

Measured memory_bytes: 44712
#include <iostream>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n ; i++)
#define rep(i,n) REP(i,0,n)
int main(){
  int n;
  cin >> n;
  int ans = 0;
  bool isAns = true;
  rep(i,n){
    char c;
    int k;
    cin >> c >> k;
    if(c == '(')ans += k;
    else ans -= k;
    if( ans < 0 ) isAns = false;
  }
  cout << (ans == 0 && isAns? "YES":"NO") << endl;
  
}

Measured memory_bytes: 1160
import java.util.Scanner;

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

		//ビンゴ作成
		int[][] bingo = new int[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				bingo[i][j] = sc.nextInt();
			}
		}

		//ビンゴを回す
		final int N = sc.nextInt();
		for (int z = N; z > 0; z--) {
			int b = sc.nextInt();
			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < 3; j++) {
					if (b == bingo[i][j]) {
						bingo[i][j] = 0;
					}
				}
			}
		}

		//ビンゴ判定

		int sum = 0;
		int sum2 = 0;
		int sum3 = 0;

		if ((bingo[0][2] + bingo[1][1] + bingo[2][0]) == 0) {
			judge = true;
		}
		check: for (int i = 0; i < 3; i++) {
			sum = 0;
			sum2 = 0;
			sum3 = 0;
			for (int j = 0; j < 3; j++) {

				sum += bingo[i][j];
				sum2 += bingo[j][i];
				sum3 += bingo[j][j];
			}
			if (sum == 0 || sum2 == 0 || sum3 == 0) {
				judge = true;
				break check;
			}
		}
		if (judge) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		//チェック用
		//		for (int i = 0; i < 3; i++) {
		//			for (int j = 0; j < 3; j++) {
		//				System.out.print(bingo[i][j] + " ");
		//			}
		//			System.out.println("");
	}
}


Measured memory_bytes: 23764
#include<stdio.h>

int main()
{
  char string[3];
  scanf("%s",string);
  int a=0; int b=0; int c=0;
  for(int i=0;i<3;++i){
    if(string[i]=='a')  a=1;
    else if(string[i]=='b')  b=1;
    else if(string[i]=='c')  c=1;
  }
  if(a==1 && b==1 && c==1)  printf("Yes\n");
  else  printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){

	int a,b;

	cin >> a;
	cin >> b;

	if (a==b){
		cout << "a == b" << endl;
	}

	if(a<b){
		cout << "a < b" << endl;
	}

	if(a>b){
		cout << "a > b" << endl;
	}
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		
		switch (op) {
		case "+":
			System.out.println(a+b);
			break;

		case "-":
			System.out.println(a-b);
			break;
		}
	}
}


Measured memory_bytes: 25044
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int N;
string S;


int main()
{

	cin >> N;
	cin >> S;

	int ans = 0;

	for (int k = 0; k < N - 1; k++) {
		vector<int> A(N);

		int c = 0;
		for (int i = 1; i < S.size(); i++) {
			if (i + A[i - c] < c + A[c]) {
				A[i] = A[i - c];
			}
			else {
				int j = max(0, c + A[c] - i);
				while (i + j < S.size() && S[j] == S[i + j]) ++j;
				A[i] = j;
				c = i;
			}

			ans = max(ans, min(A[i], i));
		}
		S.erase(S.begin());
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

AS = [0] * (N+1)
for i in range(N):
    AS[i+1] = AS[i]+A[i]

# DBG = []

def find(power):
    cnt = 0
    sam = 0
    for a in A:
        left = -1
        right = N
        while right-left>1:
            mid = left + (right-left)//2
            if a+A[mid] >= power:
                right = mid
            else:
                left = mid
        cnt += (N-right)
        sam += (AS[N]-AS[right]) + (N-right)*a
        # for i in range(right, N):
        #     DBG.append((A[i], a))
    return cnt, sam

left = 0
right = 10**15
while right-left>1:
    mid = left + (right-left)//2
    cnt, sam = find(mid)
    if cnt>M:
        left = mid
    else:
        right = mid

# ap+aq<=leftを満たすものの和を求める
cnt, ans = find(left)
print(ans - (cnt-M)*left)


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

int main (){
	int N;
	cin >> N;
	vector<int> V(N);
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}
	vector<int> C(N);
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (V[i] - C[i] > 0) {
			ans += V[i] - C[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cout << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;

string a;
ll ans = 0;

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

    cin >> a;
    ll count[27] = {0};
    ans = (ll)a.size() * (ll)(a.size() - 1) / 2;

    REP(i, a.size()) {
        count[a[i] - 'a']++;
    }
    REP(i, 27) {
        ll c = count[i] - 1;
        if (c <= 0) continue;
        ans -= c * (c+1) / 2;
    }
    ans++;
    cout << ans << endl;
    return 0;
}


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


const int N = 1e5 + 50, mod = 1e9 + 7;

long long n, m, fact[N], ifact[N];


long long po(long long b, long long p){
    long long res = 1LL
    ;
    while(p){
        if(p&1) res = (res * b)%mod;
        b = (b * b)%mod;
        p >>= 1;
    }
    return res;
}

void init(){
    fact[0] = 1, ifact[0] = 1;
    for(int i= 1;i<N;i++){
        fact[i] = (i*fact[i-1])%mod;
        ifact[i] = po(fact[i], mod-2);
    }
}

long long ncr(long long _n, long long _r){
    long long res = 1LL;
    res *= fact[_n];
    res %= mod;
    res *= ifact[_r];
    res %= mod;
    res *= ifact[_n - _r];
    res %= mod;
    return res;
}


int main(){
    init();
    cin >>  n >> m;
    if(abs(n-m)>1){
        cout << 0 << endl;
        return 0;
    }
    int ok = abs(n-m);
    if(ok) ok = 1;
    else ok = 2;
    cout << (fact[n]*fact[m]*ok)%mod<< endl;


}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long ll;

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int count2(int n) {
    int ans = 0;
    while (n > 0) {
        if (n % 10 == 2) ans++;
        n /= 10;
    }
    return ans;
}
int main() {
    int N; cin >> N;
    int cnt2 = count2(N);
    cout << cnt2 << endl;
}


Measured memory_bytes: 3564
// c++include
#include <iostream>
#include <algorithm>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用<-namespace
using namespace std;

// define, typedef
#define rpt(i, n) for(ll i = 0; i < (n); i++)
typedef long long ll;

int score(int e) {
	if (e < 400)
		return 1;
	else if (e < 800)
		return 2;
	else if (e < 1200)
		return 3;
	else if (e < 1600)
		return 4;
	else if (e < 2000)
		return 5;
	else if (e < 2400)
		return 6;
	else if (e < 2800)
		return 7;
	else if (e < 3200)
		return 8;
	else
		return 9;
}

// main関数
int main(void) {
	int n;
	cin >> n;
	int sls[11];
	for (int i = 1; i < 11; i++) {
		sls[i] = 0;
	}
	rpt(i, n) {
		int e;
		cin >> e;
		sls[score(e)]++;
	}
	int kind = 0;
	for (int i = 1; i < 9; i++) {
		if (sls[i] >= 1) {
			kind++;
		}
	}
	if (kind == 0) {
		cout << 1 << " ";
	}
	else {
		cout << kind << " ";
	}
	kind += sls[9];
	if (kind > n) {
		kind = n;
	}
	cout << kind;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
b_list = []
uni = []
for i in range(n):
  b = input()
  b_list.append(b)
  if not b in uni:
    uni.append(b)

m = int(input())
r_list = []
r_uni = []
for i in range(m):
  r = input()
  r_list.append(r)
  if not r in uni:
    uni.append(r)

uni.append("aaaaaaaaaaa")
uni_l = len(uni)
c = []
for i in range(uni_l):
  c.append(b_list.count(uni[i]) - r_list.count(uni[i]))
print(max(c))           

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = [INT() for _ in range(N)]

dic = defaultdict(int)

for x in A:
	dic[x] += 1

print(len([1 for x in dic if dic[x]%2 == 1]))


Measured memory_bytes: 18364
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int d = N%10;
  int c = N%100/10;
  int b = N%1000/100;
  int a = N/1000;
  
  if(a==b && b==c)
    cout << "Yes" << endl;
  else if(b==c && c==d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    string N;
    cin >> N;
    vector<vector<int>> dp(N.size() + 1, vector<int>(2, -1));
    dp[0][0] = 0;
    for(int i = 0; i < N.size(); i++) {
        // j = 0
        if (dp[i][0] != -1) {
            for(int k = 0; k <= N[i] - '0'; k++) {
                chmax(dp[i + 1][k != N[i] - '0'], dp[i][0] + k);
            }
        }
        if (dp[i][1] != -1) {
            // j = 1
            for(int k = 0; k <= 9; k++) {
                chmax(dp[i + 1][1], dp[i][1] + k);
            }
        }
    }

    cout << max(dp[N.size()][0], dp[N.size()][1]) << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 384
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define loop(n) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i += 2)
		cout << s[i];
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>

using namespace std;

int calc_gcj(int a, int b) {
	int A=0, B=0;
	if (a == max(a,b)) {
		A = a;
		B = b;
	} else {
		A = b;
		B = a;
	}
	if (A == B) return A;
	else return calc_gcj(B,A-B);
	return -1;
}

void solve(int a, int b) {
	int gcj = calc_gcj(a,b);
	int lcm = a/gcj*b;
	cout << gcj << " " << lcm << endl;
}

int main() {
	int a, b;
	while (cin >> a >> b) {
		solve(a,b);
	}
	return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int N; cin >> N;

    vector<int> A(N);
    for (int i = 0; i < N; ++i)
        cin >> A[i];

    vector< vector<int64_t> > dp(N, vector<int64_t>(N, 0));
    for (int i = 0; i < N; ++i)
        dp[i][i] = A[i];

    for (int L = 1; L < N; ++L)
        for (int i = 0; i + L < N; ++i)
            dp[i][i + L] = max(A[i] - dp[i + 1][i + L], A[i + L] - dp[i][i + L - 1]);

    cout << dp[0][N - 1] << "\n";
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    bool yoko = false;
    long long ans = 1;
    int N;
    string S1,S2;
    cin >> N >> S1 >> S2;
    int i = 0;
    
    if ( S1[0] == S1[1] ) {
        ans = 6; 
        i = 2;
        yoko = true;
    }
    else {
        ans = 3;
        i = 1;
    }
    
    while ( i < S1.length() ) {
        
        if ( i == N-1 || S1[i] != S1[i+1] ) {
            
            if ( !yoko ) { ans *= 2; ans %= MOD; }
            
            yoko = false;
            i++;
        }
        else {
            
            if ( yoko ) { ans *= 3; }
            else { ans *= 2; }
            ans %= MOD;
            
            yoko = true;
            i += 2;
        }
        
    }
    

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

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

#define int long long
const int mxn = 2e5 + 5;
const int MOD = 998244353;

int fact[mxn], invfact[mxn];

int exp(int a, int b, int m) {
	int res = 1;

	while (b) {
		if (b & 1)
			res = (res * a) % m;
		b /= 2;
		a = (a * a) % m;
	}

	return res;
}

int modinv(int k) {
	return exp(k, MOD - 2, MOD);
}

void precompute() {
	fact[0] = 1;
	fact[1] = 1;
	for (int i = 2; i < mxn; ++i) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD;
	}

	invfact[mxn - 1] = modinv(fact[mxn - 1]);
	for (int i = mxn - 2; i >= 0; --i) {
		invfact[i] = invfact[i + 1] * (i + 1);
		invfact[i] %= MOD;
	}

	return;
}

int ncr(int n, int r) {
	if (r > n)
		return 0;

	int res = fact[n];
	res *= invfact[r];
	res %= MOD;
	res *= invfact[n - r];
	res %= MOD;

	return res;
}

int n, m, k;

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

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

	precompute();

	int res = 0;

	cin >> n >> m >> k;

	for (int i = 0; i <= k; ++i) {
		int curr = m * exp(m - 1, n - 1 - i, MOD);
		curr %= MOD;
		curr *= ncr(n - 1, i);
		curr %= MOD;
		res += curr;
		res %= MOD;
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 6792