akhauriyash/Code-Regression huggingface dataset:
N = int(input())

count = 0
if N % 4 == 0 or N % 7 == 0:
    print("Yes")
elif N < 4:
    print("No")
else:
    while N > 4:
        N = N - 4
        if N % 7 == 0:
            print("Yes")
            count += 1
            break
    if count == 0:
        print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
	int n, t;
	cin >> n >> t;
	int a[n];
	
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
 
	int ans = 0;
	for(int i=0; i<n-1; i++){
		ans += min(t, a[i+1]-a[i]);
	}
 
	cout << ans+t << endl;
 
	return 0;
}

Measured memory_bytes: 1024
import 'dart:io';
 
void main(List<String> args) {
  List<int> N = stdin.readLineSync().split(' ').map((i) => int.parse(i)).toList();
  List<int> A = stdin.readLineSync().split(' ').map((i) => int.parse(i)).toList();
  int sum = 0;
  for(int i=0; i<N[1]; ++i) sum = sum + A[i];
  sum = N[0] - sum;
  if(sum<0) sum = -1;
  print(sum);
}

Measured memory_bytes: 14632
from itertools import accumulate

n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for i in range(q)]

ans = [0] * n
for i in range(n - 1):
    if s[i] == "A" and s[i + 1] == "C":
        ans[i + 1] = 1
        
ans = list(accumulate(ans))
for i in lr:
    print(ans[i[1]-1]-ans[i[0]-1])

Measured memory_bytes: 32384
#include <iostream>
using namespace std;
int main(void){
    long long int d;
    cin >> d;
    if (d == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }else if (d == 23){
        cout << "Christmas Eve Eve" << endl;
    }else if (d == 24){
        cout << "Christmas Eve" << endl;
    }else{
        cout << "Christmas" << endl;
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int n;
    cin >> n;
    string ans;
    if(!n){
        ans = "0";
        cout << ans << endl;
        return 0;
    }
    while(n!=0){
        int rest = n%2;
        if(rest<0)rest+=2;

        n = (n-rest)/(-2);

        ans = (char)('0'+rest) + ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        Integer a[]=new Integer[N];
        for(int i=0;i<N;i++){
            a[i]=sc.nextInt();
        }
        Arrays.sort(a,Comparator.reverseOrder());

        int Alice=0;
        int Bob=0;
        for(int i=0;i<N;i+=2){
            Alice+=a[i];
        }
        for(int i=1;i<N;i+=2){
            Bob+=a[i];
        }
        System.out.println(Alice-Bob);
    }
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<int> p(n);
    vector<int> pos(n+1);
    rep(i,n){
        cin >>p[i];
        pos[p[i]] = i;
    }

    set<int> s;
    const int L = -1, R = n;
    s.insert(L);
    s.insert(R);
    rep(i,n) s.insert(i);

    ll ans = 0;
    for(int i=1; i<=n; ++i){
        auto itr = s.lower_bound(pos[i]);
        --itr;
        int l = *itr;
        int r = *s.upper_bound(pos[i]);

        ll ct = 0;
        if(l != L){
            --itr;
            ll b = l-(*itr);
            ct += b*(r-pos[i]);
        }
        if(r != R){
            itr = s.upper_bound(pos[i]);
            ++itr;
            ll b = (*itr)-r;
            ct += b*(pos[i]-l);
        }

        ans += ct*i;
        s.erase(pos[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

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

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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

void dump_line(int *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

ll mypow(ll x,ll n){
	if(n==0) return 1;
	ll res=mypow(x*x,n/2);
	if(n&1) res=res*x;
	return res;
}

ll mod_pow(ll x,ll n,ll mod){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2,mod);
	if(n&1) res=res*x%mod;
	return res;
}

int n;

int f(ll num,bool ok){
	if(num > n) return 0;
	if(!ok){
		ll tmp=num;
		bool check[3]={};
		while(tmp>=3){
			if(tmp%10==3) check[0]=true;
			else if(tmp%10==5) check[1]=true;
			else if(tmp%10==7) check[2]=true;
			tmp/=10;
		}
		int i;
		for(i=0;i<3;i++) if(!check[i]) break;
		if(i==3) ok=true;
	}
	return f(num*10+3,ok)+f(num*10+5,ok)+f(num*10+7,ok)+ok;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n;
	cout << f(3,false)+f(5,false)+f(7,false) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j)
                continue;
            double tmp = 0;
            for (int k = 0; k < d; k++)
            {
                tmp += (double)(x[i][k] - x[j][k]) * (double)(x[i][k] - x[j][k]);
            }
            if (ceil(sqrt(tmp)) == floor(sqrt(tmp)))
                ans++;
        }
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
public class ABC136B {
    public static void Main() {
        int K, X;
        string[] str = Console.ReadLine().Split(' ');
        K = int.Parse(str[0]);
        X = int.Parse(str[1]);

        int min = X - K + 1;
        if (min < -100000) min = -1000000;
        int max = X + K - 1;
        if (max > 1000000) max = 1000000;

        for (int i = min; i <= max; i++) {
            Console.Write(i);
            if (i != max) Console.Write(" ");
        }
    }
}


Measured memory_bytes: 11092
n, m = map(int,input().split())
A = [[] for _ in range(n)]
for i in range(n):
    A[i] = input()
B = [[] for _ in range(m)]
for i in range(m):
    B[i] = input()
    
flag = False
for tate_begin in range(n-m+1):
    for yoko_begin in range(len(A[0])-len(B[0])+1):
        for check in range(m):
            a_yoko = A[tate_begin+check][yoko_begin:yoko_begin+len(B[0])]
            if a_yoko != B[check]:
                break
        else:
            flag = True
            print('Yes')
    if flag:
        break
else:
    print('No')

Measured memory_bytes: 9140
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

string s;

vii v[26];

int dp[1000005];
int to[1000005];
int to1[1000005];
int main()
{ios_base::sync_with_stdio(false);
cin>>s;
int n=s.length();
rep(i,0,n-1)v[s[i]-'a'].pb(i);

string ans;


/*while(1)
{
	int mx=0;
	char c;
	rep(i,0,25)
	{
		int id=lower_bound(all(v[i]),ptr)-v[i].begin();
		if(id>=v[i].size())
		{
			c=(char)('a'+i);
			ans+=c;
			ol(ans);
			return 0;
		}
		id=v[i][id];
		if(id>=mx)
		{
			mx=id;
			c=(char)('a'+i);
		}
	}
	ans+=c;
	ptr=mx+1;
}*/

ren(i,n-1,0)
{
	dp[i]=1;
	int mn=1e9+7;
	rep(j,0,25)
	{
		int id=lower_bound(all(v[j]),i+1)-v[j].begin();
		if(id>=v[j].size())
		{
			if(mn!=1)
			{
				mn=1;
				to[i]=j;
				to1[i]=n;
			}
		}
		else
		{
			id=v[j][id];
			if(dp[id]<mn)
			{
				mn=dp[id];
				to[i]=j;
				to1[i]=id;
			}
		}
	}
	dp[i]+=mn;
}

rep(i,0,25)
{
	if(v[i].size()==0)
	{
		ol((char)('a'+i));
		return 0;
	}
}


int mn=1e9+7,st=0;

rep(i,0,25)
{
	if(dp[v[i][0]]<mn)
	{
		mn=dp[v[i][0]];
		st=i;
	}
}



int ptr=v[st][0];

while(1)
{
	if(ptr>=n)break;
	ans+=s[ptr];
	if(to1[ptr]>=n)
	{
		ans+=(char)('a'+to[ptr]);
	}
	ptr=to1[ptr];
}
ol(ans);

return 0;
}



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

l = [0] * 1000001

ans = 0

for i in range(n):
    l[a[i]] += 1

for i in range(1, 1000001):
    if l[i] > 0:
        if l[i] == 1:
            ans += 1
        for j in range(2, 1000000//i + 1):
            l[i * j] = 0

print(ans)

Measured memory_bytes: 96764
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n,m,a,b,c,d,h,w,x,y;
string str;

signed main(){
  string cod="YAKI";
  int ans = 2;
  cin >> str;
  FOR(i,4){
    if(str[i]!=cod[i]) ans=0;
  }
  cout << (ans==2 ? "Yes" : "No" ) fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	int a[5];
	int k,i;
	for (i = 0; i < 5; i++) {
		cin >> a[i];
	}
	cin >> k;
	if (a[4] - a[0] <= k) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  for (int i = 1; i < 2000; i++) {
    if (int(i * 0.08) == A && int(i * 0.1) == B) return cout << i << "\n", 0;
  }
  cout << -1 << "\n";
}

Measured memory_bytes: 256
n=(int)(input())
a=list(map(int, input().split(" ")))
times = (int)(input())
temp = [0 for i in range(10 ** 5 + 1)]
samu = sum(a)
for i in a:
    temp[i] += 1
for i in range(times):
    moto, saki = map(int, input().split(" "))
    samu += (saki - moto) * temp[moto]
    temp[saki] += temp[moto]
    temp[moto] = 0
    print(samu)

Measured memory_bytes: 81104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUF_SIZE 200002

int main(void) {
  FILE* fp;
  fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char *tmp; int s;
  int zone = 0;
  int pos_a;
  int pos_z;
  for(tmp = line, s = 0; *tmp != '\n'; tmp++, s++) {
    if(*tmp == 'A' && !zone) {
      pos_a = s;
      zone = ~zone;
    } else if(*tmp == 'Z' && zone) {
      pos_z = s;
    }
  }
  printf("%d\n", pos_z - pos_a+1);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<char,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);
using namespace std;

int main( ) {
    ll A;
    double B;
    cin>>A>>B;
    ll C=B*100+0.5;
    ll D=A*C;
    ll E=D/100;
    printf("%lld\n",E);
    }


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 200005
int n;
string s;
int a, b, c, d;

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

    cin >> n;
    cin >> a >> b >> c >> d;
    cin >> s;
    --a; --b; --c; --d;

    FOR(i, a, c){
        if(s[i] == '#' && s[i+1] == '#'){
            cout << "No\n";
            return 0;
        }
    }
    FOR(i, b, d){
        if(s[i] == '#' && s[i+1] == '#'){
            cout << "No\n";
            return 0;
        }
    }
    if(c < d){
        cout << "Yes\n";
        return 0;
    }
    FOR(i, b, d){
        if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n;
  cin >> n;
  int ans=0;
  int digit1=0;
  int digit2=0;
  int digit3=0;

  for(int i=n;i<1000;i++){
    digit3=i/100;
    digit2=(i/10)%10; 
    digit1=i%10;
    if(digit3==digit2 and digit2==digit1){
      ans=digit3*100+digit2*10+digit1;
      break;
    }
  }

  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(void)
{
    char t[200001];
    int n;
    scanf("%s", t);
    n = strlen(t);

    rep(i, n) if (t[i] == '?')
        t[i] = 'D';

    printf("%s\n", t);
    return 0;
}

Measured memory_bytes: 1840
/*                                                                                 
	Author :- Gaurang_Kothiya
	
	Quote :- " Practice makes a man perfect. "		
*/  
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9;
const int inf64= 1e18;
const int MOD= 1e9 +7;


void Solve()
{
	int n;
	cin>>n;
	v(int) a(n);
	fe(x,a) cin>>x;
	sort(rall(a));
	
	if(n==1)
	{
		cout<<0;
		return;
	}
	if(n==2)
	{
		cout<< a[0] ;
		return;
	}

	int ans=a[0];
	int res=0;
	int i1=1;
	f(i,1,n-2)
	{
		res++;
		ans += a[i1];
		if(res==2)
		{
			res=0;
			i1++;
		}
	}
	cout<<ans;
}
 
signed main() 
{
	speed		

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

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

int a[55];

int main(){
	int n, p, cnt1, cnt2;
	long long ans;
	scanf("%d %d",&n,&p);
	cnt1 = cnt2 = 0;
	for (int i = 1; i <= n; i++){
		scanf("%d",&a[i]);
		if (a[i] & 1) cnt1++;
		else cnt2++;
	}
	if (p == 1 && cnt1 == 0) printf("0\n");
	else{
		ans = 1;
		for (int i = 1; i <= max(cnt1 - 1, 0) + cnt2; i++) ans *= 2;
		printf("%lld\n", ans);
	} 
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;
/*
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int win,cur;
    cin>>win>>cur;
    win = (win - 2*cur);
    if(win < 0){
        cout<<"0\n";
    }
    else{
        cout<<win<<"\n";
    }
    return 0;
}
*/
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    int a[n+2];
    for(int i=0;i<n;i++){
        cin>>a[i];

    }
    ll int sum =0;
    for(int i=0;i<n;i++){
        for(int j = i+1;j<n;j++){
            sum += a[i] * a[j];

        }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() { 
  int a;
  int b;
    
  cin >> a >> b;
  
  if (a + b % 2 == 0) {
    cout << a + b / 2 << endl;
  }
  else {
    cout << (a + b + 1) / 2  << endl;
  }  
}

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

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

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    cout << sum - n << endl;
}


Measured memory_bytes: 256
#maspyさんを参考に
import sys
#import numpy as np
#from numba import njit
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# この最適化がよくわからん。Numpyループなら行けるらしい
# 400msくらいは最低でもかかるけど、N=10^5でも2でも変わらんと言う
#@njit('(i4[::1],)', cache=True)
def solve(A):
  # エラトステネス古いって値側のバリエーションとして配列をとるんや
  # maxA = 10**6って言うのがポイントっぽいなあ。。
    count = np.zeros(10**6 + 10, np.int32)
    for x in A:
        if count[x] > 1:
            continue
        count[::x] += 1
    ret = 0
    for x in A:
        ret += count[x] == 1
    return ret

def solve2(A):
  count = [0 for _ in range(10**6 + 10)]
  for x in A:
    if count[x] > 1:
      continue
    for a in range(0,len(count),x):
      count[a] += 1
  ret = 0
  for x in A:
    ret += (1 if count[x] == 1 else 0)
  #print(count[:24])
  return ret
  
# このコードわからなかった。一行目のNをSKIPしたリストになっている。。
#A = np.array(read().split(), np.int32)[1:]
N = int(input())
A = list(map(int, input().split()))
# この手法だとソート不要なのか？？だから早いのか？？
print(solve2(sorted(A)))


Measured memory_bytes: 33052
import math

arr = [int(input()) for _ in range(5)]

br = 0
last = 0
for r in range(1, 10):
    for i in range(5):
        if((arr[i] % 10) == r):
            last = i
            br = 1
            break
        pass
    if(br == 1):
        break
    pass

time = 0
for i in range(5):
    time += math.ceil(arr[i]/10) * 10

time += arr[last] - math.ceil(arr[last]/10) * 10

print(time)


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

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
int A[100000];
vector<P> starts[100000];
vector<P> eds[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  // (l, r], sum(x-l-1)
  cin >> N >> M;
  rep(i, N) cin >> A[i], A[i]--;
  long long S = 0;
  long long e = 0;
  long long num = 0, T = 0;
  rep(i, N-1) {
    int s = A[i], t = A[i+1];
    if (s > t) t += M;
    starts[s].pb(P(s, t));
    eds[t%M].pb(P(s, t));
    S += (t-s);
    if (t >= M) {
      num++;
      T += s+1;
      e += M;
    }
  }
  long long m = S;
  rep(x, M) {
    int prf = e + num*x - T;
    m = min(m, S - prf);
    for (P p : eds[x]) {
      int l = p._1, r = p._2;
      if (r >= M) e -= M;
      T -= l+1;
      num--;
    }
    for (P p : starts[x]) {
      int l = p._1, r = p._2;
      //if (r >= M) e += M;
      T += l+1;
      num++;
    }
  }
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 11264
#include <iostream>

using namespace std;

int main(void) {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for(int i=A; i<=B; i++) {
        if(i/10000 == i%10 && (i/1000)%10 == (i%100)/10) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <queue>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

ll H, W, A, B;
int board[1000][1000];


int main(){

    cin >> H >> W >> A >> B;

    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            if(h < B && w < A) cout << "0";
            else if(h >= B && w >= A) cout << "0";
            else cout << "1";
        }
        cout << endl;
    }

}

Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  if (n == 2) {
    cout << "-1\n";
    return 0;
  }
  vector<int> a(n), cnt(n, 0);
  REP(i, n) {
    cin >> a[i]; --a[i];
    ++cnt[a[i]];
  }
  map<int, set<int> > mp;
  REP(i, n) mp[cnt[i]].emplace(i);
  vector<int> b;
  set<int> st;
  REP(i, n) st.emplace(i);
  REP(i, n - 8) {
    if (mp.rbegin()->first == n - 1 - i) {
      assert(mp.rbegin()->second.size() == 1);
      b.emplace_back(*mp.rbegin()->second.begin());
    } else if (i == 0 || a[b[i - 1]] != *st.begin()) {
      b.emplace_back(*st.begin());
    } else {
      b.emplace_back(*next(st.begin()));
    }
    st.erase(b[i]);
    mp[cnt[b[i]]].erase(b[i]);
    if (mp[cnt[b[i]]].empty()) mp.erase(cnt[b[i]]);
    int A = a[b[i]];
    mp[cnt[A]].erase(A);
    if (mp[cnt[A]].empty()) mp.erase(cnt[A]);
    --cnt[A];
    mp[cnt[A]].emplace(A);
  }
  vector<int> per;
  for (int e : st) per.emplace_back(e);
  int m = per.size();
  do {
    bool ok = (n <= 8 || a[b.back()] != per[0]);
    REP(i, m - 1) ok &= a[per[i]] != per[i + 1];
    if (ok) {
      for (int e : per) b.emplace_back(e);
      break;
    }
  } while (next_permutation(ALL(per)));
  REP(i, n) cout << b[i] + 1 << " \n"[i + 1 == n];
  return 0;
}


Measured memory_bytes: 11392
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int a,b;
    cin>>a>>b;
    if(a>9||b>9)cout<<-1;
    else cout<<(a*b);
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N; std::cin >> N;
    //info[i][j]: i人目が正直の時 j人目は (-1:不明 1:正直 0:不親切)
    std::vector<std::vector<int>> info(N, std::vector<int>(N, -1));
    {
        int A, x, y;
        for(int i(0); i < N; ++i){
            std::cin >> A;
            info[i][i] = 1;
            for(int j(0); j < A; ++j){
                std::cin >> x >> y;
                --x;
                info[i][x] = y;
            }
        }
    }
    int ans(0);
    for(int i(0), i_len(1 << N); i < i_len; ++i){
        std::vector<int> fact(N); 
        int honest(0);
        for(int j(0); j < N; ++j){
            fact[j] = ((i >> j) & 1);
            if(fact[j]) ++honest;
        }

        bool okay(true);
        for(int j(0); j < N; ++j){
            if(!fact[j]) continue;
            for(int k(0); k < N; ++k){
                if(info[j][k] == -1) continue;

                if(info[j][k] != fact[k]){
                    okay = false; break;
                }
            }
            if(!okay) break;
        }
        if(okay) chmax(ans, honest);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int f[120][320],u[120],v[120];
int i,j,k,l,m,n,r,s,t,w;

int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
		scanf("%d%d",&u[i],&v[i]);
	t=u[1];
	for (i=1;i<=n;i++)
		u[i]=u[i]-t,s=s+u[i];
	for (i=0;(i<=n) && (m>=i*t);i++)
	{
		w=min(m-i*t,s);
		memset(f,0,sizeof(f));
		for (j=1;j<=n;j++)
			for (l=w;l>=u[j];l--)
				for (k=i;k>0;k--)
					f[k][l]=max(f[k][l],f[k-1][l-u[j]]+v[j]);
		r=max(r,f[i][w]);
	}
	printf("%d",r);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Ti = Sarray();
            var M = Sarray()[0];
            var Tisum = Ti.Sum();
            for(var i=0;i<M;++i)
            {
                var PX = Sarray();
                var P = PX[0];
                var X = PX[1];
                WriteLine(Tisum - (Ti[P - 1] - X));
            }
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N, M;
const int MAX_M = 10;
int p[MAX_M];

int main(){
  cin >> N >> M;
  set<int> st[M];
  REP(i, M) {
    int k, s;
    cin >> k;
    REP(j, k){
      cin >> s;
      st[i].insert(s - 1);
    }
  }
  REP(i, M) cin >> p[i];

  int ans = 0;

  REP(i, 1 << N) {
    int ct[M];
    REP(k, M) ct[k] = 0;
    REP(j, N) {
      if(i >> j & 1) {
        REP(k, M) {
          if(st[k].find(j) != st[k].end()) {
            ct[k] ++;
          }
        }
      }
    }
    bool flag = true;
    REP(k, M) {
      flag = flag && (ct[k] % 2 == p[k]);
    }
    if(flag) ans++;
  }
  
  cout << ans << endl;

  return 0;
}


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if((x)>(y))(x)=(y)
#define chmax(x,y) if((x)<(y))(x)=(y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// 手前から見ていって同時に回転させる範囲の右端をどこにするかを全探索

int n, r;
string s, t;

void rec(int k, vi a, int c) {
	if (k==n) {
		chmin(r,c);
		return;
	}
	int d = a[k];
	reps(i,k,n) a[i] = (a[i]-d+10)%10, rec(k+1,a,c+(d!=0));
}

signed main() {
	while (1) {
		cin >> n;
		if (n==0) break;
		cin >> s >> t;
		vi a;
		r = inf;
		rep(i,n) a.pb((t[i]-s[i]+10)%10);
		rec(0,a,0);
		cout << r << ln;
	}
}


Measured memory_bytes: 3012
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
#define exp 1e-10
using namespace std;
const int maxn=1e5+1;
int main(){
	long long n;
	cin >> n;
	if(n==1)cout << 0 << endl;
	else cout << (1+n-1)*(n-1)/2 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f;

int n,a[30],m,p[20];
char s[200];

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
    	scanf("%s",s+1);
    	for(int j=1;j<=m;j++)a[s[j]-'a'+1]++;
    }
    for(int i=1;i<=(n+1)/2;i++){
    	for(int j=1;j<=(m+1)/2;j++){
    		int num=1;
    		if(n-i+1!=i)num*=2;
    		if(m-j+1!=j)num*=2;
    		p[num]++;
    	}
    }
    //for(int i=1;i<=4;i++)printf("p[%d]=%d\n",i,p[i]);
    bool ok=1;
    //for(int j=1;j<+26;j++)printf("a[%d]=%d\n",j,a[j]);
    for(int i=4;i>=1;i--){
    	for(int j=1;j<=26;j++)if(a[j]>=i){
			int t=min(p[i],a[j]/i);
			p[i]-=t;
			a[j]-=t*i;
		}//printf("p[%d]=%d\n",i,p[i]);
    	if(p[i])ok=0;
    }
    if(ok)printf("Yes");else printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAX = 1001;

int main(){
  int dp[MAX][MAX];
  int t;

  cin >> t;
  while(t--){
    string a,b;

    memset(dp,0,sizeof(dp));

    cin >> a >> b;
    for(int i = 0 ; i < (int)a.size() ; i++){
      for(int j = 0 ; j < (int)b.size() ; j++){
	if(a[i] == b[j]){
	  dp[i+1][j+1] = dp[i][j] + 1;
	}
	else{
	  dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
	}
      }
    }
    cout << dp[a.size()][b.size()] << endl;
  }

  return 0;
}

Measured memory_bytes: 5128
import sys
input = sys.stdin.readline
n = int(input())
H = list(map(int,input().split()))

D = [float("inf") for i in range(n)]
D[0] = 0
for i in range(1, n):
    for j in range(1, 3):
        if i-j >= 0:
            D[i] = min(D[i], D[i-j]+abs(H[i]-H[i-j]))
    
print(D[-1])

Measured memory_bytes: 88412
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	deque<ll> b;
	REP(i, n) cin >> a[i];
	REP(i, n) {
		if (i % 2 == (n - 1) % 2) {
			b.push_front(a[i]);
		}
		else {
			b.push_back(a[i]);
		}
	}
	for (auto it = b.begin(); it != b.end(); it++) {
		cout << *it << " ";
	}
	cout << endl;
	return 0;
}

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

int main(){
    ll K,A,B;cin>>K>>A>>B;
    ll ans=0;
    if(A>=B-1)ans=K+1;
    else if(A-1>=K)ans=K+1;
    else ans=A+(B-A)*((K-A+1)/2)+(K-A+1)%2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n[5],m[5];
	int i;
	int sum[5];
	int max;
	char bannmax,bann[5] = {'A','B','C','D','E'};
	
	while (scanf("%d %d",&n[0],&m[0])!=EOF){
	
		if(n[0] == 0 && m[0] == 0) break;

		sum[0]=n[0]+m[0];
		max=sum[0];
		bannmax='A';

		for (i=1;i<5;i++){
			scanf("%d %d",&n[i],&m[i]);
			sum[i]=n[i]+m[i];
		}

		for(i=0;i<5;i++){
			if(max < sum[i]){
			max=sum[i];
			bannmax=bann[i];
		}
	}

	printf("%c %d\n",bannmax,max);
	}
	
	return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>
#include<string.h>
#include<limits.h>
#define Size 15
long int dist[Size][Size], dp[1 << Size][Size];
int rec(int S, int v, int size);
int main(void)
{
  int i, j, n, e, s, t, d;
  scanf("%d%d\n", &n, &e);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      dist[i][j] = INT_MAX;
    }
  }
  memset(dp, -1, sizeof(dp));
  for (i = 0; i < e; i++) {
    scanf("%d%d%d", &s, &t, &d);
    dist[s][t] = d;
  }
  d = rec(0, 0, n);
  if (d == INT_MAX) printf("-1\n");
  else printf("%d\n", d);
}
int rec(int S, int v, int size)
{
  long int u, res = INT_MAX;
  if (dp[S][v] >= 0) return dp[S][v];
  if (S == (1 << size) - 1 && v == 0) return dp[S][v] = 0;
  for (u = 0; u < size; u++) {
    if (!(S >> u & 1)) {
      long int tmp = rec(S | 1 << u, u, size) + dist[v][u];
      if (res > tmp) res = tmp;
    }
  }
  return dp[S][v] = res;
}


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

using namespace std;

int main(void)
{
    int N, K;
    int p[1000];
    cin >> N >> K;
    for(int i = 0; i < N; i++) {
        cin >> p[i];
    }
    sort(p, p+N);
    cout << accumulate(p, p+K, 0) << endl;
    
    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#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,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;

ll MOD = 1000000007;
int main(){
    
    string S; cin >> S;
    vector<ll> dp(13);
    dp[0] = 1;
    for (auto c: S){
        vector<ll> dp_next(13);
        rep(i,10) if (c=='?' or c == (char)('0'+i))
        {
            rep(d,13)(dp_next[(d*10 + i)%13] += dp[d]) %= MOD;
        }
        dp = dp_next;
    }
    cout << dp[5];
    rn 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if (n % 1000)
        cout << 1000 - n % 1000 << endl;
    else
    {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3696
N, K, S = map(int, input().split())
ans = [0] * N

for i in range(K):
  ans[i] = S
for j in range(N - K):
  if S != 10 ** 9:
    ans[K + j] = S + 1
  else:
    ans[K + j] = 1
  
for i in range(N):
  print(ans[i], end = " ")

Measured memory_bytes: 13136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
const double eps = 1e-8;
const int MOD = 1000000007;
// int main() {
//     cin.tie(0);
//     ios::sync_with_stdio(false);
//     cout << fixed << setprecision(10);
//
// }
ll extended_gcd(ll a, ll b, ll& x, ll& y) {
    // solve ax + by = gcd(a, b)
    if (b == 0) { x = 1; y = 0; return a; }
    ll X, Y;
    ll g = extended_gcd(b, a % b, X, Y);
    x = Y; y = X - a/b * Y;
    return g;
}
int main() {
    ll a, b; cin >> a >> b;
    ll x, y;
    extended_gcd(a, b, x, y);
    cout << x << " " << y << endl;
}



Measured memory_bytes: 3124
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
nums = [None]*n

### BIT 
def init(bit, values):
    for i,v in enumerate(values):
        update(bit,i,v)
#a1 ~ aiまでの和 O(logn)
def query(bit,i):
    res = 0
    while i > 0:
        res += bit[i]
        i -= i&(-i)
    return res

#ai += x(logN)
def update(bit,i,x):
    while i <= len(bit)-1:
        bit[i] += x
        i += i&(-i)
    return


# 転倒数を求める例
def tento(l):
    n = len(l)
    # 1-indexedなので注意
    bit = [0] * (n+1)
    ans = 0
    for i,ind in enumerate(l):
        ans += (i - query(bit, ind+1))
        update(bit, ind+1, 1)
    return ans


def pp(func):
    def wrapped(*args, **keys):
        print(args, keys)
        val = func(*args, **keys)
        print(val)
        return val
    return wrapped

# @pp
def sub(fr, to, bb):
    # frをtoのいずれかに対応付ける
    elist = []
    olist = []
    for ff,bbb in zip(fr, bb):
        if (ff+bbb)%2:
            olist.append(ff)
        else:
            elist.append(ff)

    elist2 = []
    olist2 = []
    for item in to:
        if item%2:
            olist2.append(item)
        else:
            elist2.append(item)
    if len(olist2)==len(olist) and len(elist2)==len(elist):
        olist.sort()
        elist.sort()
        if to[0]%2==0:
            res = [(elist if i%2==0 else olist)[i//2] for i in range(len(to))]
            return res
        else:
            res = [(olist if i%2==0 else elist)[i//2] for i in range(len(to))]
            return res
    else:
        return None
    
    
best = 10**9
for bit in range(1<<n):
    for i in range(n):
        val = b[i] if bit>>i&1 else a[i]
        nums[i] = (val, i, bit>>i&1)
    nums.sort()
    prev, fr, bb = nums[0]
    to = [0]
    fr = [fr]
    bb = [bb]
    valid = True
    array = []
    for i in range(1,n):
        cv, cfr, cbb = nums[i]
        if prev!=cv:
            res = sub(fr, to, bb)
            if res is None:
                valid = False
                break
            array.extend(res)
            prev, fr, bb = cv, [cfr], [cbb]
            to = [i]
        else:
            fr.append(cfr)
            to.append(i)
            bb.append(cbb)
    else:
        res = sub(fr, to, bb)
        if res is None:
            valid = False
        else:
            array.extend(res)
    if valid:
        ans = tento(array)
#         print(array)
        best = min(best, ans)
#         print(nums, ans)
if best==10**9:
    print(-1)
else:
    print(best)

Measured memory_bytes: 79892
//بسم الله الرحمن الرحيم
//* In The Name 0f ALLAH *//* The Most Beneficent *//* The Most Merciful *//*
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el << endl
#define PI 3.141592653589793238
#define _test_ int t; cin >> t; while(t--)
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }
int dx[]={0,0,+1,-1,+1,-1,-1,+1};
int dy[]={+1,-1,0,0,+1,-1,+1,-1};
///*......................*//* LET'S BEGIN (-_^) *//*............................///
const int mx= 100000001;
vector<int>v={1,3,5,7,8,10,12};
vector<int>vi={4,6,9,11};
void _case_()
{
    int x,y;
    cin >> x >> y;
    if(x==2 or y==2)
        cout << "No\n";
    else{
        if(count(v.begin(),v.end(),x) and count(v.begin(),v.end(),y))
            cout << "Yes\n";
        else if(count(vi.begin(),vi.end(),x) and count(vi.begin(),vi.end(),y))
            cout << "Yes\n";
        else cout << "No\n";
    }
}

int main()
{
    //file();
    //sieve();
    optimize();
    //_test_
        _case_();
    return 0;
}

///////////*  N A Y E M  *///////////

Measured memory_bytes: 3656
import * as fs from 'fs';

const input = fs.readFileSync("/dev/stdin", "utf8");

const args = input.split("\n")
const [a, b, c] = args[0].split(" ")
const flag = a == b && b != c || a == c && b != c || b == c && a != b

console.log(flag ? "Yes" : "No")


Measured memory_bytes: 7372
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#define M 1010
#define N 1000000
#define LL long long
#pragma GCC optimize(2)
using namespace std;
string s,t;
int lens,lent,maxx;
int main()
{
	getline(cin,s),getline(cin,t);
	lens=s.size(),lent=t.size();
	for(int i=0;i<lens-lent+1;i++)
	{
		int k=i,sum=0;
		for(int j=0;j<lent;j++)
		{
			if(s[k]==t[j]) sum++;
			k++;
		}
		maxx=max(sum,maxx);
	}
	cout<<lent-maxx;
	return 0;
}
/*
*/


Measured memory_bytes: 3652
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj),rend(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 30);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    fill((T*)array, (T*)(array + N), val);
}int N, M, Q,L,R;
vector<vector<int>> p(510, vector<int>(510, 0));
int main() {
	cin >> N >> M >> Q;
	rep(i, M) { cin >> L >> R; p[L][R]++; }
	req(i, N) req(j, N) p[i][j] += p[i - 1][j];
	req(i, N) req(j, N) p[i][j] += p[i][j- 1];
	rep(i, Q) {
		cin >> L >> R;
		cout << p[R][R] + p[L - 1][L - 1] - p[L - 1][R] - p[R][L - 1] << endl;
	}
}

Measured memory_bytes: 1920
main(){
  long double v,t,y;
  int n;
  while(scanf("%Lf",&v)!=-1)
    {
      t=v/9.8;
      y=4.9*t*t;
      n=1;
      while(y>(5*n-5))
	n++;
      printf("%d\n",n);
    }
  return 0;
}

Measured memory_bytes: 0