akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <unordered_map>
#include <cstring>

using namespace std;

#define int long long  

const int maxn = 100 ;
const int W = 1e5 + 5;

int w[maxn];
int v[maxn];
int memo[W][maxn];
int n;

int dp(int weight, int idx) {

    if(idx >= n ) {
        return 0 * 1LL;
    }

    int &ans = memo[weight][idx];

    if(ans != -1 ) {
        return ans;
    }

    ans = dp(weight, idx+1);

    if(weight >= w[idx]) {
        ans = max(ans, v[idx] + dp(weight - w[idx], idx + 1));
    }


    return ans;


}



int32_t main(){

	// #ifndef ONLINE_JUDGE 
	//   freopen("input.txt", "r", stdin);
	//   freopen("output.txt", "w", stdout);
	// #endif
    
    memset(memo, -1, sizeof(memo));
  
   int weight;

   cin >> n >> weight ;

   for(int i = 0 ; i < n ; i++ ) cin >> w[i] >> v[i];


   

  cout<< dp(weight, 0) << endl;
    

    return 0;


}

Measured memory_bytes: 81716
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass

MOD = 1000000007  # type: int


def solve(N: int, M: int, a: "List[int]"):
    sa = set(a)
    dp = [0] * (N + 1)
    dp[0] = 1
    for i in range(1, N + 1):
        if i in sa:
            continue
        c = dp[i - 1]
        if i >= 2:
            c += dp[i - 2]
        dp[i] = c % MOD
    print(dp[N])


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
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13208
H,N=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(N)]
ab.sort()

ans=[10**9]*(H+1)
ans[0]=0
i=0
while i<=H:
    for a,b in ab:
        if a+i>H:
            a=H-i
        if ans[i+a]>ans[i]+b:
            ans[i+a]=ans[i]+b
    i+=1

print(ans[H])

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

int main() {
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  while (true) {
    c -= b;
    if (c <= 0) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
    a -= d;
    if (a <= 0) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <string>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;



int main(){
	
	int n, k; cin >> n >> k;
	
	int a[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	
	map<int, int> mp;
	for(int i=0; i<n; i++){
		mp[a[i]]++;
	}
	
	vector<pair<int, int>> v;
	for(pair<int, int> x : mp){
		v.push_back(make_pair(x.second, x.first));
	}
	
	sort(v.begin(), v.end());
	
	
	int nr = 0;
	if(v.size() > k){
		nr = v.size() - k;
	}
	
	int ans = 0;
	for(int i=0; i<nr; i++){
		ans += v[i].first;
	}
	
	cout << ans;
		
	
	return 0;
}

Measured memory_bytes: 12536
#define DINGER_GISBAR
#include <bits/stdc++.h>
using namespace std;
const long long MOD = static_cast<int>(1e9) + 7;
//{{{TEMPLATE_BEGIN
#include <unistd.h>
using namespace std::rel_ops;
#ifdef ZEROKUGI
#include <dumper.hpp>
#define dump(x) dumper::dumper(cerr, __LINE__, (#x), (x), 50, 1, 1)
#define tick(...) dumper::tick(__VA_ARGS__)
#pragma message "Compiling " __FILE__
#else
#define dump(x)
#define tick(...)
#endif
typedef long long lint;
typedef unsigned long long ulint;
typedef long double ldouble;
typedef vector<int> vint;
#define rep(i, n) \
    for (int i = 0, i##_len = static_cast<int>(n); i < i##_len; i++)
#define all(c) begin(c), end(c)
#define perm(c)   \
    sort(all(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define uniquenize(v) (v).erase(unique(all(v)), end(v))
#define cauto const auto &
#define memset(x, y) memset(x, y, sizeof(x))
#define popcount __builtin_popcount
#define gcd __gcd
inline lint bit(int x) { return 1LL << x; }
template <class T>
inline int size(const T& a) {
    return (int)a.size();
}
template <class T>
inline bool chmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0;
}
template <class T>
inline int clamp(T v, T lo, T hi) {
    return (v > hi) - (v < lo);
}
template <class T>
inline bool chmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
template <class T>
inline pair<vector<T>, char> operator*(const vector<T>& v, const char& c) {
    return make_pair(v, c);
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
#ifdef ZEROKUGI
    if (v.empty()) {
        cerr << "Error L" << __LINE__ << ": vector size is zero." << endl;
        exit(EXIT_FAILURE);
    }
#endif
    for (auto& x : v) is >> x;
    return is;
}
template <class T>
inline ostream& operator<<(ostream& os, const pair<vector<T>, char>& v) {
    bool t = 0;
    for (const T& x : v.first) {
        if (t) os << v.second;
        os << x;
        t = 1;
    }
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, vector<T>& v) {
    return os << v * ' ';
}
struct before_main {
    before_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
        tick(0, 0);
    };
} __before_main;
//}}}TEMPLATE_END

int ans = 0;
int n, k;

vector<int> G[100010];
int par[100010];

int dfs(int v) {
    int farthest = 0;
    for (int w : G[v]) {
        chmax(farthest, dfs(w) + 1);
    }

    if (par[v] != 0 && farthest == k - 1) {
        farthest = -1;
        ans++;
    }
    return farthest;
}

int main() {
    cin >> n >> k;
    vector<int> a(n);

    cin >> a;
    rep(i, n) a[i]--;

    if (a[0] != 0) ans++;

    for (int i = 1; i < n; i++) {
        par[i] = a[i];
        G[a[i]].push_back(i);
    }

    dfs(0);

    cout << ans << endl;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;


signed main(){
  int N,M,X;cin>>N>>M>>X;
  vector<int> C(N);
  vector<vector<int>> A(N,vector<int>(M));
  int ans=INF;
  REP(i,0,N){
    cin>>C[i];
    REP(j,0,M)cin>>A[i][j];
  }

    for (int bit = 0; bit < (1<<N); ++bit) {
      vector<int> M_vec(M,0);
      int tmp=0;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
            tmp+=C[i];
                REP(m,0,M){
                  M_vec[m]+=A[i][m];
                }
            }
        }
        bool flg=true;
        each(v,M_vec){
          if(v<X)flg=false;
        }
        if(flg)ans=min(ans,tmp);
    }
    
    if(ans!=INF)print(ans);
    else print(-1);


}


Measured memory_bytes: 3644
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=math.floor,math.ceil
from collections import deque
Yes=lambda b:print('Yes')if b else print('No');YES=lambda b:print('YES')if b else print('NO')
is_even=lambda x:True if x%2==0 else False

def main():
  n,a,b=ints()
  print(((n-1)//(a+b))*a+min(a,(n-1)%(a+b)+1))

if __name__ == '__main__':
  main()

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

int main() {
  ll n;
  cin >> n;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  reverse(h.begin(), h.end());
  ll ans = 0;
  ll count = 0;
  for (int i = 1; i < n; i++) {
    if (h[i-1] <= h[i]) count++;
    else count = 0;
    ans = max(ans, count);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc090_c();
        }

        static void abc090_c()
        {
            // ABC090 (ARC091) C - Flip,Flip, and Flip......
            // 偶奇：めくり操作が奇数回なら裏、偶数回なら表
            long[] input = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            long a;
            long b;
            long ans;

            // a<=bとする
            a = input[0];
            b = input[1];
            if (input[0] > input[1])
            {
                a = input[1];
                b = input[0];
            }

            // 1x1 -> 1回 -> 裏1
            if (a == 1 && b == 1) ans = 1;
            // 1x2 -> 2回 -> 裏0
            else if (a == 1 && b == 2) ans = 0;
            // 1x3以上 -> 両端が2回、他は3回 -> 裏b-2
            else if (a == 1 && b >= 3) ans = b - 2;
            // 2x2以上 -> 短辺4回、長辺6回 -> 裏0
            else if (a == 2) ans = 0;
            // 3x3以上 -> 4辺上は4回or6回、他は9回 -> (a-2)*(b-2)
            else ans = (a-2) * (b-2);

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13268
public class Main {
    public static void main(String[] args) {

        // ?£?, ???, ??¨?±??????????????´???¨???????????????????????????.
        // ????????????????????????.
        int[][][] info = new int[4][3][10];
        for (int i = 0; i < 4; i ++) {
            for (int j = 0; j < 3; j ++) {
                for (int k = 0; k < 10; k ++) { info[i][j][k] = 0; }
            }
        }

        // ?????±???????????????.
        java.util.Scanner sc = new java.util.Scanner(System.in);
        int n = sc.nextInt();
        int built = 0;
        int floor = 0;
        int room = 0;
        int num = 0;
        for (int i = 0; i < n; i ++) {
            built = sc.nextInt();
            floor = sc.nextInt();
            room = sc.nextInt();
            num = sc.nextInt();
            info[built - 1][floor - 1][room - 1] += num;
        }

        // ?????±????????????????§?????????¨?????????.
        for (int i = 0; i < 4; i ++) {
            for (int j = 0; j < 3; j ++) {
                for (int k = 0; k < 10; k ++) {
                    System.out.print(" " + info[i][j][k]);
                }
                System.out.print("\n");
            }
            if (i != 4 - 1) { System.out.print("####################\n"); }
        }
    }
}

Measured memory_bytes: 29280
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()

	if n%1000 == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(1000 - n%1000)
	}

}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1776
/*
    WRITER:kakitamasziru
*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;
typedef pair<long,long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    //n!はi = 1;i<=nでする
    for (long long i = n-r+1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

int dp[514514];

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> money(M);
    for(int i = 0;i<M;i++) cin >> money.at(i);
    for(int i = 0;i<514514;i++) dp[i] = INF;
    dp[0] = 0;
    for(int i = 0;i<=N;i++){
        for(int j = 0;j<M;j++){
            dp[i+money.at(j)] = min(dp[i]+1,dp[i+money.at(j)]);
        }
    }
    cout << dp[N] << endl;
    /*
    g++ abc.cpp
    ./a.out
    */
    return 0;
}


Measured memory_bytes: 5120
n, k = map(int, raw_input().split())
a = map(int, raw_input().split())

dp = [False] * (k + 1)
for i in range(1, k + 1):
    for x in a:
        if x <= i:
            if not dp[i - x]:
                dp[i] = True
                break
        else:
            break
if dp[k]:
    print('First')
else:
    print('Second')


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int H,N;
int P[1<<19];
const ll mo=1000000007;
vector<pair<int,pair<ll,ll>>> V;
vector<pair<int,pair<ll,ll>>> V2;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H;
	N=1<<H;
	FOR(i,N-1) {
		//x=i+1;
		cin>>x;
		P[(1<<(H-1))+i]=x+(1<<(H-1))-1;
	}
	//srand(time(NULL));
	//random_shuffle(P+(1<<(H-1)),P+(2<<(H-1)));
	//for(i=(1<<(H-1));i<1<<H;i++) cout<<i<<" "<<P[i]<<endl;
	
	
	ll ret=0;
	for(i=1;i<1<<(H-1);i++) {
		int cur=i;
		//cout<<i<<endl;
		V.clear();
		V.push_back({2*cur,{1LL*cur*(2*cur)%mo,0LL}});
		V.push_back({2*cur+1,{0LL,(2*cur+1)}});
		while(V[0].first<1<<(H-1)) {
			V2.clear();
			FORR(a,V) {
				V2.push_back({2*a.first,{a.second.first*1LL*a.first*2%mo,a.second.second*1LL*a.first*2%mo}});
				V2.push_back({2*a.first+1,{a.second.first*1LL*(a.first*2+1)%mo,a.second.second*1LL*(a.first*2+1)%mo}});
			}
			swap(V,V2);
		}
		FORR(v,V) {
			v.first=P[v.first];
			//cout<<v.first<<":"<<v.second.first<<":"<<v.second.second<<" -> ";
			v.second.first=v.second.first*v.first%mo;
			v.second.second=v.second.second*v.first%mo;
			//cout<<v.first<<":"<<v.second.first<<":"<<v.second.second<<endl;
		}
		sort(ALL(V));
		while(V.size()>1) {
			V2.clear();
			FOR(j,V.size()) {
				x=V[j].first/2;
				if(j+1<V.size() && V[j].first/2==V[j+1].first/2) {
					ret+=(V[j].second.first*V[j+1].second.second+V[j].second.second*V[j+1].second.first)%mo*x%mo;
					V2.push_back({x,{(V[j].second.first+V[j+1].second.first)*x%mo,(V[j].second.second+V[j+1].second.second)*x%mo}});
					j++;
				}
				else {
					V2.push_back({x,{V[j].second.first*x%mo,V[j].second.second*x%mo}});
				}
			}
			swap(V,V2);
			
		}
		//cout<<i<<" "<<ret<<endl;
	}
	cout<<ret%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 8952
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

ll res(const Vll &v)
{
	int n=v.size();
	ll ans=0;
	fup(i,0,n-1,1)
	{
		ans=(ans+i*v[i])%MOD;
		ll t=((n-1-i)*v[i])%MOD;
		ans=(ans+MOD-t)%MOD;
	}
	return ans;
}
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	Vll v1(n),v2(m);
	fup(i,0,n-1,1)scanf("%lld",&v1[i]);
	fup(i,0,m-1,1)scanf("%lld",&v2[i]);
	ll t1=res(v1),t2=res(v2);
	printf("%lld",(t1*t2)%MOD);
}

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

int main(){
  while(1){
    int n;
    cin>>n;
    int a;
    if(n==0)break;
    vector<int> k(n);
    string s;
    for(int i=0;i<n;i++)cin>>k[i];
    cin>>s;
    for(int i=0;i<s.size();i++){
      if(k[i%n]<=26){
        a=s[i]-k[i%n];
        if(a<'A'&&s[i]>='A'&&s[i]<='Z'){
           a+='z'-'A'+1;
         }else if(a<'a'&&s[i]>='a'&&s[i]<='z')a-='a'-'Z'-1;
      }else{
        a=s[i]+(52-k[i%n]);
        if(a>'z'&&s[i]<='z'&&s[i]>='a'){
          a-='z'-'A'+1;
        }else if(a>'Z'&&s[i]<='Z'&&s[i]>='A')a+='a'-'Z'-1;
      }
      //putchar(a);
      char A=a;
      cout<<A;
    }
    cout<<endl;
  }
  return 0;
}

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


int main(){
    int N,M;
    cin >> N >> M;
    vector<ll> x(N) , y(N), z(N);
    rep(i,N) cin >> x[i] >> y[i] >> z[i];
    ll ans=0;
    rep(bit,(1<<3)){
        vector<ll> res(N,0); 
        rep(i,N){
            if(bit&(1<<0))res[i]+=x[i];//1番目のビットが立っているか
            else res[i]-=x[i];
            if(bit&(1<<1))res[i]+=y[i];//2番目のビットが立っているか
            else res[i]-=y[i];
            if(bit&(1<<2))res[i]+=z[i];//3番目のビットが立っているか
            else res[i]-=z[i];
        }
        sort(res.rbegin(),res.rend());//降順ソート
        ll tmp = 0;
        rep(i,M)tmp+=res[i];//降順になっているので配列のはじめの方からM個足していけばよい
        ans=max(ans,tmp);//今までのやつのうち最大のものをとる
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
ll read()
{
	ll tmp=0; char f=1,c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1; c=getchar();}
	while('0'<=c&&c<='9'){tmp=tmp*10+c-'0'; c=getchar();}
	return tmp*f;
}
using namespace std;
int main()
{
	ll n=read();
	printf("%lld\n",48-n);
	return 0;
}

Measured memory_bytes: 128
import numpy as np
N, M, K = map(int, input().split())
xy_board = np.ones((N, M))
for _ in range(K):
    x, y, a = map(int, input().split())
    if a == 1:
        xy_board[:x, :] = 0
    elif a == 2:
        xy_board[x:, :] = 0
    elif a == 3:
        xy_board[:, :y] = 0
    elif a == 4:
        xy_board[:, y:] = 0

# print(xy_board)
print(xy_board.sum())

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

using namespace std;
typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K, S;
  cin >> N >> K >> S;
  for(int i=0; i<K; i++) {
    cout << S;
    if(i < N-1)
      cout << " ";
  }
  for(int i=0; i<N-K; i++) {
    if(S < 1000000000)
      cout << S + 1;
    else
      cout << 1;
    if(i < N-1)
      cout << " ";
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>

using namespace std;

int main(void){
	int a,b;
	int x;
	double kake,minus,plus;
	cin >> a >> b;
	plus = a+b;
	kake = a*b;
	minus = a-b;

	cout<<max({plus,kake,minus})<<endl;
}


Measured memory_bytes: 256
s=input()
s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])

if 1<=s1 and s1<=12:
    if 0<=s2 and s2<=99:
        if 1<=s2 and s2<=12:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        print("NA")
else:
    if 0<=s1 and s1<=99:
        if 1 <= s2 and s2 <= 12:
            print("YYMM")
        else:
            print("NA")
    else:
        if 1 <= s2 and s2 <= 12:
            print("YYMM")
        else:
            print("NA")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename T> T gcd(T a, T b){a = abs(a); b = abs(b); if(a<b) swap(a,b); while(b>0){a %= b; swap(a,b);} return a;}
template <typename T> T lcm(T a, T b){return (1LL * a * b) / gcd(a,b);}
template <typename T, typename U> P<T,U> operator+(const P<T,U> &a, const P<T,U> &b){return {a.first + b.first, a.second + b.second};}
template <typename T, typename U> P<T,U> operator-(const P<T,U> &a, const P<T,U> &b){return {a.first - b.first, a.second - b.second};}

template <typename T>
class SegmentTree{
private:
  int size;
  vector<T> vec;
  T e;
  function<T(T,T)> f;
  function<T(T,T)> upd;
  
  int aux(int x, int y, int i, int l, int r){
    if(r<=x || y<=l) return e;
    else if(x<=l && r<=y) return vec[i];
    else return f(aux(x,y,i*2+1,l,(l+r)/2), aux(x,y,i*2+2,(l+r)/2,r));
  };

public:
  SegmentTree(int n, T e, function<T(T,T)> f, function<T(T,T)> upd):
    size((1<<((int)ceil(log(n)/log(2))+1))-1), vec(size, e), f(f), e(e), upd(upd){}
  void update(int i, T x){
    int j = i+(size+1)/2-1;
    vec[j] = upd(vec[j], x);
    --j;
    while(j>=0){
      vec[j/2] = f(vec[(j/2)*2+1], vec[(j/2)*2+2]);
      (j /= 2) -= 1;
    }
  }

  int find(int x, int y){return aux(x,y,0,0,(size+1)/2);}
};

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

  int n,q; cin >> n >> q;
  SegmentTree<int> rsq(n, 0, [](int a, int b){return a+b;}, [](int a, int b){return a+b;});

  REP(i,q){
    int com,x,y; cin >> com >> x >> y;
    if(com){
      cout << rsq.find(x-1,y) << endl;
    }else{
      rsq.update(x-1,y);
    }
  }
  
  return 0;
}



Measured memory_bytes: 4120
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
d = list(map(int, input().split()))
M = 998244353
from collections import Counter
c = Counter(d)
if d[0]!=0 or c[0]>=2:
    ans = 0
else:
    m = max(c.keys())
    ans = 1
    for i in range(1,m+1):
        if i not in c:
            ans = 0
            break
        ans *= pow(c[i-1], c[i], M)
        ans %= M
print(ans%M)

Measured memory_bytes: 23284
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

void no(){cout << "No" << endl;}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n;
    int m = n * n;
    vector<int> ans(m + 1, -1);
    vector<int> xv(n+1);
    vector<pair<int, pair<int,int> > > le;
    vector<pair<int, pair<int,int> > > ri;
    for(int i=1;i<=n;i++){
    	cin >> x;
    	xv[i] = x;
    	ans[x] = i;
    	if(x > 1 && i > 1) le.push_back({x, {i, i - 1}});
    	if(x < m && i < n) ri.push_back({x, {i, n - i}});
    }
    sort(be(le));
    sort(be(ri));
    deque<pair<int, int> > l, r;
    for(auto& i: le) l.pb(i.second);
    for(auto& i: ri) r.pb(i.second);
    for(int i=1;i<=m;i++){
    	if(l.empty()) break;
    	if(ans[i] == -1){
    		ans[i] = l.front().first;
    		if(l.front().second == 1) l.pop_front();
    		else l.front().second--;
    	}
    }
    for(int i=m;i>=1;i--){
    	if(r.empty()) break;
    	if(ans[i] == -1){
    		ans[i] = r.back().first;
    		if(r.back().second == 1) r.pop_back();
    		else r.back().second--;
    	}
    }
    vector<vector<int> > v(n+1, vector<int> ());
    for(int i=1;i<=m;i++){
    	if(ans[i] == -1){
    		no();
    	    return 0;
    	}
    	v[ans[i]].pb(i);
    }
    for(int i=1;i<=n;i++){
    	if(v[i].size() != n || v[i][i-1] != xv[i]){
    		no();
    		return 0;
    	}
    }
    cout << "Yes" << endl;
    for(int i=1;i<=m;i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N), B(N);
    vector<pair<ll, ll>> p;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        p.push_back(make_pair(A[i], B[i]));
    }
    
    ll count = 0;
    ll cost = 0;
    sort(p.begin(), p.end());
    for (int i = 0; i < N; i++) {
        cost += p[i].first * p[i].second;
        count += p[i].second;
        if (count >= M) {
            cost -= (count-M) * p[i].first; 
            break;
        }
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 3956
#include <iostream>

using namespace std;

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

	int ans = 0;

	if (K <= A)
		ans = K;
	else
		ans = A;

	K = K - A - B;

	if (K > 0)
		ans -= K;

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

Measured memory_bytes: 3628
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a;
  cin >> a;
  for(int i=0;i<4;i++){
    cout << a[i];
  }
  cout << " ";
  for(int i=4;i<a.size();i++){
    cout << a[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    ans = 1000

    for i in range(len(a)-1):
        if a[i]<a[i+1]:
            ans += (a[i+1]-a[i])*(ans//a[i])

    print(ans)


Measured memory_bytes: 9168
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

if N % 2 == 1:
    i = N // 2
    AB.sort()
    L = AB[i][0]
    AB.sort(key=lambda x: x[1])
    R = AB[i][1]
    ans = R - L + 1
else:
    i = N // 2 - 1
    j = i + 1
    AB.sort()
    L = AB[i][0] + AB[j][0]
    AB.sort(key=lambda x: x[1])
    R = AB[i][1] + AB[j][1]
    ans = R - L + 1

print(ans)

Measured memory_bytes: 48996
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 53;
ll a[MAXN];
ll n,k;

void solve(){
    cin>>n>>k;

    ll ans = 0;
    FOR(i,1,n) cin>>a[i];

    for(ll i=1;i<=min(k,n);i++){
        // clog<<i<<"->\n";
        for(ll aage = 1;aage <= i;aage++){
            vector<ll> v;
            for(ll p=1;p<=aage;p++) v.push_back(a[p]);
            for(ll p=1;p<=i-aage;p++) v.push_back(a[n-p+1]); 

            sort(all(v));
            // for(ll x:v) clog<<x<<" ";
            // clog<<endl;
            ll sum = 0,temp = 0;
            for(ll x:v) sum += x;

            ans = max(ans,sum); 
            for(ll j=0;j<min((ll)v.size(),k-i);j++){
                temp += v[j];
                ans = max(ans,sum - temp);
            }
            // clog<<ans<<endl;
        }
    }
    cout<<ans<<endl;
}   

signed main(){

   FastRead;    


    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}




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

Y //= 1000

ans = False
for i in range(N + 1):
    for j in range((N - i) + 1):
        if 10 * i + 5 * j + 1 * (N - i - j) == Y:
            ans = True
            break
    else:
        continue
    break

if ans:
    print(i, j, N - i - j)
else:
    print(-1, -1, -1)


Measured memory_bytes: 40812
N,K = gets.chomp.split.map(&:to_i)
as = gets.chomp.split.map(&:to_i).sort
cnt_same = Array.new(N,0)
as.each do |a|
  cnt_same[a-1] += 1
end
cnt_same.delete(0)
cnt_same.sort!.reverse!
if cnt_same.size > K
  ans = cnt_same[K..-1].inject(:+)
else
  ans = 0
end
puts ans


Measured memory_bytes: 21220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
  int res = 1;
  x = x % p;
  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;

    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int lc(int a,int b){
  return a / __gcd(a, b) * b;
}
int lcm(int a, int b)
{
  int u = __gcd(a, b);
  u = power(u, mod - 2, mod);
  return ((a % mod * b % mod) % mod * u % mod) % mod;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  tc = 1;
  while (tc--)
  {
    int n, k;
    cin >> n;
    map<pair<int,int>, int> mp,mp2;
    for (int i = 1; i <= n;i++){
      int u = i;
      int v = i % 10;
      while ((u / 10) != 0)
      {
       u = u / 10;
      }
      mp[{v, u}]++;
    }
    int ans = 0;
    for (int i = 1; i <= n;i++){
      int u = i;
      int v = i % 10;
      while ((u / 10) != 0)
      {
        u = u / 10;
      }
      
      ans = ans +mp[{u,v}];
     // cout << ans << " ";
    }

      cout << ans << endl;
  }

  return 0;
}

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

int main() {
    int n;
    int a[101] = { 0 };
    int i;

    cin >> n;
    for(i = 0; i < n; i++) cin >> a[i];

    for(i = 0; i < n; i++) {
        if(a[i] % 2 == 0) {
            if((a[i] % 3) != 0) {
                if((a[i] % 5) != 0) {
                    cout << "DENIED" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define FOR(i, s, n) for(int i=(int)(s); i<(int)(n); ++i)
#define ALL(n) (n).begin(), (n).end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;

const ll MAX_V = 100000;
const ll INF = 1e9;
const ll MOD = 998244353;

int main(){
    int n, nn; cin >> n;
    int s = 0;
    nn = n;
    while(n > 0){
        s += (n % 10);
        n /= 10;
    }
    if (nn % s == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++)
        cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[n / 2] - d[n / 2 - 1] << endl;
}


Measured memory_bytes: 640
<?php
$x = explode(" ",trim(fgets(STDIN)));

$count = 0;
foreach($x as $val){
if($val % 2 == 0){
$count++;
}
}

if($count % 2 == 1){
echo 0;
}else{
sort($x);
echo $x[0] * $x[1];
}

Measured memory_bytes: 3452
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

void solve() {
    lli n, h, w;
    cin >> n >> h >> w;
    lli ans = 0;
    for (int i = 1; i <= n; ++i) {
        lli x, y;
        cin >> x >> y;
        if (x >= h and y >= w) ans++;
    }
    cout << ans << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;

    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
char C[127];
int main() {
	int n,m;
	while(scanf("%d",&n),n) {
		getchar();
		char ch1,ch2;
		memset(C,0,sizeof(C));
		for(int i=0;i<n;i++) {
			ch1=getchar();getchar();
			ch2=getchar();getchar();
			C[ch1]=ch2;
		}
		scanf("%d",&m);
		getchar();
		for(int i=0;i<m;i++) {
			char ch=getchar();getchar();
			if(C[ch])printf("%c",C[ch]);
			else printf("%c",ch);
		}
		putchar('\n');
	}
}

Measured memory_bytes: 1004
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

inline ll gcd(ll a, ll b) {
  return b > 0 ? gcd(b, a%b) : a;
}

inline ll lcm(ll a, ll b) {
  return a*b / gcd(a, b);
}

int main() {
  
  int N;
  while(cin >> N && N) {
    vector<ll> vd(N), vv(N);
    rep(i, N) {
      cin >> vd[i] >> vv[i];
      int const GCD = gcd(vd[i], vv[i]);
      vd[i] /= GCD, vv[i] /= GCD;
    }
    
    ll D = vd[0], V = vv[0];
    REP(i,1,N) {
      D = lcm(D, vd[i]);
      V = gcd(V, vv[i]);
    }
    //cout << D << " " << V << endl;
    
    rep(i, N) cout << D*vv[i]/V/vd[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1196
N = int(input())
A = [0]+list(map(int,input().split()))
costs = [0 for i in range(N+1)]

for i in range(2,N+1):
    if i-1 >= 1:
        costs[i] = costs[i-1]+abs(A[i]-A[i-1])
    if i-2 >= 1:
        costs[i] = min(costs[i], costs[i-2]+abs(A[i]-A[i-2]))
print(costs[N])

Measured memory_bytes: 13980
//be naame khodaa

#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <sstream>
#define fi first
#define se second
#define rep(i, x, n) for (int i = x; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> VI;

int main()
{
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	ll each = m*1900 + (n-m)*100;
	cout << (each << m) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	const int sz=22;
	char s[sz];
	cin>>s;
	 for(int i=0;i<=4;i++)
	 cout<<s[i];
	 cout<<" ";
	 for(int n=6;n<=12;n++)
	 cout<<s[n];
	 cout<<" ";
	 for(int m=14;m<=18;m++)
	 cout<<s[m];
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(c,b/a) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define nMAX 100000

int A[nMAX];

int Partition(int L,int R){
	int x=A[R], i=L-1, j,tmp;

	for(j=L;j<R;j++){
		if(A[j]<=x){
			++i;

			// swap(A[i].A[j])
			tmp=A[i];
			A[i]=A[j];
			A[j]=tmp;
		}
	}
	tmp=A[R];
	A[R]=A[i+1];
	A[i+1]=tmp;

	return i+1;
}

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

	pos=Partition(0,n-1);

	for(i=0;i<n;i++){
		if(i)printf(" ");

		if(i==pos){
			printf("[");
			printf("%d",A[i]);
			printf("]");
		}else printf("%d",A[i]);
	}printf("\n");

	return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

struct DSU
{
	int S;
	
	struct node
	{
		int p; ll sum;
	};
	vector<node> dsu;
	
	DSU(int n)
	{
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	
	void reset(int n)
	{
		dsu.clear();
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	int rt(int u)
	{
		if(dsu[u].p == u) return u;
		dsu[u].p = rt(dsu[u].p);
		return dsu[u].p;
	}
	
	void merge(int u, int v)
	{
		u = rt(u); v = rt(v);
		if(u == v) return ;
		if(rand()&1) swap(u, v);
		dsu[v].p = u;
		dsu[u].sum += dsu[v].sum;
	}
	
	bool sameset(int u, int v)
	{
		if(rt(u) == rt(v)) return true;
		return false;
	}
	
	ll getstat(int u)
	{
		return dsu[rt(u)].sum;
	}
};

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	DSU dsu(n);
	for(int i=0;i<m;i++)
	{
		int u,v; cin>>u>>v; u--; v--; dsu.merge(u,v);
	}
	ll ans=0;
	for(ll i=0;i<=n;i++)
	{
		if(dsu.getstat(0)<=i&&dsu.getstat(1)<=n-i)
		{
			ans=max(ans,(i*(i-1)+(n-i)*(n-i-1))/2);
		}
	}
	cout<<ans-m<<'\n';
}	


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int a, b;
bool isAlice()
{
    if(a == 1)
        return true;
    if(b == 1)
        return false;
    return a > b;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    cin >> a >> b;
    if(a == b) {
        cout << "Draw" << endl;
        exit(0);
    }

    cout << (isAlice() ? "Alice" : "Bob") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    double ans=0,tmp,min;
    int n;
    scanf("%d",&n);
    double s[n],t[n],v[n];
    for (int i=0; i<n; i++){
        double p;
        scanf("%lf",&p);
        s[i]=t[i-1],t[i]=t[i-1]+p;
    }
    for (int i=0; i<n; i++){
        scanf("%lf",&v[i]);
    }
    for (int i=0; i<t[n-1]*2; i++){
        min=fmin((double)i/2,(t[n-1]*2-(double)i)/2);
        for (int j=0; j<n; j++){
            if (i<s[j]*2){
                tmp=v[j]+(s[j]*2-(double)i)/2;
            } else if (s[j]*2<=i && t[j]*2>i){
                tmp=v[j];
            } else {
                tmp=v[j]+((double)i-t[j]*2)/2;
            }
            if (min>tmp){
                min=tmp;
            }
        }
        ans+=min;
    }
    printf("%lf\n",ans/2);
	return 0 ;
}

Measured memory_bytes: 256
import itertools


N, M, X = list(map(int, input().split()))
CA = [list(map(int, input().split())) for i in range(N)]
# print(N, M, X)
# print(CA)

INF = 10 ** 5 * 12 + 1
min_amount = INF
for i in range(1, N + 1):
    combinations = itertools.combinations(range(N), i)

    for combination in combinations:
        understanding_list = [0] * M
        amount = 0
        for i in combination:
            for j in range(1, len(CA[i])):
                understanding_list[j - 1] += CA[i][j]
            amount += CA[i][0]

        # print(understanding_list)
        is_reached = all([understanding >= X for understanding in understanding_list])
        if not is_reached: continue

        min_amount = min(amount, min_amount)

answer = -1 if min_amount == INF else min_amount

print(answer)


Measured memory_bytes: 9228
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 20*500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
ll n;
ll cnt[N];
ll ans;

void solve()
{
    cin >> n;
    for (int i = 1; i <= n;++i)
        for (int j = i; j <= n;j+=i)
            cnt[j]++;
    for (int i = 1; i <= n;++i)
        ans += i * cnt[i];
    cout << ans << '\n';
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main(void){
    int N;
    int max = -1,max_last = -1;
    vector<int> v;
    cin >> N;
    for(int i = 0;i < N;i++){
        int x;
        cin >> x;
        v.push_back(x);
        if(max < x){
            max_last = max;
            max = x;
        }else if(max_last < x){
            max_last = x;
        }
    }
    for(int i : v){
        cout << (i != max ? max : max_last) << endl;
    }
    return 0;
}

Measured memory_bytes: 2548
#include<stdio.h>
#include<string.h>
int main()
{
   char year_and_date[10];
   scanf("%s",year_and_date);
   if(year_and_date[3]=='7') year_and_date[3]='8';
   printf("%s\n",year_and_date);
   return 0;
}


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


def solve(A: int, B: int):
    if A >= 13:
        print(B)
    elif A>=6:
        print(B//2)
    else:
        print(0)
    return


# Generated by 1.1.5 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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	int n;cin>>n;
	if(n%10==3)
		cout<<"bon";
	else if((n%10==0)||(n%10==1)||(n%10==6)||(n%10==8))
		cout<<"pon";
	else if((n%10==2)||(n%10==4)||(n%10==5)||(n%10==7)||(n%10==9))
		cout<<"hon";
	return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 100000000001
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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


int main()
{
    int n, m, l[101];
    l[0] = 0;
    l[1] = 0;
    cin >> n >> m;
    FOR(i, 1, 101) l[i] = l[i-1] + i;
    if(n == 0) cout << l[m-1] << endl;
    else if(m == 0) cout << l[n - 1] << endl;
    else cout << l[n - 1] + l[m-1] << endl;
}


Measured memory_bytes: 256