akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define ll long long int
#define endl "\n"

int main() {
    ll k;
    cin>>k;
    string str="";
    for(ll i=0;i<k;i++)
    {
        str=str+"ACL";
    }
    cout<<str<<endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long a[200001], n = 0, ans = 0;
char c;
int main()
{
	for(c = getchar(); c < 'A' || c > 'C'; c = getchar());
	for(n = 0; c <= 'C' && c >= 'A'; c = getchar(), n++) a[n] = c - 'A';
	for(int i = n - 1ll, sumb = 0ll; i >= 0ll; i--)
	{
		if(!a[i])
		{
			ans += sumb;
			continue;
		}
		if(a[i] == 2ll && a[i - 1] == 1ll)
		{
			sumb++;
			i--;
			continue;
		}
		sumb = 0;
	}
	cout << ans << endl;
	return 0;
}

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

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

  auto f = [](int x) { return floor(x * 1.08); };
  rep1(i, N) {
    if (f(i) == N) {
      cout << i << endl;
      return 0;
    }
  }

  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
using namespace std;
using P = pair<int, int>;


int N;
vector<int> A;

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end());
	bool check = true;
	for (int i = 1; i < N; i++) {
		if (A[i - 1] == A[i]) {
			check = false;
		}
	}
	if (check)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int x,y;
  cin >> x >> y;
  cout << x + y/2 << endl;
  return 0;
}


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

using namespace std;

int sort(vector<int>& v)
{
        int cnt = 0;

        for (size_t i = 0; i < v.size(); i++) {
                unsigned int min = i;
                for (size_t j = i; j < v.size(); j++) {
                        if (v[j] < v[min]) {
                                min = j;
                        }
                }
                if (min != i) {
                        int tmp = v[min];
                        v[min] = v[i];
                        v[i] = tmp;
                        cnt++;
                }
        }
        return cnt;
}

int main()
{
        int n;
        cin >> n;
        vector<int> v(n);
        for (int i = 0; i < n; i++) {
                cin >> v[i];
        }
        int cnt = sort(v);
        for (int i = 0; i < n; i++) {
                cout << v[i];
                if (i < n - 1) {
                        cout << ' ';
                } else {
                        cout << '\n';
                }
        }
        cout << cnt << '\n';
}

Measured memory_bytes: 3112
N=int(input())
Open=[list(map(int,input().split())) for i in range(N)]
Profit=[list(map(int,input().split())) for i in range(N)]
ans=-1*float('inf')
for x in range(1,2**10):
    check=bin(x)[2:]
    check='0'*(10-len(check))+check
    now=0
    for i in range(N):
        cnt=0
        for k in range(10):
            if int(check[k])*Open[i][k]==1:
                cnt+=1
        now+=Profit[i][cnt]
    ans=max(ans,now)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
  int n; cin >> n;
  vll l(n);
  rep(i, n) cin >> l[i];
  sort(l.rbegin(), l.rend());
  int cnt = 0;
  rep(a, n) {
    for (int b = a+1; b < n; b++) {
      for (int c = b+1; c < n; c++) {
        if (l[a] < l[b] + l[c]) cnt++;
          else break;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String[] S = sc.nextLine().split(" ");

        StringBuilder sb = new StringBuilder();
        for (String s : S) {
            String upperCase = s.substring(0, 1).toUpperCase();
            sb.append(upperCase);
        }

        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 23764
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define MOD 1000000007

int main() {
  ll H, W;

  cin >> H >> W;

  vector<string> map(H);
  vector<vector<ll> > val(H, vector<ll>(W, 0));

  for (int i = 0; i < H; i++) {
    cin >> map[i];
  }

  val[0][0] = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (map[i][j] == '#') continue;
      if (i > 0 && map[i - 1][j] == '.') {
        val[i][j] += val[i - 1][j];
        val[i][j] %= MOD;
      }
      if (j > 0 && map[i][j - 1] == '.') {
        val[i][j] += val[i][j - 1];
        val[i][j] %= MOD;
      }
    }
  }

  ll ans = val[H - 1][W - 1];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
 
int main(){

	int n, a[100], ans=10000000;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	for(int i=-100; i<=100; i++){
		int tmp=0;
		for(int j=0; j<n; j++){
			tmp+=(a[j]-i)*(a[j]-i);
		}
		if(ans>tmp){
			ans=tmp;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU 

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	while (N != 0) {
		map<char, char> V;
		REP(i, N) {
			char cb, ca;
			cin >> cb >> ca;
			V[cb] = ca;
		}
		int M;
		cin >> M;
		REP(i, M) {
			char C;
			cin >> C;
			if ((int)V[C] == 0) {
				cout << C;
			}
			else {
				cout << V[C];
			}
		}
		cout << endl;
		cin >> N;
	}
	PAU;
	return 0;
}



Measured memory_bytes: 3084
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
#define sz(x) (int)x.size()

/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/

void solve()
{
int n;
cin>>n;
int a[n];
int i,j;
rep(i,0,n)
cin>>a[i];
sort(a,a+n);
double pre=a[0];
double ans=0;
rep(i,1,n){
ans=(a[i]+pre)/2.0;
pre=ans;
}

cout<<fixed<<setprecision(6)<<ans<<'\n';
}

int main() 
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var X, A, B int
	fmt.Scan(&X, &A, &B)
	if A-B >= 0 {
		fmt.Println("delicious")
	} else if B-A <= X {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}


Measured memory_bytes: 512
N, A = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i)

dp = Array.new(N){Array.new(50*N + 1){Array.new(N+1, 0)}}
dp[0][0][0] = 1
dp[0][xs[0]][1] = 1

(1...N).each do |i|
    (0..50*i).each do |j|
        (0..i).each do |k|
            dp[i][j][k] += dp[i - 1][j][k]
            dp[i][j + xs[i]][k+1] += dp[i - 1][j][k]
        end
    end
end

sum = 0
(1..N).each do |k|
    sum += dp[N - 1][A*k][k]
end
puts sum

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

const uint64_t MOD = 1e+9 + 7;
const uint64_t K = 64;

int main()
{
  uint64_t N;
  cin >> N;

  vector<bitset<K>> A(N);
  for (uint64_t n = 0; n < N; ++n) {
    uint64_t a;
    cin >> a;

    A[n] = bitset<K>(a);
  }

  uint64_t S = 0;
  for (uint64_t k = 0; k < K; ++k) {
    uint64_t count1 = 0;
    for (uint64_t n = 0; n < N; ++n) {
      if (A[n][k]) { ++count1; }
    }

    uint64_t T = ((N - count1) * count1) % MOD;
    uint64_t offset = (static_cast<uint64_t>(1) << k) % MOD;
    uint64_t U = (T * offset) % MOD;
    
    S = (S + U) % MOD;
  }
  cout << S << endl;

  return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, X;
	cin >> N >> X;
	if (X == 1 || X == 2 * N - 1) cout << "No";
	else {
		cout << "Yes" << endl;
		if (N == 2) cout << "1 2 3";
		else {
			static bool check[200010] = {};
			int count = 1;
			if (X == 2) check[X - 1] = check[X] = check[X + 1] = check[X + 2] = true;
			else check[X - 2] = check[X - 1] = check[X] = check[X + 1] = true;
			for (int i = 1; count <= N - 2; i++) {
				if (check[i]) continue;
				cout << i << endl;
				count++;
				check[i] = true;
			}
			if (X == 2) cout << X + 1 << endl << X << endl << X - 1 << endl << X + 2 << endl;
			else cout << X - 1 << endl << X << endl << X + 1 << endl << X - 2 << endl;
			for (int i = 1; count <= 2 * N - 5; i++) {
				if (check[i]) continue;
				cout << i << endl;
				count++;
			}
		}
	}
}

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

using namespace std;

int main()
{
	string str;
	cin>>str;
	int cnt=0,ans=0;
	for(int i=0;i<str.size();i++)
	{
		if(str[i]=='A'||str[i]=='T'||str[i]=='C'||str[i]=='G')
			cnt++;
		else
		{
			ans=max(ans,cnt);
			cnt=0;
		}
	}
	cout<<max(ans,cnt)<<'\n';
	return 0;
}

Measured memory_bytes: 256
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
count=0
for i in range(N):
    A=list(map(int,input().split()))
    Sum=[C]
    for j in range(M):
        Sum.append(A[j]*B[j])
    if sum(Sum)>0:
        count+=1
print(count)

Measured memory_bytes: 3060
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    vector<vector<int>> A(3, vector<int>(3));
    rep(i, 3) {
        rep(j, 3) {
            cin >> A.at(i).at(j);
        }
    }
    int N;
    cin >> N;
    vector<int> b(N);
    rep(i, N) cin >> b.at(i);

    rep(i, N) {
        rep(j, 3) {
            rep(k, 3) {
                if (b.at(i) == A.at(j).at(k))
                    A.at(j).at(k) = 0;
            }
        }
    }

    string ans = "No";
    rep(i, 3) {  // 横
        if (A.at(i).at(0) == 0 && A.at(i).at(1) == 0 && A.at(i).at(2) == 0) ans = "Yes";
    }
    rep(i, 3) {  // 縦
        if (A.at(0).at(i) == 0 && A.at(1).at(i) == 0 && A.at(2).at(i) == 0) ans = "Yes";
    }

    // 左下向き斜め
    if (A.at(0).at(0) == 0 && A.at(1).at(1) == 0 && A.at(2).at(2) == 0) ans = "Yes";

    // 右上向き斜め
    if (A.at(2).at(0) == 0 && A.at(1).at(1) == 0 && A.at(0).at(2) == 0) ans = "Yes";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int H = int.Parse(Console.ReadLine());
            int W = int.Parse(Console.ReadLine());



            Console.WriteLine(
                (N-H+1) * (N-W+1)
                );
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define psp printf(" ")
#define endc printf("\n")

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

const int maxn = 2100;
//const int md = 1e9 + 7;

vector<int> flp[maxn];

int calc(vector<pii> v) {
	sort(v.begin(), v.end()); reverse(v.begin(), v.end());
	int bm = 0; int ans = 1e9;
	for (int i = 0; i < v.size(); i++) {
		ans = min(ans, bm + v[i].first);
		bm = max(bm, v[i].second);
	}
	return min(ans, bm);
}

int solve(string a,string b) {
	fill(flp, flp+maxn, *new vector<int>());
	int n = a.size();
	for (int s = 0; s < n; s++) {
		for (int j = 0; j < n; j++) {
			if (b[j] == '1') { flp[(j-s+n)%n].pb(s); }
		}
	}
	int res = 1e9;
	for (int s = 0; s < n; s++) {
		int ans = 0;
		vector<pii> cur;
		for (int j = 0; j < n; j++) {
			if (b[j] != a[j]) {
				ans++;
				int pos = (j-s+n)%n;
				if (flp[pos].size() == 0) return -1;
				if (flp[pos][0] <= s) continue;
				cur.pb(mp(flp[pos][0]-s,n-flp[pos][flp[pos].size()-1]));
			}
		}
		
		ans+=s + calc(cur)*2 ;

		res = min(res, ans);
		a = a.substr(n-1,1) + a.substr(0,n-1);
	}
	return res;
}

int main() {
	IOS;
	string a,b; cin>>a>>b;
	int ans = solve(a,b); reverse(a.begin(),a.end()); reverse(b.begin(),b.end());
	cout<<min(ans,solve(a,b))<<endl;
}


Measured memory_bytes: 17408
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    int n,l;
    char a[101][101],tmp[101];
    scanf("%d %d",&n,&l);
    for(int i=0;i<n;i++)
        scanf("%s",a[i]);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            // printf("%d\n",strcmp(a[i],a[j]));
            if(strcmp(a[i],a[j])>=1){
                strcpy(tmp,a[i]);
                strcpy(a[i],a[j]);
                strcpy(a[j],tmp);
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            printf("%c",a[i][j]);
        }
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> iipair;
typedef pair<unsigned,unsigned> uupair;
typedef vector<int> vec;
typedef vector<unsigned> uvec;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    unsigned n,least_elem,result,elem;
    result=0;
    least_elem=numeric_limits<unsigned>::max();
    cin>>n;
    for(unsigned i=0;i<n;++i)
    {
        cin>>elem;
        if(elem < least_elem)
        {
            ++result;
            least_elem=elem;
        }
    }
    cout<<result;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n;cin>>n;
	int c=0;
	int ans=0;
	rep(i,n) {
		int p;cin>>p;
		if(p==i+1) c++;
		else {ans+=(c+1)/2;c=0;}
	}
	ans+=(c+1)/2;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	vector<string> s(3);
	cin>>s[0];
	cin>>s[1];
	cin>>s[2];
	reverse(s[0].begin(), s[0].end());
	reverse(s[1].begin(), s[1].end());
	reverse(s[2].begin(), s[2].end());
	int cur = 0;

	while(1){
		// cout<<cur<<endl;
		if(s[cur].empty()){
			cout<<(char)(cur+'A')<<endl;
			return;
		}
		int ncur = s[cur].back()-'a';
		s[cur].pop_back();
		cur = ncur;
	}
	
}

int main(){
	// fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
// finish date: 2018/09/13
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>>
        vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;

//最大公約数
int gcd(int a, int b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    if (a < b) {
        swap(a, b);
    }
    int r = 1; //0以外であれば何でも
    while (r != 0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


int main() {
    int N, X;
    cin >> N >> X;
    int x, ans;
    rep(i, N) {
        cin >> x;
        x -= X;
        if (i == 0) ans = x;
        ans = gcd(ans, x);
    }

    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
#define N
using namespace std;
typedef pair<int, int> P;
int dx[] = {1, 1, -1, -1};
int dy[] = {1, -1, -1, 1};
int main()
{
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int tmp_x = x2 - x1;
    int tmp_y = y2 - y1;
    int x3, y3, x4, y4;
    y3 = y2 + tmp_x;
    x3 = x2 - tmp_y;
    y4 = y3 - tmp_y;
    x4 = x3 - tmp_x;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
n = int(input())
data = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(1, n-1):
    if data[i][0] == data[i][1] and data[i-1][0] == data[i-1][1] and data[i+1][0] == data[i+1][1]:
        print("Yes")
        exit()

print("No")


Measured memory_bytes: 9048
from itertools import product
from math import ceil
def main():
    d, g = map(int, input().split())
    scoremax_set = []
    numq_set = []
    for i1 in range(1, d + 1):
        kazu, bonus = map(int, input().split())
        scoremax_set.append(i1 * 100 * kazu + bonus)
        numq_set.append(kazu)
    score_get_pat = tuple(product((1,0), repeat=d))

    inf = float('inf')
    r = inf

    for sgpe in score_get_pat:
        score = 0
        q_num = 0
        for j1, s in zip(sgpe, scoremax_set):
            score += j1 * s
        for j2, num in zip(sgpe, numq_set):
            q_num += j2 * num
        if score >= g:
            r = min(r, q_num)
        else:
            sgpe_l = [i for i, x in enumerate(sgpe) if x == 0]
            score_plus = (sgpe_l[-1]+1)*100 * (numq_set[sgpe_l[-1]] - 1)
            if score + score_plus >= g:
                q_num += ceil((g - score) / ((sgpe_l[-1]+1)*100))
                r = min(r, q_num)
    print(r)


if __name__ == '__main__':
    main()

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

#define REP(i,n) for (int i=0;i<(n);i++)

using namespace std;

class graph
{
    private:
        const int number_of_nodes;
        const bool is_directed;
    public:
        vector<int> *edges;
        graph(int number_of_nodes, bool is_directed = true): number_of_nodes(number_of_nodes), is_directed(is_directed) {
            edges = new vector<int>[number_of_nodes];
        }
        ~graph() {
            delete [] edges;
        }
        int size() const {return number_of_nodes;}
        void make_edge(int u, int v) {
            edges[u].push_back(v);
            if (!is_directed) {
                edges[v].push_back(u);
            }
        }
};

int * longest_path(graph &g)
{
    int *lp = new int[g.size()]();
    function<int(int, int)> f = [&](int u, int depth) -> int {
        if (lp[u] != 0) {
            return lp[u];
        }
        if (g.edges[u].size() == 0) {
            return lp[u] = 1;
        }
        if (depth == g.size()) {
            return lp[u] = -1;
        }
        int x_max = 0;
        for (int v: g.edges[u]) {
            int x = f(v, depth + 1);
            if (x == -1) {
                return lp[u] = -1;
            }
            x_max = max(x_max, x);
        }
        return lp[u] = x_max + 1;
    };
    for (int v = 0; v < g.size(); ++v) {
        if (f(v, 0) == -1) {
            delete [] lp;
            return nullptr;
        }
    }
    return lp;
}

int main(void)
{
    int V, E;
    cin >> V >> E;
    graph g(V);
    REP(i, E) {
        int s, t;
        cin >> s >> t;
        g.make_edge(s, t);
    }
    cout << (longest_path(g) == nullptr) << endl;
    return 0;
}


Measured memory_bytes: 3180
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

R = I()
G = I()

print(2*G-R)

Measured memory_bytes: 3820
#include <iostream>
#include <cstring>
#include <climits>
#define MAXN 405

using namespace std;

int N;							//number of elements in set
int a[MAXN];					//given set
long long dp[MAXN][MAXN];	//dp table for minimum cost of merging elements from [i]to[j]
long long sum[MAXN][MAXN];	//actually not necessary
long long cost;				//dynamic cost for minimization

long long solve(int i,int j){
	if(i==j){
		dp[i][j] = 0;
		sum[i][j] = a[i];
	}
	else if(dp[i][j]==0){
		dp[i][j] = INT64_MAX;
		for(int k=i;k<j;k++){
			solve(i,k);
			solve(k+1,j);
			cost = dp[i][k] + dp[k+1][j] + sum[i][k] + sum[k+1][j] ;
			if(dp[i][j]>cost){
				dp[i][j]  = cost;
				sum[i][j] = sum[i][k] + sum[k+1][j];
			}
		}
	}
	
	return dp[i][j];
}

int main(){
	cin>>N;
	memset(dp,0,sizeof(dp));
	memset(sum,0,sizeof(sum));
	
	for(int i=0;i<N;i++)
		cin>>a[i];

	cout<<solve(0,N-1)<<endl;
}


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

#define REP(i, n) for(ull i = 0; i != n; ++i)
#define RREP(i, n) for(ull i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for(auto i = a; i != b; ++i)
#define ALL(v) (v).begin(), (v).end()
#define IN std::cin
#define OUT std::cout

using ll = long long;
using ull = unsigned long long;
template<typename V1, typename V2>
using pair = std::pair<V1, V2>;
using str = std::string;
template<typename Val, std::size_t Size>
using arr = std::array<Val, Size>;
template<typename Val>
using vec = std::vector<Val>;
template<typename Val>
using list = std::list<Val>;
template<typename Val>
using stack = std::stack<Val>;
template<typename Val>
using queue = std::queue<Val>;
template<typename Val>
using pqueue = std::priority_queue<Val>;
template<typename Val>
using deque = std::deque<Val>;
template<typename Key, typename Val>
using map = std::map<Key, Val>;
template<typename Key, typename Val>
using mmap = std::multimap<Key, Val>;
template<typename Key, typename Val>
using umap = std::unordered_map<Key, Val>;
template<typename Key, typename Val>
using ummap = std::unordered_multimap<Key, Val>;
template<typename Key, typename Val>
using set = std::set<Key, Val>;
template<typename Key, typename Val>
using mset = std::multiset<Key, Val>;
template<typename Key, typename Val>
using uset = std::unordered_set<Key, Val>;
template<typename Key, typename Val>
using umset = std::unordered_multiset<Key, Val>;

const str ln = "\n";

int main() {
    ull N, M, result = 0, digit_max = 0;
    IN >> N >> M;

    if(N == 1 && M == 0) {
        OUT << 0 << ln;
        return 0;
    }
    
    vec<ull> s(M), c(M), value(N, 0);
    value.at(0) = 1;
    REP(i, M) {
        IN >> s.at(i) >> c.at(i);
    }

    REP(i, M) {
        if(digit_max < s.at(i)) digit_max = s.at(i);

        if(s.at(i) == 1) {
            if(value.at(0) == 1) {
                value.at(0) = c.at(i);
            }
            else if(value.at(0) != c.at(i)) {
                OUT << -1 << ln;
                return 0;
            }
        }
        else {
            if(value.at(s.at(i) - 1) == 0) {
                value.at(s.at(i) - 1) = c.at(i);
            }
            else if(value.at(s.at(i) - 1) != c.at(i)) {
                OUT << -1 << ln;
                return 0;
            }
        }
    }
    if(N > 1 && value.at(0) == 0) {
        OUT << -1 << ln;
        return 0;
    }

    REP(i, N) {
        OUT << value.at(i);
    }
    OUT << ln;
}

Measured memory_bytes: 256
N, K = map(int,input().split())
X = list(map(int,input().split()))

# Kのwindowを持っている
# 正負で挙動が少し変わる
# +方向に進むか、-方向に進むか
ans = 10**10
for i in range(N-K+1):
    plus =  abs(X[i]) + abs(X[i+K-1]-X[i])
    minus = abs(X[i+K-1]) + abs(X[i+K-1]-X[i])
    ans = min(ans,plus,minus)
print(ans)

Measured memory_bytes: 14532
import math
def ip():return int(input())
def inp():return map(int,input().split())
def linp():return list(map(int,input().split()))

n=ip()
p=linp()
ans=0
for i in range(1,n-1):
    l=[p[i-1],p[i],p[i+1]]
    if p[i]>min(l) and p[i]<max(l):ans+=1
print(ans)



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

using namespace std;
using ll = long long;
constexpr ll INF = 1e18;
int main(){
    ll n;
    cin >> n;
    vector<ll> A(n+1);
    A[0] = 0;
    for(ll i = 0; i < n; i++) {
        ll x;
        cin >> x;
        A[i + 1] = A[i] + x;
    }
    ll sum = A[n];
    ll ret = INF;
    for(ll i = 0; i < n; i++) {
        ret = min(ret, abs(sum - A[i] - A[i]));
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
vector<vector<int> > ans;
vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//do {
//    print(v);
//  } while (std::next_permutation(v.begin(), v.end()));

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	ll K;
	cin>>K;
	long double t=1;
	ll i=1;
	while(K>0){
		 ll A=0,j=i;
		while(i){
			A+=j%10;
			j/=10;
			if(j<10){A+=j;break;}
		}
		long double a=A;
		if(t<(double)i/a){
			i+=9*t;
			t*=10;
		}
		else{
			cout<<i<<endl;
			i+=t;
			K--;
		}
	}
	
	return 0;
}




















Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <numeric>
using namespace std;

int main(){
    int n ;
    cin >> n ;
    n %= 10 ;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
    {
        cout << "hon" ;
    }else if (n == 3)
    {
        cout << "bon" ;
    }else
    {
        cout << "pon" ;
    }
    
    cout << endl ;
    
}

Measured memory_bytes: 3624
A,B,C = map(int,input().split())
ans = 0
n = C // (7*A+B)
r = C %  (7*A+B)
ans += 7*n
if r == 0:
    pass
elif r <= 6*A:
    ans += r//A
    if r % A != 0:
        ans += 1
else:
    ans += 7
print(ans)


Measured memory_bytes: 5596
<?php
$dir = ["N" => 0,"E" => 1, "S" => 2,"W" => 3];
$dx = [0,1,0,-1];
$dy = [1,0,-1,0];
while($N = trim(fgets(STDIN))){
    $land = [];
    for($i = 0; $i <= 20; $i++){
        for($j = 0; $j <= 20; $j++){
            $land[$i][$j] = 0;
        }
    }
    for($i = 0; $i < $N; $i++){
        list($x,$y) = explode(" ",trim(fgets(STDIN)));
        $land[$y][$x] = 1;
    }
    $o = trim(fgets(STDIN));
    $cnt = 0;
    $x = 10;
    $y = 10;
    for($i = 0; $i < $o; $i++){
        list($d,$l) = explode(" ",trim(fgets(STDIN)));
        for($j = 0; $j < $l; $j++){
            $x += $dx[$dir[$d]];
            $y += $dy[$dir[$d]];
            if($land[$y][$x] == 1){
                $land[$y][$x] = 0;
                $cnt++;
            }
        }
    }
    echo ($cnt == $N ? "Yes" : "No")."\n";
}

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

typedef long long ll;

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

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    int n, k;
    cin >> n >> k;

    int now=1, ans=0;
    while(n>now) {
        now *= k;
        ans++;
    }

    if(now==n) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	char a;
	scanf("%c", &a);
	if (a == 'A')
		puts("T");
	else if (a == 'T')
		puts("A");
	else if (a == 'C')
		puts("G");
	else
		puts("C");
	return 0;
}

Measured memory_bytes: 128
# 入力１
Vn, En, r = map(int, input().split())

# 入力２：各頂点から別の頂点へ移動する辺とコスト
E = []
for _ in range(En):
    s, t, c = map(int, input().split())
    E.append((s,t,c))

# 初期化
INF = 10**3 * 10**4  # INF 以外で取りうる値は -10**3 * 10**4 < < 10**3 * 10**4
dp = [INF * 10] * Vn
dp[r] = 0

# ベルマン・フォード

# 頂点と同じ回数だけ dp を更新して「伝播」させる
for i in range(Vn):
    for u, v, duv in E:
        if dp[v] > dp[u] + duv:
            dp[v] = dp[u] + duv

# 負のループをチェックする
for u, v, c in E:
    # たどり着けない頂点に関しては無視
    if dp[v] > INF:
        continue
    if dp[u] + c < dp[v]:
        print("NEGATIVE CYCLE")
        break
else:
    # 解答
    for i in range(Vn):
        if not dp[i] > 10**3 * 10**4:  # 頂点数、辺のコストから、この値を下回ることは無いはず
            print(dp[i])
        else:
            print("INF")


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


int main()
{
	string str;
	char ch;
	int count[26] = { 0 };
	
	while (getline(cin, str)){
		if (str.size() == 0){
			break;
		}
		for (int i = 0; i < str.size(); i++){
			if ('A' <= str[i] && str[i] <= 'Z'){
				str[i] = char(tolower(str[i]));
			}
		}

		for (ch = 'a'; ch <= 'z'; ch++){
			for (int i = 0; i < str.size(); i++){
				if ((int)str[i] == ch){
					count[ch - 'a']++;
				}
			}
		}
	}

		for (ch = 'a';ch<='z'; ch++){
			cout << ch << " : " << count[ch - 'a'] << endl;
		}

	
	return 0;
}


Measured memory_bytes: 3216
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(double[]);

    double d = 0;

    foreach (i ; 0 .. n) {
        d += 1.0 / a[i];
    }

    double ans = 1.0 / d;

    writefln("%.12f", ans);
}




















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

C = {}
for a in A:
  if a in C:
    C[a] += 1
  else:
    C[a] = 1
C = sorted(C.items(), key=lambda x:x[1])

ans = 0
i = 0 
for _,v in C:
  if len(C)-K <= i:
    break
  ans += v
  i += 1
print(ans)


Measured memory_bytes: 38964
# -*- coding: utf-8 -*-
a = input()
alp = ['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']
for i in range(len(alp)):
    if a == alp[i]:
        print(alp[i+1])

Measured memory_bytes: 3060
fun main() {
    val n = readLine()!!.trim().toInt()
    val nums = readLine()!!.trim().split(' ').map(String::toInt)
    val group = nums.groupBy { it }
    val isDividable = BooleanArray(1000001){false}
    for ((a, l) in group) {
        if (l.size > 1) isDividable[a] = true
        for (i in (a shl 1) until isDividable.size step a) {
            isDividable[i] = true
        }
    }
    println(nums.count { !isDividable[it] })
}

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

int main(){

	string W, T;
	cin >> W;

	int count = {0};

	while(cin >> T && T != "END_OF_TEXT"){
		for(int i=0; i<T.length(); ++i){
			T[i] = tolower(T[i]);
		}

		while (! (int(*(T.begin())) >= 97 && int(*(T.begin())) <= 122) ){T.erase(T.begin());}
                while (! (int(*(T.end()-1)) >= 97 && int(*(T.end()-1)) <= 122) ){T.erase(T.end()-1);}

		if(T == W){
			++count;
		}
	}

	cout << count << endl;

	return 0;
}



Measured memory_bytes: 3052
from datetime import timedelta

while True:

    input_count = int(input())

    if input_count == 0:
        break

    records = []

    for _ in range(input_count):
        record = [int(item) for item in input().split(" ")]

        total_minute = record[1] + record[3] + record[5] + record[7]
        total_second = record[2] + record[4] + record[6] + record[8]

        time = timedelta(minutes=total_minute, seconds=total_second)
        records.append((record[0], time))

    records.sort(key=lambda item: item[1])

    print(records[0][0])
    print(records[1][0])
    print(records[-2][0])



Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
#include <stdio.h>
#include <stdlib.h>
#define rep(i,n) for(int i = 0; i < (int)n; i++)
 
int main(void){
    // Your code here!
  int count=0;
  string p;
  cin >> p;
  for(char d:p){
    count += (((int)d)-48);
    count %= 9;
  }
  if(count==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 3732
from string import ascii_uppercase
  
def row_label(i):
    return str(i + 1)

def col_label(j):
    return ascii_uppercase[j]

def solve(s_list):
    for i in range(h):
        for j in range(w):
            if s_list[i][j] == 'snuke':
                return col_label(j) + row_label(i)

if __name__ == '__main__':
    (h, w) = (int(_) for _ in input().split())
    s_list = [list(input().split()) for _ in range(h)]
    print(solve(s_list))

Measured memory_bytes: 3772
sx,sy,tx,ty=map(int,input().split())
tx=tx-sx
ty=ty-sy
sx=0
sy=0
ans=[]
def add(num,d):
    global ans
    di=["U","D","L","R"]
    for i in range(num):
        ans.append(di[d])
y=ty-sy
x=tx-sx
add(y,0)
add(x,3)
add(y,1)
add(x,2)
add(1,2)
add(y+1,0)
add(x+1,3)
add(1,1)
add(1,3)
add(y+1,1)
add(x+1,2)
add(1,0)
print("".join(ans))

Measured memory_bytes: 38640
import           Data.List
import           Data.Tuple

main :: IO ()
main = do
    n <- readLn :: IO Int
    case solve n of
        Just (k, mat) -> do
            putStrLn "Yes"
            print k
            putStr.unlines $ map (unwords.map show) mat
        Nothing -> putStrLn "No"

solve :: Int -> Maybe (Int, [[Int]])
solve 1 = Just (2, [[1, 1], [1, 1]])
solve n = case find (\k->k*(k-1)==2*n) [1..448] of
    Nothing -> Nothing
    Just k -> Just (k, map((k-1):).zipWith (++) tri $ transpose tri ++ [[]])
      where
        tri = snd $ mapAccumL ((swap.).flip splitAt) [1..n] [0..k-1]

Measured memory_bytes: 11388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    string ans[4] = {"SS", "SW", "WS", "WW"};
    rep(i, 4){
        repr(j, 1, n+1){
            bool f1 = (ans[i][j-1] == 'W');
            bool f2 = (ans[i][j] == 'W');
            bool f3 = (s[j%n] == 'x');
            ans[i] += ((f1^f2^f3) ? 'W' : 'S');
        }
        if(ans[i][n] == ans[i][0] && ans[i][n+1] == ans[i][1]){
            ans[i].pop_back();
            ans[i].pop_back();
            cout << ans[i] << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 976
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int INF = 1000000000;
const double PI = 3.1415926535897932384626433832795;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

using LL = long long int;
using LD = long double;
using pii = pair<int, int>;
using pdd = pair<double, double>;
using pll = pair<LL, LL>;
using vi = vector<int>;
using vd = vector<double>;
using vvi = vector<vi>;
using vll = vector<LL>;

//==============================================
vi dp(94);

int fib(int n) {
	if (n == 0 || n == 1) return dp[n] = 1;
	if (dp[n] != -1) return dp[n];
	return dp[n] = fib(n - 1) + fib(n - 2);
}

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

	int n;
	cin >> n;
	
	REP2(i, 1, n + 1)  dp[i] = -1;
	cout << fib(n) << "\n";
	return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

int main()
{
  int n;
  std::cin >> n;
  std::vector<int> weights;
  for(int i=0; i<n; i++)
  {
    int w;
    std::cin >> w;
    weights.push_back(w);
  }
  const int sum =  std::accumulate(weights.begin(), weights.end(), 0);

  int diffNow = sum;
  int answer = 1000000;
  for(int i=0; i<weights.size(); i++)
  {
    diffNow -= weights[i]*2;
    answer = std::min(answer, std::abs(diffNow));
    if(diffNow <= 0) { break; }
  }
  std::cout << answer;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
ll dp[110][4][4][4]={};
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
ll calcsum(int i){
  ll sum = 0;
  for(int j=0;j<4;j++){
    for(int k=0;k<4;k++){
      for(int l=0;l<4;l++){
        sum += dp[i][j][k][l];
        sum %= MOD;
      }
    }
  }
  return sum;
}
signed main(){
  init_io();
  ll n,v;
  cin >> n;
  for(int j=0;j<4;j++){
    for(int k=0;k<4;k++){
      for(int l=0;l<4;l++){
        dp[2][j][k][l] = 1;
      }
    }
  }
  dp[2][0][1][2] = dp[2][0][2][1] = dp[2][1][0][2] = 0;
  for(int i=3;i<n;i++){
    for(int j=0;j<4;j++){
      for(int k=0;k<4;k++){
        ll sum = 0,rc=0;
        for(int l=0;l<4;l++){
          sum += dp[i-1][l][j][k];
          sum %= MOD;
          if(!((l==0&&k==1)||(l==0&&j==1))){
            rc += dp[i-1][l][j][k];
            rc %= MOD;
          }
        }
        for(int l=0;l<4;l++){
          dp[i][j][k][l] = sum;
        }
        dp[i][j][k][2] = rc;
      }
    }
    dp[i][0][1][2] = dp[i][0][2][1] = dp[i][1][0][2] = 0;
  }
  /*
  for(int i=0;i<n;i++){
    for(int j=0;j<4;j++){
      for(int k=0;k<4;k++){
        for(int l=0;l<4;l++){
          cout << dp[i][j][k][l]<<" ";
        }
      }
    }
    cout << endl;
  }
  */
  cout <<calcsum(n-1)<<endl;
}


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

int cal(int n, vector<int>x,int ave){
    int ans = 0;
    for (int i = 1; i <=n; i++)
    {
        ans +=(x[i]-ave)*(x[i]-ave);
    }
    
    return ans;
}

int main(){
    int n ,ans;
    int ave = 0;
    int we =0;
    cin >> n;
    vector<int> x(n+1);
    for (int i = 1; i <= n; i++)
    {
        cin >> x[i];
        ave += x[i];
    }
    ave =ave /n;
    ans = min (cal(n,x,ave),cal(n,x,ave+1));
    cout << ans << endl;
    return 0;
}

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

int main(){
    char S[4];

    scanf("%s", S);

    if(strcmp(S, "SUN") == 0){
        printf("7\n");
    }else if(strcmp(S, "MON") == 0){
        printf("6\n");
    }else if(strcmp(S, "TUE") == 0){
        printf("5\n");
    }else if(strcmp(S, "WED") == 0){
        printf("4\n");
    }else if(strcmp(S, "THU") == 0){
        printf("3\n");
    }else if(strcmp(S, "FRI") == 0){
        printf("2\n");
    }else if(strcmp(S, "SAT") == 0){
        printf("1\n");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;

int app() {
  int n;
  cin>>n;

  string s;
  cin>>s;

  if(n%2!=0) return 0;
  
  rep(i,n/2){
    if(s[i]!=s[i+n/2]) return 0;
  }
  return 1;
}

int main(){cout<<(app()?"Yes":"No")<<endl;return 0;}


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

rui = [0]
for i in range(0,N):
    rui.append(rui[i] + A[i])

rui = sorted(rui)
ans = 0
cnt = 0
tmp = 10000000000000000

for i in rui:
    if tmp == i:
        cnt += 1
    else:
        tmp = i
        ans += cnt*(cnt-1)//2
        cnt = 1
ans += cnt*(cnt-1)//2
print(ans)


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

/* clang-format off */
#define int long long
#define double long double
struct Fast {Fast() {cin.tie(0); ios::sync_with_stdio(false);}} fast;

template <typename T> inline size_t maxElement(T beginIt, T endIt) { return max_element(beginIt, endIt); }
template <typename T> inline size_t minElement(T beginIt, T endIt) { return min_element(beginIt, endIt); }
template <typename T> inline size_t maxIndex(T beginIt, T endIt) { return distance(beginIt, *max_element(beginIt, endIt)); }
template <typename T> inline size_t minIndex(T beginIt, T endIt) { return distance(beginIt, *min_element(beginIt, endIt)); }
template <typename T> inline int sum(T beginIt, T endIt) { return accumulate(beginIt, endIt, 0); }
template <typename T> inline int mean(T beginIt, T endIt) { return sum(beginIt, endIt) / distance(beginIt, endIt); }
template <typename T> inline void debug(T x) { cerr << x << " " << "(L:" << __LINE__ << ")" << endl; }
/* clang-format on */

signed main(void) {
  /* */
  // int num;
  // num = 0; // count
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  double num; // num
  num = 0; // count
  // num = numeric_limits<double>::min(); // max
  // num = numeric_limits<double>::max(); // min
  int N;
  // array<int, 200000> A;
  string S;
  /* */

  int M, D;

  cin >> N >> M >> D;

  if (D == 0) {
  }

  for (int i = 0; i + D < N; ++i) {
    num += (double)1;
  }

  if (D == 0) {
    num *= (double)(M - 1);
    num /= (double)(N * N);
  } else {
    num *= (double)(2 * (M - 1));
    num /= (double)(N * N);
  }

  // cout << num << endl;
  cout << fixed << setprecision(10) << num << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define umap unordered_map
#define flush fflush(stdout)
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define ln "\n"
#define all(v) v.begin(),v.end()
#define MAX 1000000009
#define MOD 1000000007
#define mid (start + end) / 2
#define R(ii) (ii + ii + 1)
#define L(ii) (ii + ii)
#define N 100005
using namespace std;
typedef pair<ll,ll> pp;
typedef vector<ll> vi;
ll n, q, k, t, x, y, a, b, c;
string s;
int main(){
    #ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> t;
    set <string> S;
    map <string, ll> m;
    ll mx = 0;
    while(t--){
        cin >> s;
        m[s]++;
        mx = max(mx, m[s]);
        S.insert(s);
    }
    for(auto a : S){
        if (m[a] == mx){
            cout << a << ln;
        }
    }
    return 0;
}


Measured memory_bytes: 33280