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;

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

C++: #include<iostream>
using namespace std;
int main(){
	for(;;){
	   int t;
	   cin>>t;
	   if(t==0)break;
	   int n;
	   cin>>n;
	   int a[n],b[n];
	   for(int i=0;i<n;i++){
		   cin>>a[n]>>b[n];
		   t-=(b[n]-a[n]);
	   }
	   if(t<=0){
		   cout<<"OK"<<endl;
	   }
	   else{
		   cout<<t<<endl;
	   }
	}
	return 0;
}

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

int main() {
    int t;
    int n;
    int s,f;
    int all=0;
    int temp;
    
    cin >> t;
    cin >> n;
    
    for(int i = 0; i < n; i++) {
        cin >> s;
        cin >> f;
        
        temp = f - s;
        all += temp;
        temp = 0;
    }
    
    if ((t - all) >= 0) {
        cout << (t - all) << "\n";
    }
    else
    {
        cout << "OK" << "\n" ;
    }
    
    return 0;
}

C++: #include<stdio.h>

int main(){
	for(;;){
		int t,n,s,f,m,o=0;
		scanf("%d",&t);
		if(t==0)break;
		scanf("%d",&n);
		for(m=0;m<n;m++){
			scanf("%d%d",&s,&f);
			o+=f-s;
		}
		if(o>=t)printf("OK\n");
		else printf("%d\n",t-o);
	}
	return 0;
}