akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

const int MAX_V = 1000;
const int INF = INT_MAX/3;

struct edge{
    int to, cap, rev;
    edge(int to, int cap, int rev): to(to), cap(cap), rev(rev) {}
};

struct graph{
    vector<edge> G[MAX_V];
    bool visited[MAX_V];

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

    int ford_fulkerson(int s, int t){
        int flow = 0;
        int f = 1;
        while(f!=0){
            memset(visited, false, sizeof(visited));
            f = dfs(s, t, INF);
            flow += f;
        }
        return flow;
    }

    int dfs(int v, int t, int f){
        if(v==t) return f;
        visited[v] = true;
        for(int i=0;i<G[v].size();i++){
            edge &e = G[v][i];
            if(!visited[e.to] && e.cap > 0){
                int 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;
    }

    void print_graph(int V){
        for(int i=0;i<V;i++){
            printf("vertex: %d\n", i);
            for(int j=0;j<G[i].size();j++){
                printf("to: %d, cap: %d\n", G[i][j].to, G[i][j].cap);
            }
            cout << endl;
        }
    }
};

int main(){
    int V, E;
    cin >> V >> E;
    graph g;
    for(int i=0;i<E;i++){
        int from, to, cap;
        cin >> from >> to >> cap;
        g.add_edge(from, to, cap);
    }
    cout << g.ford_fulkerson(0, V-1) << endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    string answer = "";
    for(int i=0;i<s.size();i++){
        if(s[i]=='0' || s[i]=='1') answer.push_back(s[i]);
        else{
            if(answer.size()==0);
            else answer.erase(answer.end()-1);
        }
    }
    cout << answer << endl;
}

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

int main()
{
    string S;
    int XY[2];
    cin >> S >> XY[0] >> XY[1];

    vector<vector<int>> steps(2);

    int ind = 0, cnt = 0;
    for (auto ch : S) {
        if (ch == 'F') {
            cnt++;
        } else {
            steps[ind].push_back(cnt);
            cnt = 0;
            ind ^= 1;
        }
    }
    if (cnt > 0) steps[ind].push_back(cnt);    

    using seti = set<int>;
    bool yes = true;
    for (int i = 0; i < 2; i++) {
        seti s;
        s.insert(i == 0 && steps[i].size() > 0 ? steps[0][0] : 0);
        for (int j = (i ^ 1); j < steps[i].size(); j++) {
            seti t;
            for (auto pos : s) {
                t.insert(pos + steps[i][j]);
                t.insert(pos - steps[i][j]);
            }
            s = t;
        }
        if (s.count(XY[i]) == 0) {
            yes = false;
            break;
        }
    }

    cout << (yes ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  string s;
  cin>>s;
  if(n&1)
  {cout<<"No";return 0;}
  string a="";
  string b="";
  for(int i=0;i<n/2;i++)
    a+=s[i];
  for(int i=n/2;i<n;i++)
    b+=s[i];
  if(a==b)
    cout<<"Yes";
  else
    cout<<"No";
}

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mxn = 2e5 + 5;
int n;
int cnt[60][25][10];

void read(char *&p, int &x) {
	while (isdigit(*p)) x = x * 10 + *p - '0', p ++;
}

int main() {
	scanf("%d", &n);
	ll ans = 0;
	rep(i, n) {
		char s[25], *p = s; scanf("%s", s);
		int a = 0, b = 0, di = 0, e = 1;
		read(p, a);
		if (*p == '.') {
			++ p;
			char *op = p;
			read(p, b);
			di = p - op;
			rep(x, di) e = e * 10;
		}
		ll v = 1LL * a * e + b;
		int c2i = 0, c5i = 0;
		while (v % 2 == 0) v /= 2, c2i ++;
		while (v % 5 == 0) v /= 5, c5i ++;
		// min(c2i + c2j, c5i + c5j) >= di + dj
		rep(c2j, 60) rep(c5j, 25) if (cnt[c2j][c5j][9] && min(c2i + c2j, c5i + c5j) - di >= 0)
			ans += cnt[c2j][c5j][min(9, min(c2i + c2j, c5i + c5j) - di)];
		for (int x = di; x < 10; ++ x)
			cnt[c2i][c5i][x] ++;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3832
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int maxN = max({a, b, c});
  int ans = maxN * 10;
  if (a == maxN) ans += b + c;
  else if (b == maxN) ans += a + c;
  else ans += a + b;
  P(ans);
  return 0;
}



Measured memory_bytes: 256
a,b,c= map(int,input().split())
cnt = 0
if a == b and b == c:
    if a%2 == 0 and b%2 == 0 and c%2 == 0:
        print(-1)
        exit()
    else:
        print(0)
        exit()
while a%2 == 0 and b%2 == 0 and c%2 == 0:
    cnt +=1
    x =(b+c)//2
    y =(c+a)//2
    z =(b+a)//2
    a = x
    b = y
    c = z
print(cnt)

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

#define PI acos(-1)
#define int long long int
#define pb push_back
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 300001
#define mod 1000000007

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a;
  cin >> a;
  cout << (a + 1) % 2 << endl;
}

Measured memory_bytes: 3648
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: &Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let H = read::<i32>();
    let W = read::<i32>();

    let mut Vs = Vec::new();

    for h in 0..H {
        let S = read_String_Vec();
        Vs.push(S);
    }
    for h in 0..H {
        for w in 0..W {
            if Vs[h as usize][w as usize] == '#' { continue; }
            let mut bombs = 0;
            for hh in 0..3 {
                let hhh:i32 = h+hh-1;
                if hhh < 0 || H-1 < hhh { continue; }
                for ww in 0..3 {
                    let www:i32 = w+ww-1;
                    if www < 0 || W-1 < www { continue; }
                    if hh == 1 && ww == 1 { continue; }

                    if Vs[hhh as usize][www as usize] == '#' { bombs += 1; }
                }
            }

            let tmp = bombs.to_string().chars().collect::<Vec<char>>();
            Vs[h as usize][w as usize] = tmp[0];
        }
    }
    for h in 0..H {
        let S = vecchar_to_String( & Vs[h as usize] );
        println!("{}", S );
    }
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var di = new Dictionary<long, long>();
		long sum = 0;
		foreach(var n in A){
			if(!di.ContainsKey(n)) di.Add(n, 0);
			di[n]++;
			sum += n;
		}
		
		var sb = new StringBuilder();
		for(int i=0;i<Q;i++){
			if(!di.ContainsKey(B[i])){
				sb.AppendLine(sum.ToString());
				continue;
			}
			
			long lose = di[B[i]] * B[i];
			long gain = di[B[i]] * C[i];
			sum -= lose;
			sum += gain;
			sb.AppendLine(sum.ToString());
			
			long cnt = di[B[i]];
			if(!di.ContainsKey(C[i])) di.Add(C[i],0);
			di[B[i]] = 0;
			di[C[i]] += cnt;
		}
		
		Console.Write(sb.ToString());
		
	}
	int N;
	long[] A;
	int Q;
	long[] B,C;
	public Sol(){
		N = ri();
		A = rla();
		Q = ri();
		B = new long[Q];
		C = new long[Q];
		for(int i=0;i<Q;i++){
			var d = rla();
			B[i] = d[0]; C[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (c > a + b + 1) {
    cout << b + a + b + 1 << endl;
  } else {
    cout << b + c << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

		int n = sc.nextInt();
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < n; i++) {
			set.add(sc.nextInt());
		}
		System.out.println(set.size());
		sc.close();
	}

}


Measured memory_bytes: 23252
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define st(v) sort(v.begin(),v.end());
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 5e5+3; //AREGLAAAAAAAAR!!!!

int main(){
	int n;
	ri(n);


	FOR(i,0,n+1){
		FOR(j,0,n+1){
			if(i*4+j*7==n){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\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);
		// // 整数の入力
		// int a = sc.nextInt();
		// // スペース区切りの整数の入力
		// int b = sc.nextInt();
		// int c = sc.nextInt();
		// // 文字列の入力
		// String s = sc.next();
		// // 出力
    // System.out.println((a+b+c) + " " + s);
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println((a * b) % 2 == 0 ? "Even" : "Odd");
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template<class T>bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s,ans;
    cin>>s;
    REP(i,SZ(s)) {
        if(~i&1) {
            ans+=s[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 592
a = list(input())
before = -1
count =0
for char in a:
    current = char
    if before == current:
        count = count+1
    else:
        before = current

if count<=2:
    s = set()
    for item in a:
        s.add(item)
    if len(s) == 2:
        print("Yes")
        exit()

print("No")

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

int main() {
	int a, b;
	string s;
	cin >> a >> b >> s;
	bool ok = true;
	if(s[a] != '-') {
		ok = false;
	}
	for(int i = 0; i < s.size(); i++) {
		if(i == a) {
			continue;
		}
		if(s[i] < '0' || s[i] > '9') {
			ok = false;
			break;
		}
	}
	if(ok) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(input())
edges = [[]for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append((c, b))
    edges[b].append((c, a))
INF = float('inf')


def dfs(v, parent, distance):
    dist[v] = distance
    for d, v2 in edges[v]:
        if parent == v2:
            continue
        dfs(v2, v, distance+d)


q, k = map(int, input().split())
dist = [INF]*n
dfs(k-1, -1, 0)
for _ in range(q):
    x, y = map(lambda x: int(x)-1, input().split())
    print(dist[x]+dist[y])

Measured memory_bytes: 131772
def comp_rest(a,b):
    if a[0] > b[0]:
        return True
    elif a[0] < b[0]:
        return False
    elif a[0] == b[0]:
        return a[1] < b[1]

def solve():
    N = int(raw_input())
    SP = []
    for i in range(N):
        SiPi = raw_input().split()
        Si = SiPi[0]
        Pi = int(SiPi[1])
        SP.append([Si, Pi, i+1])
    for i in range(N):
        for j in range(i+1, N):
            if comp_rest(SP[i], SP[j]):
                SP[i], SP[j] = SP[j], SP[i]
    for i in range(N):
        print SP[i][2]

if __name__ == '__main__':
    solve()


Measured memory_bytes: 32620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
constexpr int MX = 200005;
long long n, ans;
int main(){
	scanf("%lld", &n);
	for(long long i=2; i*i<=n; i++) if(n%i==0){
		int t=0, k=0;
		for(; n%i==0; n/=i, t++);
		for(; (k+1)*(k+2)/2 <= t; k++);
		ans += k;
	}
	if(n!=1) ans++;
	printf("%lld\n", ans);
}

Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  int a, b, c;
  std::cin >> a >> b >> c;
  std::cout << (a + b) * c / 2 << std::endl;
  /* */

  return EXIT_SUCCESS;
}


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

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

using ll = long long;
using P = pair<ll,ll>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main() {
    ll N;
    cin>>N;
    vector<P> v(N);
    rep(i,N){
        string s;
        cin>>s;
        ll A = 0LL;
        ll cnt = 0LL;
        bool o = false;
        for(auto x:s){
            if(x!='.'){
                ll p = x - '0';
                A = A*10LL+p;
                if(o) cnt++;
            }
            else{
                o = true;
            }
        }
        v[i].first = A;
        v[i].second = cnt;
    }
    vector<ll> A(N),B(N);
    rep(i,N){
        ll a = 0,b=0;
        ll s = v[i].first;
        while(s%2==0) {
            s/=2LL;
            a++;
        }
        while(s%5==0){
            s/=5;
            b++;
        }
        A[i] = a - v[i].second;
        B[i] = b-v[i].second;
    }
    vector<vector<ll>> g(100,vector<ll>(100,0));
    rep(i,N){
        g[A[i]+50][B[i]+50]++;
    }
    for(int i = 99; i >= 0; i--){
        for(int j = 99; j >= 0; j--){
            if(i!=99) g[i][j] += g[i+1][j];
            if(j!=99) g[i][j] += g[i][j+1];
            if(i!=99&&j!=99) g[i][j] -= g[i+1][j+1];
        }
    }
    ll ans = 0;
    rep(i,N) {
        if(-A[i]+50>=100||-B[i]+50>=100) continue;
        ans += g[-A[i]+50][-B[i]+50];
    }
    rep(i,N){
        if(A[i]>=0&&B[i]>=0) ans--;
    }
    ans /= 2;
    cout<<ans<<endl;
}

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

vector<vector<int64_t>> combtable(51,vector<int64_t>(51));

void maketable(){
  int i,j;
  for(i=0;i<=50;i++){
    for(j=0;j<=i;j++){
      if(i==0 || j==0 || i==j){
        combtable.at(i).at(j) = 1;
      }else{
        combtable.at(i).at(j) = combtable.at(i-1).at(j) + combtable.at(i-1).at(j-1);
      }
    }
  }
}
  
  
int main(){
  int64_t n,p;
  int64_t groupa = 0;
  int64_t groupb = 0;
  int64_t acomb = 0;
  int64_t bcomb = 0;
  vector<int64_t> a(50);
  
  cin >> n >> p;
  for(int64_t i=0;i<n;i++){
    cin >> a.at(i);
    if(a.at(i) % 2 == 0){
      groupa++;
    }
  }
  maketable();
  groupb = n - groupa;   
  if(p==0){
    for(int64_t i=0;i<=groupa;i++){
      acomb += combtable.at(groupa).at(i);
    }
    for(int64_t i=0;i<=groupb;i=i+2){
      bcomb += combtable.at(groupb).at(i);
    }
    cout << acomb * bcomb << endl;
  }else{
    if(groupb == 0){
      cout << 0 << endl;
    }else{
      for(int64_t i=0;i<=groupa;i++){
        acomb += combtable.at(groupa).at(i);
      }
      for(int64_t i=1;i<=groupb;i=i+2){
        bcomb += combtable.at(groupb).at(i);
      }
      cout << acomb*bcomb << endl;
    } 
  }
}
    
    
    
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int>ar[100000];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    vector<int>vals(n+2);
    for (int i = 1;i<=n;i++){
        int x;
        cin>>x;
        vals[i] = x;
    }
    for (int i = 0;i<m;i++){
        int a,b;
        cin>>a>>b;
        ar[a].push_back(b);
        ar[b].push_back(a);
    }
    int ans = 0;
    for (int i = 1;i<=n;i++){
        bool flag = true;
        for (auto it:ar[i]){
            if (vals[it]>=vals[i])flag = false;
        }
        if (flag)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8796
#include<iostream>
#include<vector>
#include<algorithm>

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    std::vector<int> max_vec;
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
    }
    max_vec.push_back(-a[0]);
    for(int i = 1; i < n; i++){
        int cur = -a[i];
        auto pos = std::upper_bound(max_vec.begin(), max_vec.end(), cur);
        if(pos != max_vec.end()){
            *pos = cur;
        }else{
            max_vec.push_back(cur);
        }
    }
    std::cout << max_vec.size() << std::endl;
    return 0;
}


Measured memory_bytes: 4240
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second

signed main(){
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
int main()
{
  int k;cin>>k;
  int a,b;cin>>a>>b;
  int flag=0;
  for(int i=a;i<=b;i++)
  {
  	if(i%k==0)
  	{
  		cout<<"OK";
  		flag=1;
  		break;
  	}
  }
  if(flag==0)
  	cout<<"NG";
}

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

const int N = 105;

int f[N];

vector<int> v;
int n, l, mn;

int main() {
#ifdef HOME
	freopen("agc5c.in", "r", stdin);
	freopen("agc5c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int t;

	cin >> n;
	v.resize(n);
	for (auto &i: v)
		cin >> i, ++f[i];

	l = 0;
	for (int i = 1; i <= n; ++i) if (f[i])
		l = i;

	if (l == 1) {
		cout << (n > 2 ? "Impossible" : "Possible") << endl;
		return 0; }

	for (int i = l - 1; i > l / 2 + l % 2; --i)
		f[i]-= 1;
	f[l / 2 + l % 2]-= 1 + l % 2;

	for (int i = l - 1; i >= l / 2 + l % 2; --i) if (f[i] < 0) {
		cout << "Impossible" << endl;
		return 0; }

	for (int i = l; i >= 1; --i) if (f[i] > 0)
		mn = i;

	if (f[l] < 2 || (l == 1 && n > 2) || f[l / 2 + l % 2] != 0 || mn < l / 2 + l % 2)
		cout << "Impossible" << endl;
	else
		cout << "Possible" << endl;

	return 0; }


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		InputReader in = new InputReader(System.in);
		HashMap<String,String> map = new HashMap<>();
		int n = in.readInt();
		String arr[] = new String[n];
		for(int i = 0; i<n; i++) {
			String key = in.readString();
			if(map.containsKey(key)) {
				System.out.println("No"); 
				return; 
			}
			map.put(key, key);
			arr[i] = key;
		}
		String prev = arr[0]; 
		String next = ""; 
		for(int i = 1; i<n; i++){
			next = arr[i]; 
			if(next.charAt(0) != prev.charAt(prev.length()-1)) {
				System.out.println("No"); 
				return; 
			}
			prev = next; 
		}
		System.out.println("Yes");
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  vector<int> A(5);
  rep(i,5)cin>>A[i];
  int m=10;
  int M=0;
  int ans=0;
  rep(i,5){
    if(A[i]%10==0)ans+=A[i];
    else if(A[i]%10<m){
      ans+=(M+10-m);      
      m=A[i]%10;
      M=A[i];
    }
    else{
      ans+=A[i]+10-(A[i]%10);
    }
  }
  ans+=M;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3572
#include<cstdio>
#include<cmath>
struct Point{double x, y;};

int main(){
    Point a, b;
    scanf("%lf %lf %lf %lf", &a.x, &a.y, &b.x, &b.y);

    double dist = sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));

    printf("%.8f\n", dist);

    return 0;
}


Measured memory_bytes: 2720
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 123456789;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

ll a[300000];
ll L[300000],R[300000];
int main() {
	int n;
	scanf("%d",&n);
	fup(i,0,3*n-1,1)scanf("%lld",a+i);
	priority_queue<ll> q;
	ll res=0;
	fup(i,0,n-1,1)
	{
		q.push(-a[i]);
		res+=a[i];
	}
	L[n-1]=res;
	fup(i,n,3*n-1,1)
	{
		q.push(-a[i]);
		res+=a[i]+q.top();
		q.pop();
		L[i]=res;
	}
	while(!q.empty())q.pop();
	res=0;
	fdn(i,3*n-1,2*n,1)
	{
		q.push(a[i]);
		res+=a[i];
	}
	R[2*n]=res;
	fdn(i,2*n-1,0,1)
	{
		q.push(a[i]);
		res+=a[i]-q.top();
		q.pop();
		R[i]=res;
	}
	ll ans=-INF;
	fup(i,n-1,2*n-1,1)ans=max(ans,L[i]-R[i+1]);
	printf("%lld",ans);
}

Measured memory_bytes: 7668
// https://atcoder.jp/contests/abc114/tasks/abc114_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int x;
  string r;

  cin >> x;

  r = x == 3 || x == 5 || x == 7 ? "YES" : "NO";

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    ll ans = 0;
    for (ll i = 1; i <=N; i++) {
        if (i <= 9 || 100 <= i && i <= 999 || 10000 <= i && i <= 99999) {
            ans++;
        }
    }

    cout << ans << "\n";

}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }

    let mut tbl = vec![false; k + 1];

    for i in 0..k + 1 {
        let mut t = false;
        for j in 0..n {
            if i >= a[j] && !tbl[i - a[j]] {
                t = true;
            }
            tbl[i] = t;
        }
    }

    let ans = if tbl[k] { "First" } else { "Second" };
    println!("{}", ans);
}


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

void solve(string S){
	int s = S.size() - 1;
	long long ans = 0;
	for(int i = 0 ; i < (1<<s) ; i++){
		long long tot = 0;
		long long c = 0;
		for(int j = 0 ; j < S.size() ; j++){
			c = c * 10 + S[j] - '0';
			if( i >> j & 1 ) {
				tot += c;
				c = 0;
			}
		}
		ans += tot + c;
	}
	cout << ans << endl;
}



int main(){	
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	solve(S);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
using namespace std;


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

	int H, W, N;
	cin >> H >> W >> N;

	int D[10] = { 0,1,1,-1,0,-1,-1,1,0,0 };
	map<int, int>board;
	rep(q, N) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		rep(i, 9) {
			const int nexty = a + D[i];
			const int nextx = b + D[i + 1];
			if (!(1 <= nexty&&nexty < H-1 && 1 <= nextx&&nextx < W-1))continue;
			auto itr = board.find(nexty*int(1e10)+nextx);
			if (itr == board.end()) {
				board[(nexty*int(1e10) + nextx)] = 1;
			}
			else itr->second++;
		}
	}
	int answer[10] = { 0 };
	answer[0] = (H-2)*(W-2);
	ITR(itr, board) {
		answer[0]--;
		answer[itr->second]++;
	}
	rep(i, 10)cout << answer[i] << endl;
}

Measured memory_bytes: 56448
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,x,min=10000000,flg,flg2=0;
    int c[20],a[20][20];
    int money,sum[20]={};
    cin>>n>>m>>x;

    for(int i=0; i<n; i++){
        cin>>c[i];
        for(int j=0; j<m; j++){
            cin>>a[i][j];
        }
    }

    for(int i=0; i<1<<n; i++){
        flg=0;
        money=0;
        for(int j=0; j<m; j++)sum[j]=0;

        for(int j=0; j<n; j++){
            if(i & (1<<j)){
                for(int k=0; k<m; k++){
                    sum[k]+=a[j][k];
                }
                money+=c[j];        
            }
        }

        for(int j=0; j<m; j++){
            if(sum[j]<x)flg=1;
        }

        if(flg==0){
            if(min>money)min=money;
            flg2=1;
        }

    }
    if(flg2==0)cout<<-1<<'\n';
    else cout<<min<<'\n';

    return 0;

}

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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ANTHRO(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define ANTHRO(x...)
#endif


#define ll long long
#define MOD 1000000007
#define INF (int)1e9
#define EPS 1e-9
/*
    This is G-Longest Path
    This is my second attempt
*/
#define con (int)1e5+5
vector<ll> adj[con];
vector<ll> dp(con,0),i_D(con,0);
vector<bool> v(con,false);
void dfs(ll node){
    v[node]=true;
    for(ll i:adj[node]){
        dp[i]=max(dp[i],dp[node]+1);
        --i_D[i];
        if(i_D[i]==0){
            dfs(i);
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m; cin>>n>>m;
    for(ll i=0;i<m;i++){
        ll x,y; cin>>x>>y;
        adj[x].push_back(y);
        i_D[y]++;
    }
    for(ll i=1;i<=n;i++){
        if(!v[i] && i_D[i]==0){
            dfs(i);
        }
    }
    ll b=-INF;
    for(ll i:dp){
        b=max(b,i);
    }
    cout<<b<<"\n";
    return 0;
}



Measured memory_bytes: 10368
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

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

		int n = stdIn.nextInt();
		int m = stdIn.nextInt();
		int q = stdIn.nextInt();

		List<Numbers> scoreConditionList = new ArrayList<>();
		IntStream.range(0, q).forEach(i -> scoreConditionList
				.add(new Numbers(stdIn.nextInt(), stdIn.nextInt(), stdIn.nextInt(), stdIn.nextInt())));

		SequenceFactory factory = new SequenceFactory(n, m);

		List<Integer[]> sequences = factory.createArrays();

		System.out.println(calcMax(scoreConditionList, sequences));

		stdIn.close();
	}

	private static int calcMax(List<Numbers> scoreConditionList, List<Integer[]> sequences) {
		int max = 0;

		for (Integer[] sequence : sequences) {

			int score = 0;
			for (Numbers sCond : scoreConditionList) {
				score += sCond.getScore(sequence);
			}

			max = Integer.max(max, score);
		}

		return max;
	}
}

class SequenceFactory {
	int m;
	int n;

	public SequenceFactory(int n, int m) {
		this.n = n;
		this.m = m;
	}

	public List<Integer[]> createArrays() {
		List<Integer[]> arrays = new ArrayList<Integer[]>();

		//init
		int[] current = new int[n];
		for (int i = 0; i < n; i++) {
			current[i] = 1;

		}
		arrays.add(copy(current));

		while (true) {
			update(current);
			arrays.add(copy(current));

			if (isEnd(current)) {
				break;
			}
		}

		return arrays;
	}

	private Integer[] copy(int[] current) {
		Integer[] array = new Integer[current.length];

		for (int i = 0; i < array.length; i++) {
			array[i] = current[i];
		}
		return array;
	}

	private boolean isEnd(int[] current) {
		return current[0] == m && current[n - 1] == m;
	}

	private int[] update(int[] current) {
		int len = current.length;

		if (current[len - 1] != m) {
			current[len - 1] = current[len - 1] + 1;
			return current;
		}

		for (int i = len - 2; i >= 0; i--) {
			if (current[i] != m) {

				current[i] = current[i] + 1;

				for (int j = i; j < len; j++) {
					current[j] = current[i];
				}

				return current;

			}

		}

		return current;

	}

}

class Numbers {
	int a;
	int b;
	int c;
	int d;

	public Numbers(int a, int b, int c, int d) {
		this.a = a;
		this.b = b;
		this.c = c;
		this.d = d;
	}

	public int getScore(Integer[] seq) {
		if (seq[b - 1] - seq[a - 1] == c) {
			return d;
		}
		return 0;
	}

}

Measured memory_bytes: 46616
#include<bits/stdc++.h>
using namespace std;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           v.size()
#define		ss              ' '
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef		long long       ll;
typedef		vector<ll>      vll;


int main()
{
 //O_O ;
    ll n,n2;
   char a;
   cin>>a;
   n=a-'0';
   n2=n+1;
   a=n2+'0';
   cout<<a<<nn;


    return 0;
}


Measured memory_bytes: 256
//   <<In The Name Of God>>
// PTD
/*
ID: alimora2
LANG: C++11
TASK: PROB
*/
#include <bits/stdc++.h>

#define sqr(A) (A) * (A)
using namespace std;
typedef long long ll;

string refr[4] = {"dream", "dreamer", "erase", "eraser"};
string s, h;

bool ans(int x) {
	if (x == s.size())
		return 1;
	bool res = 0;
	for (int i = 0; i < 4; i++) {
		h = "";
		for (int j = x; j < min(s.size(), x + refr[i].size()); j++)
			h += s[j];
		if (h == refr[i])
			res |= ans(x + refr[i].size());
	}
	return res;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	cout << (ans(0) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1872
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=110000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll n,a,b,c,d;
  cin >> n >> a >> b  >> c >> d;
  rep(i,n){
    if(c*(n-1-i)-d*i<= b-a && b-a <=d*(n-1-i)-c*i){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

d = deque()

for i in input():
  if i=="0":
    d.append("0")
  elif i=="1":
    d.append("1")
  elif d:
    d.pop()

while d:
  print(d.popleft(),end="")
print()

Measured memory_bytes: 9348
//fifer a tak luboin
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>
 
#define ll long long
#define mp make_pair
#define pb push_back
#define s second
#define f first
#define endl "\n"
 
using namespace std; 
 
const ll inf = 1e14;
const int mod = 998244353;
const int N = (int)100100;
const double eps = 1e-10;                                     
const double pi = acos(-1.0);
int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 
bool is(ll x) {
    for (ll i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}
int main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
    //freopen("bacon.in", "r", stdin);
    //freopen("bacon.out", "w", stdout);
    ll a, b;
    cin >> a >> b;
    vector <ll> del;
    for (ll i = 1; i * i <= a; i++) {
        if (a % i == 0) {
            if (i == a / i) del.pb(i);
            else {
                del.pb(i);
                del.pb(a / i);
            }
        }
    }

    vector <ll> dd;
    for (int i = 0; i < del.size(); i++) {
        if (b % del[i] == 0) {
            dd.pb(del[i]);
        }
    } 


    int cnt = 0;
    for (int i = 0; i < dd.size(); i++) {
        if (is(dd[i]) || dd[i] == 1) cnt++;
    }
    cout << cnt;   
    return 0;    
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
	"strconv"
)

const (
	A  = "GREATER"
	B  = "LESS"
	AB = "EQUAL"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)

	if len(a) > len(b) {
		fmt.Println(A)
		return
	} else if len(a) < len(b) {
		fmt.Println(B)
		return
	}

	ans := AB
	for {
		aPartLen := math.Min(float64(len(a)), 10)
		bPartLen := math.Min(float64(len(a)), 10)
		if aPartLen == 0 && bPartLen == 0 {
			break
		}
		aNum, _ := strconv.ParseUint(a[:int(aPartLen)], 10, 64)
		bNum, _ := strconv.ParseUint(b[:int(bPartLen)], 10, 64)

		if aNum > bNum {
			ans = A
			break
		} else if aNum < bNum {
			ans = B
			break
		}
		a = a[int(aPartLen):]
		b = b[int(bPartLen):]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)


int main(){
	int m,n;
	while(cin>>m>>n,n){
		vector<pii> C1(m),C2(n);
		vector<vector<double>> yp(201),zp(201);
		vector<double> y(201,0.0),z(201,0.0);
		rep(i,m){int a,b; cin>>a>>b; C1[i]={a+100,b+100};}	//xy
		rep(i,n){int a,b; cin>>a>>b; C2[i]={a+100,b+100};}	//xz
		int limit[4]={200,0,200,0};
		rep(i,m){
			limit[0]=min(limit[0],C1[i].first);
			limit[1]=max(limit[1],C1[i].first);
			int j=(i+1)%m;
			auto xr=make_pair(C1[i].first,C1[j].first);
			auto yr=make_pair(C1[i].second,C1[j].second);
			if(xr.second<xr.first){
				swap(xr.second,xr.first);
				swap(yr.second,yr.first);
			}
			int diff=xr.second-xr.first;
			if(diff==0){
				y[xr.first]=fabs(yr.second-yr.first);
			}
			rep(x,diff){
				double l=yr.second-yr.first;
				l/=diff;
				yp[x+xr.first].push_back(yr.first+l*x);
			}
		}
		rep(i,n){
			limit[2]=min(limit[2],C2[i].first);
			limit[3]=max(limit[3],C2[i].first);
			int j=(i+1)%n;
			auto xr=make_pair(C2[i].first,C2[j].first);
			auto zr=make_pair(C2[i].second,C2[j].second);
			if(xr.second<xr.first){
				swap(xr.second,xr.first);
				swap(zr.second,zr.first);
			}
			int diff=xr.second-xr.first;
			if(diff==0){
				z[xr.first]=fabs(zr.second-zr.first);
			}
			rep(x,diff){
				double l=zr.second-zr.first;
				l/=diff;
				zp[x+xr.first].push_back(zr.first+l*x);
			}
		}
		rep(i,201){
			if(yp[i].size()>=3){
				sort(all(yp[i]));
				yp[i].erase(unique(all(yp[i])), yp[i].end());
			}
			if(zp[i].size()>=3){
				sort(all(zp[i]));
				zp[i].erase(unique(all(zp[i])), zp[i].end());
			}
			if(yp[i].size()!=0) y[i]=fabs(yp[i][0]-yp[i][1]);
			if(zp[i].size()!=0) z[i]=fabs(zp[i][0]-zp[i][1]);
		}
		double ans=0.0;
		//for(auto i:limit)cout<<i<<",";cout<<endl;
		limit[1]--; limit[3]--;
		for(int x=max(limit[0],limit[2]);x<=min(limit[1],limit[3]);x++){
			double f1=y[x]*z[x];
			double f2=(y[x+1]+y[x])/2 * (z[x+1]+z[x])/2;
			double f3=y[x+1]*z[x+1];
			ans+=(f1+f2*4+f3)/6;
		}
		cout.precision(6);
		cout<<fixed<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(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;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        ll x;
        cin>>x;
        cout<<8 - (x-400)/200;
        





        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3804
num = list(map(int,input().split()))

max_num = 0

max_num = num[0] * num[2]

max_num = max(max_num, num[0] * num[3])

max_num = max(max_num, num[1] * num[2])

max_num = max(max_num, num[1] * num[3])

print(max_num)

Measured memory_bytes: 9188