akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;



int main(){
    int N;
    cin >> N;
    int r[N];
    int l[N];
    for(int i = 0; i<N; i++){
        cin >> l[i] >> r[i];
    }
    int result = 0;
    for(int i = 0; i < N; i++){
        result += (r[i]-l[i]+1);
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	int n,a,b,c,d;
	string s;
	cin>>n>>a>>b>>c>>d>>s;

	if(s[a-1]=='#'||s[b-1]=='#'||s[c-1]=='#'||s[d-1]=='#'){
		print("No");
		return 0;
	}

	bool ok=true;
	bool dot;
	if(s[a-1]=='.'?dot=true:dot=false);
	REP(i,a,max(c,d)){
		if(dot==false&&s[i]=='#'){
			ok=false;
			break;
		}
		if(s[i]=='.')dot=true;
		else dot=false;
	}
	if(ok==false){
		print("No");
		return 0;
	}
	if(c<d){
		print("Yes");
		return 0;
	}else{
		bool sanrenzoku=false;
		if(s[b-2]=='.'?dot=true:dot=false);
		REP(i,b-1,d){
			if(dot==true){
				if(s[i]=='.'&&i!=n-1&&s[i+1]=='.'){
					sanrenzoku=true;
					break;
				}
			}
			if(s[i]=='.')dot=true;
			else dot=false;
		}
		if(sanrenzoku)print("Yes");
		else print("No");
	}
}

Measured memory_bytes: 640
n,k=map(int,input().split())
m=1000000007
ans=0
dp=[0]*(k+1) #dp[i]:=iを数列内の最大値とするもののgcd合計
for i in range(k,0,-1):
  mul_i=k//i#iの倍数の個数
  dp[i]=pow(mul_i,n,m)
  for j in range(2,mul_i+1):
    dp[i]=(m+dp[i]-dp[i*j])%m
  ans+=i*dp[i]%m
ans%=m
print(ans)






Measured memory_bytes: 11208
#include <iostream>

using namespace std;

int main()
{
    int n;

    cin>>n;

    long long a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];

    long long sum = 0;

    for(int i=1;i<n;i++){

        if(a[i]<a[i-1]){

            sum+=(a[i-1]-a[i]);
            a[i] = a[i-1];

        }

    }

    cout<<sum;

    return 0;
}


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

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

#define long long ll

int main(){
    int n;
    cin >> n;
    vector<int> a;
    rep(i,n){
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    int min_cnt = 100100100;
    for(int j = -100; j < 101; j++){
        int cnt = 0;
        rep(i,a.size()){
            cnt += abs(j-a[i])*abs(j-a[i]);
        }
        min_cnt = min(min_cnt , cnt);
    }
    cout << min_cnt << endl;
}


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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
	string s,t;
	cin>>s>>t;
	int cnt=0;
	for(int i=0;i<s.size();i++)cnt+=(s[i]!=t[i]);
	cout<<cnt<<"\n";
}

int main()
{
// #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
// #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  vector<string> A(h); rep(i, h) cin >> A[i];
  set<int> remH, remW;
  rep(i, h) {
    bool ok = true;
    rep(j, w) ok &= (A[i][j]=='.');
    if(ok) remH.insert(i);
  }
  rep(j, w) {
    bool ok = true;
    rep(i, h) ok &= (A[i][j]=='.');
    if(ok) remW.insert(j);
  }
  rep(i, h) {
    rep(j, w) if(!remH.count(i) && !remW.count(j)) cout << A[i][j];
    if(!remH.count(i)) cout << "\n";
  }
  return 0;
}


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

using namespace std;

int main()
{
    int a,b;
    char str[1024];
    cin >> a >> b;
    cin >> str;
    int len = strlen(str);
    int cnt = 0;
    for (int i = 0;i < len;++i) {
        if (str[i] >= '0' && str[i] <= '9')
            cnt++;
    }
    if (cnt == (a+b) && str[a] == '-')
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 384
class UnionFind():
    def __init__(self,n):
        self.parent = [-1 for _ in range(n)]
    
    def find(self,x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
        
    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        else:
            if self.size(x) < self.size(y):
                x,y =y,x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
    def same(self,x,y):
        return self.find(x) == self.find(y)

    def size(self,x):
        x = self.find(x)
        return -self.parent[x]

    def is_roota(self,x):
        return self.parent[x] < 0

n,m =map(int, input().split())
p = list(map(int, input().split()))
count = 0
pair_list = []
for i in range(m):
    array = list(map(int,input().split()))
    array[0] -= 1
    array[1] -= 1  # リストの添字にあわせるため
    pair_list.append(array)

uf = UnionFind(len(p))  # unionfind作成

# 整数のペア(x,y)を同じグループに結合
for i in range(m):
    uf.unite(pair_list[i][0], pair_list[i][1])

# 経路圧縮を行い、親要素をすべて根に更新する
for i in range(n):
    uf.find(i)

# 順列pに含まれる要素p[i]の値とindex+1が一致していたらcount
# p[i]の本来いて欲しいindex(ex. p[i] = 5なら５番目に並んで欲しいから4)と
# p[i]が移動したいindexにいるp[i]のindex+1
# (ex. 5番目にいる値のufにおけるindex 5番目に２がいたら２−１＝１みたいな
for i in range(n):
    if p[i] == i+1:
        count += 1
    else:
        if uf.same(p[i]-1, p[p[i]-1]-1) is True:
            count += 1
        else:
            continue
print(count)

Measured memory_bytes: 32292
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  char x;
  cin >> x;
  
  
	if(x == 'a' || x == 'i' || x == 'u' || x == 'e' || x == 'o'){
      cout << "vowel" << endl;
    }
  else{
    cout << "consonant" << endl;
  }
}
   

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {  // 探索対象keyを探索
    Node *cur = nil->next;  // 番兵の次から探索を開始
    while (cur != nil && cur->key != key) {  // curが番兵nilにたどり着くか、もしくはcur->keyが探索対象keyと同値となるまで探索を継続
        cur = cur->next;
    }
    return cur;  // 探索対象のNodeのアドレスを返す
}

void init() {  // 初期化関数
    nil = (Node *)malloc(sizeof(Node));  // 構造体型Nodeのサイズ分だけメモリを確保
    nil->next = nil;  // 空の連結リストではnilは何とも連結されていない
    nil->prev = nil;  // 同上
}

void printList() {  // 出力用関数、この問題では最後に実行する
    Node *cur = nil->next; // 番兵の次から表示
    int isf = 0;
    while (1) {
        if (cur == nil) break; // 番兵に戻ってきたら処理を終了
        if (isf++ > 0) printf(" ");  // isfと0を比較した後でインクリメント演算子++を実行
        printf("%d", cur->key);
        cur = cur->next;  // 次のNodeへ移行
    }
    printf("\n");  // 出力の最後に改行
}

void deleteNode(Node *t) {  // Nodeアドレス*tにあるNodeを削除
    if (t == nil) return;  // tが番兵なら処理しない（番兵は削除できない）
    t->prev->next = t->next;  // tの前のNodeとtの次のNodeをつなぐ
    t->next->prev = t->prev;  // tの次のNodeとtの前のNodeをつなぐ
    free(t);  // tが入っていたメモリを開放（tを完全に消去する）
}

void deleteFirst() {  // 番兵の次のNodeを削除
    deleteNode(nil->next);
}

void deleteLast() {  //番兵の前のNode、つまり最後のNodeを削除
    deleteNode(nil->prev);
}

void deleteKey(int key) {  // 引数keyを持つNodeを削除
    deleteNode(listSearch(key));
}

void insert(int key) {  // 新しい値を連結リストに追加
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;

    x->next = nil->next;  // x->nextをnil->nextにつなぐ（xの次のNodeとしてnilの次のNodeを指定しなければならないため）
    x->next->prev = x;  // nil->next->prevをxにつなぐ（nilの次のNodeの前のNodeとしてxを指定しなければならないため）
    nil->next = x;  // nil->nextをxにつなぐ（nilの次のNodeとしてxを指定しなければならないため）
    x->prev = nil;  // x-prevをnilにつなぐ（xの前のNodeとしてnilを指定しなければならないため）
}

int main(void) {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);  // 命令の個数を入力
    init();  // 初期化関数を実行
    for(i = 0; i < n; i++) {
        scanf("%s%d", com, &key);
        if (com[0] == 'i') { insert(key); np++; size++;}  // insert命令
        else if (com[0] == 'd') {  // delete系命令（delete, deleteFirst, deleteLast）
            if (strlen(com) > 6) {  // コマンドの長さが6より長いならdeleteFirstかdeleteLast
                if (com[6] == 'F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            } else {
                deleteKey(key); nd++;
            }
            size--;
        }
    }

    printList();

    return 0;
}


Measured memory_bytes: 33856
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b;
   cin >> a >> b;
   if(a + b == 15) cout << '+';
   else if(a*b == 15) cout << '*';
   else cout << 'x';
   return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <list>
#include <numeric> //accumulate

using namespace std;

//???????????°??????TEST????????????????????¬???????????????????????????????????¢????????????
#define TEST //*******************************************************************************************************************************************

//?????????????????¨??§?????\????????????????????????????????°?????????????¨???????????????????dout???????????????????????§???????????¬??????????????????????????????????????????
#ifdef TEST
    #define dout cout
#else
    stringstream dummy; //???????????°??????dout?????????????????????????????????
    #define dout dummy.str(""); dummy.clear(stringstream::goodbit); dummy //dummy?????????????????????????????????????????¨?????¢?????¢???????????????
    //???????????¨??????????????????goodbit?????????????????????????????¨???????????´????????????????????????????????¨?????°?????????????????§???????????????????????????????????? http://d.hatena.ne.jp/linden/20060427/p1
#endif



int binarySearch(int key, int data[], int begin, int end) {
    
    int i = (begin + end + 1) / 2;

    
    if(data[i]==key) return i;
    else if(begin==end) return -1; //Not Found
    else if(key < data[i]) return binarySearch(key, data, begin, i-1);
    else if(data[i] < key) return binarySearch(key, data, i+1, end);
    
    return -1;
}


int main(void) {
    int n, q;
    
    cin >> n;
    int S[n];
    for(int i=0; i<n; i++) cin>>S[i];
    
    cin >> q;
    int T[n];
    for(int i=0; i<q; i++) cin>>T[i];
    
    
//    dout<<"S = ";
//    for(int i=0; i<n; i++) dout<<S[i]<<" ";
//    dout<<endl;
//    
//    dout<<"T = ";
//    for(int i=0; i<q; i++) dout<<T[i]<<" ";
//    dout<<endl;
    
    
    //search T from S
    int ans = 0;
    for (int i=0; i<q; i++) { //S[]????????????T[i]???key?????¢?´¢
        int key = T[i];
        int foundIndex = -1;
//        int foundIndex = binarySearch(key, S, 0, n);
//        if ( foundIndex != -1 ) ans++;
        
        int left = 0;
        int right = n;
        
        while(left<right) {
            int mid = (left + right) / 2;
            
            if( S[mid]==key ) {
                foundIndex=mid;
                ans++;
                break;
            }
            else if (key<S[mid]) right=mid;
            else if (S[mid]<key) left=mid+1;
        }
        
        if(left==right) foundIndex=-1;
        
        
        

        //Test display
//        dout << "i=" << i << " : key=" << key << " foundIndex=" << foundIndex << " left=" <<left <<" right=" << right << " ans=" << ans << endl;
        
    }
    
    
    //output
    cout << ans << endl;
    
    
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  ll n, x; cin >> n >> x;
  ll bsum = 0;
  vector<P> vec(n);
  vector<P> vec2(n);
  vector<ll> aoki(n);

  rep(i, n) {
    ll b, l, u; cin >> b >> l >> u;
    bsum += b;
    vec[i] = {(x-b)*u+b*l, i};
    vec2[i] = P(l, u);
    aoki[i] = b;
  }

  sort(vec.rbegin(), vec.rend());

  vector<ll> perm(n);
  vector<ll> sum(n+1);
  vector<ll> rsum(n+1);
  rep(i, n) {
    int pos = vec[i].second;
    perm[pos] = i;

    sum[i+1] = sum[i] + (x-aoki[pos])*vec2[pos].second;
    rsum[i] = aoki[pos]*vec2[pos].first;
  }
  for(int i=n-1; i>=0; i--) {
    rsum[i] += rsum[i+1];
  }

  ll mi = -1;
  ll ma = bsum;
  while(mi+1 < ma) {
    auto med = (mi+ma)/2;
    auto p = med/x;
    auto r = med%x;
    ll now = 0;
    bool flag = false;
    //debug(p); debugln(r);
    rep(i, n) {
      ll now = 0;
      if (r <= aoki[i]) {
        now -= (aoki[i]-r)*vec2[i].first;
      } else {
        now += (r-aoki[i])*vec2[i].second;
      }
      int pos = perm[i];

      if (pos < p) {
        now += sum[p+1];
        now -= rsum[p+1];
        now -= (x-aoki[i])*vec2[i].second;
      } else {
        now += sum[p];
        now -= rsum[p];
        now += aoki[i]*vec2[i].first;
      }
      //debug(i); debugln(now);
      if (now>=0) {
        flag = true;
        break;
      }
    }

    if (flag) {
      ma = med;
    } else {
      mi = med;
    }
  }
  cout << ma << endl;
}

Measured memory_bytes: 6528
import math

N, H = map(int, input().split())
a_l = []
b_l = []
for _ in range(N):
    a, b = map(int, input().split())
    a_l.append(a)
    b_l.append(b)

a_l.sort(reverse=True)
b_l.sort(reverse=True)
ans = 0
for i in range(N):
    if a_l[0] >= b_l[i]:
        break
    else:
        ans += 1
        H = max(H - b_l[i], 0)
        if H <= 0:
            break
ans += math.ceil(H / a_l[0])
print(ans)

Measured memory_bytes: 17052
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main() {
        string s;
        cin >> s;
        vector<int> cnt(26);
        int n = s.size();
        for (int i = 0; i < n; i ++) cnt[s[i] - 'a'] ++;
        long long ans = 1 + (long long) n * (n - 1) / 2;
        for (int i = 0; i < 26; i ++) if (cnt[i] > 1) ans -= (long long) cnt[i] * (cnt[i] - 1) / 2;
        printf("%lld\n", ans);
        return 0;
}



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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-12;

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
void solve() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c) {
        cout << "No" << endl;
        return;
    }
    ll x = 4ll * a * b;
    ll y = (c - a - b) * (c - a - b);
    cout << (x - y < 0 ? "Yes" : "No") << endl;
}

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


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

long long H, W;

int main() {
  cin >> H >> W;
  if (H == 1 or W == 1) cout << 1 << endl; 
  else if (H % 2 == 0 || W % 2 == 0) {
    long long ans = H * W / 2;
    cout << ans << endl;
  }
  else {
    long long ans = H * W / 2;
    cout << ans + 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    vector<long long> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    // vector<long long> acc(n + 1, 0);
    // for (int i = 0; i < n; ++i) {
    //     acc[i + 1] = acc[i] + A[i];
    // }
    
    map<int, int, greater<int>> M;
    for (int i = 0; i < m; ++i) {
        long long b, c;
        cin >> b >> c;
        M[c] += b;
    }

    long long res = 0;
    for (int i = 0; i < n; ++i) {
        if (!M.empty()) {
            auto x = M.begin()->first;
            if (x > A[i]) {
                A[i] = x;
                if (--M[x] == 0) {
                    M.erase(x);
                }
            }
        }
        res += A[i];
    }

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int maxPar = N;
		if (maxPar % 2 == 1) maxPar--;
		boolean[][] adj = new boolean[N + 1][N + 1];
		for (int i = 1; i <= maxPar; i++) {
			adj[i][maxPar + 1 - i] = true;
		}
		int m = N * (N - 1) / 2 - maxPar / 2;
		out.println(m);
		for (int i = 1; i <= N; i++) {
			for (int j = i+1; j <= N; j++) {
				if (!adj[i][j]) {
					out.println(i + " " + j);
				}
			}
		}
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

const int mod = 1e9 + 7;
const int mxn = 1005;
int dp[mxn][mxn];
char grid[mxn][mxn];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> grid[i][j];
    dp[1][1] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (i == 1 && j == 1)
                continue;
            if (grid[i][j] == '#')
                dp[i][j] = 0;
            else
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }
    cout << dp[n][m] << '\n';
}

Measured memory_bytes: 8476
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

int main() {
  for (int n, m; scanf("%d%d", &n, &m) == 2; ) {
    vector<int> a(n + 1, 0);
    for (int i = 0; i < m; ++ i) {
      int u, v; scanf("%d%d", &u, &v);
      a[u] ++; a[v] --;
    }
    int ret(0);
    for (int i = 1; i <= n; ++ i) {
      a[i] += a[i - 1];
      if (a[i]) ret ++;
    }
    ret = ret * 2 + n + 1;
    printf("%d\n", ret);
  }
  return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll t[200010];
int main()
{
	int N;
	ll T;
	cin >> N >> T;
	for (int i = 0; i < N; i++) cin >> t[i];
	ll ans = T;
	for (int i = 0; i < N - 1; i++) {
		if (t[i + 1] - t[i] < T) ans += t[i + 1] - t[i];
		else ans += T;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	
	int n, m,k;
	cin >> n >> m>>k;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {

			if (i*(m - j) + j*(n - i) == k) {
				cout << "Yes" << endl; return 0;
			}
		}
	}
	cout << "No" << endl;

		return 0;

}




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

void dfs(int pos, int limit, std::vector<int> a) {
  if (pos == limit) {
    for (const auto& x : a) std::cout << (char)('a' + x);
    std::cout << std::endl;
    return;
  }
  int ma = 0;
  for (const auto& x : a) {
    if (x > ma) ma = x;
  }
  ++ma;
  for (int i = 0; i <= pos && i <= ma; ++i) {
    std::vector<int> cur(a);
    cur.emplace_back(i);
    dfs(pos + 1, limit, cur);
  }
}

void solve(int n) {
  std::vector<int> a;
  dfs(0, n, a);
}

int main() {
  int n;
  std::cin >> n;
  solve(n);
  return 0;
}


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


int main() {
  int N; cin >> N;
  vector<int> H(N);
  rep(i, N) cin >> H[i];
  
  rep(i, N-1) {
    if(H[i+1]-H[i] < -1) {
      cout << "No" << endl;
      return 0;
    } else if(H[i+1]-H[i] == -1) {
      H[i+1]++;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
int main(){
    int N; cin >> N;
    int H[N];
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    int ans = 0;
    int temp = 0;
    for (int i = 0; i < N-1; i++)
    {
        if(H[i] >= H[i+1]) temp++;
        else{
            if(ans < temp) ans = temp;
            temp = 0;
        }
    }
    if(ans < temp) ans = temp;
    cout << ans << endl;
}

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

int main(){
	int S;
	int h,m,s;
	cin>> S;
	
	h = S / 3600;
	S = S % 3600;
	m = S /60;
	s = S % 60;
	
	
    cout <<h <<":"<<m<<":"<<s<< endl;
    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
//#define int long long

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

bool f(string s, vector<int> a){
    int n = s.size();

    REP(i, n){
        if(a[i] == 1){
            if(s[i] == 'o' && a[(i-1+n)%n] != a[(i+1+n)%n]) return false;
            if(s[i] == 'x' && a[(i-1+n)%n] == a[(i+1+n)%n]) return false;
        }else{
            if(s[i] == 'x' && a[(i-1+n)%n] != a[(i+1+n)%n]) return false;
            if(s[i] == 'o' && a[(i-1+n)%n] == a[(i+1+n)%n]) return false;
        }
    }
    return true;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; string s;
    cin >> n >> s;

    vector<int> a(n, 0);
    bool flag;
    a[0] = 0, a[1] = 0;
    for(int i = 1; i < n-1; i++){
        if(a[i]) a[i+1] = (s[i] == 'o' ? a[i-1] : (a[i-1]+1)%2); 
        else a[i+1] = (s[i] == 'x' ? a[i-1] : (a[i-1]+1)%2);
    }
    flag = f(s, a);
    
    if(flag){
        REP(i, n) cout << (a[i] ? 'S' : 'W');
        cout << endl;
        return 0;
    }
        
    a[0] = 1, a[1] = 0;
    for(int i = 1; i < n-1; i++){
        if(a[i]) a[i+1] = (s[i] == 'o' ? a[i-1] : (a[i-1]+1)%2); 
        else a[i+1] = (s[i] == 'x' ? a[i-1] : (a[i-1]+1)%2);
    }
    flag = f(s, a);
    
    if(flag){
        REP(i, n) cout << (a[i] ? 'S' : 'W');
        cout << endl;
        return 0;
    }

    a[0] = 0, a[1] = 1;
    for(int i = 1; i < n-1; i++){
        if(a[i]) a[i+1] = (s[i] == 'o' ? a[i-1] : (a[i-1]+1)%2); 
        else a[i+1] = (s[i] == 'x' ? a[i-1] : (a[i-1]+1)%2);
    }
    flag = f(s, a);
    
    if(flag){
        REP(i, n) cout << (a[i] ? 'S' : 'W');
        cout << endl;
        return 0;
    }

    a[0] = 1, a[1] = 1;
    for(int i = 1; i < n-1; i++){
        if(a[i]) a[i+1] = (s[i] == 'o' ? a[i-1] : (a[i-1]+1)%2); 
        else a[i+1] = (s[i] == 'x' ? a[i-1] : (a[i-1]+1)%2);
    }
    flag = f(s, a);
    
    if(flag){
        REP(i, n) cout << (a[i] ? 'S' : 'W');
        cout << endl;
        return 0;
    }

    cout << -1 << endl;
}


Measured memory_bytes: 1352
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<math.h>
using namespace std;
#define MAX 200005
#define MOD 998244353
#define EPS 0.00000000001
#define INF 998244353
char s[6][6];
bool black(int H,int W,int K,int hmask,int wmask)
{
    int i,j,hcur,wcur,cnt=0;
    for(i=0;i<H;i++)
    {
        for(j=0;j<W;j++)
        {
            hcur=1<<i;
            hcur=hcur&hmask;
            wcur=1<<j;
            wcur=wcur&wmask;
            if(s[i][j]=='.'||hcur>0||wcur>0) continue;
            cnt++;
        }
    }
    return cnt==K;
}
int main()
{
    int H,W,i,j,K;
    scanf("%d %d %d ",&H,&W,&K);
    for(i=0;i<H;i++)
    {
        for(j=0;j<W;j++)
        {
            scanf("%c",&s[i][j]);
        }
        scanf("%*c");
    }
    int hmask=1<<H,wmask=1<<W;
    int ans=0;
    for(i=0;i<hmask;i++)
    {
        for(j=0;j<wmask;j++)
        {
            if(black(H,W,K,i,j)) ans++;
        }
    }
    printf("%d",ans);
    return 0;
}


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

using namespace std;

long long a, b, c;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> a >> b >> c;
    if (!(a & b & c & 1))
        return cout << 0, 0;
    long long rez = min({a * b, b * c, a * c});
    return cout << rez, 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
x=1
for i in range(60):
  z=o=0
  for j in range(n):
    if a[j]%2:o+=1
    else:z+=1
    a[j]//=2
  ans+=(x*o*z)%mod
  ans%=mod
  x=(x*2)%mod
print(ans)

Measured memory_bytes: 122936
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N, K;
   cin >> N >> K;
   int p[N];
   for(int i=0;i<N;i++){
      cin >> p[i];
   }
   long long cur=0;
   for(int i=0;i<K;i++){
      cur+=p[i]+1;
   }
   long long ans=cur;
   for(int i=K; i<N; i++ ){
      cur-=p[i-K];
      cur+=p[i];
      ans = max(ans, cur);
   }
   double dans=ans;
   cout << std::fixed << std::setprecision(2) << dans/2.0 << endl;
   return 0;
}


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

using namespace std;
double II(double val)
{
	if(val<0) return -val;
	return val;
}
int main()
{
	double N,T,A;
	double H[1000];
	double ans=114514;
	double tem;
	int i;
	int num;
	cin>>N;
	cin>>T>>A;
	for(i=0;i<N;i++){
		cin>>H[i];
		tem=II((T-A)-H[i]*0.006);
		ans=min(ans,tem);
		if(ans==tem) num=i;
	}
	cout<<num+1<<endl;
	
}

Measured memory_bytes: 256
/*==============================================*\
ID:          shahidul_brur

Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh

 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = 105;
const int LOGN = 20;
int n, k, w[maxn], v[maxn], W;
ll dp[maxn][100005];
ll cal(int i, int cap)
{
    if(i>n || cap==0) return 0LL;
    ll &ret=dp[i][cap];
    if(ret!=-1) return ret;
    ret = cal(i+1, cap);
    if(w[i]<=cap)
        ret = max(ret, cal(i+1, cap-w[i])+v[i]);
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n>>W;
    f1(i,n) cin>>w[i]>>v[i];
    mem(dp, -1);
    cout << cal(1,W) << "\n";
    return 0;
}


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

#define int long long
#define w cout
#define e '\n'
#define sz(x) (int)x.size()
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.first >> p.second; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 + 10 , mod = 998244353;

signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int k , x ; cin >> k >> x;
	if(k*500 >= x) {
		w << "Yes" ;
	}else w << "No";
}


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

int main(){
    int n,k,q;
    scanf("%d%d%d",&n,&k,&q);
    int a[q];
    int score[n];
    for(int i=0;i<q;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++) score[i]=k;
    for(int i=0;i<q;i++){
        score[a[i]-1]++;
    }
    for(int i=0;i<n;i++){
        
        if(score[i]>q) printf("Yes\n");
        else printf("No\n");
    }
}

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

// @@ !! LIM(f:updMaxMin)
// --> f:updMaxMin
// ---- inserted function updMaxMin from util.cc
template<typename T>
bool updMax(T& tmax, const T& x) {
  if (x > tmax) { tmax = x; return true;  }
  else          {           return false; }
}
template<typename T>
bool updMin(T& tmin, const T& x) {
  if (x < tmin) { tmin = x; return true;  }
  else          {           return false; }
}
// ---- end updMaxMin
// @@ !! LIM  -- end mark --

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, K; cin >> N >> K;
  using sta = pair<ll, bool>;
  vector<sta> vec;
  vector<ll> T(N), D(N);
  for (ll i = 0; i < N; i++) cin >> T[i] >> D[i];
  vector<ll> topidx(N+1, -1);
  for (ll i = 0; i < N; i++) {
    ll t = T[i], d = D[i];
    ll j = topidx[t];
    if (j < 0 || D[j] < d) topidx[t] = i;
  }
  for (ll i = 0; i < N; i++) {
    ll t = T[i], d = D[i];
    vec.emplace_back(d, topidx[t] == i);
  }
  sort(vec.begin(), vec.end(), greater<sta>());
  ll nt = 0;
  ll sum1 = 0;
  for (ll i = 0; i < K; i++) {
    auto [d, b] = vec[i];
    sum1 += d;
    if (b) nt++;
  }
  ll sum2 = 0;
  ll ans = nt * nt + sum1 + sum2;
  ll p = K - 1;
  ll q = K;
  while (true) {
    while (p >= 0 && vec[p].second) p--;
    if (p < 0) break;
    while (q < N && !vec[q].second) q++;
    if (q == N) break;
    sum1 -= vec[p].first;
    sum2 += vec[q].first;
    nt++;
    ans = max(ans, nt * nt + sum1 + sum2);
    p--;
    q++;
  }
  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 7592
(let ((n (read))
      (a (make-array 1 :element-type 'integer
                       :initial-element 0  
                       :adjustable t
                       :fill-pointer 1))
      (ans (make-array 0 :element-type 'integer
                         :adjustable t
                         :fill-pointer 0))
      (ans-c 0))
     (dotimes (i n)
       (vector-push-extend (read) a))
     (loop for i from n downto 1
           do (loop for j from 2 upto n
                    while (<= (* i j) n)
                    do (setf (aref a i) (logxor (aref a i) (aref a (* i j)))))
              (if (= (aref a i) 1) (progn (incf ans-c)
                                          (vector-push-extend i ans))))
     (format t "~A~%" ans-c)
     (if (not (= 0 ans-c)) (format t "~{~A~%~}" (coerce ans 'list))))

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i ,a, b) for (int i = a ; i <= b ; i++)
#define sz(a) int(a.size())
#define cuti(a) cout << a << endl;
#define cutii(a,b) cout << a << " " << b << endl;
#define cutiii(a,b,c) cout << a << " " << b << " " << c << endl;
#define vec(a) vector<int > a;

template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }

typedef long long LL;
typedef pair<int ,int > pii;
typedef pair<string ,int > psi;
typedef pair<string ,string > pss;
typedef pair<LL, LL> pLL;

const long long oo = 1e9 + 7;
const double PI = acos(-1.0);

double DEG_to_RAD(double d) { return d * PI / 180.0; }

int n,k,cnt;
int a[223456];
int check[223456];
vector<int > b;

int main(){
//    freopen("test.txt","r",stdin);
    cin >> n >> k;
    for (int i =1 ;i <= n; i++) {
        cin >> a[i];
        if (!check[a[i]]) {
            cnt++;
        }
        check[a[i]]++;
    }
    for (int i = 1 ; i <= 200000; i++) {
        if ( check[i]) b.push_back(check[i]);
    }
    sort(b.begin(),b.end());
    if ( cnt <= k ) {
        cout << 0 << endl;
    } else {
        int ans = 0;
        for (int i = 0 ; i < cnt - k; i++) {
            ans += b[i];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define endl '\n'
#define pii pair<int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

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

    int n; cin>>n;
    int a=0,b=0,c=0,d=0;
    for(int i=0;i<n;i++){
        string s; cin>>s;
        if(s=="AC") a++;
        else if(s=="WA") b++;
        else if(s=="TLE") c++;
        else d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
  
}

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


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

struct edge {int to; ll cost; };

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

ll GCD(ll a, ll b){
  if(b==0) return a;
  else return GCD(b, a%b);
}

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}

int main(){
  int x; 
  cin >> x;
  string ans;
  if(x>=30) ans  = "Yes";
  else ans = "No";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
a = list(input())
b = list(input())
c = list(input())

winner = 'A'
turn = a
while len(turn) != 0:
    card = turn.pop(0)
    if card == 'a':
        winner = 'A'
        turn = a
    elif card == 'b':
        winner = 'B'
        turn = b
    else:
        winner = 'C'
        turn = c

print(winner)


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

using namespace std;

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

	long long ans=0;

	for(long long i=1;i*i+i<=n;i++)
	{
		if(n%i==0)
		{
			if(i*i!=n)
			{
				if((n/i-1)>i)
					ans+=((n/i)-1);
			}
		}

	}

	cout << ans << endl;


}

Measured memory_bytes: 384
#A
N = int(input())
ST = []
for i in range(N):
    s,t = input().split()
    ST.append([str(s),int(t)])
    
L = str(input())
rest = 0
ans = 0
flag = 0
for st in ST:
    s,t = st
    ans+=t
    if flag == 1:
        rest+=t
        
    if s == L:
        flag = 1
        
    
        
print(rest)



Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
	int routeCount, limitTime;
	cin >> routeCount >> limitTime;

	int minimumCost = 1001;
	for (int routeIndex = 0; routeIndex < routeCount; routeIndex++)
	{
		int cost, routeTime;
		cin >> cost >> routeTime;

		if ((routeTime <= limitTime) && (cost < minimumCost))
		{
			minimumCost = cost;
		}
	}

	if (minimumCost > 1000)
	{
		cout << "TLE" << endl;
	}
	else
	{
		cout << minimumCost << endl;
	}

	return 0;
}

Measured memory_bytes: 256
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		ll a[n];
		rep(i,n)
		{
			cin>>a[i];
		}
		ll m=inf;
		rep(i,n)
		{
			m=min(m,a[i]);
			if(m>=a[i])
				c++;
		}
		cout<<c;

		
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
    int N;
    string S;
    cin>>N>>S;
    int counter=0;
    for(int i=0;i<N-2;i++){
        if(S.at(i)=='A'&S.at(i+1)=='B'&S.at(i+2)=='C') counter=counter+1;
    }
    cout<<counter<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int main ( void )
{
  ll in;
  while( cin >> in )
  {
     ll sum = 0;
     for ( ll i = in; i < 600; i+=in )
     {
        sum += (i * i * in);
     }
     cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
int U[100001];
set<int> R[100001];

int find(int x) {
  if (U[x] == x) return x;
  return U[x] = find(U[x]);
}

void unite(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return;
  if (R[x].size() < R[y].size()) swap(x, y);
  U[y] = x;
  for (int e : R[y]) R[x].insert(e);
  R[y].clear();
}

bool same(int x, int y) {
  return find(x) == find(y);
}
inline int mins(int v) {
  return (26-(v%26))%26;
}

int N, M;
string S;
int A[100001];
bool done[100001];
void add(int p, int v) {
  v = (26+v)%26;
  A[p] = (A[p]+v)%26;
}
bool go(int pos, int v) {
  v = (26+v)%26;
  if (R[find(pos)].empty()) return false;
  int a = A[pos];
  int left = *R[find(pos)].begin(), right = *R[find(pos)].rbegin();
  if (!done[left]) {
    add(left, a-v);
    add(pos, v-a);
    assert(A[pos] == v);
    return true;
  }
  if (!done[right]) {
    add(right, a-v);
    add(pos, v-a);
    assert(A[pos] == v);
    return true;
  }
  return false;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> S >> M;
  N = S.length();
  rep(i, N+1) U[i] = i, R[i].insert(i);
  rep(i, M) {
    int l, r;
    cin >> l >> r;
    l--;
    unite(l, r);
  }
  rep(i, N) A[i] = S[i]-(i>0?S[i-1]:'a');
  rep(i, N) A[i] = ((A[i]%26)+26)%26;
  A[N] = 0;
  N++;
  for (int p=N/2-1; p>=0; p--) {
    int right = N-1-p;
    unite(p, right);
  }
  if (N % 2 == 1) {
    int pos = (N-1)/2;
    // pos -> 0
    done[pos] = true;
    if (A[pos] != 0) {
      if (!go(pos, 0)) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  int hoge = N/2;
  for (int p=N/2-1; p>=1; p--) {
    int right = N-1-p;
    done[p] = done[right] = true;
    if (A[p] == mins(A[right])) continue;
    if (go(p, mins(A[right])) || go(right, mins(A[p]))) {
    }
    else {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}


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

using namespace std;

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

    vector<int> p(n);
    for(int i=0;i<n;i++) cin >> p[i];
    
    vector<int> ps=p;
    sort(ps.begin(),ps.end());
    
    int cnt=0;
    for(int i=0;i<n;i++){
        if(p[i]!=ps[i]){
            cnt++;
            if(cnt>2){
                cout << "NO" << endl;
                return 0;
            }
        }
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int int_n = 0;  // n
  int int_m = 0;  // m
  int int_l = 0;  // l

  int int_col_max = 0;  // 最大列数
  int int_row_max = 0;  // 最大行数

  int int_cnt_col = 0;  // 列数カウント用
  int int_cnt_row = 0;  // 行数カウント用

  int int_cnt_k = 0;  // 計算用カウント
  int int_max_k = 0;  // 最大計算用カウント
  unsigned long lng_cal = 0;  // 計算用値

  unsigned long lng_a_array[100][100] = { 0 }; // 行列A
  unsigned long lng_b_array[100][100] = { 0 }; // 行列B
  unsigned long lng_c_array[100][100] = { 0 }; // 行列C

  // 1行目:n,m,l取得
  scanf("%d %d %d",&int_n ,&int_m, &int_l);

  // 2行目:行列A(n*m)取得
  int_row_max = int_n;
  int_col_max = int_m;
  for (int_cnt_row = 0; int_cnt_row < int_row_max; int_cnt_row++)
  {
    for (int_cnt_col = 0; int_cnt_col < int_col_max; int_cnt_col++)
    {
      scanf("%lu",&lng_a_array[int_cnt_row][int_cnt_col]);
    }
  }

  // 3行目:行列B(m*l)取得
  int_row_max = int_m;
  int_col_max = int_l;
  for (int_cnt_row = 0; int_cnt_row < int_row_max; int_cnt_row++)
  {
    for (int_cnt_col = 0; int_cnt_col < int_col_max; int_cnt_col++)
    {
      scanf("%lu",&lng_b_array[int_cnt_row][int_cnt_col]);
    }
  }

  // 行列C作成
  int_row_max = int_n;
  int_col_max = int_l;
  int_max_k = int_m;
  for (int_cnt_row = 0; int_cnt_row < int_row_max; int_cnt_row++)
  {
    for (int_cnt_col = 0; int_cnt_col < int_col_max; int_cnt_col++)
    {
      lng_cal = 0;
      for (int_cnt_k = 0; int_cnt_k < int_max_k; int_cnt_k++)
      {
        lng_cal += (lng_a_array[int_cnt_row][int_cnt_k] * lng_b_array[int_cnt_k][int_cnt_col]);
      }
      lng_c_array[int_cnt_row][int_cnt_col] = lng_cal;
    }
  }

  // 行列C表示
  int_row_max = int_n;
  int_col_max = int_l;
  for (int_cnt_row = 0; int_cnt_row < int_row_max; int_cnt_row++)
  {
    for (int_cnt_col = 0; int_cnt_col < int_col_max; int_cnt_col++)
    {
      if(int_cnt_col > 0)
      {
        printf(" ");
      }
      printf("%lu",lng_c_array[int_cnt_row][int_cnt_col]);
    }
      printf("\n");
  }

  return 0; 
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t;
    cin >> s >> t;

    int ans = 0;
    for (int i = 0; i < s.length(); i++){
        if (s[i] != t[i])
            ans += 1;
    }

    cout << ans << '\n';

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector< vector<ll> > Matrix;
typedef pair<ll, ll> P;

const ll mod = 1000000009;

Matrix mul(Matrix A, Matrix B) {
	assert(A[0].size() == B.size());
	int l = A.size(), m = A[0].size(), n = B[0].size();
	Matrix res(l, vector<ll>(n, 0));
	for (int i = 0; i < l; ++i) {
		for (int j = 0; j < n; ++j) {
			for (int k = 0; k < m; ++k) {
				res[i][j] = (res[i][j] + A[i][k] * B[k][j]) % mod;
			}
		}
	}
	return res;
}
Matrix power(Matrix A, ll n) {
	int m = A.size();
	Matrix res(m, vector<ll>(m, 0));
	for (int i = 0; i < m; ++i) res[i][i] = 1;
	for (ll i = 1; i <= n; i <<= 1) {
		if (n & i) {
			res = mul(res, A);
		}
		A = mul(A, A);
	}
	return res;
}

ll solve(int W, ll H, vector<P>& obs) {
	set<ll> nob;
	map<ll, set<ll> > m;
	for (int i = 0; i < obs.size(); ++i) {
		ll x = obs[i].first, y = obs[i].second;
		if (m.find(y) == m.end()) {
			set<ll> s; s.insert(x);
			m[y] = s;
		}
		else {
			m[y].insert(x);
		}
		nob.insert(y-1);
	}
	nob.insert(H-1);

	Matrix A(W, vector<ll>(W, 0));
	for (int i = 0; i < W; ++i) {
		for (int dx = -1; dx <= 1; ++dx) {
			int x = i+dx;
			if (0 <= x && x < W) {
				A[i][x] = 1;
			}
		}
	}

	Matrix d(W, vector<ll>(1, 0)); d[0][0] = 1;
	ll nowY = 0;
	while (nowY < H-1) {
		ll nextY = *nob.lower_bound(nowY);
		d = mul( power(A, nextY-nowY), d );
		nowY = nextY;
		if (nowY < H-1) {
			Matrix nd(W, vector<ll>(1, 0));
			for (int x = 0; x < W; ++x) {
				for (int dx = -1; dx <= 1; ++dx) {
					int nx = x+dx;
					ll ny = nowY+1;
					if (0 <= nx && nx < W && (m.find(ny) == m.end() || m[ny].count(nx) == 0)) {
						nd[nx][0] = (nd[nx][0] + d[x][0]) % mod;
					}
				}
			}
			d = nd;
			++nowY;
		}
	}
//	for (int i = 0; i < W; ++i) cout << d[i][0] << " "; cout << endl;
	return d[W-1][0];
}

int main() {
	int q = 1;
	ll W, H, N;
	while (cin >> W >> H >> N, W || H || N) {
		vector<P> obs;
		for (int i = 0; i < N; ++i) {
			ll x, y; cin >> x >> y; --x, --y;
			obs.push_back( P(x, y) );
		}
		cout << "Case " << q << ": " << solve(W, H, obs) << endl;
		++q;
	}
}

Measured memory_bytes: 1516