akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N)
    {
        cin >> A[i];
    }

    ll ans = 1;
    bool isInc = false, isDec = false;
    REP(i, N - 1)
    {
        if (A[i + 1] > A[i])
        {
            if (isDec)
            {
                ans++;
                isDec = false;
            }
            else if (!isInc && !isDec)
            {
                isInc = true;
            }
        }
        else if (A[i + 1] < A[i])
        {
            if (isInc)
            {
                ans++;
                isInc = false;
            }
            else if (!isInc && !isDec)
            {
                isDec = true;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
using i64 = long long;
using p = pair<int,int> ;
#define rep(i,s,e) for(int (i) = (s);i <= (e);(i)++)

int N;

vector<int> x;

vector<int> ans;

int main(){
  cin >> N;
  x.resize(N);
  ans.resize(N);
  rep(i,0,N - 1){
    cin >> x[i];
  }

  vector<p> vec;
  rep(i,0,N - 1) vec.push_back({x[i],i});

  sort(vec.begin(),vec.end());

  rep(i,0,N - 1){
    int index = vec[i].second;

    if(N / 2  <= i){
      ans[index] = vec[N / 2 - 1].first;
    }
    else{
      ans[index] = vec[N / 2].first;
    }
  }

  for(auto an : ans){
    cout << an << endl;
  }

}


Measured memory_bytes: 5488
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N;
  cin >> N;
  vector<ll> h(N);
  rep (i, N) cin >> h[i];

  unsigned long long INF = -1;
  INF >>= 1;
  vector<ll> ans(N, INF);
  ans[0] = 0;

  rep (i,  N) {
    if (i + 1 < N) ans[i + 1] = min(ans[i + 1], ans[i] + abs(h[i] - h[i+1]));
    if (i + 2 < N) ans[i + 2] = min(ans[i + 2], ans[i] + abs(h[i] - h[i+2]));
  }

  cout << ans[N-1] << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(5e5)+5;



int main()
{
    idfc;

    int n;
    cin>>n;

    if(n>=30)
    {
        cout<<"Yes";
    }
    else cout<<"No";


    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int k;
	int a,b;
	cin>>k>>a>>b;
	int cnt=b/k -(a-1)/k;
	if(cnt>0) {
		cout<<"OK"<<endl;
	}
	else{
		cout<<"NG"<<endl;
	}


	return 0;
}


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

class Main {
  static final Scanner in = new Scanner(System.in);
  static int N, K;

  static int[] h;
  static int dp[];
  static final int MOD = 1000000007;
  static int[] pre;

  public static void main(String[] args) throws Exception {
    N = in.nextInt();
    h = new int[N];
    dp = new int[N];

    int old_sum = 0;
    for (int i = 0; i < N; i++){ h[i] = in.nextInt();
  }
  Arrays.fill(dp,-1);

    System.out.println(F(N-1));
  }

  static int F(int i){
    if(i == 0)
      return 0;
    
    if(i == 1)
      return Math.abs(h[0] - h[1]); 
    
    if(dp[i] != -1)
      return dp[i];  
      
    int a = F(i - 1) + Math.abs(h[i-1] - h[i]);
    int b = F(i - 2) + Math.abs(h[i-2] - h[i]);

    dp[i] = Math.min(a,b);
    return dp[i];
  }
}


Measured memory_bytes: 71352
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;

#define MAX 101
int n, c;
int v[MAX];
int w[MAX];

// bottom-up
ll knapsack(){
    ll dp[n+1][c+1];
    for(int i = 0; i <= n; i++){
        dp[i][0] = 0;
    }
    for(int i = 0; i <= c; i++){
        dp[0][i] = 0;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= c; j++){
            if(w[i] > j) dp[i][j] = dp[i-1][j];
            else{
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
            }
        }
    }
    return dp[n][c];
}

int main(){ _
    cin >> n >> c;
    forn(i, n){
        cin >> w[i+1] >> v[i+1];
    }
    cout << knapsack() << '\n';
    return 0;
}

Measured memory_bytes: 82440
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

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

    int f = 0;
    for (int i = 0; i < S.size(); ++i)
    {
        if(S[i] == 'A'){
            f = i;
            break;
        }
    }

    int e = S.size();
    for (int i = S.size(); i >= 0; --i)
    {
        if (S[i] == 'Z')
        {
            e = i;
            break;
        }
    }

    cout << e - f + 1 << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int n;
	while(cin>>n&&n!=0){
		int p,num;
		double BMI,min=10000,h,w;
		for(int i=0;i<n;i++){
			cin>>p>>h>>w;
			BMI=w/((h/100)*(h/100));
			if(min>=abs(BMI-22)){
				if(min!=abs(BMI-22)){
					num=p;
				}
				min=abs(BMI-22);
			}
		}
		cout<<num<<endl;
	}
	return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const long long INF = 1LL << 60;
//const int INF = 1e9+5;

int N;
vector<double> p;
double dp[3100][3100];

int main(){
  cin >> N;
  p.resize(N);
  for(int i=0;i<N;i++) cin >> p[i];
  dp[0][0] = 1.0;

  for(int i=0;i<N;i++){
    for(int j=0;j<=i;j++){
      dp[i+1][j+1] += dp[i][j] * p[i];//表
      dp[i+1][j] += dp[i][j] * (1.0-p[i]);//うら
    }
  }
  double res = 0.0;
  for(int j=(N+1)/2; j<= N;++j) res += dp[N][j];
  cout << fixed << setprecision(12) << res << endl;

}



Measured memory_bytes: 72320
#include<bits/stdc++.h>
#define ll  long long  
#define pb push_back
#define fi first
#define se second
using namespace std;
ll mo=2019;
ll i;
//vector<ll> v[1000001];
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%mo;
p=(p*p)%mo;
k>>=1;
}
return a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	string s;
	cin>>s;
	ll n=s.length();
	map<ll,ll> m;
	ll a[n+1]={0};
	reverse(s.begin(),s.end());
	for(i=0;i<n;i++)
	{
		a[i]=s[i]-'0';
	}
	ll sum[n]={0};
	sum[0]=a[0];
	for(i=1;i<n;i++)
	{
		sum[i]=sum[i-1]+(a[i]*power(10,i))%mo;
		sum[i]%=mo;
	}
	ll ans=0;
	m[0]=1;
	for(i=0;i<n;i++)
	{
		sum[i]%=mo;
			ans+=m[sum[i]];
		m[sum[i]]++;
	}
	cout<<ans;
	//cout<<"No";
	cout<<"\n"; 
 } 
}


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

int main(int argc, char *argv[]){
  string r, a;
  while(std::cin >> r >> a){
    if(r == "0")break;
    int n = r.size();
    map<char, int> hash;
    for (int i = 0; i < n; i++) {
      hash[r[i]] = i;
    }
    int hit = 0, blow = 0;
    for (int i = 0; i < n; i++) {
      if(a[i] == r[i]){
        hit++;
        continue;
      }
      if(hash.count(a[i]) == 1){
        blow++;
      }
    }
    std::cout << hit << " " << blow << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


bool comp(const std::string &a, const std::string &b) {
    if (a[0] == 'B') return true;
    if (b[0] == 'B') return false;
    if (a.size() != b.size()) return a.size() < b.size();
    return a < b;
}


int main() {
    int n, m; std::cin >> n >> m;
    std::vector<int> c = { 0,2,5,5,4,5,6,3,7,6 };
    std::vector<int> a(m);
    for (int i = 0; i < m; i++) std::cin >> a[i];
    std::vector<std::string> dp(n + 1, "B");
    dp[0] = "";
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i + c[a[j]] > n) continue;
            std::string s = dp[i] + (char)(a[j] + '0');
            if (comp(dp[i + c[a[j]]], s)) {
                dp[i + c[a[j]]] = s;
            }
        }
    }
    std::cout << dp[n] << std::endl;
    return 0;
}


Measured memory_bytes: 43648
#include<bits/stdc++.h>
#define N 2
using namespace std;
char s[N+1];
char a[202];
int top=0;
//入栈
void push(char x){
	if(top<N){
		top++;
		s[top] = x;
		return ;
	}
}
int main(){
	cin.getline(a,202);
	for(int i=0;a[i];i++){
		if(a[i]=='C'&&top==0) push(a[i]);
		else if(a[i]=='F'&&top==1) push(a[i]);
	}
	if(top==2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  rep(i,s.size()){
    s.at(i)='1'+'9'-s.at(i);
  }
  cout << s << endl;
}


Measured memory_bytes: 256
N = int(input())
l = [input() for i in range(N)]

name_dir = {"M":0,"A":0,"R":0,"C":0,"H":0}
for name in l:
    for alphabet in name_dir.keys():
        if name[0] == alphabet:
            name_dir[alphabet] += 1

name_counter = list(name_dir.values())
non0_name_counter = [s for s in name_counter if s != 0]

ans = 0
if name_counter.count(0) > 2:
    pass
elif name_counter.count(0) == 2:
    ans = non0_name_counter[0] * non0_name_counter[1] *non0_name_counter[2]
elif name_counter.count(0) == 1:
    for i in range(0,4):
        tmp = [s for s in list(range(0,4)) if s != i]
        ans += non0_name_counter[tmp[0]] * non0_name_counter[tmp[1]] * non0_name_counter[tmp[2]]
elif name_counter.count(0) == 0:
    for i in range(0,4):
        for j in range(i+1,5):
            tmp = [s for s in list(range(0,5)) if s != i and s != j]
            ans += non0_name_counter[tmp[0]] * non0_name_counter[tmp[1]] * non0_name_counter[tmp[2]]
print(ans)

Measured memory_bytes: 9772
// C++(Clang 10.0.0)

//GCC用 ナゾです
//#pragma GCC target("avx")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <stdio.h>
#include <stdlib.h> //rand() 0~RAND_MAX2147483647
#include <math.h>
#include <time.h>   //srand((unsigned int)time(NULL));
#include <unistd.h> //sleep
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <unordered_map>
#include <set>
#include <cassert> //assart(x>=0) -> x<0の時異常終了
#include <numeric>
#include <iterator>
#include <list>
#include <tuple>
#include <queue>

using namespace std;
#define ll long long int
#define FOR(i,min,max) for(ll i=(min);i<(max);i++)
#define FOReq(i,min,max) for(ll i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(ll i=(max)-1;i>=(min);i--)
#define FORREVeq(i,max,min) for(ll i=(max);i>=(min);i--)

#define all(vec) (vec).begin(),(vec).end()

const int MOD=1e9+7;
const int MOD2=998244353;
const int not0=1;
const int INF=2000000001;
const ll INFll=2e18;
//const int MAX_V=10000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INFll || MOD2 || not0){;}
    return 0;
}

#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
//#define br printf("\n");
#define br cout<<"\n";
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}
#define elif else if

#define issame(a,b,c,d) ((a)==(b) and (b)==(c) and (c)==(d))
#define isdiff3(a,b,c) ((a)!=(b) and (b)!=(c) and (c)!=(a))
#define isdiff4(a,b,c,d) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c))
#define isdiff5(a,b,c,d,e) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c) and (e)!=(a) and (e)!=(b) and (e)!=(c) and (e)!=(d))
#define Func3(f,a,b,c) (f)((f)((a),(b)),(c))
#define Func4(f,a,b,c,d) (f)((f)((f)((a),(b)),(c)),(d))

inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
inline ll samepair(ll x){return x*(x-1)/2;}
inline ll  gcd(ll a,ll b){ if(b==0)return a;else return gcd(b,a%b);}//最大公約数 なお一方が0なら答えは他方になるので番兵は０で良い また、負の数もOK -4%3=-1となるため
inline ll  lcm(ll a,ll b){return a*b/gcd(a,b);}//MODやオーバーフローには注意！
//inline ll  ceil(double a){return (ll)a+1;}
//ans = accumulate(A, A+N, 0, [](int a, int b) {return gcd(a,b);});
//auto count = std::count_if(v.begin(), v.end(), [](int x) { return x == 1 || x == 3; } );

ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

//累積和　しゃくとり法　木構造　DP キュー　乱択アルゴリズム　嘘解法　ハッシュ　next_permulation

//課題：DP 木構造　Xor

ll probNow(){
    ll ans;ans=0;
    ll N,K;
    cin>>N>>K;
    
    ll H[N];
    inarray(H, 0, N);
    
    
    
    sort(H, H+N);
    
    FOR(i, 0, N-K){
        ans+=H[i];
    }
    
    
    OutputAndReturn0(ans);
    return 0;
}

signed main(){
    cin.tie(0);    //cinとcoutの結び付き解除（cout時にcinの内容を吐き出さなくなる）
    ios::sync_with_stdio(false);  //coutとprintfの結び付き解除（coutとprintfを同時に使うな！）
    probNow();
    return 0;
}


Measured memory_bytes: 2048
r, c = map(int, input().split())
table = [[] for i in range(r+1)]

for i in range(r):
    table[i] = list(map(int, input().split()))
    table[i].append(0)
    table[i][c] = sum(table[i])

for j in range(c+1):
    result = 0
    for i in range(r):
        result += table[i][j] 
    table[r].append(result)

for i in range(r+1):
    print(' '.join(map(str, table[i])))


Measured memory_bytes: 5704
import java.util.Scanner;

public class Main {
	static int MAX = 100100;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[MAX];
		int[] b = new int[MAX];
		int n;
		n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			if(i % 2 == 0) a[x]++;
			else b[x]++;
		}

		int aMax = 0, aMaxId = 0, a2ndMax = 0;
		int bMax = 0, bMaxId = 0, b2ndMax = 0;
		for (int i = 0; i < MAX; i++) {
			if(aMax <= a[i]) {
				a2ndMax = aMax;
				aMax = a[i];
				aMaxId = i;
			} else if(a2ndMax <= a[i]) {
				a2ndMax = a[i];
			}

			if(bMax <= b[i]) {
				b2ndMax = bMax;
				bMax = b[i];
				bMaxId = i;
			} else if(b2ndMax <= b[i]) {
				b2ndMax = b[i];
			}
		}

		if(aMaxId != bMaxId) {
			System.out.println(n - aMax - bMax);
		} else if(a2ndMax > b2ndMax) {
			System.out.println(n - a2ndMax - bMax);
		} else {
			System.out.println(n - aMax - b2ndMax);
		}
	}
}

Measured memory_bytes: 62704
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))
 
typedef long long ll;
 
const int INF = 1000000000;
const int MOD = 1000000007;

int main (){
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()) {
		if (s[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
int n,a[2][3];
main(){
  cin>>n;
  for(auto& b:a)for(auto& c:b)cin>>c;
  vector<int> dp(n+1);
  for(int i=1;i<=n;++i)for(int j=0;j<3;++j)if(a[0][j] < a[1][j] && i-a[0][j]>=0)dp[i] = max(dp[i],a[1][j]-a[0][j]+dp[i-a[0][j]]);
  n+=dp[n];dp=vector<int>(n+1,0);
  for(int i=1;i<=n;++i)for(int j=0;j<3;++j)if(a[1][j] < a[0][j] && i-a[1][j]>=0)dp[i] = max(dp[i],a[0][j]-a[1][j]+dp[i-a[1][j]]);
  cout<<dp[n]+n;
}

Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b; cin>>a>>b;
	int c=b-a;
	int d=c*(c+1)/2;
	cout<<d-b<<endl;
	
	return 0;
}

Measured memory_bytes: 3640
n=gets.to_i
a=gets.split.map &:to_i
a.map!{|e|e/400}
b=[0]*10000
a.each do |e|
  b[e]+=1
end
puts [[8-b[0..7].count(0),1].max,8-(b[0..7].count(0))+b[8..-1].inject(:+)].*(" ")

Measured memory_bytes: 1916
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		
		boolean good = false;
		
		if ( s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2) )
			good = true;
		else if ( s.charAt(1) == s.charAt(2) && s.charAt(2) == s.charAt(3) )
			good = true;
		else
			good = false;
		
		if (good)
			System.out.println("Yes");
		else
			System.out.println("No");
		
	}
}

Measured memory_bytes: 22996
n = int(input())
a = list(map(int,input().split()))
cnt = [0]*(n+1)
for i in a:
  cnt[i] += 1
ans = 0
C = [[0,0] for i in range(n+1)]
for i in range(n+1):
  if cnt[i] <= 1:
    continue
  C[i][0] = cnt[i]*(cnt[i]-1)//2
  ans += cnt[i]*(cnt[i]-1)//2
  if cnt[i] > 2:
    C[i][1] = (cnt[i]-1)*(cnt[i]-2)//2
for i in range(n):
  print(ans-C[a[i]][0]+C[a[i]][1])

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

using namespace std;
typedef long long ll;

int main() {
  ll N; cin >> N;
  vector<string> s(N);
  for (ll j=0; j < N; ++j) cin >> s[j];
  ll M; cin >> M;
  vector<string> t(M);
  for (ll j=0; j < M; ++j) cin >> t[j];
  map<string, ll> m;
  for (string x: s) {
    m[x] += 1;
  }
  for (string x: t) {
    m[x] -= 1;
  }
  ll max=0;
  for (auto iter=m.begin(); iter != m.end(); ++iter) {
    if (max < iter->second) {
      max = iter->second;
    }
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
typedef long long ll;
int main()
{
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	ll q=0;
	for(ll i=k;i<=n+1;i++)
	{
		q=((i*n)%mod-(i-1)*i%mod)%mod;
		ans=(ans+q+1)%mod;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int H[N] = {};
    int X[N] = {};
    for (int i = 0;i < N;i++){
        cin >> H[i];
    }
    int flag = 0;
    for (int i = N - 1;i > 0;i--){
        if (H[i] < H[i - 1]) H[i - 1] -= 1;
        if (H[i] < H[i - 1]){
            flag = 1;
            break;
        }
    }
    if (flag == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1024
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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;}


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  double res = 0;
  double cos = 380000.0;
  for(int i = 0; i < n; i++){
    double x;
    cin >> x;
    string u;
    cin >> u;
    if(u == "JPY")res += x;
    else res += x * cos;
  }
  cout << setprecision(12);
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline int msbp(int x) {return 31-__builtin_clz(x);}
inline int msb(int x) {return 1 << msbp(x);}
typedef long long ll;
typedef pair<int, int> pii;
// const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = 0x3f3f3f3f;
// const int INF = INT_MAX;
// const int nINF = INT_MIN;
// const ll INF = LLONG_MAX;
// const ll nINF = LLONG_MIN;

/////////////////////////////////////////////////////////////////////

const int N = 2e5+10;

int t, n;

ll solve(vector<pii>& v) {
	sort(v.begin(), v.end());
	ll res = 0;
	multiset<int> cur;
	for(auto [k, add] : v) {
		if(cur.size() < k) {
			cur.insert(add);
		} else if(add > *cur.begin()) {
			cur.erase(cur.begin());
			cur.insert(add);
		}
	}
	for(int x : cur) res += x;
	return res;
}

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    cin >> t;
    while(t--) {
    	cin >> n;
    	ll ans = 0;
    	vector<pii> v1, v2;
    	REP(i, n) {
    		int k, l, r;
    		cin >> k >> l >> r;
    		if(k == n) {
    			ans += l;
    			continue;
    		}
    		ans += min(l, r);
    		if(l >= r) v1.push_back({k, l-r});
    		else v2.push_back({n-k, r-l});
    	}
    	cout << ans+solve(v1)+solve(v2) << endl;
    }

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE) CHECK IF IT SHOULD BE 2*N!!!!
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - negative arithmetic, ceiling division, modulo (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting max to 0 instead of -INF/min to 0 instead of INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)
// - round announcements (WA)
// - multiset::erase (WA)
// - forgetting to rename recursive call when copy/pasting recursive function (WA)
// - not clearing DS between test cases EVEN FOR INPUT (WA, RTE, TLE, MLE)


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

int main()
{
    int K;
    cin >> K;
    if(K % 2 == 0) {
        cout << (K / 2) * (K / 2) << endl;
    } else {
        cout << (K / 2) * (K / 2 + 1) << endl;
    }
    return 0;
}


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

int n;
vector<int> dist, cnt, ok, ng;
vector<vector<int>> g;
string s;

int solve();
void dfs(int now, int par);

int main() {
  cin >> n >> s;
  g.resize(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    g[--a].push_back(--b);
    g[b].push_back(a);
  }
  cout << solve() << endl;
  return 0;
}

int solve() {
  int res = 1e8;
  for (int root = 0; root < n; ++root) {
    dist.assign(n, -1);
    cnt.assign(n, 0);
    ng.assign(n, 0);
    ok.assign(n, 0);
    dfs(root, -1);
    if (!ng[root]) res = min(res, ok[root] / 2);
  }
  if (res == (int)(1e8)) return -1;
  return res;
}

void dfs(int now, int par) {
  if (par >= 0) dist[now] = dist[par] + 1;
  int id = 0, sum = 0, len = g[now].size();
  for (int i = 0; i < len; ++i) {
    int to = g[now][i];
    if (to == par) continue;
    dfs(to, now);
    cnt[now] += cnt[to];
    ng[to] += cnt[to];
    ok[now] += ok[to];
    if (ng[to] > ng[g[now][id]]) id = i;
    sum += ng[to];
  }
  if (ng[g[now][id]] * 2 <= sum) {
    ok[now] += sum - (sum & 1);
    ng[now] = sum & 1;
  } else {
    int loss = ng[g[now][id]], tmp = ok[now];
    ok[now] += (sum - loss) * 2;
    loss -= (sum - loss);
    tmp -= ok[g[now][id]];
    tmp = min(loss, tmp) / 2 * 2;
    ok[now] += tmp;
    loss -= tmp;
    ng[now] = loss;
  }
  cnt[now] += s[now] == '1';
}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll dp[5000][5000][4];
  dp[0][0][0]=1;
  ll k,x,d;
  cin >> x >> k >> d;
  x=abs(x);
  if(x/d<k){
    k-=x/d;
    x=x%d;
    if(k%2==1){
      cout << d-x << endl;
    }
    else{
      cout << x << endl;
    }
  }
  else{
    cout << x-k*d << endl;
  }
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n, a, b;
	vector<ll> v;
	ll count = 0;

	cin >> n >> a >> b;

	REP(i, n) {
		ll t;
		cin >> t;
		v.push_back(t);
	}

	REP(i, n) {
		if (v[i] < a || v[i] >= b) {
			count++;
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int a,b,c,d;
int main()
{
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(d>=abs(a-c)) printf("Yes\n");
	else if(max(abs(b-a),abs(c-b))<=d) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n,m,k,tmp;
    cin >> n >> m;
    vector<int> vec(m);
    rep(i,n){
        cin >> k;
        rep(j,k){
            cin >> tmp;
            vec.at(tmp-1)++;
        }
    }
    tmp=0;
    rep(i,m)if(vec.at(i)==n)tmp++;
    cout << tmp << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int x;
    cin >> x;
    cout << 1 - x << endl;
    return 0;
}

Measured memory_bytes: 3636
INF = float('inf')
n, k = map(int, input().split())
L = list(map(int, input().split()))
ans = INF
for i in range(n-k+1):
    r = L[i+k-1]
    l = L[i]
    tr = abs(r) + abs(l - r)
    tl = abs(l) + abs(r - l)
    t = min(tr, tl)
    ans = min(ans, t)
print(ans)


Measured memory_bytes: 14384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
  	int x3,y3,x4,y4;
  
  	x3=x2-(y2-y1);
  	y3=y2+x2-x1;
  	x4=x3-(x2-x1);
    y4=y3-(y2-y1);
  	cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int main(){
	string s; cin>>s; 
  	int ans=0; 
  	int n=s.size();
  	string temp1="",temp2="";
  	for(int i=0;i<n;i++){
    	temp2+=s[i];
      	if(temp2!=temp1){
        	ans++; 
          	temp1=temp2; 
          	temp2="";
        }
    }
  	cout<<ans<<endl;
  	return 0; 
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int[] a = new int[N];
  int[] b = new int[N];
  for(int i = 0;i < N;i++){
    a[i] = sc.nextInt();
  }
  for(int i = 0;i < N;i++){
    b[i] = sc.nextInt();
  }
  int ans = 0;
    for(int i = 0;i < N;i++){
      int sum = 0;
      for(int j = 0;j <= i;j++){
        sum += a[j];
      }
      for(int j = i;j < N;j++){
        sum += b[j];
      }
      ans = Math.max(sum,ans);
    }
  System.out.println(ans);
}}

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

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int mx = max(a, max(b, c));
    if (2 * mx == a + b + c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" 
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n;
  cin>>n;
  cout<<fixed<<setprecision(15)<<2*n*3.141592653589793238;
}


Measured memory_bytes: 3796
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<stw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;

int main(void){
    int N,X,L;cin>>N>>X>>L;
    int point = L;
    int count = 1;
    while(point<=X){        
        count++;
        cin >> L;
        if(cin.eof())break;
        point += L;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
def f_encolsed_points(MOD=998244353):
    # 参考: https://atcoder.jp/contests/abc136/submissions/6696160
    import sys
    input = sys.stdin.readline

    class BIT(object):
        """Binary Indexed Tree (1-indexed)"""

        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)

        def sum(self, index):
            """tree[1]からtree[index]までの和を計算"""
            ret = 0
            while index > 0:
                ret += self.tree[index]
                index -= index & (-index)
            return ret

        def add(self, index, value=1):
            """tree[index]にvalueを加算"""
            while index <= self.size:
                self.tree[index] += value
                index += index & (-index)

    N = int(input())
    Pos = [[int(i) for i in input().split()] for j in range(N)]

    Pos.sort()  # x座標でソートする
    _, pos_y = zip(*Pos)
    y_comp = {y: i for i, y in enumerate(sorted(pos_y), 1)}  # y座標を圧縮

    pow_2 = [1]
    for _ in range(N):
        pow_2.append(pow_2[-1] * 2 % MOD)

    ans = 0
    tree = BIT(N)
    # x座標が小さな点から順に考える
    for left, (_x, _y) in enumerate(Pos):
        y = y_comp[_y]

        # それぞれ、注目している点の 右|下|上 にいくつ点が存在するか
        right = N - 1 - left
        down = y - 1
        up = N - 1 - down

        lower_left = tree.sum(y)
        tree.add(y, 1)
        upper_left = left - lower_left
        lower_right = down - lower_left
        upper_right = right - lower_right

        # 包除原理(全体 - 上下左右 + 左上左下右上右下 - それ自体)
        count = (pow_2[N]
                 - (pow_2[up] + pow_2[down] + pow_2[left] + pow_2[right])
                 + (pow_2[upper_left] + pow_2[lower_left] + pow_2[upper_right] + pow_2[lower_right])
                 - 1)
        ans += count
        ans %= MOD
    return ans

print(f_encolsed_points())

Measured memory_bytes: 122468
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>

/* template start */

using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << std::endl; }

template <typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
  std::cerr << " " << h;
  if (sizeof...(t) > 0) std::cout << " :";
  debug_out(t...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  return a > b && (a = b, true);
}

template <typename Num>
constexpr Num mypow(Num a, u64 b, Num id = 1) {
  if (b == 0) return id;
  Num x = id;
  while (b > 0) {
    if (b & 1) x *= a;
    a *= a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  i64 h, w, m;
  std::cin >> h >> w >> m;

  using P = std::pair<i64, i64>;

  std::set<P> target;

  std::map<i64, i64> row, col;

  rep(i, 0, m) {
    i64 th, tw;
    std::cin >> th >> tw;

    row[th]++;
    col[tw]++;
    target.emplace(th, tw);
  }

  i64 ans = 0;

  std::vector<i64> row_vec;
  i64 row_max = 0;

  {
    for (const auto& e : row) {
      chmax(row_max, e.second);
    }

    for (const auto& e : row) {
      if (e.second == row_max) row_vec.emplace_back(e.first);
    }
  }

  std::vector<i64> col_vec;
  i64 col_max = 0;

  {
    for (const auto& e : col) {
      chmax(col_max, e.second);
    }

    for (const auto& e : col) {
      if (e.second == col_max) col_vec.emplace_back(e.first);
    }
  }

  if(row_vec.size()*col_vec.size() > m){
    std::cout<<row_max+col_max<<"\n";
    return 0;
  }

  for(const auto& r:row_vec){
    for(const auto& c:col_vec){
      i64 val=row_max+col_max;
      if(target.find(P(r,c))!=target.end())val--;
      chmax(ans,val);
    }
  }

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 67788
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  ll sum = 0;
  rep(i,n)sum+=i+1;
  cout<<sum-n<<endl;
  return 0;
}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


string s,t;
string mae, ato;
bool flag = false;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> s >> t;

    REP(i, s.size()){

        if( s == t){
            flag = true;
        }
        //dump(s);

        mae = s[0];
        s.erase(0,1);
        //dump(s);
        s = s + mae ;
        //dump(s);
    }

    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void print_vector(vector<int> v){
  for(int i = 0; i < (int)v.size(); i++){
	  if (i == (int)v.size() - 1) cout << v[i];
	  else cout << v[i] << " ";  
	}
  cout << endl;	
}

void solve(){
  	map<string, int> m;
  	int q;
  	cin >> q;
  	for(int i = 0; i < q; i++){
	  int cmd ;
	  cin >> cmd;
	  if (cmd == 0){
		  string s;
		  int key;
		  cin >> s >> key;
		  m[s] = key;  
		}
	  if (cmd == 1){
		  string s;
		  cin >> s;
		  cout << m[s] << endl;  
		}	
	} 
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"
int main()
{
	string s = "";
	cin >> s;
	char c = 'a';
	REP(i, s.length())
	{
		if (c == s[i])
		{
			COUT("Bad");
			return 0;
		}
		c = s[i];
	}
			COUT("Good");
			return 0;

	return 0;
}

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

int main(){
    string s;
    cin >> s;
    vector<char> ans;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='0'||s[i]=='1'){
            ans.push_back(s[i]);
        }else if(s[i]=='B'){
            if(!ans.empty()){
                ans.pop_back();
            }
        }
    }
    for(auto it=ans.begin(); it!=ans.end(); ++it){
        cout << *it;
    }
    cout << endl;
    return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);
	
	int s, w; cin >> s >> w;
	cout << (w >= s ? "unsafe" : "safe") << endl;
}


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

typedef long long ll;
const ll MAXN = 3e6 + 5;
const long long MOD = 1e9 + 9;
const long double eps = 1e-6;

#define mp make_pair
#define pb push_back
#define all(temp) temp.begin(), temp.end()
#define REP(i,n) for(int i = 0; i < n; ++i)

int main()
{
	//freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

	string s; cin >> s;
	int ans = 700;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == 'o') ans += 100;
	}
	cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <stack>

using namespace std;
int main() {
    long long N;
    cin >> N;
    vector<vector<pair<long long,long long>>> G(N + 1);
    for(long long i = 0; i < N; i++){
        G[i] = vector<pair<long long,long long>>(0);
    }
    for(long long i = 0; i < N - 1; i++){
        long long a,b,d;
        cin >> a >> b >> d;
        G[a].push_back(pair<long long,long long>(b,d));
        G[b].push_back(pair<long long,long long>(a,d));
    }
    bool isVisit[N];
    for(int i = 1; i < N + 1; i++){
        isVisit[i] = false;
    }
    long long distance[N];
    for(int i = 1; i < N + 1; i++){
        distance[i] = 0;
    }
    queue<long long> queueId = queue<long long>();
    queueId.push(1);
    isVisit[1] = true;
    while(queueId.size() != 0){
        long long num = queueId.front();queueId.pop();
        for(long long i = 0; i < G[num].size(); i++){
            long long tmp = G[num][i].first;
            if(!isVisit[tmp]){
                distance[tmp] = G[num][i].second + distance[num];
                queueId.push(tmp);
                isVisit[tmp] = true;
            }
        }
    }
    for(long long i = 1; i < N + 1; i++){
        if(distance[i] % 2 == 0){
            cout << 0 << endl;
        }else{
            cout << 1 << endl;
        }
    }

}

Measured memory_bytes: 8704
n,k=map(int,input().split())
v=list(map(int,input().split()))
#C,D(宝石を手放す)は最後にまとめてよい
#A,Bを行う回数a,b
#取り出せるもののうちできるだけ負かつ
#その絶対値が大きいものを取り出したい
nk=min(n,k)
discard=0
ans=0
for a in range(nk+1):
    for b in range(nk+1):
        if a+b>nk:
            break
        discard=k-(a+b)     #捨てる回数
        dis=v[:a]+v[n-b:]   #両端から取り出すリスト
        minus=[i for i in dis if i<0]  #取り出すもののうち負のもの
        minus.sort()
        ans=max(sum(dis)-sum(minus[:min(discard,len(minus))]),ans)
print(ans)

Measured memory_bytes: 3064
x, y = map(int, input().split())


ans = 10**10
if x <= y:
    ans = min(ans, y - x)

if -x <= y:
    ans = min(ans, 1 + y + x)

if x <= -y:
    ans = min(ans, 1 - y - x)

if -x <= -y:
    ans = min(ans, 2 - y + x)

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

int main() {
  std::int_fast64_t n;
  std::cin >> n;
  std::vector<std::int_fast64_t> a(n);
  std::copy_n(std::istream_iterator<std::int_fast64_t>(std::cin), n, a.begin());

  std::vector<std::int_fast64_t> b;
  for (std::int_fast64_t i = n; i >= 2; i -= 2) {
    b.push_back(a[i - 1]);
  }
  b.push_back(a[1 - 1]);
  for (std::int_fast64_t i = 3 - n % 2; i <= n; i += 2) {
    b.push_back(a[i - 1]);
  }

  {
    std::string delimiter = "";
    for (const std::int_fast64_t& b_i : b) {
      std::cout << delimiter << b_i;
      delimiter = " ";
    }
    std::cout << std::endl;
  }
  return 0;
}

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

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    rep(i, N) {
        cin >> S.at(i);
    }

    sort(S.begin(), S.end());

    rep(i, N) {
        cout << S.at(i);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256