akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 510000;
const int MOD =  998244353;
const int INV2 = (MOD+1)/2;
int modpow(int a, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template <typename T>
void fwt(vector<T>& f) {
    int n = f.size();
    for (int i = 1; i < n; i <<= 1) {
        for (int j = 0; j < n; j++) {
            if ((j & i) == 0) {
                T x = f[j], y = f[j | i];
                f[j] = (x + y)%MOD, f[j | i] = (x+MOD - y)%MOD;
            }
        }
    }
}
template <typename T>
void ifwt(vector<T>& f) {
    int n = f.size();
    for (int i = 1; i < n; i <<= 1) {
        for (int j = 0; j < n; j++) {
            if ((j & i) == 0) {
                T x = f[j], y = f[j | i];
                f[j] = (x + y)%MOD * INV2%MOD, f[j | i] = (x+MOD - y)%MOD*INV2%MOD;
            }
        }
    }
}

     signed main(){

  int n;
  cin>>n;
 vector<int> a(1ll<<n),b(1ll<<n,1),c(1ll<<n,0);
  for(int i=0;i<(1ll<<n);i++)cin>>a[i];
 c[0]=1;
 int al=0;
 for(int i=0;i<(1ll<<n);i++)al=(al+a[i])%MOD;
 al=modpow(al,MOD-2,MOD);
 for(int i=0;i<(1ll<<n);i++)a[i]=(a[i]*al)%MOD;
  fwt(a);fwt(b);fwt(c);
   //  for(int i=0;i<(1ll<<n);i++)cerr<<a[i]<<' '<<b[i]<<' '<<c[i]<<endl;
     if(a[0]!=1){
    
  for(int i=0;i<(1ll<<n);i++)b[i]=(b[i]*modpow((1+MOD-a[i])%MOD,MOD-2,MOD))%MOD;
    for(int i=0;i<(1ll<<n);i++)c[i]=(c[i]*modpow((1+MOD-a[i])%MOD,MOD-2,MOD))%MOD;
    //  for(int i=0;i<(1ll<<n);i++)cerr<<b[i]<<' '<<c[i]<<endl;
    ifwt(b),ifwt(c);
    int t=b[0]*modpow(c[0],MOD-2,MOD)%MOD;

    for(int i=0;i<(1ll<<n);i++)cout<<(b[i]+MOD-c[i]*t%MOD)%MOD<<endl;
     }else{
     c[0]=0;
       for(int i=1;i<(1ll<<n);i++){
         c[i]=(MOD - (1ll<<n)%MOD*modpow((1+MOD-a[i])%MOD,MOD-2,MOD)%MOD);
         c[0]=(c[0]+MOD-c[i])%MOD;
       }
       // for(int i=0;i<(1ll<<n);i++)cout<<c[i]<<endl;
       ifwt(c);
       for(int i=0;i<(1ll<<n);i++)cout<<c[i]<<endl;
     }
 




}


        


Measured memory_bytes: 8960
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_Beginner_Contest_161
{
    class A
    {
        static void Main(string[] args)
        {
         
            var line = System.Console.ReadLine();
            var str = line.Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);

            int boxFirst = a;
            a = b;
            b = boxFirst;

            int boxSecond = a;
            a = c;
            c = boxSecond;

            Console.WriteLine(a + " " + b + " " + c);

        }
    }
}



Measured memory_bytes: 13140
# https://atcoder.jp/contests/hitachi2020/submissions/10704509
# PyPyなら通る

def main():
    import sys
    input = sys.stdin.readline

    inf = 1 << 30
    L = 30

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

    ps = []
    coef_0 = []
    for _ in range(N):
        a, b = map(int, input().split())
        if a == 0:
            coef_0.append(b + 1)
        else:
            ps.append((a, b))  # namedtupleやめた,coef,const

    ps.sort(key=lambda p: p[0] / (p[1] + 1), reverse=True)
    coef_0.sort()

    dp = [inf] * (L + 1)
    dp[0] = 0
    for coef, const in ps:
        for visited in reversed(range(L)):
            dp[visited + 1] = min(
                dp[visited + 1],
                (dp[visited] + 1) * (coef + 1) + const
            )

    def accumulate(a):
        s = 0
        yield s  # start=x->0
        for x in a:
            s += x
            yield s

    *acc, = accumulate(coef_0)

    ans = 0
    cnt = len(acc) - 1
    for visited, consumption_time in enumerate(dp):
        rest = T - consumption_time
        if rest < 0: break  # le->lt,continue->break,restは狭義単調減少
        while cnt > 0 and acc[cnt] > rest:  # bisect_right->しゃくとり
            cnt -= 1
        visited += cnt
        if visited > ans:
            ans = visited  # 関数呼び出しとどちらが速いか(set->maxよりは逐次が速かった）
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

ll k;
ll solve(vll& x, ll b){
    vll cnt(b, 0);
    rep(i, SZ(x)){
        rep(j, b){
            cnt[j] += ((x[i]>>j)&1);
        }
    }
    //dump(cnt);
    ll ret = 0;
    for(ll i = b-1; i >= 0; i--){
        if(cnt[i] >= k){
            vll y;
            rep(j, SZ(x)){
                if((x[j]>>i)&1){
                    y.emplace_back(x[j]);
                }
            }
            ret += (1ll << i);
            ret += solve(y, i);
            break;
        }
    }
    return ret;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n >> k;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    vll sum;
    rep(i, n){
        ll s = 0;
        repr(j, i, n){
            s += a[j];
            sum.emplace_back(s);
        }
    }
    sort(ALL(sum));
    cout << solve(sum, 60) << endl;
    /*
    rep(i, SZ(sum)){
        cout << std::bitset<8>(sum[i]) << endl;
    }
    */
    return 0;
}

Measured memory_bytes: 6252
H, W = map(int, input().split())

visited = [[False]*(W+2) for _ in range(H+2)]
dh = [0,1,0,-1]
dw = [1,0,-1,0]

from collections import deque
d = deque()

S = [0]*(H+2)
S[0] = '*'*(W+2)
S[H+1] = '*'*(W+2)
white = 0
for h in range(1,H+1):
    S[h] = '*' + input() + '*'
    for w in range(1,W+1):
        if S[h][w]=='#':
            visited[h][w]=True
            d.append((h,w,0))
    


while len(d)>0:
    h,w,cnt = d.popleft()
    for i in range(4):
        h0 = h+dh[i]
        w0 = w+dw[i]
        if S[h0][w0]=='.' and visited[h0][w0]==False:
            visited[h0][w0]=True
            d.append((h0,w0,cnt+1))
print(cnt)

Measured memory_bytes: 137688
#include<bits/stdc++.h>
using namespace std;
char c;
int main() {
	ios::sync_with_stdio(false);
	cin >> c;
	if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
		cout << "vowel\n";
	else
		cout << "consonant\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
#define ck(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9;

int main() {
	string S;
	cin>>S;
	set<char> s;
	string ans="yes";
	REP(i,0,S.size()){
		if(s.find(S[i])==s.end()) s.insert(S[i]);
		else{
			ans="no";
			break;
		}
	}
	p(ans);
	return 0;
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n, m, k; cin >> n >> m >> k;

    bool ok = false;
    if (k == 0) ok = true;
    else if (k % n == 0) ok = true;
    else if (k % m == 0) ok = true;
    else {
        REP(i, n) REP(j, m)
            if (i * (m - j) + j * (n - i) == k)
                ok = true;
    }

    if (ok) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 256
s = input()
flag = 1

t = s[:(len(s)-1)//2]

for i in range(len(t)):
    if t[i] == t[-1-i]:
        continue
    else:
        flag = 0
t = s[(len(s)+3)//2-1:]
for i in range(len(t)):
    if t[i] == t[-1-i]:
        continue
    else:
        flag = 0
for i in range(len(s)):
    if s[i] == s[-1-i]:
        continue
    else:
        flag = 0
if flag == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int i,a,b,k;
  scanf("%d %d %d",&a,&b,&k);
  for(i=(a>b)?a:b;i>0;i--){
    if(a%i==0 && b%i==0){
      k--;
      if(k==0)
        break;
    }
  }
  printf("%d\n",i);
  return 0;
}

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

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

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

int main(){
  int n, m;
  cin >> n >> m;
  int a[100][100], b[100];
  rep(i,n){
    rep(j,m){
      cin >> a[i][j];
    }
  }
  rep(i, m) cin >> b[i];

  rep(i,n){
    int ans = 0;
    rep(j,m){
      ans += a[i][j] * b[j];
    }
    cout << ans << endl;
  }
}





Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
IOS;
long long int s=0;
int n;
cin>>n;
vector<int> v(n);
for(int i=0;i<n;i++)cin>>v[i];
for(int i=1;i<n;i++){
    if(v[i]<v[i-1]){
     s+=v[i-1]-v[i];
     v[i]=v[i-1];
    }
}
cout<<s<<"\n";
}
/*sjleepy*/


Measured memory_bytes: 3988
from collections import Counter as co
n=int(input())
l=list(map(int,input().split()))
var=co(l)
v=var.values()
ans=sum((i*(i-1))//2 for i in v)
for i in l:
    d=var[i]
    d=(d*(d-1))//2-((d-1)*(d-2))//2
    print(ans-d)

Measured memory_bytes: 26780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <tuple>
#include <random>
#include <unordered_map>
#include <unordered_set>
using namespace std ;

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

    string input ; 
    set<string> type ;
    for (int i=0;i<n;++i) {
        cin >> input ; 
        type.insert(input) ;
    } 
    cout << type.size(); 
}
 

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

int main(){
    int A,B;
    cin >>A>>B;
    string S;
    cin >>S;
    vector<int> index;
    string ans="No";
    for(int i=0;i<S.size();i++){
      if(S.at(i)=='-')index.push_back(i);
    }
    if(index.size()==1&&index[0]==A)ans="Yes";

    cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define foro(i, n) for(i=0; i<n; i++)
#define forl(i, n) for(i=1; i<=n; i++)
#define x first
#define y second
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 1e18 + 1;

bool isPalindrome(string &s, int low, int high){
	while(low < high){
		//printf("%c %c\n", s[low], s[high]);
		if(s[low++] != s[high--])
			return false;
	}
	//printf("true\n");
	return true;
}

int main()
{
	int i, j, k, l, tmp;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	int n = s.length();
	(isPalindrome(s, 0, n-1) && isPalindrome(s, 0, -1+(n-1)/2) && isPalindrome(s, -1+(n+3)/2, n-1)) ? printf("Yes\n") : printf("No\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W;
    cin >> H >> W;
    if (H == 1 || W == 1)
    {
        cout << 1 << "\n";
        return 0;
    }
    ll a, b;
    a = (W + 1) / 2;
    b = W / 2;
    ll all;
    ll c, d;
    c = (H + 1) / 2;
    d = H / 2;
    ll result = a * c + b * d;
    cout << result << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int N, A[200010] = {0}, t;
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		scanf("%d", &t);
		A[t]++;
	}
	for (int i = 1; i <= N; i++) printf("%d\n", A[i]);
	return 0;
}

Measured memory_bytes: 2504
require "matrix"

n, d = gets.chomp.split.map(&:to_i)
points = []
n.times{points << gets.chomp.split.map(&:to_i)}
ans = 0

points.combination(2) do |p1, p2|
  v1 = Vector[*p1]
  v2 = Vector[*p2]
  ans += 1 if (v2 - v1).r % 1 == 0
end

puts ans

Measured memory_bytes: 4604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main()
{

    string s;
    cin >> s;
    if ((s.at(0) == 'A' && s.at(1) == 'A' && s.at(2) == 'A') || (s.at(0) == 'B' && s.at(1) == 'B' && s.at(2) == 'B'))
    {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
H, W = map(int,input().split())
#A = [list(map(str,input().split())) for i in range(H)]
A = [list(input()) for i in range(H)]

#from queue import Queue
from collections import deque

dj = [1, 0, -1, 0]
di = [0, 1, 0, -1]

sum_sharp = sum([A[i].count('#') for i in range(H)])

fin_d_max = 1

for s_i in range(H):
    for s_j in range(W):
        #print(s_i,s_j)
        d_max = 0
        #q_i = Queue()
        q_i = deque()
        #q_j = Queue()
        q_j = deque()
        D = [[-1]*W for i in range(H)]
        #flag = [[0]*W for i in range(H)]
        flag = 1

        if A[s_i][s_j] == '.':
            D[s_i][s_j] = 0
            #q_i.put(s_i)
            q_i.append(s_i)
            #q_j.put(s_j)
            q_j.append(s_j)
            #while sum(map(sum, flag)) != W*H - sum_sharp:
            #while flag < W*H - sum_sharp:
            #while q_i.empty() == False:
            while len(q_i)!=0:
            #for a in range(W*H):
                #i = q_i.get()
                i = q_i.popleft()
                #j = q_j.get()
                j = q_j.popleft()
                for x in range(4):
                    ni = i+di[x]
                    nj = j+dj[x]
                    #if ni<0 or ni>=H or nj<0 or nj>=W or A[ni][nj]== '#' or 0<=D[ni][nj]<D[i][j]+1:
                    if ni<0 or ni>=H or nj<0 or nj>=W or A[ni][nj]== '#' or D[ni][nj]!=-1:
                    #if ni<0 or ni>=H or nj<0 or nj>=W:
                        continue
                    #elif A[ni][nj]== '#' or D[ni][nj] < D[i][j]+1:
                        #flag[ni][nj] = 1
                        #continue
                    else:
                        #if D[ni][nj] == -1:
                            #print(flag)
                        flag += 1
                        D[ni][nj] = D[i][j]+1
                        d_max = max(d_max, D[ni][nj])
                        #q_i.put(ni)
                        q_i.append(ni)
                        q_j.append(nj)
                        #q_j.put(nj)
        fin_d_max = max(fin_d_max, d_max)
                
print(fin_d_max)

Measured memory_bytes: 3316
$N=<>;@A=<>;
for$t(1..$N){
	for($i=0;$i<2**$N;$i+=2**$t){
		$A[$i]!=$A[$i+2**($t-1)]and$A[$i]=abs$A[$i]-$A[$i+2**($t-1)];
	}
}
print$A[0],$/

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, m, p, pp, c, t;
  ll mod=1e9+7;
  cin >> n >> m;
  vecll a(n+1, 0);
  forll(i, 0, m){
	cin >> t;
	a[t] = 1;
  }
  if (n == 1)
	cout << 1 << endl;
  else if (n == 2 && m == 0)
	cout << 2 << endl;
  else if (n == 2 && m == 1)
	cout << 1 << endl;
  else{
	pp = 1;
	if (a[1] == 0)
	  p = 1;
	else
	  p = 0;
	forll(i, 0, n - 1){
	  if (a[i] == 1 && a[i + 1] == 1){
		cout << 0 << endl;
		return 0;
	  }
      if (a[i + 2] == 1){
        pp = p;
      }
	  else if (a[i] == 1){
		c = p % mod;
		pp = p;
		p = c;
	  }
	  else if (a[i + 1] == 1){
		c = pp % mod;
		p = c;
	  }else{
		c = (pp + p) % mod;
		pp = p;
		p = c;
	  }
	}
	cout << c << endl;
  }
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int n;
const int maxn = 205;
int a[maxn];
int b[maxn];
int main()
{
     cin>>n;
     for(int i=1;i<=n;i++)
     {
         cin>>a[i];
         if(a[i]%2==1)b[i]=0;
         else
         {
             int k = 0;
             while(a[i]%2==0)
             {
                 a[i]/=2;
                 k++;
             }
             b[i]=k;
         }
     }
     sort(b+1,b+1+n);
     cout<<b[1]<<endl;
     return 0;
}

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

int n;
vector<int> a;

void solve() {
  int i;
  ll tmp1, tmp2, sum = 0;

  for (i = 0; i <= n; i++) {
    sum += abs(a[i + 1] - a[i]);
  }

  for (i = 1; i <= n; i++) {
    tmp1 = abs(a[i + 1] - a[i - 1]);
    tmp2 = abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
    cout << sum + tmp1 - tmp2 << "\n";
  }
  return;
}

int main() {
  int i;

  cin >> n;

  a.resize(n + 2);
  a[0] = 0;
  a[n + 1] = 0;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }

  solve();
  return 0;
}

Measured memory_bytes: 1664
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	string s;
	cin>>s;
	int rw=0,re=0,lw=0,le=0;
	for(char c:s)if(c=='W')rw++;else re++;
	int mi = n;
	for(char c:s) {
		if(c=='W')rw--;
		else re--;
		mi = min(mi, lw+re);
		if(c=='W')lw++;
		else le++;
	}
	cout<<mi;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

int J[1010][1010], O[1010][1010], I[1010][1010];
int n, m, k;

int main()
{
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= m; j++){
      char c;
      cin >> c;
      J[i][j] = c == 'J';
      O[i][j] = c == 'O';
      I[i][j] = c == 'I';
    }
  }

  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= m; j++){
      J[i][j] += J[i][j - 1];
      O[i][j] += O[i][j - 1];
      I[i][j] += I[i][j - 1];
    }
  }

  for (int j = 1; j <= m; j++){
    for (int i = 0; i <= n; i++){
      J[i][j] += J[i - 1][j];
      O[i][j] += O[i - 1][j];
      I[i][j] += I[i - 1][j];
    }
  }

  for (int i = 0; i < k; i++){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--; b--;
    cout << (J[c][d] - J[a][d]) - (J[c][b] - J[a][b]) << " ";
    cout << (O[c][d] - O[a][d]) - (O[c][b] - O[a][b]) << " ";
    cout << (I[c][d] - I[a][d]) - (I[c][b] - I[a][b]) << endl;
  }
}

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

class P
{
    static void Main()
    {
        Console.ReadLine();
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int other = 0;
        int multi2 = 0;
        int multi4 = 0;

        foreach (var i in a)
        {
            if (i % 2 == 0)
            {
                if (i % 4 == 0)
                {
                    multi4++;
                }
                else
                {
                    multi2++;
                }
            }
            else
            {
                other++;
            }
        }
        if (other <= multi4 || (other - 1 == multi4 && multi2 == 0))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 21728
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;
typedef long long int ll;

struct Edge{
	int to; ll dist;
	Edge(){}
	Edge(int to,ll dist):to(to),dist(dist){}
};

template <class E>
using Graph = vector<vector<E>>;
 
template<class D, D INF>
struct Dijkstra {
    vector<D> res; //res[i] = sからiまでの最短距離
    
    template<class E>
    Dijkstra(const Graph<E> &g, int s) {
        int V = (int)g.size();
        res = vector<D>(V, INF);
        
        using P = pair<D, int>;
        priority_queue<P, vector<P>, greater<P>> q;
        q.push(P(0, s));
        res[s] = 0;
        while (!q.empty()) {
            P p = q.top(); q.pop();
            if (res[p.second] < p.first) continue;
            for (E e: g[p.second]) {
                if (p.first+e.dist < res[e.to]) {
                    res[e.to] = p.first+e.dist;
                    q.push(P(res[e.to], e.to));
                }
            }
        }
    }
};
int a[200100],b[200100],d[200100];
ll sum[100100];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	Graph<Edge> g(n);
	ll c; cin >> c;
	for(int i=0;i<m;i++){
		cin >> a[i] >> b[i] >> d[i];
		a[i]--; b[i]--;
		g[a[i]].push_back(Edge(b[i],d[i]));
		g[b[i]].push_back(Edge(a[i],d[i]));
	}
	Dijkstra<ll,(ll)1e15> di(g,0);
	for(int i=0;i<m;i++){
		if(di.res[a[i]]<di.res[b[i]])sum[b[i]]+=d[i];
		else sum[a[i]]+=d[i];
	}
	vector<pair<ll,int>> v;
	for(int i=0;i<n;i++){
		v.push_back({di.res[i],i});
	}
	sort(v.rbegin(),v.rend());
	ll ans=1e15;
	ll cnt=0;
	for(int i=0;i<n;i++){
		ans=min(ans,cnt+v[i].first*c);
		cnt+=sum[v[i].second];
	}
	ans=min(ans,cnt);
	cout << ans << endl;
}



Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define INF 1e18
#define Rep(i, a, n) for (ll i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000000
#define ll long long
#define P pair<int,int>
#define cout_set(n) cout << setprecision(10) << (n) << endl; 
const double PI=3.14159265358979323846;
using namespace std;
const int mod = 1000000007; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 

ll lt[MAX+1]={};

signed main(){
    ll n; cin >> n;
    vector<ll> a; 
    rep(i,n){
        ll p;cin >> p;
        a.push_back(p);
    }
    //cout << 1 << endl;
    sort(a.begin(),a.end());
    vector<ll> b;
    ll t=0;
    while(t < n){
        ll k = a[t];
        b.push_back(k);
        t++;
        while(t != n){
            if(a[t] != k) break;
            lt[k]++;
            t++;
        }
    }
    /*
    cout << "a : ";
    for(auto y : a) cout << y << " ";
    cout << endl << "b : ";
    for(auto y : b) cout << y << " ";
    cout << endl;
*/
    ll cnt=0;
    rep(i,b.size()){
        ll k = b[i],p = 1;
        while(p*k <= MAX){
            lt[p*k] ++;
            p++;
        }
    }
    
    rep(i,b.size()){
        ll u = b[i];
        if(lt[u] == 1) cnt++;
        
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 14484
<?php
fscanf(STDIN, "%d", $n);
$in = fgets(STDIN);
$init = explode(" ", $in);
$ret = 0;
$is_even = true;
//var_dump($init, $ret, $is_even);
//exit;
do {
    for($i = 0; $i < count($init); $i++) {
        $tmp = $init[$i] % 2;
        if($tmp != 0) {
            $is_even = false;
            break;
        }
        $init[$i] = $init[$i] / 2;
    }
    if($is_even) $ret++;
} while ($is_even);

echo $ret. "\n";
//var_dump($init, $ret);

Measured memory_bytes: 4728
long a[3000],dp[3001][3001];
i,j;
main(n)
{
	for(scanf("%d",&n);~scanf("%d",a+j++););
	for(i=n;i--;)
	{
		for(j=i;j++<n;)
		{
			dp[i][j]=fmax(a[i]-dp[i+1][j],a[j-1]-dp[i][j-1]);
		}
	}
	printf("%ld",dp[0][n]);
}

Measured memory_bytes: 69888
import java.util.Scanner;


public class Main{
    public static void main(String srgs[]){
        Scanner sc = new Scanner(System.in);
        int m[] = new int[50];
        int f[] = new int[50];
        int r[] = new int[50];
        int i=0;
        while(true){
            m[i] = sc.nextInt();
            f[i] = sc.nextInt();
            r[i] = sc.nextInt();
            if(m[i]==-1 && f[i]==-1 &&r[i]==-1){
                break;
            }
            if(m[i]==-1 || f[i]==-1){
                System.out.printf("F\n");
        }else if(m[i]+f[i]>=80){
            System.out.printf("A\n");
        }else if(m[i]+f[i]<80 && 65<= m[i]+f[i]){
            System.out.printf("B\n");
        }else if(m[i]+f[i]>=50 && m[i]+f[i]<65){
            System.out.printf("C\n");
        }else if(m[i]+f[i]>=30 && m[i]+f[i]<50){
            if(r[i]>=50){
                System.out.printf("C\n");
            }else{
            System.out.printf("D\n");
            }
        }else if(m[i]+f[i]<30){
            System.out.printf("F\n");
        }
        
            
            i++;
            
        }
        sc.close();
    }
}


Measured memory_bytes: 26280
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr int MOD = 1000000007;

template<typename T> long pow_mod(long base, T exp, const T mod = 1'000'000'007) {
  base %= mod;
  long result = 1L;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % mod;
    base = (base * base) % mod;
    exp >>= 1;
  }
  return result;
}

long factrial(int n, int a) {
  if (a == 1) return n;
  return (factrial(n - 1, a - 1) * n) % MOD;
}

long comb_mod(int n, int r, const int mod = 1000000007) {
  return factrial(n, r) * pow_mod(factrial(r, r), MOD - 2) % MOD;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  long ans;
  ans = pow_mod(2, n) - 1;
  ans -= comb_mod(n, a) + comb_mod(n, b);
  while (ans < 0) {
    ans += MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6692
N = int(input())
A = list(map(int,input().split()))
K = [0]*(N+1)
M = [0]*(N+1)

for i in A:
    K[i] += 1
# print(K)
for i in range(N+1):
    M[i] = K[i]*(K[i]-1)//2
# print("K:",K)
y = sum(M)
# print("y:",y)

for a in A:
    # print("a:",a)
    print(y-K[a]+1)

Measured memory_bytes: 25376
#include <iostream>
#include <string>
using namespace std;
//---------------------------------------
void print(string str, int n1, int n2);
void reverse(string &str, int n1, int n2);
void replace(string &str, int n1, int n2, string replace_str);
//---------------------------------------

int main(void)
{
	string str;  //?????????str
	int commands;   //????????°
	
	//??????????????\???
	cin >> str;
	
	//????????°q?????\???
	cin >> commands;
	
	for(int i = 0; i < commands; i++){
		
		string command;
		int n1, n2;
		
		cin >> command;
		cin >> n1;
		cin >> n2;
		
		if(command == "print"){ //??????????????????
			print(str, n1, n2);
		}
		else if(command == "reverse"){  //??????????????????
			reverse(str, n1, n2);
		}
		else{  //????????¬????????????
			string replace_str;
			cin >> replace_str;
			replace(str, n1, n2, replace_str);
		}
	}
	
	
	return 0;
}

//------------------------------------------------------------
void print(string str, int n1, int n2)
{
	cout << str.substr(n1, n2-n1+1) << endl;
	/*
	for(int i = n1; i <= n2; i++){
		cout << str[i];
	}
	cout << endl;
	*/
}

//------------------------------------------------------------
void reverse(string &str, int n1, int n2)
{

	string copy = str;
	int j = 0;
	
	for(int i = n1; i <= n2; i++){
		str[i] = copy[n2 - j];
		j++;
	}
	
}

//------------------------------------------------------------
void replace(string &str, int n1, int n2, string replace_str)
{
	str.replace(n1, n2-n1+1, replace_str);
	/*int j = 0;
	for(int i = n1; i <= n2; i++){
		str[i] = replace_str[j];
		j++;
	}
	*/
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;

const int N=1e6+5;
int n,d,x[N],y[N];

void solve()
{
    int k;
    cin>>k;
    k/=__gcd(k,7ll);
    int cur=0;
    for(int i=1;i<=50000000;i++)
    {
        if((cur*10+1)%k==0)
        {
            cout<<i;
            return ;
        }
        cur=(cur*10+1)%k;
    }
    cout<<-1;
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //int t;
    //cin>>t;
    //while(t--)
        solve();
}


Measured memory_bytes: 3648
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

MOD = pow(10, 9) + 7

def main():
    n, c = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    
    pow_table = [[0 for _ in range(401)] for _ in range(401)]
    # pow_table[i][j]: i^j
    for i in range(1, 401):
        pow_table[i][0] = 1
    
    for i in range(1, 401):
        for j in range(1, 401):
            pow_table[i][j] = pow_table[i][j-1] * i % MOD
    for i in range(1, 401):
        for j in range(401):
            pow_table[i][j] += pow_table[i-1][j]
            if pow_table[i][j] >= MOD:
                pow_table[i][j] -= MOD
    
    dp = [[0 for _ in range(c+1)] for _ in range(n+1)]
    dp[0][0] = 1
    for i in range(1, n+1):
        for j in range(c+1):
            for k in range(j+1):
                ab = pow_table[b[i-1]][k] - pow_table[a[i-1]-1][k]
                if ab < 0:
                    ab += MOD
                dp[i][j] += dp[i-1][j-k] * ab % MOD
                if dp[i][j] >= MOD:
                    dp[i][j] -= MOD

    print(dp[n][c])


if __name__ == '__main__':
    main()


Measured memory_bytes: 44912
n,k = map(int, input().split())
mod = 10**9+7
cnt = [0]*(k+1)
for i in reversed(range(2, k+1)):
    if i*2 > k:
        cnt[i] = 1
        continue
    a = k//i
    tmp = pow(a, n, mod)
    for j in range(2*i, k+1, i):
        tmp -= cnt[j]
    cnt[i] = tmp

s = sum(cnt)
ans = pow(k,n,mod) - s
for i in range(k+1):
    ans += i*cnt[i]
    ans %= mod
print(ans)


Measured memory_bytes: 69324
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
e = []
s = [0]
sj = []

for x in p:
    e.append((1 + x) / 2)

for x in range(n):
    s.append(s[x] + e[x])

for x in range(k, n + 1):
    sj.append(s[x] - s[x - k])
    
print(max(sj))

Measured memory_bytes: 28232
#include <bits/stdc++.h>
using namespace std;
 
#define fio() ios_base::sync_with_stdio(false);\
cin.tie(NULL);
 
#define md 1000000007
typedef long long int lli;
typedef float fl;
#define mem(arr,x) memset(arr,x,sizeof(arr))

typedef struct tim
            {
               lli a; 
               lli val;
            }item;


lli comparator(item p,item q) 
{ 
    return (   p.val < q.val ) ; 
} 

lli power(lli x, lli y, lli p) 
{ 
    lli res = 1;    
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
  
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
}
 

int main()
{    
    fio();
   
    	lli i,j,k=0,l,m,n,w,z;
		cin>>n>>w;
		item ar[n+1];
		for(i=1;i<=n;i++)
			cin>>ar[i].a>>ar[i].val;
		
		lli d[n+1][w+1];
		mem(d,0);
		
    	for(i=0;i<=n;i++)
    	{
    		for(j=0;j<=w;j++)
    		{
    			z=0;
    			if(i==0 || j==0) d[i][j]=0;
    			else if (ar[i].a<=j) 
               { z=j-ar[i].a; d[i][j] = max( ar[i].val+d[i-1][z],  d[i-1][j] ); }
          		else d[i][j] = d[i-1][j]; 
           
			}
		}
		cout<<d[n][w];
}

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

int main(){
    string s;
    cin >> s;
    int n = s.length()-1;
    long long sum = 0;

    for(int bit = 0; bit < (1<<n);bit++){
        int start = 0;
        int stop = n+1;
        for(int i = 0;i < n;i++){
            if(bit & (1<<i)){
                stop = i+1;
                sum += atoll(s.substr(start,stop-start).c_str());
                start = stop;
            }
        }
        sum += atoll(s.substr(start,n+1-start).c_str());
    }
    
    cout << sum << endl;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		a[0] = sc.nextInt();
		a[1] = sc.nextInt();
		a[2] = sc.nextInt();
		sc.close();

		Arrays.parallelSort(a);
		System.out.println(a[0] + a[1] + a[2] * 10);
	}
}


Measured memory_bytes: 21844
N, M = map(int, input().split())
pS = {}
for i in range(N):
    pS[i] = [0, 0, 0]  # is_ac, penatly, AC

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    if pS[p][0] == 0 and S == 'WA':
        pS[p][1] += 1
    elif pS[p][0] == 0 and S == 'AC':
        pS[p][0] = 1
        pS[p][2] = 1

AC = 0
penatly = 0
for i in range(N):
    if pS[i][0] == 1:
        penatly += pS[int(i)][1]
        AC += pS[int(i)][2]
print(AC, penatly)


Measured memory_bytes: 23584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    cout << (h%a)*w+(w%b)*h-(h%a)*(w%b) << endl;
}



Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <cmath>
#define INF 100000000;
using namespace std;
void chmin(int &a, int b){if(a>b) a=b;}

int N,A,B,C;
vector<int> L;

int rec(int i, int a, int b, int c){
  if(i==N){
    if(!a||!b||!c) return INF;
    // 取らなければならない竹の数
    return abs(a-A) + abs(b-B) + abs(c-C);
  }

  int res = rec(i+1,a,b,c);

  chmin(res,rec(i+1,a+L[i],b,c)+(a?10:0));
  chmin(res,rec(i+1,a,b+L[i],c)+(b?10:0));
  chmin(res,rec(i+1,a,b,c+L[i])+(c?10:0));
  return res;
}

int main(){
  cin>>N>>A>>B>>C;
  L.resize(N);
  for (int i = 0;i < N; ++i) cin >> L[i];

  cout << rec(0,0,0,0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<time.h>
using namespace std;
#define int long long
#define inf 1e9+7
typedef pair<int, int> P;

signed main() {
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (i == a) {
			if (s[i] != '-') {
				puts("No");
				return 0;
			}
		}
		else {
			if (s[i]<'0' || s[i]>'9') {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Data_Nerd ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define files freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
using ll = long long;

const int N = 400;

const ll inf = 2e18;

int arr[N];

ll memo[N][N];

int main() {
	Data_Nerd
	int n; scanf("%d", &n);

	for(int i = 0; i < n; ++i) {
		scanf("%d", arr + i);
	}

	for(int i = n - 1; i >= 0; --i) {
		for(int j = i; j < n; ++j) {
			if(i == j)
				memo[i][j] = 0;
			else {
				ll sum = 0;

				for(int k = i; k <= j; ++k)
					sum += arr[k];

				memo[i][j] = inf;

				for(int k = i; k < j; ++k)
					memo[i][j] = min(memo[i][j],
							memo[i][k] + memo[k + 1][j] + sum);
			}
		}
	}

	cout << memo[0][n - 1];
}


Measured memory_bytes: 1536
n,m,c=gets.chomp.split(" ").map{|s| s.to_i}
b=gets.chomp.split(" ").map{|s| s.to_i}
ans=0
for i in 0..n-1
  a=gets.chomp.split(" ").map{|s| s.to_i}
  for j in 0..m-1
    a[j]=a[j]*b[j]
  end
  if a.inject(:+)+c>0
    ans+=1
  end
end
puts ans

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

#define tc		int t;cin>>t;while(t--)
#define ll		long long
#define pb 		push_back

int cost(vector<int> h,int n){

	vector<int> dp(n+1);
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	return dp[n];
}

int main(){

	int n;
	cin>>n;
	vector<int> h(n+1);
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}	
	cout<<cost(h,n);

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll t;
  cin >> t;
  rep(_, t) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a < b || d < b || a % b > c) {
      // cout << 1 << ' ';
      cout << "No" << endl;
      continue;
    }
    if(c >= b - 1) {
      // cout << 2 << ' ';
      cout << "Yes" << endl;
      continue;
    }
    ll g = gcd(b, d);
    ll y = a % b;
    ll k = (c - y) / g + 1;
    if(g * k + y < b) {
      // cout << 3 << ' ';
      cout << "No" << endl;
    } else {
      // cout << 4 << ' ';
      cout << "Yes" << endl;
    }
  }
}

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

lli n;

int main(void){
	cin >> n;
	vector<lli> c(5);
	rep(i, n){
		string s;
		cin >> s;
		if(s[0] == 'M'){
			c[0]++;
		}else if(s[0] == 'A'){
			c[1]++;
		}else if(s[0] == 'R'){
			c[2]++;
		}else if(s[0] == 'C'){
			c[3]++;
		}else if(s[0] == 'H'){
			c[4]++;
		}
	}
	lli ans = 0;
	rep(i, 5){
		rep(j, 5){
			rep(k, 5){
				if(i == j || j == k || k == i) continue;
				ans+=c[i]*c[j]*c[k];
			}
		}
	}
	cout << ans/6 << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long lli;
typedef vector<lli> vll;

lli n;
vll w;
vll w_;
lli ans = 0;
lli mini;


int main(){
	cin >> n;
	w = vll(n);
	w_ = vll(n);
	for(lli i = 0;i < n;i++) cin >> w[i];
	for(lli i = 0;i < n;i++) w_[i] = i;
	sort(w_.begin(),w_.end(),[](lli a,lli b){
		return w[a] < w[b];
	});
	mini = w[w_[0]];
	for(lli i = 0;i < n;i++){
		lli ans_ = 0,c = 0;
		while(w_[i] != i){
			ans_ += w[w_[i]] + w[w_[w_[i]]];
			swap(w[w_[i]],w[w_[w_[i]]]);
			swap(w_[i],w_[w_[i]]);
			c++;
		}
		if(c*(w[i]-mini) > 2*(w[i]+mini)){
			ans_ -= c*(w[i]-mini) - 2*(w[i]+mini);
		}
		ans += ans_;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define int long long int

int32_t main() {
    int x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    int val = x / d;
    int rem = x % d;
    if (k <= val) {
        cout << x - k * d << endl;
    } else if ((k - val) & 1) {
        cout << abs(rem - d) << endl;
    } else {
        cout << x - val * d << endl;
    }
    return 0;
}

/*
else {
    int rem = x % d;
    k -= val;
    if (k & 1) {
        cout << abs(rem - d) << endl;
    } else {
        cout << abs(x - val * d) << endl;
    }
}
*/

Measured memory_bytes: 3636
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
*/
#include <bits/stdc++.h>
#define LL              long long
#define ll              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)
 
#define pb              push_back
#define mp              make_pair
 
#define ON(n,i)         (n|(1LL<<i))
#define OFF(n,i)        (n&(~(1LL<<i)))
#define CHK(n,i)        (n&(1LL<<i))

#define ff              first
#define ss              second
 
#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)
 
#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())
 
#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )
#define RFOR(i,e,s)     for( LL i = e ; i>=s ; i-- )
         
 
#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("out.txt","w",stdout)
 
#define DEBUG(x)        cerr<<#x<<" = "<<x<<endl
#define PRINTALL(v)     {cerr<<endl<<"Printing: "<<#v<<endl;for(LL i = 0 ; i<v.size(); i++) DEBUG(v[i]); cerr<<endl;}
 
using namespace std;

int main(){
   
   LL mul = 1;
   LL inf = 1e18;
   LL N;
   SL(N);
   FOR(i,1,N){
       LL a;
       SL(a);
       if(a==0) mul = 0;
       if(mul <= 0) continue;
       if(mul>(inf/a)) mul = -1;
       else mul*=a;
   }
   printf("%lld\n",mul);

return 0;}

Measured memory_bytes: 3828
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long n,ii,b,sum,jj;
  long max,min;
  vector<long> a;
  vector<long> ad;
  map<long,long> mp;
  //n取得
  cin >> n;
  a.resize(n);
  ad.resize(n);


  //数列取得
  for(ii=0;ii<n;ii++){

	cin >> a[ii];
	ad[ii] = a[ii] - (ii+1);

  }

  b = 0;
  for(ii=0;ii<n;ii++){

	//cout << a[ii] - (b+(ii+1)) << endl;
	
	sum += abs(a[ii] - (b+(ii+1)));
  }
  
  sort(ad.begin(),ad.end());

  max = ad[ad.size()-1];
  min = ad[0];

  //cout << "min:" << min << endl;
  for(ii=0;ii<n;ii++){

	ad[ii] -= min;
  }
  
  for(ii=0;ii<n;ii++){
	//cout << "ad:" << ad[ii] << endl;
	if(mp.count(ad[ii]) == 0){
	  mp[ad[ii]] = 1;
	}
	else{
	  mp[ad[ii]] += 1;
	}
  }

  long maxkey,maxval;


  sum =0;
  b = 0;
  for(ii=0;ii<n;ii++){

	sum += ad[ii];
	//cout << "a:" << a[ii] << endl;
	//cout << "ad:" << ad[ii] << endl;
	//cout << "sum:" << sum << endl;
  }
  
  //cout << "sum:" << sum << endl;
  min = LONG_MAX;
  pair<long,long> prev;
  long diff,cnt,height;
  //prev.second = -1;
  prev.first = 0;
  prev.second = 0;
  cnt = 0;
  for(pair<long,long> cur: mp){
//	cout << "curkey:" << cur.first << "curval:" << cur.second << endl;
//	if(prev.second != -1){
//	  diff = cur.second - prev.second;
//	  sum = sum - diff;
//	}

	height = cur.first - prev.first;
	diff = height * cnt - height * (n -cnt);
	//cout << "height:" << height << "diff:" << diff << endl;
	sum = sum + diff;

	if(sum < min){
	  min = sum;
	}
	cnt += cur.second;
	prev = cur;
  }

  //cout << "jj:" << jj << "sum:" << sum << endl;
  cout << min << endl;
  //}  
  return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e9
#define precise cout << std::setprecision(10) << std::fixed;
#define endl "\n"
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int a[n];
        fr(i,0,n) cin>>a[i];
        fr(i,0,k)
        {
            vector<int> v(n,0);
            fr(j,0,n)
            {
                int l=j-a[j];
                int r=j+a[j]+1;
                if(l<0) l=0;
                v[l]++;
                if(r<=n-1) v[r]--;
            }
            int cnt=0;
            a[0]=v[0];
            if(a[0]==n) cnt++;
            //fr(j,0,n) cout<<v[j]<<" ";
            //cout<<endl;
            fr(j,1,n)
            {
                v[j]+=v[j-1];
                a[j]=v[j];
                if(a[j]==n) cnt++;
            }
            if(cnt==n) break;
        }
        fr(i,0,n) cout<<a[i]<<" ";
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 5236
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    int x;
    while(1){
        cin >> n >> x;
        if(n==0){
            break;
        }
        int ans = 0;
        REP(i,n){
            FOR(j,i+1,n){
                FOR(k,j+1,n){
                    int t = i+j+k+3;
                    if(t == x){
                        ans++;
                    }
                }
            }
        }
        print(ans)
    }
    


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 3092
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        int start = x - k + 1;
        for(int i = 0;i<(k*2-1);i++){
            System.out.print(start + " ");
            start++;
        }
        System.out.println();
        sc.close();
    }
}

Measured memory_bytes: 22868
a=Array.new(4,0)

10.times do
    a[3] = gets.chomp.to_i 
    3.times do |i|
        if a[2-i]<a[3-i]  
            a[2-i], a[3-i] = a[3-i], a[2-i]
        else
            break
        end
    end
end
puts a[0]
puts a[1]
puts a[2]

Measured memory_bytes: 6096
h, w = map(int, input().split())
a=[]
for i in range(h):
  a.append([it == '#' for it in input()])
q=[]
for i in range(h):
  for j in range(w):
    if a[i][j]: q.append((i, j))
cnt = -1
while q:
  cnt += 1
  r = []
  for i, j in q:
    if i > 0 and not a[i-1][j]:
      a[i-1][j]=True
      r += [(i-1, j)]
    if i < h-1 and not a[i+1][j]:
      a[i+1][j]=True
      r += [(i+1, j)]
    ai = a[i]
    if j > 0 and not ai[j-1]:
      ai[j-1]=True
      r += [(i, j-1)]
    if j < w-1 and not ai[j+1]:
      ai[j+1]=True
      r += [(i, j+1)]
  q=r
print(cnt)



Measured memory_bytes: 107908
#include <bits/stdc++.h>
// #include <atcoder/all>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
// using namespace atcoder;
typedef long long ll;

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl;
#else
#define DEBUG(x)
#endif

#define ALL(obj) (obj).begin(), (obj).end()
#define BIT(n) (1LL << (n))

const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    // write code below
    std::string s;
    cin >> s;
    if (s[s.length() - 1] == 's')
    {
        cout << s + "es" << endl;
    }
    else
    {
        cout << s + "s" << endl;
    }
    // write code above
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll w, h;

    bool is_h_edge, is_w_edge;
    while (cin >> h >> w)
    {
        if (w == 0 && h == 0)
            break;

        for (ll j=0; j<h; j++)
        {
            is_h_edge = (j == 0 || j == h-1) ? true : false;

            for (ll i=0; i<w; i++)
            {
                is_w_edge = (i == 0 || i == w-1) ? true : false;
                char letter = (is_w_edge || is_h_edge) ? '#' : '.';
                cout << letter;
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3080