akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
//桁
int kt(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==1)
    cout<<"Hello World";
    else
      cout<<b+c;
}


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

using namespace std;

const long long int mod = 1e9 + 7;
int main()
{
    int h, w;

    cin >> h >> w;

    char grid[h+1][w+1];
    long long int dp[h+1][w+1];

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> grid[i][j];
            dp[i][j] = 0;
        }
    }

    dp[0][0] = 1;

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (!i && !j)
                continue;

            if (grid[i][j] == '#')
            {
                dp[i][j] = 0;
                continue;
            }

            if (i > 0)
            {
                dp[i][j] = dp[i][j] + dp[i-1][j];
                dp[i][j] = dp[i][j] % mod;
            }

            if (j > 0)
            {
                dp[i][j] = dp[i][j] + dp[i][j-1];
                dp[i][j] = dp[i][j] % mod;
            }
        }
    }

    cout << dp[h-1][w-1] << "\n";

    return 0;
}

Measured memory_bytes: 9088
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

#define MOD 1e9+7

using namespace std;

class DBannedK {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int n;
    cin >> n;
    vector<int64_t> a_vec(n);
    map<int64_t, int64_t> m;
    map<int64_t, int64_t> calced_m;
    for (int i = 0; i < n; ++i) cin >> a_vec[i];
    for (const auto &a : a_vec) {
      m[a]++;
    }
    int64_t sum = 0;
    for (const auto &mm : m) {
      sum += mm.second * (mm.second - 1) / 2;
    }
    for (const auto &a : a_vec) {
      int64_t num = m[a] - 1;
//      if (num <= 1) continue;
      cout << sum - num << endl;
    }
  }
};


int main() {
  DBannedK solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 11008
N = int(input())
a = list(map(int, input().split()))

ans = 0
p = -1
cnt = 0
for i in range(N):
    if p == a[i]:
        cnt += 1
    else:
        ans += cnt // 2
        cnt = 1
        p = a[i]
ans += cnt // 2

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll L, R;
	cin >> L >> R;
	
	ll ans = 2 * 1e9 + 1;
	for(ll i = L; i <= min(L + 2019, R); ++i) {
		for(ll j = i + 1; j <= min(L + 2019, R); ++j) {
			ans = min(ans, (i * j) % 2019);
		}
	}
	
	cout << ans << endl;

	return 0;
}


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

struct Sieve {
  int n;
  //f:f[i]がiを最初に割った素数を表す配列 例）f[36] = 2;
  //primes:n以下の素数を集めた配列
  vector<int> f,primes;
  Sieve(int n = 1):n(n),f(n+1) {
    f[0] = f[1] = -1;
    for(int i = 2;i <= n;i++) {
      if(f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for(int j = i*2;j <= n;j += i) if(!f[j]) f[j] = i;
    }
  }
  //xが素数か判定する関数
  bool ifPrime(int x) {
    return f[x] == x;
  }

  //xを素因数分解する関数
  vector<int> factorlist(int x) { 
    vector<int> res;
    while(x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }

  //整数xの素因数を集めた配列をランレングス圧縮
  vector<pair<int,int>> factor(int x) {
    vector<int> fl = factorlist(x);
    if(fl.size() == 0) return {};
    vector<pair<int,int>> res(1,pair<int,int>(fl[0],0));
    for(int p : fl) {
      if(res.back().first == p) {
        res.back().second++;
      }else {
        res.emplace_back(p,1);
      }
    }
    return res;
  }
};

int main() {

  int N;
  cin >> N;

  Sieve s(10000);
  vector<int> primes = s.primes;
  int num = 0;
  for(int i = 0;i < primes.size() and num < N;i++) {
    if(primes.at(i) % 5 == 1) {
      cout << primes.at(i) << " ";
      num++;
    }
  }
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint(), M = getint(), L = getint();
	int C[301][301];
	rep1(j, N) rep1(i, j - 1) C[i][j] = 1e9 + 1;
	rep(i, M) {
		int a = getint(), b = getint(), c = getint();
		C[a][b] = c;
		C[b][a] = c;
	}

	rep1(k, N) {
		rep1(j, k - 1) {
			rep1(i, j - 1) {
				chmin(C[i][j], C[i][k] + C[j][k]);
			}
		}
		for (int j = k + 1; j <= N; j++) {
			rep1(i, k - 1) {
				chmin(C[i][j], C[i][k] + C[k][j]);
			}
			for (int i = k + 1; i < j; i++) {
				chmin(C[i][j], C[k][i] + C[k][j]);
			}
		}
	}

	rep1(j, N) rep1(i, j - 1) {
		C[i][j] = (C[i][j] <= L) ? 1 : 1e9;
	}

	rep1(k, N) {
		rep1(j, k - 1) {
			rep1(i, j - 1) {
				chmin(C[i][j], C[i][k] + C[j][k]);
			}
		}
		for (int j = k + 1; j <= N; j++) {
			rep1(i, k - 1) {
				chmin(C[i][j], C[i][k] + C[k][j]);
			}
			for (int i = k + 1; i < j; i++) {
				chmin(C[i][j], C[k][i] + C[k][j]);
			}
		}
	}

	int Q = getint();
	rep(i, Q) {
		int s = getint(), t = getint();
		if (s > t) swap(s, t);
		if (C[s][t] == 1) {
			*di++ = '0';
			*di++ = '\n';
		}
		else if (C[s][t] < 1e9) putint(C[s][t] - 1);
		else {
			*di++ = '-';
			*di++ = '1';
			*di++ = '\n';
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 1152
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
	auto A = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
	A[rint].writeln;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int X=sc.nextInt();
        if((A+B>=X)&&(A<=X)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

}
        
        
    }


Measured memory_bytes: 21716
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {
    double a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;

    double c = abs(a - b);
    double u = abs(v - w);

    // cout << c << ' ' << u << endl;

    if(w >= v) {
        cout << "NO" << endl;
    }
    else if(c / u <= t) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;

    return 0;
}

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

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

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

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

//}

int n,m,k,a,b,c,ans;
string s;

main(){
	cin>>n>>s;
	ans=n;
	int rs[n+1],rb[n+1],sb=0,ss=0;
	rep(i,n){
		if(s[i]=='.'){
			ss++;
			rs[i+1]++;
		}if(s[i]=='#'){
			sb++;
			rb[i+1]++;
		}
	}
	//rep(i,n)r[i+1]+=r[i];
	int ns=0,nb=0;
	rep(i,n){
		chmin(ans,nb+ss-ns);
		if(s[i]=='.'){
			ns++;
		}
		if(s[i]=='#'){
			nb++;
		}
	}
	chmin(ans,nb+ss-ns);
	dans;
}





Measured memory_bytes: 3716
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int N;
    long M;
    cin >> N >> M;
    long A[N];
    long B[N];
    map<long, int> m;
    for(int i=0; i<N; i++){
        cin >> A[i];
        B[i] = A[i];
        if(i != 0) B[i] += B[i-1];
        if(!m.count(B[i]%M)) m.insert({B[i]%M, 1});
        else m.at(B[i]%M)++;
    }
    long ans = 0;
    auto itr = m.begin();
    while(itr != m.end()){
        long v = itr->second;
        if(!itr -> first) ans += v; 
        ans += v * (v - 1) / 2;
        ++itr;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
n=int(input())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0],dp[1]=0,abs(h[1]-h[0])

for i in range(2,n):
    pre1=abs(h[i]-h[i-1])+dp[i-1]
    pre2=abs(h[i]-h[i-2])+dp[i-2]
    dp[i]=min(pre1,pre2)
print(dp[-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,x[MAXN],y[MAXN],type[MAXN],ans;
char str[3];
vector<P> h[MAXN],v[MAXN],rt[2*MAXN];
void check(vector<P> &vv,int mult)
{
    if(!vv.size()) return;
    sort(vv.begin(),vv.end());
    int last=-1;
    for(int j=0;j<(int)vv.size();j++)
    {
        if(vv[j].S==0) last=vv[j].F;
        else if(last!=-1) ans=min(ans,mult*(vv[j].F-last));
    }
    vv.clear();
}
int main()
{
    scanf("%d",&n);
    ans=INF;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%s",&x[i],&y[i],str);
        if(str[0]=='U') type[i]=1;
        else if(str[0]=='D') type[i]=2;
        else if(str[0]=='L') type[i]=3;
        else if(str[0]=='R') type[i]=4;
        if(type[i]==1) v[x[i]].push_back(P(y[i],0));
        else if(type[i]==2) v[x[i]].push_back(P(y[i],1));
        else if(type[i]==3) h[y[i]].push_back(P(x[i],1));
        else h[y[i]].push_back(P(x[i],0));
    }
    for(int i=0;i<=200000;i++) check(h[i],5);
    for(int i=0;i<=200000;i++) check(v[i],5);
    for(int i=1;i<=n;i++)
    {
        if(type[i]==4) rt[y[i]-x[i]+200000].push_back(P(x[i],0));
        else if(type[i]==2) rt[y[i]-x[i]+200000].push_back(P(x[i],1));
    }
    for(int i=0;i<=400000;i++) check(rt[i],10);
    for(int i=1;i<=n;i++)
    {
        if(type[i]==4) rt[x[i]+y[i]].push_back(P(x[i],0));
        else if(type[i]==1) rt[x[i]+y[i]].push_back(P(x[i],1));
    }
    for(int i=0;i<=400000;i++) check(rt[i],10);
    for(int i=1;i<=n;i++)
    {
        if(type[i]==3) rt[y[i]-x[i]+200000].push_back(P(x[i],1));
        else if(type[i]==1) rt[y[i]-x[i]+200000].push_back(P(x[i],0));
    }
    for(int i=0;i<=400000;i++) check(rt[i],10);
    for(int i=1;i<=n;i++)
    {
        if(type[i]==3) rt[x[i]+y[i]].push_back(P(x[i],1));
        else if(type[i]==2) rt[x[i]+y[i]].push_back(P(x[i],0));
    }
    for(int i=0;i<=400000;i++) check(rt[i],10);
    if(ans==INF) puts("SAFE"); else printf("%d\n",ans);
}

Measured memory_bytes: 40224
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, a;
  cin >> n;
  ll two=0, four=0;
  rep(_, n) {
    cin >> a;
    if(a%4==0) four++;
    else if(a%2==0) two++;
  }
  bool able=0;
  if(two==0) {if(four>=n/2) able=1;}
  else {if(four>=(n-two+1)/2) able=1;}
  if(able) cout << "Yes" << newl;
  else cout << "No" << newl;
  return 0;
}


Measured memory_bytes: 256
from fractions import gcd
# from math import gcd

N, K = map(int, input().split())
A = list(map(int, input().split()))

M = max(A)

g = A[0]
for a in A:
    g = gcd(g, a)

if K <= M and K % g == 0:
    print ('POSSIBLE')
else:
    print ('IMPOSSIBLE')

Measured memory_bytes: 88428
//#define CCF
#define OLD

#ifndef CCF
    #pragma comment(linker, "/STACK:102400000,102400000")
    #ifdef OLD
        #pragma GCC diagnostic error "-std=c++11"
    #endif
    #pragma GCC optimize ("O3")
    #pragma GCC -mcmodle=large
#endif

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

int a[4010],pb[2010],pw[2010],cb[2010][2010],cw[2010][2010],f[2010][2010];
char c[4010];

int main(){
	int n,i,j,s;
 	scanf("%d",&n);
	for(i=1;i<=n<<1;i++){
		scanf("%s%d",c+i,a+i);
		(c[i]=='B'?pb:pw)[a[i]]=i;
	}
	for(i=1;i<=n;i++){
		s=0;
		for(j=pb[i]+1;j<=n<<1;j++){
			if(c[j]=='B'&&a[j]<i)s++;
		}
		for(j=0;j<=n;j++){
			if(pw[j]>pb[i])s++;
			cb[i-1][j]=s;
		}
		s=0;
		for(j=pw[i]+1;j<=n<<1;j++){
			if(c[j]=='W'&&a[j]<i)s++;
		}
		for(j=0;j<=n;j++){
			if(pb[j]>pw[i])s++;
			cw[j][i-1]=s;
		}
	}
	for(i=1;i<=n;i++){
		f[i][0]=f[i-1][0]+cb[i-1][0];
		f[0][i]=f[0][i-1]+cw[0][i-1];
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++)f[i][j]=min(f[i-1][j]+cb[i-1][j],f[i][j-1]+cw[i][j-1]);
	}
	printf("%d",f[n][n]);
	return 0;
}

Measured memory_bytes: 47616
s = gets.chomp.chars
q = gets.to_i
ans = [[],s]
q.times do 
    order = gets.chomp.split(' ')
    if order.size == 1
        ans[0],ans[1] = ans[1],ans[0]
    else
        if (order[1] == "1")
            ans[0] << order[2]
        else
            ans[1] << order[2]
        end
    end
end
final = ans[0].reverse.join('') + ans[1].join('')
puts final


Measured memory_bytes: 35072
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#include<bits/stdc++.h>
#define fr first
#define sc second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define forn(i,n) for(int i =1;i<= (n);++i)
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
const int inf = 1e9+7;
const int nmax = 500005;
const ll linf = LLONG_MAX;
const ll mod = 1000000007;

ll n, cost[200005] , p2[200005] , scost[200005] , dp[200005];
int main(){
    fast;
    cin >> n;
    forn(i,n){
        cin >> cost[i];
    }
    sort(cost+1, cost+n+1);
    forn(i,n){
        scost[i] = scost[i-1] + cost[i];
        scost[i] %= mod;
    }
    p2[0] = 1;
    forn(i,n){
        p2[i] = 2*p2[i-1];
        p2[i] %= mod;
    }
    forn(i,n){
        dp[i] = 2*dp[i-1] + p2[(i-2 >= 0 ? i-2 : 0)]*scost[i-1] + cost[i]*p2[i-1];
        dp[i] %= mod;
    }
    cout << (dp[n]*p2[n])%mod;
    // (A , B) -> differ in k points , if we choose the k points , E 2^n pairs that differ in exactly those k points
    // (A , B) = k * cost[p1] + (k-1)*cost[p2] + .... 1*cost[pk]

    // dp[i] - total sum of costs of pairs where the last point of difference is <= i
    // dp[i] = 2*dp[i-1] + (for every combination we need to add sum of cost[j] of that combination - every point is in 2^(i-2) - combinations) + cost[i]
}


Measured memory_bytes: 6528
N = int(input())
S1 = input()
S2 = input()
dp_v = 0
dp_h = 0
mod = 1000000007
is_first = True
while S1:
    if len(S1) > 1 and S1[0] == S1[1]:
        S1 = S1[2:]
        if is_first:
            dp_h = 6
            dp_v = 0
            is_first = False
        else:
            dp_h = dp_v*2+dp_h*3
            dp_v = 0
    else:
        S1 = S1[1:]
        if is_first:
            dp_v = 3
            dp_h = 0
            is_first = False
        else:
            dp_v = dp_v*2+dp_h
            dp_h = 0
    dp_v %= mod
    dp_h %= mod
print((dp_h+dp_v) % mod)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007LL
#define eps 1e-8
#define N 1000002
#define all(x) (x).begin(), (x).end()

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vector<vector<int>> v(3, vector<int>(3));

    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            cin >> v[i][j];

    int n;
    cin >> n;
    while (n--) {
        int c;
        cin >> c;

        for (int i=0;i<3;i++) {
            for (int j = 0; j < 3; j++) {
                if (v[i][j] == c) {
                    v[i][j] = 0;
                }
            }
        }
    }

 

    for (int i = 0; i < 3; i++) {
        int ctr = 0;
        for (int j = 0; j < 3; j++) {
            if (!v[i][j]) ctr++;
        }
        if (ctr == 3) {
            cout << "Yes";
            return 0;
        }
    }
    for (int j = 0; j < 3; j++) {
        int ctr = 0;
        for (int i = 0; i < 3; i++) {
            if (!v[i][j]) ctr++;
        }
        if (ctr == 3) {
            cout << "Yes";
            return 0;
        }
    }

    int ctr = 0;
    for (int i = 0; i < 3; i++) {
        if (!v[i][i]) ctr++;
    }
    if (ctr == 3) {
        cout << "Yes";
        return 0;
    }
    ctr = 0;
    for (int i = 0; i < 3; i++) {
        if (!v[i][2-i]) ctr++;
    }

    if (ctr == 3) {
        cout << "Yes";
        return 0;
    }
    cout << "No";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		for (int i = x - k + 1; i < x + k; i++) {
			System.out.print(i + " ");
		}

	}

}


Measured memory_bytes: 23892
import collections
import bisect

n,m = map(int,input().split())
 
city = [[] for _ in range(n+1)]
arr = []
 
for i in range(m):
    s,t = map(int,input().split())
    arr.append((s,t))
 
city =collections.defaultdict(list)

for x,y in sorted(arr):
    city[x] += [y]
for x,y in arr:
    z=str(bisect.bisect(city[x],y))
    print(str(x).rjust(6, "0") + z.rjust(6,"0"))


Measured memory_bytes: 36336
#include<bits/stdc++.h>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define pb push_back
#define mk make_pair
#define ascSort(v) sort(v.begin(), v.end())
#define descSort(v) sort(v.begin(), v.end(), greater<int>())
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define umapi unordered_map<int,int>

const int m=998244353;
using namespace std;

void FIO(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
}





int32_t main(){
	
	//FIO();
	
	string s,t;cin>>s>>t;
	string ans;
	int dp[s.length()+1][t.length()+1];
	for(int i=0; i<=s.length(); i++)
		dp[i][0]=0;
	for(int i=0; i<=t.length(); i++)
		dp[0][i]=0;
	int i,j;
	for(i=1; i<=s.length(); i++){
		for(j=1; j<=t.length(); j++){
			if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	i--;j--;
	while(dp[i][j]){
		if(dp[i][j]==dp[i-1][j])
			i--;
		else if(dp[i][j]==dp[i][j-1])
			j--;
		else{
			ans.pb(s[i-1]);i--;j--;
		}

	}
	for(int i=0; i<ans.length()/2; i++){
		swap(ans[i],ans[ans.length()-i-1]);

	}
	cout<<(ans.length()?ans:" ")<<"\n";
	return 0;
		
		
	
		
		
}


Measured memory_bytes: 70656
//D 二次元累積和
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int main() {
	iostream::sync_with_stdio(false);
	int N, M, Q;
	cin >> N >> M >> Q;
	int wa[501][501];
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			wa[i][j] = 0;
		}
	}
	for (int i = 0; i < M; i++) {
		int l, r;
		cin >> l >> r;
		wa[l][r]++;
	}
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			wa[i][j] += wa[i - 1][j] + wa[i][j - 1] - wa[i - 1][j - 1];
		}
	}
	for (int i = 0; i < Q; i++) {
		int p, q;
		cin >> p >> q;
		cout << wa[q][q] - wa[p - 1][q] - wa[q][p - 1] + wa[p - 1][p - 1] << endl;
	}
	
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    int n = s.length();
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = s[n-i-1]-'0';
    }
    
    int ans;
    if (count(a.begin(), a.begin() + n-1, 9) == n-1) {
        ans = accumulate(a.begin(), a.end(), 0);
    } else {
        ans = 9 * (n-1);
        ans += a.back()-1;
    }
    
    cout << ans << endl;
    
    return 0;
}

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

class Main{




	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(c >= a && c <= b){
			System.out.println("Yes");
		}else{
			System.out.println("No");

		}

	}

}

class MyComparator implements Comparator {
	 
    public int compare(Object obj1, Object obj2) {
         
        int num1 = (int)obj1;
        int num2 = (int)obj2;
         
        if(num1 < num2) {
            return 1;
        } else if(num1 > num2) {
            return -1;
        } else{
            return 0;
        }
    }
}




Measured memory_bytes: 21844
from operator import itemgetter

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

score = 0
e = []
for idx in range(N):
    b, l, u = map(int, input().split())
    score -= b * l
    adv = (X - b) * u + b * l
    e.append((b, l, u, adv))

e.sort(key=itemgetter(3), reverse=True)  # adv降順ソート
c_adv = [0]
for b, l, u, adv in e:
    c_adv.append(c_adv[-1] + adv)


def is_ok(total):
    x_subject_count, remain_score = divmod(total, X)
    if remain_score > 0:
        for remain_subject_index in range(N):
            b, l, u, adv = e[remain_subject_index]
            remain_adv = (remain_score - b) * (u if b <= remain_score else l) + b * l

            if remain_subject_index >= x_subject_count:
                if remain_adv + c_adv[x_subject_count] + score >= 0:
                    return True
            else:
                if remain_adv + c_adv[x_subject_count + 1] - adv + score >= 0:
                    return True
    else:
        if c_adv[x_subject_count] + score >= 0:
            return True
    return False


def binary_search():
    ng = -1
    ok = X * N
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok


print(binary_search())


Measured memory_bytes: 73304
#include<stdio.h>
int main()
{
	int a,b,c,d,e;
	scanf("%d %d",&a,&b);
	c = a + b;
	d = c - 24;
	e=0;
	if(c < 24) 
		printf("%d\n",c);
	else if(c == 48) 
		printf("%d\n",e);
	else 
		printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,k,q = readline() |> split |> parseMap
	g = k*ones(Int,n)
	for i in 1:q
		a = readline() |> parseInt
		g[a] += 1
	end
	for i in 1:n
		println(g[i]-q>0?"Yes":"No")
	end
end

main()

Measured memory_bytes: 165164
#include <bits/stdc++.h>
    #define MAX 100007
     
    #define REP(i, N) for(int (i)=0; (i) < (N); (i)++)
    #define PER(i, N) for(int (i)=(N)-1; (i) >= 0; (i)--)
     
    using namespace std;
    typedef long long ll;
    typedef pair<ll, int> pii;
     
    int main(){
        
        string s; cin >> s;
     
        REP(i, s.size()){
            if(s[i] == '7') {
                cout << "Yes\n";
                return 0;
            }
        }
        cout << "No\n";
        return 0;
    }

Measured memory_bytes: 3628
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>

using namespace std;

void Solution()
{
    int n;
    
    cin>>n;
    
    cout<<n / 3600<<":"<<(n % 3600) / 60<<":"<<(n % 3600) % 60<<endl;
}



int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1160
import numpy as np
num=np.array(list(input()))

for bit in  range(1<<3):
  op=np.array(['-']*3)
  for i in range(3):
    if (bit>>i)&1:
      op[i]='+'
  formula=np.insert(num,[1,2,3],op)
  
  if eval(''.join(formula))==7:
    flag=True
    print(''.join(formula)+'=7')
    break

Measured memory_bytes: 12488
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main(int argc, char const *argv[])
{
    string s; cin >> s;
    istringstream sy(s.substr(0,4)), sm(s.substr(5,7));
    int y, m;
    sy >> y; sm >> m;
    if(y<2019) {
        return 1;
    } else if (y>=2019 && m<=4) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 8000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

int x,y;
char str[N];
bitset<N*2> bs[2];
int main(){
    scanf("%s",str);
    scanf("%d%d",&x,&y);

    int i=0;
    while(str[i]=='F')
        i++;
    int nx=i+N,ny=N;
    bs[0][nx]=1;
    bs[1][ny]=1;

    int num=0;
    int pos=0;
    while(i<=strlen(str)){
        if(str[i]=='F')
            num++;
        else{
            bs[pos]=(bs[pos]<<num) | (bs[pos]>>num);
            pos=!pos;
            num=0;
        }
        i++;
    }

    if(bs[0][x+N] & bs[1][y+N])
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=1e5+10;
string s;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>s;
	int n=s.size();
	string t(n,'x');
	cout<<t<<endl;
	return 0;
}

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

using namespace std;

int main(){
    string str;
    cin >> str;
    int res_a = 0;
    for(char c : str){
        res_a += c - '0';
    }
    int res_b = (str[0] - '0' - 1) + (str.size() - 1) * 9;
    cout << std::max(res_a, res_b) << endl;
    return 0;
}


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

int main(){
    char c11,c12,c13,c21,c22,c23;
    cin >> c11 >> c12 >> c13 >> c21 >> c22 >> c23;
    if(c11 == c23 && c12 == c22 && c13 == c21) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

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

std::vector<int> L(1000);

int N,M;
int main(void){
    while(std::cin >> N >> M){
        if(N == 0 && M == 0) break;
        for(int i=0; i<N; ++i){
            std::cin >> L[i];
        }

        bool f;
        std::vector<int> b(1012);
        for(int S=0; S<(1<<M); ++S){
            int sum = 0;
            for(int i=0; i<M; ++i){
                b[i] = (S>>i&1);
                sum += b[i];
            }

            for(int i=0; i<N-1; ++i){
                b[M+i] = L[i+1] - L[i] + b[i];
            }

            f = (sum == L[0]);
            for(int i=0; i<N+M-1; ++i){
                if(b[i] != 0 && b[i] != 1){
                    f = false;
                }
            }
            if(f){
                break;
            }
        }

        if(f){
            for(int i=0; i<N+M-1; ++i){
                std::cout << b[i];
            }
            std::cout << std::endl;
        }else{
            std::cout << "Goofy" << std::endl;
        }
    }
}

Measured memory_bytes: 3028
using System;

namespace ConsoleApp1
{
    class Class1
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string[] PQR = S.Split(' ');

            int P = int.Parse(PQR[0]);
            int Q = int.Parse(PQR[1]);
            int R = int.Parse(PQR[2]);

            int PQ = P + Q;
            int QR = Q + R;
            int PR = P + R;

            if(PQ<=QR && PQ<=PR)
            {
                Console.WriteLine(PQ);
            }
            else if(QR<=PQ && QR<=PR)
            {
                Console.WriteLine(QR);
            }
            else
            {
                Console.WriteLine(PR);
            }
        }
    }
}


Measured memory_bytes: 13140
import java.io.*;

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

      BufferedReader br =
       new BufferedReader(new InputStreamReader(System.in));

      String str = br.readLine();
      int x = Integer.parseInt(str);

      System.out.println( (int)Math.pow(x,3) );

   }
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


int main() {
    int m1, d1; cin >> m1 >> d1;
    int m2, d2; cin >> m2 >> d2;

    // 2 4 6 9 11は30
    if(m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11){
        if(d1 == 30){
            cout << 1 << endl;
            return 0;
        }
    }else if(m1 == 2){
        if(d1 == 28){
            cout << 1 << endl;
            return 0;
        }
    }else{
        if(d1 == 31){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;



    return 0;
}


Measured memory_bytes: 3648
w, h, n = map(int, input().split())
ls = [[] for _ in range(4)]
for _ in range(n):
    x, y, a = map(int, input().split())
    ls[a - 1].append(x if a < 3 else y)
l = max(ls[0] + [0])
r = min(ls[1] + [w])
d = max(ls[2] + [0])
u = min(ls[3] + [h])
if u - d < 0 or r - l < 0:
    print(0)
else:
    print((u - d) * (r - l))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    for(int i=0;i<9;i++){
        char c;std::cin>>c;
        if(i==0||i==4||i==8){
            std::cout<<c;
        }
    }
    std::cout<<std::endl;
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

struct directed_graph {
  static const int N = 1e5 + 5;
  struct data {
    int node; int val;
    data() : node(-1), val(-1) {}
    data(int node, int val) : node(node), val(val){}
  };
  int n; int ind[ N ]; vector <data> g[ N ];
  void init(int _n){
    n = _n;
    for (int i = 0; i <= n; i++) ind[i] = 0, g[i].clear();
  }
  void add_edge(int u, int v, int val = 0) {
    g[u].push_back(data(v, val)); ind[v]++;
  }
  vector <int> topological_order() {
    queue <int> q;
    for (int i = 1; i <= n; i++) if (ind[i] == 0) q.push(i);
    vector <int> ans;
    while (!q.empty()) {
      int to = q.front(); q.pop(); ans.push_back(to);
      for (auto x : g[to]) {
        ind[x.node]--;
        if (ind[x.node] == 0) q.push(x.node);
      }
    }
    if ((int)ans.size() != n) return vector <int> {}; return ans;
  }
} g;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int n, e;
  cin >> n >> e;
  g.init(n);
  for (int i = 1; i <= e; i++) {
    int u, v;
    cin >> u >> v;
    g.add_edge(u, v, 1);
  }
  vector <int> t = g.topological_order();
  vector <int> path(n + 1, 0);
  for (auto x: t) {
    for (auto val: g.g[x]) {
      path[val.node] = path[x] + 1;
    }
  }
  int mx = 0;
  for (auto x: t) mx = max(mx, path[x]);
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 7032
fun main(args: Array<String>) {
    var n = getInt()
    var m = HashMap<Long, Int>()
    var sum = 0L
    getLongs().forEach {
        sum += it
        m[it] = (m[it] ?: 0) + 1
    }

    val q = getInt()
    repeat(q) {
        val (a, b) = getLongs()

        sum += (b - a) * (m[a] ?: 0)
        m[b] = (m[b] ?: 0) + (m[a] ?: 0)
        m[a] = 0
        println(sum)
    }
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }

Measured memory_bytes: 77704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] line = br.readLine().split(" ");
		
		int h = Integer.parseInt(line[0]);
		int k = Integer.parseInt(line[1]);
		line = br.readLine().split(" ");
		br.close();
		List<Long> mons = new ArrayList<Long>();
		for(String s:line) {
			mons.add(Long.parseLong(s));
		}
		
		Collections.sort(mons,Collections.reverseOrder());
		
		long count = 0;
		for(int i=0;i<mons.size();i++) {
			if(i<k) continue;
			count += mons.get(i);
		}
		System.out.println(count);
		
	}
}


Measured memory_bytes: 69304
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <map>
#define ll long long
using namespace std;
const int  N=1e5+9;
int  n,a[N];
int main()
{
    while(~scanf("%d",&n))
    {
        for(int i=1; i<=n; i++)
        {
            scanf("%d",&a[i]);
        }
        int  cnt=0;
        int  j=1;
        while(j<=n)
        {
            if(a[j]==j)
            {
                cnt++;
                j+=2;
            }
            else
            {
                j++;
            }
        }
        printf("%d\n",cnt);
    }
return 0;
}


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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "CONTINUE"
#define FALSE__ "GAMEOVER"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define YES(f) if((f)){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(f) if((f)){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))

#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
#define fcout cout << fixed << setprecision(12)

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	int N, T;
	cin >> N >> T;
	vector<int> imos(T+1);
	rep(i, N) {
		int l, r;
		cin >> l >> r;
		imos[l]++;
		imos[r]--;
	}
	int ma = imos[0];
	reps(i, 1, T+1) {
		imos[i] += imos[i-1];
		chmax(ma, imos[i]);
	}
	cout << ma << endl;
}


void solve()
{
}






Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string a, b;

void calc() {
    if (a.size() > 80 || b.size() > 80) { cout << "overflow" << endl; return; }
    if (b.size() > a.size()) swap(a, b);
    int a1, b1, size1 = a.size()-1, size2 = b.size()-1, mod = 0, sum;
    while (size1 >= 0 && size2 >= 0) {
        a1 = a[size1] - '0';
        b1 = b[size2] - '0';
        sum = a1 + b1 + mod;
        mod = (sum > 9) ? 1 : 0; sum %= 10;
        a[size1] = (char) '0' + sum;
        size1--; size2--;
    }
    while (size1 >= 0 && mod > 0) {
        a1 = a[size1] - '0';
        sum = a1 + mod;
        mod = (sum > 9) ? 1 : 0; sum %= 10;
        a[size1] = (char) '0' + sum;
        size1--;
    }
    if (mod > 0) a = "1" + a;
    if (a.size() > 80) cout << "overflow" << endl;
    else cout << a << endl;
}


int main()  {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        calc();
    }

}



Measured memory_bytes: 3152
#include <stdio.h>
int power(int b,int p){
	int a=1,i;
	for(i=1; i<=p; i++){
		a=a*b;
	}
	return a;
}
int main(void)
{
	int n,k;
	scanf("%d%d",&n,&k);
	printf("%d\n",k*power(k-1,n-1));
	return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }


int main()
{
    int n;
    while (cin >> n) {
        VI A(n+1), B(n);
        FOR(i,0,n+1)
            cin >> A[i];
        FOR(i,0,n)
            cin >> B[i];
        LL ans = 0;
        FOR(i,0,n) {
            const int x = min(A[i],B[i]);
            ans += x;
            const int y = min(A[i+1],B[i]-x);
            ans += y;
            A[i+1] -= y;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;

    if (a + b == c || b + c == a || c + a == b) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}


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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

void solve() {
    ll n, a, b;
    cin >> n >> a >> b;

    if (abs(a-b)%2==0) {
        cout << abs(a-b)/2 << endl;
        return;
    }

    ll lo = min(a,b);
    ll hi = max(a,b);

    ll at_begin = hi - 1;
    ll at_end = n - lo;
    
    ll go_end = n - hi + 1;
    ll center_end = go_end + (n - (lo + go_end)) / 2;

    ll go_begin = lo - 1 + 1;
    ll center_begin = go_begin + ((hi - go_begin) - 1) / 2;

    cout << min(min(min(at_begin, at_end),center_begin),center_end) << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
    solve();
}


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

using namespace std;

typedef long long LL;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
    cout<<fixed;
    cout<<setprecision(10);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define fi first
#define se second
#define pb push_back

template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<int> V;
typedef vector<V> VV;
int main(){
    int N,M;
    cin>>N>>M;
    VV g(N,V(N,0));
    REP(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a][b]=g[b][a]=1;
    }
    V seq(N-1);
    iota(seq.begin(),seq.end(),1);
    int res=0;
    do{
        int ans=1;
        if(!g[0][seq[0]])
           ans=0;
        REP(i,N-2){
            if(!g[seq[i]][seq[i+1]])
                ans=0;
        }
        res+=ans;
    }while(next_permutation(seq.begin(),seq.end()));
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        String n = arr01[0];

        System.out.println(n.indexOf('7') >= 0 ? "Yes" : "No");

    }

}


Measured memory_bytes: 32572