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 <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
        int hoge; cin>>hoge;
        int ujimatu=0;
        rep(i,hoge){
            int a,b; cin>>a>>b;
            ujimatu+=abs(a-b);
        }
        if(n<=ujimatu)  cout<<"OK"<<endl;
        else cout<<(n-ujimatu)<<endl;
    }
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007



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

C++: #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <math.h>
#include <iterator>
using namespace std;

int main() {
	while (true) {
		int t, n,a = 0;
		scanf("%d", &t);
		if (t == 0) goto end;
		scanf("%d", &n);
		for (int i = 0;i < n;++i) {
			int s = 0, f = 0;
			scanf("%d%d", &s, &f);
			a += f - s;
		}
		if (a >= t) {
			printf("OK\n");
		}
		else {
			printf("%d\n", (t - a));
		}
	}
end:;
}

C++: #include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	int t,s,f,n;

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

	return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        int m;
        scanf("%d",&m);
        int a,b;
        int ans = 0;
        for(int i = 0;i < m; i++){
            scanf("%d%d",&a,&b);
            ans += b-a;
        }
        if(ans >= n)printf("OK\n");
        else {
            printf("%d\n",(n-ans));
        }
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

	int t,n,s,f,sum;

	while(1){
		cin>>t;
		if(t==0) break;
		cin>>n;
		sum=0;
		for(int i=0;i<n;i++){
			cin>>s>>f;
			if(f>s) sum+=f-s;
			else sum+=24-s+f;
		}
		if(t<=sum) cout<<"OK"<<endl;
		else cout<<t-sum<<endl;
	}

}

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

int main()
{
    int t, n, a, b;

    while( cin >> t )
    {
        if( t == 0 )
            break;
        cin >> n;

        int sum = 0;
        for( int i = 0; i < n; i++ )
        {
            cin >> a >> b;
            sum += ( b - a );
        }

        if( t <= sum )
            cout << "OK" << endl;
        else
            cout << t - sum << endl;
    }
        
    return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	
	int t;

	while (cin >> t && t != 0) {

		int n;
		int total = 0;
		cin >> n;

		int s, f;

		for (int i = 0; i < n; i++) {
			cin >> s >> f;
			total += (f - s);
		}

		if (total - t >= 0)
			cout << "OK\n";

		else
			cout << t - total << "\n";

	}
	
	return 0;

}

C++: #include <iostream>
#include <vector>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef long long ll;

int main(){
  int n, m;

  while(cin >> n, n){
    int sum = 0;

    cin >> m;

    for(int i = 0; i < m; i++){
      int a, b;
      cin >> a >> b;
      sum += b - a;
    }

    if(sum >= n){
      cout << "OK\n";
    }
    else{
      cout << n - sum << endl;
    }
  }
}

C++: //#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    int t, n;

    while (~scanf("%d", &t)) {
        if (t == 0) break;
        scanf("%d", &n);
        int cnt = 0;
        int s, f;

        REP (i, n) {
            scanf("%d%d", &s, &f);
            cnt += f - s;
        }

        if (cnt >= t) OUT("OK");
        else OUT(t - cnt);
    }

    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <ctype.h>

const int INF =100000000;

using namespace std;

int main(){

  while(1){
    int t;
    cin >>t;

    if(t == 0){
      break;
    }else{
      int n;
      int sum=0;
      cin >> n;
      for(int i = 0;i < n;i++){
	int a1,a2;
	cin >> a1 >> a2;
	sum += (a2-a1);
      }
      if(sum >= t){
	cout << "OK" << endl;
      }else{
	cout << t - sum << endl;
      }
    }
  }
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))

using namespace std;

int t, n, s[1000], f[1000];

int solve()
{
	int sum = 0;
	
	FOR(i, 0, n)
	{
		sum += f[i] - s[i];
	}

	return t - sum;
}

int main()
{
	while( cin >> t, t)
	{
		cin >> n;
		
		FOR(i, 0, n)
		{
			cin >> s[i];
			cin >> f[i];
		}
		
		int a = solve();
		
		if( a <= 0)
			cout << "OK" << endl;
		else
			cout << a << endl;
	}
	
	return 0;
}