akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
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; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
constexpr int MOD = 1000000007;

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int N, M, Q; 
vector<vector<int>> sum;

int buildSumTable(vector<int> L,vector<int> R){
  sum = vector<vector<int>> (N+1, vector<int>(N+1,0));
  REP(i,M){
    sum[L[i]][R[i]]++;
  }
  for (int i = 1; i <=N; i++)
  {
    for (int j = 1; j <= N; j++)
    {
      sum[i][j] += sum[i-1][j];
      sum[i][j] += sum[i][j-1];
      sum[i][j] -= sum[i-1][j-1];
      //もう一つは最初にしてある
    }
    
  }
  
}
int getSumRange(int L,int R){
  int ans = sum[R][R] - sum[R][L-1] - sum[L-1][R] + sum[L-1][L-1];
  return ans;
}
int main ()
{
    cin>>N>>M>>Q;
    vector<int> L(M);
    vector<int> R(M);
    REP(i,M){
      cin>>L[i]>>R[i];
    }
    vector<int> p(Q);
    vector<int> q(Q);
    REP(i,Q){
      cin>>p[i]>>q[i];
    }
    buildSumTable(L,R);
    REP(i,Q){
      int a = getSumRange(p[i],q[i]);
      cout<<a<<endl;
    }
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
#define vll vector<ll>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

template<typename T>
void vecin(vector<T>& v, int n = 0){
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n-1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}
void print(string s){
    cout << s << endl;
}

int main()
{
    ciosup;
    int n,k;
    cin >> n >> k;
    vint a(n);
    vecin(a);
    ll ans = 0;
    REP(i,n){
        REP(j,n){
            if (a[i] < a[j]){
                ll add = k;
                add *= (k - 1);
                add /= 2;
                ans = (ans + add) % MOD;
            }
            if (i < j){
                if (a[i] > a[j]){
                    ans = (ans + k) % MOD;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
s = list(input())

sunuke = ""
hunuke = ""


if C > D:
    k = ''.join(s[B-2:D+1])
    result = "..." in k
    if result == 0:
        print("No")
        exit()

while B <= D:
    if s[B] == ".":
        B += 1
        if B == D:
            hunuke = "ok"
            break
    elif s[B+1] == ".":
        B += 2
        if B == D:
            hunuke = "ok"
            break
        elif B > D:
            print("No")
            exit()
    else:
        print("No")
        exit()

while A <= C:
    if s[A] == ".":
        A += 1
        if A == C:
            sunuke = "ok"
            break
    elif s[A+1] == ".":
        A += 2
        if A == C:
            sunuke = "ok"
            break
        elif A > C:
            print("No")
            exit()
    else:
        print("No")
        exit()

if sunuke == "ok" and hunuke == "ok":
    print("Yes")
else:
    print("No")

Measured memory_bytes: 5180
import sys
H,W = map(int,input().split())
lsHW = [['.' for i in range(W+2)]]
for i in range(H):
    Sls = ['.'] + list(input()) + ['.']
    lsHW.append(Sls)
lsHW.append(['.' for i in range(W+2)])
for i in range(1,H+1):
    for j in range(1,W+1):
        if lsHW[i][j] == '.':
            continue
        else:
            if not (lsHW[i-1][j] == '#' or lsHW[i+1][j] == '#' or lsHW[i][j-1] == '#' or lsHW[i][j+1] == '#'):
                print('No')
                sys.exit()
print('Yes')

Measured memory_bytes: 9116
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 998244353;

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

	int n;
	cin >> n;
	int* a;
	a = new int[n];
	rep(i, n) cin >> a[i];
	ll* b;
	b = new ll[n+1];
	memset(b, 0, sizeof(int)*(n+1));
	rep(i, n) ++b[a[i]];
	ll sum = 0;
	REP(i, 1, n+1) sum += b[i] * (b[i] - 1) / 2;

	rep(i, n) {
		cout << sum - (b[a[i]] * (b[a[i]] - 1) / 2) + ((b[a[i]] - 1) * (b[a[i]] - 2) / 2) << "\n";
	}

	return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
	int i, j, k, count = 0, money_500, money_100, money_50, x;
	scanf("%d%d%d%d", &money_500, &money_100, &money_50, &x);
	for (i = 0; i <= money_500; i++) for (j = 0; j <= money_100; j++) for (k = 0; k <= money_50; k++) if (x == 500 * i + 100 * j + 50 * k) count++;
	printf ("%d", count);
	return (0);
}

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

struct Edge {
	int to, weight;
};

int main()
{
	int n, u, k, v, c, distance[100000]{}, upd_num = 1;
	bool must_update[100000]{ 1 };
	std::vector<Edge> dest[500000];

	std::cin >> n;
	for (int i = 0; i < n; ++i)
	{
		std::cin >> u >> k;
		for (int j = 0; j < k; ++j)
		{
			std::cin >> v >> c;
			dest[u].push_back({ v, c });
		}
		if (i)
			distance[i] = 2000000000;
	}

	while (upd_num)
		for (int i = 0; i < n && upd_num; i++)
		{
			if (!must_update[i]) continue;

			must_update[i] = false;
			upd_num--;
			for (auto e : dest[i])
			{
				int tmp = distance[i] + e.weight;
				if (tmp < distance[e.to])
				{
					distance[e.to] = tmp;
					if (!must_update[e.to])
					{
						must_update[e.to] = true;
						upd_num++;
					}
				}
			}
		}

	for (int i = 0; i < n; i++)
	{
		std::cout << i << " " << distance[i] << std::endl;
	}

	return 0;
}


Measured memory_bytes: 19840
suit = {"S": 0, "H": 1, "C": 2, "D": 3}
suit_keys = list(suit.keys())
deck = [[suit_keys[i] + " " + str(j + 1) for j in range(13)] for i in range(4)]
for _ in range(int(input())):
    card = input().split()
    deck[suit[card[0]]][int(card[1]) - 1] = ""
for i in range(4):
    for j in deck[i]:
        if j != "":
            print(j)



Measured memory_bytes: 5600
#include<stdio.h>

int main()
{
    int i,n1,n2,n3,count=0;
    scanf("%d %d %d",&n1,&n2,&n3);
    for(int i=n1; i<=n2; i++)
    {
        if(i%n3==0){
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

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

int main(){
  int k,n;
  cin >> k >> n;
  vector<int> house(n,0);
  vector<int> space(n,0);
  for (int i=0; i<n; ++i){
    cin >> house[i];
  }
  for (int i=0; i<n; ++i){
    if(i==n-1) space[i]=k-house[i]+house[0];
    else space[i]=house[i+1]-house[i];
  }
  sort(space.begin(),space.end());
  cout << k-space[n-1] << endl;
}

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

int N, M, s[505], v[505], dp[10005];

int main() {
    
    cin >> N >> M;

    for (int i = 0; i < N; i++){
        cin >> v[i] >> s[i];
    }

    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= M; j++) {
            if (s[i] <= j) dp[j] = max(dp[j], dp[j-s[i]]+v[i]);
        }
    }

    int ans = 0;
    for (int i = 0; i <= M; ++i) ans = max(ans, dp[i]);
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1212
a, b, c = map(int, input().split())
if a == b and b == c:
    if a&1 == 1:
        print(0)
    else:
        print(-1)
else:
    count = 0
    while a&1 == 0 and b&1 == 0 and c&1 == 0:
        n_a = (b+c)//2
        n_b = (a+c)//2
        n_c = (a+b)//2
        count += 1
        a = n_a
        b = n_b
        c = n_c
    print(count)


Measured memory_bytes: 3060
W, H, N = map(int, input().split(" "))
sq = []
for i in range(H):
    sq.append([1] * W)

for i in range(N):
    x, y, a = map(int, input().split(" "))
    if a == 1:
        for i, w in enumerate(sq):
            for j, h in enumerate(w):
                if j < x:
                    sq[i][j] = 0
    if a == 2:
        for i, w in enumerate(sq):
            for j, h in enumerate(w):
                if j >= x:
                    sq[i][j] = 0

    if a == 3:
        for i, w in enumerate(sq):
            for j, h in enumerate(w):
                if i < y:
                    sq[i][j] = 0
    if a == 4:
        for i, w in enumerate(sq):
            for j, h in enumerate(w):
                if i >= y:
                    sq[i][j] = 0
area = 0
for w in sq:
    for h in w:
        area += h
print(area)


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

int main() {
    int n;
    string s;
    int a=0,b=0;
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='R') a++;
        else b++;
    }
    if(a>b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

int main(){
string S; cin >> S; int N = (int) S.size();
  
  vector<vector<int>> dp( N, vector<int>( 13,0));
  
 if( N == 1){
   if( S[0] == '5' || S[0] == '?'){ cout << 1 << endl;}
   else{ cout << 0 << endl;}
   return 0;
 }
  
  //以下Nが２以上の時
  //i == 0の時の初期値設定
  if( S[0] != '?'){
    dp[0][S[0] - '0']++;}
  else{ for(int i = 0; i < 10; i++){ dp[0][i]++;}}
  //dp[0][11]などはそもそもありえない
  
  //0から１、１から２、、、、N-2からN-1への遷移を追いかける
  for(int i = 0; i < N - 1; i++){
    
   if( S[i+1] != '?'){
     for(int j = 0; j < 13; j++){
    dp[i+1][( 10 * j + ( S[i+1] - '0')) % 13] += dp[i][j];
      dp[i+1][(10 * j + ( S[i+1] - '0')) % 13] %= MOD;}}
    
    else{
      for(int j = 0; j < 13; j++){
      for(int k = 0; k < 10; k++){ // Sは k = 0,,, 9まで取りうるため
     dp[i+1][(10 * j + k) % 13  ] += dp[i][j];
        dp[i+1][(10 * j + k) % 13 ] %= MOD;}}}
    
  }
  
  cout << dp[N-1][5] << endl; return 0;}

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

using namespace std;

#define vt vector
#define llint long long int
#define REP(i,s,l) for(int i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {

    //N個の宝石 i番目Vi原価 Ci経費
    int qnt;
    vector<int> genka(qnt);
    vector<int> keihi(qnt);
    int mouke = 0;
    int sagaku;

    cin >> qnt ;
    REP(i,0,qnt){ cin >> genka[i];}
    REP(i,0,qnt){ cin >> keihi[i];}

    REP(i,0,qnt){
        // if(genka[i] > keihi[i]) mouke += genka[i] - keihi[i];
        sagaku =genka[i] - keihi[i];
        if(sagaku>0 ) mouke += sagaku;
    }

    cout << mouke << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, t, c[N], mdis[N], dis[N], mark[N];
vector<int> gr[N];
vector<pair<int, pair<int, int> > > q;
void bfs(int st, int d, int cl) {
	vector<int> vr;
	queue<int> q;
	if (mdis[st] < d)
		q.push(st), mark[st] = 1, dis[st] = d;
	while (!q.empty()) {
		int v = q.front();
		vr.push_back(v);
		q.pop();
		for (auto u : gr[v])
			if (!mark[u] && mdis[u] < dis[v] - 1)
				mark[u] = 1, dis[u] = dis[v] - 1, q.push(u);
	}	
	for (auto u : vr) {
		mdis[u] = dis[u];
		dis[u] = mark[u] = 0;
		if (c[u] == 0)
			c[u] = cl;
	}
	return;
}
int main() {
	memset(mdis, -1, sizeof(mdis));
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		gr[x].push_back(y);
		gr[y].push_back(x);
	}
	cin >> t;
	for (int i = 0; i < t; i++) {
		int vv, dd, cc;
		cin >> vv >> dd >> cc;
		vv--;
		q.push_back({vv, {dd, cc}});
	}
	reverse(q.begin(), q.end());
	for (int i = 0; i < t; i++)
		bfs(q[i].first, q[i].second.first, q[i].second.second);
	for (int i = 0; i < n; i++) 
		cout << c[i] << endl;
	return 0;
}


Measured memory_bytes: 10184
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  string n; readV(n);
  writeln(n.canFind('9') ? "Yes" : "No");
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, P, Q;
int C[550000], score[550000], scc[550000];
signed main() {
    cin >> N >> P >> Q;
    int csum = 0;
    rep(i, N) {
        cin >> C[i];
        csum += C[i];
        score[i] = P * (Q - i) - C[i];
    }
    sort(score, score + N), reverse(score, score + N);
    rep(i, N) { scc[i + 1] = scc[i] + score[i]; }
    int ans = LLONG_MIN;
    for (int i = 0; i <= N; i++) {
        chmax(ans, csum + scc[i] + P * i * (i - 1));
    }
    cout << ans << endl;
}



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

int main()
{
  int n,k;//nhow k kind
  cin >> n >> k;
  
  int64_t sum = k;
  n--;
  while(n > 0){
    sum *= k - 1;
    n--;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#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 REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

void solve(int aa,int bb, int cc){
  int n,product[1005];
  int x,y,z;
  bool o;
  vi a,b,c;
  rep(i,1005)product[i]=2;
  cin>>n;
  rep(i,n){
    cin>>x>>y>>z>>o;
    if(o){
      product[x]=product[y]=product[z]=1;
    }else{
      a.pb(x);
      b.pb(y);
      c.pb(z);
    } 
  }
  rep(i,a.size()){
    if(product[a[i]]==1&&product[b[i]]==1&&product[c[i]]==2){
      product[c[i]]=0;
    }else if(product[c[i]]==1&&product[a[i]]==1&&product[b[i]]==2){
      product[b[i]]=0;
    }else if(product[b[i]]==1&&product[c[i]]==1&&product[a[i]]==2){
      product[a[i]]=0;
    }
  }
  REP(i,1,aa+bb+cc+1){
    cout<<product[i]<<endl;
  }
}

int main(){
  int aa,bb,cc;
  while(cin>>aa>>bb>>cc){
    if(aa==0&&bb==0&&cc==0)break;
    solve(aa,bb,cc);
  }
  return 0;
}



Measured memory_bytes: 3124
#include <iostream>
using namespace std;
int main(){
  long long N;
  cin>>N;
  for(long long h=1;h<=3500;h++){
    for(long long n=h;n<=3500;n++){
      if(4*h*n-N*(h+n) > 0 && (N*h*n) % (4*h*n-N*(h+n)) == 0){
        cout << h << ' ' << n << ' ' << (N*h*n) / (4*h*n-N*(h+n));
        return 0;
      }
    }
  }
  return 1;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
#define ll long long
using namespace std;

int main()
{
    int k;
    cin>>k;
    ll i = 1;
    ll t = 7;
    while(i<100000000){
        if(t % k == 0){
            cout<<i<<endl;
            return 0;
        }
        t = (t*10+7)%k;
        i++;
    }
    cout<<"-1"<<endl;
    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  in(ll, n, k);
  V<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ng = 0, ok = *max_element(all(a));
  while (ok - ng > 1) {
    ll mid = (ng + ok) / 2;
    ll cuts = 0;
    rep(i, n) cuts += (a[i] - 1) / mid;
    if (cuts <= k) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  out(ok);
}

Measured memory_bytes: 4832
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        StringBuilder t = new StringBuilder(scanner.nextLine());
        for (int i = 0; i < t.length(); i++) {
            if (t.charAt(i) == '?') {
                char newChar;
                t.setCharAt(i, 'D');
            }
        }
        System.out.println(t);
    }
}


Measured memory_bytes: 33088
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);

		long a=s.nextLong()-1;
		long b=s.nextLong();
		long c=s.nextLong();
		long d=s.nextLong();

		long w=b-a;
		System.err.println(w);
		long x=b/c-a/c;
		System.err.println(x);
		long y=b/d-a/d;
		System.err.println(y);
		long z=b/gcd(c,d)-a/gcd(c,d);
		System.err.println(z);
		System.out.println(w-x-y+z);
	}

	private static long gcd(long c,long d){
		return c*d/lcm(c,d);
	}

	private static long lcm(long c,long d){
		return d==0?c:lcm(d,c%d);
	}
}


Measured memory_bytes: 23764
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int[][] sec = new int[3][2];
		int[] time = new int[3];
		
		for(int i = 0; i < 3; i++)
			for(int j = 0; j < 2; j++){
			sec[i][j] += sc.nextInt() * 3600;
			sec[i][j] += sc.nextInt() * 60;
			sec[i][j] += sc.nextInt();
		}
		for(int i = 0; i < 3; i++){
			time[i] = sec[i][1] - sec[i][0];
		}
		for(int i = 0; i < 3; i++){
				System.out.print(time[i] / 3600 + " ");
				System.out.print(time[i] % 3600 / 60 + " ");
				System.out.println(time[i] % 3600 % 60);
		}
		sc.close();
	}
}

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

int main() {
	int x,y,z;
	cin >> x >> y >> z;
	printf("%d %d %d\n", z, x, y);

	return 0;
}


Measured memory_bytes: 256
import sys
import heapq

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
V = MAP()

heapq.heapify(V)

while len(V)>1:
	a = heapq.heappop(V)
	b = heapq.heappop(V)
	
	c = (a+b)/2
	heapq.heappush(V, c)

print(heapq.heappop(V))

Measured memory_bytes: 3064
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {
    string s;
    cin >> s;
    size_t len = s.length();

    REP(i, len) {
        cout << "x";
    }
    

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#define LL long long
#define inl inline
#define re register
#define MAXN 101000
using namespace std;
char s[MAXN];
int n,ans=MAXN*7;
int main()
{
	scanf("%s",s+1);
	s[0]='_';
	n=strlen(s)-1;
	for(int i=1;i<=n;i++)
	{
		if(s[i]!=s[i-1])
		ans=min(ans,max(i-1,n-i+1));
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	if (a < b && b < c){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a<=k){
    cout << "Yay!"<<endl;
  }else{
    cout << ":(" << endl; 
  }
  return 0;
}


Measured memory_bytes: 256
n=int(input())

dp=list(map(int,input().split()))
for day in range(1,n):
    m=[0]*3
    day_points=list(map(int, input().split()))
    for i in range(3):
        for j in range(3):
            if i!=j:
                 m[i]=max(m[i],day_points[i]+dp[j])
    dp=m
print(max(dp))

Measured memory_bytes: 46552
import sys
input = sys.stdin.readline

n, q = [int(x) for x in input().split()]

edge = [[] for _ in range(n)]

counter = [0] * n

for _ in range(n-1):
    a, b = [int(x) for x in input().split()]
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

for _ in range(q):
    a, b = [int(x) for x in input().split()]
    counter[a-1] += b

parent = [0]
set_parent = {0}
for i in parent:
    for v in edge[i]:
        if v in set_parent:
            continue
        set_parent.add(v)
        parent.append(v)
        counter[v] += counter[i]
        
print(" ".join(map(str, counter)))

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

#define llint long long int

using namespace std;

int main(){
    llint A, V, B, W, T;

    cin >> A >> V >> B >> W >> T;

    if(A - V * T <= B - W * T  && B + W * T <= A + V * T){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3636
//abc157_c.cpp
//Sun Mar  1 20:09:47 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int keta[n];
	fill(keta,keta+n,-1);
	for (int i=0;i<m;i++){
		int s,c;
		cin >> s >> c;
		s--;
		if (keta[s]==-1){
			keta[s] = c;
		}else if (keta[s]!=c){
			cout << -1 << endl;
			return 0;
		}
	}

	if (n==1 && m==0){
		cout << 0 << endl;
		return 0;
	}

	int ans = 0;
	for (int i=0;i<n;i++){
		if (keta[i]==-1){
			if (i==0){
				ans += pow(10,n-i-1);
			}
		}else {
			if (i==0 && keta[i]==0 && n!=1){
				cout << -1 << endl;
				return 0;
			}
			ans += keta[i]*pow(10,n-i-1);
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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


def solve(H: int, A: int):
    print(-(-H//A))
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
using namespace std;
pii arr[105];
int dis(int x,int y) {
	return x*x + y*y;
}
int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> arr[i].first >> arr[i].second;
	mt19937 Rand(time(NULL)+48763);
	int tx = 0 , ty = 0;
	for(int t=0;t<100000;t++) {
		shuffle(arr+1,arr+1+n,Rand);
		int x = 0 , y = 0;
		for(int i=1;i<=n;i++) {
			int nx = x + arr[i].first;
			int ny = y + arr[i].second;
			if(dis(nx,ny) > dis(x,y))
				x = nx , y = ny; 
		}
		if(dis(x,y) > dis(tx,ty))	tx = x , ty = y;
	}
	cout << fixed << setprecision(12) << sqrt(tx*tx+ty*ty) << endl;
	return 0;
}


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

string lcs(string s,string t)
{
    int a=s.length();
    int b=t.length();
    int dp[a+1][b+1];
    string st="";
    for(int i=0;i<=a;i++)
    {
        dp[i][0]=0;
    }
    for(int j=0;j<=b;j++)
    {
        dp[0][j]=0;
    }
    int i=1;
    int j=1;

    for(int i=1;i<=a;i++)
    {
        for(int j=1;j<=b;j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
              //  string p(1,s[i-1]);
               // st=st+p;
            }
            else
            {
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    i=a;
    j=b;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
             st=st+s[i-1];
             i--;j--;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
                i--;
            else
                j--;
        }
    }
  //  cout<<dp[a][b]<<endl;
    reverse(st.begin(),st.end());
    return st;
}

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


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

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

using namespace std;
typedef long long ll;

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

    if (s.find("YAKI") == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

typedef complex<double> P;

int main(){
	int n;
	while(cin>>n){
		bool f = true;
		for(int i = 0 ; i < 10 ; i++){
			if( !(n>>i&1) ) continue;
			if(!f) cout << " ";
			cout << (1<<i);
			f = false;
		}
		cout << endl;
	}
			
}

Measured memory_bytes: 3032
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int W, H;
	int x, y, r;

	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	W -= r, H -= r;
	if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n;	cin>>n;
	vector<int> a(3*n);
	for(int i=0;i<3*n;i++)	cin>>a[i];
	sort(a.begin(),a.end());
	long long ret=0;
	for(int i=n;i<3*n;i+=2)	ret+=a[i];
	cout<<ret<<endl;
	return 0;
}


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

typedef long long ll;

int main() {
    int H, W;
    cin >> H >> W;
    int h = round((double)H / 3.0);
    int w = round((double)W / 3.0);

    cout << min({abs(h*W-(H-h-h)*W),
            abs(w*H-(W-w-w)*H),
            max(abs(h*W-(H-h)*(W/2)), abs(h*W-(H-h)*(W-W/2))),
            max(abs(w*H-(W-w)*(H/2)), abs(w*H-(W-w)*(H-H/2)))}) << endl;
}


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

int main() {
    double n, m, d;
    cin >> n >> m >> d;
    
    double ans;
    
    if (d == 0) {
        ans = (m-1) / n;
    }
    else {
        ans = 2.0 * (n-d) * (m-1) / n /n;
    }
    
    printf("%.8lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n,K;
  cin>>n>>K;

  vector<int> A(n);
  cin>>A;

  if(n == 1){
    cout<<0<<endl;
    return 0;
  }

  if(n <= K){
    cout<<1<<endl;
    return 0;
  }
  
  int ans = 0;
  int i = 0;
  while(1){
    if(i >= n-1) break;
    ans++;
    i += K-1;
    
  }
  cout<<ans<<endl;
  return 0;
}


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

#define repi(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(v) begin(v), end(v)

using ll = long long;

using Graph = vector<vector<int>>;

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

  int N, M;
  cin >> N >> M;

  Graph g(N);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;

    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> color(N, -1);
  int current_color = 0;
  queue<int> Q;

  rep(i, N) {
    if (color[i] != -1) {
      continue;
    }

    color[i] = current_color;
    Q.push(i);
    while (!Q.empty()) {
      int v = Q.front();
      Q.pop();

      for (int u : g[v]) {
        if (color[u] == -1) {
          color[u] = current_color;
          Q.push(u);
        }
      }
    }

    ++current_color;
  }

  vector<int> cnt(current_color);
  rep(i, N) {
    ++cnt[color[i]];
  }

  cout << *max_element(cnt.begin(), cnt.end()) << '\n';

  return 0;
}


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

int main()
{
	int n, k;
	string s;
	cin >> n >> k >> s;
	char t = s.at(0);
	int tRow = 0;
	vector<int> r = {0};
	//累積和の計算
	for (int i = 0; i < n; i++)
	{
		if (s.at(i) == t)
			tRow++;
		else
		{
			t = s.at(i);
			r.push_back(tRow);
			tRow = 1;
		}
		if (i == n - 1)
			r.push_back(tRow);
	}
	for (int i = 1; i < r.size(); i++)
	{
		r.at(i) += r.at(i - 1);
	}
	//最大値候補の計算
	vector<int> maxs = {1};
	int zo = s.at(0) - '0';
	for (int i = 0; i < r.size(); i++)
	{
		int right = min(i + 2 * k + (zo + i) % 2, (int)r.size() - 1);
		maxs.push_back(r.at(right) - r.at(i));
	}
	cout << *max_element(maxs.begin(), maxs.end()) << endl;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	ll ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)
			ans+=(ll)i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3608
S = input().strip()
if len(S)<26:
    for i in range(97,123):
        if chr(i) not in S:
            print(S+chr(i))
            break
else:
    flag = 0
    for i in range(24,-1,-1):
        if S[i]<S[i+1]:
            a = S[i]
            for j in range(25,i,-1):
                if S[j]>a:
                    print(S[:i]+S[j])
                    flag = 1
                    break
            if flag==1:break
    if flag==0:
        print(-1)

Measured memory_bytes: 61728
/*{{{*/
#include "bits/stdc++.h"
using namespace std;

#define MT make_tuple
#define all(x) begin(x), end(x)
#define putchar(x) cout << (x)
static int fastio = [](){ ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(17); return 0; }();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename ...T> string format(const string& fmt, T&&... args) {
    size_t sz = snprintf(nullptr, 0, fmt.c_str(), args...) + 1;
    unique_ptr<char[]> buf(new char[sz]);
    snprintf(buf.get(), sz, fmt.c_str(), args...);
    return string(buf.get(), buf.get() + sz - 1);
}

template<class T> struct rge { T b, e; auto begin() const { return b; } auto end() const { return e; } };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
template<class T> auto dud(T* x) -> decltype(cerr << *x, 0);
template<class T> char dud(...);

struct debug {
#ifdef LOCAL
    debug(int line) {
        if(line) cerr << "LINE(" << line << ") -> ";
    }
    template<class T> typename enable_if<sizeof dud<T>(0) != 1, debug&>::type operator<<(T i) {
        cerr << boolalpha << i; return * this;
    }
    template<class T> typename enable_if<sizeof dud<T>(0) == 1, debug&>::type operator<<(T i) {
        return *this << range(begin(i), end(i));
    }
    template<class T, class U> debug& operator<<(pair<T, U> d) {
        return *this << "(" << d.first << ", " << d.second << ")";
    }
    debug& operator<<(tuple<>&) { return *this << "()"; };
    template<class ...T> debug& operator<<(tuple<T...> d) {
        *this << "("; debug_tuple<sizeof...(T), 0>(d);
        return *this << ")";
    }
    template<size_t L, size_t I, class T> void debug_tuple(const T& t) {
        *this << (I == 0 ? "" : ", ") << get<I>(t);
        if(I + 1 < L) debug_tuple<L, (I + 1) % L>(t);
    }
    template<class T> debug & operator <<(rge<T> d) {
        *this << "[";
        for(auto it = d.b; it != d.e; ++it)
            *this << (it != d.b ?  ", " : "") << *it;
        return *this << "]";
    }
    debug& operator<<(ostream&(*pf)(std::ostream&)) {
        cerr << pf; return *this;
    }
#else
    debug(int) {}
    template<class T> debug& operator<<(T&&) { return *this; }
    debug& operator<<(ostream&(*)(std::ostream&)) { return *this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "] "

#define debug0()  debug(__LINE__)
#define debug1(x) debug(0)
#define GET_MACRO(_0, _1, NAME, ...) NAME
#define debug(...) GET_MACRO(_0, ##__VA_ARGS__, debug1, debug0)(__VA_ARGS__)
/*}}}*/
using LL = long long;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAX_N = 200005;

void solve(int) {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

int main() {
    int T = 1;
    //cin >> T;
    for(int i = 1; i <= T; ++i) {
        solve(i);
    }
    return 0;
}


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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;

#ifndef LOCAL_H
    const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

/************************************************************************************************************************************************/

void solve(){
    int N, K;
    cin >> N >> K;
    vector<int> h (N);
    for(int i = 0;i < N;i++){
        cin >> h[i];
    }
    SORT(h);
    int ans = INF;
    for(int i = 0;i < N-K+1;i++){
        ans = min(abs(h[i]-h[i+K-1]),ans);
    }
    cout << ans << endl;
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << (m1 != m2);
    cout << endl;
}


Measured memory_bytes: 256
w,a,b =  map(int, input().split())


if a < b:
    if a+w >= b:
        print(0)
    else:
        print(b-a-w)

elif a > b:
    if b+w > a:
        print(0)
    else:
        print(a-b-w)
    
else:
    print(0)


Measured memory_bytes: 2940
/**
 * C - Typical Stairs
 * https://atcoder.jp/contests/abc129/tasks/abc129_c
 **/
#include<iostream>
#include<vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        int ai;
        cin >> ai;
        A[ai-1] = i+1;
    }

    for(int i=0; i<N; i++) {
        if(i==N-1) {
            cout << A[i] << endl;
        } else {
            cout << A[i] << " ";
        }
    }
    return 0;
}

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

long long yaku(long long a, long long b) {
	if (a == 0) {
		return b;
	}
	else if(b==0){
		return a;
	}
	if (a<b) {
		swap(a,b);
	}
	if (a%b == 0) {
		return b;
	}
	else {
		return yaku(a%b,b);
	}
}


int main() {
	int n,i;
	long long ans,high=0;
	cin >> n;
	vector <long long> a(n), b,l(n+1),r(n+2);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	b = a;
	l[0] = 0;
	for (i = 0; i < n; i++) {
		if (i - 1 < 0) {
			l[i+1] = yaku(a[i],0);
		}
		else {
			l[i+1] = yaku(a[i], a[i - 1]);
		}
		a[i] = l[i+1];
	}
	a=b;
	r[n+1] = 0;
	for (i = n-1; i >=0; i--) {
		if (i + 1 > n-1) {
			r[i+1] = yaku(a[i], 0);
		}
		else {
			r[i+ 1] = yaku(a[i], a[i + 1]);
		}
		a[i] = r[i+1];
	}
	for (i = 0; i < n; i++) {
		
		ans = yaku(l[i], r[i+2]);
		if (high < ans) {
			high = ans;
		}
	}
	cout << high << endl;
	
	

	
}


Measured memory_bytes: 3328
K = int(input())

import fractions

ans = 0

import itertools

gcd_dic = {}

for i in itertools.combinations(range(1, K + 1), 2):
    ans_m = fractions.gcd(i[0], i[1])
    ans += ans_m * 6
    gcd_dic[(i[0], i[1])] = ans_m
    gcd_dic[(i[1], i[0])] = ans_m

for i in itertools.combinations(range(1, K+1), 3):
    ans_m = i[0]
    for l in i[1:]:
        if (ans_m, l) in gcd_dic:
            ans_m = gcd_dic[(ans_m, l)]
        else:
            ans_m = fractions.gcd(ans_m, l)
    ans += ans_m*6

for i in range(1, K+1):
    ans += i

print(ans)

Measured memory_bytes: 82596
///~Hard work pays well..smart work pays more though.~ Fu'ad daoud 
#include <stdio.h>
#include <sstream>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <cctype>
#include <functional>	
#include <stack>
#include <map>
#include <algorithm>
#include <iomanip>
#include <utility>  
#include <queue>
#include <set>

#define input(a) scanf("%lld",&a);
#define fc for_each
#define all(k) k.begin(),k.end()
#define pb push_back
#define printall(k) fc(all(k),prints);
#define lastindex(a) a.size()-1
#define lastelement(a) a[lastindex(a)]
#define forf(a,x) for(int a=0;a<x;a++)
//#define ffor(h,v,hh,hhh) for(int h=v;h<hh;h+=hhh);
#define nextline printf("\n")
#define space printf(" ")
#define mb(a,b) make_pair(a,b)


using namespace std;



typedef long long int lld;
typedef vector<lld> vlld;
typedef vector<string> vs;
typedef vector<char> vc;

lld intsum;



void printint(lld k) { printf("%lld", k); }
void printchar(char k) { printf("%c ", k); }
void printstring(string k) { cout << k << endl; }
void printbool(bool k) { printf("%b", k); }
void printpairis(pair<lld, string> k) { cout << k.first << " " << k.second << endl; }
//void printchar(vector<char> k) { fc(all(k), printchar); cout << endl; }
void printvecint(vector<lld> k) { fc(all(k), printint); nextline; }
void printvecchar(vector<char> k) { fc(all(k), printchar); nextline; }
bool isodd(int k) { return (k % 2) ? true : false; }
bool iseven(int k) { return (k % 2) ? false : true; }
bool paircompare(pair<int, string> k, pair<int, string> f) { return k.first < f.first; }
void  intsumming(lld k) { intsum += k; }
void reverseall(vector<int> &k) { reverse(all(k)); }
//void  charsumming1(char k) { charsum1 +=k; }
//void  charsumming2(char k) { charsum2 +=k; }
bool pairCompare(const pair<lld, lld> firstElem, const pair<lld, lld> secondElem) { return firstElem.second < secondElem.second; }
void printpair(pair<lld, lld> p) { printf("%lld , %lld\t", p.first, p.second); }
void printallint(vlld a) { fc(all(a), printint); }

lld a, b;
lld ss;
int main()
{
	input(a);
	input(b);
	ss = max(a - b, a + b);
	ss = max(ss, a * b);
	printf("%lld", ss);
	return 0;
}	

Measured memory_bytes: 256
main :: IO()
main = do
  (a:b:xs) <- map read . words <$> getLine
  putStrLn . show $ solve a b

solve :: Int -> Int -> Int
solve a b = 
  if 1 <= a && a <= 9 && 1 <= b && b <= 9 then   
    a * b
  else
    -1

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

using namespace std;

//#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

int main() {
    ll K, N; cin >> K >> N;
    int distSum = 0;
    int distMax = 0;
    int lastA; cin >> lastA;

    for(ll i = 0; i < N-1; i++){
        int A; cin >> A;
        int dist = A - lastA;
        lastA = A;
        distSum += dist;
        if(distMax < dist) distMax = dist;
        PRINT(dist)
    }

    if(distMax < K - distSum) distMax = K - distSum;

    cout << K - distMax << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(5)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<short, short> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator > (const edge& e) const { return cost > e.cost; }
};

int n;
string s;
int main()
{
	cin >> n;
	while (n--)
	{
		cin >> s;
		vi v;
		REP(i, s.size())
		{
			if (s[i] == '[') v.push_back(-1);
			else if (s[i] == ']') v.push_back(-2);
			else
			{
				int tmp = 0;
				while (isdigit(s[i]))
				{
					tmp *= 10;
					tmp += s[i] - '0';
					i++;
				}
				v.push_back(tmp / 2 + 1);
				i--;
			}
		}

		while (1)
		{
			vi tmp;
			REP(i, v.size())
			{
				if (v[i] == -1 && v[i + 1] < 0) tmp.push_back(-1);
				else if (v[i] == -2 && v[i - 1] < 0) tmp.push_back(-2);
				else if (v[i]>0) tmp.push_back(v[i]);
			}
			if (tmp.size() == 1)
			{
				cout << tmp[0] << endl;
				break;
			}
			vi tmp2;
			REP(i, tmp.size())
			{
				if (tmp[i]>0)
				{
					vi buf;
					while (tmp[i] > 0)
					{
						buf.push_back(tmp[i]);
						i++;
					}
					i--;
					sort(ALL(buf));
					int sum = 0;
					REP(i, buf.size() / 2 + 1)
					{
						sum += buf[i];
					}
					tmp2.push_back(sum);
				}
				else tmp2.push_back(tmp[i]);
			}
			v = tmp2;
		}
	}
}

Measured memory_bytes: 1352
function Main(input) {
	var jigen = parseInt(input.split("\n")[0].split(" ")[1]);
  	var len = parseInt(input.split("\n")[0].split(" ")[0]);
  	var output = 0;
  	for(var i = 1; i < len + 1; i++){
      for(var j = i + 1; j < len + 1; j++){
        var tmpKyori = 0;
        var iZahyo = input.split("\n")[i];
        var jZahyo = input.split("\n")[j];
        for(var k = 0; k < jigen; k++){
          var iTmpZahyo = parseInt(iZahyo.split(" ")[k]);
          var jTmpZahyo = parseInt(jZahyo.split(" ")[k]);
          //console.log("i:" + iTmpZahyo + ",j:" + jTmpZahyo + ",tmpKyoriに追加する値:" +Math.pow(iTmpZahyo - jTmpZahyo,2));
          tmpKyori += Math.pow(iTmpZahyo - jTmpZahyo,2);
        }
        var kekka = Math.sqrt(tmpKyori);
        if(kekka.toString().indexOf(".") == -1){
           output++;
           }
      }
    }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7868
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std; 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  ll n,m;
  cin>>n>>m;
  ll a[m];
  ll sum=0;
  for(ll i=0;i<m;i++)
  {
      cin>>a[i];
      sum+=a[i];
  }
  if(sum>n)
  cout<<-1<<endl;
  else
  cout<<n-sum<<endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  unordered_map<string,int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  ll ans = 0;
  for (auto& p : mp) {
    int s = p.second;
    ans += (ll)s*(s-1)/2;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int ans=1,n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
    	if(ans<=k) ans+=ans;
    	else ans+=k;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256