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 <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int st[101];
int ft[101];
int main(){
  int t;
  int n;
  while(cin>>t&&t){
    cin>>n;
    for(int i=0;i<n;i++)cin>>st[i]>>ft[i];
    int sum=0;
    for(int i=0;i<n;i++){
      sum+=max(0,ft[i]-st[i]);
    }
    if(sum>=t)cout<<"OK"<<endl;
    else cout<<t-sum<<endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

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

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

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

C++: #include <cstdio>

int t, n, s, f, sum;

int main(){
    while(scanf("%d", &t) != EOF){
        if(t == 0) break;

        scanf("%d", &n);

        sum = 0;
        for(int i = 0; i < n; i++){
            scanf("%d %d", &s, &f);

            sum += (f - s);
        }

        if(sum < t) printf("%d\n", t - sum);
        else printf("OK\n");
    }


    return 0;
}

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

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

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

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

C++: #include <iostream>
using namespace std;
int main(void){
    int t,n;
    int s[22], f[22];
 
    while(true){
        cin >> t;
        if(t == 0) {
            break;
        }
 
        cin >> n;
        for(int i = 0; i < n; i++){
            cin >> s[i] >> f[i];
        }
         
        int time = 0;
        for(int i = 0; i < n; i++){
            time += f[i] - s[i];
        }
        if(time >= t) 
            cout << "OK" << endl;
        else{
            cout << t - time << endl;
        }
    }
}

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

C++: #include <iostream>
using namespace std;
int main (void)
{
	while(true)
	{
		int n, m, p;
		p = 0;
		cin >> n;
		if(n == 0) 
		{
			break;
		}
		cin >> m;
		while(m > 0)
		{
			int s, q;
			cin >> s >>q;
			p += q-s;
			m--;
		}
		if(p >= n)
		{
			cout << "OK"<< endl;
		}
		else
		{
			cout << n - p;
		}
	}
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,a,n) for(ll i=a;i<n;i++)
int main(void){
    while(1){
        ll t=0,n;cin>>t;
        if(t==0)break;
        cin>>n;
        ll time=0;
        ll s[n],f[n];
        rep(i,0,n){
          ll s,f;
            cin>>s>>f;
            time+=f-s;
        }
        if(time>=t)cout<<"OK"<<endl;
        else cout<<t-time<<endl;
    }
    
}

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

int ans[100];
int cor;

int main(){
	int T,N;
	int s,t,sum;
	while( cin >> T >> N )
	{
		sum = 0;
		for(int i = 0;i < N;i++){
			cin >> s >> t;
			sum += t-s;
		}
		if( sum < T )
			ans[cor] = T-sum;
		cor++;
	}
	for(int i = 0;i < cor;i++){
		if( ans[i] )
			cout << ans[i] << endl;
		else
			cout << "OK" << endl;
	}
	return 0;
}

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

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

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

C++: #include <cstdio>
#include <cctype>
#include <utility>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;
	while (isspace(c)) {c = gcu();}
	if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int t; (t = in());) {
		for (int n = in(); n; n--) {
			int s = in();
			t -= in() - s;
		}
		if (t > 0)
			outl(t);
		else
			outl("OK");
	}
}

C++: #include <iostream>

using namespace std;

int main()
{
  int t,n;
  int s,f;
  int sum;

  while(1){
    sum = 0;
    cin>>t;

    if(t == 0){
      break;
    }

    cin>>n;

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

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

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

int main(){
	int time,n,start,fin,sum;
	while(cin>>time,time){
		cin>>n;
		sum=0;
		for(int i=0;i<n;i++){
			cin>>start>>fin;
			sum+=fin-start;
		}
		if(sum>=time)cout<<"OK"<<endl;
		else cout<<time-sum<<endl;
	}
}