akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

inline double add(double a, double b){
    return abs(a+b)<(1e-10)*(abs(a)+abs(b)) ? 0.0 : a+b;
}

struct vec{
    double x,y;
    vec operator-(vec b){
        return (vec){add(x,-b.x),add(y,-b.y)};
    }
    vec operator+(vec b){
        return (vec){add(x,b.x),add(y,b.y)};
    }
    vec operator*(double d){
        return (vec){x*d,y*d};
    }
    double dot(vec v){
        return add(x*v.x,y*v.y);
    }
    double cross(vec v){
        return add(x*v.y,-y*v.x);
    }
    double norm(){
        return sqrt(x*x+y*y);
    }
};
typedef vector<vec> polygon;

int ccw(vec& a, vec& b, vec& c){
    vec ab = b-a, ac = c-a;
    double o = ab.cross(ac);
    if(o>0) return 1; //CCW
    if(o<0) return -1; //CW
    if(ab.dot(ac)<0){
        return 2; //C-A-B
    }else{
        if(ab.dot(ab)<ac.dot(ac)){
            return -2; //A-B-C
        }else{
            return 0; //A-C-B
        }
    }
}

bool isOnEdge(polygon& g,vec& p){
    int n=g.size()-1;
    for(int i=0;i<n;i++){
        if(!ccw(g[i],g[i+1],p)) return true;
    }
    return false;
}
/**
bool isInterSection(vec& p0,vec& p1,vec& p2,vec& p3){//??????p[0]p[1]??¨p[2]p[3]
    switch(ccw(p0,p1,p2)*ccw(p0,p1,p3)){//
        case -1:
        case -4:
        case 0://?????§?§???????????????????????????????????????????????????????0??§return true;?????????
            break;
        default:
            return false;
    }
    switch(ccw(p2,p3,p0)*ccw(p2,p3,p1)){
        case -1:
        case -4:
        case 0://?????§?§???????????????????????????????????????????????????????0??§return true;?????????
            break;
        default:
            return false;
    }
   return true;
}
**/

int isInterSection(vec& p0,vec& p1,vec& p2,vec& p3){//??????p[0]p[1]??¨p[2]p[3]
    switch(ccw(p0,p1,p2)*ccw(p0,p1,p3)){
        case -1:
        case -4:
            break;
        case 0:
            return ~(ccw(p0,p1,p2)|ccw(p0,p1,p3))?2:-1;
        default:
            return 0;
    }
    switch(ccw(p2,p3,p0)*ccw(p2,p3,p1)){
        case -1:
        case -4:
        case 0:
            break;
        default:
            return 0;
    }
    return 1;
}

bool isInside(polygon& g,vec& p){
    int n=g.size()-1,c=0;
    vec O = (vec){-10001,-10001};
    for(int i=0;i<n;i++){
        c+=isInterSection(O,p,g[i],g[i+1]);
    }
    if(c%2) return true;
    else return false;
}

int main(){
    int n;
    cin >> n;
    polygon g;
    vec v;
    while(n--){
        cin >> v.x >> v.y;
        g.push_back(v);
    }
    g.push_back(g[0]);

    cout.precision(1);
    cout << fixed;

    cin >> n;
    while(n--){
        cin >> v.x >> v.y;
        if(isOnEdge(g,v)){
            cout << 1 << endl;
        }else if(isInside(g,v)){
            cout << 2 << endl;
        }else{
            cout << 0 << endl;
        }
    }
    return 0;
}

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

const double INF=10000;

double color[8][3]=
{0,0,0,
0,0,255,
0,255,0,
0,255,255,
255,0,0,
255,0,255,
255,255,0,
255,255,255
};
string colors[8]=
{"black",
"blue",
"lime",
"aqua",
"red",
"fuchsia",
"yellow",
"white"
};

int main(void){
    while(1){
        string str;
        cin >> str;
        if(str=="0")break;
        double c[3]={0,0,0};
        for(int i=0;i<3;i++){
            if(str[i*2+1]>='a' && str[i*2+1]<='f'){
                c[i]+=(str[i*2+1]-'a'+10)*16;
            }else c[i]+=(str[i*2+1]-'0')*16;
            if(str[i*2+2]>='a' && str[i*2+2]<='f'){
                c[i]+=str[i*2+2]-'a'+10;
            }else c[i]+=str[i*2+2]-'0';
        }
        double adk=INF;
        int ans=0;
        for(int i=0;i<8;i++){
            double dk=sqrt(pow(abs(c[0]-color[i][0]),2)+pow(abs(c[1]-color[i][1]),2)+pow(abs(c[2]-color[i][2]),2));
            if(adk>dk){
                ans=i;
                adk=dk;
            }
        }
        cout << colors[ans] << endl;
    }
    return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>

int main(void)
{
  int x;

  scanf("%d", &x);

  if(x < 0) {
  } else if(x < 1200) {
    printf("ABC\n");
  } else if(x <= 3000){
    printf("ARC\n");
  } else {
  }
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000;
#define mod MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    ll n; cin >> n;
    ll m = n;
    int digit = 0;
    int first_digit = 0;
    int ans = 0;
    while(m > 0){
        digit++;
        if(m < 10 && m > 0){
            first_digit = m%10;
        }
        m /= 10;
    }
    ans = 9*(digit-1) + first_digit;
    ll n_moto = first_digit;

    for(int i = 0; i < digit-1; i++){
        n_moto = n_moto*10 + 9;
    }
    if(n_moto > n) ans -= 1;
    cout << ans << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
t = 0
for i in range(1, 10000):
    t += ((1800 * M + 100 * N) * i) * ((1 - (1 / 2) ** M) ** (i - 1)) * ((1 / 2) ** M)
if str(int(t))[-1] == "9":
    print(int(t) + 1)
else:
    print(int(t))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC159E()
{
	int H, W, K;
	cin >> H >> W >> K;
	vvi S(H, vi(W));
	for (int i = 0; i < H; ++i)
	{
		string X;
		cin >> X;
		for (int j = 0; j < W; ++j)
		{
			S[i][j] = X[j];
		}
	}

	int ct = 2000;
	for (int i = 0; i < (1 << (H - 1)); ++i)
	{
		int c = 0;
		vi x(1,-1);
		for (int j = 0; j < H - 1; ++j)
		{
			int y = i & (1 << j);
			if (y > 0)
			{
				++c;
				x.push_back(j);
			}
		}
		x.push_back(H - 1);
		int l = 0;
		int d = 0;
		vi z(x.size());
		bool isOk = true;
		int prev = 0;
		for (int j = 0; j < W; ++j)
		{
			bool isHit = false;
			for (int b = 1; b < x.size(); ++b)
			{
				for (int k = x[b - 1] + 1; k <= x[b]; ++k)
				{
					if (S[k][j] == '1')
					{
						++z[b];
						if (z[b] == K + 1 && j == prev)
						{
							isOk = false;
							break;
						}
						if (z[b] == K + 1)
						{
							--j;
							++c;
							fill(z.begin(), z.end(), 0);
							isHit = true;
							prev = j;
							break;
						}
					}
				}
				if (!isOk)
					break;
				if (isHit)
					break;
			}
			if (!isOk)
				break;
		}
		if (!isOk)
			continue;
		ct = min(ct, c);
	}
	cout << ct << endl;

}


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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		
		int d = (int)a / (int)b;
		int r = (int)a % (int)b;
		double f = a / b;
		
		System.out.printf(d + " " + r + " " + " " + "%.5f",f);
		
		sc.close();
	}

}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m),b(m),ans(n);
    for (int i = 0;i < m;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    for (int i = 0;i < m;i++){
        ans[a[i]]++;
        ans[b[i]]++;
    }

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

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = INF + 7;
const ld PI = acos(-1.0);
int fun(int n)
{
	if(n == 2 || n == 3)
		return 1;
	for(int i=2 ; i*i <= n ;i++)
		if(n%i==0)
			return 0;
	return 1;
}
int32_t main(){
	fast;
	int n;
	cin >> n;
	
	while(1)
	{
		if(fun(n))
		{
			cout << n;
			return 0;
		}
		n++;
	}
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int n;
    cin >> n;
    
    bool flg = false;
    for(int i = 1; i <= 9; i++){
        if(n % i == 0 && n / i <= 9){
            flg = true;
            break;
        }
    }
    
    if(flg){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
    
}


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

const int maxn=1e5+100;
char s[maxn];
int main(){
	cin>>s;
	int len=strlen(s);
	bool flag=0;
	for(int i=0;i<len;i++){
		if(s[i]==s[i+1]){
			printf("%d %d\n",i+1,i+2);
			flag=1;
			break;
		}
		else if(s[i]==s[i+2]){
			printf("%d %d\n",i+1,i+3);
			flag=1;
			break;
		}
	}
	if(!flag){
		printf("-1 -1\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;cin>>N>>M;vector<bool>V(N,true);vector<int>F(N);int P=0;int A=0;
  for(int X=0;X<M;X++){
    int L;string S;cin>>L>>S;
    if(V[L-1]&&S=="WA"){
      P++;F[L-1]++;
    }
    if(V[L-1]&&S=="AC"){
      A++;V[L-1]=false;
    }
  }
  for(int X=0;X<N;X++){
    if(V[X])P-=F[X];
  }
  cout<<A<<" "<<P<<endl;
}


Measured memory_bytes: 3692
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N,T;
	int[] imos;
	public void solve() {
		N = nextInt();
		T = nextInt();
		imos = new int[T + 2];

		for(int i = 0;i < N;i++){
			int l = nextInt();
			int r = nextInt();

			imos[l]++;
			imos[r]--;
		}

		int ans = imos[0];

		for(int i = 0;i < T + 1;i++){
			imos[i + 1] += imos[i];
			ans = Math.max(ans,imos[i + 1]);
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  in(int, N, M, Q);

  VV<int> trains(N + 1, V<int>(N + 1));
  rep(i, M) {
    in(int, L, R);
    trains[L][R]++;
  }

  VV<int> sum(N + 2, V<int>(N + 2));
  for (int l = N; l >= 1; --l) {
    for (int r = 1; r <= N; ++r) {
      sum[l][r] =
          sum[l + 1][r] + sum[l][r - 1] - sum[l + 1][r - 1] + trains[l][r];
    }
  }

  rep(i, Q) {
    in(int, p, q);
    out(sum[p][q]);
  }
}


Measured memory_bytes: 5312
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

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

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

long long int DP[1100][1100] = {};

int main(){
	
	long long int n, k;
	cin >> n >> k;
	DP[0][0] = 1;
	for(int i = 0; i <= n; i++){
		for(int j = 1; j <= k; j++){
			DP[i][j] = DP[i][j - 1];
			if(i >= j){
				DP[i][j] += DP[i - j][j];
			}
			DP[i][j] %= MOD;
		}
	}
	
	cout << DP[n][k] << endl;
	
	return 0;
}


Measured memory_bytes: 11704
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const int IINF = 1e9;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

template <typename T>
void dumpvec(vector<T> vec) {
  for (T cnt : vec) {
    cout << cnt << ", ";
  }
  cout << endl;
}

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}

vector<string> split(string s, string delimiter) {
  int first = 0;
  int last = s.find_first_of(delimiter);
  vector<string> result;

  while (first < s.size()) {
    string sub = s.substr(first, last - first);
    result.push_back(sub);
    first = last + 1;
    last = s.find_first_of(delimiter, first);

    if (last == string::npos) {
      last = s.size();
    }
  }

  return result;
}

string join(vector<string> strings, string delimiter) {
  string result = "";
  for (int i = 0; i < strings.size(); i++) {
    if (result != "") result += delimiter;
    result += strings[i];
  }
  return result;
}

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += i;
  }
  cout << ans << endl;
}

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

#define ll long long

ll extgcd(ll a, ll b, ll & x, ll & y) {
	ll g = a; x = 1; y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int a, b; cin >> a >> b;
	long long x, y;
	extgcd(a, b, x, y);

	cout << x << " " << y << endl;
}

Measured memory_bytes: 3176
W, H, N  = map(int,input().split()) 
l = 0; r = W; u = H; d = 0 

for i in range(N):
    x, y, a = map(int,input().split()) 
    if a == 1:
        l = max(l,x) 
    elif a == 2:
        r = min(r,x) 
    elif a == 3:
        d = max(d,y) 
    else:
        u = min(u,y) 

print(max(0,(r-l))*max(u-d, 0)) 

Measured memory_bytes: 9144
#include <stdio.h>
#include <math.h>

int main(){
  int i,n,p,flag=0;

  scanf("%d %d",&n,&p);
  int a[n];
  for(i=0;i<n;i++){
    scanf(" %d",&a[i]);
    if(a[i]%2!=0&&flag==0){
      flag=1;
    }
  }
  long long x;
  x=(long long)pow(2,n);
  if(flag==0){
    if(p==0){
      printf("%lld",x);
      return 0;
    }else{
      printf("0");
      return 0;
    }
  }else{
    printf("%lld",x/2);
    return 0;
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);cout.tie(NULL);
int a,b,c;
cin>>a>>b>>c;
if(a+b+c>=22)
cout<<"bust";
else
cout<<"win";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
#define rrep(i, n) for(i = n - 1; i >= 0; i--)
using namespace std;

int digit(int x) {
	int ret = 0;
	while (x > 0) {
		ret += x % 10;
		x /= 10;
	}
	return ret;
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a <= digit(i) && digit(i) <= b) {
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

S_list = []
for h in range(1, H):
    w = W//2
    S_A = h*W
    S_B = (H-h)*w
    S_C = (H-h)*(W-w)
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
for h in range(1, H):
    S_A = h*W
    S_B = ((H-h)//2)*W
    S_C = -(-(H-h)//2)*W
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
H, W = W, H
for h in range(1, H):
    w = W//2
    S_A = h*W
    S_B = (H-h)*w
    S_C = (H-h)*(W-w)
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
for h in range(1, H):
    S_A = h*W
    S_B = ((H-h)//2)*W
    S_C = -(-(H-h)//2)*W
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
print(min(S_list)) 
    

Measured memory_bytes: 18932
# -*- coding: utf-8 -*-


def main(a, b):
    hit = 0
    blow = 0

    for a_e, b_e in zip(a, b):
        if a_e == b_e:
            hit += 1
        elif a_e in b:
            blow += 1

    print(hit, blow, sep=' ')

while True:
    try:
        a = [int(e) for e in input().split()]
        b = [int(e) for e in input().split()]
    except:
        break

    main(a, b)

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

int main(){

	for(int y = 0; y < 9; ++y){
		for(int x = 0; x < 9; ++x){
			cout << y+1 << 'x' << x+1 << '=' << (x+1) * (y+1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NMX = Sarray();
            var N = NMX[0];
            var M = NMX[1];
            var X = NMX[2];
            var C = new long[N];
            var A = new long[N][];
            var Asum = new long[M];
            for (var i = 0; i < N; ++i)
            {
                var ca = Sarray();
                C[i] = ca[0];
                A[i] = ca.Skip(1).ToArray();
                for (var j = 0; j < M; ++j)
                    Asum[j] += A[i][j];
            }
            if (Asum.Any(a => a < X))
            {
                WriteLine(-1);
                return;
            }
            var lst = 1L << (int)N;
            var ans = long.MaxValue / 2;
            for (var s = 1; s < lst; ++s)
            {
                var t = s;
                var AAsum = new long[M];
                var cst = 0L;
                for (var i = 0; i < N; ++i)
                {
                    if ((t & (1 << i)) != 0)
                    {
                        for (var j = 0; j < M; ++j)
                            AAsum[j] += A[i][j];
                        cst += C[i];
                    }
                }
                if (AAsum.Any(a => a < X)) continue;
                ans = Min(ans, cst);
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 28808
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

const ll mod = 1e9+7;

int main()
{
    ll N;
    cin >> N;
    ll A,B,C;
    A = 1LL;
    B = 2LL;
    C = 1LL;
    REP(i,N){
        A *= 10;
        A %= mod;
        B *= 9;
        B %= mod;
        C *= 8;
        C %= mod;
    }
    if(A+C - B < 0){
        A += mod;
    }
    cout << (A - B + C) << endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

std::string S, T;

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

    int LS = S.size(), LT = T.size();

    int res = LT;

    for(int i=0;i+LT<=LS;++i){
        int cnt = 0;

        for(int j=0;j<LT;++j){
            if(T[j] != S[i+j]){
                cnt += 1;
            }
        }

        res = std::min(res, cnt);
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n,k; cin >> n >> k;
  vector<int> c(n+1);
  rep1(i,n) {
    int cnt = 0;
    int x = 1;
    while(x * i < k) {
      x *= 2;
      cnt++;
    }
    c[i] = cnt;
  }

  vector<double> p(c[1]+1);
  p[0] = 1;
  rep(i,c[1]) p[i+1] = p[i] / 2.;
  
  double res = 0;
  rep1(i,n) {
    res += p[c[i]] / n;
  }
  printf("%.9f\n", res);
  
  return 0;
}


Measured memory_bytes: 3788
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[1<<16];
int x[5];
int y[5];
int main(){
	int a;
	while(scanf("%d",&a),a<=4){
		x[0]=a;
		scanf("%d%d%d%d%d%d%d",y,x+1,y+1,x+2,y+2,x+3,y+3);
		for(int i=0;i<(1<<16);i++)dp[i]=0;
		dp[0]=1;
		for(int i=0;i<(1<<16);i++){
	//		if(dp[i])printf("%d: %d\n",i,dp[i]);
			for(int j=0;j<16;j++){
				if(!(i&(1<<j))){
					int row=j/4;int col=j%4;
					for(int k=0;k<4;k++){
						int tr=row+y[k];
						int tc=col+x[k];
						if(tr<0||tc<0||tr>3||tc>3||((i+(1<<j))&(1<<(tr*4+tc))))continue;
						dp[i+(1<<j)+(1<<(tr*4+tc))]+=dp[i];
					}
					break;
				}
			}
		}
		printf("%d\n",dp[(1<<16)-1]);
	}
}

Measured memory_bytes: 1284
//package reedeka;
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n, t, a;
		n = sc.nextInt();
		t = sc.nextInt();
		a = sc.nextInt();
		int i;
		double tmp, temp, s;
		int index = 1;
		int h;
		h = sc.nextInt();
		temp = t - 0.006*h;
		tmp = Math.abs(a - temp);
		for(i=2; i<=n; i++) {
			h = sc.nextInt();
			temp = t - 0.006*h;
			s = Math.abs(a-temp);
			if(s<tmp) {
				tmp = s;
				index = i;
			}
		}
		System.out.println(index);
	}
}


Measured memory_bytes: 38868
#include<iostream>
#include<algorithm>
using namespace std;
const int N=2001;
int n,a[N],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<n-1;i++)
		for(int j=i+1;j<n;j++)
			ans+=lower_bound(a+j+1,a+n+1,a[i]+a[j])-a-j-1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int s[100]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1,51};
	int a;
	cin>>a;
	cout<<s[a]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second

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

signed main(){
	int n,m,X,Y;
	cin>>n>>m>>X>>Y;
	int x[n];
	int y[m];
	r(i,n)cin>>x[i];
	r(i,m)cin>>y[i];
	for(int i=X+1;i<=Y;i++){
		int c=0;
		r(j,n)if(x[j]>=i)c++;
		r(j,m)if(y[j]<i)c++;
		if(!c){
			cout<<"No War"<<endl;
			return 0;
		}
	}
	cout<<"War"<<endl;
}

Measured memory_bytes: 256
a,b=[int(x) for x in str(input()).split()]
b/=1000
e=int(b//10)
x=-1
y=-1
z=-1

for i in range(0,e+1):
  q=(b-a-9*i)/4

  if q==int(q):
    if q>=0:
      r=(10*a-b-5*q)/9

      if r==int(r):
        if r>=0:
          if (i+int(q+r))==a:
            if int(10*i+5*q+r)==b:

              x,y,z=i,int(q),int(r)
              break

print(x,y,z)


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>

#define BIT(a) (1 << (a))

using namespace std;

long long MOD = 1000000007;

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

int c[1005];
int box[1005];



int main(void){
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++){
        cin >> c[i];
    }
    int Q;
    cin >> Q;
    int t, x, d;
    int ans = 0;
    int flag = 0;
    for (int i = 0; i < Q; i++){
        cin >> t >> x >> d;
        if (t == 1){
            box[x] += d;
            if (box[x] > c[x] && flag == 0){
                ans = x;
                flag = 1;
            }
        }
        if (t == 2){
            box[x] -= d;
            if (box[x] < 0 && flag == 0){
                ans = x;
                flag = 1;
            }
        }
    }
    cout << ans << endl;
    return 0;

}




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

using namespace std;
using ll = long long;

#define INF (1LL << 60)

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    string S, T, U;
    ll A, B;
    cin >> S >> T >> A >> B >> U;
    if(S == U) --A;
    else if(T == U) --B;
    _PS(A);
    _PS(B);

    return 0;
}

/*



*/

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

using namespace std;

int main(){
  int a, b, keta, target, ans;
  cin >> a >> b;
  keta=log10(b)+1;
  target = a * pow(10, keta) + b;
  ans = sqrt(target);
  
  if((ans * ans)==target){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}


Measured memory_bytes: 4008
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans=1;
    rep(i,n){
        if(a[i]<=1e18/ans&&a[i]*ans<=(ll)1e18) ans*=a[i];
        else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4052
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // abs()
#include <stdbool.h>
#include <math.h>           // sqrt(), pow()

#define MAX_N 100

int
main(int argc, char** argv)
{
	int x[MAX_N];
	int y[MAX_N];
	long l;
	int t;
	int i, n;

	scanf("%d\n", &n);
	for (i = 0; i < n; ++i)
		scanf("%d", &x[i]);

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

	l = 0;
	for (i = 0; i < n; ++i)
		l += abs(x[i] - y[i]);

	printf("%.8f\n", (double) l);

	l = 0;
	for (i = 0; i < n; ++i)
	{
		t = abs(x[i] - y[i]);
		l += t * t;
	}

	printf("%.8f\n", sqrt((double) l));

	l = 0;
	for (i = 0; i < n; ++i)
	{
		t = abs(x[i] - y[i]);
		l += t * t * t;
	}

	printf("%.8f\n", pow((double) l, 1.0 / 3));

	int max = 0;
	for (i = 0; i < n; ++i)
	{
		t = abs(x[i] - y[i]);
		if (t > max)
			max = t;
	}

	printf("%.8f\n", (double) max);
	return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(string, s);
  sort(all(s));
  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
    out("Yes");
  } else {
    out("No");
  }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(ll i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

ll N;

void solve() {
	cin >> N;
	rep(i, 1, 3500 + 1) {
		rep(j, 1, 3500 + 1) {
			ll c = 4 * i * j - N * i - N * j;
			ll d = N * i * j;
			if(c > 0 && d % c == 0) {
				cout << i << " " << j << " " << d / c << "\n";
				return;
			}
		}
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
INF=10**15
N=int(input())
h=list(map(int,input().split()))
dp=[INF for i in range(N)]
dp[0]=0
for i in range(1,N):
    if i>1:
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
    else:
        dp[i]=dp[i-1]+abs(h[i]-h[i-1])
print(dp[N-1])

Measured memory_bytes: 13980
local n, m = io.read("*n", "*n")
local cost = {}
local parent = {}
for i = 1, n do
  cost[i] = io.read("*n")
  parent[i] = i
end

local function uf_findroot(idx)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end

for i = 1, m do
  local x, y = io.read("*n", "*n")
  x, y = x + 1, y + 1
  local xp, yp = uf_findroot(x), uf_findroot(y)
  parent[y], parent[yp] = xp, xp
end

local group = {}
for i = 1, n do
  local p = uf_findroot(i)
  if not group[p] then group[p] = {} end
  table.insert(group[p], cost[i])
end
local groupcnt = 0
local mincost = 0
local remcost = {}
for _k, cs in pairs(group) do
  groupcnt = groupcnt + 1
  table.sort(cs)
  mincost = mincost + cs[1]
  for i = 2, #cs do
    table.insert(remcost, cs[i])
  end
end
if groupcnt == 1 then
  print(0)
elseif (groupcnt - 1) * 2 <= n then
  table.sort(remcost)
  for i = 1, (groupcnt - 1) * 2 - groupcnt do
    mincost = mincost + remcost[i]
  end
  print(mincost)
else
  print("Impossible")
end


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

int main() {
	int N, K;
	cin >> N;
  	cin >> K;
  	int i, j, sum;
  sum = 0;
  for (i = 0; N > i; i++) {
    int n, a, b;
    cin >> n;
    a = 2 * n;	//Aの移動距離
    b = (K - n) * 2;	//Bの移動距離
    if (a <= b)
      sum += a;
    else
      sum += b;
      }
    cout << sum <<endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int n,i,j,k,sum,max;
    while (1) {
        scanf("%d",&n);
        if (n==0) break;
        int num[n];
        max=-500000000;
        for (i=0;i<n;i++) scanf("%d",&num[i]);
        for(i=0;i<n;i++) {
            sum=0;
            for(j=i;j<n;j++) {
                sum+=num[j];
                if(sum>max) max=sum;
            }
        }
        printf("%d\n",max);
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int t[105];
int v[105];
double dp[20010][101];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> t[i];
        t[i] += t[i-1];
    }
    for(int i = 1; i <= N; i++) cin >> v[i];
    t[N+1] = 20001;
    v[N+1] = 0;
    for(int i = 1; i <= 100; i++) dp[0][i] = -1e9;
    int index = 1;
    //for(int i = 1; i <= N + 1; i++) cerr << t[i] << endl;
    for(int timer = 0; timer <= 20000; timer++) {
        while(t[index] <= timer) index++;
        //cerr << timer << " " << index << endl;
        for(int j = 0; j <= 100; j++) dp[timer+1][j] = -1e9;
        for(int velocity = 0; velocity <= v[index]; velocity++) {
            //cerr << timer << " " << index << " " << velocity << " " << dp[timer][velocity] << endl;
            for(int NewV = velocity - 1; NewV <= velocity + 1; NewV++){
                if(NewV > v[index]) continue;
                if(NewV < 0) continue;
                double nowval = (velocity + NewV);
                nowval /= 2;
                if(velocity == NewV && velocity < v[index]) nowval += 0.25;
                chmax(dp[timer+1][NewV], dp[timer][velocity] + nowval);
            }
        }
    }
    cout << fixed << setprecision(20) << dp[20001][0] << endl;
    return 0;
}


Measured memory_bytes: 16000
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		long ans = 0;
		long startWithB = 0;
		long endWithA = 0;
		long both = 0;
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
			boolean isPrevA = false;
			for (int j = 0; j < s[i].length(); j++) {
				if (isPrevA && s[i].charAt(j) == 'B') {
					ans++;
				}
				if (s[i].charAt(j) == 'A')
					isPrevA = true;
				else
					isPrevA = false;
			}
			if (s[i].charAt(0) == 'B')
				startWithB++;
			if (s[i].charAt(s[i].length() - 1) == 'A')
				endWithA++;
			if ((s[i].charAt(0) == 'B') && (s[i].charAt(s[i].length() - 1) == 'A'))
				both++;
		}
		sc.close();
		if (!((both == startWithB) && (both == endWithA)))
			ans += Math.min(Math.min(startWithB, endWithA), n - 1);
		else if (both == 0)
			ans += Math.min(Math.min(startWithB, endWithA), 0);
		else
			ans += Math.min(Math.min(startWithB, endWithA), both - 1);
		System.out.println(ans);
	}
}


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

int main() {
    char c;
    cin >> c;
    if('A' <= c && c <= 'Z'){
        puts("A");
    } else {
        puts("a");
    }
}

Measured memory_bytes: 3588
use proconio::{fastout, input};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        n: Chars,
    }

    let sum = n.iter().map(|c| convert_char_to_u32(c)).sum::<u32>();
    if sum%9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn convert_char_to_u32(c: &char) -> u32 {
    (*c as u32) - 48
}


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

class UnionFind
{
public:
    ll n;
    lvector uf;
    UnionFind(ll N);
    //~UnionFind();
    ll find(ll x);
    ll size(ll x) {return -(*this).uf[(*this).find(x)];}
    void unite(ll x, ll y);
};

UnionFind::UnionFind(ll N)
{
  (*this).n=N;
  rep(i,n) (*this).uf.emplace_back(-1);
}

ll UnionFind::find(ll x)
{
  if((*this).uf[x]<0) return x;
  (*this).uf[x]=(*this).find((*this).uf[x]);
  return (*this).uf[x];
}

void UnionFind::unite(ll x, ll y)
{
  x=(*this).find(x);
  y=(*this).find(y);
  if(x==y) return;
  if((*this).size(x)>(*this).size(y)) swap(x,y);
  (*this).uf[y]+=(*this).uf[x];
  (*this).uf[x]=y;
  (*this).n-=1;
  return;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,k,a,b,c,d;cin>>n>>m>>k;
  auto unifin=UnionFind(n);
  lvector friends(n,0),cands(n,0);
  rep(i,m) {
    cin>>a>>b;a--,b--;
    unifin.unite(a,b);
    friends[a]++,friends[b]++;
  }
  rep(i,n) cands[i]=unifin.size(i)-friends[i]-1;
  rep(i,k) {
    cin>>c>>d;c--,d--;
    if(unifin.find(c)!=unifin.find(d)) continue;
    cands[c]--,cands[d]--;
  }
  rep(i,n) printf("%lld ",cands[i]);
  return 0;
}

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int K;
	
	cin >> K;
	
	if(K % 2 == 1)
		cout << (K / 2) * ((K / 2) + 1);
	else
		cout << (K / 2) * (K / 2);
	
	return 0;
}

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

int main()
{
    int imos[100005] = {};
    int sum = 0;
    int cnt = 0;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        imos[a]++, imos[b + 1]--;
    }
    
    for(int i = 1; i <= 100000; i++) {
        sum += imos[i];
        if(sum > 0) cnt++;
    }

    cout << cnt << endl;
    return (0);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

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

    int n;
    cin >> n;
    VI a(n+2,0);
    REP1(i,1,n) {
        cin >> a[i];
    }
    int tot=0;
    REP(i,n+1) {
        tot+=abs(a[i]-a[i+1]);
    }
    REP1(i,1,n) {
        cout << tot-abs(a[i+1]-a[i])-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1]) << '\n';
    }
    return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>

int main(){
   int s, m, h, amari, S;
   scanf("%d", &S);
   h = S / 3600;
   amari = S % 3600;
   m = amari / 60;
   s = amari % 60;
   printf("%d:%d:%d\n", h, m, s);

   return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<functional>


using namespace std;

int h,w,n;
int dp[1005][1005];
int fie[1005][1005];
int main(void){
	while(1){
		memset(dp,0,sizeof(dp));
		memset(fie,0,sizeof(fie));
		scanf("%d%d%d",&h,&w,&n);
		if(h==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++)scanf("%d",&fie[j][i]);
		}
		dp[0][0]=n-1;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(dp[j][i]%2==0){
					dp[j+1][i]+=dp[j][i]/2;
					dp[j][i+1]+=dp[j][i]/2;
				}else{
					if(fie[j][i]==1){
						dp[j+1][i]+=(dp[j][i]+1)/2;
						dp[j][i+1]+=dp[j][i]/2;
					}
					if(fie[j][i]==0){
						dp[j+1][i]+=dp[j][i]/2;
						dp[j][i+1]+=(dp[j][i]+1)/2;
					}
				}
			}
		}
		int x=0,y=0;
		while(x<w && y<h){
			if((fie[x][y]+dp[x][y])%2==0)y++;
			else x++;
		}
		printf("%d %d\n",y+1,x+1);
	}
	return 0;
}

Measured memory_bytes: 9084
#define aaaa 1
#ifdef aaaa
    #include <bits/stdc++.h>
    #ifdef LOCAL
        #include "cxx-prettyprint-master/prettyprint.hpp"
        #define print(x) cout << x << endl
    #else
        #define print(...) 42
    #endif
    using namespace std;
    using ll = long long;
    #define INF 1'010'000'000'000'000'017LL
    #define mod 1000000007LL
    #define eps 0.0001
    #define all(x) (x).begin(), (x).end()
    #define reverse(x) (x).rbegin(), (x).rend()
    #define FOR(i,a,b) for(ll i=(a);i<(b);++i)
    #define rep(i,n)  FOR(i,0,n)
    #define SZ(x) ((ll)(x).size())
    #define sum(x) accumulate(ALL(x), 0LL)//?
    #define pb(x) push_back(x)
    template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
    public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

#endif
int main() { 
    ll N, cnt1 = 0, cnt2 = 0, cnt4 = 0;
    cin >> N;
    rep(_, N){
        ll a;
        cin >> a;
        if(a%4 == 0) cnt4++;
        else if(a%2 == 0) cnt2++;
        else cnt1 ++;
    }
    string ans;
    if (cnt2 == 0 && (cnt4+1)>=cnt1) ans = "Yes";
    else if (cnt4>=cnt1) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(6) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    int a,b;
    string s;
    while(1){
        cin >> a >> s >> b;
        if(s[0]=='+'){
            print(a+b);
        }
        else if(s[0]=='-'){
            print(a-b);
        }
        else if(s[0]=='/'){
            print(a/b);
        }
        else if(s[0]=='*'){
            print(a*b);
        }
        else{
            break;
        }

    }

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[20],b[20];
	int i,flag=0;
	scanf("%s%s",a,b);
	if(strlen(a)!=strlen(b)-1)
	{
		printf("No\n");
	}
	else
	{
		for(i=0;i<strlen(a);i++)
		{
			if(a[i]!=b[i])
			flag=1;
		}
		if(flag)
		printf("No\n");
		else
		printf("Yes\n");
	}
} 

Measured memory_bytes: 3656