akhauriyash/Code-Regression huggingface dataset:
from itertools import permutations
INF=10**18
n,c=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(c)]
a=[list(map(int,input().split())) for _ in range(n)]
dp=[[0 for _ in range(c)]for i in range(3)]
for i in range(n):
  for j in range(n):
    dp[(i+j)%3][a[i][j]-1]+=1
li=list(permutations(list(range(c)),3))
fans=INF
for i,j,k in li:
  ans=0
  for x in range(c):
    ans+=dp[0][x]*d[x][i]
    ans+=dp[1][x]*d[x][j]
    ans+=dp[2][x]*d[x][k]
  fans=min(fans,ans)
print(fans)

Measured memory_bytes: 76392
#include <bits/stdc++.h>

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   
    int n, k;

    cin >> n >> k;
    vector<int> a(n);
    set<int> len;

    REP(i ,n){
        int A;
        cin >> A;

        a[A-1]++;
    }

    sort(a.rbegin(), a.rend());

    int cnt = 0;

    REP(i, k){
        cnt += a[i];
    }
    
    cout << n - cnt << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;

int main(void){
    string s;
    cin >> s;
    if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]){
        cout << "Yes" << endl;
        return 0;
    }
    if(s[0] == s[2] && s[1] == s[3] && s[0] != s[1]){
        cout << "Yes" << endl;
        return 0;
    }
    if(s[0] == s[3] && s[1] == s[2] && s[0] != s[1]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		int i=1;
		while(true){
        	String x=br.readLine();
        	if(x.equals("0")) break;
        	sb.append("Case "+i+": "+x+"\n");
    		i++;
        }
		System.out.print(sb);
	}
}

Measured memory_bytes: 27048
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>

#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>

#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int,int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;


signed main() {
    ll n , a, b ;
    cin >> n >> a >>b ;
    ll sum = a +b ;
    ll e = n / sum ;
    ll k = n % sum ;
    cout << e*a + min(k , a );

    return 0;









}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {

	private static BufferedReader br;//Scannerは普段使わないからわからん
	
	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new InputStreamReader(System.in));
		
		for(;;){
			int judge = nextInt();
			if(judge==0) break;
			//採点を読み取る
			int data[] = new int[judge];
			int indexOfMax=0, indexOfMin=0;
			for(int i=0; i<judge; i++){
				data[i] = nextInt();
				if(data[i] > data[indexOfMax]) indexOfMax = i;
				if(data[i] < data[indexOfMin]) indexOfMin = i;
			}
			//合計を計算
			int total = 0;
			for(int i=0; i<judge; i++){
				if(i==indexOfMax || i==indexOfMin) continue;
				total += data[i];
			}
			//平均を表示 キャストすれば切り捨てられるはず
			System.out.println((int)(total/(judge-2)));
		}
		
		br.close();
	}
	
	//入力 意外と１行だった
	private static int nextInt() throws Exception{
		return Integer.parseInt(br.readLine());
	}

}



Measured memory_bytes: 24664
#include<bits/stdc++.h>
#define mp make_pair
#define ss second
#define ff first
#define ll long long int
#define tcase ll t;cin>>t;while(t--)
#define sz(a) int((a).size())
#define pb push_back
#define present(c,x) (�.find(x) != �.end())
#define cpresent(c,x) (find(all�,x) != �.end())
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define Yes cout<<"Yes\n";
#define No cout<<"No\n";
#define yes cout<<"yes\n";
#define no cout<<"no\n";
#define f(i,a) for(int i=0;i<a;i++)
#define in insert
#define matrix vector<vector<ll> >
#define E endl
#define I(x) cin>>x;
#define O(x) cout<<x;
const ll M=1000000000;

using namespace std;
/*
ll modexpo(ll a,ll b,ll p)
{
    ll ans=1;
      a=a%p  // update a if(a>=p)

        if(a==0)
            return 0;

                while(b!=0)
                {
                    if(b%2==1)
                        ans=(ans*a)%p;

                    a=a*a;
                    b=b/2;

                }
                return ans;
}*/
/*
ll countbit(ll n)
{
    ll c=0;
    while(n!=0)
    {
        c+=n&1;
        n>>=1;
    }
    return c;
}*/



/*  vector<int> prime1;
  int prime[10000001];

void sieve(int n)
{
       for(long long i=2;i<=n;i++)
       {
         if(prime[i]==0)
         {  prime[i]=i;
            prime1.pb(i);
         }

            for(long long j=0;j<sz(prime1) && prime1[j]<=prime[i] && i*prime1[j]<=n;j++)
            {

                   prime[i*prime1[j]]=prime1[j];


            }


      }

 return ;
}*/

void fastio()
{
       ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

}


int main()
{
    fastio();


    int n;
    cin>>n;
    cout<<((n+1000-1)/1000)*1000-n;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
using namespace std;

int gcd(int a, int b);

int main()
{
    int a, b;
 
    while (cin >> a >> b){
        cout << gcd(a, b) << " " << a / gcd(a, b) * b << endl;
    }
 
    return (0);
}

int gcd(int a, int b)
{
    if (b == 0){
        return (a);
    }
    else {
        return (gcd(b, a % b));
    }
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  int n;cin>>n;

  int ans=0;
  for(int i=1;i<=n/2;i++){
    if(i!=n-i)ans++;
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int N, Z, W;
int a[2000];

int main(void){
    cin >> N >> Z >> W;
    for(int i = 0; i < N; i++) cin >> a[i];

    int res = abs(a[N-1] - W);
    if(N >= 2) res = max(abs(a[N-1] - W), abs(a[N-1] - a[N-2]));
    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let R: i64 = buf.trim().parse().ok().unwrap();
    if R < 1200 {
        println!("ABC");
    } else if R < 2800 {
        println!("ARC");
    } else {
        println!("AGC");
    }
}


Measured memory_bytes: 4352
from collections import *
from itertools import *
from math import *
n=int(input())
a=sorted(list(map(int,input().split())))
b=list(Counter(a))
mod=7+10**9
if n%2==1:
    if a[0]!=0:
        print(0)
        exit()
    for i in range(1,n):
        if ceil(i/2)*2!=a[i]:
            print(0)
            exit()
    print(2**(n//2)%mod)
if n%2==0:
    for i in range(n):
        if floor(i/2)*2+1!=a[i]:
            print(0)
            exit()
    print(2**(n//2)%mod)

Measured memory_bytes: 20680
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

int main() {
  long long N,T,u,p,sum;
  string A="";
  cin>>N;
  sum=26;
  u=26;
  A="a";
  for(int i=1;i<10000;i++){
    if(sum<N){
      u*=26;
      sum+=u;
      A+="a";
      continue;
    }
    T=i;
    break;
  }
  if(T!=1){
p=N-sum+u-1;
  for(int i=T;i>0;i--){
    A[i-1]+=p%26;
    p/=26;

  }
  cout<<A<<endl;
  }
  else{
    A[0]+=N-1;
    cout<<A<<endl;
  }
}

Measured memory_bytes: 3628
n = int(input())
s = []
h = []
c = []
d = []
for _ in range(n):
    card = input().split()
    mark = card[0]
    num = int(card[1])
    
    if mark == 'S':
        s.append(num)
    if mark == 'H':
        h.append(num)
    if mark == 'C':
        c.append(num)
    if mark == 'D':
        d.append(num)

for num in range(1, 13+1):
    if num not in s:
        print(f'S {num}')
for num in range(1, 13+1):
    if num not in h:
        print(f'H {num}')
for num in range(1, 13+1):
    if num not in c:
        print(f'C {num}')
for num in range(1, 13+1):
    if num not in d:
        print(f'D {num}')


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define FASTIO
using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S;
    cin >> S;
    bool c = false, f = false;
    for (auto a : S) {
        if (a == 'C') {
            c = true;
        }
        if (c && a == 'F') {
            f = true;
        }
    }
    prints()(f ? "Yes" : "No");
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3636
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long li;
typedef pair <li, li> pi;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main() {
    int n, m;
    cin >> n >> m;

    vector<vector<int>> next(n);
    rep(i, m) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        next[p].push_back(q);
        next[q].push_back(p);
    }

    vector<int> vis(n);
    vector<int> ansforward, ansrev;

    int pos = 0;
    while (true) {
        vis[pos] = 1;
        ansforward.push_back(pos);
        bool ok = false;
        for (auto &&npos : next[pos]) {
            if (!vis[npos]) {
                ok = true;
                pos = npos;
                break;
            }
        }
        if (!ok) {
            break;
        }
    }

    pos = 0;
    vis[0] = 0;
    while (true) {
        vis[pos] = 1;
        if (pos) {
            ansrev.push_back(pos);
        }
        bool ok = false;
        for (auto &&npos : next[pos]) {
            if (!vis[npos]) {
                ok = true;
                pos = npos;
                break;
            }
        }
        if (!ok) {
            break;
        }
    }

    reverse(ansrev.begin(), ansrev.end());
    vector<int> ans;
    for (auto &&node : ansrev) {
        ans.push_back(node);
    }
    for (auto &&node : ansforward) {
        ans.push_back(node);
    }
//
//    for (auto &&item : next[ans.front()]) {
//        if (!vis[item]) {
//            cout << item + 1 << " is not visited, but reachable directly from start " << ans.front() + 1 << endl;
//        }
//    }
//
//    for (auto &&item : next[ans.back()]) {
//        if (!vis[item]) {
//            cout << item + 1 << " is not visited, but reachable directly from end " << ans.back() + 1 << endl;
//        }
//    }
    cout << ans.size() << endl;
    rep(i, ans.size()) {
        cout << ans[i] + 1;
        if (i == ans.size() - 1) {
            cout << endl;
        } else {
            cout << ' ';
        }
    }

    return 0;
}


Measured memory_bytes: 7736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};

lli gcd(lli a , lli b) {
    if(b == 0) return a;
    a %= b;
    return gcd(b,a);
}

void solve() {
    lli n, ans = 0;
    cin >> n;
    lli a[n + 1], b[n];
    for (int i = 0; i < n + 1; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i < n; ++i) {
        lli defeat = min(a[i], b[i]);
        ans += defeat;
        b[i] -= defeat;
        defeat = min(a[i + 1], b[i]);
        ans += defeat;
        a[i + 1] -= defeat;
        b[i] -= defeat;
    }
    cout << ans << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
main = do
  inputs <- map(read::[Char]->Int) <$> words <$> getLine
  let a = head inputs
      b = last inputs
  putStr $ judge a b

judge::Int->Int->String
judge x y | x <= 0 && y >= 0 = "Zero"
          | x > 0 && y > 0 = "Positive"
          | odd (min y 0 - x) = "Positive"
          | otherwise = "Negative"

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){

	int n,k;
	cin>>n>>k;
	//baoli(n,k);
	//return 0;
	if(n==1){
        if(k>0) printf("-1\n");
        else printf("0 0 1 1\n");
        return 0;
	}
	int all=(1<<n);

	if(k<all){
        if(k==0){
            for(int i=0;i<all;i++) printf("%d %d ",i,i);
            return 0;
        }
        for(int i=1;i<all;i++){
            if(i==k) continue;
            printf("%d ",i);
        }
        printf("%d ",k);
        for(int i=all-1;i>=1;i--){
            if(i==k) continue;
            printf("%d ",i);
        }
        printf("0 %d 0\n",k);
        return 0;
	}
	else printf("-1\n");

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a < b){
		printf("a < b\n");
	}
	else if(a > b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;

}



Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> b(N);
    rep(i, N) {
        cin >> b[i];
        b[i]--;
    }
    vector<int> ans;
    while(b.size()) {
        int i = -1;
        rep(j, b.size()) if(b[j] == j) i = j;
        if (i == -1) {
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(b[i]);
        b.erase(b.begin() + i);
    }
    rrep(i, N - 1) cout << ans[i] + 1 << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int n,m;
    cin>>n>>m;
    vector<set<int>> e(n);
    vi v;
    REP(i,1,n){
        v.pb(i);
    }
    REP(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        e[a].insert(b);
        e[b].insert(a);
    }
    int ans=0;
    do{
        if(!e[0].count(v[0])){
            continue;
        }
        bool flag=true;
        REP(i,1,n-1){
            if(!e[v[i-1]].count(v[i])){
                flag=false;break;
            }
        }
        if(flag)ans++;
    }while(next_permutation(all(v)));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main(void){
    int N, K;
    long long sum;
    sum = 0;

    cin >> N >> K;

    int H[N];
    for(int i = 0; i < N; ++i){
        cin >> H[i];
    }

    sort(H, H + N);
    for(int i = 0; i < N - K; ++i){
        sum += H[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 1024
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(M)]
ans = min(a)+min(b)
for i in xy:
  x = i[0]-1
  y = i[1]-1
  c = i[2]
  ans = min(a[x]+b[y]-c,ans)
  
print(ans)

Measured memory_bytes: 82156
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        sc.close();
        double ans = (double)N / (1+2*D);
        System.out.println((int)Math.ceil(ans));
        

    }
}

Measured memory_bytes: 21972
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    String ans = "No";
    if((Math.abs(a - c) <= d) || ((Math.abs(a - b) <= d) && (Math.abs(b - c) <= d))) ans = "Yes";
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
def resolve():
    N, T = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]
    AB.sort()
    dp = [[0] * (T + 1) for _ in range(N + 1)]

    for i in range(N):
        t, v = AB[i]
        for j in range(T + 1):
            if t + j <= T:
                dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + v)
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

    ans = 0
    for i, (t, v) in enumerate(AB):
        ans = max(ans, dp[i][T - 1] + v)
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 145820
#include <bits/stdc++.h>

using namespace std;

constexpr int MAX_N = 100 + 5;

char C[MAX_N][MAX_N];
int H, W;

int main()
{   
    cin >> H >> W;
    
    for (int i = 1; i <= H; i++)
        cin >> (C[i] + 1);
        
    for (int i = 1; i <= 2 * H; i++){
        for (int j = 1; j <= W; j++)
            cout << C[(i + 1) / 2][j];
        cout << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int def[10] = {-100000, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    int n, m; cin >> n >> m;
    int a[m];
    vector<pair<int, int>> hand(m); // num, cost
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        hand[i] = {a[i], def[a[i]]};
    }
    sort(hand.begin(), hand.end(), greater<>());
    int mnv = hand[0].first, mnc = hand[0].second;
    for (int i = 1; i < m; i++) {
        int cost = hand[i].second;
        int val = hand[i].first;
        if (mnc > cost) {
            mnc = cost;
            mnv = val;
        }
    }
    int order = n/mnc;

    string ans;
    vector<string> s;
    for (int ord = order; ord >= 1; ord--) {
        ans = "";
        for (int i = 0; i < ord; i++) {
            ans += to_string(mnv);
        }
        int left = n - mnc * ord;
        queue<pair<int, string>> q;
        q.push({left, ans});
        bool flag = false;
        while (!q.empty()) {
            int fl = q.front().first;
            string fs = q.front().second;
            q.pop();
            if (fl == 0) {
                flag = true;
                s.push_back(fs);
            }
            if (fl < 0) {
                continue;
            }
            // find included unique number
            set<char> uniH;
            for (auto &c : fs) {
                uniH.insert(c);
            }
            for (auto it = uniH.begin(); it != uniH.end(); it++) {
                for (int i = 0; i < m; i++) {
                    string ns(fs);
                    ns[ns.find(*it)] = to_string(hand[i].first)[0];
                    int diff = hand[i].second - def[*it - '0'];
                    if (diff > 0) {
                        sort(ns.begin(), ns.end(), greater<>());
                        q.push({fl - diff, ns});
                    }
                }
            }
        }
        if (flag) break;
    }
    sort(s.begin(), s.end());
    cout << s.back() << endl;
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <unordered_set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
	int n;
	cin >> n;

	unordered_set<int> set;
	int a;
	rep(i, n) {
		cin >> a;
		set.insert(a);
	}

	cout << ((set.size() == n) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 8520
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
a = intl()
b = intl()
c = intl()

ans = 0
for i in range(n):
	ans += b[ a[i]-1 ]
	if a[i] - a[i-1] == 1 and i >= 1:
		ans += c[ a[i-1]-1 ]
print(ans)

Measured memory_bytes: 9160
#include<iostream>
#include<vector>
using namespace std;

int main() {
	int N;
	int X;
	cin >> N >> X;

	vector<int> D(N+1);
	D[0] = 0;
	int x;
	for (int i = 0; i < N; i++) {
		cin >> x;
		D[i + 1] = D[i] + x;
	}
	
	int ans = 0;
	for (int i = 0; i < N+1; i++) {
		if (D[i] <= X) {
			ans++;
		}
	}
	cout << ans;

	return 0;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int x = -1;
		switch(s){
		case "MON": x = 6;
		break;
		case "TUE": x = 5;
		break;
		case "WED": x = 4;
		break;
		case "THU": x = 3;
		break;
		case "FRI": x = 2;
		break;
		case "SAT": x = 1;
		break;
		case "SUN": x = 7;
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 21204
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, W; cin >> N >> W;

    vector<intmax_t> w(N), v(N);
    for (size_t i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    auto dp = make_v(0LL, N + 1, W + 1);
    for (size_t i = 0; i < N; ++i) {
        for (size_t weight = 0; weight <= W; ++weight) {
            chmax(dp[i + 1][weight], dp[i][weight]);
            if (weight >= w[i]) {
                chmax(dp[i + 1][weight], dp[i][weight - w[i]] + v[i]);
            }
        }
    }

    cout << dp[N][W] << "\n";

    return 0;
}


Measured memory_bytes: 80256
n = int(input())
h = [int(i) for i in input().split()] # input:"1 2 3 4 5"

#2019/08/08とき直し
#次のマスの高さを１高くすることができるようにする
ans = 'Yes'
for i in range(n-1):
  if h[i]>h[i+1]+1:
    ans = 'No'
    break
  elif h[i]==h[i+1]+1:
    h[i+1]+=1
print(ans)

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vi vec(n);
    vector<queue<int>> que(n);
    REP(i,n){
        cin>>vec[i];
        vec[i]--;
        que[vec[i]].push(i);
    }
    vi ans(n);
    REP(i,n){
        int a=-1;
        REP(j,n){
            if(!que[j].size()){
                continue;
            }
            int now=0;
            REP(k,que[j].front()){
                if(!que[vec[k]].size()){
                    continue;
                }else if(que[vec[k]].front()<=k){
                    now++;
                }
            }
            if(now==j){
                a=j;
            }
        }
        if(a==-1){
            cout<<-1<<endl;
            return 0;
        }else{
            ans[i]=a;
            que[a].pop();
        }
    }
    reverse(all(ans));
    REP(i,n){
        cout<<ans[i]+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    
    if(a>b) cout<<"a > b"<<endl;
    if(a==b)cout<<"a == b"<<endl;
    if(a<b)cout<<"a < b"<<endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;

int main(int argc, const char * argv[]) {

    int ans;
    
    for(int i=0; i<5; i++)
    {
        int a;
        cin >> a;
        if(a == 0) ans = i+1;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3564
#include <stdio.h>

int main(){
  int n;  scanf("%d", &n);
  char s[4010];  scanf("%s", s);
  long long int n_r = 0, n_g = 0, n_b = 0;
  for(int i=0; i<n; i++)
    if(s[i] == 'R')  n_r++;
    else if(s[i] == 'G')  n_g++;
    else if(s[i] == 'B')  n_b++;
  
  long long int ans = n_r * n_g * n_b;

  for(int i=0; i<n-2; i++){
    for(int j=i+1; j<n-1; j++){
      if(s[i] == s[j])  continue;
      int k = j*2-i;
      if(k >= n)  continue;
      if(s[k] != s[i] && s[k] != s[j])
	ans--;
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1736
X, n = map(int, input().split())

def Base_10_to_n(X, n): 
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

x10 = X 
x2 = Base_10_to_n(x10, n)
print(len(x2))

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    W,a,b=MI()
    d1=max(0,b-(a+W))
    d2=max(0,a-(b+W))
    print(max(d1,d2))

main()


Measured memory_bytes: 38384
A, B, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for _ in range(m):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    ans = min(ans, a[x] + b[y] - c)
print(ans)


Measured memory_bytes: 24752
//package atcoder;
import java.util.*;

 class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		int n=Integer.parseInt(s.substring(0,2));
		int m=Integer.parseInt(s.substring(2));
		if(n>=1&&n<=12)
		{
			if(m>=1&&m<=12)
			{
				System.out.println("AMBIGUOUS");
			}
			else
			{
				System.out.println("MMYY");
			}
		}
		else
		{
			if(m>=1&&m<=12)
			{
				System.out.println("YYMM");
			}
			else
			{
				System.out.println("NA");
			}
		}

	}

}


Measured memory_bytes: 21716
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<deque>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long ll;

using namespace std;

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

	int N;
	int i = 0;
	cin >> N;
	while (1) {
		if (i >= N) {
			cout << i - N << endl;
			return 0;
		}
		i += 1000;
	}
}

Measured memory_bytes: 3648
import java.util.*;
import java.io.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int n = sc.nextInt();
      if(n == 0) break;
      int i;
      int[] array = new int[n];

      for(i=0; i<n; i++){
        array[i] = sc.nextInt();
      }
      Arrays.sort(array);
      array[0] = 0;
      array[array.length-1] = 0;

      int ave=0;
      for(i=0; i<n; i++){
        ave += array[i];
        //System.out.println(ave);
      }
      ave /= n-2;

    System.out.printf("%d\n", ave);
    }
  }
}


Measured memory_bytes: 29428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll INF = 1e18;

int main(){
  double a, b, x; cin >> a >> b >> x;
  double ans = 0.0;
  
  if(a* a * b >= 2.0 * x){
    ans = atan2(b, 2.0*x/(a*b));
  }else{
    ans = atan2(2.0*(a*a*b - x)/(a*a), a);
  }
  cout << fixed << setprecision(10) << ans * 180.0 / 3.141592652589;
}

Measured memory_bytes: 256
gets
a = gets.chomp.split.map(&:to_i)
a_size = a.size

if a_size == 2
  puts a.inject(&:-).abs
  exit
end

sum = 0
remining = a.inject(&:+)
min = Float::MAX

a.each.with_index(1) do |_a, index|
  break if index == a_size

  sum += _a
  remining -= _a
  min = [min, (sum - remining).abs].min
end

puts min

Measured memory_bytes: 20484
a, b, c, d = list(map(int, input().split()))
while a > 0 or c > 0:
    if c - b <= 0:
        print('Yes')
        break
    else:
        c = c - b
    if a - d <= 0:
        print('No')
        break
    else:
        a = a - d

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.flush();
	ll a[3];
	cin>>a[0]>>a[1]>>a[2];
	bool ans=false;
	sort(a,a+3);
	if(a[0]==a[1]&& a[1]!=a[2])
	{
		ans=true;
		}
	if(a[1]==a[2] && a[1]!=a[0])
	{
		ans=true;
		}
	
	if(ans)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
		}
	
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
int n, s;
 
int sum(int x){
    int tmp = n, ans = 0;
    while(tmp){
        ans += tmp % x;
        tmp /= x;
    }
    return ans;
}
 
signed main(){
    cin >> n >> s;
    for(int i = 2; i * i <= n; i++){
        if(sum(i) == s){
            cout << i;
            return 0;
        }
    }
    for(int i = sqrt(n) - 1; i >= 1; i--){
        if(s < i) continue;
        int tmp = n - (s - i);
        if((tmp % i) != 0) continue;
        if((tmp / i) <= (s - i)) continue;
        if((tmp / i) == 1) continue;
        //cout << tmp << " " << i << endl;
        cout << tmp / i;
        return 0;
    }
    if(s == 1){
        if(n == 1) cout << 2;
        else cout << n;
        return 0;
    }
    if(s == n){
        cout << n + 1;
        return 0;
    }
    cout << -1;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <fstream>
#include <unordered_map>

using namespace std;

ifstream fin("../data.txt");

long long ans;
string s;
int n;

void solve(int index, long long sum) {
  if (index == n) ans += sum;
  else {
    long long temp = 0;
    for (int i = index; i < n; i++) {
      temp = temp*10 + s[i] - '0';
      solve(i + 1, sum + temp);
    }
  }
}

int main() {

  getline(cin, s);
  n = s.size();
  solve(0, 0);

  cout << ans;

  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
using namespace std;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '1') s[i] = '9';
        else s[i] = '1';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
/* Sport Meet */
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		while((line = in.readLine()) != null){
			int n = Integer.parseInt(line);
			if(n==0) break;
			Team[] teams = new Team[n];
			
			for(int i=0; i<n; i++){
				line = in.readLine();
				String[] tmp = line.split(" ");
				int id = Integer.parseInt(tmp[0]);
				int sec = 0;
				for(int j=1; j<=4; j++){
					sec += Integer.parseInt(tmp[2*j-1]) * 60 + Integer.parseInt(tmp[2*j]);
				}
				teams[i] = new Team(id, sec);
			}
			
			Arrays.sort(teams, new team_comparator());
			System.out.println(teams[0].id);
			System.out.println(teams[1].id);
			System.out.println(teams[n-2].id);			
		}
	}
}

class Team{
	int id;
	int sec;
	
	public Team(int id, int sec){
		this.id = id;
		this.sec = sec;
	}
}

class team_comparator implements Comparator<Team>{
	public int compare(Team t1, Team t2){
		return t1.sec - t2.sec;
	}
}

Measured memory_bytes: 12000
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn ss(a:usize, b:usize) -> usize {
    a * 10 + b
}

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
    }
    let mut max = 0;
    if ss(a, b) + c > max {
        max = ss(a ,b) + c;
    }
    if ss(b, a) + c > max {
        max = ss(b ,a) + c;
    }
    if ss(c, a) + b > max {
        max = ss(c ,a) + b;
    }
    if ss(a, c) + b > max {
        max = ss(a ,c) + b;
    }
    if ss(b, c) + a > max {
        max = ss(b ,c) + a;
    }
    if ss(c, b) + a > max {
        max = ss(c ,b) + a;
    }
    println!("{}", max);
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        private static int Count(string str, string reserchTarget)
        {
            return str.Length - str.Replace(reserchTarget, "").Length;
        }

        static void Main(string[] args)
        {          
            var str = Console.ReadLine();
            string target = "1";
            var countResult = Count(str, target);
            Console.WriteLine(countResult);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;

int main(){
  typedef map<int,int> Imap;
  int n;
  while(scanf("%d,",&n)>0){
    Imap h;
    h[n]++;
    for(int i=1;i<4;i++){
      scanf("%d,",&n);
      h[n]++;
    }
    scanf("%d",&n);
    h[n]++;
    if(h.size()==2){
      for(Imap::iterator it=h.begin();it!=h.end();it++){
	if(it->second==4){
	  cout<<"four card";
	  break;
	}
	else if(it->second==3){
	  cout<<"full house";
	  break;
	}
      }
    }
    else if(h.size()==3){
      for(Imap::iterator it=h.begin();it!=h.end();it++){
	if(it->second==3){
	  cout<<"three card";
	  break;
	}
	else if(it->second==2){
	  cout<<"two pair";
	  break;
	}
      }
    }
    else if(h.size()==4) cout<<"one pair";
    else{
      int m[5];
      int i=0;
      for(Imap::iterator it=h.begin();it!=h.end();it++) m[i++]=it->first;
      sort(m,m+5);
      for(int j=0;j<4;j++){
	if(m[j+1]!=m[j]+1&&!(m[j]==1&&m[j+1]==10)){
	  cout<<"null";
	  break;
	}
	if(j==3) cout<<"straight";
      }
    }
    cout<<endl;
  }
    return 0;
}

Measured memory_bytes: 1204
using System;

namespace diverta2019_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var s = new string[N];

            var a = 0;
            var b = 0;
            var ab = 0;
            var same = 0;
            var none = 0;
            for (int i = 0; i < N; i++)
            {
                s[i] = Console.ReadLine();
                var flag1 = s[i][0] == 'B';
                var flag2 = s[i][s[i].Length - 1] == 'A';
                if (flag1) b++;
                if (flag2) a++;
                if (flag1 && flag2) same++;
                s[i] = s[i].Replace("AB", "0");
                foreach (var c in s[i])
                {
                    if (c == '0') ab++;
                }
            }
            var n = Math.Min(a, b);
            var max = Math.Max(a, b);
            if (same > 0 && n == same && max == same) n--;
            Console.WriteLine(n + ab);
        }
    }
}


Measured memory_bytes: 13180
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;

int main() {
	ll a, b, k, ta;
	cin >> a >> b >> k;
	ta = a;
	a = a-k;
	if(a < 0) a = 0;
	k = k - ta;
	if(k>0) b = b-k;
	if(b < 0) b = 0;
	
	cout << a << " " << b << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{   int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a+b==c+d)
    printf("Balanced");
    else if(a+b>c+d)
    printf("Left");
    else
    printf("Right");

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int INF=1e9+7;
vector<int> v1;
int main(){
	int n,m;
	int s=INF;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>a;
		v1.push_back(a);
	}
	sort(v1.begin(),v1.end());
	for(i=0;i<=n-m;i++){
		a=v1[i+m-1]-v1[i];
		if(s>a)s=a;
	}
	cout<<s<<endl;
	return 0;
}
		


Measured memory_bytes: 892
#include <bits/stdc++.h>

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> S(H + 2, vector<int>(W + 2));
  for (int i = 1; i <= H; i++) {
    string s;
    cin >> s;
    for (int j = 1; j <= W; j++) {
      if (s[j - 1] == '#') S[i][j] = 1;
    }
  }
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (S[i][j] and !S[i - 1][j] and !S[i][j - 1] and !S[i + 1][j] and !S[i][j + 1]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
//#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


int32_t main(){
 fastio;
 ll a;
 cin>>a;
 
 string s;
 cin>>s;
 ll res = 0;
 ll b = (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0');
 res = a*b;
 res/=100;
 cout << res << endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        for(int i=0;i<s.length;i++)s[i]=(char)((s[i]-'A'+23)%26+'A');
        System.out.println(s);
	}
}


Measured memory_bytes: 26104
N, A, B, C, D = map(int,input().split())
S = input()

ans = True
d = False
for i in range(B,D-1):
    if(S[i] == "#" and d):
        ans = False
        break
    elif(S[i] == "#"):
        d = True
    else:
        d = False
d = False
for j in range(A,C-1):
    if(S[j] == "#" and d):
        ans = False
        break
    elif(S[j] == "#"):
        d = True
    else:
        d = False
if(C>D):
    ans = ans and S[B-2:D+1].count("...")!=0

print("Yes" if ans else "No")

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>

using namespace std;

int main()
{
    char ch[5]= {'A','T','G','C'};
    char ss[20];
    cin >>ss;
    int t=0,maxe=0;
    for(int i=0;ss[i]!='\0';i++)
    {
        if(ss[i]==ch[0]||ss[i]==ch[1]||ss[i]==ch[2]||ss[i]==ch[3])
        {
            t++;
            if(maxe<t)
                maxe=t;
        }
        else
        {

                t=0;
        }
    }
    cout <<maxe;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int n, m;
	int l, r, l_temp, r_temp, i;
	scanf("%d%d", &n, &m);
	scanf("%d%d", &l, &r);
	for(i=2; i<=m; i++){
	  scanf("%d%d", &l_temp, &r_temp);     
      if(l < l_temp){
		l = l_temp;
      }
      if(r_temp < r){
		r = r_temp;
      }
    }
  	if(r - l + 1 < 0){
      printf("0");
    }
  	else{
      printf("%d", r - l + 1);
    }
	return 0;
}


Measured memory_bytes: 128
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int a[3];
    int ansb=true;
    a[0]= -1;
    a[1] = -1;
    a[2] = -1;
    int n,m;
    int s,c;
    cin >> n>>m;
    rep(i,m){
        cin>>s;
        cin >>c;
        if(s==1&c==0){
            if(n!=1){
                ansb =false;
            }
        }
        if(a[s-1]==-1||a[s-1]==c){
            a[s-1]=c;
        }
        else{
            ansb =false;
        }
    }
    if(n==1){
        if(a[0]==-1){
            a[0]=0;
        }
    }
    else{
        if(a[0]==-1){
            a[0]=1;
        }if(a[1]==-1){
            a[1]=0;
        }if(a[2]==-1){
            a[2]=0;
        }
    }
    if(ansb){
        rep(i,n){
            cout << a[i];
        }
        cout <<endl;
    }else{
        cout << -1<<endl;
    }
}

Measured memory_bytes: 888