akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int h, w;
  cin >> h >> w;
  v2i dp(h, v1i(w));
  vector<string> v(h);
  rep(i, h) cin >> v[i];
  rep(i, h){
    rep(j, w){
      if(i == 0 && j == 0){
        if(v[i][j] == '#') dp[i][j] = 1;
        else dp[i][j] = 0;
      }
      else if(i == 0){
        if(v[i][j-1] == '.' && v[i][j] == '#') dp[i][j] = dp[i][j-1]+1;
        else dp[i][j] = dp[i][j-1];
      }
      else if(j == 0){
        if(v[i-1][j] == '.' && v[i][j] == '#') dp[i][j] = dp[i-1][j]+1;
        else dp[i][j] = dp[i-1][j];
      }
      else{
        int t, s;
        if(v[i][j-1] == '.' && v[i][j] == '#') t = dp[i][j-1]+1;
        else t = dp[i][j-1];
        if(v[i-1][j] == '.' && v[i][j] == '#') s = dp[i-1][j]+1;
        else s = dp[i-1][j];
        dp[i][j] = min(t, s);
      }
    }
  }
  cout << dp[h-1][w-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,m,q,a[2020][2020],d[2020][2020],sd[2020][2020],lx,rx,ly,ry,du[2020][2020],dd[2020][2020],dl[2020][2020],dr[2020][2020];
char s[2020][2020];
int ed,di;
int main(){
	scanf("%d%d%d",&n,&m,&q);
	fo(i,1,n) scanf("%s",s[i]+1);
	fo(i,1,n)
		fo(j,1,m){
			a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
			if (s[i][j]=='1') a[i][j]++;
			if (s[i][j]=='1'&&s[i-1][j]=='1'){
				d[i][j]++;du[i][j]++;
			}
			if (s[i][j]=='1'&&s[i][j-1]=='1'){
				d[i][j]++;dl[i][j]++;
			}
			if (s[i][j]=='1'&&s[i+1][j]=='1'){
				d[i][j]++;dd[i][j]++;
			}
			if (s[i][j]=='1'&&s[i][j+1]=='1'){
				d[i][j]++;dr[i][j]++;
			}
		}
	fo(i,1,n)
		fo(j,1,m)
			sd[i][j]=sd[i-1][j]+sd[i][j-1]-sd[i-1][j-1]+d[i][j];
	fo(i,1,n){
		fo(j,1,m){
			dd[i][j]+=dd[i][j-1];
			du[i][j]+=du[i][j-1];
		}
	}
	fo(j,1,m){
		fo(i,1,n){
			dl[i][j]+=dl[i-1][j];//dl[i][j-1];
			dr[i][j]+=dr[i-1][j];//dr[i][j-1];
		}
	}
	while (q--){
		scanf("%d%d%d%d",&lx,&ly,&rx,&ry);
		//int ed di!!!!
		ed=(sd[rx][ry]-sd[lx-1][ry]-sd[rx][ly-1]+sd[lx-1][ly-1]-du[lx][ry]+du[lx][ly-1]-dd[rx][ry]+dd[rx][ly-1]-dl[rx][ly]+dl[lx-1][ly]-dr[rx][ry]+dr[lx-1][ry])/2;
		di=a[rx][ry]-a[lx-1][ry]-a[rx][ly-1]+a[lx-1][ly-1];
		//printf("%d %d\n",di,ed);
		printf("%d\n",di-ed);
	}
	return 0;
}

Measured memory_bytes: 116992
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<queue>

#define mp(a,b) make_pair(a,b)

using namespace std;
int main(){
  int n;
  while(cin >> n && n != 0){
    int x = 0;
    int mx = -1,mn = 1000;
    for (int i = 0; i < n; ++i){
      int tmp;
      cin >> tmp;
      x += tmp;
      mx = max(tmp,mx);
      mn = min(tmp,mn);
    }
    x -= mn;
    x -= mx;
    x /= n-2;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    const ll m = 1e9 + 7;
    int n;
    cin >> n;
    vector<ll> a(n);
    ll s = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        s += a[i];
    }

    ll ans = 0;

    for (int i = 0; i < n; i++){
        ans = (ans%m)+((a[i]%m)*((s-a[i])%m))%m;
        s -= a[i];
    }
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


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


int main(){

long long int a,b,c,e;
cin>>a>>b>>c>>e;

long long int d = e;

d -= a;

if(d <= 0) cout<<e<<endl;

else{
    d -= b ;
    if(d<= 0) cout<<a<<endl;
    else{
        cout<<a-d<<endl;
    }
}


}


Measured memory_bytes: 3580
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int n,m;
vector<int> g[100005],rg[100005];
int indeg[100005];

int dist[100005];
int rec(int v){
  if(~dist[v]) return dist[v];
  for(auto to:rg[v]){
    chmax(dist[v],rec(to)+1);
  }
  return dist[v];
}
int main(){
  cin>>n>>m;
  REP(i,n-1+m){
    int a,b;scanf("%d%d",&a,&b);--a;--b;
    g[a].pb(b);
    rg[b].pb(a);
  }

  int root=-1;
  REP(i,n) if(rg[i].empty()) root=i;

  assert(~root);
  memset(dist,-1,sizeof(dist));
  dist[root]=0;

  REP(i,n) if(dist[i]==-1){
    rec(i);
  }

  REP(i,n){
    int res=-1;
    for(auto p:rg[i]) if(dist[p]==dist[i]-1){
      res=p;
    }
    printf("%d\n",res+1);
  }
  return 0;
}





Measured memory_bytes: 14080
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int  n;
vector <vector <int> > g;
vector <int> depth;
vector <int> size;
vector <bool> visited;
vector <int> parent;
int dfs(int s,int depth2);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    n=nxt();
    vector <int> r1;
    g.resize(n+1,r1);
    depth.resize(n+1);
    depth[1]=0;
    size.resize(n+1,0);
    for(int i=0;i<n-1;i++)
    {
        int u=nxt(),v=nxt();
        g[u].push_back(v);
        g[v].push_back(u);
    }

    visited.resize(n+1,0);
    parent.resize(n+1,-1);

    dfs(1,0);
    
    int x=n;
    for(int i=0;i<(depth[n]-1)/2;i++)
        x=parent[x];
    int f=size[1]-1-size[x];
    int s=size[x]-1;

    if(f<=s)
        cout<<"Snuke\n";
    else
        cout<<"Fennec\n";
    
    
    return 0;   
}

int dfs(int s,int depth2)
{
    visited[s]=1;
    depth[s]=depth2;
    size[s]=1;
    for(auto i:g[s])
    {
        if(!visited[i])
        {
            parent[i]=s;
            size[s]+=dfs(i,depth2+1);
        }
    }

    return size[s];

}




 
 


Measured memory_bytes: 13184
function Main(input) {
	var inputArr = input.split("\n");
	var knArr = inputArr[0].split(" ");
	var n = parseInt(knArr[0], 10);
	var k = parseInt(knArr[1], 10);
  　inputArr.shift();
  	var list = inputArr
    	.filter(i => i !== '')
    	.sort(function(a, b){return a-b;});
    var min = list[list.length - 1];
	for(var i = 0; i < n - k + 1; i++) {
      var p = list[i + k - 1] - list[i];
      min = p < min ? p : min;
	}
    console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 28948
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

ll expo(ll a, ll b){
    ll ex = 1;
    rep(i, b){
        ex *= a;
    }
    return ex;
}

ll fact(ll a){
    ll fc = 1;
    REP(i, 1, a+1){
        fc *= i;
    }
    return fc;
}

int main() {
    ll n;
    cin >> n;
    if(n%10==3) {
        cout << "bon" << endl;
    }
    else if(n%10==0 || n%10== 1 || n%10==6 || n%10 ==8){
        cout << "pon" << endl;
    }
    else {
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin>>n;
    vi a(n),sum(n,0);
    cin>>a;
    sum[0]=a[0];
    REPF(i,1,n) {
        sum[i]+=sum[i-1]+a[i];
    }

    int ans=INF;
    REP(i,n-1) {
        int a=sum[i];
        int b=sum[n-1]-a;
        chmin(ans,abs(a-b));
    }
    cout<<ans<<endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

class BIT {
public:
    /* [1, n] */
    vector<long long> bit;

    BIT(int M) :
            bit(vector<long long>(M + 1, 0)) {}

    /* [1, a], a is 1-indexed */
    long long sum(int a) {
        long long res = 0;
        for (int i = a; i > 0; i -= (i & -i)) {
            res += bit[i];
        }
        return res;
    }

    /* [a, b), a and b are 1-indexed */
    long long sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }

    /* a is 1-indexed */
    void add(int a, long long x) {
        for (int i = a; i < bit.size(); i += (i & -i)) {
            bit[i] += x;
        }
    }
};

int main() {
    long long N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    int left = 0;
    int right = 1 << 30;
    long long geta = N + 1;
    while (right - left > 1) {
        int mid = (left + right) / 2;
        BIT bit(N * 2 + 10);
        long long num = 0;
        int sum = 0;

        bit.add(sum + geta, 1);
        rep(i, N) {
            int val;
            if (a[i] <= mid) val = 1; else val = -1;
            sum += val;
            num += bit.sum(1, sum + geta);
            bit.add(sum + geta, 1);
        }

        long long boundary = (N + 1) * N / 2 / 2;
        if (num > boundary) right = mid; else left = mid;
    }

    cout << right << endl;
}

Measured memory_bytes: 2176
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll arr[100005],sum[100005],crs[100005];

int main()
{jizz
	ll n,q,x,l,r,t,p,ans=0;
	cin >> n >> q >> arr[0],sum[0]=arr[0];
	for(int i=1;i<n;++i)
		cin >> arr[i],sum[i]=sum[i-1]+arr[i];
	crs[0]=arr[0],crs[1]=arr[1];
	for(int i=2;i<n;++i)
		crs[i]=arr[i]+crs[i-2];
	while(q--)
	{
		cin >> x,l=0,r=1000000000;
		if(x>=arr[n-1])
		{
			cout << crs[n-1] << "\n";
			continue;
		}
		while(l<r)
		{
			ll m=l+r>>1;
			p=lower_bound(arr,arr+n,x-m)-arr;
			t=upper_bound(arr,arr+n,x+m)-arr;
			if(t+1>=n-t+p) r=m;
			else l=m+1;
		}
		p=lower_bound(arr,arr+n,x-l)-arr;
		t=upper_bound(arr,arr+n,x+l)-arr;
		//cout << l << " " << p << " " << t << "\n";
		if(arr[t-1]-x==x-arr[p] && t>=n-t+1+p)
			--t;
		if(t+1==n-t+p) --p;
		//cout << l << " " << p << " " << t << "*\n";
		ans=sum[n-1]-sum[t-1];
		if(p>0) ans+=crs[p-1];
		cout << ans << "\n";
	}
}

Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  int n;
  cin >> n;
  cout << n*n << endl;
}

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

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

typedef long long ll;


using namespace std;

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


long long int n,cnt=0,ans=LINF,a,b,c[ohara],C,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,p[ohara];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>d>>C;
      rep(i,d)cin>>p[i]>>c[i];
      ll cntt=0;
      for(int bit=0;bit<(1<<(d));bit++){
        cntt=0;
        cnt=0;
        map<ll,ll> mp;
        rep(i,d){
          if(bit&(1<<i)){
            cnt+=100*(i+1)*p[i];
            mp[i]++;
            cnt+=c[i];
            cntt+=p[i];
          }
        }
        if(cnt>=C)ans=min(ans,cntt);
        else{
        rrrep(i,d-1,0){
          if(mp[i]==0){
            rrep(j,1,p[i]+1){
              cnt+=100*(i+1);
              cntt++;
              if(j==p[i])cnt+=c[i];
              if(cnt>=C)break;
            }
          }
          if(cnt>=C)break;
        }
        }
        ans=min(ans,cntt);
      }
      Cout(ans);
     

       
return 0;
}


Measured memory_bytes: 2304
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
n = int(input())
s = input()
t = input()
#  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

for i in range(n-1, -1, -1):
    # print(s[-(i+1):], t[:i+1])
    if s[-(i+1):] == t[:i+1]:
        l = len(t[:i+1])
        print((len(t) - l) * 2 + l)
        break
else:
    print(len(s) * 2)


Measured memory_bytes: 3316
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    up = 0
    down = 0
    mp = []
    mm = []
    for _ in range(N):
        w = INF
        e = 0
        for s in sys.stdin.readline().rstrip():
            if s == '(': e += 1
            else: e -= 1
            w = min(w,e)
        if w < 0:
            if e > 0 :mp.append((w,e))
            elif w == e: down += e
            else: mm.append((w,e))
        else: up += e

    mp.sort(reverse=True)
    for w,e in mp:
        if up + w < 0:
            print('No')
            exit(0)
        up += e

    mm.sort(reverse=True)
    for w,e in mm:
        if down - w > 0:
            print('No')
            exit(0)
        down += e


    if up + down == 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 86784
//222/03/2020
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
struct OverloadedNode{
    ll val,pos;
    bool operator < (const OverloadedNode &rhs) const {
        if(val==rhs.val) return pos<rhs.pos;
        else return val<rhs.val;
    }
};

//template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//typedef tree<OverloadedNode,null_type,less<OverloadedNode>,rb_tree_tag,tree_order_statistics_node_update>OverloadedPbds;
//template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
//template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
//template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
//template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
//template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
//template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

/*Containers*/
//vector<ll>v;
//deque<ll>dq;
//stack<ll>stk;
//map<ll,ll>mp;
//unordered_map<ll,ll>ump;
//set<ll>st;
//multiset<ll>mst;
//unordered_set<ll>ust;
//unordered_multiset<ll>umst;
//priority_queue<ll,deque<ll>,greater<ll>>pq;
//Pbds<ll>ost;
/*OverLoaded Containers*/
//vector<OverloadedNode>v;
//deque<OverloadedNode>dq;
//stack<OverloadedNode>stk;
//map<OverloadedNode,OverloadedNode>mp;
//set<OverloadedNode>st;
//multiset<OverloadedNode>mst;
//priority_queue<OverloadedNode>pq;
//OverloadedPbds oost;
/*Global Variables*/

int main(){
    _fastio
    ll n,m;
    cin>>n>>m;
    ll ans=(n*(n-1))/2;
    ans+=((m*(m-1))/2);
    cout<<ans<<en;



    return 0;
}


Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int a, b;
    cin >> a >> b;
    if ((a*b)%2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    //cout << ans << endl;
}

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

using namespace std;
const int N = 1e5 + 3;
vector<pair<int, int>> adj[N];
int color[N];
void go(int node, int p, bool ev) {
	color[node] = ev;
	for (auto child: adj[node])
		if (child.first != p)
			go(child.first, node, (ev + child.second) % 2);
}
int main() {
//	freopen("input.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int u, v, w;
		scanf("%d %d %d", &u, &v, &w);
		adj[u].emplace_back(v, w);
		adj[v].emplace_back(u, w);
	}
	go(1, 0, 0);
	for (int i = 1; i <= n; ++i)
		printf("%d\n", color[i]);
	return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
int main()
{
	int n, k;
	std::cin >> n >> k;
	std::vector<int> d;
	int l;
	for (int i = 0; i < k; i++)
	{
		std::cin >> l;
		d.push_back(l);
	}
	std::vector<int> possible_value;
	for (int i = 0; i <= 9; i++)
	{
		std::vector<int>::iterator fd = find(d.begin(), d.end(), i);
		if (fd == d.end())
		{
			possible_value.push_back(i);
		}
	}
	std::string buf = std::to_string(n);
	std::reverse(buf.begin(), buf.end());
	std::string result;
	int add_value = 0;
	for (unsigned int i = 0; i < buf.size(); i++)
	{
		for (unsigned int j = 0; j < possible_value.size(); j++)
		{
			if ((buf[i] - '0') + add_value == possible_value[j])
			{
				result.append(std::to_string(possible_value[j]));
				break;
			}
			else if ((buf[i] - '0') + add_value < possible_value[j])
			{
				if (i > 0)
				{
					result[i - 1] = '0' + possible_value[0];
				}
				result.append(std::to_string(possible_value[j]));
				add_value = 0;
				break;
			}
			if (j + 1 == possible_value.size())
			{
				add_value = 1;
				result.append(std::to_string(possible_value[0]));
			}
		}
	}
	if (add_value != 0)
	{
		if (possible_value[0] == 0)
		{
			result.append(std::to_string(possible_value[1]));
		}
		else
		{
			result.append(std::to_string(possible_value[0]));
		}
	}
	std::reverse(result.begin(), result.end());
	std::cout << result;
    return 0;
}



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

long long n;

int main(){

	cin>>n;
	
	long long v[n],ans=0;
	vector<int> sol;
	bool neg=true;
	for(int i=0;i<n;i++){
    cin>>v[i];
    if(v[i]>=0)neg=false;
    }
	
	if(neg){
	    long long mas=0;
	    
	    for(int i=1;i<n;i++){
	        if(v[i]>v[mas])mas=i;
        }
        cout<<v[mas]<<endl;
        cout<<n-1<<endl;
        for(int i=0;i<mas;i++)cout<<"1"<<endl;
	    for(int i=mas+1;i<n;i++)cout<<n-i+1<<endl;
	    return 0;
    }
	
	
	long long disp=0,pari=0;
	
	for(int i=0;i<n;i++){
	    if(i%2)disp+=max(0ll,v[i]);
	    else pari+=max(0ll,v[i]);
    }
    long long tmp=0;
    if(pari>=disp){
        cout<<pari<<endl;
        bool ok=true;
        for(int i=0;i<n;i+=2){
            if(v[i]<0){
                
                if(i==0 || i==n-1){
                    if(i==0)ok=false;
                    ans++;
                    sol.push_back(i+1-tmp);
                    tmp++;
                }
                else{
                    ans++;
                    sol.push_back(i+1-tmp);
                    tmp+=2;
                }
            }
        }
        int tmp2=0;
        
        for(int i=int(ok);i<n-tmp;i+=2){
        sol.push_back(i+1-tmp2);
        
        if(i==0)tmp2++;
        else
        tmp2+=2;
        
        ans++;
        }
          
    }
    else{
        
        cout<<disp<<endl;
        
        for(int i=1;i<n;i+=2){
            if(v[i]<0){
                if(i==n-1){
                    ans++;
                    sol.push_back(i+1-tmp);
                    tmp++;
                }
                else{
                    ans++;
                    sol.push_back(i+1-tmp);
                    tmp+=2;
                }
            }
        }
        int tmp2=0;
        for(int i=0;i<n-tmp;i+=2){
        ans++;
        
       
        
        sol.push_back(i+1-tmp2);
        
         if(i==0)
        tmp2++;
        else
        tmp2+=2;
        }
        
    }
    cout<<ans<<endl;
    for(int i=0;i<sol.size();i++)cout<<sol[i]<<endl;

return 0;
}


Measured memory_bytes: 256
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


MY_NAMESPACE(sandbox)
ll gcd(ll a, ll b)
{
	if (a < b)
		swap(a, b);
	if (a % b == 0)
		return b;
	return gcd(b, a % b);
}

ll modpow(ll base, ll exponent, ll mod)
{
	ll retval = 1;
	while (exponent > 0)
	{
		if (exponent % 2)
			retval = (retval * base) % mod;
		exponent /= 2;
		base = (base * base) % mod;
	}
	return retval;
}

class HashPair
{
public:
	static size_t m_hash_pair_random;

	template<class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const {

		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);

		size_t seed = 0;
		seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		seed ^= m_hash_pair_random + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		return seed;
	}
};

size_t HashPair::m_hash_pair_random = (size_t)random_device()();

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

	ll modval = 1000000007;

	int n;
	cin >> n;
	//map<pll, int> cnt;
	unordered_map<pll, int, HashPair> cnt;
	for (int i = 0; i < n; i++)
	{
		ll a, b;
		cin >> a >> b;
		if (a != 0 && b != 0)
		{
			if (a < 0)
			{
				a *= -1;
				b *= -1;
			}
			ll g = gcd(abs(a), abs(b));
			cnt[{a / g, b / g}]++;
		}
		else if (a == 0 && b == 0)
			cnt[{0, 0}]++;
		else if (a == 0)
			cnt[{0, 1}]++;
		else  // b == 0
			cnt[{1, 0}]++;
	}

	ll num00 = 1;
	if (cnt[{0, 0}] == 0)
		num00 = 0;
	else
		num00 = cnt[{0, 0}];
	cnt.erase(make_pair(0,0));

	ll num = 1;
	while (!cnt.empty())
	{
		auto this_item = cnt.begin();
		pll const& this_pair = this_item->first;
		pll anti_pair = { this_pair.second, -this_pair.first };
		if (anti_pair.first < 0)
			anti_pair = { -this_pair.second, this_pair.first };
		else if (anti_pair.first == 0)
			anti_pair = { 0, 1 };
		if (cnt.find(anti_pair) == cnt.end())
			cnt[anti_pair] = 0;
		auto anti_item = cnt.find(anti_pair);

		num = num * (modpow(2, this_item->second, modval) - 1 + modpow(2, anti_item->second, modval) - 1 + 1) % modval;
		cnt.erase(this_item);
		cnt.erase(anti_item);
	}
	ll retval = (num + modval - 1) % modval;
	cout << (retval + num00) % modval << "\n";
		
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 14700
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		for(int i = 0; i < n; i++){
		    x[i] = sc.nextInt();
		}
		
		// 計算
		int result = Integer.MAX_VALUE;
		for(int i = 0; i < n-k+1; i++){
		    if(x[i] < 0 && x[i+k-1] > 0){
		        result = min(result, min(abs(x[i])*2 + abs(x[i+k-1]), abs(x[i]) + abs(x[i+k-1])*2));
		    }else{
		        result = min(result, max(abs(x[i]), abs(x[i+k-1])));
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 52084
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  //ios::sync_with_stdio(false);cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/
vector<int> ans;

struct Data {
  vector<int> e;
};
vector<Data> v;
vector<int> o;
void dfs(int i, int d, int c) {
  if (ans[i] == -1)
    ans[i] = c;
  if (d <= o[i])return;
  o[i] = d;

  if (d > 0)for (auto& j : v[i].e) {
    dfs(j, d - 1, c);
  }
}

void Calc() {

  var(int, n, m);
  v.resize(n);
  ans.resize(n, -1);
  o.resize(n);
  err(n, m);
  rep(i, m) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;

    v[a].e.push_back(b);
    v[b].e.push_back(a);
  }

  int q = in;
  //assert(n <= 2000 && m <= 2000 && q <= 2000);
  struct Q {
    int i;
    int v, d, c;
    void In() { scanf("%d%d%d", &v, &d, &c); }
  };
  vector<Q> qu(q);
  int cnt = 0;
  for (auto& i : qu) {
    i.i = cnt++;
    i.In();
  }
  reverse(all(qu));

  for (auto& i : qu) {
    dfs(i.v - 1, i.d, i.c);
  }
  for (auto& i : ans) {
    cout << (i == -1 ? 0 : i) << endl;
  }
}

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

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

  int val = 1;

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

  cout << val << endl;
}

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

#define lli long long int 
#define pb push_back 
#define in (int i = 0 ; i < n ; i++)
#define jm (int j = 0 ; j < m ; j++)

int main ()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    char str [256];
    scanf(" %s", str);

    if (strcmp(str , "SAT") == 0)
    {
        printf("1\n");
        return 0 ;
    }
    else if (strcmp(str , "MON") == 0)
    {
        printf("6\n");
        return 0 ;
    }
    else if (strcmp(str , "TUE") == 0)
    {
        printf("5\n");
        return 0 ;
    }
    else if (strcmp(str , "WED") == 0)
    {
        printf("4\n");
        return 0 ;
    }
    else if (strcmp(str , "THU") == 0)
    {
        printf("3\n");
        return 0 ;
    }
    else if (strcmp(str , "FRI") == 0)
    {
        printf("2\n");
        return 0 ;
    }
    else if (strcmp(str , "SUN") == 0)
    {
        printf("7\n");
        return 0 ;
    }

    return 0 ;
}

Measured memory_bytes: 256
from itertools import combinations

n = int(input())
D = []
ans = 0
for i in range(n):
    x,y = map(int,input().split())
    D.append((x,y))
for i,j in combinations(range(1,n+1),r=2):
    p,q = D[i-1]
    r,s = D[j-1]
    ans += ((p-r)**2+(q-s)**2)**(0.5)
print(2*ans/n)

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

typedef long long ll;
ll X;

ll pow5 (ll n) {
	ll tmp = n*n;
	return tmp*tmp*n;
}

void f (ll a, ll b) {
	ll tmp = pow5(a) - pow5(b);
	if (tmp == X) {
		cout << a << " " << b << endl;
		return;
	}
	if (a==b)
		return;
	if (tmp > X)
		f(a,b+1);
	else
		f(a+1,b);;
}

int main () {
	cin >> X;
	f (0, -63);
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, W; cin >> N >> W;
	vector<pair<ll, ll>> knp(N);
	ll w1 = 0;
	for (int i = 0; i < N; i++) {
		cin >> knp[i].first >> knp[i].second;
		if (i == 0)w1 = knp[0].first;
		knp[i].first -= w1;
	}

	vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(301, vector<ll>(101,-1000)));
	dp[0][0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 300; j++) {
			for (int k = 0; k <= 100; k++) {
				dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
				if (j + knp[i].first <= 300 && k + 1 <= 100)
					dp[i + 1][j + knp[i].first][k + 1] = max(dp[i + 1][j + knp[i].first][k + 1], dp[i][j][k] + knp[i].second);

			}
		}
	}

	ll ans = 0;
	for (int j = 0; j <= 300; j++) {
		for (int k = 0; k <= 100; k++) {
			if (j + w1 * k <= W) {
				ll temp = dp[N][j][k];
				ans = max(ans, temp);
				/*
				if (temp > 0) {
					printf("j=%d k=%d weight=%lld temp=%lld \n", j, k, j + w1 * k, temp);
					printf("weight=%lld\n", w1 * k);
				}
				*/
			}
		}
	}

	cout << ans << endl;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

class Mod {
  public:
  Mod(){
   setFact(MAX_N);
  }
  ll powmod(ll a, ll p){
    ll ans = 1;
    ll mul = a;
    for(; p > 0; p >>= 1, mul = (mul*mul) % mod){ //初期条件なし、pを2で割り続け、mulの値を更新
      if((p & 1) == 1) ans = ( ans * mul) % mod;//pが1なら ansの値を更新
    }
    return ans;
  }

  const static int MAX_N = 1000000;
  const ll mod = 1e9+7;

  ll fact[MAX_N + 1];
  ll revfact[MAX_N + 1];

  void setFact(int N){
    fact[0] = 1;
    for(int i = 1; i < N; ++i){
      fact[i] = (fact[i-1]*i) % mod;
    }
    revfact[N-1] = powmod(fact[N-1],mod-2);//逆元を求める
    for(int i = N-2;i >= 0;--i){
      revfact[i] = (revfact[i+1] * (i+1)) % mod;
    }
  }

  ll getP(int a,int b){
    return (fact[a] * revfact[b]) % mod;
  }

  ll getC(int a, int b){
    return (fact[a] * revfact[b] % mod) * revfact[a-b] % mod;
  }

  ll mod_add(ll a, ll b) {
    return (a + b) % mod;
  }

  ll mod_sub(ll a, ll b) {
    return (a - b + mod) % mod;
  }

  ll mod_mul(ll a, ll b) {
    return a*b % mod;
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(all(a));

  Mod mods;
  ll M = 0, m = 0;
  REP(i, k - 1, n){
    //cout << mods.getC(i , k - 1) * a[i] % mods.mod << endl;
    M += mods.getC(i  , k - 1) * a[i] % mods.mod ;
  }
  reverse(all(a));
  REP(i, k - 1, n){
    //cout << mods.getC(i  , k - 1) * a[i] % mods.mod << endl;
    m += mods.getC(i  , k - 1) * a[i] % mods.mod ;
  } 

  cout << (M - m) % mods.mod << endl;
  return 0;
}


Measured memory_bytes: 16640
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val s = next()

    var lastColor = s.first()
    var count = 0

    for (i in 1 until s.length) {
        if (lastColor == s[i]) {
            count++
            lastColor = if (s[i] == '0') '1' else '0'
        } else {
            lastColor = s[i]
        }
    }

    println(count)
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main(){

	
	int N;
	cin >> N;
	vecl(dp)
		pb(dp, 0);
	fx(N) {
		vecpl(dp)
	}
	sorts(dp);
	int ans = 0;
	fx(N) {
		dp[x + 1] += dp[x];
	}
	fx(N) {
		if (dp[x+1]-dp[x]>dp[x]*2) {
			ans = x;
		}
	}
	ce(N-ans)


    return 0;
}



Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[n][3];
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			cin >> a[i][j];
		}
	}
	int dp[n][3];
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	for(int i = 1; i < n; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			dp[i][j] = 0;
		}
	}
	for(int i = 1; i < n; i++)
	{
		dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i][0];
		dp[i][1] = max(dp[i-1][0],dp[i-1][2])+a[i][1];
		dp[i][2] = max(dp[i-1][0],dp[i-1][1])+a[i][2];
	}
	int ans = max(dp[n-1][0],dp[n-1][1]);
	cout << max(ans,dp[n-1][2]) << '\n';
}

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

using namespace std;

int n,m;

int main()
{
    scanf("%d%d",&n,&m);
    int ans = n / (2 * m + 1);
    if(n % (m * 2 + 1))
        ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 int main(void){
   long long int a,b,c,d,i,sum=0;
   scanf("%lld",&a);
   for(i=0;i<a+1;i++){
     sum+=i;
   }for(b=0;b<=a;b+=3){
     sum-=b;
   }for(c=0;c<=a;c+=5){
     sum-=c;
   }for(d=0;d<=a;d+=15){
     sum+=d;
   }printf("%lld",sum);
   return 0;
 }
     
   
   

Measured memory_bytes: 1736
def InsertionSort(A,N):
    for i in range(1,N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j = j - 1
        A[j+1] = v
        for j in range(0,N-1):
            print("{0} ".format(A[j]),end = '')
        print(A[N-1])


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

for i in range(0,N-1):
    print("{0} ".format(A[i]),end = '')
print(A[N-1])

InsertionSort(A,N)



Measured memory_bytes: 5984
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
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; }
 
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
 
inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,c,x,y; cin>>a>>b>>c>>x>>y;
  
  ll ans=a*x+b*y;
  chmin(ans, max(x,y)*2*c);
  if(x>y){
    chmin(ans, y*2*c+(x-y)*a);
  }else{
    chmin(ans, x*2*c+(y-x)*b);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
int map[105];


int main()
{
	int n,t,ans;
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%d",&t);
		if(map[t]==0){
			ans++;
			map[t]=1;
		}
	}
	printf("%d",ans); 
	return 0;
} 

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
        String ans = "YES";
        if ((n - n % 2) / 2 + n % 2 < k ) {
		  ans = "NO";
        }
    
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
// Problem : A - Multiplication 1
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

void solve(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int t;
    //cin>>t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <queue>
#include <cstdio>
using namespace std;
typedef long long ll;
ll n;
queue<ll> q;
main(){
	register int i,j;
	char c;
	//freopen("String.in","r",stdin);
	//freopen("String.out","w",stdout);
	while(cin>>c){
		n++;
		if(c=='S')q.push(1);
		else if(!q.empty())q.pop(),n-=2;
	} 
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cctype>
#include <ctime>
#include <algorithm>
#include <cmath>

int nextch(void)
{
    static char bufdatum[BUFSIZ];
    static char *buf = bufdatum, *endbuf = bufdatum;
    if (endbuf == buf)
    {
        endbuf = (buf = bufdatum) + fread(bufdatum, 1, BUFSIZ, stdin);
        if (endbuf == buf)
            return EOF;
    }
    return *buf++;
}

void legit(void) {}

template<typename Car, typename ...Cdr>
void legit(Car &var, Cdr &...Rest)
{
    int peek;
    while (!isdigit(peek = nextch())
#ifdef LEGIT_NEGI
        && peek != '-'
#endif  // LEGIT_NEGI
        )
        ;
#ifdef LEGIT_NEGI
    bool negi;
    if (peek == '-')
        negi = true;
    else
        negi = false;
#endif  // LEGIT_NEGI
    var = 0;
    do
        var = (((var << 2) + var) << 1) + (peek ^ '0');
    while (isdigit(peek = nextch()));
#ifdef LEGIT_NEGI
    if (negi)
        var = -var;
#endif  // LEGIT_NEGI
    legit(Rest...);
}

void solve(void);

int main(void)
{
#ifdef redirect
    freopen("check/data.in", "r", stdin);
    freopen("check/prog.out", "w", stdout);
    freopen("check/log.out", "w", stderr);
#endif  // redirect
#ifdef chrono
    auto begtm = clock();
#endif  // chrono
    solve();
#ifdef chrono
    auto endtm = clock();
    printf("%f\n", static_cast<float>(endtm - begtm) / CLOCKS_PER_SEC);
#endif  // chrono
    return 0;
}

typedef long long laolin;

const size_t MaxN = static_cast<size_t>(2e5) + 7;

size_t n;
laolin arr[MaxN];
laolin proced[MaxN];
bool negi[MaxN];
size_t neginum;

laolin abs(laolin n)
{
    return n < 0 ? -n : n;
}

void solve(void)
{
    legit(n);
    neginum = 0;
    for (size_t i = 0; i < n; ++i)
    {
        legit(arr[i]);
        proced[i] = arr[i] - i;
        if (proced[i] <= 0)
        {
            negi[i] = true;
            ++neginum;
        }
        else
            negi[i] = false;
    }
    std::sort(proced, proced + n);
    laolin mid = proced[n & 1 ? n / 2 : n / 2 - 1];
    laolin sum = 0;
    for (size_t i = 0; i < n; ++i)
        sum += abs(proced[i] - mid);
    printf("%lld\n", sum);
}



Measured memory_bytes: 3584