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<cstdio>
#include<iostream>
using namespace std;

int main(){

int t,n,count=0;
int A[100];
cin >> t;


do{
cin >> n;
int a=0;
for(int i=0;i<n;i++){
int x,y;
cin >>x>>y;
a+=(y-x);
}
if(a >= t) A[count]=0;
else A[count]=t-a;
count++;
cin>>t;
}while(t!=0);

for (int i=0;i<count;i++){
if(A[i]) cout << A[i] <<"\n";
else cout << "OK\n";
}
}

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

C++: # include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int t, n;

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

C++: #include<iostream>
using namespace std;
struct s {
	int inn;
	bool o;
};
int main(){
	s ar[100];
	int t, n, s, f, a, x;
	for (int i = 0;; i++){
		a = 0;
		cin >> t;
		if (t == 0){
			x = i;
			break;
		}
		cin >> n;
		for (int i = 0; i < n; i++){
			cin >> s >> f;
			a += (f - s);
		}
		if (a < t){
			ar[i].inn = t - a;
			ar[i].o = true;
		}
		else { 
			ar[i].o = false;
		}
	}
	for (int i = 0; i < x; i++){
		if (ar[i].o == false){
			cout << "OK";
		}
		else cout << ar[i].inn;
		cout << endl;
	}
	char c;
	cin >> c;
}

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 <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

int main(){

	int t,sum,s,e,n;

	while(true){
		scanf("%d",&t);
		if(t == 0)break;

		scanf("%d",&n);

		sum = 0;

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

		if(sum >= t){
			printf("OK\n");
		}else{
			printf("%d\n",t-sum);
		}

	}


    return 0;
}

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

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

C++: #include <stdio.h>

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int t;
    while(cin >> t && t){

        int n;
        cin >> n;

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

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

   return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    while(cin >> t, t)
    {
        int n; cin >> n;
        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;
    }
    return 0;
}

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

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

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

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

C++: #include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int t,n,s,f,i,x,a[1000],cnt;
	cnt=0;
	for(i=0;i<1000;i++) a[i]=0;
	while(1){
		cin>>t;
		if(t==0) break;
		cin>>n;
		x=0;
		for(i=0;i<n;i++){
			cin>>s>>f;
			x=x+f-s;
		}
//		if(t-x<=0) cout<<"OK"<<endl;
//		else cout<<t-x<<endl;
		if(t-x<=0){
			a[cnt]=10000;
			cnt=cnt+1;
		}
		else{
			a[cnt]=t-x;
			cnt=cnt+1;
		}
	}
	for(i=0;i<1000;i++){
		if(a[i]==0) break;
		if(a[i]==10000) cout<<"OK"<<endl;
		else cout<<a[i]<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int T;
    while(cin >> T, T)
    {
        int N, cnt = 0;
        cin >> N;
        for(int i = 0; i < N; i++)
        {
            int s, f;
            cin >> s >> f;
            cnt += f - s;
        }
        if(cnt >= T) puts("OK");
        else printf("%d\n", T - cnt);
    }
}