akhauriyash/Code-Regression huggingface dataset:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = list(map(int, input().split()))
from collections import defaultdict
ns = defaultdict(set)
ins = defaultdict(set)
ds = [0]*n
sts = [None]*m
for i in range(m):
    s,t = map(int, input().split())
    s -= 1
    t -= 1
    ns[t].add(s)
    ins[s].add(t)
    ds[s] += 1
    sts[i] = (s,t)
ts = [None]*n

def sub(x):
    global ts
    if x is not None:
        s,t = x
#         s,t = sts[x]
        if ds[s]<=1:
            return None
        ns[t].remove(s)
        ins[s].remove(t)
        ds[s] -= 1
    ts[n-1] = 0
    for i in range(n-2, -1, -1):
        tt = 0
        for v in ins[i]:
            tt += (ts[v])
        ts[i] = tt/len(ins[i]) + 1
    if x is not None:
        ns[t].add(s)
        ins[s].add(t)
        ds[s] += 1
    return ts[0]
ans = sub(None)
its = ts[:]
for i in range(n):
    if len(ins[i])>=2:
        mm = max(its[j] for j in ins[i])
        for j in ins[i]:
            if its[j]==mm:
                break
        res = sub((i,j))
        if res is not None:
            ans = min(ans, res)
print(ans)

Measured memory_bytes: 114896
//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector< pair<ll, ll> >
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for (ll i=0; i<n; ++i)
#define foris(i, a, b) for (ll i=a; i<b; ++i)
#define ford(i, n) for (ll i=n; i>=0; --i)
#define fords(i, a, b) for (ll i=a; i>=b; --i)
#define forr(i, a) for (auto &i : a)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;
//endregion

int main() {
    io();
    int a, b;
    cin >> a >> b;
    if ((1 <= a and a <= 9) and (1 <= b and b <= 9)) cout << a*b;
    else cout << -1;
}


Measured memory_bytes: 892
import java.util.Scanner;

public class Main {

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

		if (N % K == 0) {
			System.out.println(0);
		} else {
			System.out.println(1);
		}

	}
}


Measured memory_bytes: 21460
#include <stdio.h>

int main()
{
    int n,l,max,sum;

    scanf("%d %d",&n,&l);
    max = l + n - 1;
    sum = (max + l) * n / 2;

    if (max < 0)
    {
        printf("%d",sum - max);
    }
    else if ((l <= 0) && (0 <= max))
    {
        printf("%d",sum);
    }
    else
    {
        printf("%d",sum - l);
    }
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

struct SegTree {
	int n;
	std::vector<int64_t> maxed;
	std::vector<int64_t> added;
	SegTree (int n_) {
		for (n = 1; n < n_; n <<= 1);
		maxed.resize(n << 1, -1000000000000000000);
		added.resize(n << 1);
	}
	void flush(int node) {
		if (added[node]) {
			maxed[node] += added[node];
			if (node < n) {
				added[node << 1] += added[node];
				added[node << 1 | 1] += added[node];
			}
			added[node] = 0;
		}
	}
	void fetch(int node) {
		maxed[node] = std::max(maxed[node << 1], maxed[node << 1 | 1]);
	}
	void assign(int i, int64_t val, int node = 1, int node_l = 0, int node_r = 0) {
		if (!node_r) node_r = n;
		flush(node);
		if (node_l == i && node_r == i + 1) maxed[node] = val;
		else {
			int m = node_l + ((node_r - node_l) >> 1);
			if (i < m) assign(i, val, node << 1, node_l, m);
			else assign(i, val, node << 1 | 1, m, node_r);
			fetch(node);
		}
	}
	int64_t max(int l, int r, int node = 1, int node_l = 0, int node_r = 0) {
		if (!node_r) node_r = n;
		flush(node);
		if (l >= node_r || r <= node_l) return -1000000000000000000;
		if (l <= node_l && r >= node_r) return maxed[node];
		int m = node_l + ((node_r - node_l) >> 1);
		int64_t res = std::max(
			max(l, r, node << 1, node_l, m),
			max(l, r, node << 1 | 1, m, node_r));
		fetch(node);
		return res;
	}
	void add(int l, int r, int val, int node = 1, int node_l = 0, int node_r = 0) {
		if (!node_r) node_r = n;
		flush(node);
		if (l >= node_r || r <= node_l) return;
		if (l <= node_l && r >= node_r) {
			added[node] += val;
			flush(node);
		} else {
			int m = node_l + ((node_r - node_l) >> 1);
			add(l, r, val, node << 1, node_l, m);
			add(l, r, val, node << 1 | 1, m, node_r);
			fetch(node);
		}
	}
};

int main() {
	int n = ri(), m = ri();
	std::vector<std::pair<int, int> > right[n + 1];
	for (int i = 0; i < m; i++) {
		int l = ri();
		int r = ri();
		int val = ri();
		right[r].push_back({l, val});
	}
	SegTree tree(n + 1);
	tree.assign(0, 0);
	for (int i = 1; i <= n; i++) {
		tree.assign(i, tree.max(0, i));
		for (auto j : right[i]) tree.add(j.first, i + 1, j.second);
	}
	std::cout << tree.max(0, tree.n) << std::endl;
	
	return 0;
}


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

int n, a[111], res;

int main()
{
    cin >> n;
    int p = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
            res = max(p, res), p = 0;
        else
            p++;
    }
    res = max(p, res);
    cout << res + 1 << endl;
}


Measured memory_bytes: 3104
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n;
	ll sum = 0, sum2 = 0, minn = INF;
	vector<ll>list;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		sum += num;
		list.push_back(num);
	}

	for (int i = 0; i < n - 1; i++) {
		sum -= list[i];
		sum2 += list[i];
		minn = min(minn, abs(sum - sum2));
	}

	cout << minn << endl;


	return 0;
}

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

int func(int x)
{
    if(x%2==0)
    {
        return x/2;
    }
    else
    {
        return 3*x+1;
    }
}
int main()
{
    int x;
    cin>>x;
 
    bool flag = true;
    for(int i=x;i<pow(10,6);i++)
    {
        bool flag = true;
        for(int j=2;j<sqrt(i);j++)
        {
            if(i%j==0)
            {
                flag = false;
            }
        }
        if(flag)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input());

s = [input() for i in range(n)]

ac = wa = tle = re = 0

for s_kind in s:
    if s_kind == "AC":
        ac += 1
    elif s_kind == "WA":
        wa += 1
    elif s_kind == "TLE":
        tle += 1
    elif s_kind == "RE":
        re += 1
    
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)

Measured memory_bytes: 16328
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int ,int > P;
typedef long long ll;

string ans;
char c;
string S = "aiueo";
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

string solve(){
	for (int i = 0; i < 5; ++i)
	{
		if(c == S[i]){
			return "vowel";
		}
	}
	return "consonant";
}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> c;
	ans = solve();
	answer();
	return 0;
}

Measured memory_bytes: 256
# https://pitsbuffersolution.com/compro/atcoder/arc079e.php

def main():
    N = int(input())
    *a, = map(int, input().split())

    tot = sum(a)

    def is_ok(k):
        b = (x + k - (N - 1) for x in a)

        cnt = 0
        for x in b:
            cnt += (x + N) // (N + 1)

        return cnt <= k

    ret = 0

    k = max(0, tot - N * (N - 1))
    while k <= tot:
        if is_ok(k):
            ret = k
            break
        k += 1

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int n,x,i,min=1000,a;
  scanf("%d%d",&n,&x);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    x-=a;
    if(a<min)
      min=a;
  }
  printf("%d\n",n+x/min);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD1 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
 



map< int, int > prime_factor(int n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}



void solve(void)
{
  int N;cin>>N;
  map<int,int> pf;
  for (int i = 1; i <= N; i++)
  {
    auto x = prime_factor(i);
    for (auto &&z : x)
    {
      pf[z.first] += z.second;
    }
    
  }
  vector<int> cnt(MEM_SIZE,0);
  for (auto &&x : pf)
  {
    cnt[x.second+1]++;
  }
  for (int i = MEM_SIZE-1; i >= 0; i--) 
  {
    cnt[i] += cnt[i+1];
  }
  // DEBUG(cnt);
  cout<<cnt[75] + cnt[25]*(cnt[3]-1)+(cnt[5]*(cnt[5]-1)/2*(cnt[3]-2)+cnt[15]*(cnt[5]-1));
  
  




  
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3856
/*   _ _ _                     
    | | | | ___  ___           
    | | | || . ||  _|          
    |_____||_  ||_|  _____     
             |_|    |_____|  */
// Time : 19/10/20
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
int main(){
#ifdef Wqr_
    freopen("in.txt","r",stdin);
#endif
    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int n;
    cin >> n;
    string in;
    cin >> in;
    int ans = 1;
    for(int i = 0; i < n - 1; i++){
        if(in[i] != in[i + 1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

import sys


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


def resolve():
    n = int(input())
    s_list = []
    for _ in range(n):
        s_list.append(input().rstrip())

    s_set = set(s_list)

    print(len(s_set))


if __name__ == "__main__":
    resolve()



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

int main(){
  int a,b;
  cin >> a >>b;
  if (9 >= a >= 1 && 9 >= b >= 1){
  	cout << a*b << endl;
  }
  else{
  	cout << -1 << endl;
   
  }
  return 0;
}


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

int lcs(string str1, string str2)
{
  int m = str1.size(), n = str2.size();
  int c[1001][1001];
  str1 = ' ' + str1;
  str2 = ' ' + str2;
  for (int i = 1; i <= m; i++) c[i][0] = 0;
  for (int i = 1; i <= n; i++) c[0][i] = 0;

  for (int i = 1; i <= m; i++){
    for (int j = 1; j <= n; j++){
      if (str1[i] == str2[j]) c[i][j] = c[i - 1][j - 1] + 1;
      else if (c[i - 1][j] > c[i][j - 1]) c[i][j] = c[i - 1][j];
      else  c[i][j] = c[i][j - 1];
    }
  }
  return (c[m][n]);
}
int main()
{
  int q;
  cin >> q;
  while (q--){
    string str1, str2;
    cin >> str1 >> str2;
    cout << lcs(str1, str2) << endl;
  }
}

Measured memory_bytes: 5128
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    n_half = n // 2
    a = list(map(int, input().split()))
    ls = [0] * n
    ans = []

    for i in range(n-1, -1, -1):
        if (sum(ls[i::i+1]) % 2) != a[i]:
            ls[i] = 1
            ans.append(i+1)
    print(sum(ls))
    if ans:
        print(*ans[::-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 14776
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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;
}
const int MOD = 1000000007;
int main() {
    int N, L;
    cin >> N >> L;
    int azi = 0;
    rep(i, 1, N + 1) { azi += L + i - 1; }
    int min = 100000;
    int res;
    rep(i, 1, N + 1) {
        int azi2 = 0;
        rep(r, 1, N + 1) {
            if(i != r) {
                azi2 += L + r - 1;
            }
        }
        if(abs(azi - azi2) < min) {
            min = abs(azi - azi2);
            res=azi2;
        }
    }
    cout << res << endl;
}

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

#define ll long long
#define mod 1000000007

int main() {

    ll h,w;
    cin>>h>>w;
    char a[h][w];
    ll maze[h][w];

    for(ll i=0;i<h;i++)
        for(ll j=0;j<w;j++){
            cin>>a[i][j];

            if(a[i][j]=='.')maze[i][j]=0;
            else maze[i][j]=-1;
        }

    for (ll i=0; i<h; i++)
    {
        if (maze[i][0] == 0)
            maze[i][0] = 1;
        else
            break;
    }
    for (ll i=1; i<w; i++)
    {
        if (maze[0][i] == 0)
            maze[0][i] = 1;
        else
            break;
    }

    for (ll i=1; i<h; i++)
    {
        for (ll j=1; j<w; j++)
        {
            if (maze[i][j] == -1)
                continue;
            if (maze[i-1][j] > 0)
                maze[i][j] = (maze[i][j]%mod + maze[i-1][j]%mod)%mod;

            if (maze[i][j-1] > 0)
                maze[i][j] = (maze[i][j]%mod + maze[i][j-1]%mod)%mod;
        }
    }
    ll ans= (maze[h-1][w-1] > 0) ? maze[h-1][w-1]%mod : 0;
    cout<<ans;
    return 0 ;
}


Measured memory_bytes: 9088
n = gets.chomp.to_i
c = 0
if n > 0 then
  a = gets.chomp.split(" ").map(&:to_i)
  i = 1
  a.each do |x|
    if x != i then
      if a[x-1] != i then
        c = 99
        break;
      else
        c += 1
      end
    end
    i += 1
  end
  if c > 2
    puts "NO"
  else
    puts "YES"
  end
end


Measured memory_bytes: 3836
a, v = map(int, input().split())
b, w = map(int, input().split())

t = int(input())

if a == b:
    print('YES')
    exit()

if w >= v:
    print('NO')
    exit()

d = abs(a - b)

vel = v - w

if (d + vel - 1) // vel > t:
    print('NO')
else:
    print('YES')


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

int ei[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
int ej[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };

int main(){
  int h,w;
  cin >> h >> w;
  string s[h];
  rep(i,h) cin >> s[i];
  
  rep(i,h)rep(j,w){
    if(s[i][j] == '.'){
      int mine=0;
      rep(k,8){
        int I = i+ei[k];
        int J = j+ej[k];
        if(I < 0 || I >= h || J < 0 || J >= w) continue;
        if(s[I][J]=='#') mine++;
      }
      s[i][j] = '0'+mine;
    }
  }
  
  rep(i,h) cout << s[i] << endl;
        
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();

		int n;
		int m;
		if(a<=b) {
			n=a;
			m=b;
		} else {
			n=b;
			m=a;
		}
		for(int i=0; i<m; i++) {
			System.out.print(n);
		}
		System.out.println();
		sc.close();
	}
}


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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  
  rep(i, ty - sy) cout << "U";
  rep(i, tx - sx) cout << "R";
  cout << "U";
  rep(i, tx - sx + 1) cout << "L";
  rep(i, ty - sy + 1) cout << "D";
  cout << "R";
  rep(i, tx - sx) cout << "R";
  rep(i, ty - sy) cout << "U";
  cout << "R";
  rep(i, ty - sy + 1) cout << "D";
  rep(i, tx - sx + 1) cout << "L";
  cout << "U";
  
  return 0;
}


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

int main(){
  int N; int c1=0;int c2=0;int c3=0;int c4=0; string s;
  cin>>N;
  for (int i=0; i<N;++i){
    cin>>s;
    if(s == "AC")c1++;
    if(s == "WA")c2++;
    if(s == "TLE")c3++;
    if(s == "RE")c4++;  
  }
  cout<<"AC"<<" "<<"x"<<" "<<c1<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<c2<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<c3<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<c4<<endl;
 return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int main(){

    int N,K;
    cin >> N >> K;

    if(N%K != 0){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan =new Scanner(System.in);
		long x=Long.parseLong(scan.next());
		long y=Long.parseLong(scan.next());
		long coppy_x=x;
		long count=0;
		while (x<=y){
			++count;
			x*=2;
		}
		System.out.print(count);
	}
}
//end


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double EPS = 1e-7;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define dist(a,b) ( pow(a.X - b.X, 2) + pow( a.Y - b.Y, 2 ) )
typedef tuple <int, int, int> line;
typedef complex <double> point;
typedef vector <point> polygon;
int main()
{
    Hello
    int n, arr[100000];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    int h[100000];
    h[0] = 0;
    h[1] = abs( arr[0] - arr[1] );
    for (int i = 2; i < n; i++)
    {
        h[i] = min ( h[i - 1] + abs(arr[i] - arr[i - 1]), h[i - 2] + abs(arr[i] - arr[ i - 2]) );
    }
    cout << h[n - 1];
    return 0;
}



Measured memory_bytes: 1024
from bisect import bisect_right

def LIS(A):
    B = [INF for _ in range(len(A))]
    B[0] = A[0]
    for i in range(1,len(A)):
        pt = bisect_right(B,A[i])
        if B[pt-1] != A[i]:
            B[pt] = A[i]
    return bisect_right(B,INF-1)

n = int(input())
A = [int(input()) for _ in range(n)]
INF = 10**9+2

print(LIS(A))



Measured memory_bytes: 10360
#include<bits/stdc++.h>
#define ll long long
#define ljc 1000000007
using namespace std;
inline char gc(){
    static char now[1<<16],*S,*T;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
struct edge{
	int to,nxt;
}g[11010];
int sz[10101],head[10101],n,tot;
inline void made(int from,int to){
	g[++tot].to=to;g[tot].nxt=head[from];head[from]=tot;
}
ll dp[5010][5010],F[5050],tmp[5050];
void dfs(int u,int faa){
	dp[u][1]=sz[u]=1;
	for (int i=head[u];i;i=g[i].nxt){
		int v=g[i].to;
		if (v==faa) continue;
		dfs(v,u);
		for (int j=0;j<=sz[u]+sz[v];j++) tmp[j]=0;
		for (int j=1;j<=sz[u];j++){
			for (int k=1;k<=sz[v];k++){
				tmp[j]=(tmp[j]+ljc-dp[u][j]*(F[k]*dp[v][k]%ljc)%ljc)%ljc;
				tmp[j+k]=(tmp[j+k]+dp[v][k]*dp[u][j]%ljc)%ljc;
			}
		}
		sz[u]+=sz[v];
		for (int j=0;j<=sz[u];j++) dp[u][j]=tmp[j];
	}
}
signed main(){
	n=read();
	for (int i=1;i<n;i++){
		int x=read(),y=read();
		made(x,y);made(y,x);
	}
	F[0]=1;
	for (int i=2;i<=n;i+=2){
		F[i]=1ll*(i-1)*F[i-2]%ljc;
	}
	dfs(1,0);
	ll ans=0;
	for (int i=2;i<=n;i+=2) ans=(ans+dp[1][i]*F[i]%ljc)%ljc;
	cout<<ans;
	return 0;
}



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

using namespace std;

typedef long long int ll;

int main()
{
  string s,t;
  cin >> s >> t;

  int count = 0;

  for(int i = 0; i < s.size(); i++){
    if(s[i] != t[i]){
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3856
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x: i64 = read();
    let y: i64 = read();
    let z: i64 = read();

    if x <= z {
        println!("0");
        return;
    };

    println!("{}", (x - z) / (y + z));
}


Measured memory_bytes: 4352
s = input()
k = int(input())

ans = []

for i in range(len(s)):
    if 123 - ord(s[i]) <= k:
        if s[i] == "a":
            ans.append("a")
            continue
        ans.append("a")
        k -= 123 - ord(s[i])
    else:
        ans.append(s[i])

last = chr((ord(ans[-1])-97+k)%26 + 97)
ans[-1] = last


print(*ans, sep = "")


Measured memory_bytes: 7156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;

int main(){
    int a,b;
    cin >> a >> b;
    if(a==1) a+=13;
    if(b==1) b+=13;
    if(a>b) puts("Alice");
    else if(a==b) puts("Draw");
    else puts("Bob");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int x,y,size,i,j;
  int pr[10][10]={0};
  int cnt=0,max=0;

  while(1){
    if(scanf("%d,%d,%d",&x,&y,&size) == EOF){
      break;
    }
    pr[x][y]++; 
    if(y-1>=0)pr[x][y-1]++;
    if(x-1>=0)pr[x-1][y]++;
    if(y+1<=9)pr[x][y+1]++;
    if(x+1<=9)pr[x+1][y]++;

    if((size==2) || (size==3)){
      if((x+1<=9) && (y+1<=9))pr[x+1][y+1]++;
      if((x-1>=0) && (y+1<=9))pr[x-1][y+1]++;
      if((x+1<=9) && (y-1>=0))pr[x+1][y-1]++;
      if((x-1>=0) && (y-1>=0))pr[x-1][y-1]++;

      if(size==3){
	if(y-2>=0)pr[x][y-2]++;
	if(x-2>=0)pr[x-2][y]++;
	if(y+2<=9)pr[x][y+2]++;
	if(x+2<=9)pr[x+2][y]++;
      }
    }
  }

  for(i=0;i<=9;i++){
    for(j=0;j<=9;j++){
      
      if(pr[i][j]==0){
	cnt++;
      }

      if(pr[i][j]>max){
	max=pr[i][j];
      }
    }
  }
  
  printf("%d\n%d\n",cnt,max);
  
  return 0;

}

Measured memory_bytes: 600
// Aizu Vol-3 0337: Japanese Calendar
// 2017.8.25

#include <stdio.h>

int greg[] = { 1989, 1926, 1912, 1868, 0 };
char jan[] = { 'H', 'S', 'T', 'M', 0 };

int main()
{
	int E, Y, i;
	scanf("%d%d", &E, &Y);
	if (E == 0) {
		for (i = 0; greg[i] > 0; i++) {
			if (Y >= greg[i]) { printf("%c%d\n", jan[i], Y - greg[i] + 1); break; }
		}
	} else printf("%d\n", Y + greg[(4-E) & 3] - 1);
	return 0;
}

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

int main(void) {
	int n, ans = 0;
	cin >> n;
	vector<int> l(n), r(n);	
	for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
	for (int i = 0; i < n; i++) {
		ans += r[i] - l[i] + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
     
int main(){ios_base::sync_with_stdio(0);cin.tie(0); 
    int x, y;
    cin >> x >> y;
    int cnt = 0;
    for(int i = 0; i <= x; ++i){
        for(int j = 0; j <=x; ++j){
            int z = y - i - j;
             if( 0 <= z && z <= x  && ( z + i + j) == y) cnt++;
        }
    }
    cout << cnt;
}

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

sum = 0
for i in range(k, n+2):
    min_sum = i * (i-1) / 2
    max_sum = i * (2 * n - i + 1) / 2
    sum += max_sum - min_sum + 1
print(int(sum % (10**9 + 7)))


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

int main(){
	int N;
	cin >> N;
	vector<int> a(N+1);
	REP(i,N){
		cin >> a[i];
	}
	
	vector<int> ans(N+1);
	ans.assign(N+1,0);
	
	for (int i = N; i >= 1 ; --i) {
		int count = 1;
		int temp = 0;
		while(i*count <= N){
			temp += ans[i*count];
			count++;
		}
		if(temp % 2 == a[i] % 2 ){
			ans[i] = 0;
		}else{
			ans[i] = 1;
		}
	}
	
	int num = 0;
	REP(i,N){
		num += ans[i];
	}
	
	cout << num << endl;
	REP(i,N){
		if(ans[i] != 0){
			cout << i << " ";
		}
	}
    return 0;
}

Measured memory_bytes: 2432
n=int(input())

l  = input()
l =[int(i) for i in l.split()]
v ={}
for i in l :
    if  i in v:
        v[i]+=1
    else:v[i] = 1
m = int(input())
l = input()
l = [int(i) for i in l.split()]
t = 1
for i in l :
    if not(i in v) :
        t= 0
        break
    else:
        v[i]-=1
        if v[i]<0:
            t=0
            break
if t==1:
    print("YES")
if t==0:
    print("NO")


Measured memory_bytes: 49760
package main

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

func check(x, y, x1, y1, x2, y2 float64) float64 {
	return (x2-x1)*y - (y2-y1)*x + x1*y2 - x2*y1
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	a := make([]float64, 8)
	for scanner.Scan() {
		info := strings.Split(scanner.Text(), ",")
		for j := 0; j < 8; j++ {
			a[j], _ = strconv.ParseFloat(info[j], 64)
		}
		if check(a[0], a[1], a[2],a[3], a[6], a[7])*check(a[4], a[5], a[2], a[3], a[6], a[7]) < 0 && check(a[6], a[7], a[0], a[1], a[4], a[5])*check(a[2],a[3], a[0], a[1], a[4], a[5]) < 0 {
			fmt.Println("YES")	
		} else {
			fmt.Println("NO")
		}
	}
}


Measured memory_bytes: 1084
from heapq import heappush, heappop

N, K = map(int, input().split(' '))
h = []
for _ in range(N):
    t, d = map(int, input().split(' '))
    heappush(h, (-d, t))

dsum = 0
used = {}
q = []
for _ in range(K):
    d, t = heappop(h)
    if t not in used:
        used[t] = 1
    else:
        heappush(q, (-d, t))
    dsum += -d
res = len(used)**2 + dsum

while h and q:
    d, t = heappop(h)
    if t not in used:
        used[t] = 1
        m, _ = heappop(q)
        dsum = dsum - m - d
        res = max(res, len(used)**2 + dsum)
print(res)

Measured memory_bytes: 21324
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod7=1000000007LL;
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add(LL _x, LL _y, LL _mod=mod7){
  _x+=_y;
  return _x>=_mod ? _x-_mod : _x;
}
inline LL sub(LL _x, LL _y, LL _mod=mod7){
  _x-=_y;
  return _x<0 ? _x+_mod : _x;
}
inline LL mul(LL _x, LL _y ,LL _mod=mod7){
  _x*=_y;
  return _x>=_mod ? _x%_mod : _x;
}
LL mypow(LL _a, LL _x, LL _mod){
  if(_x == 0) return 1LL;
  LL _ret = mypow(mul(_a, _a, _mod), _x>>1, _mod);
  if(_x & 1) _ret=mul(_ret, _a, _mod);
  return _ret;
}
LL mymul(LL _a, LL _x, LL _mod){
  if(_x == 0) return 0LL;
  LL _ret = mymul(add(_a, _a, _mod), _x>>1, _mod);
  if(_x & 1) _ret=add(_ret, _a, _mod);
  return _ret;
}
void sleep(double sec = 1021){
  clock_t s = clock();
  while(clock() - s < CLOCKS_PER_SEC * sec);
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
const int N=333;
const int BS=13131;
int n, bs[N+N];
char c[N][N];
void build(){
  bs[0]=1;
  for(int i=1; i<N+N; i++)
    bs[i]=mul(bs[i-1],BS);
}
int vl[N+N][N+N];
int vd[N+N][N+N];
void init(){
  scanf("%d", &n);
  for(int i=1; i<=n; i++)
    scanf("%s", c[i]+1);
  for(int i=1; i<=n; i++){
    {
      int tvl=0;
      for(int j=1; j<=n+n; j++){
        tvl=add(mul(tvl, BS), c[i][j>n?j-n:j]);
        vl[i][j]=tvl;
      }
    }
    {
      int tvl=0;
      for(int j=1; j<=n+n; j++){
        tvl=add(mul(tvl, BS), c[j>n?j-n:j][i]);
        vd[j][i]=tvl;
      }
    }
  }
}
int hs_vl(int ii, int j1, int j2){
  if(ii > n) ii -= n;
  return sub(vl[ii][j2], mul(vl[ii][j1-1], bs[j2-j1+1]));
}
int hs_vd(int i1, int i2, int jj){
  if(jj > n) jj -= n;
  return sub(vd[i2][jj], mul(vd[i1-1][jj], bs[i2-i1+1]));
}
void solve(){
  int ans=0;
  for(int i=1; i<=n; i++)
    for(int j=1; j<=n; j++){
      bool ok=true;
      for(int k=0; k<n; k++){
        if(hs_vl(i+k, j, j+n-1) !=
           hs_vd(i, i+n-1, j+k)){
          ok=false;
          break;
        }
      }
      if(not ok) continue;
      ans++;
    }
  cout<<ans<<endl;
}
int main(){
  build();
  //__ = getint();
  while(__ --){
    init();
    solve();
  }
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n; 
cin>>n;
vector<int>a(n);
for(int i = 0; i<n; i++){
    cin>>a[i];
}
sort(a.begin(),a.end());
double ans = a[0];
for(int i = 1; i<n; i++){
    ans = (ans + a[i])/2;
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;








int main(void){
    int m = 998244353;
    int n,s;
    cin>>n>>s;
    int *a = new int[n];
    for(int i = 0; i < n; i++) {
        cin>>a[i];
    }

    long (*arr)[4000] = new long[4000][4000];
    for(int i = 0; i <= s; i++) {
        arr[n-1][i] = 0;
    }
    arr[n-1][a[n-1]] = 1;
    arr[n-1][0] = 2;

    for(int i = n-2; i >=0; i--) {
        for(int j = 0; j <=s; j++) {
            arr[i][j] = (arr[i+1][j-a[i]]+2*arr[i+1][j])%m;
        }
    }
    cout<<arr[0][s]<<"\n";
    

    



    return 0;
}

Measured memory_bytes: 85328
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << a * b - a - b + 1;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  
  for (int j = 0;j < N;j++) {
    for (int i = 0;i < N - 1;i++) {
      if (vec.at(i) < vec.at(i + 1)) {
        int a = vec.at(i);
        vec.at(i) = vec.at(i + 1);
        vec.at(i + 1) = a;
      }
    }
  }
  
  int Alice = 0;
  int Bob = 0;
  
  for (int i = 0;i < N;i += 2) {
    Alice += vec.at(i);
  }
  
  for (int i = 1;i < N;i += 2) {
    Bob += vec.at(i);
  }
  
  cout << Alice - Bob << endl;
        

}


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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long LL;

const int INF = 0x3f3f3f3f;


int main(void) {
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    int dp[n], a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];

    fill_n(dp, n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j : {i+1, i+2}) {
            if (j < n) {
                dp[j] = min(dp[j], dp[i] + abs(a[i]-a[j]));
            }
        }
    }
    cout << dp[n-1] << endl;

    return 0;
}



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

long long ara[3][4007];

int main()
{

        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x,y=0,z=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        scanf("%lld",&n);
        cin>>str;

        if(n<=3)printf("0\n");
        else
        {

            for(i=0;i<n;i++)
            {
                if(str[i]=='R')cnt++;
                else if(str[i]=='G')y++;
                else{  z++; }

                ara[0][i+1]=cnt; ara[1][i+1]=y; ara[2][i+1]=z;
            }

            char ch,th,rh;

            for(i=0;i<n-2;i++)
            {
                ch=str[i];

                for(j=i+1;j<n-1;j++)
                {
                    if(str[j]!=ch)
                    {
                        th=str[j];

                        if(ch!='R' && th!='R')x=0;
                        else if(ch!='G' && th!='G')x=1;
                        else{ x=2;  }

                        fr=ara[x][n]-ara[x][j+1-1];

                        p=j-i; h=j+p;

                        if(h<=n-1)
                        {
                            if(x==2)rh='B';
                            else if(x==1)rh='G';
                            else{ rh='R';  }

                            if(str[h]==rh)fr--;

                        }

                        ans=ans+fr;

                    }

                }

            }

            printf("%lld\n",ans);

        }




    return 0;

}





Measured memory_bytes: 3864
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

int main(){
    long long dp[105][21];
    int n,begin,ans,k;
    cin>>n;
    cin>>begin;
    memset(dp, 0, sizeof(dp));
    dp[0][begin]=1;
    for(int i=1; i<n-1; i++){
        cin>>k;
        for(int j=0; j<21; j++){
            if(j+k<=20) dp[i][j+k]+=dp[i-1][j];
            if(j-k>=0) dp[i][j-k]+=dp[i-1][j];
        }
    }
    cin>>ans;
    cout<<dp[n-2][ans]<<endl;
    return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> ivec;
const ll N = 1e9+7;

int main(){
    string s;cin >> s;
    // rep(i,4) cin >> s[i];
    int count[4] = {};
    // int sj[4];
    // sj[0] = s[0] - 'a';
    // count[0]++;
    
    for(int i = 0; i< 4;i++){
        rep(j,4){
            if(s[i]== s[j]){
                count[j]++;
            }
            // else count[i]++;
        }
    }
    bool ok = true;
    rep(i,4){
        if(count[i] != 0 && count[i] != 2) ok = false;
    }
    // rep(i,4) cout << count[i] ;
    // cout << endl;
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(void){
    char a;
    for(int i=0;i<3;i++){
        cin>>a;
        if(a=='1'){
            cout<<9;
        }else{
            cout<<1;
        }
    }
    cout<<endl;
    return 0;
}

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)
#define fi first
#define se second

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, f[100][10], p[100][11];
int res = -INF;

void solve(int now, int n, int cnt) {
    if(cnt != 0 && n == 10) {
        int sum = 0;
        rep(i, N) {
            int c = 0;
            rep(j, 11) if(f[i][j] & (now >> j)) ++c;
            sum += p[i][c];
        }
        chmax(res, sum);
    }
    if(n < 10) {
        solve(now, n + 1, cnt);
        solve((now | (1 << n)), n + 1, cnt + 1);
    }
}

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

    cin >> N;
    rep(i, N) rep(j, 10) cin >> f[i][j];
    rep(i, N) rep(j, 11) cin >> p[i][j];
    solve(0, 0, 0);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define reg register
#define ll long long
using namespace std;
inline void file_io(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
string a, b, c;
int cnta, cntb;
int main() {
    cin >> a >> b;
    scanf("%d%d", &cnta, &cntb);
    cin >> c;
    if(a == c)
        cnta--;
    else
        cntb--;
    printf("%d %d\n", cnta, cntb);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void){
    
    int a[5];
    long int ans;
    for(int i=0;i<5;i++)  {
        scanf("%d",&a[i]);
        if(a[i] == 0) printf("%d",i+1);
    } 



    //printf("%d",ans);

    return 0;
}

Measured memory_bytes: 1688
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)(1e9)+7)
#define MAX ((ull)(1e9)+1)

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b/a, c) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int MOD = 1e8;
int main() {
    IO;
    string s1,s2 ;
    cin>>s1>>s2;
    int n =s1.size();
    int m =s2.size();
    int ans =INT_MAX;
    for(int i  = 0; i<=n-m ; i ++){
        int dif= 0;
        for(int j = i ; j< i + m ; j ++){
            if(s1[j]!=s2[j-i]){
                dif++;
            }
        }
        ans=min(ans,dif);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <math.h>
int isPrime(int);
int main(){
  int n,i,count=0;
  int Number[10000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&Number[i]);
    count+=isPrime(Number[i]);
  }
  printf("%d\n",count);
  return 0;
}
 
int isPrime(int x){
  int i=3;
  if(x==2){
    return 1;
  }
  if(x<2 || x%2==0){
    return 0;
  }
  while(i<=sqrt(x)){
    if(x%i==0)return 0;
      i=i+2;
  }
  return 1;
}

Measured memory_bytes: 628
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;






public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    //public static long mod = (long) (1e9+7);
    public final static int MAX = (int)1e5;
  // static Scanner sc = new Scanner(System.in);
   static List<Integer>[] edge;
   private static int N = (int) (2e5 + 11);
	public static void main(String[] args) {
	   
	 FastReader sc = new FastReader();

	long n = sc.nextLong();
	out.print((n*(n-1))/2);
	 out.close();
	}
}

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

const int maxn = 100050;

int n, m;
bool g[maxn];
int c[maxn];
char a[maxn];

int main()
{
	#ifdef MPS
		freopen("a.in","r",stdin);
		freopen("a.out","w",stdout);
	#endif
	scanf("%d%d",&n,&m);
	int a1 = 0, a2 = 0;
	for(int i = 1; i <= m; ++ i)
	{
		int id; scanf("%d",&id);
		scanf("%s",a+1);
		if(a[1] == 'A')
		{
			if(!g[id]) {++ a1; a2 += c[id];}
			g[id] = true;
		}
		else
		{
			c[id] ++;
		}
	}
	printf("%d %d\n",a1,a2);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll a[n],b[n];
  rep(i,n) R a[i];
  rep(i,n) R b[i];
  ll ans=0;
  rep(i,n) {
    ll x=ceil((double)(max(0LL,b[i]-a[i]))/2);
    a[i]+=2*x;
    ans+=x;
  }
  rep(i,n) {
    ll x=max(0LL,a[i]-b[i]);
    ans-=x;
    b[i]+=x;
  }
  if(ans>=0) pr("Yes");
  else pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,d,x[200001],y[200001];
    cin>>n>>d;
    rep(i,n) cin>>x[i]>>y[i];
    ll ans=0;
    rep(i,n) if(d*d>=x[i]*x[i]+y[i]*y[i]) ans++;
    cout<<ans;
}

Measured memory_bytes: 6740
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin>>a;
  for(int i=0;i<4-1;i++){
    if(a[i]==a[i+1]){
      cout<<"Bad"<<endl;
      return 0;
    }
  }
  cout<<"Good"<<endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int p[21];
  rep(i,n) cin >>p[i];

  int ans =0;
  for (int i =0; i<n-2;++i)
  {
      if (p[i+1]>p[i]&& p[i+1]<p[i+2]) ans +=1;
      else if(p[i+1]<p[i]&& p[i+1]>p[i+2]) ans +=1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    B=list(map(int,input().split()))
    ans=[]
    for i in range(n):
        for j in range(len(B)-1,-1,-1):
            if B[j]==j+1:
                ans.append(B.pop(j))
                break
        else:
            print(-1)
            break
    else:
        print('\n'.join(map(str,ans[::-1])))

if __name__=='__main__':
    main()

Measured memory_bytes: 3064
//グラフ上の探索
//
//反省点:グラフの扱いに慣れていなかった
#include <bits/stdc++.h> 

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll N,A,B,C,D;
  cin>>N>>A>>B>>C>>D;
  int d=abs(A-B);
  bool ok=false;
  for(int i=0;i<N;i++){
    ll Up=D*(N-1-i)-C*i;
    ll Down=C*(N-1-i)-D*i;
    if(Down<=d&&d<=Up)ok=true;
  }
  if(ok)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())

l = list(map(int,input().split()))

l.reverse()

x = 0
sum_x = []
sum_y = [sum(l)]*(n-1)
abs_xy = []

for i in range(n-1):
    x += l[i]
    sum_x.append(x)
    sum_y[i] -= sum_x[i]
    abs_xy.append(abs(sum_x[i]-sum_y[i]))


print(min(abs_xy))



Measured memory_bytes: 101968