akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        boolean[] a = new boolean[N];
        for (int i = 0; i < N; i++) {
            a[i] = in.i() == 1;
        }

        boolean[] b = new boolean[N];
        for (int i = N; i > 0; i--) {
            boolean c = a[i - 1];
            for (int j = 2 * i - 1; j < N; j += i) {
                c ^= b[j];
            }
            b[i - 1] = c;
        }

        StringBuilder sb = new StringBuilder();
        int n = 0;
        for (int i = 0; i < N; i++) {
            if (b[i]) {
                sb.append(i + 1).append(' ');
                n++;
            }
        }
        out.println(n);
        out.println(sb);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 38548
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let S = readLine()!.toArray()
var (tile1, tile2) = (0, 0)
for i in 0..<S.count {
    if i % 2 > 0 {
        if S[i] == "0" {
            tile1 += 1
        }
    } else {
        if S[i] == "1" {
            tile1 += 1
        }
    }
}
for i in 0..<S.count {
    if i % 2 > 0 {
        if S[i] == "1" {
            tile2 += 1
        }
    } else {
        if S[i] == "0" {
            tile2 += 1
        }
    }
}
print(min(tile1, tile2))


Measured memory_bytes: 8192
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> init(n);
  for (int i = 0; i < n; i++) cin >> init[i];
  vector<int> state(n);
  for (int i = 0; i < n; i++) cin >> state[i];
  priority_queue<pair<int, int>> pq;
  for (int i = 0; i < n; i++) pq.emplace(state[i], i);
  long long ans = 0;
  while (!pq.empty()) {
    auto last = pq.top(); pq.pop();
    int val = last.first;
    int ind = last.second;
    if (state[ind] != val) continue;
    if (val == init[ind]) continue;
    if (val < init[ind]) { ans = -1; break; }
    int left = state[(ind + (n - 1)) % n];
    int right = state[(ind + 1) % n];
    int add = left + right;
    int rem = val - init[ind];
    if (rem < add) { ans = -1; break; }
    ans += rem / add;
    state[ind] = val - add*(rem / add);
    pq.emplace(state[ind], ind);
  }
  cout << ans << "\n";
  return 0;
}


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

int main() {
 string s;
 cin >> s;
 if (s[2] == s[3] && s[4] == s[5]){
   cout << "Yes" << endl;
 }
 else cout << "No" << endl;
  
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

struct StarrySkyTree {
  vector<ll> seg, sum, lazy, cnt;
  int size,n_;
  StarrySkyTree() {}
  StarrySkyTree(int n) {
    n_=n;
    init(n);
  }
  void init(int n) {
    size = 1;
    while (size < n) size *= 2;
    seg.resize(size * 2);
    lazy.resize(size * 2);
    sum.resize(size * 2);
    cnt.resize(size * 2);
    for(int i = 0; i < size*2; i++){
      seg[i]=0;
      sum[i]=0;
      cnt[i]=0;
    }
  }
  void update(int k,ll v){
    k += size-1;
    sum[k] = v;
    while(k > 0){
      k = (k - 1)/2;
      sum[k] = sum[k * 2 + 1] + sum[k * 2 + 2];
    }
  }
  void update2(int k,ll v){
    k += size-1;
    cnt[k] = v;
    while(k > 0){
      k = (k - 1)/2;
      cnt[k] = cnt[k * 2 + 1] + cnt[k * 2 + 2];
    }
  }
  void push(int k, int l, int r) {
    seg[k] += lazy[k];
    if(lazy[k]%2==1){
      int num=cnt[k];
      sum[k]=num-sum[k];
    }
    if (r - l > 1) {
      lazy[k * 2 + 1] += lazy[k];
      lazy[k * 2 + 2] += lazy[k];
    }
    lazy[k] = 0;
  }
  void add(int a, int b, ll v, int k, int l, int r) {
    push(k, l, r);
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      lazy[k] += v;
      push(k, l, r);
    } else {
      add(a, b, v, k * 2 + 1, l, (l + r) / 2);
      add(a, b, v, k * 2 + 2, (l + r) / 2, r);
      sum[k] = sum[k * 2 + 1]+sum[k * 2 + 2];
    }
  }
  void add(int a, int b, ll v) {
    add(a, b, v, 0, 0, size);
  }
  ll query(int a, int b, int k, int l, int r) {
    push(k, l, r);
    if (r <= a || b <= l) return 0; // caution
    if (a <= l && r <= b) return sum[k];
    ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return vl+vr;
  }
  ll query(int a, int b) {
    return query(a, b, 0, 0, size);
  }
};

int n,q;
vector<int> g[101011];
vector<int> a;
int idx[2][100001];

int cnt=0;

void dfs(ll v,ll pre){
  a.push_back(v);
  idx[0][v]=cnt++;
  for(ll nv : g[v]){
    if(nv==pre)continue;
    dfs(nv,v);
  }
  a.push_back(v);
  idx[1][v]=cnt++;
}

int main(){
  cin>>n>>q;
  rep(i,n-1){
    int a;
    cin>>a;
    a--;
    g[i+1].push_back(a);
    g[a].push_back(i+1);
  }
  dfs(0,-1);

  StarrySkyTree sgt;
  sgt.init(n*2);

  rep(i,n){
    char c;
    cin>>c;
    if(c=='G'){
      sgt.update(idx[0][i],1);
    }
    sgt.update2(idx[0][i],1);
  }

  while(q--){
    ll v;
    cin>>v;
    v--;
    sgt.add(idx[0][v],idx[1][v]+1,1);
    if(sgt.query(0,2*n)>=(n+1)/2)cout<<"broccoli"<<endl;
    else cout<<"cauliflower"<<endl;
  }

  return 0;
}



Measured memory_bytes: 32816
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

s = input()
d = {"SUN": 7, "MON": 6, "TUE": 5,"WED": 4, "THU": 3,"FRI":2,"SAT":1}
print(d[s])

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

int main()
{
    long long n, k;
    cin >> n >> k;
    if (n%k==0) cout << 0;
    else if (n>k)
    {
        if (n-(n/k)*k<=(-n+(n/k+1)*k)) cout << n-(n/k)*k;
        else cout << (-n+(n/k+1)*k);
    }
    else if (n<k)
    {
        if (n<=k-n)  cout << n;
        else cout << k-n;
    }


}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define ABS(x) ((x) > 0 ? (x) : -(x))

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	int ct = 0, cx = 0, cy = 0;
	for (int i = 0; i < N; i++) {
		int t, x, y;
		cin >> t >> x >> y;

		int d = ABS(cx - x) + ABS(cy - y);
		if ((t - d) < 0 || (t - d) % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()

people = []
prev = s[0]
neg = False
if prev == "0":
	neg = True

count = 1

for i in range(1, len(s)):
	if prev != s[i]:
		people.append(count)
		count = 0
		prev = s[i]
	count += 1
people.append(count)


if len(people)/2 <= k:
	print(n)
	quit()


max_people, start, prep = 0, 0, 0
if neg == False:
	max_people = sum(people[:(k*2)+1])
	start = 2
	prep = max_people - people[0] - people[1]
else:
	max_people = sum(people[:k*2])
	start = 1
	prep = max_people - people[0]

scan = (k*2)+1
i = 0
for i in range(start, len(people)-(k*2)+1, 2):
	try:
		cur_sum = prep + people[i+scan-1] + people[i+scan-2]
	except IndexError:
		cur_sum = prep + people[-1]
	max_people = max(max_people, cur_sum)
	prep = cur_sum - people[i] - people[i+1]

print(max_people)



Measured memory_bytes: 4596
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n,m,h[100005];
    bool isgood[100005];//false:not good, true:good
    rep(i,100005)isgood[i]=true;
    cin>>n>>m;
    rep(i,n)cin>>h[i];
    rep(i,m){
        int a,b;
        cin>>a>>b;
        --a;--b;
        if(h[a]<h[b])isgood[a]=false;
        else if(h[a]>h[b])isgood[b]=false;
        else isgood[a]=isgood[b]=false;
    }
    int ans=0;
    rep(i,n){
        if(isgood[i])ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4120
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

struct UnionFind {//ユニオンファインド
  vector<int> d;
  UnionFind(int n=0): d(n, -1) {}
  int find(int x){
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y){
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] +=d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y){ return find(x) == find(y);}
  int size(int x){ return -d[find(x)];}
};

int main(){
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a,b);
  }

  int ans = 0;
  rep(i,n) ans = max(ans, uf.size(i));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4012
from bisect import bisect_left
a,b,q=map(int,input().split())
s=[]
t=[]
x=[]
s.append(-10**12)
t.append(-10**12)
for i in range(a):
    s.append(int(input()))
for i in range(b):
    t.append(int(input()))
s.append(10**12)
t.append(10**12)
for i in range(q):
    x=int(input())
    tmp_s=bisect_left(s,x)-1
    tmp_s_1=s[tmp_s]
    tmp_s_2=s[tmp_s+1]
    tmp_t=bisect_left(t,x)-1
    tmp_t_1=t[tmp_t]
    tmp_t_2=t[tmp_t+1]
    print(min(abs(x-tmp_s_1)+abs(tmp_s_1-tmp_t_1),
    abs(x-tmp_s_1)+abs(tmp_s_1-tmp_t_2),
    abs(x-tmp_s_2)+abs(tmp_s_2-tmp_t_1),
    abs(x-tmp_s_2)+abs(tmp_s_2-tmp_t_2),
    abs(x-tmp_t_1)+abs(tmp_t_1-tmp_s_1),
    abs(x-tmp_t_1)+abs(tmp_t_1-tmp_s_2),
    abs(x-tmp_t_2)+abs(tmp_t_2-tmp_s_1),
    abs(x-tmp_t_2)+abs(tmp_t_2-tmp_s_2)))

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

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

    double n, m, d;
    cin >> n >> m >> d;

    if (d < 0.5)
        cout << setprecision(9) << (n - d) * (m - 1) / n / n << endl;
    else
        cout << setprecision(9) << 2 * (n - d) * (m - 1) / n / n << endl;

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()

total_AB, total_B = 0, 0
for c in S:
    if c=='a':
        if total_AB < A+B:
            print('Yes')
            total_AB += 1
        else:
            print('No')
    elif c=='b':
        if total_AB < A+B and total_B < B:
            print('Yes')
            total_AB += 1
            total_B += 1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4016
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<string.h>
#include<cstring>
#include<set>
#include<queue>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<map>
#include<stack>
#include<list>
#define pii pair<int, int>
#define pll pair<LL, LL>
#define pil pair<int, LL>
#define pli pair<LL, int>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MINF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const LL LLINF = 1e18;
const int INF = 1e9;
const int MOD = 20101009;
const int HMOD = 999959;
const int VMOD = 5000000;
const int MAXN = 3e5+10;
const int MAXM = 5e5+10;
const int INV = 10050505;
const LL LLINV = 1e18;
const double eps = 1e-3;
int dirx[5] = {0, -1, 1, 0, 0}, diry[5] = {0, 0, 0, -1, 1};


int main()
{
IOS;
    int x;
    scanf("%d", &x);
    printf("%d\n", ((x*360)/__gcd(x, 360))/x);
    

    return 0;
}



Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,n,s) for(int i=(int)(s);i<(int)(n);++i)
#define RREP(i,n,s) for(int i=(int)(s);i>=(int)(n);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int dir[] = {1,0,-1,0,1};
int main() {
    int n;cin>>n;

    vector<int> prime;
    bool p[300000];
    fill(p, p+300000, true);
    p[0] = false;
    p[1] = false;
    REP2(i,300000,2) {
        if(p[i]) prime.push_back(i);

        int tmp = i*2;
        while(tmp < 300000) {
            p[tmp] = false;
            tmp += i;
        }
    }

    vector<int> p2(prime.begin(), prime.end());
    FOR(i,p2) {
        *i = *i%5;
    }

    int cnt = 0;
    REP(i,p2.size()) {
        if(p2[i] == 1) {
            cout << prime[i] << " ";
            cnt++;
            if(cnt == n) break;
        }
    }

    cout << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std; 
typedef pair<long long int,long long int> pa;
#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())
#define pb push_back
#define  MAX 1000001
long long int MOD=1e9+7;
long long int INF=1e18;
//LUCKY_PIN - atcoder
int main()
{
         ios_base::sync_with_stdio(false); 
         cin.tie(NULL);
         cout.tie(NULL);
         long long int i,j,k=0,l=0,r=0,m=0,n,c,p=0,cnt=0,cnt1=0,x,y,z=0,a,b,low,mid,high,ans=0,maxi=0,mini=INF,t1,x1,y1;
    string s;
   cin>>n;
    cin>>s;
    cnt=0;
    for(i=0;i<=9;i++)
    {
        for(j=0;j<=9;j++)
        {
            for(k=0;k<=9;k++)
            {
                l=0;
                for(m=0;m<n;m++)
                {
                    r=s[m]-int('0');
                if(l==0)
                {
                    if(r==i)
                        l++;
                }
                else if(l==1)
                {
                    if(r==j)
                        l++;
                }
                    else if(l==2)
                    {
                        if(r==k)
                        { l++;
                         cnt++;
                         break;
                        }
                    }
                   
                    
                }
                
            }
        }
    }
    
    cout<<cnt<<endl;
}
    

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans=0,x=0;
  for(int i=0;i<n;i++){
    if(s[i]=='I'){
      x++;
    }else{
      x--;
    }
    ans=max(ans,x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  vector<vector<int>> G(N);
  rep(i, M) {
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
    G[A[i]].pb(B[i]);
    G[B[i]].pb(A[i]);
  }

  typedef pair<int, int> P;  // now, prev
  queue<P> q;

  vector<int> par(N, -1);
  q.push(P(-2, 0));

  while (!q.empty()) {
    auto p = q.front();
    q.pop();

    int now = p.se, prev = p.fi;

    for (int next : G[now]) {
      if (par[next] != -1)
        continue;
      par[next] = now;
      q.push(P(now, next));
    }
  }

  vector<int> ans(N - 1);

  repp(i, 1, N - 1) {
    if (par[i] == -1) {
      cout << "No\n";
      return 0;
    }
    ans[i - 1] = par[i] + 1;
  }

  cout << "Yes\n";
  rep(i, len(ans)) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 16864
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

void getPrime(ll n, vector<ll>& list)
{
	vector<bool> isPrime(n + 1, true);

	for (auto i = 2ll; i <= n; ++i)
	{
		if (isPrime[i])
		{
			list.push_back(i);
			for (auto j = 2ll; i * j <= n; ++j)
			{
				isPrime[i * j] = false;
			}
		}
	}
}

int main()
{
	ll X;
	cin >> X;

	auto m = (ll)1e5 +10;
	vector<ll> list;
	getPrime(m, list);

	auto result = X;
	for (auto i = 0; i < (int)list.size(); ++i)
	{
		if (list[i] >= X)
		{
			result = list[i];
			break;
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 512
function Main(input) {
  input = input.split(' ').map(num => parseInt(num, 10));
  A = input[0];
  B = input[1];
  C = input[2];
  (A + B) >= C ? console.log('Yes') : console.log('No');
}

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

Measured memory_bytes: 7372
#include <cstdio>
using namespace std;

int main()
{
    char a[105];
    char ch;
    int n,l,r;
    while(~scanf("%d",&n))
    {

        scanf("%s",a);
        l=0;  //要加几个左括弧
        r=0;
        for(int i=0;a[i]!='\0';i++)
        {
            //scanf("%c",&ch);
            ch=a[i];
            if(ch=='(')
            {
                r++;
            }
            if(ch==')')
            {
                if(r)
                {
                    r--;
                }
                else
                {
                    l++;
                }
            }
        }
        for(int i=0;i<l;i++)
        {
            printf("(");
        }
        printf("%s",a);
        for(int i=0;i<r;i++)
        {
            printf(")");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

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

        int N = sc.nextInt();
        int[] A = new int[N];
        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            list.add(A[i]);
        }
        Collections.sort(list);

        int x;
        if(N%2==0){
            x = 1;
        }
        else{
            if(list.get(0)!=0){
                System.out.println(0);
                return;
            }
            if(N==1 && list.get(0)==0){
                System.out.println(1);
            }
            x = 2;
        }
        long ans = 1;
        for(int i=x; i<N; i=i+2){
            if(list.get(i)!=i || list.get(i-1)!=i){
                System.out.println(0);
                break;
            }
            if(i==N-1){
                for(int j=0; j<N/2; j++){
                    ans = ans * 2 % 1000000007;
                }
                System.out.println(ans);
            }
        }
    }
}

Measured memory_bytes: 64356
#C-Poll
import collections
n=int(input())
words = [input() for _ in range(n)]
count = collections.Counter(words)
leng = len(count)
ansallay = []
#抽出用に何回出てればansに出すかを変数に突っ込む
record = count.most_common()[0][1]
ms=count.most_common()
for num in range(leng):
    if(ms[num][1] == record):
        ansallay.append(ms[num][0])
    else:
        break
ansallay.sort()
for word in ansallay:
    print(word)



Measured memory_bytes: 47636
<?php
$n = intval(fgets(STDIN));

$primes = era(55555);
foreach($primes as $p){
  if($p % 5 == 1)$primeFive[] = $p;
}
echo implode(" ", array_splice($primeFive, 0, $n));

function era($n){
    $map = array_fill(2,$n-1, true);
    $rootn = sqrt($n);
    for($i = 2; $i <= $rootn; $i++){
        if(isset($map[$i])){
            for($j = $i*$i; $j <= $n; $j+=$i){
                unset($map[$j]);
            }
        }
    }
    return array_keys($map);
}


Measured memory_bytes: 6648
#include <iostream>
#include <vector>
#include <cstring>
#define SIZE 1000

using namespace std;

int m, n, b[501], r[501];
int match[SIZE];
bool used[SIZE];
vector<int> G[SIZE];

bool dfs(int v){
	used[v]=1;
	for(int i=0; i<G[v].size(); i++){
		int u=G[v][i], w=match[u];
		if(w<0||!used[w]&&dfs(w)){
			match[v]=u, match[u]=v;
			return 1;
		}
	}
	return 0;
}

void solve(){
	int res=0;
	memset(match, -1, sizeof(match));
	for(int v=0; v<m+n; v++){
		if(match[v]<0){
			memset(used, 0, sizeof(used));
			if(dfs(v)) res++;
		}
	}
	cout<<res<<endl;
}

int main(){
	while(1){
		cin >> n >> m;
		if(!n && !m) break;
		for(int i=0; i<n; i++){
			cin >> b[i];
		}
		for(int i=0; i<m; i++){
			cin >> r[i];
		}
		for(int i=0; i<SIZE; i++) G[i].clear();
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				int a = b[i], c = r[j];
				while(c){
					a %= c;
					swap(a, c);
				}
				if(a != 1){
					G[i].push_back(j+n);
					G[n+j].push_back(i);
				}
			}
		}
		solve();
	}
}


Measured memory_bytes: 4856
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int dp[111111];
int h[111111];

main(){
	int n;cin>>n;
	int k;cin>>k;
	rep(i,n)cin>>h[i];
	rep(i,111111)dp[i]=MOD;
	dp[0]=0;
	rep(i,n){
		for(int j=i+1;j<=i+k;j++)chmin(dp[j],dp[i]+abs(h[i]-h[j]));
	}
	dump(dp[n-1]);
}






Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void) {
  ll N, M;
  cin >> N >> M;

  if(N != 1) {
    ll d = (N - 1) % MOD;
    ll n = ((M + 1) / (N - 1) + 1) % MOD;
    ll x1 = ((M + 1) % (N - 1)) % MOD;
    ll xn = (M + 1) % MOD;

    // cout << d << " " << n << " " << x1 << " " << xn << endl;

    ll sum = (((((x1 + xn) % MOD) * n) % MOD) * ((MOD + 1) / 2)) % MOD;

    // cout << sum << endl;

    cout << (xn + (((sum - xn + MOD) % MOD) * 2) % MOD) % MOD << endl;;
  } else {
    cout << (M + 1) % MOD << endl;
  }
}

Measured memory_bytes: 3100
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 999999999;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) { std::cout << x << '\n'; }
template <typename T>
void print(std::vector<T>& v, string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  map<char, bool> m;
  REP(i, s.size()) {
    m[s[i]] = true;
  }
  bool a = !(m['N'] ^ m['S']);
  bool b = !(m['W'] ^ m['E']);

  if (a && b) {
    print("Yes");
  } else {
    print("No");
  }

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	set<int> a;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		a.insert(x);
	}
	if(a.size()==n){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}

}


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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  vector<vector<int> > G(N, vector<int>(N, -1));
  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;
    for (int j = 0; j < num; j++) {
      int a, b;
      cin >> a >> b;
      a--;
      G[i][a] = b;
    }
  }

  int maxv = 0;
  for (int i = 0; i < (1<<N); i++) {
    vector<int> d(N, 0);
    for (int j = 0; j < N; j++) {
      if (i>>j & 1) {
        d[j] = 1;
      }
    }
    bool flg = true;
    for (int j = 0; j < N; j++) {
      if (d[j]) {
        for (int k = 0; k < N; k++) {
          if (G[j][k] == -1) continue;
          if (G[j][k] != d[k]) flg = false;
        }
      }
    }
    if (flg) maxv = max(maxv, __builtin_popcount(i));
  }
  cout << maxv << endl;
  return 0;
}

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

fun main() = abc175a()

@OptIn(ExperimentalStdlibApi::class)
fun abc175a() = SimpleFastIOWithToken_abc175a().exec {
    val s = readString()

    val answer = when {
        s.contains("RRR") -> 3
        s.contains("RR") -> 2
        s.contains("R") -> 1
        else -> 0
    }

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_abc175a(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_abc175a.() -> Unit) {
        var t: Throwable? = null
        Thread(null, { action() }, "solve", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }
            .apply { start() }.join()
        t?.let { throw it }
        kotlin.io.print(sb)
    }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


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


S = input().strip()

odd = S[0::2]
even = S[1::2]

is_easy = True
if 'L' in odd:
    is_easy = False

if 'R' in even:
    is_easy = False

if is_easy:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
import sys
input=sys.stdin.readline
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    p=list(map(int,input().split()))
    d=0
    while True:
        if x-d in p:
            if x+d in p:
                d+=1
            else:
                a=x+d
                break
        else:
            a=x-d
            break
    print(a)

Measured memory_bytes: 61852
using System;

class ABC_131_A
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();

        for (int i = 0; i < 3; i++)
        {
            if (s[i]==s[i+1]) {
                Console.WriteLine("Bad");
                return;
            }

        }

        Console.WriteLine("Good");
    }
}

Measured memory_bytes: 11092
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, q;
    double[] x, y;
    int i, j, countr;
    double x0, y0, ax, ay, bx, by, tmp;

    n = sc.nextInt();
    x = new double[n + 1];
    y = new double[n + 1];

    for(i = 0;i < n;i++){
      x[i] = sc.nextDouble();
      y[i] = sc.nextDouble();
    }
    x[n] = x[0];
    y[n] = y[0];

    q = sc.nextInt();

    for(i = 0;i < q;i++){
      x0 = sc.nextDouble();
      y0 = sc.nextDouble();
      countr = 0;

      for(j = 0;j < n;j++){
        if((x[j] - x0) * (y[j + 1] - y0) - (y[j] - y0) * (x[j + 1] - x0) == 0){
          if((x[j] - x0) * (x[j + 1] - x0) <= 0 && (y[j] - y0) * (y[j + 1] - y0) <= 0){
            break;
          }else if(x0 < x[j + 1] && x0 < x[j] && y0 == y[j] && y0 == y[j + 1]){
            if((y[(j - 1 + n) % n] - y0) * (y[(j + 2) % n] - y0) > 0){
              countr++;
            }
          }
        }

        if((y[j] - y0) * (y[j + 1] - y0) <= 0 && y0 != y[j + 1]){
          ax = x[j];
          ay = y[j];
          bx = x[j + 1];
          by = y[j + 1];

          if(ay > by){
            tmp = ay;
            ay = by;
            by = tmp;
            tmp = ax;
            ax = bx;
            bx = tmp;
          }
          if((ax - x0) * (by - y0) - (bx - x0) * (ay - y0) > 0){
            countr++;
            if((y[(j - 1 + n) % n] - y0) * (y[j + 1] - y0) > 0 && y[j] == y0){
              countr++;
            }
          }
        }
      }

      if(j < n){
        System.out.println("1");
      }else{
        if(countr % 2 == 1){
          System.out.println("2");
        }else{
          System.out.println("0");
        }
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 35120
#include <bits/stdc++.h>
#define DEBUG
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll read(){
	char c=getchar();bool flag=0;ll x=0;
	while(c<'0'||c>'9'){if(c=='-')flag=1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
	return flag?-x:x;
}
#define N 2010 
const ll p=1e9+7;
ll dp[N][N],fac[N*N],inv[N*N];
ll fpow(ll a,ll x){
	ll ans=1;
	while(x){
		if(x&1) ans=ans*a%p;
		a=a*a%p,x=x/2; 
	}
	return ans;
}
ll Cnt(ll n,ll m){
	return fac[m]*inv[n]%p*inv[m-n]%p;
}
int main(){
	ll n=read(),k=read();
	if(k==1){
		printf("1");
		return 0;
	}
	fac[0]=1;
	for(ll i=1;i<=n*k;i++) fac[i]=fac[i-1]*i%p;
	inv[n*k]=fpow(fac[n*k],p-2);
	for(ll i=n*k-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%p;
	for(ll i=1;i<=n;i++) dp[i][0]=1;
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=i;j++){
			dp[i][j]=dp[i-1][j]+dp[i][j-1]*(n-(j-1))%p*Cnt(k-2,n*k-i-(j-1)*(k-1)-1)%p;
			dp[i][j]%=p;
		}
	}
	printf("%lld",dp[n][n]); 
}


Measured memory_bytes: 94848
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

N, M = map(int,input().split())

if N == 1 or M == 1:
    if N + M == 2:
        print(1)
    else:
        print(N*M-2)
else:
    print((N-2)*(M-2))


Measured memory_bytes: 10436
#include<bits/stdc++.h>
using namespace std;
#define M 2505
#define ll long long
struct hh{
	int u,v,w;
}eg[M<<1];
ll dis[M];
vector<int>d[M],g[M];
bool ck1[M],ck2[M];
void dfs(int x){
	if(ck1[x])return;
	ck1[x]=1;
	for(int i=0;i<(int)d[x].size();++i)dfs(d[x][i]);
}
void Dfs(int x){
	if(ck2[x])return;
	ck2[x]=1;
	for(int i=0;i<(int)g[x].size();++i)Dfs(g[x][i]);
}
bool in(int x){
	return ck1[x]&ck2[x];
}
int main(){
	int n,m,p;
	scanf("%d%d%d",&n,&m,&p);
	for(int i=1;i<=m;++i)scanf("%d%d%d",&eg[i].u,&eg[i].v,&eg[i].w),eg[i].w-=p,d[eg[i].u].push_back(eg[i].v),g[eg[i].v].push_back(eg[i].u);
	dfs(1);Dfs(n);
	memset(dis,-63,sizeof(dis));
	dis[1]=0;
	for(int i=1;i<=n;++i){
		int p=0;
		for(int j=1;j<=m;++j)if(dis[eg[j].u]+eg[j].w>dis[eg[j].v]&&in(eg[j].u)&&in(eg[j].v))dis[eg[j].v]=dis[eg[j].u]+eg[j].w,p=1;
		if(!p)break;
		if(i==n)return puts("-1"),0;
	}
	if(dis[n]<-1e18)puts("-1");
	else printf("%lld",max(0ll,dis[n]));
}

Measured memory_bytes: 768
#include<functional>
#include <algorithm>
#include  <iostream>
#include   <ctype.h>
#include   <cstring>
#include   <fstream>
#include    <cstdio>
#include    <vector>
#include    <string>
#include     <cmath>
#include     <deque>
#include     <stack>
#include     <queue>
#include      <list>
#include       <set>
#include       <map>
#define INF 0X7FFFFFFF
#define PI acos(-1.0)
typedef long long ll;
using namespace std;
const int N = 1e6;
inline int getint()
{
	int w = 0, q = 0;
	char c = getchar();
	while ((c<'0' || c>'9') && c != '-') c = getchar();
	if (c == '-') q = 1, c = getchar();
	while (c >= '0'&&c <= '9') w = w * 10 + c - '0', c = getchar();
	return q ? -w : w;
}
int main() {
	int n = getint();
	cout << n*(n + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
n = list(map(int,input().split()))
ki = []
gu = []
count = 0

for x in range(3):
    if n[x] %2 == 0:
        ki.append(x)
    else:
        gu.append(x)

if len(gu) < len(ki) != 3:
    n[ki[0]] += 1
    n[ki[1]] += 1
    count +=1
elif len(ki) < len(gu) != 3:
    n[gu[0]] += 1
    n[gu[1]] += 1
    count +=1


n.sort(reverse=True)
count += (n[0] -n[1]) / 2
count += (n[0] -n[2]) / 2

print(int(count))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

int main()
{
    int K, A, B;
    cin >> K;
    cin >> A >> B;
    int KA = (A - 1) / K;
    int KB = B / K;
    bool ret = (KA < KB);
    cout << (ret?"OK":"NG") << "\n";
    return 0;
}


Measured memory_bytes: 3624
n,m = map(int, input().split())
a_list = []
for i in range(m):
    a_list.append(int(input()))

# memo = [-1 for _ in range(n)]
step_now = 0
step_1   = 0
step_2   = 0
DIV_NUM = 1000000007
if 1 in a_list:
    a_list.pop(0)
    step_now = 0
else:
    step_now = 1
for i in range(1, n):
    if i == 1:
        step_1 = step_now
        if i+1 in a_list:
            a_list.pop(0)
            step_now = 0
        else:
#             memo[i] = (memo[0] + 1) % DIV_NUM
            step_now = step_1 + 1
    else:
        step_2 = step_1
        step_1 = step_now
        if i+1 in a_list:
            a_list.pop(0)
            step_now = 0
        else:
#             memo[i] = (memo[i-1] + memo[i-2]) % DIV_NUM
            step_now = (step_1 + step_2) % DIV_NUM
    if step_now ==  step_1 == step_2 == 0:
        break

print(step_now)

Measured memory_bytes: 49112
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int, int>
#define f first
#define s second 
using namespace std;
const LL INF = (LL) 1e9 + 5;
const LL MOD = (LL) 1e9 + 7;
const int MAXN = 25;

int n, dp[1 << 18][MAXN], num[2][MAXN], odd[1 << 18][MAXN];

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

	cin >> n;
	for (int i = 0; i < n; i++) cin >> num[0][i];
	for (int i = 0; i < n; i++) cin >> num[1][i];
	
	for (int i = 0; i < (1 << n); i++) {
		for (int j = 0; j < n; j++) {
			int res = 0;
			for (int k = 0; k < n; k++) {
				if (k < j && (i >> k & 1)) res ^= 1;
				if (k > j && (~i >> k & 1)) res ^= 1;
			}
			odd[i][j] = res;
		}
	}
	
	for (int i = 1; i < (1 << n) - 1; i++) {
		for (int j = 0; j < n; j++) {
			dp[i][j] = INF;
			if (i >> j & 1) continue;
			int pre = num[odd[i][j]][j], mv = 0;
			for (int k = 0; k < n; k++) {
				if (~i >> k & 1) continue;
				int x = num[odd[i][k]][k];
				if (x >= pre) {
					dp[i][j] = min(dp[i][j], dp[i ^ 1 << k][k] + mv);
				}
				mv++;
			}
		}
	}
	
	int ans = INF, all = (1 << n) - 1;
	for (int i = 0; i < n; i++) {
		ans = min(ans, dp[all ^ 1 << i][i] + i);
	}
	
	cout << (ans >= INF ? -1 : ans) << '\n';

	return 0;
}

Measured memory_bytes: 51456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double w = sc.nextDouble();
		double h = sc.nextDouble();
		double x = sc.nextDouble();
		double y = sc.nextDouble();
		System.out.print(h * w / 2.0);
		System.out.print(" ");
		if (x == w / 2.0 && y == h / 2.0) System.out.print(1);
		else System.out.print(0);
	}
}


Measured memory_bytes: 26452