akhauriyash/Code-Regression huggingface dataset:
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc167_c
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000

const int nax = 20;
const ll infll = LLONG_MAX/3;
vector<vector<ll>> a(nax, vector<ll>(nax));
vector<ll> c(nax);
int n, m, x;

int main() {
    scanf("%d %d %d", &n, &m, &x);
    for(int i=0; i<n; i++) {
        scanf("%lld", &c[i]);
        for(int j=0; j<m; j++) {
            scanf("%lld", &a[i][j]);
        }
    }
    ll rs = infll;
    for(int i=0; i<(1<<n); i++) {
        vector<ll> t(nax);
        ll cost = 0;
        // cout << "check for: " << i << endl;
        for(int b=0; b<n; b++) {
            if(i&(1<<b)) {
                cost += c[b];
                // cout << "inc: " << b << endl;
                for(int j=0; j<m; j++) {
                    t[j] += a[b][j];
                }
            }
        }
        bool ok = true;
        for(int j=0; j<m; j++) {
            if(t[j]<x) ok = false;
        }
        // cout << "cost: " << cost << " " << ok << " " << x << endl;
        // for(int j=0; j<m; j++) {
        //     cout << t[j] <<" " ;
        // }
        // cout << endl;
        if(ok) rs = min(rs, cost);
    }
    if(rs>=infll) rs = -1;
    printf("%lld\n", rs);
}


Measured memory_bytes: 3796
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

const inf = 1001001001001

func f(x, y int) {
	ans := inf
	for i := 0; i < 4; i++ {
		s := x
		e := y
		cnt := 0
		if i&1 == 1 {
			s = -s
			cnt++
		}
		if i&2 == 2 {
			e = -e
			cnt++
		}
		if s <= e {
			cnt += e - s
			ans = min(ans, cnt)
		}
	}

	out(ans)
}

func main() {
	sc.Split(bufio.ScanWords)
	x, y := getInt(), getInt()

	f(x, y)
	// out("----")

	// ax := abs(x)
	// ay := abs(y)
	// if x == y {
	// 	out(0)
	// 	return
	// }
	// if ax == ay {
	// 	out(1)
	// 	return
	// }

	// if x >= 0 && y >= 0 && x > y {
	// 	if y == 0 {
	// 		out(x - y + 1)
	// 	} else {
	// 		out(x - y + 2)
	// 	}
	// 	return
	// }
	// if x >= 0 && y >= 0 && x < y {
	// 	out(y - x)
	// 	return
	// }

	// if x < 0 && y >= 0 && ax > ay {
	// 	if y == 0 {
	// 		out(ax - ay)
	// 	} else {
	// 		out(ax - ay + 1)
	// 	}
	// 	return
	// }
	// if x < 0 && y >= 0 && ax < ay {
	// 	out(ay - ax + 1)
	// 	return
	// }

	// if x >= 0 && y < 0 && ax > ay {
	// 	out(ax - ay + 1)
	// 	return
	// }
	// if x >= 0 && y < 0 && ax < ay {
	// 	out(ay - ax + 1)
	// 	return
	// }

	// if x < 0 && y < 0 && ax > ay {
	// 	out(ax - ay)
	// 	return
	// }
	// if x < 0 && y < 0 && ax < ay {
	// 	out(ay - ax + 2)
	// 	return
	// }
}


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

int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;

    vector<int> nums;    
    if (S[0] == '0') nums.push_back(0); 
    for (int i = 0; i < S.size();) {
        int j = i;
        while (j < S.size() && S[j] == S[i]) ++j; 
        nums.push_back(j - i);
        i = j;
    }
    if (S.back() == '0') nums.push_back(0);

    vector<int> sums((int)nums.size() + 1, 0);
    for (int i = 0; i < nums.size(); ++i) sums[i+1] = sums[i] + nums[i];

    int res = 0;
    for (int left = 0; left < sums.size(); left += 2) {
        int right = left + K*2+1;
        if (right >= sums.size()) right = (int)sums.size() - 1;
        res = max(res, sums[right] - sums[left]);
    }
    cout << res << endl;
}

Measured memory_bytes: 1272
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> b;
  int ret = 0;
  for (int L = 0; L <= k; ++L) {
    for (int R = 0; L + R <= k && L + R <= n; ++R) {
      b.clear();
      for (int i = 0; i < L; ++i) b.push_back(a[i]);
      for (int i = 0; i < R; ++i) b.push_back(a[n - 1 - i]);
      sort(b.begin(), b.end());
      int rem = k - L - R;
      int cur = accumulate(b.begin(), b.end(), 0);
      for (int i = 0; i < rem && i < b.size() && b[i] < 0; ++i) cur -= b[i];
      ret = max(ret, cur);
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#! /usr/bin/python
# -*- coding: utf-8 -*-

MAX_Y = 8
MAX_X = 8

def main():
    # 入力
    N = int(raw_input())

    for i , j in enumerate(range(N)):
        raw_input()

        data = []
        for j in range(MAX_Y):
            input_list = map(int, raw_input())
            data.append(input_list)
        bomb_X = int(raw_input())
        bomb_Y = int(raw_input())

        bomb_town = explosion(data, ((bomb_X-1, bomb_Y-1),))
        print("Data " + str(i+1) + ":")
        printBomb(bomb_town)

def printBomb(bomb):
    for x in bomb:
        print(reduce(lambda x, y: x+y, (map(str, x))))

# 盤面内か判定
def isIn(x, y):
    return 0<=x<MAX_X and 0<=y<MAX_Y

# 爆弾を爆破
def explosion(data, bomb):
    for b in bomb:
        if data[b[1]][b[0]] == 1:
            new_bomb = bom(data, b)
            burned_data = burned(data, b)
            data = explosion(burned_data, new_bomb)

    return data

# 燃やす
def burned(data, b):
    data[b[1]][b[0]] = 0
    return data

# 燃焼範囲をチェック
def bom(data, b):
    bomb_area =  [(-3, 0), (-2, 0), (-1, 0), (1, 0), (2, 0), (3, 0),
                (0, -3), (0, -2), (0, -1), (0, 1), (0, 2), (0, 3)]
    new_bomb = []
    for x in bomb_area:
        buf = tuple([sum(x) for x in zip(x,b)])
        if isIn(*buf):
            new_bomb.append(buf)

    return new_bomb

if __name__=='__main__':
    main()

Measured memory_bytes: 4444
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main(){
    int n;cin>>n;
    vector <string> S(n);
    for(auto &in:S){
        cin>>in;
    }
    vector<vector<int>> alpha(n,vector<int>(26,0));
    for(int x=0;x<n;x++){
        string & s=S[x];
        for(int i=0;i<(int)s.length();i++){
            alpha[x][s[i]-'a']++;
        }
    }
    string ans="";
    for(int i=0;i<26;i++){
        int minv=INF;
        for(int j=0;j<n;j++){
            minv=min(minv,alpha[j][i]);
        }
        ans+=string(minv,'a'+i);
    }
    cout<<ans<<endl;
    //system("pause");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
vector<double> a;
double dp[3010][3010]={0};
int main(){
  int n;
  cin >> n;
  //double a[n];
  a.resize(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  dp[0][0]=1.0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=i;j++){
      dp[i+1][j+1]+=dp[i][j]*a[i];
      dp[i+1][j]+=dp[i][j]*(1.0-a[i]);
    }
  }
  double res = 0.0;
  for (int j = (n+1)/2; j <= n; j++) res += dp[n][j];
  cout << fixed << setprecision(10) << res << endl;
}


Measured memory_bytes: 69120
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]

result = []
y = 0
while y < H:
    x = 0
    while x < W:
        if a[y][x] % 2 == 1:
            if x == W - 1:
                if y == H - 1:
                    break
                else:
                    result.append('%d %d %d %d' % (y + 1, x + 1, y + 2, x + 1))
                    a[y + 1][x] += 1
            else:
                result.append('%d %d %d %d' % (y + 1, x + 1, y + 1, x + 2))
                a[y][x + 1] += 1
        x += 1
    if y == H - 1:
        break
    y += 1
    x = W - 1
    while x >= 0:
        if a[y][x] % 2 == 1:
            if x == 0:
                if y == H - 1:
                    break
                else:
                    result.append('%d %d %d %d' % (y + 1, x + 1, y + 2, x + 1))
                    a[y + 1][x] += 1
            else:
                result.append('%d %d %d %d' % (y + 1, x + 1, y + 1, x))
                a[y][x - 1] += 1
        x -= 1
    y += 1

print(len(result))
#print('\n'.join(result))
print(*result, sep='\n')


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

void dump(const vector<string>& a) {
  rep(i,a.size()) {
    if (i > 0) cout << " ";
    cout << a[i];
  }
  cout << endl;
}

bool isStable(const vector<string>& stableA, const vector<string>& checkB) {
  rep(i, stableA.size()) {
    if (stableA[i] != checkB[i]) {
      return false;
    }
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  vector<string> a(n, "");
  rep(i, n) {
    cin >> a[i];
  }

  // bubble sort
  auto ba = a; // copy
  rep(i,n) {
    for(int j = n-1; j >= i+1; --j) {
      if (ba[j][1] < ba[j-1][1]) {
        swap(ba[j], ba[j-1]);
      }
    }
  }

  dump(ba);
  cout << "Stable" << endl;

  // selection sort
  auto sa = a; // copy
  rep(i,n) {
    int minj = i;
    for (int j = i; j < n; ++j) {
      if (sa[j][1] < sa[minj][1]) {
        minj = j;
      }
    }
    if (i != minj) {
      swap(sa[i], sa[minj]);
    }
  }

  dump(sa);
  cout << (isStable(ba, sa) ? "Stable" : "Not stable") << endl;

  return 0;
}



Measured memory_bytes: 3236
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
a = Counter(v[::2]).most_common()
b = Counter(v[1::2]).most_common()
if len(a) == 1:
    a.append([0, 0])
if len(b) == 1:
    b.append([0, 0])
if a[0][0] == b[0][0]:
    if a[1][1] > b[1][1]:
        print(n - a[1][1] - b[0][1])
    else:
        print(n - a[0][1] - b[1][1])
else:
    print(n- a[0][1] - b[0][1])

Measured memory_bytes: 20692
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#define int long long

using namespace std;

signed main()
{
	int a,b,c,d,ans;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	ans=max(a*c,max(a*d,max(b*c,b*d)));
	if((a<=0&&b>=0)||(c<=0&&d>=0))
		ans=max(ans,0ll);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3240
import sys
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    A = string_to_int(inputs[0])
    B = string_to_int(inputs[1])
    C = string_to_int(inputs[2])
    s = 0
    prev_i = -1
    for i in A:
        i -= 1
        s += B[i]
        if prev_i != -1 and i == prev_i + 1:
            s += C[prev_i]
        prev_i = i

    return s


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(3))
    print(ret)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cout << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 998244353;
//////////////////////////////////////////

int main(){
  ins(S);
  if(sz(S) == 1) die(1);
  // 0 1コ 1 2コのおわり
  vvi v(sz(S) , vi(2 , 0));
  v[0][0] = 1;
  if(S[0] != S[1]) v[1][0] = 2;
  v[1][1] = 1;
  for(int i = 2; i < sz(S) ;i++){
    v[i][0] = v[i-1][1] + 1;
    if(S[i] != S[i-1]){
      amax(v[i][0] , v[i-1][0] + 1);
    }
    v[i][1] = v[i-2][0] + 1;
    if(i != 2){
      if(S[i-3] != S[i-1] || S[i-2] != S[i]){
        amax(v[i][1] , v[i-2][1] + 1);
      }
    }
  }
  out(max(v[sz(S)-1][0] , v[sz(S)-1][1]));
}

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

int main()
{
    long long n,i,a,b,c,d;
    cin>>n>>a>>b>>c>>d;

    long long x = b-a;

    for(i=0;i<=n-1;++i)
    {
        if(x>=(n-i-1)*c - d*i && x<=d*(n-i-1)-c*i)
        {cout<<"YES";return 0;}
    }

    cout<<"NO";
}


Measured memory_bytes: 256
ans = 0
s = 9
flag = True
for i in range(5):
    n = int(input())
    if n%10 != 0:
        s = min(s,n%10)
        ans += n//10+1
        flag = False
    else:
        ans += n//10
else:
    if flag:
        print(ans*10)
    else:
        print((ans-1)*10+s)
        
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MD=int(1e9)+7;

int madd(int x,int y) {
	if (x+y<MD) return x+y; else return x+y-MD;
}
int msub(int x,int y) {
	if (x-y>=0) return x-y; else return x-y+MD;
}
int mmul(int x,int y) {
	return int(ll(x)*y % MD);
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N,K;
	cin>>N>>K;
	
	set<int> s;
	for (int i=1; i*i<=N; ++i) {
		s.insert(i);
		s.insert(N/i);
	}

	map<int,int> pos;
	vector<tuple<int,int,int>> r;
	int prev=0;
	for (int x:s) {
		r.emplace_back(x,x-prev,0);
		pos[x]=sz(r)-1;
		prev=x;
	}
	int m=sz(r);

	rep(i,0,m) {
		int x=get<0>(r[i]);
		get<2>(r[i])=pos[N/x];
	}
	
	vector<int> f(m);
	rep(i,0,m) f[i]=get<1>(r[i]);
	rep(i,0,K-1) {
		vector<int> g(m);
		rep(j,0,m) {
			int p=get<2>(r[j]);
			g[p]=madd(g[p],f[j]);
		}
		per(j,0,m-1) g[j]=madd(g[j],g[j+1]);
		rep(j,0,m) g[j]=mmul(g[j],get<1>(r[j]));
		f=g;
	}
	
	int res=0;
	rep(i,0,m) res=madd(res,f[i]);
	cout<<res<<"\n";
}


Measured memory_bytes: 7480
N, M = map(int, input().split(" "))
ac = 0
wa = 0
ans = [0] * N
wro = [0] * N
for i in range(M):
    p, s = input().split(" ")
    if ans[int(p)-1] == 0:
        if s == "AC":
            ac += 1
            ans[int(p)-1] = 1
            wa += wro[int(p)-1]
        else:
            wro[int(p)-1] += 1
print(str(ac) + " " + str(wa))


Measured memory_bytes: 4596
#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};

const LL MOD = 2;

void solve(long long N, std::vector<long long> a){
    VLL memo(N+1, 0);
    VI boxIdx;
    for(int i=N; i>0; i--){
        int idx = i;
        int sum = 0;
        while(idx <= N) {
            sum += memo[idx];
            idx += i;
        }

        if(a[i-1] != sum % 2) {
            memo[i] = 1;
            boxIdx.PB(i);
        }
    }

    cout << boxIdx.size() << endl;
    REP(i, boxIdx.size()) cout << boxIdx[i] << (i+1 == boxIdx.size() ? "\n" : " ");
}

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


Measured memory_bytes: 4472
#include<bits/stdc++.h>
using namespace std;
const double eps=1e-3;
const double g=9.8;
const int Max=100;
double L[Max],R[Max],B[Max],T[Max];
double N,V,X,Y;
double getHy(double vy,double t)
{
    return vy*t-g*t*t/2;
}
int cmp(double l,double r,double a)
{
    if(a<l+eps)
    {
        return -1;
    }
    if(a>r-eps)
    {
        return 1;
    }
    return 0;
}
int check(double qx,double qy)
{
    double a=g*g/4;
    double b=g*qy-V*V;
    double c=qx*qx+qy*qy;
    double det=b*b-4*a*c;
    if(det<0&&det>-eps)
    {
        det=0;
    }
    if(det<0)
    {
        return 0;
    }
    for(int d=-1;d<=1;d+=2)
    {
        double t2=(-b+d*sqrt(det))/(2.0*a);
        if(t2<=0)
        {
            continue;
        }
        double t=sqrt(t2);
        double vx=qx/t;
        double vy=(qy+g*t*t/2.0)/t;
        double yt=getHy(vy,X/vx);
        if(yt<Y-eps)
        {
            continue;
        }
        int flag=1;
        for(int i=1;i<=N;i++)
        {
            if(L[i]>=X)
            {
                continue;
            }
            if(R[i]==X&&Y<=T[i]&&B[i]<=yt)
            {
                flag=0;
            }
            int yl=cmp(B[i],T[i],getHy(vy,L[i]/vx));
            int yr=cmp(B[i],T[i],getHy(vy,R[i]/vx));
            int xh=cmp(L[i],R[i],vx*vy/g);
            int yh=cmp(B[i],T[i],getHy(vy,vy/g));
            if(xh==0&&yh>=0&&yl<0)
            {
                flag=0;
            }
            if(yl*yr<=0)
            {
                flag=0;
            }
        }
        if(flag)
        {
            return 1;
        }
    }
    return 0;
}
int main()
{
    scanf("%lf%lf%lf%lf",&N,&V,&X,&Y);
    for(int i=1;i<=N;i++)
    {
        scanf("%lf%lf%lf%lf",&L[i],&B[i],&R[i],&T[i]);
        R[i]=min(R[i],X);
    }
    int flag1=check(X,Y);
    for(int i=1;i<=N;i++)
    {
        int flag2;
        flag2=check(L[i],T[i]);
        if(flag2==1)
        {
            flag1=1;
        }
        flag2=check(R[i],T[i]);
        if(flag2==1)
        {
            flag1=1;
        }
    }
    if(flag1==1)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 3236
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String[] strbfr = br.readLine().split(" ");
			int m = Integer.parseInt(strbfr[0]);
			int f = Integer.parseInt(strbfr[1]);
			int r = Integer.parseInt(strbfr[2]);
			if (m < 0 & f < 0 & r < 0) { break; }

			int sum = m + f;
			String score = null;
			if (m < 0 | f < 0) {
				score = "F";
			} else {
				if (sum >= 80) {
					score = "A";
				} else if (sum >= 65 & sum < 80) {
					score = "B";
				} else if (sum >= 50 & sum < 65) {
					score = "C";
				} else if (sum >= 30 & sum < 50) {
					if (r >= 50) {
						score = "C";
					} else {
						score = "D";
					}
				} else {
					score = "F";
				}
			}
			System.out.println(score);
		}
	}
}

Measured memory_bytes: 24444
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <sstream>

using namespace std;
typedef typedef long long ll;

ll gcd(ll a, ll b);

int main(int argc, const char * argv[]) {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll CD = (C * D) / gcd(C, D);

    ll div_c_count = (B / C);
    div_c_count -= (A % C == 0) ? (A / C) - 1 : (A / C);
    div_c_count = (div_c_count < 0) ? 0 : div_c_count;
    
    ll div_d_count = (B / D);
    div_d_count -= (A % D == 0) ? (A / D) - 1 : (A / D);
    div_d_count = (div_d_count < 0) ? 0 : div_d_count;
    
    ll div_cd_count = (B / CD);
    div_cd_count -= (A % CD == 0) ? (A / CD) - 1 : (A / CD);
    div_cd_count = (div_cd_count < 0) ? 0 : div_cd_count;
    
    cout << (B - A + 1) - (div_c_count + div_d_count - div_cd_count) << endl;
    
    return 0;
}

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }
    if (b == 0) {
        return a;
    }
    int r = a % b;
    return gcd(b, r);
}



Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
	int n,k,r,s,p;
	cin>>n>>k>>r>>s>>p;
	string t,tt;
	cin>>t;
	ll ans=0;
	tt=t;
	rep(i,n){
		if(t[i]=='r'){
			if(i-k<0) tt[i]='p';
			else if(tt[i-k]!='p') tt[i]='p';
			else if(i+k>=n) tt[i]='r';
			else if(t[i+k]=='s') tt[i]='s';
			else if(t[i+k]=='p') tt[i]='r';
			else tt[i]='r';
		}
		else if(t[i]=='s'){
			if(i-k<0) tt[i]='r';
			else if(tt[i-k]!='r') tt[i]='r';
			else if(i+k>=n) tt[i]='s';
			else if(t[i+k]=='p') tt[i]='p';
			else if(t[i+k]=='r') tt[i]='s';
			else tt[i]='s';
		}
		else if(t[i]=='p'){
			if(i-k<0) tt[i]='s';
			else if(tt[i-k]!='s') tt[i]='s';
			else if(i+k>=n) tt[i]='p';
			else if(t[i+k]=='s') tt[i]='p';
			else if(t[i+k]=='r') tt[i]='r';
			else tt[i]='p';
		}
	}
	rep(i,n){
		if(tt[i]=='r' && t[i]=='s') ans+=r;
		else if(tt[i]=='s' && t[i]=='p') ans+=s;
		else if(tt[i]=='p' && t[i]=='r') ans+=p;
	}
	//rep(i,n) cout<<tt[i];
	//cout<<endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    String in = cin.next();
    char[] temp = in.toCharArray();
    int count = 0;

    for (char a : temp) {

      if (a == '0') count++;

    }

    int res = in.length() - count >= count ? count * 2 : (in.length() - count) * 2;

    System.out.println(res);


  }

}


Measured memory_bytes: 27220
function Main(input) {
	input = input.split("\n");
	var stair_num = parseInt(input[0]);
	var stair_arr = input[1].split(" ").map( v => parseInt(v,10) ); 
	var lawest = 0;
  	for(var i=0; i<stair_num; i++){
      	if( stair_arr[i] < lawest ){ console.log("No"); return; }
      	if( stair_arr[i] > lawest ){
        	lawest = stair_arr[i]-1;
        }
    }
  
  	console.log("Yes");
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17804
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}
import scala.annotation.tailrec

object Main extends App {
  val Array(n, q) = in.readLine.split(" ").map(_.toInt)
  val s = in.readLine
  val op = Iterator.continually(in.readLine)
    .take(q)
    .map(_.split(' ').map(_.head))
    .toArray

  def evalute(pos:Int):Int = {
    def rec(pos:Int, cnt:Int):Int = {
      if(pos < 0 || n <= pos || cnt == q) pos match{
        case p if p < 0 => 0
        case p if 0 <= p && p < n => 1
        case p if n <= p => 2
      }
      else if(s(pos) == op(cnt)(0)) {
        if(op(cnt)(1) == 'L') rec(pos-1, cnt+1)
        else rec(pos+1, cnt+1)
      }
      else rec(pos, cnt+1)
    }
    rec(pos,0)
  }
  
  def binarySearch(x:Int):Int = {
    var left = 0
    var right = n

    @tailrec
    def loop(left:Int, right:Int):Int = {
      if(right - left < 2) left
      else {
        val mid = (left + right) / 2
        if(evalute(mid) <= x) loop(mid,right)
        else loop(left, mid)
      }
    }
    loop(left, right)
  }

  val l = binarySearch(0)
  val r = binarySearch(1)
  debug(l,r)
  val ans = r - l
  println(ans)

  def debug(any:Any*):Unit = {
    if(this.getClass.toString != "class Main$")
      println(any.mkString(" "))
  }
}

Measured memory_bytes: 61984
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define REP(i, n) for(int i=0; i<n; i++)


int main(){
    int N;
    cin >> N;
    vector<ll> a(N);

    ll inp;
    cin >> inp;
    a[0] = inp;
    for(int i=1; i < N; i++){
        cin >> inp;
        a[i] = a[i-1] + inp;
    }

    ll res;
    ll min = LLONG_MAX;
    REP(i,N-1){
        ll me = a[i];
        ll bear = a[N-1] - a[i];
        res = abs(me - bear);
        if(res < min)
            min = res;
    }
    cout << min << endl;
    return 0;
}


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

#define M  1000003/* your task*/
#define L 12

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

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

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

int h1(int key){ return key % M; }
int h2(int key){ return (key % (M-1)) +1; }

int find(char str[]){
  int key,i,j;

  key = getKey(str);
  for(i=0;i<M;i++){
    j = (h1(key) +i * h2(key)) % M;
    if(H[j][0] == '\0') return 0;
    else if(strcmp(H[j],str) == 0){
      return 1;
      break;
    }
  }
}

int insert(char str[]){
  int key,i,j;

  key = getKey(str);
  for(i=0;i<M;i++){
    j = (h1(key) +i * h2(key)) % M;
    if(H[j][0] == '\0'){
      strcpy(H[j],str);
      break;
    }
  }
  return 0;
}

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



Measured memory_bytes: 13460
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll a;
    double b;
    cin >> a >> b;
    ll B = b*100 + 0.001;
    cout << a*B/100 << endl;

return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
const int MAXN = 1005;
const int MAXV = MAXN*(MAXN-1)/2;
vector<int> E[MAXV];
int id[MAXN][MAXN];
 
bool reached[MAXV];
bool finished[MAXV];
int dp[MAXV]; // max length of path from v
int dfs(int pos) {
	if (reached[pos]) {
		if (!finished[pos])return -1;
		return dp[pos];
	}
	dp[pos] = 0;
	reached[pos] = true;
	for (int i = 0; i < E[pos].size(); i++) {
		//cout <<"pos == " << pos <<  "to " << E[pos][i] << endl;
		int res = dfs(E[pos][i]);
		if (res == -1)return -1;
		dp[pos] = max(dp[pos], res + 1);
	}
	finished[pos] = true;
	return dp[pos];
}
 
int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n-1));
  
  int V = 0;
  rep(i,n)rep(j,n) {
    if (i < j) {
      id[i][j] = V++;
    }else if(i > j){
      id[i][j] = id[j][i];
    }
  }
  rep(i,n) {
    rep(j,n-1) {
      cin >> a[i][j];
      a[i][j]--;
      a[i][j] = id[i][a[i][j]];
    }
  }
  
  rep(i,n) {
    
    rep(j,n-2) {
      E[a[i][j]].push_back(a[i][j + 1]);
    }
  }
  int ans = 0;
  rep(i,n) {
    rep(j,n){
      int res = dfs(a[i][j]);
      if (res == -1) {
        puts("-1");
        return 0;
      }
      ans = max(ans, res);
    }
  }
  cout << ans + 1 << endl;
  return 0;
}

Measured memory_bytes: 38528
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll n; cin>>n;
    vector<ll>ans(n);
    for(int x=1;x<=sqrt(n)+1;x++){
        for(int y=1;y<=sqrt(n)+1;y++){
            for(int z=1;z<=sqrt(n)+1;z++){
                ll a=x*x+y*y+z*z+x*y+y*z+z*x;
                if(a<=n){
                    ans[a-1]++;
                }
            }
        }
    }
    rep(i,n){
        cout<<ans[i]<<endl;
    }
}





























































































Measured memory_bytes: 3600
N=int(input())
A,B,C=[list(map(int,input().split())) for i in range(3)]
satisfaction=0
for i in range(N):
    satisfaction+=B[A[i]-1]
    if i!=0 and A[i]==A[i-1]+1:
        satisfaction+=C[A[i-1]-1]
print(satisfaction)

Measured memory_bytes: 3060
S = input()
S1, S2 = S[0:2], S[2:4]

months = [str(i).zfill(2) for i in range(1, 13)] 
years = [str(i).zfill(2) for i in range(0, 100)]

yymm = False
mmyy = False
if S1 in months and S2 in years:
    mmyy = True
if S1 in years and S2 in months:
    yymm = True
if mmyy and not yymm:
    print("MMYY")
elif not mmyy and yymm:
    print("YYMM")
elif mmyy and yymm:
    print("AMBIGUOUS")
else:
    print("NA")


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    int n,k;cin>>n>>k;
    V l(n);rep(i,n)cin>>l[i];
    sort(RALL(l));
    int ans=0;
    rep(i,k)ans+=l[i];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map> //I'm sorry to use map
#include<algorithm>
using namespace std;

struct Puz{
  int board[3][3];
  int zx, zy; //coodinate of zero
  int cnt;

  bool operator < (const Puz &p)const{
    for(int i = 0;i < 3;i++){
      for(int j = 0;j < 3;j++){
        if(board[i][j] == p.board[i][j]) continue;
        return board[i][j] > p.board[i][j];
      }
    }
    return false;
  }

  bool operator == (const Puz &p)const{
    for(int i = 0;i < 3;i++){
      for(int j = 0;j < 3;j++){
        if(board[i][j] != p.board[i][j]) return false;
      }
    }
    return true;
  }
};



int d[5] = {0, -1, 0, 1, 0}; //direction
Puz g = {{{1, 2, 3}, {4, 5, 6}, {7, 8, 0}}}; //goal
map<Puz, int> mem; //memory

//queue
int head, tail;
Puz Q[30000];

void enqueue(Puz x){

  Q[tail] = x;

  if(tail + 1 == 30000) tail = 0;
  else tail++;
}

Puz dequeue(){

  Puz x = Q[head];

  if(head + 1 == 30000) head = 0;
  else head++;

  return x;
}

//solve
int bfs(Puz s){

  enqueue(s);
  mem[s] = 1;

  while(head != tail){
    Puz p = dequeue(), q;

    if(p == g) return p.cnt;

    for(int i = 0;i < 4;i++){
      int x = p.zx + d[i], y = p.zy + d[i + 1];

      if(0 <= x && x < 3 && 0 <= y && y < 3){
        q = p;
        swap(q.board[q.zy][q.zx], q.board[y][x]);
        q.zy = y;
        q.zx = x;
        q.cnt++;
        if(!mem[q]++) enqueue(q); //memorizing
      }
    }
  }

  return 0;
}

int main(){

  Puz s;

  //input
  for(int i = 0;i < 3;i++){
    for(int j = 0;j < 3;j++){
      cin >> s.board[i][j];
      if(s.board[i][j] == 0){
        s.zy = i;
        s.zx = j;
      }
    }
  }
  s.cnt = 0;

  //output
  cout << bfs(s) << endl;

  return 0;
}


Measured memory_bytes: 21516
N = int(input())
L = sorted([sorted(list(input())) for i in range(N)])

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

ans = 0
n_same_str = 1
for i in range(N-1):
    if L[i] == L[i+1]:
        n_same_str += 1
    else:
        if n_same_str >= 2:
            ans += comb(n_same_str, 2)
        n_same_str = 1

if n_same_str >= 2:
            ans += comb(n_same_str, 2)

print(ans)

Measured memory_bytes: 103128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll arr[100001];

int main()
{

	ll n;
	cin>>n;
	
	for(ll i=0;i<n;i++)
	{
	    cin>>arr[i];
	}
	
	ll dp[n]={0};
	
	dp[1]=abs(arr[1]-arr[0]);
	
	for(ll i=2;i<n;i++)
	{
	    dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]) , dp[i-1] +abs(arr[i]-arr[i-1]));
	}
	
	cout<<dp[n-1]<<"\n";
	
}


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

void maxHeapify(int A[],int i,int n){
    int largest,temp;
    int left_child = 2*i;
    int right_child = 2*i + 1;
    if(left_child <= n && A[left_child] > A[i]) largest = left_child;
    else largest = i;
    if(right_child <= n && A[largest] < A[right_child]) largest = right_child;

    if(largest != i){
        temp = A[i];
        A[i] = A[largest];
        A[largest] = temp;
        maxHeapify(A,largest,n);
    }
}

int main(){
    int n;
    cin >> n;
    int A[n+1];
    for(int i = 1; i <= n; i++) cin >> A[i];
    
    for(int i = n/2; 0 < i; i--){
        maxHeapify(A,i,n);
    }

    for(int i = 1; i <= n; i++){
        cout << " " << A[i];
    }
    cout << endl;
}


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

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

    int N;

    cin >> N;

    cout << N * N * N;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll MOD=1000000007;
const ll E=1e18;

const ll MX=40;

ll dp[MX][MX][4];
ll A[MX][MX];

vector<ll> dx={-1,0,1,0};
vector<ll> dy={0,1,0,-1};


int main(){
  ll h,w;
  while(cin>>w>>h){
    if(h==0){break;}
  for(int i=0;i<h;i++){
    for(int t=0;t<w;t++){
      for(int j=0;j<4;j++){dp[i][t][j]=-E;}
      cin>>A[i][t];
    }
  }
  vector<ll> cost(4);
  for(auto &I:cost){cin>>I;}
  priority_queue<pair<pll,pll>> Q;//cost,muki,h,w
  dp[0][0][1]=0;
  Q.push({{0,1},{0,0}});
  while(!Q.empty()){
    auto I=Q.top(); Q.pop();
    ll x=I.S.F,y=I.S.S,k=I.F.S;
    if(dp[x][y][k]!=I.F.F){continue;}
    //cout<<x<<" "<<y<<" "<<k<<" "<<-1LL*I.F.F<<endl;
    for(int i=0;i<4;i++){
      ll d=(k+i)%4;
      ll X=x+dx[d];
      ll Y=y+dy[d];
      if(X<0 || Y<0 || X>=h || Y>=w){continue;}
      ll n=I.F.F;
      if(i!=A[x][y]){n-=cost[i];}
      if(dp[X][Y][d]<n){dp[X][Y][d]=n; Q.push({{n,d},{X,Y}});}
    }
  }
  
  ll ans=E;
  for(int j=0;j<4;j++){
    ans=min(ans,-1LL*dp[h-1][w-1][j]);
  }
  cout<<ans<<endl;
  }

  return 0;
}



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

public class Main {

	public static void main(String[] args) throws Exception{
		// TODO ?????????????????????????????????????????????
		String str[], ans;
		int W, H, x, y, r;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        str = br.readLine().split(" ");
        W = Integer.parseInt(str[0]);
        H = Integer.parseInt(str[1]);
        x = Integer.parseInt(str[2]);
        y = Integer.parseInt(str[3]);
        r = Integer.parseInt(str[4]);

        if(r <= x && x + r <= W && r <= y && y + r <= H){
        	ans = "Yes";
        }else{
        	ans = "No";
        }
        System.out.println(ans);

	}

}

Measured memory_bytes: 24448
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] a = new int[n];
		int min = Integer.MAX_VALUE;
		for(int i=0;i<n;i++){
			a[i] = stdIn.nextInt();
			if(min>a[i]) min = a[i];
		}
		for(int i=1;i<=min;i++){
			boolean flag = true;
			for(int j=0;j<n;j++){
				if(a[j]%i!=0){
					flag = false;
					break;
				}
			}
			if(flag) System.out.println(i);
		}
	}
}

Measured memory_bytes: 18900
N, W = map(int, input().split())
value = []
weight = []
for _ in range(N):
    v, w = map(int, input().split())
    value.append(v)
    weight.append(w)

inf = float("inf")
dp = [[ -inf for _ in range(W+1)] for _ in range(N+1)]
for i in range(W+1):
    dp[0][i] =0

for i in range(N):
    for w in range(W+1):
        if w>=weight[i]:
            dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]
#print(dp)
print(dp[N][W])



Measured memory_bytes: 42480
def merge_jibun(A, left, mid, right):
    global count
    # inf = 10 ** 9
    L = A[left:mid] + [10 ** 9]
    R = A[mid:right] + [10 ** 9]
    # L.append(1000000)
    # R.append(1000000)

    i = 0
    j = 0
    
    
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def merge_hoka(A, left, mid, right):
    global count
    inf = 10 ** 9
    L = A[left:mid] + [inf]
    R = A[mid:right] + [inf]
 
    i = 0
    j = 0
    for k in range(left, right):
        count += 1
        # print(L)
        # print(R)
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge_jibun(A, left, mid, right)
        # merge_hoka(A, left, mid, right)

n = int(input())
A = list(map(int, input().split()))
count = 0
mergeSort(A, 0, n)

print(' '.join(list(map(str, A))))
print(count)


Measured memory_bytes: 66684
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;

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

    if (m == 0)
    {
        cout << 0 << " " << 0 << endl;
        return 0;
    }

    vector<int> p(m);
    vector<bool> s(m);
    vector<bool> ac(n);
    vector<int> v_wa(n);

    long long int res_ac = 0;
    long long int res_wa = 0;

    for (int i = 0; i < n; ++i)
    {
        ac[i] = false;
        v_wa[i] = 0;
    }
    for (int i = 0; i < m; ++i)
    {
        string str;
        cin >> p[i];
        cin >> str;

        p[i]--;
        if (str == "AC")
        {
            s[i] = true;
        }
        else
        {
            s[i] = false;
        }
    }
    for (int i = 0; i < m; ++i)
    {
        //AC
        if (s[i])
        {
            if (!ac[p[i]])
            {
                ac[p[i]] = true;
                res_ac++;
                res_wa += v_wa[p[i]];
            }
        }
        //WA
        else
        {
            if (!ac[p[i]])
            {
                v_wa[p[i]]++;
            }
        }
    }

    cout << res_ac << " " << res_wa << endl;
}


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

int main(){
    int x;
    cin>>x;
    if(x==0)cout<<1<<endl;
    else cout<<0<<endl;

}


Measured memory_bytes: 3588
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int ap[101];
int main(){
	fastio;
	int x,n;
	cin>>x>>n;
	rb(i,1,n){
		int ai;
		cin>>ai;
		ap[ai]=1;
	}
	int l=x,r=x;
	while(1){
		if(!ap[l]){
			cout<<l<<endl;
			return 0;
		}
		if(!ap[r]){
			cout<<r<<endl;
			return 0;
		}
		l--;
		r++;
	}
	return 0;
}


Measured memory_bytes: 3624
def is_ll(n):
    cur = n % 10
    while n > 10:
        n //= 10
        if abs(n % 10 - cur) > 1:
            return False
        cur = n % 10
    return True

def find_next_ll(n):
    o = n
    cur = n % 10
    while n > 10:
        n //= 10
        if -1 < n % 10 - cur < 2 and cur != 9:
            n *= 10
            n += cur
            break
        cur = n % 10
    n += 1
    while n < o:
        cur = n % 10
        n *= 10
        n += max(0, cur - 1)
    return n

K = int(input())

ll = 1
for i in range(1, K):
    n = ll + 1
    if not is_ll(n):
        ll = find_next_ll(ll)
    else:
        ll = n
print(ll)


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

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();

		StringTokenizer st = new StringTokenizer(str," ");

		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());

		if (a < b && b < c) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

using namespace std;

const int N = 2e6+7;
const int MOD = 1e9+7;
const double eps = 1e-11;
typedef pair<int, int> pii;

long long A[N], inv[N];

inline long long qpow(long long a, int p)
{
    long long res = 1;
    while (p) {
        if (p&1) res = res*a%MOD;
        a = a*a%MOD;
        p >>= 1;
    }
    return res;
}

inline long long inverse(const long long &a)
{
    return qpow(a, MOD-2);
}

inline void init()
{
    inv[0] = A[0] = 1;
    for (int i = 1; i < N; ++i) {
        A[i] = A[i-1]*i%MOD;
        inv[i] = inverse(A[i]);
    }
}

inline long long C(const int &p, const int &q)
{
    return A[p]*inv[q]%MOD*inv[p-q]%MOD;
}

inline long long calc(const int &x, const int &y)
{
    if (x < 0 || y < 0) return 0;
    long long res = 0;
    for (int i = 0; i <= x; ++i)
        (res += C(i+y+1, i+1)) %= MOD;
    return res;
}

inline void solve()
{
    int r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    init();
    long long res = calc(r2, c2)-calc(r2, c1-1)-calc(r1-1, c2)+calc(r1-1, c1-1);
    res = (res%MOD+MOD)%MOD;
    cout << res << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 31488
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
t=list(input().rstrip())
s=[]
for i in range(n+1):
    s.append(int(t[n-i]))
ans=[]
now=0
while now<n:
    for i in range(m,0,-1):
        if now+i<=n:
            if s[now+i]==0:
                ans.append(i)
                now=now+i
                break
    else:
        print(-1)
        sys.exit()
ans.reverse()
for i in ans:
    print(i,end='')
    print(' ',end='')







Measured memory_bytes: 68088