akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cassert>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

// Mod int
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}

int n;
int x, y, z;

bool check(int j, int k) {
  if (k > z) return false;
  if (k != z) {
    int p = 1<<(z-k-1);
    if (!(j & p)) return false;
  }
  int q = 1<<(y+z-k-1);
  if (!(j&q)) return false;
  int r = 1<<(x+y+z-k-1);
  if (!(j&r)) return false;
  return true;
}

int shift(int j, int k, int mask) {
  int ret = j<<1;
  ret += 1;
  ret <<= (k-1);
  return ret&mask;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> n >> x >> y >> z;
  int s = 1<<16;
  int mask = s-1;
  vector<mint> dp1(s);
  vector<mint> dp2(s);
  dp1[0] = 1;
  for(int i=1; i<=n; i++) {
    rep(j, s) {
      if (dp1[j] == 0) continue;
      for(int k=1; k<=10; k++) {
        if (!check(j, k)) {
          dp2[shift(j, k, mask)] += dp1[j];
        }
      }
    }
    rep(j, s) {
      dp1[j] = dp2[j];
      dp2[j] = 0;
    }
  }

  mint ans = 0;
  rep(i, s) {
    ans += dp1[i];
  }
  mint all = 1;
  rep(i, n) {
    all *= 10;
  }
  cout << all-ans << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,a,b;
void solve()
{
    if(a+b>n+1||a*b<n)
    {
        printf("-1\n");
        return ;
    }
    while(n>0){
        ll x=min(a,n-b+1);
        for(ll i=n-x+1;i<=n;i++)
            printf("%d ",i);
        n-=x;
        b--;
    }
    printf("\n");
}
int main()
{
    scanf("%lld%lld%lld",&n,&a,&b);
    solve();
}

Measured memory_bytes: 2176
#include <stdio.h>

int main()
{
    int n, cnt = 0;
    scanf("%d", &n);
    int a[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i < n - 1; i++)
    {
        if (a[i] > a[i - 1] && a[i] < a[i + 1])
            cnt++;
        else if (a[i] < a[i - 1] && a[i] > a[i + 1])
            cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define int long long
const int MOD=1e9+7;
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 2e5 + 5;

int n, a[maxn];
map<int, int> cnt;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int ans = 0;
    for(auto x : cnt)
        ans += (x.second * (x.second - 1)) / 2;
    for(int i = 0; i < n; i++)
    {
        int cur = ans;
        cur -= (cnt[a[i]] * (cnt[a[i]] - 1)) / 2;
        cur += ((cnt[a[i]] - 2) * (cnt[a[i]] - 1)) / 2;
        cout << cur << "\n";
    }
    return 0;
}

Measured memory_bytes: 11136
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
signed main(){
    int h,w;cin>>h>>w;
    char gri[55][55];
    rep(i,0,h)rep(j,0,w)cin>>gri[i][j];
    int tate[4]={0,1,0,-1};
    int yoko[4]={1,0,-1,0};
    rep(i,0,h)rep(j,0,w){
        bool ch=false;
        if(gri[i][j]!='#')continue;
        rep(k,0,4){
            int g=i+tate[k];int l=j+yoko[k];
            if(0<=g&&g<h&&0<=l&&l<w&&gri[g][l]=='#')ch=true;
        }
        if(!ch){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
// SeeAlso: https://atcoder.jp/contests/abc059/tasks/abc059_a

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

string s1, s2, s3;

int main() {
    cin >> s1 >> s2 >> s3;
    auto l = locale::classic();
    cout << toupper(s1[0],l) << toupper(s2[0],l) << toupper(s3[0],l) << 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 A, B;
  cin >> A >> B;
  if(A <= 9 && B <= 9) cout << A * B << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int n;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
		n = scan.nextInt();
		if(n==0){
			break;
		}
		String mu = scan.nextLine();
		String[] word = new String[n];
		int mozi[] = new int[n];
		for(int i=0;i<n;++i){
			word[i]=scan.nextLine();
			mozi[i]=word[i].length();
		}
		int hit=0;
		for(int i=0;i<n;++i){
			int result = cut1(mozi,i);
			if(result!=-1&&result<n-3){
				result = cut2(mozi,result);
				if(result!=-1&&result<n-2){
					result = cut1(mozi,result);
					if(result!=-1&&result<n-1){
						result = cut2(mozi,result);
						if(result!=-1&&result<n){
							result = cut2(mozi,result);
							if(result!=-1){
								hit = i+1;
								break;
							}
						}
					}
				}
			}
		}
		System.out.println(hit);
		}
	}
	
	public static int cut1(int[] mozi, int num){
		int d=mozi[num];
		if(d==5){
			return num+1;
		}
		for(int i=num+1;i<n;++i){
			d+=mozi[i];
			if(d==5){
				return i+1;
			} else if(d>5){
				break;
			}
		}
		return -1;
	}
	public static int cut2(int[] mozi, int num){
		int d=mozi[num];
		if(d==7){
			return num+1;
		}
		for(int i=num+1;i<n;++i){
			d+=mozi[i];
			if(d==7){
				return i+1;
			} else if(d>7){
				break;
			}
		}
		return -1;
	}
}

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

int main(){
	int n;
	cin>>n;
	for (int i = 0; i<n; i++){
		int a;
		cin>>a;
		if (a%2!=0){
			continue;
		}
		if (!(a%3==0||a%5==0)){
			cout<<"DENIED"<<endl;
			return 0;
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <iterator>
#include <math.h>
#include <cstdlib>
#include <cmath>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
int main(){
  int N;
  cin >> N;
  char S[N];
  cin >> S;
  long unsigned int ans = 0;
  FOR(i,1,N){
    vector<char> first;
    FOR(j,0,i){
      first.push_back(S[j]);
    }
    vector<char> second;
    FOR(j,i,N){
      second.push_back(S[j]);
    }
    sort(first.begin(),first.end());
    first.erase(unique(first.begin(), first.end()), first.end());
    sort(second.begin(),second.end());
    second.erase(unique(second.begin(), second.end()), second.end());
    copy(second.begin(), second.end(), back_inserter(first));
    sort(first.begin(),first.end());
    int beflen = first.size();
    first.erase(unique(first.begin(), first.end()), first.end());
    ans = max(ans, beflen - first.size());
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<string.h>
#include<limits.h>
#define int long long
using namespace std;

int mincost[1000][1000];
signed main() {
	int a, b; scanf("%lld%lld", &a, &b);
	for (int c = 0; c < a; c++) {
		for (int d = 0; d < a; d++) {
			mincost[c][d] = LLONG_MAX;
		}
		mincost[c][c] = 0;
	}
	for (int c = 0; c < b; c++) {
		int d, e, f; scanf("%lld%lld%lld", &d, &e, &f);
		mincost[d - 1][e - 1] = -f;
	}
	for (int x = 0; x < a; x++) {
		for (int y = 0; y < a; y++) {
			for (int z = 0; z < a; z++) {
				if (mincost[y][x] != LLONG_MAX&& mincost[x][z] != LLONG_MAX) {
					mincost[y][z] = min(mincost[y][z], mincost[y][x] + mincost[x][z]);
				}
			}
		}
	}
	for (int i = 0; i < a; i++) {
		if (mincost[i][i] < 0 &&mincost[0][i]!=LLONG_MAX&& mincost[i][a - 1] != LLONG_MAX) {
			puts("inf");
			return 0;
		}
	}
	printf("%lld\n", -mincost[0][a - 1]);
}

Measured memory_bytes: 8192
#include<stdio.h>
int main ()
{
    int N,a,b,c,y,z ;
    scanf ("%d",&N) ;   
    a = N%10;
    y = N/10;
    b = y%10;
    z = y/10;
    c = z%10;
   
    if (a==7)
    {
         printf("Yes\n");
    }
    else if (b==7)
    {
        printf("Yes\n");
    }
    else if (c==7)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1644
#include <iostream>
#include <stack>
#include <cstring>
using namespace std;

int n;
string s;
string ans;
int main() {
  cin >> n >> s;

  stack<char> a;
  int f = 0;
 
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == '(') a.push(s[i]);
    else {
      if(a.empty()) f++;
      else a.pop();
    }
  }
  int l = a.size();

  for(int i = 0; i < f; i++) cout << '(';
  cout << s;
  for(int i = 0; i < l; i++) cout << ')';
  cout << endl;
}
     

 


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M,Q;
  cin>>N>>M>>Q;
  int a[Q],b[Q],c[Q],d[Q];
  REP(i,Q){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    a[i]--;b[i]--;
  }
  lint ans=0;
  stack<vector<int>> s;
  s.push(vector<int>());
  while(!s.empty()){
    auto v=s.top();
    s.pop();
    if(v.size()<N){
      FOR(i,v.empty()?1:*(v.end()-1),M+1){
        auto vc=v;
        vc.push_back(i);
        s.push(vc);
      }
    }else{
      // for(auto e:v){
      //   cerr<<e<<" ";
      // }
      // cerr<<endl;
      lint temp=0;
      REP(i,Q){
        if(v[b[i]]-v[a[i]]==c[i])temp+=d[i];
      }
      // cerr<<temp<<endl;
      ans=max(ans,temp);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int count = 0;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		while(true) {
			for(int i = 0; i < n; i++) {
				if(a[i] % 2 == 0) {
					a[i] = a[i]/2;
				}else {
					System.out.println(count);
					sc.close();
					return;
				}
			}
			count++;
		}
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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

Measured memory_bytes: 23380
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int S[200010], T[200010], X[200010];
pair<int, pair<int, int>> P[200010];
int D[200010];
int ans[200010];
map<int, int> mp;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    set<int> st;
    rep(i, N) {
        cin >> S[i] >> T[i] >> X[i];
        T[i]--;
        S[i] = max(0LL, S[i] - X[i]); 
        T[i] = max(0LL, T[i] - X[i]); 
        P[i].first = X[i];
        P[i].second = {S[i], T[i]};
    }
    sort(P, P + N);
    rep(i, 200010) ans[i] = INF;
    rep(i, Q) {
        cin >> D[i];
        st.insert(D[i]);
    }
    rep(i, Q) {
        auto it = st.lower_bound(P[i].second.first);
        //cout << *it << " " << P[i].second.first << " " << P[i].second.second << endl;
        while(it != st.end() && *it <= P[i].second.second) {
            //cout << "*" << *it << endl;
            auto mpit = mp.find(*it);
            if (mpit == mp.end()) {
                //cout << "test" << endl;
                mp[*it] = P[i].first;
                auto it2 = it;
                it2++;
                st.erase(it);
                it = it2;
            }
        }
    }
    rep(i, Q) {
        auto mpit = mp.find(D[i]);
        if (mpit == mp.end()) {
            cout << -1 << endl;
        } else {
            cout << mpit->second << endl;
        }
    }


    

    return 0;
}


Measured memory_bytes: 28544
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[10005],n,i,k,ans=0;
int main()
{
	cin>>n>>k;
	for(i=1;i<=n;i++)
	cin>>a[i];    
	sort(a+1,a+n+1);
	for(i=n-k+1;i<=n;i++)
	ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int x; cin >> x;

    if (x >= 30) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 3560
N = int(input())
*A, = map(int, input().split())

def dfs(l, r):

    if l==r:
        return A[l]
    mid = (l+r)//2
    ans = 1
    ans = ans * dfs(l, mid)
    ans = ans * dfs(mid+1, r)
    return ans

ans = dfs(0, len(A)-1)

if ans>10**18:
    print(-1)
    exit()
print(ans)

Measured memory_bytes: 21656
// g++ -std=gnu++1y -O2 xxx.cpp

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    ll N; cin>>N;
    map<ll, ll> m;

    ll A;
    for (int i=0;i<N;i++) {
        cin >> A;
        m[A]++;

        if (m[A] > 1) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 12800
<?php
fscanf(STDIN, "%d %d %d %d", $w, $h, $x, $y);
if(2*$x == $w && 2*$y == $h){
  $m = 1;
}else{
  $m = 0;
}
echo(($w*$h/2).' '.$m)
?>


Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

class UnionFind{
private:
    using uint = std::uint_fast64_t;
    std::vector<uint> par;
    std::vector<uint> sizes;

    uint find(uint x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }
public:
    UnionFind() = delete;
    UnionFind(uint size) : par(size), sizes(size, 1){
        for(uint i = 0; i < size; ++i) par[i] = i;
    }

    bool unite(uint x, uint y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        
        if(sizes[x] < sizes[y]) std::swap(x, y);
        if(sizes[x] == sizes[y] && x > y) std::swap(x, y);
        sizes[x] += sizes[y];
        sizes[y] = 0;
        par[y] = x;
        return true;
    }
    bool isSame(uint x, uint y ){ return find(par[x]) == find(par[y]);}
    uint getSize(uint x){return sizes[find(par[x])];}
}; 

int main(){
    int N, M, K;
    cin >> N >> M >> K;

    vector<vector<int>> dfri(N), block(N);
    vector<int> ndfri_block(N, 0);
    UnionFind fri(N);
    rep(i, M){
        int a, b; cin >> a >> b; a--, b--;
        fri.unite(a, b);
        dfri[a].push_back(b);
        dfri[b].push_back(a);
    }
    rep(i, K){
        int c, d; cin >> c >> d; c--, d--;
        block[c].push_back(d);
        block[d].push_back(c);
    }

    for(int i = 0; i < N ;i++){
        for(auto& b : block[i]){
            bool dfr = false;
            if(fri.isSame(i, b) == false) continue;
            for(auto& df : dfri[b]){
                if(df == i) dfr = true;
            }
            if(dfr == false) ndfri_block[i]++;
        }
    }

    for(int i = 0; i < N; i++){
        //cout << i << " : " << fri.getSize(i) - 1 << " " << dfri[i].size() << " " << ndfri_block[i] << endl;
        int ans = fri.getSize(i) - 1 - dfri[i].size() - ndfri_block[i];
        cout << max(ans, 0) << " \n"[i == N-1];
    }
}


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


int main(){

  int e1,e2,e3,e4;
  cin>>e1>>e2>>e3>>e4;

  if(e1 == e2 && e3 == e4 || e1 == e3 && e2 == e4 || e1 == e4 && e2 == e3) cout<<"yes"<<endl;
  else cout<<"no"<<endl;
  
 return 0;
}


Measured memory_bytes: 3120
from operator import itemgetter


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
XY.sort(key=itemgetter(1))
for i in range(N):
    XY[i][1] = i
XY.sort(key=itemgetter(0))

y_nor_list = [xy[1] for xy in XY]

sg_left = Bit(N)
sg_right = Bit(N)

left_lower = [0] * N
left_upper = [0] * N
right_lower = [0] * N
right_upper = [0] * N

for i in range(N):
    c = y_nor_list[i] + 1
    left_lower[i] = sg_left.sum(c)
    left_upper[i] = i - left_lower[i]
    sg_left.add(c, 1)

for i in range(N-1, -1, -1):
    c = y_nor_list[i] + 1
    right_lower[i] = sg_right.sum(c)
    right_upper[i] = N - 1 - i - right_lower[i]
    sg_right.add(c, 1)

# print(left_lower)
# print(left_upper)
# print(right_lower)
# print(right_upper)

LARGE = 998244353

pow2m1 = [0] * (N + 1)
for i in range(1, N + 1):
    pow2m1[i] = (2 * pow2m1[i - 1] + 1) % LARGE

res = 0
for i in range(N):
    r = pow2m1[N]
    r -= pow2m1[left_lower[i] + left_upper[i]]
    r -= pow2m1[right_lower[i] + right_upper[i]]
    r -= pow2m1[left_lower[i] + right_lower[i]]
    r -= pow2m1[left_upper[i] + right_upper[i]]
    r += pow2m1[left_lower[i]]
    r += pow2m1[left_upper[i]]
    r += pow2m1[right_lower[i]]
    r += pow2m1[right_upper[i]]
    res += r

print(res % LARGE)


Measured memory_bytes: 117592
import java.util.Scanner;

/**
 * ARC061C_Many_Formulas
 */
public class Main {
    private static Scanner sc;

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

        String S = sc.next();

        int length = S.length() - 1; // 文字列の間に"+"を入れるかどうか、文字列の間の数
        int tmp = 0;
        long answer = 0;
        for (int i = 0; i < (1 << length); i++) {
            // パターン1つ1つの繰り返し区切り場所をリセット
            tmp = 0;
            for (int j = 0; j < length; j++) {
                // 場所ごとの組み合わせで対応が異なる処理を入れる
                // 0ならなにもせず、1なら+を入れて区切り場所を移動
                if ((i >> j) % 2 == 1) {
                    // "+"を入れる場合
                    answer += Long.parseLong(S.substring(tmp, j + 1));
                    tmp = j + 1; // 区切りの位置を更新
                }
            }
            // 残りの文字列部分全てを計算する
            answer += Long.parseLong(S.substring(tmp));
        }

        System.out.println(answer);

        sc.close();
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
    ll N, D;
  	cin >> N >> D;
  	cout << (N-1) / (2*D+1) + 1;
    
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;

    if(a >= 13) {
        cout << b << endl;
    } else if(a <= 5) {
        cout << 0 << endl;
    } else {
        cout << b / 2 << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
numbers = [int(x) for x in input().split()]

negative_sign_count = len([x for x in numbers if x < 0])
abs_numbers = [abs(x) for x in numbers]
abs_numbers.sort()

# 負の数が偶数 or 0を含む場合はすべての符号を正に反転できる
if negative_sign_count % 2 == 0 or 0 in numbers:
  print(sum(abs_numbers))
# それ以外はひとつだけ正にできない数があるので、絶対値が一番小さい数を負にする
else:
  print(sum(abs_numbers[1:]) - abs_numbers[0])

Measured memory_bytes: 66320
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define endl "\n"
#define int long long
#define debug(x) cout << #x << " is " << x << endl;
using namespace std;
int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a % b);
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(2);
	int n, edges = 0, vertex = 0; cin >> n;
	vector <vector <int>> adj(n + 1);
	for (int i = 0; i < n - 1; ++i) {
		int u, v; cin >> u >> v;
		if (v < u) swap(u, v);
		edges += u * (n - v + 1);
	}
	for (int i = 1; i <= n; ++i){
		vertex += i * (n - i + 1);
	}
	cout << vertex - edges << endl;
}

Measured memory_bytes: 7944
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto A = new long[](N);
    auto B = new long[](N);
    foreach (i; 0 .. N)
        scan(A[i], B[i]);
    B[] *= -1;
    zip(A, B).sort();
    // writeln(A);
    // writeln(B);
    long ans;
    long j = 0;
    auto pq = PQueue();
    foreach (i; 1 .. M + 1)
    {
        while (A[j] <= i)
            pq.insert(-B[j++]);
        if (!pq.empty)
        {
            ans += pq.front;
            pq.popFront();
        }
    }
    writeln(ans);
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  REP(i, N)
  cin >> V[i];
  REP(i, N)
  cin >> C[i];
  vector<int> sub(N);
  REP(i, N)
  sub[i] = V[i] - C[i];
  int ans = 0;
  REP(i, N)
  {
    if (0 < sub[i])
      ans += sub[i];
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int A[3];
  cin>>A[0]>>A[1]>>A[2];
  sort(A,A+3);
  int a = 2*A[2]-A[0]-A[1];
  if (a%2==0){
    cout << a /2 << endl;
  }else{
    cout << a / 2+2 << endl;
  }
  return 0;
}


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

int gcd(int a,int b){
if(a == b) return a;
int temp = a-b;
if(temp < b) std::swap(temp,b);
return gcd(temp,b);
}


int main(){
int a,b;
std::cin >> a >> b;
if(a < b) std::swap(a,b);
std::cout << gcd(a,b) << std::endl; 
}

Measured memory_bytes: 3096
from collections import Counter

n = int(input())
a = list()
ans = 0
while n % 2 == 0:
    a.append(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        a.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    a.append(n)
m = list(Counter(a).values())
for i in range(len(m)):
    j, k = 1, 1
    while m[i] >= j:
        k += 1
        j += k
        ans += 1
print(ans)


Measured memory_bytes: 9484
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;
const long long L_INF = 9223372036854775807;
const int INF = 10000;
const int MAX = 50;

int main() {
	int N, K;
	int num = 1;

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		if (num * 2 < num + K) {
			num *= 2;
		}
		else {
			num += K;
		}
	}

	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

ll n,ans;
ll a[200010];
int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	ll sum=a[0],left=0;
	rep(i,1,n){
		while(sum&a[i]){
			ans+=i-left;
			sum^=a[left];
			left++;
		}
		sum^=a[i];
//		printf("%lld %lld %lld\n",left,i,ans);
	}
	printf("%lld\n",ans+(n-left)*(n-left+1)/2);
	return 0;
}

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

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

using namespace std;

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

ll N, K;
ll i, j, k;
vector<pair<pll,ll>> ans;

int main(){
    
    scanf("%lld%lld", &N,&K);
    if(N==1){
        if(K==1){
            printf("1 2 3");
        }else{
            printf("-1");
        }
        return 0;
    }
    
    ll a = 2 * N * (2 * N - 1) / 2 + K * N * 2;
    ll b = N * (N - 1) / 2 + (K + N * 2) * N;
    //printf("%lld %lld\n", a, b);
    if(a>b){
        printf("-1");
        return 0;
    }
    vector<bool> mk(N * 2 + 1);
    i = N - 1;
    j = N - 1;
    k = 0;
    while(k<N&&(k+K)+(j+K+N)<(i+K+N*2)){
        k++;
    }
    a = k;
    ans.push_back({{k + K, j + N + K}, i + N * 2 + K});
    mk[k] = true;
    mk[N + j] = true;
    i--;
    j -= 2;
    k ++;
    while(j>=0&&k<N){
        ans.push_back({{k+K, j + N + K}, i + N * 2 + K});
        mk[k] = true;
        mk[N + j] = true;
        i--;
        j -= 2;
        k++;
    }
    if(k<N){
        printf("-1\n");
        return 0;
    }
    k = 0;
    j = N * 2 - 1;
    while(k<j){
        while(k<j&&mk[k]){
            k++;
        }
        while(k<j&&mk[j]){
            j--;
        }
        if(k>=j)
            break;
        ans.push_back({{k + K, j + K}, i + K + N * 2});
        k++;
        j--;
        i--;
    }
    fornum(i,0,N){
        printf("%lld %lld %lld\n", ans[i].first.first, ans[i].first.second, ans[i].second);
    }
    

    return 0;
}

Measured memory_bytes: 5360
import java.util.*;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        UnionFind uf = new UnionFind(n);
        
        for(int i=0; i<m; i++){
            int x = Integer.parseInt(sc.next())-1;
            int y = Integer.parseInt(sc.next())-1;
            int z = Integer.parseInt(sc.next());
            uf.unite(x,y);
        }
        
        System.out.println(uf.groupCount());
    }
}

class UnionFind{
    int n;
    int[] par;
    int[] size;
    
    public UnionFind(int n){
        this.n = n;
        par = new int[n];
        for(int i=0; i<n; i++){
            par[i] = i;
        }
        size = new int[n];
        Arrays.fill(size, 1);
    }
    
    public int find(int x){
        if(par[x] == x){
            return x;
        }else{
            par[x] = find(par[x]);
            return par[x];
        }
    }
    
    public boolean unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x==y) return false;
        
        if(size[x]<size[y]){
            int tmp = x;
            x = y;
            y = tmp;
        }
        size[x] += size[y];
        par[y] = x;
        return true;
    }
    
    public boolean same(int x, int y){
        return find(x)==find(y);
    }
    
    public int size(int x){
        return size[find(x)];
    }
    
    public int groupCount(){
        Set<Integer> s = new HashSet<>();
        for(int i=0; i<n; i++){
            s.add(this.find(i));
        }
        return s.size();
    }
}


Measured memory_bytes: 63036
def s(a, b): 
	if (a == 0): 
		return b 
	return s(b%a, a) 

def result(monstar_h, n): 
	new = s(monstar_h[0], monstar_h[1]) 
	for i in range(2, n): 
		new = s(new,monstar_h[i]) 
	return new

n = int(input())
monstar_h = list(map(int, input().split()))
print(result(monstar_h, n)) 


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

int main(){
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int h = h2 - h1;
    int m = m2-m1;
    if(m<0){
        h--;
        m += 60;
    }
    int ans = h*60+m-k;
    cout << ans << endl;
}


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

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >

const int mod=998244353;
const long double inf=1e14;
int power(int a,int b,int p)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}
map<pii,int> mpp;
vi adj[100005];
int arr[100005];
bool vis[100005];
void dfs(int val,int c)
{
    arr[val]=c;
    vis[val]=true;
    trav(i,adj[val])
    {
        if(!vis[i])
        {
            if(mpp[{i,val}]%2==0)
                dfs(i,c);
            else
                dfs(i,c^1);
        }
    }
}
int32_t main()
{
    int n,x,y,w;
    cin>>n;
    rep(i,n-1)
    {
        cin>>x>>y>>w;
        adj[x].pb(y);
        adj[y].pb(x);
        mpp[{x,y}]=w;
        mpp[{y,x}]=w;
    }
    rep(i,n+2)
    vis[i]=false;
    dfs(1,0);
    repa(i,1,n)
    cout<<arr[i]<<endl;
    return 0;
}

Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i))
#define EACH(e,v) for(auto& e:v)

const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int H, W;
vector< string > A;

int dist[1010][1010];
queue< pair<int,int> > q;

signed main() {

  cin >> H >> W;

  function< bool(int,int) > inside = [&](int h, int w) {
    return (h >= 0) && (h < H) && (w >= 0) && (w < W);
  };

  A.resize(H);
  REP(i, H) cin >> A[i];

  REP(i, 1010) REP(j, 1010) dist[i][j] = -1;

  REP(i, H) REP(j, W) if (A[i][j] == '#') {
    dist[i][j] = 0;
    q.emplace(make_pair(i, j));
  }

  while (!q.empty()) {
    int h, w;
    tie(h, w) = q.front();
                q.pop();
    REP(i, 4) {
      int a = h + dx[i];
      int b = w + dy[i];
      if (inside(a, b) && dist[a][b] == -1) {
        dist[a][b] = dist[h][w] + 1;
        q.emplace(make_pair(a, b));
      }
    }
  }

  int res = dist[0][0];
  REP(i, H) REP(j, W) if (res < dist[i][j]) res = dist[i][j];
  cout << res << endl;

}


Measured memory_bytes: 13456
N, K = map(int,input().split())

Prb = [0]*N
for x in range(N):
  Pt = x +1
  Prb[x] = 1/N
  while Pt < K:
    Pt = Pt * 2
    Prb[x] = Prb[x] * 1/2

print(sum(Prb))

Measured memory_bytes: 42592
import sys
from collections import Counter
input = lambda: sys.stdin.readline().rstrip()
n, m, k = map(int, input().split())

fgraph = [list() for _ in range(n)]  # 隣接行列のリスト版
bgraph = [list() for _ in range(n)]  # brock関係のグラフ
cgraph = [list() for _ in range(n)]  # 友達候補のグラフ
sys.setrecursionlimit(10**9)
rks = [None]*n


def dfs(graph, s, r):  # 深さ優先探索
    if rks[s] is None:
        rks[s] = r
    for j in range(len(graph[s])):
        if rks[graph[s][j] - 1] is not None:
            continue
        dfs(graph, graph[s][j]-1, r)


for i in range(m):
    a, b = map(int, input().split())
    fgraph[a-1].append(b)
    fgraph[b-1].append(a)

 # fgraphの連結成分を調べる
c = -1
for i in range(n):
    if rks[i] is None:
        c += 1
        dfs(fgraph, i, c)  # iから始めるDFS。ｃが同じなら同じ連結成分にいる

for i in range(k):
    c, d = map(int, input().split())
    if rks[c-1] == rks[d-1]:  # 同一連結成分の中でのブロック関係のみ注目
        bgraph[c-1].append(d)
        bgraph[d-1].append(c)

counter = Counter(rks)
for i in range(n):
    print(counter[rks[i]] - len(fgraph[i]) - len(bgraph[i]) - 1)


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

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  ll tmp = A + B;
  ll res = 0;
  ll cnt = N / tmp;
  res += A * cnt;
  ll amari = N % tmp;
  if(amari >= A){
    res += A;
  }else{
    res += amari;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
import Foundation
let abhm = readLine()!.split(separator: " ").map { Double($0)! }
let a = abhm[0], b = abhm[1], h = abhm[2], m = abhm[3]

let jisinKaku = h * 30 + m * 0.5
let hunsinKaku = m * 6
let kaku = min(360 - abs(jisinKaku - hunsinKaku), abs(jisinKaku - hunsinKaku))
let cosinus = cos(kaku * Double.pi / 180)
let ans = a * a + b * b - (2 * a * b * cosinus)
print(ans.squareRoot())

Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a;
  in(a);
  out(a / 3);
  memi;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
 
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second
 
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>
 
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>
 
#define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.)
#define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n
 
const ll HMOD = (ll)1e9 + 7;
const ll LMOD = 998244353;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
const long double EPS = 1e-10;
 
void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}
 
void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}
 
void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}
 
int main(){
  int N;
  cin >>N;
  int a;
  FOR(i,1,N+1){
    if(i%2==0)continue;
    
    int c=0;
    FOR(j,1,i+1){
      if(i%j==0){
        c++;
        
      
      }
    
    }
    if(c==8) a++;
    
  
  }
  cout<<a<<endl;
  
 return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int a[5],k;
main(){
    for(int i=0;i<5;i++)cin>>a[i];
    cin>>k;
    bool f=1;
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            if(abs(a[j]-a[i])>k){
                f=0;
                break;
            }
        }
    }
    cout<<(!f?":(":"Yay!")<<endl;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  ll res = 0;

  for (int l = 0; l <= k; l++) {
    for (int r = 0; l + r <= k; r++) {
      if(l + r > n) continue;
      int d = k - l - r;
      ll count = 0;
      vector<int> tmp;
      for (int i = 0; i < l; i++) {
        count += v[i];
        tmp.push_back(v[i]);
      }
      for (int i = n-r; i < n; i++) {
        count += v[i];
        tmp.push_back(v[i]);
      }
      sort(ALL(tmp));
      for (int i = 0; i < d; i++) {
        if(i >= int(tmp.size())) break;
        if(tmp[i] > 0) break;
        count -= tmp[i];
      }
      res = max(res, count);
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>

void make_mat(int r, int c, long mat[101][101])
{
	for (size_t i = 0; i < r; i++)
		for (size_t j = 0; j < c; j++)
			std::cin >> mat[i][j];
}

int main(int argc, char const* argv[])
{
	int n, m, l;
	std::cin >> n >> m >> l;
	long mat_A[101][101] = {};
	long mat_B[101][101] = {};
	long mat_ret[101][101] = {};

	make_mat(n, m, mat_A);
	make_mat(m, l, mat_B);

	for (size_t i = 0; i < n; i++)
		for (size_t j = 0; j < l; j++)
			for (size_t k = 0; k < m; k++)
				mat_ret[i][j] += mat_A[i][k] * mat_B[k][j];

	for (size_t i = 0; i < n; i++)
		for (size_t j = 0; j < l; j++)
			if (j != l - 1)
				std::cout << mat_ret[i][j] << " ";
			else
				std::cout << mat_ret[i][j] << std::endl;

	return 0;
}

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

int main(){
	int N, ans=10000007;
	cin >> N;
	vector<int> v(N);
	for(int i=0 ; i<N ; ++i){
		cin >> v[i];
	}

	for(int i=-100 ; i<=100 ; ++i){
		int sum = 0;
		for(int j=0 ; j<N ; ++j){
			sum += pow(v[j] - i, 2);
		}
		ans = min(sum, ans);
	}

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

Measured memory_bytes: 256
def main():
    import sys
    import numpy as np
    input = sys.stdin.readline
    n,m = map(int,input().split())
    A = list(list(input().rstrip()) for i in range(n))
    B = list(list(input().rstrip()) for i in range(m))
    A = np.array(A)
    B = np.array(B)
    
    for i in range(n-m+1):
        for j in range(n-m+1):
            a_b = A[i:i+m,j:j+m]
            if (a_b==B).all():
                print('Yes');exit()
    print('No')
    
if __name__=='__main__':
    main()

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

using namespace std;

int main(void){
  string s, p;
  cin >> s;
  cin >> p;
  int l = p.size();
  for(int i = 0;i < s.size();++i){
    // s の i 文字目から l 文字を取って考える．剰余を考えながらやる．
    bool flag = true;
    for(int j = 0;j < l;++j){
      int u;
      if(j + i >= s.size()){
        u = (j + i) % s.size();
      }else{
        u = j + i;
      }
      if(p[j] != s[u]){
        flag = false;
      }
    }
    if(flag == true){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3172
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W, K = MAP()
c = [list(input()) for _ in range(H)]
S = [[0] * W for i in range(H)]
for i in range(H):
    for j in range(W):
        if c[i][j] == "#":
            S[i][j] = 1
S = np.array(S, dtype=np.int32)

ans = 0
for y in product([0, 1], repeat=H):
    for x in product([0, 1], repeat=W):
        Y = [i for i, n in enumerate(y) if n]
        X = [i for i, n in enumerate(x) if n]
        mask = np.zeros((H, W))
        mask[np.ix_(Y, X)] = 1
        ans += np.sum(mask * S) == K
print(ans)


Measured memory_bytes: 27100
#include <bits/stdc++.h> 
#define ll long long
#define M 1000000007
using namespace std;
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    string a;
    cin>>a;if(a=="ABC")cout<<"ARC";else
    {
         cout<<"ABC";
    }
    
}

Measured memory_bytes: 3568
n = int(input())
s = input()

left_max = 0
tmp = 0
for i in range(n):
    if s[i] == ')':
        tmp += 1
    else:
        tmp -= 1
    left_max = max(left_max, tmp)

right_max = 0
tmp = 0
for i in range(n):
    if s[::-1][i] == '(':
        tmp += 1
    else:
        tmp -= 1
    right_max = max(right_max, tmp)

for i in range(left_max):
    s = '(' + s
for i in range(right_max):
    s = s + ')'
print(s)


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,b,c,cmp,data,m,h,x,y,xcmp=0,ycmp=0,sum=0;

string s,w;

vector<int> z;

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

       cin >> n >> a >> b;
       rrrep(i,n,0){
           h=i;
     while(h!=0){
            sum+=h%10;
           h/=10;
        }
        if(sum>=a && sum<=b){
          ans+=i;
        }
        sum=0;
       }
       Cout(ans);
return 0;
}


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


// ??\??? ????????¨???

typedef bool B;
typedef long double D;
typedef complex<D> P;
typedef vector<P> VP;
typedef struct {P s,t;} L;
typedef vector<L> VL;
typedef struct {P c;D r;} C;
typedef vector <C> VC;

const D eps=1.0e-10;
const D pi=acos(-1.0);
template<class T> bool operator==(T a, T b){return abs(a-b)< eps;}
template<class T> bool operator< (T a, T b){return a < b-eps;}
template<class T> bool operator<=(T a, T b){return a < b+eps;}
template<class T> int sig(T r) {return (r==0||r==-0) ? 0 : r > 0 ? 1 : -1;}
#define X real()
#define Y imag()

D ip(P a, P b) {return a.X * b.X + a.Y * b.Y;}
D ep(P a, P b) {return a.X * b.Y - a.Y * b.X;}
D sq(D a) {return sqrt(max(a, (D)0));}
P vec(L l){return l.t-l.s;}


// verify AOJ 2514
P proj(P b,P p){ return b*ip(b,p)/norm(b);}
P proj(L l,P p){ return l.s+proj(vec(l),p-l.s);}
P refl(L l,P p){ return proj(l,p)*D(2.0)-p; }

// ccw
enum CCW{
	LEFT = 1,
	RIGHT = 2,
	BACK = 4,
	FRONT = 8,
	MID = 16,
	ON=FRONT|BACK|MID
};

inline int ccw(P base, P a, P b) {              //???a??¨???b???????????????????????????
	a -= base; b -= base;
	if (ep(a, b) > 0)
		return LEFT;    // counter clockwise
	if (ep(a, b) < 0)
		return RIGHT;   // clockwise
	if (ip(a, b) < 0)
		return BACK;    // b--base--a on line
	if (norm(a) < norm(b))
		return FRONT;   // base--a--b on line
	// otherwise
	return MID;      // base--b--a on line  a??¨b????????????????????????
}

int main(void){
	P base,point1;
	{
		D x[2],y[2];
		rep(i,2)cin >> x[i] >> y[i];
		base={x[0],y[0]},point1={x[1],y[1]};
	}
	int q;
	cin >> q;
	cout.precision(10);
	rep(loop,q){
		D x,y;
		cin >> x >> y;
		P point2={x,y};
		int ans=ccw(base,point1,point2);
		switch(ans){
			case LEFT:
					cout << "COUNTER_CLOCKWISE" << endl;
					break;
			case RIGHT:
					cout << "CLOCKWISE" << endl;
					break;
			case BACK:
					cout << "ONLINE_BACK" << endl;
					break;
			case FRONT:
					cout << "ONLINE_FRONT" << endl;
					break;
			case MID:
					cout << "ON_SEGMENT" << endl;
					break;
		}
	}
	return 0;
}

Measured memory_bytes: 1244
#include <stdio.h>
#include <iostream>
#include <string>

std::string G = "Good\n";
std::string B = "Bad\n";

int main() {

	std::string s;
	std::cin >> s;

	for (int i = 0; i < s.size() - 1; ++i) {

		if (s[i] == s[i + 1]) { std::cout << B; return 0; }

	}

	std::cout << G;

	return 0;
}

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

int main(){
  char ch;
  while(1){  
    scanf("%c",&ch);
    if (ch == '\n') break;
    if('a'<=ch && ch<='z'){
      int num=ch;
      printf("%c",num-32);
    }
    else if('A'<=ch && ch<='Z'){
      int num=ch;
      printf("%c",num+32);
    }
    else printf("%c",ch);
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3140