akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n: String = read();
    let big_int = 1000_000_000 + 7;
    let mut gain = vec![0i64; n.len() + 1];
    gain[0] = 1;
    for i in 1..n.len() + 1 {
        gain[i] = gain[i - 1] * 3;
        gain[i] %= big_int;
    }
    let mut pow2 = vec![0i64; n.len() + 1];
    pow2[0] = 1;
    for i in 1..n.len() + 1 {
        pow2[i] = pow2[i - 1] * 2;
        pow2[i] %= big_int;
    }

    let mut ans = 0i64;
    let mut found = 0;
    debug!(gain);
    for (i, c) in n.chars().enumerate() {
        if c == '1' {
            debug!(gain[n.len() - i - 1], pow2[found]);
            ans += gain[n.len() - i - 1] * pow2[found];
            ans %= big_int;
            found += 1;
        }
    }
    debug!(ans, found);
    ans += pow2[found];
    ans %= big_int;
    println!("{:?}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 6396
/*
 * atcoder/abc118/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }

const string M_INF = "-";
const int MAX = 10100;
int N, M;
vector<int> A;
int C[10] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

// dp[i] := コストiまでで作れる最大の整数
string dp[MAX];

void chmax(string &a, string b) {
  if (a == M_INF) { a = b; return; }
  if (a.size() < b.size()) { a = b; return; }
  if (b.size() > a.size()) { return; }
  if (b > a) a = b;
}

void solve() {
  cin >> N >> M;
  A.resize(M);
  loop(m,0,M) cin >> A[m];
  loop(i,0,N+1) dp[i] = M_INF;
  dp[0] = "";

  loop(i,0,N+1) {
    if (dp[i] == M_INF) continue;
    for (auto&&a: A) {
      chmax(dp[i+C[a]], dp[i] + (char)('0'+a));
    }
  }
  cout << dp[N] << endl;
}

int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int c[n], s[n], f[n];
  for (int i = 0; i < n-1; i++) {
    cin >> c[i] >> s[i] >> f[i];
  }
  
  int time[n];
  
  for (int i = 0; i < n-1; i++) {
    time[i] = 0;
    for (int j = i; j < n-1; j++) {
      time[i] = ((max(s[j], time[i]) + f[j] - 1) / f[j]) * f[j];
      time[i] += c[j];
    }
  }
  time[n-1] = 0;
  for (int i = 0; i < n; i++) {
    cout << time[i] << endl;
  }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define N '\n'
#define S ' '
#define Z '0'
#define RT return
#define elif else if
#define W(a) while(a)
#define RP(a,b,c) for(ll a=(b);a<(c);++a)
#define R(a,b) for(ll a=0;a<(b);++a)
#define RD(a,b) for(ll a=(b);a>=0;++a)
#define LI(a) for(auto &x:a)I(x)
#define P(a) cout<<#a<<N
#define F(a) cout<<fixed<<setprecision(10)<<a
#define D(a,b,c) cout<<setfill(a)<<setw(b)<<right<<c
#define V cin.tie(0);ios::sync_with_stdio(false)
ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,v,w,x,y,z;
const int P[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
inline void I(){}
template<class T,class...A>inline void I(T&&t,A&&...a){cin>>t;I(move(a)...);}
template<class T>inline void O(T t){cout<<t<<N;}
template<class T,class...A>inline void O(T t,A...a){cout<<t<<S;O(move(a)...);}
inline ll dig(ll a){ll d=1;W(a/=10)++d;RT d;}
inline ll GCD(ll a,ll b){ll c;W(a){c=a;a=b%a;b=c;}RT b;}
inline bool isp(ll a){if(a<48){RP(i,0,15)if(P[i]==a)RT 1;}
    elif(a<2809)RT GCD(614889782588491410,a)==1;
    else {O("Error:Argument is Over-2808!");exit(1);}RT 0;}

class Comp {
public:
    const vector<ll> &_v;
    Comp(const vector<ll> &v): _v(v) {}
    bool operator()(ll a, ll b) { return _v[a] < _v[b]; }
};

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{
    ll n = av.size();
    vector<ll> p(n), av2(n), bv2(n);
    for (ll i = 0; i < n; i++)
        p[i] = i;
    sort(p.begin(), p.end(), Comp(av));
    for (ll i = 0; i < n; i++) {
        av2[i] = av[p[i]];
        bv2[i] = bv[p[i]];
    }
    av = av2;
    bv = bv2;
}

int main(){
    V;
    I(n,m);
    vector<ll> A,B;
    R(i,m){I(a,b);A.push_back(a);B.push_back(b);}
    sort2vectors(A,B);
    RP(j,0,m){
        if(A[j]!=-1){
            RP(i,j+1,m){
                if(A[i]!=-1&&max(A[i],A[j])<min(B[i],B[j])){
                    A[j]=max(A[i],A[j]);
                    B[j]=min(B[i],B[j]);
                    A[i]=-1;
                }
            }
        }
    }
    R(i,m)if(A[i]!=-1)++s;
    O(s);














}


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

int main()
{
    vector<int> bar;
    int n, w;
    char sp;
    int a[2];
    cin >> w;
    for(int c =1; c <= w; c++)
        bar.push_back(c);
    cin >> n;
    for(int c =0; c < n; c++)
    {
        cin >> a[0] >> sp  >> a[1];
        swap(bar[a[0] -1],bar[a[1] -1]);
    }
    for(int c=0; c < w; c++)
        cout << bar[c] << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1216
n, k = gets.split.map(&:to_i)
CACHE = {}

def blue(k, i)
  return 0 if k < i
  h(i, k - i)
end

def red(k, i)
  need = i - 1
  return 0 if k < need
  h(i + 1, k - need)
end

def ex(i)
  return 1 if i.zero?
  return CACHE[i] if CACHE.key?(i)
  CACHE[i] = i * ex(i - 1)
end

def c(n, r)
  ex(n) / (ex(r) * ex(n - r))
end

def h(n, r)
  c(n + r - 1, r)
end

(1..k).each do |i|
  ans = blue(k, i) * red(n - k, i)
  puts ans % (10 ** 9 + 7)
end


Measured memory_bytes: 8316
class Dice
  def initialize(dice = [])
    @dice = dice
  end

  def getTop
    @dice[0]
  end
  
  def getFront
    @dice[1]
  end

  def getRight
    @dice[2]
  end

  def getLeft
    @dice[3]
  end

  def getBack
    @dice[4]
  end

  def getBottom
    @dice[5]
  end

  def getDiceArray
    [ 
      @dice[0],
      @dice[1],
      @dice[2],
      @dice[3],
      @dice[4],
      @dice[5]
    ]
  end

  def setTop(t)
    case t
    when @dice[0]
      return
    when @dice[1]
      self.role("N")
    when @dice[2]
      self.role("W")
    when @dice[3]
      self.role("E")
    when @dice[4]
      self.role("S")
    when @dice[5]
      self.role("N")
      self.role("N")
    end
  end


  def role(c)
    case c
    when "N"
      @dice = 
        [
          @dice[1],
          @dice[5],
          @dice[2],
          @dice[3],
          @dice[0],
          @dice[4]
        ]

    when "S"
      @dice = 
        [
          @dice[4],
          @dice[0],
          @dice[2],
          @dice[3],
          @dice[5],
          @dice[1]
        ]
    
    when "E"
      @dice = 
        [
          @dice[3],
          @dice[1],
          @dice[0],
          @dice[5],
          @dice[4],
          @dice[2]
        ]
    
    when "W"
      @dice = 
        [
          @dice[2],
          @dice[1],
          @dice[5],
          @dice[0],
          @dice[4],
          @dice[3]
        ]
    end
  end

  def setFront(n)
    case n
    when @dice[0]
      return false
    when @dice[1]
      return true
    when @dice[2]
      self.turn("L")
    when @dice[3]
      self.turn("R")
    when @dice[4]
      self.turn("R")
      self.turn("R")
    when @dice[5]
      return false
    end
  end

  def turn(c)
    case c
    when "R"
      @dice =
        [
          @dice[0],
          @dice[2],
          @dice[4],
          @dice[1],
          @dice[3],
          @dice[5]
        ]
    when "L"
      @dice =
        [
          @dice[0],
          @dice[3],
          @dice[1],
          @dice[4],
          @dice[2],
          @dice[5]
        ]
    end
  end
end

dice_arr = gets.split.map(&:to_i)
@dice_origin = Dice.new(dice_arr)
dice_arr = gets.split.map(&:to_i)
@dice = Dice.new(dice_arr)

same_dice = false
4.times do
  4.times do
    if @dice_origin.getDiceArray == @dice.getDiceArray
      same_dice = true
    end
    @dice.turn("R")
  end
  @dice.role("N")
end

4.times do
  4.times do
    if @dice_origin.getDiceArray == @dice.getDiceArray
      same_dice = true
    end
    @dice.turn("R")
  end
  @dice.role("E")
end



if same_dice 
  puts "Yes" 
else
  puts "No"
end

Measured memory_bytes: 6092
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    string n;
    cin>>n;
    if(n[0]=='9'||n[1]=='9'){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
# define ld  long double
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
#define pll pair<ll, ll>
# define mp make_pair
# define ac accumulate
# define mod 1000000007
#define um unordered_map
# define pii pair<ll,ll>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int  main()
{
	
	ll n;
	cin>>n;
	ll arr[n+3];
	map<ll,ll>odd,even;
	
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];

	}
	for(ll i=1;i<n;i=i+2)
	{
		odd[arr[i]]++;
	}
	for(ll i=0;i<n;i=i+2)
	{
		even[arr[i]]++;
	}
	ll ans=-1,flag,temp=-1;
	for(auto i:odd)
	{
		if(i.ss>ans)
		{
			flag=i.ff;
			ans=i.ss;
		}
	}
	ans=-1;
	for(auto i:even)
	{
		if(i.ss>ans&&i.ff!=flag)
		{
			temp=i.ff;
			ans=i.ss;
		}
	}
	ll cnt=0;
	if(ans==-1)
		temp=flag+1;
	for(ll i=0;i<n;i=i+2)
	{
		if(arr[i]!=temp)
			cnt++;

	}
	
	for(ll i=1;i<n;i=i+2)
	{
		if(arr[i]!=flag)
			cnt++;
	}
    ll res=cnt;
	ans=-1;
	for(auto i:even)
	{
		if(i.ss>ans)
		{
			temp=i.ff;
			ans=i.ss;
		}
	}
	ans=-1;
	for(auto i:odd)
	{
		if(i.ss>ans&&i.ff!=temp)
		{
			flag=i.ff;
			ans=i.ss;
		}
	}
     cnt=0;
	if(ans==-1)
		flag=temp+1;
	for(ll i=0;i<n;i=i+2)
	{
		if(arr[i]!=temp)
			cnt++;

	}
	
	for(ll i=1;i<n;i=i+2)
	{
		if(arr[i]!=flag)
			cnt++;
	}
	cout<<min(res,cnt);
}
	

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=100005,INF=1<<28;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,A,B,C,X;cin>>N>>A>>B>>C>>X;
        if(N==0) break;
        
        vector<int> Y(N);
        for(int i=0;i<N;i++) cin>>Y[i];
        
        int now=0;
        
        if(X==Y[now]) now++;
        
        if(now==N){
            cout<<0<<endl;
            continue;
        }
        
        for(int i=1;i<=10000;i++){
            X=(A*X+B)%C;
            if(X==Y[now]){
                now++;
            }
            if(now==N){
                cout<<i<<endl;
                break;
            }
            if(i==10000){
                cout<<-1<<endl;
                break;
            }
        }
    }
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    if (a%2==1 && b%2==1){
        cout<<"Odd\n";
    }else{
        cout<<"Even\n";
    }
    return 0;
}


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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	string s;
	cin >> s;
	REP(i,1,s.length()){
		if(s[i-1] == 'A' and s[i] == 'C'){
			P("Yes");
			return;
		}
	}
	P("No");
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
const int MaxN = 100;
char a[5][MaxN + 5];
int p[5], len[5];

int main()
{
	for(int i = 1; i <= 3; i++) p[i] = 0;
	p[1] = 1;
	scanf("%s", a[1] + 1);
	scanf("%s", a[2] + 1);
	scanf("%s", a[3] + 1);
	for(int i = 1; i <= 3; i++) len[i] = strlen(a[i] + 1);
	int r = 1;
	while(1) {
		if(p[r] == len[r] + 1) {
			//printf("%d %d %d", p[1], p[2], p[3]);
			if(r == 1) printf("A\n");
			else if(r == 2) printf("B\n");
			else if(r == 3) printf("C\n");
			break;
		}
		if(a[r][p[r]] == 'a') {
			p[1]++;
			r = 1;
		}
		else if(a[r][p[r]] == 'b') {
			p[2]++;
			r = 2;
		}
		else if(a[r][p[r]] == 'c') {
			p[3]++;
			r = 3;
		}
	}
	return 0;
}




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

const int N = 1e5 + 5;
int n;
long long a[N], b[N];
// pair <int, int> sum[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n + 1; i++) scanf("%lld", &a[i]);
    for (int i = 1; i <= n; i++) scanf("%lld", &b[i]);

    long long res = 0;
    for (int i = 1; i <= n; i++) {
        res += min(a[i] + a[i + 1], b[i]);
        a[i + 1] = max((long long)0, a[i + 1] - max(b[i] - a[i], (long long)0));
    }
    // for (int i = 1; i <= n + 1; i++) cout << a[i] << " ";
    // cout << endl;
    printf("%lld", res);
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    static long INF = 1000000000000000L;
    
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextInt();
        String[] array = new String[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.next();
        }
        Arrays.sort(array);
        
        for (int i = 0; i < n; i++) {
            System.out.print(array[i]);
        }
        System.out.println();
    }
}

Measured memory_bytes: 22728
sd = ["#", "."]

while True:
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break
    for i in range(a):
        for j in range(b):
            if i % 2 == 0:
                print(sd[j % 2], end='')
            elif i % 2 != 0:
                print(sd[j % 2 - 1], end='')
        print()
    print()



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

int main(){
   char a[3];
   char b[3];
   char c[3];
   scanf("%s", a);
   scanf("%s", b);
   scanf("%s", c);
  cout<<a[0]<<b[1]<<c[2]<<endl;
  return 0;
}

Measured memory_bytes: 256
#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[i];
  }

  int pa = a[0], b = 1, ans = 0;
  for (int i = 1; i < N; ++i) {
    if (a[i] == pa) {
      ++b;
    } else {
      ans += b / 2, pa = a[i], b = 1;
    }
  }
  ans += b / 2;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    unsigned long i,j;
    unsigned long ret = 0;
    scanf("%lu",&i);
    for ( j = 1 ; j <= i ; j++){
        if ((j % 3 == 0 ) && (j % 5 == 0)) {
            ret = ret;//NA
        }else if (j % 3 == 0 ){
            ret = ret;//NA
        }else if(j % 5 == 0){
            ret = ret;//NA
        }else{
            ret = ret + j;
        }
    }
    printf("%lu\n",ret);
    return 0;
}


Measured memory_bytes: 1724
n = int(input())
a = []
b = []
c = []

def root(x):
    global rs
    if rs[x] == x:
        return(x)
    else:
        return(root(rs[x]))

for _ in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    for j in range(i+1,n):
        if a[i][j] >= 0:
            b.append([a[i][j],i,j])
rs = [(i) for i in range(n)]

b.sort()
ans = 0
while(len(b)):
    if root(b[0][1]) != root(b[0][2]):
        ans += b[0][0]
        rs[root(rs[b[0][2]])] = root(b[0][1])
        c.append(b[0])
    del(b[0])
print(ans)


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

using namespace std;

using ll = long long;
using ld = long double;

#define mp make_pair

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

   //   freopen("a.txt", "r", stdin);

      ll N, K;
      cin >> N >> K;

      if (N < K) {
            cout << min(N, K - N);
      }
      else {
            N -= N / K * K;
            cout << min(N, K - N);
      }

      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 REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,q,a,l,r;
	vll ans;
	cin >> n;
	vll v(n);  rep(i,n) cin >> v[i];
	cin >> q;
	rep(i,q){
		cin >> a >> l >> r;
		if(a==0) ans.pb(*min_element(v.begin()+l,v.begin()+r));
		else if(a==1) ans.pb(*max_element(v.begin()+l,v.begin()+r));
	}
	for(auto& e:ans) cout << e << endl;
	return 0;
}


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

    using namespace std;

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int s,w;
        cin>>s>>w;
        if(w>=s)
            cout<<"unsafe";
        else
            cout<<"safe";
        return 0;
    }


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

int main(){
    string S;
    cin >> S;
    bool flg = false;
    int c = 0;
    int r;
    for(int i=1;i<4;i++){
        if(S[0] == S[i]){
            c++;
            r = i;
        }
    }

    if(c == 1 && r == 1 && S[2] == S[3]){
        flg = true;
    }
    else if(c == 1 && r == 2 && S[1] == S[3]){
        flg = true;
    }
    else if(c == 1 && r == 3 && S[1] == S[2]){
        flg = true;
    }

    if(flg == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	string s; cin >> s;
	if (s == "SUN")cout << 7 << endl;
	if (s == "MON")cout << 6 << endl;
	if (s == "TUE")cout << 5 << endl;
	if (s == "WED")cout << 4 << endl;
	if (s == "THU")cout << 3 << endl;
	if (s == "FRI")cout << 2 << endl;
	if (s == "SAT")cout << 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
using namespace std;

struct town {
	long x;
	long y;
	town(long ix, long iy) {
		x = ix;
		y = iy;
	}
};

// 順列
class Permutation {
	// 公開関数
public:
	// コンストラクタ
	Permutation(const vector<town>& loc);
	// デストラクタ
	~Permutation();
	// 順列を計算するメイン関数
	double calc_main(int N);
	// 内部関数
private:
	// 順列を計算するための再帰関数
	void calc_perm(vector<bool> jdg, int num, double sum);
	double dist(int i, int j);
	// 内部変数
private:
	// 計算した順列を格納するvector配列
	vector<double> ans;
	// 計算する階乗を示す整数
	int N = 1;
	const vector<town>& loc;
};

// コンストラクタ
Permutation::Permutation(const vector<town>& loc) : loc(loc) {
	// 答えを格納するメンバ変数のvector配列を初期化
	ans.clear();
}

// デストラクタ
Permutation::~Permutation() {
}

double Permutation::dist(int i, int j) {
	double ans = 0;
	ans = sqrt((double)pow((loc[i].x - loc[j].x), 2) + (double)pow((loc[i].y - loc[j].y), 2));
	return ans;
}

// 順列を計算するメイン関数
double Permutation::calc_main(int N) {
	// 計算する階乗を示す整数を内部変数に格納
	this->N = N;

	// 順列に含まれているかを確認するbool型のvector配列を宣言
	vector<bool> jdg(this->N, false);

	// 再帰関数を用いて順列を計算
	for (int k = 0; k < N; k++) {
		jdg[k] = true;
		calc_perm(jdg, k, (double)0.0);
		jdg[k] = false;
	}

	// 順列が格納されたvector配列を戻り値として返す
	return (double)accumulate(ans.begin(), ans.end(), 0.0)/(double)ans.size();
}

// 順列を計算するための再帰関数
void Permutation::calc_perm(vector<bool> jdg, int num, double sum) {
	double dsum = 0;
	// すべての整数を使って順列を作成した場合
	if (jdg.end() == find(jdg.begin(), jdg.end(), false)) {
		// 答えを格納
		ans.push_back(sum);
	}

	// 整数のループ
	for (size_t i = 0; i < N; i++) {
		if (jdg[i] == false) {
			dsum = sum;
			jdg[i] = true;
			dsum += dist(num, i);
			calc_perm(jdg, i, dsum);
			jdg[i] = false;
		}
	}
}

int main() {

	long N;
	cin >> N;

	long x, y;
	vector<town> loc(N, town(0, 0));
	for (long i = 0; i < N; i++) {
		cin >> x >> y;
		loc[i] = town(x, y);
	}

	Permutation p(loc);
	double ave = p.calc_main(loc.size());

	cout << fixed;
	cout << setprecision(8) << ave << endl;

	return 0;
}



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

using namespace std;

int main(){
	string s1, s2;
	cin>>s1>>s2;
	int m = s1.length(), n = s2.length();
	int lookup[m+1][n+1];
	memset(lookup, 0, sizeof lookup);
	int i, j;
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			if(s1[i-1]==s2[j-1])
				lookup[i][j] = 1 + lookup[i - 1][j - 1];
			else
				lookup[i][j] = max(lookup[i][j-1], lookup[i-1][j]);
		}
	}

	//printf("%d\n", lookup[m][n]);

	int count = 0;
	i = m, j = n;
	string ans = "";
	while(count <lookup[m][n]){
		if(s1[i-1]==s2[j-1]){
			ans +=s1[i-1];
			i--;
			j--;
			count++;
		}
		else{
			if(lookup[i][j-1] > lookup[i-1][j]) j--;
			else i--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout<<ans;
	return 0;
}

Measured memory_bytes: 35456
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int cnt=0,k,s,l,a,b,c,d;
	cin>>l>>a>>b>>c>>d;
	k=a;
	s=b;
	while(k>0||s>0)
	{
		k-=c;
		s-=d;
		cnt++;
	}
	cout<<l-cnt<<endl;
	return 0;
}

Measured memory_bytes: 3080
s = input()
n_op = len(s) - 1
for i in range(2**n_op):
  op = ['-'] * n_op
  for j in range(n_op):
    if i>>j & 1:
      op[n_op - 1 - j] = '+'
    
  formula = ''
  for p_s, p_op in zip(s, op+['']):
    formula += p_s + p_op
  if eval(formula) == 7:
    print(formula + '=7')
    break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
ll M=1e9+7;
int main()
{
	ll n,ans=0,x=0;
	cin>>n;
	vector<ll> vec(n+1,0);
	for(ll i=1;i<=n;i++){
		cin>>vec[i];
		vec[i]=vec[i]%M;
		ans+=(x*vec[i]);
		ans=(ans%M);
		x+=vec[i];
		x=(x%M);
	}
	cout<<ans<<endl;
	
}


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

using namespace std;

int cnt[30];

int main() {
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++) {
    cnt[s[i] - 'A']++;
  }
  bool ok = true;
  for(int i = 0; i < s.size(); i++) {
    if(cnt[s[i] - 'A'] == 2) ok = true;
    else {
      ok = false;
      break;
    }
  }
  if(ok) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}
#endif


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

    int N; cin >> N;
    vl T(N); REP(i, N) cin >> T[i];

    ll ans = T[0];
    FOR(i,1,N) {
        ans = lcm(ans, T[i]);
    }

    cout << ans << endl;

    return 0;
}

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

#define mp make_pair
#define pb push_back
#define f first
#define s second 
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define int long long
#define forn(i, x, y) for(int i = x; i <= y; i++)
#define forev(i, y, x) for(int i = y; i >= x; i--)

using namespace std;

const int maxn = (int)3e5 + 100;
const int mod = (int)1e9 + 7;
const int P = (int)1e6 + 7;
const int inf = (int)1e9 + 7;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef long double ld;

using namespace std;

int a;
string s;
main () {
	cin >> a >> s;
	if(a < 3200) s = "red";
	cout << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  string s;
  cin >> s;
  ll n, k;
  cin >> k;
  n = s.size();
  fi(0, n) {
    if(i == n - 1) {
      k %= 26;
      if(s[i] + k > 'z') {
        k = s[i] + k - 'z';
        s[i] = 'a' + k - 1;
      }
      else {
        s[i] += k;
      }
      break;
    }
    if(s[i] != 'a' && 'z' - s[i] + 1 <= k) {
      k -= ('z' - s[i] + 1);
      s[i] = 'a';
    }
  } 
  cout << s << endl;
  return 0;
}



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

using namespace std;

int main(){

	/*0から順にAXYZWB*/
	int map[6][2]={{1,2},{-1,3},{1,-1},{4,5},{5,2},{2,1}};
	int now;
	string p;

	while(1){

		cin>>p;
		if(p=="#") break;

		now=0;
		for(int i=0;i<p.size()&&now!=-1;i++){
			now=map[now][p[i]-'0'];
		}

		if(now==5) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}

}

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

int x,y,c;
int field[10][10];
bool is_field[10][10];

void initis_field()
{
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			is_field[i][j] = false;
		}
	}
}

void check_field(int x,int y)
{
	if(field[x][y] == c)
		is_field[x][y] = true;
	int vx[4] = {-1,0,1,0};
	int vy[4] = {0,-1,0,1};
	for(int i=0;i<4;i++){
		if(is_field[x+vx[i]][y+vy[i]]==false && c == field[x+vx[i]][y+vy[i]] )
			check_field(x+vx[i],y+vy[i]);
	}
}

int counting()
{
	int count = 0;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			if(is_field[i][j] == true)
				count++;
		}
	}
	return count;
}

void change_tile(int id,int x,int y,int before)
{
	field[x][y] = id;
	int vx[4] = {-1,0,1,0};
	int vy[4] = {0,-1,0,1};
	for(int i=0;i<4;i++){
		if(field[x+vx[i]][y+vy[i]]==before)
			change_tile(id,x+vx[i],y+vy[i],before);
	}
}

int change(int id,int depth)
{
	int tile_num = 0;
	initis_field();
	check_field(1,1);
	tile_num = counting();
	for(int id=1;id<=6;id++){
		if(field[1][1] != id && depth != 0){
			int beforefield[10][10];
			for(int i=0;i<10;i++){
				for(int j=0;j<10;j++){
					beforefield[i][j] = field[i][j];
				}
			}
			change_tile(id,1,1,field[1][1]);
			tile_num = max(tile_num,change(id,depth-1));
			for(int i=0;i<10;i++){
				for(int j=0;j<10;j++){
					field[i][j] = beforefield[i][j];
				}
			}
		}
	}
	return tile_num;
}

int main()
{
	while(cin >> x >> y >> c){
		if(x==0 && y==0 && c==0)
			break;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				field[i][j] = 0;
			}
		}
		for(int i=1;i<=x;i++){
			for(int j=1;j<=y;j++){
				cin >> field[i][j];
			}
		}
		int maxtile = 0;
		maxtile = max(maxtile,change(0,5));
				
		cout << maxtile << endl;
	}
	return 0;
}

Measured memory_bytes: 872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n, m;    cin >> n >> m;
    vector<vector<bool>> g(n, vector<bool>(n, false));
    rep(i, m){
        ll a, b;    cin >> a >> b;
        a--, b--;
        g[a][b] = g[b][a] = true;
    }
    vector<ll> chk(n);
    rep(i, n)   chk[i] = i;
    ll res=0;
    do{
        bool flag=true;
        if(chk[0]) break;
        rep(i, n-1){
            flag &= g[chk[i]][chk[i+1]];
        }
        res += flag;
    }while(next_permutation(ALL(chk)));
    cout << res << endl;
}


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

int main() {
    long N;
    cin >> N;
    int ans = 0;
    
    for(int i = 1; i < N; i++) {
        ans += (N - 1) / i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	ll tot = 0;
	rep(i, n) tot += max(0LL, a[i] - b[i]);
	ll tot1 = 0;
	rep(i, n) tot1 += max(0LL, (b[i] - a[i]) / 2);
	cout << ((tot1 >= tot) ? "Yes" : "No") << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = new int[n];
        int max = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (max < a[i]) {
                max = a[i];
            }
        }
        int result = 0;
        for (int i = 0; i < n; i++) {
            if (max == a[i]) {
                result += a[i] / 2;
                max = -1;
            } else {
                result += a[i];
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 23124
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define next safsafs
#define prev asfgewe

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

const int MAXN = 220 * 1000;

int a[MAXN], prev[MAXN], next[MAXN];

int main () {
//  ios_base::sync_with_stdio(0);
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

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

	for (int i = 0; i < n; ++i) {
		prev[i] = i - 1;
		while (prev[i] >= 0 && a[i] < a[prev[i]]) {
			prev[i] = prev[prev[i]];
		}
	}

	for (int i = n - 1; i >= 0; --i) {
		next[i] = i + 1;
		while (next[i] < n && a[i] < a[next[i]]) {
			next[i] = next[next[i]];
		}
	}

	long long res = 0;
	for (int i = 0; i < n; ++i) {
		res += a[i] * (long long) (i - prev[i]) * (next[i] - i);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))
void solve(){
      ll a;
      cin>>a;
      cout<<a+a*a+a*a*a;
}
int main() {
    ios;
	int t=1;
	//cin>>t;
	while(t--)solve();
 
    
}


Measured memory_bytes: 3644
/* � Ashiq Uddin Pranto
   Department of Computer Science and Engineering
   BATCH 27
   University Of Rajshahi,Bangladesh
*/
#include<bits/stdc++.h>

#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define matrix(x) vector<vector<x>>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 1000000007
#define MOD(a,b) (a%b + b)%b

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main()
{
    //fastio
    ll n;
    sfl(n);
    vll a(n);
    ll cnt = 0;
    for(ll i=0;i<n;i++)
    {
        sfl(a[i]);
    }
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            for(ll k=j+1;k<n;k++)
            {
                if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
                {
                    if((a[i]+a[j]>a[k])&& (a[i]+a[k]>a[j])&& (a[j]+a[k]>a[i]))
                    {
                        cnt++;
                    }
                }
            }
        }
    }
    cout<<cnt;

    return 0;
}

Measured memory_bytes: 3704
t = gets.chomp.split('')

if t[0] == '?' and t.length == 1
  t[0] = 'D'
end

if t[0] == '?' and t.length > 1
  if t[1] == 'D'
    t[0] = 'P'
  elsif t[1] == '?'
    t[0] = 'P'
    t[1] = 'D'
  else
    t[0] = 'D'
  end
end

0.upto t.length-1 do |i|
  if t[i] == '?' and t[i+1] == '?'
    if t[i-1] == 'P'
      t[i] = 'D'
      t[i+1] = 'D'
    else
      t[i] = 'P'
      t[i+1] = 'D'
    end
  else
    if t[i] == '?'
      if t[i-1] == 'P'
        t[i] = 'D'
      elsif t[i+1] == 'D'
        t[i] = 'P'
      else
        t[i] = 'D'
      end
    end
  end
end

puts t.join('')

Measured memory_bytes: 31688
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n;
    cin>>n;
    vector<pair<long long int,long long int>> v(n);
    REP(i,n){
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    pair<long long int, long long int> pre = v[0];
    long long int result = 1;
    FOR(i,1,n){
        if(pre.first+pre.second<=v[i].first-v[i].second){
            result++;
            pre = v[i];
        }else{
            if(pre.first+pre.second>v[i].first+v[i].second){
                pre = v[i];
            }
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
void dfs(string S, vector<pair<char, vector<int>>> &c, int &N){
  if (S[0] != '['){
    c.back().first = S[0];
    N++;
  } else {
    int L = S.size();
    int cnt = 0;
    int p = 0;
    for (int i = 0; i < L; i++){
      if (S[i] == '['){
        cnt++;
      }
      if (S[i] == ']'){
        cnt--;
      }
      if (S[i] == '-' && cnt == 1){
        p = i;
        break;
      }
    }
    int v = c.size() - 1;
    c[v].second.push_back(c.size());
    c.push_back(make_pair(' ', vector<int>(0)));
    dfs(S.substr(1, p), c, N);
    c[v].second.push_back(c.size());
    c.push_back(make_pair(' ', vector<int>(0)));
    dfs(S.substr(p + 1, L - 1), c, N);
  }
}
int main(){
  string S;
  cin >> S;
  vector<pair<char, vector<int>>> c;
  c.push_back(make_pair(' ', vector<int>(0)));
  int N = 0;
  dfs(S, c, N);
  map<char, int> mp;
  for (int i = 0; i < N; i++){
    char a;
    int v;
    cin >> a >> v;
    mp[a] = v;
  }
  int M = c.size();
  vector<int> p(M, -1);
  for (int i = 0; i < M; i++){
    for (int j : c[i].second){
      p[j] = i;
    }
  }
  vector<int> cnt(M, 0);
  bool ok = true;
  for (int i = 0; i < M; i++){
    if (c[i].first != ' '){
      int v = i;
      int n = mp[c[i].first];
      cnt[v]++;
      for (int j = 0; j < n; j++){
        if (v == 0){
          ok = false;
          break;
        }
        v = p[v];
        cnt[v]++;
      }
    }
  }
  for (int i = 0; i < M; i++){
    if (cnt[i] != 1){
      ok = false;
    }
  }
  if (ok){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3192
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

set<lint> divisor(lint N){
    set<lint> res;
    for(int i=1;i<=1100000;i++){
        if(N%i==0){
            res.insert(i);
            res.insert(N/i);
        }
    }
    return res; 
}

int main(void){
    lint N;
    cin >> N;
    lint ans=0;
    set<lint> div[2];
    div[0]=divisor(N);
    div[1]=divisor(N-1);
    rep(i,2) div[i].erase(1);
    ans+=div[1].size();
    while(!div[0].empty()){
        auto itr=div[0].begin();
        lint num=*itr;
        div[0].erase(itr);
        lint n=N;
        while(n%num==0) n/=num;
        if(n%num==1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl b(n),c(n);
  ll ans=0;
  rep(i,n){
    cin >> b[i];
    b[i]--;
  }
  rep(i,n){
    for(ll j=n-i-1;j>=0;j--){
      if(b[j]==j){
        c[n-1-i]=b[j]+1;
        FOR(k,j,n-1){
          b[k]=b[k+1];
        }
        break;
      }
      else if(j==0){
        ans=1;
      }
    }
  }
  if(ans){
    cout << -1 << endl;
  }
  else{
    rep(i,n){
      cout << c[i] << endl;
    }
  }
}

Measured memory_bytes: 256