akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;
vector<vector<ll>> dp = vector<vector<ll>>(100005, vector<ll>(13, 0));
vector<vector<int>> mod = vector<vector<int>>(100005, vector<int>(13, 0));
int main() {
  string S;
  cin >> S;
  REP(i, 13) mod[1][i] = i;
  REPS(i, 2, 100005) {
    REP(j, 13) { mod[i][j] = mod[i - 1][j] * 10 % 13; }
  }

  dp[0][0] = 1;

  REPS(i, 1, S.size() + 1) {
    int c = -1;
    if(S[S.size() - i] != '?') {
      c = S[S.size() - i] - '0';
    }
    REP(j, 13) {
      if(c == -1) {
        REP(k, 10) { dp[i][j] += dp[i - 1][(j + 13 - mod[i][k]) % 13]; }
      } else {
        dp[i][j] += dp[i - 1][(j + 13 - mod[i][c]) % 13];
      }
      dp[i][j] %= MOD;
    }
  }

  cout << dp[S.size()][5] << endl;
}


Measured memory_bytes: 22400
N = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
L = [A[i] - B[i] for i in range(N)]
ans = 0
if sum(A) < sum(B) :
    ans = -1
else :
    debt = []
    deposit = []
    for i in range(N) :
        if L[i] < 0 :
            debt.append(-L[i])
        elif L[i] > 0 :
            deposit.append(L[i])
        
    debt = sorted(debt)
    deposit = sorted(deposit,reverse=True)
    
    debt_duplicated = debt.copy()
    deposit_duplicated = deposit.copy()
    
    deposit_trash = []
    
    #print(debt)
    #print(deposit)
    
    for i in range(len(debt)) :
        
        while True :
            if debt[i] == 0 :
                break
            else :
                if debt[i] <= deposit[0] :
                    deposit[0] -= debt[i]
                    debt[i] = 0
                else :
                    debt[i] -= deposit[0]
                    deposit[0] = 0
                    deposit_trash.append(deposit.pop(0))
        
            
        
#        for j in range(len(deposit)) :
#            if debt[i] <= deposit[j] :
#                deposit[j] -= debt[i]
#                debt[i] = 0
#                break
#            else :
#                debt[i] -= deposit[j]
#                deposit[j] = 0
    deposit = deposit_trash + deposit
    for i in range(len(debt)) :
        if debt[i] != debt_duplicated[i] :
            ans += 1
    for i in range(len(deposit)) :
        if deposit[i] != deposit_duplicated[i] :
            ans += 1

print(ans)
#print(debt)
#print(deposit)



Measured memory_bytes: 19024
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int k = sc.nextInt();
    int x = sc.nextInt();

    List<String> ans = new ArrayList<>();
    for (int i = Math.max(-1000000, x - k + 1); i <= Math.min(1000000, x + k - 1); i++) {
      ans.add(String.valueOf(i));
    }
    os.println(String.join(" ", ans));
  }
}

Measured memory_bytes: 23252
#include <stdio.h>


typedef struct{
	int index;
	int s;
}STACK_T;


int main()
{
	char c;
	char figure[20000];
	int stack[20000];
	STACK_T stack2[20000];
	int sp, sp2;
	int index;
	int count, sum;
	int i;


	// データを入力
	i = count = 0;
	while( (c = fgetc(stdin)) != '\n'){
		figure[i++] = c;
		count++;
	}


	// 面積の計算
	sp = sp2 = sum = 0;
	for(i = 0; i < count; i++){
		// スタックに積んでいく
		if(figure[i] == '\\')
			stack[sp++] = i;
		// スタックから取り出す&面積の計算
		else if(figure[i] == '/' && sp >= 1){
			index = stack2[sp2].index = stack[--sp];
			sum += stack2[sp2].s = i - stack[sp];
			// 結合
			while(sp2 >= 1 && index < stack2[sp2 - 1].index){
				stack2[--sp2].index = index;
				stack2[sp2].s += stack2[sp2 + 1].s;
			}
			sp2++;
		}
	}


	// 表示
	printf("%d\n", sum);
	printf("%d", sp2);
	for(i = 0; i < sp2; i++){
		if(i == 0)
			printf(" ");
		printf("%d", stack2[i].s);
		if(i != sp2 - 1)
			printf(" ");
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define srep(i, from, to) for(int i=from;i<(int)(to);i++)

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

  vector<string> s(n);
  rep(i, n) cin >> s[i];

  map<string, ll> m;

  rep(i, n) {
    string x = s[i];
    sort(x.begin(), x.end());
    m[x] += 1;
  }

  ll ans = 0;
  for(auto& p:m) {
    ans += p.second*(p.second-1)/2;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 18176
//
// Created by user on 3/9/2020.
//
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
    ios_base :: sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    bool A = false, B = false;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == 'A') A = true;
        else B = true;
    }
    if (A == true and B == true) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10010];
int out[110][110];
int now;
int h , w , n;
void dfs(int x,int y){
    if(y < 0 || h <= y || x < 0 || w <= x)
        return;
    if(out[y][x] != 0) //塗り終わった
        return;
    if(now == n)
        return;
    out[y][x] = now + 1;
    a[now]--;
    if(a[now] == 0)
        now ++;
    dfs(x + 1 , y);
    dfs(x - 1 , y);
    dfs(x , y + 1);
    dfs(x , y - 1);
}
int main(){
    cin >> h >> w >> n;
    int in;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    dfs(0,0);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++)
            cout << out[i][j] << (j == w - 1 ? "" : " ");
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 768
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <iostream>
#include <utility>
#include <sstream>
#include <cstring>
#include <bitset>
#include <climits>
 
using namespace std;
#define  AS(arr)  (sizeof(arr)/sizeof(arr[0]))
#define ALL(c) (c).begin(),(c).end() 
#define SIZE(a) int((a).size())
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define REP(i,n) for(int i=0;i<(int)n;++i)
typedef vector<int> VI;
typedef vector<string> VS;
typedef long long LL;
int a[100005];
int b[100005];

int main(void){
    int N;
    cin >> N;
    long long ret = 0;
    REP(i, N)
    {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(&b[0], &b[N]);
    REP(i,N)
    {
        auto it = lower_bound(&b[0], &b[N], a[i]);
        if(abs(it - &a[i]) % 2 == 1) ret++;
    }
    ret /= 2;
    cout << ret << endl;
}


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

int n;
long a[410];
long s[410];
long dp[410][410];

long solve(int l, int r){
  if(l >= r) return 0;
  if(dp[l][r] > 0) return dp[l][r];
  long ret = solve(l, l) + solve(l+1, r);
  for(int i=1; i<r-l; i++) ret = min(ret, solve(l, l+i) + solve(l+i+1, r));
  return dp[l][r] = ret + s[r+1] - s[l];
}

int main(){
  cin >> n;
  s[0] = 0;
  rep(i, n){
    cin >> a[i];
    s[i+1] = s[i] + a[i];
  }
  rep(i, n){
    rep(j, n) dp[i][j] = 0;
    if(i<n-1) dp[i][i+1] = a[i] + a[i+1];
  }
  cout << solve(0, n-1) << endl;
}

Measured memory_bytes: 1536
st = input()
total = int(st)
signs = len(st) - 1
for i in range(1, 2 ** signs):
    start = 0
    for j in range(1, signs + 1):
        if (i & (1 << (j - 1))) >> (j - 1) == 1:
            total += int(st[start:j])
            start = j
    total += int(st[start: ])
print(total)

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

int main(){
	int n;
	cin >> n;
	vector<double> v(n);
	for(int i=0;i<n;i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	double ans = v[0];
	for(int i=1;i<n;i++) {
		ans = (ans + v[i])/2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    int H[N];
    for(int i = 0; i < N; i++) cin >> H[i];
    
    int ans = 0, tmp = 0;
    for(int i = 1; i < N; i++){
        if(H[i-1] >= H[i]){
            tmp++;
        }else{
            tmp = 0;
        }
        ans = max(ans, tmp);
    }

    cout << ans << "\n";
    return 0;
}


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

using namespace std;

int main(){
    std::string S;
    cin >> S;
    int i, l;
    l = (int)(S.length());
    
    int m, n;
    m = 0; n = 0;

    for(i=0; i<l; i++){
        if(S[i] == '0') m++;
        else n++;
    }
    
    int min;
    min = m >= n ? n : m;
    cout << 2 * min << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll x;
int main() {
    cin>>x;
    if(x<1200) cout<<"ABC"<<endl;
    else if(x<2800) cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ans = 0;
  bool flag = false;
  while(!flag){
    REP(i, N){
      int cnt = A[i]/N;
      A[i] %= N;
      ans += cnt;
      REP(j, N){
        if(i == j) continue;
        A[j] += cnt;
      }

      if(i == N-1){
        REP(j, N){
          if(A[j] >= N) break;
          if(j == N-1) flag = true;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
while True:
	n, x = list(map(int, input().split()))
	if n == x == 0:
		break
	ans = 0
	for i in range(1, n + 1):
		for j in range(i + 1, n + 1):
			sec = x - i - j
			if j < sec <= n:
				ans += 1
	print(ans)



Measured memory_bytes: 5592
#include<iostream>
#include<string>
#include <vector>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
using vll = vector<ll>;
const ll MOD = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	bool flag = true;
	rep(i, n) {
		if (i % 2 == 0 && s[i] == 'L') flag = false;
		if (i % 2 == 1 && s[i] == 'R') flag = false;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

min_c = 1001

for i in range(0, N):
  c, t = map(int, input().split())
  if T < t:
    continue
  if c < min_c:
    min_c = c

if min_c != 1001:
  print(min_c)
else:
  print('TLE')


Measured memory_bytes: 2940
#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <deque>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
	char C;
	cin >> C;

    cout << static_cast<char>(C + 1) << endl;

    return 0;
}


Measured memory_bytes: 888
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = ReadLine().Split(' ');
            int num = int.Parse(a[0] + a[1]);

            WriteLine(Check(num) ? "Yes" : "No");
        }

        static bool Check(int num)
        {
            return (int)Math.Sqrt(num) * (int)Math.Sqrt(num) == num;
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



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

const int MAXN = 1e5 + 10, MOD = 998244353;

long long n, ans = 1, cnt;
long long d[MAXN], a[MAXN];

long long power (long long a, long long b){
    long long res = 1;
    while(b) {
        if (b & 1) 
            res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res % MOD;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> d[i];
        a[d[i]]++;    
    }
    if (d[0] ^ 0)
      	return cout << 0 << '\n', 0;
    sort(d, d + n);
    
    if (a[0] ^ 1)
        return cout << 0 << '\n', 0;
    
    for (int i = 1; i < n; i++) {
        if (cnt + 1 == d[i])
            cnt++;
    }
    
    if (d[n - 1] ^ cnt)
        return cout << 0 << '\n', 0;

    for (int i = 1; i <= n - 1; i++) {
        ans *= power(a[i - 1], a[i]);
        ans %= MOD;  
    }
    
    cout << (ans + MOD) % MOD << '\n';
    return 0;
}

Measured memory_bytes: 1792
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<b){
    System.out.println("a < b");
    }else if(a>b){
    System.out.println("a > b");
  }else if(a==b){
    System.out.println("a == b");
  }
  
}
}


Measured memory_bytes: 26084
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long long> a(3*N);
    for(int i=0; i<3*N; i++) cin >> a[i];

    long long sum1 = 0;
    for(int i=0; i<N; i++) sum1 += a[i];
    priority_queue<long long, vector<long long>, greater<long long>> pq;
    for(int i=0; i<N; i++) pq.push(a[i]);

    vector<long long> b(2*N);
    for(int i=N; i<3*N; i++) b[i-N] = a[i];
    sort(b.begin(), b.end());

    long long sum2 = 0;
    for(int i=0; i<N; i++) sum2 += b[i];

    multiset<long long> ms;
    for(int i=0; i<N; i++) ms.insert(b[i]);

    multiset<long long> ms2;
    for(int i=N; i<2*N; i++) ms2.insert(b[i]);

    long long ans = sum1 - sum2;

    for(int i=N; i<2*N; i++){
        long long tp = pq.top();
        if(tp < a[i]){
            sum1 += a[i] - tp;
        }
        pq.push(a[i]);
        pq.pop();

        auto itr = ms.find(a[i]);
        auto itr2 = ms2.find(a[i]);
        if(itr != ms.end()){
            sum2 -= a[i];
            ms.erase(itr);
            sum2 += *ms2.begin();
            ms.insert(*ms2.begin());
            ms2.erase(ms2.begin());
        }else{
            ms2.erase(itr2);
        }

        ans = max(ans, sum1 - sum2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector

int main(){
    ll a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    if(abs(a-b) - (v-w)*t > 0) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(void){
    int a;
    cin>>a;
    int flag = 1;
    for(int i =0;i<a;i++){
        int b;
        cin>>b;
        
        if(b%2 ==0){
            if(b%3 !=0 && b%5 !=0){
                flag =0;
                break;
            }
        }
    }
    if(flag==1){
        cout<<"APPROVED"<<endl;
    
        
    }else{
        cout<<"DENIED"<<endl;
    }
}
    
   

Measured memory_bytes: 256
import sys
import collections
input = sys.stdin.readline

s = input().strip()
n = len(s)
cnt = collections.defaultdict(int)
cnt[0] = 1
res = sm = 0
p10 = 1
for d in reversed(s):
	sm = (sm + int(d) * p10) % 2019
	res += cnt[sm]
	cnt[sm] += 1
	p10 = p10 * 10 % 2019
print(res)


Measured memory_bytes: 69120
uses math ;
var a:array[1..100000] of int64 ;
      i,n:longint ;
			ans1,ans2,sum1,sum2:int64 ;
begin 
   readln(n) ;
	 for i:=1 to n do read(a[i]) ;
	 if a[1]>0 then 
	 begin 
	   sum1:=a[1];
		 ans2:=a[1]+1 ;
		 sum2:=-1 ;
	 end
	 else if (a[1]=0) then 
	 begin 
	   sum1:=1;
		 ans1:=1;ans2:=1 ;
		 sum2:=-1 ;
	 end
	 else 
	 begin 
	   sum1:=1;
		 ans1:=abs(a[1])+1 ;
		 sum2:=a[1] ;
	 end;
	 for i:=2 to n do 
	 begin 
	   if sum1>0 then
		 begin 
		   if a[i]+sum1>=0 then 
			 begin 
			   ans1:=ans1+a[i]+sum1+1 ;
				 sum1:=-1 ;
			 end
			 else sum1:=sum1+a[i] ;
		 end
		 else 
		 begin 
		   if a[i]+sum1<=0 then 
			 begin 
			   ans1:=ans1+abs(sum1+a[i])+1 ;
				 sum1:=1 ;
			 end
			 else sum1:=sum1+a[i] ;
		 end;
	 end;
	 if sum1=0 then inc(ans1) ;
	 for i:=2 to n do //这段跟上段一模一样
	 begin 
	   if sum2>0 then
		 begin 
		   if a[i]+sum2>=0 then 
			 begin 
			   ans2:=ans2+a[i]+sum2+1 ;
				 sum2:=-1 ;
			 end
			 else sum2:=sum2+a[i] ;
		 end
		 else 
		 begin 
		   if a[i]+sum2<=0 then 
			 begin 
			   ans2:=ans2+abs(sum2+a[i])+1 ;
				 sum2:=1 ;
			 end
			 else sum2:=sum2+a[i] ;
		 end;
	 end;
	 if sum2=0 then inc(ans2) ;
	 writeln(min(ans1,ans2)) ;
end.

Measured memory_bytes: 1024
n,m,x,y = map(int, input().split())
x_list = list(map(int,input().split()))
y_list = list(map(int,input().split()))
x_max = max(x_list)
y_min = min(y_list)

def is_war(z):
  if x_max < z and y_min >=z and x<z and z<=y:
    return True
  else:
    return False

flag = False
for i in range(-100,100,1):
  if is_war(i):
    flag = True
print("No War" if flag else "War")

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
	        String s = sc.next();
	        if(s.contains(s.toLowerCase()))
	        	System.out.println("a");
	        else
	        	System.out.println("A");
	}
}

Measured memory_bytes: 35704
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  
  if(N % 2 != 0){
    cout << "No" << endl;
    return 0;
  }
  
  for(int i = 0; i < N / 2; i++){
    if(S.at(i) != S.at(N / 2 + i)){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = {1,0,-1,0},dx[4] = {0,1,0,-1};
typedef pair<ll, ll> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r, d, x;
    cin >> r >> d >> x;
    for (int i = 0; i < 10;i++) {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

W = list(range(N))
E = list(range(N))
w, e = 0, 0

if S[0] == 'W':
    W[0] = 1
    E[0] = 0
else:
    W[0] = 0
    E[0] = 1

for i in range(1, N):
    if S[i] == 'W':
        W[i] = W[i-1] + 1
        E[i] = E[i-1]

    else:
        W[i] = W[i-1]
        E[i] = E[i-1] + 1

min_cost = float('inf')
for i in range(N):
    cost = 0
    if i-1 != 0:
        cost += W[i-1]
    cost += E[N-1] - E[i]
    min_cost = min(min_cost, cost)
    # print(cost)

print(min_cost)
# print(W)
# print(E)

Measured memory_bytes: 47064
// abc124_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    vector<int> list_1, list_0;

    if (S[0] == '0') list_1.emplace_back(0);
    REP(i, N){

        int tmp = i;
        if (S[i] == '0'){
            while (tmp < N && S[tmp] == '0') tmp++;
            list_0.emplace_back(tmp - i);
        } else {
            while (tmp < N && S[tmp] == '1') tmp++;
            list_1.emplace_back(tmp - i);
        }
        i = tmp-1;
    }
    if (S[N-1] == '0') list_1.emplace_back(0);

//    print(list_1);
//    print(list_0);

    if (list_0.empty() || list_1.empty()){
        print(N);
        return 0;
    }

    int tmp = list_1[0];
    int ans = 0;
    REP(i, list_0.size()){
        tmp += list_1[i+1];
        tmp += list_0[i];

        if (i >= K){
            tmp -= list_1[i-K];
            tmp -= list_0[i-K];
        }
        ans = max(ans, tmp);
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 1024
_ = input()#"3242"
a,b,c,d = [int(_[i]) for i in range(4)]
e = [-1,1]
def f(s):
    if s == 1:
        print("+",end="")
    else:
        print("-",end="")
for i in e:
    for j in e:
        for k in e:
            if a + i*b + j*c + k*d == 7:
                print(a,sep="",end="")
                f(i)
                print(b,end="")
                f(j)
                print(c,end="")
                f(k)
                print(d,"=7",sep="")
                exit()


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
/*
ctrl+shift+b でコンパイル及び実行
*/

//01
int main(int argc, const char * argv[]) {
    int A,B,T = 0;
    cin >> A;
    cin >> B;
    cin >> T;
    int sum = 0;
    sum = T / A * B;

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<ll, ll>
#define vint vector<int>
using namespace std;

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

vector<pint> v(300001);
int n; ll a,b;
int main(){
	cin>>n>>a>>b;
	if(a+b-1>n || a*b<n){
		co(-1);
		return 0;
	}
	ll k=10000000;
	int bb=b;
	FOR(i,0,n){
		if(i%a==0||n-i<=bb){
			if(i%a==0) bb--;
			v[i]=pint(k,i);
			k-=1000000;
		}else{
			v[i]=pint(v[i-1].first+1,i);
		}
	}
	sort(v.begin(),v.begin()+n);
	FOR(i,0,n){
		v[i].first=i;
		swap(v[i].first,v[i].second);
	}
	sort(v.begin(),v.begin()+n);
	FOR(i,0,n) cout<<v[i].second+1<<" \n"[i==n-1];
}


Measured memory_bytes: 6912
#include<iostream>
#include<map>
using namespace std;
int gcd(int x, int y);
int euc(int x, int y, int f);
int main(){
  int n,m;
  while(cin >>n>>m,n||m){
    if(n<m){int c = n; n = m; m = c;}
    cout <<gcd(n,m)<<" "<<euc(n,m,0)<<endl;
  }
  return 0;
}
int gcd(int x, int y){
  if(y == 0){return x;}
  return gcd(y,x%y);
}
int euc(int x, int y, int f){
  if(y == 0){return f;}
  f++;
  return euc(y,x%y,f);
}

Measured memory_bytes: 1160
hoge = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
s = int(input())
print(hoge[s - 1])

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    bitset<64> A(0);
    int q; cin >> q;
    rep(_,q){
        int query; cin >> query;
        if(query == 0){
            int i; cin >> i;
            if(A.test(i)) cout << 1 << endl;
            else cout << 0 << endl;
        }else if(query == 1){
            int i; cin >> i;
            A.set(i);
        }else if(query == 2){
            int i; cin >> i;
            A.set(i,0);
        }else if(query == 3){
            int i; cin >> i;
            A.flip(i);
        }else if(query == 4){
            if(A.all()) cout << 1 << endl;
            else cout << 0 << endl;
        }else if(query == 5){
            if(A.any()) cout << 1 << endl;
            else cout << 0 << endl;
        }else if(query == 6){
            if(!A.any()) cout << 1 << endl;
            else cout << 0 << endl;
        }else if(query == 7){
            cout << A.count() << endl;
        }else if(query == 8){
            cout << (A.to_ullong()) << endl;
        }
    }
}


Measured memory_bytes: 3104
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int N,K;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		N = nextInt();
		K = nextInt();
		long []H = nextLongArray(N);
		Arrays.sort(H);

		int n = N-K;
		long ans = 0;
		for(int i=0;i<n;i++) {
			ans += H[i];
		}

		out.println(ans);
	}

	static long modpow(long a, long n, long mod) {
	    long res = 1;
	    while (n > 0) {
	        if ((n & 1) != 0) res = res * a % mod;
	        a = a * a % mod;
	        n >>= 1;
	    }
	    return res;
	}
	static long modinv(long a, long mod) {
	    return modpow(a, mod - 2, mod);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}

	long lcm(long m, long n) {
	        return m * n / gcd(m, n);
	}

	private final int[] sizeTable = {
	        9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, Integer.MAX_VALUE
	};

	public int stringSize(int x) {
	    for (int i = 0;; i++)
	        if (x <= sizeTable[i])
	            return i + 1;
	}
}

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


int main (void){
  long long int n = 0,m = 0,s = 0,t = 0;
  cin >> n >> m;
  vector<vector<long long int>> g(n,vector<long long int>());

  for(int i = 0;i < m;i++){
    long long int a = 0,b = 0;
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
  }
  cin >> s >> t;
  s--;
  t--;

  queue<pair<int,int>> que;
  vector<vector<long long int>> dist(n,vector<long long int>(4,-1));
  dist[s][0] = 0;
  pair<int,int> cur;
  int l = 0;

  que.push({s,0});

  while(!que.empty()){
    if(dist[t][0] != -1){break;}
    cur = que.front();
    que.pop();
    l = (cur.second + 1) % 3;


    for(int i = 0;i < g[cur.first].size();i++){
      if(dist[t][0] != -1){break;}
      if(dist[g[cur.first][i]][l] == -1){
        que.push({g[cur.first][i],cur.second+1});
        dist[g[cur.first][i]][l]++;
      }
    }
  }

  if(dist[t][0] == -1){
    cout << -1 << endl;
  }else{
    cout << (cur.second + 1) / 3 << endl;
  }
  return 0;

}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N, V[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> V[i];

    map<int, int> cnt[2];
    rep(i, 0, N) cnt[i % 2][V[i]]++;

    vector<pair<int, int>> v[2];
    rep(i, 0, 2) {
        fore(p, cnt[i]) v[i].push_back({ p.second, p.first });
        sort(all(v[i]), greater<pair<int,int>>());
    }

    // どちらも最適
    if (v[0][0].second != v[1][0].second) {
        int ans = N - v[0][0].first - v[1][0].first;
        cout << ans << endl;
        return;
    }

    // すべて同じ数だった
    if (v[0].size() == 1 and v[1].size() == 1) {
        int ans = N / 2;
        cout << ans << endl;
        return;
    }

    int ans = inf;
    if (2 <= v[0].size()) chmin(ans, N - v[0][1].first - v[1][0].first);
    if (2 <= v[1].size()) chmin(ans, N - v[0][0].first - v[1][1].first);
    cout << ans << endl;
}


Measured memory_bytes: 6524
import java.util.*;
public class Main {
	static int cnt = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0;i < n;i++) {
			list.add(sc.nextInt());
		}
		boolean flag = false;
		while(!flag) {
			for(int i = 0;i < n;i++) {
				int a = list.get(i);
				if(a % 2 == 0) {
					a = a / 2;
					list.set(i, a);
				}else {
					flag = true;
					break;
				}
			}
			if(!flag)cnt++;
		}
		System.out.print(cnt);
	}

}

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

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

    ll a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i] -= (i + 1);
    }

    sort(a, a + n);
    ll ans = 0;
    int k = n / 2;
    ll t = 0;
    if(n % 2 == 0){
        t = a[k];
        ll s = a[k - 1];
        if((t + s) % 2 == 0){
            t = (t + s) / 2;
            for(int i = 0; i < n; i++){
                ans += abs(a[i] - t);
            }
        }else{
            t = (t + s) / 2;
            ll sum = 0;
            for(int i = 0; i < n; i++){
                ans += abs(a[i] - t);
            }
            t++;
                for(int i = 0; i < n; i++){
                sum += abs(a[i] - t);
            }

            if(ans > sum){
                ans = sum;
            }
        }
    }else{
        t = a[k];
        for(int i = 0; i < n; i++){
            ans += abs(a[i] - t);
        }
    }

    cout << ans << endl;
}

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

int main() {
	string s;
	cin >> s;
	while(s != "-"){
		int m, h;
		cin >> m;
		for (int i = 0; i < m; i++){
			cin >> h;
			s += s.substr(0, h);
			s = s.substr(h, s.length() - h);
		}
		cout << s << endl;
		cin >> s;
	}
	return 0;
}


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

string A(string str){
  char tmp;
  for(int i=0,j=str.length()-1;i<j;i++,j--){
    tmp=str[i];
    str[i]=str[j];
    str[j]=tmp;
  }
  return str;
}

string J(string str){
  char tmp;
  tmp=str[str.length()-1];
  for(int i=str.length()-1;i>0;i--)
    str[i]=str[i-1];
  str[0]=tmp;
  return str;
}

string C(string str){
  char tmp;
  tmp=str[0];
  for(int i=0;i<str.length()-1;i++)
    str[i]=str[i+1];

  str[str.length()-1]=tmp;
  return str;
}

string E(string str){
  string tmp,str2;
  if(str.length()%2){
    tmp=str.substr(0,str.length()/2);
    str2.assign(&str[str.length()/2+1],&str[str.length()]);
    str2+=str[str.length()/2];
    str2+=tmp;
  }else{
    tmp=str.substr(0,str.length()/2);
    str2.assign(&str[str.length()/2],&str[str.length()]);
    str2+=tmp;
  }
  return str2;
}

string P(string str){
  string num=("9012345678");
  for(int i=0;i<str.length();i++)
    if(str[i]>=0x30 && str[i]<=0x39)
      str[i]=num[str[i]-0x30];
  return str;
}

string M(string str){
  string num=("1234567890");
  for(int i=0;i<str.length();i++)
    if(str[i]>=0x30 && str[i]<=0x39)
      str[i]=num[str[i]-0x30];
  return str;
}

int main(){
  int n;
  string str1,str2;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    cin>> str1 >>str2;
    for(int i=str1.length()-1;i>=0;i--){
      switch(str1[i]){
      case 'A': str2=A(str2); break;
      case 'J': str2=J(str2); break;
      case 'C': str2=C(str2); break;
      case 'E': str2=E(str2); break;
      case 'P': str2=P(str2); break;
      case 'M': str2=M(str2); break;
      }
    }
    cout<< str2<< endl;
  }
  return 0;
}

Measured memory_bytes: 1244
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int c = sc.nextInt();
    int d = sc.nextInt();
    c = c-1;
    d = d-1;
    c = (c*(c+1))/2;
    d = (d*(d+1))/2;
    c = c+d;
    System.out.println(c);
  }
}

Measured memory_bytes: 23764
#include <stdio.h>

int main(void) {
  int i, j, n, k, order[n];
  
  scanf("%d", &n);
  for(i=1; i<=n;i++) {
    scanf("%d", &k);
    order[k-1] = i;
  }
  
  for(j=0;j<n;j++) {
    printf("%d ", order[j]);
  }
  
  return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;

bool sosu(long long x){
	for(long long i=2;i*i<=x;i++){
		if(x%i==0){
			return false;
		}
	}
	return true;
}

int main(){
	long long x;
	cin >> x;
	for(long long i=x;;i++){
		if(sosu(i)==true){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#!/bin/usr/env

S = input()

tmp = {}
ans = []
for i in S:
  if (i in tmp):
    tmp[i] += 1
  else:
    tmp[i] = 1

for j in tmp.values():
  if j % 2 == 1:
    print("No")
    exit()
  else:
    pass

print("Yes")
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
#define printv(v) for(auto it : v) cout<<it<<" ";cout<<endl;
#define prec(n) fixed<<setprecision(n)
const int mod1 = 1000000007;
const int mod2 = 998244353;
const int N = 1e5;

int main()
{
	optimize

	#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
	#endif

	int n,x,t;
	cin>>n>>x>>t;

	cout<<(n+x-1)/x * t<<endl;


	return 0;
}

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

using namespace std;

int main(void)
{
	string str, command;
	string commands[3] = {"print", "reverse", "replace"};
	int q, a, b;
	int i, j;

	cin >> str >> q;
	for (i = 0; i < q; i++)
	{
		cin >> command;
		for (j = 0; j < 3 && command != commands[j]; j++);

		if (j == 0)
		{
			cin >> a >> b;
			cout << str.substr(a, b - a + 1) << endl;
			continue;
		}
		if (j == 1)
		{
			cin >> a >> b;
			string temp;
			char ch;
			temp = str.substr(a, b - a + 1);
			int k, len = temp.length();
			for (k = 0; k < len / 2; k++)
			{
				ch = temp.at(k);
				temp.at(k) = temp.at(len - k - 1);
				temp.at(len - k - 1) = ch;
			}
			str.replace(a, b - a + 1, temp);
			continue;
		}
		if (j == 2)
		{
			cin >> a >> b;
			string p;
			cin >> p;
			str.replace(a, b - a + 1, p);
			continue;
		}

	}
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V
const double PI=3.14159265358979323846;
#define MODI 1e9+7

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

typedef pair<ll, ll> P;
struct modint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 MOD=1000000007;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a;
    while(b){
        if(b&1) (n*=A)%=modint::MOD;
        (A*=A)%=modint::MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

int a[100001];

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

    REP(i, n) {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }

    int ans = 0;

    REPN(i, 1, 100000) {
        int tmp = a[i-1] + a[i] + a[i+1];
        ans = max(tmp, ans);
    }

    cout << ans << endl;

}
 

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void)
{
    int rgb_length;
    int r_count = 0;
    int g_count = 0;
    int b_count = 0;
    string rgb;

    cin >> rgb_length;
    cin >> rgb;

    for(int i = 0; i < rgb_length; i++){
        if(rgb[i] == 'R'){
            r_count += 1;
        }else if(rgb[i] == 'G'){
            g_count += 1;
        }else{
            b_count += 1;
        }
    }

    long long rgb_comb = (long long)(r_count) * g_count * b_count;

    int different_count = 0;
    for(int dist = 0; dist <= (rgb_length - 3) / 2; dist++){
        for(int i = 0; i <= rgb_length - 3 - dist * 2; i++){
            int j = i + dist + 1;
            int k = j + dist + 1;
            if(rgb[i] != rgb[j] && rgb[j] != rgb[k] && rgb[k] != rgb[i]){
                different_count += 1;
            }
        }
    }

    cout << rgb_comb - different_count << endl;

    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<cstdlib>

using namespace std;

#define LL long long
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
int n;
void ex_gcd(LL a, LL b, LL &d, LL &x, LL &y) {
    if (!b) {
        d = a, x = 1, y = 0;
    } else {
        ex_gcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}
LL ex_crt(LL *m, LL *r, int n) {
    LL M = m[1], R = r[1], x, y, d;
    for (int i = 2; i <= n; ++i) {
        ex_gcd(M, m[i], d, x, y);
        if ((r[i] - R) % d)
            return -1;
        x = (r[i] - R) / d * x % (m[i] / d);
        R += x * M;
        M = M / d * m[i];
        R %= M;
    }
    return R > 0 ? R : R + M;
}
LL m[maxn], r[maxn];
LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}
LL pp;
int main() {
    scanf("%d%lld",&n,&pp);
        for (int i = 1; i <= n; ++i){
            scanf("%lld", &m[i]);
            r[i]=m[i]/2;
    	}
    	LL d=m[1];
    	for(int i=2;i<=n;i++) d=d/gcd(d,m[i])*m[i];
    	LL x=ex_crt(m,r,n);
    	if(x==-1){
            puts("0");
            return 0;
    	}
    	LL ans=0;
    	if(pp>=x) ans++;
    	ans+=max(0ll,(pp-x)/d);
        printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <iomanip>
#include <numeric>
using namespace std;

long long int calc(long long int a, long long int b)
{
  long long int x = a * b;
  long long int tmp, r;
 
  /* 自然数 a > b を確認・入替 */

  if(a < b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }

  return x / b;
}

int main()
{
	long long int A, B, C, D;
	cin >> A >> B >> C >> D;

	long long int cx = B / C - (A - 1) / C;
	long long int dx = B / D - (A - 1) / D;
	
	long long int cm = calc(C, D);
	long long int x = B / cm - (A - 1) / cm;

	long long int ans = cx + dx - x;

	if (ans == 0)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << (B - A + 1) - ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define Scan(a) int a;scanf("%d", &a);
#define ScanS(a) char a[500];scanf("%s", a);
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
class Graph {
public:
	int vn;
	int sumcost = 0;
	vector<vector<pii>> g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
	void scan(int edcount, bool oindexed, bool w) {
		REP(i, edcount) {
			int a, b, c = 1;
			scanf("%d %d", &a, &b);
			if (w)scanf("%d", &c);
			con(a - oindexed, b - oindexed, c);
		}
	}
};
class BiDGraph : public Graph {//無向
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		sumcost++;
	}
};
signed main() {
	int n;
	cin >> n;
	string str[2];
	cin >> str[0] >> str[1];
	map<char, int> s;
	BiDGraph g(n);
	ll ans;
	bool bef;
	if (str[0][0] == str[1][0])
		ans = 3, bef = 0;
	else
		ans = 6, bef = 1;
	rep(i, 1 + bef, n) {
		if (str[0][i] == str[1][i]) {
			if (!bef)
				ans *= 2;
			bef = 0;
		}
		else {
			if (bef) {
				ans *= 3;
			}
			else {
				ans *= 2;
			}
			i++;
			bef = 1;
		}
		ans %= MODU;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main () {
  int N;
  string s;
  cin >> N >> s;
  int i = 0;
  while (i < N){
    for (int j = 0; j < s.size(); j++){
      if (s.at(j) == 'Z') s.at(j) = 'A';
      else s.at(j) += 1;
    }
    i++;
  }
  cout << s << endl;
}

Measured memory_bytes: 256