akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int LL
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
const int MAX_N=100005;
int n,A,B;
int h[MAX_N];
bool check(int k)
{
	int lazy=k*B;
	int res=0;
	rep(i,0,n)res+=ceil(1.0*(h[i]-lazy>0?h[i]-lazy:0)/(A-B));
	return res<=k;
}
signed main()
{
	cin>>n>>A>>B;
	rep(i,0,n)cin>>h[i];
	int lb=1,ub=INF;
	while(lb<ub)
	{
		int mid=(lb+ub)/2;
	//	cout<<mid<<endl;
		if(check(mid))ub=mid;
		else lb=mid+1;
	}
	cout<<lb<<endl;
	return 0;
}




Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SIZE 200005
#define Z(x) (((x)>0)?(x):0)
#define INF 100000000000000000LL

using namespace std;
typedef long long int ll;
typedef pair <ll,int> P;

int main(){
    int a,b;
    int d[4]={0,0,0,0};
    rep(i,3){
        cin>>a>>b;
        a--,b--;
        d[a]++;
        d[b]++;
    }
    if(d[0]<=2&&d[1]<=2&&d[2]<=2&&d[3]<=2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

// #define amari(x) ((x) % 1000000007)
#define amari(x) ((x) % 998244353)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(long i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

struct Pony
{
    long u, v, w;

    Pony(long u_, long v_, long w_)
    {
        u = u_;
        v = v_;
        w = w_;
    }

    bool operator<(const Pony &another) const
    {
        return u < another.u || (u == another.u && v < another.v);
    };
};

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

  ll r, d, x;

  cin >> r >> d >> x;

  rep(i, 10) {
    x = x*r - d;
    cout << x << endl;
  }
}


Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

int main() {
        string s;
        cin >> s;
        if (s.size() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
}



Measured memory_bytes: 256
N = int(input())
numList = list(map(int, input().split()))
i = 0
temp = 1
counter = 0
while True:
    if numList[i] == temp:
        temp += 1
        counter += 1
    i += 1
    if i == N:
        break
if counter == 0:
    print(-1)
else:
    print(N - counter)

Measured memory_bytes: 26268
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb; 

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


int main() {
    string S;
    cin >> S;
    ll result[26];
    rep(i,26){
        result[i] = 0; 
    }

    rep(i,S.size()){
        int num = S[i] - 'a';
        result[num]++;
    }

    rep(i,26){
        if(result[i] == 0){
            char ans = 'a' + i;
            cout << ans << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;

}


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cur = 0;
  for (int ni = 0; ni < n; ni++) {
    if (s[ni] == 'E') cur++;
  }
  int answer = cur;
  for (int ni = 0; ni < n; ni++) {
    if (s[ni] == 'W') cur++;
    else cur--;
    if (cur < answer) answer = cur;
  }
  cout << answer << endl;
  return 0;
}

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

string S; long long N, dp[10009][109][2], mod = 1000000007;

int main() {
	cin >> S >> N;
	dp[0][0][1] = 1;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < 10; k++) {
				if ((int)(S[i] - '0') > k) {
					dp[i + 1][(j + k) % N][0] += dp[i][j][0]; dp[i + 1][(j + k) % N][0] %= mod;
					dp[i + 1][(j + k) % N][0] += dp[i][j][1]; dp[i + 1][(j + k) % N][0] %= mod;
				}
				else if ((int)(S[i] - '0') == k) {
					dp[i + 1][(j + k) % N][0] += dp[i][j][0]; dp[i + 1][(j + k) % N][0] %= mod;
					dp[i + 1][(j + k) % N][1] += dp[i][j][1]; dp[i + 1][(j + k) % N][1] %= mod;
				}
				else {
					dp[i + 1][(j + k) % N][0] += dp[i][j][0]; dp[i + 1][(j + k) % N][0] %= mod;
				}
			}
		}
	}
	long long ret = dp[S.size()][0][0] + dp[S.size()][0][1]; ret--; ret += mod; ret %= mod;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 17280
#!usr/bin/env python3
#! = map(int, input().split())
#! = [int(input()) for i in range()]

#A
"""
n,l=map(int, input().split())
s=[list(input()) for i in range(n)]
s.sort()
for i in s:
    for j in i:
        print(j,end="")
print()
"""

#B
a,b = map(int,input().split())
s = list(input())
k = s[:a]
asfpod = list("11234567890")
if s[a] != "-":
    print("No")
    quit()
d = s[a+1:]
for i in k:
    if i not in asfpod:
        print("No")
        quit()
for i in d:
    if i not in asfpod:
        print("No")
        quit()
print("Yes")
#C

#D

#E

#F
"""
n = int(input())
a = list(map(int, input().split()))
l = 0
r = 0
if n == 1:
    print(1)
    quit()
ans = 0
flag = [False for i in range(200000)]
flag[a[0]] = True
while r < n-1:
    r += 1
    while flag[a[r]]:
        flag[a[l]] = False
        l += 1
    ans = max(ans, r-l+1)
    flag[a[r]] = True
print(ans)
"""

#G
"""
r,c,d = map(int, input().split())
stage = [list(map(int, input().split())) for i in range(r)]
lis = []
for i in range(r):
    for j in range(c):
        lis.append([stage[i][j],i,j])
lis.sort(key = lambda x:-x[0])

for l,y,x in lis:
    if y+x <= d and (y+x-d)%2 == 0:
        print(stage[y][x])
        quit()
"""
#H

#I
"""
mod = 1000000007

def pow(a,b,c):
    n = 1
    m = a
    v = b
    while v > 0:
        if v%2 == 1:
            n *= m%c
            n %= c
        m *= m
        m%= c
        v //= 2
    return n%c

n = int(input())
a = list(map(int, input().split()))
l = 0
r = 0
ans = 0
flag = False
while r < n-1:
    while a[r] != -1:
        r += 1
        if r == n-1:
            break
    l = r-1
    while a[r] == -1:
        flag = True
        r += 1
    if a[r] != a[l]:
        su = 1
        s = a[r]-a[l]+1
        for i in range(1, r-l):
            su *= (s+i-1)
            su %= mod
            su *= pow(i, mod-2, mod)
            su %= mod
        ans += su
        ans %= mod
if ans == 0 and flag:
    ans = 1
print(ans)
"""
#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

// #pragma comment(linker, "/STACK:16777216")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define int ll
#define pii pair<int, int>
const int SZ = 2e5 + 4;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

struct custom_hash {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return x + FIXED_RANDOM;
    }
};

int n;

void read() {
    cin >> n;
}

void solve() {
    if (n & 1) {
        cout << 0;
        return;
    }
    int x = 10;
    int ans1 = 0;
    while (x <= n) {
        ans1 += n / x;
        x *= 5;
    }
    x = 2;
    int ans2 = 0;
    while (x <= n) {
        ans2 += n / x;
        x *= 2;
    }
    cout << min(ans1, ans2);
}

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

    read();
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int n;
  int a,b,c,d;
  int i,j,k,l;

  while(1) {
    b = 0;
  scanf("%d",&n);
  if(n == 0) {
    break;
  }

  for(i = 0; i< n/4; i++) {
     scanf("%d",&a);

    b = b + a;
  }

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

  }

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
 using namespace std;
 #define int long long
 #define rep(i,n) for(int i=0;i<n;i++)
 signed main(){
	 int n;
	 cin>>n;
	 int a[n];
	 rep(i,n){
		 cin>>a[i];
	 }
	 int ans=0;
	 rep(i,n-1){
		 if(a[i]<a[i+1]){
			 ans+=a[i+1]-a[i];
		 }
	 }
	 ans+=a[0]-0;
	 cout<<ans<<endl;
 }


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

int main() {
  int n;
  cin >> n;
  bool ok = false;
  for (int i = 1; i < 10; i++) {
    int j = n/i;
    if (j <= 9 && i*j == n) {
      ok = true;
    }
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3600
N = int( input() )
C = 0

def ch(k):
  global C
  if k < 2:
    return
  
  n = N
  while (n >= k) and (n%k == 0):
    n = n // k
  if ( n%k == 1 ):
    C += 1
  return

#　k = 1
ch(N)
ch(N-1)
#
nn = int( N**0.5 )
for k in range(2,nn+1):
  z = N%k
  if z <= 1:
    ch(k)
    k2 = N//k
    if k!=k2:
      ch(k2)
#
print(C)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int n,t,x,y;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
	{
        cin>>t>>x>>y;
        if(!(x+y<=t&&(t-x-y)%2==0))
		{
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

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

int N, M;
int x[51];
int y[51];
int sx[51];
int sy[51];
int main(){
    ios::sync_with_stdio(false);
    cin >> N >> M;
    
    REP(i,N) {
        cin >> sx[i] >> sy[i];
    }
    
    REP(i,M) {
        cin >> x[i] >> y[i];
    }
    
    REP(i,N) {
        int ind = -1;
        int dis = INF;
        REP(j,M) {
            int tdis = abs(sx[i]-x[j]) + abs(sy[i]-y[j]);
            if (tdis < dis) {
                dis = tdis;
                ind = j;
            }
        }
        cout << ind+1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>

using namespace std;

typedef long long ll;

#define rep(i,n) for(ll (i) = 0; (i) < (n); (i)++)

template<class T> void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

int main(void){
    int N;
    cin >> N;
    int A[100010];
    rep(i,N) cin >> A[i];
    long long INF = 1LL << 60;
    long long dp[100010];
    for(int i = 0;i < 100010; ++i) dp[i] = INF;
    dp[0] = 0;

    for(int i = 1; i < N; i++){
        chmin(dp[i],dp[i-1] + abs(A[i] - A[i - 1]));
        if (i > 1) chmin(dp[i],dp[i-2] + abs(A[i] - A[i - 2]));
    }

    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



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

  int ans = 0;
  REP(i, s.size()){
    if(s[i]== '+') ++ans;
    else --ans;
  }

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


Measured memory_bytes: 3600
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 2e5+5;


void solve(){
	int h,n;
	cin>>h>>n;
	vector<int>dp(h+1,mod),a(n+1),b(n+1);
	forn(i,n)cin>>a[i]>>b[i];
	dp[0]=0;
	forn(i,h){
		forn(j,n){
			umin(dp[i],(i>=a[j]?dp[i-a[j]]:0)+b[j]);
		}
	}
	cout<<dp[h];


}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
  using namespace std;
  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
  void _print() {cout << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define debug(x...) cout << "[" << #x << "] = ["; _print(x)
  #else
  #define debug(x...)
  #endif
  #define int long long int 
  #define fi first
  #define se second
  #define FIO {ios::sycnt2_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
  #define pb push_back
  #define all(x) (x).begin(), (x).end()
  #define rall(x) (x).rbegin(), (x).rend()
  #define forn(i, n) for (int i = 0; i < (int)(n); ++i)
  #define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
  #define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
  #define all(x) (x).begin(), (x).end()
  #define pow10(n) stoll("1"+string(n,'0'))
  //fill(all(arr),1)
  //if(map.count(key)){}
  //bitset<20> b(n);
  //int num=b.count();
  //int mini=min({a,b,c,d,e});
  #define int long long int
  typedef pair<int, int> pii;
  typedef vector<int> vi;
  typedef vector<pii> vpi;
  typedef vector<vi> vvi;
  typedef long long ll;
  typedef vector<ll> vll;
  typedef vector<vll> vvll;
  typedef long double ld;
  int32_t main()
  {
 int a,b,c,d;
 cin>>a>>b>>c>>d;
 int x,y;
 cout<<max({a*c,a*d,b*c,b*d});
}

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x * y / GCD(x, y);
}
int main(){
    int n; cin >> n;
    int res = 0;
    if(n < 10) {
        cout << n << endl;
        return 0;
    }
    else res += 9;
    if(n < 100) {
        cout << res << endl;
        return 0;
    }
    else if(n < 1000) res += n - 99;
    else res += 900;
    if(n < 10000) {
        cout << res << endl;
        return 0;
    }
    res += n  - 9999;
    if(n == 100000) res--;
    cout << res << endl;
}
   

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ll long long int
using namespace std;
ll *arr;
int main(){
	io;
	int n;
	ll temp;
	cin >> n;
	arr = new ll[n+5];
	for(int i = 0;i < n;++i){
		cin >> arr[i];
	}
	sort(arr,arr+n);
	bool f = 1;
	for(int i = 0;i < n-1;++i){
		if(arr[i] == arr[i+1]){
			f = 0;
			break;
		}
	}
	if(f)
		cout << "YES";
	else
		cout << "NO";
	delete []arr; 
	return 0;
}

Measured memory_bytes: 1792
if __name__ == '__main__':
    n = int(raw_input())
    S = map(int, raw_input().split())
    q = int(raw_input())
    T = map(int, raw_input().split())
    cnt = 0
    for x in T:
        left = 0
        right = n
        # search [left, right)
        while left < right:
            mid = (left + right) / 2
            if S[mid] == x:
                cnt += 1
                break
            elif S[mid] > x:
                right = mid
            else:
                left = mid + 1
    print cnt


Measured memory_bytes: 13204
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=110;
int a[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=gi();
    for(int i=1;i<=n;) {
	int j=i;
	while(a[j+1]==a[i]) ++j;
	ans+=(j-i+1)/2,i=j+1;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h_list = list(map(int, input().split()))

lowed = [True for i in range(n)]
fin = [False for i in range(n)]

if h_list == sorted(h_list):
    print("Yes")
else:
    while True:
        count = 0
        for i in range(n - 1):
            if h_list[i] > h_list[i+1] and lowed[i]:
                h_list[i] -= 1
                lowed[i] = False
                count += 1
        if count == 0 or lowed == fin:
            break
    if h_list == sorted(h_list):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14396
N, K = map(int, input().split())
A = list(n for n in range(N+1))
ans = 0
for i in range(K,N+2):
  L = i*(i-1)//2
  R = i*(2*N+1-i)//2
  ans += (R-L+1)
print(ans%((10**9)+7))

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

int n;
vector<vector<int>> graph(101010, vector<int>(0));
map<P, int> mp;
P edge[101010];

void dfs(int a, int pa, int pc){
  int c = 1;
  for(int x : graph.at(a)){
    if(x == pa) continue;
    if(c == pc) c++;
    mp[make_pair(a, x)] =  c;
    dfs(x, a, c);
    c++;
  }
  return;
}

int main(){
  cin >> n;
  rep(i, n - 1){
    int a, b;
    cin >> a >> b;
    edge[i] = make_pair(a, b);
    graph.at(a).push_back(b);
    graph.at(b).push_back(a);
  }
  
  int mc = 0;
  rep(i, n + 1){
    int tmp = graph.at(i).size();
    mc = max(tmp, mc);
  }
  dfs(1, 0, 0);
  
  cout << mc << endl;
  rep(i, n - 1){
    cout << mp[edge[i]] << endl;
  }
  return 0;
}


Measured memory_bytes: 14080
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

mns = []
res = 0
plus = 0
for i in range(n):
    if a[i] < b[i]:
        res += 1
        plus += b[i]-a[i]
    elif a[i] > b[i]:
        mns.append(b[i]-a[i])
mns.sort()
cnt = 0
while plus > 0:
    plus += mns[cnt]
    res += 1
    cnt += 1
    if plus > 0 and cnt == len(mns):
        print(-1)
        exit()
print(res)



Measured memory_bytes: 18644
import java.util.*;

public class Main {
    public static void main(String[] args)  throws java.io.IOException{
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        sc.close();
        int result = 0;
        while(a<=b){
            if(c%a==0){
                result++;
            }
            a++;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 17360
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
     
namespace IO {
	const int maxn(1 << 21 | 1);
     
	char ibuf[maxn], *iS, *iT, c;
	int f;
     
	inline char Getc() {
		return iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, maxn, stdin), (iS == iT ? EOF : *iS++)) : *iS++;
	}
     
	template <class Int> inline void In(Int &x) {
		for (f = 1, c = Getc(); c < '0' || c > '9'; c = Getc()) f = c == '-' ? -1 : 1;
		for (x = 0; c >= '0' && c <= '9'; c = Getc()) x = x * 10 + (c ^ 48);
		x *= f;
	}
}
     
using IO :: In;
     
const int maxn(1e5 + 5);
     
int n;
char s[maxn];
     
int main() {
	scanf(" %s", s + 1), n = strlen(s + 1);
	if (s[1] == '0' || s[n] == '1') return puts("-1"), 0;
	for (int i = 1; i <= n; ++i)
		if (s[i] == '0' && s[n - i] == '1') return puts("-1"), 0;
	for (int i = 1, lst = 1, tot = 1; i < n; ++i) {
		if (s[i] == '1') printf("%d %d\n", lst, ++tot), lst = tot;
		else printf("%d %d\n", lst, ++tot);
	}
	return 0;
}

Measured memory_bytes: 1536
def main():
    N, M, X = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]
    
    upside_cost = sum(i > X for i in A)
    downside_cost = sum(i < X for i in A)
    
    if(upside_cost < downside_cost):
        print(upside_cost)
    else:
        print(downside_cost)
        
if __name__=="__main__":
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int ans = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= x; y++) {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            }
        }
        System.out.println(ans);
    }

}


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

int main(){
  int n;
  cin>>n;
  vector<int> a(1e5+1,1);
  a[0]=0;
  a[1]=0;
  for(int i=2;i<1e5+1;i++){
    if(a[i]==1){
      for(int j=i+i;j<1e5+1;j+=i)a[j]=0;
    }
  }
  //for(int i=0;i<100;i++)cout<<i<<" "<<a[i]<<endl;
  vector<int> r(1e5+1,0);
  int tmp=0;
  for(int i=0;i<1e5+1;i++){
    if(a[i]==1&&a[(i+1)/2]==1)tmp++;
    r[i]=tmp;
  }

  int l,r1;
  for(int i=0;i<n;i++){
    cin>>l>>r1;
    cout<<r[r1]-r[l-1]<<endl;
  }
}


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

int main(void)
{
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    sort(A, A+N);
    for (int i = 0; i < N-1; i++) {
        if (A[i] == A[i+1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string S;
bool flag[30];

int main()
{
	in >> S;

	std::sort(S.begin(), S.end());
	for (auto c : S) { flag[c - 'a'] = true; }
	for (char c = 'a'; c <= 'z'; ++c)
	{
		if (!flag[c - 'a'])
		{
			out << c << std::endl;
			return 0;
		}
	}
	out << "None" << std::endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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

/*
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}
*/

#define ARRAY_MAX 100005
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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




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



int main() {

	
	int n, cnt = 0;
	cin >> n;
	vector<int> a(n+10);
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (i != a[i]) {
			cnt++;
		}
	}

	if (cnt <= 2) {
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}



	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
#include <ctype.h> // isdigit
#include <cassert>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(u) begin(u),end(u)
#define PB push_back
#define LE(n,m) ((n) < (m) + EPS * (abs(n) + abs(m)))
#define GE(n,m) ((n) + EPS * (abs(n) + abs(m)) > (m))
#define LT(n,m) ((n) + EPS * (abs(n) + abs(m)) < (m))
#define GT(n,m) ((n) > (m) + EPS * (abs(n) + abs(m)))
#define EQ(n,m) (abs((n)-(m)) < EPS * (abs(n) + abs(m)))

typedef long long int ll;
const int INF = (1<<30) - 1;
const double EPS = 1e-9;
const int MOD = 1000000007;

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    //cout.setf(ios::fixed);
    
    int N; cin >> N;
    
    vector<int> inputs(N);
    for(auto &v: inputs)
        cin >> v;
    
    vector<int> exists(1000, false);
    for(int l=1; l<=3; l++){
        for(int i=0; i<N+1-l; i++){
            int v = 0;
            for(int j=0; j<l; j++)
                v = v*10 + inputs[i+j];
            exists[v] = true;
        }
    }
    
    for(int i=0; i<1000; i++){
        if(!exists[i]){
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    ll a[100000], s=0, m=1e9;
    bool f=true, z=false;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        s+=abs(a[i]);
        m=min(m, abs(a[i]));
        if(a[i]<0)f=!f;
        if(a[i]==0)z=true;
    }
    if(z||f){
        cout<<s<<endl;
    }else{
        cout<<s-m*2<<endl;
    }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;
    cin>>n>>m;
    ll soma=0;
    rep(i,0,m){
        ll a;
        cin>>a;
        soma+=a;
    }
    if(soma>n)cout<<-1<<'\n';
    else cout<<n-soma<<'\n';
    return 0;   
}           


Measured memory_bytes: 3656
x1,y1,x2,y2 = (int(i) for i in input().split())

x = (x2 - x1)
y = (y2 - y1)

x3 = x2 - y
y3 = y2 + x

x4 = x3 - x
y4 = y3 - y

print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

  int n,k; cin >>n>>k;
  vector<ll> h(n); rep(i,n) cin >> h[i];

  sort(h.begin(), h.end(), greater<ll>());

  ll ans = 0;
  for (int i = k; i < n; i++) {
    ans += h[i];
  }

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




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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const long double eps = 1e-8;

const i64 MAXN = 200005;


i64 n, k;
i64 a[MAXN];
vector<i64> b;

vector<i64> pos;
vector<i64> neg;
i64 zero_cnt;

i64 cnt(vector<i64>& q, i64 v) {
    i64 R = 0;
    for (i64 i = 0; i < q.size(); i++) {
        R += upper_bound(q.data() + i + 1, q.data() + q.size(), v / q[i]) - (q.data() + i + 1);
    }
    return R;
}

i64 cnt(i64 v) {
    i64 R = 0;
    if (v >= 0) {
        R += (pos.size() + neg.size()) * zero_cnt;
        R += (zero_cnt - 1) * zero_cnt / 2;
    }
    if (v < 0) {
        for (auto x : pos) {
            R += neg.end() - lower_bound(neg.begin(), neg.end(), -v / x + (-v % x ? 1 : 0));
        }
    } else {
        R += pos.size() * neg.size();
        R += cnt(pos, v);
        R += cnt(neg, v);
    }
    return R;
}

i64 bin(i64 l, i64 r) {
    if (l == r) {
        return l;
    }
    if (l + 1 == r) {
        if (cnt(l) >= k) {
            return l;
        } else {
            return r;
        }
    }

    i64 t = (l + r) / 2;
    if (cnt(t) < k) {
        return bin(t, r);
    } else {
        return bin(l, t);
    }
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> k;
    for (i64 i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (i64 i = 0; i < n; i++) {
        if (a[i] == 0) {
            zero_cnt += 1;
            continue;
        }
        if (a[i] > 0) {
            pos.push_back(a[i]);
        } else {
            neg.push_back(-a[i]);
        }
    }

    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

//    for(i64 i = -20; i <= 20; i++) {
//        cerr << i << ": " << cnt(i) << endl;
//    }

//    for (i64 i = 0; i < n; i++) {
//        for (i64 j = i + 1; j < n; j++) {
//            b.push_back(a[i] * a[j]);
//        }
//    }
//    sort(b.begin(), b.end());
//
//    for (i64 i = 1; i <= b.size(); i++) {
//        const i64 rng = 1'000'000'000'000'000'000ll;
//        k = i;
//        i64 R = bin(-rng, rng);
//        if (b[i - 1] != R) {
//            return 0;
//        }
//    }

    const i64 rng = 1'000'000'000'000'000'000ll;
    i64 R = bin(-rng, rng);
    cout << R << endl;

    return 0;
}

Measured memory_bytes: 3956
import java.lang.Math.abs
import java.util.*

fun main(args: Array<String>) {
    try {
        val sc = Scanner(System.`in`)
        val a = sc.nextInt()
        val b = sc.nextInt()
        val kk = abs(a) + abs(b)
        if (kk % 2 != 0) {
            println("IMPOSSIBLE")
            return
        }
        val k = kk / 2
        println(k)
    } catch(e: Exception) {
        println(e)
    }
}

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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
typedef vector<int> vr;
typedef pair<int, int> pr;
#define pb push_back
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
#define endl "\n"
//cout << fixed << setprecision(2);


int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s, t;
    cin >> s >> t;
    int len = s.size();
    int ans = 0;
    for(int i = 0; i < len ; i++){
        if(s[i] != t[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n;
    ll ans = 0;

    cin >> n;

    int mon[n+1], hero[n];

    for (int i = 0; i < n+1; i++) cin >> mon[i];
    for (int i = 0; i < n; i++) cin >> hero[i];

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

        ans += min(hero[i], mon[i]+mon[i+1]);

        if (mon[i] < hero[i]) mon[i+1] -= min(mon[i+1], (hero[i]-mon[i]));
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;

namespace program {
  class Program {
    static void Main()
    {
      var w = Input.ScanStr();
      if(w == "Sunny") Out("Cloudy");
      if(w == "Cloudy") Out("Rainy");
      if(w == "Rainy") Out("Sunny");
    }
    static public void Out(object s) { Console.Write($"{s} "); }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 11092
N = int(input())
A = list(map(int, input().split()))

mod4 = 0
mod2 = 0
other = 0
counter = {0:0, 1:0, 4:0}
for n in A:
    count = 0
    while n % 2 == 0:
        count += 1
        n //= 2
        if count >= 2:
            break
    if count == 0:
        counter[0] += 1
    elif count == 1:
        counter[1] += 1
    else:
        counter[4] += 1
ans = None
if counter[1] == 0:
    if counter[4] + 1 >= counter[0]:
        ans = 'Yes'
    else:
        ans = 'No'
else:
    if counter[4] >= counter[0]:
        ans = 'Yes'
    else:
        ans = 'No'
print(ans)
    


Measured memory_bytes: 14228
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;

int main(){
	cin>>n;
	int res=1;
	while(res<=n) res*=2;
	cout<<res/2<<endl;
}

Measured memory_bytes: 256
n=int(input())
e=[[0 for i in range(6)]for j in range(n)]
for i in range(n):
	a=list(map(int,input().split()))
	e[i]=a	
for i in range(n-1):
	if e[0][0]==e[i+1][1]:
		e[i+1][0],e[i+1][1],e[i+1][4],e[i+1][5]=e[i+1][1],e[i+1][5],e[i+1][0],e[i+1][4]		
	elif e[0][0]==e[i+1][2]:
		e[i+1][0],e[i+1][2],e[i+1][3],e[i+1][5]=e[i+1][2],e[i+1][5],e[i+1][0],e[i+1][3]
	elif e[0][0]==e[i+1][3]:
		e[i+1][0],e[i+1][2],e[i+1][3],e[i+1][5]=e[i+1][3],e[i+1][0],e[i+1][5],e[i+1][2]	
	elif e[0][0]==e[i+1][4]:
		e[i+1][0],e[i+1][1],e[i+1][4],e[i+1][5]=e[i+1][4],e[i+1][0],e[i+1][5],e[i+1][1]		
	elif e[0][0]==e[i+1][5]:
		e[i+1][0],e[i+1][1],e[i+1][4],e[i+1][5]=e[i+1][5],e[i+1][4],e[i+1][1],e[i+1][0]
		
	for k in range(4):
		if 	e[0][1]!=e[i+1][1]:
			e[i+1][1],e[i+1][2],e[i+1][4],e[i+1][3]=e[i+1][3],e[i+1][1],e[i+1][2],e[i+1][4]
		else:
			break
count=0
for i in range(n):
	for j in range(n):
		if e[i]==e[j]:
			count=count+1
if count==n:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar()
#define pc(x) putchar(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=char(n%10+48);n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
using ll = long long;

int n;
ll a, t, cur;
#include <ext/pb_ds/assoc_container.hpp>
__gnu_pbds::gp_hash_table<ll, __gnu_pbds::null_type> mp;
bool no;

int main(){
	scan(n);
	while(n--){
		scan(a);
		t = __gcd(t, a);
		if(!no){
			for(ll i = 2; i*i <= a; i++){
				if(a%i == 0){
					if(mp.find(i) != mp.end()){
						no = 1;
						break;
					}
					mp.insert(i);
					while(a%i == 0)
						a /= i;
				}
			}
			if(a > 1){
				if(mp.find(a) != mp.end()){
					no = 1;
					break;
				}
				mp.insert(a);
			}
		}
	}
	//pair first
	if(!no)
		puts("pairwise coprime");
	else if(t == 1)
		puts("setwise coprime");
	else
		puts("not coprime");
}

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

int main() {
  int n, k; cin >> n >> k;
  set<int> s;
  while (k--) {
    int d; cin >> d;
    while (d--) {
      int a; cin >> a;
      s.insert(a);
    }
  }
  cout << n-s.size();
  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	//run();
	string s;
	cin >> s;
	int q;
	cin >> q;
	string f1, f2;
	bool rev[3] { 1, 0, 0 };
	while (q--) {
		int t;
		cin >> t;
		if (t == 1) {
			for (int j = 0; j < 3; j++)
				rev[j] ^= 1;
			swap(f1, f2);
			swap(rev[0], rev[2]);
		} else {
			int f;
			char c;
			cin >> f >> c;
			if (f == 1)
				f1 += c;
			else
				f2 += c;
		}
	}
	if (rev[0])
		reverse(all(f1));
	if (rev[1])
		reverse(all(s));
	if (rev[2])
		reverse(all(f2));
	cout << f1 << s << f2;
}


Measured memory_bytes: 1088
n = int(input())
s = []
for _ in range(n):
    s.append(input())
common = [100]*26
for ss in s:
    tmp = [0]*26
    for c in ss:
        tmp[ord(c)-ord('a')] += 1
    for i in range(26):
        common[i] = min(common[i], tmp[i])

ans = ''
for i in range(26):
    ans += chr(i+ord('a'))*common[i]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
int x,a,b,fa;
cin>>x>>a>>b;
if(a-b<0&&(a-b)*(-1)<=x){
   cout<<"safe";
}
else if(a-b<0){
   cout<<"dangerous";
}
else{
    cout<<"delicious";
}
 return 0;
}

Measured memory_bytes: 256
#%%
N, K = map(int, input().split())
S = list(input())

saisyo = 0
for i in range(N-1):
    if S[i+1] == S[i] :
        saisyo += 1
#print(saisyo)

nr = 0
nl = 0
for i in range(N):
    if i == 0:
        if S[i] == 'R':
            nr += 1
        elif S[i] == 'L':
            nl += 1
    else:
        if S[i] == 'R' and S[i-1] == 'L':
            nr += 1
        elif S[i] == 'L' and S[i-1] == 'R':
            nl += 1

#print(nr)
#print(nl)

rcheck = 0
lcheck = 0
if S[0] == 'R':
    rcheck += 1
else:
    lcheck += 1
if S[-1] == 'R':
    rcheck += 1
else:
    lcheck += 1

ans = saisyo

#rの時
if nr - K >= 2:
    ans += 2*K
elif nr - K == 1:
    if rcheck == 0:
        ans += 2*K
    elif rcheck >= 1:
        ans += 2*K - 1
elif nr - K == 0:
    if rcheck == 0:
        ans += 2*K
    elif rcheck >= 1:
        ans += 2*K - 1
    elif rcheck == 2:
        ans += 2*K - 2
else:
    ans += 2*nr - rcheck

rans = ans 
ans = saisyo

#lの時
if nl - K >= 2:
    ans += 2*K
elif nl - K == 1:
    if lcheck == 0:
        ans += 2*K
    elif lcheck >= 1:
        ans += 2*K 
    elif lcheck >= 1:
        ans += 2*K - 1
elif nl - K == 0:
    if lcheck == 0:
        ans += 2*K
    elif lcheck >= 1:
        ans += 2*K - 1
    elif lcheck == 2:
        ans += 2*K - 2
else:
    ans += 2*nl - lcheck

lans = ans

ans = max(rans, lans)
print(ans)


Measured memory_bytes: 4212
import numpy as np
N = int(input())
h = list(map(int, input().split()))
diff = np.array([i for i in h])


# 右から見ていったときに、最小値までの数値と、それ以降昇順になっている値までに最小値を足す
# 以降それを繰り返す
def find_min_idx(l):
    # 0以外で最小の値を取得
    non_0_list = [i for i in l if i != 0]
    min_value = min(non_0_list)
    min_idx = np.where(l == min_value)[0][0]
    return min_idx


def get_min_value(l, min_idx):
    return l[min_idx]


def get_end_idx(l, min_idx, min_value):
    for idx, i in enumerate(l):
        if idx > min_idx:
            if i == 0:
                return idx - 1
            if i < min_value or i == 0:
                return idx - 1
    else:
        return len(l) - 1


def find_start_idx(l, min_idx):
    if len(l[:min_idx]) == 0:
        return 0
    for idx, i in enumerate(reversed(l[:min_idx])):
        if i == 0:
            return idx
    else:
        return len(l[:min_idx])-1


count = 0
while not all([i == 0 for i in diff]):
    #  print(count, diff)
    #  import pdb
    #  pdb.set_trace()
    min_idx = find_min_idx(diff)
    min_value = get_min_value(diff, min_idx)
    end_idx = get_end_idx(diff, min_idx, min_value)
    start_idx = find_start_idx(diff, min_idx)
    #  print('min_idx, end_idx, start_idx', min_idx, end_idx, start_idx)
    #  import pdb
    #  pdb.set_trace()
    for idx, i in enumerate(diff):
        if i == 0:
            continue

        if idx <= end_idx:
            if idx >= min_idx - start_idx - 1:
                diff[idx] -= min_value
            elif idx >= min_idx:
                diff[idx] -= min_value

    count += min_value

    #  print(count, diff, '\n')

print(count)


Measured memory_bytes: 14000
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A));
  ll sum=0;
  vector<ll> B(N);
  REP(i,N){
    sum+=A[i];
    B[i]=sum;
  }
  ll cnt = 1;
  REPR(i,N-2){
    if(B[i]*2>=A[i+1]){
      cnt++;
    }else{
      break;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 1792