akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;
const long long MAXN = 2e5+5;
int main()
{
	long long n,relsum = 0;
	cin >> n;
	long long sl[MAXN];
	for (int i = 0; i < n; i++)
	{
		cin >> sl[i];
	}
	for (int i = 0; i < n; i++)
	{
		relsum += sl[i];
	}
	//cout << relsum;
	long long sumx[n ] = {0};
	long long sumy[n] = {0};
	for (int i = 1; i <= n - 1;i++)
	{
		sumx[i] += sumx[i - 1] + sl[i - 1];
		sumy[i] = relsum - sumx[i];
	}

	/*
	for (int i = 1; i < n - 1;i++)
	{
		cout << sumx[i] << "xxx" << sumy[i] << endl;
	}
	*/
	
	long long cha[n - 1] = {0};
	for (int i = 1; i <= n - 1;i++)
	{
		cha[i] = abs((sumx[i])- (sumy[i]));
		
	}
	/*
	for (int i = 1; i < n - 1;i++)
	{
		cout << cha[i] << endl;
	}*/
	
	long long min = cha[1]; 
	for (int i = 1; i <= n - 1;i++)
	{
		if (cha[i] < min)
		min = cha[i];
	}
	cout << min;
} 


Measured memory_bytes: 6528
#include <bits/stdc++.h>
 
#define NMAX 100005
using namespace std;
 
int dp[NMAX], dg[NMAX];
vector<int>G[NMAX];
 
void DFS(int nod){
    for(auto it: G[nod]){
        if(dp[it] == 0)
            DFS(it);
        dp[nod] = max(dp[nod], dp[it] + 1);
    }
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
 
    for(int i = 1; i <= m; ++i){
        int x, y;
        cin >> x >> y;
 
        G[x].emplace_back(y);
        dg[y]++;
    }
 
    for(int i = 1; i <= n; ++i)
        if(dg[i] == 0)
            DFS(i);
 
    int maxx = 0;
    for(int i = 1; i <= n; ++i)
        maxx = max(maxx, dp[i]);
    cout << maxx << '\n';
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;




int main() {
    string s;
    cin>>s;
    if(s[0]=='<')s='>'+s;
    else s='<'+s;
    if(s[s.size()-1]=='<')s=s+'>';
    else s=s+'<';
    vi v(s.size()+1,INF);
    rep(i,s.size()-1){
        if(s[i]=='>'&&s[i+1]=='<')v[i+1]=0;
    }
    for(int i=0;i<v.size();i++){
        if(v[i]==0){
            while(i<v.size()&&s[i]=='<'){
                i++;
                if(v[i]==INF||v[i]<v[i-1]+1)v[i]=v[i-1]+1;
                else break;
            }
        }
    }
    for(int i=v.size()-1;i>=0;i--){
        if(v[i]==0){
            while(i>=0&&s[i-1]=='>'){
                i--;
                if(v[i]==INF||v[i]<v[i+1]+1)v[i]=v[i+1]+1;
                else break;
            }
        }
    }
    ll ans=0;
    for(int i=1;i<v.size()-1;i++)ans+=v[i];
    // rep(i,v.size())cout<<v[i]<<" ";
    // cout<<endl;
    fin(ans);
    
}



Measured memory_bytes: 3116
#include <stdio.h>

int main(void)
{
    int x, y, z, min, max;
    scanf("%d %d %d", &x, &y, &z);

    min = x < y ? x : y;
    min = z < min ? z : min;

    max = x > y ? x : y;
    max = z > max ? z : max;

    printf("%d %d\n", min, max);

    return 0;
}


Measured memory_bytes: 2112
#include<stdio.h>
#include<string.h>
int main(void){
    int N,A,B,max,min;
    scanf("%d %d %d",&N,&A,&B);

    if(A>B){
        max=B;
    }else{
        max=A;
    }

    min=(A+B)-N;
    if(min<0){
        min=0;
    }

    printf("%d %d",max,min);
    return 0;
}

Measured memory_bytes: 128
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
H,W,D = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
Q = int(input())
LR = [tuple(map(int,input().split())) for _ in range(Q)]

N = H*W

B = [0]*(N+1)
for h in range(H):
    for w in range(W):
        n = A[h][w]
        B[n] = (h,w)

C = [[0 for _ in range((H*W)//D+1)]for _ in range(D)]
for i in range(D+1,N+1):
    rem = i%D
    x0,y0 = B[i-D]
    x1,y1 = B[i]
    C[rem][i//D] = abs(x1-x0) + abs(y1-y0)

for i in range(D):
    for j in range(1,(H*W)//D+1):
        C[i][j] += C[i][j-1]

for l,r in LR:
    i = l%D
    print(C[i][r//D] - C[i][l//D])

Measured memory_bytes: 38492
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main()
{
	

    fastio
    ll t, i, j;
    cin>>t>>i;
    cout<<t*i;
}

Measured memory_bytes: 3612
N = int(input())
K = int(input())
x = [int(i) for i in input().split()]

suml = [0] * N

for i in range(N):
  delta = abs(K-x[i])
  if x[i] < delta:
  	suml[i] = suml[i] + x[i]*2
  else:
  	suml[i] = suml[i] + delta*2

print(sum(suml))

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
class disjoint_set {
  public:
  vector<int> rank, prt, ptl;
  disjoint_set (int size) {
    rank.resize(size);
    prt.resize(size);
    ptl.resize(size);
    for (int i = 0; i < size; i++) {
      prt[i] = i;
      rank[i] = 0;
      ptl[i] = 0;
    }
  }
  int find (int x) {
    if (x == prt[x]){
      return x;
    } else {
      int r = find(prt[x]);
      ptl[x] += ptl[prt[x]];
      return prt[x] = r;
    }
  }
  bool is_equiv (int x, int y) {
    return find(x) == find(y);
  }
  bool unite (int x, int y, int w) {
    if (find(x) == find(y)) {
      return false;
    }
    w += ptl[x];
    w -= ptl[y];
    x = find(x);
    y = find(y);
    if (rank[x] < rank[y]) {
      swap(x, y);
      w *= -1;
    }
    prt[y] = x;
    ptl[y] = w;
    if (rank[x] == rank[y]) {
      rank[x]++;
    }
    return true;
  }
  int diff (int x, int y) {
    find(x);
    find(y);
    return ptl[y] - ptl[x];
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  disjoint_set djs(n);
  while (q--) {
    int c;
    cin >> c;
    if (c == 0) {
      int x, y, z;
      cin >> x >> y >> z;
      djs.unite(x, y, z);
    } else {
      int x, y;
      cin >> x >> y;
      if (!djs.is_equiv(x, y)) {
        cout << "?" << '\n';
      } else {
        cout << djs.diff(x, y) << '\n';
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4152
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    REP(i, H) cin >> S[i];

    // 2 次元 imos
    vector<vector<int>> num_white(H+1, vector<int>(W+1));
    REP(i, H){
        REP(j, W){
            if(S[i][j] == '1') ++num_white[i][j];
            num_white[i][j+1] += num_white[i][j];
        }
    }
    REP(i, H){
        REP(j, W) num_white[i+1][j] += num_white[i][j];
    }

    int ans = 1e+7;
    // 横に引く線の位置について全探索
    for(int i = 0; i < (1 << (H-1)); ++i){
        vector<int> pos_hol;
        REP(j, H) if(i & (1<<j)) pos_hol.push_back(j);
        pos_hol.push_back(H-1);

        int num_lines = pos_hol.size()-1;

        int pos_ver = -1; // 縦線の位置
        bool flag = true;
        REP(j, W){
            //左から順に見ていって K を超えたらその手前で線を引く
            REP(k, pos_hol.size()){
                int num = num_white[pos_hol[k]][j];
                if(k > 0) num -= num_white[pos_hol[k-1]][j];
                if(pos_ver >= 0) num -= num_white[pos_hol[k]][pos_ver];
                if(k > 0 and pos_ver >= 0) num += num_white[pos_hol[k-1]][pos_ver];
                if(num > K){
                    pos_ver = j-1;
                    ++num_lines;
                }
                if(j == 0 and num > K){
                    flag = false;
                    break;
                }
            }
            if(!flag) break;
        }
        if(flag) ans = min(ans, num_lines);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
k = int(input())

ans = 'No'

def solve(a, b, c, k):
    global ans
    if a < b < c:
        ans = 'Yes'
        return

    if k == 0:
        return

    solve(a*2, b, c, k-1)
    solve(a, b*2, c, k-1)
    solve(a, b, c*2, k-1)

solve(a, b, c, k)
print(ans)



Measured memory_bytes: 67856
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    int ans=100100100;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        int tmp=0;
        while(a%2==0){
            a/=2;
            tmp++;
        }
        ans=min(ans,tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

map<ll, int> prime_factor(ll n) {
    map<ll, int> ret;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll ans = 1;
    for (auto p : prime_factor(n - 1)) ans *= ((ll)p.second + 1);
    ans--;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i != 0) continue;
        ll j = n / i;
        ll k;
        if (i != 1) {
        k = n; while (k % i == 0) k /= i;
        if (k % i == 1) ans++;
        }
        if (i == j) break;
        k = n; while (k % j == 0) k /= j;
        if (k % j == 1) ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main() {

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

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

 return 0 ;
}  


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pb push_back
#define N 300003
#define inf (ll)1e9+11
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll mod=1e9+7;   

signed main()
{
    warmup
    
    int n,k,s;
    cin>>n>>k>>s;
    int a[n+1],i,j;
    for(i=1;i<=k;++i)
        a[i]=s;
    for(j=1;;++j)
        if(s%j)
            break;
    for(;i<=n;++i)
        a[i]=j;
    for(i=1;i<=n;++i)
        cout<<a[i]<<' ';
    
    
    return 0;
}


Measured memory_bytes: 1664
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    int n, ma, mb;
    cin >> n >> ma >> mb;

    vector<vector<ll>> dp(401, vector<ll>(401, MAX));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        int a, b, c;
        cin >> a >> b >> c;

        for(int j = 400; j >= a; j--){
            for(int k = 400; k >= b; k--){
                dp[j][k] = min(dp[j][k], dp[j - a][k - b] + c);
            }
        }
    }

    int ans = MAX;
    for(int i = 1; i <= 400; i++){
        for(int j = 1; j <= 400; j++){
            int g = __gcd(i, j);
            if(i / g == ma && j / g == mb) ans = min(ans, (int)dp[i][j]);
        }
    }

    if(ans != MAX) cout << ans << "\n";
    else cout << "-1\n";

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int total=0;

    rep(i,n){
        cin >> a[i];
        total += a[i];
    }
    int cnt = 0;
    rep(i,n){
        if(4*m*a[i] >= total)cnt++;
    }
    if(cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if(0<=x-r && 0<=y-r && x+r<=W && y+r<=H){
            System.out.println("Yes");
        }else System.out.println("No");
    }
}


Measured memory_bytes: 26408
#include<stdio.h>

int main(void)
{
        int a,b,c,s;
        scanf("%d",&a);
        scanf("%d",&b);
        scanf("%d",&c);

        s=a+b;
        if(s>=c){
                printf("Yes\n");
        }
        else if(s<c)
        {
                printf("No\n");
        }
        return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;

    //配列の昇順ソート
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(), p.end());
    
    int ans = 0;
    rep(i,k) ans += p[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#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 watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const bool DEBUG = 0;
const int MAXN = 405;

int n;
ll a[MAXN];
ll pre[MAXN];
ll dp[MAXN][MAXN];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n;
	forn(i,0,n) forn(j,i+1,n) dp[i][j]=INF;
	forn(i,0,n)
	{
		cin>>a[i];
		pre[i]=a[i];
		if(i) pre[i]+=pre[i-1];
	}
	
	for(int l=n-1;l>=0;l--) forn(r,l+1,n)
	{
		forn(i,l,r)
		{
			dp[l][r]=min(dp[l][r], dp[l][i]+dp[i+1][r]+pre[r]-(l?pre[l-1]:0LL));
		}
	}
	
	cout<<dp[0][n-1]<<'\n';
	
	return 0;
}


Measured memory_bytes: 4888
import java.util.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		
		int ans = 0;
		if(n==1) ans = 2;
		else if(n==0 || n==2) ans = 1;
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 17360
#include <stdio.h>
#include<math.h>
int main(){

  int check(int);
  
  int n;
  int number[10000];
  int i;
  int j;
  int count=0;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&number[i]);
    if(check(number[i]) == 1) count++;
  }

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

  return 0;
}

int check(int x){
  int i=3;
  if(x == 2) return 1;
  if(x < 2 || x % 2 == 0) return 0;
  while(i<= sqrt((double)x)){
    if(x % i == 0) return 0;
    i += 2;
  }
  return 1;
}



Measured memory_bytes: 2144
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int f[105][4][4],ans,n;
string s[3];
int main()
{	cin>>n;
	cin>>s[1];s[1]=' '+s[1];
	cin>>s[2];s[2]=' '+s[2];
	if(s[1][1]==s[2][1])f[1][1][1]=f[1][2][2]=f[1][3][3]=1;
	else f[1][1][2]=f[1][2][1]=f[1][1][3]=f[1][3][1]=f[1][2][3]=f[1][3][2]=1;
	for(int i=2;i<=n;i++)
	{	if(s[1][i]==s[2][i])
		{	if(s[1][i-1]==s[2][i-1])
			{	f[i][1][1]=(f[i][1][1]+f[i-1][2][2])%1000000007;	
				f[i][1][1]=(f[i][1][1]+f[i-1][3][3])%1000000007;
				f[i][2][2]=(f[i][2][2]+f[i-1][1][1])%1000000007;	
				f[i][2][2]=(f[i][2][2]+f[i-1][3][3])%1000000007;	
				f[i][3][3]=(f[i][3][3]+f[i-1][1][1])%1000000007;	
				f[i][3][3]=(f[i][3][3]+f[i-1][2][2])%1000000007;
			}	
			else
			{	f[i][1][1]=(f[i][1][1]+f[i-1][2][3])%1000000007;
				f[i][1][1]=(f[i][1][1]+f[i-1][3][2])%1000000007;
				f[i][2][2]=(f[i][2][2]+f[i-1][1][3])%1000000007;
				f[i][2][2]=(f[i][2][2]+f[i-1][3][1])%1000000007;
				f[i][3][3]=(f[i][3][3]+f[i-1][1][2])%1000000007;
				f[i][3][3]=(f[i][3][3]+f[i-1][2][1])%1000000007;
			}
		}	
		else 
		{	if(s[1][i]==s[1][i-1])
			{	memcpy(f[i],f[i-1],sizeof(f[i-1]));
			}
			else if(s[1][i-1]==s[2][i-1])
			{	f[i][2][3]=(f[i][2][3]+f[i-1][1][1])%1000000007;
				f[i][3][2]=(f[i][3][2]+f[i-1][1][1])%1000000007;
				f[i][1][3]=(f[i][1][3]+f[i-1][2][2])%1000000007;
				f[i][3][1]=(f[i][3][1]+f[i-1][2][2])%1000000007;
				f[i][1][2]=(f[i][1][2]+f[i-1][3][3])%1000000007;
				f[i][2][1]=(f[i][2][1]+f[i-1][3][3])%1000000007;
			}
			else 
			{	f[i][3][1]=(f[i][3][1]+f[i-1][1][2])%1000000007;
				f[i][2][3]=(f[i][2][3]+f[i-1][1][2])%1000000007;
				f[i][2][1]=(f[i][2][1]+f[i-1][1][2])%1000000007;
				
				f[i][1][3]=(f[i][1][3]+f[i-1][2][1])%1000000007;
				f[i][3][2]=(f[i][3][2]+f[i-1][2][1])%1000000007;
				f[i][1][2]=(f[i][1][2]+f[i-1][2][1])%1000000007;
				
				f[i][1][2]=(f[i][1][2]+f[i-1][2][3])%1000000007;
				f[i][3][1]=(f[i][3][1]+f[i-1][2][3])%1000000007;
				f[i][3][2]=(f[i][3][2]+f[i-1][2][3])%1000000007;
				
				f[i][2][1]=(f[i][2][1]+f[i-1][3][2])%1000000007;
				f[i][1][3]=(f[i][1][3]+f[i-1][3][2])%1000000007;
				f[i][2][3]=(f[i][2][3]+f[i-1][3][2])%1000000007;
				
				f[i][2][1]=(f[i][2][1]+f[i-1][1][3])%1000000007;
				f[i][3][1]=(f[i][3][1]+f[i-1][1][3])%1000000007;
				f[i][3][2]=(f[i][3][2]+f[i-1][1][3])%1000000007;
				
				f[i][1][2]=(f[i][1][2]+f[i-1][3][1])%1000000007;
				f[i][1][3]=(f[i][1][3]+f[i-1][3][1])%1000000007;
				f[i][2][3]=(f[i][2][3]+f[i-1][3][1])%1000000007;
			}
		}
	} 
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			ans=(ans+f[n][i][j])%1000000007;
	printf("%d",ans);
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    b = c = 0
    for d in a:
        if d%2 == 0:
            b += 1
        else:
            c += 1
    t = 3**n

    return t - (2**b)


print(main())




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

int main(){

  //入力
  int N;
  cin >> N;
  int A[N][N];
  for(int i=0;i<N;i++) for(int j=0;j<N;j++) A[i][j] = 0 ;
  for(int i=0;i<N;i++){
    int X;
    cin >> X;
    for(int j=0;j<X;j++){
      int p; int q;
      cin >> p >> q;
      p--; q++;
      A[i][p]=q;
    }
  }

  int MaxNum=0;

  for(int i=0;i<(1<<N);i++){
    bitset<15> ibit = static_cast<bitset<15>>(i);
    bool ok = true;
    for(int j=0;j<N;j++){
      if(ibit[j]==0) continue;
      for(int k=0;k<N;k++){
        if(A[j][k]==0) continue;
        if((A[j][k]==2 && ibit[k]==0)||(A[j][k]==1 && ibit[k]==1)){
          ok = false;
          break;
        }
      }
    }

    if(ok){
      if(ibit.count() > MaxNum) MaxNum = ibit.count();
    }

  }

  cout << MaxNum << endl;

}


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

int main(){
  vector<bool> num(101,false);
  FOR(i,1,10){
    FOR(j,1,10){
      num[i*j] = true;
    }
  }
  int n;
  cin >> n;
  if(num[n])cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

int main()
{
	char c;
	cin >> c;
	if(c == 'a' || c == 'i' || c == 'e' || c == 'o' || c == 'u')
		cout << "vowel" << endl;
   	else cout << "consonant" << endl;

	return 0;
}	

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#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;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 200003;
const db pi = acos(-1);

int sx,sy,ex,ey;
int n;
struct fountain{
	int x,y;
	friend bool operator < (fountain a,fountain b){return a.x<b.x;}
}a[N];
set<int>s;
int tree[N],k;
map<int,int>id;

void change(int x,int v){for(;x<=k;x+=x&-x)tree[x]=max(tree[x],v);}
int getv(int x){int ans=0;for(;x;x-=x&-x)ans=max(ans,tree[x]);return ans;}

int main(){
	sx=get(),sy=get(),ex=get(),ey=get();
	n=get();
	fo(i,1,n)a[i].x=get(),a[i].y=get();
	if (sx>ex){
		sx=1e+8-1-sx;
		ex=1e+8-1-ex;
		fo(i,1,n)a[i].x=1e+8-1-a[i].x;
	}
	if (sy>ey){
		sy=1e+8-1-sy;
		ey=1e+8-1-ey;
		fo(i,1,n)a[i].y=1e+8-1-a[i].y;
	}
	int n_=0;
	fo(i,1,n)
	if (a[i].x>=sx&&a[i].x<=ex&&a[i].y>=sy&&a[i].y<=ey)a[++n_]=a[i];
	n=n_;
	sort(a+1,a+1+n);
	fo(i,1,n)s.insert(a[i].y);
	k=1;
	for(set<int>::iterator h=s.begin();h!=s.end();h++,k++)id[*h]=k;
	k--;
	int mv=0;
	fo(i,1,n){
		int v=getv(id[a[i].y]);
		change(id[a[i].y],v+1);
		mv=max(mv,v+1);
	}
	if (mv==min(ex-sx,ey-sy)+1)printf("%.14lf\n",db(1)*100*(ex-sx+ey-sy)-db(1)*(20.0-pi*5)*(mv-1)+db(1)*(pi*10-20));
	else printf("%.14lf\n",db(1)*100*(ex-sx+ey-sy)-db(1)*(20.0-pi*5)*mv);
	return 0;
}

Measured memory_bytes: 21376
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.S;
		Console.WriteLine("{0}",s[0]+""+s[1]+""+s[2]);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  int ans = -1;
  int num = 1;
  for (int i = 0; i <= N; i++) {
    if (num == 2) {
      ans = i;
      break;
    }
    num = a.at(num - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
a,b,c = map(int,input().split())
d,e,f = map(int,input().split())
g,h,i = map(int,input().split())

x = []
y = [a,b,c,d,e,f,g,h,i]

n = int(input())
for s in range(n):
  x.append(int(input()))

for m in range(9):
  if y[m] in x:
      y[m] = 0

if y[0] == y[1] == y[2] == 0:
    print("Yes")
elif y[3] == y[4] == y[5] == 0:
    print("Yes")

elif y[6] == y[7] == y[8] == 0:
    print("Yes")

elif y[0] == y[3] == y[6] == 0:
    print("Yes")

elif y[1] == y[4] == y[7] == 0:
    print("Yes")

elif y[2] == y[5] == y[8] == 0:
    print("Yes")

elif y[0] == y[4] == y[8] == 0:
    print("Yes")

elif y[2] == y[4] == y[6] == 0:
    print("Yes")

else:

    print("No")


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

using namespace std;

// 問題に出てくる分銅の質量は2のn乗
// 下位のビットから1ビットずつ確認していく

int main() {
	int w;
	while (cin >> w) {
		string weights;

		// 対応するビットが1になっている確認。
		// 対応していたら値を出力する
		for (int bit = 1; bit < 1024; bit <<= 1) {
			if (bit & w) {
				weights.append(to_string(bit));
				weights.push_back(' ');
			}
		}
		// 最後のスペースを改行に置き換え
		weights.back() = '\n';
		cout << weights;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>

using namespace std;





int main(){
    int room[4][3][10]={0};
    int n;
    cin>>n;
    
    int b,f,r,v;
    for(int i=0;i<n;++i){
        cin>>b>>f>>r>>v;
        room[b-1][f-1][r-1]+=v;
    }
        
    for(int i=0;i<4;++i){
        for(int j=0;j<3;++j){
            for(int k=0;k<10;++k){
                cout<<" "<<room[i][j][k];
            }
            cout<<'\n';
        }
        if(i<3){
            cout<<"####################"<<endl;
          

        }
    
        
    }
    
    
    
    
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i < n; ++i)
#define count(arr) (sizeof(arr) / sizeof((arr)[0]))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

// 各node(i,j)に対しid tableを作っておく
const int MAXN=1005;
int id[MAXN][MAXN];
int toId(int i,int j){
  if(i>=j) swap(i,j); // i<j
  return id[i][j];
}

int main() {
  // input
  int n; cin>>n;
  vector<vector<int>> a(n,vector<int>(n-1));
  rep(i,n) {
    rep(j,n-1) {
      cin>>a[i][j];
      a[i][j]--;
    }
  }

  // id table作成
  int V=0;
  rep(i,n)rep(j,n) {
    if(i>=j) continue;
    id[i][j]=V++;
  }

  // E,indeg作成
  vector<int> E[V];
  vector<int> indeg(V,0);
  rep(i,n) {
    rep(j,n-1) a[i][j]=toId(i,a[i][j]);
    rep1(j,n-1) {
      E[a[i][j-1]].pb(a[i][j]);
      indeg[a[i][j]]++;
    }
  }

  // topological sort
  queue<int> q;
  vector<int> res;
  rep(v,V) if(indeg[v]==0) q.push(v);
  while(!q.empty()){
    int v0=q.front();
    q.pop();
    res.pb(v0);
    for(int v1:E[v0]) {
      indeg[v1]--;
      if (indeg[v1]==0) q.push(v1);
    }
  }

  // judge whether DAG or not
  if (res.size()<V){
    cout<<-1<<endl;
    return 0;
  }

  // calculate diameter
  vector<int> LP(V,1);
  for(int v0:res){
    for(int v1:E[v0]){
      LP[v1]=max(LP[v1],LP[v0]+1);
    }
  }
  cout<<*(max_element(LP.begin(),LP.end()))<<endl;
  return 0;
}


Measured memory_bytes: 41460
#include<stdio.h>
int main(){
  double ans;
  int n,i,cnt=0;
  scanf("%d",&n);
  for(i=0;i<=n;i++)
    if(i%2==1)
      cnt++;
  ans = (double)cnt/(double)n;
  printf("%lf",ans);
  return 0;
}

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

int main(){
   int n,k; cin>>n>>k;
   vector<int> p(n);
   rep(i,n) cin>>p[i];
   //期待値を二倍した値に変換している
   rep(i,n) p[i]++;
   int mx=0;
   int s=0;
   queue<int> q;
   rep(i,n){
      s+=p[i];
      q.push(p[i]);
      if(q.size()>k){
         s-=q.front(); q.pop();
      }
      if(q.size()==k){
         mx=max(mx,s);
      }
   }
   double ans=mx;
   ans /=2;
   printf("%.10f\n",ans);
   return 0;
}


Measured memory_bytes: 1792
import math
from typing import List, NoReturn, Tuple


def main() -> NoReturn:
    n: int = int(input())
    # 0.9615384615384616 == 25 / 26
    group: int = math.ceil(math.log(0.9615384615384616 * n + 1, 26))
    in_group_index: int = n - 1 - (26 * (26 ** (group - 1) - 1)) // 25

    alphabet_num: List[int] = []
    alphabet: str = "abcdefghijklmnopqrstuvwxyz"
    temp = in_group_index
    for i in range(group - 1, -1, -1):
        alphabet_num.append(temp // 26 ** i)
        temp %= 26 ** i
    name_chars: List[str] = [alphabet[i] for i in alphabet_num]
    print("".join(name_chars))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10280
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

vector<int> G[100000];
int p[100000];
int group[100000];

void dfs(int v, int g) {
    group[v] = g;

    for (int to : G[v]) {
        if (group[to] < 0) dfs(to, g);
    }
}

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

    for (int i = 0; i < N; i++) {
        cin >> p[i];
        p[i]--;
    }

    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;

        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    memset(group, -1, sizeof(group));
    int g = 0;
    for (int v = 0; v < N; v++) {
        if (group[v] < 0) dfs(v, g++);
    }

    int ans = 0;
    for (int v = 0; v < N; v++) {
        if (group[v] == group[p[v]]) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8576
#include <stdio.h>
using namespace std;
int a,b;
int main(){
  scanf("%d %d",&a,&b);
  if (a==1 ){
    a+=13;
  }
  if (b==1){b+=13;}
  if (a>b){printf("%s\n","Alice" );}
  else if (b>a){printf("%s\n","Bob" );}
  else {printf("%s\n","Draw" );}
}


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

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;
}

#define IOS ios::sync_with_stdio(false), cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vvi;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

vector<bool> isSafe;
vll dp;

int main() {
  IOS;
  constexpr char endl = '\n';

  int N, M;
  cin >> N >> M;
  isSafe.assign(N + 1, true);
  rep(i, M) {
    int a;
    cin >> a;
    isSafe[a] = false;
  }

  dp.assign(N + 1, 0);
  dp[0] = 1;
  if (isSafe[1]) dp[1] = 1;
  FOR(n, 2, N + 1) {
    if (isSafe[n - 1]) dp[n] += dp[n - 1];
    if (isSafe[n - 2]) dp[n] += dp[n - 2];
    dp[n] %= MOD;
  }

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

Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define int ll
//int INF = 1e9;
const long long INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template<class T> inline void chmax(T & a, T b) { if (a < b) a = b; }
template<class T> inline void chmin(T& a, T b) { if (a > b)  a = b; }

signed main() {
	ios::sync_with_stdio(false);
	int sum = 0;
	int N;
	cin >> N;
	vector<int> d(N);
	rep(i, N) cin >> d[i];
	rep(i, N) {
		for (int j = i + 1; j < N; j++) {
			if (j == N) break;
			sum += d[i] * d[j];
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
using System;

	class Takoyaki
	{

		static void Main(string[] args)
		{
			
			string[] input = Console.ReadLine().Split(' ');
			int n = int.Parse(input[0]);
			int x = int.Parse(input[1]);
		    int t = int.Parse(input[2]);

		int kaisuu;
		int warizan = n / x;
		int amari = n % x;

        if (amari >= 1)
        {
			kaisuu = warizan + 1;
        }
        else
        {
			kaisuu = warizan;
        }

		int time = kaisuu * t;

		Console.WriteLine(time);



		}

	}

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

int main(){
  int n;
  cin >> n;
  int a, b, c, d;
  a = n%10;
  b = n/10-(n/100)*10;
  c = n/100-(n/1000)*10;
  d = n/1000;
  if (((a == b) && (b == c)) || ((b == c) && (c == d))){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line().split_whitespace().map(|s| s.to_string()).collect()
    }

    pub struct Reader {
        buf : VecDeque<String>
    }

    impl Reader {
        pub fn new() -> Reader {
            Reader {buf : VecDeque::new()}
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T where T: FromStr, T::Err: Debug {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }
    }
}

const MOD : i64 = 1000000007;
fn f(n : i64) -> i64 {
    match n {
        1 => 1i64,
        _ => n * f(n - 1) % MOD,
    }
}

fn with_large_stack(func : fn() -> ()) {
    use std::thread::Builder;
    let builder = Builder::new();
    let th = builder.stack_size(10000000);

    th.spawn(move || {
        func();
    }).unwrap().join();
}

fn main() {
    with_large_stack(_main);
}

fn _main() {
    let mut reader = reader::Reader::new();

    let m : i64 = reader.next();
    let n : i64 = reader.next();

    println!("{}", if (m - n).abs() <= 1 {
        f(m) * f(n) * (2 - (m - n).abs()) % MOD 
    } else {
        0
    });
}

Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll x,ans;
  cin >> x;
  ans=(x-1)/11;
  if(ans*11+6>=x){
    cout << 2*ans+1 << endl;
  }else{
    cout << 2*ans+2 << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
MAX = 0
cnt = 0
WORD = []
for i in range(N):
    if i == 0:
        cnt = 1
        MAX = 1
        WORD.append(S[i])
    elif S[i] == S[i-1]:
        cnt+=1
        if cnt == MAX:
            WORD.append(S[i])
        if cnt > MAX:
            MAX = cnt
            WORD.clear()
            WORD.append(S[i])
    else:
        cnt = 1
        if cnt == MAX:
            WORD.append(S[i])

for ans in WORD:
    print(ans)

Measured memory_bytes: 20680
from bisect import bisect_left as b
n=int(input())
p=[-1]*(n+1)
p[-1]=float("INF")
q=n
for i in range(n):
    x=int(input())
    d=b(p,x)-1
    q=min(q,d)
    p[d]=x
print(n-q)

Measured memory_bytes: 7028
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        long ans = 0;
        for (int a=1;a<=k;a++){
            for (int b=1;b<=k;b++){
                for (int c=1;c<=k;c++){
                    ans+=gcd(gcd(a,b),c);
                }
            }
        }
        System.out.println(ans);
    }
    static long factorial(long num){
        if (num<2)return 1;
        else return num*factorial(num-1);
    }
    static int arraySum(int[] array){
        int ans = 0;
        for (int value : array) ans += value;
        return ans;
    }
    static long combination(long a, long b){
        long data = 1;
        for (int i=0;i<b;i++){
            data*=a-i;
        }
        return data/factorial(b);
    }
    static double log(double base,double antilogarithm){
        return Math.log(antilogarithm)/Math.log(base);
    }

    static long gcd(long x,long y){
        if (y==0)return x;
        else return gcd(y,x%y);
    }
    static long lcm(long x,long y){
        return x/gcd(x,y)*y;
    }

}


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

int main(void){
    int a,b,check = 0;
    cin >> a >> b;
    string s;
    cin >> s;
    for(int i = 0;i < (a+b+1);i++){
        if((i != a && s[i] == '-') || (i == a && s[i] != '-'))++check;
    }
    if(check == 0)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	map<int, ll> mp;
	ll sum = 0;
	rep(i, n) {
		int a;
		cin >> a;
		mp[a]++;
		sum += a;
	}
	int q;
	cin >> q;
	while (q--) {
		int b, c;
		cin >> b >> c;
		ll tmp = mp[b];
		sum -= tmp * b;
		mp[b] = 0;
		mp[c] += tmp;
		sum += c * tmp;
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 9444
#include <iostream>
    #include <vector>
    using namespace std;
     
    int main(){
      int N;
      int ans=0,cst=0;
      cin >> N ;
      vector<int> vl(N);
      for(int i = 0;i <N ;i++){
        cin >> vl[i];
      }
      for(int i = 0;i<N; i++){
        cin>>cst;
        if ((vl[i] - cst) > 0){
          ans += vl[i] - cst;
        }
      }
      cout << ans << endl; 
      return 0;
    }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a;
    int b;
    cin >> a;
    cin >> b;
    int count = 0;
    for(int i = 1; i <= a; i = i+2){
        count ++;
    }
    if(count >= b) cout << "YES" << "\n";
    else cout << "NO" << "\n";
}


Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)



int main() {
	int n,ans=0,cnt=0;
	cin >> n;
	VI a(n);
	rep(i, n) cin >> a[i];

	sort(all(a));

	for (int i = n ; i >= 0; i--) {
		if (cnt % 2 == 0) {
			ans += a[i];
		} else {
			ans -= a[i];
		}
		cnt++;
	}

	cout << abs(ans) << endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <string>

using namespace std;
#define M 1100000

int main(){
  long long ans=0, a[M], N, i, x, end;
  cin >> N;
  for (i = 0; i < N*3; i++)
    cin >> a[i];
  sort(a, a+N*3);
  for (i = N; i < N*3; i+=2){
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4096
import sys
from statistics import *
from collections import *
from operator import itemgetter
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
ct = 0
cap = ["M", "A", "R", "C", "H"]
ct = [0] * 5
for i in range(n):
    s = input()
    for i in range(5):
        if s[0] == cap[i]:
            ct[i] += 1
ans = 0
for a in range(5):
    for b in range(a+1, 5):
        for c in range(b+1, 5):
            ans += ct[a] * ct[b] * ct[c]
print(ans)

Measured memory_bytes: 5148
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools



sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

#N = int(input())
AB = input().split()
A = int(AB[0])
B = int(AB[1].replace('.',''))

ans = A*B
print(int(ans//100))


Measured memory_bytes: 68760
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
using namespace std;
int main()
{
	long long l,r;
	cin>>l>>r;
	if(r-l>=2020){
		cout<<0<<endl;
		return 0;
	}
	long long mn=9223372036854775807;
	for(long long i=l;i<r;i++){
		for(long long j=i+1;j<=r;j++){
			mn=min(mn,((i%2019)*(j%2019))%2019);
		}
	}
	cout<<mn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    int A, B, C, d = 0;
    cin >> A >> B >> C;
    int w = A * 7 + B;
    if(C >= w) {
        d = 7 * (C / w);
        C %= w;
    }
    d += (C > A * 7) ? 7 : ceil(C * 1.0 / A);

    cout << d << endl;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <tuple>
#include <map>
#include <numeric>

using namespace std;
#define PI 3.14159265359
#define ll long long int

int main(void)
{
    ll N, M;
    cin >> N >> M;
    if(N == M) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256