akhauriyash/Code-Regression huggingface dataset:
"""
2,3の倍数で構成
すべての和が6の倍数ならok

2,3,4,6 = 15
8,9,10,12 で繰り返し
"""
import sys

N = int(input())
q = []

if N == 3:
    print ("2 5 63")
    sys.exit()

i = 1
while len(q) < (N // 8) * 8:

    if i % 2 == 0 or i % 3 == 0:
        q.append(i)

    i += 1

i -= 1
if N - len(q) >= 2:
    q.append(i+3)
    q.append(i+9)

if N - len(q) >= 2:
    q.append(i+2)
    q.append(i+4)

if N - len(q) >= 2:
    q.append(i+8)
    q.append(i+10)

if N - len(q) >= 1:
    q.append(i+6)

if N - len(q) >= 1:
    q.append(i+12)

print (" ".join(map(str,q)))







Measured memory_bytes: 41456
from collections import deque
n, k = map(int, input().split())
a = [-1] + list(map(int, input().split()))
town = [-1] * (n + 1)
town[1] = 0
now_town = 1
second_first = 0
while True:
    if town[a[now_town]] != -1:
        second_first = a[now_town]
        break
    town[a[now_town]] = town[now_town] + 1
    if town[a[now_town]] == k:
        print(a[now_town])
        exit()
    now_town = a[now_town]
    # print(town)
start_index = town[second_first]
end_index = max(town)
rest = k - end_index
div = (rest-1) % (end_index - start_index + 1)
# print(rest, div)
ans = town.index((start_index) + div)
print(ans)

Measured memory_bytes: 102836
(defun main ()
  (let* ((h (read))
         (w (read))
         (grid (make-array (list (+ h 2) (+ w 2)) :initial-element -1))
         (current-positions '((1 1)))
         (white-num 0))
    (loop
      for i from 1 to h do 
      (loop
           for j from 1 to w
           for c in (concatenate 'list (read-line))
           do (if (equal c #\.)
                (progn
                  (incf white-num)
                  (setf (aref grid i j) 9999)))))
    (setf (aref grid 1 1) 0)
    (loop
      while current-positions do 
      (let* ((pos (pop current-positions))
            (i (car pos))
            (j (cadr pos)))
        (if (and (< 0 (aref grid (+ i 1) (+ j 0))) 
                 (< (1+ (aref grid i j)) (aref grid (+ i 1) (+ j 0))))
          (progn
            (setf (aref grid (+ i 1) (+ j 0)) (1+ (aref grid i j)))
            (setf current-positions
                  (nconc current-positions (list (list (+ i 1) (+ j 0)))))))

        (if (and (< 0 (aref grid (- i 1) (+ j 0))) 
                 (< (1+ (aref grid i j)) (aref grid (- i 1) (+ j 0))))
          (progn
            (setf (aref grid (- i 1) (+ j 0)) (1+ (aref grid i j)))
            (setf current-positions
                  (nconc current-positions (list (list (- i 1) (+ j 0)))))))

        (if (and (< 0 (aref grid (+ i 0) (+ j 1))) 
                 (< (1+ (aref grid i j)) (aref grid (+ i 0) (+ j 1))))
          (progn
            (setf (aref grid (+ i 0) (+ j 1)) (1+ (aref grid i j)))
            (setf current-positions
                  (nconc current-positions (list (list (+ i 0) (+ j 1)))))))

        (if (and (< 0 (aref grid (+ i 0) (- j 1))) 
                 (< (1+ (aref grid i j)) (aref grid (+ i 0) (- j 1))))
          (progn
            (setf (aref grid (+ i 0) (- j 1)) (1+ (aref grid i j)))
            (setf current-positions
                  (nconc current-positions (list (list (+ i 0) (- j 1)))))))))

    (let* ((goal (aref grid h w))
           (ans (if (/= goal 9999)
                  (- white-num goal 1)
                  -1)))
      (format t "~a~%" ans))))

(main)


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

ll dp[22][1 << 21];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector< vector<int> > a(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}

	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < (1 << n); j++) {
			if (__builtin_popcount(j) != i) continue;
			for (int k = 0; k < n; k++) {
				if (j & (1 << k)) continue;
				if (a[i][k] == 0) continue;
				(dp[i + 1][j | (1 << k)] += dp[i][j]) %= MOD;
			}
		}
	}
	cout << dp[n][(1 << n) - 1] << endl;
	return 0;
}


Measured memory_bytes: 309504
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;

int main(){

int n;cin>>n;
ll a[n];
rep(i,n)cin>>a[i];
ll sum,ans=0,cnt;
rep(i,60){
    cnt=0;
    rep(j,n){
        if(a[j]>>i&1)cnt++;
    }
    sum= cnt*(n-cnt)%MOD;
    rep(j,i) sum = sum*2%MOD;
    ans += sum;
    ans %= MOD;
}

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

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
int main() {
    int N, M;
    cin >> N >> M;

    vector<P> bridge(M);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        bridge[i] = P(a, b);
    }

    sort(bridge.begin(), bridge.end());

    int ans = 0;
    int p = 1e6;
    for (int i = 1, k = 0; i <= N; i++) {
        if (p == i) {
            ans++;
            p = 1e6;
        }

        while (k < M && bridge[k].first == i) {
            p = min(p, bridge[k].second);
            k++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1152
C = str(input())

a = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

for i in range(len(a)):
    if a[i] == C:
        print(a[i+1])

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if((a + b) % 2 == 0)
    cout << (a + b) / 2 << endl;
  else
    cout << (a + b) / 2 + 1 << endl;
  
}


Measured memory_bytes: 3612
li1 = list(map(int,input().split()))
li2 = list(map(int,input().split()))
li3 = list(map(int,input().split()))

dyoko1 = li1[1]-li1[0]
dyoko2 = li1[2]-li1[1]
dtate1 = li2[0]-li1[0]
dtate2 = li3[0]-li2[0]

if li2[1]-li2[0] != dyoko1 or li3[1]-li3[0] != dyoko1:
  print("No")
  exit()
elif li2[2]-li2[1] != dyoko2 or li3[2]-li3[1] != dyoko2:
  print("No")
  exit()
elif li2[1]-li1[1] != dtate1 or li2[2]-li1[2] != dtate1:
  print("No")
  exit()
elif li3[1]-li2[1] != dtate2 or li3[2]-li2[2] != dtate2:
  print("No")
  exit()
  
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>
// #include "utiltime.hpp"

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(double x) { ll m = (ll)sqrt(x); return m + (m * m <= (ll)(x) ? 0 : -1); }
ll ceilsqrt(double x) { ll m = (ll)sqrt(x); return m + ((ll)x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }

/*******************************************************/

int main() {
	int n; cin >> n;
	ll x; cin >> x;
	vll a(n); Loop(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	Loop(i, n) {
		if (x >= a[i]) {
			x -= a[i];
			ans++;
		}
		else break;
	}
	if (ans == n && x > 0) ans--;
	cout << ans << endl;
}

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

int main(){
  string x;
  string y;
  while(cin >> x >> y,x!="0"){
    int hit = 0;
    int blw = 0;

    for(int i=0; i<4; ++i){
      for(int j=0; j<4; ++j){
	if(x[i]==y[j]){
	  if(i==j){
	    ++hit;
	  }else if(i!=j){
	    ++blw;
	  }
	}
      }
    }

    cout << hit << " " << blw << endl;
  }
  return 0;
}
    



Measured memory_bytes: 2988
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n,a[100000], a1[100000];
  
	scanf("%d", &n);
  
	for(int i=0; i<n; i++){
	  scanf("%d", &a[i]);
      a1[i]=a[i];
	}
    sort(a1, a1+n);
    map<int, int> mp;
    for(int i=0; i<n; i++){
      mp[a1[i]]=i;
    }
    for(int i=0; i<n; i++){
      a[i]=mp[a[i]];
    }
    int c=0;
    for(int i=0; i<n; i++){
	  if((a[i]+i)%2!=0) c++;
    }
	printf("%d\n", c/2);

	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();

    int n;
    cin >> n;
    
    cout << 3 * n * n;
    
    cout << '\n';
    return 0;
}

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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

template<typename T1,typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 & a, T2 b) { if (a < b) a = b; }

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kMax9 = 1000000010;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, int n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

double dist(double lhs, double rhs) {
  return sqrt(lhs * lhs + rhs * rhs);
}

ll p = kMod;

ll quick_mod(ll a, ll b)
{
    ll ans = 1;
    a %= p;
    while(b)
    {
        if(b & 1)
        {
            ans = ans * a % p;
            b--;
        }
        b >>= 1;
        a = a * a % p;
    }
    return ans;
}

ll C(ll n, ll m)
{
    if(m > n) return 0;
    ll ans = 1;
    for(int i=1; i<=m; i++)
    {
        ll a = (n + i - m) % p;
        ll b = i % p;
        ans = ans * (a * quick_mod(b, p-2) % p) % p;
    }
    return ans;
}

ll Lucas(ll n, ll m)
{
    if(m == 0) return 1;
    return C(n % p, m % p) * Lucas(n / p, m / p) % p;
}

int main() {
  long n, m, k, a, b;
  string s;
  ll ans = 1;
  long x, y;

  cin >> x >> y;
  if ((x + y) % 3 != 0) { cout << 0 << endl; return 0; }
  auto x_ = x - (x + y) / 3;
  auto y_ = y - (x + y) / 3;
  if (x_ < 0 || y_ < 0) { cout << 0 << endl; return 0; }

  cout << Lucas(x_ + y_, y_) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define N 410
#define ll long long
using namespace std;
int n, a[N][4];
ll ans, ans1, b[5];
map<ll, int>mp;
inline ll id(ll a, int b, int c, int d){return (a<<30)+(b<<20)+(c<<10)+d;}
inline void ins(ll x, int y){
	int a=x>>30, b=(x>>20)&1023, c=(x>>10)&1023, d=x&1023;
	mp[id(a, b, c, d)]+=y;
	mp[id(b, c, d, a)]+=y;
	mp[id(c, d, a, b)]+=y;
	mp[id(d, a, b, c)]+=y;
}
int main(){
	scanf("%d", &n);
	mp.clear();
	for(int i=1; i<=n; i++){
		for(int j=0; j<=3; j++)scanf("%d", &a[i][j]);
		ins(id(a[i][0], a[i][1], a[i][2], a[i][3]), 1);
	}
	ans=0;
	for(int i=1; i<=n-5; i++){
		ins(id(a[i][0], a[i][1], a[i][2], a[i][3]), -1);
		for(int j=i+1; j<=n; j++)
			for(int k=0; k<=3; k++){
				ins(id(a[j][0], a[j][1], a[j][2], a[j][3]), -1);
				b[1]=id(a[i][0], a[j][(0+k)%4], a[j][(3+k)%4], a[i][1]);
				b[2]=id(a[i][1], a[j][(3+k)%4], a[j][(2+k)%4], a[i][2]);
				b[3]=id(a[i][2], a[j][(2+k)%4], a[j][(1+k)%4], a[i][3]);
				b[4]=id(a[i][3], a[j][(1+k)%4], a[j][(0+k)%4], a[i][0]);
				if(mp[b[1]]&&mp[b[2]]&&mp[b[3]]&&mp[b[4]]){
					ans1=1; for(int ii=1; ii<=4; ii++){ans1*=mp[b[ii]]; ins(b[ii], -1);}
					ans+=ans1; for(int ii=1; ii<=4; ii++)ins(b[ii], 1);
				}
				ins(id(a[j][0], a[j][1], a[j][2], a[j][3]), 1);
			}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 20352
using System;

namespace B___Qualification_simulator
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var a = int.Parse (input[1]);
            var b = int.Parse (input[2]);
            var s = Console.ReadLine ();
            var count = 0;
            var rank = 0;
            foreach (var p in s)
            {
                if (p == 'a' && count < a + b)
                {
                    Console.WriteLine ("Yes");
                    count++;
                }
                else if (p == 'b' && count < a + b && rank < b)
                {
                    Console.WriteLine ("Yes");
                    count++;
                    rank++;
                }
                else
                    Console.WriteLine ("No");
            }
        }
    }
}

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

int main() {
//	freopen("input.txt", "r", stdin);
	int a, b, x, c;
	cin >> a >> b >> c >> x;
	int ans =0;
	for (int i = 0; i <= c; ++i)
	{
		for (int j = 0; j <= b; ++j)
		{
			for (int k = 0; k <= a; ++k)
			{
				if (50*i + 100*j + 500*k == x)
					{
//					cout << i << " " << j << " " << k << endl;
					++ans;
					}
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int Z = 1e9+7;

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

    int c[n+1][n+1];
    c[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        c[i][0] = c[i][i] = 1;
        for (int j = 1; j < i; j++) {
            c[i][j] = (c[i-1][j-1] + c[i-1][j]) % Z;
        }
    }

    for (int i = 1; i <= k; i++) {
        cout << (i <= n - k + 1 ? 1ll * c[n-k+1][i] * c[k-1][i-1] % Z : 0) << endl;
    }

    return 0;
}

Measured memory_bytes: 15488
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

const LL mod = 998244353;

int a[5];

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif

  
  int x = 0;
  for (int i = 0; i < 5; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 0) {
      x = i + 1;
    }
  }
  printf("%d\n", x);
  

#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 3760
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
 
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int[] a = new int[N];
		int XOR = 0;
		for (int i = 0; i < N; i++) {
			int x = input.nextInt();
			XOR^=x;
			a[i]=x;
		}
		for (int i = 0; i < N; i++) System.out.print((XOR^a[i])+" ");
	}
}


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

int calendar[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
	int month, day;
	while (1) {
		int sum = 0;
		cin >> month >> day;
		if (month == 0) break;
		for (int i = 0; i < month - 1; i++) {
			sum += calendar[i];
		}
		sum += day;
		if (sum % 7 == 0) cout << "Wednesday" << endl;
		if (sum % 7 == 1) cout << "Thursday" << endl;
		if (sum % 7 == 2) cout << "Friday" << endl;
		if (sum % 7 == 3) cout << "Saturday" << endl;
		if (sum % 7 == 4) cout << "Sunday" << endl;
		if (sum % 7 == 5) cout << "Monday" << endl;
		if (sum % 7 == 6) cout << "Tuesday" << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

    //座標圧縮の前処理
    vector<string> vals;
    for (int i = 0; i < (int)a.size(); i++) {
        vals.push_back(a[i]);
    }
    sort(vals.begin(), vals.end());
    vals.erase(unique(vals.begin(), vals.end()), vals.end());  //重複のない列にしている

    for (int i = 0; i < vals.size(); i++) {
        string name = vals[i];
        priority_queue<P> q;
        for (int i = 0; i < n; i++) {
            if (name == a[i]) {
                q.push(P(p[i], i+1));
            } 
        } 
        while (!q.empty()) {
            P p = q.top(); q.pop();
            cout << p.second << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
  
  private static long X = 1000000007;
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    long[][] memo = new long[N+1][N+1];
    for (int i = 0; i <= N; i++) {
      for (int j = 0; j <= N; j++) {
        memo[i][j] = -1;
      }
    }
    for (int i = 1; i <= K; i++) {
      if (N-K+1 >= i) {
        long count = (comb(N-K+1, i, memo) * comb(K-1, i-1, memo)) % X;
        System.out.println(count);
      } else {
        System.out.println(0);
      }
    }
  }
  
  private static long comb(int n, int r, long[][] memo) {

    if (r == n || r == 0) {
      return 1;
    }

    if (memo[n][r] != -1) {
      return memo[n][r];
    }

    memo[n][r] = (comb(n-1, r-1, memo) + comb(n-1, r, memo)) % X;
    
    return memo[n][r];
  }
}


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

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long max = a * c;
    if (a * d > max) max = a * d;
    if (b * c > max) max = b * c;
    if (b * d > max) max = b * d;

    cout << max << endl;
    

   return 0;
}

Measured memory_bytes: 3632
#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 FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

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

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

string S;

bool check(string s){
    for(int i = 0; i < s.size(); ++i){
        if(s[i] != s[s.size() - i - 1]) return false;
    }
    return true;
}

void solve(){
    bool b = true;
    b = b && check(S);
    string hSa = S.substr(0, (S.size() - 1) / 2);
    b = b && check(hSa);
    string hSb = S.substr((S.size() + 3) / 2 - 1, (S.size() - 1) / 2);
    b = b && check(hSb);
    if(b) cout << "Yes";
    else cout << "No";
}
int main(){
    cin >> S;
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int ans;

		while(true){

			try {
				String inputed = br.readLine();
				if(inputed.length() == 1 && inputed.equals("0"))break;

				ans = 0;
				for(int i = 0; i < inputed.length(); i++){
					ans += inputed.charAt(i)-'0';
				}

				System.out.printf("%d\n", ans);

			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}


Measured memory_bytes: 24960
n,k = map(int, input().split())
a=[]
while k>1:
    a.append(k)
    k/=2
a.append(k/2)
ans=0
c=0
b=n
while n>=1:
    if n>=a[c]:
        ans+=(2**(-c))*(1/b)
        n-=1
    else:
        c+=1
print(ans)


Measured memory_bytes: 3060
/*
AizuOnline A0183
Black-and-White
*/
#include <stdio.h>

char hantei(char * ban)
{
  int lines[][3]={{0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}};
  char color[2]="bw";
  int i,j,k;
  int result;
  
  for(i=0;i<2;i++)
    for(j=0;j<8;j++)
      {  result = 1;
        for(k=0;k<3;k++)
          {   /*printf("%d %d %d %c\n",i,j,k,ban[lines[j][k]]); */
            result &= (color[i]==ban[lines[j][k]])?1:0;
          }
        if(result)
          return(color[i]);
      }
  return('+');

}
main()
{
  char banmen[10];
  char ret;
  
  while(EOF != scanf("%3s",banmen) && banmen[0] != '0')
    { scanf("%3s",banmen+3);
      scanf("%3s",banmen+6);

      /*printf("BAN=%s\n",banmen); */
      ret = hantei((char *)banmen);
      if(ret == '+')
        printf("NA\n");
      else
        printf("%c\n",ret);
    }
return(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,a[100001]={0},sum[100001]={0};
	vector<pair<int,int> > v;
	int tot=0;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++){
		char c;
		cin>>c;
		a[i]=c-'0';
//		scanf("%d",&a[i]);
		if(i-1&&a[i]&&a[i-1]==0){
			sum[i]=1;
			v.push_back({sum[i-1],0});
		}
		else{
			if(i-1&&a[i]==0&&a[i-1]){
			sum[i]=1;
			v.push_back({sum[i-1],1});
			}
			else{
				sum[i]=sum[i-1]+1;
			}
		}
		
	}
	v.push_back({sum[n],a[n]});
	int l=0,Tot=0,r=0,tmpans=0,finalans=0;
	for(int i=0;i<v.size();i++,r++){
		
//		cout<<v[i].second<<" "<<Tot<<" "<<i<<endl;
		tmpans+=v[i].first;
//		cout<<tmpans<<endl;
		if(v[i].second==0){
			Tot++;
		}
		if(Tot>k){
			tmpans-=v[i].first;
			r--;
			break;
		}
	}
//	cout<<tmpans<<endl;
	if(Tot<=k){
		printf("%d\n",n);
		return 0;
	}
	Tot=k;
	finalans=tmpans;
	while(r+1<v.size()){
		r++;
		
		tmpans+=v[r].first;
//		cout<<tmpans<<endl;
		if(v[r].second==0){
			if(v[l].second==0){
				l++;
				tmpans-=v[l-1].first;
			}
			else{
				l+=2;
				tmpans-=v[l-1].first;
//				cout<<v[l-2].first<<endl;
				tmpans-=v[l-2].first;
			}
		}
		finalans=max(tmpans,finalans);
	}
	printf("%d\n",finalans);
	return 0;
}

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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10E9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}
                                              
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;  

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif

  
   int n; cin >> n;
   string s; cin >> s;
   int x = 0 , y = 0;
   forn(i , 0 , (int)s.size()){
     if(s[i] == 'R') x++;
     else y++;  
   } 
     
   cout << ((x > y) ? "Yes" : "No")  << endl;
  
      
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

bool vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
  }
  else { // 発見できなかったとき
    return false;
  }
}
int main(void){
    // Your code here!
    int n,m; cin >> n >> m;
    int a;
    vector<ll> dp(n+1,0);
    rep(i,m) {
        cin >> a;
        dp[a] = -1;
    }
    dp[0] = 1;
    if (dp[1] != -1) dp[1] = 1;
    FOR(i,2,n){
        if (dp[i] == -1) continue;
        if (dp[i-1] != -1) dp[i] += dp[i-1];
        if (dp[i-2] != -1) dp[i] += dp[i-2];
        dp[i]%=MOD;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  int count[26]={0};
  rep(i,(int)s.size()){
    count[s[i] - 'a']++;
  }
  rep(i,26){
    if(count[i]==0){
      cout << (char)('a'+i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long N;
  scanln(N);
  long[] as = readln.split.to!(long[]);
  if (as.all!(a => a%2==1 || (a%3==0 || a%5==0))) {
    writeln("APPROVED");
  } else{
    writeln("DENIED");
  }
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scn= new Scanner(System.in);
        int n = scn.nextInt();
        int d = scn.nextInt();
        for(int i=1;;i++){
            if(n<=(2*d+1)*i){
                System.out.println(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 21844
/*input
6 2 4
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

void solve(){
    int n,a,b;cin >> n >> a >> b;
    int timess = n/(a+b);
    int left = n-timess*(a+b);
    cout << timess*a+min(left,a) << endl;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  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);
		int x = sc.nextInt();
		int y = sc.nextInt();

		while (true) {
			if (x < y) {
				int tmp1 = x;
				x = y;
				y = tmp1;
			}
			int tmp2 = y;
			y = x % y;
			x = tmp2;
			if (y == 0)
				break;
		}
		System.out.println(x);

	}

}


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

int main(){
  int n,i,saidai=1;
  cin>>n;
  int a[n];
  string s[n];
  a[0]=1;
  for(i=0;i<n;i++){
    cin>>s[i];
  }
  sort(s,s+n);
  for(i=1;i<n;i++){
    if(s[i]==s[i-1]){
      a[i]=a[i-1]+1;
    }else{
      a[i]=1;
    }
    saidai=max(saidai,a[i]);
  }
  for(i=0;i<n;i++){
    if(a[i]==saidai){
      cout<<s[i]<<endl;
    }
  }
}


Measured memory_bytes: 15104
#include <stdio.h>

main(void)
{
	int a,b,c,d,e;
	while(scanf("%d %d",&a,&b)!=-1){
		d=a+b;
		for(c=0;d!=0;c++){
			d/=10;
		}
		printf("%d\n",c);
	}
	return 0;
}

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

int main(void) {
    int H, W;
    int checkH = 1;
    int checkW = 1;
    
    while(true) {
        cin >> H >> W;
        
        if(H == 0 && W == 0)   break;
        
        checkH = 1;
        checkW = 1;
        for(int h = 0; h < H; ++h) {
            checkW = checkH;
            for(int w = 0; w < W; ++w) {
                if(checkW == 1) {
                    cout << "#";
                    checkW = 0;
                } else {
                    cout << ".";
                    checkW = 1;
                }
            }
            cout << endl;
            
            if(checkH == 1) {
                checkH = 0;
            } else {
                checkH = 1;
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
t = input()
b = input()

MOD = 10**9 + 7

cnts = [0]*(len(b)+1)
cnts[0] = 1

for c in t:
    for i in range(len(b)-1, -1, -1):
        if c == b[i]:
            cnts[i+1] = (cnts[i+1] + cnts[i]) % MOD
print(cnts[-1])

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

int main() {
  int N;
  int C = 0,W = 0,T = 0,R = 0;

  cin >> N;
  for(int i=0;i<N;++i){
    string s; cin >> s;
    if(s == "AC"){
      C += 1;
    }else if(s == "WA"){
      W+=1;
    }else if(s == "TLE"){
      T += 1;
    }else if(s == "RE"){
      R += 1;
    }
  }
  cout << "AC x " << C << endl;
  cout << "WA x " << W << endl;
  cout << "TLE x " << T << endl;
  cout << "RE x " << R << endl; 

  return 0;
}


Measured memory_bytes: 3572
#include <algorithm>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
const int inf = 1 << 30;
const int INF = INT_MAX;

bool atgc(char c) {
  if (c == 'A' || c == 'T' || c == 'G' || c == 'C') {
    return true;
  } else {
    return false;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int m = 0, count = 0;
  for (auto c : s) {
    if (!atgc(c)) {
      m = max(m, count);
      count = 0;
    } else {
      ++count;
    }
  }
  m = max(m, count);
  cout << m << endl;
  return 0;
}

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

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

  int A, B, C;
  cin >> A >> B >> C;
  if(A == B && B != C){
    cout << "Yes" <<endl;
    return 0;
  }
  if(B == C && C != A){
    cout << "Yes" <<endl;
    return 0;
  }
  if(C == A && A != B){
    cout << "Yes" <<endl;
    return 0;
  }
  cout << "No" <<endl;
}


Measured memory_bytes: 256
import sys

def main():
    flg=True
    input()
    tmp = input().replace('\n','').split()
    for i in tmp:
        i = int(i)
        if i%2 == 0:
            if i%3 != 0 and i%5 != 0:
                flg=False
                break
    if flg:
        print("APPROVED")
    else:
        print("DENIED")
if __name__ == '__main__':
    input = sys.stdin.readline
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,x,y;
char f[55][55];
int rui[55][55];
int calc(int a,int b,int c,int d){
	return rui[b][d]-rui[a-1][d]-rui[b][c-1]+rui[a-1][c-1];
}
int dp[45][45][45][45];
int rec(int a,int b,int c,int d){
	if(dp[a][b][c][d] < 100000) return dp[a][b][c][d];
	int &ret = dp[a][b][c][d];
	ret = min(calc(a,x,c,y),ret);
	ret = min(calc(a,x,y,d),ret);
	ret = min(calc(x,b,c,y),ret);
	ret = min(calc(x,b,y,d),ret);
	for(int X=x;X<=b;X++) for(int Y=y;Y<=d;Y++){
		if(X==b && Y==d) continue;
		ret = min(ret,calc(X+1,b,c,Y)+calc(a,X,Y+1,d)+rec(a,X,c,Y));
	}
	for(int X=x;X<=b;X++) for(int Y=c;Y<=y;Y++){
		if(X==b && Y==c) continue;
		ret = min(ret,calc(X+1,b,Y,d)+calc(a,X,c,Y-1)+rec(a,X,Y,d));
	}
	for(int X=a;X<=x;X++) for(int Y=y;Y<=d;Y++){
		if(X==a && Y==d) continue;
		ret = min(ret,calc(a,X-1,c,Y)+calc(X,b,Y+1,d)+rec(X,b,c,Y));
	}
	for(int X=a;X<=x;X++) for(int Y=c;Y<=y;Y++){
		if(X==a && Y==c) continue;
		ret = min(ret,calc(a,X-1,Y,d)+calc(X,b,c,Y-1)+rec(X,b,Y,d));
	}
	return ret;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		string str; cin>>str;
		for(int j=1;j<=m;j++){
			f[i][j] = str[j-1];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(f[i][j] == 'P'){
				x = i;
				y = j;
			}
			rui[i][j] = (f[i][j]=='#'?1:0);
			rui[i][j] += rui[i-1][j];
			rui[i][j] += rui[i][j-1];
			rui[i][j] -= rui[i-1][j-1];
		}
	}
	rep(i,45)rep(j,45)rep(k,45)rep(l,45)dp[i][j][k][l] = INF;
	cout << rec(1,n,1,m) << endl;
}

Measured memory_bytes: 16384
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
          
bool comp(pair<string, int> a, pair<string, int> b){
    return a.S < b.S;
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int x ,y, z;
    cin >> x >> y >> z;
    cout << floor((x - z) / (y + z));
}


Measured memory_bytes: 256
import sys
card = []
array = []
rank = ["S","H","C","D"]
for i in rank:
    for j in range(1,14):
        card.append(i + " " + str(j))
        
n = int(input())
for line in sys.stdin.readlines():
    array.append(line.rstrip())

for cards in array:
    card.remove(cards)
for y in card:
    print(y)



Measured memory_bytes: 5596
// Garg's Code
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
 
#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define rf(i,x,n) for(ll i = x; i >= x; i--) 
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll MAX = LLONG_MAX, MOD = 1000000007, MODA = 1e9 - 1;
const ll MIN = LLONG_MIN; 
int main()
{
  fast();

  
  ll t;
  string s;
  cin >> s;
  if(s == "SAT")
    cout << 1;
  else if(s == "SUN")
    cout << 7;
  else if(s == "MON")
    cout << 6;
  else if(s == "TUE")
    cout << 5;
  else if(s == "WED")
    cout << 4;
  else if(s == "THU")
    cout << 3;
  else if(s == "FRI")
    cout << 2;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <functional>
#define MOD 1000000007

int i,j,k;

struct edge {
    int to;
    int cost;
};

typedef long long ll;
using namespace std;
using P = pair<int, int>;

bool compare_by_b(pair<int,pair<string,int>> a, pair<int,pair<string,int>> b) {
    if(a.second.first != b.second.first){
        return a.second.first < b.second.first;
    }else{
    return a.second.second > b.second.second;
    }
}

int main(void) {
    int n;
    vector<int> w;
    int sum[150]={0};
    cin>>n;
    for(i=0;i<n;i++){
        int ww;
        cin >> ww;
        w.push_back(ww);
    }
    sum[1]=w[0];
    for(i=2;i<=n;i++){
        sum[i]=sum[i-1]+w[i-1];
    }
    int ans=sum[n];
    int asum,bsum;
    for(i=1;i<=n;i++){
        asum=sum[i];
        bsum=sum[n]-asum;
        if(abs(asum-bsum)<ans){
            ans = abs(asum-bsum);
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
using namespace std;
typedef long long ll;

int main(){
  int n,h,w;
  cin >> n >> h >> w;
  cout << (n-h+1)*(n-w+1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=5e5;
struct Point{int l,r;}p[N];
int n,f[N];
int cmp(const Point &a,const Point &b){return a.r<b.r;}
int find(int id)
{
    int l=0,r=id-1,x=p[id].l;
    while(l<r)
    {
        int mid=(l+r+1)>>1;
        if(p[mid].r<=x)l=mid;
        else r=mid-1;
    }
    return l;
}
int main()
{
    scanf("%d",&n);
    for(int i=1,x,l;i<=n;i++)scanf("%d%d",&x,&l),p[i].l=x-l,p[i].r=x+l;
    sort(p+1,p+n+1,cmp);
    for(int i=1;i<=n;i++)
    {
        f[i]=max(f[i-1],f[find(i)]+1);
    }
    cout<<f[n]<<endl;
}

Measured memory_bytes: 2816
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        //String line = sc.nextLine();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int L = A + B;
        int R = C + D;
        if(L > R){
            System.out.println("Left");
        }else if(L < R){
            System.out.println("Right");
        }else{
            System.out.println("Balanced");
        }
        
    }
}

Measured memory_bytes: 21844
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, Q = lr()
S = '-' + sr() + '-'
TD = [sr().split() for _ in range(Q)]

L = 1
for t, d in TD[::-1]:
    if d == 'L':
        if L <= N and S[L] == t:
            L += 1
    if d == 'R':
        if L >= 1 and S[L-1] == t:
            L -= 1
R = N
for t, d in TD[::-1]:
    if d == 'L':
        if R <= N and S[R+1] == t:
            R += 1
    if d == 'R':
        if R >= 1 and S[R] == t:
            R -= 1

answer = max(0, R - L + 1)
print(answer)
# 34


Measured memory_bytes: 40920
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<str> vs;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
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;};

int main() {
    int a,b,c;
    cin >> a>>b>>c;
    cout << min(a+b,min(b+c,c+a)) << endl;
}

Measured memory_bytes: 256
fun main() {
    readLine()!!
    val intList = readLine()!!.split(" ").map { it.toInt() }
    val costList = mutableListOf<Int>()
    val average = intList.sum() / intList.size
    var sum = 0
    for (i in intList) {
        sum += (i - average) * (i - average)
    }
    costList.add(sum)
    sum = 0
    for (i in intList) {
        sum += (i - average - 1) * (i - average - 1)
    }
    costList.add(sum)
    println(costList.min())

}

Measured memory_bytes: 37920