akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m, d; cin >> n >> m >> d;
  ld res = (ld)(n - d) * (m - 1) * (d != 0 ? 2 : 1);
  res /= (n * n);
  cout << setprecision(12) << res << endl;
  return 0;
}

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

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int q = Integer.parseInt(str[0]);
		SortedMap<String, Integer> mpa = new TreeMap<String, Integer>();
		for(int i = 0; i < q; i++){
			str = br.readLine().split(" ");
			int op = Integer.parseInt(str[0]);
			if(op == 0){
				String key = str[1];
				int x = Integer.parseInt(str[2]);
				mpa.put(key, x);
			}else{
				String key = str[1];
				System.out.println(mpa.get(key));
			}
		}
	}
}



Measured memory_bytes: 95524
#include <bits/stdc++.h>
using namespace std;
#define incant() cin.tie(0), ios::sync_with_stdio(false)
#define int long long
#define uint unsigned long long
#define double long double
using str = string;
template <class T> using vec = vector<T>;
template <class T> using vvec = vec<vec<T>>;
template <class T> using que = queue<T>;
template <class T> using pque = priority_queue<T>;
template <class... T> using tup = tuple<T...>;
using vint = vec<int>;
using vvint = vvec<int>;
using vstr = vec<str>;
using pint = pair<int, int>;
using vp = vec<pint>;
using tll = tup<int, int, int>;
using vt = vec<tll>;
using mint = map<int, int>;
using dict = map<str, int>;
using qint = que<int>;
using qp = que<pint>;
using pqint = pque<int>;
using pqp = pque<pint>;
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fir first
#define sec second
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define sz(x) x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define ms(v, x) memset(v, x, sizeof(v))
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload3(__VA_ARGS__, revi, _rev,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) out(x), indent()
#define debug(x) cerr << __LINE__ << ": " << #x << ": " << (x) << '\n'
#define YN(x) print((x) ? "YES" : "NO")
#define Yn(x) print((x) ? "Yes" : "No")
#define yn(x) print((x) ? "yes" : "no")
#define POS(x) print((x) ? "POSSIBLE" : "IMPOSSIBLE")
#define Pos(x) print((x) ? "Possible" : "Impossible")
#define pos(x) print((x) ? "possible" : "impossible")
const int INF = 1e16, MOD = 1e9 + 7, LIMIT = 100001;
const int dx4[] = {-1, 0, 1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const double EPS = 1e-9;
int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
int combination(int n, int r){int res = 1; rep(i, 1, r + 1) res *= n--, res /= i; return res;}
const str alphabet = "abcdefghijklmnopqrstuvwxyz";
int c, n, m, x, y, z, w, h, res = 0, cnt = 0, sum = 0, mx = -INF, mn = INF;
str s, t;
bool flag = true;

signed main(){
    incant();
    cin >> n >> h;
    int a[n], b[n];
    rep(i, n){
        cin >> a[i] >> b[i];
        chmax(mx, a[i]);
    }
    sort(b, b + n, greater<int>());
    int i = 0;
    while(b[i] > mx && h > 0){
        res++, h -= b[i], i++;
    }
    while(h > 0){
        res++, h -= mx;
    }
    print(res);
}


Measured memory_bytes: 1792
#include <stdio.h>
int fib(int n){
  if(n == 0 || n == 1) return 1;
  return fib(n-1) + fib(n-2);
}
int main(){
  int i, n, F[44];
  F[0] = 1;
  F[1] = 1;
  scanf("%d",&n);
  for(i = 2; i <= n; i++){
    F[i] = F[i-1] + F[i-2];
  }
  printf("%d\n",F[n]);
  return 0;
}

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

//#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    vector<pair<int,int>> v;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int t;
        cin >> t;
        v.push_back({t,i});
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) cout << v[i].second << ' ';
    cout << '\n';
}
/*

 */

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

int main() {
    string S;
    getline(cin, S);
    for (int i=0; i<S.size(); i++) {
        if (((S.at(i)-'a')>=0)&&(S.at(i)-'a'<=25))
            S.at(i)=S.at(i)-'a'+'A';
        else if (((S.at(i)-'A')>=0)&&(S.at(i)-'A'<=25))
            S.at(i)=S.at(i)-'A'+'a';
    }
    cout <<S <<endl;
    return 0;
}


Measured memory_bytes: 3140
def main():
    import sys
    import math
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # map(int, input().split())

    n = int(input())
    wow = dict()
    for _ in range(n):
        s = list(input()[:-1])
        s.sort()
        s = str(s)
        if wow.get(s) == None:
            wow[s] = 0
        wow[s] += 1
    # print(wow)

    def combinations_count(n, r):
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    ans = 0
    for i in wow.values():
        # print(i)
        if i == 1:
            continue
        ans += combinations_count(i, 2)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

vector<int> G[2500];

int V, E;
int from[5000], to[5000], cost[5000];
bool reachable[5000];
ll d[5000];

void bfs(int g) {
    queue<int> que;
    que.push(g);
    reachable[g] = 1;
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int u : G[v]) {
            if (reachable[u]) continue;
            reachable[u] = 1;
            que.push(u);
        }
    }
}

int bellman_ford(int s) {
    for (int i = 0; i < V; i++) d[i] = LINF;
    d[s] = 0;
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < E; j++) {
            if (d[from[j]] == LINF || d[to[j]] <= d[from[j]] + cost[j]) continue;
            d[to[j]] = d[from[j]] + cost[j];
            if (i == V - 1 && reachable[to[j]]) {
                return true;
            }
        }
    }
    return false;
}

void solve() {
    int p;
    cin >> V >> E >> p;
    rep(i, E) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        from[i] = a;
        to[i] = b;
        cost[i] = p - c;
        G[b].push_back(a);
    }
    bfs(V - 1);
    if (bellman_ford(0)) {
        cout << -1 << endl;
    } else {
        cout << max(0LL, -d[V - 1]) << endl;
    }
}

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


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

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

int main() {
    ll x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[222222],l,r,mid,curl,z,num;
bool nl,b[222222];
bool check(int mid)
{
	for (int i=1;i<2*n;i++)
	{
		if (a[i]>=mid) b[i+1]=1;
		else b[i+1]=0;
	}
	b[1]=b[2];b[2*n+1]=b[2*n];
	curl=-1;
	for (int i=1;i<=2*n;i++)
	{
		if (b[i]==b[i+1])
		{
			if (curl!=-1)
			{
				if (b[i]==nl)
				{
					for (int j=curl;j<=i+1;j++) b[j]=nl;
				}
				else
				{
					num=0;
					for (int j=curl;j<=i+1;j++) 
					{
						if (!b[j]) num++;
					}
					if (!nl)
					{
						for (int j=curl;j<curl+num;j++) b[j]=0;
						for (int j=curl+num;j<=i+1;j++) b[j]=1;
					}
					else
					{
						for (int j=i+1;j>=i+2-num;j--) b[j]=0;
						for (int j=curl;j<i+2-num;j++) b[j]=1;
					}
				}
				curl=i;
				nl=b[i];
				i++;
			}
			else 
			{
				curl=i;
				nl=b[i];
			}
		}
	}
	if (b[n+1]) return 1;
	return 0;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=2*n-1;i++)
	{
		scanf("%d",&a[i]);
	}
	l=1;r=2*n-1;
	while(l<=r)
	{
		mid=(l+r)/2;
		if (check(mid)) l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 1280
s=str(input())
s=s[::-1]
n=len(s)
ans=0

c=[[(2**(n-1))]]
for i in range(n-1):
    if i>=1:
        d=c[i][:-1]
    else:
        d=[]
    d.append(c[i][-1]//2)
    d.append(c[i][-1]//2)
    #d=d[::-1]
    c.append(d)
for i in range(n):
    for j in range(len(c[i])):
        ans+=c[i][j]*(10**j)*int(s[i])
        #print(c[i][j]*(10**j)*int(s[i]))
#print(c)
print(ans)

Measured memory_bytes: 3064
s = input()
t = input()
cnt1 = [0]*26
cnt2= [0]*26
for x in s:
    cnt1[ord(x) - ord('a')] += 1
for x in t:
    cnt2[ord(x) - ord('a')] += 1
cnt1.sort()
cnt2.sort()
ok = True
for i in range(26):
    if cnt1[i] != cnt2[i]:
        ok = False
        break
if ok:print('Yes')
else:print('No')


Measured memory_bytes: 3632
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

ll max_n = 10000010;


vector<ll> primes(max_n);
vector<bool> is_prime(max_n, true);
vector<bool> is_found(max_n, false);
vector<map<ll,ll>> prime_factors(max_n);

ll sieve(ll N){
    fill(is_prime.begin(), is_prime.end(), true);
    is_prime[0] = false;
    is_prime[1] = false;
    ll num_p=0;
    for(ll i=2;i<N;i++){
        if(is_prime[i]){
            primes[num_p++] = i;
            for(ll j=2*i;j<N;j+=i){
                is_prime[j] = false;
            }
        }
    }
    return num_p;
}

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

void Main(){
    ll N;
    sll(N);
    ll ans = 0;
    rep(i, N+1){
        ll j = i + 1;
        ll max_d = N / j;
        ll this_add = (1 + max_d) * max_d / 2;
        ans += this_add * j;
    }
    
    cout << ans << endl;
    


}

int main(){
    Main();
}

Measured memory_bytes: 317596
s=input()
k=int(input())
if len(s)==1:
  print(k//2)
  exit()
c=[]
c_=1
for i in range(1,len(s)):
  if s[i-1]==s[i]:
    c_+=1
  else:
    c.append(c_)
    c_=1
c.append(c_)
if len(c)==1:
  print((c[0]*k)//2)
elif s[0]==s[-1]:
  ans=sum([c_//2 for c_ in c[1:-1]])*k
  ans+=c[0]//2
  ans+=c[-1]//2
  ans+=((c[0]+c[-1])//2)*(k-1)
  print(ans)
else:
  print(sum([c_//2 for c_ in c])*k)
#print(c)


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

vector<vector<int> > graph;
vector<int> a, b;
vector<int> flag;
int n, m;

void dfs(int v){
    flag[v] = 1;
    for(int i = 0; i < n; i++){
        if(graph[v][i] == 1 && flag[i] == 0){
            dfs(i);
        }else{
            continue;
        }
    }
}

int main(){
    cin >> n >> m;
    int ans = 0;
    a = vector<int>(51, 0);
    b = vector<int>(51, 0);
    graph = vector<vector<int> >(51, vector<int>(51, 0));
    flag = vector<int>(51, 0);
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = 1;
        graph[b[i]][a[i]] = 1;
    }
    for(int i = 0; i < m; i++){
        graph[a[i]][b[i]] = 0;
        graph[b[i]][a[i]] = 0;
        for(int l = 0; l < n; l++){flag[l] = 0;}
        dfs(0);
        int f = 0;
        for(int l = 0; l < n; l++){
            if(flag[l] == 0){
                f = 1;
                break;
            }
        }
        ans += f;
        graph[a[i]][b[i]] = 1;
        graph[b[i]][a[i]] = 1;
    }
    cout << ans  << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  cout<<"100 100\n";
  int A,B;
  cin>>A>>B;A--,B--;
  vector<vector<char>> C(100,vector<char>(100,'#'));
  for(int i=50;i<100;i++)
    for(int j=0;j<100;j++)
      C[i][j]='.';
  for(int i=0;i<100;i+=2){
    for(int j=0;j<100;j+=2){
      if(A==0)break;
      C[i][j]='.',A--;
    }
    if(A==0)break;
  }
  for(int i=51;i<100;i+=2){
    for(int j=0;j<100;j+=2){
      if(B==0)break;
      C[i][j]='#',B--;
    }
    if(B==0)break;
  }
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++)
      cout<<C[i][j];
    cout<<'\n';
  }
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
using namespace std;
typedef long long LL;

int main() {
    int a, p;
    cin >> a >> p;
    a = (3 * a) + p;
    cout << a / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using P = pair<int, int>;
using ll = long long;
const int INF = 1001001001;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <deque>
using namespace std;

int main() {
    int a, b;
    while (2 == scanf("%d%d", &a, &b) && (a || b)) {
        puts((a % 2 && b % 2) ? "no" : "yes");
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 0
#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h> // sqrt
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long> data(N + 1);
    data.at(0) = 2;
    data.at(1) = 1;
    long ans= 0;
    for (int i = 2; i < N + 1; i++) {
        ans = data.at(i - 2) + data.at(i - 1);
        data.at(i) = ans;
    }
    ans = data.at(N);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y,a,b,c;scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
    int p[a],q[b],r[c];
    for(int i=0;i<a;i++)scanf("%d",&p[i]);
    for(int i=0;i<b;i++)scanf("%d",&q[i]);
    for(int i=0;i<c;i++)scanf("%d",&r[i]);
    sort(p,p+a),sort(q,q+b),sort(r,r+c);
    priority_queue<int,vector<int>,greater<int>> A,B;
    for(int i=0;i<x;i++)A.push(p[a-1-i]);
    for(int i=0;i<y;i++)B.push(q[b-1-i]);
    for(auto C:r){
        if(A.top()>=B.top()){
            if(B.top()<C)B.pop(),B.push(C);
        }
        else{
            if(A.top()<C)A.pop(),A.push(C);
        }
    }
    long long ans=0;
    while(A.size())ans+=A.top(),A.pop();
    while(B.size())ans+=B.top(),B.pop();
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2552
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int N;
    cin  >> N;
    graph G(N);
    vector<pair<ll,ll>> E(N - 1);
    for(int i = 0; i < N; i++){
        G[i] = vector<ll>(0);
    }
    for(int i = 0; i < N - 1; i++){
        ll A,B;
        cin >> A >>B;
        A--;
        B--;
        G[A].push_back(B);
        G[B].push_back(A);
        E[i].first = A;
        E[i].second = B;
    }
    vector<ll> c(N);
    for(int i = 0; i < N; i++){
        cin >> c[i];
    }
    sort(c.begin(),c.end(),greater<ll>());
    vector<ll> V(N);
    for(int i = 0; i < N; i++){
        V[i] = -1;
    }
    queue<ll> q = queue<ll>();
    q.push(0);
    ll paintCount = 0;
    while(!q.empty()){
        ll currentV = q.front();q.pop();
        V[currentV] = c[paintCount];
        paintCount++;
        for(int i = 0; i < G[currentV].size(); i++){
            ll next = G[currentV][i];
            if(V[next] != -1){
                continue;
            }
            q.push(G[currentV][i]);
        }
    }
    ll score = 0;
    for(int i = 0; i < N -1; i++){
        score += min(V[E[i].first],V[E[i].second]);
    }
    cout << score << endl;
    for(int i = 0; i < N; i++){
        cout << V[i] << endl;
    }
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s; cin >> s;

    unordered_map<char, bool> exist;
    for (auto &si: s) {
        exist[si] = true;
    }

    for (char c = 'a'; c <= 'z'; ++c) {
        if (!exist[c]) {
            return cout << s << c << "\n", 0;
        }
    }

    for (size_t i = s.length() - 1; i >= 1; --i) {
        if (s[i - 1] < s[i]) {
            char best = s[i];
            for (size_t j = i; j < s.length(); ++j) {
                if (s[j] > s[i - 1]) {
                    chmin(best, s[j]);
                }
            }
            s[i - 1] = best;
            return cout << s.substr(0, i) << "\n", 0;
        }
    }

    cout << -1 << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	string a;
	while (cin >> a)
	{
		int b = 0; int c = 0;
		for (int i = 0; i < a.size(); i++)
		{
			if (a[i] == 'J')
			{
				if (a[i + 1] == 'O'&&a[i + 2] == 'I')
				{
					b++;
				}
			}
			if (a[i] == 'I')
			{
				if (a[i + 1] == 'O'&&a[i + 2] == 'I')
				{
					c++;
				}
			}
		}
		cout << b << endl << c << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3144
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { std::cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { std::cin >> first; Scan(rest...); }
#define OUT(d) std::cout<<d;
#define FOUT(n, d) std::cout<<std::fixed<<std::setprecision(n)<<d;
#define SOUT(n, c, d) std::cout<<std::setw(n)<<std::setfill(c)<<d;
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";
#define FLUSH std::cout<<std::flush;
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
#define PAIR std::pair<int, int>
#define IN(a, x, b) (a<=x && x<b)
#define SHOW(d) {std::cout << #d << "\t:" << d << "\n";}
#define SHOWVECTOR(v) {std::cout << #v << "\t:";for(const auto& i : v){std::cout << i << " ";}std::cout << "\n";}
#define SHOWVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout << j << " ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout<<'('<<j.first<<", "<<j.second<<") ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR(v) {for(const auto& i:v){std::cout<<'('<<i.first<<", "<<i.second<<") ";}std::cout<<"\n";}
#define CHECKTIME(state) {auto start=std::chrono::system_clock::now();state();auto end=std::chrono::system_clock::now();auto res=std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count();std::cerr<<"[Time:"<<res<<"ns  ("<<res/(1.0e9)<<"s)]\n";}
#define SHOWQUEUE(a) {std::queue<decltype(a.front())> tmp(a);std::cout << #a << "\t:";for(int i=0; i<static_cast<int>(a.size()); ++i){std::cout << tmp.front() << "\n";tmp.pop();}std::cout << "\n";}

//#define int ll
using ll = long long;
constexpr int INFINT = 1 << 30;
constexpr ll INFLL = 1LL << 60;
constexpr double EPS = 0.0000000001;
constexpr int MOD = 1000000007;

int main() {
	INIT;
	VAR(int, n);
	VEC(int, a, n);
	std::vector<int> sorted(a);
	std::sort(ALL(sorted));
	int ans = 0;
	REP(i, n) {
		int t = std::distance(std::begin(sorted), std::lower_bound(ALL(sorted), a[i]));
		if ((i + t) % 2 == 1) ++ans;
	}
	ans /= 2;
	OUT(ans)BR;
	return 0;
}

Measured memory_bytes: 1024
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n, k = nm()
x = nl()

if 0 in x:
    k -= 1
if n == 1:
    print(x[0])
    exit()

zero = bisect_left(x, 0)
costs = []
#print(zero, max(zero - k, 0), min(zero + k, n - k) + 1)
for i in range(max(zero - k, 0), min(zero + k, n - k) + 1):
    if x[i] < 0 and x[i+k-1] > 0:
        costs.append(-2 * x[i] + x[i+k-1])
        costs.append(-1 * x[i] + 2 * x[i+k-1])
    else:
        costs.append(max(abs(x[i]), abs(x[i+k-1])))
    #print(i, x[i], costs)
print(min(costs))

Measured memory_bytes: 14660
s = input().strip()
n = len(s)

acum = [0] * (n + 1)
acgt = ['A', 'C', 'G', 'T']

for i in range(1, n + 1):
    if s[i - 1] in acgt:
        acum[i] = acum[i - 1] + 1
    else:
        acum[0] = 0

print(max(acum))



Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        string[] s = SpRead(' ');
        int H = int.Parse(s[0]);
        int W = int.Parse(s[1]);
        string[,] list = new string[50, 50];
        for (int i = 0; i < H; i++)
        {
            s = Console.ReadLine().ToCharArray().Select(a => a.ToString()).ToArray();
            for (int j = 0; j < W; j++) { list[i, j] = s[j]; }
        }
        bool flag = true;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (list[i, j] == "#")
                {
                    if (i != 0)
                    {
                        if (list[i - 1, j] == "#") { flag = true; continue; }
                        else flag = false;
                    }
                    if (i != W - 1)
                    {
                        if (list[i + 1, j] == "#") { flag = true; continue; }
                        else flag = false;
                    }
                    if (j != 0)
                    {
                        if (list[i, j - 1] == "#") { flag = true; continue; }
                        else flag = false;
                    }
                    if (j != H - 1)
                    {
                        if (list[i, j + 1] == "#") { flag = true; continue; }
                        else flag = false;
                    }

                }

                if (!flag)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
        }
        Console.WriteLine("Yes");
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


Measured memory_bytes: 13368
def bills(count, value):
    max10000 = value // 10000
    for i in range(max10000 + 1):
        max5000 = min(count - i, (value - i * 10000) // 5000)
        for j in range(max5000 + 1):
            k = (value - i * 10000 - j * 5000) // 1000
            if i + j + k == count:
                return i, j, k
    
    return -1, -1, -1

v = bills(*map(int, input().split()))
print("{} {} {}".format(*v))

Measured memory_bytes: 3064
import numpy as np
n, W = map(int, input().split())
dp = np.full(n*10**3+1, W+1,'i8')
dp[0] = 0
for i in range(n):
  w, v = map(int, input().split())
  dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
print(np.max(np.where(dp<=W)))

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

using namespace std;

long max(long a, long b)
{
    if(a>b) return a; return b;
}

long max_val(vector<pair<long, long> > v, long w, long n)
{
    long dp[n+1][w+1];
    for(long i=0; i<n+1; i++) dp[i][0]=0;
    for(long i=0; i<w+1; i++) dp[0][i]=0;

    for(long i=1; i<n+1; i++)
    {
        long x=i-1;
        for(long j=1; j<w+1; j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j-v[x].first>=0)
            {
                // note the [i-1] in the second term of the following line. This makes the difference between 0/1 knapsack and unbounded knapsack problems.
                dp[i][j]=max(dp[i-1][j], (dp[i-1][j-v[x].first]+v[x].second));
            }
        }
    }
    return dp[n][w];
}

int main()
{
    // long t; cin>>t;
    long t = 1;
    while(t--)
    {
        long n, k;
        cin>>n>>k;
        vector<pair<long, long> > v;
        long x, y;
        // weight first, then value
        for(long i=0; i<n; i++)
        {
            cin>>x>>y;
            // y=x; 
            v.push_back(make_pair(x,y));
        }

        long ans = max_val(v, k, n);
        cout<<ans<<endl;
    }

    return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int n;
int a[11];

void bitBruteForth() {
   bool printed = false;
   rep (mask, (1<<10)) {
      bool ok = true;
      int oldA = -1, oldB = -1;
      rep (j, 10) {
         if ((mask>>j)&1) {
            if (a[j] > oldA) {
               oldA = a[j];
            } else {
               ok = false;
            }
         } else {
            if (a[j] > oldB) {
               oldB = a[j];
            } else {
               ok = false;
            }
         }
      }
      if (ok) {
         puts("YES");
         printed = true;
         break;
      }
   }
   if (!printed) puts("NO");
}

bool ans;

void rec(int idx, int l, int r) {
   if (idx == 10) {
      ans = true;
      return;
   }

   int val = a[idx];
   if (l < val) rec(idx+1, val, r);
   if (r < val) rec(idx+1, l, val);
}

int main() {
   cin >> n;
   while (n--) {
      rep (i, 10) cin >> a[i];
      ans = false;
      rec(0, -1, -1);
      puts(ans?"YES":"NO");
   }

   return 0;
}


Measured memory_bytes: 2904
n,a,b=map(int,input().split())
if a==0 and b==0:
    print(0)
    exit()
if n<=a:
    print(n)
elif n<=a+b:
    print(a)
else:
    if n%(a+b)<=a:
        print(a*(n//(a+b))+n%(a+b))
    else:
        print(a*(n//(a+b))+a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    int n;
    cin>>n;
    int a[n];
    set<int> s;
    for(int i = 0;i<n;i++){
        cin>>a[i];
        s.insert(a[i]);
    }
    if(s.size() == n){
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }
	return 0;
}

Measured memory_bytes: 11136
from sys import stdin
import numpy as np
from copy import deepcopy

N, T = list(map(int,input().split()))
lst = [list(map(int,input().split())) for i in range(N)]
# lst[0]: cost
# lst[1]: time

arr = np.array(lst)
possible_root = arr[arr[:,1]<=T]
if possible_root.size == 0:
  ans = "TLE"
else:
  ans = min(possible_root[:,0])

print(ans)

Measured memory_bytes: 20652
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, std::vector<long long> H){
  ll ans = 0;
  ll now = 0;
  rrep(i,N-1){
    if(i!=N-1){
      if(H[i]>=H[i+1]) now++;
      else now = 0;
    }
    chmax(ans,now);
  }
  cout << ans << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> H(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&H[i]);
  }
  solve(N, std::move(H));
  return 0;
}


Measured memory_bytes: 1024
S = input()

if (("a" in S) and ("b" in S)) and ("c" in S):
  print ("Yes")
else:
  print ("No")

"""
ちょっとした解説

Sは3文字なので、a,b,cのすべての文字が含まれていれば"abc"を並び替えて作ることが出来ます。
逆に一つでもかけていた場合は"abc"の並び替えで作ることはできません。
よってin演算子でa,b,cが全てはいっているか調べてあげればよいです。

and演算子で3つの条件式をつなぐのを思いつくことも一つのポイント
実はカッコは不要で、if　("a" in S) and ("b" in S) and ("c" in S):
でもちゃんと動きます。
"""

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

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int N = a[n - 1];
    int k = 0;
    double c = 1.0 * N / 2, d = abs(c - a[0]);
    for (int j = 0; j < n - 1; j++){
        if (d > abs(c - a[j])){
            d = abs(c - a[j]);
            k = j;
        }
    }

    cout << N << " " << a[k] << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

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

class State{
public:
  int id, cost;
  bool used;

  State(int _id, int _cost, bool _used){
    id = _id;
    cost = _cost;
    used = _used;
  }

  bool operator<(const State &st)const{
    return cost > st.cost;
  }
};

int n, m;
bool closed[102][2];
vector<P> t[102];

void solve(){
  priority_queue<State> open;

  memset(closed, 0, sizeof(closed));
  open.push(State(0, 0, 0));

  while(!open.empty()){
    State st = open.top();
    open.pop();

    if(closed[st.id][st.used]) continue;
    closed[st.id][st.used] = true;

    if(st.id == n - 1){
      cout << st.cost << endl;
      return;
    }

    for(int i = 0; i < t[st.id].size(); i++){
      int to = t[st.id][i].first;
      int cost = t[st.id][i].second;
      open.push(State(to, st.cost + cost, st.used));
    }

    if(st.used) continue;

    for(int i = 0; i < t[st.id].size(); i++){
      int a = t[st.id][i].first;

      for(int j = 0; j < t[a].size(); j++){
        int b = t[a][j].first;

        open.push(State(b, st.cost, true));
      }
    }
  }

  while(true){}
}

int main(){
  while(cin >> n >> m, n || m){
    for(int i = 0; i < n; i++){
      t[i].clear();
    }

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

    solve();
  }
}

Measured memory_bytes: 0
n = int(input())
S = []
T = []
for i in range(n):
    s, t = input().split()
    S.append(s)
    T.append(int(t))
x = input()

idx = S.index(x)

ans = 0
for i in range(idx+1, n):
    ans += T[i]

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int d;
vector<int> c(26);
vector<vector<int>> s;
vector<int> t, now;
vector<int> last(26, -1);
ll best = 0;

ll score(){
    ll res = 0;
    rep(i,26)last[i] = -1;
    rep(i,d){
        res += s[i][t[i]];
        last[t[i]] = i;
        rep(j,26) res -= c[j] * (i - last[j]);
    }
    return res;
}

int main(){
    auto start = std::chrono::system_clock::now();      // 計測スタート時刻を保存
    random_device seed;
    mt19937 mt(seed());
    uniform_int_distribution<int> rnd1(0,25);
    uniform_int_distribution<int> rnd3(-16,16);


    cin >> d;
    uniform_int_distribution<int> rnd2(0,d-1);

    rep(i,26) cin >> c[i];
    s.resize(d);
    rep(i,d)s[i].resize(26);
    rep(i,d)rep(j,26) cin >> s[i][j];
    t.resize(d);
    rep(i,d)t[i] = rnd1(mt);
    best = score();
    // vecprint(t);
    while(true){
        auto end = std::chrono::system_clock::now();       // 計測終了時刻を保存
        auto dur = end - start;        // 要した時間を計算
        auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
        if(msec>=1900) break;

        int day1 = rnd2(mt);
        int day2 = day1 + rnd3(mt);
        day2 = min(d-1,day2);day2 = max(0,day2);
        int con = rnd1(mt);
        swap(t[day1], t[day2]);
        // int old = t[day];
        // t[day] = con;
        ll now_s = score();
        if(best < now_s) best = now_s;
        else swap(t[day1], t[day2]);
    }

    // cout << score() << endl;
    rep(i,d)cout << t[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 1e9;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}



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

    string t = s.substr(0, n / 2);
    string t1 = s.substr(n / 2, n - n/2);
    if (t == t1) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}

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

using namespace std;

int main(void){
  int A[12];
  for(int i = 0; i < 12; i++){
    cin >> A[i];
  }
  sort(A, A+12);

  if(A[0] == A[3] && A[4] == A[7] && A[8] == A[11]){
    cout << "yes\n";
  }else{
    cout << "no\n";
  }

  return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	ll S, W;
	cin >> S >> W;
	string ans = "safe";
	if (S <= W) ans = "unsafe";
	cout << ans << endl;
	return 0;
}


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

int main() {
  int n,m;
  cin >>n>>m;
  if(n==1){
    cout<<m<<endl;
    return 0;
  }
  int kotae=1;
  for(int i=m/n+1;i>=2;--i){
    int tmp=kotae;
    if(m%i==0)kotae=max(kotae,i);
    if(m/kotae<n){
      kotae=tmp;
      break;
    }
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    
    String n = sc.next();
    char[] digit = n.toCharArray();

    int total = 0;
    for(int i = 0; i< digit.length; i++){
      total += Character.getNumericValue(digit[i]);
    }

    if(total % 9 == 0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

    return;

  }
}

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var h = int.Parse(Console.ReadLine());

            Console.WriteLine((a + b) * h / 2);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  long long sum=0;
  for (int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  vector<long long> B(N+1);
  B[0]=0;
  for (int i=0;i<N;i++){
    B[i+1]=B[i]+A[i];
  }
  long long ans=0;
  for (int i=0;i<N+1;i+=2){
    ans=max(ans,B[N]-2*B[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
# https://www.youtube.com/watch?v=C5_NnCp1CRI&feature=youtu.be
# TODO: combinations_with_replacement in Python
# https://atcoder.jp/contests/abc165/submissions/12656990

# TODO: WA
import sys
# sys.stdin = open('input.txt')


# https://atcoder.jp/contests/abc165/submissions/12832942
def dfs(A):
    global ans
    if len(A) == n+1:
        now = 0
        for j in range(q):
            if A[b[j]] - A[a[j]] == c[j]:
                now += d[j]
        ans = max(ans, now)
        return
    else:
        # A.append(A[-1])
        A = A + [A[-1]]
        while A[-1] <= m:
            # print(A)
            dfs(A)
            A[-1] += 1

def dfs_no_mutation(original):
    global ans
    A = original[:]
    if len(A) == n+1:
        now = 0
        for j in range(q):
            if A[b[j]] - A[a[j]] == c[j]:
                now += d[j]
        ans = max(ans, now)
        return
    else:
        A.append(A[-1])
        while A[-1] <= m:
            print(A)
            dfs(A)
            A[-1] += 1


def comb_with_replacement(A, n, m):
    global lists
    if len(A) == n+1:
        lists.append(A)
    else:
        A.append(A[-1])
        while A[-1] <= m:
            comb_with_replacement(A, n, m)
            A[-1] += 1

# https://atcoder.jp/contests/abc165/submissions/12679398
# AC
def dfs2(i):
    global ans
    for j in range(num[i-1], m):
        num[i] = j
        if i == n:
            print(num)
            now = 0
            for k in range(q):
                if num[b[k]] - num[a[k]] == c[k]:
                    now += d[k]
            ans = max(ans, now)
        else:
            dfs2(i+1)


n, m, q = map(int, input().split())
a, b, c, d = [], [], [], []
ans = 0

for i in range(q):
    ai, bi, ci, di = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

dfs([1])
# dfs_no_mutation([1])

num = [0] * (n+1)
# dfs2(1)

# lists = []
# comb_with_replacement([1], 4, 5)
# print(lists)
print(ans)

Measured memory_bytes: 9344