akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
void _fast () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); }
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr int MAX = 1000005;

int main() { _fast();
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> cnt(MAX, 0);
	vector<bool> seen(MAX, false);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	for (int &e : cnt) {
		if (e > 1) e = 0;
	}
	
	for(int &e : a) if (not seen[e]) {
		seen[e] = true;
		for (int i = e + e; i < MAX; i += e) {
			cnt[i] = 0;
		}
	}
	
	int ans = 0;
	for (int e : cnt) ans += e;
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 8240
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		ans += a - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,Q,a[200005],b[200005],p[200005],q[200005],ans[200005];
vector<ll> e[200005];
bool d[200005];
void bfs(ll s){
	queue<ll> que;
	que.push(s);
	d[s]=true;
	while(!que.empty()){
		ll t=que.front(); que.pop();
		//cout<<t<<e[t].size()<<endl;
		for(int i=0;i<e[t].size();i++){
			int k=e[t][i];
			if(!d[k]){
				d[k]=true;
				ans[k]=ans[k]+ans[t];
				que.push(k);
			}
		}
	}
}
int main(void){
	cin>>n>>Q;
	for(int i=0;i<n-1;i++){
		cin>>a[i]>>b[i];
		e[a[i]-1].push_back(b[i]-1);
		e[b[i]-1].push_back(a[i]-1);
	}
	for(int i=0;i<Q;i++){
		cin>>p[i]>>q[i];
		ans[p[i]-1]+=q[i];
	}
	bfs(0);
	for(int i=0;i<n;i++){
		cout<<ans[i];
		if(i!=n-1) cout<<" ";
	}
	cout<<endl;
	
}


Measured memory_bytes: 24304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,V,B,W,T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    ll d = abs(A-B);
    if(V<=W) cout << "NO\n";
    else{
        ll dv = V-W;
        cout << (dv*T>=d? "YES\n":"NO\n");
    }
}

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

int main(){
    long long int a ,b,c,d;
    cin >> a >> b;
    if(a < b){
        if(a <= b - a){
            c = a;
        }else{
            c = b -a;
        }
    }else if(a > b){
        d = a- (a / b)*b;
        if(d <= b - d){
            c = d;
        }else{
            c = b - d;
        }
    }else if(a == b){
        c = 0;
    }
    cout << c << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    int a, b;
    cin >> a >> b;

    exrep(i, 1, 3) {
        if(i != a && i != b) {
            out(i);
        }
    }
    
    re0;
}

Measured memory_bytes: 764
use std::io;
use std::io::stdin;
use std::process::exit;

fn main() {
    let mut input_line: String = String::new();
    stdin().read_line(&mut input_line).expect("Err");

    let inputs: Vec<&str> = input_line.split_whitespace().collect();

    let n: i32 = inputs[0].parse().unwrap();
    let m: i32 = inputs[1].parse().unwrap();

    stdin().read_line(&mut input_line).expect("Err");
    let a_: Vec<&str> = input_line.split_whitespace().collect();

    let mut total_needed_day = 0;

    for i in 2..a_.len(){
        // println!("a_[{}]: {}", i, a_[i]);
        let a:i32 = a_[i].parse().unwrap();
        total_needed_day += a;
    }

    // println!("total_needed_day:{}", total_needed_day);

    if total_needed_day > n {
        print!("-1");
    } else {
        print!("{}", n-total_needed_day);
    }

}

Measured memory_bytes: 2376
#include<bits/stdc++.h>
using namespace std;
int n;
int x[105];
int y[105];
int h[105];
int solve(int yy,int xx){
	int ret = -1;
	int maxheight = numeric_limits<int>::max();
	for(int i=0; i<n; i++){
		int delta = abs(xx-x[i])+abs(yy-y[i]);
		if(h[i]==0){
			//아무리 커봐야 delta까지만 가능  
			if(maxheight>delta) maxheight = delta;
			if(ret!=-1 && maxheight<ret) return -1;
		}
		else{
			int fix = delta+h[i];
			if(ret==-1) ret = fix;
			else if(ret!=fix) return -1;
			
			if(ret>maxheight) return -1;
		}
	}
	if(ret==-1) return maxheight;
	else return ret;
}
int main(){
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>x[i]>>y[i]>>h[i];
	}
	for(int i=0; i<=100; i++){
		for(int j=0; j<=100; j++){
			int height = solve(i,j);
			if(height!=-1){
				cout<<j<<" "<<i<<" "<<height<<'\n';
				return 0;
			}
		}
	}
}

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

using namespace std;

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

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, p;
    cin >> a >> p;
    ppp((3*a+p)/2);








    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

        Scanner s=new Scanner(System.in);
        int h = s.nextInt();
        int n = s.nextInt();
        int a[] = new int[n+1];
        int b[] = new int[n+1];
        long[] mh = new long[h+1];
        Arrays.fill(mh, -1);
        for(int i=0;i<n;i++) {
            a[i] = s.nextInt();
            b[i] = s.nextInt();
        }
        long cus = 0;
        for (int i = 0; i<n; i ++) {
            for (int j = 1; j<=h; j ++) {
                if (j - a[i] <= 0) {
                    cus = 0;
                } else {
                    cus = mh[j - a[i]];
                }
                if (mh[j] < 0 || mh[j] > cus + b[i]) {
                    mh[j] = cus + b[i];
                }
            }
        }

        System.out.println(mh[h]);
    }
}

Measured memory_bytes: 28124
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;

  vector<string> data(7);
  data = {"SAT","FRI","THU","WED","TUE","MON","SUN"};

  for (int i = 0; i < 7; i++) {
    if (s == data[i]) {
      cout << i+1 << endl;
    }
  }

}


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

constexpr int inf = 1 << 29;

int main(void){
    for(int n, m, C; cin >> n >> m >> C, n;){
        vector<vector<Edge>> edge(n);
        rep(_, m){
            int a, b, c; cin >> a >> b >> c;
            a--, b--;
            edge[a].push_back(Edge(b, c));
        }

        priority_queue<State, vector<State>, greater<State>> q;
        q.push(State(0, 0, 0));

        vector<vector<int>> minCost(n, vector<int>(n, inf));

        while(q.size()){
            int cost, v, num_zero;
            tie(cost, v, num_zero) = q.top();
            q.pop();

            if(minCost[v][num_zero] != inf){
                continue;
            }
            minCost[v][num_zero] = cost;

            for(auto & e : edge[v]){
                int nv, diff_cost;
                tie(nv, diff_cost) = e;

                if(minCost[nv][num_zero] == inf){
                    q.push(State(cost + diff_cost, nv, num_zero));
                }
                if(num_zero + 1 < n and minCost[nv][num_zero + 1] == inf){
                    q.push(State(cost, nv, num_zero + 1));
                }
            }
        }

        int res;
        rep(i, n){
            if(minCost[n - 1][i] <= C){
                res = i;
                break;
            }
        }

        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 5208
#!/usr/bin/env python
# coding: utf-8

# In[76]:


s = int(input())
s_str = str(s)
order = len(s_str)

tmp_list = [s_str[i] for i in range(len(s_str))]
if set(tmp_list) == set(["0","1"]):
    if len(s_str) <= 10:
        a = s
        b = 1
        c = 1
        d = 0
    else:
        a = 10**9
        b = 10**(len(s_str)-10)
        c = 1
        d = 0
elif len(s_str) >= 10:
    a = int(s_str[:9]) +1
    b = 10**(len(s_str) - 9)
    c = 10**(len(s_str[9:])) - int(s_str[9:])
    d = 1
else:
    a = int(s_str)
    b = 1
    c = 1
    d = 0

print('0 0 ' + str(a) + ' ' + str(d) + ' ' + str(c) + ' ' + str(b))


# In[ ]:






Measured memory_bytes: 3064
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    # T = A*K = 77...7
    K = read_int()
    seen = set()
    T = 7
    i = 1
    while T%K not in seen:
        if T%K == 0:
            return i
        seen.add(T%K)
        T = (T%K)*10+7
        i += 1
    return -1


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 156468
import java.util.Scanner;

class Main{
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		String kensaku = sc.next();
		int count = 0;
		while(0 < 1) {
			String str = sc.next();
			if(str.equals("END_OF_TEXT")) break;
			if(str.toLowerCase().equals(kensaku)) count++;
		}
		System.out.printf("%d\n",count);
		sc.close();
	}	
}


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

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    // int* A = new int[Q];
    map<int, int> A;
    for (int i = 0; i < Q; i++) {
        int a;
        cin >> a;
        if (A.count(a) == 0) {
            A[a] = 1;
        } else {
            A[a]++;
        }
    }
    vector<int> point(N, K);
    // for (int i = 0; i < Q; i++) {
    //     for (int j = 0; j < point.size(); j++) {
    //         if (j == A[i] - 1) {
    //             continue;
    //         }
    //         point[j]--;
    //     }
    // }
    // for (int i = 0; i < point.size(); i++) {
    //     if (point[i] <= 0) {
    //         cout << "No" << endl;
    //     } else {
    //         cout << "Yes" << endl;
    //     }
    // }

    for (int i = 0; i < N; i++) {
        point[i] -= Q;
        point[i] += A[i+1];
        if (point[i] <= 0) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
}

Measured memory_bytes: 5760
import itertools
n , m = list(map(int, input().split()))
p = []
s = []

cheak = [0]*n

for i in range(m):
    x,y = [j for j in input().split()]
    p.append(int(x))
    s.append(y)

ok = 0
out = 0

for i in range(m):
    if s[i]=="AC" and cheak[p[i]-1]==0:
        cheak[p[i]-1]=1
        ok += 1

#print(cheak)

for i in range(m):
    if cheak[p[i]-1]==1 and s[i]=="WA":
        out += 1
    elif cheak[p[i]-1]==1 and s[i]=="AC":
        cheak[p[i]-1]= -1

#print(cheak)      

print(str(ok)+" "+str(out))




Measured memory_bytes: 14268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i, j, a, b, c;
  cin >> i;
  j = i;
  a = j / 100;
  j = j % 100;
  b = j / 10;
  j = j % 10;
  c = j;
  cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int N=2e5+5;
int inf=0x3f3f3f3f;
typedef pair<int,int> pa;

double PI=3.141592654;

int main()
{
    double r;
     cin>>r;
     cout<<2*r*PI;
   return 0;
}


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

using namespace std;


void solve() {
    int n, C;
    cin >> n >> C;
    vector<vector<pair<int,int>>> t(100005);
    for (int _ = 0; _ < n; _++) {
        int x,y,z;
        cin >> x >> y >> z; z--;
        t[x].emplace_back(1, z);
        t[y].emplace_back(0, z);
    }
    vector<int> status(C);
    int free = 0, soft = 1, use = 2;
    int cnt = 0, res = 0;
    for (int i = 1; i < 100005; i++) {
        sort(t[i].begin(), t[i].end());
        for (int j = 0; j < C; j++) {
            if (status[j] == soft) {
                status[j] = 0;
                cnt--;
            }
        }
        for (auto& p: t[i]) {
            int k,z;
            tie(k,z) = p;
            if (!k) {
                status[z] = soft;
            } else {
                assert(status[z] < use);
                if (status[z] == free) cnt++;
                status[z] = use;
                res = max(res, cnt);
            }
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

int main(){
  int n;
  cin >> n;
  string w[n];
  bool flag=true;

  cin >> w[0];

  rep(i,n-1){
    cin >> w[i+1];
    if(w[i].back()==w[i+1][0]){
      rep(j,i+1){
        if(w[j]==w[i+1]) flag=false;
      }
    }else{
      flag=false;
    }
    if(!flag) break;
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n = int(input())
n = n%10

if n in (2,4,5,7,9):
    print("hon")
elif n in (0,1,6,8):
    print("pon")
else:
    print("bon")

Measured memory_bytes: 67596
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	string s;
	cin>>s;
	while(s!=""){
		if(s.substr(0,5)=="dream"||s.substr(0,7)=="dreamer"||s.substr(0,5)=="erase"||s.substr(0,6)=="eraser"){
			if(s.substr(0,6)=="eraser"){
        		s.erase(0,6);
        		continue;
        	}
    		if(s.substr(0,5)=="erase"){
      			s.erase(0,5);
      			continue;
    		}
	        if(s.substr(0,7)=="dreamer"){
	        	if(s.substr(5,6)=="eraser")
	         	    s.erase(0,5);
				else if(s.substr(5,5)=="erase")
					s.erase(0,5);
				else	
	        	    s.erase(0,7);
	        	continue;
	        }
	        if(s.substr(0,5)=="dream"){
	       	    s.erase(0,5);
	       	    continue;
	        }
		}
		else{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
} 


Measured memory_bytes: 512
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;

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

    if(A <= 5){
        cout << 0;
    }
    else if(A <= 12){
        cout << B / 2;
    }
    else{
        cout << B;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <stack>
#include <cassert>
#define mp make_pair
#define MIN(a,b) (a>b?b:a)
//#define MAX(a,b) (a>b?a:b)
typedef long long ll;
typedef unsigned long long ull;
const int MAX=2e6+5;
const int INF=1e9+5;
using namespace std;
const ll MOD=1000000007;
typedef pair<ll,int> pii;
typedef pair<ll,ll> pll;
const double eps=0.00000001;
ll fact[MAX],inv[MAX];
ll x[10],y[10];
ll pow_mod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll num(ll sx,ll sy,ll ex,ll ey)//从（sx,sy）到（ex，ey）情况数
{
    ex-=sx;ey-=sy;
    return fact[(ex+ey)]*inv[ex]%MOD*inv[ey]%MOD;
}
ll cal(ll sx,ll sy,ll ex,ll ey)//从（sx,sy）到（ex,ey）过程中经过B区域的情况数
{
    ll re=0,now=num(sx,sy,x[3],y[3])*num(x[3],y[3],ex,ey)%MOD;
    re=now;
    ll right_x,right_y,down_x,down_y;//向右、向下走的坐标
    right_x=down_x=x[3];right_y=down_y=y[3];
    for(ll step=x[3]+y[3]+1;step<x[4]+y[4];step++)
    {
        if(right_x!=x[4])
        {
            now+=num(sx,sy,right_x+1,right_y-1)*num(right_x+1,right_y,ex,ey)%MOD;
            ++right_x;
        }
        else
        {
            now-=num(sx,sy,right_x,right_y)*num(right_x+1,right_y,ex,ey)%MOD;
            ++right_y;
        }
        if(down_y!=y[4])
        {
            now+=num(sx,sy,down_x-1,down_y+1)*num(down_x,down_y+1,ex,ey)%MOD;
            ++down_y;
        }
        else
        {
            now-=num(sx,sy,down_x,down_y)*num(down_x,down_y+1,ex,ey)%MOD;
            ++down_x;
        }
        now%=MOD;
        re=(re+now)%MOD;
    }
    if(x[3]!=x[4]||y[3]!=y[4])
        re=(re+num(sx,sy,x[4],y[4])*num(x[4],y[4],ex,ey)%MOD)%MOD;
    return re;
}
int main()
{
    fact[0]=fact[1]=1;
    for(ll i=1;i<=2e6+1;i++)
        fact[i]=fact[i-1]*i%MOD;
    inv[(int)2e6+1]=pow_mod(fact[(int)2e6+1],MOD-2);
    for(ll i=2e6;i>=1;i--)
        inv[i]=(i+1)*inv[i+1]%MOD;
    for(ll i=1;i<=6;i++)
        scanf("%lld",&x[i]);
    for(ll i=1;i<=6;i++)
        scanf("%lld",&y[i]);
    --x[1];--y[1];
    ++x[6];++y[6];
    ll an=0;
    for(int i=1;i<=2;i++)
        for(int j=1;j<=2;j++)
            for(int p=5;p<=6;p++)
                for(int q=5;q<=6;q++)
                    an=(an+((i+j-p-q)%2?-1:1)*cal(x[i],y[j],x[p],y[q]))%MOD;
	an%=MOD;
    while(an<0)
        an+=MOD;
    printf("%lld\n",an);
}


Measured memory_bytes: 31616
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	map<int, vector<int> >mp;
	for(int i = 0; i < m; i++){
		int a,b;
		cin >> a >> b;
		a--; b--;
		mp[a].push_back(b);
		mp[b].push_back(a);
	}
	for(int i: mp[0]){
		for(int j: mp[i]){
			if(j == n-1){
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 22896
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll N, A[200000] = {};
    cin >> N;
    REP(i, N) {
        ll a;
        cin >> a;
        A[i + 1] = A[i] + a;
    }
    ll half1 = A[N] / 2;
    ll half2 = (A[N] + 1) / 2;
    ll ans = A[N];
    REP(i, N) {
        ans = min(abs(A[N] - A[i] - half1) + abs(A[i] - half1), ans);
        ans = min(abs(A[N] - A[i] - half2) + abs(A[i] - half2), ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author k16069kk
 */
public class Main {

    private static int Culc(int num, int sum) {
        int number[] = new int[num];
        int ans = 0;
        int count = 0;
        
        for (int i = 0; i < number.length; i++) {
            number[i] = i+1;
        }
        
        for (int i = 0; i < num; i++) {
            for (int j = i+1; j < num; j++) {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            }
        }
        return count;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

        int num = 0;
        int sum = 0;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()) {
                num = Integer.parseInt(st.nextToken());
                sum = Integer.parseInt(st.nextToken());
            }
            if (num == 0 && sum == 0) {
                break;
            }
            System.out.println(Culc(num, sum));
        }
    }
}



Measured memory_bytes: 24924
while 1:
    h,w=map(int,input().split())
    if h==0 and w==0: 
        break
    for y in range(h): 
        if y == 0 or y == h-1:
            print('#'*w)
        else: 
            print('#','.'*(w-2),'#',sep='')
    print('')

Measured memory_bytes: 7680
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n;s(n);
	vector<int> vec(1000001 , 0);
	vector<int> vecc;
	bool is = true;
	for(int i = 0;i<n;i++)
	{
		int x;s(x);
		vecc.push_back(x);
		if(vec[x] && x != 1) is = false;
		vec[x] = 1;
	}
	
	vector<int> arr(1000001 , 0);
	for(int i = 2;i<=1000000;i++)
	{
		if(!arr[i])
		{
			int count = 0;
			for(int j = arr[i];j<=1000000;j+=i)
			{
				if(vec[j]) count++;
				arr[j] = 1;
			}
			
			if(count >= 2) is = false;
		}
	}
	
	if(is)
	{
		cout<<"pairwise coprime"<<endl;return 0;
	}
	
	int gcdd = vecc[0];
	
	for(int i = 1;i<n;i++)
	{
		gcdd = __gcd(gcdd , vecc[i]);	
	}
	
	if(gcdd == 1)
	{
		cout<<"setwise coprime"<<endl;	
	}
	else
	{
		cout<<"not coprime"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 15028
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
   long long int n,d,b,k,i,c=0;
   cin>>n>>d;
   for(i=0;i<n;i++)
   {
       cin>>b>>k;


       if((abs(b)*abs(b))+ (abs(k)*abs(k))<=(d*d))
        c++;

   }
   cout<<c;
   return 0;
}


Measured memory_bytes: 3640
N = int(input())
res = False
for i in range(1, N+1):
  if i * i > N:
    break
  else:
    q = N // i
    if i * q == N and 1 <= i <= 9 and 1 <= q <= 9:
      res = True
      break
print('Yes' if res else 'No')

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
using namespace std;
int n,x,t;
multiset<int>s;
int main()
{
    scanf("%d%d",&t,&n);
    for(int i=1;i<=n;++i){
        scanf("%d",&x);
        s.insert(x);
    }
    while(s.size()>1){
        int k1=*(s.begin());
        set<int>::iterator it=s.end();
        --it;
        int k2=*it;
        s.erase(it);
        s.erase(s.begin());
        if(k2-k1)s.insert(k2-k1);
    }
   if(s.size()) cout<<*(s.begin())-1<<endl;
    else puts("0");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		int c = a / 500;
		int d = c * 500;
		
		int e = a - d;
		
		if (e > b) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
void dfs(int i,vector<vector<int>>& edges,vector<int>& dp,vector<int>& vis) {
	vis[i] = 1;
	for (auto j : edges[i]) {
		if (vis[j] == 0) dfs(j,edges,dp,vis);
		dp[i] = max(dp[i], 1 + dp[j]);
	}
}
int main()
{
  int n,m,u,v;
  cin>>n>>m;
  vector<vector<int>> edges(n+1);
  vector<int> dp(n+1,0);
  vector<int> vis(n+1,0);
  for(int i=0;i<m;i++)
  {
    cin>>u>>v;
    edges[u].push_back(v);
  }
  for(int i=1;i<=n;i++)
  {
    if(vis[i]==0) dfs(i,edges,dp,vis);
  }
  int ans = dp[0];
	for (int i = 1; i <= n; i++) ans = max(ans, dp[i]);
	cout << ans << endl;
}

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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int N;
    cin >> N;
    vi t(N+1), x(N+1), y(N+1);
    t[0] = x[0] = y[0];
    rep(i, N) cin >> t[i + 1] >> x[i + 1] >> y[i+1];

    bool can = true;
    rep(i, N){
        int dt = t[i+1] - t[i];
        int ds = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < ds) can = false;
        if (ds%2 != dt%2) can = false;
    }

    cout << (can == true ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 1408
fun main(args: Array<String>) {
    val (S, T) = readLine()!!.split(" ")
    val (A, B) = readLine()!!.split(" ").map(String::toInt)
    val U = readLine()!!

    if (U == S) {
        print(A - 1)
        print(" ")
        println(B)
    } else {
        print(A)
        print(" ")
        println(B - 1)
    }
}



Measured memory_bytes: 38124
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

vector<int> vv;

ll n;

void rec(ll x, int cur = 100) {
	if (x == 1) {
		return;
	}

	if (x & 1) {
		rec(x - 1, cur - 1);
		vv.insert(vv.begin(), cur);
	}
	else {
		rec(x / 2, cur - 1);
		vv.pb(cur);		       		
	}
}

void solve() {
	scanf("%lld", &n);
	rec(n + 1);

	for (int i = 1; i <= 100; ++i) {
		vv.pb(i);
	}

	printf("%d\n", vv.size());

	for (int i = 0; i < vv.size(); ++i) {
		printf("%d", vv[i]);
		printf(i + 1 == vv.size() ? "\n" : " ");
	}                 
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N;
    cin >> N;
    long long h[N];
    long long dp[N];
    for (long long i = 0; i< N; i++) cin >> h[i];
    dp[0] = 0;
    dp[1] =abs(h[1]-h[0]);
    
    for (long long 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;
}


Measured memory_bytes: 5192
#include<stdio.h>
#define MAX 100000
#define N 2000000000

typedef struct Card{
  char suit;
  int value;
}Card;

Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(Card A[], int left, int mid, int right) {
  int i, j, k,n1,n2;

  n1 = mid - left;
  n2 = right - mid;

  for (i=0;i<n1;i++){
    L[i] = A[left + i];
  }
  for (i=0;i<n2;i++){
    R[i] = A[mid + i];
  }
  L[n1].value = R[n2].value = N;
  i = 0;
  j = 0;

  for (k=left;k<right;k++) {
    if (L[i].value <= R[j].value)
      A[k] = L[i++];
    else A[k] = R[j++];
  }
}

void mergeSort(Card A[], int left, int right) {
  int mid;
  if (left + 1 < right) {
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(Card A[], int p, int r) {
  int i, j;
  Card t, x;
  x = A[r];
  i = p - 1;
  for (j=p;j<r;j++){
    if (A[j].value <= x.value) {
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;

  return i + 1;
}

void quickSort(Card A[], int p, int r) {
  int q;
  if (p < r) {
    q = partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}

int main() {
  int n, i, v;
  Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for (i=0;i<n;i++) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, 0, n);
  quickSort(B, 0, n-1);

  for (i=0;i<n;i++)
    if (A[i].suit != B[i].suit){
      stable = 0;
    }
  if (stable == 1){
    printf("Stable\n");
  }
  else printf("Not stable\n");

  for (i=0;i<n;i++){
    printf("%c %d\n", B[i].suit, B[i].value);
  }

  return 0;
}



Measured memory_bytes: 4188
#include <stdio.h>
#include <stdlib.h>
#define LEN 100005

typedef struct Process
{
	char name[15];
	int time;
}Process;

Process Queue[LEN];
int head = 0, tail = 0;

Process dequeue()
{
	Process p = Queue[head];
	head = ++head == LEN ? 0 : head;

	return p;
}

void enqueue(Process p)
{
	Queue[tail] = p;
	tail = ++tail == LEN ? 0 : tail;
}

int isQueueEmpty() 
{
	return head == tail;
}


int main()
{
	int N, Q;
	scanf("%d %d", &N, &Q);

	for (int i = 0; i < N; i++)
	{
		scanf("%s %d", Queue[i].name, &Queue[i].time);
	}
	head = 0;
	tail = N;

	int timeSum = 0;
	while (!isQueueEmpty())
	{
		Process p = dequeue();
		if (p.time <= Q)
		{
			printf("%s %d\n", p.name, timeSum += p.time);
		}
		else
		{
			p.time -= Q;
			enqueue(p);
			timeSum += Q;
		}
	}

	return 0;
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{


    ll n,m,c;
    cin >> n >> m >> c;
    vector<ll> v;
    for(ll i = 0; i < m; i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++)
    {

        ll cur = c;
        for(ll j = 0; j < m; j++)
        {

            ll x;
            cin >> x;
            cur+=x*v[j];
        }
        if(cur > 0) ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int MOD = 1e9 + 7;

signed main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int ans = 0;
  REP (i, A+1) {
    REP (j, B+1) {
      REP (k, C+1) {
        if (500 * i + 100 * j + 50 * k == X) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
MOD = 10**9 + 7
MOD_t_MAX = 2*10**6 + 10

fac  = [None] * MOD_t_MAX
finv = [None] * MOD_t_MAX
inv  = [None] * MOD_t_MAX
def MOD_COM_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MOD_t_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD
def MOD_COM(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

def main():
    k = int(input())
    s = input()
    n = len(s)
    MOD_COM_init()
    ans = 0
    a = 1
    b = pow(26, k, MOD)
    for i in range(k+1):
        ans += a * MOD_COM(i + n-1, n-1) * b % MOD
        a *= 25
        b *= inv[26]
        a %= MOD
        b %= MOD
    print(ans % MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 216512
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  vector<string> s = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string t;
  cin >> t;
  int idx = find(all(s), t) - begin(s);
  dump(idx);
  rep(i, 1, 8) {
    if (s[(i + idx) % 7] == "SUN") {
      cout << i << endl;
      return 0;
    }
  }
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<deque>
#include<tuple>
#include<stdio.h>
#include<iomanip>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int x[5];
	rep(i, 5){
		cin>>x[i];
	}
	rep(i, 5){
		if(x[i]==0){
			cout<<i+1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3576
#include<stdio.h>
#include<string.h>

#define M 1046527/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return /* your task */key % M; }
int h2(int key){ return /* your task */1 + (key % (M - 1)); }

int find(char str[]){

    /* your task */

  long long key, i, h;
  key = getKey(str);
  for(i = 0 ;; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }

  return 0;
}

int insert(char str[]){

    /* your task */
  
  long long key, i, h;
  key = getKey(str);
  for(i = 0 ;; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h], str);
      return 0;
    }
  }
  
  return 0; 
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 16072
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define pb push_back
#define int long long
using namespace std;
const int M = 1000000007;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> C(n + 1);
    for (int i = 1; i <= n; i++) cin >> C[i];
    vector<int> SUM_DP_VALUES(2e5 + 1);
    vector<int> DP(n + 1);
    DP[0] = 1;
    for (int i = 1; i <= n; i++) {
        DP[i] = SUM_DP_VALUES[C[i]];
        if (C[i] != C[i - 1]) DP[i] += DP[i - 1];
        DP[i] %= M;
        if (C[i] != C[i - 1]) SUM_DP_VALUES[C[i]] += DP[i - 1];
        SUM_DP_VALUES[C[i]] %= M;
    }
    cout << DP[n];
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vecl = vector<ll>;
using Graph = vector<vector<int>>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int ans1 = 0, ans2 = 0;
  REP(i, S.size()) {
    if (i % 2 == 0 && S.at(i) == '0')
      ans1++;
    else if (i % 2 != 0 && S.at(i) == '1')
      ans1++;
  }
  REP(j, S.size()) {
    if (j % 2 == 0 && S.at(j) == '1')
      ans2++;
    else if (j % 2 != 0 && S.at(j) == '0')
      ans2++;
  }
  cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {


		public static void main(String[] agrs)
		{
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int l = sc.nextInt();
			int a=2;
			int num=0;
			int min=l;
			while(a<=n)
			{
				num=l+a-1;
				if(Math.abs(num)<Math.abs(min))
				{
					min = num;
				}
				++a;
			}
		
			int sum=0;
			int b=1;
			while(b<=n)
			{
				num=l+b-1;
				while(num!=min)
				{
					sum+=num;
					break;
				}
				++b;
			}
			System.out.println(sum);
			
		}
		}
	 
	



Measured memory_bytes: 22740
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int N,T;
int main(int argc, char const *argv[])
{
    cin>>N>>T;
    std::vector<int> c(N);
    std::vector<int> t(N);
    for(int i=0;i<N;i++){
        cin>>c[i]>>t[i];
        if(t[i]>T){
            c[i]=1001;
        }
    }

    int min = *std::min_element(c.begin(), c.end());
    if(min==1001){
        cout<<"TLE"<<endl;
    }else{cout<<min<<endl;}
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#define pb push_back
using namespace std;

inline char nc(){
  static char buf[100000],*p1=buf,*p2=buf;
  return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline void read(int &x){
  char c=nc(),b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}

const int N=200005;

int T[N<<2],F[N<<2];
inline void Build(int x,int l,int r){
  if (l==r) return void(T[x]=l);
  int mid=(l+r)>>1; Build(x<<1,l,mid); Build(x<<1|1,mid+1,r);
  T[x]=max(T[x<<1],T[x<<1|1]);
}
inline void Add(int x,int l,int r,int ql,int qr){
  if (ql<=l && r<=qr){
    T[x]++; F[x]++; return;
  }
  int mid=(l+r)>>1;
  if (ql<=mid) Add(x<<1,l,mid,ql,qr);
  if (qr>mid) Add(x<<1|1,mid+1,r,ql,qr);
  T[x]=F[x]+max(T[x<<1],T[x<<1|1]);
}
inline int Query(int x,int l,int r,int ql,int qr){
  if (ql<=l && r<=qr)
    return T[x];
  int mid=(l+r)>>1,ret=0;
  if (ql<=mid) ret=max(ret,Query(x<<1,l,mid,ql,qr));
  if (qr>mid) ret=max(ret,Query(x<<1|1,mid+1,r,ql,qr));
  return ret+F[x];
}

int n,m;
vector<int> R[N];

int main(){
  int x,y;
  read(n); read(m);
  for (int i=1;i<=n;i++) read(x),read(y),R[x].pb(y);
  int ans=0; Build(1,0,m+1);
  for (int i=0;i<=m;i++){
    for (int x:R[i])
      Add(1,0,m+1,0,x);
    ans=max(ans,Query(1,0,m+1,i+1,m+1)-i-m-1);
  }
  printf("%d\n",max(n-m,ans));
  return 0;
}

Measured memory_bytes: 14208
import numpy as np
H,N=map(int,list(input().split(" ")))
a=np.empty(N,dtype=int)
b=np.empty(N,dtype=int)
for i in range(N):
    a[i],b[i]=map(int,list(input().split(" ")))
dp=np.empty(H+1,dtype=int)
dp[0]=0
for h in range(1,H+1):
    t=h-a
    t[t<0]=0
    dp[h]=np.min(dp[t]+b)
print(dp[H])

Measured memory_bytes: 12508
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#define MAX 30001
using namespace std;

void eratos ( int n, bool prime[]){
    for ( int i = 0; i <= n; i++ ) prime[i] = false;
    for ( int i = 3; i <= n; i += 2 ) prime[i] = true;
    prime[2] = true;
    int limit = (int)sqrt((double)n) + 1;
    for ( int i = 3; i <= limit; i += 2 ){
	if ( !prime[i] ) continue;
	for ( int j = i + i; j <= n; j += i ) prime[j] = false;
    }
}

int main(void){
    bool prime[MAX + 1];
    int P[MAX];
    eratos( MAX, prime );
    int size = 0;
    for ( int i = 2; i <= MAX; i++ ){
	if ( prime[i] )  P[size++] = i;
    }
    int T;

    while(1){
	scanf("%d", &T);
	if ( T == 0 ) break;
	int sum = 0;
	for ( int i = 0; i < size; i++ ){
	    if ( P[i] > T ) { i = size; continue; }
	    for ( int j = i; j < size; j++ ){
		if ( P[i] + P[j] > T ) { j = size; continue; }
		int th = T - (P[i] + P[j]);
		if ( th >= P[j] && prime[th] ){
		    if ( th < P[i]+P[j] ) sum++;
		}
	    }
	}
	printf("%d\n", sum);



    }
    return 0;
}

Measured memory_bytes: 920
#define _USE_MATH_DEFINES

#include <iostream>
#include <iterator>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <climits>
#include <ctime>

using namespace std;
using ll = long long;
using ull = unsigned long long;

bool check(int a, int b, string s) {
	if (a + b + 1 != s.size())
		return false;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == '-' && i != a)
			return false;
		if (i == a && s[i] != '-')
			return false;
	}
	return true;
}

void solve() {
	int a, b;
	scanf("%d %d\n", &a, &b);
	string s;
	getline(cin, s);
	if (!check(a, b, s))
		cout << "No";
	else
		cout << "Yes";
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();

#ifdef LOCAL
	cerr << double(clock()) / CLOCKS_PER_SEC << " sec" << endl;
#endif
	return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    int n;
    cin>>n;
    vector<int>a(n),b(n),ar(n);
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<n; i++)
        cin>>b[i];

    for(int i=0; i<n; i++)
        ar[i]=i+1;
    int x,y;

    int cnt=1;
    do
    {
//        for(int i=0;i<n;i++)cout<<ar[i]<<" ";
//        cout<<endl;
        if(ar==a)
            x=cnt;
        if(ar==b)
            y=cnt;
        cnt++;
//        cout<<cnt<<endl;
    }
    while (next_permutation(all(ar)));
    cout<<abs(x-y);
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]

def popcnt(n):
  c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
  c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
  c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f)
  c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff)
  c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff)
  c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff)
  return c

answer = 10 ** 18

for i in range(2 ** (H - 1)):
    answer_tmp = popcnt(i)
    dic = [-1] * H
    index = 0
    for j in range(H):
        dic[j] = index
        if i >> j & 1:
            index += 1
    tmp = [0] * (index + 1)
    
    flag = 0
    for k in range(W):
        for j in range(H):
            if S[j][k] == "1":
                tmp[dic[j]] += 1
        if k == 0 and max(tmp) > K:
            flag = 1
            break
        if max(tmp) > K:
            answer_tmp += 1
            for j, t in enumerate(tmp):
                tmp[j] = 0
            for j in range(H):
                if S[j][k] == "1":
                    tmp[dic[j]] += 1
            if max(tmp) > K:
                flag = 1
                break
    if flag:
        continue
    answer = min(answer, answer_tmp)

print(answer)

Measured memory_bytes: 46812