akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static Constans;

public static class Constans
{
    public const long Mod = (long)1e9 + 7;
}

public struct ModInt
{
    public long Num;

    public ModInt(long num)
    {
        Num = num;
    }

    // x^n
    public static long Power(long x, long n)
    {
        long pow = 1;
        while (n > 0)
        {
            if (n % 2 == 0)
            {
                x *= x;
                x %= Mod;
                n /= 2;
            }
            else
            {
                pow *= x;
                pow %= Mod;
                n--;
            }
        }

        return pow;
    }

    public static ModInt GetInv(long f)
    {
        // フェルマーの小定理 a^(-1) = a^(mod-2)
        return new ModInt(Power(f, Mod - 2));
    }

    public ModInt GetInv()
    {
        return GetInv(Num);
    }

    public override string ToString()
    {
        return Num.ToString();
    }

    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Num += r.Num;
        if (l.Num >= Mod)
        {
            l.Num -= Mod;
        }
        return l;
    }

    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Num -= r.Num;
        if (l.Num < 0)
        {
            l.Num += Mod;
        }
        return l;
    }

    public static ModInt operator *(ModInt l, ModInt r)
    {
        return new ModInt(l.Num * r.Num % Mod);
    }

    public static implicit operator ModInt(long n)
    {
        n %= Mod;
        if (n < 0)
        {
            n += Mod;
        }
        return new ModInt(n);
    }
}

public class Solution
{
    static ModInt nCk(long n, long k)
    {
        var result = new ModInt(1);
        for (long i = n; i > n - k; i--)
        {
            result *= i;
        }
        for (long i = 2; i <= k; i++)
        {
            result *= ModInt.GetInv(i);
        }
        return result;
    }

    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = vals[0];
        var a = vals[1];
        var b = vals[2];

        // (2^n - 1) - nCa - nCb
        var result = ModInt.Power(2, n) - 1 - nCk(n, a) - nCk(n, b);
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 13396
def partition(A, p, r):
    x = A[r] # last item
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i + 1

n = int(input())
A = [i for i in map(int,input().split())]

x = partition(A,0,n-1)
ans = []

for i in range(n):
    if i == x:
        ans.append('[' + str(A[i]) + ']')
    else:
        ans.append(str(A[i]))
print(' '.join(ans))


Measured memory_bytes: 16596
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N, n;
    string S, s1, s2;
    bool ok;

    cin >> N >> S;

    if(N%2==0) {
        s1 = S.substr(0,N/2);
        s2 = S.substr(N/2, N-1);
        if(s1==s2) {
            ok = true;
        } else {
            ok = false;
        }
    } else {
        ok = false;
    }
    
    if(ok) {cout << "Yes" << endl;}
    else {cout << "No" << endl;}

    return 0;
    
}

Measured memory_bytes: 256
#include<stdio.h>
static const int N = 101;

int main(){
  int M[N][N];
  int n, u, k, v; 
  int i, j;

  scanf("%d", &n); 

  for ( i = 1; i <=n; i++ ){ //init M
    for ( j = 1; j <=n; j++ ) M[i][j] = 0;
  }
  
  for ( i = 1; i <= n; i++ ){
    scanf("%d %d", &u, &k);
    //u--;
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      //v--;
      M[u][v] = 1;  //  adjacency  =1
    }
  }
  
  for ( i = 1; i <= n; i++ ){   // print result
    for ( j = 1; j <=n; j++ ){
      if ( j>1 ) printf(" ");
      printf("%d", M[i][j]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2048
n,c = gets.chomp.split(" ").map{ |item| item.to_i}
list = []
100000.times do |st|
  list[st] = []
  c.times do |cc|
    list[st][cc] = 0
  end
end
n.times do |nn|
  s,t,cc = gets.chomp.split(" ").map{ |it| it.to_i}
  s.upto(t) do |st|
    list[st-1][cc-1] = 1
  end
end
size = 1
list.each do |one|
  nsize = one.count(1)
  size = nsize if nsize > size
end
print "#{size}\n"

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

vector<bool> seen;  // 訪問済みの点
ll ans;
ll N, M;

// BFSのための再帰関数
void dfs(const Graph &G, int v, int counter) {
    if(counter == N-1){
        ans++;
    }
    else{
        for (auto next_v : G[v]) { 
            if (seen[next_v]) continue;
            seen[v] = true;
            dfs(G, next_v, counter+1); // 再帰的に値を追加していく
            seen[v] = false;
        }
    }
}

int main()
{
    cout << fixed << setprecision(15);
    cin >> N >> M;

    // グラフ
    Graph G(N);
    seen.assign(N, false);

    REP(i, M){
        ll a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    ans = 0;

    // 幅優先探索でカウンターを加算
    dfs(G, 0, 0);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;

int main()
{
    int trash;
    int n;
    trash = scanf("%d", &n);

    if (n == 2)
    {
        int b;
        trash = scanf("%d", &b);
        printf("%d\n", 2 * b);
        return 0;
    }

    int b[n - 1];
    int v = 0;
    trash = scanf("%d", &b[0]);
    v += b[0];
    for (int i = 1; i < n - 1; i++)
    {
        trash = scanf("%d", &b[i]);
        v += min(b[i], b[i - 1]);
    }

    v += b[n - 2];

    printf("%d\n", v);
    return 0;
}

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

int main(){
	long long int x,cnt;
	cin>>x;
	long long int y = x/500;
	if(y>0){
		cnt = y*1000;
		long long int z = x%500;
		long long int rem = z/5;
		cnt+= rem*5;
		cout<<cnt;
	}
	else{
		if(x/5 == 0)
			cout<<"0";
		else{
			cnt  = (x/5)*5;
			cout<<cnt;
		}
	}
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(n: int, p: "List[int]"):
    ans = 0
    for i in range(1,n-1):
        if (p[i-1] > p[i]) ^ (p[i] < p[i+1]):
            ans +=1
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(n)]  # type: "List[int]"
    solve(n, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

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

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	int N, M; cin >> N >> M;
	ll unit = M * 1900 + (N - M) * 100;
	ll times = pow(2, M);
	cout << unit * times << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
 
using namespace std;
 
typedef pair<int,int>P;
 
const int MAX_N = 2005;
 
vector<int> X,Y,X1,Y1,X2,Y2;
int flag[MAX_N*2][MAX_N*2];
int n;
 
int main()
{
    int p,q,r,s;
    scanf("%d",&n);
    rep(i,n){
        scanf("%d%d%d%d",&p,&q,&r,&s);
        X.push_back(p),X.push_back(r);
        Y.push_back(q),Y.push_back(s);
        X1.push_back(p),X2.push_back(r);
        Y1.push_back(q),Y2.push_back(s);
    }
    sort(X.begin(),X.end());
    sort(Y.begin(),Y.end());
    X.erase(unique(X.begin(),X.end()),X.end());
    Y.erase(unique(Y.begin(),Y.end()),Y.end());
    rep(i,n){
        X1[i] = lower_bound(X.begin(),X.end(),X1[i]) - X.begin();
        Y1[i] = lower_bound(Y.begin(),Y.end(),Y1[i]) - Y.begin();
        X2[i] = lower_bound(X.begin(),X.end(),X2[i]) - X.begin();
        Y2[i] = lower_bound(Y.begin(),Y.end(),Y2[i]) - Y.begin();
        flag[X2[i]][Y2[i]]++,flag[X1[i]][Y2[i]]--;
        flag[X2[i]][Y1[i]]--,flag[X1[i]][Y1[i]]++;
    }
    rep(i,4005){
    	rep(j,4005){
    		flag[i+1][j] += flag[i][j];
    	}
    }
    rep(i,4005){
    	rep(j,4005){
    		flag[i][j+1] += flag[i][j];
    	}
    }
    ll ans = 0;
    rep(i,Y.size()-1){
        rep(j,X.size()-1){
            if(flag[j][i]>0){
                ans += (ll)(X[j+1]-X[j])*(Y[i+1]-Y[i]);
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 66084
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
bool isover(int);
bool isover(int,int);
int main() {
	int n; string ans; bool is_str_use;
	string str, str1; int nexta; int memo, age;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		age = 0; ans = ""; is_str_use = false;
		cin >> str >> str1;
		if (isover(str.size(), str1.size())) {
			cout << "overflow" << endl;
			continue;
		}
		for (int i = 0; i < str.size() / 2; ++i) {
			swap(str[i], str[str.size() - 1 - i]);

		}
		for (int i = 0; i < str1.size() / 2; ++i) {
			swap(str1[i], str1[str1.size() - 1 - i]);
		}
		if (str.size() < str1.size()) {
			is_str_use = true;
		}
		for (int i = 0; i < min(str.size(), str1.size()); ++i) {
			memo = (str[i] - '0') + (str1[i] - '0') + age;
			if (memo > 9) {
				age = memo / 10;
				memo -= (memo / 10) * 10;
			}
			else {
				age = 0;
			}
			ans += memo + '0';
		}
		if (str.size() == str1.size()&&age!=0) {
			ans += age + '0';
			age = 0;
		}
		if (isover(ans.size())) {
			cout << "overflow" << endl;
			continue;
		}
		if (is_str_use) {
			swap(str, str1);

		}
		for (int i = min(str.size(), str1.size()); i < str.size(); ++i) {
			memo = (str[i] - '0') + age;
			if (memo > 9) {
				age = memo / 10;
				memo -= (memo / 10) * 10;
			}
			else {
				age = 0;
			}
			ans += memo + '0';
		}
		if (age != 0)ans += age+'0';
		if (isover(ans.size())) {
			cout << "overflow" << endl;
			continue;
		}
		for (int i = 0; i < ans.size() / 2; ++i) {
			swap(ans[i], ans[ans.size() - 1 - i]);
		}
		cout << ans << endl;
	}
	return 0;
}
bool isover(int a) {
	if (a > 80) {
		return true;
	}
	return false;
}
bool isover(int a, int b) {
	if (a > 80 || b > 80) {
		return true;
	}
	return false;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define MEM 100001
#define sanic ios_base::sync_with_stdio(0)
using namespace std;
typedef long long ll;
const ll INF = 1e9+9;
ll a,b;
int main() {
    cin >> a >> b;
    a--;
    b--;
    cout << a*(a+1)/2 + b*(b+1)/2;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    
    String s = sc.nextLine();
    
    if(s.equals("SSS")){
      System.out.println(0);
    }else if(s.equals("SSR") || s.equals("SRS") || s.equals("RSS") || s.equals("RSR")){
      System.out.println(1);
    }else if(s.equals("RRR")){
      System.out.println(3);
    }else{
      System.out.println(2);
    }
    
    return;

  }
}

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

int main(){
	
	int a,b,c;
	cin>>a>>b>>c;
	int preva=a;
	int prevb=b;
	int prevc=c;
	a=prevc;
	b=preva;
	c=prevb;
	cout<<a<<" "<<b<<" "<<c<<endl;
	
}

Measured memory_bytes: 3588
//2018年  3月 25日 日曜日 22:54:18 JST
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i + 1];
	ll res = 0;
	rep(i, 1, N + 2) {
		res += abs(A[i] - A[i - 1]);
	}
	rep(i, 1, N + 1) {
		int r = max(A[i - 1], A[i + 1]);
		int l = min(A[i - 1], A[i + 1]);
		int v = A[i];
		if(l <= v && v <= r) {
			cout << res << "\n";
		}
		else {
			 cout << res +  (r - l) - (abs(v - l) + abs(v - r)) << "\n";
		}
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 1664
program araiguma
implicit none
integer :: h,n,Dsum,i
integer,allocatable :: a(:)
Dsum = 0
read(*,*)h,n
allocate(a(n))
read(*,*)a(:)
do i = 1,n
    Dsum = Dsum + a(i)
end do
if (Dsum .ge. h) then
    write(*,*)'Yes'
else
    write(*,*)'No'
end if

end program araiguma

Measured memory_bytes: 1152
// ProblemURL : https://atcoder.jp/contests/abc044/tasks/arc060_a
// ---------------------------------------------
package main

import "fmt"

const inf = 1 << 60

func main() {
	var n, a int
	fmt.Scan(&n, &a)
	xs := make([]int, n+1)
	xs[0] = -inf
	for i := 1; i <= n; i++ {
		fmt.Scan(&xs[i])
	}

	dp := [51][51][2501]int{}
	dp[0][0][0] = 1
	for i := 1; i <= n; i++ {
		for j := 0; j <= n; j++ {
			for k := 0; k <= 2500; k++ {
				dp[i][j][k] += dp[i-1][j][k]
				if j-1 >= 0 && k-xs[i] >= 0 {
					dp[i][j][k] += dp[i-1][j-1][k-xs[i]]
				}
			}
		}
	}

	ans := 0
	for j := 1; j <= n; j++ {
		ans += dp[n][j][a*j]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 52992
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 998244353
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=60+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}/*
struct Edge{
	int nxt,v;
//	int w;
//	int id;
}e[N<<1];
void add(int u,int v){
	e[++tot].v=v,e[tot].nxt=head[u],head[u]=tot;
	e[++tot].v=u,e[tot].nxt=head[v],head[v]=tot;
}*/
ll n,ans,t[N][N];
#define lowbit(x) x&(-x)
void add(int k,int x){
	t[k][x]++;
}
ll ask(int K,int x){
//	cout<<K<<" "<<x<<endl; 
	ll ans=0;
	for(int k=K;k<N;k++){
		for(int i=x;i<N;i++){
//			bug(i);
			ans+=t[k][i];
		}
//		ans+=t[k][0];
//		bug(k);
	}
	return ans;
}
char s[N];
int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	n=read();
	double x;
	for(int i=1;i<=n;i++) {
		cin>>s+1;
		ll y=0;
		int m=strlen(s+1),flg=0,flg1=0;
		for(int i=1;i<=m;i++){
			if(isdigit(s[i])) {
				y=y*10LL+s[i]-'0';
				if(flg) flg1++; 
			}	
			else flg=1;
		}
		for(int i=flg1;i<9;i++) y*=10;
//		ll y=x*dd;
		int t1=0,t2=0;
//		bug(y);
		while(y%2==0) y/=2,++t1;
		while(y%5==0) y/=5,++t2;
//		bug(y);
		ans+=ask(max(0,18-t1-t2+t2),max(0,18-t1-t2+t1));
//		bug(ans);
		add(t1,t2);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define MOD (ll)1e15
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<int, int> pr;
typedef pair<pair<int, int>, int> tup;

inline void solve()
{
	int n, k;
	int r, p, s;
	cin >> n >> k;
	cin >> r >> s >> p;
	string t;
	cin >> t;

	vector<vector<int>> dp(n, vector<int>(3, 0));

	fore(i, 0, k)
	{
		if (t[i] == 's')
			dp[i][0] += r;
		else if (t[i] == 'p')
			dp[i][1] += s;
		else if (t[i] == 'r')
			dp[i][2] += p;
 	}

	fore(i, k, n)
	{
		fore(j, 0, 3)
		{
			int plus = 0;
			if (t[i] == 's' && j == 0)
				plus += r;
			else if (t[i] == 'p' && j == 1)
				plus += s;
			else if (t[i] == 'r' && j == 2)
				plus += p;

			fore(h, 0, 3)
			{
				if (j != h)
					dp[i][j] = max(dp[i][j], dp[i - k][h] + plus);
			}
		}
	}
	ll res = 0;
	fr(i, n, n - k)
	{
		res += max(dp[i][0], max(dp[i][1], dp[i][2]));
	}

	cout << res;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 5840
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int N=605;
const int MOD=1e9+7;
int add (int x,int y)   {x=x+y;return x>=MOD?x-MOD:x;}
int mul (int x,int y)   {return (LL)x*y%MOD;}
int dec (int x,int y)   {x=x-y;return x<0?x+MOD:x;}
int Pow (int x,int y)
{
	if (y==1) return x;
	int lalal=Pow(x,y>>1);
	lalal=mul(lalal,lalal);
	if (y&1) lalal=mul(lalal,x);
	return lalal;
}
bool in[N];
int n;
int a[N];
int cnt=0;
int f[N][N][N];
int g[N],num;
bool vis[N];
int nn;
bool cmp (int x,int y)	{return x>y;}
int main()
{
	memset(in,false,sizeof(in));
	memset(vis,false,sizeof(vis));
	scanf("%d",&n);n<<=1;nn=n;
	for (int u=1;u<=n;u++)	scanf("%d",&a[u]);
	int cnt=0;
	for (int u=1;u<=n;u+=2)
	{
		if (a[u]==-1&&a[u+1]==-1) cnt++;
		if (a[u]>0&&a[u+1]>0) vis[a[u]]=true,vis[a[u+1]]=true;
		if (a[u]>0) in[a[u]]=true;
		if (a[u+1]>0) in[a[u+1]]=true;
	}
	for (int u=n;u>=1;u--) if (!vis[u]) g[++num]=u;
//	for (int u=1;u<=num;u++) printf("%d ",g[u]);printf("\n");
	f[0][0][0]=1;
	for (int u=1;u<=num;u++)
	for (int i=0;i<=min(nn,num);i++)
	for (int j=0;j<=min(nn,num);j++)
	if (f[u-1][i][j])
	{
		//printf("%d %d %d %d\n",u,i,j,f[u-1][i][j]);
		if (in[g[u]])//如果在集合里面 
		{
			f[u][i][j+1]=add(f[u][i][j+1],f[u-1][i][j]);
			if (i) f[u][i-1][j]=add(f[u][i-1][j],f[u-1][i][j]);
		}
		else
		{
			f[u][i+1][j]=add(f[u][i+1][j],f[u-1][i][j]);
			if (i) f[u][i-1][j]=add(f[u][i-1][j],f[u-1][i][j]);
			if (j) f[u][i][j-1]=add(f[u][i][j-1],mul(f[u-1][i][j],j));
		}
	}
	int ans=f[num][0][0];
	for (int u=1;u<=cnt;u++) ans=mul(ans,u);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 858496
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<typeof((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


int main() {
  int X, t;
  cin >> X >> t;
  cout << max(0, X - t) << endl;
  return 0;
}

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

def f(a: int, b:int) -> int:
    return max(len(list(str(a))), len(list(str(b))))

ans = float("inf")
for i in range(1, int(n**0.5)+1):
    if n%i == 0:
        ans = min(ans, f(i, n//i))

print(ans)


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

struct Interval {
  int start, slutt;
};
bool operator<(Interval a, Interval b) {
  return a.start < b.start;
}

Interval input[1000000];

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int h,n,ans;
  int a;
  cin >> h>>n;
  int yn=0; 
  for (int j=0;j<n;j++){
    cin>>a;
    h=h-a;
    if(h<=0){
      yn=1;
      break;
    }
  }
  if(yn==0){
    cout<<"No"<<endl;	  
  }else{
    cout<<"Yes"<<endl;	  
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int V, E, r;
    cin >> V >> E >> r;
    vector<vector<P>> edge(V);
    REP(i, E) {
        int s, t, d;
        cin >> s >> t >> d;
        edge[s].emplace_back(d, t);
    }
    vector<int> cost(V, INT_MAX);
    cost[r] = 0;
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.emplace(0, r);
    while (!pq.empty()) {
        int c, i;
        tie(c, i) = pq.top();
        pq.pop();
        if (c > cost[i]) continue;
        for (auto &p : edge[i]) {
            int d, j;
            tie(d, j) = p;
            if (c + d < cost[j]) {
                cost[j] = c + d;
                pq.emplace(c + d, j);
            }
        }
    }
    REP(i, V) {
        if (cost[i] == INT_MAX) {
            cout << "INF" << endl;
        } else {
            cout << cost[i] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 12912
function Main (input) {
  input = input.split("\n").map(inp1 => parseInt(inp1, 10));
  if (input.every(inp => inp != 1)) console.log(1);
  if (input.every(inp => inp != 2)) console.log(2);
  if (input.every(inp => inp != 3)) console.log(3);
}

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

Measured memory_bytes: 22080
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

// pascal's triangle // C[n][k] -> nCk //　O(n^2)
const int MAX_N = 10000;
ll C[MAX_N][MAX_N];
void comb_table(int n){
  REP(i,n+1){
    REP(j,i+1){
      if(j==0 || j==i){
        C[i][j]=1LL;
      }else{
        C[i][j]=(C[i-1][j-1]+C[i-1][j]);
      }
    }
  }
}


int main(){
  ll n, a, b;
  cin >> n >>a >> b;
  ll v[n];
  REP(i,n)cin >> v[i];

  sort(v, v+n);

  double ave = 0;

  REP(i,a){
    ave += v[n-1-i];
  }
  ave /= double(a);

  ll x = v[n-a];

  comb_table(51);

  if(ave == x){
    int xnum = upper_bound(v, v+n, x) - lower_bound(v, v+n, x);
    ll ans = 0;
    for(int i = a; i <= min(int(b),xnum); i++){
      ans += C[xnum][i];
    }
    cout.precision(20);
    cout << fixed <<  ave << endl;
    cout << ans << endl;
  }else{
    int xnum = upper_bound(v, v+n, x) - lower_bound(v, v+n, x);
    int xina = (upper_bound(v, v+n, x) - v) - (n - a);
    cout.precision(20);
    cout << fixed <<  ave << endl;
    cout << C[xnum][xina] << endl;
  }

  return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 22;
const int maxtot = 2100000;
const int mo = 1e9 + 7;

int n, d[maxn], f[maxn][maxtot];

int countOnes(int x) {
    int res = 0;
    while (x > 0) {
        res += (x & 1);
        x >>= 1;
    }

    return res;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < n; ++j) {
            int x;
            cin >> x;
            d[i] = (d[i] << 1) | x;
        }
    }

    int tot = (1 << n);
    f[0][0] = 1;

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j < tot; ++j) {
            if (countOnes(j) == i)
                for (int k = 0; k < n; ++k)
                    if ((j & (1 << k)) && (d[i] & (1 << k)))
                        f[i][j] = (f[i][j] + f[i-1][j - (1<<k)]) % mo;
        }
    }

    cout << f[n][tot-1] << endl;
	return 0;
}

Measured memory_bytes: 162048
n = int(input())
list_score = list(map(int, input().split()))
ans = "Yes"
max_value = 0
for i in range(n):
    if list_score[i] > max_value:
        max_value = list_score[i]
    if max_value - list_score[i] > 1:
        ans = "No"
        break

print(ans)

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

int findSumOfDigits(int n) {
  int sum=0;
  while(n>0) sum+=n%10, n/=10;
  return sum;
}

int main() {
  int N;
  cin >> N;
  int min=100000000;
  for(int i=1; i<=N-1; i++) {
    int num=findSumOfDigits(i)+findSumOfDigits(N-i);
    if(num<min) min=num;
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ()
{
  int A,B,C,D,Right,Left;
  cin >> A >> B >> C >> D;
  Left = (A + B);
  Right = (C + D);
  if ( Left > Right )
  {cout << "Left" << endl;}
  else if ( Left == Right )
  {cout << "Balanced" << endl;}
  else
  {cout << "Right" << endl;}
  return 0;
}

Measured memory_bytes: 256
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))

left = math.ceil(a.index(min(a)) / (k - 1))
surplus = (k-(a.index(min(a)) % (k - 1))) % k + 1
right = math.ceil((len(a)-a.index(min(a))-surplus)/(k-1))
print(left+right)


Measured memory_bytes: 20268
#include<bits/stdc++.h>
using namespace std;
long long H = 2;
long long A[] = { 1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215,33554431,67108863,134217727,268435455,536870911,1073741823,2147483647,4294967295,8589934591,17179869183,34359738367,68719476735,137438953471,274877906943,549755813887,1099511627775, };
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> H;
	cout << *lower_bound(A, A + 40, H) << endl;
	return 0;
}

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

int main()
{
  int X;
  
  cin >> X;
  
  if (X >= 400 && X <= 599) cout << 8 << endl;
  else if (X >= 600 && X <= 799) cout << 7 << endl;
  else if (X >= 800 && X <= 999) cout << 6 << endl;
  else if (X >= 1000 && X <= 1199) cout << 5 << endl;
  else if (X >= 1200 && X <= 1399) cout << 4 << endl;
  else if (X >= 1400 && X <= 1599) cout << 3 << endl;
  else if (X >= 1600 && X <= 1799) cout << 2 << endl;
  else if (X >= 1800 && X <= 1999) cout << 1 << endl;
  else {}
  
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
int main() {
	int H[100], W[100];
	int i= 0, j, k, l;
	
	while (1) {
		std::cin >> H[i] >> W[i];
		if (H[i] == 0 && W[i] == 0) break;
		i++;
	}

	for (l = 0; l < i; l++) {
		for (k = 0; k < H[l]; k++) {
			for (j = 0; j < W[l]; j++) {
				std::cout << "#";
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}

	return 0;
}

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

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

  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  while(q--) {
    ll x;
    cin >> x;

    int right = 0;
    ll sum = 0;
    ll res = 0;
    for (int left = 0; left < n; ++left) {
      while(right < n && (sum + a[right] <= x)) {
        sum += a[right];
        ++right;
      }
      res += (right - left);
      if(left == right) right++;
      else sum -= a[left];
    }
    cout << res << '\n';
  }
  return 0;
}


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

using namespace std;

template< class t>
long long int gcd( t g,t h )
{
    return ( h==0 ? g : gcd(h,g%h) );
}

int main() 
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ;
    
    long long int x,n,i,j,ans,neg=0,a[100005]={0},b[100005]={0},c[100005]={0},z[100005],mx=0;
    
    cin>>n;
    
    for(i=0;i<n;i++)
    {
        cin>>z[i];
        b[z[i]]++;
    }
    
    for(i=0;i<n;i++)
    {
        if(z[i]==0)
        {
            neg++;
        }
        else
        {
            a[z[i]-1]++;
        }
    }
    
    for(i=0;i<n;i++)
    {
        
            c[z[i]+1]++;
    }
    
    mx=neg;
    
    for(i=0;i<100005;i++)
    {
        if(mx<=(c[i]+a[i]+b[i]))
        {
            mx = c[i]+a[i]+b[i];
        }
    }
    
    cout<<mx;
    
    return 0;
}


Measured memory_bytes: 3328
/**
 *     author: nayakashutosh9
 *     college: National Institute of Technology, Rourkela
 *	   "Winners Never Quit and Quitters Never Win".
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;

/*******************************************************************/



int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	// int t = 1, z = 1;
	// cin >> t;
	// cin.ignore();
	// while (t--) {

	// }
	int n; cin >> n;
	cout << (n + n * n + n * n * n) << endl;

	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep2(i, n) for(ll i = 2; i <=(ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll powmod(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 4010;
const int MOD = 1e9+7;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll s;
    cin >> s;
    int k = floor(s/3.0);
    ll ans = 0;
    COMinit();
    for(int i = k; i >= 1; i--){
        int b = s - 3*i;
        ans += COM(i+b-1, i-1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> vect(n);
  for(int i=0;i<n;i++) cin>>vect[i];
  sort(vect.begin(),vect.end());
  vector<bool> dp(k+1);
  int mn=vect[0];
  int flag;
  for(flag=0;flag<mn;flag++) dp[flag]=false;
  for(int i=flag;i<=k;i++){
    for(int j=0;vect[j]<=i&&j<n;j++){
      if(dp[i-vect[j]]==false){
      	dp[i]=true;
      	break;
      }
      else dp[i]=false;
    }
  }
  if(dp[k]) cout<<"First";
  else cout<<"Second";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>

using namespace std;

// "A"

typedef map<string, long long int> Back3;
typedef map<int, Back3> Memo;
Memo result_memo;
string given = "AGTC";
long long int mod = 1e9 + 7;

int ok(string str)
{
    if (str.find("AGC") != string::npos)
    {
        return false;
    }
    for (int i = 0; i < 3; i++)
    {
        string t = str;
        char tmp = t[i];
        t[i] = t[i + 1];
        t[i + 1] = tmp;
        if (t.find("AGC") != string::npos)
        {
            return false;
        }
    }
    return true;
}

long long int memoRet(int cur, string back3, int N)
{
    if (result_memo[cur].find(back3) != result_memo[cur].end())
    {
        return result_memo[cur][back3];
    }
    if (cur == N)
    {
        return 1;
    }

    long long int ret = 0;

    for (int i = 0; i < 4; i++)
    {
        string str = back3 + given[i];
        if (ok(str))
        {
            ret = ret + memoRet(cur + 1, str.substr(1), N);
        }
    }
    result_memo[cur][back3] = ret % mod;
    return ret % mod;
}

int main()
{
    int N;
    cin >> N;
    long long int ret = memoRet(0, "TTT", N);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 768
character(4) :: s
read *,s
if ((s(1:1) == s(2:2) .and. s(1:1) /= s(3:3) .and. s(3:3) == s(4:4)) .or.&
    (s(1:1) /= s(2:2) .and. s(1:1) == s(3:3) .and. s(2:2) == s(4:4)) .or.&
    (s(1:1) == s(4:4) .and. s(1:1) /= s(2:2) .and. s(2:2) == s(3:3))) then
print '(a)','Yes'
else
print '(a)','No'
endif
end

Measured memory_bytes: 640
#include<stdio.h>
int main(void) {
	int a, b, N, s, f, A=0, B=0;
	scanf("%d %d", &a, &b);
	scanf("%d", &N);
	while (N > B) {
		B++;
		scanf("%d %d", &s, &f);
		if (A == 0) {
			if (s <= a && f <= a) {
				A = 0;
			}
			else if (b <= s && b <= f) {
				A = 0;
			}
			else A = 1;
		}


	}
	printf("%d\n", A);
	return 0;
}


Measured memory_bytes: 2136
import sys
input = sys.stdin.readline

n = int(input())
a = sorted(map(int, input().split()))

for i in range(a[1]):
  flag = 2
  for j in range(n):
    if a[j] % (a[1]-i) != 0:
      flag = flag - 1
    if flag == 0:
      break
  else:
    print(a[1]-i)
    break
else:
  print(1)

Measured memory_bytes: 59632
//package _0138;



import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	class data implements Comparable<data>{

		int no;

		double time;

		data(int no,double time){

			this.no = no;

			this.time = time;

		}

		

		public int compareTo(data o) {

			return (this.time - o.time)>0?1:-1;

		}

		

		public String toString() {

			return no+" "+time;

		}

	}

	void run(){

		data[][] in = new data[3][8];

		for(int i = 0 ; i < 24;i++){

			in[i/8][i%8] = new data(sc.nextInt(),sc.nextDouble());

		}

		for(int i = 0; i < 3 ;i ++){

			Arrays.sort(in[i]);

		}

		for(int i = 0; i < 3; i++){

			System.out.println(in[i][0]);

			System.out.println(in[i][1]);

		}

		data[] cand =  new data[6];

		int z = 0;

		for(int i =0 ; i<3;i++){

			for(int j = 2; j<=3; j++){

				cand[z++] = in[i][j];

			}

		}

		Arrays.sort(cand);

		System.out.println(cand[0]);

		System.out.println(cand[1]);

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int A,B; cin >> A >> B;
    if(B%A == 0){
        cout << A+B << endl;
    }else{
        cout << B-A << endl;
    }
    return 0;
}

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

int expr(string &S, int &p, int a, int b, int c, int d) {
  char next = S[p++];

  if (next == '0') return 0;
  if (next == '1') return 1;
  if (next == 'a') return a;
  if (next == 'b') return b;
  if (next == 'c') return c;
  if (next == 'd') return d;
  if (next == '-') {
    return !expr(S, p, a, b, c, d);
  }
  if (next == '(') {
    int lhs = expr(S, p, a, b, c, d);
    char op = S[p++];
    int rhs = expr(S, p, a, b, c, d);
    S[p++];
    if (op == '^') {
      return lhs ^ rhs;
    }
    if (op == '*') {
      return lhs & rhs;
    }
  }

  assert(false);
}

int parse(string &S) {
  int x = 0;
  REP(a, 0, 2) REP(b, 0, 2) REP(c, 0, 2) REP(d, 0, 2) {
    int p = 0, bit = expr(S, p, a, b, c, d);
    x |= bit << (a * 8 + b * 4 + c * 2 + d);
  }
  return x;
}

vector<int> solve() {
  vector<vector<bool>> dp(17, vector<bool>(1 << 16));

  dp[1][0b0000000000000000] = true;
  dp[1][0b1111111111111111] = true;
  dp[1][0b1111111100000000] = true;
  dp[1][0b1111000011110000] = true;
  dp[1][0b1100110011001100] = true;
  dp[1][0b1010101010101010] = true;

  REP(i, 2, 17) {
    REP(s, 0, 1 << 16) if (dp[i - 1][s]) {
      dp[i][~s & ((1 << 16) - 1)] = true;
    }
    for (int k = 1; i - k - 3 >= 1; k++) {
      REP(s, 0, 1 << 16) if (dp[k][s]) {
        REP(t, 0, 1 << 16) if (dp[i - k - 3][t]) {
          dp[i][s ^ t] = true;
          dp[i][s & t] = true;
        }
      }
    }
  }

  vector<int> ans(1 << 16);
  REP(s, 0, 1 << 16) REP(i, 1, 17) if (dp[i][s]) {
    ans[s] = i;
    break;
  }
  return ans;
}

int main(void) {
  vector<int> ans = solve();

  for (string S; cin >> S, S != ".";) {
    cout << ans[parse(S)] << endl;
  }
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int n; cin >> n;
  int k; cin >> k;
  vi a(n); REP(i, n) cin >> a[i];

  while(k > 0) {
    k--;
    bool ed = true;
    REP(i, n) {
      ed &= a[i] == n;
    }
    if(ed) break;

    vi imos(n);
    REP(i, n) {
      imos[max(0, i-a[i])]++;
      if(i+a[i]+1 < n) imos[i+a[i]+1]--;
      //cout << imos << endl;
    }
    FOR(i, 1, n) {
      imos[i] += imos[i-1];
    }

    a = imos;
  }

  REP(i, n) {
    cout << a[i];
    if(i == n-1) cout << endl;
    else cout << " ";
  }

}








Measured memory_bytes: 4900
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<cstring>
#include<string>
using namespace std;
int main(){
    int n=0,t=0,h=0;
    string T,H;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> T >> H;
        if(T == H){
            t++;
            h++;
        }
        else if(T > H){
            t += 3;
        }
        else if(T < H){
            h += 3;
        }
    }
    cout << t << " " << h <<endl;
}


Measured memory_bytes: 3136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<Integer> check=new ArrayList<Integer>();
		//array = new int[h+1][w+1];
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//Collections.reverse(list);
		int n = sc.nextInt();
		for(int i=1;10>i;i++) {
			for(int j=1;10>j;j++) {
				if(n==i*j) {
					System.out.println("Yes");
					System.exit(0);
				}
			}
		}
		System.out.println("No");
	}

}


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

int main(){
	int N;
	cin >> N;
	vector<int> card(N);
	for(int i = 0; i < N; i++)
		cin >> card.at(i);

	sort(card.begin(), card.end());
	reverse(card.begin(), card.end());

	int point = 0;
	for(int i = 0; i < N; i++)
		point = (i%2) ? point - card.at(i) : point + card.at(i);
	cout << point << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>

typedef long long ll;

using namespace std;

const ll MOD = 1000000007LL;

int main(void) {
    int N, M;
    cin >> N >> M;
    // vector<int> a(M, 0);
    // for (int i = 0; i < M; i++) { cin >> a[i]; }
    vector<ll> DP(N + 1, 0);
    DP[0] = 1;
    for (int i = 0; i < M; i++) {
        int ai;
        cin >> ai;
        DP[ai] = -1;
    }
    if (DP[1] == 0)
        DP[1] = 1;

    for (int i = 2; i <= N; i++) {
        if (DP[i] < 0)
            continue;
        ll ai2 = max(0LL, DP[i - 2]);
        ll ai1 = max(0LL, DP[i - 1]);
        DP[i] = (ai2 + ai1) % MOD;
    }

    // for (auto v : DP) { cout << v << " "; } cout << endl;
    // cout << (DP[N] & MOD) << endl;
    cout << DP[N] << endl;
}

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

void fnInput(int& rnMonster, int& rnFinCnt, vector<int>& rvnLifePnt)
{
  cin >> rnMonster >> rnFinCnt;
  rvnLifePnt.resize(rnMonster);

  for (int& rnLifePnt : rvnLifePnt)
    cin >> rnLifePnt;
}
  
llong fnGameOverCnt(int nFinCnt, vector<int>& rvnLifePnt)
{
  sort(begin(rvnLifePnt), end(rvnLifePnt), greater<int>());

  llong nGameOverCnt = 0;
  for (int n = nFinCnt; n < rvnLifePnt.size(); n++)
    nGameOverCnt += rvnLifePnt[n];

  return nGameOverCnt;
}
  
int main()
{
  int nMonstr, nFinCnt;
  vector<int> vnLifePnt;

  fnInput(nMonstr, nFinCnt, vnLifePnt);
  cout << fnGameOverCnt(nFinCnt, vnLifePnt) << endl;

  return 0;
}

Measured memory_bytes: 1024
n=int(input())
a=sorted(list(map(int,input().split())))[::-1]

i=0
find=0
ans=1
while i<len(a)-1:
  if a[i]==a[i+1]:
    find+=1
    ans*=a[i]
    i+=2
    if find==2:
      print(ans)
      break
  else:
    i+=1
else:
  print(0)

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> a(n);
    for(int i=0;i<n;i++)a[i]=0;
    for(int i=0;i<q;i++){
        int s;
        cin>>s;
        s--;;
        a[s]++;
    }
    for(auto i:a){
        if(i+k-q>0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

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

using namespace std;

int n,K;
long long ans;
int mod = 1e9 + 7;

int main(){
	scanf("%d%d",&n,&K);
	for(int i=K;i<=n+1;i++){
		long long mi = (long long)(i-1)*i/2LL;
		long long ma = (long long)(n-i+1 + n)*i/2LL;

		ans += ma-mi+1;
		ans %= mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int N; cin >> N;
  
  vector<int> L(10); int sum = 0;
  for(int i=0; i<N; i++){
    cin >> L[i]; sum += L[i];
  }
  sort(L.begin(), L.begin()+N, greater<int>());

  if(L[0] < sum-L[0]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;

int main() {
	int a, b, c; cin >> a >> b >> c;
	vector<int> v;
	
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);

	sort(v.begin(), v.end());

	if (v[0] + v[1] == v[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np

from itertools import combinations_with_replacement as CwR



n, m, q = map(int, input().split())
Lis = [[int(e) for e in input().split()] for _ in range(q)]

Tables = list(CwR(range(1,m+1),n))
Sum_cor = []
for Table in Tables:
    d_sum = 0
    for l in Lis:
        if Table[l[1]-1]-Table[l[0]-1] == l[2]:
            d_sum+=l[3]
    Sum_cor.append(d_sum)

print(max(Sum_cor))


Measured memory_bytes: 43020