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>
using namespace std;

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

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

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

C++: #include <iostream>

using namespace std;

int main(){
  int t, n;
  while( 1 ){
    cin >> t;
    if( !t ){ return 0; }
    cin >> n;
    int h = 0;
    for( int i = 0; i < n; i++ ){
      int s, f;
      cin >> s >> f;
      h += ( f - s );
    }
    if( t <= h ){
      cout << "OK" << endl;
      continue;
    }
    cout <<  ( t - h )  << endl;
  }
}

C++: #include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
   int t,n,s,f;
   int ch;
   while(cin>>t,t){
       ch=0;
       cin>>n;
       for(int i=0;i<n;i++){
           cin>>s>>f;
            ch+=(f-s);
       }
       if(ch>=t) cout<<"OK"<<endl;
       else cout<<t-ch<<endl;
   }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int t;
	while(cin>>t,t){
		int n;
		cin>>n;
		int sum=0;
		rep(i,n){
			int a,b;
			cin>>a>>b;
			sum+=b-a;
		}
		if(sum>=t)cout<<"OK"<<endl;
		else cout<<t-sum<<endl;
	}
}

C++: #include <stdio.h>

int main()
{
	int s,f,t,total;
	int i,j,n;
	
	scanf("%d",&t);
	while(t != 0){
		//初期化
		total = 0;

		scanf("%d",&n);
		for(i = 0; i < n; i++){
			scanf("%d%d",&s,&f);
			total += f-s;
		}

		if(total <= t)	printf("%d\n",t-total);
		else			printf("NO\n");

		scanf("%d",&t);
	}

	return 0;
}

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

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

int main() {
    int t;
    int n;
    int s,f;
    int all;
    int temp;
    
    while (1) {
        all = 0;
        cin >> t;
        if (t == 0) {
            break;
        }
        
        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 <iostream>

using namespace std;

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

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

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

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

int main(void)
{
 int set_time,times,a,b;
  while(1){
    cin >> set_time;
    int c=0,d=0;
    if(set_time == 0){
      break;
    }else{
      cin >> times;
      while( times !=  0){
        cin >> a  >> b ;
        c = b -a;
        d += c;
        times -= 1;
      }
      if(d >= set_time){
        cout << "OK" << endl;
      }else{
        set_time -= d;
        cout << set_time << endl;
      }
    }

  }
}

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

int t;
int n;
int s;
int f;

int main() {
  while (1) {
    int sum = 0;
     scanf("%d", &t);
     if (t == 0) return 0;

     scanf("%d", &n);
     for (int i=0; i<n; i++) {
       scanf("%d%d", &s, &f);
       sum += f-s;
     }
     if (sum < t) {
       printf("%d\n", t-sum);
     } else {
       puts("OK");
     }
  }
}

C++: #include<iostream>
using namespace std;
int main() {
  int t;
  while(cin >> t, t) {
    int n;
    int sum = 0;
    cin >> n;
    for(int i=0; i<n; i++) {
      int a, b;
      cin >> a >> b;
      sum += (b-a);
    }

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

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

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

int main() {
	int t, n, s, f;
	std::cin >> t;
	while (t != 0) {
		std::cin >> n;
		for (auto i = 0; i < n; ++i) {
			std::cin >> s >> f;
			t -= f - s;
		}
		if (t > 0) {
			std::cout << t << std::endl;
		}
		else {
			std::cout << "OK" << std::endl;
		}
		std::cin >> t;
	}
}

C++: //============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;

int main() {
	int t,n,s,f;
	int x;
	while(1){
		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;
	}

	return 0;
}

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

int main(){
  int t,n,s,f,cnt;
  while(true){
    cin>> t;
    cnt = 0;
    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;
}