akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
using namespace std::chrono;
const int N = 1e5+5 , M=N,inf=(int)1e9;
const int mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
int ans ;
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
  ll n ;
  int t , a ;
  cin >> n >> t >> a ;
  vector < float > v( n ),cal(n) ;
  for ( int i = 0 ; i < n ;i++) cin >> v[i] , cal[i] = t - (v[i]*0.006) ;
  float minm = abs(a - cal[0] ) ;
  int id = 1 ;
  for( int i = 1 ; i < n ; i++)
  {
      if( minm > abs(a - cal[i])){
        minm = abs(a - cal[i]);
        id = i + 1 ;
      }
  }
  cout << id ;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	int A, B;
	cin >> A >> B;
	
	int ans = 0;

	for (int i = A; i <= B; i++) {
		int n = i;
		int d[5];
		d[0] = (n % 10); n /= 10;
		d[1] = (n % 10); n /= 10;
		d[2] = (n % 10); n /= 10;
		d[3] = (n % 10); n /= 10;
		d[4] = (n % 10); n /= 10;
		if (d[0] == d[4] && d[1] == d[3]) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;

vector<int> G[101010];

int white[101010];

int need[101010];

i64 all[101010];
i64 once[101010];

i64 FF = 0;

void init(i64 ff){
  queue<pair<int,int>> que;
  que.push({ff,-1});
  vector<int> vec;
  while(!que.empty()){
    int v = que.front().first;
    int f = que.front().second;
    que.pop();
    vec.push_back(v);
    for(int to : G[v]){
      if(to == f) continue;
      que.push({to,v});
    }
  }
  reverse(vec.begin(),vec.end());
  for(int i : vec){
    if(white[i] == 1) need[i] = -1;
    for(int to : G[i]){
      if(need[to] == 0) continue;
      if(need[to] == -1) need[i] = -1;
    }
    if(need[i] == 0) need[i] = 1;
  }
}

void dfs1(int v,int f = -1){
  i64 MAX = -1e9;
  i64 sum = 0;
  i64 cnt = 0;
  for(int to : G[v]){
    if(f == to) continue;
    if(need[to] == 1) continue;
    dfs1(to,v);
    sum += all[to];
    MAX = max(MAX , all[to] - once[to]);
    cnt++;
  }
  if(MAX == -1e9){
    all[v] = 2;
    once[v] = 1;
  }
  else{
    all[v] = sum + 2 + ((white[v] + cnt + 1) % 2);
    once[v] = sum - MAX + 1 + ((white[v] + cnt) % 2);
  }
}

i64 ans[101010];

void dfs2(int v,int f = -1,i64 f_all = 0,i64 f_once = 0){
  vector<pair<i64,int>> vec;
  vec.push_back({0,-1});
  i64 sum = 0;
  i64 cnt = 0;
  for(int to : G[v]){
    if(need[to] == 1) continue;
    cnt++;
    if(f == to){
      sum += f_all;
      vec.push_back({f_all - f_once,to});
    }
    else{
      sum += all[to];
      vec.push_back({all[to] - once[to] , to});
    }
  }
  sort(vec.rbegin(),vec.rend());

  ans[v] = sum - vec[0].first + (white[v] + cnt - 1) % 2;

  //cout << v << " " << f_all << " " << f_once << " " << sum << endl;
  for(int to : G[v]){
    if(f == to) continue;
    if(need[to] == 1) continue;
    dfs2(to , v , sum - all[to] + (white[v] + cnt) % 2 + 2, sum - all[to] - vec[vec[0].second == to].first + (white[v] + cnt - 1) % 2 + 1);
  }
}

int main(){
  cin >> N;
  for(int i = 0;i < N - 1;i++){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);		
  }
  {
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0;i < N;i++){
      white[i] = s[i] == 'W';
      cnt += s[i] == 'W';
      if(s[i] == 'W') FF = i;
    }
    if(cnt <= 1){
      cout << cnt << endl;
      return 0;
    }
  }
  init(FF);
  dfs1(FF);
  dfs2(FF);
  i64 res = ans[FF];
  for(int i = 0;i < N;i++){
    if(need[i] == 1) continue;
    res = min(res , ans[i]);
  }
  cout << res << endl;
}


Measured memory_bytes: 33936
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 10000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int main(){
    int count=0;
    string s,a,b;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]!='x') a.push_back(s[i]);
    }

    b=a;
    reverse(a.begin(),a.end());
    if(a!=b) cout<<-1<<endl;
    else{
        int nowend=s.size()-1;
        int nowstart=0;
        while(nowend>nowstart){
            if(s[nowend]==s[nowstart]){
                nowend--;
                nowstart++;
            }else{
                count++;
                if(s[nowend]=='x'){
                    nowend--;
                }else nowstart++;
            }
        }
        cout<<count<<endl;
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int p){
	for(int i=2;i<=sqrt(p);i++){
		if(!p%i)return false;
	}
	return true;
}
int n,m,Q,l,r,a,b,ans[510][510];
signed main(){
	cin>>n>>m>>Q;
	rep(i,m){
		cin>>l>>r;
		ans[l][r]++;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(j)ans[i][j]+=ans[i][j-1];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(j)ans[j][i]+=ans[j-1][i];
		}
	}
	rep(i,Q){
		cin>>a>>b;
		cout<<ans[b][b]-ans[a-1][b]-ans[b][a-1]+ans[a-1][a-1]<<endl;
	}
	return 0;
}

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

typedef long long ll;

ll arr[405];
ll prefix[405];
ll dp[405][405];

ll rekur(int a,int s)
{
	if(s-a==0)return 0;
	if(s-a==1)return arr[a]+arr[s];
	if(dp[a][s]!=-1)return dp[a][s];
	dp[a][s]=0;
	ll temp=(ll)1e18;
	for(int q=a;q<s;q++)
	{
		temp=min(temp,(prefix[q]-prefix[a-1]) + (prefix[s]-prefix[q]) + rekur(a,q) + rekur(q+1,s));
	}
	dp[a][s]=temp;
	return dp[a][s];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll z;
	cin>>z;
	memset(dp,-1,sizeof(dp));
	for(int q=1;q<=z;q++)
	{
		cin>>arr[q];
		prefix[q]=prefix[q-1]+arr[q];
	}
	
	ll ans=rekur(1,z);
	cout<<ans<<endl;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define L (idx*2)
#define R ((idx*2)+1)
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
int n,x[200005],ap,bp,ss,ee;
pii seq[800005][2];
priority_queue<pair<int,pair<pii,pii> > >pq;
void up(int st,int ed,int idx,int pos,int val)
{
    int mid=(st+ed)/2;
    if(st>pos||ed<pos)return;
    if(st==ed)
    {
        seq[idx][pos%2]={val,pos};
        return;
    }
    up(st,mid,L,pos,val);
    up(mid+1,ed,R,pos,val);
    if(seq[L][0].F>seq[R][0].F)
    {
        seq[idx][0]=seq[R][0];
    }
    else
    {
        seq[idx][0]=seq[L][0];
    }
    if(seq[L][1].F>seq[R][1].F)
    {
        seq[idx][1]=seq[R][1];
    }
    else
    {
        seq[idx][1]=seq[L][1];
    }
    return;
}
pii mx(int st,int ed,int idx,int l,int r,int tp)
{
    int mid=(st+ed)/2;
    if(st>r||ed<l)return {imx,imx};
    if(l<=st&&r>=ed)return seq[idx][tp];
    pii a,b;
    a=mx(st,mid,L,l,r,tp);
    b=mx(mid+1,ed,R,l,r,tp);
    if(a.F>b.F)
    {
        return b;
    }
    else
    {
        return a;
    }
}
void pq_push(int st,int ed)
{
    //printf("%d %d\n",st,ed);
    if(ed-st+1<2)return;
    //printf("%d %d\n",st,ed);
    pii a=mx(1,n,1,st,ed,st%2);
    pii b=mx(1,n,1,a.S+1,ed,(st+1)%2);
    pq.push({-a.F,{{st,ed},{a.S,b.S}}});
    return;
}
int main()
{
    for(int i=0;i<800005;i++)seq[i][0]={imx,imx},seq[i][1]={imx,imx};
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x[i]);
        up(1,n,1,i,x[i]);
    }
    pq_push(1,n);
    while(!pq.empty())
    {
        ap=pq.top().S.S.F;
        bp=pq.top().S.S.S;
        ss=pq.top().S.F.F;
        ee=pq.top().S.F.S;
        pq.pop();
        printf("%d %d ",x[ap],x[bp]);
        pq_push(ss,ap-1);
        pq_push(ap+1,bp-1);
        pq_push(bp+1,ee);
    }
}


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


int main(){
    int n,k;cin >> n >> k;
    ll ans = 0;
    for(int b = 1;b <= n;b++){
        int m = n/b;
        int r = n%b;
        ans += m*max(b-k,0) + max(0,r-k+1);
        if(k==0) ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
long long n,k,c[2007][2007];
int main() {
	for(int i=1; i<2007; i++) {
		c[i][i]=c[i][0]=1;
		for(int j=1; j<i; j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	scanf("%d%d",&n,&k);
	int q=n-k;
	if(!q) {
		puts("1");
		for(int i=1; i<k; i++)puts("0");
		return 0;
	}
	printf("%d\n",n-k+1);
	for(int i=2; i<=k; i++) {
		printf("%lld\n",(c[q-1][i]+2*c[q-1][i-1]+c[q-1][i-2])%mod*c[k-1][i-1]%mod);
	}
	return 0;
}

Measured memory_bytes: 30336
#include<cstdio>
int main(){
	int n,k,m=1,i;
	scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++)
	{
		if(m+k<=m*2){
			m=m+k;}
			else{
				m=m*2;
				}
	}

	
	printf("%d",m);
	return 0;
}
	

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main{

	private void solve(){
		int n=gInt();
		int[]a=ints(n).toArray();

		long r=a[0]-1;
		a[0]=1;
		int mincost=1;
		for(int i=1;i<n;++i) {
			if(a[i]<=mincost+1){
				mincost=Math.max(mincost,a[i]);
			}else{
				r+=(a[i]-1)/(mincost+1);
				a[i]=1;
			}
		}
		System.out.println(r);
		System.err.println(Arrays.toString(a));
	}

	public static void main(String[]$){
		new Main().solve();
	}

	static Scanner s=new Scanner(System.in);


	static int gInt(){
		return s.nextInt();
	}
	static long gLong(){
		return s.nextLong();
	}
	static long gDouble(){
		return s.nextLong();
	}


	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

	static class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{

		int to,cur,d;

		Range(int from,int to,int d){
			this.cur=from-d;
			this.to=to;
			this.d=d;
		}

		Range(int n){
			this(0,n-1,1);
		}

		@Override
		public Iterator<Integer> iterator(){
			return this;
		}

		@Override
		public boolean hasNext(){
			return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
		}

		@Override
		public int nextInt(){
			return cur+=d;
		}
	}


	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}

	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}


	static IntStream ints(int n){
		return REPS(n).map(i->gInt());
	}

	static Stream<String> strs(int n){
		return REPS(n).mapToObj(i->s.next());
	}

}


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

int main() {
  
  int a, b;
  cin >> a >> b;
  
  if (a > b) {
    for(int i = 0; i < a; i++) {
      cout << b;
    }
  } else {
    for(int i = 0; i < b; i++) {
      cout << a;
    }
  }
  
}


Measured memory_bytes: 256
N  = int(input())
p_list = list(map(int,input().split()))
cnt = 0
for i, p in enumerate(p_list):
    if i == 0:
        continue
    if i > N-2:
        continue
    if (p_list[i-1] < p  < p_list[i+1]) or (p_list[i-1] > p  > p_list[i+1]):
        #print(p,i)
        cnt +=1
print(cnt)

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdlib.h>
#include<stack>
#include<set>
#include<string.h>
#include<map>
#include<vector>
#define pb push_back
#define ins insert 
#define mp make_pair
#define ll long long 
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define M 10000007
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin>>n;
    ll a[n+1][3],dp[n+1][3];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i+1][0]>>a[i+1][1]>>a[i+1][2];
        dp[i+1][0]=M;
        dp[i+1][1]=M;
        dp[i+1][2]=M;
    }
    dp[1][0]=a[1][0];
    dp[1][2]=a[1][2];
    dp[1][1]=a[1][1];
    for (int i = 2; i <n+1; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            dp[i][j]=max(a[i][j]+dp[i-1][(j+1)%3],a[i][j]+dp[i-1][(j+2)%3]);
        }
    }
    cout<<max3(dp[n][0],dp[n][1],dp[n][2]);
    return 0 ;
}


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

#define int long long
#define REP(i, l, r) REPEAT(i,l,r,true) // [l, r)
#define rep(i, n) REP(i,0,n)           // [0, n)
#define REPEAT(i, l, r, condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n, l, r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...) true
#define showlr(n,l,r) true
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int, int>;

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

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &e:v)is >> e;
    return is;
}

template<class T>
ostream &operator<<(ostream &os, vector<T> v) {
    os << "{";
    for (T &e:v)os << e << (v.size() - (int) (&e - &v[0]) > 1 ? ", " : "");
    os << "}";
    return os;
}

void _DEBUG() {}

template<typename H, typename... T>
void _DEBUG(H a, T...b) {
    cerr << a << (sizeof...(b) ? "," : "\n");
    _DEBUG(b...);
}

inline void in() {}

template<typename H, typename... T>
void in(H &a, T &... b) {
    cin >> a;
    in(b...);
}

inline void out() {}

template<typename H, typename... T>
void out(H a, T... b) {
    cout << a << (sizeof...(b) ? " " : "\n");
    out(b...);
}

template<class T>
void resz(int n, T &v) { v.resize(n); }

template<class H, class... T>
void resz(int n, H &a, T &... b) {
    a.resize(n);
    resz(n, b...);
}

template<typename V, typename H>
void resize(vector<V> &v, const H a) { v.resize(a); }

template<typename V, typename H, typename... T>
void resize(vector<V> &v, const H &a, const T... b) {
    v.resize(a);
    for (auto &v:v) resize(v, b...);
}

const int INF = 1LL << 55;
const int MOD = 1000000007;
const double EPS = 1e-8;

/*------------end of definitions------------*/

int N, M;
vector<pint> V;
int ans;

signed main() {

    in(N, M);
    V.resize(N);
    rep(i, N) {
        int a, b;
        in(a, b);
        V[i] = {a, b};
    }
    sort(all(V), [](pint a, pint b) {
        if (a.fs == b.fs) {
            return a.sc > b.sc;
        } else {
            return a.fs < b.fs;
        }
    });

    priority_queue<int> pq;

    int j = 0;

    REP(i, 1, M + 1) {
        while (j < N && V[j].fs <= i) {
            pq.push(V[j].sc);
            j++;
        }

        if (pq.size()) {
            ans += pq.top();
            pq.pop();
        }
        show(ans);
    }
    out(ans);

    return 0;
}


Measured memory_bytes: 2936
#include<cstdio>
#include<cstring>
#include<cstdlib>

bool search(char s[]){
  int n = strlen(s);
  int i=0;

  while(1){
    if(i==n) break;
    if(n-i<5) return false;
    char t[10];
    for(int j=0;j<5;j++)
      t[j] = s[i+j];
    t[5]=0;
    if(strcmp(t,"dream")!=0&&strcmp(t,"erase")!=0)
      return false;
      i+=5;
    if(strcmp(t,"dream")==0&&s[i]=='e'&&s[i+1]=='r'){
      if(s[i+2]!='a')
      i+=2;
    }
    if(strcmp(t,"erase")==0&&s[i]=='r')
      i++;
  }
  return true;
}

int main(void){
  char s[1000000];

  scanf("%s",s);

  bool ans  = search(s);

  if(ans)
    printf("YES\n");
  else
    printf("NO\n");

  return 0;
}


Measured memory_bytes: 256
N , K = map(int,input().split())
x = 0
y = 0
for i in range(1 , N + 1):
    if i % K == 0:
        x += 1
    if i % K == K//2:
        y += 1
if K % 2 == 1:
    y = 0
print(x**3 + y**3)

Measured memory_bytes: 3060
h, w = map(int, input().split())
field = [input() for _ in range(h)]
directions = [(1, 0), (-1, 0), (0, 1), (0, -1)]
for i in range(h):
    for j in range(w):
        if field[i][j] == '#':
            ret = False
            for di, dj in directions:
                x = i + di
                y = j + dj
                if 0 <= x < h and 0 <= y < w and field[x][y] == '#':
                    ret = True
            if not ret:
                print('No')
                exit()
print('Yes')


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

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int solve(vector<int> &C){
  if(C.size()<=2) return 0;
  int res = (int)C.size();
  REP(i,C.size()){
    if(i+4<C.size()&&C[i]==C[i+4]){
      vector<int> tmp = C;
      tmp.erase(tmp.begin()+i+4);
      tmp.erase(tmp.begin()+i);
      res = min(res,solve(tmp));
    }
    if(i+5<C.size()&&i%4!=3&&C[i]==C[i+5]){
      vector<int> tmp = C;
      tmp.erase(tmp.begin()+i+5);
      tmp.erase(tmp.begin()+i);
      res = min(res,solve(tmp));
    }
    if(i+3<C.size()&&i%4!=0&&C[i]==C[i+3]){
      vector<int> tmp = C;
      tmp.erase(tmp.begin()+i+3);
      tmp.erase(tmp.begin()+i);
      res = min(res,solve(tmp));
    }
    if(i%4!=3&&i+1<C.size()&&C[i]==C[i+1]){
      vector<int> tmp = C;
      tmp.erase(tmp.begin()+i+1);
      tmp.erase(tmp.begin()+i);
      res = min(res,solve(tmp));
    }
  }
  return res;
}

int main(void){
  int N;
  cin>>N;
  while(N--){
    vector<int> C(20);
    REP(i,20)cin>>C[i];
    cout<<solve(C)<<endl;
  }
  return 0;
}

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

int main() {
	// your code goes here
	int n, m, v[101], t1, t2;
	cin >> n;
	for(int i=1; i<=n; i++) cin >> v[i];
	
	cin >> m;
	for(int i=0; i<m; i++) {
		cin >> t1 >> t2;
		int pre = v[t1], sum = 0;
		v[t1] = t2;
		for(int i=1; i<=n; i++) sum += v[i];
		cout << sum << endl;
		v[t1] = pre;
	}
	
	return 0;
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

typedef db T;
const db eps = 1e-8;
int sgn(T x){return (x>eps)-(x<-eps);}
struct P{
    T x,y;
    P(){} P(T x,T y):x(x),y(y){}
    void read(){scanf("%lf%lf",&x,&y);}
    P operator - (const P&b) const {return P(x-b.x,y-b.y);}
    P operator + (const P&b) const {return P(x+b.x,y+b.y);}
    T operator * (const P&b) const {return x*b.x+y*b.y;}
    P operator * (const T&k) const {return P(x*k,y*k);}
    T operator ^ (const P&b) const {return x*b.y-y*b.x;}
    bool operator < (const P&b) const {return sgn(y-b.y)?y<b.y:x<b.x;}
};
T abs(P x){return sqrt(x*x);}
struct C{
    P o;T r;
    void read(){o.read();scanf("%lf",&r);}
};
int relation(C A,C B){
    T dis = abs(A.o - B.o);
    if(sgn(dis - (A.r + B.r)) == 1) return 4;
    if(sgn(dis - (A.r + B.r)) == 0) return 3;
    if(sgn(dis - fabs(A.r - B.r)) == 1) return 2;
    if(sgn(dis - fabs(A.r - B.r)) == 0) return 1;
    return 0;
}

int main(){
    C o1 , o2;
    o1.read();
    o2.read();
    printf("%d\n",relation(o1,o2));
    return 0;
}

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

int main(){
  int x[5];
  cin >> x[0] >>  x[1] >>  x[2] >>  x[3] >>  x[4];
  for(int i=0;i<5;i++){
    if(x[i]==0)cout << i+1 << endl;
  }
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    
    ll n,m;
    cin>>n>>m;

    if(n==1&&m == 1){
        cout<<1<<endl;
    }else if(n==1 && m!=1){
        cout<<m-2<<endl;
    }else if(n!=1 && m==1){
        cout<<n-2<<endl;
    }else{
        cout<<(n-2)*(m-2)<<endl;
    }


    return 0;
}


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

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if(b - a <= 0) cout << "delicious" << endl;
    else if(b - a <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}

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

int main()
{
  int N, L;
  std::cin >> N >> L;
  std::vector<std::string> strs(N);

  for(int i = 0; i<N; i++) {
    std::cin >> strs[i];
  }

  std::sort(strs.begin(), strs.end(), std::less<std::string>());
  std::string out;
  for(auto s : strs) out += s;

  std::cout << out << std::endl;

  return 0;
}


Measured memory_bytes: 3616
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
ans = []

for n in range(N):
  ame = 0
  for i in range(n+1):
    ame += A1[i]
  for j in range(n, N):
    ame += A2[j]
  ans.append(ame)
  
print(max(ans))

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

int dig(int n){
    int sum=0;
    while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(void){
    int n,a,b;
    int total=0;
    cin >> n >> a >> b;

    for(int i=0;i<=n;i++){
        int sum = dig(i);
        if(a<=sum&&sum<=b) total+=i;
    }
  
    cout << total << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- conding: utf-8 -*-
import sys

for line in sys.stdin.readlines():
    n = int(line.strip())
    if n > 36:
        print(0)
        continue
    elif n == 36:
        print(1)
        continue
    cnt = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                d = n - (a + b + c)
                if 0 <= d and d <= 9:
                    cnt += 1
    print(cnt)

Measured memory_bytes: 7556
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s[0] == s[1]){
        cout << "Bad";
    }else if (s[1] == s[2]){
        cout << "Bad";
    }else if (s[2] == s[3]){
        cout << "Bad";
    }else{
        cout << "Good";
    }
    return 0;
}


Measured memory_bytes: 3592
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let a: u32 = sc.cin();
    let b: u32 = sc.cin();
    let c: u32 = sc.cin();
    put!(max!(10*a+b+c, 10*b+a+c, 10*c+a+b));
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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

using namespace std;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int m = max(x, y);

  int ans = INT_MAX;
  for (int i = 0; i <= m; ++i) {
    int aa = max(a * (x - i), 0);
    int bb = max(b * (y - i), 0);
    ans = min(aa + bb + c * i * 2, ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  ll ans = 1;
  for (int i = n; i > 0; i--) ans = ans * i % 1000000007;
  cout << ans << endl;
}


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

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


int main() {
int H,W;
cin>>H>>W;
char S[H][W];
rep(i,H){
    rep(j,W){
        cin>>S[i][j];
    }
}
int max_dist[H][W];
rep(i,H){
    rep(j,W){
        if(S[i][j]=='#'){
            max_dist[i][j]=0;
        }
        else{
            int dist[H][W];
            rep(k,H){
                rep(l,W){
                    dist[k][l]=-1;
                }
            }
            queue<int> que_y,que_x;

    // 初期条件 (頂点 (sx,sy) を初期ノードとする)
    dist[i][j] = 0;
    que_y.push(i);
    que_x.push(j); 
    //移動方法4通り
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que_x.empty()) {
        int y = que_y.front(); // キューから先頭頂点を取り出す
        que_y.pop();
        int x = que_x.front();
        que_x.pop();

        // (x,y) から辿れる頂点をすべて調べる
       rep(m,4){

            if ((y+dy[m]>=0)&&(y+dy[m]<H)&&(x+dx[m]>=0)&&(x+dx[m]<W)&&(S[y+dy[m]][x+dx[m]]=='.')){ //道でなければ飛ばす
            if(dist[y+dy[m]][x+dx[m]] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな頂点について距離情報を更新してキューに追加する
            dist[y+dy[m]][x+dx[m]] = dist[y][x] + 1;
            que_y.push(y+dy[m]);
            que_x.push(x+dx[m]);
            }
        }
    }
    max_dist[i][j]=0;
    rep(k,H){
        rep(l,W){

    
        max_dist[i][j]=max(max_dist[i][j],dist[k][l]);
        }
    }


        }
    }
}
int ans=0;
rep(i,H){
    rep(j,W){
        ans=max(ans,max_dist[i][j]);
    }
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main(void){
  long long int N,A,B;
  long long int i;
  int h[100000];
  long long int K;
  long long int left,right;
  long long int sum;

  scanf("%lld %lld %lld",&N,&A,&B);
  //printf("%d\n", N);

  for(i=0;i<N;++i){
    scanf("%d",&h[i]);
    //printf("h[%lld]=%lld\n", i,h[i]);
  }

  left=0;
  right=1000000000;
  //K=(right+left)/2;

  //printf("%d\n", K);

  while(left!=right-1){
    K=(right+left)/2;
    sum=0;
    for(i=0;i<N;i++){
      if(h[i]-K*B > 0){
        sum += (h[i]-K*B)%(A-B) ? (h[i]-B*K)/(A-B)+1 : (h[i]-B*K)/(A-B);
      }
    }
    if(sum <= K){
      right=(right+left)/2;
    }else{
      left=(right+left)/2;
    }
    //printf("%lld,%lld\n", left,right);

    /*if(left==right-1){
      break;
    }*/
  }

  printf("%lld\n", right);

  return 0;
}


Measured memory_bytes: 512
n = gets.to_i
n.times do
  ans = 0
  b = []
  5.times{ b << gets.split.map(&:to_i) }
  5.times do |i|
    5.times do |j|
      if b[i][j] == 1
        6.times do |k|
          6.times do |m|
            f = nil
            k.times do |p|
              m.times do |q|
                f = true if i + p > 4 || j + q > 4 || b[i+p][j+q] == 0
              end
            end
            ans = k * m if f.nil? && ans < k * m
          end
        end
      end
    end
  end
  p ans
  gets
end

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

vector<int> idx[300];

bool check(string s){
  
  int x = -1;
  
  for(int i=0;i<(int)s.size();i++){
    
    auto ite = lower_bound( idx[(int)s[i]].begin(), idx[(int)s[i]].end(), x + 1 );
    
    if( ite == idx[(int)s[i]].end() ) return true;

    x = *ite;

  }

  return false;
}

int len;
int cnt[200005];

string s;

void dfs(int x, string ans){
  
  if( (int)ans.size() == len - 1 ){
    
    for(int i='a';i<='z';i++){
      
      if( check( ans + (char)i ) ){
	cout<<ans+(char)i<<endl;
	exit(0);
      }
      
    }
    
  }
  
  for(int i='a';i<='z';i++){
    
    auto ite = lower_bound( idx[i].begin(), idx[i].end(), x + 1 );
    
    if( ite == idx[i].end() ){
      
      ans += (char)i;
      cout<<ans<<endl;
      assert(0);
      exit(0);
      
    }
          
    int nx = *ite;
    
    if( (int)ans.size() + cnt[nx] == len - 2 ) dfs( nx, ans + (char)i );
    
  }
  
}

int getlen(){

  set<char> S;
  
  int len = 1;
  
  for(int i=s.size()-1;i>=0;i--){
    
    cnt[i] = len - 1;    
    
    S.insert(s[i]);
    
    if( S.size() == 26 ){
      len++;
      S.clear();
    }
    
  }
  
  return len;
}

signed main(){
  
  cin>>s;
  
  for(int i=0;i<(int)s.size();i++) idx[(int)s[i]].push_back(i);
  
  len = getlen();
  
  dfs( -1, "" );
    
  return 0;
}


Measured memory_bytes: 46084
#include<bits/stdc++.h>
#define FAST_IO   ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Relocate freopen("./in.txt","r",stdin),freopen("./out.txt","w",stdout)
#define up(mi,a,b) for(mi=a;mi<=b;++mi)
#define down(mi,b,a) for(mi=b;mi>=a;--mi)
#define mfill(a,v) memset(a,v,sizeof(a))
#define INF 0x3f3f3f3f
#define MAX 5500010
#define v_n 5005
#define LL long long
#define ULL unsigned long long 
#define e_n 50005
#define eps 0.000000001
#define Blen 31 
const LL MOD = 998244353;
using namespace std;
vector<int> hh;
int work[MAX];
int main(void)
{
	int i, j, k;
	//Relocate;
	FAST_IO;
	int N;
	cin >> N;
	up(i, 1, N)
	{
		cin >> work[i];
	}
	up(i, 1, N)
	{
		cin >>j;
		hh.push_back(work[i] - j);
	}
	sort(hh.begin(), hh.end(),greater<int>());
	LL ans = 0;
	for (auto one : hh)
	{
		if (one <= 0)
			break;
		ans += one;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
m = [1]
for i in range(1,7):
    if 6**i < 100000:
        m.append(6**i)
    if 9**i < 100000:
        m.append(9**i)
        
N = int(input())

dp = [10**9 for x in range(100001)]
dp[0] = 0
for v in range(1,100001):
    for i in range(len(m)):
        if v >= m[i] and dp[v - m[i]] != -1:
            dp[v] = min(dp[v],1 + dp[v-m[i]])

print(dp[N])


Measured memory_bytes: 3992
#include <iostream>
#include <string>
using namespace std;
int main(void){
	const int DPM[] = {31,29,31,30,31,30,31,31,30,31,30,31};
	const string DAYS[] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month,date;
	while(cin >> month >> date){
		if(month==0)break;
		int day = 3;
		for(int i=1;i<month;++i) day += DPM[i-1];
		day = (day+date-1)%7;
		cout << DAYS[day] << "\n";
	}
	return 0;
}

Measured memory_bytes: 0
/**
*
* Author: MARS
* Lang: GNU C++14
*
**/

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair<int,int>

typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl pi = acos(-1);
const ll inf = 1LL<<30;
const dbl eps = 1e-9;
const ll mod = 1e9+7;

/** /////////// ** Code ** /////////// **/

const int N=0;

int main(){
    int x,t,n;
    scanf("%d%d%d",&n,&x,&t);
    printf("%d\n",(n+x-1)/x*t);

}


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

int main()
{
	int64_t h, w, ch, cw, dh, dw;
	cin >> h >> w >> ch >> cw >> dh >> dw;
	ch--;
	cw--;
	dh--;
	dw--;
	vector<string> ss(h);
	for (auto &&s : ss)
	{
		cin >> s;
	}

	auto inside = [](int64_t a, int64_t b, int64_t c, int64_t d) {
		return 0 <= a && a < c && 0 <= b && b < d;
	};

	vector<int64_t> dd = {0, 1, 0, -1, 0};

	int64_t inf = (1LL << 60);

	vector<vector<int64_t>> dist(h, vector<int64_t>(w, inf));
	priority_queue<pair<int64_t, pair<int64_t, int64_t>>, vector<pair<int64_t, pair<int64_t, int64_t>>>, greater<>> pq;
	dist[ch][cw] = 0;
	pq.push({dist[ch][cw], {ch, cw}});

	while (!pq.empty())
	{
		int64_t d = pq.top().first;
		int64_t i = pq.top().second.first;
		int64_t j = pq.top().second.second;
		pq.pop();

		if (dist[i][j] < d)
		{
			continue;
		}

		for (int k = 0; k < 4; k++)
		{
			int64_t ni = i + dd[k];
			int64_t nj = j + dd[k + 1];

			if (inside(ni, nj, h, w) && (ss[ni][nj] == '.') && (dist[i][j] < dist[ni][nj]))
			{
				dist[ni][nj] = dist[i][j];
				pq.push({dist[ni][nj], {ni, nj}});
			}
		}

		for (int64_t di = -2; di <= 2; di++)
		{
			for (int64_t dj = -2; dj <= 2; dj++)
			{
				int64_t ni = i + di;
				int64_t nj = j + dj;

				if (inside(ni, nj, h, w) && (ss[ni][nj] == '.') && (dist[i][j] + 1 < dist[ni][nj]))
				{
					dist[ni][nj] = dist[i][j] + 1;
					pq.push({dist[ni][nj], {ni, nj}});
				}
			}
		}
	}

	if (dist[dh][dw] == inf)
	{
		cout << -1 << endl;
		return 0;
	}
	cout << dist[dh][dw] << endl;

	return 0;
}

Measured memory_bytes: 13532
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n, m;
    cin >> n >> m;

    vector<vector<int>> g(n + 1);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    bool ans = false;
    rep(i, g[1].size()) {
        int index = g[1][i];
        rep(j, g[index].size()) {
            if (g[index][j] == n) {
                ans = true;
                break;
            }
        }
    }
    if (ans) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 12016
open Printf
open Scanf

let id x = x

let k = scanf "%d" (fun k -> k)

let rec run v k n =
    if v mod k = 0 then n
    else if v < k then run (v * 10 + 7) k (n + 1)
    else run (v mod k) k n

let () =
    if k mod 2 = 0 then print_endline "-1"
    else if k mod 5 = 0 then print_endline "-1"
    else printf "%d\n" (run 7 k 1)


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

int main() {
vector<long>vec(150);
int n;
cin >> n;
for (int i=0;i<n;i++){
    cin >> vec.at(i);
}

long cure=0;
for (int i=0;i<n;i++){
    for (int j=0;j<n;j++){
       int p=vec.at(i);
        int q=vec.at(j);
       cure+=p*q;
        
    }
}
for(int i=0;i<n;i++){
    int p=vec.at(i);
    cure-=p*p;
}
cout << cure/2 <<endl;
}


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

using namespace std;

int main() {

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

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

	int q;
	scanf("%d", &q);

	int cnt = 0;
	for (int i = 0; i < q; ++i) {
		int t;
		scanf("%d", &t);

		S[n] = t;
		int j = 0;
		while (S[j] != t) {
			j++;
		}
		if (j != n) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    int N; cin>>N;
    int ai[N+1];
    for (int i=1;i<=N;i++) {
        cin >> ai[i];
    }

    int next=1;
    int removed=0;
    for (int i=1;i<=N;i++) {
        if (ai[i] == next) {
            next++;
        } else {
            removed++;
        }
    }

    if (removed == N) {
        cout << -1 << endl;
    } else {
        cout << removed << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 998244353LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

ll n,k;


int main(){
  ll ans=0;
  cin >> n >> k;
  vi L(k),R(k);
  vi wa(n+1);
  REP(i,k){
    cin>>L[i]>>R[i];
    //L[i]--;
    //R[i]--;
  }



  vi dp(n);
  dp[0]=1;
  wa[0]=0;
  wa[1]=1;

  for(ll i=1;i<n;i++){
    ll val=0;
    for(ll j=0;j<k;j++){
      ll start=i-R[j];
      ll _end=i-L[j]+1;
      start=max(start,0LL);
      _end=max(_end,0LL);
      if (_end!=0LL){
        //cout<<"st"<<start<<"ed"<<_end<<endl;
        val+=(wa[_end]-wa[start]+MOD)%MOD;
      }
    }
    val%=MOD;
    dp[i]=val;
    wa[i+1]=(wa[i]+dp[i]+MOD)%MOD;
  }

  ans=dp[n-1];
  cout<<ans<<endl;
/*
  REP(i,n){
    cout<<dp[i]<<endl;
  }
  */

  return 0;
}




Measured memory_bytes: 6420
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <cstdio>
using namespace std;

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/* */
/* 入力開始！ */
/* 入力終了！ */
void bakuhatu(char chart[][10][12],int m1,int y,int x)
{
   int i,j,k,l;
   int start,end;
   int range = 3;

   chart[m1][y][x] = '0';
 
   if(x - range < 1) start = 0;
   else start = x - range;
    
   if(x + range > 6) end = 7;
   else end = x + range;
 
   for(i=start; i<=end; i++) {
      if(chart[m1][y][i] == '1') bakuhatu(chart,m1,y,i);
   }
 
 
   if(y - range < 1) start = 0;
   else start = y - range;
    
   if(y + range > 6) end = 7;
   else end = y + range;
 
   for(i=start; i<=end; i++) {
      if(chart[m1][i][x] == '1') bakuhatu(chart,m1,i,x);
   }
}
int main(void)
{
   int i,j,k,l;
   int a,b,c,d;
   int memory[2];
   int x,y;
   int n;
   char chart[1000][10][12] = {0};
   char iranai[3];
 
   scanf("%d",&n);
   for(i=0;i<n;i++) {
      for(j=0;j<8;j++) scanf("%s",chart[i][j]);
      scanf("%d",&x);
      scanf("%d",&y);
      bakuhatu(chart,i,y-1,x-1);
   }
   for(i=0;i<n;i++) {
      printf("Data %d:\n",i+1);
      for(j=0;j<8;j++) printf("%s\n",chart[i][j]);
   }
   return 0;
}

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

int main (void) {
  int N,i,j,m,n;
  string s,t;
  bool suc;
  cin >> N;
  cin >> s;
  cin >> t;
  for(i=0;i<N;++i){
    suc = true;
    for(j=i;j<N;++j){
      if(s[j]!=t[j-i]){
	suc=false;
	break;
      }
    }
    if(suc){
      cout<<i+t.length();
	return 0;
    }
  }
  cout<<s.length()+t.length();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n;
    ll i,j,k;
    cin>>n;
    int arr[n];
    ll dp[n+5][n+5],dpp[n+5][n+5];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(i=0;i<n;i++){
        dp[i][i] = arr[i];
        dpp[i][i] = 0;
    }
    for(i=2;i<=n;i++){
        for(j=0;j+i<=n;j++){
            dpp[j][j+i-1]=LLONG_MAX;
            for(k=j;k<j+i-1;k++){
                
               // cout<<j<<" "<<" "<<k<<" "<<j+i-1<<" "<<dpp[j][k]<<" "<<dpp[k+1][j+i-1]<<" "<<dp[j][k]<<" "<<dp[k+1][j+i-1]<<endl;
                if(dpp[j][k]+dpp[k+1][j+i-1]+dp[j][k]+dp[k+1][j+i-1]<dpp[j][j+i-1]){
                     dpp[j][j+i-1] = dpp[j][k]+dpp[k+1][j+i-1]+dp[j][k]+dp[k+1][j+i-1];
                     dp[j][j+i-1] = dp[j][k]+dp[k+1][j+i-1];
                } //cout<<j<<" "<<j+i-1<<" "<<dpp[j][j+i-1]<<endl;  
               
                
            }
        }
    }
    cout<<dpp[0][n-1]<<endl;
    
}

Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

const int MOD = 1000000007;


vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(10, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 10; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'0'] = i;
    }
    return res;
}



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

    int n;
    string S;
    cin >> n;
    cin >> S;

    vector<vector<int> > next = calcNext(S);

        // DP
    int dp[30010][4] = {{}};
    dp[0][0] = 1;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 10; ++j) {
            if (next[i][j] >= n) continue; // 次の文字 j がもうない場合はスルー
            //add(dp[next[i][j] + 1], dp[i]);
            for (int k = 1; k < 4; k++)
            {
                dp[next[i][j]+1][k] += dp[i][k-1];
            }
            
            
        }
    }

    // 集計
    long long res = 0;
    for (int i = 0; i <= n; ++i) res += dp[i][3];

    cout << res << endl;
    
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
  string s, t;
  cin >> s >> t;
  int n = -1;
  if (s.length() < t.length())
  {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  for (int i = 0; i <= s.length() - t.length(); i++)
  {
    auto flag = true;
    for (int j = 0; j < t.length(); j++)
    {
      if (s[i + j] != '?' && s[i + j] != t[j])
      {
        flag = false;
        break;
      }
    }
    if (flag)
      n = i;
  }

  if (n != -1)
  {
    for (int j = 0; j < t.length(); j++)
    {
      s[n + j] = t[j];
    }
    for (int i = 0; i < s.length(); i++)
    {
      if (s[i] == '?')
        s[i] = 'a';
    }
    cout << s << endl;
  }
  else
  {
    cout << "UNRESTORABLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
import sys
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n
 F[S],H=0,[(0,S)]
 while H:
  c,u=heappop(H)
  if u==G:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:
    F[v]=t
    heappush(H,(t,v))
 return-1
def s(n,k):
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r();p=map(int,f[2:].split())
  if'0'==f[0]:
   print(g(n,E,*p))
  else:
   c,d,e=p
   E[c]+=[(e,d)]
   E[d]+=[(e,c)]
for e in iter(r,'0 0\n'):
 s(*map(int,e.split()))


Measured memory_bytes: 6304