akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> f(n);
  rep(i, n){
    cin >> a[i];
  }
  rep(i, n){
    cin >> f[i];
  }
  sort(a.begin(), a.end());
  //sort(f.begin(), f.end(), greater<int>());
  sort(f.rbegin(), f.rend());
  vector<ll> af(n);
  rep(i, n){
    af[i]=(ll)a[i]*f[i];
  }
  ll l=-1, r=1e12;
  while(l+1<r){
    ll m=(l+r)/2;
    ll num=0;
    rep(i, n){
      if(af[i]>m){
        ll tmp=(af[i]-m-1)/f[i]+1;
        num+=tmp;
      }
    }
    if(num<=k){
      r=m;
    } else {
      l=m;
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 6372
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int h[n];
	int ans[n];
	for(int i=0;i<n;i++) 
		{
			cin>>h[i];
			ans[i] = INT_MAX;
		}
	ans[0]=0;
	ans[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++)
	{
		ans[i] = min(abs(h[i]-h[i-2])+ans[i-2], abs(h[i]-h[i-1])+ ans[i-1]);
	}
	cout<<ans[n-1]<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, a, b; cin >> n >> a >> b;
    vector <int> h(n);
    for (int i = 0; i < n; ++ i) {
        cin >> h[i];
    }
    auto chk = [&] (int tms) {
        ll used = 0;
        for (int i = 0; i < n; ++ i) {
            if (h[i] <= 1LL * tms * b) continue;
            used += (h[i] - 1LL * tms * b - 1) / (a - b) + 1;
        }
        return used <= tms;
    };
    int lb = 1, rb = 1e9;
    while (lb < rb) {
        int md = (lb + rb) >> 1;
        if (chk(md)) rb = md;
        else lb = md + 1;
    }
    cout << lb << endl;
    return 0;
}


Measured memory_bytes: 640
#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 h, w;
  cin >> h >> w;
  vs s(h);
  rep(i, h) cin >> s[i];
  rep(i, h) rep(_, 2) cout << s[i] << '\n';
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll a[500005];
ll bit[500005];
ll n;
void update(ll i,ll x)
{
    while(i<=n)
    {
        bit[i]+=x;
        i+=(i&(-i));
    }
}
ll query(ll i)
{
    ll s=0;
    while(i>0)
    {
        s+=bit[i];
        i=i-(i&(-i));
    }
    return s;
}
int main() {
    //ll n;
    cin>>n;
    ll q;
    cin>>q;
    for(ll i=1;i<=n;i++)
    cin>>a[i];
    
    for(ll i=1;i<=n;i++)
    update(i,a[i]);
    while(q--)
    {
        ll z,x,y;
        cin>>z>>x>>y;
        x++,y++;
        if(z==1)
        {
            cout<<query(y-1)-query(x-1)<<endl;
        }
        else
        {
            a[x]+=(y-1);
            update(x,y-1);
        }
    }
}
    

Measured memory_bytes: 12156
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
#define par pair<pair<int,int>, int>
#define f first
#define s second
    
int n;


int main()
{
    
        scanf("%d",&n);
        printf("%lld",1ll*n*(n-1)/2);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using ll = long long;
using namespace std;
int N;
int v[200];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  int sum = 0;
  for(int i = 0; i < N; ++i) {
    cin >> v[i];
    sum += v[i];
  }

  if (sum % 10) {
    cout << sum << endl;
  } else {
    int d = sum;


    for(int i = 0; i < N; ++i) {
      if ((v[i] % 10) != 0 && v[i] < d) d = v[i];
    }

    sum -= d;
    cout << sum << endl;
  }
}

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

using namespace std;

# define ll long long
# define pll pair<ll,ll>
# define F first
# define S second
# define pb push_back
# define ld long double
ll mod=1000000007;
string ans;
ll func1(vector<vector<pll>>&dp,string &s,string &t,int a,int b)
{
    if(a==0||b==0)
    return 0;
    if(dp[a][b].F!=-1)
    return dp[a][b].F;
    if(s[a-1]==t[b-1])
    {
        //ans.pb(s[a-1]);
        dp[a][b].S=1;
        return dp[a][b].F=1+ func1(dp,s,t,a-1,b-1);
    }
    ll x=func1(dp,s,t,a-1,b);
    ll y=func1(dp,s,t,a,b-1);
    if(x>=y)
    {
        dp[a][b].S=2;
        return dp[a][b].F=x;
    }
    dp[a][b].S=0;
    return dp[a][b].F=y;
    
    
}

int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        ll t=1;
        //cin>>t;
        while(t--)
        {
           string s,t;
           cin>>s>>t;
           vector<vector<pll>>dp(s.size()+1,vector<pll>(t.size()+1,{-1,-1}));
           ll tp=func1(dp,s,t,s.size(),t.size());
           ll x=dp[s.size()][t.size()].S;
           ll i=s.size(),j=t.size();
           while(i*j!=0)
           {
            if(x==1)
            {
                ans.pb(s[i-1]);
                i--; j--;
            }
            if(x==0)
            j--;
            else if(x==2)
            i--;
            x=dp[i][j].S;
           }
           reverse(ans.begin(),ans.end());
          cout<<ans;
            
        }
        
    }

Measured memory_bytes: 141696
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8


def run():
    n, *A = map(int, read().split())
    v = 0
    acum = []
    for a in A:
        v += a
        acum.append(v)

    # greedy
    ans = INF
    for V in (-1, 1):
        cums = 0
        count = 0
        for a in acum:
            #print(a, '---------')
            V *= -1
            if (a + cums) * V > 0:
                continue
            else:
                update = abs(a + cums) + 1
                cums += (update) * V
                count += update
                #print(V, cums, count)
        ans = min(ans, count)
    print(ans)



if __name__ == "__main__":
    run()


Measured memory_bytes: 36540
n,k = map(int,input().split())
k = min(k,n-1)
mod=10**9+7
fact = [1]*(2*10**5+1)
for i in range(2,2*10**5+1):
  tmp = fact[i-1]*i
  tmp%=mod
  fact[i]=tmp
fact_inv = [0]*(2*10**5+1)
for i in range(2*10**5+1):
  fact_inv[i]=pow(fact[i],mod-2,mod)
  
ans=0
def comb(a,b):
  tmp = (fact[a]*fact_inv[a-b]%mod)*fact_inv[b]
  tmp%=mod
  return tmp


for i in range(k+1):
  tmp = comb(n,i)*comb(n-1,i)
  tmp%=mod
  ans+=tmp
  ans%=mod
  
print(ans%mod)

Measured memory_bytes: 42736
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    ll h, ans = 0;
    cin >> h;
    ll cnt = 0;
    while(h > 0){
        h /= 2;
        cnt++;
    }
    for(int i = 0; i < cnt; i++){
        ans += 1LL<<i;
    }
    cout << ans << endl;
    return 0;
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    vector<vector<vector<int>>> dp(n+1,vector<vector<int>>(n+1,vector<int>(k+1,0)));
    for (int i = 0;i < n;++i) for (int j = 0;j < k+1;++j) dp[i][i+1][j] = 1;
    for (int i = 2;i <= n;++i) {
        for (int j = 0;j < n+1-i;++j) {
            if (s[j] == s[j+i-1]) for (int l = 0;l < k+1;++l) dp[j][j+i][l] = max({dp[j+1][j+i-1][l]+2,dp[j][j+i-1][l],dp[j+1][j+i][l]});
            else for (int l = 0;l < k+1;++l) dp[j][j+i][l] = max(dp[j][j+i-1][l],dp[j+1][j+i][l]);
        }
        for (int j = 0;j < n+1-i;++j) {
            for (int l = 0;l < k;++l) dp[j][j+i][l+1] = max({dp[j][j+i][l+1],dp[j+1][j+i-1][l]+2});
        }
    }
    cout << dp[0][n][k] << endl;
}

Measured memory_bytes: 110336
n,m=map(int,input().split())
a=[list(input()) for i in range(n)]
b=[list(input()) for i in range(m)]
f=True
for i in range(n-m+1):
  for j in range(n-m+1):
    f=True
    for k in range(i,i+m):
      for l in range(j,j+m):
        if b[k-i][l-j]!=a[k][l]:
          f=False
    if f:
      print('Yes')
      break
  if f:
    break
if not f:
  print('No')

Measured memory_bytes: 3064
import scala.io.StdIn

object Main extends App {
  case class Point(x: Int, y: Int)
  def readPoints(n: Int): List[Point] = (0 until n).foldLeft(List.empty[Point]){
    (acc, _)  =>
      val wkp = StdIn.readLine().trim.split(' ').map(_.toInt)
      Point(wkp(0), wkp(1)) :: acc
  }

  def comparePoint(red: Point, blue: Point): Boolean = red.x < blue.x && red.y < blue.y

  val pointCount = StdIn.readLine().trim.toInt
  val redPoints = readPoints(pointCount).sortBy(e => (e.x, e.y))
  val bluePoints = readPoints(pointCount).sortBy(e => (e.x, e.y))

  val r = bluePoints.foldLeft(0, Set.empty[Point], Set.empty[Point]){ (acc, e) =>
    var cnt = acc._1
    var checkRed = acc._2
    var checkBlue = acc._3

    val targetRed = redPoints.filterNot(p => checkRed.contains(p)).filter(p => comparePoint(p, e)).sortBy(p => -p.y)
    if(targetRed.nonEmpty && !checkBlue.contains(e)){
      (cnt + 1, checkRed + targetRed.head, checkBlue + e) 
    } else {
      (cnt, checkRed, checkBlue)
    }
  }
  println(r._1)
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    if(a>=b){
        if(c>=d) cout << b+d;
        else cout << b+c;
    }
    else{
        if(c>=d) cout << a+d;
        else cout << a+c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/


string s;
int main() {

  cin >> s;
  rep(i, s.size() - 1) if (s[i] == 'A' && s[i + 1] == 'C') {
    cout << "Yes" << endl; return 0;
  } 
  cout << "No" << endl;  return 0;
  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007LL;
const ll INF=1000000000;
const int MAX=100001;
int da[MAX];
int db[MAX];
vector<int> G[MAX];
void dfsa(int v,int d){
    da[v]=d;
    for(int i=0;i<(int)G[v].size();i++){
        if(da[G[v][i]]==INF){
            dfsa(G[v][i],d+1);
        }
    }
}
void dfsb(int v,int d){
    db[v]=d;
    for(int i=0;i<(int)G[v].size();i++){
        if(db[G[v][i]]==INF){
            dfsb(G[v][i],d+1);
        }
    }
}
int main() {   
    int n;
    cin>>n;
    for(int i=0;i<=n;i++){
        da[i]=INF;
        db[i]=INF;
    }
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfsa(1,0);
    dfsb(n,0);
    int br=0;int wh=0;
    for(int i=1;i<=n;i++){
        if(da[i]<=db[i]){
            br++;
        }else{
            wh++;
        }
    }
    if(br>wh){
        cout<<"Fennec"<<endl;
    }else{
        cout<<"Snuke"<<endl;
    }
    getchar();
    getchar();
}

Measured memory_bytes: 11136
n,k=map(int,input().split())
a=list(map(int,input().split()))


kouho=[]
for l in range(n):
    kouho.append(a[l])
    tmp=a[l]
    for r in range(l+1,n):
        tmp+=a[r]
        kouho.append(tmp)
kouho.sort()

cnt=0
while 2**cnt<=kouho[-1]:
    cnt+=1

flag=[1]*len(kouho)

while cnt>=0:
    tmp_cnt=0
    for i,item in enumerate(kouho):
        if 2**cnt & item and flag[i]==1:
            tmp_cnt+=1
    if tmp_cnt>=k:
        for i,item in enumerate(kouho):
            if 2**cnt & item and flag[i]==1:
                continue
            else:
                flag[i]=0
    cnt-=1

ans=-1
cnt=0
#print(kouho)
#print(flag)
for i in range(len(kouho)):
    if flag[i]==1:
        cnt+=1
        if ans==-1:
            ans=kouho[i]
        else:
            ans=ans&kouho[i]
    if cnt==k:
        print(ans)
        exit()








Measured memory_bytes: 112644
n=gets.to_i
s=n.times.map{gets.chomp}
h={}
"a".upto("z") do |l|
  h[l]=63
end
s.each do |t|
  "a".upto("z") do |l|
    h[l]=t.count(l) if h[l] > t.count(l)
  end
end
a=""
"a".upto("z") do |l|
  a+=l*h[l]
end
puts a

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

struct UnionFind{
    vector<int> d;
    UnionFind(int n):d(n,-1){}
    int find(int x){
        if(d[x]<0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int  y){
        x = find(x);y = find(y);
        if(x==y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) {return find(x) == find(y);}
    int size(int x) {return -d[find(x)];}
};

int main(){
    int n,m;cin >> n >> m;
    UnionFind gp(200005);
    rep(i,m){
        int a,b;cin >> a >> b;
        --a;--b;
        gp.unite(a,b);
    }
    int ans = 0;
    rep(i,n) ans = max(ans,gp.size(i));
    cout << ans << endl;
    
}



Measured memory_bytes: 4048
N,K=map(int, raw_input().split())
H=map(int, raw_input().split())

dp=[ float("inf") for i in range(N) ] 
dp[0]=0

for i in range(N-1):
	for k in range(K,0,-1):
		if i+k<N:dp[i+k]=min(dp[i+k], dp[i]+ abs( H[i]-H[i+k] )  )
print dp[N-1]


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

#define int long long
typedef long long ll;
using namespace std;

int n, d;
int mp[123][123];

int get(int a, int b) {
    int ans = 0;
    for (int i = 1; i <= d; i++) 
        ans += (mp[a][i] - mp[b][i]) * (mp[a][i] - mp[b][i]);
    return ans;
}

int32_t main() {
    ios::sync_with_stdio(0), cin.tie(0);
    unordered_set<int> st;
    for (int i = 0; i <= 100000; i++)st.insert(i * i);
    cin >> n >> d;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= d; j++)cin >> mp[i][j];
    int ans = 0;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++) {
            if (st.count(get(i, j)))ans++;
        }
    cout << ans << endl;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

ll A, B, C;

ll solve(ll a, ll b, ll c)
{
    return (a & 1) * b * c;
}

int main() {
    cin >> A >> B >> C;
    cout << min(min(solve(A,B,C), solve(B,C,A)), solve(C,A,B)) << endl;
    return 0;
}

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

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

int main() {
  int N, K; cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end(), greater<int>());
  if (N == 1) {
    if (A.at(0) == K) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  if (A.at(0) < K) { cout << "IMPOSSIBLE" << endl; return 0; }
  int G = A.at(0);
  for (int i = 1; i < N; i++) G = gcd(G, A.at(i));
  if (G == 1) cout << "POSSIBLE" << endl;
  else {
    if (K % G == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int h, w, n;
int calc(int x, int y)
{
	while (x > 0)
	{
		if ((x + y) % 2)
		{
			int tmp = min(x, w - y - 1);
			x -= tmp;
			y += tmp;
		}
		else
		{
			int tmp = min(x, y);
			x -= tmp;
			y -= tmp;
		}
		x--;
	}
	return y;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	cin >> h >> w >> n;
	vector<pii> v;
	REP(i, n)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		v.emplace_back(a, b);
	}
	sort(ALL(v));
	vi goal(w);
	REP(i, w) goal[i] = i;
	for(auto i: v)
	{
		int l = calc(i.first % (2 * w), i.second), r = calc(i.first % (2 * w), i.second + 1);
		swap(goal[l], goal[r]);
	}
	vi ans(w);
	REP(i, w) ans[goal[calc(h, i)]] = i;
	for (auto i : ans) cout << i + 1 << endl;
	return 0;
}

Measured memory_bytes: 5956
n=int(input())
a=input()
b=input()
c=input()

s='abcdefghijklmnopqrstuvwxyz'

al=[]
bl=[]
cl=[]
ans=0
for i in range(n):
    si=[s.index(a[i]),s.index(b[i]),s.index(c[i])]
    sj=[]
    for j in range(len(set(si))):
        sj.append(si.count(list(set(si))[j]))
    ans+=(3-max(sj))
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}

short dp[5001][5001];
void dfs(int x,int y,int depth){
    if(dp[y][x]>=depth)return;
    dp[y][x]=depth;
    if(depth==0)return;
    int ny=y+1;
    int nx=x+1;
    dfs(nx,ny,depth-1);
    ny=y;
    dfs(nx,ny,depth-1);
}

void solve(){
    memset(dp,-1,sizeof(dp));
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y,a;
        cin>>x>>y>>a;
        dfs(x,y,a);
    }
    int cnt=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(dp[j][i]>=0)cnt++;
        }
    }
    cout<<cnt<<endl;
}
int main(){

    solve();

    return 0;
}

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

const int MAXN = 1e5 + 10;
int gf[MAXN], ge[MAXN], n, a[MAXN];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i], gf[i] = __gcd(a[i], gf[i - 1]);
	for (int i = n; i >= 0; i--)
		ge[i] = __gcd(a[i], ge[i + 1]);
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans = max(__gcd(gf[i - 1], ge[i + 1]), ans);
	cout << ans;
}

Measured memory_bytes: 1408
#include <cstdio>

int main() {
    int n;
    int a[3100];
    int ans=0;

    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }


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

    printf("%d\n", ans);
}



Measured memory_bytes: 128
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if (b - a > k) or (c - a > k) or (d - a > k) or (e - a > k) or (c - b > k) or (d - b > k) or (e - b > k) or (d - c > k) or (e - c > k) or (d - e > k):
    print(":(")

else:
    print("Yay!")

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    int n;
    vi h;
    cin>>n;
    h.resize(n);
    REP(i,n) cin>>h[i];

    vi sum(n);
    fill(ALL(sum),0);
    int cnt = 0;
    
    FOR(i,1,n){
        if(h[i-1]>=h[i]){
            sum[i] = sum[i-1]+1;
        }else{
            sum[i] = 0;
        }
    }

    sort(ALL(sum));

    cout << sum[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//2次元累積和を返す関数
vector<vector<ll>> csum2d(vector<vector<ll>> a){
	vector<vector<ll>> res(a.size() + 1, vector<ll>(a[0].size() + 1, 0));
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[0].size(); j++)
		{
			res[i + 1][j + 1] = res[i][j + 1] + res[i + 1][j] - res[i][j] + a[i][j];
		}
	}
	return res;
}

int main(){
	int a;
	cin >> a;
	string s;
	cin >> s;
	cout << (a >= 3200 ? s : "red") << endl;
	return 0;
}



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

int main(){
  string s;
  cin >> s;
  rep(i,s.size()){
    if(i==3)cout << 8;
    else{
      cout << s[i];
    }  
  }  
  return 0;

}


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

int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];

  long long cnt1 = 0;
  long long sum1 = 0;
  for (int i=0; i<n; i++) {
    sum1 += a[i];
    if (i % 2 == 0) {
      if (sum1 <= 0) {
        cnt1 += 1 - sum1;
        sum1 = 1;
      }
    } else {
      if (sum1 >= 0) {
        cnt1 += sum1 + 1;
        sum1 = -1;
      }
    }
  }
  long long cnt2 = 0;
  long long sum2 = 0;
  for (int i=0; i<n; i++) {
    sum2 += a[i];
    if (i % 2 == 1) {
      if (sum2 <= 0) {
        cnt2 += 1 - sum2;
        sum2 = 1;
      }
    } else {
      if (sum2 >= 0) {
        cnt2 += sum2 + 1;
        sum2 = -1;
      }
    }
  }
  cout<<min(cnt1, cnt2)<<endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[200002];
long long ans;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+1+n,greater<int>());
	for(int i=m+1;i<=n;i++){
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
import sys

read = sys.stdin.read
readline = sys.stdin.readline

K, *A = map(int, read().split())
maximum = 2
minimum = 2
for i in A[::-1]:
    if i > maximum:
        print(-1)
        exit()
    if i >= minimum:
        new_minimum = i
    else:
        new_minimum = (minimum + i - 1) // i * i
    new_maximum = maximum // i * i + i - 1
    if minimum <= new_minimum <= new_maximum and maximum <= new_maximum:
        minimum, maximum = new_minimum, new_maximum
    else:
        print(-1)
        exit()

print(minimum, maximum)


Measured memory_bytes: 14092
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t A, B, pro, gcd;
  cin >> A >> B;
  pro = A * B;
  while (true) {
    if (A % B == 0) {
      gcd = B;
      break;
    }
    else {
      int64_t C = B;
      B = A % C;
      A = C;
    }
  }
  
  //cout << gcd << endl; //check
  cout << pro / gcd << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python
# coding: UTF-8

s = input()
a, b = map(int,(s[:2],s[2:]))

flag = "00"
dict = {
  "00": "NA",
  "10": "MMYY",
  "01": "YYMM",
  "11": "AMBIGUOUS",
}

if 0 < a < 13:
  flag = "1" + flag[1]

if 0 < b < 13:
  flag = flag[0] + "1"
  
print(dict[flag])

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int gcd(lint a, lint b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

signed main() {
  int N;
  cin >> N;

  int A = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A = gcd(A, a);
  }

  cout << A << endl;

  return 0;
}


Measured memory_bytes: 256
#
# File    : A.rb
# Author  : Kazune Takahashi
# Created : 2018-8-5 20:58:22
# Powered by Visual Studio Code
#

r = gets.to_i

if r < 1200
  puts "ABC"
elsif r < 2800
  puts "ARC"
else
  puts "AGC"
end

Measured memory_bytes: 3836
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  int n,x;
  cin>>n>>x;
  if(x==1 || x==2*n-1) cout<<"No"<<endl;
  else{
    cout<<"Yes"<<endl;
    if(n<3){
      fr(i,3) cout<<i+1<<endl;
    }
    else if(x==2){
      fr(i,n-2) cout<<i+5<<endl;
      cout<<3<<endl;
      cout<<2<<endl;
      cout<<1<<endl;
      cout<<4<<endl;
      fr(i,n-3) cout<<i+n+3<<endl;
    }
    else{
      int j=1;
      fr(i,n-2){
        if(j==x-2) j+=4;
        cout<<j<<endl;
        j++;
      }
      cout<<x-1<<endl;
      cout<<x<<endl;
      cout<<x+1<<endl;
      cout<<x-2<<endl;
      fr(i,n-3){
        if(j==x-2) j+=4;
        cout<<j<<endl;
        j++;
      }
    }
  }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

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

    string s;
    int k;
    cin>>s>>k;
    vector<string> v;
    for(int i=1;i<=min(k,(int)s.size());i++){
        for(int j=0;i+j<=s.size();j++){
            string t=s.substr(j,i);
            v.push_back(t);
            //cout<<t<<endl;
        }
    }
    sort(v.begin(),v.end());
    int num=1;
    if(k==1){
        cout<<v[0]<<endl;
        return 0;
    }
    for(int i=1;i<v.size();i++){
        if(v[i]==v[i-1])continue;
        num++;
        if(num==k){
            cout<<v[i]<<endl;
            break;
        }
    }
}

Measured memory_bytes: 1660
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var k = cin.nextInt();
            var x = cin.nextInt();
            var y = cin.nextInt();

            Console.WriteLine(n<=k?n*x:k*x+(n-k)*y);
        }
    }    

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}

Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var S = cin.next();
            
            if(S[0] == S[1])
            {
                Console.WriteLine("Bad");
            }else if (S[1] == S[2])
            {
                Console.WriteLine("Bad");
            }
            else if (S[2] == S[3])
            {
                Console.WriteLine("Bad");
            }
            else
            {
                Console.WriteLine("Good");
            }         

                      
        }

        

        public static long Sum(int left, int right, long[] a)
        {
            return a[right] - a[left];
        }
    }

    class Point
    {
        public int x { get; set; }
        public int y { get; set; }
    }


    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }


int main() {
  int N, K; cin>>N>>K;
  if(K > (N-1)*(N-2)/2) {
    cout << -1 << endl;
  } else {
    int rem = (N-1)*(N-2)/2-K;
    vector<pint> ans;
    for(int i	= 2; i <= N; i++) {
      ans.push_back(make_pair(1, i));
    }
    for(int i = 2; i < N; i++) {
      if(rem <= 0) break;
      for(int j = i+1; j <= N; j++) {
        ans.push_back(make_pair(i, j));
        rem--;
        if(rem <= 0) break;
      }
    }
    cout << ans.size() << endl;
    REP(i,ans.size()) cout << ans[i].first << " " << ans[i].second <<endl;
  }
  return 0;
}


Measured memory_bytes: 888
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
bool check(string A, string B) {
	int lenA = A.size();
	if (A[lenA - 1] == B[0]) {
		return true;
	}
	return false;
}
void solve() {
	int N;
	cin >> N;
	set<string> word;
	set<string>::iterator itr;
	string str;
	cin >> str;
	word.insert(str);
	string pre = str;
	for (int i = 1; i < N; ++i) {
		cin >> str;
		if (check(pre, str) == false) {
			cout << "No" << endl;
			return;
		}
		itr = word.find(str);
		if (itr != word.end()) {
			cout << "No" << endl;
			return;
		}
		word.insert(str);
		pre = str;
	}
	cout << "Yes" << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <set>
#include <functional>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
typedef pair<string,int> P;
bool check(string &S) {
	for(int i=0;i<9;i++) {
		if(S[i]!=S[0]) return false;
	}
	for(int i=21;i<30;i++) {
		if(S[i]!=S[21]) return false;
	}
	for(int i=9;i<=18;i+=3) {
		if(S[i]!=S[i+1]||S[i+1]!=S[i+2]) return false;
	}
	return true;
}
string op(string &S,int x) {
	string nS=S;
	if(x==0) {
		swap(nS[6],nS[21]);
		swap(nS[7],nS[22]);
		swap(nS[8],nS[23]);
		swap(nS[12],nS[17]);
		swap(nS[9],nS[11]);
	}else if(x==1) {
		swap(nS[0],nS[27]);
		swap(nS[1],nS[28]);
		swap(nS[2],nS[29]);
		swap(nS[14],nS[15]);
		swap(nS[18],nS[20]);
	}else if(x==2) {
		swap(nS[0],nS[23]);
		swap(nS[3],nS[26]);
		swap(nS[6],nS[29]);
		swap(nS[9],nS[20]);
		swap(nS[15],nS[17]);
	}else {
		swap(nS[2],nS[21]);
		swap(nS[5],nS[24]);
		swap(nS[8],nS[27]);
		swap(nS[11],nS[18]);
		swap(nS[12],nS[14]);
	}
	return nS;
}
int solve(string &S) {
	queue<P> Q;
	set<string> vis;
	Q.push(P(S,0));
	vis.insert(S);
	while(!Q.empty()) {
		P p=Q.front();Q.pop();
		if(check(p.first)) {
			return p.second;
		}
		for(int i=0;i<4;i++) {
			string nS=op(p.first,i);
			if(vis.find(nS)==vis.end()) {
				vis.insert(nS);
				Q.push(P(nS,p.second+1));
			}
		}
	}
	return 114514;
}
int main() {
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++) {
		string S;
		for(int j=0;j<30;j++) {
			int x;
			scanf("%d",&x);
			S.push_back('0'+x);
		}
		printf("%d\n",solve(S));
	}
}

Measured memory_bytes: 1276
// ITP1_8_D:   Ring
// 2017.7.27

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>

char *gets(char *s);

int main()
{
	char s[210], p[110];
	char *pp;
	int i, len1, len2;


	gets(s);
	len1 = strlen(s);
	strcpy(p, s);
	strcpy(s + len1, p);

	gets(p);
	len2 = strlen(p);

	for (i = 0, pp = s; ; i++, pp++) {
		if (i >= len1) {
			puts("No");
			break;
		}
		if (!strncmp(pp, p, len2)) {
			puts("Yes");
			break;
		}
	}
	return 0;
}

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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

const int INF = 1e9;
int e;

int main() {

  while(1){
    cin>>e;
    if(e==0) break;
    int m = INF;
    for(int z = 0; z <= 100; z++){
      for(int y = 0; y <= 1000; y++){
        int x = e - y*y - z*z*z;
        if(x < 0) continue;
        m = min(m,x+y+z);
      }
    }
    cout<<m<<endl;
  }

  return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

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

    int n;
    cin >> n;
    vector<ll> a(3 * n);
    rep(i, 0, 3 * n) cin >> a[i];
    ll ans = 0, sum = 0;
    rep(i, 0, n) ans += a[i] - a[3 * n - 1 - i];
    priority_queue<ll, vector<ll>, greater<ll>> q1;
    priority_queue<ll> q2;
    vector<ll> s1(n + 1), s2(n + 1);
    rep(i, 0, n) {
        q1.push(a[i]);
        q2.push(a[3 * n - i - 1]);
    }
    rep(i, 0, n) {
        q1.push(a[i + n]);
        s1[i + 1] = a[i + n] - q1.top() + s1[i];
        q1.pop();
        q2.push(a[2 * n - 1 - i]);
        s2[i + 1] = q2.top() - a[2 * n - 1 - i] + s2[i];
        q2.pop();
    }
    rep(i, 0, n + 1) sum = max(sum, s1[i] + s2[n - i]);
    cout << ans + sum << endl;
    //debug(s1), debug(s2);
    return 0;
}

Measured memory_bytes: 6000
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;
map<int,ll> bargersize;
ll size(int N){
    if(bargersize[N]!=0)return bargersize[N];
    else if(N==0)return bargersize[0]=1;
    else{
        return bargersize[N]=3+2*size(N-1);
    }
}
map<int,ll>patinum;
ll patisize(int N){
    if(patinum[N]!=0)return patinum[N];
    else if(N==0)return patinum[0]=1;
    else{
        return patinum[N]=1+2*patisize(N-1);
    }
}
ll pati(int N,ll X){
    if(X<=0)return 0;
    else if(size(N)<=X)return patisize(N);
    else{
        ll ans=pati(N-1,X-size(N-1)-2)+pati(N-1,X-1);
        if(X>=size(N-1)+2)ans++;
        return ans; 
    }
    
}

int main(){
int N;
ll X;
cin>>N>>X;
cout<<pati(N,X)<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int x,y;
  cin>>x>>y;
  if(x<=8 && y<=8) cout<<"Yay!\n";
  else cout<<":(\n";
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3668
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    string s = "No";
    FOR(i,0,25){
      FOR(j,0,20){
        if(i*4 + j*7 == n) s = "Yes";
      }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int N=sc.nextInt();
  int flag=0;
  for(int i=0;i<N;i++){
    int a=sc.nextInt();
    if(a%2==1){
      continue;
    }
    else{
      if((a%3==0) || (a%5==0)){
        continue;
      }
      else{
        flag=1;
        break;
      }
    }
  }
  if(flag==1){
    System.out.println("DENIED");
  }
  else{
    System.out.println("APPROVED");
  }     
}
}

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

int main(){
    int H, W, i, j;
    vector <string> str(100);
    vector <int> e_pos;
    int cnt = 0, cnt_i = -1;
    vector <int> Hi, Wj;

    cin >> H >> W;
    for(i = 0; i < H; i++){
        cin >> str[i];
        for(j = 0; j < W; j++){
            if(str[i][j] == '.'){
                cnt++;
            }
            if(j == W - 1){
                Hi.push_back(cnt);
                cnt = 0;
            }
        }
    }
    for(j = 0; j < W; j++){
        for(i = 0; i < H; i++){
            if(str[i][j] == '.'){
                cnt++;
            }
            if(i == H - 1){
                Wj.push_back(cnt);
                cnt = 0;
            }
        }
    }
    for(i = 0; i < H; i++){
        if(Hi[i] == W){
            continue;
        }
        for(j = 0; j < W; j++){
            if(Wj[j] == H){
                continue;
            }
            printf("%c", str[i][j]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 256
julia -EH,W,A,B=`tr \  ,`";M,C,Z,X=10^9+7,1,0,W+H-B-2;for I=0:H-2;C=C*(X-I)%M*invmod(-~I,M)%M;end;for I=1:H-A;Z+=C;C=(B+I-1)*(H-I)%M*C%M*invmod((X-I+1)*I,M)%M;end;Z%M"

Measured memory_bytes: 155772