akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, V;
	cin >> A >> V;
	int B, W;
	cin >> B >> W;
	int T;
	cin >> T;
	if (V <= W) {
		cout << "NO" << endl;
		return 0;
	}
	int D = abs(A - B);
	int X = V - W;
	if (T * X >= D) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl


using ll = long long;
const ll mod = LLONG_MAX;

int a[100010];
int b[100010];
int main(){
  int n;
  cin>>n;
  rep(i,n){
    cin>>a[i];
    b[a[i]-1]++;
    b[a[i]]++;
    b[a[i]+1]++;
  }
  int ret=0;
  int ans=-1;
  rep(i,100010){
    if(b[i]>ret){
      ret=b[i];
      ans=i;
    }
  }
  cout<<ret<<endl;


}


Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
  int n;cin>>n;
  float s = 0;
  for(int i = 0; n > i; i++){
    int tmp;cin>>tmp;
    s += (float)1/tmp;
  }
  cout << fixed << setprecision(10) << (float)1/s << endl;
}

Measured memory_bytes: 256
S = int(input())
sum_all = 0
sum_fizzbuzz = 0
for i in range(1,S+1):
    sum_all = sum_all + i
    if i % 3 == 0 or i % 5 == 0 or i % 15 ==0:
        sum_fizzbuzz = sum_fizzbuzz + i
#print(sum_all)
#print(sum_fizzbuzz)
print(sum_all - sum_fizzbuzz)

Measured memory_bytes: 9064
S = list(input())
l = len(S)
for i in range(l) :
    S.pop(-1)
    if i % 2 != 0 :
        A = S[0:len(S)//2]
        B = S[len(S)//2:len(S)]
        if A == B :
            print(len(S))
            break
            


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

int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h+2, vector<char>(w+2, '#'));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s.at(i+1).at(j+1);
    }
  }
  int ans = 0;
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if(s[i][j]=='.'){
        queue<vector<int>> q;
        q.push({i,j,0});
        map<vector<int>, int> dic;
        while(!(q.empty())){
          vector<int> nex = q.front();
          q.pop();
          int i_nex = nex[0];
          int j_nex = nex[1];
          if(!(dic.count({i_nex, j_nex}))){
            dic[{i_nex,j_nex}] = nex[2];
            vector<vector<int>> neis = {{1,0},{-1,0},{0,1},{0,-1}};
            for(auto nei:neis){
              int x = i_nex + nei[0];
              int y = j_nex + nei[1];
              if(!(dic.count({x, y})) && s[x][y]=='.'){
                q.push({x,y,nex[2]+1});
              }
            }
          }
        }
        int M = 0;
        for(pair<vector<int>,int> p:dic){
          M = max(M, p.second);
        }
        ans = max(ans, M);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#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>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <bits/stdc++.h>
#include <cmath>
#include <stdio.h>
#include <utility>
using namespace std;
#define ll long long

int main()
{
   int a,b,c;cin>>a>>b;
   b=2*b;
   if(b>=a){
       cout<<"0"<<endl;
   }else{
       cout<<a-b<<endl;
   }
   
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define MAXN 100000
 
int v[MAXN+1];
 
bool cmp(const int &a, const int &b){
    return a>b;
}
 
int main(){
    int n;
    scanf("%d", &n);
 
    for(int i=1; i<=n; i++)
        scanf("%d", &v[i]);
 
    std::sort(v+1, v+n+1, cmp);
 
    int p=1;
    for(int i=2; i<=n; i++)
        if(v[i]>=i)
            p=i;
 
    p--;
 
    int q=p+1;
    for(int i=p+2; i<=n; i++)
        if(v[i]>p)
            q=i;
 
    if((q-p)%2+(v[p+1]-p)%2==2) printf("Second\n");
    else printf("First\n");
 
    return 0;
}

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

using namespace std;

#define endl "\n"

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

	int a,b;
	cin >> a >> b;
	bool arr[4];
	memset(arr,false,sizeof(arr));
	arr[a] = true;
	arr[b] = true;
	for(int i=1; i<=3; i++){
		if(!arr[i]){
			cout << i << endl;
			return 0;
		}

	}


	return 0;
}


Measured memory_bytes: 384
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize,
        a: [f64; n]
    }
    let rev_sum: f64 = a.iter().map(|s| 1. / s).sum();
    let res = 1. / rev_sum;
    println!("{:.12}", res);
}


Measured memory_bytes: 2196
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

ll ceil(ll a, ll b) {  // a÷b以上の最小の整数
    if(b == 0) {
        return 0;
    }
    return (a+b-1)/b;
}
 
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
 
int main() {
    ll h, w, k;
    cin >> h >> w >> k;
    
    vector<string> board(h);
    ll sx, sy;
    rep(i, h) {
        cin >> board[i];
        rep(j, w) {
            if(board[i][j] == 'S') {
                sx = i, sy = j;
            }
        }
    }
    
    vvl dist(h, vl(w, -1));  // dist[i][j] : (sx, sy)から(i, j)への最短距離(未訪問のとき-1)
    queue<P> Q;
    Q.push(make_pair(sx, sy));
    dist[sx][sy] = 0;
    while(!Q.empty()) {
        ll x = Q.front().first;
        ll y = Q.front().second;
        rep(dir, 4) {
            ll nx = x + dx[dir];
            ll ny = y + dy[dir];
            if(nx < 0 || h <= nx || ny < 0 || w <= ny) {
                continue;
            }
            if(board[nx][ny] == '#') {
                continue;
            }
            if(0 <= dist[nx][ny]) {
                continue;
            }
            dist[nx][ny] = dist[x][y] + 1;
            Q.push(make_pair(nx, ny));
        }
        Q.pop();
    }
    
    ll u = INF;
    rep(i, h) {
        rep(j, w) {
            if(abs(sx - i) + abs(sy - j) <= k && dist[i][j] >= 0) {
                chmin(u, min({i, h-1-i, j, w-1-j}));
            }
        }
    }

    out(1 + ceil(u, k));
    re0;
}

Measured memory_bytes: 9460
from heapq import *
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
X=p[:x]
Y=q[:y]
heapify(X)
heapify(Y)

for i in r:
    if X[0]>=i and Y[0]>=i:
        break
    if X[0]<Y[0]:
        heappushpop(X,i)
    else:
        heappushpop(Y,i)

print(sum(X)+sum(Y))

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

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n+1);
    vector<ll> lim(n+1);
    rep(i,n+1) cin>>a[i];
    
    if(n==0){
        if(a[0]>1){
            cout<<-1<<endl;
        }else{
            cout<<1<<endl;
        }
        return 0;
    }
    
    
    lim[0]=1;
    REP(i,n){
        lim[i]=min(INF,(lim[i-1]-a[i-1])*2); //深さiで許されるnodeの数
        if(lim[i]<=0){
            cout<<-1<<endl;
            return 0;
        }
    }
    if(lim[n]-a[n]<0){
            cout<<-1<<endl;
            return 0;
    }
    

    ll ans=0;
    ll t=0; //現状のあるランクのnode数
    for(int i=n;i>=0;i--){
        t=min(t,lim[i]-a[i]);
        t+=a[i];
        ans+=t;
    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4844
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>
#define FIO ios_base::sync_with_stdio(0);  cin.tie(0);
#define PI 3.14159265358979323846
#define mod 998244353
#define ll long long
#define vll vector<long long>  
#define all(c) c.begin(), c.end()
// Used to traverse in any STL container with iterators
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
// Find whether element is present in given container or not
#define present(container, element) (container.find(element) != container.end())
// Finds whether element in present container is present in vector or not
#define cpresent(container, element) (find(all(container),element) != container.end())
using namespace std;




int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    FIO

    ll n;
    cin>>n;
    if(n%1000 )cout<<1000 - n%1000;
    else cout<<0; 
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define MAX_SIZE 1000
#define MAX_BM_LOG 12
#define MAX_BM 4096
#define INF 1000000000

using namespace std;

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

int dp[MAX_SIZE][MAX_BM];
int cost[MAX_SIZE], bms[MAX_SIZE];
int n, m;

int rek(int cur, int bm) {
    if (cur >= m)
        return (bm != (1 << n) - 1) * INF;
    if (dp[cur][bm] == -1)
        dp[cur][bm] = min(rek(cur + 1, bm), cost[cur] + rek(cur + 1, bm | bms[cur]));
    return dp[cur][bm];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(dp, -1, sizeof(dp));
    memset(bms, 0, sizeof(bms));
    cin >> n >> m;
    int b, t;
    for (int ctr1 = 0; ctr1 < m; ++ctr1) {
        cin >> cost[ctr1] >> b;
        for (int ctr2 = 0; ctr2 < b; ++ctr2)
            cin >> t, bms[ctr1] |= (1 << (t - 1));
    }
    cout << (rek(0, 0) >= INF ? -1 : rek(0, 0));
    return 0;
}

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

int main(){
	char x;
	x=getchar();
	switch(x){
		case 'A':x='T';break;
		case 'T':x='A';break;
		case 'C':x='G';break;
		case 'G':x='C';break;
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

typedef pair<int,int> pii;

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

    int n; cin >> n;
    std::vector<ll> a(n); rep(i,n) cin >> a[i];
    
    ll low = 0LL;
    ll high = a[0]*2LL;
    ll mid = (high+low)/2LL;
    if(mid%2==1) mid -=1;
    
    while(low < high){

        bool possible = true;

        ll x = mid;

        rep(i,n){
            x = (a[i]-x/2)*2;
            if(x<0) possible = false;
        }

        if(x==mid && possible){break;}

        //cout << low << " " << mid << " " << high << " " << x << endl;

        if(mid < x){
            low = mid+2;
        } else {
            high = mid-2;
        }

        mid = (high+low)/2;
        if(mid%2==1) mid -=1;
    }

    rep(i,n){
        cout << mid << " ";
        mid = (a[i]-mid/2)*2;
    }
    cout << '\n';


    return 0;
}

Measured memory_bytes: 2176
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

int main(){
  ll n;cin>>n;
  vector<P>res;
  ll dame=n;
  if(n%2==1)dame--;
  for(ll i=1;i<n;i++){
    for(ll j=i+1;j<=n;j++){
      if(j==dame)continue;
      res.push_back(P(i,j));
    }
    dame--;
  }
  cout<<res.size()<<endl;
  for(auto p:res){
    cout<<p.first<<" "<<p.second<<endl;
  }

}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int n = ReadAndParseInt();
            int[] dx = ReadAndParseIntArr();
            int d = dx[0];
            int x = dx[1];
            int[] a = new int[n];
            for(int i=0;i<n;++i)
            {
                a[i] = ReadAndParseInt();
            }

            int sum = x;
            for(int i=0;i<n;++i)
            {
                int tmpa = a[i];
                sum += (d - 1) / tmpa + 1;
            }
            Console.WriteLine(sum);
        }
        
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)


const int MAX_N = 2 * (int) 1e5;
ll N, A[MAX_N], A1[MAX_N];
ll sum = 0;

void solve() {
    sort(A1, A1 + N);
    ll b = A1[N / 2];
    ll ans = 0, ans1 = 0;
    REP(i, N) {
        ans += abs(A[i] - (i + 1) - b);
    }
    cout << ans << endl;
}

int main() {
    cin >> N;
    REP(i, N) {
        cin >> A[i];
        A1[i] = A[i] - (i + 1);
    }
    solve();
    return 0;
}


Measured memory_bytes: 3328
n = int(input())
s = input()

ans = 0
cnt = 0
for i in s:
    if i == "A":
        cnt = 1
    elif cnt == 1 and i == "B":
        cnt = 2
    elif cnt == 2 and i == "C":
        ans += 1
        cnt = 0
    else:
        cnt = 0
print(ans)



Measured memory_bytes: 2940
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 3005;
const ll mm = 1e+18;
void solve()
{
    string s;
    cin>>s;
    int mx=0;
    int x=0;
    rep0(i,3){
        if(s[i]=='R') x++;
        else{
            mx=max(mx,x);
            x=0;
        }
    }
    mx=max(mx,x);
    pr(mx);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

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

int main(){
	long long a[200000], n;
	cin >> n;
	for(long long i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for(long long i = 0; i < n - 1; i++) {
		if (a[i] == a[i+1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;

typedef long long LL;

const int N=100005;

int n;
LL a[N],b[N];
map<LL,int> ma;

LL sqr(LL x)
{
    return x*x;
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        LL x;scanf("%lld",&x);
        for (LL j=2;j*j*j<=x;j++)
            while (x%(j*j*j)==0) x/=j*j*j;
        ma[x]++;a[i]=x;
        LL y=1;
        for (LL j=2;j*j*j<=x;j++)
            if (x%j==0)
            {
                y*=(x%(j*j)==0)?j:j*j;
                while (x%j==0) x/=j;
            }
        if (sqr((LL)sqrt(x))==x) y*=(LL)sqrt(x);
        else y*=x*x;
        b[i]=y;
    }
    int ans=0;
    if (ma[1]) ans++,ma[1]=0;
    for (int i=1;i<=n;i++) ans+=max(ma[a[i]],ma[b[i]]),ma[a[i]]=ma[b[i]]=0;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 14336
#include <stdio.h>

int main(){
    int A[100][100], b[100], c[100] = {0}, n, m, i, j;
    scanf("%d%d", &n, &m);
    for(i=0; i<n; i++) for(j=0; j<m; j++) scanf("%d", &A[i][j]);
    for(j=0; j<m; j++) scanf("%d", &b[j]);
    for(i=0; i<n; i++) for(j=0; j<m; j++) c[i] += A[i][j] * b[j];
    for(i=0; i<n; i++) printf("%d\n", c[i]);
    return 0;
}


Measured memory_bytes: 2104
def main():
    n, a, b = map(int, input().split(" "))
    if a == 0:
        print("0")
        return
    count = (n // (a + b))
    ans = count * a
    if count * (a + b) != n:
        remain = n - (count * (a + b))
        if remain < a:
            ans += remain
        else:
            ans += a
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define int long long
using namespace std;
int n,m,x[1004],y[1004],z[1004],ans,ans2,k,o,ni,a[1004];

signed main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>z[i];
		
	}
	//cout<<1<<endl;
	bitset<5> bits[9];
	for(int i=0;i<8;i++){
		bitset<5> t(i);
		bits[i]=t;
	}
	//cout<<2<<endl;
	for(int i=0;i<8;i++){
		//cout<<3<<endl;
		for(int j=0;j<n;j++){
			a[j]=0;
			if(bits[i][0])a[j]+=x[j];
			else a[j]-=x[j];
			if(bits[i][1])a[j]+=y[j];
			else a[j]-=y[j];
			if(bits[i][2])a[j]+=z[j];
			else a[j]-=z[j];
			
		}
		//cout<<4<<endl;
		sort(a,a+n);
		ans2=0;
		
		for(int j=n-1;j>=n-m;j--)ans2+=a[j];
		//cout<<ans2<<endl;
		ans=max(ans,abs(ans2));
	}
	
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        if(floor(i*1.08)  == n){
            cout << i;
            exit(0);
        }
    }
    cout << ":(";
}


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

signed main(){
    int N;
    cin >>N;
    int all=0;
    map<int,int>memo;
    vector<int>vec(N);
    REP(i,N){
        int a;
        cin >>a;
        vec[i]=a;
        memo[a]++;
    }
    for(auto it=memo.begin();it!=memo.end();it++){
        int b=it->second;
        all +=b*(b-1)/2;
    }
    REP(i,N){
        int c=memo[vec[i]];
        cout<<all-c+1<<endl;
    }
}

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

bool CheckMM(int num){
	if (num <= 12 && 0 < num) return true;
	else return false;
}

int main()
{
	int S = 0;
	std::string ans;
	std::cin >> S;

	int upper = S / 100;
	int lower = S % 100;

	bool up = CheckMM(upper);
	bool lw = CheckMM(lower);
	if (up && lw) ans = "AMBIGUOUS";
	else if (up) ans = "MMYY";
	else if (lw) ans = "YYMM";
	else ans = "NA";

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;

const int N=12;

ll p[N];

int32_t main(){
    string s;
    cin >> s;
    ll n=s.size();
    p[0]=1;
    for (int i=1;i<N;i++){
        p[i]=p[i-1]*2;
    }
    ll ans=0;
    for (int i=0;i<n;i++){
        ll z=s[i]-'0';
        for (int j=i;j<n;j++){
            ans+=z*p[max((ll)0,n-j-2)]*p[i];
            z*=10;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int data[100], n, i, j, mini, swap_times, swap_flag, tmp;
	const char *fmt = "%d";

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", data+i);
	}
	swap_times = 0;
	for (i = 0; i < n; i++) {
		mini = i;
		swap_flag = 0;
		for (j = i; j < n; j++) {
			if (data[j] < data[mini]) {
				mini = j;
				swap_flag = 1;
			}
		}
		tmp = data[i];
		data[i] = data[mini];
		data[mini] = tmp;
		swap_times += swap_flag;
	}
	for (i = 0; i < n; i++) {
		printf(fmt, data[i]);
		fmt = " %d";
	}
	printf("\n%d\n", swap_times);
	return 0;
}

Measured memory_bytes: 600
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val l = (0 until n).map { sc.next().toLong() }
    println(problem175b(n, l))
}

fun problem175b(n: Int, l: List<Long>): Long {
    var count = 0L
    for (i in 0 until n) {
        val a = l[i]
        for (j in i + 1 until n) {
            val b = l[j]
            if (a == b) continue
            for (k in j + 1 until n) {
                val c = l[k]
                if (b == c || a == c) continue
                if (a + b > c && b + c > a && c + a > b) count++
            }
        }
    }
    return count
}

Measured memory_bytes: 38792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanString()

	f := true

	if len(s) == 0 || len(s)%2 == 1 {
		fmt.Fprintln(wr, "No")
		return
	}


	for i := 0; i < len(s)/2; i++ {
		if s[i*2:i*2+2] != "hi" {
			f = false
		}
	}

	if f {
		fmt.Fprintln(wr, "Yes")
	} else {
		fmt.Fprintln(wr, "No")
	}
}


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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i <= n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve() {
    ll a, b, c, x, count = 0;
    cin >> a >> b >> c >> x;
    rep(i, a) {
        rep(j, b) {
            rep(k, c) {
                if(!i && !j && !k)  continue;
                ll total = (500 * i + 100 * j + 50 * k);
                if (total == x) {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}

int main() {
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

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

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    int count = 0;
    if (a == b && b == c && a % 2 == 0)
    {
        cout << -1 << endl;
    }
    else
    {
        while (true)
        {
            if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
            {
                cout << count << endl;
                break;
            }
            else
            {

                ll aa = a;
                ll bb = b;
                ll cc = c;
                a = (bb + cc) / 2;
                b = (aa + cc) / 2;
                c = (aa + bb) / 2;
                count++;
            }
        }
    }
}

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

int main() {
  ll K, A, B;
  cin >> K >> A >> B;
  ll biscuit = 1;
  for (ll i = 0; i < K; i++) {
    if (i < K-1 && biscuit >= A) {
      biscuit += max(B-A,2LL);
      i++;
    }
    else biscuit += 1;
  }
  cout << biscuit << endl;
}


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

int cnt_odd[100010];
int cnt_even[100010];

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

  for (int i = 1; i <= n; i++) {
    int v;
    cin >> v;
    if (i % 2 == 1) {
      cnt_odd[v]++;
    } else {
      cnt_even[v]++;
    }
  }

  // 奇数番目の最頻値、2番目に多い値
  int O1 = 0, O2 = 0;
  // 偶数番目の最頻値、2番目に多い値
  int E1 = 0, E2 = 0;
  for (int i = 1; i <= 100000; i++) {
    if (cnt_odd[O1] < cnt_odd[i]) {
      O2 = O1;
      O1 = i;
    } else if (cnt_odd[O2] < cnt_odd[i]) {
      O2 = i;
    }

    if (cnt_even[E1] < cnt_even[i]) {
      E2 = E1;
      E1 = i;
    } else if (cnt_even[E2] < cnt_even[i]) {
      E2 = i;
    }
  }

  int ans1 = n - cnt_odd[O1] - cnt_even[E1];
  int ans2 = n - cnt_odd[O1] - cnt_even[E2];
  int ans3 = n - cnt_odd[O2] - cnt_even[E1];
  if (O1 != E1) {
    printf("%d", ans1);
  } else {
    printf("%d", min(ans2, ans3));
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

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


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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it = (c).begin(); it != (c).end(); it++)
#define X first
#define Y second

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = (int)1e6 + 1;


int main(void){
    bool isP[N];
    memset(isP, true, N);
    isP[0] = isP[1] = false;
    for(int i = 2; i * i < N; i++) if(isP[i]) for(int j = i * i; j < N; j += i) isP[j] = false;

    for(int a, d, n, res; cin >> a >> d >> n, a; cout << res << endl){
        while(n){
            if(isP[a]) res = a, n--;
            a += d;
        }
    }

    return 0;
}

Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int a;
    cin>>a;
    cout<<3*a*a<<endl;





    return 0;
}


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

int main(){
	long long N;
	cin>>N;
	for(long long i=(long long)sqrt(N);i>0;i--){
		if(N%i==0){
			cout<<N/i-2+i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.Stack;


public class Main {
	String str;
	int s,e;
	String sc;
	String ms;
	int num;
	ArrayList<Integer> list = new ArrayList<Integer>();
	
	public boolean db(int g){
		int m = 0;
		int f = 0;
		for(int i = g;i < str.length();i++){
			switch(str.charAt(i)){
			case '[':
				if(m > 0){
					s = i-1;
					f++;
				}
				m++;
				break;
			case ']':
				if(m < 0){
					e = i+1;
					if(f > 0)
						return true;
				}
				m--;
				break;
			default:
				m = 0;
				break;
			}
		}
		return false;
	}
	
	public void f(){
		sc = "";
		int k,b = 0;
		e = 0;
		num = 0;
		char c;
		while(db(e)){
			list.clear();
			ms = str.substring(s,e);
/*			String[] si = ms.substring(2,ms.length()-2).split("\\]\\[");
			for(int i = 0;i < si.length;i++){
				list.add(Integer.valueOf(si[i]));
			}
			Collections.sort(list);
			k = 0;
			for(int i = 0;i < list.size()/2+1;i++){
				k += list.get(i);
			}
			sc = sc + str.substring(s,m.start()) + "[" + k + "]";
			s = m.end();*/
			for(int i = 0;i < ms.length();i++){
				c = ms.charAt(i);
				if(0 <= c-'0' && c-'0' <= 9){
					num = 10*num + (c-'0');
				}
				else{
					if(num > 0){
						list.add(num);
						num = 0;
					}
				}
			}
			Collections.sort(list);
			k = 0;
			for(int i = 0;i < list.size()/2+1;i++){
				k += list.get(i);
			}
			sc = sc + str.substring(b,s) + "[" + k + "]";
			b = e;
		}
		sc = sc + str.substring(b,str.length());
		str = sc;
	}
	
	public void fs(){
	/*	int s = 0;
		String sc = "";
		String ms;
		Pattern p = Pattern.compile("\\[\\d*\\]");
		Matcher m = p.matcher(str);
		while(m.find()){
			ms = m.group();
			sc = sc + str.substring(s,m.start()) + "[" + (Integer.valueOf(ms.substring(1,ms.length()-1))/2+1) + "]";
			s = m.end();
		}
		sc = sc + str.substring(s,str.length());
		str = sc;*/
		sc = "";
		char c;
		num = 0;
		for(int i = 0;i < str.length();i++){
			c = str.charAt(i);
			if(0 <= c-'0' && c-'0' <= 9){
				num = 10*num + (c-'0');
			}
			else{
				if(num > 0){
					sc = sc + (num/2+1);
					num = 0;
				}
				sc = sc + c;
			}
		}
		str = sc;
	}
	
	public static void main(String[] args) {
		int n;
		String str;
		Stack<Integer> s = new Stack<Integer>();
		ArrayList<Integer> list = new ArrayList<Integer>();
		int num = 0;
		Scanner in = new Scanner(System.in);
		for(n = Integer.valueOf(in.nextLine());n > 0;n--){
			str = in.nextLine();
			for(int i = 0;i < str.length();i++){
				switch(str.charAt(i)){
				case '[':
					s.push(-1);
					break;
				case ']':
					if(num == 0){
						list.clear();
						while(s.peek() > 0){
							list.add(s.pop());
						}
						s.pop();
						Collections.sort(list);
						for(int k = 0;k < list.size()/2+1;k++)
							num += list.get(k);
						s.push(num);
						num = 0;
					}
					else{
						s.pop();
						s.push(num/2+1);
						num = 0;
					}
					break;
				default:
					num = 10*num + (str.charAt(i)-'0');
					break;
				}
			}
			System.out.println(s.pop());
		}
	}

}

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

int main() {
  int N,c;
  cin >> N;
  vector<int> vec(N);
  int cnt = 1;
  
  for (int i = 0;i<N;i++){
    int a;
    cin >>a;
    vec.at(i) = a;
    if (vec.at(0) == 2){
      cout << 1 << endl;
      break;
    }
  }
  
  c = vec.at(0);
  
  for (int i = 0;i<N;i++){   
    if (vec.at(0) != 2) {
      if (c != 2){
        cnt++;
        c = vec.at(c-1);
      }
      else if(c == 2){
        cout << cnt << endl;
        break;
      }
      if ( i == N-1 && c != 2){
        cout << -1 << endl;
        break;
      }
    }
  }
  
  
}




Measured memory_bytes: 3788
//  __      __       .__           .____________                   __________        __ ________   __                 
// /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
// \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
//  \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
//   \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
//        \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define endl '\n'

using namespace std;

void solve()
{
    int n;
    cin >> n;
    while(n)
    {
        if(n % 10 == 7)
        {
            cout << "Yes" << endl;
            return;
        }
        n /= 10;
    }
    cout << "No" << endl;
}

int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3596
import sys
n,m=map(int,input().split())
if m<=n:
  print(0)
  sys.exit()
x=sorted(list(map(int,input().split())))
l=[0]*(m-1)
for i in range(m-1):
  l[i]=x[i+1]-x[i]
l.sort()
s=0
for i in range(n-1):
  s+=l[m-2-i]
print(x[m-1]-x[0]-s)

Measured memory_bytes: 13960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x;
	cin >> x;
	cout << abs(1 - x) << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF=1e9+7,MAXK=1e5+10;
int K;
bool vis[MAXK];
deque<pair<int,int> > dq;
int main(){
	scanf("%d",&K);
	dq.push_front(make_pair(1,1));
	while(dq.size()){
		pair<int,int> cur=dq.front();
		dq.pop_front();
		vis[cur.first]=1;
		if(!cur.first){
			printf("%d",cur.second);
			return 0;
		}
		if(!vis[cur.first*10%K])
			dq.push_front(make_pair(cur.first*10%K,cur.second));
		if(!vis[(cur.first+1)%K])
			dq.push_back(make_pair((cur.first+1)%K,cur.second+1));
	}
	return 0;
}

Measured memory_bytes: 896
# ARC072C - Sequence (ABC059C)
def main():
    n = int(input())
    lst = list(map(int, input().rstrip().split()))
    cnt = [0] * 2
    
    # start with positive number
    cur = 0
    for i, j in enumerate(lst):
        cur += j
        if i % 2 == 0 and cur <= 0:
            cnt[0] += abs(cur) + 1
            cur = 1
        elif i % 2 == 1 and cur >= 0:
            cnt[0] += abs(cur) + 1
            cur = -1

    # start with negative number
    cur = 0
    for i, j in enumerate(lst):
        cur += j
        if i % 2 == 0 and cur >= 0:
            cnt[1] += abs(cur) + 1
            cur = -1
        elif i % 2 == 1 and cur <= 0:
            cnt[1] += abs(cur) + 1
            cur = 1

    print(min(cnt))


if __name__ == "__main__":
    main()

Measured memory_bytes: 14468
from itertools import combinations
INF = int(1e18)
def main():
    n, k = map(int, input().split())
    a = [int(i) for i in input().split()]
    p = [i for i in range(1,n)]
    #必ず見えるようにする建物の組合せを決める
    #左端の建物は常に見えるので注意する
    ans = INF
    for i in combinations(p, k-1):
        s = set(i)
        cost = 0
        mx = a[0]
        for j in range(1, n):
            if j in s:
                if a[j] > mx:
                    mx = a[j]
                    continue
                mx += 1
                cost += mx-a[j]
            mx = max(mx, a[j])
        ans = min(cost, ans)                
    print(ans)
main()

Measured memory_bytes: 3064
#include <iostream>

int main()
{
	int K, X = 0;
	std::cin >> K >> X;

	for (int i = X - (K - 1); i < X + K; ++i)
	{
		if (i < -1000000 || i>1000000)
		{
			continue;
		}

		std::cout << i << " ";
	}

	std::cout << "\n";

	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.math;

void main() {
	string[] inputs = split(readln());
	int X = to!int(inputs[0]);
	int A = to!int(inputs[1]);
	int B = to!int(inputs[2]);
	
	if(A - B >= 0) "delicious".writeln;
	else if(X >= abs(A - B)) "safe".writeln;
	else "dangerous".writeln;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const int INF = 1e9+1;


int main() {
    int N;
    cin >> N;
    
    vector<int> d(N);
    
    for (int i =0; i < N; i++) cin >> d[i];

    int res = 0;
    for (int i =0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            res += d[i] * d[j];
        }
    }
    cout << res << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  cout << ((n == m) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int dp[1000],i,j,k,l,m,n;
    for(i=0;i<=200;i++)
    dp[i]=0;
    dp[4]=1;
    dp[7]=1;
    for(i=0;i<=200;i++)
    {
        if(dp[i])
        {
            dp[i+4]=1;
            dp[i+7]=1;
        }
    }
    cin>>n;
    if(dp[n])
    printf("Yes");
    else
    printf("No");
    return 0;
}

Measured memory_bytes: 256
def solve():
    from itertools import permutations
    from sys import stdin
    f_i = stdin
    
    while True:
        n = int(f_i.readline())
        k = int(f_i.readline())
        if n == 0:
            break
        
        cards = []
        for i in range(n):
            cards.append(f_i.readline().rstrip())
        
        nums = set(''.join(t) for t in permutations(cards, k))
        
        print(len(nums))

solve()


Measured memory_bytes: 6040
// https://beta.atcoder.jp/contests/abc107

#define SUBMIT
#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <map>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_N = 100000;
int N, K;
int x[MAX_N];

// left_time[i] i個原点から左に向かっていったときに必要な時間
vector<int> left_time;
vector<int> right_time;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    string program_input_str = R"(1 1
0
)";
    stringstream stream(program_input_str);
#endif
    int left_count = 0, right_count = 0;
    stream >> N >> K;
    for (int i = 0; i < N; ++i) {
        stream >> x[i];
        if (x[i] < 0) {
            left_count++;
            left_time.push_back(abs(x[i]));
        }
        else if (0 < x[i]) {
            right_count++;
            right_time.push_back(x[i]);
        }
        else K -= 1;
    }

    reverse(left_time.begin(), left_time.end());
    left_time.insert(left_time.begin(), 0);
    right_time.insert(right_time.begin(), 0);

    int ans = numeric_limits<int>::max();
    for (int i = 0; i < left_time.size(); ++i) {
        auto r = K - i;
        if (right_time.size() <= r) continue;

        auto cost = min(2 * abs(left_time[i]) + abs(right_time[r]), abs(left_time[i]) + 2 * abs(right_time[r]));
        ans = min(ans, cost);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1404
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
//#include <iomanip>
//#include <bits/stdc++.h>

using namespace std;

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



Measured memory_bytes: 3076
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=105;

int n,t[N];

int main()
{
	scanf("%d",&n);int mx=0;
	for (int i=1;i<=n;i++)
	{
		int x;scanf("%d",&x);
		t[x]++;mx=max(mx,x);
	}
	if (!(mx&1)&&t[mx/2]!=1||(mx&1)&&t[(mx+1)/2]>2) {puts("Impossible");return 0;}
	for (int i=(mx+1)/2+1;i<=mx;i++) if (t[i]<2) {puts("Impossible");return 0;}
	for (int i=1;i<(mx+1)/2;i++) if (t[i]) {puts("Impossible");return 0;}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is #" << (x) <<"#" <<endl
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 1e3+7;
const ll inf = 1e18+7;

string tablero[MAX];
ll dp[MAX][MAX];

ll DP(ll x,ll y){
  if (x<0||y<0||tablero[x][y] == '#') return 0;
  ll &ans = dp[x][y];
  if(ans!=-1) return ans;
  return ans = (DP(x-1,y)+DP(x,y-1))%mod;
}

int main() {
  fastio;
  ll h,w;
  cin>>h>>w;
  f(i,0,MAX){
    f(j,0,MAX) dp[i][j]=-1;
  }
  f(i,0,h){
    cin>>tablero[i];
  }
  dp[0][0] = 1;
  DP(h,w);
  cout<<DP(h-1,w-1)%mod<<"\n";
  return 0; 
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

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

using ll = long long;

template<class T> void chmax(T& a, T b){ if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b){ if (a > b) { a = b; } }

int main() {
    ll a, b;
    string s;
    cin >> a >> s;
    s.erase(s.begin() + 1);
    b = stoi(s);
    cout << a * b / 100 << endl;

    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

	char g[500][500];
char a[500][500], b[500][500];

struct Point{ int x, y; };
int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

void bfs(int h, int w){
	bool dis[500][500] = {{0}};
	queue<Point> q;

	dis[0][0] = true;
	b[0][0] = '#';
	q.push({0,0});

	Point u;
	while(not q.empty()){
		u = q.front(); q.pop();
		rep(i,4){
			Point next;
			next.x = u.x + dx[i];
			next.y = u.y + dy[i];
			if(next.x < 0 || next.x >= w || next.y < 0 || next.y >= h) continue;
			if(not dis[next.y][next.x] && (a[next.y][next.x] == '.' or g[next.y][next.x] == '#')){
				dis[next.y][next.x] = true;
				b[next.y][next.x] = '#';
				q.push(next);
			}
		}
	}
}

int main(){
	int h, w;
	cin >> h >> w;

	rep(i,h){
		cin >> g[i];
	}

	rep(i,h) rep(j,w) a[i][j] = b[i][j] = '.';
	rep(i,h){
		rep(j,w){
			if(g[i][j] == '#'){
				a[i][j] = b[i][j] = '#';
			}
		}
	}
	//rep(i,h){ rep(j,w){ cout << a[i][j]; } cout << endl; }

	for(int i = 1; i < h; i+=2){
		for(int j = 1; j < w - 1; j++){
			a[i][j] = '#';
		}
	}
	//rep(i,h){ rep(j,w){ cout << a[i][j]; } cout << endl; }

	for(int i = 1; i < h - 1; i++){
		if((i - 1) % 4 == 1) a[i][w - 2] = '#';
		if((i - 1) % 4 == 3) a[i][1] = '#';
	}


	bfs(h,w);
	//rep(i,h){ rep(j,w){ if(a[i][j] == '.') b[i][j] = '#'; } }

	//rep(i,h){ rep(j,w){ if(a[i][j] == '#' && b[i][j] == '#') cout << a[i][j]; else cout << '.'; } cout << endl; }

	rep(i,h){ rep(j,w){ cout << a[i][j]; } cout << endl; }
	cout << endl;
	rep(i,h){ rep(j,w){ cout << b[i][j]; } cout << endl; }
}


Measured memory_bytes: 1664