akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}


fun main() {
    val (H, W, K) = nextIntList()
    val M = Array(H) { next().toCharArray() }
    val B = M.map { a -> a.count { it == '#' } }.sum()
    val G = B - K
    val X = rec_bit((0 until W).toList())
    val Y = rec_bit((0 until H).toList())
    val CX = M.transposed().map { it.count { it == '#' } }
    val CY = M.map { it.count { it == '#' } }
    var ans = 0
    for (ys in Y) {
        for (xs in X) {
            var cnt = ys.sumBy { CY[it] } + xs.sumBy { CX[it] }
            for (y in ys) {
                for (x in xs) {
                    if (M[y][x] == '#') cnt--
                }
            }
            if (cnt == G) ans++
        }
    }
    println(ans)
}

fun rec_bit(seeds: List<Int>, pos: Int = 0, patterns: Array<Int> = emptyArray()): Array<Array<Int>> {
    return if (pos < seeds.size) {
        val res1 = rec_bit(seeds, pos + 1, patterns + seeds[pos])
        val res2 = rec_bit(seeds, pos + 1, patterns)
        res1 + res2
    } else {
        arrayOf(patterns)
    }
}

fun Array<CharArray>.transposed(): Array<CharArray> {
    val A = Array(this[0].size) { CharArray(this.size) }
    for (y in this.indices) {
        for (x in this[0].indices) {
            A[x][y] = this[y][x]
        }
    }
    return A
}

Measured memory_bytes: 40356
n = int(input())
a = list(map(int, input().split()))
s = [0]
if (n == 2):
    print(abs(a[0] - a[1]))
else:
    for i in range(n):
        s.append(a[i] + s[i])

    b = 1e+9
    j = 1
    
    while(j < n):
        if (abs(s[j] - (s[n] - s[j])) < b):
            b = abs(s[j] - (s[n] - s[j]))
        j += 1
    print(b)

Measured memory_bytes: 24812
#include<bits/stdc++.h>
using namespace std;
int main()
{


    vector<int>arr;
    for(int i=0;i<3;i++)
    {
        int n;
        cin>>n;
        arr.push_back(n);

    }

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

    if(arr[0]+arr[1]==arr[2])
    {
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;
 
 
 int lis( int arr[], int n )  
{  
    int lis[n]; 
   
    lis[0] = 1;    
  
    /* Compute optimized LIS values in bottom up manner */
    for (int i = 1; i < n; i++ )  
    { 
        lis[i] = 1; 
        for (int j = 0; j < i; j++ )   
            if ( arr[i] > arr[j] && lis[i] < lis[j] + 1)  
                lis[i] = lis[j] + 1;  
    } 
  
    // Return maximum value in lis[] 
    return *max_element(lis, lis+n); 
}  
void computeLPSArray(char* pat, int M, int* lps) 
{ 
    // length of the previous longest prefix suffix 
    int len = 0; 
  
    lps[0] = 0; // lps[0] is always 0 
  
    // the loop calculates lps[i] for i = 1 to M-1 
    int i = 1; 
    while (i < M) { 
        if (pat[i] == pat[len]) { 
            len++; 
            lps[i] = len; 
            i++; 
        } 
        else // (pat[i] != pat[len]) 
        { 
            // This is tricky. Consider the example. 
            // AAACAAAA and i = 7. The idea is similar 
            // to search step. 
            if (len != 0) { 
                len = lps[len - 1]; 
  
                // Also, note that we do not increment 
                // i here 
            } 
            else // if (len == 0) 
            { 
                lps[i] = 0; 
                i++; 
            } 
        } 
    } 
} 
    
int main()
{
  fastio();
 
ll int T;
T=1;
ll int anscount=1;
while(T--)
{
    ll int flag=0,i=0;
    string s;
    cin>>s;
    ll int n;n=s.size();
    for(i=0;i<s.size()/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            flag=1;
        }
    }
    string s1 = s.substr(0,s.size()/2),s2=s.substr(s.size()/2+1,s.size()/2);
    s=s1;
    n=s.size();
    for(i=0;i<s.size()/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            flag=1;
        }
    }
    s=s2;
    n=s.size();
    for(i=0;i<s.size()/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            flag=1;
        }
    }
 
    if(flag)
    cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;
}
    return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
table = Array.new(n, -1)
m.times do
  conds = gets.split.map(&:to_i)
  if conds[0] == 1 && conds[1] == 0 && n != 1
    puts -1
    exit
  end
  if table[conds[0]-1] == -1
    table[conds[0]-1] = conds[1]
  elsif table[conds[0]-1] != conds[1]
    puts -1
    exit
  end
end
if table[0] == -1 && table.size == 1
  puts '0'
elsif table[0] == -1
  puts '1' + table[1..-1].map{|ele| ele = ele == -1 ? 0 : ele }.join
else
  puts table.map{|ele| ele = ele == -1 ? 0 : ele }.join
end

Measured memory_bytes: 1788
n=int(input())
nt,nx,ny=0,0,0
for i in range(n):
    t,tx,ty=map(int,input().split())
    dis=abs(tx-nx)+abs(ty-ny)
    tm=t-nt
    if dis>tm or dis%2!=tm%2:
        print("No")
        exit()
    nt,nx,ny=t,tx,ty
print("Yes")

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
    int n,m,k;
    cin>>n>>m;
    int a[n][m]={};
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int b[m]={};
    for(int i=0;i<m;i++) cin>>b[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            k+=a[i][j]*b[j];
        }
        cout<<k<<endl;
        k=0;
    }
    return 0;
}


Measured memory_bytes: 3144
text = [s for s in input().split()]
s_text = set(text)
a, b = 0, 0
for s in s_text:
    if text.count(s) > a:
        a = text.count(s)
        x = s
    if len(s) > b:
        b = len(s)
        y = s
print(x, y)

Measured memory_bytes: 7436
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
#define _CRT_SECURE_NO_DEPRECATE
#define MP make_pair
#define INF (int)1e9
#define read(type) readInt<type>()
#define IN(path) freopen(path,"r",stdin)

typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;

template <typename T> inline void write(T x)
{
	int i = 20;
	char buf[21];
	// buf[10] = 0;
	buf[20] = '\n';

	do
	{
		buf[--i] = x % 10 + '0';
		x /= 10;
	} while (x);
	do
	{
		putchar(buf[i]);
	} while (buf[i++] != '\n');
}

template <typename T> inline T readInt()
{
	T n = 0, s = 1;
	char p = getchar();
	if (p == '-')
		s = -1;
	while ((p<'0' || p>'9') && p != EOF && p != '-')
		p = getchar();
	if (p == '-')
		s = -1, p = getchar();
	while (p >= '0'&&p <= '9') {
		n = (n << 3) + (n << 1) + (p - '0');
		p = getchar();
	}

	return n * s;
}

int V, N;
PLL arr[5002];
long long dp[102][100002];
long long knapsack(long long i, long long w) {
	if (i < 0) {
		return 0;
	}
	if (dp[i][w] != -1) {
		return dp[i][w];
	}
	if (arr[i].first > w) {
		dp[i][w] = knapsack(i - 1, w);
	}
	else{
		dp[i][w] = max(arr[i].second + knapsack(i - 1, w - arr[i].first),
			knapsack(i - 1, w));
	}
	return dp[i][w];
}

int main() {

	N = read(long long); V = read(long long);
	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 100001; j++) {
			dp[i][j] = -1;
		}
	}
	for (int i = 0; i < N; i++) {
		int vi, wi;
		wi = read(long long); vi = read(long long);
		arr[i] = MP(wi, vi);
	}

	write(knapsack(N-1,V));
}

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

int main() {
    //
    long long num;
    long long cnt = 0;

    cin >> num;
    vector<long long> vec(num);

    for (int i = 0; i < num; i++) cin >> vec.at(i);

    for (int i = 0; i < num - 2; i++) {
        for (int j = i + 1; j < num - 1; j++) {
            if (vec.at(i) == vec.at(j)) continue;
            for (int k = j + 1; k < num; k++) {
                if (vec.at(j) == vec.at(k)) continue;
                if (vec.at(i) == vec.at(k)) continue;
                if (vec.at(i) + vec.at(j) > vec.at(k) && vec.at(i) + vec.at(k) > vec.at(j) && vec.at(k) + vec.at(j) > vec.at(i)) {
                    //cout << i+1 << "," << j+1 << "," << k+1 << endl;
                    cnt++;
                }
            }
        }
    }

    cout << cnt;
}


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

signed main(){
  int N, A, B;
  cin >> N >> A >> B;
  int now;
  cin >> now;
  int ans = 0;
  for ( int i = 0; i < N-1; i++ ) {
    int a;
    cin >> a;
    ans += min((a-now)*A, B);
    now = a;
  }

  cout << ans << endl;
}


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

using namespace std;

int n, h;

int main () {
    scanf ("%d%d", &h, &n);
    for (int i = 1, x;i <= n;i ++) {
        scanf ("%d", &x);
        h -= x;
    }
    printf("%s", (h <= 0 ? "Yes" : "No"));
}


Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    int r = 0;
    int ans = n+1;
    for (int l = 0; l < n; ++l) {
        while (r < n && sz(mp) < k) {
            if (a[r] <= k) mp[a[r]]++;
            r++;
        }
        if (sz(mp) < k) break;
        chmin(ans, r - l);
        if (a[l] <= k) {
            if (mp[a[l]] == 1) mp.erase(a[l]);
            else mp[a[l]]--;
        }
    }
    cout << (ans == n+1 ? 0 : ans) << endl;
}



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

int main () {
  
  char c;
  cin >> c;
  
  if(c == 'a'|| c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(){
	int a, b, c, d, e;
	cin >> a >> b;
	c = a + (a-1);
	d = b + (b-1);
	e = a + b;
	if (e>=d && e>=c){
		cout << e << endl;
	}else if (c>=d && c>=e){
		cout << c << endl;
	}else if (d>=e && d>=c){
		cout << d << endl;
	}
	return 0;
}

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

using namespace std;


int N, M;
int A[310][310];
bool unused[310];

int main(){

    cin >> N >> M;
    for(int i = 0; i < N; i++)
        for(int j = 0; j < M; j++)
            cin >> A[i][j], A[i][j]--;
    
    int ans = 1<<29;
    for(int ite = 0; ite < M; ite++){
        int freq[310] = {};
        for(int i = 0; i < N; i++){
            for(int j = 0; j < M; j++){
                if(!unused[A[i][j]]){
                    freq[A[i][j]]++;
                    break;
                }
            }
        }
        int best_sport = 0;
        for(int i = 0; i < M; i++){
            if(freq[best_sport] < freq[i]){
                best_sport = i;
            }
        }
        ans = min(ans, freq[best_sport]);
        unused[best_sport] = true;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
s=list(str(input()))
t=list(str(input()))
n=len(s)
f=True
g=False
for i in range(n):
    f = True
    for j in range(n):
        if t[j]==s[(i+j)%n]:
            f = f and True
        else:
            f = False
    if f:
        g = g or f
if g:
    print("Yes")
else:
    print("No")
    

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

const int MAX_N = 105;

struct Node
{
  long long v, w;

  Node () {}

  Node (long long v_, long long w_) : v(v_), w(w_) {}

  bool operator < (const Node &b) const
  {
    return v > b.v;
  }
};

int N, W;
long long w1;
vector<Node> v[4];
long long s[4][MAX_N];

int Bs(int l, int r, long long tmp_w)
{
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (tmp_w + (w1 + 3) * mid <= W) l = mid;
    else r = mid;
  }
  return l;
}

int main()
{
  #ifdef OJ
    freopen("/home/linjian/Documents/cpp_programs/in.txt", "r", stdin);
  #endif
  cin >> N >> W;
  long long v1; scanf("%lld%lld", &w1, &v1);
  v[0].push_back(Node(v1, w1));
  for (int i = 1; i < N; ++i) {
    long long tmp_w, tmp_v; scanf("%lld%lld", &tmp_w, &tmp_v);
    v[tmp_w - w1].push_back(Node(tmp_v, tmp_w));
  }
  for (int i = 0; i < 4; ++i) {
    sort(v[i].begin(), v[i].end());
    s[i][0] = 0;
    for (int j = 0; j < (int)v[i].size(); ++j) {
      s[i][j + 1] = s[i][j] + v[i][j].v;
    }
  }
  long long max_v = 0;
  for (int i = 0; i <= (int)v[0].size(); ++i) {
    for (int j = 0; j <= (int)v[1].size(); ++j) {
      for (int k = 0; k <= (int)v[2].size(); ++k) {
        long long tmp_w = w1 * i + (w1 + 1) * j + (w1 + 2) * k;
        long long tmp_v = s[0][i] + s[1][j] + s[2][k];
        if (tmp_w > W) continue;
        int l = Bs(0, (int)v[3].size() + 1, tmp_w);
        tmp_v += s[3][l];
        // if (i == 0 && j == 2 && k == 0) printf("l=%d\ttmp_v=%d\n", l, tmp_v);
        max_v = max(max_v, tmp_v);
        // if (max_v < tmp_v) {
          // max_v = tmp_v;
          // printf("w:%d\tw+1:%d\tw+2:%d\tw+3:%d\n", i, j, k, l);
        // }
      }
    }
  }
  printf("%lld\n", max_v);
  return 0;
}

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

int main()
{
	string s;
	cin >> s;

	if(s[0] == s[1] or s[1] == s[2] or s[2] == s[3]) cout << "Bad" << endl;
	else cout << "Good" << endl;

	return 0;
}


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

public class Main{

  private class ValueManager {

    private long a;

    private long b;

    private int k;

    private long[] aSum;

    private long[] bSum;

    private int idx = 0;

    public ValueManager(long a, long b, int k) {
      super();
      this.a = a;
      this.b = b;
      this.k = k;
      this.aSum = new long[this.k];
      this.bSum = new long[this.k];
    }

    public boolean calcuNumCookies(String downTarget) {
      if ("a".equals(downTarget)) {
        this.a = (this.a % 2 != 0) ? this.a - 1 : this.a;

        final long half = this.a / 2;
        this.a -= half;
        this.b += half;

      } else if ("b".equals(downTarget)) {
        this.b = (this.b % 2 != 0) ? this.b - 1 : this.b;

        final long half = this.b / 2;
        this.b -= half;
        this.a += half;
      }

      this.aSum[idx] = a;
      this.bSum[idx] = b;

      return (this.k == ++this.idx);
    }

    public long getFinalValueA() {
      return this.aSum[aSum.length - 1];
    }

    public long getFinalValueB() {
      return this.bSum[bSum.length - 1];
    }
  }

  public static void main(String[] args) {

    Main main = new Main();
    Main.ValueManager vManager = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      String[] tmp = br.readLine().split("\\s");
      final long a = Long.parseLong(tmp[0]);
      final long b = Long.parseLong(tmp[1]);
      final int k = Integer.parseInt(tmp[2]);
      vManager = main.new ValueManager(a, b, k);
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    while (true) {
      boolean bFlag = vManager.calcuNumCookies("a");
      if (bFlag) {
        break;
      }
      bFlag = vManager.calcuNumCookies("b");
      if (bFlag) {
        break;
      }
    }

    System.out.printf("%d %d", vManager.getFinalValueA(), vManager.getFinalValueB());
  }
}


Measured memory_bytes: 22868
import bisect

n = int(input())
abc = [tuple(map(int, input().split(" "))) for i in range(3)]
# n = 100000
# abc = [tuple(range(n)) for i in range(3)]

a, b, c = [sorted(abc_i) for abc_i in abc]

print(sum(bisect.bisect_left(a, b_i) * (n-bisect.bisect(c, b_i)) for b_i in b))

Measured memory_bytes: 23200
def main():
    n, k = map(int, input().split())
    s = list("*" + input() + "*")
    count = 0
    for i in range(1, n + 1):
        if (s[i] == s[i - 1] == "L") or (s[i] == s[i + 1] == "R"):
            count += 1
    print(min(count + 2 * k, n - 1))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3956
import numpy as np
N, W = map(int, input().split())
w, v = [], []
for i in range(N):
    a, b = map(int, input().split())
    w += [a]
    v += [b]
 
DP = np.zeros(W+1, dtype=int)
# i 円以下で買える商品の最大価値
for i in range(N):
    DP[w[i]:] = np.maximum(DP[:-w[i]]+ v[i], DP[w[i]:])
print(DP[-1])

Measured memory_bytes: 15480
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		if (A % 2 == 1 && B % 2 == 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		scan.close();
	}
}


Measured memory_bytes: 22612
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 500010;
const int MOD = (ll)1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

typedef pair<int, int>P;

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





vector<int>v[1010];
vector<int>ans[1010];
signed main() {
	int N; cin >> N;
	if (N % 2 == 0) {
		int k = N / 2;
		REP(i, k) {
			v[i].pb(i + 1); v[i].pb(N - i);
		}
		int cnt = 0;
		REP(i, k-1) {
			for (auto x : v[i]) {
				for (auto y : v[i + 1]) {
					cnt++;
				}
			}
		}
		if (k > 2) {
			for (auto x : v[k - 1]) {
				for (auto y : v[0]) {
					cnt++;
				}
			}
		}
		print(cnt);
		REP(i, k - 1) {
			for (auto x : v[i]) {
				for (auto y : v[i + 1]) {
					pe(x); print(y);
				}
			}
		}
		if (k > 2) {
			for (auto x : v[k - 1]) {
				for (auto y : v[0]) {
					pe(x); print(y);
				}
			}
		}
	}
	if (N % 2 == 1) {
		int k = N / 2 + 1;
		REP(i, k-1) {
			v[i].pb(i + 1); v[i].pb(N - i - 1);
		}
		v[k - 1].pb(N);
		int cnt = 0;
		REP(i, k - 1) {
			for (auto x : v[i]) {
				for (auto y : v[i + 1]) {
					cnt++;
				}
			}
		}
		if (k > 2) {
			for (auto x : v[k - 1]) {
				for (auto y : v[0]) {
					cnt++;
				}
			}
		}
		print(cnt);
		REP(i, k - 1) {
			for (auto x : v[i]) {
				for (auto y : v[i + 1]) {
					pe(x); print(y);
				}
			}
		}
		if (k > 2) {
			for (auto x : v[k - 1]) {
				for (auto y : v[0]) {
					pe(x); print(y);
				}
			}
		}
	}
}	


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

using namespace std;

int main()
{ ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0) ;
   string a, b ;
   int n ;
   cin>>n;
   cin >> a >> b;
   for ( int i = 0 ; i<n;i++) cout<<a[i]<<b[i] ;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>            
using namespace std;
#define pb push_back
typedef long long ll;
typedef long double ld;
const int add = 1e9;
const int INF = 2e9;
const ll mod = 1e9 + 7;
const ll mod1 = 3e9 + 19;
const ll mod2 = 3e9 - 71;
const ll longINF = 3e18;
const ll ph = 31;
const ld pi = acos(-1);
const ld eps = 1e-8;
const int M = 1 << 18;

int n, m, k;
                                                                                                                                                                                                               
int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);                                                                                         
	cout.tie(0);
	#ifdef LOCAL
        	freopen("input.txt", "r", stdin);
        	freopen("output.txt", "w", stdout);
        #endif               
        cin >> n >> m >> k;
        for (int i = 0; i <= n; i++) {
        	for (int j = 0; j <= m; j++) {
        		if (n * m - i * j - (n - i) * (m - j) == k) {
        			cout << "Yes";
        			return 0;
        		}
        	}
        }
        cout << "No";
	return 0;
}

Measured memory_bytes: 256
SA = list(str(input())) 
SB = list(str(input())) 
SC = list(str(input())) 
list=[SA,SB,SC]
a=0
while True:
    if len(list[a])==0:
        break
    b=ord(list[a][0])-97
    list[a].pop(0)
    a=b
print(chr(a+65))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
     ll n;
     cin>>n;
     cout<<(n^1);
   }
}

Measured memory_bytes: 3600
# sortして累積和と元のリストを後ろから比較。
N = int(input())
A = list(map(int, input().split()))
A.sort()
R = []
s = 0
for i in A:
  s += i
  R.append(s)
  
# R = [sum(A[:i]) for i in range(N)]

A.sort(reverse=True)
R.sort(reverse=True)
#print(A)
#print(R)

cnt = 1
for i,j in zip(R[1:], A[:-1]):
#  print(i,j)
  if i * 2 >= j:
    cnt += 1
  else:
    break
print(cnt)

Measured memory_bytes: 65896
def main():
    N = int(input()[-1])  # 文字列または整数(一変数)

    if N == 3:
        print("bon")
        return
    if N == 0 or N == 1 or N == 6 or N == 8:
        print("pon")
        return
    print("hon")
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=0;
    rep(i,101){
        if(a<=i&&i<b&&c<=i&&i<d)ans++;
    }
    cout<<ans<<endl;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    ll a,b,n;
    Scll3(a,b,n);

    double x = min(b-1,n)%b;
    printf ("%lld\n", (ll)(a*x/b) );

    return 0;
}



Measured memory_bytes: 3824
#include <stdio.h>
void sort(int A[], int len_A){
    int i, j, tmp;
    for (i = 0; i < len_A - 1; i++){
        for (j = 0; j < len_A - 1; j++){
            if (A[j + 1] < A[j]){
                tmp = A[j];
                A[j] = A[j + 1];
                A[j + 1] = tmp;
            }
        }
    }
}

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

    int alice = 0;
    int bob = 0;
    sort(a, n);
    /*
    for (int i = 0; i < n; i++){
        printf("%d\n", a[i]);
    }
    */

    if (n % 2 == 0){
        for (int i = 0; i < n; i++){
            if (i % 2 == 0){
                bob += a[i];
            }
            else {
                alice += a[i];
            }
        }
    }
    else {
        for (int i = 0; i < n; i++){
            if (i % 2 == 0){
                alice += a[i];
            }
            else {
                bob += a[i];
            }
        }
    }

    int ans = alice - bob;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    long long H, W, A, B, i, j;

    cin >> H >> W >> A >> B;

    for(i=1; i<=H; i++){
        for(j=1; j<=W; j++){
            if((i<=B&&j<=A) || (i>B&&j>A)){
                cout << 1;
            }
            else{
                cout << 0;
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        long n = input.nextLong();
        long ans = 0;
        for (int i = 1; i < n+1;i++){
            if (i%3 == 0 || i%5 == 0){
                continue;
            } else {
                ans += i;
            }
        }
        System.out.println(ans);
    }
}

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

int main(){


  string a,b;
  int f=1,cnt=0,cnt1=0;

  cin>>a>>b;
  
  for(int i=0;i<(int)a.size();i++) cnt++;
  for(int i=0;i<(int)b.size();i++) cnt1++;
  
  
  if(cnt<cnt1){
    for(int i=0;i<(int)a.size();i++){
  if(f==1){
    cout<<a[i];
    f=0;
  }
  if(f==0){
     cout<<b[i];
      f=1;
  }

    }
      cout<<b[cnt1-1];
  }
  if(cnt>cnt1){
  for(int i=0;i<(int)b.size();i++){
  if(f==1){
    cout<<a[i];
    f=0;
  }
  if(f==0){
     cout<<b[i];
      f=1;
  }

    }
  cout<<a[cnt-1];

  }
   if(cnt==cnt1){
  for(int i=0;i<(int)a.size();i++){
  if(f==1){
    cout<<a[i];
    f=0;
  }
  if(f==0){
     cout<<b[i];
      f=1;
  }
    }


  }
  cout<<endl;


  return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int N, K;
	cin >> N >> K;

	vector<int> a( N+1 );
	for( int i = 0; i < N; ++i ) {
		int x;
		cin >> x;
		a[x] += 1;
	}

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

	int ks = 0;
	for( int i = N; i > N-K; --i ) {
		ks += a[i];
	}

	cout << N - ks << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MAXN 1000005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
int main()
{
    scanf("%d",&n);
    printf("%d\n",(n-1)/2);
}


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

int main(){
    int c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
    }
    int dif1 = c[0][1] - c[0][0];
    int dif2 = c[0][2] - c[0][1];

    if(c[1][1] - c[1][0] == dif1 && c[1][2] - c[1][1] == dif2 
    && c[2][1] - c[2][0] == dif1 && c[2][2] - c[2][1] == dif2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] aArr = new int[n];
		int[] bArr = new int[n];
		
		for(int i = 0; i < n; i++) {
			aArr[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			bArr[i] = sc.nextInt();
		}
		sc.close();
		int a = getUnderNum(aArr);
		int b = getUnderNum(bArr);
		
		System.out.println(Math.abs(a - b));
	}
	
	public static int getUnderNum(int[] intArr) {
		
		int n = intArr.length;
		int retVal = 0;
		
		for(int i = 0; i < n - 1; i++) {
			
			int under = 0;
			for(int j = 0; j < i; j++) {
				if(intArr[j] < intArr[i]) {
					under++;
				}
			}
			
			retVal += (intArr[i] - 1 - under) * fact(n - i - 1); 
		}
		
		return retVal;
	}
	
	public static int fact(int n) {
		int retVal = 1;
		for(int i = 1; i <= n; i++) {
			retVal *= i;
		}
		return retVal;
	}
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int ch[] = {0,2,5,5,4,5,6,3,7,6};
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i,m)cin >> a[i];
  sort(a.rbegin(),a.rend());
  vector<int> dp(n+1,-1);
  dp[0] = 0;
  rep(i,n)rep(j,m){
    if(i+ch[a[j]] > n)continue;
    dp[i+ch[a[j]]] = max(dp[i+ch[a[j]]],dp[i]+1);
  }
  vector<int> v(10,0);
  for(int i = n;i > 0;){
    bool is = false;
    rep(j,m){
      if(i-ch[a[j]] >= 0 && dp[i]-1 == dp[i-ch[a[j]]]){
        v[a[j]]++;
        i -= ch[a[j]];
        is = true;
        break;
      }
    }
    assert(is);
  }
  for(int i = 9;i > 0;i--)rep(j,v[i])cout << i;
  cout << endl;




  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
typedef long long int lli;
const lli inf = 1e18;

int main(){
	lli l,n;
	cin >> l >> n;
	vector<lli> x(n);
	for(int i=0; i<n; i++) cin >> x[i];

	lli ans = 0;
	for(int d=0; d<2; d++){
		vector<lli> sum(n+1, 0);
		vector<lli> bsum(n+1, 0);
		for(int i=0; i<n; i++){
			sum[i+1] = sum[i]+x[i];
			}
		for(int i=n-1; i>=0; i--){
			bsum[i] = bsum[i+1]+(l-x[i]);
		}
		for(int i=0; i<n; i++){
			int m = n-i-1;
			lli sub = sum[i+(m+1)/2]-sum[i] +bsum[n-m/2];
			sub *= 2;
			if(m%2 == 0){
				sub += x[i+m/2];
			}else{
				sub += l-x[n-(m+1)/2];
			}
			ans = max(ans, sub);
		}
		for(int i=0; i<n; i++){
			x[i] = l-x[i];
		}
		reverse(x.begin(), x.end());
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
import java.nio.file.*;
import java.nio.charset.*;
import java.util.*;


public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(b / a > c){
            System.out.println(c);
        }else{
            System.out.println(b / a);
        }
    }
}



Measured memory_bytes: 22612
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int a[20], b[20], c[20];

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

    rep(i, n)
    {
        cin >> a[i];
        a[i]--;
    }
    rep(i, n)
    {
        cin >> b[i];
    }
    rep(i, n - 1)
    {
        cin >> c[i];
    }

    int score = 0;
    rep(i, n)
    {
        score += b[a[i]];
    }

    rep(i, n - 1)
    {
        if (a[i] + 1 == a[i + 1]) {
            score += c[a[i]];
        }
    }
    cout << score << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> list = {64,32,16,8,4,2,1};
  for (int i=0; i<7; i++) {
    if (list.at(i) <= n) {
      cout << list.at(i) << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define quick ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int main()
{
	quick;
	int n;
	cin>>n;
	double a;
	double sum=0;
	string s;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>s;
		if(s=="JPY")
			sum+=a;
		else
			sum+=a*380000.0;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
s=raw_input()
flag=0
s1=s[::-1]
# print s1
if s1!=s:
  print "No"
  exit(0)
s1=s[0:(len(s)-1)/2]
s2=s1[::-1]
# print s1
if s1!=s2:
  print "No"
  exit(0)

print "Yes"

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

int main(){
  int n,m,c;
  cin>>n>>m>>c;
  int a[n][m];
  int b[m];
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int sum=c;
    for(int j=0;j<m;j++){
      cin>>a[i][j];
      sum+=a[i][j]*b[j];
    }
    if(sum>0){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Ohajiki Game
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=sc.nextInt();
			int r = 32;
			int k = 0;
			boolean f = true;
			while(r>0){
				if(f)r-=(r-1)%5;
				else {
					r=Math.max(0, r-a[k]);
					k=(k+1)%n;
				}
				System.out.println(r);
				f=!f;
			}
		}
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
const int N=1e5+5;

int n,m,f[N],ans,a[N],mid,b[N],c[N],ky;
ll num;

inline void update(int x,int y){ for(;x<=ky;x+=x&-x) f[x]+=y;}
inline int query(int x){ int an=0; for(;x;x-=x&-x) an+=f[x]; return an;}

inline ll calc(){
	ll an=0;
	b[0]=0,memset(f,0,sizeof(f));
	for(int i=1;i<=n;i++) b[i]=b[i-1]+(a[i]<=mid?1:-1),c[i]=b[i];
	c[ky=n+1]=0,sort(c+1,c+ky+1),ky=unique(c+1,c+ky+1)-c-1;
	for(int i=0;i<=n;i++) b[i]=lower_bound(c+1,c+ky+1,b[i])-c;
	
	update(b[0],1);
	for(int i=1;i<=n;i++) an+=(ll)query(b[i]-1),update(b[i],1);
	
	return an;
}

inline void solve(){
	int L=1,R=1e9;
	while(L<=R){
		mid=L+R>>1;
		if(calc()>=num) ans=mid,R=mid-1;
		else L=mid+1;
	}
}

int main(){
	scanf("%d",&n),num=n*(ll)(n+1)>>1,num=(num>>1)+1;
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	
	solve();
	
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  int a,b,c,x,n,t,frame=0;

  while(1){
    cin>>n>>a>>b>>c>>x;
    if(!(n||a||b||c||x))break;
    queue<int> q;

    for(int i=0; i<n; i++){
      cin>>t;
      q.push(t);
    }

    t=0;
    while(!q.empty()){
      if(frame > 10000) {
	frame=0;
	break;
      }

      if(x==q.front()) {
	q.pop();
	//cout<<x<<" "<<frame<<endl;
      }
      x=(a*x+b)%c;
      frame++;
    }

    cout<<frame-1<<endl;
    frame=0;
  }
}

Measured memory_bytes: 908
#include<iostream>
using namespace std;
int main()
{
    int a,b,sub=0;
    cin>>a;
    cin>>b;
    if(a>=13)
    {
        cout<<b;
    }
    if(a>=6 && a<=12)
    {
        cout<<b/2;
    }
    if(a<=5)
    {
        cout<<0;
    }
}


Measured memory_bytes: 256
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  s = input()
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'TLE':
    tle += 1
  elif s == 'RE':
    re += 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

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

using namespace std;

int N;
int x[200000];
int y[200000];

int main(){
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
        y[i] = x[i];
    }

    sort(x, x + N);

    int m1 = x[N / 2 - 1];
    int m2 = x[N / 2];

    for (int i = 0; i < N; ++i) {
        if (y[i] <= m1) {
            cout << m2 << endl;
        } else {
            cout << m1 << endl;
        }
    }
}

Measured memory_bytes: 3712
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pr pair<int,int>
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#ifdef DEBUG
    #define GG(x) assert(x)
#else
    #define GG(x) (x)
#endif
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e>=0);while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    ll f[N],a[N];
    void main()
	{
        ll n=qread(),E=qread(),T=qread();fo(i,1,n) a[i]=qread();a[n+1]=E;
        memset(f,0x3f,sizeof f);f[0]=0;ll pre=bin(45);
        for(int j=0,i=1;i<=n;i++)
        {
            while(a[j+1]+a[j+1]<=a[i]+a[i]-T) chmin(pre,f[j]-a[j+1]-a[j+1]),j++;
            assert(j<=i);assert(f[i-1]<=f[i]);
            f[i]=min(pre+a[i]+a[i],f[j]+T);
        }
        write(f[n]+E);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


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

int main() {
  char c[3];cin>>c;
  string ans = c[0]==c[2]?"Yes":"No";
  cout << ans << endl;
}


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

namespace {
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define LEN(x) (int)((x).size())
#define X first
#define Y second

#define FOR(i, begin, end)  \
  for (__typeof(end) i = (begin) - ((begin) > (end));  \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
  
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<ll> vll;
template<typename T> using min_pq = priority_queue<T, vector<T>, greater<T>>;

ll expmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

struct IOS { IOS() { ios::sync_with_stdio(0); cin.tie(0); } } IOS;
}

const int MAX_N = 200000;
const ll MODD = 1000000009LL;
const ld EPS = 1e-9;

vector<string> grid;

int main() {
	int H, W;
	cin >> H >> W;
	grid.resize(H);
	FOR(i,0,H) cin >> grid[i];
	
	vector<string> red(H, string(W, '.'));
	vector<string> blue(H, string(W, '.'));
  
	FOR(i,0,H) blue[i][0] = '#';
  
	FOR(i,0,H) {
		if (i % 2 == 0) continue;
		FOR(j,0,W-1) {
			blue[i][j] = '#';
		}
	}
	
	FOR(i,0,H) FOR(j,0,W)
		if (blue[i][j] == '.')
			red[i][j] = '#';
		
	FOR(i,0,H) FOR(j,0,W)
		if (grid[i][j] == '#')
			red[i][j] = blue[i][j] = '#';
	
	FOR(i,0,H) cout << red[i] << '\n';
	cout << '\n';
	FOR(i,0,H) cout << blue[i] << '\n';
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    string S; cin >> S;
    if (S == "AAA" | S == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

  public static void main(String [] args) {

    Scanner s = new Scanner(System.in);
    int n = s.nextInt();

    int[] dp = new int[n + 1];

    dp[0] = 0;
    dp[1] = 1;

    for (int i = 2; i <= n; i ++) {
      int min = dp[i - 1] + 1;

      for (int j = 6; j <= i; j *= 6) {
        if (dp[i - j] + 1 < min)
          min = dp[i - j] + 1;
      }

      for (int j = 9; j <= i; j *= 9) {
        if (dp[i - j] + 1 < min)
          min = dp[i - j] + 1;
      }

      dp[i] = min;
    }

    System.out.println(dp[n]);

  }

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int t[100010][2],id=1;
ll l;

void add(string &s){
	int now=0;
	for(auto x:s){
		if(t[now][x-'0']<0) t[now][x-'0']=id++;
		now=t[now][x-'0'];
	}
}

ll get(ll x){
	ll ans=1;
	while(x%2==0) x/=2,ans*=2;
	return ans;
}

ll dfs(int pos, int len){
	int v1=t[pos][0]<0, v2=t[pos][1]<0;
	ll ans=0;
	if(v1!=v2) ans=get(l-len);
	if(!v1) ans^=dfs(t[pos][0],len+1);
	if(!v2) ans^=dfs(t[pos][1],len+1);
	return ans;
}

int main(){FIN;
	memset(t,-1,sizeof(t));
	int n; cin>>n>>l;
	fore(i,0,n){
		string s; cin>>s;
		add(s);
	}
	if(dfs(0,0)) cout << "Alice\n";
	else cout << "Bob\n";
}

Measured memory_bytes: 4332
#include <iostream>
#include <string>
using namespace std;
#define INF 1000000000000000000

int main(){
    int i, n;
    long int sum = 1;
    bool flag = false;

    cin >> n;
    long long a[n];
    for(i=0;i<n;i++){
        cin >> a[i];
        if(a[i] == 0){
            cout << 0 << endl;
            flag = true;
            break;
        }
    }
    if(flag == false){
        for(i=0;i<n;i++){
            if(INF/sum < a[i]){
                cout << -1 << endl;
                flag = true;
                break;
            }
            sum *= a[i];
        }
    }

    if(flag == false){
        cout << sum << endl;
    }

    return 0;
}

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

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 105;

int n;
ll capacity;
ll w[N],a[N];
ll dp[N][10*N*N];


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

    cin>>n>>capacity;
    for(int i=1;i<=n;i++)cin>>w[i]>>a[i];

    for(int i=1;i<=n;i++){
        for(int j=0;j<=capacity;j++){
            if(w[i]<=j){
                dp[i][j]=max(dp[i][j],a[i]+dp[i-1][j-w[i]]);
            }
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
        }
    }
    ll ans=0;
    for(int j=0;j<=capacity;j++)ans=max(ans,dp[n][j]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 87424
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    string s ;
    cin >> s ;
    int n = s.size();
    int ans = 999 ;
    for(int i = 0; i <= n - 3; ++i){
    int num = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + s[i+2] - '0';
    ans = min(ans, abs(num - 753));
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
const int nmax = 1e6;
int k, x;
int main() {
    cin >> k >>  x;
    if(k == 1) cout << x << endl;
    else {
        for(int i = x - k + 1; i <= x + k - 1; ++i) {
            cout << i << " ";
        }
        cout << endl;
    }
    
}

Measured memory_bytes: 256