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++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i:a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

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

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

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int t,n,s,f,i,j,sum;
	while(1){
		scanf("%d",&t);
		sum=0;
		if(t==0) break;
		scanf("%d",&n);
		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<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/
  

  int t;

  int n;

  int s,f;

  while(cin>>t,t){
    cin>>n;


    int ans=0;

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

    }

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

    
  return 0;

}

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

C++: #include <stdio.h>

int main(void)
{
	int i;
	int n;
	int t;
	int s, f;
	int total;
	
	while (scanf("%d", &t), t != 0){
		total = 0;
		scanf("%d", &n);
		
		for (i = 0; i < n; i++){
			scanf("%d %d", &s, &f);
			total += f - s;
		}
		if (t <= total){
			printf("OK\n");
		}
		else {
			printf("%d\n", t - total);
		}
	}
	return (0);
}

C++: using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

 
class Program
{
    static void Main(string[] args)
    {
        while(true){
            int t,n;
            t=int.Parse(Console.ReadLine());
            n=int.Parse(Console.ReadLine());
            int sum=0;
            for(int i=0;i<n;++i){
                int s,f;		
                string[] input = Console.ReadLine().Split(' ');
                s=int.Parse(input[0]);
                f=int.Parse(input[1]);
                sum+=f-s;
            }
            if(sum>=t){
                Console.WriteLine("OK");
            }else{
                Console.WriteLine(t-sum);
            }
        }
    }
}

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

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

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

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

int main() {
    while (true) {
        int t;
        cin >> t;
        
        if (t==0) {
            break;
        }
        
        int n;
        cin >> n;
        
        int c = 0;
        
        for (int i=0; i<n; i++) {
            int si, fi;
            cin >> si >> fi;
            c += fi-si;
        }
        
        if (c>=t) {
            cout << "OK" << endl;
        }
        else {
            cout << t-c << 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<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int t,n,s,f,sum,i;
	while(1){
		cin>>t;
		if(t==0) break;
		cin>>n;
		sum=0;
		for(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 d, n, s, t, sum;
int main(void){
    while(cin>>d>>n, d){
        sum=0;
        for(int i=0; i<n; i++){
            cin >> s >> t;
            sum += t-s;
        }
        if(sum<d) cout << d-sum << endl;
        else cout << "OK" << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <map> 
using namespace std;
 
const int MAX= 10000100;
 
int main(void){
  int t,n;
  int ans = 0;
  while(cin>>t,t){
    cin>>n;
    for(int i = 0 ; i < n ; i ++){
      int s,e;
      cin>>s>>e;
      ans+=e-s;
    }
    if(ans>t)cout<<"OK"<<endl;
    else cout<<t-ans<<endl;
   }
}

C++: #include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int t, n;
        cin >> t >> n;
        if(t == 0)
            return 0;

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

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

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

int main(void)
{
  while (true)
  {
    int goal;
    cin >> goal;
    if ( goal == 0 ) break;
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; ++i)
    {
      int start, finish;
      cin >> start >> finish;
      sum += finish - start;
    }
    if (sum < goal)
    {
      cout << goal - sum << endl;
    }
    else
    {
      cout << "OK" << endl;
    }
  }
  return 0;
}