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<stdio.h>
int main(void)
{
	int t,n,s,f,i,sum;
	while(1){
		scanf("%d",&t);
		if(t==0) break;
		scanf("%d",&n);
		sum=0;
		for(i=0;i<n;i++){
			scanf("%d %d",&s,&f);
			sum+=f-s;
		}
		if(t<sum) printf("OK\n");
		else printf("%d\n",t-sum);
	}
	return 0;
}

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

C++: #include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const double EPS = 1e-10;
const int INF = 1001001001;

int main()
{
	int t;
	while(scanf("%d", &t), t){
		int n;
		scanf("%d", &n);
		
		int sum = 0;
		rep(i, n){
			int a, b;
			scanf("%d%d", &a, &b);
			sum += b-a;
		}
		
		if(sum < t)
			printf("%d\n", t-sum);
		else
			puts("OK");
	}
	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>
#include <cstdio>
using namespace std;
 
int main(){
    int t;
    while(cin >> t && t){
        int n;
        cin >> n;
        int s = 0;
        for(int i = 0 ; i < n; i++){
            int a,b;
            cin >> a >> b;
            s += b-a;
        }
        if( s >= t ){
            cout << "OK" << endl;
        }else{
            cout << t - s << endl;
        }
    }
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define INF 114514
using namespace std;




int main(){
	int w, m;
	while (1) {
		int n, sum = 0;
		cin >> m;
		if (m == 0) return 0;
		cin >> n;
		for (int i = 0; i < n; i++) {
			int a, b;
			cin >> a >> b;
			sum += b - a;
		}
		if (sum >= m) cout << "OK" << endl;
		else cout << m - sum << endl;
	}
	return 0;
}

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

int main(void){
	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;
			sum += f-s;
		}
		if(sum >= t)cout << "OK";
		else cout << t - sum;
		cout << endl; 
	}
	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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

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

C++: #include<stdio.h>
int main(void)
{
    int t,n,s,f,i;
	while(1)	{
		scanf("%d",&t);
		if(t==0)	break;
		scanf("%d",&n);
		for (i=1;i<=n;i++){
			scanf("%d",&s);
			scanf("%d",&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 t,n,s,f,cnt;
  while(true){
    cin>> t;
    if(t==0)break;
    cin >> n;
    for(int i=0;i<n;i++){
      cin >> s >> f;
      cnt+= f-s;
    }
    if(cnt >= t)cout<< "OK" << endl;
    else cout << t-cnt << endl;

  }
  return 0;
}

C++: #include<stdio.h>

int main(){

int G,N;
while(1){
scanf("%d",&G);if(G==0)break;

scanf("%d",&N);
int s,f;
for(int i=0;i<N;i++)
{
scanf("%d %d",&s,&f);
f-=s;
G-=f;
if(G<=0)break;
}
if(G<=0)printf("OK\n");
else printf("%d\n",G);
}
return 0;
}

C++: int main()
{
	for(int t,n;__builtin_scanf("%d%d",&t,&n),t;){
		int sum=0;
		while(n--){
			int a,b; __builtin_scanf("%d%d",&a,&b);
			sum+=b-a;
		}
		if(sum>=t)
			__builtin_puts("OK");
		else
			__builtin_printf("%d\n",t-sum);
	}
	return 0;
}

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

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

	while(1)
	{
		cin >> t;
		if(t == 0)
			return 0;

		cin >> n;

		sum = 0;
		for(int i=0;i<n;++i)
		{
			cin >> a >> b;
			sum += b - a;
		}
		if(t <= sum)
			cout << "OK" << endl;
		if(t >= sum)
			cout << t - sum << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int t;
vector<int> n;

void init(){
  t=0;
  n.resize(0);
}

bool input(){
  cin>>t;
  if(t==false)return false;
  int t_n;
  cin>>t_n;
  for(int i=0;i<t_n;i++){
    int a,b;
    cin>>a>>b;
    n.push_back(b-a);
  }
  return true;
}

int solve(){
  int res=t;
  for(int i=0;i<n.size();i++){
    res-=n[i];
  }
  res=max(res,0);
  return res;
}

int main(){
  while(init(),input()){
    int ans=solve();
    if(ans==0){
      cout<<"OK"<<endl;
    }else{
      cout<<ans<<endl;
    }
  }
}

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

int main(){

int n;
while(1){

scanf("%d",&n);if(n==0)break;
int y,t,b;

double s=0,max=0,r;
int MM=0;
scanf("%d",&y);
for(int i=0;i<n;i++){
scanf("%d %lf %d",&b,&r,&t);

if(t==1){
s=1+y*r/100;
}
else{
double s1=1+r/100;s=s1;

for(int j=1;j<y;j++)
{
	s=s*s1;
}
}

if(s>max){max=s;MM=b;}
}
printf("%d\n",MM);

}
return 0;
}

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

using namespace std;

int main()
{
	int t, n, at;

	int st, et;

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

		at = 0;

		cin >> n;

		for(int i= 0;i < n; i++)
		{
			cin >> st >> et;
			at += (et - st);
		}

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