akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
 
int main(){
    int x;
    cin>>x;
    if(x>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3636
<?php
fscanf(STDIN, '%s', $s);
$n = strlen($s);
$r0[0] = $r0[1] = $r1[0] = $r1[1] = 0;
for ($i = 0; $i < $n; $i++) {
    $j = (int)$s[$i];
    if ($i % 2 === 0) $r0[$j]++;
    else $r1[$j]++;
}
$ans = min($r0[1] + $r1[0], $r0[0] + $r1[1]);
echo $ans . PHP_EOL;

Measured memory_bytes: 4604
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(10) << x
using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin>>n;
  vector <ll> v1,v2,v3,v4;
  for(ll i=0;i<n;i++)
  {
      ll x,y;
      cin>>x>>y;
      v1.pb(x+y); v2.pb(x-y);
  }
  sort(v1.begin(),v1.end());
  sort(v2.begin(),v2.end());
  ll a1 = abs(v1[n-1]-v1[0]);
  ll a2 = abs(v2[n-1]-v2[0]);
  cout<<max(a1,a2)<<endl;
}


Measured memory_bytes: 6688
n = int(input())
a = list(map(int,input().split()))
a.sort()
if a[0]==0:
  print("0")
else:
  ans = 1
  for i in range(n):
    ans = ans*a[i]
    if ans > 1e18:
      print("-1")
      break
  else:
    print(ans)

Measured memory_bytes: 84836
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<long long> A(N), S(N + 1), PS(N + 1);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		S[i + 1] = S[i] + A[i];
		PS[i + 1] = PS[i] + (A[i] > 0 ? A[i] : 0);
	}
	long long ans = -(1LL << 60);
	for (int i = 0; i <= N - K; ++i) {
		long long mid = max((long long)(0), S[i + K] - S[i]);
		long long sum = mid + PS[i] + (PS[N] - PS[i + K]);
		ans = max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
class DisjointSet:
    def __init__(self, size):
        self.parent = list(range(size))
        self.rank = [0]*size
    
    def find(self, x):
        stack = []
        parent = self.parent
        while parent[x] != x:
            stack.append(x)
            x = parent[x]
        for y in stack:
            parent[y] = x
        return x

    def union(self, x, y):
        xr, yr = self.find(x), self.find(y)
        
        if self.rank[xr] > self.rank[yr]:
            self.parent[yr] = xr
        elif self.rank[xr] < self.rank[yr]:
            self.parent[xr] = yr
        elif xr != yr:
            self.parent[yr] = xr
            self.rank[xr] += 1

from itertools import chain

N = int(input())
points = tuple(tuple(map(int,input().split())) for _ in range(N))
ds = DisjointSet(N)

x_i = sorted((x,i) for i,(x,y) in enumerate(points))
y_i = sorted((y,i) for i,(x,y) in enumerate(points))

xr = [x_i[0]]
yr = [y_i[0]]

for (x0,i0),(x1,i1) in zip(x_i,x_i[1:]):
    if x0 == x1:
        ds.union(i0,i1)
    else:
        xr.append((x1,i1))

for (y0,i0),(y1,i1) in zip(y_i,y_i[1:]):
    if y0 == y1:
        ds.union(i0,i1)
    else:
        yr.append((y1,i1))

deltas = sorted(
        chain(
            ((x1-x0,i0,i1) for (x0,i0), (x1,i1) in zip(xr,xr[1:])),
            ((y1-y0,i0,i1) for (y0,i0), (y1,i1) in zip(yr,yr[1:])),
        )
    )


def it():
    for d,i0,i1 in deltas:
        i0,i1 = ds.find(i0), ds.find(i1)
        if i0 != i1:
            ds.union(i0,i1)
            yield d
print(sum(it()))

Measured memory_bytes: 141072
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    vector<vector<int>> dp(1 << N, vector<int>(51, INF));
    // dp[S][v]:=使うカードの集合がSで最後がvのときの最小操作数
    dp[0][0] = 0;
    for(int bit = 0; bit < (1 << N); bit++) {
        vector<pair<int, int>> ord;
        int now = __builtin_popcount(bit);
        for(int i = 0; i < N; i++) {
            if(!(bit & (1 << i))) {
                ord.pb(MP(i, now));
                now++;
            }
        }
        int base = __builtin_popcount(bit);
        for(int v = 0; v <= 50; v++) {
            if(dp[bit][v] == INF)
                continue;
            for(auto p : ord) {
                int org = p.first;
                int cur = p.second;
                int next = (abs(org - base) % 2 ? B[org] : A[org]);
                if(next >= v) {
                    dp[bit | (1 << org)][next] = min(dp[bit | (1 << org)][next],
                                                     dp[bit][v] + (cur - base));
                }
            }
        }
    }
    int res = INF;
    rep(i, 51) { res = min(res, dp[(1 << N) - 1][i]); }
    cout << (res == INF ? -1 : res) << endl;
    return 0;
}

Measured memory_bytes: 66856
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream> 
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;

#define assert_range(x,a,b) assert((a) <= (x) and (x) <= (b))
using ll = long long;
const int INF = 1e9;

const int MAX_V = 1e5;
const int MAX_N = 100;
const int UNDEFINED = 1e9+10;

int dp[MAX_N+1][MAX_V+1];

int main() {
    ios_base::sync_with_stdio(0);
    int n, W;
    cin >> n >> W;
    vector<int> w(n);
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
    }
    for (int i = 0; i <= n; ++i) {
        for (int x = 0; x <= MAX_V; ++x) {
            dp[i][x] = UNDEFINED;
        }
    }
    dp[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int x = 0; x <= MAX_V; ++x) {
            dp[i][x] = dp[i-1][x];
            if (x >= v[i-1] and dp[i-1][x-v[i-1]] + w[i-1] <= W) {
                dp[i][x] = min(dp[i][x], dp[i-1][x-v[i-1]] + w[i-1]);
            }
        }
    }
    ll res = 0;
    for (int x = 0; x <= MAX_V; ++x) {
        if (dp[n][x] != UNDEFINED) {
            res = x;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 39680
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    G = [[] for _ in range(N)]
    G_c = [0 for _ in range(N)]
    edges = []
    colors = {}
    for _ in range(N-1):
        a, b = (int(i) for i in input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
        edges.append((a-1, b-1))
        colors[(a-1, b-1)] = -1
        colors[(b-1, a-1)] = -1
    from collections import deque
    G_color = ['WHITE' for _ in range(N)]
    G_parent = ['NIL' for _ in range(N)]

    def bfs(s):
        K = set()
        G_color[s] = 'GRAY'
        Q = deque()
        Q.append(s)
        while Q:
            u = Q.popleft()
            k = len(G[u])
            c = (G_c[u] % k) + 1
            for v in G[u]:
                if G_color[v] == 'WHITE':
                    G_color[v] = 'GRAY'
                    G_parent[v] = u
                    Q.append(v)
                    colors[u, v] = c
                    colors[v, u] = c
                    G_c[u] = c
                    G_c[v] = c
                    K.add(c)
                    c = c % k + 1
            G_color[u] = 'BLACK'
        return K
    K = bfs(0)
    print(len(K))
    for e in edges:
        print(colors[e])


if __name__ == '__main__':
    main()


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

using namespace std;

int main ( void )
{
	string in;
	while (cin >> in)
	{
		if (in[0] == 'x' && in[in.size() - 1] == 'x')
			cout << 'x' << endl;
		else
			cout << 'o' << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <functional>
#include <array>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long int ull;
typedef vector<int> vi;
#define rep(i,a,n) for(int i = (a);i < (n);i++)
#define per(i,a,n) for(int i = (a);i > (n);i--)
#define lep(i,a,n) for(int i = (a);i <= (n);i++)
#define pel(i,a,n) for(int i = (a);i >= (n);i--)
#define all(v) (v).begin(),(v).end()
#define clr(a,b) memset((a),(b),sizeof(a))
#define sz size()
#define pb push_back
#define print(x) cout << x << endl
#define INF 1e+9
int n,m,l;
string s,t;
char d[51][51];
int x[3] = {1,-1,0};
int y[3] = {1,-1,0};

int main(){
  cin >> n >> m;
  rep(i,0,n){
    rep(j,0,m){
      cin >> d[i][j];
    }
  }
  rep(i,0,n){
    rep(j,0,m){
      if(d[i][j] != '#'){
        int t = 0;
        rep(k,0,3){
          rep(l,0,3){
            if(x[k] == 0 && y[l] == 0)continue;
            if(d[i+y[k]][j+x[l]] == '#')t++;
          }
        }
        d[i][j] = '0'+t;
      }
    }
  }
  rep(i,0,n){
    rep(j,0,m){
      printf("%c",d[i][j]);
    }
    puts("");
  }
  return 0;
}


Measured memory_bytes: 256
from math import factorial
H,W,A,B=map(int, input().split())
p=10**9+7
ans=0
X=[1,1]  #階乗テーブル
Y=[1,1]  #階乗の逆元テーブル
calc=[0,1]  #逆元計算用テーブル
for i in range( 2, H+W-2 ):
    X.append( ( X[-1] * i ) % p )
    calc.append( ( -calc[p % i] * (p//i) ) % p )
    Y.append( (Y[-1] * calc[-1]) % p )
for i in range(B,W):
  ans+=(X[H-A-1+i]*X[A+W-2-i]*Y[H-A-1]*Y[i]*Y[A-1]*Y[W-1-i])%p

print(ans%p)

Measured memory_bytes: 26864
#!/usr/bin/env python3
s = input()
t = input()
dp = [[0]*(1+len(t)) for _ in range(1+len(s))]
def match(s_,t_,i,j):
    if s_[i] == t_[j]:
        return 1
    else: return 0
#　配列アラインメントの感じでマッチしたら+1 そうでなかったら+0を返す
# traceback関数を作って戻る必要がある
# 漸化式 dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j],dp[i][j]+match())
# traceback[i+1][j+1] = 0 だったら上、1なら左、2なら斜め
traceback =[[-1]*(1+len(t)) for _ in range(1+len(s))]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j]+1
            traceback[i+1][j+1] = 3
        elif dp[i][j+1] >= dp[i+1][j]:
            dp[i+1][j+1] = dp[i][j+1]
            traceback[i+1][j+1] = 1
        else:
            dp[i+1][j+1] = dp[i+1][j]
            traceback[i+1][j+1] = 2
        
# traceback時の初期値がx = len(s),y = len(t)
# tracebackの挙動を見ながらx,y を更新する
#　終了条件はx,y == 0,0 になったとき
# traceback[x][y] % 2 == 1 の時、s[x-1]を出力する。
x,y = len(s),len(t)
"""for i in range(1+len(s)):
    #print(dp[i])
    print(traceback[i])
"""
output = []
while True:
    if traceback[x][y] == 3:
        output.append(s[x-1])
        #print()
    x_ = x
    y_ = y
    x -= traceback[x_][y_] % 2 
    y -= traceback[x_][y_] // 2
    #print(x,y)
    if x == 1 and y == 1:
        if traceback[x][y] == 3:
            output.append(s[x-1])
        break
    if x == 0 or y == 0:
        break
for i in range(len(output)-1,-1,-1):
    print(output[i],end="")
print()

    

Measured memory_bytes: 178952
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const ll LINF=1e18;
const int MOD=1e9+7;
//const int MOD=998244353;

int main(){
	int n,m; cin>>n>>m;
	int a[301][301];
	FOR(i,0,n){
		FOR(j,0,m){
			cin>>a[i][j];
			a[i][j]--;
		}
	}

	int deleted[301]={};
	int ans=INF;
	stack<int> st[301];
	FOR(i,0,n){
		ROF(j,0,m){
			st[i].push(a[i][j]);
		}
	}
	FOR(i,0,m){
		int num[301]={};
		FOR(j,0,n){
			int t=st[j].top();
			num[t]++;
		}
		int M=0,Mi;
		FOR(j,0,m){
			if(num[j]>M){
				M=num[j];
				Mi=j;
			}
		}
		ans=min(ans,M);
		deleted[Mi]=1;
		FOR(j,0,n){
			while(!st[j].empty()){
				int t=st[j].top();
				if(!deleted[t]) break;
				st[j].pop();
			}
		}
	}
	co(ans);
}


Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
const int maxn = 3000005;
const int maxm = maxn*2;
const ll inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int n,m,cnt;
map<pair<int,int>,int>mp;
ll ans[10];
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>m>>cnt;
    for(int i = 1;i<=cnt;i++) {
        int x,y; cin>>x>>y;
        for(int i = max(1,x-2);i<=min(x,n-2);i++)
            for(int j = max(1,y-2);j<=min(m-2,y);j++) mp[make_pair(i,j)]++;
    }
    ans[0] = 1ll*(n-2)*(m-2);
    map<pair<int,int>,int> :: iterator it;
    for(it = mp.begin();it!=mp.end();it++) {
        //cout<<(it->second)<<'\n';
        ans[it->second] ++;
        ans[0] --;
    }
    for(int i = 0;i<10;i++) cout<<ans[i]<<'\n';
    return 0;
}


Measured memory_bytes: 56576
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = sorted(li())
half = A[-1]//2
#if N % 2 == 0
ind = bisect.bisect_left(A, half)
#if ind > 0 and A[ind] - half > A[ind-1] - half:
    #ind -= 1
if A[ind]!=half:
    if ind > 0 and half - A[ind-1] < A[ind] - half:
        ind -= 1
if ind == N-1:
    ind -= 1
print(A[-1], A[ind])

Measured memory_bytes: 14256
char s[1025];
i,w;
main(f){
	for(i=0;s[i]=getchar(),s[i]+1;i++){
		if(s[i]==32||s[i]==46||s[i]==44){
			if(i-w>2&&i-w<7){
				s[i]=0;
				if(!f)
					putchar(32);
				printf(s+w);
				f=0;
			}
			w=i+1;
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 0
import time


def main():

    N, Q = map(int, input().split())
    S = input()

    sum = [0] * (N + 1)

    for i in range(1, N):
        if S[i-1] == 'A' and S[i] == 'C': sum[i] = sum[i-1] + 1
        else: sum[i] = sum[i-1]

    for i in range(Q):
        l, r = map(int, input().split())
        print(sum[r-1] - sum[l-1])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    # print(end - start)


Measured memory_bytes: 6184
#include <iostream>

using namespace std;

int s[200000];
int ec[200001];
int sc[200001];
int ans;

int main()
{
    char ch;

    int len = 0;
    while ((ch = getchar()) != '\n')
    {
        ec[len] = 0;
        sc[len] = 0;
        s[len++] = ch - '0';
    }

    ec[len] = 0;
    sc[len] = 0;
    int ans = 0;
    int cur;
    for (int i = 0; i < len; ++i)
    {
        cur = s[i];
        int ix = i+1;
        while (ix < len)
        {
            cur *= 10;
            cur += s[ix];
            cur %= 2019;
            if (cur == 0)
            {
                ans++;
                ec[ix]++;
                sc[i] = ix;
                break;
            }
            ix++;
        }
    }

    for (int i = 1; i < len; ++i)
    {
        if (ec[i-1] && sc[i])
        {
            ans += ec[i-1];
            ec[sc[i]] += ec[i-1];
        }
    }

    cout << ans << "\n";
    return 0;
}


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

bool kaibun(string s){
    // cout << s << endl;
    int l = s.length()-1,r=0;
    while(0<l-r){
        if(s[r]!=s[l]) return false; 
        r++,l--;
    }
    return true;
}

signed main(void){
    string s; cin >> s;
    if(kaibun(s.substr(0,s.length())) && kaibun(s.substr(0,(s.length()-1)/2)) && kaibun(s.substr((s.length()+3)/2 - 1,s.length() - ((s.length()+3)/2 - 1)))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	int N, H, W;

	cin >> N >> H >> W;
	cout << (N - H + 1) * (N - W + 1) << endl;

	return 0;
}


Measured memory_bytes: 256
#ABC 087C
import sys
n = int(sys.stdin.readline())

A = [list(map(int, sys.stdin.readline().split())) for _ in range(2)]
#print(A)

ans=0
for i in range(n):
    score=0
    score+= (sum(A[0][0:i+1]) + sum(A[1][i:n]))
    ans = max(ans, score)

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
#define ll long long
#define ld long double
#define ALL(x) begin(x),end(x)
     
int main(){
  ll n; cin >> n;
  vector<ll> vec; //順列生成
  for(ll i=1;i<=n;i++) vec.push_back(i);
  
  vector<ll> p(n),q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  ll pa = 0,qb  =0;
  ll now  =1;
  do{
    bool paFlag = true, qbFlag = true;
    rep(i,n) if(vec[i]!=p[i]) paFlag = false;
    rep(i,n) if(vec[i]!=q[i]) qbFlag = false;
    if(paFlag) pa = now;
    if(qbFlag) qb = now;
    now++;
  } while (std::next_permutation(vec.begin(), vec.end()));
  
  cout << abs(pa-qb) << endl;
}

Measured memory_bytes: 3576
def soinsuu(n):
    ans = [0 for _ in range(n+1)]
    while n>1:
        for i in range(2,n+1):
            if n % i==0:
                ans[i] += 1
                n = n//i
                break
    return ans

N = int(input())

sosuu_cnt_list = [0 for _ in range(N+1)]
for i in range(1,N+1):
    tmp_sosuu_cnt = soinsuu(i)
    for sss,cnt in enumerate(tmp_sosuu_cnt):
        sosuu_cnt_list[sss] += cnt

cnt = 1
for sosuu_cnt in sosuu_cnt_list:
    if sosuu_cnt !=0:
        cnt *= sosuu_cnt+1
        cnt %= 10**9+7



print(cnt)

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

int main(void){
    int MAX, MIN, w;
    scanf("%d %d", &MAX, &MIN);
    if(MAX < MIN){
        w = MAX;
        MAX = MIN;
        MIN = w;
    }
    if(MAX==MIN) printf("%d\n", 2*MAX);
    else printf("%d\n", 2*MAX - 1);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i,N) {
        cin >> A[i];
        B[i] = A[i] - i;
    }

    sort(B.begin(), B.end());

    int b = N % 2 == 1 ? B[N / 2] : (B[N / 2 - 1] + B[N / 2]) / 2;
    long long ans = 0;
    rep(i,N) ans += abs(B[i] - b);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int h,w; cin >> h >> w;
    vs fig(h);
    rep(i,h) cin >> fig[i];
    
    rep(i,2*h){
        rep(j,w){
            cout<<fig[(i)/2][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
using namespace std;
#define int long long int
#define function function2
int power[61];
void function()
{
	power[0]=1;
	int j;
	for(j=1;j<=60;j++)
	   power[j]=2*power[j-1];
}
int solve(vector<int> &arr,int k,int prev)
{
	if(arr.size()<k)
	  return 0;
	if(prev==0)
	   return 0;
	int count[61]={0};
	int j;
	for(int x:arr)
	{
		int y=x;
		for(j=60;j>=0;j--)
		{
			if(y>=power[j])
			{
				count[j]++;
				y-=power[j];
			}
		}
	}
	int ptr=-1;
	for(j=prev-1;j>=0;j--)
	{
		if(count[j]>=k)
		{
			ptr=j;
			break;
		}
	}
	if(ptr==-1)
	   return 0;
	vector<int> vec;
	for(int x:arr)
	{
		if(x&power[ptr])
		{
			vec.push_back(x);
		}
	}
	int answer=power[ptr]+solve(vec,k,ptr);
	return answer;
}
int32_t main()
{
	function();
	int n,k;
	cin>>n>>k;
	int arr[n];
	int j;
	for(j=0;j<n;j++)
	{
		cin>>arr[j];
	}
	vector<int> vec;
	for(j=0;j<n;j++)
	{
		int sum=0;
		int i;
		for(i=j;i<n;i++)
		{
			sum+=arr[i];
			vec.push_back(sum);
		}
	}
	int answer=solve(vec,k,60);
	cout<<answer<<endl;
}


Measured memory_bytes: 9008
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - 81
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  for (int a = 1; a <= 9; a++) {
    int b = n / a;
    if (a * b == n && b <= 9) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long

template <class T>
T mymax(T a,T b){
    if(a>=b) return a;
    return b;
}
template <class T>
T mymin(T a,T b){
    if(a<=b) return a;
    return b;
}

ll gcd(ll a, ll b){
    if(a<b){
        swap(a,b);
    }
    while(b){
        ll r = a%b;
        a=b;
        b=r;
    }
    return a;
}

ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

struct XX{
    int a;
    int b;
    int z;
    int i;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.b) == (riRight.b)){
            return riLeft.i < riRight.i;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.b) > (riRight.b);
    }
};

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

struct edge{
    int to;
    int cost;
};
typedef pair<int,int> P;//first:最短距離、second:頂点番号
vector<edge>G[400];//G[各頂点番号]
int d[400];

void dijkstra(int s,int V){//V:頂点数
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d,d+V+1,INT_MAX_VALUE);
    d[s]=0;
    que.push(P(0,s));
    
    while(!que.empty()){
        P p=que.top();
        que.pop();
        int v=p.second;
        if(d[v]<p.first){
            continue;
        }
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //cin >> x >> y;
    //テスト用
    //ifstream ifs( "1_06.txt" );
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    edge e;
    
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        e.to=i+1;
        e.cost=100-tmp;
        G[i].push_back(e);
        
        e.to=i+(N+1);
        e.cost=100-tmp;
        G[i].push_back(e);
    }
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        e.to=i+1+(N+1);
        e.cost=100-tmp;
        G[i+(N+1)].push_back(e);
    }
    
    dijkstra(0,(N+1)*2);
    cout << 100*(N+1)-d[2*(N+1)-1] << endl;
    
    //ここまで
    //cout << "debug" << endl;
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}



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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, M;
  cin >> N >> M;
  ll K;
  cin >> K;
  llvec A(N), B(M);
  rep(i, N)cin >> A[i];
  rep(i, M)cin >> B[i];
  llvec S(N+1, 0), T(M+1, 0);
  rep(i, N)S[i+1] = S[i] + A[i];
  rep(i, M)T[i+1] = T[i] + B[i];
  ll ans = 0;
  rep(i, N+1){
    if(K<S[i])break;
    ll ind = (ll) (upper_bound(ALL(T), K-S[i]) - T.begin());
    ans = max(ans, i + ind-1);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 9572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt" , "r" , stdin);
	// freopen("output.txt" , "w" , stdout);
	// #endif

	ll n,ans=0;
	cin>>n;
	map<string,ll>m;
	for(ll i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		m[s]++;
	}
	for(auto i:m)
	{
		if(i.second>1)
			ans+=(i.second*(i.second-1))/2;
	}
	cout<<ans<<endl;

	
	
}


Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 3

int c[MAX][MAX];
int target = MAX+1;

bool func(int a[MAX], int b[MAX]) {
  bool flag = true;

  rep(i,MAX) {
    rep(j,MAX) {
      if (a[i] + b[j] != c[i][j]) {
        flag = false;
        break;
      }
    }
    if (!flag) break;
  }

  return flag;
}

int main() {
  rep(i,MAX)rep(j,MAX){
    cin >> c[i][j];
  }

  int a[3],b[3];

  for (int i = 0; i <= c[0][0]; ++i) {
    a[0] = i; b[0] = c[0][0] - i;
    for (int j = 0; j <= c[1][1]; ++j) {
      a[1] = j; b[1] = c[1][1] - j;
      for (int k = 0; k <= c[2][2]; ++k) {
        a[2] = k; b[2] = c[2][2] - k;

        if (func(a,b)) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, K = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
dp = [[0] * (K + 1) for _ in range(N + 1)]
#dp[n][k]...n人目まででk個の飴を分ける組み合わせ
dp[0][0] = 1
	
for n in range(1, N + 1):
	#cum...累積和
	cum = [0] * (K + 2)
	for k in range(K + 1):
		cum[k + 1] = cum[k] + dp[n - 1][k]
		dp[n][k] = cum[k + 1] - cum[max(0, k - a[n - 1])]
		dp[n][k] %= mod

print(dp[-1][-1])


Measured memory_bytes: 130200
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long int idx[100001];
long long int power(long long int x,long long int y,long long int z)
{
    long long int res=1;
    x%=z;
    while(y>0)
    {
        if(y&1)
        res=(res*x)%z;
        x=(x*x)%z;
        y/=2;
    }
    return res;
}

long long int power1(long long int x,long long int y)
{
    long long int res=1;
    while(y>0)
    {
        if(y&1)
        res=(res*x);
        x=(x*x);
        y/=2;
    }
    return res;
}

long int root(long int x)
{
    while(idx[x]!=x)
    x=idx[x];
    return x;
}

void union1(long int x,long int y)
{
    idx[root(x)]=root(y);
}
int main() {
	
	
int n;
cin>>n;
long int a[n],b[n];
for(long int i=0;i<n;i++)
cin>>a[i];
b[0]=0;
b[1]=abs(a[1]-a[0]);
for(long int i=2;i<n;i++)
{
    b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
}
cout<<b[n-1];
	
	
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

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

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

#define ll long long
#define ld long double
#define debug(x) \
	//    (cout << #x << ": " << (x) << endl)
#define eb emplace_back
#define fi first
#define se second

using namespace std;

const int nm = 3002;
const int mod = 998244353;

int n, m, a[nm];
int g[nm][nm];

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
	}
	g[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		g[i][0] = (g[i - 1][0] * 2) % mod;
		for (int j = 1; j <= m; ++j) {
			g[i][j] = (g[i - 1][j] * 2) % mod;
			if (a[i] <= j) {
				g[i][j] = (g[i][j] + g[i - 1][j - a[i]]) % mod;
			}
		}
	}
	printf("%d\n", g[n][m]);
}

Measured memory_bytes: 38948
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
speed_up;
int n;
vector<int> vec;
cin>>n;
while(n--)
{
    int a;
    cin>>a;
    vec.push_back(a);
}
int mx, mi, i, j, mi_val = INT_MAX;
mx = *max_element(vec.begin(), vec.end());
mi = *min_element(vec.begin(), vec.end());
//cout<<mi<<endl;
for(i = mi ; i<=mx; i++)
{   int sum = 0;
    for(j = 0; j<vec.size(); j++)
    {
         sum += (vec[j]  - i)*(vec[j] - i);
         //cout<<sum<<endl;
    }
    if(sum<mi_val)
    {
        mi_val = sum;
    }

}
cout<<mi_val<<endl;


return 0;
}


Measured memory_bytes: 3596
<?php
  $a = explode(" ",fgets(STDIN));
  $b = explode(" ",fgets(STDIN));
  $c = 0;
  for($i=0; $i<$a[0]; $i++){
    if((int)$b[$i] >= (int)$a[1]){
     	$c++; 
    }
    
  }
	echo $c;

  
  ?>

Measured memory_bytes: 12792
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <algorithm>
using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)n;(i)++)
#define foreach(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)

int n;
const int MAX_N = 100000;
string in;
vector<int> v;
bool sieve[MAX_N];

inline char F(int alpha, int beta, char gamma) {
  return 'a'+((alpha*(gamma-'a')+beta)%26);
}

int main() {
  int i, j, k, l;
  fill(sieve, sieve + MAX_N, true);
  for (i = 2; i < MAX_N; i+=2) sieve[i] = false;
  for (i = 3; i < MAX_N; i+=2) if (sieve[i]) {
    v.push_back(i);
    for (j = i+i; j < MAX_N; j+=i) {
      sieve[j] = false;
    }
  }
  
  cin >> n;
  cin.ignore();
  int vsz = v.size();
  rep(i,n) {
    getline(cin, in);
    int insz = in.size();
    rep(j,vsz) rep(k,26) {
      string cipher;
      rep(l,insz) {
        if (in[l] == ' ') {
          cipher += ' ';
          continue;
        }
        cipher += F(v[j], k, in[l]);
      }
      if (cipher.find("that") != -1 || cipher.find("this") != -1) {
        cout << cipher << endl;
        j = vsz;
        k = 26;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
from itertools import permutations
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))
A = []
for z in permutations(range(1,N+1),N):
    A.append(z)
A = sorted(A)
indP = -1
indQ = -1
for i,a in enumerate(A):
    if a==P:
        indP = i
    if a==Q:
        indQ = i
print(abs(indP-indQ))

Measured memory_bytes: 45552
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
using ll = long long;

void rec(ll x, ll a, ll d) {
	if (a * 26 < x)
		rec(x - a*26, a * 26, d + 1);
	else {
		vector<char> s;
		x--;
		for (int i = 0; i < d; i++) {
			printf("%c", x / a + 'a');
			x %= a;
			a /= 26;
		}
		printf("\n");
	}
}
ll n;
int main() {
	scanf("%lld", &n);
	rec(n, 1, 1);
}

Measured memory_bytes: 1684
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){return (a%mod * b%mod)%mod;}
inline int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     SPEED;
     int a,b,c;
     cin>>a>>b>>c;
     int five=0;
     int seven=0;
     five+=a==5;
     five+=b==5;
     five+=c==5;
     seven+=a==7;
     seven+=b==7;
     seven+=c==7;
     if(five==2&&seven==1)
     	cout<<"YES"<<endl;
     else
     	cout<<"NO"<<endl;
     time();
     return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns, MultiWayIf #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> VU.Vector Int32 -> Int32
solve !n !k !an = VU.last $ V.last dp
 where
  big = 10 ^ 9 + 7

  plus x y = let z = x + y in if z >= big then z - big else z
  minus x y = let z = x - y in if z < 0 then z + big else z

  dp :: V.Vector (VU.Vector Int32)
  dp = V.postscanl'
    (\(!dpi) (!i) -> VU.scanl'
      (\(!dpij) (!j) ->
        let !p = if j - fromIntegral (an VU.! i) - 1 >= 0
              then dpi VU.! (j - fromIntegral (an VU.! i) - 1)
              else 0
            !q = dpi VU.! j
            !a = dpij `plus` q `minus` p
        in  a
      )
      1
      (VU.generate k (+ 1))
    )
    (VU.generate (k + 1) (\i -> if i == 0 then 1 else 0))
    (V.convert $ VU.generate n id)

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, k) <-
    (\(!vec) -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  an <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n k an


Measured memory_bytes: 4348
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    int tmp=100;
    for(int i=0; i<k; i++){
        for(int j=tmp; j>=1; j--){
            if(a%j==0 && b%j==0){
                tmp=j-1;
                break;
            }
        }
    }
    cout << tmp+1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(lambda x:int(x),input().split()))
q=int(input())
m=list(map(lambda x:int(x),input().split()))
sumlist=[]
bin=[0]*n

def suc(bin):
    i=-1
    while bin[i]==1:
        bin[i]=0
        i=i-1
    bin[i]=1
    return(bin)

for i in range(2**n-1):
    tmpsum=0
    for j in range(n):
        if bin[j]==1:
            tmpsum+=a[j]
    sumlist.append(tmpsum)
    bin=suc(bin)

for i in m:
    flag=True
    for j in sumlist:
        if i==j:
            print("yes")
            flag=False
            break
    if flag:
        print("no")



Measured memory_bytes: 43076
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
res = 0

for i in range(N):
    if b[i] >= a[i]:
        res += a[i]
        b[i] -= a[i]
        if b[i] >= a[i+1]:
            res += a[i+1]
            a[i+1] = 0
        else:
            tmp = b[i]
            res += tmp
            a[i+1] -= tmp
    else:
        res += b[i]
print(res)


Measured memory_bytes: 18476
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>

int main(){
  int n;
  std::cin>>n;
  int B[1500]={0};
  for(int k=0;k<n;k++){
    std::string str1;
    std::string str2;
    std::cin>>str1;
    std::cin>>str2;
    int A[1000][1000]={0};
    /*初期化？*/
    for(int i=0;i<str1.size();i++){
      if(str1[i]==str2[0]){
	A[i][0]=1;
      }
      if(i>0){
	A[i][0]=std::max(A[i][0],A[i-1][0]);
      }
    }
    for(int j=0;j<str2.size();j++){
      if(str1[0]==str2[j]){
	A[0][j]=1;
      }
      if(j>0){
	A[0][j]=std::max(A[0][j],A[0][j-1]);
      }
    }
    for(int i=1;i<str1.size();i++){
      for(int j=1;j<str2.size();j++){
	if(str1[i]==str2[j]){
	  A[i][j]=A[i-1][j-1]+1;
	}else{
	  A[i][j]=std::max(A[i-1][j],A[i][j-1]);
	}
      }
    }
    B[k]=A[str1.size()-1][str2.size()-1];
  }
  for(int i=0;i<n;i++){
    std::cout<<B[i]<<"\n";
  }
  return 0;
}



Measured memory_bytes: 7104
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int n, m, k; cin >> n >> m >> k;
    vector<int> d(m), rd(n, -1);
    for (int i = 0; i < m; i++) {
        cin >> d[i];
        d[i]--;
        rd[d[i]] = i; // dの逆写像
    }
    vector<vector<int>> v(n, vector<int>(k));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            cin >> v[i][j]; v[i][j]--;
        }
    }
    vector<vector<int>> g(1 << m);
    for (int i = 0; i < (1 << m); i++) {
        for (int r = 0; r < k; r++) {
            int t = 0;
            for (int j = 0; j < m; j++) {
                if ((i & (1 << j)) && rd[v[d[j]][r]] != -1) {
                    t |= (1 << rd[v[d[j]][r]]);
                }
            }
            g[i].push_back(t);
        }
    }
    //dump(g);
    // (1<<m)-1から0までの距離
    vector<int> dist((1 << m), -1);
    queue<int> que;
    que.push((1 << m) - 1);
    dist[(1 << m) - 1] = 0;
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (int u : g[v]) {
            if (dist[u] == -1) {
                que.push(u);
                dist[u] = dist[v] + 1;
            }
        }
    }
    //dump(dist);
    cout << dist[0] << endl;
    return 0;
}


Measured memory_bytes: 38796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;



signed main(){
    string s;
    cin>>s;
    ll acnt=0,ans=0;
    bool aflag=true,bcflag=false;
    for(int i=0;i < (int)s.size();i++)
    {
        if(aflag){
            if(s.at(i)=='A'){
                aflag=false;
                bcflag=true;
                acnt++;
            }
        }else if(bcflag){
            if(s.at(i)=='B' && i+1<(int)s.size() && s.at(i+1)=='C'){
                i++;
                ans+=acnt;
            }else if(s.at(i)=='A'){
                acnt++;
            }else{
                acnt=0;
                bcflag=false;
                aflag=true;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int a = n / 500;
	int b = (n % 500) / 5;
	cout << 1000 * a + 5 * b << endl;
	return 0;
}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*

	Optimizer

*/
//#pragma GCC optimize("Ofast")


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

	int n,m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;

	return 0;
}


Measured memory_bytes: 256
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

module Util =
    let strRev s =
        s
        |> Seq.rev
        |> Seq.map string
        |> String.concat ""

[<EntryPoint>]
let main _ =
    let N = read int
    let A = reada int

    let total = 3.0 ** (float N) |> int
    seq {
        for i in 0 .. N - 1 do
            if A.[i] % 2 = 0 then yield 2
            else yield 1
    }
    |> Seq.fold (fun acc e -> acc * e) 1
    |> fun x -> total - x
    |> printfn "%d"
    0 // return an integer exit code


Measured memory_bytes: 14044
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a + b == 15) {
			System.out.println("+");
		}else if(a * b == 15) {
			System.out.println("*");
		}else {
			System.out.println("x");
		}
	}
}

Measured memory_bytes: 23892
implicit none
integer :: N
integer, allocatable :: A(:,:)
integer :: i
integer, allocatable :: u(:), l(:)
integer :: su, sl, smax

read *, N
allocate(A(N,2))
read *, (A(i,1), i=1,N)
read *, (A(i,2), i=1,N)

allocate(u(N))
allocate(l(N))

su = 0
sl = 0
do i = 1, N
   su = su + A(i,1)
   sl = sl + A(N-i+1,2)
   u(i) = su
   l(N-i+1) = sl
enddo

smax = 0
do i = 1, N
   su = u(i) + l(i)
   if (su > smax) then
      smax = su
   endif
enddo

write(6,'(i0)') smax
stop
end

Measured memory_bytes: 256