akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,b,a) for(int i=b;i>=a;i--)
#define mset(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || '9'<ch;ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=2005,mo=1e9+7;
int n,k,f[N][N];
int main()
{
	n=read(),k=read();
	f[0][n+1]=1;
	fo(i,1,k-1)
	{
		int t=f[i-1][n-i+2];
		fd(j,n-i+1,1)
		{
			f[i][j]=(t+f[i-1][j])%mo;
			t=(t+f[i-1][j])%mo;
		}
	}
	int ans=0;
	fo(j,2,n+1) ans=(ans+f[k-1][j])%mo;
	fo(i,1,n-k-1) ans=ans*2%mo;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 15232
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


signed main(void) {
    int a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define R(_x, _y) (0 <= _x && _x <= M - 1 && 0 <= _y && _y <= N - 1)
#define A(a) (!(R(x + dx[a], y + dy[a]) && b[y + dy[a]][x + dx[a]]))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
ll table[2019], t2[2019];
int main() {
	ll n, c = 0;
	scanf("%lld", &n);
	if (n % 2) {
		puts("0");
		return 0;
	}
	else {
		n /= 10;
		c += n;
		while (n) {
			n /= 5;
			c += n;
		}
		printf("%lld\n", c);
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){ 

	int a, b;

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

	if (a + b == 15){
		printf("+");
	}
	else if (a*b == 15){
		printf("*");
	}
	else{
		printf("x");
	}

	return 0;

}

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

/***typededfs***/
typedef long long ll;
typedef long double ldb;

/***defines***/
#define M1 1000000007
#define M2 998244353
#define F first
#define S second
#define pb push_back
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forz(i,n) for(int i=0;i<(n);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define rforz(i,n) for(int i=(n-1);i>=0;i--)
#define rfore(i,a,b) for(int i=(a);i>=(b);i--)
#define test int T; cin>>T; while(T--)
#define all(v) v.begin(),v.end()
#define mm(a,b) ((a%M1)*(b%M1))%M1
#define ma(a,b) ((a%M1)+(b%M1))%M1


const int N = 1e6+5;
int prime_factor[N+5];
vector<pair<int,int>>prime_factors[N+5];


int main(){
    FASTIO;
  	int n;
  	cin>>n;
    for(int i=2;i<=n;i++){
        if(prime_factor[i]!=0) continue;
        prime_factor[i]=i;
        for(int j=2*i;j<=n;j+=i){
            prime_factor[j] = i; //prime_factor[x] = largest prime factor of x
        }
    }  
    for(int i=2;i<=n;i++){
        int x=i;
        map<int,int>m; //m[x] stores how many times x has come in prime factorisaiton of i
        while(x!=1){
            m[prime_factor[x]]++;
            x/=prime_factor[x];
        }
        for(auto v:m){
            prime_factors[i].pb(v);
        }
    }
    ll ans{};
    fore(i,1,n-1){
        //cout<<"\ni = "<<i<<'\n';
        ll temp=1;
        for(auto x:prime_factors[i]){
            temp*=(x.S+1);
            // cout<<"_"<<x.F<<"_ ";
            // cout<<x.S<<' ';
        }
        ans+=temp;
        // if(prime_factors[i].size()==0)
        // ans++;
        //cout<<"ans = "<<ans<<'\n';
    }
    cout<<ans<<'\n';

}

Measured memory_bytes: 73532
n = int( input() )
p = [ int( pi ) for pi in input().split() ]

sump = int( 0 )
for pi in p:
    sump += pi

ans = int( 0 )
for i in range( n+1 ):
    if i == 0:
        ans += 1
        px = 1
        if p[ i ] == 1 and n == 0:
            ans = 1
            break
        if p[ i ] != 0 and p[ i ] != 1:
            ans = -1
            break
    else:
        if px*2 <= sump:
            ans += px*2
            px = px*2 - p[ i ]
            sump = sump - p[ i ]
        else:
            ans += sump
            px = sump - p[ i ]
            sump = sump - p[ i ]
#        print( px, sump )
        if i != n and px <= 0:
            ans = -1
            break
        elif i == n and sump != 0:
            ans = -1
            break
        elif i == n and px != 0:
            ans = -1
            break

print( ans )


Measured memory_bytes: 20008
#include<stdio.h>
#include<math.h>
#include <string.h>
int main()
{
    char s[101];
    int len,i,count=0;
    scanf("%s", s);
    len=strlen(s);
    for(i=0;i<len/2;i++)
    {
        if(s[i]!=s[len-i-1])
        {
            count++;
        }
    }
    printf("%d\n", count);
     return 0;
}


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

int main(){
  int n;
    cin >> n;
  string s;
    cin >> s;
  int ans=0;
    for(int i=0; i<n ;i++){
      int cnt=0;
      for(char c='a'; c<='z'; c++){
        bool right=false, left=false;
        for(int j=0; j<i; j++)
          if(s[j]==c) left=true;
        for(int j=i; j<n; j++)
          if(s[j]==c) right = true;
        if(left && right) cnt += 1;
      }
      ans = max(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n){
        cin >> h[i];
    }
    sort(h.begin(),h.end(),greater<int>());
    
    rep(i,min(n,k)){
        h[i]=0;
    }
    ll sum = 0;
    rep(i,n) sum += h[i];
    cout << sum;

    return 0;
}

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

int main() {
  int X ,Y ; 
  cin >> X >> Y ;
  
  int a  ; //a=turu , b = kame
  
  for (a = 0 ; a <= X ; a++){
    if ( Y == 2*a + 4*(X-a)  ){
      cout << "Yes" << endl ; 
      return 0 ; 
    }
  }
  
  cout << "No" << endl ; 
  
  
}



Measured memory_bytes: 3632
#include<stdio.h>

int main(){
  int n,i,c;
  int count=0;
  int ans=1;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%d", &c);
    while(c%2==0){count++;
    c/=2;
    }
  }
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

int main(){
    int N,K;cin>>N>>K;
    // N以下の正の整数であって，Kの倍数であるもの
    vector<long long>num(K,0);
    FOR(i,1,N+1) num[i%K]++;//num[x] = kでわってx余る数がN以下にいくつ有るか
    ll res = 0;
    REP(a,K){
        int b = (K-a)%K;
        int c = (K-b)%K;
        if((a+c)%K != 0) continue;
        res += num[a] * num[b] * num[c];
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<18;
int n, m, d[maxn], vis[maxn], t = 1;
vector<array<int, 2>> g[maxn];
map<int, vector<int>> gc[maxn];
queue<int> pq;
set<int> cv[maxn];
void enq(int v, int c, int x) {
	if(!cv[v].insert(c).second) return;
	if(d[v] > x) d[v] = x, pq.push(v);
	for(auto i : gc[v][c]) {
		enq(i, c, x);
	}
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	for(int f, t, c, i = 0; i < m; i++) {
		cin >> f >> t >> c;
		g[f].push_back({t, c});
		g[t].push_back({f, c});
		gc[f][c].push_back(t);
		gc[t][c].push_back(f);
	}
	memset(d, 0x3f, sizeof d);
	d[1] = 0;
	int v;
	pq.push(1);
	while(!pq.empty()) {
		t++;
		v = pq.front(); pq.pop();
		for(auto _i : g[v]) {
			int i = _i[0], c = _i[1];
			enq(i, c, d[v]+1);
		}
	}
	if(d[n] > n) d[n] = -1;
	cout << d[n];
}


Measured memory_bytes: 101120
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def main():
    N, M, K = LI()

    rows = M*M*sum([d * (N-d) for d in range(1, N)])
    cols = N*N*sum([d * (M-d) for d in range(1, M)])
    ans = (rows + cols) * cmb(M*N-2, K-2, MOD) % MOD

    print(ans)

main()

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

void printChess(int chess[]) {
	for (int i = 0; i<8; i++) {
		for (int j = 0; j<8; j++) {
			if (j == chess[i])
				cout << "Q";
			else
				cout << ".";
		}
		cout << endl;
	}
}

bool isBlank(int chess[], int &r) {
	for (int i = 0; i<8; i++) {
		if (chess[i] == 100) {
			r = i;
			return true;
		}
	}
	return false;
}

bool setQ(int chess[], int r, int c) {
	for (int i = 0; i<8; i++) {
		if (chess[i] == c)
			return false;
		if (i + chess[i] == r + c)
			return false;
		if (i - chess[i] == r - c)
			return false;
	}
	return true;
}

void solve(int chess[]) {
	int r;
	if (isBlank(chess, r)) {
		for (int c = 0; c<8; c++) {
			if (setQ(chess, r, c)) {
				chess[r] = c;
				solve(chess);
				chess[r] = 100;
			}
		}
	}
	else {
		printChess(chess);
	}
}

int main() {
	int k, r, c, chess[8];
	for (int i = 0; i<8; i++) chess[i] = 100;
	cin >> k;
	for (int i = 0; i<k; i++) {
		cin >> r >> c;
		chess[r] = c;
	}
	solve(chess);
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<P> ans;
    int x = -1;
    int index = 0;
    rep(i, n) {
        if (abs(a[i])>x) {
            x = abs(a[i]);
            index = i;
        }
    }

    rep(i, n) {
        if ((ll)a[i]*a[index]<0) {
            ans.emplace_back(index+1, i+1);
        }
    }
    if (a[index]>=0) {
        rep(i, n-1) {
            ans.emplace_back(i+1, i+2);
        }
    }
    else {
        for (int i=n-1; i>=1; i--) {
            ans.emplace_back(i+1, i);
        }
    }
    int m = ans.size();
    cout << m << endl;

    
    rep(i, m) cout << ans[i].first << " " << ans[i].second << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
int main(void) {
	int i,a[2],b[2],c[2],d[2];
	for(i=0;i<2;i++){
		scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
	}
	int s[2];
	for(i=0;i<2;i++){
		s[i]=a[i]+b[i]+c[i]+d[i];
	}
	int j,tmp;
	for(j=1;j>0;j--){
		for(i=0;i<j;i++){
			if(s[i]<s[i+1]){
				tmp=s[i];
				s[i]=s[i+1];
				s[i+1]=tmp;
			}
		}
	}
	printf("%d\n",s[0]);
	return 0;
}


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

int main(void) {
  int A, B, C;
  cin >> A >> B >> C;

  int poison_eat = min(A+B+1, C);
  int eat = poison_eat+B;
  cout << eat << endl;
  return 0;
}


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

int main() {
	
	int n,m,i;
	cin>>n>>m;
	
	int a[m];
	for(i=0;i<m;i++)
	cin>>a[i];
	
	int tot = 0;
	
	for(i=0;i<m;i++)
	tot += a[i];
	
	//cout<<tot<<endl;
	if(tot > n)
	cout<<"-1";
	
	else
	cout<<n - tot;
	
	return 0;
}

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

using namespace std;

int T, N, K, X[100000+10], A[100000+10];

int main() {
  cin >> T; // ???????????????????????°???????????????
  for (int t=0; t<T; ++t) {
    // ???????????????????????°???????????????
    cin >> N >> K;
    for (int i=0; i<N; ++i) cin >> X[i]; // ??¶??????????????\???
    for (int i=0; i+1<N; ++i) A[i] = X[i+1]-X[i]; // ??¶??¨??¶??????
    sort(A, A+N-1); // ?????? A ?????´?????????
    // ?????? A ????????? max(0,N-1-(K-1)) ????????????????????????
    int sum = 0;
    for (int i=0; i<max(0,N-1-(K-1)); ++i) sum += A[i];
    cout << sum << endl;
  }
  return 0;
}

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

int main(){
	int n,a;
	cin >> n;
	set<int> s;
	while(n--){
		cin >> a;
		if (s.count(a)>0) s.erase(a);
		else s.insert(a);
	}
	cout << s.size();
	
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,x;
  scanf("%d%d",&n,&m);
  int sum = 0;
  for(int i=0;i<m;i++)
  {
    scanf("%d",&x);
    sum+=x;
  }
  
  
  sum = max(-1,n-sum);
  printf("%d\n",sum);
  
  return 0;
}

Measured memory_bytes: 3728
package main

import (
	"fmt"
	"sort"
	"math"
)

func concat(A, B []int) []int {
	Z := []int{}

	for _, a := range A {
		Z = append(Z, a)
	}

	for _, b := range B {
		Z = append(Z, b)
	}

	return Z
}

func gcdseq(A []int) int {
	g := A[0]

	for i := 1; i < len(A); i++ {
		g = gcd(g, A[i])
	}

	return g
}

func gcd(x, y int) int {
	if x % y == 0 {
		return y
	} else {
		return gcd(y, x % y)
	}
}

func main() {
	var N int
	fmt.Scanf("%d", &N)

	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}
	
	sort.Sort(sort.Reverse(sort.IntSlice(A)))

	minAns := math.MaxInt64
	minIdx := -1

	for i := 0; i < len(A)-1; i++ {
		if g := gcd(A[i], A[len(A)-1]); g < minAns {
			minAns = g
			minIdx = i
		}
	}

	gcd1 := gcdseq(concat(A[:minIdx], A[minIdx+1:]))
	gcd2 := gcdseq(A[:len(A)-1])

	if gcd1 > gcd2 {
		fmt.Println(gcd1)
	} else {
		fmt.Println(gcd2)
	}
}

Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)

int32_t main()
{
    int n,m;
    cin>>n>>m;
    int arr[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }

    vi adj[n+1];
    int u,v;
    for(int i=0;i<m;i++){
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    int cnt=0;
    for(int i=1;i<=n;i++){
        int val=arr[i];
        int flag=0;
        for(auto x:adj[i]){
            if(arr[x] >= val){
                flag=1;
                // cout<<"adjacent :"<<i<<endl;
                break;
            }
        }
        if(flag==0)
            cnt++;
    }
    cout<<cnt<<endl;

}

// 1 --> 3  cnt=0;
// 2 --> 4  cnt=1   
// 3 --> 1 4 cnt=2
// 4 --> 2 3 6 cnt=2
// 5 -->  cnt=3
// 6 --> 4  cnt=3





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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int ans = 0;
    for(int ia=0;ia<=a;ia++) {
        for(int ib=0;ib<=b;ib++) {
            for(int ic=0;ic<=c;ic++) {
                if(500*ia+100*ib+50*ic==x) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    string s;
    cin >> s;
    ll n = sz(s);
    if(s[n - 1] == 's'){
        cout << s << "es" ;
    }
    else cout << s << "s";
}
int main(){ 
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3852
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>

using namespace std;
#define ll          long long
#define endl        "\n"
#define inf         10000000002
#define pb          push_back
#define pf          push_front
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(a)      a.begin(),a.end()
#define mp          make_pair
#define MAX         100
#define yes         cout<<"YES"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0

ll gcd(ll a, ll b)
{
      if(!b) return a;
      return gcd(b,a%b);
}

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      //freopen("inputNew.txt", "r", stdin);

      ll hon[]={2,4,5,7,9};
      ll pon[]={0,1,6,8};
      ll bon[]={3};

      ll N;
      cin>>N;
      ll lastDigit=N%10;
      loop(i,0,5){if(hon[i]==lastDigit){cout<<"hon"<<endl;bye;}}
      loop(i,0,4){if(pon[i]==lastDigit){cout<<"pon"<<endl;bye;}}
      loop(i,0,1){if(bon[i]==lastDigit){cout<<"bon"<<endl;bye;}}

}


Measured memory_bytes: 3660
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
 int n;
 double a,m,sum;
 while(1){
  cin >> n;
  int s[n+1]={};
  if(n==0) break;

  sum=0;
  for(int i=0;i<n;++i){
   cin >> s[i];
   sum+=s[i];
  }
  m=sum/n;

  a=0;
  for(int i=0;i<n;++i){
   a+=pow(s[i]-m,2);
  }
  a=sqrt(a/n);
  cout << fixed << setprecision(8) << a << endl ;
 }
 return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t n;
  cin >> n;
  int64_t cnt = 0;
  set<int64_t> s;
  for(int64_t i=2;i*i <= n;i++){
    int64_t l=n;
    while(l % i == 0){
      l = l/i;
    }
    if(l % i == 1){
      s.insert(i);
    }
  }
  for(int64_t i=1;i*i < n;i++){
    if((n-1)%i==0){
      s.insert((n-1)/i);
    }
  }
  if(n != 2){
    cout << s.size()+1 << endl;
  }else{
    cout << 1 << endl;
  }
  
  
}
      
    
      

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int n;
LL T[1005],A[1005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld%lld",&T[i],&A[i]);
	for(int i=2;i<=n;i++){
		LL t=max((T[i-1]-1)/T[i],(A[i-1]-1)/A[i])+1;
		T[i]*=t;A[i]*=t;
	}
	cout<<T[n]+A[n]<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;
int main() {
       int a, b;
cin>>a>>b;
if(a+b>=10)
cout<<"error"<<endl;
else
cout<<a+b<<endl;


	system("pause");
	return 0;
}

Measured memory_bytes: 504
use std::io;
use std::cmp;


fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split(' ')
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {
    let n = read_one::<usize>();
    let path = read::<isize>();
    // cost[n] = cost of path(n - 1) to path(n)
    let mut cost = Vec::new();

    for i in 0..(n + 1) {
        if i == 0 {
            cost.push(path[0].abs());
        } else if i == n {
            cost.push(path[n - 1].abs());
        } else {
            cost.push((path[i - 1] - path[i]).abs());
        }
    }

    let sum: isize = cost.iter().sum();

    for i in 1..(n + 1) {
        let cost_i = sum - cost[i - 1] - cost[i];
        if i == 1 {
            println!("{}", cost_i + path[i].abs());
        } else if i == n {
            println!("{}", cost_i + path[n - 2].abs());
        } else {
            println!("{}", cost_i + (path[i - 2] - path[i]).abs());
        }
    }
}

Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

string s = "CODEFESTIVAL2016", t;

int main(){
	cin >> t;
	int ans = 0;
	for(int i=0; i<16; i++) ans += (s[i] == t[i]);
	cout << 16 - ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int K;
	int h[100001];
	int dp[100001]={};
	scan(N);scan(K);
	rep(i,N){
		scan(h[i]);
	}
	dp[1]=abs(h[0]-h[1]);
	for(int i=2;i<N;i++){
		dp[i]=INF;
		rep1(k,K){
			if(k<=i){
				dp[i]=min(dp[i],dp[i-k]+abs(h[i-k]-h[i]));
			}
		}
	}
	prin(dp[N-1]);
	return 0;
}


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

int la[500010];

typedef long long ll;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  char bef = '.';
  for (int i = 0; i < n; ++i) {
    la[i] = -1;
  }
  for (int i = 0; i < n; ++i) {
    char c = s[i];
    if (c == '<') {
      if (bef != '<') {
        la[i] = 0;
      }
      else {
        la[i] = la[i-1] + 1;
      }
    }
    bef = c;
  }
  // for (int i = 0; i <= n; ++i) { 
  //   // cerr << i << " " << la[i] << endl;
  // }
  if (s[n-1] == '>') la[n] = 0;
  else  { la[n] = la[n-1] + 1; }
  for (int i = n-1; i >= 0; --i) {
    char c = s[i];
    if (c == '>') {
      if (la[i] == -1) { 
        if (i == 0) {
          la[i] = la[i+1]+1;
        }
        else {
          la[i] = max(la[i+1], la[i-1])+1;
        }
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i <= n; ++i) { 
    // cerr << i << " " << la[i] << " " << s[i] << endl;
    assert(la[i] != -1);
    ans += la[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2820
#include <stdio.h>
z[9999],a,b,c;
f(x,y){
	fflush(!printf("? %d %d\n",x,y));
	scanf("%s",&b);
	b=b=='Y';
}
main(i){
	if(scanf("%d%d",&a,&b),a<=b){puts("Impossible");return 0;}
	for(i=a+=b;~--i;)!c||f(i,z[c-1])?(z[c++]=i):c--;
	for(c=*z,i=a;~--i;)z[i]=f(c,i);
	for(printf("! "),i=0;i<a;)printf("%d",z[i++]);
	puts("");
}

Measured memory_bytes: 736
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


import numpy as np
N, K = read_ints()
H = np.array(read_ints())
K = min(len(H), K)

dp = np.full((N), np.inf)
dp[0] = 0
# Kまで初期化しておかないと厄介なことになる
# i-kのコストは直接飛ぶのが必ず最小になる
dp[1:K+1] = np.abs(H[0]-H[1:K+1])

for i in range(K+1, N):
    # i-Kまでのコストリストを作成しておく
    dp[i] = (dp[(i - K):(i)] + np.abs(H[i] - H[(i - K):(i)])).min()


print(int(dp[-1]))


# 配るDPでもやってみる


Measured memory_bytes: 22824
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 1e7 + 17;

int n;
int a[200], mt[200];
vector<int> g[200];
bool pr[maxn], used[200];

bool read()
{
	if (scanf("%d", &n) != 1)
		return false;

	forn (i, n)
		scanf("%d", a + i);

	return true;
}

bool dfs(int v)
{
	if (used[v])
		return false;

	used[v] = true;

	for (auto to : g[v])
		if (mt[to] == -1 || dfs(mt[to]))
			return mt[to] = v, true;

	return false;
}

void solve()
{
	for (int i = 2; i < maxn; ++i)
		pr[i] = true;

	for (int i = 2; i < maxn; ++i)
		if (pr[i] && 1ll * i * i < maxn)
			for (int j = i * i; j < maxn; j += i)
				pr[j] = false;

	pr[2] = false;
	set<int> s;

	for (int i = 0; i < n; ++i)
	{
		if (s.count(a[i]))
			s.erase(a[i]);
		else
			s.insert(a[i]);

		s.insert(a[i] + 1);
	}

	vector<int> v0, v1;

	for (auto i : s)
		(i % 2 == 0) ? v0.push_back(i) : v1.push_back(i);

	for (int i = 0; i < size(v0); ++i)
		for (int j = 0; j < size(v1); ++j)
			if (pr[abs(v0[i] - v1[j])])
				g[i].push_back(j);

	memset(mt, -1, sizeof(mt));

	for (int i = 0; i < size(v0); ++i)
	{
		memset(used, false, sizeof(used));
		dfs(i);
	}

	int matching = 0;

	for (int i = 0; i < size(v1); ++i)
		matching += mt[i] != -1;

	int ans = matching;
	ans += 2 * ((size(v0) - matching) / 2);
	ans += 2 * ((size(v1) - matching) / 2);
	ans += 3 * ((size(v0) - matching) % 2);
	printf("%d\n", ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
#define ll long long

using namespace std;
ll segment[2000005],a[2000005];
ll n;
ll Query(int left,int right, int node=1,int start=0,int en=2e5){
    if(start > right || en < left)  return 0;
    if(left <= start && en <= right)    return segment[node];
    int mid=(start+en)/2;
    int ans1=Query(left,right,2*node,start,mid);
    int ans2=Query(left,right,2*node+1,mid+1,en);

    return (ans1+ans2);

}
void update(int index,int node=1,int start=0,int en=2e5){
if(start==en){
    segment[node]++;
    return;
}
int mid=(start+en)/2;
if(index <=mid)update(index,2*node,start,mid);
else update(index,2*node+1,mid+1,en);

segment[node]=segment[2*node]+segment[2*node+1];

}

int main()
{

        scanf("%I64d",&n);
        ll Ans=0;
        for(int i=0; i<n; i++){
            scanf("%I64d",&a[i]);
        }
        for(int i=0; i<n; i++){
            int cur =Query(a[i],2e5);
            update(a[i]);
            if(cur == i)
                Ans++;
        }
        cout<<Ans<<endl;

    return 0;
}


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

int main(){
    long int h1, h2,k1 , k2, a, b, c, d, sum1, sum2;
    cin >> h1 >> h2 ;
    cin >> k1 >> k2;
    cin >> a >> b >> c >> d;

    sum1=h1/10*c+a*h1+h2*b+h2/20*d;
    sum2=k1/10*c+a*k1+k2*b+k2/20*d;

    if(sum1>sum2){
        cout << "hiroshi" << '\n';
    }else if(sum1<sum2){
        cout << "kenjiro" << '\n';
    }else if(sum1==sum2){
        cout << "even" << '\n';
    }
    return 0;

}


Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	int n;
	cin >> n;
	ll int ans = 1;
	FOR(i, 1, n + 1)
	{
		ans *= i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1156
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	static int H, W;
	static char[][] map;
	static int[][] num;
	static Queue<Point> que = new ArrayDeque<Point>();

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		map = new char[H][W];
		num = new int[H][W];
		int periodCnt = 0;

		for (int i = 0; i < H; i++) {
			String temp = sc.next();
			for (int j = 0; j < W; j++) {
				map[i][j] = temp.charAt(j);
				if (map[i][j] == '.') {
					periodCnt++;
				}
			}

		}
		que.add(new Point(0, 0));
		num[0][0] = 0;
		map[0][0] = 'x';

		while (!que.isEmpty()) {
			Point a = que.poll();
			int n = num[a.x][a.y] + 1;

			solve(a.x + 1, a.y, n);
			solve(a.x - 1, a.y, n);
			solve(a.x, a.y + 1, n);
			solve(a.x, a.y - 1, n);
		}

		if (map[H - 1][W - 1] != 'x') {
			System.out.println(-1);
		} else {
			System.out.println(periodCnt - num[H - 1][W - 1] - 1);
		}
		sc.close();
	}

	public static void solve(int x, int y, int n) {
		if (x < 0 || H <= x || y < 0 || W <= y || map[x][y] == '#' || map[x][y] == 'x') {
			return;
		}
		map[x][y] = 'x';
		num[x][y] = n;
		que.add(new Point(x, y));
	}

}


Measured memory_bytes: 22740
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    B=LI()
    a=0
    b=0
    for i in range(N):
        if A[i]>B[i]:
            b+=A[i]-B[i]
        elif (B[i]-A[i])%2==0:
            a+=(B[i]-A[i])//2
        else:
            a+=(B[i]+1-A[i])//2
            b+=1
            
    if a>=b:
        print("Yes")
    else:
        print("No")
    

main()


Measured memory_bytes: 73220
#include <cstdio>

typedef long long ll;
const int maxn=100000+10,mod=1000000007;
int w[maxn];

ll power(ll a,ll b){
	ll ret=1;
	while(b){
		if(b&1)ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}

ll inv(ll a){
	return power(a,mod-2);
}

int main(){
	// freopen("in.txt","r",stdin);
	int n;ll ans=0;scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",w+i);
	for(int i=1;i<n;++i)
		ans=(ans+(w[n]-w[i])*inv(i))%mod;
	for(int i=1;i<n;++i)
		ans=ans*i%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int mod = 1e9 + 7;

int main(){ 
  int k, t;
  cin >> k >> t;
  vector<int> a(t);
  int mx = 0;
  rep(i, t) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  cout << max(mx - 1 - (k - mx), 0);
  return 0;
} 

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  int cnt5=0, cnt7=0;
  if (a == 5) ++cnt5;
  else if (a == 7) ++cnt7;

  if (b == 5) ++cnt5;
  else if (b == 7) ++cnt7;

  if (c == 5) ++cnt5;
  else if (c == 7) ++cnt7;
  
  if (cnt5 == 2 && cnt7 == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <unordered_map>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define LLI long long int
#define REP(i, n) for(LLI i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(LLI i = s, i##_l = (e); i < i##_l; i++)
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main() {
	cout << fixed << setprecision(10);
	LLI N;
	cin >> N;
	vector<LLI> a(N);
	unordered_map<LLI, LLI> m;
	unordered_map<LLI, LLI> cntm;

	REP(i, N) {
		cin >> a[i];
		m[a[i]] = 0;
	}
	REP(i, N) {
		m[a[i]]++;
	}
	LLI all = 0;
	for (auto& val : m)
	{
		all += val.second * (val.second - 1) / 2;
	}
	for (auto& val : m)
	{
		LLI c = val.second - 1;
		cntm[val.first] = all - val.second * (val.second - 1) / 2 + c * (c - 1) / 2;
	}

	REP(i, N) {
		cout << cntm[a[i]] << " ";
	}
	return 0;
}

Measured memory_bytes: 17608
s = input()
t = ''
for c in s:
    if c in (s[0],s[-1]):
        t += c
r = len(t)
for c,d in zip(t[:-1],t[1:]):
    if c==d:
        r += 1
if len(s)%2==r%2:
    print('Second')
else:
    print('First')


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
vector<PII> h;
map<int, int> h2;
map<int, vector<int>> g;
map<int, bool> used;
void update(int cur)
{
    for (auto &&x : g[cur])
    {
        used[x] = true;
    }
}
bool check(int cur)
{
    int curh = h2[cur];
    for (auto &&x : g[cur])
    {
        if (curh <= h2[x])
        {
            return false;
        }
    }
    return true;
}
int main()
{
    int n, m;
    cin >> n >> m;
    h.resize(n);
    rep(i, n)
    {
        cin >> h[i].first;
        h[i].second = i;
        h2[i] = h[i].first;
    }
    sort(ALL(h), greater<PII>());
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    rep(i, n)
    {
        int j = h[i].second;
        if (used[j] == true)
            continue;
        if (check(j))
        {
            ans++;
            update(j);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
    string s;
    getline(cin,s);
    vector<string> str;
    s+=" ";
    string buf="";
    rep(i,s.size()){
        if(s[i]!=' '){
            buf+=s[i];
        }
        else{
            str.pb(buf);
            buf="";
        }
    }
    map<string,int> mp;
    rep(i,str.size()){
        mp[str[i]]++;
    }
    string ans="";
    int n=-1;
    rep(i,str.size()){
        if(mp[str[i]]>n){
            ans = str[i];
            n=mp[str[i]];
        }
    }
    string l="";
    int num=-1;
    rep(i,str.size()){
        if((int)(str[i].size())>num){
            num=str[i].size();
            l=str[i];
        }
    }
    cout<<ans<<" "<<l<<endl;
}

Measured memory_bytes: 1196
#include<stdio.h>
long long int t[4000];
int k[4000];
bool sub[4000];
int main(){
    int a;
    while(scanf("%d",&a),a){
        for(int i=0;i<4000;i++){
            t[i]=0;
            k[i]=0;
            sub[i]=false;
        }
        int o=0;
        for(int i=0;i<a;i++){
            int b,c,d;
             
            scanf("%d%d%d",&b,&c,&d);
            t[b-1]+=(long long)c*(long long)d;
            if(!sub[b-1]){
                k[o++]=b-1;
                sub[b-1]=true;
            }
        }
        bool ok=false;
        for(int i=0;i<o;i++){
            if(t[k[i]]>=1000000LL){
                printf("%d\n",k[i]+1);
                ok=true;
            }
        }
        if(!ok)printf("NA\n");
    }
}


Measured memory_bytes: 2732
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll> 
#define mll map<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0; i<n; i++)
#define All(x,v) for(auto x:v)
#define arrin(a,n) ll a[n]; rep(i,n) cin>>a[i]
#define vi vector<int>
#define nl "\n"
#define print(arr) All(x,arr) cout<<x<<" "; cout<<nl
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ing(m,ad) rep(i,m){ int u,v; cin>>u>>v; u--;v--; ad[u].pb(v); ad[v].pb(u);}
#define vdsort(v) sort(v.begin(),v.end(),greater<int>())
#define F first
#define S second
#define mod 1000000007
const int MAXN=100005;
int spf[MAXN];
ll fac1[MAXN],fac2[MAXN],inv[MAXN];
ll gcd(ll x, ll y){ return y?gcd(y,x%y):x; }

void sieve(){  
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j)  spf[j] = i; 
    } 
} 
vector<int> getFactorization(int x){
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

ll exp(ll n, ll m){
    ll a = 1;
    while (m){
        if (m & 1) a = (a * n % mod) % mod;
        m /= 2;
        n = (n*n) % mod;
    }
    return a;
}

void pre(){
    fac1[0]=fac2[0]=inv[1]=1;
    for(int i=1;i<MAXN;i++){
        fac1[i]=(fac1[i-1]*i)%mod;
        if(i>1) inv[i]=( mod - ((ll)(mod/i)*inv[mod%i])%mod ) %mod;
    }
    for(int i=1;i<MAXN;i++) fac2[i]=(fac2[i-1]*inv[i])%mod;
}
ll C(int n,int k){
    if(n<k) return 0;
    return ((fac1[n]*fac2[n-k]%mod)*fac2[k]%mod);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,t=1;
    // cin>>t;
    while(t--){
        cin>>n;
        if(n>=30) cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3100
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 1 << 17

using namespace std;

const int mod = 1000000007;

int n, m;
int a[20], f[20][N], fac[N], ifac[N];

void init(int);
int quick_pow(int, int);
int C(int, int);

int main(){
	cin >> n >> m; init(1 << n);
	for(int i = 1; i <= m; ++i)
		cin >> a[i];
	reverse(a + 1, a + 1 + m);
	f[0][0] = 1; int all = 1 << n;
	for(int i = 1; i <= m; ++i)
		for(int s = 0; s < all; ++s){
			f[i][s] = f[i - 1][s]; int sum = 0;
			for(int j = 0; j < n; ++j)
				sum += ((s >> j) & 1) * (1 << j);
			if(sum > all - a[i] + 1) continue;
			for(int j = 0; j < n; ++j){
				if(!((s >> j) & 1)) continue;
				int tmp = sum - (1 << j);
				if(tmp > all - a[i] + 1) continue;
				(f[i][s] += 1ll * f[i - 1][s ^ (1 << j)] * C(all - a[i] - tmp, (1 << j) - 1) % mod * fac[1 << j] % mod) %= mod;
			}
		}
	int ans = 0;
	for(int s = 0; s < (1 << n); ++s){
		int cnt = 0, sum = 0;
		for(int j = 0; j < n; ++j){
			cnt += ((s >> j) & 1);
			if(!((s >> j) & 1)) sum += 1 << j;
		}
		int tmp = 1ll * f[m][s] * fac[sum] % mod;
		if(cnt & 1) (ans += mod - tmp) %= mod;
		else (ans += tmp) %= mod;
	}
	cout << 1ll * ans * (1 << n) % mod << endl;
	return 0;
}

int quick_pow(int x, int y){
	int sum = 1;
	for(; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) sum = 1ll * sum * x % mod;
	return sum;
}

int C(int x, int y){
	return 1ll * fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}

void init(int n){
	fac[0] = 1;
	for(int i = 1; i <= n; ++i)
		fac[i] = 1ll * fac[i - 1] * i % mod;
	ifac[n] = quick_pow(fac[n], mod - 2);
	for(int i = n; i; --i)
		ifac[i - 1] = 1ll * ifac[i] * i % mod;
	return ;
}

Measured memory_bytes: 9216
#include <stdio.h>
int main(void){
    int i, j;
    int n, m;
    int a[100][100], b[100];
    long long int c[100];

    scanf("%d%d", &n, &m);

    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%d", &a[i][j]);
        }
    }

    for(j = 0; j < m; j++){
        scanf("%d", &b[j]);
    }

    for(i = 0; i < n; i++){
        c[i] = 0;
        for(j = 0; j < m; j++){
            c[i] += a[i][j] * b[j]; 
        }
        printf("%lld", c[i]);
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2148
{-# LANGUAGE
  ScopedTypeVariables, BangPatterns, TupleSections, ExplicitForAll,
  LambdaCase, MultiWayIf, Unsafe, RecordWildCards, FlexibleContexts, CPP,
  NoMonomorphismRestriction, GADTs,
  RankNTypes, EmptyDataDecls, EmptyCase, ViewPatterns #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import qualified Data.IntMap.Lazy as IML
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import Data.Word
import System.IO
import Data.Function
import Control.Monad.Primitive
import qualified Data.Vector.Primitive.Mutable as VPM
import qualified Data.Vector.Generic.Mutable as VGM
import Data.STRef
import Data.IORef

main :: IO ()
main = do
  [n,k] <- map readInt . words <$> getLine
  putStrLn $ if k <= shiftR (n+1) 1 then "YES" else "NO" 


rInt :: StateT BSL.ByteString Maybe Int
rInt = StateT $ BSL.readInt . BSL.dropWhile (<'!')

#define D(f,r,d) f::Integral a=>a->d;f=fromIntegral;r::String->d;r=read
#define C(f,r,g,h,d) D(f,r,d);g,h::RealFrac a=>a->d;g=floor;h=ceiling
C(_toInteger_,readInteger,floorInteger,ceilInteger,Integer)
C(toInt,readInt,floorInt,ceilInt,Int)
C(toI8,readI8,floorI8,ceilI8,Int8)
C(toI16,readI16,floorI16,ceilI16,Int16)
C(toI32,readI32,floorI32,ceilI32,Int32)
C(toI64,readI64,floorI64,ceilI64,Int64)
C(toWord,readWord,floorWord,ceilWord,Word)
C(toW8,readW8,floorW8,ceilW8,Word8)
C(toW16,readW16,floorW16,ceilW16,Word16)
C(toW32,readW32,floorW32,ceilW32,Word32)
C(toW64,readW64,floorW64,ceilW64,Word64)
D(toDouble,readDouble,Double)
D(toFloat,readFloat,Float)
#undef D
#undef C


#define N(f,g,a,m)\
  f :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> e -> m (a i e); f=A.newArray;\
  g :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> m (a i e); g=A.newArray_
#define C(a,m)
N(newIOA,newIOA_,IOArray,IO)
N(newSTA,newSTA_,STArray s,ST s)
#undef C
#define C(a,m) MArray (a) e (m), 
N(newIOUA,newIOUA_,IOUArray,IO)
N(newSTUA,newSTUA_,STUArray s,ST s)
#undef C
#undef N

Measured memory_bytes: 508
a, b, k = map(int, input().split())
if a > 0:
  if a-k >= 0: 
    print(a-k, b)
  else: 
    if b <= -(a-k):#a-k<0
      print(0,0)
    else:
      print(0, b+(a-k))
else:
  if b > 0:
    if b-k <= 0: 
      print(a,0)
    else:
      print(a,b-k)
  else:
    print(a,b)

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

int main(){
  int n, r, h, V[41], xl, xr;
  while(cin >> r >> n, r){
    for(int i = 0; i < 2*r+1; ++i) V[i] = 0;
    double ans = 20.0;
    for(int i = 0; i < n; ++i){
      cin >> xl >> xr >> h;
      for(int j = max(xl,-r); j < min(xr,r+1); ++j){
	V[j+r] = max(h, V[j+r]);
      }
      if(xr == r) V[2*r] = max(V[2*r],h);
    }
    for(int i = 0; i < 2*r+1; ++i){
      ans = min(ans, V[i] + r - sqrt(r*r - (i-r)*(i-r)));
      if(i+1-r <= r) ans = min(ans, V[i] + r - sqrt(r*r - (i+1-r)*(i+1-r)));
      if(abs(i-1-r) <= r) ans = min(ans, V[i-1] + r - sqrt(r*r - (i-r)*(i-r)));
    }
    printf("%.4lf\n", ans);
  }			     
  return 0;
}

Measured memory_bytes: 3120