akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define plint pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int n,k;
    cin >> n >> k;
    int ans=1;
    while(n>=k){
        n /= k;
        ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;


int main(){
int A,B;
string S;
cin >> A >> B;
cin >> S;
bool ok = false;
if(S[A] == '-'){
    for(int i = 0; i < A; i++){
        if(S[i] != '-')ok = true;
        else ok = false;
    }
}

if(ok){
    for(int i = A + 1; i < A + B + 1; i++){
        if(S[i] != '-')ok = true;
        else ok = false;
    }
}
if(ok){
    cout << "Yes" << endl;
}
else{
    cout << "No" << endl;
}
}

Measured memory_bytes: 256
N=int(input())
K=int(input())

ans=float("inf")
for i in range(2**N):
    val=1
    for j in range(N):
        if i%2==0:
            val*=2
            i//=2
        else:
            val+=K
            i//=2
    ans=min(ans,val)
print(ans)

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

int main(){
  string S;
  cin >> S;
  bool a=false;
  for(int i=0;i<S.size()-1;i++){
    if(S.at(i)=='A' && S.at(i+1)=='C'){
      cout << "Yes" << endl;
      a=true;
      break;
    }
  }
  if(!a){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import fractions
from functools import reduce
import numpy as np
N, X = map(int, input().split())
xlist = list(map(int, input().split()))
xlist.append(X)
xlist.sort()
sa = list(np.array(xlist[1:]) - np.array(xlist[:-1]))
print(reduce(fractions.gcd, sa))

Measured memory_bytes: 24100
n, s = int(input()), str(input())

num1, num2, num3 = set([]), set([]), set([])
for i in range(n):
    if s[i] in num1:
        continue
    num1.add(s[i])
    for j in range(i + 1, n):
        tmp2 = s[i] + s[j]
        if tmp2 in num2:
            continue
        num2.add(tmp2)
        for k in range(j + 1, n):
            num3.add(tmp2 + s[k])
print(len(num3))


Measured memory_bytes: 41324
import sys
import collections

sys.setrecursionlimit(10**6)
N, M = map(int, input().split())

def factor(m):
    fac = collections.Counter()
    while (m&1) == 0:
        m >>= 1
        fac[2] += 1
    for p in range(3, m, 2):
        if p*p > m:
            break
        while m % p == 0:
            m //= p
            fac[p] += 1
    if m > 1:
        fac[m] += 1
    return fac

fac = factor(M)

def search(i, ps, divisor):
    if M < N * divisor:
        return 1
    if i == len(ps):
        assert M % divisor == 0
        return divisor
    p, cnt = ps[i]
    dmax = 1
    for j in range(cnt+1):
        dmax = max(dmax, search(i+1, ps, divisor))
        divisor *= p
    return dmax

print(search(0, list(fac.items()), 1))


Measured memory_bytes: 3316
#include <stdio.h>
#define MAX (int)1e5+1

int main(){
  int n,k,q,a[MAX],g[MAX],i;
  
  scanf("%d%d%d",&n,&k,&q);
  for(i=0;i<q;i++)
    scanf("%d",&a[i]);
  
  for(i=1;i<=n;i++)g[i]=0;
  for(i=0;i<q;i++){
    g[a[i]]++;
  }
  for(i=1;i<=n;i++)
    printf("%s\n",(k-q+g[i]>0) ? "Yes" : "No");
  
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  int n,k; cin>>n>>k;
  vector<int> t(n);
  rep(i, k) {
    int d; cin>>d;
    rep(j, d) {
      int a; cin>>a; a--;
      t[a]++;
    }
  }
  int ans = 0;
  rep(i, n) {
    if (t[i] == 0) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
const int mod = 1e9 + 7;

string ff(int i, int j, int k, int l){
    string s = "";
    s += "ACGT"[i];
    s += "ACGT"[j];
    s += "ACGT"[k];
    s += "ACGT"[l];
    return s;
}

int main(){
    int n;
    cin >> n;
    if(n == 3){
        cout << 61 << endl;
        return 0;
    }
    int no[3] = {0,2,1};
    int dp[4][4][4][101] = {};
    auto f = [=](int i, int j, int k)->bool{
        bool ret = false;
        if(i==no[0]&&j==no[1]&&k==no[2])   ret = true;
        return ret;
    };
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            for(int k = 0; k < 4; k++){
                for(int l = 0; l < 4; l++){
                    bool ok = true;
                    if(f(i,j,k) || f(j,k,l))    ok = false;
                    swap(i,j);
                    if(f(i,j,k) || f(j,k,l))    ok = false;
                    swap(i,j); swap(j,k);
                    if(f(i,j,k) || f(j,k,l))    ok = false;
                    swap(j,k);  swap(k,l);
                    if(f(i,j,k) || f(j,k,l))    ok = false;
                    swap(k,l);
                    if(ok)  dp[j][k][l][3]++;
                }
            }
        }
    }

    for(int x = 3; x < n-1; x++){
        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 4; j++){
                for(int k = 0; k < 4; k++){
                    for(int l = 0; l < 4; l++){
                        bool ok = true;
                        if(f(i,j,k) || f(j,k,l))    ok = false;
                        swap(i,j);
                        if(f(i,j,k) || f(j,k,l))    ok = false;
                        swap(i,j); swap(j,k);
                        if(f(i,j,k) || f(j,k,l))    ok = false;
                        swap(j,k);  swap(k,l);
                        if(f(i,j,k) || f(j,k,l))    ok = false;
                        swap(k,l);
                        if(ok)  dp[j][k][l][x+1] += dp[i][j][k][x], dp[j][k][l][x+1]%=mod;
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            for(int k = 0; k < 4; k++){
                ans += dp[i][j][k][n-1];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;
typedef tuple<ll,ll,ll> tl;
typedef tuple<ll,ll,ll,ll> ql;
 
#define FOR(i, a, b) for(ll i=(a); i<=(b); i++)
#define ROF(i, a, b) for(ll i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define FILL(x, n, v) fill(x, x+n, v);
#define ALL(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define f first
#define s second
#define ins insert
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ft front
#define bk back
#define pp pop
#define ppb pop_back
#define ppf pop_front
 
#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';
 
const ll MOD = 1e9+7; //998244353
const ll MAXN = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
 
int main(){
    FAST
    ld r;
    cin >> r;
    cout << setprecision(10) << (ld)2*r*PI;
}

Measured memory_bytes: 3804
#include<iostream>
using namespace std;
 
int main(){
    int N;
    cin>>N;
     
    int d=0;
    int p[1000][3];
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            cin>>p[i][j];
        }
        for(int a=0;a<i;a++){
            if((p[i][0]==p[a][0]||p[i][0]==p[a][1]||p[i][0]==p[a][2])&&
               (p[i][1]==p[a][0]||p[i][1]==p[a][1]||p[i][1]==p[a][2])&&
               (p[i][2]==p[a][0]||p[i][2]==p[a][1]||p[i][2]==p[a][2])){
               d++;
               p[i][0]=0; p[i][1]=0; p[i][2]=0;
               break;
            }
        }
    }
     
     
     
    cout<<d<<endl;
     
    return 0;
}

Measured memory_bytes: 3108
C = [list(map(int, input().split())) for k in range(3)]

for k in range(2):
    if C[k][0]-C[k+1][0] != C[k][1]-C[k+1][1] or C[k][1]-C[k+1][1] != C[k][2]-C[k+1][2]:
        print("No")
        exit(0)
    elif C[0][k]-C[0][k+1] != C[1][k]-C[1][k+1] or C[1][k]-C[1][k+1] != C[2][k]-C[2][k+1]:
        print("No")
        exit(0)
print("Yes")

Measured memory_bytes: 3064
#include <cmath>
#include <iostream>

using namespace std;

typedef long long ll;

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

const ll MOD = 1000000007;
const int MAX =1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll solve(const int sx, const int sy) {
    int x = sx, y = sy;
    int n = 0, k = 0;

    while (y < 2 * x) {
        x--;
        y++;
    }

    if (y != 2 * x) {
        return 0LL;
    }

    n = x + 1;
    k = sx - x + 1;

    // cout << n << "," << k << endl;

    return COM(n - 1, k - 1);
}

int main(void) {
    int x, y;
    cin >> x >> y;

    COMinit();

    printf("%lld\n", solve(x, y));
    
    return 0;
}


Measured memory_bytes: 23680
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    val top = (n - 3) / 2 + 1
    val (cmpsts, sqrtLmtNdx) = (new Array[Int]((top >>> 5) + 1), (Math.sqrt(n).toInt - 3) / 2)

    def isCmpst(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) != 0
    def setCmpst(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    private def cull(cmpstId: Int, p: Int): Unit = {
      if(cmpstId <= top){
        setCmpst(cmpstId)
        cull(cmpstId + p, p)
      }
    }

    private def get(cndId: Int): Unit = {
      if(cndId <= sqrtLmtNdx){
        if(!isCmpst(cndId)){
          val p = 2 * cndId + 3
          cull((p * p - 3) >>> 1, p)
        }
        get(cndId + 1)
      }
    }

    private def next(cndId: Int): Int =
      if ((cndId > top) || !isCmpst(cndId)) 2 * cndId + 3 else next(cndId + 1)

    def exec: Iterator[Int] = {
      get(0)
      Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) >>> 1)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 65840
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin>>N;
	vector<int> H(N*2);

	for(int i=0;i<N*2;i++){
		cin>>H[i];
	}
	sort(H.begin(),H.end());
	int R=0;
	for(int i=0;i<N*2;i++){
		if(i%2==0){
			R+=H[i];
		}
	}


	cout<<R<<endl;
	return 0;
}


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

int main()
{
    int n; cin >> n;
    vector<int> ans(n+1);
    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= 100; y++)
        {
            for (int z = 1; z <= 100; z++)
            {
                int m = x * x + y * y + z * z + x * y + y * z + z * x;
                if (m <= n)
                {
                    ans[m]++;
                }
                else
                {
                    break;
                }
            }
        }
    }
    rep(i,n){
        cout << ans[i+1] << endl;
    }
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>

using namespace std;

vector<vector<int>> score(50,vector<int>(3));
vector<int> tscore(50,-1);
vector<int> rtscore(50,-1);

int main(){
  int cnt = 0;
  while(1){
    cin >> score.at(cnt).at(0) >> score.at(cnt).at(1) >> score.at(cnt).at(2);
    if(score.at(cnt).at(0) == -1 && score.at(cnt).at(1) == -1 && score.at(cnt).at(2) == -1) break;
    tscore.at(cnt) = score.at(cnt).at(0) + score.at(cnt).at(1);
    if(score.at(cnt).at(2) != -1) rtscore.at(cnt) = score.at(cnt).at(2);
    cnt++;
  }

  for(int i=0;i < cnt;i++){
    if(score.at(i).at(0) == -1 || score.at(i).at(1) == -1) cout << "F" << endl;
    else if(tscore.at(i) >= 80) cout << "A" << endl;
    else if(tscore.at(i) >= 65 && tscore.at(i) < 80) cout << "B" << endl;
    else if(tscore.at(i) >= 50 && tscore.at(i) < 65) cout << "C" << endl;
    else if(tscore.at(i) >= 30 && tscore.at(i) < 50){
      if(rtscore.at(i) >= 50) cout << "C" << endl;
      else cout << "D" << endl;
    }
    else if(tscore.at(i) < 30) cout << "F" << endl;
  }
  return 0;
}


Measured memory_bytes: 3160
n = int(input())
list_a = list(map(int, input().split()))

def calc(flag_sign):
  temp_flag = flag_sign
  sum_a = 0
  count = 0
  for one_a in list_a:
    if temp_flag:
      if sum_a + one_a > 0:
        sum_a += one_a
      else:
        count += abs(sum_a) - one_a + 1
        sum_a = 1
      temp_flag = False
    else:
      if sum_a + one_a < 0:
        sum_a += one_a
      else:
        count += abs(sum_a) + one_a + 1
        sum_a = -1
      temp_flag = True
  return count
    
print(min(calc(True), calc(False)))

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

int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	int r,s,p;
	scanf("%d %d %d",&r,&s,&p);
//	cout << r << " " << s << " " << p << endl;
	string t;
	cin >> t;
	ll cnt = 0;
	for(int i = 0;i < k;i++){
		if(t[i] == 'r') cnt += p;
		if(t[i] == 's') cnt += r;
		if(t[i] == 'p') cnt += s;
//		cout << cnt << endl;
	}
	for(int i = k;i < n;i++){
		if(t[i] == t[i-k]){
			t[i] = 'a';
			continue;
		}
		else{
			if(t[i] == 'r') cnt += p;
			if(t[i] == 's') cnt += r;
			if(t[i] == 'p') cnt += s;
		}
//		cout << "i = " << i << " " << cnt << endl;
	}
//	cout << t << endl;
	cout << cnt << endl;
	return 0;
} 

Measured memory_bytes: 512
using System;
using System.Linq;

class cs
{
    static void Main()
    {
        var l = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

        long X = l[0]; 
        var K = l[1]; 
        var D = l[2]; 

        long ans = 0; 

        var moveTimesToRoundTrip = Math.Abs(X) / D;

        if (moveTimesToRoundTrip >= K)
        {
            // 往復移動をしない場合
            // 現在地から移動回数*移動距離を足し引きして求める
            if (X >= 0)
            {
                ans = X - K * D;
            }
            else
            {
                ans = X + K * D;
            }
        }
        else
        {
            // 往復移動をする場合

            // distanceBeforeRoundTrip: 往復移動する前の距離
            var distanceBeforeRoundTrip = X % D;

            // roundTripTimes: 往復回数
            // 原点近くにたどり着くまでにmoveTimesToRoundTripかかる
            // 残りの回数roundTripTimesは原点をまたいで-D, +Dを繰り返す
            var roundTripTimes = K - moveTimesToRoundTrip;

            if (roundTripTimes % 2 == 0)
            {
               
                ans = distanceBeforeRoundTrip;
            }
            else
            {
                
                if (distanceBeforeRoundTrip > 0)
                {
                    ans = distanceBeforeRoundTrip - D;
                }
                else
                {
                    ans = distanceBeforeRoundTrip + D;
                }
            }
        }

        Console.WriteLine(Math.Abs(ans));

    }
}


Measured memory_bytes: 28252
fun main(args: Array<String>) {
    // Your code here!
    var n = readLine()!!.toInt()
    var s = readLine()!!
    var msg = "No"
    
    if(n % 2 == 0){
        for(i in 0..n/2){
            val buil = StringBuilder()
            buil.append(s.substring(0,i)).append(s.substring(0,i))
            if(buil.toString() == s){
                msg = "Yes"
            }
        }
    }
    print(msg)
}


Measured memory_bytes: 33788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n, k, q;
    cin >> n >> k >> q;
    ll a[q];
    rep(i, 0, q){
        cin >> a[i];
        a[i]--;
    }

    ll p[n];
    rep(i, 0, n){
        p[i] = k - q;
    }

    rep(i, 0, q){
        p[a[i]]++;
    }

    ll num = n;
    rep(i, 0, n){
        if(p[i] <= 0){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>
#define NIL -1

typedef struct Node{int p,l,r;}tree;
tree T[10000];
int ten;

void preParse(int u){
  if(u==NIL)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v,l,r,root;

  scanf("%d",&ten);

  for(i=0;i< ten;i++)T[i].p=NIL;

  for(i=0;i<ten;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l=l; T[v].r=r;
    if(l!=NIL) T[l].p=v;
    if(r!=NIL) T[r].p=v;
  }

  for(i=0;i<ten;i++)if(T[i].p==NIL)root=i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  return 0;
}




Measured memory_bytes: 2004
/*    三玖天下第一！！！  */
#include<bits/stdc++.h>
using namespace std;
int n,d[105]={};
long long ans=0;
inline int dread()
{
	int x=0;bool f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) f^=(ch=='-');
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch^48);
	return f?x:-x;
}
inline void Kaslana()
{
	n=dread();
	for(int i=1;i<=n;i++) d[i]=dread();
}
inline void Raiden()
{
	for(int i=1;i<n;i++) for(int j=i+1;j<=n;j++) ans+=1LL*d[i]*d[j];
}
inline void Zaychik()
{
	printf("%lld\n",ans);
}
int main()
{
    Kaslana(),Raiden(),Zaychik();return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

//ll mod = 1000000007;
ll mod = 998244353;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

vector<pair<ll, ll>> prime_factorize(ll N) {
	vector<pair<ll,ll>> res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0; 
		while (N % a == 0) {
			++ex;
			N /= a;
		}
		res.push_back({ a, ex });
	}
	if (N != 1) res.push_back({ N, 1 });
	return res;
}


int main() {
	char c;
	cin >> c;
	if (isupper(c)) {
		cout << "A" << endl;
	}
	else {
		cout << "a" << endl;
	}
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		String str=in.nextLine(); char[] C=str.toCharArray();
		
		for(int i=0;i<C.length;i++) {
			if(C[i]>=65 && C[i]<=90)C[i]+=32;
			else if(C[i]>=97 && C[i]<=122)C[i]-=32;
			out.print(C[i]);
		}
		out.println();
		out.flush();
	}

}



Measured memory_bytes: 26072
#include<iostream>
#include<string>
using namespace std;
int main(){
  int r , k=1;
  cin>>r;
  string s;
  cin>>s;
  for(int i=0;i<r/2;i++){
    if(s[i]!=s[i+r/2]) k=0;
  }
  if(r%2!=0) cout<<"No"<<endl;
  else{
    if(k==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
int main(){
    int n;cin>>n;
    VI even,odd;
    unordered_map<int,int>me,mo;
    rep(i,n){
        ll a;cin>>a;
        if(i%2==0){
            even.push_back(a);
            me[a]++;
            }
        else{ 
            odd.push_back(a);
            mo[a]++;
        }
    }
    P e_fi=P(0,0),e_se=P(0,0),o_fi=P(0,0),o_se=P(0,0);
    
    for(auto v:me){
        if(e_fi.se<=v.se){
            e_se=e_fi;
            e_fi=P(v.fi,v.se);
        }
        else if(e_se.se<v.se){
            e_se=v;
        }
    }
    for(auto v:mo){
        if(o_fi.se<=v.se){
            o_se=o_fi;
            o_fi=P(v.fi,v.se);
        }
        else if(o_se.se<v.se)o_se=v;
    }
    if(e_fi.fi!=o_fi.fi){
        cout<<n-e_fi.se-o_fi.se<<endl;return 0;
    }
    else{
        int one=n-e_fi.se-o_se.se,two=n-e_se.se-o_fi.se;
        cout<<min(one,two)<<endl;return 0;
    }
}


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


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

    for (int i = 1; i <= 5; i++) {
        cin >> x;
        if (x == 0) {
            cout << i << '\n';
            return 0;
        }
    }
 
    return 0;
}

Measured memory_bytes: 3604
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	s       = bufio.NewScanner(os.Stdin)
	n, k, w = 0, 0, []int{}
)

func check(p int) int {
	i := 0
	for j := 0; j < k; j++ {
		s := 0
		for s+w[i] <= p {
			s += w[i]
			i++
			if i == n {
				return n
			}
		}
	}
	return i
}

func binarySearch() int {
	left, right := 0, 100000*100000
	for right-left > 1 {
		mid := (left + right) / 2
		v := check(mid)
		if v >= n {
			right = mid
			continue
		}
		left = mid
	}
	return right
}

func main() {
	s.Split(bufio.ScanWords)

	n = nextInt(s)
	k = nextInt(s)
	w = make([]int, n)

	for i := range w {
		w[i] = nextInt(s)
	}
	fmt.Println(binarySearch())
}

func nextInt(s *bufio.Scanner) int {
	s.Scan()
	r, err := strconv.Atoi(s.Text())
	if err != nil {
		panic(err)
	}
	return r
}



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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s, t;
	cin >> s >> t;
	int ct = 0;
	for(int i=0; i < s.length(); i++){
		if(s[i] != t[i]) ct++;
	}
	cout << ct << endl;

	return 0;
}


Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <cmath>
using namespace std; 
#define N 100002
vector<int>g[N];
int parent[N], dis[N];
int n, num=0;
void dfs(int cur, int par){
	int i, now;
	dis[cur] = dis[par] + 1;
	
	for(i=0; i<g[cur].size(); i++){
		now = g[cur][i];		
		if(now == par)
			continue;
		parent[now] = cur;
		dfs(now, cur);
	}
}
// 求一棵子树中结点的数量 
void dfs1(int cur, int par){
	int i, now;
	num++;	
	for(i=0; i<g[cur].size(); i++){	
		now = g[cur][i];	
		if(now == par)
			continue;
		dfs1(now, cur);
	}
}

int main(){
	int i, to, from, k, cur, cnt, par;
	cin>>n;
	for(i=0; i<n-1; i++){
		cin>>to>>from;
		g[to].push_back(from);
		g[from].push_back(to);
	}
	// 求1到其他顶点的距离 
	dis[0] = -1;
	dfs(1, 0);
	k = dis[n] - 1;
	
	cur = n;
	par = parent[cur];
	cnt = 0;
	//cout<<k<<endl;
	// 从第n个顶点出发，通过parent向根节点回溯 
	while(1){	
		if(cnt>=k/2 || par == 1)
			break;
		cur = par;
		par = parent[cur];		
		cnt++;	
	}
	//cout<<cur<<' '<<par<<endl; 
	dfs1(cur, par);
	//cout<<num<<endl;
	if(num>=n-num)
		cout<<"Snuke";
	else
		cout<<"Fennec"; 
}

Measured memory_bytes: 11136
import Control.Applicative

solve a b
  | a > 0 && b > 0 = "Positive"
  | a * b <= 0 = "Zero"
  | otherwise = if (a-b)`mod`2 == 0 then "Negative" else "Positive"

main :: IO()
main = do
  [a, b] <- map (read::String->Int) . words <$> getLine
  putStrLn $ solve a b


Measured memory_bytes: 508
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (PrintWriter out = new PrintWriter(System.out); Scanner sc = new Scanner(System.in);) {
            Task task = new Task();
            task.solve(sc, out);
            out.flush();

        } catch (Exception e) {
            // DO NOT USE
        }
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
            // TODO
            int a = nint(sc);
            int b = nint(sc);

            if(a % 2 != 0 && b %2 != 0){
                out.println("Yes");
                return;
            }

            out.println("No");
        }
    }

    // method
    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return sc.next();
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    
    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s,n=map(int,input().split())
if n>0:
	x=list(int(input()) for _ in range(n))

w0=int(1)
b0=int(0)
cnt=0

for i in range(1,s):
	if n>0 and i==x[cnt]:
		w1=int(0)
		b1=w0
		w0=w1
		b0=b1
		if cnt<n-1: 
			cnt+=1
	else:
		w1=b0+w0
		b1=w0
		w0=w1
		b0=b1

print((w0+b0)%1000000007) 

Measured memory_bytes: 7068
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;

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

  int n;
  cin >> n;
  vi a(n);
  rep(i, n)cin >> a[i];

  ll ans=0;
  rep(i, n-1){
    if(a[i]>a[i+1]){
      ans+=a[i]-a[i+1];
      a[i+1]=a[i];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3984
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

ll INF = 1e9 + 7;

ll n, m;

bool calc(ll x) {
	if (n >= x) {
		if (m >= 2 * x) return true;
		else return false;
	}
	else {
		ll k = x - n;
		if (m >= (2*x+2*k)) return true;
		else return false;
	}
}

int main() {
	cin >> n >> m;
	ll l = 0, r = 1e12;
	while (r - l > 1) {
		if (calc((l + r) / 2)) l = (l + r) / 2;
		else r = (l + r) / 2;
	}
	cout << l << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::cerr;
using std::endl;

namespace chrono = std::chrono;
using namespace std::literals;

[[gnu::constructor]]
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}

int foo(int a, int x) {
    if (a < x) {
        return (x - a + 1) / 2 + (x - a) % 2;
    } else {
        return a - x;
    }
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int x = std::max({a, b, c});

    int u = foo(a, x) + foo(b, x) + foo(c, x);
    x -= 1;
    int v = foo(a, x) + foo(b, x) + foo(c, x);
    cout << std::min(u, v) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=100000;
typedef long long ll;
typedef pair<int,int> P;

int main(){
   int N,A,B;
   cin >> N >> A >> B;
   int x=N*A;
   cout << min(x,B) << endl;
}


Measured memory_bytes: 256
s = input()
t = input()
n1, n2 = len(s), len(t)
dp = [[0] * (n2 + 1) for _ in range(n1 + 1)]
for i in range(1, n1 + 1):
	for j in range(1, n2 + 1):
		if s[i - 1] == t[j - 1]:
			dp[i][j] = dp[i - 1][j - 1] + 1
		else:
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
res = ''
i, j = n1 , n2
while i >= 1 and j >= 1:
	if s[i - 1] == t[j - 1]:
		res += s[i - 1]
		i -= 1
		j -= 1
	elif dp[i][j] == dp[i - 1][j]:
		i -= 1
	else:
		j -= 1
print(res[::-1])

Measured memory_bytes: 112220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

	int X, Y, Z;
	cin >> X >> Y >> Z;

	X = X - Z;

	co(X / (Y + Z));
	Would you please return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int n, d, i=0, m=0;
    
    scanf("%d%d",&n,&d);
    
    while(m<n){
        i++;
        m=i*(1+2*d);
    }
    printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 1708
#include <deque>
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
struct state { long long a, b; };
inline bool operator<(const state& s1, const state& s2) { return s1.a < s2.a; }
int N; long long D, A[33], B[33];
long long sa1[32777], sb1[32777], sa2[32777], sb2[32777]; // bit-dp sum
int cnt1, cnt2; state vl[14348922], vr[14348922]; // meet-in-the middle
int main() {
	scanf("%d%lld", &N, &D);
	for (int i = 0; i < N; i++) scanf("%lld%lld", &A[i], &B[i]);

	// Meet-in-the-middle Algorithm
	int sep1 = (N >> 1), sep2 = N - sep1;
	for (int i = 0; i < sep1; i++) {
		int b1 = (1 << i), b2 = (1 << (i + 1));
		for (int j = b1; j < b2; j++) {
			sa1[j] = sa1[j - b1] + A[i];
			sb1[j] = sb1[j - b1] + B[i];
		}
	}
	for (int i = 0; i < sep2; i++) {
		int b1 = (1 << i), b2 = (1 << (i + 1));
		for (int j = b1; j < b2; j++) {
			sa2[j] = sa2[j - b1] + A[i + sep1];
			sb2[j] = sb2[j - b1] + B[i + sep1];
		}
	}
	cnt1 = 0;
	for (int i = 0; i < 1 << sep1; i++) {
		int r = (1 << sep1) - i - 1, j = r;
		do {
			// i -> remain, j -> anna, k -> bruno
			int k = r - j;
			vl[cnt1++] = state{ sa1[k] - sa1[j], sb1[k] - sb1[j] };
			j = (j - 1) & r;
		} while (j != r);
	}
	cnt2 = 0;
	for (int i = 0; i < 1 << sep2; i++) {
		int r = (1 << sep2) - i - 1, j = r;
		do {
			// i -> remain, j -> anna, k -> bruno
			int k = r - j;
			vr[cnt2++] = state{ sa2[k] - sa2[j], sb2[k] - sb2[j] };
			j = (j - 1) & r;
		} while (j != r);
	}
	sort(vl, vl + cnt1);
	sort(vr, vr + cnt2);
	int cl = 0, cr = 0;
	deque<int> que;
	long long ret = 0;
	for (int i = cnt2 - 1; i >= 0; i--) {
		while (cr < cnt1 && vl[cr].a + vr[i].a <= D) {
			while (!que.empty() && vl[que.back()].b <= vl[cr].b) que.pop_back();
			que.push_back(cr);
			cr++;
		}
		while (cl < cnt1 && vl[cl].a + vr[i].a < -D) {
			if (!que.empty() && que.front() == cl) que.pop_front();
			cl++;
		}
		if (!que.empty()) ret = max(ret, vr[i].b + vl[que.front()].b);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 452100
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    int n;
    cin >> n;
    rep(i, 11) {
        if (n <= i * 1000) {
            cout << i * 1000 - n << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    lunlun = [i for i in range(10)]
    def make(s,keta):
        lst = []
        end = int(s[-1])
        if end == 0:
            lst = [s+"0",s+"1"]
        elif end == 9:
            lst = [s+"8",s+"9"]
        else:
            lst = [s+str(end+i) for i in range(-1,2)]
        if keta == 1:
            for lun in lst:
                lunlun.append(int(lun))
        else:
            for lun in lst:
                make(lun,keta-1)
            
    for keta in range(1,10):
        for i in range(1,10):
            make(str(i),keta)

    k = I()
    ans = lunlun[k]
    print(ans) 
                
        

main()


Measured memory_bytes: 88240
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 998244353
#define MAX 100009
#define endl '\n'
#define mp make_pair
#define INF 1000000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define F first
#define S second
 
using namespace std;

bool isprime(ll n){			//to check whteher no is prime or not
	if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

ll power(ll a,ll n){
	ll ans=1;
	while(n){
		if(n%2!=0){
			ans=((ans%mod)*(a%mod))%mod;
			n--;
		}
		else{
			a=((a%mod)*(a%mod))%mod;
			n/=2;
		}
	}
	return ans;
}

int main(){
	fast
//	int t;
//	cin>>t;
//	while(t--){
		ll a,b,c,d,n,m;
		ld p,q,r,s;
		cin>>a>>b>>c>>d;
		//bool flag=1;
		int x,y;
		x=c/b;
		if(c%b!=0)	x++;
		y=a/d;
		if(a%d!=0)	y++;
		int flag=1;
		while(a>0&&c>0){
			if(flag==1){
				c-=b;
				flag=0;
			}
			else{
				a-=d;
				flag=1;
			}
		}
		if(a<=0)	cout<<"No";
		else	cout<<"Yes";
//	}
}



Measured memory_bytes: 3628
#include<cstdio>
#include<set>
using namespace std;
set<int>s;
set<int>:: iterator it;

int ans=0,i,n,x;
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&x);
		it=s.find(x);
		if (it!=s.end())
		{
			//it=s.find(x);
			s.erase(it);
			ans--;
		}
		else
		{
			ans++;
			s.insert(x);
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 4864
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
long long min(long long a, long long b){
    if(a < b) return a;
    else return b;
}
long long max(long long a, long long b){
    if(a < b) return b;
    else return a;
}
int main(){
  int n;
  scanf("%d",&n);
  if(n%10==3){
    printf("bon");
  }
  else if(n%10==0 || n%10==1  || n%10==6 || n%10==8){
    printf("pon");
  }
  else{
    printf("hon");
  }
  return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <climits>
using namespace std;

typedef vector<int>			vi;
typedef vector<vi>			vvi;
typedef vector<vvi>			vvvi;
typedef long long int 		ll;
typedef vector<ll>			vll;
typedef vector<vll>			vvll;
typedef vector<vvll>		vvvll;

typedef pair<int, int>		ii;
typedef vector<ii>			vii;
typedef set<int> 			si;


int main(){

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

	int n, m;
	cin >> n >> m;

	vi count(n + 1, 0);

	int l, r;
	for(int i = 0; i < m; i++){
		cin >> l >> r;
		count[l - 1]++;
		count[r]--;
	}

	int ans = (count[0] == m ? 1 : 0);
	for(int i = 1; i <= n; i++){
		count[i] = count[i - 1] + count[i];
		if(count[i] == m)
			ans++;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#define FLG 1001
using namespace std;
class DisjointSet{
private:
  vector<int> rank,p;
  int fib[FLG+1];
  void link(int x,int y){
    if(rank[x] > rank[y]){
      p[y] = x;
    }else{
      p[x] = y;
      if(rank[x] == rank[y]) rank[y]++;
    }
  }
public:
  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size+1,0);
    p.resize(size+1,0);
    FIB();
  }
  void makeSet(int x){
    p[x] = x;
    rank[x] = 0;
  }
  void Union(int x,int y){
    link(findSet(x),findSet(y));
  }
  int findSet(int x){
    if(x != p[x]) p[x] = findSet(p[x]);
    return p[x];
  }
  bool isSameOut(int x,int y){
    return (findSet(x)==findSet(y));
  }
  void FIB(){
    fib[0]=2,fib[1]=3,p[0]=0,p[1]=1;
    for(int i=2;i<=FLG;i++){
      fib[i] = (fib[i-1]+fib[i-2]) % FLG;
      p[i] = i;
    }
  }
  int FIBGET(int x){
    return fib[x];
  }
};
int main(){
  int V,d;
  while(cin >> V >> d){
    DisjointSet D(1001);
    for(int i=0,l=V%FLG;i<l;i++){
      for(int j=i+1;j<l;j++){
	int a=D.FIBGET(i),b=D.FIBGET(j);
	if(abs(a-b)<d){
	  if(!D.isSameOut(i,j)) D.Union(i,j);
	}
      }
    }
    int ans = 0,list[1002]={0};
    for(int i=0,l=V%FLG;i<l;i++){
      int root = D.findSet(i);
      if(list[root]==0){
	list[root]=1;
	ans++;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1208
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int a, b, c; cin >> a >> b >> c;
	cout << ( a <= c && c <= b ? "Yes" : "No" ) << endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map { it.toInt() }
    var count = 0
    var min = 1000000000

    for (i in 0 until n) {
        min = if (min < p[i]) min else p[i]
        if (min == p[i]) count++
    }
    println(count)
}

Measured memory_bytes: 82856
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = unsafe { _read_value!(_scanned, $t) };
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

fn main() {
    input! {
        n: usize,
        m: u64,
        abs: [(u64, u64); n],
    }
    let mut abs = abs;
    abs.sort_by_key(|&(a, _)| a);
    let (mut r, mut m) = (0, m);
    for (a, b) in abs {
        if m <= b {
            r += a * m;
            println!("{}", r);
            return;
        } else {
            r += a * b;
            m -= b;
        }
    }
    unreachable!();
}


Measured memory_bytes: 8444
s = int(input())
a = [s]
c = 0
while True:
  c += 1
  if s % 2 == 0:
    s = s/2
  else:
    s = 3 * s + 1
  if s not in a:
  	a.append(s)
  else:
    break
print(c+1)
  

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
    int H, W;
    while(true){
    cin >> H >> W;
        if(H == 0 && W == 0)
            break;
        for (int i = 0; i < H; i++){

            for (int j = 0; j < W; j++){
              cout << "#";
            }

            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B;
  cin >> A >> B;
  if(A%3==0||B%3==0||(A+B)%3==0)
  {
    cout << "Possible" << endl;
  }
  else
  {
    cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans=INT_MAX,temp,num[105];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&num[i]);
	for(int i=-100;i<=100;i++)
	{
		temp=0;
		for(int j=1;j<=n;j++)
		{
			temp+=(num[j]-i)*(num[j]-i);
		}
		ans=min(temp,ans);
	}
	printf("%d",ans);
}

Measured memory_bytes: 256