akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

    int mis = 0;
    int N; cin >> N;
    F0R(i, N) {
        int cur; cin >> cur;
        if (cur != i+1) mis++;
    }
    string ans = (mis <= 2) ? "YES" : "NO";
    cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

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

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        class Point
        {
            public int x;
            public int y;
        }

        static void Main(string[] args)
        {
            long n = Int64.Parse( Console.ReadLine());
            Point[] p = new Point[n];

            for(int i=0; i<n; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                p[i] = new Point { x =int.Parse( s[0]), y = int.Parse( s[1]) };
            }

            double distance = 0.0;
            for (int i=0; i<n; i++)
            {
                for(int j=i+1; j<n;j++)
                {
                    var dis = Math.Pow(p[i].x - p[j].x, 2) + Math.Pow(p[i].y - p[j].y, 2);
                    dis = Math.Sqrt(dis);
                    distance += dis;
                }
            }

            Console.WriteLine( (distance*2) / n);
        }

        static int rec(int[] n, int i, int j, int x)
        {
            if (i + 1 == j)
            {
                return Math.Min(n[j], x);
            }
            return rec(n, i + 1, j, n[i]) + rec(n, i, j - 1, n[j]);
        }


    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int32_t main(){
	ios::sync_with_stdio(0);
	int a, x;
	cin >> a >> x;
	if(a*500>=x)
		cout <<"Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 500000
 
int n,A[N];
 
int main(){
    int i;
 
    scanf("%d",&n);
    for(i = 1;i <= n; i++){
      scanf("%d",&A[i]);
    }
    for(i = n/2;i >= 1;i--){
      maxHeapify(i);
    }
    for(i = 1;i <= n;i++){
      printf(" %d",A[i]);
    }
    printf("\n");
    return 0;
  }

void maxHeapify(int i){
  int c;
  int l = 2 * i;
  int r = 2 * i + 1;
  int max=0;
  if(l <= n && A[l] > A[i]){
    max = l;
  }
  else {
    max = i;
  }
 
  if(r <= n && A[r] > A[max]){
    max = r;
  }
 
  if(max != i){
    c = A[i];
    A[i] = A[max];
    A[max] = c;
    maxHeapify(max);
  }
}
 

Measured memory_bytes: 2552
A, B, C, X, Y = map(int, input().split())
C *= 2
if X == Y:
    print(min((A * X + B * Y, C * X)))
elif X > Y:
    ans = 0
    ans += min(C * Y, A * Y + B * Y)
    num = X - Y
    ans += min(C, A) * num
    print(ans)
elif Y > X:
    ans = 0
    ans += min(C * X, A * X + B * X)
    num = Y - X
    ans += min(C, B) * num
    print(ans)


Measured memory_bytes: 3064
n,k = map(int,input().split())
A = list(map(int,input().split()))

dp = [0 for i in range(k+1)]

for i in range(1,k+1):
    for j in range(n):
        if i - A[j] >= 0 and dp[i-A[j]] == 0:
            dp[i] = 1
if dp[k]:
    print("First")
else:
    print("Second")

Measured memory_bytes: 45232
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>

//Some constants don't work
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN -2147483648
#endif
//short hand tricks
typedef long long ll;

using namespace std;

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> v(N);
    //keep track of all numbers
    vector<int> freq(1e6+1, 0);
    for(int i=0; i<N; i++) {
        cin >> v[i];
        freq[v[i]]++;
    }
    int res = N;
    //see if number has any divisor that's another number excluding itself
    for(int i=0; i<N; i++) {
        //check every divisor
        int num = v[i];
        freq[num]--;
        //O(sqrt(n))
        for(int i=1; i*i<=num; i++) {
            if(num%i==0) {
                if(freq[i]>0 || freq[num/i]>0) {
                    //divisor is another number
                    res--;
                    break;
                }
            }
        }
        freq[num]++;
    }
    cout << res << "\n";
    
    return 0;
}


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

int main()
{
	map<string, bool> T;
	int n;
	string com, str;
	cin >> n;
	for(int i = 0; i < n; ++ i)
	{
		cin >> com >> str;
		if(com[0] == 'i')
		{
			T[str] = true;
		}
		else if(com[0] == 'f')
		{
			if(T[str])	cout << "yes" << endl;
			else	cout << "no" << endl;
		}
	}
	
	return 0;
} 


Measured memory_bytes: 52560
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 120


int main(){
  int color[MAX];
  int count=0;
  for(int i=0;i<3;i++){
    cin>>color[i];
    for(int j=0;j<i;j++){
      if(color[j]==color[i]) count++;
    }
  }
  if(count==3) cout<<"1"<<endl;
  else if(count==1) cout<<"2"<<endl;
  else cout<<"3"<<endl;
  
  

}


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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int N,K,C; cin>>N; cin>>K;cin>>C;
  string str;cin>>str;
  vector<int> L(K,0);
  vector<int> R(K,0);
  int cnt = 0;
  int dcnt = INF;
  int d = 0;
  for (auto &&s : str)
  {
    if(s =='o' && dcnt >= C)
    {
      L[cnt] = d;
      dcnt = -1;
      cnt++;
    }
    if(cnt == K)break;
    d++;
    dcnt++;
  }
  reverse(ALL(str));
  cnt = 0;
  dcnt = INF;
  d = 0;
  for (auto &&s : str)
  {
    if(s =='o' && dcnt >= C)
    {
      R[cnt] = N -1 - d;
      dcnt = -1;
      cnt++;
    }
    if(cnt == K)break;
    d++;
    dcnt++;
  }
  reverse(ALL(R));
  // DEBUG(L,R);
  for (int i = 0; i < K; i++)
  {
    if(L[i] == R[i])
    {
      cout<<R[i] + 1<<endl;
    }
  }
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 6708
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int h,w;
char mp[111][111];
int xx[4]={0,1,0,-1};
int yy[4]={-1,0,1,0};
int sx,sy;

int tile(int y,int x){
    if(y<h&&x<w&&y>=0&&x>=0&&mp[y][x]!='#'){
        mp[y][x]='#';
        int t=0;
        for(int i=0;i<4;i++){
            t+=tile(y+yy[i],x+xx[i]);
        }
        return t+1;
    }
return 0;
}

int main(){
    
    while(1){
    
        scanf(" %d %d",&w,&h);
        
        if(w==0&&h==0)break;
        
        for(int i=0;i<h;i++){
            scanf(" %s",mp[i]);
            for(int j=0;j<w;j++){
                if(mp[i][j]=='@'){
                    sx=j;
                    sy=i;
                }
            }
        }
        
        cout << tile(sy,sx) << endl;
        
    }
    
    return 0;
    
}

Measured memory_bytes: 3172
def insertion_sort(array, g, result):
    for i in range(g, len(array)):
        v = array[i]
        j = i - g
        while j >= 0 and array[j] > v:
            array[j + g] = array[j]
            j -= g
            result['count'] += 1
        A[j + g] = v


def g_gene(n):
    yield 1
    for i in range(2, n):
        x = int((3 ** i - 1) / 2)
        if x < n:
            yield x
        else:
            raise StopIteration()


def shell_sort(array, result):
    result['count'] = 0
    G = list(reversed(list(g_gene(len(array)))))
    m = len(G)
    result['G'] = G
    result['m'] = m
    for i in range(m):
        insertion_sort(array, G[i], result)


if __name__ == '__main__':
    import sys
    n = int(sys.stdin.readline())
    A = []
    for _ in range(n):
        A.append(int(sys.stdin.readline()))
    result = {}
    shell_sort(A, result)
    print(result['m'])
    print(' '.join(map(str, result['G'])))
    print(result['count'])
    for a in A:
        print(a)

Measured memory_bytes: 47248
#include<iostream>
#include<map>
#include<cmath>

using namespace std;

long long a[302][302];
pair<long long,long long> where[302*302];
long long left1[302*302];

int main ()
{
    long long h,w,d,q,l,r,i,j;

    cin>>h>>w>>d;

    for(i=1;i<=h;i++)
        for(j=1;j<=w;j++)
        {
            cin>>a[i][j];
            where[a[i][j]]=make_pair(i,j);
        }

    for(i=w*h-d;i>=1;i--)
    {
        left1[i]=left1[i+d]+abs(where[i+d].first-where[i].first)+abs(where[i+d].second-where[i].second);
    }

    cin>>q;

    for(i=0;i<q;i++)
    {
        cin>>l>>r;

        cout<<left1[l]-left1[r]<<endl;
        //cout<<left1[l]<<" "<<left1[6]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;pair<int,int>p[200100];int N,i,c,b,n[200100],d[200100];main(){cin>>N;for(;i<N;i++)cin>>c>>b,p[i]={c,b};sort(p,p+N);d[N]=1;for(;i--;){c=i+1;while(c<N&&p[c].first<p[i].first+p[i].second)c=n[c];d[i]=(d[i+1]+d[n[i]=c])%998244353;}cout<<*d;}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<cstdlib>
#include<map>
#include<stack>
#include<algorithm>
typedef long long ll;
using namespace std;
struct mm{
ll x,y;}s[100006];
bool cmp(mm A,mm B){
    if(A.y!=B.y)
return A.y<B.y;
 return A.x>B.x;
}
int main(){
 int N,M,sum,m;sum=0;
   cin>>N>>M;m=0;
    for(int i=1;i<=M;i++)
        cin>>s[i].x>>s[i].y;
        sort(s+1,s+1+M,cmp);
      for(int i=1;i<=M;i++)
        if(s[i].x>=m)m=s[i].y,sum++;
      cout<<sum<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

const int MAX = 2001000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = (finv[i - 1] * inv[i]) % MOD;
  }
}

ll COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll n, ll t) {
  ll ret = 1;
  while (0 < t) {
    if (t % 2 == 0) {
      n *= n;
      n %= MOD;
      t >>= 1;
    } else {
      ret *= n;
      ret %= MOD;
      --t;
    }
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  string S;
  ll K;
  cin >> K >> S;
  ll size = S.size();
  ll ans = 0;

  COMinit();

  REP(i, K + 1) {
    ll p = modpow(26, i);
    ll c = COM((size + K - 1 - i), (size - 1));
    ll p2 = modpow(25, (K - i));
    // cout << c << " " << p << " " << p2 << endl;
    ans += (((p * c) % MOD) * p2) % MOD;
    ans %= MOD;
  }

  cout << ans << endl;
}

Measured memory_bytes: 51188
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

int n,m,q;
V<int> a,b,c,d;

ll dfs(V<int> v,int nex){
  if(nex==n)return 0;

  V<int> to=v;
  ll res=0,sco;
  rep(i,v[nex-1],m+1){
    to[nex]=i;
    sco=0;

    rep(j,0,q){
      if(b[j]==nex && to[b[j]]-to[a[j]]==c[j])sco+=d[j];
    }

    chmax(res,dfs(to,nex+1)+sco);
  }
  return res;
}

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  cin>>n>>m>>q;
  a.resize(q);b.resize(q);c.resize(q);d.resize(q);
  rep(i,0,q){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    a[i]--;
    b[i]--;
  }

  V<int> tmp(n,0);
  ll ans=0;
  rep(i,1,m+1){
    tmp[0]=i;
    chmax(ans,dfs(tmp,1));
  }
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3660
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void y(bool c) { if (c)print("Yes"); else print("No"); };


ll dp[2010][2010];//dp[i][j]=i番目までで左がj個使用済みの時の最大値
void solve() {
	int N; cin >> N;
	vector<int>A(N);
	vector<pii>v(N);
	REP(i, N) {
		cin >> A[i];
		v[i] = { A[i],i };
	}
	VSORT(v); VREVERSE(v);
	REP(i, N) {
		REP(j, i + 1) {
			//左に追加
			chmax(dp[i + 1][j + 1], dp[i][j] + v[i].first*abs(v[i].second - j));
			//右に追加
			chmax(dp[i + 1][j], dp[i][j] + v[i].first*abs(v[i].second - (N - 1 - (i - j))));
		}
	}
	ll ans = 0;
	REP(i, N + 1)ans = max(ans, dp[N][i]);
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}




Measured memory_bytes: 26352
N = gets.to_i
table = Hash.new { 0 }
s_list = N.times.map { gets.chomp.chars }
ans = 0
s_list.each do |s|
  key = s.sort
  if table[key] > 0
    ans += table[key]
  end
  table[key] += 1
end
puts ans


Measured memory_bytes: 84476
/* https://atcoder.jp/contests/abc086/tasks/arc089_a */

#include <iostream>
#include <vector>

  int N;
std::vector<int> T;
std::vector<int> X;
std::vector<int> Y;

int main(int argc, char *argv[])
{
  // Input
  std::cin >> N;

  T = std::vector<int>(N+1);
  X = std::vector<int>(N+1);
  Y = std::vector<int>(N+1);

  T.at(0) = 0;
  X.at(0) = 0;
  Y.at(0) = 0;

  for (int i = 1; i < N+1; ++i) {
    std::cin >> T.at(i) >> X.at(i) >> Y.at(i);
  }

  // Output
  for (int i = 1; i < N+1; ++i) {
    int diff_t = T.at(i) - T.at(i-1);
    int diff_x = X.at(i) - X.at(i-1);
    int diff_y = Y.at(i) - Y.at(i-1);

    if (diff_t >= diff_x + diff_y && (diff_t - diff_x + diff_y)%2 == 0) {
      continue;
    } else {
      std::cout << "No" << std::endl;
      return 0;
    }
  }

  std::cout << "Yes" << std::endl;

  return 0;
}


Measured memory_bytes: 1408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DWeLoveABC solver = new DWeLoveABC();
        solver.solve(1, in, out);
        out.close();
    }

    static class DWeLoveABC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            String s = in.next();
            ModInt[] mi = new ModInt[4];
            Arrays.fill(mi, new ModInt(0));

            mi[0] = new ModInt(1);

            if (s.charAt(0) == 'A') {
                mi[1] = new ModInt(1);
            }

            if (s.charAt(0) == '?') {
                mi[0] = new ModInt(3);
                mi[1] = new ModInt(1);
            }

            for (int i = 1; i < s.length(); i++) {
                char c = s.charAt(i);

                if (c == '?') {
                    mi[3] = mi[3].mul(3).add(mi[2]);
                    mi[2] = mi[2].mul(3).add(mi[1]);
                    mi[1] = mi[1].mul(3).add(mi[0]);
                    mi[0] = mi[0].mul(3);
                }
                if (c == 'C') {
                    mi[3] = mi[3].add(mi[2]);
                }
                if (c == 'B') {
                    mi[2] = mi[2].add(mi[1]);
                }
                if (c == 'A') {
                    mi[1] = mi[1].add(mi[0]);
                }
            }


            out.println(mi[3].getVal());

        }

    }

    static class ModInt {
        long val;
        int MOD = (int) 1e9 + 7;

        public ModInt(long i) {
            this.val = (i + MOD) % MOD;
        }

        public ModInt mul(long l) {
            return new ModInt(this.val * l);
        }

        public ModInt add(ModInt m) {
            return new ModInt(this.val + m.getVal());
        }

        public long getVal() {
            return val;
        }

        public String toString() {
            return "ModInt{" +
                    "val=" + val +
                    ", MOD=" + MOD +
                    '}';
        }

    }
}



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

bool is_white_line(vector<char> &vec){
  int count = 0;
  rep(i, vec.size()){
    if (vec.at(i) == '.') count++;
  }
  if (count == vec.size()) return true;
  else return false;
}
bool is_white_row(vector<vector<char>> &vec, int i){
  int count = 0;
  rep(j, vec.size()){
    if (vec.at(j).at(i) == '.') count++;
  }
  if (count == vec.size()) return true;
  else return false;
}
int main(){
  int a, b;
  cin >> a >> b;
  vector<vector<char>> plane(a, vector<char>(b));
  rep(i, a){
    rep(j, b) cin >> plane.at(i).at(j);
  }
  vector<int> el;
  rep(i, a){
    if (is_white_line(plane.at(i))){
      el.push_back(i);
    }
  }
  rep(i, el.size()) plane.erase(plane.begin() + el.at(i) - i);
  vector<int> er;
  rep(i, b){
    if (is_white_row(plane, i)){
      er.push_back(i);
    }
  }
  rep(i, er.size()){
    rep(j, plane.size()) plane.at(j).erase(plane.at(j).begin() + er.at(i) - i);
  }
  rep(i, plane.size()){
    rep(j, plane.at(i).size()){
      cout << plane.at(i).at(j);
    }
    cout << endl;
  }
}

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

int main() {
string S;
  cin>>S;
 if(S.at(5)=='1'){
   cout<<"TBD"<<endl;
 }
  else if(S.at(5)=='0'&&S.at(6)<='4'){
    cout<<"Heisei"<<endl;
  }
  else if(S.at(5)=='0'&&S.at(6)>='5'){
    cout<<"TBD"<<endl;
  }
}
    

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

void prime_list(vector<unsigned int> &plist, unsigned int max_prime){

    if(plist.size() && plist[plist.size()-1] >= max_prime ) return;
    if(max_prime <= 2){
        plist.push_back(2);
        return;
    }

    unsigned int rt = int(sqrt((double)max_prime));
    prime_list(plist, rt);

    unsigned int bias = plist[plist.size()-1] + 1;
    if(bias == 3) bias = 2;
    unsigned int num = (max_prime - bias + 1) / 2;
    if(num == 0) return;

    char *l = new char[num];
    memset(l, 1, num);

    FOREACH(it, plist){
        unsigned int prime = *it;
        if(prime > rt) break;
        unsigned int st = max(rt - (rt % prime), prime);
        for(unsigned int i = st; i <= max_prime; i += prime){
            if(i >= bias){
                unsigned int idx = i - bias;
                if(idx % 2 == 1){
                    l[idx/2] = 0;
                }
            }
        }
    }
    for(unsigned int i = 0; i < num; i++){
        if(l[i]){
            plist.push_back(bias + 1 + i * 2);
        }
    }
    delete l;
    return;
}

int main(){
    vector<unsigned int> v;
    unsigned int n = 2;
    while(v.size() < 10010){
        n = n * 2;
        prime_list(v, n);
    }

    unsigned int t = 0;
    REP(i, 10000){
        unsigned int tv = v[i];
        v[i] += t;
        t += tv;
    }

    while(cin >> n, n){
        cout << v[n-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1328
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

class AABCSwap {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int X, Y, Z; in >> X >> Y >> Z;
	    out << Z << ' ' << X << ' ' << Y << '\n';
	}
};


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

	AABCSwap solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys
ss=list(input())
s=np.array(ss)
s.sort()
count=1
for i in range(1,len(s)):
    if s[i]==s[i-1]:
        count+=1
    else:
        if count%2==0:
            count=1
        else:
            print("No")
            sys.exit()
if count%2!=0:
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 21636
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)
using namespace std;
inline int read() {
	int res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	return bo ? ~res + 1 : res;
}
typedef long long ll; const int N = 9e5 + 5;
int h, w, n, m, dx[] = {-1, 1, 0, 0, -1, -1, 1, 1, 0}, dy[] = {0, 0, -1, 1, 1, -1, 1, -1, 0}, c[N];
struct cyx {int x, y;} a[N]; map<ll, int> orz;
ll which(int x, int y) {return 1ll * (x - 1) * w + y;}
inline bool comp(const cyx &a, const cyx &b) {return a.x < b.x || (a.x == b.x && a.y < b.y);}
int main() {
	int i, j, x, y; h = read(); w = read(); n = read(); For (i, 1, n) {
		x = read(); y = read(); For (j, 0, 8) {
			int tx = x + dx[j], ty = y + dy[j];
			if (tx < 1 || tx > h || ty < 1 || ty > w) continue;
			a[++m] = (cyx) {tx, ty};
		}
		orz[which(x, y)] = 1;
	}
	sort(a + 1, a + m + 1, comp); For (i, 1, m)
		if (i == 1 || a[i].x != a[i - 1].x || a[i].y != a[i - 1].y) {
			int x = a[i].x, y = a[i].y, tot = 0;
			if (x == 1 || x == h || y == 1 || y == w) continue; For (j, 0, 8) {
				int tx = x + dx[j], ty = y + dy[j];
				if (orz[which(tx, ty)]) tot++;
			}
			if (tot) c[tot]++;
		}
	ll sum = 1ll * (h - 2) * (w - 2); For (i, 1, 9) sum -= c[i]; cout << sum << endl;
	For (i, 1, 9) cout << c[i] << endl;
	return 0;
}

Measured memory_bytes: 164736
def main(word, num):
    strs = list(word)
    target = strs[num-1]

    new_strs = []
    for s in strs:
        if s != target:
            s = "*"
        new_strs.append(s)

    return ''.join(new_strs)


if __name__ == "__main__":
    input()
    word = input()
    num = int(input())
    print(main(word, num))


Measured memory_bytes: 38256
# coding: utf-8
# Your code here!

n=int(input())
a=list(map(float,input().split()))
b=list(map(float,input().split()))

c=[abs(a[i]-b[i]) for i in range(n)]  #abs:絶対値
for p in range(1,4):
    ans=0
    for d in c:
        ans+=d**p
    print("{:.6f}".format(ans**(1/p)))

print("{:.6f}".format(max(c)))


Measured memory_bytes: 5680
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;
#include <map>
#include <math.h>

using ll = long long;
using namespace std;

int main(){
    int n, odd=0, even=0; cin >> n;
    rep(i, n){
        int a; cin >> a;
        if(a%2==0) even++;
        else odd++;
    }
    
    int odd_rest, even_rest, odd_quotient=1, even_quotient=1;

    odd_rest = odd%2;
    odd_quotient = odd/2;
    even += odd_quotient;
    odd -= 2*odd_quotient;
    odd = odd_rest;

    while(even_quotient==0){
        even_rest = even%2;
        even_quotient = even/2;
        even = even_rest+even_quotient;
    }

    if(odd==1) out("NO");
    else out("YES");
}

Measured memory_bytes: 256
import java.util.*;

class Main{

	public static void main(String[] args){
	
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		if(A%2 == 0 || B%2 == 0){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}

	}
}

Measured memory_bytes: 23764
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    a = list(map(int, input().split()))
    temp = c
    for j in range(m):
        temp += a[j] * b[j]
    if temp > 0:
        ans += 1
print(ans)


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

#define debug(x) cerr << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

void initFactorials()
{
  fat[0] = 1;
  inv[0] = 1;
  for(int i = 1; i < maxn; i++)
  {
    fat[i] = (i * fat[i-1]) % mod;
    inv[i] = exp(fat[i], mod - 2);
  }
}

string s;
int findNum(int pos, char c, int inc)
{
  int cnt = 0;
  for(int i = pos; s[i] == c; i += inc)
    cnt++;
  return cnt;
}

int main()
{
  ios::sync_with_stdio(0);
  vector<int>ans;
  cin >> s;
  int n = s.size();
  for(int i = 0 ; i < n ; i++)
  {
    if(i < n - 1 && s[i] == 'R' && s[i + 1] == 'L')
    {
      int numR = findNum(i, 'R', -1);
      int numL = findNum(i + 1, 'L', +1);
      
      ans.push_back(((numR + 1) / 2) + (numL / 2));
      ans.push_back((numR / 2) + ((numL + 1) / 2));
      i++;
    }
    else
    {
      ans.push_back(0);
    }
  }

  for(const auto &c : ans)
    cout << c << ' ';
  cout << endl;

  return 0;
}

Measured memory_bytes: 4164
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
// const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;
const ll INF = ll(1e18) + 1;

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

   int n;
   ll k;
   cin >> n >> k;
   vector<ll> a(n);
   rep(i, 0, n) cin >> a[i];
   sort(a.begin(), a.end());
   ll l = -INF, r = INF;
   while (l + 1 < r) {
      ll x = (l + r) / 2;
      bool ok = [&] {
         ll tot = 0;
         rep(i, 0, n) {
            if (a[i] < 0) {
               int l = -1, r = n;
               while (l + 1 < r) {
                  int mid = (l + r) / 2;
                  if (a[mid] * a[i] < x)
                     r = mid;
                  else
                     l = mid;
               }
               tot += n - r;
            } else {
               int l = -1, r = n;
               while (l + 1 < r) {
                  int mid = (l + r) / 2;
                  if (a[mid] * a[i] < x)
                     l = mid;
                  else
                     r = mid;
               }
               tot += r;
            }
            if (a[i] * a[i] < x) tot--;
         }
         tot /= 2;
         return tot < k;
      }();
      if (ok)
         l = x;
      else
         r = x;
   }
   cout << l << endl;
   return 0;
}

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

using namespace std;

template <typename T>
inline T read()
{
	T x = 0;
	char ch = getchar();
	bool f = 0;
	while(ch < '0' || ch > '9')
	{
		f = (ch == '-');
		ch = getchar();
	}
	while(ch <= '9' && ch >= '0')
	{
		x = ((x + (x << 2)) << 1) + (ch - '0');
		ch = getchar();
	}
	return  f? -x : x;
}

template <typename T>
void put(T x)
{
	if(x < 0)
	{
		x = -x;
		putchar('-');
	}
	if(x < 10) {
		putchar(x + 48);
		return;
	}
	put(x / 10);
	putchar(x % 10 + 48);
	return ;
}

#define reg register
#define rd read <int>
#define pt(i) put <int> (i), putchar(' ')

typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull;
typedef unsigned int ui;

const int Maxn = 2e5 + 111;



int main()
{
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#endif
	string a;
	cin >> a;
	if(a[0] == '7' || a[1] == '7' || a[2] == '7') puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define pn putchar('\n')
#define ps putchar(' ')
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
const int N=1e6+5;

ll a[N],f[N];
 ll n,m;
 bool check(ll z,ll k)
 {
 	 rep(i,0,n)
 	 {
 	 	 if(a[i]*f[n-1-i]<z)continue;
 	 	 if(a[i]-z/f[n-1-i]>k)return false;
 	 	 k-=(a[i]-z/f[n-1-i]);
	  }
	  return true;
 }
int main()
{

 scanf("%lld %lld",&n,&m);
 rep(i,0,n)
 scanf("%lld",&a[i]);
 rep(i,0,n)
 scanf("%lld",&f[i]);
 sort(a,a+n);sort(f,f+n);
 ll l=0,r=1e12+12;
 ll ans;
 while(l<=r)
 {
 	 ll mid=(l+r)>>1;
 	 if(check(mid,m))
 	 {
 	 	ans=mid;
 	 	r=mid-1;
	  }
	  else
	  l=mid+1;
 }
 cout<<ans;
}





Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

vector<int> r;
int k0;

struct Graph {
    struct Vertex { int n; };
    struct Edge { int i, n, k; };
    Graph(int n, int m) : v(n, { -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j, int k) {
        e[m] = { j, v[i].n, k };
        v[i].n = m;
        m++;
    }
    void dfs(int i, int p, int kp) {
        int k = 0;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge &o = e[j];
            if (o.i == p) continue;

            k++;
            if (k == kp) k++;
            r[o.k] = k;
            k0 = max(k0, k);
            dfs(o.i, i, k);
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n;
    cin >> n;

    r.assign(n - 1, 0);

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b, i);
        g.add_edge(b, a, i);
    }

    g.dfs(0, -1, 0);

    cout << k0 << '\n';
    for (int i = 0; i < n - 1; i++) {
        cout << r[i] << '\n';
    }

    return 0;
}

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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll,ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

ll dp[1<<17];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  vector<vll> a(N,vll(N));
  for(ll i=0;i<N;i++){
    for(ll j=0;j<N;j++){
      cin>>a[i][j];
    }
  }
  for(ll s=0;s<(1<<N);s++){
    for(ll i=0;i<N;i++)if((s>>i)&1){
      for(ll j=i+1;j<N;j++)if((s>>j)&1){
        dp[s]+=a[i][j];
      }
    }
    for(ll t=(s-1)&s;t>0;t=(t-1)&s){
      dp[s]=max(dp[s],dp[t]+dp[s^t]);
    }
  }
  cout<<dp[(1<<N)-1]<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int64_t N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A, A+N);
  int ans = 0;
  int equal = 1;
  for(int i=1;i<N;i++){
    if(A[i] == A[i-1]){
      equal++;
    }
    else{
      if(A[i-1] > equal){
        ans += equal;
      }
      else{
        ans += equal - A[i-1];
      }
      equal = 1;
    }
  }
  if(A[N-1] > equal){
    ans += equal;
  }
  else{
    ans += equal - A[N-1];
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
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();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

long long gcd(long long x, long long y){
    if(x < y) swap(x,y);
    return x % y == 0 ? y : gcd(y, x%y);
}
int main(void){
    int N; cin >> N;
    ll T[N], ma=0; REP(i,N){cin >> T[i]; chmax(ma, T[i]);}

    if(N==1){
        cout << T[0] << endl;
        return 0;
    }
    ll ans=T[0]/gcd(T[0],T[1])*T[1];
    FOR(i,1,N-1){
        ans = ans/gcd(ans, T[i+1])*T[i+1];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <cstring>
using namespace std;
typedef pair<int,int> pos;
char map[20][20];
const int next[4][2] = {
  {-1,0},{1,0},{0,-1},{0,1},
};
int main()
{
  for(;;){
    int w,h;
    scanf("%d %d",&w,&h);
    if(w == 0 || h == 0) break;
    string dummy;
    getline(cin,dummy);
    memset(map,'.',sizeof(map));
    pos p;
    for(int i=0; i<h; i++){
      string s;
      getline(cin,s);
      for(int j=0; j<w; j++){
        if(s[j] == '@'){
          p = make_pair(i,j);
        }
        map[i][j] = s[j];
      }
    }
    set<pos> memo;
    memo.insert(p);
    queue<pos> q;
    q.push(p);
    for(;;){
      if(q.empty()) break;
      p = q.front(); q.pop();
      for(int i=0; i<4; i++){
        pos pn = make_pair(p.first+next[i][0], p.second+next[i][1]);
        if(pn.first < 0 || pn.first >= h || pn.second < 0 || pn.second >= w ||
           map[pn.first][pn.second] == '#'){
          continue;
        }
        if(memo.insert(pn).second){
          q.push(pn);
        }
      }
    }
    printf("%d\n", memo.size());
  }
  return 0;
}

Measured memory_bytes: 1284
;;;; main
(let* ((n (read))
       (m (read))
       (a nil)
       (bc nil)
       (d (make-array (list n)))
       (ans 0))
  (loop :for i :from 1 :to n 
        :for x := (read)
        :do (push x a)
        :do (incf ans x))
  (setf a (sort a #'<))
  (setf bc (sort (loop :for j :from 1 :to m
                       :for b := (read)
                       :for c := (read)
                       :collect (cons b c))
                 (lambda (x y) (> (cdr x) (cdr y)))))
  (loop :with r := n
        :while (< 0 r) 
        :for (b . c) :in bc
        :do (if (<= b r)
                (loop :for j :from 1 :to b
                      :do (setf (aref d (- n r)) c)
                      :do (decf r))
                (loop :for j :from 1 :to r
                      :do (setf (aref d (- n r)) c)
                      :do (decf r))))
  (loop :for x :in a
        :for y :across d
        :while (< 0 (- y x))
        :do (incf ans (- y x)))
  (format t "~A~%" ans))


Measured memory_bytes: 83952
n,m,x = map(int,input().split())
price = []
A = []
for i in range(n):
    l = list(map(int,input().split()))
    price.append(l[0])
    A.append(l[1:])
# print(A,price)

mini = 10**7

for biti in range(1<<n):
    comprehension = [0]*m
    value = 0
    for i in range(n):
        if (biti >> i & 1):
            for j in range(m):
                comprehension[j] += A[i][j]
            value += price[i]
    flag = True
    for com in comprehension:
        if com < x:
            flag = False
    if flag:
        mini = min(mini,value)
if mini == 10**7:
    print(-1)
else:
    print(mini)

Measured memory_bytes: 73756
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,x=0;
    cin>>a>>b>>c;
    for(int i=0;i<c;i++){
        b=b-a;
        if(b<0)
           break;
        x++;
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;

int main(){
    int N;
    cin>>N;
    int ans=N;
    int A[100001]={};
    
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        A[a]++;
    }
    
    for(int i=0; i<=100000; i++){
        if(A[i]>=3){
            ans -= A[i] - (2-A[i]%2);
            A[i] = 2 - A[i]%2;
        }
    }
    
    
    int l=0, r=100000;
    while(l<r){
    
        if(A[l]==2 && A[r]==2){
            A[l]=1;
            A[r]=1;
            ans-=2;
        }
        
        while(A[l]<=1 && l<100000){
            l++;
        }
        while(A[r]<=1 && r>=1){
            r--;
        }
    }
    
    for(int i=0; i<=100000; i++){
        if(A[i]==2){
            ans-=2;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int main () {
  int n;
  int sum, max_sum;

  while(cin >> n, n){
    vector<int> a;
    for(int i = 0; i < n; i++){
      int temp;
      cin >> temp;
      a.push_back(temp);
    }

    max_sum = a[0];

    for(int begin = 0; begin < n; begin++){
      sum = 0;
      for(int end = begin; end < n; end++){
        sum += a[end];
        if (max_sum < sum){
          max_sum = sum; 
        }
      }
    }

    cout << max_sum << endl;
  }
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

ll x[MAXN], y[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%lld%lld", &x[i], &y[i]);
	}
	int ans = n;
	REP(i, 0, n) {
		REP(j, 0, n) {
			if (i == j) {
				continue;
			}
			ll dx = x[i] - x[j], dy = y[i] - y[j];
			int saved = 0;
			REP(k, 0, n) {
				REP(l, 0, n) {
					if (x[k] - x[l] == dx && y[k] - y[l] == dy) {
						saved++;
					}
				}
			}
			ans = min(ans, n - saved);
		}
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, a, odd = 0, t4 = 0;
    cin >> N;
    REP(i, N) {
        cin >> a;
        if (a % 4 == 0) t4++;
        else if (a % 2 != 0) odd++;
    }

    if (t4 >= odd || (t4 + odd == N && t4 + 1 == odd)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256