akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#ifdef ACMTUYO
struct RTC{~RTC(){cerr << "Time: " << clock() * 1.0 / CLOCKS_PER_SEC <<" seconds\n";}} runtimecount;
#define DBG(X) cerr << #X << " = " << X << '\n';
#else
struct RTC{};
#define DBG(X)
#endif

#define fast_io() ios_base::sync_with_stdio(false)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(c) (c).begin(),(c).end()
#define forn(i, n) for (int i = 0; i < (n); i++)
typedef long long int ll;
const int maxn = 5010;
int n, k;
ll nextt[maxn], cost[maxn];
ll len[maxn], total[maxn];
ll best(int start, ll steps) {
  if (steps == 0) return 0LL;
  ll ans = 0;
  ll acu = cost[start];
  int cur = nextt[start];
  ans = max(ans, acu);
  steps--;
  while (steps--) {
    acu += cost[cur];
    ans = max(ans, acu);
    cur = nextt[cur];
  }
  return ans;
}
int main() {
  scanf("%d %d", &n, &k);
  forn (i, n) {
    scanf("%lld", nextt + i);
    nextt[i]--;
  }
  forn (i, n) {
    scanf("%lld", cost + i);
  }
  forn (i, n) {
    if (len[i] == 0) {
      total[i] = cost[i];
      len[i] = 1;
      int cur = nextt[i];
      while (cur != i) {
        total[i] += cost[cur];
        len[i]++;
        cur = nextt[cur];
      }
      cur = nextt[i];
      while (cur != i) {
        total[cur] = total[i];
        len[cur] = len[i];
        cur = nextt[cur];
      }
    }
  }
  ll answer = LLONG_MIN;
  forn (start, n) {
    answer = max(answer, cost[start]);//one movement
    ll acu = cost[start];
    int cur = nextt[start];
    ll steps = k - 1;
    answer = max(answer, acu + best(cur, min(steps, len[cur])));
    if (steps >= len[cur] and total[cur] > 0) {
      ll r = max(0LL, steps / len[cur] - 1LL);
      ll rem = steps - r * len[cur];
      answer = max(answer, acu + r * total[cur] + best(cur, rem));
    }
  }
  printf("%lld\n", answer);
  return 0;
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e3 + 20;
const int INF = 0x3f3f3f3f;
const ll llINF=0x3f3f3f3f3f3f3f3f;
struct Edge
{
    int from, to, cap, flow;
	ll cost;
};
struct MCMF
{
    int n, m, s, t;
    vector<Edge> edges;
    vector<int> G[maxn];
    int inq[maxn];
    ll d[maxn]; //最短路数组
    int p[maxn]; //记录路径
    int a[maxn]; //记录流量
    void init(int n)
    {
        this->n = n;
        for (int i = 0; i < n; i++)
            G[i].clear();
        edges.clear();
    }
    void addedge(int from, int to, int cap, ll cost)
    {
        edges.push_back(Edge{from, to, cap, 0, cost});
        edges.push_back(Edge{to, from, 0, 0, -cost});
        m = edges.size();
        G[from].push_back(m - 2);
        G[to].push_back(m - 1);
    }
    bool spfa(int s, int t, int &flow, ll &cost)
    {
        for (int i = 0; i < n; i++)
            d[i] = llINF;
        memset(inq, 0, sizeof(inq));
        d[s] = 0;
        inq[s] = 1;
        p[s] = 0;
        a[s] = INF;
        queue<int> q;
        q.push(s);
        while (!q.empty())
        {
            int u = q.front();
            q.pop();
            inq[u] = 0;
            for (int i = 0; i < G[u].size(); i++)
            {
                Edge &e = edges[G[u][i]];
                if (e.cap > e.flow && d[e.to] > d[u] + e.cost)
                {
                    d[e.to] = d[u] + e.cost;             //松弛
                    p[e.to] = G[u][i];                   //记录上一个点
                    a[e.to] = min(a[u], e.cap - e.flow); //流量控制
                    if (!inq[e.to])
                    {
                        q.push(e.to);
                        inq[e.to] = 1;
                    }
                }
            }
        }
        if (d[t] == llINF)
            return false; //不存在最短路
        flow += a[t];
        cost += d[t] * a[t];
        int u = t;
        while (u != s)
        {
            edges[p[u]].flow += a[t];
            edges[p[u] ^ 1].flow -= a[t];
            u = edges[p[u]].from;
        }
        return true;
    }
    ll Mincost(int s, int t)
    {
        int flow = 0;ll cost = 0;
        while (spfa(s, t, flow, cost))
            ;
        return cost;
    }
}F;
int main()
{
	int n;
	scanf("%d",&n);
	int S=2*n+1;int T=S+1;
	int sp1=T+1,sp2=T+2,sp3=T+3,sp4=T+4;
	F.init(sp4+1);
	for(int i=0,cnt,x,y;i<n;i++)
	{
		scanf("%d%d%d",&x,&y,&cnt);
		F.addedge(S,i,cnt,0);
		F.addedge(i,sp1,INF,x+y);
		F.addedge(i,sp2,INF,x-y);
		F.addedge(i,sp3,INF,-x+y);
		F.addedge(i,sp4,INF,-x-y);
	}
	for(int i=0,cnt,x,y;i<n;i++)
	{
		scanf("%d%d%d",&x,&y,&cnt);
		F.addedge(i+n,T,cnt,0);
		F.addedge(sp1,i+n,INF,-x-y);
		F.addedge(sp2,i+n,INF,-x+y);
		F.addedge(sp3,i+n,INF,x-y);
		F.addedge(sp4,i+n,INF,x+y);
	}
	printf("%lld\n",-F.Mincost(S,T));
}


Measured memory_bytes: 1180
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	v := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&c[i])
	}

	var sum int
	for i := 0; i < n; i++ {
		if v[i] > c[i] {
			sum += v[i] - c[i]
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;
 
/* constant */
 
const int MAX_N = 100;
 
/* typedef */
 
/* global variables */
 
double xs[MAX_N], ys[MAX_N];
 
/* subroutines */
 
/* main */
 
int main() {
  int n;
  cin >> n;
 
  for (int i = 0; i < n; i++) cin >> xs[i];
  for (int i = 0; i < n; i++) cin >> ys[i];
 
  double sum1 = 0.0, sum2 = 0.0, sum3 = 0.0, maxd = 0.0;
 
  for (int i = 0; i < n; i++) {
    double d = abs(xs[i] - ys[i]);
    sum1 += d;
    sum2 += d * d;
    sum3 += d * d * d;
    if (maxd < d) maxd = d;
  }
 
  printf("%.6lf\n", sum1);
  printf("%.6lf\n", sqrt(sum2));
  printf("%.6lf\n", pow(sum3, 1.0 / 3));
  printf("%.6lf\n", maxd);
 
  return 0;
}


Measured memory_bytes: 3420
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = sorted(il())
    print(abs(min(A) - max(A)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10064
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)


def solve1():
    ab = sorted([x + y for x in A[:K] for y in B[:K]], reverse=True)
    f = sorted([c + e for c in C for e in ab[:K]], reverse=True)
    return f[:K]


for top in solve1():
    print(top)

Measured memory_bytes: 236428
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 3000010;

int main(void){
    ll N;
    string S;
    ll L[MAX_N], R[MAX_N];
    ll answer = MAX_N;

    cin >> N >> S;
    L[0] = 0;
    R[0] = 0;

    rep(i, N){
        if (S[i] == 'W') L[i + 1] = L[i] + 1;
        else L[i + 1] = L[i];
        if (S[N - i - 1] == 'E') R[i + 1] = R[i] + 1;
        else R[i + 1] = R[i];
    }

    rep(i, N) answer = min(answer, L[i] + R[N - i - 1]); 

    cout << answer << endl;

    return 0;
}

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

using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;

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

  string ans1, ans2, in;
  int tm = 0;
  map<string, int> gedo;
  while (cin >> in) {
    if (ans2.size() < in.size()) ans2 = in;
    if (tm < ++gedo[in]) {ans1 = in;tm = gedo[in];}
  }

  cout << ans1 << " " << ans2 << endl;

  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

ll dp[101][301][101];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; ll W; cin>>n>>W;
    vll w(n),v(n);
    rep(i,n) cin>>w[i]>>v[i];
    ll w0 = w[0];
    rep(i,n) w[i]-=w0;
    rep(i,n)FOR(j,0,300)FOR(k,0,n){
        if (j>=w[i] && k>=1){
            if (dp[i][j-w[i]][k-1]+v[i] > dp[i][j][k]){
                dp[i+1][j][k] = dp[i][j-w[i]][k-1]+v[i];
            }else{
                dp[i+1][j][k] = dp[i][j][k];
            }
        }else{
            dp[i+1][j][k] = dp[i][j][k];
        }
    }
    ll ans=0;
    FOR(j,0,300)FOR(k,0,n){
        if (w0*k+j<=W) chmax(ans,dp[n][j][k]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 24064
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
c = [[] for _ in range(m)]
for i in range(m):
    c[i] = list(map(int, input().split()))
a.sort()
c.sort(key=lambda x: x[1], reverse=True)
ans = sum(a)
sa = 0
cnt = 0
r = c[0][0]
for i, v in enumerate(a):
    if r <= i and cnt <= m - 2:
        cnt += 1
        r += c[cnt][0]
    if r > i and v < c[cnt][1]:
        ans += abs(c[cnt][1] - v)
    else:
        break
print(ans)


Measured memory_bytes: 32760
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(0);
  lint h; cin >> h;
  lint cnt = 0;
  while (h > 0) {
    h = floor(h/2);
    cnt++;
  }
  cout << pow(2, cnt) - 1<< '\n';
}


Measured memory_bytes: 384
# coding: utf-8

import math
import fractions
import heapq
import collections
import re
import array
import bisect

from collections import Counter, defaultdict


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]


def main():
    N = int(input())
    ans = 3**N
    ad = 1
    for i in map(int, input().split()):
        if i % 2 == 0:
            ad *= 2
    return ans - ad


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 5588
s = raw_input().split()
a= int(s[0]) 
b= int(s[1])
c= int(s[2])
d= int(s[3])

w = c-a 
h = d-b 
u ="U"
d = "D"
r = "R"
l = "L"

str = "U"*h + "R"*w + "D"*h + "L"*w + "L" + u*(h+1) + r*(w+1) + d + r + d*(h+1) + l*(w+1) + u  
print str

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

template<typename T>
struct Node{
    int id;
    T v;
    bool done = false;
    Node(int id, T v=1e9): id(id), v(v) {}
    Node(): id(0), v(1e9) {}
};

template<typename T>
struct Edge{
    int from, to, id;
    T cost;
    Edge(int from, int to, T cost=1, int id=-1): from(from), to(to), cost(cost), id(id) {}
};

template<typename T>
struct Graph{
    int N;
    vector<vector<Edge<T>>> adj;
    vector<Node<T>> node;
    vector<pair<int,int>> i2e; // 辺番号から辺への変換

    Graph(int N): N(N) {
        adj.assign(N, vector<Edge<T>>());
        node.assign(N, Node<T>());
        for(int i=0; i<N; ++i) node[i].id = i;
    }

    Graph() {}

    void add_edge(int i, int j, T cost=1, int id=-1){
        Edge<T> e(i, j, cost, id);
        if(id != -1) i2e.emplace_back(i, adj[i].size());
        adj[i].emplace_back(e);
    }

    vector<Edge<T>> get_adj(Node<T> node){
        return adj[node.id];
    }

    void assign(int n){
        N = n;
        adj.assign(N, vector<Edge<T>>());
        node.assign(N, Node<T>());
        for(int i=0; i<N; ++i) node[i].id = i;
    }

    void reset(){
        for(int i=0; i<N; ++i){
            node[i].done = false;
            node[i].v = 1e9;
        }
    }
};

int main(void){
    int N,M; cin >> N >> M;
    Graph<int> G(N);
    VI H(N); REP(i,N) cin >> H[i];
    REP(i,M){
        int a,b; cin >> a >> b; a--; b--;
        if(H[a] >= H[b]) G.add_edge(b,a);
        if(H[a] <= H[b]) G.add_edge(a,b);
    }

    int ans = 0;
    REP(i,N) if(G.adj[i].empty()) ans++;
    cout << ans << endl;
    return 0;
}

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

#include <atcoder/all>
using namespace atcoder;

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

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    ds.merge(a, b);
  }

  vector<vector<int>> g = ds.groups();
  cout << g.size() - 1 << endl;
  return 0;
}

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


// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3") 
// #pragma GCC optimization ("unroll-loops")
 
#define ll  long long int
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
 
#define MD          1000000007
#define M           100011

long long  md=MD;


int solve(){
	int n,i,j,k;
	cin>>n;
	vector<int> v(n+1);
	for(i=1;i<=n;++i)cin>>v[i];
	vector<int> b(n+1);
	b[n]=0;
	int a=0;
	for(i=n-1;i>=1;--i){
		if(v[i]>=v[i+1])b[i]=b[i+1]+1;
		else b[i]=0;
		a=max(a,b[i]);

	}cout<<a<<"\n";




	return 0;
}


int main(){

 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t,i;

    t=1;
    // cin>>t;

    while(t--){
    	solve();
    }



    

}



Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int h,w,k;
    cin>>h>>w>>k;
    vii b(h+1,vi(w+1,0));
    FOR(i,0,h){
        string s;
        cin>>s;
        FOR(j,0,w){
            if(s[j]=='1'){
                b[i][j]=1;
            }
        }
    }
    int ans=mod;
    FOR(t,0,1<<h){
        int g[12]={};
        int c[12]={};
        int idx=0,tmp=0;
        FOR(i,0,h){
            g[i]=idx;
            if(t&(1<<i)){
                idx++;
                tmp++;
            }
        }
        //cerr<<"t:"<<bitset<10>(t)<<" "<<"tmp:"<<tmp<<endl;
        FOR(i,0,h){
            //cerr<<g[i]<<endl;
        }
        FOR(j,0,w){
            int f=0;
            int cc[12]={};
            FOR(i,0,h){
                cc[g[i]]+=b[i][j];
            }
            FOR(i,0,h){
                if(cc[i]+c[i]>k){
                    f=1;
                }
            }
            if(f){
                tmp++;
                FOR(i,0,h){
                    c[i]=cc[i];
                }
                int ff=0;
                FOR(i,0,h){
                    if(c[i]>k){
                        ff=1;
                        break;
                    }
                }
                if(ff){
                    goto LB;
                }
            }else{
                FOR(i,0,h){
                    c[i]+=cc[i];
                }
            }
        }
        //cerr<<"**** t:"<<bitset<11>(t)<<" "<<ans<<endl;   
        if(ans>tmp){
            ans=min(ans,tmp);
            //cerr<<"**** t:"<<bitset<11>(t)<<" "<<ans<<endl;        
        }
        LB:ans=ans;
    }



    cout<<ans;
}


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

int main() {
  int n,k,c;
  string s;
  cin>>n>>k>>c>>s;
  vector<int> P,Q,ans;
  for(int i=0;i<n;i++){
      if(s[i]=='o'){
         P.push_back(i+1);
         i+=c;
      }
  }
  reverse(s.begin(),s.end());
  for(int i=0;i<n;i++){
      if(s[i]=='o'){
         Q.push_back(n-i);
         i+=c;
      }
  }

  if(P.size()!=k||Q.size()!=k){
      return 0;
  } 
 
  else{
    sort(P.begin(),P.end());
    sort(Q.begin(),Q.end());
    int i=0,j=0;
    while(i!=P.size()&&j!=Q.size()){
        if(P[i]>Q[j]) j++;
        else if(P[i]==Q[j]){
           ans.push_back(P[i]);
            i++,j++;
        } 
        else i++;
    }
    rep(k,ans.size()) cout<<ans[k]<<endl;
  }

}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
string s;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>s;
	if (s=="SUN") kill(7)
	if (s=="MON") kill(6)
	if (s=="TUE") kill(5)
	if (s=="WED") kill(4)
	if (s=="THU") kill(3)
	if (s=="FRI") kill(2)
	if (s=="SAT") kill(1)
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	string res = "No";
	string N; cin >> N;

	if (N[0] == N[1] && N[1] == N[2]) res = "Yes";
	if (N[1] == N[2] && N[2] == N[3]) res = "Yes";

	cout << res << endl;
}

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

class Main {
    public static void main(String[] args) {
        String[] line = new Scanner(System.in).nextLine().split(" ", 3);
        int[] arr = new int[3];
        arr[0] = Integer.parseInt(line[0]);
        arr[1] = Integer.parseInt(line[1]);
        arr[2] = Integer.parseInt(line[2]);
        Arrays.sort(arr);
        if (arr[0] + arr[1] == arr[2]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>

int main(int argc, char const *argv[]){
	
	int N;
	int num = 0;
	std::cin >> N;
	std::vector<int> fig(N);

	for (int i = 0; i < N; ++i){
		std::cin >> fig[i];
	}

	for (int i = 0; i < N; ++i){
		int minj = i;
		for (int j = i; j < N; ++j){
			if(fig[j]<fig[minj]){
				minj = j;
			}
		}
		if(i!=minj){
			int buff = fig[i];
			fig[i] = fig[minj];
			fig[minj] = buff;
			num += 1;
		}
	}

	for (int i = 0; i < N; ++i){
		std::cout << fig[i];
		if(i<N-1) std::cout << " ";
	}
	std::cout << std::endl;
	std::cout << num << std::endl;	

	return 0;
}


Measured memory_bytes: 3104
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s;
    R(s);
    string t=s;
    reverse(ALL(t));
    if(t!=s)W("No");
    else{
        reverse(t.begin(),t.begin()+(SZ(s)-1)/2);
        W(t==s?"Yes":"No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define RECT(h, w) ((h) << 8 | (w))
#define HEIGHT(rect) ((rect) >> 8)
#define WIDTH(rect) ((rect) & 0xFF)
#define MAX 150

int rects[MAX * MAX];

int comp_rect(const void* a, const void* b)
{
    int t = HEIGHT(*(int*)a) * HEIGHT(*(int*)a) - HEIGHT(*(int*)b) * HEIGHT(*(int*)b)
            + WIDTH(*(int*)a) * WIDTH(*(int*)a) - WIDTH(*(int*)b) * WIDTH(*(int*)b);

    return t ? t : HEIGHT(*(int*)a) - HEIGHT(*(int*)b);
}

int main(void)
{
    int h, w, i, rect;

    for(i = 0, w = 2; w < MAX; w++)
        for(h = 1; h < w; h++)
            rects[i++] = RECT(h, w);

    qsort(rects, i, sizeof(int), comp_rect);

    while(scanf("%d%d", &h, &w), w + h)
    {
        rect = RECT(h, w), i = 0;

        while(comp_rect(&rects[i], &rect) <= 0)
            i++;

        printf("%d %d\n", HEIGHT(rects[i]), WIDTH(rects[i]));
    }

    return 0;
}

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

int main(){
  int i,j,cnt=0;
  int n;
  string a,b,c;
  cin>>n;
  cin>>a;
  cin>>b;
  cin>>c;
  for(i=0;i<n;i++){
    if(a[i]==b[i] && b[i]==c[i])continue;
    if(a[i]==b[i] || b[i]==c[i] || c[i]==a[i])cnt++;
    else cnt+=2;
  }
  cout<<cnt;
}

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

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    int A[100100];
    for (int i = 0; i < Q; i++) {
        cin >> A[i]; //A[0]~A[Q-1] == A_1 ~ A_Q
    }

    vector<int> point(N, K-Q); //加点なしの仮定：Qステップ後には皆K―Q点
    for (int i = 0; i < Q; i++) {
        point.at(A[i]-1)++; // A[i]の人の点数＋１していく
    }

    for (int i = 0; i < N; i++) {
        if (point.at(i) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s;
    cin>>s;
    string s0[6];
    rep(0,i,6)s0[i]=s.substr(i,1);
    if(s0[2]==s0[3]&&s0[4]==s0[5]){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
n,x,y=map(int,input().split())
x-=1
y-=1
d=[10000 for i in range(n)]
ans=[0 for i in range(n)]
for i in range(n):
    for j in range(i,n):
        m=min(abs(i-j),abs(x-i)+abs(y-j)+1,abs(y-i)+abs(x-j)+1)
        ans[m]+=1

for i in range(1,n):
    print(ans[i])

Measured memory_bytes: 3444
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最小公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最大公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n = input();
    ll ans = 0;
    for(int i=1;i<=n;i*=100){
      if(i*10>n)ans += n-i+1;
      else ans += i*9;
      //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math

#n, a, b= map(int, input().split())
#a, b  = map(int, input().split())
#h = list(map(int, input().split()))
#s = list(str(input()))
n = int(input())
n_1 = n-1

tot = 0
count = 0
num = int(n/2)
list_ini = list(str(n_1))
tot_min = 1 + sum(int(i) for i in list_ini)

for i in range(num):
  a = i+1
  b = n-i-1
  list_a = list(str(a))
  list_b = list(str(b))
  tot_a = sum(int(ii) for ii in list_a)
  tot_b = sum(int(ii) for ii in list_b)
  if(tot_min > tot_a + tot_b):
    tot_min = tot_a + tot_b
    
print(tot_min)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
// ll dp[2][5005][5005];
ll f[25000100], u[25010000];
int main() {
    int n, g[2][3];
    cin >> n;
    for(int i = 0; i < 2; i++) {
        cin >> g[i][0] >> g[i][1] >> g[i][2];
    }
    // memset(dp, -1, sizeof dp);
    // for(int i = 0; i < 2; i++) {
    //     for(int j = 0; j <= n; j++) {
    //         dp[i][j][j] = 0;
    //         for(int q = n; q >= 0; q--) {
    //             for(int k = 0; k < 3; k++) { 
    //                 if(g[i][k] < g[!i][k]) {
    //                     if(q+g[i][k] <= n && dp[i][j][q+g[i][k]] != -1) {
    //                         dp[i][j][q] = max(dp[i][j][q], dp[i][j][q+g[i][k]] + g[!i][k]);
    //                         // if(dp[i][j][q]) {
    //                         //     printf("dp[%d][%d][%d]:%d\n", i, j, q, dp[i][j][q]);
    //                         // }
    //                     }
    //                 }
    //             }
    //         }
    //     }
    // }
    for(int i = 0; i <= 25000000; i++) {
        u[i] = i;
        for(int k = 0; k < 3; k++) {
            if(g[0][k] < g[1][k] && i - g[0][k] >= 0) {
                u[i] = max(u[i], u[i - g[0][k]] + g[1][k]);
            }
        }
    }
    for(int i = 0; i <= 25000000; i++) {
        f[i] = i;
        for(int k = 0; k < 3; k++) {
            if(g[1][k] < g[0][k] && i - g[1][k] >= 0) {
                f[i] = max(f[i], f[i - g[1][k]] + g[0][k]);
            }
        }
    }
    ll ans = n;
    ans = max(ans, f[u[n]]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 390912
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

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

    int n, k;
    cin >> n >> k;
    VI vi = VI(n+1, 0);
    for (int i = 1; i <= n; ++i)
    {
        cin >> vi[i];
    }
    unsigned int ans = 1000000000;
    for (int i = 1; i <= (n-k+1); ++i)
    {
        ans = min(ans, (unsigned int)(min((abs(vi[i])+abs(vi[i]-vi[k-1+i])), (abs(vi[k-1+i])+abs(vi[i]-vi[k-1+i])))));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<functional>
#include<string>
#include<iostream>
using namespace std;
int main(void)
{
	int i,cnt,n;
	string a[200000];
	scanf("%d",&n);
	for(i=0;i<n;i++)	cin >>a[i];
	sort(a,a+n);
	cnt=1;
	for(i=1;i<n;i++)	{
		if(a[i]!=a[i-1])	cnt++;
	}
	cout <<cnt <<endl;
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<int> l(m), r(m);
  rep(i,m) cin >> l[i] >> r[i];
  
  sort(l.begin(), l.end());
  sort(r.begin(), r.end());
  
  cout << max(0,r[0]-l[m-1]+1) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, K;
  cin >> N >> K;
  vector<lint> A(N);
  REP(i, N) {
    cin >> A[i];
    A[i]--;
  }
  vector<lint> S(N+1);
  FOR(i, 1, N+1) S[i] = A[i-1] + S[i-1];
  map<lint, lint> cnt;
  REP(i, min(N+1, K)) {
    cnt[S[i]%K]++;
  }
  lint ans = 0;
  int j = K;
  REP(i, N+1) {
    cnt[S[i]%K]--;
    ans += cnt[S[i]%K];
    if(j < N+1) {
      cnt[S[j]%K]++;
      j++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 15872
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int ans=0;
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		long d = sc.nextInt();

		long ac = a*c;
		long ad = a*d;
		long bc = b*c;
		long bd = b*d;

		long i = 0;
		long j = 0;

		if(ac > ad) {
			i = ac;
		}
		else {
			i = ad;
		}

		if(bc > bd) {
			j = bc;
		}
		else {
			j = bd;
		}

		if(i > j) {
			System.out.println(i);
		}
		else {
			System.out.println(j);
		}
	}
}


Measured memory_bytes: 35688
#include <algorithm>
#include <boost/format.hpp>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

struct Point {
  int r;
  int c;
};

std::string gen_line(int r1, int c1, int r2, int c2) {
  return (boost::format("%d %d %d %d")
          % (r1+1) % (c1+1) % (r2+1) % (c2+1)).str();
}

int main() {
  int h, w; std::cin >> h >> w;
  int a[501][501];
  for (int r = 0; r < h; r++) {
    for (int c = 0; c < w; c++) {
      std::cin >> a[r][c];
    }
  }

  bool move = false;
  std::vector<Point> ps;
  std::vector<std::string> lines;
  for (int r = 0; r < h; r++) {
    bool inc = (r % 2 == 0);  // inc: right move, dec(false): left move
    int c = (inc) ? 0 : w - 1;
    int update = (inc) ? 1 : -1;
    while ((c >= 0) && (c < w)) {
      if (a[r][c] % 2 != 0) {
        if (move) {
          ps.push_back({r, c});
          for (int i = 0; i < ps.size() - 1; i++) {
            lines.push_back(gen_line(ps[i].r, ps[i].c, ps[i+1].r, ps[i+1].c));
          }
          ps.clear();
        }
        move = !move;
      }

      if (move) {
        ps.push_back({r, c});
      }

      c += update;
    }
  }

  std::cout << lines.size() << std::endl;
  for (auto line : lines) {
    std::cout << line << std::endl;
  }
}

Measured memory_bytes: 9972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    int n; cin >> n;
    cout << 180*(n-2) << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main() {
    int X;
    std::cin >> X;

    int max_value = 1;
    for (int b = 2; b * b <= X; b ++) {
        for (int p = 2; std::pow(b, p) <= X; p++) {
            max_value = std::max(max_value, (int)std::pow(b, p));
        }
    }
    std::cout << max_value << std::endl;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
from collections import *
from math import gcd

N = int(input())
zerozero = 0
zero1 = 0
zero2 = 0
cnt = defaultdict(int)

for _ in range(N):
    A, B = map(int, input().split())
    
    if A==0 and B==0:
        zerozero += 1
    elif A==0:
        zero1 += 1
    elif B==0:
        zero2 += 1
    else:
        G = gcd(abs(A), abs(B))
        A //= G
        B //= G
        
        if (A<0 and B<0) or (A<0 and B>0):
            cnt[(-A, -B)] += 1
        else:
            cnt[(A, B)] += 1

ans = 1
MOD = 10**9+7
checked = set()

for k, v in cnt.items():
    if k in checked:
        continue
    
    if k[0]>0 and k[1]>0:
        k2 = (k[1], -k[0])
    else:
        k2 = (-k[1], k[0])
    
    if k2 in cnt:
        v2 = cnt[k2]
        ans *= pow(2, v, MOD)+pow(2, v2, MOD)-1
        ans %= MOD
        checked.add(k2)
    else:
        ans *= pow(2, v, MOD)
        ans %= MOD

ans *= pow(2, zero1, MOD)+pow(2, zero2, MOD)-1
ans %= MOD
ans += zerozero
ans %= MOD
print((ans-1)%MOD)

Measured memory_bytes: 112572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
const int max_n=100000;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
ll modpower(ll a,ll b){  //aのb乗
  ll ans=1;
  while(b>0){
    a%=mod;
    if((b&1)==1){
      ans=ans*a%mod;
    }
    b>>=1;
    a*=a;
  }
  return ans;
}
ll modfacts(ll a){      //aの階乗
  ll ans=1;
  for(ll i=2;i<=a;i++)ans=ans*i%mod;
  return ans;
}
ll inv(ll a){           //aの逆元
  return modpower(a,mod-2);
}
ll modcom(ll a,ll b){   //aCb
  if(b>a)return 0;
  if(a<0||b<0)return 0;
  if(b*2>a)b=a-b;
  ll ans=inv(modfacts(b));
  rep(i,b)ans=ans*(a-i)%mod;
  return ans;
}
int main(){
  ll n,m,k;
  cin>>n>>m>>k;
  ll c=modcom(m+1,m-2),d=modcom(n+1,n-2);
  c*=modcom(m*n-2,k-2);
  c%=mod;
  c*=(n*n)%mod;
  c%=mod;
  d*=modcom(m*n-2,k-2);
  d%=mod;
  d*=(m*m)%mod;
  d%=mod;
  cout<<(c+d)%mod<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int i,j,n,s,count=0,a[101];


  //load N
  scanf("%d",&n);
  //load number
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
  }

  //Algorithm
  for(i=1;i<=n;i++){
    for(j=n;j>=i+1;j--){
      //swap
      if(a[j]<a[j-1]){
	s=a[j];
	a[j]=a[j-1];
	a[j-1]=s;
	count++;
      }
    }
  }


  //print number
    for(i=1;i<=n;i++){
      printf("%d",a[i]);
      if(i!=n){
	printf(" ");
      }
    }

    printf("\n");
    printf("%d\n",count);

  return 0;

}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int[] xx = new int[n + 1];
        int[] yy = new int[m + 1];
        for(int i = 0;i < n;i ++){
            xx[i] = sc.nextInt();
        }
        xx[n] = x;
        for(int i = 0; i < m;i ++){
            yy[i] = sc.nextInt();
        }
        yy[m] = y;
        Arrays.sort(xx);
        Arrays.sort(yy);
        boolean flag = false;
        if(xx[n] < yy[0]){
        flag = true;
        }
        System.out.println(flag ? "No War" : "War");
    }
}

Measured memory_bytes: 21972
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
s = input()
i = 0
flag = False
ans = 0
for i in range(len(s)):
    if flag:
        if s[i] == 'R':
            ans += 1
        else:
            flag = False
    else:
        if s[i] == 'R':
            ans = max(ans,1)
            flag = True
        else:
            flag = False
print(ans)


Measured memory_bytes: 10388
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef long long ll;
const int inf = 1<<30;
const int md = 1e9+7;
const int N = 105;
int n,m;
int T;
int v[N];
int ar[N];
bool ans=1;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&ar[i]);
	sort(ar+1,ar+n+1);
	for(int i=1;i<=ar[n]+1;i++)
		v[max(i-1,ar[n]+1-i)]++;
/*
	if(n==2)
	{
		ans=(ar[1]==1 && ar[2]==1);
		puts(ans?"Possible":"Impossible");
		return 0;
	}*/
	//if(ar[2]==1)ans=0;

	int len=(ar[n]+1)/2;
	for(int i=n;i>=1;i--)
	{
		if(v[ar[i]]>0)
		{
			v[ar[i]]--;
			//cout<<i<<' ';
		}
		else
		{
			if(len>=ar[i])
			{
				ans=0;
				continue;
			}
			v[ar[i]]--;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(v[i]>0)ans=0;
	}
	puts(ans?"Possible":"Impossible");
    return 0;
}

Measured memory_bytes: 256
N=int(input())
ox=input()



count=0
skip=[False]*N
for i in range(N):
    if skip[i]:
        continue
    if i==N-1:
        break
    if ox[i]=='O':
        if ox[i+1]=='X':
            count+=1
            if i==N-1:
                break
            skip[i+1]=True
            
            continue
        else:
            continue
    else:
        if ox[i+1]=='O':
            count+=1
            if i==N-1:
                break
            skip[i+1]=True
            continue
        else:
            continue

print(count)



Measured memory_bytes: 6512
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		cout << (n-2) * 180 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
int n;
void input(){
	cin>>n;
	return;
}

void solve(){
	int m=n%1000;
	if(m!=0)m=1000-m;
	cout << m;
	return;
}
int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int n,sum=0;
  cin>>n;cin>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')sum++;
  }
  cout<<sum;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>

using namespace std;

int main(void){

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

  int max = r[1] - r[0];
  int min = r[0];
  for(int j = 1; j < n; j++) {
    if(max < r[j] - min) max = r[j] - min;
    if(r[j] < min) min = r[j];
  }
  cout << max << endl;

  return 0;
}





Measured memory_bytes: 3876