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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(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>=(b);i--)
#define FORMAP(x, mp) for(auto x=mp.begin();x!=mp.end();x++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define print(x) cout << x;
#define println(x) cout << x << endl;
#define printd(x, f) cout << fixed << setprecision(f) << x << endl;

#define PB push_back
#define MP make_pair
#define F first
#define S second

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PI acos(-1.0)

#define NO "No"
#define YES "Yes"

int h, w;
vector<string> s(101);
map<char, int> mp;

string solve()
{
  REP(i, h) REP(j, w) mp[s[i][j]]++;

  if (h % 2 == 0 && w % 2 == 0) {
    FORMAP(x, mp) if (x->S % 4) return NO;
    return YES;
  }

  if (h % 2 && w % 2) {
    map<int, int> c;
    FORMAP(x, mp) c[x->S % 4]++;
    if (c[3]) return NO;
    if (c[1] != 1) return NO;
    if (c[2] > (h - 1) / 2 + (w - 1) / 2) return NO;
    return YES;
  }

  if (w % 2) swap(h, w);
  map<int, int> c;
  FORMAP(x, mp) c[x->S % 4]++;
  if (c[1] || c[3]) return NO;
  if (c[2] > w / 2) return NO;
  return YES;
}

int main()
{
  cin >> h >> w;
  REP(i, h) cin >> s[i];
  println(solve());
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


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 d=sc.nextInt();
        int e=Math.abs(a-b);
        int f=Math.abs(b-c);
        if((Math.abs(a-c)<=d)||((e<=d)&&(f<=d))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        

    }

        
        
    }


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
/*
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1155&lang=jp

 
	sorce: ICPC Domestic 2008	

	構文解析の問題。

	<formula> ::= 0 | 1 | 2 | P | Q | R |
              -<formula> | (<formula>*<formula>) | (<formula>+<formula>)

	下のように書き換え

	<expr>::=<term1><op><term1>|<term1>
	<term1>::='-'<term1>|<term2>
	<term2>::='('<expr>')'|0|1|2

	文字の部分は数字に置き換え、全探索。
*/
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int _and[3][3] = { 
				{ 0, 0, 0 },
				{ 0, 1, 1 },
				{ 0, 1, 2 } };
const int _or[3][3] = {
				{ 0, 1, 2 },
				{ 1, 1, 2 },
				{ 2, 2, 2 } };

const int _not[3] = { 2, 1, 0 };
string s;
int idx;

int term1 (void );
int term2 (void );
int expr (void );

int term1 (void ){
	if (s[idx] == '-' ){
		idx++;
		return _not[term1()];
	}else return term2();
}

int term2 (void ){
	int res = 0;
	if (s[idx] == '(' ){
		idx++;
		res = expr ();
		idx++;
	}else{
		return (s[idx] - '0' );
	} // end if

	return res;
}

int expr (void ){
	int a = term1 ();
	while (idx < s.size() && s[idx] != ')' ){
		char op = s[idx++];
		int b = term1 ();
		switch (op ){
			case '*': a = _and[a][b]; break;
			case '+': a = _or[a][b]; break;
		} // end switch
	} // end if

	return a;
}

int parse (void ){
	
	idx = 0;
	int res = expr ();

	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);

	string str = "";
	while (cin >> str, str != "." ){
		int res = 0;
		int n = str.length();
		rep (p, 3 ){
			string s1 = str;
			rep (i, n ) if (s1[i] == 'P' ) s1[i] = (char)('0'+p);
			rep (q, 3 ){
				string t1 = s1;
				rep (i, n ) if (t1[i] == 'Q' ) t1[i] = (char)('0'+q);
				rep (r, 3 ){
					s = t1;
					rep (i, n ) if (s[i] == 'R' ) s[i] = (char )('0'+r);
					int ans = parse ();
//					cerr << s << '=' << ans << endl;
					if (ans == 2 ) res++;
				} // end rep
			} // end rep
		} // end rep
		cout << res << endl;
	} // end while
	
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>  
using namespace std;
int n;  
int f[130];  
int a[130];  
string st;  
int main()
{
    cin>>n; 
    memset(f,127,sizeof(f));  
    for(int i=1; i<=n; i++)
    {
        cin>>st;  
        memset(a,0,sizeof(a)); 
        for(int j=0; j<st.size(); j++) 
        a[st[j]]++;  
        for(int j=97; j<=122; j++)
        f[j]=min(a[j],f[j]); 
    }
    for(int i=97; i<=122; i++) 
    {
        for(int j=1; j<=f[i]; j++)  
        cout<<char(i);  
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n ;
    cin >> n ;
    vll v;
    forn(i , 1 , n ) {
       ll x  , y ;
       cin >> x >> y ;
       swap(x , y) ;
       v.pb({x , y}) ;
    }
    sort(all(v)) ;
    ll timee = 0 ;
    ll flag = -1;
    forn(i , 0 , v.sz - 1 ) {
       ll dl = v[i].fi ;
       ll tr = v[i].se ;
       timee = timee + tr;
       if(timee <= dl) con;
       else{
        flag = 0 ;
        br ;
       }
    }
    if(flag == 0 ) {
        cout << "No\n" ;
        ro ;
    }
    else {
        cout << "Yes\n" ;
        ro ;
    }
    ro ;
}































Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
bool cmp(int x, int y)
{
    return x>y;
}
int main()
{
    int n, m;
    cin >> n >> m;
    int a[n+1];
    for (int i=1; i<=n; i++) cin >> a[i];
    sort (a+1, a+n+1, cmp);
    double t=0;
    for (int i=1; i<=n; i++) t+=a[i];
    if (a[m]<(t*1.0/(4.0*m))) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 10000
#define Q 500

int main(){
    int n,q,i,j,count=0;
    int S[N],T[Q];

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&T[i]);
    }
    for(i=0;i<q;i++){
        for(j=0;j<n;j++){
            if(T[i] == S[j]){
                count++;
                break;
            }
        }
    }
    printf("%d\n",count);
    return 0;
}


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


int main(){
  ll N,M;
  cin >> N >> M;
  
  if(M<2){
    cout << 0 << endl;
    return 0;
  }
    
  if(M>2*N){
    cout << N+((M-2*N)/4) <<endl;
  }else{
    
      cout << M/2 << endl;
    
  }
  
  /*rep(i,N){
    M-=2;
    if(M==0){
      cout << i+1 << endl;
      return 0;
    }else if(M<0){
      cout << i << endl;
      return 0;
    }
  }
  
  cout << N+(M/4) << endl;*/

  
  
  
}

Measured memory_bytes: 3588
use whiteread::parse_line;

fn main() {
    let (r, g, b, n): (usize, usize, usize, usize) = parse_line().unwrap();
    let mut cnt = 0;

    for x in 0..=n {
        for y in 0..=n {
            if x * r + y * g > n {
                break;
            }
            if (n - (x * r + y * g)) % b == 0 {
                cnt += 1;
            }
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2136
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    h = list(map(int, input().split()))
    cost = [0 for _ in range(n)]
    cost[1] = abs(h[1] - h[0])

    for i in range(2, n):
        cost[i] = min(cost[i - 2] + abs(h[i] - h[i - 2]),
                      cost[i - 1] + abs(h[i] - h[i - 1]))

    print(cost[n - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 13976
#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
 
  // 入力
  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);
  
  int result;
  if(a<b)result=b-a;
  else   result=a-b;
  if(result%2==1){
    printf("IMPOSSIBLE\n");
    return 0;
  }
  result/=2;

  if(a<b)result=b-result;
  else   result=a-result;

  printf("%d\n",result);
 
  return 0;
}

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

int main() {
  int A,B,T;
  int count=0;
  cin>>A>>B>>T;
  while(T>=A){
  int i=1;
    T=T-i*A;
      i++;
    count=count+B;
  }
  cout<<count;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)(a - 1)/(int)(b))
//#define int long long

int commmon_chars(string &s, string &t){
    vector<bool> c1('z'+1,false), c2('z'+1,false);
    for(char c: s) c1[c] = true;
    for(char c: t) c2[c] = true;
    int ret = 0;
    reps(i,'a','z'){
        if(c1[i] && c2[i]) ret++;
    }
    return ret;
}

signed main(){
    int n; string s;
    cin >> n >> s;
    
    int ans = 0;
    rep(i,n){
        string front = s.substr(0,i);
        string back  = s.substr(i,n-i);
        ans = max(ans,commmon_chars(front, back));
    }
                  
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
nl=[9**i for i in range(1,6)][::-1]
sl=[6**i for i in range(1,7)][::-1]
a=n
for i in range(n+1):
    totals=0
    ps=i
    for j in sl:
        if ps >= j:
            totals+=ps//j
            ps= ps-ps//j*j
    totaln=0
    pn=n-i
    for k in nl:
        if pn >=k:
            totaln+= pn //k
            pn=pn-pn//k*k
    a=min(a,totals+totaln+ps+pn)
print(a)


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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
template<class T> lint gcd(T a, T b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T> lint lcm(T a, T b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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 pi acos(-1)
#define mod 1000000007
#define MOD 998244353

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
        
    int N, M;
    cin >> N >> M;

    vi nostep(M);
    rep(i, M) cin >> nostep[i];

    vli dp(N + 1);
    rep(i, 3) {
        if (binary_search(all(nostep), i) || i == 0) {
            dp[i] = 0;
            continue;
        }
        dp[i] = dp[i - 1] + 1;
    }

    for (int i = 3; i < N + 1; i++) {
        if (binary_search(all(nostep), i)) {
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    }

    cou(dp[N]);
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int x[105],y[105];
int X,Y;
bool cheak(int a, int b){
	if(a >= b)
		return true;
	if(a >= Y)
		return true;
	else if(b <= X)
		return true;
	else return false;	
	}
int main(){
	int n,m;
	cin>>n>>m>>X>>Y;
	for(int i = 1; i <= n ;i++)
		cin>>x[i];
    for(int i = 1; i <= m; i++)
    	cin>>y[i];
    sort(x + 1, x + n + 1);
    sort(y + 1, y + m + 1);
    if(cheak(x[n],y[1]))
    	puts("War");
    else puts("No War");
    return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//code
	int n,x;
	cin>>x;
	
	n=x%10;
	
	switch(n)
	{
		case 2:
		case 4:
		case 5:
		case 7:
		case 9: cout<<"hon"<<endl;
				break;
				
		case 0:
		case 1:
		case 6:
		case 8: cout<<"pon"<<endl;
				break;
				
		case 3: cout<<"bon"<<endl;
				break;
			
	}
	
 	return 0;
 	
}



Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;


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

  ll N,M;cin>>N>>M;
  vector<vint> g(N);
  repeat(i,M){
    int u,v;cin>>u>>v;u--;v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<bool> visit(N,false);
  vint color(N,0);
  ll dim0=0,bi=0,nobi=0;
  repeat(i,N){
    if(visit[i])continue;
    if(g[i].empty()){
      dim0++;
      continue;
    }
    bool isbi=true;
    queue<int> Q;
    Q.push(i);
    color[i]=1;
    while(!Q.empty()){
      int v = Q.front();
      Q.pop();
      if(visit[v])continue;
      visit[v]=true;
      for(int u:g[v]){
        if(color[v]==color[u])isbi=false;
        color[u]=-color[v];
        Q.push(u);
      }
    }
    if(isbi)bi++;
    else nobi++;
  }
  debugArray(color,N);
  debug(dim0);
  debug(nobi);
  debug(bi);
  cout << dim0*(2*N-dim0)+nobi*nobi+2*nobi*bi+2*bi*bi<<endl;
  return 0;
}


Measured memory_bytes: 7936
import java.awt.*;
import java.util.*;
import java.text.*;
import java.util.List;

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 ans = 0;

        long five = 5;
        List<Long> list = new ArrayList<>();
        while (five <= n) {
            list.add(five);
            five *= 5;
        }
//        System.out.println(list);
        
        if (n % 2 == 1) {
            System.out.println(0);
            return;
        }

        for (long t: list) {
            ans += n / t / 2L;
        }

        System.out.println(ans);
    }


}


Measured memory_bytes: 35520
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,k,q = map(int, input().split())
    res = [0]*n
    for _ in range(q):
        i = int(input())
        res[i-1] += 1
    for i in res:
        if i<q-k+1:
            print('No')
        else:
            print('Yes')



if __name__ == '__main__':
    main()

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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
typedef pair<ll,ll> P;

#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define rrep(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,n) rep(i,0,n)
#define RREP(i,n) rrep(i,n,0)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n, m, cnt[20][112345], dp[1123456];

int main(){
  cin >> n >> m;
  for(int i = 0; i < n; ++i){
    int tmp;
    cin >> tmp;
    for(int j = 0; j < m; ++j) cnt[j][i + 1] = cnt[j][i] + (j == tmp - 1);
  }

  // for(int i = 0; i < m; ++i) for(int j = 0; j <= n; ++j) printf("%d%c", cnt[i][j], " \n"[j == n]);

  // for(int i = 0; i < m; ++i) printf("%d%c", cnt[i][n], " \n"[i == m - 1]);
  for(int i = 1; i < 1 << m; ++i) dp[i] = inf;
  for(int i = 0; i < 1 << m; ++i){
    int sum = 0;
    for(int j = 0; j < m; ++j) if((i >> j) & 1) sum += cnt[j][n];
    for(int j = 0; j < m; ++j) if(!((i >> j) & 1)){
      dp[i + (1 << j)] = min(dp[i + (1 << j)], dp[i] + cnt[j][n] - cnt[j][sum + cnt[j][n]] + cnt[j][sum]);
    }
  }

  cout << dp[(1 << m) - 1] << endl;
  //for(int i = 0; i < 1 << m; ++i) printf("%d%c", dp[i], " \n"[i == (1 << m) - 1]);
}



Measured memory_bytes: 15084
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nk[0];
        var k = nk[1];
        var abk = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var r = abk[0];
        var s = abk[1];
        var p = abk[2];
        long res = 0;
        string hands = Console.ReadLine();
        for (int mod = 0; mod < k; mod++)
        {
            char last = '_';
            for (int i = mod; i < n; i += k)
            {
                if (last == hands[i])
                {
                    last = '_';
                    continue;
                }
                switch (hands[i])
                {
                    case 'r':
                        res += p;
                        break;
                    case 'p':
                        res += s;
                        break;
                    case 's':
                        res += r;
                        break;
                    default:
                        break;
                }
                last = hands[i];
            }
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 13536
import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		TreeMap<String, LinkedList<Integer>> map=new TreeMap<String, LinkedList<Integer>>();
		for(; sc.hasNext();){
//		for(int i=0; i<8; i++){
			String word=sc.next();
			int page=sc.nextInt();
			if(!map.containsKey(word))
				map.put(word, new LinkedList<Integer>());
			map.get(word).add(page);
		}
		for(Entry<String, LinkedList<Integer>> entry : map.entrySet()){
			println(entry.getKey());
			Integer[] pages=entry.getValue().toArray(new Integer[0]);
			sort(pages);
			for(int i=0; i<pages.length; i++){
				print(pages[i]+"");
				if(i!=pages.length-1)
					print(" ");
			}
			println("");
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 12000
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

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

const int MX=1e5+10;
int N,K,W; 
int t[MX];
int memo[100][MX];
int w[MX],v[MX];


int solve(int i, int r){
	if(i==N) return 0;
	if(memo[i][r]!=-1)return memo[i][r];
	int ans=solve(i+1,r);
	if(r>=w[i]) ans=max(ans,solve(i+1,r-w[i])+v[i]);
	return memo[i][r]=ans;
}

int32_t main(){
   boost;
   IO();

   memset(memo,-1,sizeof(memo));
   cin>>N>>W;
   for(int i=0; i<N;i++) cin>>w[i]>>v[i];

   cout << solve(0,W) << endl;
	


   return 0;
}



Measured memory_bytes: 81764
#include<bits/stdc++.h>
#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scl1(a) scanf("%lld",&a)
#define scl2(a,b) scanf("%lld%lld",&a,&b)
#define scl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pf1(a) printf("%d ",a)
#define pfl1(a) printf("%lld ",a)
#define pfn printf("\n")
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vl vector<long long>
#define si set<int>
#define sl set<long long>
#define msi multi_set<int>
#define msl multi_set<long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define mii map<int,int>
#define mli map<long long,int>
#define mll map<long long,long long>
#define umii unordered_map<int,int>
#define umli unordered_map<long long,int>
#define umll unordered_map<long long,long long>
#define lp(i,a,b) for(int i=a;i<b;i++)
#define rlp(i,a,b) for(int i=a;i>b;i--)
#define dslp(it,c) for(typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define pb push_back
#define pf push_front
#define ft first
#define sd second
#define N 100001
#define mod 1000000007
#define mod1 100000000
using namespace std;
typedef vector<vector<ll> > matrix;

int main(){
    float d,t,s;
    cin>>d>>t>>s;
    if( (d/s) <= t )
    printf("Yes\n");
    else
    printf("No\n");
}

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

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 1e5;
llong a[N+3],s[N+3];
int n; llong M,X,K;
int ans;

int main()
{
	scanf("%d%lld%lld%lld",&n,&M,&X,&K);
	for(int i=1; i<=n; i++) scanf("%lld",&a[i]); sort(a+1,a+n+1);
	int left = 1,right = n;
	while(left<right)
	{
		int mid = left+((right-left)>>1); llong x = X; x--; int rk = 0; bool ret = false;
//		printf("check %d\n",mid);
		for(int i=1; i<=n; i++)
		{
			if(a[i]>a[mid]+M) {x--; rk++;}
		}
		if(rk>=K) {ret = false;}
		else if(x<=0) {ret = true;}
		else
		{
			llong rst = M*x;
//			printf("rst=%lld\n",rst);
			for(int i=1; i<=n-rk; i++)
			{
				if(i==mid) continue;
				rst -= min(M,a[mid]+M-a[i]);
			}
//			printf("rst=%lld\n",rst);
			if(rst<=0) {ret = true;}
			else
			{
				int gg = K-1-rk;
				for(int i=n-rk,j=1; j<=gg; i--)
				{
					if(i==mid) continue;
					rst -= max(0ll,a[i]-a[mid]); j++;
				}
//				printf("gg=%d rst=%lld\n",gg,rst);
				if(rst<=0) {ret = true;}
			}
		}
		if(ret) {right = mid;}
		else {left = mid+1;}
	}
	printf("%d\n",n-right+1);
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
             
public static class Program
{
    public static void Main()
    {
        int N = GetInt();
        string A = ReadLine();
        string B = ReadLine();
        string C = ReadLine();
        int count = 0;
        for (int i = 0; i < N; i++)
        {
            if (A[i] == B[i])
            {
                if (A[i] != C[i]) ++count;
            } else if (A[i] == C[i]) {
                ++count;
            } else if (B[i] == C[i]) {
                ++count;
            } else {
                count += 2;
            }
        }
        Console.WriteLine(count.ToString());
    }
    
    private static string ReadLine()
    {
    	return Console.In.ReadLine();
    }
    
    public static int[] GetIntArray()
    {
    	List<int> temp = new List<int>();
    	foreach (string c in ReadLine().Split(' '))
            temp.Add(int.Parse(c));
        return temp.ToArray();
    }
    
    public static int GetInt()
    {
    	return int.Parse(ReadLine());
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  ll n;
  cin>>n;
  vector<ll> a(n+1),b(n);
  rep(i,n+1){cin>>a[i];}
  rep(i,n){cin>>b[i];}
  ll k=0;
  k+=min(a[0],b[0]);
  b[0]-=k;
  for(int i=1;i<n+1;i++){
    ll s=min(b[i-1],a[i]);
    k+=s;
    a[i]-=s;
    if(i==n){break;}
    ll t=min(a[i],b[i]);
    k+=t;
    b[i]-=t;}
  cout<<k<<endl;
}

Measured memory_bytes: 1792
/*
*  Author: windystreet
*  Date  : 2019-08-05 20:51:35
*  Motto : Think twice, code once.
*/
#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

int s[maxn];

void solve(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>s[i];
    if(n == 1) puts("Yes");
	else{
		long long cnt = 0;
		s[1]--;
		for(int i=2;i<=n;i++){
			if(s[i] > s[i-1]) s[i]--;
		}
		for(int i=1;i<n;i++){
			if(s[i] > s[i+1]){
				printf("No\n");return;
			}
		}
		printf("Yes\n");
	}

    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("F:/in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
    //printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

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

  int a,b,c;

  scanf("%d%d%d",&a,&b,&c);

  if(a == b && b == c && a == c){
    printf("1");
  }else if(a != b && b != c && a != c){
    printf("3");
  }else{
    printf("2");
  }

  return 0;
}

Measured memory_bytes: 128
from collections import Counter

N=int(input())

dic={}
ans=0

for i in range(N):
    si=input()
    # ci=Counter(si)
    # c=sorted(ci.elements())
    # c=sorted(Counter(si).elements())
    sorted_s=''.join(sorted(Counter(si).elements()))
    if sorted_s in dic:
        ans+=dic[sorted_s]
        dic[sorted_s]+=1
    else:
        dic[sorted_s]=1

print(ans)

Measured memory_bytes: 22304
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cassert>
#include<deque>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef vector<P> VP;
typedef vector<VP> VVP;
 
int n,m,c;
int mincost[100][1000];//mincost[a][b] := aにb回チェンジしてきたときの最小値
struct Pox
{
  int p;
  int pop_cost;
  int cost;
  priority_queue<int> Q;
  Pox(int p=-1,int cost =-1,int pop_cost=-1,priority_queue<int> Q=priority_queue<int>()):p(p),cost(cost),pop_cost(pop_cost),Q(Q){}
};
 
void Input(VVP& G)
{
  for(int i=0;i<m;i++)
    {
      int f,t,c;
      cin >> f >> t >> c;
      f--,t--;
      G[f].push_back(P(t,c));
    }
}
 
 
 
int main()
{
 
  while(cin >> n >> m >> c,n|m|c)
    {
      VVP G(n);
 
      Input(G);
      rep(i,n)rep(k,m)mincost[i][k] = (1<<29);
      rep(i,m)mincost[0][i] = 0;
      deque<Pox> deq;
      deq.push_back(Pox(0,0,0,priority_queue<int>() ));
      int ans = (1<<29);
 
      while(!deq.empty())
    {
      Pox pox = deq.front(); deq.pop_front();
      if(pox.pop_cost >= ans)
        continue;
      if(pox.p == n-1)
        {
          assert(pox.cost <= c);
          ans = min(ans,pox.pop_cost);
          continue;
        }
 
      rep(i,G[pox.p].size())
        {
          int next = G[pox.p][i].first;
          int ncost = G[pox.p][i].second+pox.cost;
          int pcost = pox.pop_cost;
          priority_queue<int> q = pox.Q;
          q.push(G[pox.p][i].second);
          if(ncost > c)
        {
          while(ncost > c)
            {
              assert(!q.empty());
              ncost -= q.top();
              q.pop();
              pcost++;
            }
        }
          if(mincost[next][pcost] > ncost)
        {
          mincost[next][pcost] = ncost;       
          deq.push_back(Pox(next,ncost,pcost,q));
        }
        }
    }
      cout << ans << endl;
    }
  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int a, b;
  cin >> a >> b;
  cout << a*b - a - b + 1 << endl;
}

Measured memory_bytes: 256
m = [chr(ord('a')+i) for i in range(26)]
t = {}
for i in range(26):
    t[m[i]] = i


def affine(s):
    for a in range(26):
        for b in range(26):
            text = ''.join([m[a * (t[x] - b + 26) % 26]
                            if x != ' ' else ' ' for x in s])
            if 'that' in text or 'this' in text:
                return text


n = int(input())

for i in range(n):
    print(affine(input()))



Measured memory_bytes: 5604
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

void solve(istream& cin, ostream& cout) {
    int n;
    cin >> n;
    lint t;
    cin >> t;
    rep(i, 1, n) {
        lint x;
        cin >> x;
        lint g = __gcd(t, x);
        t *= x / g;
    }
    cout << t;
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>


int main(void)
{
	//変数の宣言
	int n,q;
	char s[1000010];
	int k[80];
	int d,m;
	long int dm;
	
	//よく使う変数
	int i,j,l;
	int flag=0;
	long int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d",&n);
	scanf("%s",&s);
	scanf("%d",&q);
	
	for(i=0;i<q;i++){
		scanf("%d",&k[i]);
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	
	
	for(i=0;i<q;i++){
		d=0;
		m=0;
		dm=0;
		ans=0;
		for(j=0;j<n;j++){
			if(j>=k[i]){//もしかしたら一つずれてるかも
				if(s[j-k[i]]=='D'){
					d--;
					dm=dm-m;
				}
				if(s[j-k[i]]=='M'){
					m--;
				}
			}
			
			if(s[j]=='D'){
				d++;
			}
			if(s[j]=='M'){
				m++;
				dm=dm+d;
			}
			if(s[j]=='C'){
				ans=ans+dm;
			}
		}
		printf("%ld\n",ans);
	}
	
	
//	printf("計算部分終了\n");
	//出力
	
	
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 1152
#include<iostream>

using namespace std;

typedef long long ll;

ll mod_pow(ll x,ll n,ll mod){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}

int main(){

	ll n,m;
	cin>>m>>n;
	cout<<mod_pow(m,n,1000000007)<<endl;
}

Measured memory_bytes: 1156
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
 
typedef pair<int,int> PA;
typedef pair<PA,PA> PPA;
 
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
 
int masu[55][55][55][55]; 

int main(){
  
  int w,h,tx,ty,kx,ky,ans;
  int d[55][55];
  
  while(cin >> w >> h,w!=0&&h!=0){
    cin >> tx >> ty >> kx >> ky;
    tx--;
    ty--;
    kx--;
    ky--;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> d[i][j];
      }
    }
    
    ans = 101;
    
    queue<PPA> que;
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	for(int k=0;k<h;k++){
	  for(int l=0;l<w;l++) masu[i][j][k][l] = -1;
	}
      }
    }
    masu[ty][tx][ky][kx] = 0;
    que.push(PPA(PA(ty,tx),PA(ky,kx)));
    
    while(!que.empty()){
      PPA p = que.front();
      que.pop();
      
      int y1 = p.first.first;
      int x1 = p.first.second;
      int y2 = p.second.first;
      int x2 = p.second.second;
      
      for(int i=0;i<4;i++){
	int ay = y1 + dy[i];
	int ax = x1 + dx[i];
	if(ay<0||ay>=h||ax<0||ax>=w||d[ay][ax] == 1){
	  ay = y1;
	  ax = x1;
	}
	int by = y2 - dy[i];
	int bx = x2 - dx[i];
	if(by<0||by>=h||bx<0||bx>=w||d[by][bx] == 1){
	  by = y2;
	  bx = x2;
	}
	if(masu[ay][ax][by][bx]!=-1) continue;
	masu[ay][ax][by][bx] = masu[y1][x1][y2][x2]+1;
	
	if(masu[ay][ax][by][bx] >= 100) continue;
	que.push(PPA(PA(ay,ax),PA(by,bx)));
	
	if(ay==by&&ax==bx) ans = min(ans,masu[ay][ax][by][bx]);
	
      }
    }
    
    if(ans >= 100) cout << "NA" << endl;
    else cout << ans << endl;
    
  }
  return(0);
}



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

int main(int argc, char const* argv[])
{
    int n;
    vector<int> a;
    cin >> n;
    n *= 3;
    for (int i = 0; i < n; i++) {
        int input;
        cin >> input;
        a.push_back(input);
    }
    sort(a.begin(), a.end());

    long long int ans = 0;
    for (int i = n - 2, j = 0; j < n / 3; i -= 2, j++) {
        ans += a[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int t[100010], x[100010], y[100010];
    for(int i = 0;i < N;++i)
    {
        cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
    }
    bool can = true;
    for(int i = 0;i < N; ++i)
    {
        int dt = t[i + 1] - t[i];
        int ds = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        if(dt < ds)
            can = false;
        if(dt % 2 != ds % 2) 
            can = false;
    }
    cout << (can ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
#include<array>
#include<vector>
#include<climits>
 
using namespace std;

using ll = long long;
 
int main() {
  ll n;
  cin >> n;
  int res = INT_MAX;
  for (ll i=1; i*i<=n; ++i) {
    if(n%i == 0) {
      int e = max(log10(i), log10(n/i));
      res = min(res, e);
    }
  }
  cout << res+1 << endl;
}


Measured memory_bytes: 640
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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;
}
int main() {
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    int HMAX = 50;
    int WMAX = 50;

    int h, w;
    cin >> h >> w;
    char s[WMAX][HMAX];
    rep(y, 0, h) {
        rep(x, 0, w) {
            cin >> s[x][y];
        }
    }
    rep(y, 0, h) {
        rep(x, 0, w) {
            if (s[x][y] == '#') {
                int cnt = 0;
                rep(i, 0, 4) {
                    if (s[x+dx[i]][y+dy[i]] == '#') cnt++;
                }
                if (cnt == 0) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
//
//  supercon.cpp
//
//
//  Created by Fourier Shuzaei on 2018/06/02.
//

#include "bits/stdc++.h"
using namespace std;
#define ri(a,b,c) for(int a=(b);a<(c);++a)
#define ll long long
#define rll(a,b,c) for(ll a=(b);a<(c);++a)

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

    int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
    char aa[4];
  a=0;
    cin>>aa;
  ri(i,0,4)if(aa[i]=='+')++a;else --a;















    cout<<a<<"\n";
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int A, B; cin >> A >> B;
    FOR(i, 1, 1000000){
        if(i * 8 / 100 == A){
            if(i / 10 == B){
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scs(s) scanf("%s", s)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) cout<<v[X]<<" "; cout<<endl;
#define grid(v) for(int X=0;X<v.size();X++){for(int Y=0;Y<v[X].size();Y++) cout<<v[X][Y]<<" ";cout<<endl;}
#define endl "\n"
const int INF = 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector< vector< int > > vvi;
typedef vector< vector< ii > > vvii;
const int MOD=1e9+7;
const ll LINF=100000000000000000LL;
ll dp[405][405];
ll mult[405][405];
ll powep[405][405];
ll powe(ll v, ll e)
{
    ll ret=1;
    while(e>0)
    {
        if(e&1) ret=(ret*v)%MOD;
        v=(v*v)%MOD;
        e>>=1;
    }
    return ret;
}
ll a[405];
ll b[405];
int main()
{
    int n,c;
    BUFF;
    cin>>n>>c;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    dp[0][0]=1;
    for(int i=0;i<=400;i++)
    {
        for(int j=0;j<=400;j++)
        {
            powep[i][j]=powe(i,j);
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=c;j++)
        {
            for(ll k=a[i];k<=b[i];k++)
            {
                mult[i][j]=mult[i][j]+powep[k][j];
            }
            mult[i][j]=mult[i][j]%MOD;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=c;j++)
        {
            for(int k=0;k<=j;k++)
            {
                dp[i][j]+=(dp[i-1][k]*mult[i][j-k])%MOD;
            }
            dp[i][j]=dp[i][j]%MOD;
        }
    }
    cout<<dp[n][c]<<endl;
    return 0;
}


Measured memory_bytes: 4096
import Data.Array

main :: IO ()
main = do
  n : q : _ <- map read . words <$> getLine
  s <- getLine
  let
    ks = listArray (1, n) . countAC $ s
    f (l, r) = ks ! l - ks ! r
  lrs <- sequence . replicate q $ (unsafeListToPair . map read . words) <$> getLine
  mapM_ (print . f) lrs

countAC :: String -> [Int]
countAC = map snd . scanr step (False, 0)
  where
    step 'A' (True, k) = (False, succ k)
    step c (_, k) = (c == 'C', k)

unsafeListToPair :: [a] -> (a, a)
unsafeListToPair (x : y : _) = (x, y)
unsafeListToPair _ = undefined


Measured memory_bytes: 98172
data = [i for i in input().split()]

stack = []
for v in data:
    if v == '+':
        b = stack.pop()
        a = stack.pop()
        stack.append(a + b)
    elif v == '-':
        b = stack.pop()
        a = stack.pop()
        stack.append(a - b)
    elif v == '*':
        b = stack.pop()
        a = stack.pop()
        stack.append(a * b)
    else:
        stack.append(int(v))

print(stack.pop())


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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define STDIO
#define mp make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front 
#define pb push_back
#define pp push
#define lb lower_bound 
#define ub upper_bound

inline void checkmin(int &x, int y){x = min(x, y);}
inline void checkmax(int &x, int y){x = max(x, y);}

string s;

int main() {
	#ifndef STDIO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>s;
    if(sz(s) & 1) {
    	cout<<"No"<<endl;
    	return 0;
	}
    for(int i = 0; i < sz(s); i++) {
    	if(i & 1) {
    		if(s[i] != 'i') {
    			cout<<"No"<<endl;
    			return 0;
			}
		}else {
			if(s[i] != 'h') {
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
    /* end code */
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a < b)
		cout << "a < b" << "\n";
	else if(a > b)
		cout << "a > b" << "\n";
	else
		cout << "a == b" << "\n";
}

Measured memory_bytes: 3076
A=[]
for _ in range(3):
    A.append(list(map(int,input().split())))

C=[[False]*3 for _ in range(3)]
D=[(0,0),(0,1),(0,2),(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)]

N=int(input())
for _ in range(N):
    b=int(input())
    for (p,q) in D:
        if A[p][q]==b:
            C[p][q]=True

T=False
for i in range(3):
    U=True
    for j in range(3):
        U&=C[i][j]
    T|=U
    
for j in range(3):
    U=True
    for i in range(3):
        U&=C[i][j]
    T|=U 

U=True
for i in range(3):
    U&=C[i][i]
T|=U

U=True
for i in range(3):
    U&=C[i][2-i]
T|=U

if T:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 62232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=2e9;

int main(){
    int n; cin>>n;
    int ans=0,s[110];
    for(int i=0;i<n;i++){
        cin>>s[i];
        ans+=s[i];
    }
    if(ans%10!=0){
        cout<<ans<<endl;
        return 0;
    }
    sort(s,s+n);
    for(int i=0;i<n;i++){
        if(s[i]%10!=0){
            cout<<ans-s[i]<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n;
	cin>>n;
	if((n%10)==0||(n%10)==1||(n%10)==6||(n%10)==8)
	cout<<"pon";
	else if((n%10)==3)
	cout<<"bon";
	else cout<<"hon";
}

Measured memory_bytes: 3624