akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/math>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
using namespace std;
using namespace atcoder;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

template <typename T>
class SegmentTree {
    using F = function<T(T, T)>;
    int n;
    F f;
    T t;
    vector <T> dat;
public:
    SegmentTree(F f, T t) : f(f), t(t) {}
    void init(int n_) {
        n = 1;
        while (n < n_) n <<= 1;
        dat.assign(n << 1, t);
    }
    void build(const vector <T> &v) {
        auto n_ = (int)v.size();
        init(n_);
        for (int i = 0; i < n_; i++) dat[n + i] = v[i];
        for (int i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
    }
    //k番目の値をxに変更する。
    void set_val(int k, T x) {
        dat[k += n] = x;
        while (k >>= 1) dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }
    //[a,b)に対してfを適用する。
    T query(int a, int b) {
        T vl = t, vr = t;
        for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) vl = f(vl, dat[l++]);
            if (r & 1) vr = f(dat[--r], vr);
        }
        return f(vl, vr);
    }
};

int main(){
  //using namespace std;
  
  long long n, k;
  cin>>n>>k;
  long long a[n];
  REP(i, n) cin>>a[i];
  
  auto f = [](long long a, long long b) { return max(a, b); };
  SegmentTree<long long> seg(f, 0LL);
  seg.build(vector<long long>(300'010, 0LL));
  
  for(int i = n - 1; i >= 0; i--){
    if(i == n - 1){
      seg.set_val(a[i], 1);
      continue;
    }
    long long l = max(0LL, a[i] - k);
    long long r = min(300'000LL, a[i] + k);
    long long maxlen = seg.query(l, r + 1) + 1;
    seg.set_val(a[i], maxlen);
  }
  long long ans = seg.query(0, 300'005);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 16264
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int p[n],pmax=0,cntr=0;
    for(int i=0; i<n; i++){
        cin>>p[i];
        if(pmax==0 || p[i]<=pmax){
            cntr++;
            pmax=p[i];
        }
    }
    cout<<cntr<<endl;
    return 0;
}

Measured memory_bytes: 4376
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
    double a, b, c, d, e, f,x,y;

    while (cin>>a>>b>>c>>d>>e>>f)
    {
        x = (c*e-b*f) / (a*e-b*d);
        y = (a*f-c*d) / (a*e - b*d);

        if (x == 0){ x = 0; }
        if (y == 0){ y = 0; }
        printf("%.3f %.3f\n", x, y);
    }

    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

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

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int H, W;
    
    while (in.hasNext()) {
      StringBuilder odd  = new StringBuilder();
      StringBuilder even = new StringBuilder();
      StringBuilder total = new StringBuilder();
      String crlf = System.getProperty("line.separator");
      H = in.nextInt();
      W = in.nextInt();
      if(H == 0 && W == 0) break;
      
      for (int w = 0; w < W; w++) {
        if (w % 2 == 1) { 
          odd.append("#");
          even.append(".");
        } else {
          odd.append(".");
          even.append("#");
        }
      }
      odd.append(crlf);
      even.append(crlf);
      
      for (int h = 0; h < H; h++) {
        if (h % 2 == 1) total.append(odd);
        else            total.append(even);
      }
      System.out.println(total.toString());
    }
  }
}

Measured memory_bytes: 18372
N = int(input())
S = input()

wnums = [0]
enums = [0]
for i in range(0, N-1):
    if S[i] == 'W':
        wnums.append(wnums[i]+1)
    else:
        wnums.append(wnums[i])

j=0
for i in range(N-1, 0, -1):
    if S[i] == 'E':
        enums.append(enums[j]+1)
    else:
        enums.append(enums[j])
    j += 1

ans = 3*10**5
num = 0
for i in range(N):
    num = wnums[i] + enums[N-i-1]
    if ans > num:
        ans = num
    num = 0
print(ans)

Measured memory_bytes: 18080
# coding: utf-8


def solve(*args: str) -> str:
    x, y = map(int, args[0].split())

    count = 0
    while x <= y:
        count += 1
        x *= 2

    return str(count)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
map<ll,ll> ma;
ll a[50]={1,2,4,5,8,10,13,14,18,21,26,28,33,36,40,41,46,50,57,60,68};
ll solve(ll xx){
    if(xx<=20) return a[xx];
    if(ma[xx]) return ma[xx];
    if(xx%2) return ma[xx]=(2*solve(xx/2)%mod+solve(xx/2-1)%mod)%mod;
    else return ma[xx]=(2*solve(xx/2-1)%mod+solve(xx/2)%mod)%mod;
}
int main(){
    ll n;
    scanf("%lld",&n);
    ll ans=solve(n);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

vector<bool> flag_prime(ll max){
    vector<bool> flag(max,true);

    flag[0] = false;
    flag[1] = false;
    for(int i = 2; i*i < max+1; i++){
        if(flag[i]){
            for(int j = 2; i*j < max+1; j++) flag[i*j] = false;
        }
    }

    return flag;
}

vector<int> num_prime(int max){
    vector<int> num;
    vector<bool> flag = flag_prime(max);

    for(int i = 0; i < max+1; i++){
        if(flag[i]) num.push_back(i);
    }

    return num;
}

int main(){
    int max = 1e6;
    vector<bool> flag = flag_prime(max);
    vector<int> cnt(max);
    int now = 0;
    for(int i = 0; i < max; i++){
        if(flag[i] && flag[(i+1)/2]) now++;
        cnt[i] = now;
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int l,r;
        cin >> l >> r;
        l--;
        cout << cnt[r]-cnt[l] << endl;
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin >> d[i];
  }
  sort(d.begin(), d.end(), greater<int>());
  int ans;
  ans = N;
  for(int i=0; i<N-1; i++){
    if(d[i] == d[i+1]){
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np
n,m = map(int,input().split())
a = np.array([list(input()) for _ in range(n)])
b = np.array([list(input()) for _ in range(m)])
flg = 0
for i in range(n-m+1):
  for j in range(n-m+1):
    if (a[i:i+m,j:j+m] == b).all():
      flg = 1
print("Yes" if flg == 1 else "No")

Measured memory_bytes: 12436
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 2005

int N;
int L[SIZE];

int main(){

	scanf("%d",&N);
	for(int i = 0; i < N; i++){

		scanf("%d",&L[i]);
	}
	sort(L,L+N);

	int ans = 0;
	int left,right,mid;
	int range_L,range_R;

	for(int a = 0; a < N-2; a++){
		for(int b = a+1; b < N-1; b++){
			left = b+1,right = N-1,mid = (left+right)/2;
			range_L = -1;
			while(left <= right){

				if(L[mid] > L[b]-L[a]){

					range_L = mid;
					right = mid-1;

				}else{

					left = mid+1;
				}
				mid = (left+right)/2;
			}
			if(range_L == -1)continue;

			left = b+1,right = N-1,mid = (left+right)/2;
			range_R = -1;
			while(left <= right){

				if(L[mid] < L[a]+L[b]){

					range_R = mid;
					left = mid+1;

				}else{

					right = mid-1;
				}
				mid = (left+right)/2;
			}
			if(range_R == -1)continue;

			ans += range_R-range_L+1;
		}
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(a, b) for(int unsafe_cnt=a; unsafe_cnt < b;unsafe_cnt++)
#define fn auto
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
void iput(int input) {put(input);}

fn main() -> int {
  string a, b, c;
  bool bl=true;
  cin >> a >> b >> c;
  bl &= a[a.size() - 1] == b[0] ? true : false;
  bl &= b[b.size() - 1] == c[0] ? true : false;
  if(bl){put("YES");}else{put("NO");}
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
typedef pair<int, P>PP;
constexpr long long inf = 1e17;
constexpr int mod = 1000000007;
vector<string>c;
vector<vector<int>>dist;
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
signed main() {
	int h, w, k; cin >> h >> w >> k;
	int xa, ya, xb, yb; cin >> xa >> ya >> xb >> yb;
	xa--; xb--; ya--; yb--;
	c.resize(h);
	rep(i, h)cin >> c[i];
	dist.resize(h);
	rep(i, h) {
		dist[i].resize(w);
		rep(j, w)dist[i][j] = inf;
	}

	queue<PP>Q;
	Q.push(PP(0, P(xa, ya)));
	dist[xa][ya] = 0;
	while (Q.size()) {
		PP p = Q.front(); Q.pop();
		int vi = p.second.first, vj = p.second.second;
		if (dist[vi][vj] < p.first)continue;
		rep(i, 4) {
			for (int j = 1; j <= k; j++) {
				int ni = vi + dx[i] * j, nj = vj + dy[i] * j;
				if (0 <= ni && ni < h && 0 <= nj && nj < w&&c[ni][nj] == '.'&&dist[ni][nj]>dist[vi][vj]) {
					if (dist[ni][nj] > dist[vi][vj] + 1) {
						dist[ni][nj] = dist[vi][vj] + 1;
						Q.push(PP(dist[ni][nj], P(ni, nj)));
					}
				}
				else break;
			}
		}
	}
	if (dist[xb][yb] == inf)dist[xb][yb] = -1;
	cout << dist[xb][yb] << endl;
}


Measured memory_bytes: 15284
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
typedef  long long ll;
const int maxn=2e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int a[maxn];
int main()
{
    int n;
    cin>>n;
    int num=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        num^=a[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(i!=1) printf(" %d",a[i]^num);
        else printf("%d",a[i]^num);
    }
    return 0;
}


Measured memory_bytes: 4472
# F - Bracket Sequencing

N = int(input())
L = []
R = []
for _ in range(N):
    S = list(str(input()))
    len_S = len(S)
    L_d = 0
    L_min_d = 0
    R_d = 0
    R_min_d = 0
    for i in range(len_S):
        if S[i] == '(':
            L_d += 1
        else:
            L_d -= 1
            L_min_d = min(L_min_d, L_d)
        if S[len_S-i-1] == ')':
            R_d += 1
        else:
            R_d -= 1
            R_min_d = min(R_min_d, R_d)
    if L_d >= 0:
        L.append((L_d, L_min_d))
    else:
        R.append((R_d, R_min_d))

L.sort(key=lambda x: x[1], reverse=True)
R.sort(key=lambda x: x[1], reverse=True)

ans = 'Yes'
l_now = 0
for d, min_d in L:
    if l_now + min_d < 0:
        ans = 'No'
        break
    else:
        l_now += d

r_now = 0
for d, min_d in R:
    if r_now + min_d < 0:
        ans = 'No'
        break
    else:
        r_now += d

if l_now != r_now:
    ans = 'No'

print(ans)

Measured memory_bytes: 174828
#include <stdio.h>

int main(){

    int n,i,j,k,b,f,r,v,count[10][10][10]; 
 
  	 
    for(i=1;i<=4;++i){
	  for(j=1;j<=3;++j){
	    for(k=1;k<=10;++k){		 
	     count[i][j][k]=0;
       }
	  }
    }	 	  
      
 	 scanf("%d",&n);
 
 	 for(j=0;j<n;++j){
	  scanf("%d",&b); // ?????????????????¨???
	  scanf("%d",&f);
  	  scanf("%d",&r);
	  scanf("%d",&v);
	  
     //printf("%c %d \n",sut,num);
	
	  count[b][f][r]+=v;    

	 }	 
	
    for(i=1;i<=4;++i){
	  for(j=1;j<=3;++j){ 
		for(k=1;k<=10;++k){  
        printf (" %d",count[i][j][k]);
        if (k==10) printf ("\n");
      }
        if ((j==3)&&(i!=4)) printf ("####################\n");
	 }
    }	

	return 0;
}

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

int main()
{

    int n, k, a, count { 0 };
    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a >= k)
            count++;
    }
    cout << count << '\n';

    return 0;
}


Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


N = int(input())

table = list(map(int,input().split()))

swap_count = 0

for i in range(len(table)-1):
    for k in range(len(table)-1,i,-1):
        if table[k] < table[k-1]:
            table[k],table[k-1] = table[k-1],table[k]
            swap_count += 1

print(' '.join(map(str,table)))
print("%d"%(swap_count))



Measured memory_bytes: 6364
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define loop(x) for(int i=0;i<x;i++)
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra
ll mod=1e9 + 7;

// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }
 int h,w;
 string s[1005];
 int visited[1004][1005];
 int a[]={0,1};
 int b[]={1,0};
  ll dp[1003][1005];
 ll solve(int x,int y){
 	// cout<<x<<y<<endl;
  if(x==h-1 && y==w-1)
    return 1;
   
  if(dp[x][y]!=-1)
  {//cout<<"yes"<<endl;
    return dp[x][y]%mod;
  }
  ll ans=0;
  for(int i=0;i<2;i++){
    if((x+a[i]<h) && (y+b[i]<w) && (s[x+a[i]][y+b[i]]=='.') ){
      ans=(ans+solve(x+a[i],y+b[i]))%mod;
    }
  }
  return dp[x][y]=(ans%mod);
}
int main(){
    IOS;   
    // int n;
    
    cin>>h>>w;
    // string s[h+1];
    memset(dp,-1,sizeof dp);
    // memset(visited,0,sizeof visited);
    loop(h)cin>>s[i];
    cout<<(solve(0,0)%mod)<<endl;
   
}
// https://atcoder.jp/contests/dp/tasks/dp_d
// https://codeforces.com/contest/1131/problem/C
 
//csjosh

Measured memory_bytes: 9600
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int64_t GCD(int64_t a, int64_t b) {
  if (a < b)
    std::swap(a, b);
  int64_t r;
  while (1) {
    r = a % b;
    if (r == 0) {
      return b;
    } else {
      a = b;
      b = r;
    }
  }
}

int64_t LCM(int64_t a,int64_t b){
  return a*b/GCD(a,b);
}

int64_t ThreeLCM(int64_t a,int64_t b,int64_t c){
  return LCM(LCM(a,b),c);
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int64_t a;
  cin>>a;
  const int64_t MAX=3500;
  for(int64_t h=1;h<MAX;h++){
    for(int64_t n=1;n<=MAX;n++){
      int64_t three_lcm=ThreeLCM(a,h,n);
      int64_t bunsi=4*three_lcm/a-three_lcm/h-three_lcm/n;
      if(bunsi>0&&three_lcm%bunsi==0){
        cout<<h<<" "<<n<<" "<<three_lcm/bunsi<<endl;
      return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    cout << max(a*b,c*d) << endl;

    return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    string n;
    cin >> n;
    int sum = 0;
    rep(i, sz(n)) sum += (n[i] - '0');
    if (sum%9==0) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3752
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    int a,b;
    string s;
    cin >> a >> b >> s;
    rep(i,0,s.size()){
        if(i == a){
            if(s[i] != '-'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(!(s[i] >= '0' && s[i] <= '9')){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        int[] alphabet = new int[26];
        for(int i = 0; i < S.length(); i++){
            alphabet[S.charAt(i) - 'a']++;
        }
        for(int i = 0; i < 26; i++){
            if(alphabet[i] == 0){
                System.out.println((char)('a' + i));
                return;
            }
        }
        System.out.println("None");
    }
}


Measured memory_bytes: 24076
#include<iostream>
	#include<cstdio>
	#include<vector>
	using namespace std;
	const int MAX_N=100000+100;
	long long int INF=2e10;
	vector<int> w,from,to;
	long long d[MAX_N];
	bool ans=false;
	bool relax(int e){
		if(d[to[e]]>d[from[e]]+w[e] && d[from[e]]!=INF){
			d[to[e]]=d[from[e]]+w[e];
			return true;
		}
		return false;
	}
	int main(){
		int n,m,s,a,b,c;
		cin>>n>>m>>s;
		fill(d,d+n+10,INF);
		d[s]=0;
		for(int i=0;i<m;i++){
			cin>>a>>b>>c;
			from.push_back(a);
			to.push_back(b);
			w.push_back(c);
		}
		for(int i=0;i<n;i++){
			ans=false;
			for(int j=0;j<m;j++){
				if(relax(j)==true){
					ans=true;
				}
			}
		}
		if(ans==true){
			cout<<"NEGATIVE CYCLE"<<endl;
			return 0;
		}
		for(int i=0;i<n;i++){
			if(d[i]==INF){
				cout<<"INF"<<endl;
			}
			else
				cout<<d[i]<<endl;
		}
	}
	

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

#define       pb                 push_back
#define       mx                 200005
#define       MOD                1000000007
#define 	  optimize           ios::sync_with_stdio(0);cin.tie(0);
#define 	  inf                0x3f3f3f3f
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);

using namespace std;

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

int main()
{
    ll n, ans;

    cin >> n;

    cout << (((n*n)+n)/2)-n << endl;


    return 0;
}


Measured memory_bytes: 256
from collections import deque

k = int(input())

a = deque([9,8,7,6,5,4,3,2,1])
current_num = 0

for i in range(k):
  current_num = a.pop()
  current_str = str(current_num)
  current_last = int(current_str[-1])

  up = ""  
  mid = current_str + str(current_last)
  down = ""

  if current_last >= 0 and current_last <= 8:
    up = current_str + str(current_last + 1)

  if current_last >= 1 and current_last <= 9:
    down = current_str + str(current_last - 1)
  
  if len(down) != 0:
    a.appendleft(down)

  a.appendleft(mid)

  if len(up) != 0:
    a.appendleft(up)

print(current_num)

Measured memory_bytes: 69084
def main():
    N = int(input())
    ans = [0 for i in range(N + 1)]

    for x in range(1, 100):
        for y in range(1, 100):
            for z in range(1, 100):
                s = x**2 + y**2 + z**2 + x*y + y*z + z*x

                if 1 <= s <= N:
                    ans[s] += 1

    for i in range(1, N + 1):
        print(ans[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 9136
#include <stdio.h>
void main (){
  int k,i,j=0;
  scanf("%d",&k);
  for(i=0;i<3;i++){
    if(k%10==7)j=1;
    k/=10;
  }
  if(j==1)printf("Yes");
  else printf("No");
  
}

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

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s.push_back('a');
    char before = s[0];
    int cnt = 0;
    vector<int> v;
    if (*s.begin() == '0') v.push_back(0);
    int zero = 0;

    for (auto c : s) {
        if (c == before) {
            cnt++;
        } else {
            v.push_back(cnt);
            if (before == '0') zero++;
            cnt = 1;
            before = c;
        }
    }
    if (zero <= k) {
        cout << n << endl;
        return 0;
    }

    s.pop_back();
    if (*s.rbegin() == '0') v.push_back(0);

    int size = v.size();
    int csum[size + 1];
    csum[0] = 0;
    for (int i = 1; i <= size; ++i) {
        csum [i] = csum[i - 1] + v[i - 1];
    }
    int Max = 0;

    for (int l = 0, r = 2 * k + 1; r <= size; l += 2, r += 2) {
        Max = max(Max, csum[r] - csum[l]);
    }
    cout << Max << endl;
    return 0;
}



Measured memory_bytes: 1272
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

ll powMod(ll x, ll n) {
  if (n == 0) return 1;
  ll r = powMod(x, n / 2);
  if (n % 2 == 0) return (r * r) % MOD;
  return (r * r % MOD) * x % MOD;
}


int main(void) {

  int n, m;
  cin >> n >> m;
  int c[200010] = {}, f[200010] = {};
  int p; string s;
  int ac = 0, pe = 0;
  rep(i, m) {
    cin >> p >> s;
    if (s == "WA") c[p]++;
    else {
      if (f[p] == 0) {
	ac++;
	pe += c[p];
	f[p]++;
      }
    }
  }
  cout << ac << " " << pe << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    int a[N];
    for(int i = 0; i < N; i++) cin >> a[i];

    int sm = 0;
    for(int i = 0; i < N; i++) sm += a[i];

    int cnt = 0;
    for(int i = 0; i < N; i++) {
        if(a[i] * 4 * M >= sm) {
            cnt++;
        }
    }

    if(cnt >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  unsigned count = 0;
  
  for (unsigned x=a/100*100;x<=b;x+=100) {
    unsigned xx = x+(x/10000)+(x/1000%10*10);
    //cerr << xx << endl;
    if (xx >= a && xx <= b)
      ++count;
  }

  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,t = LI()
    a = sorted([I() for _ in range(n)])
    r = 1
    i = 0
    for j in range(n):
        while a[i] < a[j] - t:
            i += 1
        r *= j-i+1
        r %= mod

    return r



print(main())



Measured memory_bytes: 14072
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){

  int n;
  int i;

  scanf("%d", &n);

  int a[n];

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

  for(i = n - 1; i >= 1; i--){
    printf("%d ", a[i]);
  }
  printf("%d\n", a[0]);
  
  return 0;
}


Measured memory_bytes: 2060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        arr: [i8; 5],
        k: i8
    );
    if (arr[4] - arr[0]) > k {
        println!(":(");
    } else {
        println!("Yay!");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#define NIL -1
int P[10000],L[10000],R[10000];

void preParse(int u){
    if(u==NIL)return;
    printf(" %d",u);
    preParse(L[u]);
    preParse(R[u]);
}

void inParse(u){
    if(u==NIL)return;
    inParse(L[u]);
    printf(" %d",u);
    inParse(R[u]);
}

void postParse(u){
    if(u==NIL)return;
    postParse(L[u]);
    postParse(R[u]);
    printf(" %d",u);
}

int main()
{
    int i,n,s,l,r,root;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        P[i]=NIL;
        L[i]=NIL;
        R[i]=NIL;
    }
    
for(i=0;i<n;i++){
    scanf("%d%d%d",&s,&l,&r);
    L[s]=l;
    R[s]=r;
    if(l!=NIL)P[l]=s;
    if(r!=NIL)P[r]=s;
}

for(i=0;i<n;i++)if(P[i]==NIL)root=i;
    
printf("Preorder\n");
preParse(root);
printf("\n");
printf("Inorder\n");
inParse(root);
printf("\n");
printf("Postorder\n");
postParse(root);
printf("\n");

    return 0;
}



Measured memory_bytes: 2136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <random>

using namespace std;
constexpr int D = 365;
vector<int> c(26);
vector< vector<int> > s(D, vector<int>(26));
vector<int> num(D), ans(D);

int score() {
    int sat = 0;
    vector<int> last(26);
    for (int d=0; d<D; d++) {
        int j = num[d] - 1;
        last[j] = d + 1;
        for(int i=0; i<26; i++) {
            sat -= (d + 1 - last[i]) * c[i];
        }
        sat += s[d][j];
    }
        // assert(1 <= out[d] and out[d] <= 26)
        // j = out[d] - 1
        // last[j] = d + 1
        // for i in range(26):
        //     sat -= (d + 1 - last[i]) * c[i]
        // sat += s[d][j]
    return sat;
}

int main(void) {
    int g;
    cin >> g;
    for(int i=0; i<26; i++) {
        cin >> c[i];
    }
    for(int i=0; i<D; i++) {
        for(int j=0; j<26; j++) {
            cin >> s[i][j];
        }
    }

    int temp = numeric_limits<int>::min();
    random_device seed_gen;
    default_random_engine engine(seed_gen());
    uniform_int_distribution<> dist(1, 26);
    for(int a=0; a<10000; a++) {
        for(int i=0; i<D; i++) {
            num[i] = dist(engine);
        }
        if(int sat = score(); sat > temp) {
            ans = num;
            temp = sat;
        }
    }
    

    for(int i=0; i<D; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3676
#include <iostream>
using namespace std;
int main(){
  int x, y;
  while(1){
    cin >> x >> y;
    if (x == 0 && y == 0) break;
    if (x < y)
      cout << "" << x << " " << y << endl;
    else
      cout << "" << y << " " << x << endl;
  }
  return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> x(N), y(N);
  map<int, map<int, int> > G;
  for(int i = 0; i < N; ++i) {
    cin >> x[i] >> y[i];
    cin >> G[y[i]][x[i]];
  }
  int res = 0;
  for(int i = 0; i < N; ++i) {
    res = max(res, G[y[i]][x[i]] + G[y[i]][x[i]+1]
              + G[y[i]+1][x[i]] + G[y[i]+1][x[i]+1]);
    res = max(res, G[y[i]][x[i]] + G[y[i]][x[i]-1]
              + G[y[i]+1][x[i]] + G[y[i]+1][x[i]-1]);
  }
  cout << res << " / " << 1 << endl;
  return 0;
}

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

int n;
int c;
int s;
int res;

int main(){
  cin >> n;
  for(int i = 1; i <= n; ++i){
    c = 0;
    s = i;
    while(s > 0){
      c += 1;
      s /= 10;
    }
    if(c % 2 == 1){
      res += 1;
    }
  }
  cout << res << endl;
}

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

int min(int a, int b){
  if(a>b)return b;
  else return a;
}

int main(){
  int n,x,y;
  cin >> n >> x >> y;
  x--;y--;
  int ans[n];
  rep(i,n)ans[i]=0;
  rep(i,n-1){
    for(int j=i+1;j<n;j++){
      ans[min(abs(i-j),abs(y-j)+abs(x-i)+1)]++;
    }
  }
  for(int i=1;i<n;i++){
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
typedef pair<ll,ll> P;
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,minu=0,zero=0,absmin=1e9;cin>>n;
  lvector a(n,0);
  rep(i,n) {
    cin>>a[i];
    if(a[i]==0) zero++;
    if(a[i]<0) minu++;
    if(absmin>abs(a[i])) absmin=abs(a[i]);
  }
  ll ans=0;
  rep(i,n) ans+=abs(a[i]);
  if(minu%2==1&&zero==0) ans-=2*absmin;
  print(ans);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    ll a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a, a+n);

    ll H[2]; H[0]=0; H[1]=0;
    int k=0;
    for(int i=n-1; i>=1; i--) {
        if(a[i]==a[i-1]) H[k++]=a[i--];
        if(k==2) {
            cout << H[0]*H[1] << endl;
            return 0;
        }
    }

    cout << '0' << endl;
    return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

int n, m;
map<string, string> hm;
string s, t;

int main()
{
  while((cin >> n) && n){
    hm.clear();
    rep(i, n){
      cin >> s >> t;
      hm[s] = t;
    }

    cin >> m;
    rep(i, m){
      cin >> s;
      cout << (hm[s] != "" ? hm[s] : s);
    }

    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1216
//・Except for the beginning and the end of special commands, Gururin does not face north.
//より、現在向いている方向northで文字列を分けるとよさそう。計算量の工夫はいらない。
#include <iostream>
#include <string>
#include <vector>
using namespace std;

string s;
vector<int> t;

int main() {
	int i, j;
	int dir = 0;
	
	cin >> s;
	for (i = 0; i < s.length(); i++) {
		if (dir == 0) t.push_back(i);
		if (s[i] == 'R') dir = (dir + 1) % 4;
		else dir = (dir + 3) % 4;
	}
	if (dir == 0) t.push_back(i);
	
	int ans = 0;
	for (i = 0; i < (int)t.size() - 1; i++) {
		bool used[4] = {false};
		dir = 0;
		for (j = t[i]; j < t[i + 1]; j++) {
			if (s[j] == 'R') {
				dir = (dir + 1) % 4;
				used[dir] = true;
			}
			else { dir = (dir + 3) % 4; }
		}
		for (j = 0; j < 4; j++) if (!used[j]) break;
		if (j == 4) ans++;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3244
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] inA = Console.ReadLine().Split(' ');
            string[] inB = Console.ReadLine().Split(' ');

            int[] a = new int[N];
            int[] b = new int[N];

            for (int i = 0; i < N; i++)
            {
                a[i] = int.Parse(inA[i]);
                b[i] = int.Parse(inB[i]);
            }

            int ans = 0;
            for (int s = 0; s < N; s++)
            {
                int tmp = 0;
                for (int i = 0; i < N; i++)
                {
                    if(i <= s)
                    {
                        tmp += a[i];
                    }
                    if (s <= i)
                    {
                        tmp += b[i];
                    }
                }

                ans = Math.Max(ans, tmp);
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int calc(int x)
{
    int ret = 0;
    // 100で割り切れるまで割る
    while (x % 100 == 0) {
        x /= 100;
        ++ret;
    }
    return ret;
}

int main()
{
    int D, N; cin >> D >> N;
    int cnt = 0, val = 0;
    while (cnt < N) {
        ++val;
        // valが100で何回割れるかをcalcで計算
        // それがDと等しいならばインクリメント
        if (calc(val) == D) ++ cnt;
    }
    cout << val << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	vector<int> pos,neg;
	for(auto i:a)
	{
		if(i>=0)pos.push_back(i);
		else neg.push_back(i);
	}

	sort(neg.rbegin(),neg.rend());
	sort(pos.begin(),pos.end());
	n=neg.size();int p=pos.size();

	int ans=1e18;
	vector<int> left(n+1),right(p+1);
	for(int i=1;i<=n;i++)left[i]=-neg[i-1];
	for(int i=1;i<=p;i++)right[i]=(pos[i-1]);


	for(int x=0;x<=k;x++)
	{
		if(k-x>n or x>p)continue;
//		cout<<x<<" "<<k-x<<"\n";
		ans=min(ans,2*right[x]+left[k-x]);
		ans=min(ans,2*left[k-x]+right[x]);
//		cout<<ans<<"\n";
	}
	cout<<ans;
}

Measured memory_bytes: 5636
#!/usr/bin/env python3
# -*- coding: utf-8 -*-



def main():
    Q, H, S, D = map(int, input().split())
    N = int(input())

    # 1Lあたりの価格に換算
    QN = 4*Q
    HN = 2*H
    SN = S
    DN = D/2.0

    # 2Lサイズが一番安い場合のみ端数処理が必要
    cost = 0
    if min(QN, HN, SN, DN) == DN:
        cost += N//2 * D
        cost += N%2  * min(QN, HN, SN)
    else:
        cost += N * min(QN, HN, SN)

    print(cost)

if __name__ == "__main__": main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

ll factorial(){

}

int main(int argc, const char * argv[]) {
	int n;
	cin >> n;
	ll a[n];
	REP(i,n){
		cin >> a[i];
	}
	sort(a,a+n);
//	REP(i,n) errln(a[i]);
	ll aj = a[n-1];
	ll ideal_ai = (aj+1)/2;
	ll ai;
	errln(aj);
	errln(ideal_ai);
	if(a[n-2] <= ideal_ai){
		ai = a[n-2];
	}else if(a[0] >= ideal_ai){
		ai = a[0];
	}else{
		ll c1 ,c2;
		REP(i,n-1){
			if(a[i]==ideal_ai){
				ai = ideal_ai;
				break;
			}
			if(a[i]>ideal_ai){
				c1 = a[i-1];
				c2 = a[i];
				if(abs(c2 - ideal_ai) <abs( ideal_ai - c1)){
					ai = c2;
				}else{
					ai = c1;
				}
				break;
			}
		}
	}
	printf("%d %d\n",aj,ai);
	return 0;

}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int judge(int x,int y)
{int z=x-y;
 if(z>0)
 return z;
 else
 return 0;}
int main()
{int a,b;
 cin>>a>>b;
 cout<<judge(a,b);
system ("pause");
return 0;
}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7
//vvll v(n,vll(m)) n行m列
//A.erase(A.begin()+i) 配列Aのi番目を消せる

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll n;
  cin>>n;
  vll v(n);
  FOR(i,0,n){
    cin>>v[i];
  }
  vll ans(n);
  bool D=false,d=true;
  for(ll i=n-1;i>=0;i--){
    for(ll j=i;j>=0;j--){
    //  co(v[j]);
      if(v[j]==j+1){
    //    co(v[j]);
        ans[i]=v[j];
        v.erase(v.begin()+j);
        D=true;
        break;
      }
    }
    if(D){
      D=false;
    }
    else{
      d=false;
      break;
    }
  }
  if(d){
    FOR(i,0,n){
      co(ans[i]);
    }
  }
  else{
    co(-1);
  }
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int ans=0;
	cin>>s;
	int n=s.size();
	int l=0; int r=n-1;
	while(l<=r)
	{
		if(s[l]==s[r])
		{
			l++; r--;
			continue;
		}
		if(s[l]!='x' && s[r]!='x')
		{
			cout<<-1<<endl;
			return 0;
		}
		if(s[l]=='x')
		{
			l++;
			ans++;
			continue;
		}
		if(s[r]=='x')
		{
			r--;;
			ans++;
			continue;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n;
    cin>>n;
    vi a(n*3+1);
    for(int i=1;i<=3*n;i++) cin>>a[i];
    ll mx=0,mi=0;
    priority_queue<int,vector<int>,greater<int>> ql;
    multiset<pi> qr,re;
    for(int i=1;i<=n;i++) ql.push(a[i]),mx+=a[i];
    for(int i=n+1;i<=3*n;i++)
    {
        qr.insert(make_pair(a[i],i));
        mi+=a[i];
    }
    while(qr.size()>n)
    {
        mi-=(*qr.rbegin()).first;
        re.insert(*qr.rbegin());
        qr.erase(qr.find(*qr.rbegin()));
    }
    ll ans=-0x3f3f3f3f3f3f3f3f;
    for(int i=n+1;i<=2*n+1;i++)
    {
        ans=max(ans,mx-mi);
        if(i==2*n+1) break;
        ql.push(a[i]);
        mx+=a[i];
        mx-=ql.top();
        ql.pop();
        if(re.count(make_pair(a[i],i)))
            re.erase(make_pair(a[i],i));
        if(qr.count(make_pair(a[i],i)))
        {
            mi-=a[i];
            qr.erase(make_pair(a[i],i));
            qr.insert(*re.begin());
            mi+=(*re.begin()).first;
            re.erase(re.begin());
        }
    }
    cout<<ans<<'\n';

}

Measured memory_bytes: 11256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

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

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

	return 0;
}

Measured memory_bytes: 256
n,m = gets.chomp.split().map(&:to_i)
ps = m.times.map{gets.split}

ps.sort_by!{|p,s| p}
account = ps.select{|p,s| s == 'AC'}.map{|p,s| p}.uniq.count

wahash = {}
wahash.default = 0

wacount = 0
ps.each do |p,s|
  next if wahash[p] == -1
  if s == 'WA'
    wahash[p] += 1
  elsif s == 'AC'
    wacount += wahash[p]
    wahash[p] = -1
  end
end

puts [account, wacount].join(' ')


Measured memory_bytes: 33088
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    char a, b;
    cin >> a >> b;
    if(a == 'H') cout << b << endl;
    else if(b == 'D') cout << 'H' << endl;
    else cout << 'D' << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n,m,c;
    scanf("%d %d %d",&n,&m,&c);
    int b[m],a[n][m];
    int count = 0;
    for(int i = 0;i < m;i++)
    scanf("%d ",&b[i]);
    for(int j = 0;j < n;j++){
        for(int i = 0;i < m;i++){
            scanf("%d ",&a[j][i]);
        }
    }
    for(int j = 0;j < n;j++){
        int sum = 0;
        for(int i = 0;i < m;i++){
            sum += a[j][i] * b[i];
        }
        sum += c;
        if(sum > 0)count++;
    }
    printf("%d\n",count);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){

int a,b;

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

if (a == b){

printf("a == b\n");

}

else if (a < b){

printf("a < b\n");

}

else if (a > b){

printf("a > b\n");

}

return 0;

}

Measured memory_bytes: 580
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(){
    int N,M;
    scanf("%d %d",&N,&M);
    int A[M];
    int total=0;
    int ans = 0;
    for(int i = 0;i<M;i++){
        scanf("%d",&A[i]);
        total += A[i];
    }
    if(total > N) ans = -1;
    else ans = N - total;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1760