akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int x;
int y;
int z;
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> x >> y >> z;
    if(x > y){
        swap(x, y);
    }
    if(y > z){
        swap(y, z);
    }
    if(x > y){
        swap(x, y);
    }
    if(x == y && x != z){
        cout << "Yes\n";
    }
    else if(x != y && y == z){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000001;
const ll LINF=4000000000000000010;
const double EPS=1e-9;
ll ac[100010],cc[100010],hc[100010];
ll f[300010],fi[300010];
ll mod_pow(ll x,ll n,ll mod){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret=ret*x%mod;
        }
        x=x*x%mod;
        n>>=1;
    }
    return ret;
}
 
void fact(ll n){
	f[0]=1;
	for(ll i=1;i<=n;i++){
		f[i]=f[i-1]*i%MOD;
	}
	fi[n]=mod_pow(f[n],MOD-2,MOD);
	for(ll i=n-1;i>=0;i--){		
		fi[i]=fi[i+1]*(i+1)%MOD;
	}
}
 
ll ncr(ll n,ll r){
	if(r==0){
		return 1;
	}else{
		return ((f[n]*fi[r])%MOD*fi[n-r])%MOD;
	}
}
ll b[100010];
//ac*(cc+hc)*(3^hh)
int main(){
    string s;cin>>s;
    int n=s.length();
    fact(n+1);
    b[0]=1;
    for(int i=0;i<=n;i++){
        b[i+1]=b[i]*3;
        b[i+1]%=MOD;
    }
    for(int i=0;i<n;i++){
        if(s[i]=='A'){
            ac[i]++;
        }else if(s[i]=='C'){
            cc[i]++;
        }else if(s[i]=='?'){
            hc[i]++;
        }
        ac[i+1]+=ac[i];
        cc[i+1]+=cc[i];
        hc[i+1]+=hc[i];
    }
    ll ans=0;
    for(int i=1;i<n-1;i++){
        if(s[i]=='B'||s[i]=='?'){
            ll acc=ac[i-1];
            ll ccc=cc[n-1]-cc[i];
            ll hc1=hc[i-1];
            ll hc2=hc[n-1]-hc[i];
            ll s2=(ccc*b[hc2]%MOD+hc2*b[hc2-1]%MOD)%MOD;
            ans+=acc*s2%MOD*b[hc1]%MOD;
            ans%=MOD;
            ans+=hc1*s2%MOD*b[hc1-1]%MOD;
            ans%=MOD;
        }
    }
    cout<<ans<<endl;
}


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

#define endl '\n'

using namespace std;

typedef unsigned long long int ulli;

const ulli N = 2e5, M = 2e5;

ulli n, m, k, sumaDeAHasta[N + 1], sumaDeBHasta[M + 1], flechaA, flechaB, maxLibrosLeidos;

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

    cin >> n >> m >> k;
    for (int i=1; i<=n; ++i)
    {
        cin >> sumaDeAHasta[i];
        sumaDeAHasta[i] += sumaDeAHasta[i - 1];
    }
    for (int i=1; i<=m; ++i)
    {
        cin >> sumaDeBHasta[i];
        sumaDeBHasta[i] += sumaDeBHasta[i - 1];
    }
    while (flechaA < n && k >= sumaDeAHasta[flechaA + 1])
        ++flechaA;
    while (flechaB < m && k-sumaDeAHasta[flechaA] >= sumaDeBHasta[flechaB + 1])
        ++flechaB;
    maxLibrosLeidos = flechaA + flechaB;
    while (flechaA)
    {
        --flechaA;
        while (flechaB < m && k-sumaDeAHasta[flechaA] >= sumaDeBHasta[flechaB + 1])
            ++flechaB;
        maxLibrosLeidos = max(maxLibrosLeidos, flechaA + flechaB);
    }
    cout << maxLibrosLeidos << endl;

    return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

std::string s, t;
int main() {
    std::cin >> s;
    std::cin >> t;
    SORT(s);
    SORT(t);
    std::reverse(t.begin(), t.end());
    int l = std::min(s.size(), t.size());
    bool f = true;
    REP(i, l) {
        if(s[i] == t[i]) continue;
        else if(s[i] < t[i]) {
            std::cout << "Yes" << std::endl;
            return 0;
        } else {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    if(s.size() < t.size()) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = 10**9

# 個数制限なしナップザック問題
h,n = map(int, input().split())

# 二次元配列で
a,b = [],[]
for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

dp = [[INF] * (h + 1) for _ in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for j in range(h + 1):
        if j <= a[i]:
            dp[i + 1][j] = min(dp[i][j], b[i])
        else:
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - a[i]] + b[i])
print(dp[n][h])

# 一次元配列で
# dp = [INF]*(h+1)
# dp[0] = 0
# for i in range(n):
#     a,b = map(int, input().split())
#     for j in range(h):
#         nj = min(a+j, h)
#         dp[nj] = min(dp[nj], dp[j]+b)
# print(dp[-1])


Measured memory_bytes: 152296
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<string.h>
using namespace std;

struct Node { int key; Node *parent, *left, *right; };

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->parent = NIL;
  z->left = NIL;
  z->right = NIL;
  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if (y == NIL) {
    root = z;
  } else if (z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
}

void Preorder(Node *p) {
  printf(" %d", p->key);
  if (p->left != NIL) Preorder(p->left);
  if (p->right != NIL) Preorder(p->right);
}

void Inorder(Node *p) {
  if (p->left != NIL) Inorder(p->left);
  printf(" %d", p->key);
  if (p->right != NIL) Inorder(p->right);
}

void Postorder(Node *p) {
  if (p->left != NIL) Postorder(p->left);
  if (p->right != NIL) Postorder(p->right);
  printf(" %d", p->key);
}

void find(int key) {
  Node *x = root;
  while (x != NIL) {
    if (key < x->key) {
      x = x->left;
    } else if (key > x->key) {
      x = x->right;
    } else if (key == x->key) {
      printf("yes\n");
      break;
    }
  }
  if (x == NIL) {
    printf("no\n");
  }
}

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

  char str[12];
  int key;
  for ( int i = 0; i < n; i++ ) {
    scanf("%s", str);
    if ( strcmp(str, "insert") == 0 ) {
      scanf("%d", &key);
      insert(key);
    } else if ( strcmp(str, "print") == 0 ) {
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    } else if ( strcmp(str, "find") == 0 ) {
      scanf("%d", &key);
      find(key);
    }
  }

  return 0;
}



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

int main(){
    int a,b;
    cin >> a >> b;
    int ans = a;
    for(int i = a + 1; i <= b; i++){
        if(ans > 0)ans = 1;
        else if(ans == 0){
            ans = 0;
            break;
        }else if(ans < 0){
            ans = -1;
        }
            ans *= i;
    }

    if(ans > 0)cout << "Positive" << endl;
    else if(ans == 0)cout << "Zero" << endl;
    else cout << "Negative" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

A, B, H, M = map(int, input().split())

short_rad = math.radians((H * 60 + M) * 0.5)
long_rad = math.radians(M * 6)

diff = abs(short_rad - long_rad)

l = A * A + B * B - 2 * A * B * math.cos(diff)

print(math.sqrt(l))


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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (x).size()

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

ll sum(int n){
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}

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

   
   int a,b,c;cin>>a>>b>>c;
   string s=to_string(a)+to_string(b)+to_string(c);
   int n=stoi(s);
   if(n%4==0){
      cout << "YES";
   }else{
      cout << "NO";
   }
   return 0;
}


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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

string res;

int main()
{
    ll a, b;
    string s;

    cin >> a >> s >> b;
    if (s == "+")
    {
        println(a + b);
    }
    else
    {
        println(a - b);
    }
}

Measured memory_bytes: 3484
// Author := Abhishek Giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vecapital_in_tor<(type)> 
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)
#define el "\n"

/*##################################################################################*/

/*
int prime[1000000] = {0} ;
vecapital_in_tor< int > p ;
void calculateprime()
{
    //calculating primes
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; (ll)i*i <= 1000000 ; i++)
    {
        if(prime[i] == 0)
        {
            p.pb(i);
            for(ll j = i*i ; j <= 1000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}
*/

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool isprime(ll n)
{
    for(ll i = 2 ; (ll) i*i <= n ; i++)
    {
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

ll fib(int n) 
{ 
  ll a = 0, b = 1, c, i; 
  if( n == 0) 
    return a; 
  for (i = 2; i <= n; i++) 
  { 
    c = (a + b); 
    a = b; 
    b = c; 
  } 
  return b; 
}


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

ll extendedgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extendedgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

ll findgrouplcm(vector<int> &arr, int n) 
{ 
    ll ans = arr[0]; 
  
    for (ll i = 1; i < n; i++) 
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));
  
    return ans; 
}


ll powerwithmod(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}


bool comp(const pair<int,int> &a , const pair<int,int> &b){
    return a.first < b.first;
    if(a.first == b.first)  return a.second < b.second;
}

void solve(){
    vector< char > state(501,false);
    int x,n,temp;
    in(x)>>n;
    if(n == 0){
        cout<<x;
        return;
    }
    f(i,n){
        in(temp);state[temp] = true;
    }
    int res = -1 , mn = 101 ;
    f(i,105){
        
        if(state[i] == true)    continue;
        
        int d = abs ( i - (float)x );
        if(  d < mn ){
            mn = d;
            res = i;
        }
    }
    cout<<res;
}

int main() {
    fast();
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#4
#入力
N=int(input())
A=list(map(int,input().split()))

#デバッグ関連
debug=0#0:本番,1:デバッグ

def pront(*n):
    if debug==1:
        print(n)

#処理
X={}
for i in A:
    if i in X:
        X[i]+=1
    else:
        X[i]=1

        x=0
for i in X.items():
    pront(i)
    if i[0]>i[1]:
        x+=i[1]
    else:
        x+=i[1]-i[0]
        
print(x)

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

using namespace std;

int n;
vector<int> a;
vector<int> b;

int main(){
    cin >> n;
    vector<int> ak(n);
    vector<int> bk(n);

    for (int i = 0; i < n; ++i) {
        int ai;
        cin >> ai;
        a.push_back(ai);
    }

    for (int i = 0; i < n; ++i) {
        int bi;
        cin >> bi;
        b.push_back(bi);
    }

    int ans = 0;
    for (int k = 0; k < 29; ++k) {
        int t = 1 << k;
        for (int i = 0; i < n; ++i) {
            ak[i] = a[i] % (t << 1);
            bk[i] = b[i] % (t << 1);
        }
        sort(bk.begin(), bk.end());

        int tmp = 0;
        for (int i = 0; i < n; ++i) {
            int ai = ak[i];
            tmp += lower_bound(bk.begin(), bk.end(), t - ai) -
            upper_bound(bk.begin(), bk.end(), 2 * t - ai - 1);
            tmp += lower_bound(bk.begin(), bk.end(), 3 * t - ai) -
            upper_bound(bk.begin(), bk.end(), 4 * t - ai - 1);
        }
        if ((tmp & 1) == 1) ans += t;
    }

    cout << ans << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)


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

    string S;
    cin >> S;

    vi counts(26, 0);
    ll ans = 1;
    for (int i=0;i<S.length();i++) {
        ans += (i - counts[S[i] - 'a']);

        counts[S[i] - 'a']++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;

int main() {
  ll n, k;
  cin >> n >> k;
  ll a = n % k;
  ll ans = min(a, k-a);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#define ll long long
#define double long double

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int seq[n];
    for (int i = 0; i < n; i++) {
        cin >> seq[i];
    }
    sort(seq, seq + n);
    int max_no = 1;
    int last = -1;
    for (int i = 0; i < n; i++) {
        if (seq[i] != last) {
            //case 1
            int delta = 0;
            while (i - delta >= 0 && (seq[i - delta] == seq[i] - 1 || seq[i - delta] == seq[i])) {
                delta++;
            }
            int delta_up = 0;
            while (i + delta_up < n && (seq[i + delta_up] == seq[i] + 1 || seq[i + delta_up] == seq[i])) {
                delta_up++;
            }
            //case 2
            int delta2 = 0;
            while (i - delta2 >= 0 && (seq[i - delta2] == seq[i])) {
                delta2++;
            }
            int delta_up2 = 0;
            while (i + delta_up2 < n && (seq[i + delta_up2] == seq[i] + 1 || seq[i + delta_up2] == seq[i] + 2 || seq[i + delta_up2] == seq[i])) {
                delta_up2++;
            }
            //case 3
            int delta3 = 0;
            while (i - delta3 >= 0 && (seq[i - delta3] == seq[i] - 1 || seq[i - delta3] == seq[i] - 2 || seq[i - delta3] == seq[i])) {
                delta3++;
            }
            int delta_up3 = 0;
            while (i + delta_up3 < n && (seq[i + delta_up3] == seq[i])) {
                delta_up3++;
            }
            max_no = max(max(delta2 + delta_up2 - 1, delta + delta_up - 1), max(max_no, delta3 + delta_up3 - 1));
        }
        last = seq[i];
    }
    cout << max_no;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    ll ansa = A * (N / (A + B));
    ansa += min(A, N % (A + B));
    cout << ansa << endl;
    return 0;
}

Measured memory_bytes: 256
[N,W]=[int(i) for i in input().split()]
WV=[]
for i in range(N):
	WV+=[[int(j) for j in input().split()]]
DP=[[0 for i in range(W+1)]for j in range(N)]
for i in range(N):
	for sum_w in range(W+1):
		if sum_w>=WV[i][0]:
			DP[i][sum_w]=max(DP[i-1][sum_w],DP[i-1][sum_w-WV[i][0]]+WV[i][1])
		else:
			DP[i][sum_w]=DP[i-1][sum_w]
print(DP[N-1][W])


Measured memory_bytes: 171656
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    ans=[N%K]
    a=N//K
    b=N%K
    if K==2:
        print(len(bin(N))-2)
        exit()
    elif K==8:
        print(len(oct(N))-2)
        exit()
    while True:
        a=a//K
        ans.append(a%K)
        if a==0:
            break
    print(len(ans))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
T lcm(T a, T b) {
    return (a / gcd(a, b)) * b;
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    int n;
    cin >> n;
    VI a(n);
    REP(i, n) {
        int tmp;
        cin >> tmp;
        if(tmp % 4 == 0) a[i] = 2;
        else if(tmp % 2 == 0) a[i] = 1;
        else a[i] = 0; 
    }
    int ans = 0;
    REP(i, n) ans += a[i];
    if(n % 2 == 0) {
        cout << (ans >= n ? "Yes" : "No") << endl;
    } else {
        n = (n - 1) / 2;
        cout << (ans >= n ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 998244353
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
int a[maxn];
int b[maxn];
int n;
map<int, int> r;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]), 
		b[i] = a[i];
	sort(b, b + n);
	for (int i = 0; i < n; i++)
		r[b[i]] = i;
	int ans = 0;
	for (int i = 0; i < n; i += 2)
		if (r[a[i]] % 2) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM emptm()
#define V vector
#define Q queue
#define DQ deque
#define PQ prioritm_queue
#define ST stack
#define FI first
#define MAn 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v[50];
map<LL,LL>u;
void Y()
{
    cout<<"YES"<<endl;
}
void N()
{
    cout<<"NO"<<endl;
}
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a,b,c;
   cin>>n>>m;
   for(i=0;i<n;i++)
   {
       for(j=0;j<m;j++)
       {
           cin>>o;
           v[i].PSB(o);
       }
   }
   k=0;
   for(i=0;i<n-1;i++)
   {
       for(j=i+1;j<n;j++)
       {
           l=0;
           for(z=0;z<m;z++)
           {
               l+=(v[i][z]-v[j][z])*(v[i][z]-v[j][z]);
           }
           DL x=(DL)l;
           if(ceil(sqrt(x))==floor(sqrt(x)))
           {
               k++;
           }
       }
   }
   cout<<k<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#include <ctime>
#define rep(i,m,n) for(i=m;i<=(int)n;i++)
#define mod 998244353
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
#define ls rt<<1
#define rs rt<<1|1
#define all(x) x.begin(),x.end()
const int maxn=2e5+10;
const int N=5e4+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,ret[110][110];
int main()
{
    int i,j;
    scanf("%d%d",&n,&m);
    scanf("%d",&k);
    int sx=1,sy=1;
    rep(i,1,k)
    {
        scanf("%d",&j);
        while(j--)
        {
            ret[sx][sy]=i;
            if(sx&1)
            {
                if(++sy==m+1)
                {
                    sx++;
                    sy--;
                }
            }
            else
            {
                if(--sy==0)
                {
                    sx++;
                    sy++;
                }
            }
        }
    }
    rep(i,1,n)rep(j,1,m)printf("%d%c",ret[i][j],j==m?'\n':' ');
    return 0;
}


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

int query(string s) {
	cout << "? " << s << '\n';
	cout.flush();
	int dis;
	cin >> dis;
	return dis;
}

int L;
string charset;
vector<string> strs;

string merge(int l, int r) {
	if (l == r) {
		return strs[l];
	}
	int mid = (l + r) >> 1;
	string sl = merge(l, mid);
	string sr = merge(mid + 1, r);
	string cur = "";
	int should = L - sl.length();
	int pr = 0, _pr = (signed) sr.size();
	for (int i = 0; i < (signed) sl.size(); i++) {
		while (pr < _pr && query(cur + sr[pr] + sl.substr(i)) == should - 1) {
			cur += sr[pr++];
			should--;
		}
		cur += sl[i];
	}
	while (pr < _pr) {
		cur += sr[pr++];
	}
	return cur;
}

int main() {
	for (int i = 0; i < 26; i++) {
		charset += (char) ('a' + i);
	}
	for (int i = 0; i < 26; i++) {
		charset += (char) ('A' + i);
	}
	for (int i = 0; i < 10; i++) {
		charset += (char) ('0' + i);
	}
	L = 0;
	for (int i = 0; i < 62; i++) {
		char c = charset[i];
		string s;
		int cnt;
		s.assign(128, c);
		L += (cnt = 128 - query(s));
		strs.push_back(s.substr(0, cnt));
	}
	string ans = merge(0, (signed) strs.size() - 1);
	cout << "! " << ans << '\n';
	cout.flush();
	return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define ll 	 long long
#define pb push_back
#define mp make_pair
using namespace std;

int main()  
{  

string s; cin>>s;

ll dd=0;

int d= s.size();


for(int i=0; i<d; i++)
{
	dd+=s[i]-'0';
}


if(dd%9==0) cout<<"Yes\n";
else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 3756
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Main ans = new Main();
		System.out.println(ans.solve());
	}

	private long solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long [] array = new long[N+1];
		for(int i=1;i<=N;i++){
			array[i] = sc.nextLong();
		}

		long [][] dp = new long[N+1][K+1];
		long MOD = (long) 1e9+7;

		for(int i=0;i<=K;i++){
			dp[1][i] = (i<=array[1]) ? 1 : 0;
		}

		for(int i=2;i<=N;i++){
			for(int j=0;j<=K;j++){
				if (j==0) {
					dp[i][j] = dp[i-1][j];
				} else {
					dp[i][j] = (MOD+ dp[i-1][j] + dp[i][j-1] - (((j-1-array[i]) >=0) ? dp[i-1][(int)(j-1-array[i])] : 0))%MOD;
				}
			}
		}

		return dp[N][K];
	}

}

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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 2e5 + 5;

int suf[N];


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

    int n, k, c;
    cin >> n >> k >> c;

    string s; cin >> s;

    // Precompute something for all suffixes
    int last = 1e8;
    for (int i = n-1; i >= 0; i--) {
        if (s[i] == 'x' || last-i <= c) {
            suf[i] = suf[i+1];
        } else {
            suf[i] = suf[i+1] + 1;
            last = i;
        }
    }

    debug(
        cout << "Suffix: ";
        for (int i = 0; i < n; i++) {
            cout << suf[i] << ' ';
        }
        cout << endl;
    )

    last = -1e8;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int tot = cnt + suf[max(i, last+c) + 1];

        // Answer
        if (tot < k) {
            cout << i+1 << endl;
        }

        // Add s[i] to the prefix
        if (s[i] == 'o' && i-last > c) {
            last = i;
            cnt++;
        }
    }

    return 0;
%>

Measured memory_bytes: 2580
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
    	int n = s.nextInt();
    	int k = s.nextInt();
    	int[] h = new int[n];
    	for (int i=0;i<n;i++) {
    		h[i] = s.nextInt();
    	}
    	int[] dp = new int[n];
    	Arrays.fill(dp, 1000000000+5);
    	dp[0] = 0;
    	for (int i=0;i<n;i++) {
    		for (int j=i+1;j<=i+k;j++) {
    			if (j<n) {
    				dp[j] = Math.min(dp[j], dp[i] + Math.abs(h[i]-h[j]));
    			}
    		}
    	}		
    	System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 58012
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

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

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

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

const int P = 37;

int point(int x, int y) {
    x %= P, y %= P;
    return P * x + y + 1;
}

int infpoint(int x) {
    return P * P + x + 1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    /*
    for (int p = 2; ; ++p)
        if (prime(p) && p * p + p + 1 >= 1000) {
            cout << p << '\n';
            return 0;
        }
    */
    const int N = P * P + P + 1;
    const int K = P + 1;
    printf("%d %d\n", N, K);
    forn(a, 0, P)
        forn(b, 0, P) {
            // y = ax + b
            forn(x, 0, P)
                printf("%d ", point(x, a * x + b));
            printf("%d\n", infpoint(a));
        }
    forn(a, 0, P) {
        // x = a;
        forn(y, 0, P)
            printf("%d ", point(a, y));
        printf("%d\n", infpoint(P));
    }
    // inf
    fore(i, 0, P)
        printf("%d ", infpoint(i));
    printf("\n");
}


Measured memory_bytes: 512
from collections import defaultdict, deque
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
edges = [list(range(N)) for i in range(N)]
for i in range(N):
    edges[i].remove(i)
for _ in range(M):
    a, b = map(int, input().split())
    edges[a-1].remove(b-1)
    edges[b-1].remove(a-1)
size = defaultdict(lambda: [0, 0])
color = [-1]*N
def set_color(root):
    
    que = deque([root])
    color[root] = 0
    size[root][0]+=1
    while que:
        v = que.pop()
        for nv in edges[v]:
            if color[nv]<0:
                c = 1- color[v]
                color[nv] = c
                size[root][c]+=1
                que.append(nv)
            elif color[nv] == color[v]:
                print(-1)
                sys.exit()
for i in range(N):
    if color[i]<0:
        set_color(i)
S = set([0])
for a, b in size.values():
    S = set(s+b for s in S)|set(s+a for s in S)
ans = min(x*(x-1)//2+(N-x)*(N-x-1)//2 for x in S)            
print(ans)                

Measured memory_bytes: 18928
#include<iostream>

using namespace std;

int main(){
  int P,N,ndata[55],wan,lop,a;
  while(1){
    cin>>N;
    cin>>P;
    if(N==0&&P==0){
      break;
    }
    for(lop=0;lop<50;lop++){
      ndata[lop]=0;
    }
    lop=0;
    wan=P;
    while(1){
      /*if(N==3&&P==3){
        lop=0;
        cout<<lop<<endl;
        break;
      }*/
      for(lop=0;lop<N;lop++){
        if(wan!=0){
          wan--;
          ndata[lop]++;
        }else{
          wan=wan+ndata[lop];
          ndata[lop]=0;
        }
        /*cout<<"wan="<<wan<<endl;
        for(int lop2=0;lop2<N;lop2++){
          cout<<lop2<<"  "<<ndata[lop2]<<endl;
        }
        cout<<endl;
        cin>>a;*/
        if(ndata[lop]==P&&wan==0){
          break;
        }
      }
      if(ndata[lop]==P&&wan==0){
        cout<<lop<<endl;
        break;
      }
    }

  }
  return 0;
}

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

int main()
{
  std::string S;
  std::cin >> S;
  bool res = true;
  for (int i=0; i<3; i++) {
    if (S[i] == S[i+1]) { res = false; break; }
  }
  if (res) std::cout << "Good" << std::endl;
  else std::cout << "Bad" << std::endl;
  return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


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

Measured memory_bytes: 256
class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, Q, *CLR = map(int, open(0).read().split())
C, LR = CLR[:N], CLR[N:]

memo = [-1] * (N + 1)
R = []
for i, c in enumerate(C):
    if memo[c] != -1:
        R.append((memo[c], i))
    memo[c] = i

R.sort(key=lambda x: x[0])

LRI = sorted(
    ((l - 1, r - 1, i) for i, (l, r) in enumerate(zip(*[iter(LR)] * 2))),
    key=lambda x: -x[0]
)

bit = BIT(N + 5)
ans = [0] * Q
cur = len(R) - 1
for l, r, i in LRI:
    while 0 <= cur and l <= R[cur][0]:
        bit.add(R[cur][1], 1)
        cur -= 1
    ans[i] = r - l + 1 - bit.sum(r)

for a in ans:
    print(a)

Measured memory_bytes: 329760
n,x = map(int,input().split())
a = list(map(int,input().split()))
ans,count=0,0
for i in range(n-1):
    count = max(0,a[i]+a[i+1]-x)
    a[i+1] -= min(a[i+1],count)
    ans += count
print(ans)

Measured memory_bytes: 14540
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

    ll a = 1, b = n;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            a = i; b = n / i;
        }
    }

    cout << (a - 1) + (b - 1) << endl;

    return 0;
}


Measured memory_bytes: 384
#include <cstdio>

int l, r;

int main(){
	std::scanf("%d%d", &l, &r);
	if(l <= 0 && r >= 0)
		return std::puts("Zero"), 0;
	if(l > 0)
		return std::puts("Positive"), 0;
	else
		return std::puts((r - l + 1) & 1 ? "Negative" : "Positive"), 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

string x="rsp";

int main(){fastio
    string s,t;cin>>s>>t;
    cout<<t<<s<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000;
#define MOD 1000000007LL;
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;

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

int N; cin >> N;

// 4 = 1 + 1 + 2
if (N%2 == 0){
    cout << N << " " << N << " " << N/2 << endl;
    return 0;
}

rep(h, 1, 3501) rep(n, 1, 3501){
    int64_t deno = 4*h*n - N*(n+h), mono = N*h*n;
    if (deno > 0 && mono % deno == 0){
        cout << h << " " << n << " " << mono / deno << endl;
        return 0;
    }
}



}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



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

int main(){
	int n,h ; cin >> n ;
	int mx = 0 ;
	int cnt = 0 ;
	for(int i=0;i<n;i++){
		cin >> h ;
		if(mx<=h){
			cnt++ ;
			mx = h ;
		}
	}
	cout << cnt << endl ;
}

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

int main() {
  int N;
  cin >> N;
  int t[110000], x[110000], y[110000]; //0だらけの配列を宣言
  t[0] = x[0] = y[0] = 0; //初期状態
  for (int i=0; i<N; i++) cin >> t[i+1] >> x[i+1] >> y[i+1];
  bool can = true;
  for (int i=0; i<N; i++) {
    int dt = t[i+1] - t[i]; //移動にかけられるステップ数
    int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]); //移動すべき距離(絶対値)
    if (dt < dist) {
      can = false;
    }
    if ((dist % 2) != (dt % 2)) { //dtとdistの偶奇が一致する必要がある
      can = false;
    }
  }
    
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int k, x;
    cin >> k >> x;
    int ansA;
    ansA = max(x-k+1, -1000000);
    int ansB;
    ansB = min(x+k-1, 1000000);
    for(int i = ansA; i <= ansB; i++){
        cout << i << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
struct S{int f,t,c;}s;
int C(S l,S r){return l.c>r.c;}
int u[100],r[100];
int F(int x)
{
	return (u[x]-x?u[x]=F(u[x]):x);
}
void U(int x,int y)
{
	x=F(x),y=F(y);
	if(r[x]>r[y])u[y]=x;
	else if(r[x]<r[y])u[x]=y;
	else u[x]=y,++r[y];
}
int main()
{
	int n,m,i,a;
	while(scanf("%d%d",&n,&m),n)
	{
		std::vector<S>v;
		for(a=i=0;i<n;++i)r[u[i]=i]=1;
		while(m--)
		{
			scanf("%d%d%d",&s.f,&s.t,&s.c);
			if(s.c>0)v.push_back(s);
			else a+=s.c;
		}
		std::sort(v.begin(),v.end(),C);
		for(i=0;i<v.size();++i)
		{
			s=v[i];
			if(F(s.f)!=F(s.t))
			{
				if(n>2)U(s.f,s.t),--n;
				else a+=s.c;
			}
		}
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int bubbleSort(int* ,int);

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

  cnt = bubbleSort(value,n);

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

  return 0;

}
int bubbleSort(int *A,int n){
  int i,j,tmp,cnt = 0;

  for(i = 0; i < n - 1;i++){
      for(j = n - 1; j > i;j--){
	if(A[j] < A[j-1]) {
	  tmp = A[j];
	  A[j] = A[j-1];
	  A[j-1] = tmp;
	  cnt++;
	}
      }
    }
  return cnt;
	}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
using lint = long int;

int N;
lint res = 0;
vector<int> A(200010, 0);

int main(){
    cin >> N;

    for(int i = 0; i < N; i++) cin >> A[i];

    int forward = 0;
    for(int i = 0; i < N; i++){
        if(forward < A[i]) forward = A[i];
        else res += forward - A[i];
    }

    cout << res << endl;
    return 0;
}

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

int main()
{
    char c[3][3];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < 3; i++)
    {
        cout << c[i][i] ;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
#include <cassert>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

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

    ll sum = 0;
    REP(i,N) sum += A[i];

    ll pre = 0;
    ll min_diff = sum;
    for (int i = 0; i < N; i++) {
        pre += A[i];
        sum -= A[i];
        min_diff = min(min_diff, abs(pre - sum));
    }

    cout << min_diff << endl;

    return 0;
}


Measured memory_bytes: 1792
N,K = map(int, input().split())
R,S,P = map(int, input().split())
T = list(input())


def subtotal(sub_T):
    #dp[hand, sub_total_point]
    dp = [['non', 0]]
    sub_total_point = 0

    for i in range(0,len(sub_T)):
        hand = sub_T[i]
        if hand != dp[i][0]:
            if hand == 'r':
                sub_total_point += P
            elif hand == 's':
                sub_total_point += R
            elif hand == 'p':
                sub_total_point += S
            else:
                pass

        else:
            hand = 'n'

        dp.append([hand,sub_total_point])

    return sub_total_point

def main():
    total_point = 0

    if K==1:
        total_point += subtotal(T)

    else:
        for m in range(0, K):
            sub_T = []
            for n in range(0, int(N/K)+1):
                if n*K+m < N:
                    sub_T.append(T[n*K+m])
                else:
                    pass

            total_point += subtotal(sub_T)

    print(total_point)

if __name__ == "__main__":
    main()


Measured memory_bytes: 16280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,N_tmp,sum;
  //int group_cnt;
  //int person_cnt;
  int flg;
  
  // ここにプログラムを追記
  cin >> N;
  N_tmp = N;
  while(0 < N_tmp){
    sum +=  N_tmp % 10;
    N_tmp = N_tmp / 10;
    //cout << sum <<" "<<N_tmp << endl;
  }
  flg = N % sum;
  if(flg == 0){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int N,Q; cin>>N>>Q;
  string S; cin>>S;
  vector<int> A(N,0);
  for(int i=1;i<N;i++){
    if(S.at(i)=='C'&&S.at(i-1)=='A') A.at(i)++;
    A.at(i)+=A.at(i-1);
  }
  rep(i,Q){
    int l,r,k; cin>>l>>r;
    r--;
    if(l==1) k=0;
    else{
      l--;
      k=max(A.at(l),A.at(l-1));
    }
    cout<<A.at(r)-k <<endl;
  }
}


Measured memory_bytes: 3804
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		TreeSet<Integer> ts = new TreeSet<>();
		ts.add(0);
		ts.add(1);
		for (int i = 6; i <= 100000; i = i * 6) {
			ts.add(i);
		}
		for (int i = 9; i <= 100000; i = i * 9) {
			ts.add(i);
		}
		int[] money = new int[ts.size()];
		int cnt = 0;
		for (int i : ts) {
			money[cnt] = i;
			cnt++;
		}
		int n = sc.nextInt();
		int[][] dp = new int[ts.size() + 1][n + 1];
		Arrays.fill(dp[0], 100010);
		dp[0][0] = 0;
		int i = 1;
		for (; i < ts.size(); i++) {
			if (money[i] > n) {
				break;
			}
			for (int j = 0; j <= n; j++) {
				if (money[i] > j) {
					dp[i][j] = dp[i - 1][j];
				} else {
					dp[i][j] = Math.min(dp[i - 1][j], dp[i][j - money[i]] + 1);
				}
			}

		}
		System.out.println(dp[i-1][n]);
	}
}


Measured memory_bytes: 28116
import numpy as np
S=input()
N=len(S)
mod=[0 for i in range(2019)]
mod2=0
ten=1
for i in range(N-1,-1,-1): 
  s=int(S[i])*ten
  mod2+=np.mod(s,2019)
  mod2=np.mod(mod2,2019)
  mod[mod2]+=1
  ten=(ten*10)%2019
ans=0
for i in range(2019):
  k=mod[i]
  if i==0:
    if k>=2:
      ans+=k*(k-1)//2+k
    else:
      ans+=k
  else:
    if k>=2:
      ans+=k*(k-1)//2
print(ans) 

Measured memory_bytes: 27280
chk (x1,y1) (x2,y2) (xp,yp) (xq,yq) = 
  let dp = (y2-y1) / (x2-x1) * (xp-x1) + y1 - yp
      dq = (y2-y1) / (x2-x1) * (xq-x1) + y1 - yq
  in
    if dp * dq >= 0
    then True
    else False

ans (x1:y1:x2:y2:x3:y3:xp:yp:_) =
  let c1 = chk (x1,y1) (x2,y2) (x3,y3) (xp,yp)
      c2 = chk (x2,y2) (x3,y3) (x1,y1) (xp,yp)
      c3 = chk (x3,y3) (x1,y1) (x2,y2) (xp,yp)
  in
    if c1 && c2 && c3
    then "YES"
    else "NO"

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Double]]
      o = map ans i
  mapM_ putStrLn o
  

Measured memory_bytes: 4480
N, M = map(int, input().split())

d = {}
count_AC = 0
count_WA = 0
for m in range(M):
  p, S = input().split()
  if p in d:
    if d[p]['AC'] > 0:
      continue
    else:
      if S == 'AC':
        d[p]['AC'] = 1
        count_AC += 1
        count_WA += d[p]['WA']
      else:
        d[p]['WA'] += 1
  
  else:
    d[p] = {'AC' : 0, 'WA' : 0}
    if S == 'AC':
      d[p]['AC'] += 1
      count_AC += 1
    else:
      d[p]['WA'] += 1
    
print(count_AC, count_WA)

Measured memory_bytes: 44408
//
// Created by Daiki Kuyoshi on 2020/05/02.
//

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int N, M, Q;
int ans = 0;
vi a(100), b(100), c(100), d(100);

vi A;

void dfs(int nw, int l){
    if(nw >= N){
        int sum = 0;
        for(int i=0; i<Q; i++){
            if(A.at(b.at(i)-1) - A.at(a.at(i)-1)== c.at(i)){
                sum += d.at(i);
            }
        }
        ans = max(ans, sum);
        return ;
    }
    for(int i=l; i<=M; i++){
        A.push_back(i);
        dfs(nw+1, i);
        A.pop_back();
    }
}

int main(){
    cin >> N >> M >> Q;
    for(int i=0; i<Q; i++){
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    }

    dfs(0,1);
    cout << ans << endl;
}

Measured memory_bytes: 3192