akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
struct Edge {
    int from, to; string spell;
    Edge(int f, int t, string s)
         :from(f), to(t), spell(s){}
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ifstream cinu("1169_input.txt");
    int N, A, S, G;
    while(cin >> N >> A >> S >> G && N){
        vector<Edge> es;
        int x_, y_; string s;
        rep(i, A){
            cin >> x_ >> y_ >> s;
            es.push_back(Edge(y_, x_, s));
        }
        vector<string> dist(N);
        for(string& s : dist) s = "~"; dist[G] = "";
        bool fail = false;
        rep(repnum, N * 6){
            bool update = false, update_s = false;
            for(const Edge& e : es)
              if(dist[e.from] != "~" && dist[e.to] > e.spell + dist[e.from]){
                  dist[e.to] = e.spell + dist[e.from];
                  update = true;
                  if(e.to == S) update_s = true;
              }
            if(!update) break;
            if(repnum > N && update_s){
                fail = true;
                break;
            }
        }
        if(dist[S] == "~" || fail) cout << "NO" << endl;
        else cout << dist[S] << endl;
    }
    return 0;
}

Measured memory_bytes: 3512
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <numeric>

using namespace std;

int main()
{
    string s;
    int n, m, k;
    cin >> s;

    if (!(s[0] == s[1] && s[0] == s[2] && s[0] == s[3]) && ((s[0] == s[1] && s[2] == s[3]) || (s[0] == s[2] && s[1] == s[3]) || (s[0] == s[3] && s[1] == s[2])))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n;
int m;
vector<int>adj[maxn];
vector<int>rev[maxn];
vector<int>adjs[maxn];
vector<int>revs[maxn];
vector<int>topol;
int cnt;
int dp[maxn];
int pd[maxn];
int cmp[maxn];
bool mark[maxn];
void dfs(int o){
	mark[o]=true;
	for(int i=0;i<adj[o].size();i++){
		if(mark[adj[o][i]]==false){
			dfs(adj[o][i]);
		}
	}
	topol.push_back(o);
}
void dfs2(int o){
	mark[o]=true;
	cmp[o]=cnt;
	for(int i=0;i<rev[o].size();i++){
		if(mark[rev[o][i]]==false){
			dfs2(rev[o][i]);
		}
	}
	//topol.push_back(adj[o][i]);
}
void dfs3(int o){
	mark[o]=true;
	for(int i=0;i<adjs[o].size();i++){
		if(mark[adjs[o][i]]==false){
			dfs3(adjs[o][i]);
		}
	}
	topol.push_back(o);
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a;
		int b;
		cin>>a>>b;
		adj[a].push_back(b);
		rev[b].push_back(a);
	}
	for(int i=1;i<=n;i++){
		if(mark[i]==false){
			dfs(i);
		}
	}
	reverse(topol.begin(),topol.end());
	fill(mark,mark+maxn,0);
    for(int i=0;i<n;i++){
  //  	cout<<topol[i]<<endl;
		if(mark[topol[i]]==false){
			dfs2(topol[i]);
			cnt++;
		}
	}
	for(int i=1;i<=n;i++){
		dp[cmp[i]]++;
		pd[cmp[i]]++;
		for(int j=0;j<adj[i].size();j++){
			if(cmp[i]!=cmp[adj[i][j]]){
			adjs[cmp[i]].push_back(cmp[adj[i][j]]);
			revs[cmp[adj[i][j]]].push_back(cmp[i]);
		}
		}
	}
	fill(mark,mark+maxn,0);
	topol.clear();
	for(int i=0;i<cnt;i++){
		if(mark[i]==false){
			dfs3(i);
		}
	}
//	for(int i=1;i<=n;i++){
//		cout<<i<<" "<<cmp[i]<<endl;
//	}
	reverse(topol.begin(),topol.end());
	for(int i=0;i<topol.size();i++){
		for(int j=0;j<adjs[topol[i]].size();j++){
			pd[adjs[topol[i]][j]]=max(pd[adjs[topol[i]][j]],pd[topol[i]]+dp[adjs[topol[i]][j]]);
//			cout<<adjs[topol[i]][j]<<" "<<pd[adjs[topol[i]][j]]<<endl;
		}
	}
	int max1=0;
	for(int i=0;i<cnt;i++){
		max1=max(max1,pd[i]);
	} 
	cout<<max1-1;
}

Measured memory_bytes: 26876
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

char c[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

int main() {
	int n; cin >> n;
	string s1, s2;
	
	for (int i=0; i<n; i++) {
		cin >> s1 >> s2;
		reverse(s1.begin(), s1.end());
		reverse(s2.begin(), s2.end());
		
		string s = "";
		
		if (s1.size() == s2.size()) {
			int r = 0, t = 0;
			for (int i=0; i<(int)s1.size(); i++) {
				int x = s1[i]-c[0], y = s2[i]-c[0];
				int z = x + y + t;
				r = z%10;
				t = z/10;
				s += c[r];
			}
			if (t) s += c[t];
		} else if (s1.size() > s2.size()) {	
			int r = 0, t = 0;
			for (int i=0; i<(int)s2.size(); i++) {
				int x = s1[i]-c[0], y = s2[i]-c[0];
				int z = x + y + t;
				r = z%10;
				t = z/10;
				s += c[r];
			}
			if (t) {
				for (int i=(int)s2.size(); i<(int)s1.size(); i++) {
					int z = s1[i]-c[0]+t;
					r = z%10;
					t = z/10;
					s += c[r];
				}
				if (t) s += c[t];
			} else {
				for (int i=(int)s2.size(); i<(int)s1.size(); i++) s += c[s1[i]-c[0]];
			}
		} else {
			int r = 0, t = 0;
			for (int i=0; i<(int)s1.size(); i++) {
				int x = s1[i]-c[0], y = s2[i]-c[0];
				int z = x + y + t;
				r = z%10;
				t = z/10;
				s += c[r];
			}
			if (t) {
				for (int i=(int)s1.size(); i<(int)s2.size(); i++) {
					int z = s2[i]-c[0]+t;
					r = z%10;
					t = z/10;
					s += c[r];
				}
				if (t) s += c[t];
			} else {
				for (int i=(int)s1.size(); i<(int)s2.size(); i++) s += c[s2[i]-c[0]];
			}
		}
		
		if (s.size() > 80) cout << "overflow" << endl;
		else {
			reverse(s.begin(), s.end());
			cout << s << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <vector>
#include "limits.h"
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <functional>


#define mod 1000000000+7;
typedef long long ll;
using namespace std;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n; cin >> n;
	vector<int> p(n);
	for(int i{}; i<n; i++){
		cin >> p[i];
	}
	int ans{}, curMin{1000000000};
	for(int i{}; i<n; i++){
		curMin = min(curMin,p[i]);
		if(curMin == p[i]) ans++;
	}
	cout << ans << "\n";

}

Measured memory_bytes: 3968
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
using namespace std::literals;

struct Point {
  double x, y;
};

double square(double x) { return x * x; }
double distance(Point a, Point b) {
  return sqrt(square(a.x - b.x) + square(a.y - b.y));
}

int main() {
  constexpr auto N_max = 8;
  auto N = 0;
  auto P = array<Point, N_max>{};
  cin >> N;
  for (auto i = 1; i <= N; ++i)
    cin >> P[i].x >> P[i].y;

  auto order = vector<int>{};
  order.resize(N);
  iota(begin(order), end(order), 1);

  auto sum = 0.0;
  auto pattern = 0;
  do {
    ++pattern;
    for (auto i = 0; i + 1 < N; ++i)
      sum += distance(P[order[i]], P[order[i + 1]]);
  } while (next_permutation(begin(order), end(order)));

  cout << setprecision(10) << (sum / pattern);
  return 0;
}


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

int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    int i = 0;
    while(i < S.size()) {
        if (S.substr(i, 5) == "maerd") {
            i += 5;
            continue;
        } else if (S.substr(i, 5) == "esare") {
            i += 5;
            continue;
        } else if (S.substr(i, 6) == "resare") {
            i += 6;
            continue;
        } else if (S.substr(i, 7) == "remaerd") {
            i += 7;
            continue;
       } else {
            printf("NO");
            return 0;
       }
    }
    printf("YES");
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < n; i++)
 
int main(void){
    ll n, k;
    cin >> n >> k;
 
    ll v[n];
    rep(i, n){
        cin >> v[i];
    }
 
    ll ma = -100000000;
    rep(a, n + 1){
        rep(b, n + 1){
            vector<ll> h;
            if(a + b > n || a + b > k) continue;
            rep(i, a){
                h.push_back(v[i]);
            }
            rep(i, b){
                h.push_back(v[n-1-i]);
            }
 
            sort(h.begin(), h.end());
            ll cost = accumulate(h.begin(), h.end(), 0LL);
            rep(i, k - a - b){
                if(i >= h.size()) break;
                if(h[i] != abs(h[i]))
                    cost -= h[i];
            }
            ma = max(ma, cost);
        }
    }
 
    cout << ma << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int main(){
    int N;
    cin>>N;
    map<int,int> D;
    rep(i,N){
        int d;
        cin>>d;
        D[d]++;
    }
    int M;
    cin>>M;
    map<int,int> T;
    rep(i,M){
        int t;
        cin>>t;
        T[t]++;
    }

    string ans="YES";
    repr(e,T){
        if(D[e.first]<e.second){
            ans="NO";
            break;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 22272
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int, int> fc;
    erep(i, 1, n) {
      int t = i;
      rep(j, 2, 100) {
        if (t == 1) break;
        while (t % j == 0) fc[j]++, t /= j;
      }
    }
    int p = 0, q = 0, r = 0, s = 0;
    for (auto& x : fc) {
      if (x.second >= 24) p++;
      if (x.second >= 14) q++;
      if (x.second >= 4) r++;
      if (x.second >= 2) s++;
    }
    int ans = 0;
    if (fc[2] >= 74) ans++;
    ans += p * (s - 1);
    ans += q * (r - 1);
    if (r >= 2) ans += r * (r -1) / 2 * (s - 2);
    cout << ans << endl;
    return 0;
}



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

#define int long long
signed main(){
    string s;
    cin >> s;
    if(s.size()%2==0){
        if(s[0]==s[s.size()-1])cout << " First ";
        else cout << " Second ";
    }else{
        if(s[0]==s[s.size()-1])cout <<  " Second ";
        else cout <<" First ";
    }

 
    return 0;

}

Measured memory_bytes: 512
'use strict'
const main = (input: string) => {
    const std: string[] = input.split('\n')
    const n: number = ~~std.shift()
    let l: string[] = std.map((v,i) => {
        const [key, val] = v.split(' ')
        // 文字列ソートなので3桁の数値になるようにしとく
        return `${key}${999 - Number(val)},${++i}`
    }).sort()
    const r = l.forEach(v => console.log(v.split(',')[1]))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())

Measured memory_bytes: 7628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,T; cin >> n >> T;
    int ans = 1<<30;
    for (int i = 0; i < n; i++) {
        int c, t; cin >> c >> t;
        if (t <= T)
        {
            ans = min(ans, c);
        }
    }
    if (ans == 1<<30)
    {
        cout << "TLE\n";
    } else {
        cout << ans << endl;
    }
    return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<std::string> S){
    sort(ALL(S));
    VS ans;
    int max_cnt = 0;
    int cnt = 1;

    REP(i, N) {
        if(i+1 == N || S[i] != S[i+1]){
            if(max_cnt < cnt) {
                max_cnt = cnt;
                ans.clear();
                ans.PB(S[i]);
            } else if(cnt == max_cnt) {
                ans.PB(S[i]);
            }
            cnt = 1;
        } else {
            cnt++;
        }
    }

    REP(i, ans.size()) cout << ans[i] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}



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

int main(){
    int n;
    string s;
    map<string, int> mp;
    cin >> n;
    while (n){
        cin >> s;
        mp[s] ++;
        n --;
    }
    
    int mx = 0;
    for (auto p: mp){
        mx = max(mx, p.second);
    }

    for (auto p: mp){
        if (p.second != mx) continue;
        cout << p.first << endl;
    }

    return 0;
}

Measured memory_bytes: 19220
#include <cmath>
#include <cstddef>
#include <iostream>
#include <vector>

const double kEpsilon = 1e-10;
inline bool equals(double a, double b)
{
    return fabs(a - b) < kEpsilon;
}

class Point
{
  public:
    double x, y;

    Point() = default;
    Point(double x, double y) : x(x), y(y)
    {
    }

    Point operator+(const Point &p)
    {
        return Point(x + p.x, y + p.y);
    }
    Point operator-(const Point &p)
    {
        return Point(x - p.x, y - p.y);
    }
    Point operator*(const double k)
    {
        return Point(x * k, y * k);
    }

    double SquaredNorm()
    {
        return x * x + y * y;
    }
    double abs()
    {
        return sqrt(this->SquaredNorm());
    }

    bool operator<(const Point &p) const
    {
        return x != p.x ? x < p.x : y < p.y;
    }
    bool operator==(const Point &p) const
    {
        return fabs(x - p.x) < kEpsilon && fabs(y - p.y) < kEpsilon;
    }

    double dot(const Point &p) const
    {
        return x * p.x + y * p.y;
    }
    double cross(const Point &p) const
    {
        return x * p.y - y * p.x;
    }
};

double dot(const Point &p1, const Point &p2)
{
    return p1.x * p2.x + p1.y * p2.y;
}
double cross(const Point &p1, const Point &p2)
{
    return p1.x * p2.y - p1.y * p2.x;
}

using Vector = Point;

struct Segment
{
    Point p1, p2;

    Segment() = default;
    Segment(Point &p1, Point &p2) : p1(p1), p2(p2)
    {
    }
};
using Line = Segment;

class Circle
{
  public:
    Point c;
    double r;
    Circle(Point c = Point(), double r = 0.0) : c(c), r(r)
    {
    }
};

using Polygon = std::vector<Point>;

auto swap = [](auto &a, auto &b) {
    auto tmp = a;
    a = b;
    b = tmp;
};

int cross_number(Segment &l, Point &p)
{
    Vector a = l.p1 - p;
    Vector b = l.p2 - p;

    if (a.y > b.y)
        swap(a, b);

    // If p is on the segment
    if (a.cross(b) == 0 && a.dot(b) <= 0)
        return -1;

    if (a.y <= 0 && b.y > 0 && a.cross(b) > 0)
        return 1;

    return 0;
}

int contain(Polygon &pol, Point &p)
{
    auto n = pol.size();
    Segment l;

    unsigned total_cross_number = 0;

    for (size_t i = 0; i <= n - 1; ++i)
    {
        l.p1 = pol.at(i);
        l.p2 = pol.at((i + 1) % n);

        auto ncross = cross_number(l, p);

        // If p is on the segment
        if (ncross == -1)
            return 1;

        total_cross_number += ncross;
    }

    return (total_cross_number % 2) * 2;
}

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

    Polygon pol;
    Point p;
    for (size_t i = 0; i < n; ++i)
    {
        std::cin >> p.x >> p.y;
        pol.push_back(p);
    }

    int q;
    std::cin >> q;
    for (size_t i = 0; i < q; ++i)
    {
        std::cin >> p.x >> p.y;
        std::cout << contain(pol, p) << std::endl;
    }
}



Measured memory_bytes: 3280
//  LINK ZADATKA: http://abc073.contest.atcoder.jp/tasks/abc073_b

#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#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 <complex>
#include <fstream>
#include <cstring>
#include <string>
#include <climits>

using namespace std;

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;


#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define INF 999999999
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define _gcd __gcd
#define eps 1e-9
int polje[100100];
int main(){
	
	int n, l, r;
	
	scanf("%d", &n);
	
	REP(i, n){
		scanf("%d %d", &l, &r);
		FOR(j, l, r) polje[j] = 1; 
	}
	int sol = 0;
	REP(i, 100010) if(polje[i] == 1) sol++;
	printf("%d\n", sol);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;

bool is_integer(double A){
    if(floor(A) == A){
        return true;
    }
    else{
        return false;
    }
}
//A19:55 - 20:00
//B
int main()
{
    vector<int> N;
    N = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << N[K-1] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (1000000000)
#define MOD (1000000007)

int main(void)
{
    char s[5];
    scanf("%s",s);
    int c=0;
    for(int i=1;i<4;i++)
    { 
        if(s[i-1]==s[i])c++;
    }
    if(c==0)
    {
        printf("Good\n");
    }else
    {
        printf("Bad\n");
    }
    

    return 0;
}


Measured memory_bytes: 128
import javax.swing.*;
import java.io.*;
import java.sql.Struct;
import java.text.DecimalFormat;
import java.util.*;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] board = new double[n];
        for(int i = 0; i < n; i++) {
            board[i] = sc.nextDouble();
        }
        double[][] probabilities = new double[n][n + 1];
        probabilities[0][0] = board[0];
        probabilities[0][1] = 1 - board[0];

        for(int i = 1 ; i < n; i++) {
            for (int j = 0; j <= n; j++) {
                double res = 0;
                if (i > 0) {
                    res += probabilities[i - 1][j] * board[i];
                }
                if (j > 0 && i > 0) {
                    res += probabilities[i - 1][j - 1] * (1 - board[i]);
                }
                probabilities[i][j] = res;
            }
        }

        double res = 0;
        for (int j = 0; j <= n / 2 ; j++) {
            res += probabilities[n - 1][j];
        }

        System.out.println(String.format("%.9f", res));
    }
}

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

#define INF 1e9
using namespace std;

#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

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

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

typedef long long ll;

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

int bfs(pair<int, int> start_pos, const int &H, const int &W, const vector<vector<char>> &m) {
    vector<vector<int>> cost(H + 2, vector<int>(W + 2, INF));
    cost[start_pos.first][start_pos.second] = 0;
    int maxi_cost = -1;

    queue<pair<int, int>> que;
    que.push(start_pos);

    int di[] = {0, 0, -1, 1};
    int dj[] = {-1, 1, 0, 0};
    while (!que.empty()) {
        auto now_pos = que.front();
        que.pop();
        REP(i, 4) {
            int np_i = now_pos.first + di[i];
            int np_j = now_pos.second + dj[i];
            if (m[np_i][np_j] == '.') {
                if (chmin(cost[np_i][np_j], cost[now_pos.first][now_pos.second] + 1)) {
                    auto np = make_pair(np_i, np_j);
                    que.push(np);
                }
            }
        }
        if (que.empty()) {

            return cost[now_pos.first][now_pos.second];
        }

    }
    return -1;
}

void printVec(vector<vector<char>> m,int H,int W) {
    REP(i,H+2) {
        REP(j,W+2) {
            cout << m[i][j];
        }
        cout << endl;
    }
}

int main() {
    int H, W;
    cin >> H >> W;

    vector<vector<char>> m(H + 2, vector<char>(W + 2, '#'));
    FOR(i, 1, H + 1) {
        string s;
        cin >> s;
        vector<char> vc(ALL(s));
        REP(j,W) {
            m[i][j+1] = vc[j];
        }
    }
    // printVec(m,H,W);

    int ans = 0;
    FOR(st_i, 1, H + 1) {
        FOR(st_j, 1, W + 1) {
            if (m[st_i][st_j] == '#') continue;
            auto pos = make_pair(st_i, st_j);
            auto res = bfs(pos, H, W, m);
            if (res == -1) {
                cout << "err in " << st_i << st_j << endl;
                return 1;
            }
            // cout << st_i << " " << st_j << " " << res << endl;
            chmax(ans, res);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
using namespace std;
#define N 100009

int main(){
    string a;
    cin>>a;
    long l=a.size();
    string data[l];
    long count0=0;
    long count1=0;
    for (long i=0; i<l; i++){
        data[i] = a.substr(i, 1);
        if (data[i]=="0") count0++;
        else count1++;
    }
    
    if (count0>count1) cout<<count1*2<<endl;
    else cout<<count0*2<<endl;
}

Measured memory_bytes: 5760
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x[] = new int[n];
        for(int i=0; i<n; i++){
            x[i] = sc.nextInt();
        }
        int y[] = x.clone();
        Arrays.sort(y);
        for(int i=0; i<n; i++){
            if(x[i]<y[n/2]) System.out.println(y[n/2]);
            else System.out.println(y[n/2-1]);
        }
    }
}


Measured memory_bytes: 92740
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef pair<int, int> P;
int w, h;
string f[20];
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};
bool isin(int x, int y) { return x>=0&&x<h&&y>=0&&y<w; }
int main() {
    while (scanf("%d%d",&w,&h)) {
        if (!w&&!h) break;
        int sx=-1,sy=-1;
        for (int i=0; i<h; i++) {
            cin>>f[i];
            for (int j=0; j<w; j++) if (f[i][j]=='@') {
                sx=i; sy=j;
                f[i][j]='#';
            }
        }
        queue<P> que;
        que.push(P(sx,sy));
        int res=1;
        while (!que.empty()) {
            int x=que.front().first, y=que.front().second;
            que.pop();
            for (int i=0; i<4; i++) {
                int nx=x+dx[i], ny=y+dy[i];
                if (isin(nx,ny)&&f[nx][ny]=='.') {
                    que.push(P(nx,ny));
                    f[nx][ny]='#';
                    res++;
                }
            }
        }
        printf("%d\n",res);
    }
}

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


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

int main(){

	ll a,b,c,d;
	cin>>a>>b>>c>>d;

	ll ca = (b)/c - (a-1)/c;
	ll cb = (b)/d - (a-1)/d;
	ll lcm = (c*d)/gcd(c,d);
	ll dup = (b)/lcm - (a-1)/lcm;
	//cout<<ca<<" "<<cb<<" "<<"\n";
	cout<<(b-a+1)-(ca+cb-dup);
}

Measured memory_bytes: 256
n,k = map(int, input().split())
w = [int(input()) for _ in range(n)]

def check(p):
    c = t = 0
    for wi in w:
        t += wi
        if t > p:
            t = wi
            c += 1
            if c >= k:
                return False
    return True

s = max(w)
l = sum(w)
while s != l:
    m = (s+l)//2
    if check(m):
        l = m
    else:
        s = m = m+1
print(s)

Measured memory_bytes: 11580
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, a, b) = [int(e) for e in lines[0].split(" ")]

    return (n, a, b)

def solve(n, a, b):
 

    c = b - a 
    d = c // 2
    result1 = 0
    if c % 2 == 0:
        result_p = min([b-1, n-a, d])
    else:
        result_p = min([b-1, n-a])

    game_count_1 = a - 1
    a_idx = 1
    b_idx = b - game_count_1
    dist = b_idx - a_idx
    result_q = 0
    if dist % 2 == 0:
        game_count_2 = dist // 2
        result_q = game_count_1 + game_count_2 
    else:
        dist = (b_idx - 1) - a_idx
        game_count_2 = dist // 2
        result_q = game_count_1 + 1 + game_count_2 


    game_count_3 = n - b
    a_idx = a + game_count_3
    b_idx = n
    dist = b_idx - a_idx
    result_r = 0
    if dist % 2 == 0:
        game_count_4 = dist // 2
        result_r = game_count_3 + game_count_4
    else:
        dist = b_idx - (a_idx + 1)
        game_count_4 = dist // 2
        result_r = game_count_3 + 1 + game_count_4



    result = min([result_p, result_q, result_r])

    return result

def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include<cstdio>

int n,m,p;
int x[101];

int main(void){
	while(1){
		scanf("%d %d %d",&n,&m,&p);
		if(n+m+p==0)break;
		int all=0;
		for(int i=0;i<n;i++){
			scanf("%d",&x[i]);
			all+=x[i];
		}
		all*=(100-p);
		printf("%d\n",x[m-1]>0?all/x[m-1]:0);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath>
#include<vector>
#include<stack>
#include<map>
#include<set>
#define Run(i,l,r) for(int i=l;i<=r;i++)
#define Don(i,l,r) for(int i=l;i>=r;i--)
#define ll long long
#define ld long double
#define inf 0x3f3f3f3f
#define mk make_pair
#define fir first
#define sec second
#define il inline
#define rg register
#define pb push_back
using namespace std;
char t[10]="keyence$",s[1000];
int n;
bool check(int x,int l,int len){
	for(int i=0;i<len;i++)if(s[x+i]!=t[l+i])return false;
	return true;
}
int main(){
	scanf("%s",s);
	n = strlen(s);
	for(int k=0;k<=7;k++){
		if(check(0,0,k)&&check(n-7+k,k,7-k)){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}//by tkys_Austin;


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc=new Scanner(System.in);

		long x=sc.nextLong();
		int i=0;
		double yokin=100;
		
		/*while(yokin<x) {
			yokin=yokin*1.01;
			yokin=Math.floor(yokin); //while文
			
			i++;
		}
		System.out.println(i);*/
		
		for(i=0;yokin<x;i++) {	//for文
			yokin=yokin*1.01;
			yokin=Math.floor(yokin);
		}
		System.out.println(i);
		
		
		sc.close();
	}

}

Measured memory_bytes: 27048
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n,m; cin>>n>>m;
    int total=0;
    int a[m];
    rep(i,m){
        cin>>a[i];
        total += a[i];
    } 
    int ans = 0;
    
    if(total>n) ans = -1;
    else ans = n - total;

    cout << ans << ln;
    return 0;
 }

Measured memory_bytes: 3652
//AtCoder ABC054 A - RGB Cards
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll r,g,b;
    cin>>r>>g>>b;
    ll ans=r*100+g*10+b;
    cout<<(ans%4==0?"YES":"NO")<<endl;
    return 0;
}

Measured memory_bytes: 256
m , d = map(int , input().split())
ans = 0
for i in range(4,m+1):
    for n in range(10, d+1):
        d10 = int(str(n)[0])
        d1 = int(str(n)[1])
        if d1 >= 2 and d10 >= 2:
            if d10 * d1 == i:
                ans +=1
print(ans)

Measured memory_bytes: 3060
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<vector>

typedef std::pair<double, int> P;
std::vector<P> v[4];

int main()
{
	for( int i = 0; i != 24; ++i )
	{
		int n;
		double t;
		std::cin >> n >> t;

		v[i/8].push_back( P( t, n ) );
	}

	for( int i = 0; i != 3; ++i )
		std::sort( v[i].begin(), v[i].end() );

	for( int i = 0; i != 3; ++i )
		for( int j = 2; j != 8; ++j )
			v[3].push_back( v[i][j] );

	std::sort( v[3].begin(), v[3].end() );

	for( int i = 0; i != 4; ++i )
		for( int j = 0; j != 2; ++j )
			std::cout << v[i][j].second << ' ' << std::fixed << std::setprecision( 2 ) << v[i][j].first << std::endl;

	return 0;
}

Measured memory_bytes: 1300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
using namespace std;
struct SAComp{
	const int h,*g;
	SAComp(const int h, const int* g) : h(h), g(g) {}
	bool operator()(const int a, const int b){
		return a == b ? false : g[a] != g[b] ? g[a] < g[b] : g[a+h] < g[b+h];
	}
};
vector<int> buildSA(string &t){
	int n=t.size();
	int g[n],b[n];
	vector<int>suff(n);
	for(int i=0;i<n;i++)suff[i]=i,g[i]=t[i];
	b[0]=b[n-1]=0;
	sort(suff.begin(),suff.end(),SAComp(0,g));
	for(int h=1;b[n-1]!=n-1;h<<=1){
		SAComp comp(h,g);
		sort(suff.begin(),suff.end(),comp);
		for(int i=0;i<n-1;i++)b[i+1]=b[i]+comp(suff[i],suff[i+1]);
		for(int i=0;i<n;i++)g[suff[i]]=b[i];
	}
	return suff;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin>>s;
	s+='$';
	int n=s.size();
	vector<int>suff=buildSA(s);
	vector<pair<char,int>>sorted(n);
	for(int i=0;i<n;i++)sorted[i]={s[(suff[i]-1+n)%n],i};
	sort(sorted.begin(),sorted.end());

	int T;
	for(cin>>T;T--;){
		string q;
		cin>>q;
		int start=0,stop=n,idx=q.size()-1;
		for(;idx>=0;idx--){
			pair<char,int> ql={q[idx],start},qr={q[idx],stop};
			start=lower_bound(sorted.begin(),sorted.end(),ql)-sorted.begin();
			stop=lower_bound(sorted.begin(),sorted.end(),qr)-sorted.begin();
			if(start==stop)break;
		}
		if(idx<0){
			//{vector<int>v;for(;start<stop;start++)v.push_back(suff[start]);sort(v.begin(),v.end());for(auto &e:v)printf("%d\n",e);}
			puts("1");
		}else{
			puts("0");
		}
	}
}

Measured memory_bytes: 23376
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main()
{
  int n;
  cin >> n;
  char s[n];
  int count = 1;
  for(int i =0; i<n ;++i){
    cin >> s[i];
    if(i>0 && s[i-1]!=s[i]){
      count++;
    }
  }
  cout << count << endl;
}

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

using namespace std;

long long dp[1000][1000], p[1005], n, a[1005];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    p[0] = 0;
    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= n; j++)
            dp[i][j] = 1e18;
    for (int i = 0; i < n; i++){
        p[i + 1] = (p[i] + a[i]);
        dp[i][i + 1] = 0;
    }
    for (int j = 1; j <= n; j++){
        for (int i = j - 2; i >= 0; i--){
            for (int k = i; k < j; k++){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + p[j] - p[i]);
            }
        }
    }
    cout << dp[0][n];
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 200200;

int A[MAX];
int C[MAX];
int V[MAX];

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n, m;
	scanf("%d%d", &n, &m);
	FOR (i, 0, n)
	{
		int x;
		scanf("%d", &x);
		x--;
		C[x]++;
		V[i] = x;
	}

	int res = 0;

	FOR (i, 0, n)
	{
		FOR (j, 0, C[i])
		{
			if (i - j >= 0)
			{
				if (A[i-j]) res++;
				A[i-j]++;
			}
			else res++;
		}
	}

	FOR (i, 0, m)
	{
		int ind, y;
		scanf("%d%d", &ind, &y);
		ind--;
		y--;

		int x = V[ind];

		C[x]--;
		int p = x - C[x];
		if (p < 0 || A[p] > 1) res--;
		if (p >= 0) A[p]--;

		p = y - C[y];
		if (p < 0 || A[p]) res++;
		if (p >= 0) A[p]++;
		C[y]++;

		V[ind] = y;

		printf("%d\n", res);
	}

}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
int s[105][105];
int dp[105][105];
int32_t main(){
	fast;
	int h,w;
	cin >> h >> w;
	
	f(i,0,105)  f(j,0,105)  dp[i][j] = inf;
	
	for(int i=1 ; i<=h ; i++)  for(int j=1 ; j<=w ; j++){
		char c;
		cin >> c;
		if(c == '#')   s[i][j] = 1;
	}

	for(int i=h ; i>=1 ; i--){
		for(int j=w ; j>=1 ; j--){
			if(i==h && j==w)  dp[i][j] = s[i][j];
			else if(i == h && j < w){
				dp[i][j] = dp[i][j+1];
				if(s[i][j] == 1 && s[i][j+1] == 0)  dp[i][j]++;
			}
			else if(j == w && i < h){
				dp[i][j] = dp[i+1][j];
				if(s[i][j] == 1 && s[i+1][j] == 0)  dp[i][j]++;
			}
			else {
				dp[i][j] = min(dp[i][j] , dp[i][j+1] + (s[i][j] == 1 && s[i][j+1] == 0));
				dp[i][j] = min(dp[i][j] , dp[i+1][j] + (s[i][j] == 1 && s[i+1][j] == 0));
			}

 		}
	}
	cout << dp[1][1];
}

Measured memory_bytes: 384
_ = int(input())
H = list(map(int, input().split()))

ans = 'Yes'
last_h = H[-1]
for h in reversed(H):
    if h - last_h > 1:
        ans = 'No'
        break
    elif h - last_h == 1:
        last_h = h - 1
    else:
        last_h = h

print(ans)

Measured memory_bytes: 20772
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MOD = 1e9 + 7;
const int MAXN = 200020;

long long f[MAXN];

long long get_MOD(long long k)
{
    return ((k % MOD) + MOD) % MOD;
}

long long quick_pow (int x, int y)
{
    long long ans = 1, t = x;
    while (y)
    {
        if (y % 2 == 1)
        {
            ans *= t;
            ans = get_MOD(ans);
        }
        t *= t;
        t = get_MOD(t);
        y >>= 1;
    }
    return ans;
}

long long cal(int x, int y)
{
    int m = x + y;
    long long ans = f[m];
    ans *= quick_pow(f[x], MOD - 2);
    ans = get_MOD(ans);
    ans *= quick_pow(f[y], MOD - 2);
    ans = get_MOD(ans);
    return ans;
}

int main ()
{
    int h, w, s, t;
    scanf("%d%d%d%d", &h, &w, &s, &t);
    long long ans = 0;
    int all = h + w;
    f[0] = 1;
    for (int i = 1; i <= all; i ++)
    {
        f[i] = f[i - 1] * (long long) i;
        f[i] = get_MOD(f[i]);
    }
    for (int i = t + 1; i <= w; i ++)
    {
        long long x, y;
        x = cal(i - 1, h - s - 1);
        y = cal(w - i, s - 1);
        ans += x * y;
        ans = get_MOD(ans);
    }
    printf ("%lld\n", ans);
    return 0;
}


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

int main() {
  int N, W;
  cin >> N >> W;
  vector V(W + 1, -1L);
  V.at(0) = 0;
  for (int w, v; cin >> w >> v;) {
    for (int i = W; i >= 0; i--) {
      if (V.at(i) != -1) {
        if (i + w < W + 1) V.at(i + w) = max(V.at(i + w), V.at(i) + v);
      }
    }
  }
  cout << *max_element(V.begin(), V.end()) << "\n";
}

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

int main(){
  int n,m;
  while(cin >> n >> m, n){
    vector<int> a(n), b(m);
    for(int i=0;i<n;i++){
      cin >> a[i];
    }
    for(int i=0;i<m;i++){
      cin >> b[i];
    }

    int step = 0, cur = 0;
    for(;;){
      cur += b[step];
      cur += a[cur];
      step++;
      if(cur >= n-1)break;
    }
    cout << step << endl;
  }
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,a[100005],b[100005],sum=0,i;
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld %lld",&a[i],&b[i]);
	}
	sum=0;
	for(i=n-1;i>=0;i--)
	{
		a[i]+=sum;
		if(a[i]%b[i]==0)
		{
			;
		}
		else
		{
			sum+=b[i]-a[i]%b[i];
		}
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 1920
using System;
using System.Collections.Generic;
class Solve{
    int n;
    int m;
    int q;
    int[] a;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        bool[] check = new bool[m];
        int[] counts = new int[m];
        int[] place = new int[m];
        int[] s = new int[m];
        int count = m-2;
        for(int i=0;i<m;i++){
            check[i]=false;
            counts[i] = 0;
        }
        {
            int j = 0;
            for(int i=q-1;i>=0;i--){
                if(!check[a[i]]){
                    check[a[i]] = true;
                    place[a[i]] = j;
                    s[j] = a[i];
                    j++;
                }
            }
            for(int i=0;i<m;i++){
                if(!check[i]){
                    place[i] = j;
                    s[j] = i;
                    j++;
                }
            }
        }
        for(int i =  q-1;i>=0;i--){
            if(counts[place[a[i]]]<n){
                if(place[a[i]] == 0 || counts[place[a[i]]-1] > counts[place[a[i]]]){
                    counts[place[a[i]]]++;
                }
            }
        }
        while(count >= 0){
            if(s[count]<s[count+1]){
                count--;
            }
            else{
                break;
            }
        }
        if(count>=0 && counts[count]<n){
            Console.WriteLine("No");
        }
        else{
            Console.WriteLine("Yes");
        }
    }
    void getinput(){
        string[] str = Console.ReadLine().Split(' ');
        n = int.Parse(str[0]);
        m = int.Parse(str[1]);
        q = int.Parse(Console.ReadLine());
        str = Console.ReadLine().Split(' ');
        a = new int[q];
        for(int i=0;i<q;i++){
            a[i] = int.Parse(str[i])-1;
        }
    }    
}

Measured memory_bytes: 10968
using System;
class p
{
  static void Main()
  {
    int K = int.Parse(Console.ReadLine());
    string[] ipt = Console.ReadLine().Split(' ');
    int A = int.Parse(ipt[0]);
    int B = int.Parse(ipt[1]);
    bool result = false;
    for (int i = A; i <= B; i++) {
      if (i % K == 0) {
        result = true;
        break;
      }
    }
    Console.WriteLine(result ? "OK" : "NG");
  }
}

Measured memory_bytes: 27536
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val n = s.nextInt * 100 + s.nextInt * 10 + s.nextInt
    if (n % 4 == 0) "YES" else "NO"
  }

  val tests = List(
    """4 3 2""".stripMargin -> """YES""",
    """2 3 4""".stripMargin -> """NO"""
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 25652
import java.util.Scanner;

public class Main {

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

		int K = sc.nextInt();

		int a = K/2;
		int b = (K)%2==1 ? a+1:a;

		System.out.println(a*b);


	}

}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n;
	map<string,ll>m;
	cin >> n;
	for(int i=1; i<=n; i++){
		string s;
		cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
int main(void)
{
  int i,sum;
  char num[1001];

  for(;;){
    scanf("%s", &num);
    if(num[0] == '0') break;
    
    sum = 0;
    for(i=0;num[i]!='\0';i++)
      sum += num[i] - '0';
    printf("%d\n", sum);
  }
  
  return 0;
}


Measured memory_bytes: 2144
def main():
    N, D = map(int,input().split())
    point_list = [[int(_) for _ in input().split()] for i in range(N)]

    count = 0
    for i in range(N):
        if (point_list[i][0]**2 + point_list[i][1]**2)**0.5 <= D:
            count += 1
    print(count)


if __name__ == "__main__":
    main()

Measured memory_bytes: 42648
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

void transpose(vector<vector<char>> &b)
{
    if (b.size() == 0)
        return;

    vector<vector<char>> trans_vec(b[0].size(), vector<char>());

    for (int i = 0; i < b.size(); i++)
    {
        for (int j = 0; j < b[i].size(); j++)
        {
            trans_vec[j].push_back(b[i][j]);
        }
    }

    b = trans_vec; // <--- reassign here
}
int main()
{

    ll wa = 0, target = 0, n, sa = INF;

    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
        target += a[i];
    }
    rep(i, n)
    {
        wa += a[i];
        sa = min(sa, abs(wa * 2 - target));
    }

    cout << sa << endl;
    return 0;
}


Measured memory_bytes: 1792
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
    
     int n, m, x1; cin >> n >> m >> x1;
     std::vector<std::vector<int> > v(n, vector<int> (m));
     std::vector<int> cst(n);
     for(int i = 0; i < n; i++){
     	cin >> cst[i];
     	for(int j = 0; j < m; j++){
     		//int x; cin >> x;
     		cin >> v[i][j];
     	}
     }
     int l = (1LL << (n)) ;
     int mn = 1e16;
     for(int i = 1; i < l; i++){
     	int ansr = 0;
     	std::vector<int> temp(m, 0);
     	int x = i;
     	int j = 0;
     	while(x){
     		if(x&1){
     			ansr += cst[j];
     			//cout << v[j][0]<<"\n";
     			for(int k = 0; k < m; k++)
     				temp[k] += v[j][k]; 
     		}
     		j++;
     		x = x >> 1;
     	}
     	int flag = 1;
     	for(int k = 0; k < m; k++){
     		if(temp[k] < x1)
     			flag = 0;
     	}
     	if(flag){
     		mn = min(mn, ansr);
     	}
     }
     if(mn >= 1e15)
     	cout << "-1";
     else cout << mn;
    	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll A[10],As[10];
ll i, j, k;

ll calc(bool flg){
    ll ret = 0;
    fornum(i,0,7){
        As[i] = A[i];
    }
    if(flg&&As[0]>0&&As[3]>0&&As[4]>0){
        ret += 3;
        --As[0];
        --As[3];
        --As[4];
    }
    ret += As[0] / 2 * 2;
    ret += As[1];
    ret += As[3] / 2 * 2;
    ret += As[4] / 2 * 2;
    return ret;
}
int main(){
    fornum(i,0,7){
        scanf("%lld", &A[i]);
    }

    printf("%lld", max(calc(false), calc(true)));
    return 0;
}

Measured memory_bytes: 256