akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int dy[] = {-1, -1, 0, 1, 1, 1, 0, -1};
    int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};

    for(;;){
        int h, w;
        cin >> h >> w;
        if(h == 0)
        return 0;

        vector<string> grid(h);
        for(int i=0; i<h; ++i)
        cin >> grid[i];

        set<string> ss;
        string ret;
        int maxLen = -1;
        for(int y=0; y<h; ++y){
            for(int x=0; x<w; ++x){
                for(int d=0; d<8; ++d){
                    int y1 = y;
                    int x1 = x;
                    string s;
                    do{
                        s += grid[y1][x1];
                        y1 += dy[d] + h;
                        x1 += dx[d] + w;
                        y1 %= h;
                        x1 %= w;
                    }while(y1 != y || x1 != x);

                    int n = s.size();
                    while(n >= max(maxLen, 2)){
                        string t = s.substr(0, n);
                        if(ss.find(t) == ss.end()){
                            ss.insert(t);
                        }else{
                            if(n > maxLen || (n == maxLen && t < ret)){
                                maxLen = n;
                                ret = t;
                            }
                            break;
                        }
                        -- n;
                    }
                }
            }
        }

        if(maxLen == -1)
        cout << 0 << endl;
        else
        cout << ret << endl;
    }
}

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


#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;




int main() {
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int ans = 0;
	for(int i = 0;i<=a;i++){
		for(int j = 0;j<=b;j++){
			for(int k = 0;k <= c; k++){
				if(500*i + 100*j + 50*k == x){
				ans++;
			  }
		    }
	    }
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)

using namespace std;


int main(void) {

	long long a;
	long long b;

	

	cin >> a >> b;

	if (a <= b) {

		for (int i = 0; i < b; i++) {
			cout << a;
		}
	}
	else
	{

		for (int i = 0; i < a; i++) {
			cout << b;
		}
	
	}


}






Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    int mn = INF;
    for(int pos = 1; pos <= 100; pos++){
        int cost = 0;
        rep(i, n){
            cost += (X[i] - pos) * (X[i] - pos);
        }
        chmin(mn, cost);
    }
    cout << mn << ln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll a,b;

void init(){
	cin>>a>>b;
	cerr<<"初期化終了"<<endl;
}

int main(void){
	init();
	cout<<max({a+b,a*2-1,b*2-1})<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define PI 3.14159265358979323846264
#define pii pair <int, int>
#define pipii pair <int, pair <int, int> > 
#define piipi pair <pair <int, int>, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
#define FOR(i, x, y) for (int i=x; i<=y; i++)
#define FORD(i, y, x) for (int i=y; i>=x; i--)
#define debug printf("OK\n")
int a, b, c;
int main() {
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool check(ll mid,ll n,ll a,ll b,vector<ll>h){
  ll ret=0;
  ll dis=a-b;
  rep(i,n){
    h[i]-=mid*b;
    if(h[i]>0)ret+=(h[i]+dis-1)/dis;
  }
  return ret<=mid;
}
void solve(){
  ll n,a,b;cin>>n>>a>>b;
  vector<ll>h(n);
  rep(i,n)cin>>h[i];
  ll right=pow(10,9)+10;
  ll left=-1;
  while(right-left>1){
    ll mid=(right+left)/2;
    if(check(mid,n,a,b,h))right=mid;
    else left=mid;
  }
  cout<<right<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
  cin.tie(nullptr);cout<<fixed;
  cout<<setprecision(30);
	solve();
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int main(){
	int A,B;
	cin>>A>>B;
        cout<<fixed<<setprecision(10)<<double(A)*B/(A+B)<<endl;
	return(0);
}

Measured memory_bytes: 256
program main
  implicit none
  integer(8) i,M,D,ans,j
  read(*, *) M, D
  !read(*, *) (L(i), i = 1,N)
  ans = 0
  do i = 1,M
    do j = 1,D
      if (i == mod(j,10)*(j/10) .and. mod(j,10)>1 .and. j/10>1) then
        ans = ans + 1
        !write(*, *) i,j
      end if
    end do
  end do

  write(*, *) ans
end program main


Measured memory_bytes: 640
/******************
*  Writer: Oh no  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;

int n;
string s;
char c;
set<string> t;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	cin>>s;
	c=s[s.size()-1];
	t.insert(s);
	for(int i=2;i<=n;i++){
		cin>>s;
		if(t.count(s) || s[0]!=c){
			cout<<"No";
			return 0;
		}
		c=s[s.size()-1];
		t.insert(s);
	}
	cout<<"Yes";
	
	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.next();
		
		int ans = s.length();
		int n = ans;
		
		int slen = 0;
		
		for(int i = 0 ; i < n ; i++) {
			if(s.charAt(i) == 'S') {
				slen++;
			}
			else {
				if(slen > 0) {
					ans -= 2;
					slen--;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 25164
n = int(input())
h = list(map(int,input().split()))
ans = 0
for _ in range(100):
  streak = False
  for i in range(n):
    if h[i] > 0:
      h[i] -= 1
      if streak:
        pass
      else:
        ans += 1
        streak = True
    else:
      streak = False
print(ans)


Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  ll A, B, K;

  cin >> A >> B >> K;

  ll t = min(A, K);
  A -= t;
  K -= t;

  t = min(B, K);
  B -= t;
  K -= t;

  cout << A << " " << B << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int n;
    int d[100];
    int tmp;
    int ans = 1;

    scanf("%d", &n);
    scanf("%d", &d[0]);
    for (int i = 1; n > i; i++) {
        int iFlag = 0;
        scanf("%d", &d[i]);
        for (int j = 0; i > j; j++) {
            if (d[i] == d[j]) {
                iFlag = 1;
                break;
            }
        }
        if (0 == iFlag) {
            ans++;
        }
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
using namespace std;
#define N (1000000000+7)
typedef long long ll;
typedef pair<int, int> P;

int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int a[200010];
int num[200010];

int main(void) {
	int n, k, kinds = 0, ans = 0;
	cin >> n >> k;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		num[a[i]]++;
	}
	for (int i = 1;i <= n;i++) {
		if (num[i])kinds++;
	}
	if (kinds <= k) {
		cout << 0 << endl;
		return 0;
	}
	sort(num, num + 200010);
	for (int i = 1;i < 200010;i++) {
		if (num[i]) {
			ans += num[i];
			kinds--;
			if (kinds <= k)break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>

using int64 = long long;

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

    int H, W;
    std::cin >> H >> W;

    std::vector<std::string> a;
    for (int i = 0; i < H; i++) {
        std::string row;
        std::cin >> row;

        bool all = true;
        for (int j = 0; j < W; j++) {
            all = all && (row[j] == '.');
        }
        if (!all) a.push_back(row);
    }

    for (auto row : a) {
        for (int j = 0; j < W; j++) {
            bool all = true;
            for (auto row2 : a) {
                all = all && (row2[j] == '.');
            }
            if (!all) std::cout << row[j];
        }
        std::cout << std::endl;
    }

    return 0;
}


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

int main() {
  	int x, n;
    int t1 = 0;
  	int t2 = 101;
	int ans;


 	cin >> x >> n ;
    int f[100] ;
  //  int g[100-x-1] ;
  
  int p[n];
  if(n == 0)
  {ans = x;}
  else
  {
  	for(int i=0; i<n; i++) 
  	{
   	 cin >> p[i];
    }
    for(int k = 0; k<100 ; k++)
    {
      f[k] = k;
    }

    

    
    for(int j=0; j<n; j++) 
  	{

      	f[p[j]] = 10000;


    }
        for(int h = 0; h<x ; h++)
    {
    	if(f[h]!=10000){t1 = f[h];} 

    }
         for(int l = 100; l>=x ; l--)
    {
    	if(f[l]!=10000){t2= f[l];}   
    }
       


	if (x-t1 <= t2-x) 
	{ans = t1;}
    else
    {ans = t2;}
    
  }
  
	cout << ans << endl;
  
}



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

using namespace std;

int matrix[3][3];

int main() {

	for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            cin >> matrix[i][j];
        }
	}

	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
        int k; cin >> k;
        for(int j = 0; j < 3; ++j){
            for(int x = 0; x < 3; ++x){
                if(matrix[j][x] == k){
                    matrix[j][x] = -1;
                }
            }
        }
	}
	if(matrix[0][0] == - 1 && matrix[0][1] == -1 && matrix[0][2] == - 1){
        cout << "Yes";
        return 0;
	}else if(matrix[1][0] == - 1 && matrix[1][1] == -1 && matrix[1][2] == - 1){
        cout << "Yes";
        return 0;
	}else if(matrix[2][0] == - 1 && matrix[2][1] == -1 && matrix[2][2] == - 1){
        cout << "Yes";
        return 0;
	}else if(matrix[0][0] == - 1 && matrix[1][0] == -1 && matrix[2][0] == - 1){
        cout << "Yes";
        return 0;
	}else if(matrix[0][1] == - 1 && matrix[1][1] == -1 && matrix[2][1] == - 1){
        cout << "Yes";
        return 0;
	}else if(matrix[0][2] == - 1 && matrix[1][2] == -1 && matrix[2][2] == - 1){
        cout << "Yes";
        return 0;
	}else if(matrix[0][0] == - 1 && matrix[1][1] == -1 && matrix[2][2] == - 1){
        cout << "Yes";
        return 0;
	}else if(matrix[0][2] == - 1 && matrix[1][1] == -1 && matrix[2][0] == - 1){
        cout << "Yes";
        return 0;
	}else cout << "No";

	return 0;

}


Measured memory_bytes: 256
import itertools
import math
N=int(input())
T=[None]*N
for i in range(N):
    T[i] = list(map(int,input().split()))

seq=[i for i in range(N)]
kumi=list(itertools.permutations(seq))
L_sum=0
for i in range(len(kumi)):
    for j in range(N-1):
        L_sum+=math.sqrt((T[kumi[i][j]-1][0]-T[kumi[i][j+1]-1][0])**2+(T[kumi[i][j]-1][1]-T[kumi[i][j+1]-1][1])**2)
        #print(kumi[i][j],kumi[i][j+1])
        #,T[kumi[i][j+1]-1][0],T[kumi[i][j]-1][1],T[kumi[i][j+1]-1][1])
num=1
for i in range(1,N+1):
    num*=i
#print(L_sum)
print(L_sum/num)

Measured memory_bytes: 7972
t1, x1, y1 = 0, 0, 0

can = true
n = gets.chomp.to_i
n.times do
  t2, x2, y2 = gets.chomp.split.map(&:to_i)
  dist = (x1 - x2).abs + (y1 - y2).abs
  t = t2 - t1

  if t >= dist && t % 2 == dist % 2
    t1, x1, y1 = t2, x2, y2
  else
    can = false
    break
  end
end

puts can ? 'Yes' : 'No'

Measured memory_bytes: 3836
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=200;
struct Point{
    int x, y;
    Point(int x=0, int y=0):x(x), y(y) {}
    bool operator < (const Point &a) const{
        return y<a.y;
    }
}point[maxn+5];
int n;
bool map[maxn+5][maxn+5];

int main(void){
    scanf("%d", &n);
    for (int i=0, a, b; i<n; i++){
        scanf("%d%d", &a, &b);
        map[b][a]=true;
    }

    int cnt=0;
    for (int i=0, a, b; i<n; i++){
        scanf("%d%d", &a, &b);
        point[i]=Point(a, b);
    }sort(point, point+n);
    for (int i=0; i<n; i++){
        int a=point[i].x, b=point[i].y;
        bool ifbreak=false;
        for (int x=a-1; x>=0; x--){
            for (int y=b-1; y>=0; y--)
                if (map[y][x]) {cnt++; map[y][x]=false; ifbreak=true; break;}
            if (ifbreak) break;
        }
    }printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string tmps;
    vector<string>s[26][26];
    vector<string>s1;
    for(int i(0);i<n;i++){
        cin>>tmps;
        bool newpresent(true);
        if(tmps.size() == 1){
            for(int j(0);j<s1.size();j++){
                if(tmps == s1[j])newpresent = false;
            }
            if(newpresent)s1.push_back(tmps);
        }
        else{
            for(int j(0);j<s[(int)tmps[0]-97][(int)tmps[1]-97].size();j++){
                if(tmps == s[(int)tmps[0]-97][(int)tmps[1]-97][j]){
                    newpresent = false;
                    break;
                }
            }
             if(newpresent)s[(int)tmps[0]-97][(int)tmps[1]-97].push_back(tmps);
        }
    }
    int presentnum(s1.size());
    for(int i(0);i<26;i++){
        for(int j(0);j<26;j++){
            presentnum += s[i][j].size();
        }
    }
    cout<<presentnum<<endl;
    return 0;
}

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

using namespace std;
vector<long long> factors;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
vector<vector<ll>> matrix;
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b){
	vector<vector<ll>> res(a.size(),vector<ll>(b.size(),0));
	for(ll i = 0; i < a.size(); ++i){
		for(ll j = 0;j < a.size(); ++j){
			for(ll k = 0; k < a.size(); ++k){
				res[i][j] += a[i][k] * b[k][j];
				res[i][j]%=MOD;
			}
		}
	}
	return res;
}

vector<vector<ll>> pw(vector<vector<ll>> a,ll n){
	vector<vector<ll>> res(a.size(),vector<ll>(a.size(),0));
	for(ll i = 0;i < a.size(); ++i){
		for(ll j = 0; j < a.size(); ++j){
			if(i == j)
				res[i][j] = 1;
		}
	}
	while(n){
		if(n&1)
			res = mul(res,a);
		a = mul(a,a);
		n>>=1;
	}
	return res;
}

int main()
{
	IOS
	int n;
	cin >> n;
	ll k;
	cin >> k;
	vector<vector<ll>> a(n,vector<ll>(n));
	for(ll i = 0; i < n; ++i){
		for(ll j = 0; j < n; ++j){
			cin >> a[i][j];
		}
	}
	a = pw(a,k);
	ll res = 0;
	for(ll i = 0; i < n; ++i){
		for(ll j = 0;j < n;++j){
			res = (a[i][j] + res)%MOD;
		}
	}
	cout <<res;
	return 0;
}


Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

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

fn main(){
    let s: Vec<char> = read::<String>().chars().collect();
    let t: Vec<char> = read::<String>().chars().collect();
    let mut ans = false;
    let size = s.len();
    for i in 0..size {
        let mut po = true;
        for j in 0..size {
            if s[(i+j)%size] != t[j] {
                po = false;
                break;
            }
        }
        if po {
            ans = true;
        }
    }
    println!("{}", if ans {"Yes"} else {"No"});
}

Measured memory_bytes: 4352
<?php
$N = trim(fgets(STDIN));
$count = 0;
for($i = 3; $i <= $N; $i+=2){
    $c = 0;
    for($j = 1; $j <= $i; $j++){
        if($i % $j == 0)$c++;
    }
    if($c == 8)$count++;
}
echo $count;



Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>

using namespace std;

int main(void)
{
	set <string> s;
	vector <string> date;
	string temp1, temp2;
	int m, n;
	int i, j, k;


	cin >> m;

	for (i = 0; i < m; i++) {
		cin >> temp1;
		date.push_back(temp1);
	}


	for (i = 0; i < m; i++) {

		n = date[i].size() - 1;

		for (j = 0; j < n; j++) { //temp1??¨temp2????????????
			
			for (k = 0; k < n + 1; k++) {
			
				temp1 = date[i].substr(0, j + 1);

				temp2 = date[i].substr(j + 1, n - j);
	

				s.insert(temp1 + temp2);
				s.insert(temp2 + temp1);

				reverse(temp1.begin(), temp1.end());
				s.insert(temp1 + temp2);
				s.insert(temp2 + temp1);

				reverse(temp2.begin(), temp2.end());
				s.insert(temp1 + temp2);
				s.insert(temp2 + temp1);

				reverse(temp1.begin(), temp1.end());
				s.insert(temp1 + temp2);
				s.insert(temp2 + temp1);



				temp1.clear();
				temp2.clear();

			}




		}

		
		cout << s.size() << endl;


		s.clear();
	}
	

	return (0);
}

Measured memory_bytes: 3260
import queue
import math
import copy
"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
N = int(input())
A = [int(i) for i in input().split()]
T = sum(A)/2

b = 0
c = 0
m = 2020202021
for a in A:
	if b <= T:
		if m > (T-b)//0.5:
			m = (T-b)//0.5
	else:
		if m > (b-T)//0.5:
			m = (b-T)//0.5
	b += a
if b <= T:
	if m > (T-b)//0.5:
		m = (T-b)//0.5
else:
	if m > (b-T)//0.5:
		m = (b-T)//0.5
print(int(m))

Measured memory_bytes: 26936
def main(str)
  nm, as = str.split("\n").map { |x| x.split(" ").map(&:to_i) }
  _n, m = nm[0..1]
  sum = as.inject(&:+)
  as.count { |a| 4 * m * a >= sum } >= m
end

puts(main($stdin.read.chomp) ? 'Yes' : 'No')

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,a[2000010],l[2000010],r[2000010],s[2000010];
ll top=0;
ll ans=0;

signed main(){
	std::ios::sync_with_stdio(false);
	cin>>n;

	for(ll i=1;i<=n;i++){
		cin>>a[i];
		l[i]=0;
		r[i]=n+1;
	}
	for(ll i=1;i<=n;i++){
		while(top!=0&&a[s[top]]>a[i]){
			r[s[top]]=i;
			top--;
		}
		l[i]=s[top];
		top++;
		s[top]=i;	
	}
	for(ll i=1;i<=n;i++){
		ans+=(r[i]-i)*(i-l[i])*a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 14080
// #include <bits/stdc++.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
// static const int MOD = 998244353;
// static const int MAX = 100005;
// static const int ls = 101;
// static const int NMAX = 5005;
// static const lli INFTY = 1000000000000;

// typedef priority_queue<int, greater<int>> RevQ;
int n, t;
string s;
// lli l, r;
// lli gcd(lli a, lli b) {
//   return b ? gcd(b, a%b) : a;
// }

struct menu {
  int flag = 0;
  int v;
};

int main(){
  cin >> n >> t;
  vector<int> a(n), b(n);
  rep(i,n) {
    cin >> a[i] >> b[i];
  }
  menu dp[n+1][t];
  rep(i,n+1)rep(j,t) {
    dp[i][j].v = 0;
    // dp[i][j].flag.resize(n);
  }
  REP(i, 1, n+1) {
    rep(j, t) {
      int remain = dp[i-1][j].v;
      int add = 0;
      if (j >= a[i-1]) {
        add = dp[i-1][j-a[i-1]].v + b[i-1];
      }
      if (j >= a[i-1] && add > remain) { // equal is necessary?
        // cout << "added: " << i << " at time: " << j << " value: " << add << endl;
        dp[i][j].v = add;
        dp[i][j].flag = dp[i-1][j-a[i-1]].flag;
        dp[i][j].flag = 1;
      } else {
        dp[i][j].v = remain;
        dp[i][j].flag = 0;
      }
    }
  }

  int point = t-1;
  vector<int> intime(n);
  for(int i = n; i >= 1; i--) {
    if(dp[i][point].flag) {
      intime[i-1] = 1;
      point -= a[i-1];
    }
  }
  int maxv = 0;
  rep(i, n) {
    if (intime[i] == 0 && b[i] > maxv) {
      maxv = b[i];
    }
    // if (dp[n][t-1].flag[i]) {
    //   cout << i+1 << " ";
    // }
  }
  // cout << endl;
  // cout << "maxv: " << maxv << endl;
  cout << dp[n][t-1].v + maxv << endl;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll h,w,k;
char G[15][1005];

ll counter(ll x){
  if(x==0) return 0;
  return counter(x>>1)+(x&1);
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>h>>w>>k;
  rep(i,h){
    rep(j,w){
      cin>>G[i][j];
    }
  }
  
  ll ans=INF;
  for(ll bit=0; bit<(1<<(h-1)); bit++){
    ll yoko=counter(bit);
    vll borders;
    rep(i,h-1){
      if(bit&(1<<i)){
        borders.push_back(i+1);
      }
    }
    borders.push_back(h);
    vll cntByBlock(borders.size());
    ll tate=0;
    
    bool ok=true;
    rep(i,w){
      rep(j,borders.size()){
        ll start=0;
        if(j>0) start=borders[j-1];
        
        ll cnt=0;
        irep(ki,start,borders[j]){
          if(G[ki][i]=='1'){
            cnt++;
          }
        }
        if(cnt>k){
          ok=false;
          break;
        }else{
          if(cntByBlock[j]+cnt>k){
            tate++;
            rep(kj,cntByBlock.size()) cntByBlock[kj]=0;
            i--;
            break;
          }else{
            cntByBlock[j]+=cnt;
          }
        }
      }
      if(!ok) break;
    }
    
    if(ok) chmin(ans,yoko+tate);
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

u64 mm(u64 _a, u64 _b)
{
  u64 a = _a, b = _b;
  while (b>0) {
    u64 bt = b;
    b = a%b;
    a = bt;
  }
  return _a / a * _b;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  u64 t[n];
  for (int i = 0; i < n; ++i) cin >> t[i];
  if (n==1) {
    cout << t[0] << endl;
    return 0;
  }
  u64 m = mm(t[0], t[1]);
  for (int i = 2; i < n; ++i) m = mm(m, t[i]);
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	string S;
	cin >> N;
	cin >> S;
	vector<int> A(N + 1);
	A[0] = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'E') {
			A[i + 1] = 1;
		}
		else {
			A[i + 1] = 0;
		}
	}
	for (int i = 0; i < N; i++) {
		A[i + 1] += A[i];
	}

	int res = N + 1;
	int a;
	for (int i = 0; i < N; i++) {
		a = i - A[i];
		a += A[N] - A[i + 1];
		res = min(res, a);
	}

	cout << res << endl;
}

Measured memory_bytes: 2964
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int x,int y,int z)
{
    int maxx=max(max(x,y),z);
    for(int i=maxx;i>=1;i--)
        if(x%i==0 && y%i==0 && z%i==0) return i;
    return 1;
}

int main()
{
    int n;
    cin>>n;
    ll sum=0;
    ll t=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            for(int k=1;k<=j;k++)
            {
                t=gcd(i,j,k);
                if(i==j && j==k)
                    sum+=t;
                else if(i!=j && i!=k && j!=k)
                    sum+=t*6;
                else
                    sum+=t*3;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3636
/*




0516: maximum sum




*/




#include <stdio.h>




#define N 100000




int getMaximumSum(int array[], int n, int k);




int main(void){
	
	int i;
	int n, k;
	int sum;
	int array[N];
	
	while(1){
		
		scanf("%d %d", &n, &k);
		
		if(!n && !k){
			
			break;
			
		}
		
		for(i=0; i<n; i++){
			
			scanf("%d", &array[i]);
			
		}
		
		sum = getMaximumSum(array, n, k);
		
		printf("%d\n", sum);
		
	}
	
	return 0;
	
}








int getMaximumSum(int array[], int n, int k){
	
	int ret = 0;
	int temp = 0;
	int i, m;
	
	for(i=0; i<=n-k; i++){
		
		m = 0;
		//temp = 0;
		
		if(i > 0){
			
			temp -= array[i-1];
			temp +=array[i+k-1];
			
			if(ret < temp){
				
				ret = temp;
				
			}
			
		}
		else{
			
			while(m < k){
				
				temp += array[i+m];
				m++;
				
			}
			
			if(ret < temp){
				
				ret = temp;
				
				
			}
			
			
		}
	}
	
	return ret;
	
}

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

int main(){
	ll N;
	cin >> N;
	vector<ll> a(N);
	ll S(0);
	for(ll i(0);i<N;++i){
		cin >> a[i];
		S += a[i];
	}
	vector<vector<ll>> R(N, vector<ll>(S+1, 0));
    R[0][a[0]] = 1;
    R[0][0] = 2;
	for(ll t(1);t<N;++t){
        for(ll r(0);r<S+1;++r){
            R[t][r] = 2 * R[t-1][r];
            if(r-a[t] >= 0) R[t][r] += R[t-1][r-a[t]];
            R[t][r] %= NUM;
        }
    }
    ll R_cnt(0), RG_cnt(0);
    for(ll t=(S+1)/2; t<S+1; ++t) R_cnt += R[N-1][t]%NUM;

    if(S % 2 == 0){
        vector<vector<ll>> RG(N, vector<ll>(S+1, 0));
        RG[0][0] = RG[0][a[0]] = 1;
        for(ll t(1);t<N;++t){
            for(ll r(0);r<S+1;++r){
                RG[t][r] = RG[t-1][r];
                if(r-a[t] >= 0) RG[t][r] += RG[t-1][r-a[t]];
                RG[t][r] %= NUM;
            }
        }
        RG_cnt = RG[N-1][S/2];
    }
    ll ans(1);
    for(int i(0);i<N;++i){
        ans *= 3;
        ans %= NUM;
    }
    ans = ans - 3 * R_cnt % NUM + 3 * RG_cnt %NUM;
    if(ans < 0) cout << ans + NUM <<endl;
    else cout << ans%NUM << endl;
	return 0;
}

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

#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    int H, W, N;
    cin >> H >> W >> N;
    if (N % max(H, W) == 0){
        cout << N / max(H, W);
    } else {
        cout << 1 + N / max(H, W);
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[][] F = new int[N][10];
		int[][] P = new int[N][10];

		for (int i = 0; i < N; i++) {
			F[i] = nextIntArray(sc, 10);
		}
		for (int i = 0; i < N; i++) {
			P[i] = nextIntArray(sc, 11);
		}

		sc.close();

		long ans = Long.MIN_VALUE;

		for (int a = 1; a <= 1023; a++) {

			int[] c = new int[N]; //店ごとの、joisinoと同時に空いている時間帯の数。
			for (int i = 0; i < N; i++) { //店iについて
				for (int k = 0; k < 10; k++) {
					int b = (a >> k) & 0x1; //joisinoがあいてるか
					if (b == 1 && F[i][k] == 1) {
						c[i]++;
					}
				}
			}

			long sum = 0;
			for (int i = 0; i < N; i++) {
				sum += P[i][c[i]];
			}

			ans = Math.max(ans, sum);
		}

		out.println(ans);

	}

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

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 26096
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;

int main() {
    string s;
    while (getline(cin, s), s != "0") {
        stringstream ss(s);
        int n, sum = 0, one = 0;
        while (ss >> n) {
            sum += (10 <= n ? 10 : n);
            if (n == 1) ++ one;
        }
        int res = 0;
        for (int i=0; i<=one; ++i) {
            if (21 < sum + 10 * i) break;
            res = max(res, sum + 10 * i);
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1224
// In the name of God

#include <bits/stdc++.h>

using namespace std;

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

	int n;
	cin >> n;

	n %= 10;

	if(n == 3) cout << "bon";
	else if(n==0||n==1||n==6||n==8) cout << "pon";
	else cout << "hon";
	
	return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[100005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    long n = strlen(str);

    if(str[n-1]=='1' || str[0]=='0') {
        printf("-1\n"); return 0;
    }

    long i;
    for(i=0; i<n/2; i++) {
        if(str[i]!=str[n-2-i]) {
            printf("-1\n"); return 0;
        }
    }

    long curr=1;
    for(i=0; i<n-1; i++) {
        printf("%ld %ld\n", curr, i+2);
        if(str[i]=='1' && i<=(n-1)/2) curr=i+2;
    }

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;
int test[123456];
int main() {
	int n;
	int b = 0;
	int c = 0;
	int ans = 1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> test[i];
	}
	for (int h = 0; h < n - 1; h++) 
	{
		if (test[h] < test[h + 1])
		{
			if (c > 0) 
			{ 
				c = 0; 
				ans++;
			}
			else
			{
				 b++;
			}
		}
		if (test[h] > test[h + 1]) {
			if (b > 0) 
			{
				b = 0; 
				ans++;
			}
			else 
			{
				c++; 
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
    public class Main {
        public static int M = 1046527;
        public static char H[][] = new char[M][14];
        public static char x[] = new char[14];
        public static void main(String[] args) {
            Scanner scan = new Scanner(System.in);
            int N = scan.nextInt();
            String cmd, s;
            for(int i = 0; i < N; i++) {
                char []str = new char[14];
                cmd = scan.next();
                s = scan.next();
                for(int j = 0; j < s.length(); j++) {
                    str[j] = s.charAt(j);
                }
                if(cmd.charAt(0) == 'i') {
                    insert(str);
                }else {
                    if(find(str) == 1) {
                        System.out.println("yes");
                    }else {
                        System.out.println("no");
                    }
                }
            }
            scan.close();
        }
        public static int getChar(char ch) {
            if(ch == 'A') return 1;
            else if(ch == 'C') return 2;
            else if(ch == 'G') return 3;
            else if(ch == 'T') return 4;
            else return 0;
        }
        public static long getKey(char []str) {
            long sum = 0;
            long p = 1;
            for(int i = 0; i < 14; i++) {
                sum += p * (getChar(str[i]));
                p *= 5;
            }
            return sum;
        }
        public static int find(char []str) {
            long key = getKey(str);
            int h;
            for(int i = 0;; i++) {
                h = (h1(key) + i * h2(key)) % M;
                if(isCheck(H[h], str)) return 1;
                else if(H[h][0]== x[0]) return 0;
            }
        }
        public static boolean isCheck(char[] c1, char[] c2) {
            for(int i = 0; i < 14; i++) {
                if(c1[i] != c2[i]) {
                    return false;
                }
            }
            return true;
        }
        public static void strcpy(char[] c1, char[] c2) {
            for(int i = 0; i < 14; i++) {
                c1[i] = c2[i];
            }
        }
        public static int insert(char str[]) {
            long key = getKey(str);
            int h;
            for(int i = 0;; i++) {
                h = (h1(key) + i * h2(key)) % M;
                if(isCheck(H[h], str)) return 1;
                else if(H[h][0]== x[0]) {
                    strcpy(H[h], str);
                    return 0;
                }
            }
        }
        public static int h1(long key) {
            return (int)(key % M);
        }
        public static int h2(long key) {
            return (int)(key % (M - 1));
        }
        public static void disp(char []c) {
            for(int i = 0; i < 14; i++) {
                System.out.print(c[i]);
            }
            System.out.println();
        }
    }


Measured memory_bytes: 373332
//
//  main.cpp
//  D - Five, Five Everywhere
//
//  Created by 张栩浩 on 2018/5/6.
//  Copyright © 2018年 张栩浩. All rights reserved.
//
/*
#include <iostream>
using namespace std;
#define maxn 500000
bool isprime[maxn];
int primenum[maxn];
int cntl;
int n;
int ans[1000];
void Eratosthenes()
{
    memset(isprime,true,sizeof(isprime));
    isprime[1]=false;
    for(int i=2;i<=maxn/i;i++)
        if(isprime[i])
            for(int j=i*i;j<=maxn;j+=i)
                isprime[j]=false;
    for (int i=2;i<=maxn;i++)
    {
        if(isprime[i])
            primenum[cntl++]=i;
    }
}
bool dfs(int i,int sum,int j)
{
    if(i==n&&!isprime[sum])
    {
        return true;
    }
    else if(i==n)
        return false;
    if(dfs(i+1, sum+primenum[j+1], j+1))
        ans[i+1]=primenum[j+1];
    return false;
}
int main()
{
    cin>>n;
    Eratosthenes();
    if(dfs(0, 0+primenum[0], 0))
        ans[0]=primenum[0];
    for(int i=0;i<n;i++)
    {
        cout<<ans[i]<<endl;
    }
    return 0;
}
*/
#include <iostream>
using namespace std;

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

int n;

int main() {
    cin >> n;
    for (int i = 31; i <= 55555; i += 30) {
        if (isprime(i) == true) {
            if (i != 31) cout << " ";
            cout << i; n--;
        }
        if (n == 0) break;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
	final static int ICE_TEA_COUNT = 4;
	final static double SHORT_TEA = 0.25;
	public static void main(String[] args)throws Exception {
		BufferedReader br = new BufferedReader ( new InputStreamReader(System.in));
		String [] input = br.readLine().split(" ");
		String  input2 = br.readLine();
		long [] iceTeaList = new long[4];
		for(int i = 0;i<ICE_TEA_COUNT ;i++) {
			iceTeaList[i] = Integer.parseInt(input[i]);
		}

		int max = Integer.parseInt(input2);
		long [] resultTea = new long[4];
		int multiple = 2;
		long beforeResult = 1;
		boolean continueFlag = false;
		int point = 0;
		resultTea[0] = (long)( max / SHORT_TEA);
		for(int i = 0;i<ICE_TEA_COUNT-1 ;i++) {
			if(beforeResult == 0) {
				continueFlag = true;
			}else if(iceTeaList[i+point]*multiple > iceTeaList[i+1]) {
				resultTea[i+1] = resultTea[i+point]/multiple;
				resultTea[i+point] = resultTea[i+point]%multiple;
				continueFlag = false;
				point = 0;
				multiple = 2;
			}
			if(continueFlag) {
				point -= 1;
				multiple *=2;
				if(i+point >= 0) {
					beforeResult = (long)resultTea[i+point];
					i -= 1;
				}else {
					beforeResult = 1;
				}
			}else {
				beforeResult = resultTea[i+1];
			}
		}
		long resultValue=0;
		for(int i =0 ; i<ICE_TEA_COUNT;i++) {
			resultValue += resultTea[i] * iceTeaList[i];
		}
		System.out.println(resultValue);
	}
}

Measured memory_bytes: 23124
MOD = 10**9+7
def pow(a, b):
    res = 1
    while b:
        if b & 1: res = res * a % MOD
        a = a**2 % MOD
        b >>= 1
    return res
    
m, n = list(map(int, input().split()))
print(pow(m, n))


Measured memory_bytes: 5600
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
typedef long long ll;

int main() {
  int A, P;
  cin >> A >>P;
  P += A*3;
  printf("%d\n", P/2);
}


Measured memory_bytes: 256
S = input()
l = len(S)
ans = 0
for i in range(1<<(l-1)):
    s = 0
    tmp = 0
    for j in range(l):
        tmp = tmp*10+int(S[j])
        if i >> j & 1:
            s += tmp
            tmp = 0
    ans += s + tmp
print(ans)

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

int n,a,b,c;
int ls[8];

int use_a[8]={0};
int find_best2() {
    int res = INT_MAX;
    for (int i = 1; i < pow(4, n); ++i) {
        int carry=1;
        for (int y=0;y<n;y++) {
            use_a[y] += carry;
            if (use_a[y] > 3) {
                use_a[y] = 0;
                carry = 1;
            } else {
                carry=0;
            }
        }
        int ca=0,cb=0,cc=0, lena=0, lenb=0,lenc=0;
        for (int x = 0; x < n; ++x) {
            if(use_a[x] == 1) {
                lena += ls[x];
                ca++;
            }
            else if(use_a[x] == 2) {
                lenb += ls[x];
                cb++;
            }
            else if(use_a[x] == 3) {
                lenc += ls[x];
                cc++;
            }
        }
        if (ca == 0 || cb == 0 || cc == 0) continue;
        int cost = ((a>lena)?a-lena:lena-a) + 10 * (ca-1);
        cost += ((b>lenb)?b-lenb:lenb-b) + 10 * (cb-1);
        cost += ((c>lenc)?c-lenc:lenc-c) + 10 * (cc-1);
        if (cost < res) {
            res = cost;
        }
    }
    return res;
}

int main(int argc, char *argv[])
{
    scanf("%d %d %d %d", &n,&a,&b,&c);
    for (int i = 0; i < n; ++i) {
        scanf("%d", ls+i);
    }
    printf("%d\n", find_best2());
    return 0;
}


Measured memory_bytes: 128
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if (a == b && b == c && c == a)
    puts("1");
  else if (a == b || b == c || c == a)
    puts("2");
  else
    puts("3");
  return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int h, w, n;
int sr, sc;
std::string s[2];
int main() {
	std::cin >> h >> w >> n;
	std::cin >> sr >> sc;
	std::cin >> s[0] >> s[1];

	int l = sc, r = sc, u = sr, d = sr;
	for (int j = 0; j < n; ++j)
		for (int i = 0; i < 2; ++i) {
			auto tmp = s[i][j];

			switch (tmp)
			{
			case 'L':
				if (i == 0)
					--l;
				else
					r = std::max(r - 1, 1);
				break;
			case 'R':
				if (i == 0)
					++r;
				else
					l = std::min(l + 1, w);
				break;
			case 'U':
				if (i == 0)
					--u;
				else
					d = std::max(d - 1, 1);
				break;
			case 'D':
				if (i == 0)
					++d;
				else
					u = std::min(u + 1, h);
				break;
			}

			if (l < 1 || r > w || u < 1 || d > h) {
				std::cout << "NO" << std::endl;
				return 0;
			}
		}

	std::cout << "YES" << std::endl;
	return 0;
}


Measured memory_bytes: 776
#include<stdio.h>

int main(void){

	int n;

	scanf("%d",&n);

	switch(n%10){
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		printf("hon\n");
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		printf("pon\n");
		break;
	case 3:
		printf("bon\n");
		break;
	}


	return 0;
}


Measured memory_bytes: 1644
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n, l;
    cin >> n >> l;
    int init = 0;
    int eat = l;
    for (int i = 0; i < n; ++i) {
        int temp = l + i;
        init += temp;
        if (abs(temp) < abs(eat))
            eat = temp;
    }
    cout << init - eat << "\n";

    return 0;
}

Measured memory_bytes: 256
N = int(input())
d = {}
for i in range(N):
    s = str(input())
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
M = int(input())
for i in range(M):
    s = str(input())
    if s in d:
        d[s] -= 1
    else:
        d[s] = -1

if max(d.values()) < 0:
    print(0)
else:
    print(max(d.values()))


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = 998244353ll;

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<ll> r,g,b;
int a[334334];

int main(void){
	int n,m,i,j,x,y,z;
	ll ans = 1ll;
	string s;
	cin >> n; m = n*3;
	for(i=1; i<=n; ++i){
		mul_mod(ans,i);
	}
	cin >> s;
	for(i=0; i<m; ++i){
		switch(s[i]){
			case 'R':
			r.push_back(i);
			break;

			case 'G':
			g.push_back(i);
			break;

			case 'B':
			b.push_back(i);
			break;
		}
	}
	for(i=0; i<n; ++i){
		x = min({r[i],g[i],b[i]});
		z = max({r[i],g[i],b[i]});
		y = r[i]+g[i]+b[i]-x-z;
		a[x] = 0;
		a[y] = 1;
		a[z] = 2;
	}
	x = 0; y = 0; z = 0;
	for(i=0; i<m; ++i){
		switch(a[i]){
			case 0:
			++x;
			break;

			case 1:
			mul_mod(ans,x);
			--x; ++y;
			break;

			case 2:
			mul_mod(ans,y);
			--y; ++z;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4596
#include <iostream>
#include <string>

using namespace std;

signed main(void)
{
  int len;
  string s;
  bool flag = true;

  cin >> s;

  len = s.length();
  for (int i = 0; i < len; i++) {
    for (int j = 0; j < len; j++) {
      if (s[i] == s[j] && i != j) {
        flag = false;
        break;
      }
    }
  }

  if (flag) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }

  return (0);
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def solve():
  h,n = (int(i) for i in input().split())
  query = []
  for i in range(n):
    a,b = (int(i) for i in input().split())
    query.append((a,b))
  ap = [10**9+7]*(h+10003)
  ap[0] = 0
  for i in range(h+1):
    nowap = ap[i]
    for a,b in query:
      if i+a <= h+10001:
        ap[i+a] = min(ap[i+a],nowap+b)
      else:
        continue
  ans = 10**9+7
  for i in range(h,h+10001):
    ans = min(ans,ap[i])
  print(ans)

solve()

Measured memory_bytes: 40400
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
   string s;
   cin>>s;
   int l=s.size();
   int ans=1000;
   for(int i=0;i<l-1;i++){
      string part=s.substr(i,3);
      int a=stoi(part);
      int sa=abs(a-753);
      ans=min(ans,sa);
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256