akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void)
{
	int m, f, r;
	while(1){
		scanf("%d %d %d", &m, &f, &r);

		if(m == -1 && f == -1 && r == -1){
			break;
		}else if(m == -1 || f == -1 || m + f < 30){
			printf("F\n");
		}else if(m + f >= 80){
			printf("A\n");
		}else if(65 <= m + f && m + f < 80){
			printf("B\n");
		}else if(50 <= m + f && m + f < 65){
			printf("C\n");
		}else if(30 <= m + f && m + f < 50){
			if(r >= 50){
				printf("C\n");
			}else{
				printf("D\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 584
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		
		Scanner s=new Scanner(System.in);

		int n=s.nextInt();
		int[] arr=new int[n];
		int k=s.nextInt();
		for(int i=0;i<n;i++) {
			arr[i]=s.nextInt();
		}
		
		int[] dp=new int[n];
		
		dp[0]=0;
		for(int i=1;i<n;i++) {
			int ans=1000000000;
			for(int j=Math.max(0,i-k);j<i;j++) {
				ans=Math.min(dp[j]+Math.abs(arr[i]-arr[j]),ans);
			}
			dp[i]=ans;
		}
		
		System.out.println(dp[n-1]);
		
	
		
	}
}

Measured memory_bytes: 51616
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1]%d7 + C[i - 1][j]%d7)%d7;}}}
    return C[n][k]%d7;
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

ll kk=1;
void dfsi(vector<bool> &vis, vector<ll> adj1[], ll n, ll start, vector<ll> &pre, vector<ll> &pos){
    vis[start]=true;
    pre[start]=kk;kk++;
    for(ll i: adj1[start]){
        if(!vis[i]){
            vis[i]=true;
            dfsi(vis,adj1,n,i,pre,pos);
        }
    }
    pos[start]=kk;kk++;
}

void bfsi(vector<ll> &dis, vector<ll> adj[], ll s, vector<ll> &parent){
    dis[s]=-1;
    queue<ll> q;
    q.push(s);
    while(!q.empty()){
        ll z=q.front();
        q.pop();
        for(ll v:adj[z]){
            if(dis[v]==0){
            q.push(v);
            dis[v]=-dis[z];
                parent[v]=z;}
        }
    }
}

void make_set(ll v, vector<ll> &parent, vector<ll> &krank) {
    parent[v] = v;
    krank[v] = 0;
}

ll find_set(ll v,vector<ll> &parent, vector<ll> &krank) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v], parent, krank);
}

void union_sets(ll a, ll b,vector<ll> &parent, vector<ll> &krank) {
    a = find_set(a,parent,krank);
    b = find_set(b,parent,krank);
    if (a != b) {
        if (krank[a] < krank[b])
            swap(a, b);
        parent[b] = a;
        if (krank[a] == krank[b])
            krank[a]++;
    }
}

void dijkstra(ll s, vector<ll> &dist, vector<ll> &parent, ll n, vector<pair<ll,ll>> adj[]){
    dist[s]=0;
    vector<bool> u(n,false);
    fori(n){
        ll v=-1;
        forj(n){
            if(!u[j] &&(v==-1||(dist[j]<dist[v]))) v=j;
        }
        if(dist[v]==d7) break;
        u[v]=true;
        for(auto j:adj[v]){
            ll a,b;
            a=j.first;
            b=j.second;
            if(dist[v]+b<dist[a]){
                dist[a]=dist[v]+b;
                parent[a]=v;
            }
        }
    }
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now
   
    ll n;
    //cin>>n;
    string s;
    cin>>s;
    if(s=="AAA"||s=="BBB"){
        cout<<"No";
    }else{cout<<"Yes";}
    
//code ends
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <vector>
#include <queue>

using namespace std;
typedef long long LL;
typedef unsigned int u32;
#define pb push_back

int o[100];char str[5];
void Print(LL num,int tag=1)
{
	int l=0;printf("? ");
	while (num) o[++l]=num%10,num/=10;
	for (int i=l;i>=1;i--) printf("%d",o[i]);
	if (tag) for (int i=l+1;i<=18;i++) printf("0");
	puts("");fflush(stdout);
}
void Printo(int l)
{
	printf("? ");
	for (int i=1;i<=l;i++) printf("%d",o[i]);
	puts("");fflush(stdout);
}
int x[100],y[100];
bool comp(LL a,LL b)
{
	memset(x,0,sizeof x);
	memset(y,0,sizeof y);
	int l1=0;while (a) x[++l1]=a%10,a/=10;
	int l2=0;while (b) y[++l2]=b%10,b/=10;
	for (int i=1,j=l1;i<j;i++,j--) swap(x[i],x[j]);
	for (int i=1,j=l2;i<j;i++,j--) swap(y[i],y[j]);
	x[l1+1]=-1;y[l2+1]=-1;
	for (int i=1;;i++)
		if (x[i]!=y[i]) return x[i]<y[i];
}
int main()
{
	
	LL lb=1e8-1,rb=1e9;
	while (rb-lb>1) {
		LL mid=lb+rb>>1;
		Print(mid);scanf("%s",str);
		(*str=='Y')?rb=mid:lb=mid;
	}
	
	while (rb%10==0) rb/=10;
	int l=0;memset(o,0,sizeof o);LL num=rb;
	
	num=rb+1;Print(num,0);scanf("%s",str);
	if ((*str=='Y')==comp(rb,rb+1)) {
		printf("! %lld\n",rb);
		fflush(stdout);return 0;
	}
	num=rb;
	while (num) o[++l]=num%10,num/=10;
	for (int i=1,j=l;i<j;i++,j--) swap(o[i],o[j]);
	num=rb;
	for (int i=l+1;;i++)
	{
		o[i]=1;num*=10;Printo(i);
		scanf("%s",str);
		if (*str=='Y') {
			printf("! %lld\n",num);
			fflush(stdout);return 0;
		}
		o[i]=0;
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    ll S, MOD=1e9L+7, n, ans=0;
    cin >> S;
    n=S/3;
    vector<vector<ll> > dp(n+1, vector<ll>(S+1, 0));
    dp[0][0]=1;
    for(ll i=1; i<=n; i++){
        for(ll j=0; j<=S; j++){
            ll cnt=0;
            if(j-3>=0) cnt=dp[i-1][j-3];
            if(j-1>=0)
                dp[i][j]=(dp[i][j-1]+cnt)%MOD;
            else dp[i][j]=cnt;
        }
    }
    for(ll i=1; i<=n; i++){
        ans=(ans+dp[i][S])%MOD;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 13600
#include <iostream>
#include <stdio.h>

int gcd(int a,int b){return b?gcd(b,a%b):a;}

void calc(long  N) {
    auto lcm = 2 * N / gcd(N, 2);
    std::cout << lcm << std::endl;
}

int main(int argc, char** argv) {
    long N;
    scanf("%ld", &N);
    calc(N);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long K = sc.nextLong();
        if (N%K == 0) {
            System.out.println(0);
            return;
        }

        long x = (N+K-1)/K;

        long negative = N-x*K;
        long positive = negative+K;

        System.out.println(Math.min(-negative, positive));
    }
}



Measured memory_bytes: 21844
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}


#include <iostream>

int main()
{
    int A, B, X;
    cin >> A >> B >> X;

    if (X >= A && X <= A + B) { cout << "YES" << endl; }
    else { cout << "NO" << endl; }
}


Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
e = [[int(i) for i in input().split()] for i in range(n)]
e.sort()
ans = 0
for i in range(n):
    if m >= e[i][1]:
        ans += e[i][0]*e[i][1]
        m -= e[i][1]
    else:
        ans += e[i][0]*m
        break
print(ans)


Measured memory_bytes: 21608
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n,k; cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i], --a[i];

    vector<vector<ll>> nxt(70, vector<ll>(n, 0));
    rep(i,n) {
        nxt[0][i] = a[i];
    }
    for (int i = 1; i < 70; ++i) {
        rep(j,n) {
            nxt[i][j] = nxt[i-1][nxt[i-1][j]];
        }
    }

    string s(bitset<64>(k).to_string<char, char_traits<char>, allocator<char>>());
    reverse(s.begin(), s.end());

    int cur = 0;
    for (int i = s.length()-1; i >= 0; --i) {
        if (s[i]=='1') {
            cur = nxt[i][cur];
        }
    }

    cout << cur+1 << '\n';
    return 0;
}


Measured memory_bytes: 115992
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;

void solve(std::string C) { cout << char(C[0] + 1) << endl; }

int main() {
  int a;
  std::string C;
  std::cin >> C;
  solve(C);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
//import java.util.Math.*;

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

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String action,word;
    int i;
    Set<String> list = new HashSet<String>();
    //List<String> list = new ArrayList<>();
    String tmp[] = new String[2];
    
    for(i = 0; i < n; i++){
        action = sc.next();
        word = sc.next();

        if(action.equals("insert")){
            list.add(word);
        }else if(action.equals("find")){
            if(list.contains(word)){
                System.out.println("yes");
            }else{
                System.out.println("no");
            }
        }else{
            System.out.println("error");
        }
    }
//    System.out.println(list.get(1));
    

    }

}



Measured memory_bytes: 253080
fun main(args:Array<String>?): Unit {
    while(true){
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val count = Array(7){0}
        repeat(n){
            count[(readLine()!!.toInt() / 10).let{if (it > 6) 6 else it}]++
        }
        println(count.joinToString("\n"))
    }
}


Measured memory_bytes: 65728
import java.util.*;

public class Main {

    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();

        if(K >= S.length()){
            System.out.println(S);
        } else {
            System.out.println(S.substring(0, K) + "...");
        }
    }
}

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define SORT(v) sort(ALL(v))
//#define scanf scanf_s

int m, n;
char hata[1005][1005];
char emb[2][2];
int is_emb[1005][1005];

bool check(int i, int j)
{
	return (hata[i][j] == emb[0][0] && hata[i + 1][j] == emb[1][0] && hata[i][j + 1] == emb[0][1] && hata[i + 1][j + 1] == emb[1][1]);
}

int change(int i, int j, char c, int cnt)
{
	if (c == hata[i][j]) return cnt;
	else
	{
		hata[i][j] = c;
		if (i == 0 && j == 0)
		{
			cnt -= is_emb[i][j];
			if (check(i, j)) cnt++;
		}
		else if (i == 0 && j > 0 && j < n - 1)
		{
			cnt -= (is_emb[i][j] + is_emb[i][j + 1]);
			if (check(i, j)) cnt++;
			if (check(i, j + 1)) cnt++;
		}
		else if (i == 0 && j == n - 1)
		{
			cnt -= is_emb[i][j - 1];
			if (check(i, j - 1)) cnt++;
		}
		else if (i > 0 && i < n - 1 && j == 0)
		{
			cnt -= (is_emb[i][j] + is_emb[i - 1][j]);
			if (check(i, j)) cnt++;
			if (check(i - 1, j)) cnt++;
		}
		else if (i == m - 1 && j == 0)
		{
			cnt -= is_emb[i - 1][j];
			if (check(i - 1, j)) cnt++;
		}
		else if (i > 0 && i < n - 1 && j == n - 1)
		{
			cnt -= (is_emb[i - 1][j - 1] + is_emb[i][j - 1]);
			if (check(i - 1, j - 1)) cnt++;
			if (check(i, j - 1)) cnt++;
		}
		else if (i == m - 1 && j>0 && j < n - 1)
		{
			cnt -= (is_emb[i - 1][j - 1] + is_emb[i - 1][j]);
			if (check(i - 1, j - 1)) cnt++;
			if (check(i - 1, j)) cnt++;
		}
		else if (i == m - 1 && j == n - 1)
		{
			cnt -= is_emb[i - 1][j - 1];
			if (check(i - 1, j - 1)) cnt++;
		}
		else
		{
			cnt -= (is_emb[i - 1][j - 1] + is_emb[i][j - 1] + is_emb[i - 1][j] + is_emb[i][j]);
			if (check(i - 1, j - 1)) cnt++;
			if (check(i, j - 1)) cnt++;
			if (check(i - 1, j)) cnt++;
			if (check(i, j)) cnt++;
		}
	}

	return cnt;
}

int main()
{
	cin >> m >> n;
	memset(is_emb, 0, sizeof(is_emb));
	REP(i, m)REP(j, n) cin >> hata[i][j];
	REP(i, 2)REP(j, 2) cin >> emb[i][j];
	int cnt = 0;
	REP(i, m - 1)REP(j, n - 1)
	{
		if (check(i, j))
		{
			is_emb[i][j] = 1;
			cnt++;
		}
	}
	int ans = 0;
	REP(i, m)REP(j, n)
	{
		int tmp = cnt;
		char c = hata[i][j];
		ans = max({ ans, change(i, j, 'J', tmp), change(i, j, 'O', tmp), change(i, j, 'I', tmp) });
		hata[i][j] = c;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 100010, mod = 1e9 + 7;

int n;
int a[N], b[N], c[N];
LL sum[N], cnt[N];

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", a + i);
    for(int i = 1; i <= n; i++) scanf("%d", b + i);
    for(int i = 1; i <= n; i++) scanf("%d", c + i);
    sort(a + 1, a + 1 + n);
    sort(b + 1, b + 1 + n);
    sort(c + 1, c + 1 + n);

    for(int i = 1, j = 1; i <= n; i++)
    {
        while(j < n && b[i] >= c[j]) j++;
        if(b[i] >= c[j]) break;
        cnt[i] = n - j + 1;
    }

    for(int i = n; i >= 1; i--) sum[i] = sum[i + 1] + cnt[i];

    LL res = 0;
    for(int i = 1, j = 1; i <= n; i++)
    {
        while(j < n && a[i] >= b[j]) j++;
        if(a[i] >= b[j]) break;
        res += sum[j];
    }

    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define INF 900000000

using namespace std;

int main()
{
	int a,b;
	
	cin>>a>>b;
	cout<<a*b<<" "<<2*(a+b)<<endl;  
    return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
const int mod1=1e9+7;
const int P1=19260817;
const int P2=998244353;
const int mod2=1004535809;
#define ll long long
typedef pair<ll,ll>Pi;
ll fsp(ll x,int y){
    ll ans=1;
    while(y){
        if(y&1) ans=ans*x%mod1;
        x=x*x%mod1,y>>=1;
    }
    return ans;
}
ll ksm(ll x,int y){
    ll ans=1;
    while(y){
        if(y&1) ans=ans*x%mod2;
        x=x*x%mod2,y>>=1;
    }
    return ans;
}
char s[N];
map<Pi,int>ma;
ll n,l1,l2=1,r1,r2=1,ans,res1,res2,add1,add2,inv1,inv2;
int main(){
    scanf("%lld%s",&n,s+1);
    add1=fsp(P1,n);add2=ksm(P2,n);
    inv1=fsp(P1,mod1-2),inv2=ksm(P2,mod2-2);
    for(int i=n;i;i--){
        if(s[i]=='-'){
            res1=(res1-add1+mod1)%mod1;
            res2=(res2-add2+mod2)%mod2;
        }
        if(s[i]=='+'){
            res1=(res1+add1)%mod1;
            res2=(res2+add2)%mod2;
        }
        if(s[i]=='<'){
            res1=res1*inv1%mod1;
            res2=res2*inv2%mod2;
        }
        if(s[i]=='>'){
            res1=res1*P1%mod1;
            res2=res2*P2%mod2;
        }
    }
    for(int i=n;i;i--){
        ll k1=0,k2=0;
        if(s[i]=='-'){
            l1=(l1-add1+mod1)%mod1,k1=mod1-add1;
            r1=(r1-add2+mod2)%mod2,k2=mod2-add2;
        }
        if(s[i]=='<'){
            l1=l1*inv1%mod1,l2=l2*inv1%mod1;
            r1=r1*inv2%mod2,r2=r2*inv2%mod2;
        }
        if(s[i]=='>'){
            l1=l1*P1%mod1,l2=l2*P1%mod1;
            r1=r1*P2%mod2,r2=r2*P2%mod2;
        }
        if(s[i]=='+'){
            l1=(l1+add1)%mod1,k1=add1;
            r1=(r1+add2)%mod2,k2=add2;
        }
        ++ma[Pi((k1-l1+mod1)*fsp(l2,mod1-2)%mod1,(k2-r1+mod2)*ksm(r2,mod2-2)%mod2)];
        ans+=ma[Pi((res1-l1+mod1)*fsp(l2,mod1-2)%mod1,(res2-r1+mod2)*ksm(r2,mod2-2)%mod2)];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int INF = (int) 1e9;
#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)

const int MAX_V = 1000;
template <typename T = int, typename U = ll> class MaxFlow {
public:

    struct edge {
        T to;
        U cap, rev;
    };

    map<T, vector<edge> > G;
    map<T, bool> used;

    void add_edge(T from, T to, U cap) {
        G[from].push_back((edge){to, cap, G[to].size()});
        G[to].push_back((edge){from, 0, (U) G[from].size() - 1});
    }

    U dfs(T v, T t, U f) {
        if (v == t) return f;
        used[v] = true;
        for (auto&& e : G[v]) {
            if (!used[e.to] && e.cap > 0) {
                U d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    U max_flow(T s, T t) { //sからtへの最大流
        U flow = 0;
        while (1) {
            used.clear();
            U f = dfs(s, t, INF);
            if (f == 0) return flow;
            flow += f;
        }
    }
};

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

    int n;
    cin >> n;
    MaxFlow<> mf;
    int a[n], b[n], c[n], d[n];
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, n) cin >> c[i] >> d[i];

    rep(red, n) rep(blue, n) {
        if (a[red] < c[blue] && b[red] < d[blue]) {
            mf.add_edge(red, blue + 100, 1);
        }
    }

    rep(i, n) {
        mf.add_edge(-1, i, 1);
        mf.add_edge(i + 100, INF, 1);
    }
    cout << mf.max_flow(-1, INF) << endl;
    return 0;
}



Measured memory_bytes: 512
n, m = gets.split.map(&:to_i)

City = Struct.new("City", :i, :p, :y, :id)
cc = Array.new(m)

for i in 0...m
    p, y = gets.split.map(&:to_i)
    cc[i] = City.new(i+1, p, y, 0)
end

cc.sort! do |a,b|
    a.y<=>b.y
end

cnt = Hash.new
cc.each do |c|
    if cnt.has_key?(c.p)
        cnt[c.p] += 1
    else
        cnt[c.p] = 1
    end
    c.id = sprintf("%06d%06d", c.p, cnt[c.p])
end

cc.sort! do |a,b|
    a.i<=>b.i
end

cc.each do |c|
    puts c.id
end


Measured memory_bytes: 28524
/*#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
*/
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define rrep()
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    map<char,int> mp;
    
    mp['I']=1;
    mp['V']=5;
    mp['X']=10;
    mp['L']=50;
    mp['C']=100;
    mp['D']=500;
    mp['M']=1000;
    
    string s;
    while(cin>>s){
        int ans=0;
        rep(i,0,s.length()-1){
            if(mp[s[i]]<mp[s[i+1]]) {
                ans-=mp[s[i]]; 
            }
            else ans+=mp[s[i]];
        }
        cout<<ans+mp[s[s.length()-1]]<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
} 

void solve()
{
  ll n,d;
  cin>>n>>d;
  ll ans=0;
  rep(i,0,n)
  {
    ll a,b;
    cin>>a>>b;
    if((a*a+b*b)<=d*d)
      ans++;
  }
  cout<<ans;
}


int main()       
{
  fastio
  ll tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3652
N = gets.to_i

def yakusu_count (n)
    count = 0
    for i in 1..n do
        if n % i == 0 then
            count += 1
        end
    end
    return count
end

eight_count = 0
for i in 1..N do
    if i.odd? then
        if yakusu_count(i) == 8 then
            eight_count += 1
        end
    end
end

puts eight_count

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

int main(){
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d,vector<int>(26));
  int i,j;
  for(i=0;i<26;i++){
    cin >> c.at(i);
  }
  for(j=0;j<d;j++){
    for(i=0;i<26;i++){
      cin >> s.at(j).at(i);
    }
  }
  
  int k;
  for(k=0;k<d;k++){
    cout << k%26+1 << endl;
  }
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> as(n);
	for (auto &a : as)
	{
		cin >> a;
	}
	int maxi = *max_element(as.begin(), as.end());
	cout << ((maxi < accumulate(as.begin(), as.end(), 0) - maxi) ? "Yes" : "No") << endl;
	return 0;
}

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

const int N=100100;
int a[N],X,n,q,sum;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>X>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	int L=0,R=X,tag=-1,i=1; 
	for(cin>>q;q --> 0;){
		int x,y;cin>>x>>y;
		for(;i<=n&&a[i]<x;++i){
			int tmp=tag*(a[i]-a[i-1]);
			L+=tmp;L=max(0,min(X,L));
			R+=tmp;R=max(0,min(X,R));
			sum+=tmp;tag=-tag;
		}
		int tmp=max(L,min(R,y+sum))+tag*(x-a[i-1]);
		cout<<max(0,min(X,tmp))<<'\n';
	}
	return 0;
}


Measured memory_bytes: 1664
/* 
    Author - linpaws07 
*/
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define inf (int)1e9
#define f first
#define s second
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define scd(t) scanf("%d",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define memst(a, b) memset(a, (b), sizeof(a))
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rp(i,n) for(int i=0;i<(n);i++)
#define fr(i,a,b) for(int i=(a);i<(b);i++)
#define fre(i,a,b) for(int i=(a);i<=(b);i++)
#define frd(i,a,b) for(int i=(a);i>=(b);i--)
inline bool eq(double a, double b) { return fabs(a-b) < 1e-9; }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
auto start = high_resolution_clock::now();
inline void measure();

int64 ar[402], dp[402][402], sum[402];
int main(){
    FAST
    //Do awesome things here
    int n;
    cin >> n;
    memst(dp, -1);
    rp(i, n){
        cin >> ar[i];
    }
    sum[0] = ar[0];
    fr(i, 1, n){
        sum[i] = sum[i - 1] + ar[i];
    }
    fr(i, 1, n + 1){
        fr(j, 0, n){
            int l = j, r = i + j - 1;
            if(l == r){
                dp[l][r] = 0;
                continue;
            }  
            if(r >= n) continue;
            int64 s = sum[r] - (l == 0 ? 0 : sum[l - 1]);
            fr(k, l, r){
                int64 ans = dp[l][k] + dp[k + 1][r] + s;
                if(dp[l][r] == -1 || dp[l][r] > ans)    dp[l][r] = ans;
            }
        }
    }
    cout << dp[0][n - 1] << endl;
    return 0;
}


inline void measure(){
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << duration.count() << endl;
}

Measured memory_bytes: 1536
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(ones ...int) int {
	ret := ones[0]
	for _, v := range ones {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, k := nextInt(), nextInt()
	a := nextInts(n)

	// dp[i][j]: ibit目まで見て，確定値がk未満ならj=1，kと同じならj=0
	dp := make([][2]int, 50)
	for i := range dp {
		dp[i][0], dp[i][1] = -1, -1
	}
	dp[49][0] = 0
	for bit := 50 - 2; bit >= 0; bit-- {
		one := 0
		for i := range a {
			if (uint(a[i])>>uint(bit))&1 == 1 {
				one++
			}
		}

		digit := int(uint(1) << uint(bit))
		if dp[bit+1][1] >= 0 {
			// 0か1か，最大を取る方を使えば良い
			dp[bit][1] = max(dp[bit][1], dp[bit+1][1]+digit*max(one, n-one))
		}
		if dp[bit+1][0] >= 0 {
			if uint(k)&uint(digit) > 0 {
				// xのbit[bit]に0を使う
				dp[bit][1] = max(dp[bit][1], dp[bit+1][0]+digit*one)
				// 1を使う
				dp[bit][0] = max(dp[bit][0], dp[bit+1][0]+digit*(n-one))
			} else {
				// 0を使う
				dp[bit][0] = max(dp[bit][0], dp[bit+1][0]+digit*one)
			}
		}
	}

	puts(max(dp[0][0], dp[0][1]))
}


Measured memory_bytes: 3200
// @gaurav_512
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1e9+7
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'
 
ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//
 
 
void solve()
{
	int n;
	cin>>n;
	vi h(n);
	fi(n)cin>>h[i];
	vi dp(n);
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i=2; i<n; i++)
	{
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1]<<endl;
}
int main()
{
	fastio;
    int T;
//    cin>>T;
//    while(T--)
        solve();
	return 0;
}

Measured memory_bytes: 3960
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int n, m;
void solve() {
  string top = "";
  for (int i = 0; i < m+2; ++i) top += "#";
  cout << top << endl;
  string str;
  for (int i = 0; i < n; ++i) {
	cin >> str;
	str = "#" + str + "#";
	cout << str << endl;
  }
  cout << top  << endl;
}

int main() {
  while (cin >> n >> m) {
    solve();
  }
}







Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}

module Main where

import qualified Data.ByteString.Char8 as B8
import Data.Maybe (fromJust)
import Data.Char (toUpper,isDigit)
import Data.List
import qualified Data.Map as M
import Data.Array.IO
import Data.IORef
import Data.Ix (range)
import Control.Monad
import Control.Applicative
import Text.Printf
import Data.Time.Calendar
import Debug.Trace

readDigits = map read <$> words <$> getLine :: IO [Int]
readDigits' = map read <$> lines <$> getContents :: IO [Int]

--
main :: IO ()
main = do
   (\x -> [h x,m x, s x]) <$> (readLn :: IO Int)
   >>= putStrLn . (intercalate  ":") . map show
    where
    h x = x `div` 3600
    m x = x `mod` 3600 `div` 60
    s x = x `mod` 3600 `mod` 60

Measured memory_bytes: 3616
import std.stdio, std.conv, std.string;

void main() {
	auto ip = readln.split.to!(int[]);
	if(ip[0] % 3 == 0 || ip[1] % 3 == 0 || (ip[0] + ip[1]) % 3 == 0){
		writeln("Possible");
	} else {
		writeln("Impossible");
	}
}

Measured memory_bytes: 256
s=input()
num=len(s)
cnt=0
for i in range(1,len(s)+1):
    if i%2!=0:
        if s[i-1]=="R" or s[i-1]=="U" or s[i-1]=="D":
            cnt+=1
    else:
        if s[i-1]=="L" or s[i-1]=="U" or s[i-1]=="D":
            cnt+=1
if num==cnt:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
def isprime(x):
    if  x==2:
        return True
    if x<2 or x&1==0:
        return False
    return pow(2,x-1,x)==1

cnt=0
n=int(input())
for i in range(n):
    a=int(input())
    if isprime(a):
        cnt+=1
print(cnt)

Measured memory_bytes: 7736
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

template<typename T> void simultaneous_equation(T &x, T &y, T a, T b, T c, T d, T e, T f)
{
	if (a == 0 || b == 0 || d == 0 || e == 0)
	{
		if (a == 0)
		{
			y = c / b;
			x = (f - e * y) / d;
		}
		else if (b == 0)
		{
			x = c / a;
			y = (f - d * x) / e;
		}

		if (d == 0)
		{
			y = f / e;
			x = (c - b * y) / a;
		}
		else if (e == 0)
		{
			x = f / d;
			y = (c - a * x) / b;
		}
	}
	else
	{
		double a0 = a * e;
		double c0 = c * e;

		double d0 = d * b;
		double f0 = f * b;

		x = (f0 - c0) / (d0 - a0) + 0;

		y = (c - a * x) / b + 0;
	}
}

int main()
{
	double a, b, c, d, e, f;
	for (; cin >> a >> b >> c >> d >> e >> f;)
	{
		double x, y;

		simultaneous_equation(x, y, a, b, c, d, e, f);
		cout << fixed << setprecision(3) << x << " " << y << endl;
	}
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define P int
using namespace std;
string s;
int p,f;
P bns1();
P g_A(){
  P r=0;
  if(s[p]=='('){
    p++;r=bns1();p++;
  }
  else{
    while(isdigit(s[p])){
      r=r*10+(s[p]-'0');
      p++;
    }
  }
  if(r<0||r>9999)f++;
  return r;
}
P bns1(){
  P res=g_A();
  while(!isdigit(s[p])&&s[p]!='='){
    int t=p++;
    if(s[t]=='+')res+=g_A();
    if(s[t]=='-')res-=g_A();
    if(s[t]=='*')res*=g_A();
    if(res<0||res>9999)f++;
  }
  return res;
}
int main(){
  while(cin>>s){
    p=f=0;
    int ans=bns1();
    if(f)cout<<'E'<<endl;
    else cout<<ans<<endl;
  }
}

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	int n;
	cin >> n;
	vector<ll> a(100007, 0);
	for (int i = 1; i <= n+1; i++) {
		cin >> a[i];
	}
	
	ll sum = 0;
	for (int i = 1; i <= n+1; i++) {
		sum += abs(a[i] - a[i-1]);
	}
	for (int i = 1; i <= n; i++) {
		ll tmp = sum;
		tmp -= abs(a[i] - a[i-1]);
		tmp -= abs(a[i] - a[i+1]);
		tmp += abs(a[i-1] - a[i+1]);
		cout << tmp << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 2048
import sys
input = sys.stdin.readline
s = int(input())
s1 = s//100
s2 = s%100
if s1>12 or s1==0:
  if s2==0 or s2>12:
    print("NA")
  else:
    print("YYMM")
else:
  if s2==0 or s2>12:
    print("MMYY")
  else:
    print("AMBIGUOUS")

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(void){
    int l[4],r[4];
    double left,right;
    for(int i=0;i<4;i++){
        l[i] = 0;
        r[i] = 0;
    }
    while(cin >> left >> right){
        if(left>=1.1)       l[0]++;
        else if(left>=0.6)  l[1]++;
        else if(left>=0.2)  l[2]++;
        else                l[3]++;
        if(right>=1.1)      r[0]++;
        else if(right>=0.6) r[1]++;
        else if(right>=0.2) r[2]++;
        else                r[3]++;
    }
    for(int i=0;i<4;i++)    cout << l[i] << " " << r[i] << endl;
}


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

typedef long long LL;

LL n,p;

int main()
{
   scanf("%lld%lld",&n,&p);
   if(n==1){
      printf("%lld\n",p);
      return 0;
   }
   LL ans = 1LL;
   for(LL i=2;i*i<=p;i+=((i==2)?1:2)){
      LL cnt = 0;
      while(p%i == 0){
         cnt++;
         p/=i;
      }
      cnt/=n;
      for(int j=1;j<=cnt;j++) ans*=i;
   }
   printf("%lld\n",ans);
 	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 200005
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
int n;
ll ans=1e18,X,x[N],sum[N];
int main(){
	n=read(),X=read();
	for(int i=1;i<=n;++i)sum[i]=(x[i]=read())+sum[i-1];
	for(int k=1;k<=n;++k){
		ll tmp=0;
		for(int j=1,l=0,r=n;r&&tmp+k*X<ans;++j,r=l){
			l=max(r-k,0);
			tmp+=(j==1?5:(j<<1)+1)*(sum[r]-sum[l]);
		}
		ans=min(ans,tmp+k*X);
	}
	printf("%lld",ans+n*X);
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    int sum = 1;
    int front = H[0];
    for (int i = 1; i < N; i++) {
        if (H[i] >= front) {
            sum++;
            front = H[i];
        }
    }
    cout << sum << endl;
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;
const ll N= 1e5+55,mod = 1e9+7;
ll a[26];
int main() {
// 	freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	ll i,j,x,y;
	string s;
	cin>>s;
	char ch;
	for(i=0;i<s.size();i++)a[s[i]-'a']++;
	for(i=0;i<26;i++){
		if(a[i]==0){
			ch=i+'a';
			cout<<ch<<"\n";
			return 0;
		}
	}
	cout<<"None\n";

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 200010
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    int T;
    cin >> T;
    if (T>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int K, T;
  cin >> K >> T;
  vector<int> a(T);
  for(int i = 0; i < T; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  for(int i = 0; i < T; i++){
    a[0] -= a[1];
    a[1] = 0;
    sort(a.begin(), a.end(), greater<int>());
  }
  if(a[0] != 0)cout << a[0] - 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
ans = [0]*n
for _ in range(m):
    s,c = map(int,input().split())
    if n >= 2 and s == 1 and c == 0:
      print(-1)
      exit()
    if ans[s-1] == 0:
        ans[s-1] = c
    elif ans[s-1] != 0 and ans[s-1] == c:
        pass
    elif ans[s-1] != 0 and ans[s-1] != c:
        print(-1)
        exit()
if n == 1:
  print(*ans)
elif n != 1 and ans[0] == 0:
    ans[0] = 1
    ans = map(str,ans)
    ans = "".join(ans)
    print(ans)
else:
    ans = map(str,ans)
    ans = "".join(ans)
    print(ans)

Measured memory_bytes: 3064
import re
N = int(input())
mod = 10 ** 9 + 7

dp = [{} for _ in range(N + 1)]
s = ['A', 'C', 'G', 'T']
dp[0]['TTT'] = 1

for l in range(1, N + 1):
	for c1 in s:
		for c2 in s:
			for c3 in s:
				for c4 in s:
					tmp = c1 + c2 + c3 + c4
					tm = c1 + c2 + c3
					mp = c2 + c3 + c4
					if re.search(r'AGC', tmp):
						continue
					if re.search(r'GAC', tmp):
						continue
					if re.search(r'ACG', tmp):
						continue
					if re.search(r'A.GC', tmp):
						continue
					if re.search(r'AG.C', tmp):
						continue
					if tm in dp[l - 1].keys():
						if mp in dp[l].keys():
							dp[l][mp] += dp[l - 1][tm]
						else:
							dp[l][mp] = dp[l - 1][tm]

ans = 0
for i in dp[N].values():
	ans = (ans + i) % mod
	
print(ans)

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/


int main() {
  double a, b;
  cin >> a >> b;
  cout << fixed << setprecision(15);
  cout << a / b << endl;
}


Measured memory_bytes: 256
using System;
using System.Text;

class Program
{
  public static void Main()
  {
    string S = Console.ReadLine();
    Console.WriteLine(judge(S) ? "YES" : "NO");
  }
  public static bool judge(string s) {
    for (int i = 0; i < s.Length-1; i ++) {
      for (int j = 0; j <= s.Length - i; j ++) {
        if(s.Remove(i, j) == "keyence") return true;
      }
    }
    return false;
  }
}


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

using namespace std;
using ll=long long;
const ll mod = 1e9 + 7;
int dy[] = {1, -1, 0, 0};
int dx[] = {0, 0, 1, -1};

int main() {
    int N,C,K;
    cin>>N>>C>>K;
    vector<int> T(N);

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

    }
    sort(T.begin(),T.end());
    int start=-1;
    int ans=0;
    int pass=0;
    for (int i = 0; i < N; ++i) {
        if(start<0||T[i]>start+K){
            start=T[i];
            ans++;
            pass=0;
        }
        pass++;
        if(pass==C){
            pass=0;
            start=-1;
        }

    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 640
import java.util.Scanner;

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 x = sc.nextInt();
		int sum=0,count=0;
		for(int i=0;i<=a;i++) {
			if(x<i*500) break;
			for(int j=0;j<=b;j++) {
				if(i*500+j*100>x)break;
				for(int k=0;k<=c;k++) {
					if(i*500+j*100+k*50>x) break;
					if(i*500+j*100+k*50==x) {
						count++;
						break;
					}
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21332
def makelist(n,m,p):
    return [[[0 for k in range(p)]for i in range(m)]for j in range(n)]

n,a = map(int,input().split())
x = list(map(int,input().split()))

dp = makelist(n+1,n+1,n*a+1)
dp[0][0][0] = 1
for j in range(n+1):
    for k in range(n+1):
        for s in range(n*a+1):
            if j*k > 0 and s >= x[j-1]:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]
            elif j >= 1 and s < x[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
ans = 0
for k in range(1,n+1):
    ans += dp[n][k][k*a]
print(ans)

Measured memory_bytes: 96348
def solve(query):
    q_x = sorted(query, key=lambda x: x[1])
    q_y = sorted(query, key=lambda x: x[2])

    g = set()

    for a, b in zip(q_x, q_x[1:]):
        s = a[0]
        t = b[0]
        w = min(abs(b[1]-a[1]), abs(b[2] - a[2]))
        g.add((w, s, t))

    for a, b in zip(q_y, q_y[1:]):
        s = a[0]
        t = b[0]
        w = min(abs(b[1]-a[1]), abs(b[2] - a[2]))
        g.add((w, s, t))

    _g = sorted(list(g))

    ans = 0
    for w, a, b in _g:
        if unite(a, b):
            ans += w
    return ans


def root(x):
    if x == par[x]:
        return x
    par[x] = y = root(par[x])
    return y


def unite(x, y):
    rt_x = root(x)
    rt_y = root(y)
    if rt_x == rt_y:
        return False
    if rt_x < rt_y:
        par[rt_y] = rt_x
    else:
        par[rt_x] = rt_y

    return True


if __name__ == '__main__':
    n = int(input())
    query = []
    par = [i for i in range(n+1)]
    for i in range(n):
        a, b = map(int, input().split())
        query.append((i, a, b))

    print(solve(query))


Measured memory_bytes: 58748
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String line =sc.nextLine();
		char[] ar = line.toCharArray();
		for(char ch:ar){
			if(ch>='A'&&ch<='Z'){
				System.out.printf("%c",ch+32);
			}else if(ch>='a'&&ch<='z'){
				System.out.printf("%c",ch-32);
			}else{
				System.out.print(ch);
			}
		}
		System.out.println();
	}
}

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

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  mint p1 = 1, p2, c = n;
  rep(i, n) {
    p1 *= (m - i);
  }
  p2 = p1 / m;

  mint ans = p1 * p1;
  rep(i, n) {
    if (i % 2 == 0) ans -= c * p1 * p2;
    else ans += c * p1 * p2;
    c = c * (n - i - 1) / (i + 2);
    p2 = p2 / (m - i - 1);
  }

  cout << ans.x << endl;

  return 0;
}

/*
*/


Measured memory_bytes: 3620