akhauriyash/Code-Regression huggingface dataset:
/* author:hellojim */
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	string s;
	cin>>s;
	if(s[s.size()-1]=='s')s+="es";
	else s+='s';
	cout<<s<<endl; 
	return 0;
}



Measured memory_bytes: 3664
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const N_MAX = 100000;

int N;
ll a[N_MAX + 1];

int main() {
  scanf("%d", &N);

  rep(i, N) {
    scanf("%lld", &a[i]);
  }
  sort(a, a + N);

  ll count = 0;
  ll l_count = 0;
  ll bef = a[0];
  rep(i, N) {
    ll x = a[i];
    if (x > N) {
      count++;
      continue;
    }
    if (bef == x) {
      l_count++;
    } else {
      if (bef == l_count) {
        //
      } else if (bef < l_count) {
        count += l_count - bef;
      } else {
        count += l_count;
      }
      l_count = 1;
      bef = x;
    }
  }
  if (bef < l_count) {
    count += l_count - bef;
  } else if (bef > l_count) {
    count += l_count;
  }
  printf("%lld\n", count);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,c=0,t;
    double t1;
    string s,s1,s2;
    cin>>s>>s1;
    s2 = s+s1;
    n = stoi(s2);
    t = sqrt(n);
    t1 = sqrt(n);
    if(t==t1)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }



}


Measured memory_bytes: 256
##knapsackProblem
n, w = map(int, input().split())
vw = [list(map(int, input().split())) for _ in range(n)]

dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]

for i in range(n + 1):
    for j in range(w + 1):
        if j == 0:
            dp[i][j] = 0
        elif i == 0:
            dp[i][j] = 0
        else:
            if j - vw[i - 1][1] >= 0:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - vw[i - 1][1]] + vw[i - 1][0])
            else:
                dp[i][j] = dp[i - 1][j]

ans = 0
for i in range(n + 1):
    ans = max(ans, max(dp[i]))

print(ans)


Measured memory_bytes: 16132
S = input()
T = input()


    
if True:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
    if tmp == -1:
        print('UNRESTORABLE')
    else:
        res = ''
        count = 0
        for i in range(len(S)):
            if tmp <= i < tmp + len(T):
                res += T[count]
                count += 1
            elif S[i] == '?':
                res += 'a'
            else:
                res += S[i]

        print(res)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;


bool alpha[1000];
int main(void){
  string s;
  cin>>s;
  if(s.size()!=26){
    for(int i=0;i<s.size();i++){
      alpha[s[i]]=true;
    }
    for(int i='a';i<='z';i++){
      if(!alpha[i]){
	s+=(char)(i);
	cout<<s<<endl;
	break;
      }
    }
  }
  else if(s=="zyxwvutsrqponmlkjihgfedcba") cout<<-1<<endl;
  else{
    for(int i=s.size()-1;i>0;i--){
      if(s[i-1]>s[i]){
	continue;
      }
      else{
	int tmp=s[i];
	for(int j=i+1;j<s.size();j++){
	  if(s[i-1]<s[j]) tmp=min(tmp,(int)s[j]);
	}
	
	cout<<s.substr(0,i-1)<<(char)tmp<<endl;
	break;
      }
    }
  }
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string a, b;
    cin >> a >> b;
    if(a[1] == b[1] && a[0] == b[2] && a[2] == b[0]) cout << "YES";
    else cout << "NO";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
class Main
{
	public static void main(String args[])
	{
		HashMap<Character, String> codeMap = new HashMap<Character, String>();
		codeMap.put('A', "00000");
		codeMap.put('B', "00001");
		codeMap.put('C', "00010");
		codeMap.put('D', "00011");
		codeMap.put('E', "00100");
		codeMap.put('F', "00101");
		codeMap.put('G', "00110");
		codeMap.put('H', "00111");
		codeMap.put('I', "01000");
		codeMap.put('J', "01001");
		codeMap.put('K', "01010");
		codeMap.put('L', "01011");
		codeMap.put('M', "01100");
		codeMap.put('N', "01101");
		codeMap.put('O', "01110");
		codeMap.put('P', "01111");
		codeMap.put('Q', "10000");
		codeMap.put('R', "10001");
		codeMap.put('S', "10010");
		codeMap.put('T', "10011");
		codeMap.put('U', "10100");
		codeMap.put('V', "10101");
		codeMap.put('W', "10110");
		codeMap.put('X', "10111");
		codeMap.put('Y', "11000");
		codeMap.put('Z', "11001");
		codeMap.put(' ', "11010");
		codeMap.put('.', "11011");
		codeMap.put(',', "11100");
		codeMap.put('-', "11101");
		codeMap.put('\'', "11110");
		codeMap.put('?', "11111");
		HashMap<String, Character> charMap = new HashMap<String, Character>();
		charMap.put("101", ' ');
		charMap.put("000000", '\'');
		charMap.put("000011", ',');
		charMap.put("10010001", '-');
		charMap.put("010001", '.');
		charMap.put("000001", '?');
		charMap.put("100101", 'A');
		charMap.put("10011010", 'B');
		charMap.put("0101", 'C');
		charMap.put("0001", 'D');
		charMap.put("110", 'E');
		charMap.put("01001", 'F');
		charMap.put("10011011", 'G');
		charMap.put("010000", 'H');
		charMap.put("0111", 'I');
		charMap.put("10011000", 'J');
		charMap.put("0110", 'K');
		charMap.put("00100", 'L');
		charMap.put("10011001", 'M');
		charMap.put("10011110", 'N');
		charMap.put("00101", 'O');
		charMap.put("111", 'P');
		charMap.put("10011111", 'Q');
		charMap.put("1000", 'R');
		charMap.put("00110", 'S');
		charMap.put("00111", 'T');
		charMap.put("10011100", 'U');
		charMap.put("10011101", 'V');
		charMap.put("000010", 'W');
		charMap.put("10010010", 'X');
		charMap.put("10010011", 'Y');
		charMap.put("10010000", 'Z');
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext())
		{
			String str = sc.nextLine();
			int length = str.length();
			StringBuffer codeBuf = new StringBuffer();
			for (int i = 0; i < length; i++)
			{
				codeBuf.append(codeMap.get(str.charAt(i)));
			}
			length = codeBuf.length();
			LOOP1: for (int i = 5, j = 0; i <= length;)
			{
				for (int k = i; j < k; k--)
				{
					Character a;
					try
					{
						a = charMap.get(codeBuf.substring(j, k));
					}
					catch (Exception e)
					{
						break;
					}
					if (a != null)
					{
						System.out.print(a);
						j = k;
						continue LOOP1;
					}
				}
				for (int k = i + 1; k <= length; k++)
				{
					Character a;
					try
					{
						a = charMap.get(codeBuf.substring(j, k));
					}
					catch (Exception e)
					{
						break;
					}
					if (a != null)
					{
						System.out.print(a);
						j = k;
						i = i + 5;
						continue LOOP1;
					}
				}
				i = i + 5;
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e9

signed main()
{
    int n,m;
    cin >> n >> m;
    int ans = n;
    int a;
    for(int i = 0;i < m;i++){
        cin >> a;
        ans -= a;
    }

    if(ans < 0)
        cout << -1 << endl;
    else
        cout << ans << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct f{char n[21];int m[9],t;double x;}f;
f F[50];
int N,i,j;
int c(const void *a,const void *b)
{
	if((*(f*)a).x==(*(f*)b).x)
		return strcmp((*(f*)a).n,(*(f*)b).n);
	return (*(f*)a).x-(*(f*)b).x>0?-1:1;
}
int main()
{
	for(;scanf("%d\n",&N),N;)
	{
		for(i=0;i<N;i++)
		{
			scanf("%s",F[i].n);
			for(j=0;j<9;j++)
				scanf("%d",&F[i].m[j]);
			F[i].t=(F[i].m[4]+F[i].m[5])*F[i].m[8];
			F[i].t+=F[i].m[1]+F[i].m[2]+F[i].m[3];
			F[i].x=((double)(F[i].m[6]*F[i].m[7]*F[i].m[8]-F[i].m[0])/F[i].t);
		}
		qsort(F,N,sizeof(f),c);
		for(i=0;i<N;i++)
			puts(F[i].n);
		puts("#");
	}
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

int sub_sum(int x0, int y0, int x1, int y1, const vector<VI>& v) {
    return v[x1][y1] - v[x1][y0] - v[x0][y1] + v[x0][y0];
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<VI> black_cnt(2 * k, VI(2 * k, 0));
    REP(i, n) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'B') black_cnt[x % (2 * k)][y % (2 * k)]++;
        else black_cnt[(x + k) % (2 * k)][y % (2 * k)]++;
    }

    vector<VI> cnt_sum(4 * k + 1, VI(4 * k + 1, 0));
    FOR(i, 1, 4 * k)FOR(j, 1, 4 * k) cnt_sum[i][j] = black_cnt[(i - 1) % (2 * k)][(j - 1) % (2 * k)];
    FOR(i, 1, 4 * k)FOR(j, 1, 4 * k) cnt_sum[i][j] += cnt_sum[i - 1][j];
    FOR(i, 1, 4 * k)FOR(j, 1, 4 * k) cnt_sum[i][j] += cnt_sum[i][j - 1];

    int ans = 0;
    FOR(i, 0, k * 2)FOR(j, 0, k * 2) {
        int cnt = sub_sum(i, j, i + k, j + k, cnt_sum);
        // cnt += sub_sum(0, 0, i, j, cnt_sum);
        cnt += sub_sum(i + k, j + k, i + 2 * k, j +2 * k, cnt_sum);
        // cnt += sub_sum(0, j + k, i, 2 * k, cnt_sum);
        // cnt += sub_sum(i + k, 0, 2 * k, j, cnt_sum);
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 78720
#include <algorithm>
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

#include <map>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  const int m = getInt();
  vector<int> v(n, 0);

  REP(i,m){
    const int a = getInt();
    const int l = getInt();
    REP(j,l) v[(a + j) % n] = 1;
  }

  int zp = -1;
  REP(i,n) if(v[i] == 0) zp = i;

  map<int, int> memo;
  if(zp == -1){
    printf("%d 1\n", n);
  }else{
    int c = 0;

    REP(i,n + 1){
      const int cc = v[(zp + i) % n];
      if(cc == 1){
        ++c;
      }else{
        if(c) memo[c]++;
        c = 0;
      }
    }

    vector<pair<int, int> > ans;
    FOR(it, memo) ans.push_back(*it);
    sort(ans.rbegin(), ans.rend());

    REP(i,ans.size())
      printf("%d %d\n", ans[i].first, ans[i].second);
  }

  return 0;
}


Measured memory_bytes: 1036
#include<stdio.h>

int main(void){
    int x,i=1;
    
    scanf("%d",&x);
    while(1){
        printf("Case %d: %d\n",i,x);
        i++;
        scanf("%d",&x);
        if(x==0){
            break;
        }
    }
    
    return 0;
}


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

int main() {
  int n,ans=0; cin >> n;
  rep(i,n){
    int l,r; cin >> l >> r;
    ans += (r-l+1);
  }
  cout << ans << endl;
}

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

int main() {
  int N, X, ret = 0;
  cin >> N >> X;
  int m, m_min = 1000;
  for (int i = 0; i < N; i++) {
    cin >> m;
    X -= m;
    m_min = min(m_min, m);
  }
  cout << N + int(X / m_min) << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	int t1 = (int)(N/1.08);
	int t2 = t1 + 1;

	if( N <= t1 * 1.08 &&  t1*1.08 <(N+1)){
		cout << t1 << endl;
		return 0;
	}else if(N <= t2 * 1.08 &&  t2*1.08 <(N+1)){
		cout << t2 << endl;
		return 0;
	}else{
		cout << ":(" << endl;
		return 0;
	}

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  	char s[3], t[3];
  	int i, cnt;
  
  	scanf("%s",s);
  	scanf("%s",t);
  
  	for(i = 0; i < 3; i++){
      	if(s[i] == t[i]){
          	++cnt;
        }
    }

  	printf("%d",cnt);
  
  	return 0;
}

Measured memory_bytes: 128
n,q=[int(i) for i in input().split()]
nt=[[c for c in input().split()] for i in range(n)]
for i in range(n):
    nt[i][1]=int(nt[i][1])
t=0
while len(nt)>0:
    p=nt.pop(0)
    if p[1]<=q:
        t+=p[1]
        print(p[0],t)
    else:
        t+=q
        p[1]-=q
        nt.append(p)


Measured memory_bytes: 13780
#include <iostream>
using namespace std;
int main() {
	char X;
	cin >> X;
	
	if (X == 'a' || X == 'i' || X == 'u' || X == 'e' || X == 'o') {
		cout << "vowel" << endl;
	}
	
	else {
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 3560
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
const double INF=1e9;
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int>out(m+1,0);
  rep(i,n){
    int a,b;
    cin>>a>>b;
    loop(j,b,m+1)out[j]=max(out[j],out[j-b]+a);
  }
  cout<<out[m]<<endl;
}

Measured memory_bytes: 1236
#include<stdio.h>

int main(){
  int n, i, j, minj, tmp, cnt = 0, flag;
  scanf("%d", &n);

  int array[n];
  for(i = 0; i < n; i++) scanf("%d", &array[i]);

  for(i = 0; i < n; i++){
    minj = i;
    flag = 0;
    for(j = i; j < n; j++){
      if(array[j] < array[minj]) {
	minj = j;
	flag = 1;
      }
    }
    if(flag == 1){
      tmp = array[i];
      array[i] = array[minj];
      array[minj] = tmp;
    
      cnt++;
    }
  }

  for(i = 0; i < n; i++){
    if(i == n-1) printf("%d\n",array[i]);
    else printf("%d ",array[i]);
  }
  printf("%d\n",cnt);

  return 0;
}



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

int main() {
	int n,a,b;
	string s;
	int t1=0,t2=0;
	cin >> n >> a >> b >> s;
	for(int i=0;i<n;i++){
		if((s[i]=='a')&&((t1+t2)<(a+b))){
			cout << "Yes" << endl;
			t1++;
		}
		else if((s[i]=='b')&&(t2<b)&&((t1+t2)<(a+b))){
			cout << "Yes" << endl;
			t2++;
		}
		 else cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


int main()
{
  ll n;
  cin >> n;
  ll ans = 0;
  vector<int> vec(n+1, 0);
  for(ll i = 1; i <= n; i++) {
    ll tmp = n/i;
    ans += i * (tmp*(tmp+1)/2);
  }
  cout << ans << endl;
  return 0;
}

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

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

  if (A >= 499) {
    cout << "Yes" << endl;
  }
  else if ( (N % 500) <= A) {
    cout << "Yes" << endl; 
  }
  else {cout << "No" <<  endl;
  }
}

Measured memory_bytes: 3516
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int c[2][100005]={0};
set<pii> s[2];

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;

rep(i,1,n)
{
	int x;
	cin>>x;
	c[i%2][x]++;
}

rep(i,1,100004)
{
	s[0].insert(mp(-c[0][i],i));
	s[1].insert(mp(-c[1][i],i));
}

set<pii> :: iterator it=s[0].begin(),it1=s[1].begin(),it2=it,it3=it1;

if(it->ss!=it1->ss)
{
	ol(n+it->ff+it1->ff);
	return 0;
}

it2++;
it3++;

ol(min(n+it->ff+it3->ff,n+it2->ff+it1->ff));

return 0;
}



Measured memory_bytes: 10368
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>

#define INF 100000001
using namespace std;
typedef long long ll;

int main() {
	int n;
	string s;
	cin >> n >> s;
	reverse(s.begin() + n, s.end());
	//for (auto itr = s.begin(); itr != s.end(); itr++) {
	//	cout << *itr << " ";
	//}
	//cout << " " << endl;
	map<pair<string, string>, ll> map, map1;
	for (int i = 0; i < (1 << n); i++) {
		string s1, s2, t1, t2;
		for (int j = 0; j < n; j++) {
			if (i&(1 << j)) {
				s1.push_back(s[j]);
				t1.push_back(s[n + j]);
			}
			else {
				s2.push_back(s[j]);
				t2.push_back(s[n + j]);
			}
		}
		map[make_pair(s1, s2)]++;
		map1[make_pair(t1, t2)]++;
	}
	ll ans = 0;
	/*for (auto itr = map.begin(); itr != map.end(); itr++) {
		cout << itr->first.first << " " << itr->first.second << " " << itr->second << endl;
	}
	cout << endl;
	for (auto itr = map1.begin(); itr != map1.end(); itr++) {
		cout << itr->first.first << " " << itr->first.second << " " << itr->second << endl;
	}*/
	for (auto itr = map.begin(); itr != map.end(); itr++) {
		ans += itr->second*map1[itr->first];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 108288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

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

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        string S;cin>>S;
        if(S[0]=='#') break;
        
        int cnt=1;
        int le=0,ri=1;
        int i=S.size()-1;
        if(S[i]=='t'){
            le=90;
            i-=4;
        }else{
            i-=5;
        }
        for(i;i>=0;){
            if(S[i]=='h'){
                le=le*2-90;
                i-=5;
            }else{
                le=le*2+90;
                i-=4;
            }
            ri*=2;
            cnt++;
        }
        
        //cout<<le<<" "<<ri<<endl;
        
        int g=gcd(le,ri);
        le/=g;
        ri/=g;
        
        if(ri==1) cout<<le<<endl;
        else cout<<le<<'/'<<ri<<endl;
        
    }
}



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

static const int MAX = 200005;
static const int INF = 1e9;

// 隣接リストを用いた幅優先探索 O(|V|+|E|)
vector<int> G[MAX], d(MAX, INF); // 始点sから頂点iまでの最短距離をd[i]に記録
// main関数からこれらを削除すること

void bfs(int s) {
  queue<int> q;
  q.push(s);
  d[s] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v = 0; v < G[u].size(); v++) {
      if (d[G[u][v]] == INF) {
        d[G[u][v]] = d[u] + 1;
        q.push(G[u][v]);
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 無向(有向)グラフの隣接リスト
  int n; // n:頂点数
  cin >> n;
  
  //vector<int> G[n]; // G:頂点数がnのグラフを表す隣接リスト
  
  int u, v;
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--;
    v--;
    G[u].emplace_back(v);
    G[v].emplace_back(u); // 有向グラフではこの行をコメントアウト
  }
  
  bfs(0);
  
  int now = 0, maxd = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] > maxd) {
      now = i;
      maxd = d[i];
    }
  }
  
  fill(d.begin(), d.end(), INF);
  bfs(now);
  
  int dia = 0;
  for (int i = 0; i < n; i++) {
    dia = max(dia, d[i]);
  }
  
  if (dia % 3 == 1) cout << "Second\n";
  else cout << "First\n";
}

Measured memory_bytes: 13556
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n, i, loc;
	int c[501], s[501], f[501],t[501];
	cin >> n;
	n--;
	for (i = 0; i < n; i++)
	{
		cin >> c[i] >> s[i] >> f[i];
	}
	for (i = 0; i < n; i++)
	{
		t[i] = 0;
		loc = i;
		while (loc < n)
		{
			t[i] = t[i] > s[loc] ? (t[i]%f[loc]? t[i] + f[loc]-t[i] % f[loc]:t[i]) : s[loc];
			t[i] += c[loc];
			loc++;
		}
	}
	for (i = 0; i < n; i++)
		cout << t[i] << endl;
	cout << '0' << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
                int n;
                scanf("%d", &n);

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

                for (int i = n - 1; 0 <= i; i--) {
                        printf("%d", num[i]);
                        if (i != 0) {
                                printf(" ");
                        }
                }
                printf("\n");
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A[100000], N;
int main(){
  int i;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=0;i<N;i++){
    if(A[i]%2==1){
      break;
    }
  }
  if(i<N){
    wt_L("first");
    putchar_unlocked('\n');
  }
  else{
    wt_L("second");
    putchar_unlocked('\n');
  }
  return 0;
}
// cLay varsion 20180730-1

// --- original code ---
// int N, A[1d5];
// 
// {
//   int i;
//   rd(N,A(N));
//   rep(i,N) if(A[i]%2==1) break;
//   if(i<N) wt("first"); else wt("second");
// }


Measured memory_bytes: 640
#include <stdio.h>
#include <memory.h>
int sum,map[14][14];
void snake(int y,int x){
    if(y==0 || x==0 || map[y][x]==0)
        return ;
    map[y][x]=0;
    snake(y,x+1);
    snake(y+1,x);
    snake(y,x-1);
    snake(y-1,x);
}

int main(void){
    int i,o;
    while(sum=0,1){
        memset(map,0,sizeof(map));
        for(i=1;i<=12;i++)
            for(o=1;o<=12;o++)
                if(scanf("%1d",&map[i][o]) == EOF)
                    return 0;
        for(i=1;i<=12;i++)
            for(o=1;o<=12;o++)
                if(map[i][o]==1){
                    snake(i,o);
                    sum++;
                }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

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

#define PI 3.14159265359


int main() {
	int n;
	cin >> n;
	cout << n * n << endl;


	return 0;
}

Measured memory_bytes: 888
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sx, sy, tx, ty := nextInt(), nextInt(), nextInt(), nextInt()

	dx, dy := tx-sx, ty-sy

	// 一周目
	for i := 0; i < dx; i++ {
		fmt.Print("R")
	}
	for j := 0; j < dy; j++ {
		fmt.Print("U")
	}
	for i := 0; i < dx; i++ {
		fmt.Print("L")
	}
	for j := 0; j < dy; j++ {
		fmt.Print("D")
	}

	// 二周目
	fmt.Print("D")
	for i := 0; i < dx; i++ {
		fmt.Print("R")
	}
	fmt.Print("R")
	for j := 0; j < dy; j++ {
		fmt.Print("U")
	}
	fmt.Print("UL")
	fmt.Print("U")
	for i := 0; i < dx; i++ {
		fmt.Print("L")
	}
	fmt.Print("L")
	for j := 0; j < dy; j++ {
		fmt.Print("D")
	}
	fmt.Println("DR")
}


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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;

signed main(){
    
    int n;
    cin >> n;

    int tx,ty,th;
    int xyh[n][3];
    REP(i,n){
        cin >> xyh[i][0] >> xyh[i][1] >> xyh[i][2];
        if(xyh[i][2] != 0){
            tx = xyh[i][0];
            ty = xyh[i][1];
            th = xyh[i][2];
        }
    }


    REP(cx,101) REP(cy,101){
        int H = th + abs(tx - cx) + abs(ty - cy);
        int c = 1;
        
        REP(i,n){
            if(xyh[i][2] != max((H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy)),0LL)) c = 0;
        }
        if(c == 1) cout << cx << " " << cy << " " << H;
    }

    

    return 0;
}
//g++ -std=c++14 code1.cpp


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, i;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> i;
	cout << (n - i + 1) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 200001;

int n, m;
string s;
vector <int> v[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> s;
    vector <int> a(n), b(n);
    for(int i = 0 ; i < m ; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        if(s[y] == 'A') a[x]++;
        else b[x]++;
        if(s[x] == 'A') a[y]++;
        else b[y]++;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    deque <int> ready;
    vector <int> vis(n);
    for(int i = 0 ; i < n ; i++){
        if(a[i] == 0 || b[i] == 0){
            ready.push_back(i);
            vis[i] = 1;
        }
    }
    while(ready.size()){
        int node = ready.front();
        ready.pop_front();
        for(auto &i : v[node]){
            if(vis[i]) continue;
            if(s[node] == 'A') a[i]--;
            else b[i]--;
            if(a[i] == 0 || b[i] == 0){
                ready.push_back(i);
                vis[i] = 1;
            }
        }
    }
    for(int i = 0 ; i < n ; i++){
        if(a[i] > 0 && b[i] > 0) finish("Yes");
    }
    cout << "No" << endl;
}


Measured memory_bytes: 13136
import math

str = input()

nums = [int(x) for x in str.split(' ')]

ct = nums[0] / (nums[1] + nums[2])
ct = math.floor(ct)
res = nums[0] % (nums[1] + nums[2])
res = math.floor(res)

if res > nums[1]:
  res = nums[1]

blue_ball = nums[1] * ct + res

print(blue_ball)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

// X = max({x[0],...,x[n-1],a})
// y[i] = x[i] - a
//ll dp[i][j]: y[0],..,y[i-1] から0枚以上選んで合計をj-n*Xにするような選び方の総数

ll dp[55][100000];
ll x[55];

int main () {
  int n, a;
  cin >> n >> a;
  rep(i,n) cin >> x[i];
  int X = *max_element(x,x+n);

  vi y(n);
  rep(i,n) y[i] = x[i] - a;

  rep(i,55)rep(j,6050) dp[i][j] = 0;
  dp[0][n*X] = 1;
  rep(i,50) {
    rep(j,5050) {
      if (dp[i][j] == 0) continue;
      dp[i+1][j] += dp[i][j];
      dp[i+1][j+y[i]] += dp[i][j];
    }
  }

  ll ans = dp[n][n*X] - 1;
  cout << ans << endl; 
  return 0;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

vector<ll> enum_div(ll n){
	vector<ll> ret;
	for(ll i=1;i*i<=n;++i){
		if(n%i==0){
			ret.push_back(i);
			if(i*i!=n){
				ret.push_back(n/i);
			}
		}
	}
	sort(ALL(ret));
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in();
	auto D1 = enum_div(N);
	auto D2 = enum_div(N-1);
	vll C;
	set_difference(ALL(D2),ALL(D1),back_inserter(C));

	ll S=C.size();
	for(auto& x:D1){
		if(x==1) continue;
		ll X = N/x;
		while(X>=x && !(X%x)){
			X /= x;
		}
		if((X%x)==1ll) S++;
	}

	out(S);
	return 0;
}


Measured memory_bytes: 3716
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    # preparation
    p=int(input())
    invfact=[0]*p
    invfact[p-1]=p-1 # Wilson's theorem
    for i in range(2,p):
        invfact[p-i]=invfact[p-i+1]*(p-i+1)%p

    # initialize
    A=list(map(int,input().split()))
    ans=[0]*p
    ans[0]=A[0]
    r=[0]*(p+1) # for use of r[-1]=0
    r[0]=1

    # iterate
    for k in range(1,p):
        newr=[0]*(p+1) # newr(x)=(x-(k-1))r(x)
        v=0 # v=f[k-1](k)
        power=1
        for i in range(p):
            v+=ans[i]*power%p
            power*=k
            power%=p
            newr[i]=(r[i-1]-(k-1)*r[i])%p
        r=newr
        for i in range(p):
            ans[i]+=(A[k]-v)*invfact[k]*r[i]
            ans[i]%=p
    print(*ans)
resolve()

Measured memory_bytes: 44240
// ?????¨?????????math.h ?????????????????????????????????M_PI????????????
// float ????????????????????????double ????????????
// float , double, long double ????????§???????????????????????????
#include <stdio.h>
#include <math.h>

int main(void){
  double r;
  double m,e;
  double pi = M_PI;
  scanf("%lf",&r);
  m = r*r*pi;
  e = 2*r*pi;
  printf("%f %f\n",m,e);


return 0;
}

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

using namespace std;

int main()
{
  uint64_t L, R;
  cin >> L >> R;

  uint64_t ans = 2019;

  for(uint64_t i = L;
      i < L + 2019 && i <= R;
      ++i)
    {
      for(uint64_t j = i + 1;
          j < L + 2019 && j <= R;
          ++j)
        {
          ans = min(ans, (i * j) % 2019);
        }
    }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b;
  int x, y;
  string dis;
  cin >> a >> b >> x >> y >> dis;
  if (a == dis) {
    cout << x -1 << " " << y << endl;
  }
  else {
    cout << x << " " << y - 1 << endl;
  }
    
}

Measured memory_bytes: 256
import collections
n=int(input())
t = list(map(int,input().split()))
c = collections.Counter(t)
c1 = sorted(c.items(), key=lambda x:-x[1])
count = 0

for k,i in c1:
    if k<=i:
        count += i-k
    else:
        count += i
print(count)

Measured memory_bytes: 71208
#include <cstdio>
#include <vector>
using namespace std;

#define MAXNUM 30001
bool prime[MAXNUM];

void eratosthenes()
{
	prime[0]=prime[1]=false;

	for(int i=2; i<MAXNUM; i++)
	{
		prime[i]=true;
	}
	
	for(int i=2; i*i<MAXNUM; i++)
	{
		if(prime[i])
		{
			for(int j=i*i; j<MAXNUM; j+=i)
			{
				prime[j]=false;
			}
		}
	}
}

int main()
{
	eratosthenes();
	vector<int> p;

	for(int i=2; i<30001; i++)
		if(prime[i]) p.push_back(i);

	int T;
	while(scanf("%d", &T), T)
	{
		int cnt=0;
		for(int i=0; i<p.size(); i++)
		for(int j=i; j<p.size(); j++)
		{
			int t=T-p[i]-p[j];
			if(t<0) break;
			
			if(p[i]<=p[j]&&p[j]<=t&&prime[t])
			{
				if(p[i]+p[j] > t && p[i]+t > p[j] && p[j]+t > p[i]) 
				{
					
					cnt++;
				}
			}
		}

		printf("%d\n", cnt);
	}

}

Measured memory_bytes: 872
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var arr = arrStr();
        Console.WriteLine(arr[1] + arr[0]);

    }

    static int[] arrInt()
    {
        return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
    }

    static string[] arrStr()
    {
        return Console.ReadLine().Split(' ').ToArray();
    }

}

Measured memory_bytes: 26152
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?
	
	// I don't wanna feel the PAIN.

// I BeG you to KILL me, pleASE...

#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Os")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;

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

const ll maxn=1e2+10, lg=22, mod=1e9+7, inf=1e18;

ll n,m,S[maxn][maxn],dp[maxn][maxn],ans;
bool a[maxn][maxn];

ll query(ll x,ll y,ll z,ll w){
	return S[z][w]+S[x][y]-S[x][w]-S[z][y];
}

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

    char ch;
    cin>>n>>m;
	ll X,Y;
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
    	cin>>ch;
        if(ch=='o') a[i][j]=1;
        if(ch=='E') X=i, Y=j;
    }
    if(X-1>n-X){
        for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)if(i>n+1-i) swap(a[i][j],a[n+1-i][j]);
        X=n+1-X;
    }
    if(Y-1>m-Y){
        for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)if(j>m+1-j) swap(a[i][j],a[i][m+1-j]);
        Y=m+1-Y;
    }
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++) S[i][j]=a[i][j];
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++) S[i][j]+=S[i][j-1];
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++) S[i][j]+=S[i-1][j];
    ll _n=n-(X-1)-(X-1), _m=m-(Y-1)-(Y-1);
    for(int x=0;x<X;x++)for(int y=0;y<Y;y++){
		dp[0][1]=query(x,y,X+x-1,Y+y);
        dp[1][0]=query(x,y,X+x,Y+y-1);
        for(int i=1;i<=_n;i++)for(int j=1;j<=_m;j++) dp[i][j]=max(query(i-2+X+x,j-1+y,i-1+X+x,j-1+Y+y)+dp[i-1][j],query(i-1+x,j-2+Y+y,i-1+X+x,j-1+Y+y)+dp[i][j-1]);
        ans=max(ans,dp[_n][_m]);
    }
    cout<<ans;

	return 0;
}












Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

long long MAX = 1e18;

int main() {
string s;
cin >> s;
cout << s.substr(0,3) << endl;

return 0;
}


Measured memory_bytes: 3468
import  java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System. `in`)
  val a=sc.nextInt();
  val b=sc.nextInt();
  println(problem(a,b))
}

fun problem(a: Int, b: Int): Int {
    return if(a>=10||b>=10)-1 else a*b
}


Measured memory_bytes: 29608
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int index[] = new int[6];
		while(n-- != 0)
		{
			double height = stdIn.nextDouble();
			if(height < 165)
			{
				++index[0];
			}
			else if(height < 170)
			{
				++index[1];
			}
			else if(height < 175)
			{
				++index[2];
			}
			else if(height < 180)
			{
				++index[3];
			}
			else if(height < 185)
			{
				++index[4];
			}
			else
			{
				++index[5];
			}
		}
		System.out.print("1:");
		for(int i = 0; i < index[0]; ++i)
		{
			System.out.print("*");
		}
		System.out.println();
		System.out.print("2:");
		for(int i = 0; i < index[1]; ++i)
		{
			System.out.print("*");
		}
		System.out.println();
		System.out.print("3:");
		for(int i = 0; i < index[2]; ++i)
		{
			System.out.print("*");
		}
		System.out.println();
		System.out.print("4:");
		for(int i = 0; i < index[3]; ++i)
		{
			System.out.print("*");
		}
		System.out.println();
		System.out.print("5:");
		for(int i = 0; i < index[4]; ++i)
		{
			System.out.print("*");
		}
		System.out.println();
		System.out.print("6:");
		for(int i = 0; i < index[5]; ++i)
		{
			System.out.print("*");
		}
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int Binary_Search(ll first,ll last,vector<ll>v,ll search_value)
{
    int pos=-1;
    while(first<=last)
    {
        ll mid=first+((last-first)/2);
        if(v[mid]==search_value)
        {
            pos=mid;
            break;
        }
        else if(search_value>v[mid])
        {
            first=mid+1;
        }
        else
        {
            last=mid-1;
        }
    }
    return pos;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    {
        return a;
    }
    else
    {
        return gcd(b,a%b);
    }
}
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

int main()
{
    int n;
    cin>>n;
    int arr[105];
    int c=0;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        if(i%2==1)
        {
            if(arr[i]%2==1)
            {
                c++;
            }
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;
    int buf=(h2-h1)*60+(m2-m1);
    int res=buf-k;
    cout<<res<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <climits>
using namespace std;
using Int = int32_t;
using ll = long long int;
using ull = unsigned long long int;
constexpr ull mod = 1e9 + 7;


int main() {

	Int A, B; cin >> A >> B;

	cout << (6 - A - B) << endl;

}

Measured memory_bytes: 256
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())
    = [list(list(sys.stdin.readline().rstrip())) for i in range(h)] #文字列を分解して二次元配列入力

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    h,w= map(int, sys.stdin.readline().split())
    print("#"*(w+2))
    for i in range(h):#１行ずつ入力
        print("#"+input()+"#")
    print("#"*(w+2))


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

#define INFTY 1000001
#define MAX 100

class Edge{
public:
    int target, cost;
    Edge(int target = 0, int cost = 0) : target(target), cost(cost) {}
};

std::vector<Edge> G[MAX];
bool visited[MAX];
int parent[MAX], key[MAX];
int V, minv, min_index;

int minKey() {
    minv = INFTY;
    for (int v = 0; v < V; v++)
        if (!visited[v] && key[v] < minv)
            minv= key[v], min_index = v;
    return min_index;
}


void printMST()
{
    int sum = 0;
    for (int i = 1; i < V; i++)
        sum += key[i];
    std::printf("%d\n", sum);

}

void prim() {

    for (int i = 0; i < V; i++) {
        key[i] = INFTY;
        visited[i] = false;
    }
    key[0] = 0;
    parent[0] = -1;

    int current, target, cost;

    for (int i = 0; i < V-1; i++) {
        current = minKey();
        visited[current] = true;

        for (unsigned long v = 0; v < G[current].size(); v++) {
            target = G[current][v].target;
            cost = G[current][v].cost;
            if (!visited[target] && cost < key[target])
                parent[target] = current, key[target] = cost;
        }
    }
    printMST();

}


int main()
{
    std::scanf("%d", &V);
    int cost;

    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            std::scanf("%d", &cost);
            if (cost != -1) G[i].push_back(Edge(j, cost));
        }
    }

    prim();
    return 0;
}



Measured memory_bytes: 3232
#include <stdio.h>

#ifdef DEBUG
#define  DPRINT printf
#else
#define DPRINT(...)
#endif

#define W_MAX 10000

int
solve(int n, int k)
{
	int w[n];
	int i, wmin, wmax, wsum, a;
	int lb, rb, p, q, m = 0;

	if (k <= 0)
		return -1;

	wmin = W_MAX, wmax = 0, wsum = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", w + i);
		if (wmin > w[i])
			wmin = w[i];
		if (wmax < w[i])
			wmax = w[i];
		wsum += w[i];
	}

	lb = wsum / k;
	rb = wsum;
	p = (lb + rb) / 2;
	if (lb < wmax)
		lb = wmax;
	for (;lb < rb;) {
		DPRINT("%d %d %d\n", lb, p, rb);
		for (q = a = i = 0, m = 1; i < n && m <= k; i++) {
			if (a + w[i] <= p) {
				a += w[i];
			} else {
				if (q < a)
					q = a;
				a = w[i], m++;
			}
		}
		if (q < a) /* 最後のトラックをチェック */
			q = a;

		if (m < k) {
			DPRINT("<\n");
			rb = q - 1;
			if (rb < lb)
				rb = lb;
		} else if (m > k) {
			DPRINT(">\n");
			lb = (q + wmin < p + 1) ? p + 1 : q + wmin;
			if (rb < lb)
				lb = rb;
		} else {
			DPRINT("=\n");
			rb = q;
			if (rb < lb)
				rb = lb;
		}
		p = (lb + rb) / 2;
	}
	return p;
}

int
main(void)
{
	int n, k;

	scanf("%d%d", &n, &k);
	printf("%d\n", solve(n, k));

	return 0;
}



Measured memory_bytes: 2156
#include<stdio.h>

int main(){

long Q,H,S,D;
long N,min=100000000000000000;
long iceTea[4];
scanf("%ld",&Q);
scanf("%ld",&H);
scanf("%ld",&S);
scanf("%ld",&D);
scanf("%ld",&N);

iceTea[0] = (2*Q+H)*N;
iceTea[1] = 4*Q*N;
iceTea[2] = 2*H*N;
iceTea[3] = S*N;

for (int i = 0; i < 4; i++)
{
  if (min>iceTea[i]){min = iceTea[i];}
}

if (N==1){
  printf("%ld",min);
}else if (N%2==0){
  min > D*N/2 ? printf("%ld",D*N/2) : printf("%ld",min); 
}else{
  min > D*(N-1)/2+min/N ? printf("%ld",D*(N-1)/2+min/N) : printf("%ld",min); 
}

return 0;

}

Measured memory_bytes: 1728
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	string S1, S2, S3;
	cin >> S1 >> S2 >> S3;
	cout << (char)toupper(S1[0]) << (char)toupper(S2[0]) << (char)toupper(S3[0]) << endl;
	return 0;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int min = 1; //最小値の用意
  int minimum = 1;
  
  for (int i = 0; i < N; i++) {
    min *= 2; //N回２をかける
  } 
 
  for (int j = 0; j < N; j++) {
    for (int k = 0; k < j; k++) {
      minimum *= 2;
    }
    minimum += K * (N-j);
  
    if (minimum < min) {
      min = minimum;
      minimum = 1;
    }
    else {
      minimum = 1;
    }
  }
  
  cout << min << endl;
}
  
  

Measured memory_bytes: 256