akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  string s;
  cin >> s;

  int a = stoi(s.substr(0, 2));
  int b = stoi(s.substr(2, 2));
  cerr << a << " "<< b << endl;

  if (a <= 12 && a != 0) {
    if (b <= 12 && b != 0) {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "MMYY" << endl;
    }
  } else {
    if (b <= 12 && b != 0) {
      cout << "YYMM" << endl;
    } else {
      cout << "NA" << endl;
    }
    
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

double N,K,Prob_N,Sum,X;
int nr,Pow_2;

int main()
{
    cin >> N >> K;
    Prob_N = 1.0 / N;
    for(int i = 1; i <= N; ++i)
    {
        nr = 0;
        Pow_2 = i;
        while(Pow_2 < K)
            Pow_2 = (Pow_2 << 1),++nr;
        X = (1 << nr);
        Sum += (Prob_N * (1.0 / X));
    }
    cout <<fixed << setprecision(15) << Sum;
    return 0;
}


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

int main()
{
    while (1)
    {
        int cnt = 0, n = 0, x = 0;
        cin >> n >> x;

        if (n == 0 && x == 0)
        {
            return 0;
        }

        for (size_t i = 1; i <= n; i++)
        {
            for (size_t j = i + 1; j <= n; j++)
            {
                for (size_t k = j + 1; k <= n; k++)
                {
                    if (i + j + k == x)
                    {
                        cnt++;
                    }
                }
            }
        }

        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3012
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          tree.dispRoundPath();
        }
      }

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode(-1);
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode(val);

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  void dispRoundPath() {

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    System.out.print(buf);
    buf.setLength(0);
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode(int key) {
    this.key = key;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


Measured memory_bytes: 126180
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


int main() {
	init();

	int N, W; cin >> N >> W;
	vector<pair<int, int>>vec(N);
	rep(i, 0, N) {
		int a, b; cin >> a >> b;
		vec[i] = { a,b };
	}
	vector<vector<int>>dp(N + 1, vector<int>(W + 1, 0));
	rep(i, 0, N) {
		rep(j, 0, W + 1) {
			chmax(dp[i + 1][j], dp[i][j]);
			if (j - vec[i].second >= 0)chmax(dp[i + 1][j], dp[i + 1][j - vec[i].second] + vec[i].first);
			if (!(j + vec[i].second > W))chmax(dp[i + 1][j + vec[i].second], dp[i][j] + vec[i].first);
		}
	}
	int ans = 0;
	rep(i, 0, W + 1)chmax(ans, dp[N][i]);
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 6848
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    scan.close();

    if(!S.contains("A") || !S.contains("B")) {
      System.out.println("No");
    }
    else {
      System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] T = new int[N];
		int tsum = 0;
		for(int i=0;i<N;i++) {
			T[i] = sc.nextInt();
			tsum += T[i];
		}

		int M = sc.nextInt();
		int[] P = new int[M];
		int[] X = new int[M];
		for(int i=0;i<M;i++) {
			P[i] = sc.nextInt();
			X[i] = sc.nextInt();
		}

		for(int i=0;i<M;i++) {
			int ans = tsum;
			ans -= T[P[i]-1];
			ans += X[i];
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 23508
import java.util.*;

class Main{
	public static void main(String[]args){
    	Scanner scan = new Scanner(System.in);
      	int x = scan.nextInt();
      	boolean found = false;
      	while(true){
          for(int i=x;;i++){
            int y=2;
            for(;y<Math.sqrt(i);y++){
            	if(i%y==0)break;
            }
            if(Math.sqrt(i)<y)
            found=true;
            if(found){
                  System.out.println(i);
              return;
            }  
          }
        
        }
    }
}

Measured memory_bytes: 21716
import math
import itertools

INF = 10**9+7
n = 0
def main():
	n = int(input())
	s = [input() for i in range(n)]
	chr_list =  [INF for i in range(26)]
	for i in s:
		for j in range(26):
			chr_count = i.count(chr(97+j))
			if(chr_count < chr_list[j]): chr_list[j] = chr_count
	text = ''
	for i in range(26):
		text = text + chr(i+97) * chr_list[i]
	print(text)

main()


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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> ten = { 1, 10, 9, 12, 3, 4 };
	vector<long long> result(13);
	result[0] = 1;
	vector<long long> temp(13);
	int remain = 0;
	for (int i = 0; i < n; i++) {
		if (s[n - i - 1] == '?') {
			copy(result.begin(), result.end(), temp.begin());
			for (int j = 0; j < 13; j++) {
				for (int k = 1; k < 10; k++) {
					result[(j + k * ten[i % 6]) % 13] += temp[j];
				}
			}
			for (int j = 0; j < 13; j++) {
				result[j] %= 1000000007;
			}

		} else {
			remain += (s[n - i - 1] - 48) * ten[i % 6];
			remain %= 13;
		}
	}

	cout << result[(18 - remain) % 13];
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int m = max(n, k);
    vector<double> ps(m+1);
    for (int i = k; i <= m; ++i) {
        ps[i] = 1;
    }
    for (int i = k-1; i >= 0; --i) {
        ps[i] = ps[min(2*i, m)]/2;
    }
    double s = 0;
    for (int i = 1; i <= n; ++i) {
        s += ps[i];
    }
    cout << setprecision(20) << s/n << endl;
    return 0;
}


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

int main(){
    int n, t, a; cin >> n >> t >> a;
    double Htemp[n];
    vector<double>ans(n);
    for(int i=0;i<n;i++){
        cin >> Htemp[i];
        Htemp[i] = t - Htemp[i] * 0.006;
        ans.at(i) = abs(a - Htemp[i]);
    }
    int cnt;
    double different = 650;
    for(int i=0;i<n;i++){
        if(ans.at(i) <= different){
            cnt = i + 1;
            different = ans.at(i);
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <math.h> 

using namespace std;



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

	int h1, m1, h2, m2, t1, t2, k, ans;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	t1 = h1 * 60 + m1;
	t2 = h2 * 60 + m2;
	ans = t2 - t1 - k;
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3156
#include <iostream>

using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  if(a==1){
    if(b==1){
      cout<<"Draw"<<endl;
      return 0;
    }
    cout<<"Alice"<<endl;
    return 0;
  }else if(b==1){
    cout<<"Bob"<<endl;
    return 0;
  }
  if(a>b){
    cout<<"Alice"<<endl;
    return 0;
  }else if(a<b){
    cout<<"Bob"<<endl;
    return 0;
  }else{
    cout<<"Draw"<<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++)
#define ll long long int

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    ll ans = 0;
    vector<ll> a(n+1);
    vector<ll> b(n);
    for(int i=0;i<n+1;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    for(int i=0;i<n;i++){
        if((a[i]+a[i+1])>=b[i]){
            ans +=b[i];
            if(a[i]<b[i]){
                a[i+1]-=b[i]-a[i];
            }
            }else{
                ans+=a[i]+a[i+1];
                a[i+1]=0;
            }
        }
    
    cout << ans << endl;
}

Measured memory_bytes: 1792
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
S=get_nsp
l=array(N,0)
r=array(N,0)
S.size.times do|i|
    if i!=0
          l[i]+=l[i-1]
          r[N-1-i]+=r[N-i]
    end
    if S[i]=="E"
        l[i]+=1
    end
    if S[N-1-i]=="W"
        r[N-1-i]+=1
    end
end
ans=N
N.times do|i|
  val=N-l[i]-r[i]
  if ans>val
      ans=val
  end
end
puts ans

Measured memory_bytes: 32148
#include<stdio.h>
#include<stdlib.h>
#define ll long long
ll dp[2048][2048];
ll n, i, j;
ll max(ll a, ll b){return a > b ? a : b;}
ll min(ll a, ll b){return a < b ? a : b;}
ll zt(ll a, ll b){return max(a, b) - min(a, b);}
struct child{ ll A, r; };
struct child a[2048];
int cmp(const void *x,const void *y){
    int a = ((const struct child*)x)->A;
    int b = ((const struct child*)y)->A;
    return a > b ? -1 : a < b; 
}
ll search(ll p,ll q){
    if(p > q) return 0;
    if(dp[p][q] != -1) return dp[p][q];
    ll k = p - 1 + n - q;
    dp[p][q] = max(search(p + 1, q) + a[k].A * zt(p, a[k].r), dp[p][q]);
    dp[p][q] = max(search(p, q - 1) + a[k].A * zt(q, a[k].r), dp[p][q]);
    return dp[p][q]; 
}
int main(){
    scanf("%lld",&n);
    for(i = 0; i < n; i++){
        scanf("%lld",&a[i].A);
        a[i].r = i + 1;
    }
    for(i = 0; i < 2048; i++)
        for(j = 0; j <2048; j++)
            dp[i][j] = -1;
    qsort(a,n,sizeof(a[0]),cmp);
    printf("%lld\n",search(1, n));
    return 0;
}

Measured memory_bytes: 34688
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>

struct SubTree {
	long long int min_step, back_for_minstep, need_to_push;
	long long int push_back_multiplier, sum_initial, sum_target;
};
int main() {
	int n; std::cin >> n;
	std::vector<std::vector<int>> nodes(n);
	for (auto i = 1; i < n; ++i) {
		int u, v; std::cin >> u >> v;
		nodes[--u].push_back(--v);
		nodes[v].push_back(u);
	}
	std::vector<int> initial_size(n), target_size(n);
	for (auto& a : initial_size) std::cin >> a;
	for (auto& b : target_size) std::cin >> b;
	std::vector<int> depth(n, -1), parent(n, -1), child_count(n, 0); depth[0] = 0;
	std::stack<int> stack; stack.push(0);
	while (!stack.empty()) {
		const auto top = stack.top(); stack.pop();
		for (const auto next : nodes[top]) if (depth[next] == -1) {
			depth[next] = depth[top] + 1;
			parent[next] = top;
			stack.push(next);
			++child_count[top];
		}
	}
	std::vector<SubTree> sub_trees(n);
	for (auto i = 0; i < n; ++i) if (child_count[i] == 0) {
		stack.push(i);
	}
	while (!stack.empty()) {
		const auto top = stack.top(); stack.pop();
		long long int sum_min_step{ 0 }, sum_back{ 0 }, sum_multiplier{ 0 }, max_need{ 0 }, sum_need{ 0 }, sum_initial_size{ initial_size[top] }, sum_target_size{ target_size[top] };
		for (const auto next: nodes[top]) if (depth[next] > depth[top]) {
			sum_min_step += sub_trees[next].min_step;
			sum_back += sub_trees[next].back_for_minstep;
			sum_multiplier += sub_trees[next].push_back_multiplier;
			max_need = std::max(max_need, sub_trees[next].need_to_push);
			sum_need += sub_trees[next].need_to_push;
			sum_initial_size += sub_trees[next].sum_initial;
			sum_target_size += sub_trees[next].sum_target;
		}
		const auto need_to_push{ std::max(max_need, sum_initial_size - sum_target_size) };
		sum_min_step += need_to_push;
		for (const auto next : nodes[top]) if (depth[next] > depth[top]) {
			sum_min_step += (need_to_push - sub_trees[next].need_to_push) * sub_trees[next].push_back_multiplier;
		}
		sub_trees[top] = SubTree{ sum_min_step, need_to_push, std::max(sum_target_size - sum_initial_size + need_to_push, 0LL),
			sum_multiplier + 1, sum_initial_size, sum_target_size };
		if (parent[top] != -1 && --child_count[parent[top]] == 0) {
			stack.push(parent[top]);
		}
	}
	std::cout << sub_trees[0].min_step << '\n';
}


Measured memory_bytes: 15744
import sys
import collections
s=input()
t=input()
s2=collections.deque([])
for i in s:
  s2.append(i)
for i in range(len(s)):
  if ''.join(s2)==t:
    print('Yes')
    sys.exit()
  c=s2.popleft()
  s2.append(c)
print('No')

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

signed main(){
	int a,b,c;cin>>a>>b>>c;
	int x,y;cin>>x>>y;
	int ans = 1e18;
	for(int k=0;k<(int)1e6;k++){
		int cost = c*k+max((int)0,(x-(k/2)))*a+max((int)0,(y-(k/2)))*b;
		ans = min(ans,cost);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
msum = 0

for i in range(n):
  sum = 0
  for j in range(i + 1):
    sum += a1[j]
    #print(a1[j], end = '')
  for j in range(i, n):
    sum += a2[j]
    #print(a2[j], end = '')
  #print()
  #print(sum)
  if msum < sum:
    msum = sum
print(msum)

Measured memory_bytes: 3060
# pragma GCC optimize("Ofast")
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }

int N=8,white=0,gray=1,black=2;
int n;
int ans=0;

vector<vector<int> > M(N,vector<int> (N,0)); //隣接行列を用いたグラフ表現
vector<int> color(N,0),d(N,0),f(N,0); //d,fはタイムスタンプ（最初の訪問, 調べ終えた）

void dfs_visit(int u){ //グラフデータは隣接行列にて受け取る
    
    //for(auto x:color) cout << x ;
    //cout << endl;
    int count1=0;
    rep(i,n){
        if(color[i]==black) ++count1; 
    }
    if(count1==n-1) ans++;
    color[u] = black;
    rep(v,n){
        if(M[u][v] == 0) continue;
        if(color[v] == white) {
            
            dfs_visit(v);
            color[v]=white;
        }
    }
    return;
}

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

    rep(i,m){
        int a,b;
        cin >> a >> b;
        M[a-1][b-1] = M[b-1][a-1] = 1;
    }
    dfs_visit(0);
    /*
    rep(i,n){
        rep(j,n){
            if(j) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
    */
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = 0
if n < 10:
  ans = n
elif n < 10**2:
  ans = 9 
elif n < 10**3:
  ans = n - 90
elif n < 10**4:
  ans = 909
elif n < 10**5:
  ans = n - 9090
else:
  ans = 90909
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize(3)
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<bitset>
#include<deque>
using namespace std;
#define ll long long
// #define inf 0x3f3f3f3f
#define ri register int
#define il inline
#define fi first
#define se second
#define mp make_pair
#define pi pair<int,int>
#define mem0(x) memset((x),0,sizeof (x))
#define mem1(x) memset((x),0x3f,sizeof (x))
il char gc()
{
	static const int BS = 1 << 22;
	static unsigned char buf[BS], *st, *ed;
	if (st == ed) ed = buf + fread(st = buf, 1, BS, stdin);
	return st == ed ? EOF : *st++;
}
#define gc getchar
template<class T>void in(T &x)
{
	x = 0;
	bool f = 0;
	char c = gc();
	while (c < '0' || c > '9')
	{
		if (c == '-') f = 1;
		c = gc();
	}
	while ('0' <= c && c <= '9')
	{
		x = (x << 3) + (x << 1) + (c ^ 48);
		c = gc();
	}
	if (f) x = -x;
}
#undef gc
#define pb push_back
ll n;
int s[500], hd = 250, tl = 249;
int dfs(ll x)
{
	if (x == 0) return 0;
	if (x == 1)
	{
		s[++tl] = 1;
		return 1;
	}
	if (x & 1)
	{
		int t = dfs(x >> 1);
		s[++tl] = t + 1;
		return t + 1;
	}
	else
	{
		int t = dfs(x - 1);
		s[--hd] = t + 1;
		return t + 1;
	}
}
signed main()
{
#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
#endif
	in(n);
	dfs(n);
	printf("%d\n", (tl - hd + 1) << 1);
	for (ri i = 1; i <= (tl - hd + 1); ++i) printf("%d ", i);
	for (ri i = hd; i <= tl; ++i) printf("%d ", s[i]);
	return 0;
}
//346gerw

Measured memory_bytes: 256
int main()
{
  int n;
  scanf("%d", &n);
  double ans;
  int i, cnt = 0;
  for (i = 1; i <= n; i++)
  {
    if (i % 2 != 0)
      cnt++;
  }
  ans = (double)cnt / n;
  printf("%lf", ans);
}


Measured memory_bytes: 128
import sys
import statistics                                                                                                                       
readInt = lambda f=sys.stdin: [int(i) for i in f.readline().split()];
n = readInt()[0]
A = readInt()
C = [a - i for i, a in enumerate(A)]
b = int(statistics.median(C))
ans = sum([abs(c - b) for c in C])

print(ans)

Measured memory_bytes: 29604
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class DGatheringChildren {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        string s;
        in>>s;
        int n=s.length(),m=0,r;
        bool f=1;
        vector<int> ans(n);
        s+='R';
        fr(i,n+1){
            if(f){
               if(s[i]=='R') ++m;
               else f=0,++m,r=i-1;
            }
            else{
                if(s[i]=='L') ++m;
                else{
                    f=1;
                    if(m&1){
                        if((i-r)&1) ans[r]=m/2+1,ans[r+1]=m/2;
                        else ans[r]=m/2,ans[r+1]=m/2+1;
                    }
                    else ans[r]=ans[r+1]=m/2;
                    m=1;
                }
            }
        }
        fr(i,n) out<<ans[i]<<" ";
        out<<endl;
    }
};

int main() {
    DGatheringChildren solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main(void){
	int N;
	cin >> N;
	vector<int> H(N,0);
	for(int i=0;i < N;i++){
		cin >> H[i];
	}
	bool S = true;
	if(N == 1);
	else{
		for(int i = N - 2; 0 <= i; i--){
			if(H[i] - H[i+1] == 1) H[i]--;
			else if(H[i] > H[i+1]){
				S = false;
				break;
			}
		}
	}
	if(S) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

vector<long long int>v;

long long gcd(long long a, long long b)
{
	long long a1 = a,b1=b;
	long long c;
	while (a != 0) 
	{ c = a; a = b%a; b = c; }
	long long t = b1 / b;
	return t*a1;
}
int main() {
	int n;
	long long t,res=1;
	scanf("%d", &n);
	while (n--)
	{
		scanf("%lld", &t);
		v.push_back(t);
	}
	for (auto it=v.begin();it!=v.end();it++)
	{
		res = gcd(*it, res);
		
	}
	std::cout << res;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n, m, a, sum = 0;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        cin >> a;
        sum += a;
    }
    cout << (n - sum < 0 ? -1 : n - sum) << endl;
    return 0;
}

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

signed main(){
	int X; cin>>X;
	int now=2,ans=0;
	while(now*now<=X){
		int tmp=2;
		while(pow(now,tmp)<=X)tmp++;
		tmp--;
		int p=pow(now,tmp);
		ans=max(ans,p);
		now++;
	}
	if(X<=3)ans=1;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
typedef vector<pii> vpii;
#define reps(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define all(g) (g).begin(),(g).end()
#define pb push_back
const int mod = 1e9 + 7;
#define INF 1<<25
/*
input case
output case
*/

int N;
vl prime_cubes;
vi primes;

const ll MAX = pow(1e10, 1.0 / 3) + 10;
const int MAX2 = 1e5 + 10;

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

void build_primes(){
    reps(i,2,MAX){
        if (is_prime(i)) { prime_cubes.pb(1ll*i*i*i);}
    }
    reps(i,2,MAX2){
        if (is_prime(i)) { primes.pb(i);}
    }
}

ll norm(ll x){
    for (ll q:prime_cubes){
        if (q > x){ break;}
        while(x % q == 0){
            x /= q;
        }
    }
    return x;
}

const ll inf = 1e12;

ll mul(ll a, ll b) {
    if (inf / b < a)
        return inf;
    else
        return a * b;
}

ll contr(ll x){
    ll y = 1;
    for(int p: primes){
        if (1ll * p * p >x){ break;}
        // 最高で2回まで素数で割る
        // if (x % p == 0 and (x / p) % p == 0){
        if (x % p == 0){
            if ((x / p) % p == 0){
                y = mul(y, p);
                x /= p;
                x /= p;
            }else{
                y = mul(y, mul(p, p));
                x /= p;
            }
        }
        // if (x % (p * p) == 0){
        //     y = mul(y, p);
        //     x /= (p * p);
        // }else if (x % p == 0){
        //     y = mul(y, mul(p,p));
        //     y *= (p * p);
        //     x /= (p);
        // }
    }
    if (x != 1){
        y = mul(y, mul(x, x));
    }
    return y;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    build_primes();
    map<ll, int> cnt;
    rep(i,N){
        ll x;
        cin >> x;
        x = norm(x);
        cnt[x]++;
    }
    int ans = 0;
    set<ll> used;
    for (auto pr: cnt){
        ll x = pr.first;
        int c = pr.second;
        ll y = contr(x);
        if (used.count(x)){
            continue;
        }
        if (x == y){
            ans += 1;
        }else{
            if (cnt.count(y)){
                ans += max(c,cnt[y]);
                used.insert(y);
                used.insert(x);
            }else{
                used.insert(x);
                ans += c;
            }
        }
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back
#define fi first
#define se second
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
#define INF (ll)1e18
#define ll long long
#define P pair<ll, ll>
#define vll vector<ll>
#define vvll vector<vll>

ll n, m, st;
vector<vector<P> > g;

void solve1(void) {
    vll dist(n, INF);
    priority_queue<P, vector<P>, greater<P> > q;
    q.push(P(0, st)); 
    dist[st] = 0; // "見た"
    while (q.size()) { 
        // q = {(d, v)} : 頂点vに距離dで到達できる（dは最適とは限らない）
        // dist[v] : 今までに見た中で、vに到達するための最短距離
        //
        // vの初出がここに来た時点で、dist[v]が最適であることは保証されている！
        // あとは、d = dist[v]のものだけ遷移すれば良い
        P st = q.top(); q.pop();
        ll d = st.fi, v = st.se;
        if (d > dist[v]) continue; // 同じvに異なる距離dで到達可能だが、最適なものだけを見ればよい
        rep(i, g[v].size()) {
            P edge = g[v][i];
            ll u = edge.fi, cost = edge.se;
            if (dist[v] + cost >= dist[u]) continue;
            dist[u] = dist[v] + cost; // "見た"
            q.push(P(dist[v] + cost, u));
        }
    }
    rep(i, n) {
        if (dist[i] == INF) 
            cout << "INF" << endl;
        else
            cout << dist[i] << endl;
    }
}

void solve2(void) {
    vll dist(n, INF); 
    priority_queue<P, vector<P>, greater<P> > q;
    q.push(P(0, st));  
    while (q.size()) { 
        // q = {(d, v)}: vにdで到達できる（dは最適とは限らない）
        // dist[v]: 今までに"見た"中で、vに到達するための最短距離
        P st = q.top(); q.pop();
        ll d = st.fi, v = st.se;
        if (d >= dist[v]) continue; 
        chmin(dist[v], d); // "見た"
        rep(i, g[v].size()) {
            P edge = g[v][i];
            ll u = edge.fi, cost = edge.se;
            q.push(P(dist[v] + cost, u));
        }
    }
    rep(i, n) {
        if (dist[i] == INF) 
            cout << "INF" << endl;
        else
            cout << dist[i] << endl;
    }
}
int main(void) {
    cin >> n >> m >> st;
    g.resize(n);
    rep(i, m) {
        ll u, v, d; cin >> u >> v >> d;
        g[u].pb(P(v, d));
    }
//    solve1();
    solve2();

    return 0;
}



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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    int n;
    cin >> n;
    if(n >= 1800){
        cout << "1" << endl;
    } else if(n >= 1600){
        cout << "2" << endl;
    } else if(n >= 1400){
        cout << "3" << endl;
    } else if(n >= 1200){
        cout << "4" << endl;
    } else if(n >= 1000){
        cout << "5" << endl;
    } else if(n >= 800){
        cout << "6" << endl; 
    } else if(n >= 600){
        cout << "7" << endl;
    } else if(n >= 400){
        cout << "8" << endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll a, b;
    cin >> a >> b;

    for(ll x = 1; x <= 10000; x++) {
        ll c = x * 0.08;
        ll d = x * 0.10;
        if(c == a && d == b) {
            out(x);
            re0;
        }
    }
    
    out(-1);
    re0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

typedef struct Point_
{
    double x;
    double y;
} Point;

void koch(int n, Point a, Point b)
{
    if (n == 0)
        return;

    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}

int main()
{
    Point a, b;
    int n;

    scanf("%d", &n);

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}


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

int main() {
    ll n, m;
    cin >> n >> m;
    int ans = 0;
    for(int i=pow(m, 0.5)+1; i>=1; i--){
        if(m%i==0){
            int tmp = m/i;
            if(tmp*n<=m){
                ans = max(ans, tmp);
            }
            if(i*n<=m){
                ans = max(ans, i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
N = int(input())
A = [int(a) for a in input().split()]
dpx = [0]*(N+1)
dpy = [0]*(N+1)
dpx[0] = sum(A[:N])
dpy[-1] = sum(A[2*N:])
X = []
Y = []
for i in range(N):
  heappush(X,A[i])

for i in range(N):
  heappush(Y,-A[3*N-1-i])

for i in range(N):
  a = heappop(X)
  b = A[N+i]
  if b>a:
    heappush(X,b)
    dpx[i+1] = dpx[i]+b-a
  else:
    heappush(X,a)
    dpx[i+1] = dpx[i]
  
  c = -heappop(Y)
  d = A[2*N-1-i]
  if d<c:
    heappush(Y,-d)
    dpy[N-1-i] = dpy[N-i]+d-c
  else:
    heappush(Y,-c)
    dpy[N-1-i] = dpy[N-i]

ans = -float('inf')
for i in range(N+1):
  ans = max(ans, dpx[i]-dpy[i])
print(ans)

Measured memory_bytes: 37212
N=int(input())
d_pre=input().split()
d=[int(s) for s in d_pre]
d.sort()
d_2=d[::-1]
ans=1
if 0 in d_2:
    print(0)
else:
    for i in range(N):
        ans*=d_2[i]
        if ans>10**18:
            print(-1)
            break
        elif i==N-1:
            print(ans)

Measured memory_bytes: 22380
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
       		String[] strStdIn = new String[1];
		int m = 0;
		while (m != 1) {
			strStdIn[m] = scanner.nextLine();
			m++;
		}

		String target = strStdIn[0];

		String rightString = "CODEFESTIVAL2016";
		int count = 0;

		for (int i=0; i < rightString.length(); i++) {
			if (!target.substring(i, i+1).equals(rightString.substring(i, i+1))) {
				count++;
			}
			if (i + 1 == rightString.length()) {
				break;
			}
		}
		
		System.out.println(count);
    	}
}

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

using namespace std;

int main(void)
{
	string S; cin>>S;
	int len = S.size();
	int s[len],b_num = 0, w_num = 0;
	for(int i = 0; i < len; i++){
		if(S[i] == 'W'){
			s[i] = 1;
			w_num++;
		}
		else{
			s[i] = 2;
			b_num++;
		}
	}
	
	int ans = 0;
	int j = 0;
	while(j < len && b_num != len && w_num != len){
		if(s[j] == 1){
			while(s[j] == 1){
				j++;
			}
		}
		else{
			while(s[j] == 2){
				j++;
			}
		}
		ans++;
	}
	if(ans != 0) ans--;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 896
//
//  Problem Name: Knapsack 1

//  Created by Kushal Warke
//  Copyright © 2018 Kushal Warke. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <fstream>
#include <map>
#include <vector>
#include <set>
#include <sstream>
#include <stack>
#include <list>
#include <queue>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector< pair<int,int> > vpi;
typedef vector< pair<long long,long long> > vpll;

double EPS = 1e-9; 
int INF = 1000000005;
struct data {
    int score;
    string name;
    int index;
};
bool cmp(data a, data b) {
    if(a.name==b.name) return a.score > b.score;
    return a.name < b.name;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<data> v(n);
    FOR(i,0,n) {
        cin>>v[i].name;
        cin>>v[i].score;
        v[i].index = i+1;
    }
    sort(v.begin(),v.end(),cmp);
    FOR(i,0,n) {
        cout<<v[i].index<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n,i,o,r,sum;
	scanf("%d",&n);
	int a[200][3]={0};

	for(i=0;i<n;i++){
		for(o=0;o<3;o++){
			scanf("%d",&a[i][o]);
			for(r=i;r>=0;r--){
				if(a[i][o] == a[r][o] && r!=i || a[i][o]*1000 == a[r][o] ){
					if(a[r][o] <=100)
						a[r][o]*=1000;
					if(a[i][o] <=100)
						a[i][o]*=1000;
				}
			}

		}
	}
	for(i=0;i<n;i++){
		sum=0;
		for(o=0;o<3;o++){
			if(a[i][o] <=100)
				sum+=a[i][o];
		}
		printf("%d\n",sum);
		
	}
	return 0;
}

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

#define trade(a,b) tmp=(a);(a)=(b);(b)=tmp;

long M;

int sort(long l[],int N){
        int i=1,j,k;
        long tmp;

        for(i=0;i<N;i++){
                for(j=i;j>0;j=(j-1)/2){
                        if(l[j]<l[(j-1)/2]){
                                trade(l[j],l[(j-1)/2]);
                        }else{
                                break;
                        }
                }
        }

        for(i=0,k=N-1;i<N;i++){
                trade(l[0],l[k]);
                k--;
                for(j=0;j*2+1<=k;){
                        if(j*2+2>k || l[j*2+1]<l[j*2+2]){
                                if(l[j]>l[j*2+1]){
                                        trade(l[j],l[j*2+1]);
                                        j=j*2+1;
                                }else{
                                        break;
                                }
                        }
                        else if(l[j]>l[j*2+2]){
                                trade(l[j],l[j*2+2]);
                                j=j*2+2;
                        }else{
                                break;
                        }
                }
        }

        return 0;

}

long getmaxsum(long l[],int N){
                int i,j;
                long maxsum=0;

                for(i=0,j=N-1;j-i>=0;i++){
                        while(l[i]+l[j-1]<M && j-i>=0)
                                j--;
                        if(maxsum<l[i]+l[j])
                                maxsum=l[i]+l[j];
                }

                return maxsum;
}

main(){
        int i,j;

        long k,N;

        long l[1000+500500+1];

        while(1){
                scanf("%ld %ld",&N,&M);
                if(N==0)break;
                for(i=0;i<N;i++)
                        scanf("%ld",&l[i]);

                sort(l,N);

                for(i=0,k=N;i<2*N-1;i++)
                        for(j=(i>=N ? i-N+1: 0); i-j>=j; j++){
                                if(l[i-j]+l[j]<M)
                                        l[k++]=l[i-j]+l[j];
                        }
                l[k++]=0;
                N=k;
                //printf("N=%ld\n",N);

                sort(l,N);

                printf("%ld\n",getmaxsum(l,N));

        }
        return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int count = 1;
    for (int i = 1; i < N; i++) {
      if (a.at(i) < a.at(i - 1))
      count++;
    }
    cout << count << endl;
  }

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	sort(a.rbegin(), a.rend());
	ll ans = 0;
	priority_queue<P> pq;
	pq.push(P(a[0], a[0]));
	for(int i = 1; i < n; ++i){
		P q = pq.top();
		pq.pop();
		ans += q.first;
		pq.push(P(a[i], q.first));
		pq.push(P(a[i], q.second));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8988
N = gets.chomp.to_i
array = gets.chomp.split.map(&:to_i)
count_array = Array.new(N, 0)

array.each { |num| count_array[num - 1] += 1 }

total_count = count_array.map do |num|
  (num * num - num) / 2
end.inject(&:+)

N.times.each do |k|
  k_balls_pair_count = count_array[array[k] - 1] - 1
  puts total_count - k_balls_pair_count
end


Measured memory_bytes: 26116
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <stack>
#include <set>

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    if (s == t) {
        cout << "Yes" << endl;
    } else if (set<char>(s.begin(), s.end()) != set<char>(t.begin(), t.end())) {
        cout << "No" << endl;
    } else {
        for (int i = 0; i < s.length() - 1; ++i) {
            s.insert(s.begin(), s.back());
            s.pop_back();
            if (s == t) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  std::vector<std::string> blue(n);
  for(int i = 0; i < n; i++)
  {
    cin >> blue.at(i);
  }
  sort(begin(blue), end(blue)) ;
  std::string judge = blue.at(0);
  map<std::string, int> data;
  for(int i = 0; i < n; i++)
  {
    if(blue.at(i) != judge)
    { 
    int x = count(begin(blue), end(blue), judge);
    data[judge] = x;
    judge = blue.at(i);
    }
    if(i == n - 1)
    {
      int x = count(begin(blue), end(blue), judge);
      data[judge] = x;
    }
  }
  
  int m;
  cin >> m;
  for(int i = 0; i < m; i++)
  {
    std::string r;
    cin >> r;
    if(data.count(r) )
    {
      data.at(r) -= 1;
    }
  }
  int answer = 0;
  for(auto x : data)
  {
    auto a = x.first;
    auto b = x.second;
    answer = max(b, answer);
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	// 基準となる単語
	private static final String[] CORRECT_WORDS = { "the", "that", "this" };

	public static void main(String[] args) {

		// ストリームを作成する
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		while (true) {
			String line = readLine(reader);

			// 終了判定
			if (line == null) {
				break;
			}

			// 26パターン試す
			String result = null;
			for (int i = 1; i <= 26; i++) {
				// コード変換をかける
				result = shiftString(line, i);

				// 正しい変換ならここで変換終了
				if (isCorrect(result)) {
					break;
				}
			}

			// 結果を表示する
			System.out.println(result);
		}

	}

	/**
	 * ストリームから1行読み込んで、文字列として返す。
	 *
	 * @param reader
	 *            入力ストリーム
	 * @return 文字列
	 */
	private static String readLine(BufferedReader reader) {
		String line = null;
		try {
			line = reader.readLine();
		} catch (IOException e) {
			throw new RuntimeException();
		}
		return line;
	}

	/**
	 * 文字列内のアルファベットを指定文字分だけシフトする。
	 *
	 * @param target
	 *            対象文字列
	 * @param shift
	 *            シフトする文字数
	 * @return シフト後の文字列
	 */
	private static String shiftString(String target, int shift) {
		StringBuilder buffer = new StringBuilder();

		for (int i = 0; i < target.length(); i++) {
			char ch = target.charAt(i);
			if (ch >= 'a' && ch <= 'z') {
				ch = (char) (ch + shift);
				if (ch > 'z') {
					ch = (char) ((ch % ('z')) + 'a' - 1);
				}
			}
			buffer.append(ch);
		}

		return buffer.toString();
	}

	/**
	 * 渡された文字列に正しい単語が含まれているか確認する。
	 *
	 * @param target
	 *            チェック対象文字列
	 * @return 正しい場合はtrue、そうでない場合はfalse
	 */
	private static boolean isCorrect(String target) {
		boolean result = false;
		for (String word : CORRECT_WORDS) {
			if (target.contains(word)) {
				result = true;
				break;
			}
		}
		return result;
	}
}

Measured memory_bytes: 17808
//omajinai c++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
constexpr auto mod = 1000000007;

using namespace std;
 int main() {
   int a,b,c;
   cin>>a>>b>>c;
   
   if(a==b&&a!=c||b==c&&a!=c||a==c&&a!=b){
     cout<<"Yes";
   }
   else{
     cout<<"No";
   }
 }


Measured memory_bytes: 256
using System;

namespace _0055
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string s = Console.ReadLine();
                if (s == null)
                {
                    break;
                }
                double n = double.Parse(s);
                Console.WriteLine(n * 7.81481481);
            }
        }
    }
}

Measured memory_bytes: 9264
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int T;
    cin >> T;

    REP(_, T) {
        int N; cin >> N;

        ll ans = 0;

        vector<pair<ll, ll>> pos, neg;
        REP(i, N) {
            ll k, l, r; cin >> k >> l >> r;

            if (l > r) {
                ans += r;
                pos.eb(l - r, k);
            } else {
                ans += l;
                neg.eb(r - l, N - k);
            }

        }

        sort(ALL(pos), greater<>());
        sort(ALL(neg), greater<>());

        set<int> free;
        REP(i, N) free.insert(i + 1);

        for(auto &p : pos) {
            auto it = free.upper_bound(p.se);
            if (it != free.begin()) {
                it--;
                free.erase(*it);
                ans += p.fi;
            }
        }

        set<int>().swap(free);
        REP(i, N) free.insert(i + 1);

        for(auto &p : neg) {
            auto it = free.upper_bound(p.se);
            if (it != free.begin()) {
                it--;
                free.erase(*it);
                ans += p.fi;
            }
        }

        print(ans);
    }
    
}


Measured memory_bytes: 15672
// myfirstatcoder.cpp : アプリケーションのエントリ ポイントを定義します。

#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,cc,n) for(int i=cc;i<(n);++i)
#define drep(i,cc,n) for(int i=cc;i>(n);--i)
#define llrep(i,cc,n) for(long long i=cc;i<(n);++i)
using namespace std;
using ll = long long;

int main()
{
	int N;
	string T;
	cin >> T;
	N = T.length();
	if (T.at(0) == '?')
		if (N>1 && T.at(1) == 'D')
			T.at(0) = 'P';
		else
			T.at(0) = 'D';
	reps(i, 1, N - 1)
	{
		if (T.at(i) == '?')
		{
			if (T.at(i - 1) == 'P')
				T.at(i) = 'D';
			else
			{
				if (T.at(i + 1) == 'D')
					T.at(i) = 'P';
				else
					T.at(i) = 'D';
			}
		}
	}
	if (T.at(N - 1) == '?')
		T.at(N - 1) = 'D';
	cout << T << endl;

	return 0;
}



Measured memory_bytes: 3716
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	char s;
	scan(s);
	if('A'<=s&&s<='Z'){
		prin("A");
	}
	else prin("a");
	return 0;
}


Measured memory_bytes: 3592