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,n;

  while(cin>>t,t){
    int total=0;
    cin>>n;

    for(int i=0;i<n;++i){
      int a,b;
      cin>>a>>b;
      total+=b-a;
    }

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

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

int main(){
 int t,i,k,n,s[10],f[10],a;
	while(cin>>t){
		if(t==0){
			break;
		}	
	cin>>n;
		a=0;
		for(i=0;i<n;i++){			
		cin>>s[i]>>f[i];
		a=a+f[i]-s[i];		
			}
			if(a>=t){
			cout<<"OK"<<endl;				
				}
			else{
			cout<<t-a<<endl;
				}
	}
return 0;
}

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

using namespace std;

int main()
{
	int n, t;
	int st, fi;

	while (scanf("%d", &t), t != 0){
		int t_cnt = 0;
		scanf("%d", &n);
		for (int i = 0; i < n; i++){
			scanf("%d%d", &st, &fi);
			t_cnt += fi - st;
		}
		if (t <= t_cnt){
			cout << "OK" << endl;
		}
		else {
			cout << t - t_cnt << endl;
		}
	}

	return (0);
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

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

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

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<<endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>
int main(){
	while(1){
		int start,end,target,n;
		scanf("%d",&target);
		if(!target) break;
		scanf("%d",&n);
		while(n--){
			scanf("%d %d",&start,&end);
			target -= end-start;
		}
		if(target>0) printf("%d\n",target);
		else printf("OK\n");
	}
	return 0;
}

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

using namespace std;

int main() {
	int t;

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

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

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

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

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

C++: #include<stdio.h>
int main(){
	int t,n,s,f,i,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(sum>=t)printf("OK\n");
		else printf("%d\n",t-sum);
	}
	return 0;
}

C++: #include <bits/stdc++.h>

#define rep_(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
#define rrep_(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rrep_(v, 0, n - 1)
#define rlep(v, n) rrep_(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define eachv(v, i) rep(i, v.size())
#define reachv(v, i) rrep(i, v.size())
#define debug(x) std::cerr << #x << " = " << x << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int t;
    while (t = in()){
        int n = in();
        int total_time = 0;
        rep(i, n) total_time += abs(in() - in());
        if (total_time < t) printf("%d\n", t - total_time);
        else puts("OK");
    }

    return (0);
}

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

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

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