Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		t, _ := strconv.Atoi(scanner.Text())
		if t == 0 {
			break
		}
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		for i  := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			s, _ := strconv.Atoi(buf[0])
			f, _ := strconv.Atoi(buf[1])
			t -= (f-s)
		}
		if t <= 0 {
			fmt.Println("OK")
		} else {
			fmt.Println(t)
		}
	}
}

C++: #include "bits/stdc++.h"
using namespace std;

#define ASC(a) a.begin(), a.end()		// 昇順ソート 例：sort(ASC(a));
#define DESC(a) a.rbegin(), a.rend()	// 降順ソート 例:sort(DESC(a));
#define rep(i, n) for(int i = 0; i < n; ++i)
//#define rep(i, a, n) for(int i = a; i < n; ++i)
#define Rep(i, n) for(int i = 1; i < n; ++i)
#define In(a) rep(i, n) cin>>a[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;
#define only_unique(vec) vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
#define souwa(vec) accumulate(ASC(vec), 0)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };


// ────────────────────────────────────────────────────
int  main() {
	while (1) {
		int t; cin >> t;
		if (!t) break;

		int n; cin >> n;
		vii h(n);
		int def = 0;
		rep(i, n) {
			cin >> h[i].first >> h[i].second;
			def += h[i].second - h[i].first;
		}
		if (t <= def) cout << "OK" << endl;
		else cout << t - def << endl;
	}
}

C++: #include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    while( true ) {
        int t;
        cin >> t;
        if( t == 0 ) break;
        int n;
        cin >> n;
        int res = 0;
        for( int i = 0; i < n; ++i ) {
            int s, f;
            cin >> s >> f;
            if( s > f ) {
                res += 24 - s + f;

            } else {
                res += f - s;

            }
        }

        if( res >= t ) cout << "OK";
        else cout << t - res;
        cout << endl;

    }
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n,t,i,k,h,x,w;
	w=0;
	while(1){
	scanf("%d",&n);
	if(n==0) break;
	scanf("%d",&t);
	for(i=0;i<t;i++){
		scanf("%d %d",&k,&h);
		w+=h-k;
		}
	if(n=<w){
		printf("OK\n");
		}
	else{
		x=n-w;
		printf("%d\n",x);
		}
	w=0;	
	}
		return 0;
}

C++: # define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <set>
# include <map>
# include <stack>
using namespace std;
# define M_PI 3.141592
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define pri_max 60000
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main()
{
	int t;
	while (cin >> t&&t)
	{
		int n,S=0;
		cin >> n;
		for (int i = 0; i < n; i++)
		{
			int s, e;
			cin >> s >> e;
			S += e - s;
		}
		if (S >= t)cout << "OK" << endl;
		else cout << t - S << endl;
	}
}

C++: #include<stdio.h>
int main(void)
{
	int n,t,i,k,h,x,w;
	w=0;
	while(1){
	scanf("%d",&n);
	if(n==0) break;
	scanf("%d",&t);
	for(i=0;i<t;i++){
		scanf("%d %d",&k,&h);
		w+=h-k;
		}
	if(n<=w){
		printf("OK\n");
		}
	else{
		x=n-w;
		printf("%d\n",x);
		}
	w=0;	
	}
		return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define REP(v, n) FOR(v, 0, n)
using namespace std;

int main(){
	int t, n, s, f, sum;
	
	while(cin >> t, t){
		cin >> n;
		sum = 0;
		REP(i, n){
			cin >> s >> f;
			sum += (f - s);
		}
		if(sum >= t) cout << "OK" << endl;
		else cout << t - sum << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
    while(1){
     int t,n,c=0;
     cin>>t;
     if(t==0)break;
     cin>>n;
     for(int i=0;i<n;++i){
        int s,e;
        cin>>s>>e;
        c+=e-s;
     }
        if(c>t)cout<<"OK"<<endl;
        else cout<<t-c<<endl;
    }

    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int t,n,i,s,f,z;
	while(1){
		scanf("%d",&t);
		if(t==0)break;
		scanf("%d",&n);
		z=0;
//		printf("%d\n",n);
		for(i=0;i<n;i++){
			scanf("%d &d",&s,&f);
			z=z+(f-s);
		}
		if(z>=t){
			printf("OK\n");
		}
		if(z<t){
			printf("%d\n",t-z);
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
    int t, n, s, f;
    int total;
    while (cin>>t, t) {
        total = 0;
        cin>>n;
        for (int i = 0; i < n; ++i) {
            cin>>s>>f;
            int tmp = f - s;
            total += tmp;
        }

        if (total >= t) cout<<"OK"<<endl;
        else cout<< t - total << endl;

    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int t, n, s, f;
  while(cin >> t, t){
    cin >> n;
    int sum = 0;
    while(n--){
      cin >> s >> f;
      sum += f - s;
    }
    if(sum >= t) cout << "OK" << endl;
    else cout << t - sum << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
main(){
  while(1){
    int T,N,s,f,sum=0;
    scanf("%d",&T);
    if(T==0) break;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
      scanf("%d %d",&s,&f);
      sum+=(f-s);
    }
    if(sum>=T) puts("OK");
    else printf("%d\n",T-sum);
  }
}

C++: #include <iostream>
using namespace std;

int main() {
    int t, n;
    while (cin >> t, t) {
        cin >> n;
        int total = 0;
        for (int i = 0; i < n; i++) {
            int s, f;
            cin >> s >> f;
            total += f - s;
        }
        if (total >= t) cout << "OK" << endl;
        else cout << t - total << endl;
    }
}