akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>

using namespace std;

typedef pair<int, int> pii;
typedef priority_queue<pii> pqp;

int solve(int a[], int n) {
    if (a[0] < n) {

    }
} 

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

    int pp2[n+1];
    pp2[1] = 0;
    for (int i = 2; i <= n; i++) {
        pp2[i] = max(0, pp2[i-1] - int(floor(log2(1.0 * a[i] / a[i-1]) / 2)) * 2);
    }
    
    long long pp2s[n+2];
    pp2s[n+1] = 0;
    for (int i = n; i > 0; i--) {
        pp2s[i] = pp2s[i+1] + pp2[i];
    }

    int rmp2[n+1];
    pqp q;
    for (int i = 1; i <= n; i++) {
        while (!q.empty() && q.top().first > pp2[i]) {
            rmp2[q.top().second] = i;
            q.pop();
        }
        q.push(pii(pp2[i], i));
    }
    while (!q.empty()) {
        rmp2[q.top().second] = n + 1;
        q.pop();
    }

    long long adp2[n+2];
    adp2[n+1] = 0;
    for (int i = n; i > 0; i--) {
        adp2[i] = 1ll * pp2[i] * (rmp2[i] - i) + adp2[rmp2[i]];
    }

    int pm2[n+2];
    pm2[n] = 1;
    for (int i = n - 1; i > 0; i--) {
        pm2[i] = max(1, pm2[i+1] - int(floor(log2(1.0 * a[i] / a[i+1]) / 2)) * 2);
    }
    
    long long pm2s[n+1];
    pm2s[0] = 0;
    for (int i = 1; i <= n; i++) {
        pm2s[i] = pm2s[i-1] + pm2[i];
    }

    int lmm2[n+1];
    for (int i = n; i > 0; i--) {
        while (!q.empty() && q.top().first > pm2[i]) {
            lmm2[q.top().second] = i;
            q.pop();
        }
        q.push(pii(pm2[i], i));
    }
    while (!q.empty()) {
        lmm2[q.top().second] = 0;
        q.pop();
    }

    long long adm2[n+2];
    adm2[0] = 0;
    for (int i = 1; i <= n; i++) {
        adm2[i] = 1ll * (pm2[i] - 1) * (i - lmm2[i]) + adm2[lmm2[i]];
    }

    long long ans = 2e10;
    for (int i = 0; i <= n; i++) {
        ans = min(ans, pm2s[i] - adm2[i] + pp2s[i+1] - adp2[i+1]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12144
def f():
 c=0
 for W in iter(input,'0'):
  c+=1
  W=int(W)
  d=[0]*-~W
  for _ in[0]*int(input()):
   v,w=map(int,input().split(','))
   for i in range(W,w-1,-1):
    if d[i]<d[i-w]+v:d[i]=d[i-w]+v
  print(f'Case {c}:\n{d[W]}\n{d.index(d[W])}')
f()


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b;
    cin >> a >> b;
    cout << a * b << '\n';
}


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

using namespace std;

#define FOR(i,k,n) for(int i=k;i<n;i++)
#define FORR(i,k,n) for(int i=k;i<=n;i++)
#define scan(a) scanf("%d",&a)
#define scann(a,b) scanf("%d%d",&a,&b)
#define scannn(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define mst(a,n)  memset(a,n,sizeof(a))
#define ll long long
#define N 100005
#define mod 1000000007
#define INF 0x3f3f3f3f

const double eps=1e-8;
const double pi=acos(-1.0);

ll a[N];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll n,k;
    while(cin>>n)
    {
        ll sum=0;
        for(int i=0;i<n;i++)
            cin>>a[i],sum+=a[i];
        int flag=0;
        if(sum%(n*(n+1)/2))
            flag=1;
        else
        {
            k=sum/(n*(n+1)/2);
            for(int i=0;i<n;i++)
            {
                ll d=(i==0?a[0]-a[n-1]:a[i]-a[i-1]);
                if(k-d<0||(k-d)%n)
                {
                    flag=1;
                    break;
                }
            }
        }
        if(flag)
            puts("NO");
        else
            puts("YES");
    }
    return 0;
}


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

#define ll long long
#define pb push_back
#define ins insert
#define mp make_pair
#define pii pair<int, int>
#define pil pair<int, ll>
#define pib pair<int, bool>
#define SET(a, c) memset(a, c, sizeof(a))
#define MOD 1000000007
#define enld endl
#define endl "\n"
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define found(u, val) u.find(val) != u.end()

#include <string>
#include <vector>
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
//#include <algorithm>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//#include <cmath>
//#include <cstring>
//#include <sstream>
//#include <stack>
//#include <queue>

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

    int n, W;
    cin >> n >> W;

    vl values, weights;
    values.resize(n);
    weights.resize(n);
    ll sumValue = 0;
    for (int i = 0; i < n; i++) {
        cin >> weights[i] >> values[i];
        sumValue += values[i];
    }

    ll dp[sumValue + 1];
    for (int i = 0; i <= sumValue; i++) {
        dp[i] = 1e11;
    }
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        int value = values[i], weight = weights[i];
        for (int value_already = sumValue - value; value_already >= 0; value_already--) {
            dp[value_already + value] = min(dp[value_already] + weight, dp[value_already + value]);
            // if (dp[value_already + value] != 10000000) cout << dp[value_already + value] << endl;
        }
    }
    ll answer = 0;
    for (int i = 0; i <= sumValue; i++) {
        if (dp[i] <= W) answer = i;
    }
    cout << answer;
}

Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;int N,A,B,C,l[9],i;int dfs(int a,int b,int c,int mp,int i){return i==N?a&&b&&c?10*mp+abs(A-a)+abs(B-b)+abs(C-c):10000:min({dfs(a,b,c,mp,i+1),dfs(a+l[i],b,c,mp+1,i+1),dfs(a,b+l[i],c,mp+1,i+1),dfs(a,b,c+l[i],mp+1,i+1)});}
main(){cin>>N>>A>>B>>C;while(i<N)cin>>l[i++];cout<<dfs(0,0,0,0,0)-30<<endl;}

Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;

    ll xmin = (ll)floorl(n * 1.08);
    ll xmax = (ll)ceill(n * 1.08);

    REP(x, n+1) {
        if (n == (ll)(1.08L * x)) {
            cout << x << endl;
            return 0;
        }
    }
    
    cout << ":(" << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1


#ifndef ONLINE_JUDGE
#define watch(x)		cerr << #x << " = " << x << "\n"
#else
#define watch(x)		42
#endif

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

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
#endif
}

int32_t main()
{
	c_p_c();

	int a,b; cin>>a>>b;

	char dec; cin>>dec;

	int f; cin>>f;

	b *= 100;
	b += f;

	cout << (a*b)/100;

	return 0;
}

Measured memory_bytes: 3616
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	for i := n; i <= 999; i++ {
		if string(strconv.Itoa(i)[0]) == string(strconv.Itoa(i)[1]) && string(strconv.Itoa(i)[2]) == string(strconv.Itoa(i)[1]) {
			fmt.Println(i)
			return
		}
	}
}


Measured memory_bytes: 512
import random
import time
import copy
import math
start=time.time()
d=int(input())
c=list(map(int,input().split()))
s=[]
cli=[]
for i in range(d+1):
  ch=[]
  for j in c:
    ch.append(i*j)
  cli.append(ch)
for i in range(d):
  s.append(list(map(int,input().split())))
last=[0]*26
score=0
solution=[]
for day in range(1,d+1):
  co=[]
  dla=[]
  down=0
  for (i,j) in zip(last,c):
    down+=(day-i)*j
  for (i,j) in zip(last,c):
    dla.append(down-(j*(day-i)))
  for con in range(26):
    co.append(s[day-1][con]-dla[con])
  choice=co.index(max(co))
  score+=co[choice]
  last[choice]=day
  #print(choice+1)
  #print(score)
  solution.append(choice)
#print(score)
stemp=abs(score//50)
etemp=1
def tem():
  return stemp-((stemp-etemp)*(time.time()-start)/1.9)
while time.time()-start<1.9:
  
  sc=0
  sol=copy.deepcopy(solution)
  for x in [random.randrange(d) for i in range(5)]:
    sol[x]=random.randrange(26)
  last=[0]*26
  for (day,i) in zip(range(1,d+1),sol):
    sc+=s[day-1][i]
    last[i]=day
    for (i,j) in zip(last,range(26)):
      sc-=cli[day-i][j]
  try:
    prob = math.exp((sc-score)/tem())
  except:
    prob=0
  #print("{} {}".format(sc,prob))
  if prob>random.random():
    solution=copy.deepcopy(sol)
    score=sc
    #print(score)
for i in solution:
  print(i+1)
#print(sco)

Measured memory_bytes: 10424
#include <stdio.h>

int main(void)
{
  int N, K, Q;
  scanf("%d%d%d", &N, &K, &Q);
  int score[100000] = {};
  for(int i = 0 ; i < Q; i++){
    int j;
    scanf("%d", &j);
    score[j-1]++;
  }
  for(int i = 0; i < N; i++)
    printf(Q-score[i] < K ? "Yes\n" : "No\n");
}


Measured memory_bytes: 896
#include <iostream>
#include <map>
#include <queue>
#include <vector>

#define MAX_V 100000
#define INF   10000000000

int V, E, r;
unsigned long long int d[MAX_V];
bool used[MAX_V];

std::map<int, int> cost[MAX_V];

struct edge{
    int to;
    int cost;
};

std::vector< struct edge > G[MAX_V];

void dijkstra( int s ) {
    /*
    std::fill(d, d+V, INF);
    std::fill(used, used+V, false);
    d[s] = 0;

    while (true) {
        int v=-1;

        for (int u=0; u<V; u++) {
            if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
        }

        if (v == -1) break;

        used[v] = true;

        for (int u=0; u<V; u++) {
            if (cost[v].find( u ) != cost[v].end()) {
                d[u] = std::min( d[u], d[v] + cost[v][u] );
            }
        }
    }
    */
    std::priority_queue< std::pair<int, int>,
                         std::vector< std::pair<int, int> >,
                         std::greater< std::pair<int, int> > > que;

    std::fill(d, d+V, INF);
    d[s] = 0;
    que.push( std::make_pair(0, s) );

    while( !que.empty() ) {
        std::pair<int, int> p = que.top();
        que.pop();

        int v = p.second;

        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); i++) {
            struct edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push( std::make_pair(d[e.to], e.to) );
            }
        }
    }

    for (int i=0; i<V; i++) {
        if (d[i] >= INF) {
            std::cout << "INF" << std::endl;
        } else {
            std::cout << d[i]  << std::endl;
        }
    }
}

int main() {
    std::cin >> V >> E >> r;


    for (int i=0; i<E; i++) {
        int s, t, c;
        std::cin >> s >> t >> c;

        struct edge e;
        e.to = t;
        e.cost = c;
        G[s].push_back( e );
        // cost[s][t] = c;
    }
    dijkstra( r );
    return 0;
}



Measured memory_bytes: 18128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    double T, X;
    cin >> T >> X;

    cout << std::fixed << std::setprecision(15) << T / X << endl;

    return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
int mod = 1e9+7;
int dp[100001];
int fib(int n) {
    if(n==0) return 0;
    if(n==1) return 1;
    if(dp[n] != 0) {
        return dp[n];
    }
    return dp[n] = (fib(n-1)+fib(n-2))%mod;
}
void Main(){
    int N = read(), M = read();
    int_fast64_t ans = 1;
    if (M == 0) {
        printf("%d\n", fib(N+1));
        return;
    }
    vector<int> V(M+1);
    V[0] = read();
    int temp, last = V[0];
    for (int i = 1; i<M; i++) {
        temp = read();
        V[i] = temp-last-1;
        last = temp;
    }
    V[M] = N-last;
    for (auto v:V) {
        ans *= fib(v);
        ans %= mod;
    }
    printf("%lld\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

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

using namespace std;

typedef long long ll;

ll log2(ll n) {
    ll res = 0;
    while (n % 2 == 0) {
        n /= 2;
        res++;
    }
    return res;
}

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

    vector<ll> a(n);
    for (auto &i : a)
        cin >> i;

    ll ans = 0;
    for (auto &i : a) {
        ans += log2(i);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
import math
A,B,H,M=map(int,input().split())
b=30*H+30*(M/60)
c=6*M
d=math.fabs(b-c)
d=math.radians(d)
f=0

f=A**2+B**2-2*A*B*(math.cos(d))
print(math.fabs(math.sqrt(f)))


Measured memory_bytes: 9500
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

class union_find{
	vector<int> a;
public:
	union_find(int n):a(n,-1){}
	int find(int x){
		if(a[x]<0) return x;
		return a[x]=find(a[x]);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x!=y){ a[x]+=a[y]; a[y]=x; }
	}
	int size(int x){ return -a[find(x)]; }
};

template<class T>
struct edge{
	int u,v;
	T cost;
	bool operator<(const edge &e)const{ return cost>e.cost; }
};

template<class T>
T Kruskal(int n,int m,edge<T> *E){
	if(n<=1) return 0;

	T tot=0;
	union_find U(n);
	sort(E,E+m);
	rep(i,m){
		if(U.find(E[i].u)!=U.find(E[i].v)){
			U.unite(E[i].u,E[i].v);
			tot+=E[i].cost;
			if(U.size(E[i].u)==n) return tot;
		}
	}
	return tot;
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	int x[10000],y[10000];
	rep(i,n) scanf("%d%d",x+i,y+i);

	double ans=0;
	static edge<double> E[100000];
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		double cost=sqrt((x[u]-x[v])*(x[u]-x[v])+(y[u]-y[v])*(y[u]-y[v]));
		E[i]=(edge<double>){u,v,cost};
		ans+=cost;
	}

	ans-=Kruskal(n,m,E);

	printf("%.9f\n",ans);

	return 0;
}

Measured memory_bytes: 1636
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define SZ(x) ((int)(x).size())
//#define int ll
#define el '\n'
template<class T> bool inline rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool inline rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
typedef long long ll; typedef long double ld; typedef double dd; typedef pair<int, int> pii;
const ll INFLL=0x7f7f7f7f7f7f7f7f, MOD=1e9+7; const int INF=0x7f7f7f7f;

//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';

/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vv<int> vis, color; 
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){if(a<0) a=-a; if(b<0) b=-b; while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}

///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

int n; cin>>n;
set<int> s;
vv<int> l(n+1), r(n+1), e(n+1), v(n+2);
s.insert(0); s.insert(n+1);
ll ans=0;
for(int i=1;i<=n;++i){
	cin>>v[i];
	e[v[i]]=i;
}
for(ll i=n;i;--i){
	set<int>::iterator p=s.upper_bound(e[i]), q=p;
	q--;
	int x=v[*p], y=v[*q];
	if(*p!=n+1) ans+=i*(*next(p)-*p)*(e[i]-*q);
	if(*q!=0) ans+=i*(*p-e[i])*(*q-*prev(q));

	l[i]=*q+1, r[i]=*p-1;
	s.insert(e[i]);
}
cout<<ans<<el;


return 0;
}


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

void solve()
{
    int n; cin >> n;
    vector<pair<int, int>>vp;
    for(int i = 0; i < n; i++)
    {
        int a, b; cin >>  a >> b;
        vp.push_back(make_pair(a, b));
    }
    bool ok = false;
    for(int i = 0; i < n-2; i++)
    {
        if(vp[i].first == vp[i].second && vp[i+1].first == vp[i+1].second && vp[i+2].first == vp[i+2].second)
        {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3632
sx,sy,tx,ty=map(int,input().split())

dx=tx-sx
dy=ty-sy

root=""
for i in range(dy):
    root=root+"U"
for i in range(dx):
    root=root+"R"
for i in range(dy):
    root=root+"D"
for i in range(dx):
    root=root+"L"
    
root=root+"L"
for i in range(dy+1):
    root=root+"U"
for i in range(dx+1):
    root=root+"R"
root=root+"D"

root=root+"R"
for i in range(dy+1):
    root=root+"D"
for i in range(dx+1):
    root=root+"L"
root=root+"U"

print(root) 
   

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
    int n, q;
    scanf("%d%d",&n,&q);
    char s[n + 1];
    scanf("%s",s);
    int l[q], r[q];
    for(int i = 0; i < q; i++){
        scanf("%d%d",&l[i],&r[i]);
        l[i]--;
        r[i]--;
    }
    int a[n];
    for(int i = 0; i < n; i++)
        a[i] = 0;
    for(int i = 1; i < n; i++){
        if(s[i] == 'C' && s[i - 1] == 'A')
            a[i] = a[i - 1] + 1;
        else
            a[i] = a[i - 1];
    }
    for(int i = 0;i < q; i++){
        printf("%d\n",a[r[i]] - a[l[i]]);
    }
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int cnt = 0;
    for(int i=0; i<N-1; i++){
        if(x >= a[i]){
            x -= a[i];
            cnt++;
        }else{
            break;
        }
    }
    if(x == a[N-1]) cnt++;

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"c=0\n"
"for t in open(0).readlines()[:0:-1]:a,b=map(int,t.split());c+=(-a-c)%b\n"
"print(c)\n"
"\"";
  system(s);
  return 0;
}            

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

using namespace std;

using ll = long long;

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

    constexpr ll MOD = 1e9 + 7;

    int n;
    string s;
    cin >> n >> s;

    vector<int> cur(n + 1, 1), nxt(n + 1);
    cur[0] = 0;

    for (int i = 2; i <= n; ++i) {
        if (s[i - 2] == '<') {
            for (int j = 1, sum = 0; j <= n - i + 1; ++j) {
                (sum += cur[j]) %= MOD;
                (nxt[j] = sum) %= MOD;
            }
        }
        else {
            for (int j = n - i + 1, sum = 0; 1 <= j; --j) {
                (sum += cur[j + 1]) %= MOD;
                (nxt[j] = sum) %= MOD;
            }
        }

        swap(cur, nxt);
    }

    cout << cur[1] << endl;

    return 0;
}


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

int main(){
  string s;
  cin>>s;
  long long N=s.size();
  long long begin;
  long long end;
  for(long long i=0; i<N-1; i++){
    if(s.at(i)=='A'){
      begin=i;
      break;
    } //ifA
  } //i
  for(long long i=N-1; i>=0; i--){
    if(s.at(i)=='Z'){
      end=i;
      break;
    } //ifA
  } //i
  cout<<end-begin+1<<endl;
}


Measured memory_bytes: 640
n = int(input())
al = [int(i) for i in input().split()]
bl = [int(i) for i in input().split()]
cl = [int(i) for i in input().split()]

for i in range(len(al)-len(cl)):
    cl.append(0)


v = sum(bl)
memo = -2
for i in al:
    if i == memo +1:
        v += cl[memo-1]
    memo = i
    
print(v)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int K, T;
	cin >> K >> T;

	int max_a = 0;
	for (int i = 0; i < T; i++)
	{
		int a;
		cin >> a;

		max_a = max(max_a, a);
	}

	cout << max(max_a - 1 - (K - max_a), 0);

	return 0;
}

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


s = input()
i = 0
j = len(s)-1
ans = 0
while i<=j:
    if s[i]!=s[j]:
        ans += 1
    i += 1
    j -= 1
print(ans)

Measured memory_bytes: 61900
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

string S,T;

bool check_string(string subs, string T){
    bool flag = true;
    REP(i,subs.length()){
        if(subs[i] != T[i] && subs[i] != '?'){
            flag = false;
            break;
        }
    }
    return flag;
}


int main(){
    cin >> S;
    cin >> T;
    int sizes = S.length();
    int sizet = T.length();
    vector<string> str;
    int part = sizes - sizet + 1;
    bool flag = false;
    if(part <= 0) {cout << "UNRESTORABLE" << endl;return 0;}
    else{
        REP(i,part){
            string SS;
            //SS = S;
            string subs = S.substr(i,sizet);
            if(check_string(subs,T)){
                flag = true;
                REP(k,sizes){
                    if(k < i || k >= i + sizet){
                        if(S[k] == '?'){
                            SS.append("a");
                        }
                        else{
                            SS.append(S.substr(k,1));
                        }
                    }
                    else{
                        SS.append(T.substr(k-i,1));
                    }
                    
                }
                str.push_back(SS);
            }
        }
    }
    sort(ALL(str));

    cout << (flag ? str[0] : "UNRESTORABLE") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,D;
    cin >> N >> D;
    vector<vector<int>> A(N,vector<int>(D));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++) cin >> A[i][j];
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            int d = 0;
            for(int k = 0; k < D; k++) d += (A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
            for(int k = 0; k < 401; k++){
                if(d == k*k) ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 10000000000000010ll
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE int i=n;i>=p;--i)
#define vep(p,n,i) for(RE int i=p;i<n;++i)
#define pii pair<int,int>
#define mk make_pair
#define RE register
#define P 1000000007
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define EPS 1e-8
#define sq sqrt
#define S second
#define F first
#define mod 998244353
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
    RE int x=0,f=1;RE char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=((ll)x*10+ch-'0')%mod;ch=getc();}
    return x*f;
}
const int MAXN=200010;
int n,len;
ll c[MAXN];
int lin[MAXN],ver[MAXN<<1],nex[MAXN<<1];
inline void add(int x,int y)
{
	ver[++len]=y;
	nex[len]=lin[x];
	lin[x]=len;
}
int main()
{
	//freopen("1.in","r",stdin);
	cin>>n;
	put(n%1000==0?0:1000-n%1000);return 0;
}


Measured memory_bytes: 3768
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rep3(i,n,m) for(ll i=(n);i<(ll)(m);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int stoi (string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}


// 降順ソート: sort(A, A+N, greater<>());
// min: *min_element(A, A+N)
// argmin: min_element(A, A+N)-A



int main(){	
	// ll A;
    // cin >> A;
	// cout << "hello" << endl;
	// cout << stoi("14") << endl;
	// cout << max({1,3}) << endl;
	ll A, B;
	cin >> A >> B;
	if(B%A==0){
		cout << A+B << endl;
	}else{
		cout << B-A << endl;
	}
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(abs(a-c)<=d)cout<<"Yes"<<endl;
  else if (abs(a-b)<=d&&abs(b-c)<=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  long long a[n];
  map<int, int> mp;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    mp[a[i]]++;
  }
  int ans = 0;
  for(auto p: mp){
    int x = p.first;
    int y = p.second;
    if(y < x) ans += y;
    else ans += y - x;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  const double INF = 10000.0;
  double v[N];
  priority_queue<double> que;
  for (int i = 0; i < N; i++) {
    cin >> v[i];
    que.push(INF - v[i]);
  }
  
  for (int i = 0; i < N - 1; i++) {
    double a, b;
    a = que.top();
    que.pop();
    b = que.top();
    que.pop();
    que.push((a+b)/2.0);
  }
  
  cout << fixed << setprecision(10) << INF - que.top() << endl;
  
}

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

using namespace std;


int main() {
    int n;
    cin >> n;
    int ret = 1;
    for (int i = 2; i < 100; i++) {
        for (int j = i * i; j <= n; j *= i)ret = max(ret, j);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
  }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N , A;
    cin >> N;
    if (N <= 9){
        cout << N << endl;
    }else if(N <= 99){
        cout << 9 << endl;
    }else if(N <= 999){
        cout << N - 90 << endl;
    }else if(N <= 9999){
        cout << 909 << endl;
    }else if(N <= 99999){
        cout << N -9090 <<endl;
    }else{
        cout << 90909 << endl;
    }
    return 0;
}

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

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

  int s = 0, t = 0;
  for(int i = 0; i < 4; i++)
    s += a[i];
  for(int i = 0; i < 4; i++)
    t += b[i];

  cout << max(s, t) << endl;
  return 0;
}

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

#define int long long

const int N = 16e3 + 10;
int x, y, _dp[2][2 * N + 100], *dp[2];
string s;
vector <int> vec[2];

void fill_dp(int indx) {
	for (int i = -N + 1; i < N; i++)
		dp[1][i] = 0;
	dp[1][0] = 1;
	
	for (int i = 0; i < vec[indx].size(); i++) {
		int now = (i & 1), prv = (now ^ 1), x = vec[indx][i];
		for (int j = -N + 1; j < N; j++) {
			dp[now][j] = 0;
			if (j - x > -N)
				dp[now][j] = dp[prv][j - x];
			if (j + x < N)
				dp[now][j] = max(dp[now][j], dp[prv][j + x]);
		}
	}
}

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	dp[0] = _dp[0] + N + 50;
	dp[1] = _dp[1] + N + 50;
	
	cin >> s >> x >> y;
	while (s.size() && s.back() == 'T')
		s.pop_back();
	if (!s.size())
		return cout << (!x && !y? "Yes\n": "No\n"), 0;
	
	int tmp = 0, indx = 0;
	while (indx < s.size() && s[indx] == 'F')
		tmp++, indx++;
//	if (indx == s.size())
//		return cout << (tmp == x && !y? "Yes\n": "No\n");
	
	int last = 0, num = 0;
	for (int i = indx; i < s.size(); i++) {
		if (s[i] == 'T')
			vec[num & 1].push_back(last), last = 0, num++;
		else
			last++;
	}
	vec[num & 1].push_back(last);
	
	fill_dp(0);
	if (!dp[((int)vec[0].size() & 1) ^ 1][x - tmp])
		return cout << "No\n", 0;
	fill_dp(1);
	cout << (dp[((int)vec[1].size() & 1) ^ 1][y]? "Yes\n": "No\n");
}

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

int n;
string s;
int ans;

void dfs(int depth, int id)
{
  for (char i='0'; i<='9'; i++)
    for (int j=id; j<n; j++)
      if (i == s[j])
      {
        if (depth < 2)
          dfs(depth + 1, j + 1);
        else
          ans++;
        break;
      }
}

int main()
{
  cin >> n;
  cin >> s;
  ans = 0;

  dfs(0, 0);
  cout << ans << endl;
}

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

using namespace std;

int get(){
	static char c;
	for(c=getchar();c!='#'&&c!='.';c=getchar());
	return c=='#';
}

const int N=2005;
int n,m,up[N],ch[N],ans,qu[N],qr;

int main(){
	scanf("%d%d",&n,&m);
	ans=max(n,m);
	for(int i=1;i<=n;i++){
		int a=get(),b;
		qr=0;
		for(int x=1;x<m;x++){
			b=get();
			if((a==b)!=ch[x])ch[x]^=1,up[x]=0;
			up[x]++,a=b;
			while(qr&&up[qu[qr]]>up[x])qu[qr--]=0;
			qu[++qr]=x;
			ans=max(ans,up[x]*2);
			if(up[qu[qr-1]]*(x+1)<=ans)continue;
			for(register int k=1;k<=qr;k++)ans=max(ans,up[qu[k]]*(x+1-qu[k-1]));
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include <algorithm>
#include<string>
using namespace std;

int main() {
        long long int N,M;
        long long int Ans = 0;

        cin >> N >> M;

        if((N==1)&&(M==1)) Ans = 1;
        else if(N==1) Ans = M-2;
        else if(M==1) Ans = N-2;
        else Ans = (N-2)*(M-2);

        cout << Ans << endl;

        return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    for(int i=a;i<=b;i++){
      if(i%k==0){
        System.out.println("OK");
        return;
      }
    }
    System.out.println("NG");
    return;
  }
}
      
        

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


void solve(string l1, string l2, string l3){
    string s1, s2, s3;
    s1 = l1[0];
    s2 = l2[1];
    s3 = l3[2];
    cout << s1 + s2 + s3 << endl;
    
    
}

int main(){
    string l1, l2, l3;
    cin >> l1;
    cin >> l2;
    cin >> l3;
    solve(l1, l2, l3);

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
const int maxx = 1e5+5;
ll n, a, b, m[maxx];

bool check(ll x) {
	ll cnt = 0, cn = a - b;
	for(int i = 1; i <= n; i++) {
		ll t = m[i] - b * x;
		if(t > 0) {
			cnt += t / cn;
			if(t % cn) cnt++;
			if(cnt > x)
				return false;
		}
	}
	return true;
}

int main() {
	ll ans;
	scanf("%lld%lld%lld", &n, &a, &b);
	for(int i = 1; i <= n; i++) 
		scanf("%lld", &m[i]);
	ll r = 1e10, l = 0, mid;
	ans = r;
	while(l <= r) {
		mid = (l + r) / 2;
		if(check(mid)) {
			r = mid - 1;
			ans = min(ans, mid);
		}else 
			l = mid + 1;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <cmath>
#include <string>

using namespace std;

int main(void) {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((abs(a - b) <= d && abs(c - b) <= d) || abs(a - c) <= d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import math
def primeFactors(n):
    d=dict()
    while n % 2 == 0:
        if 2 in d:
            d[2]+=1
        else:
            d[2]=1
        n = n // 2

    for i in range(3, int(math.sqrt(n)) + 1, 2):

        while n % i == 0:
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
            n = n // i

    if n > 2:
        if n in d:
            d[n]+=1
        else:
            d[n]=1

    return d

def getcount(S):
    return int((math.sqrt(1+8*S)-1)/2)


n=int(input())

d = primeFactors(n)

total=0

for x in d:
    total+=getcount(d[x])

print(total)





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

int main() {
  int H, W, K;
  cin >> H >> W >> K;

  vector<string> s(H);
  rep(i, H) cin >> s[i];

  int ans = 0;
  rep(is, 1 << H) rep(js, 1 << W) {  //シフト演算子。たとえば1<<3なら1→1000(8を出力)にシフト
    int cnt = 0;
    rep(i, H) rep(j, W) {
      if (is >> i & 1) continue;
      if (js >> j & 1) continue;
      if (s[i][j] == '#') cnt++;
    }
    if (cnt == K) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    cin >> n >> x;
    int m[n];
    int ans=n;
    for(int i=0;i<n;i++)cin >> m[i];
    for(int i=0;i<n;i++)x-=m[i];
    sort(m,m+n);
    ans += x/m[0];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100000

typedef struct{
  int p;
  int l;
  int r;
}Node;

void preParse(Node*,int);
void inParse(Node*,int);
void postParse(Node*,int);

int main(){

   int i;
   int n;
   int id;
  Node T[N];

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&T[id].l,&T[id].r);
    T[T[id].l].p = id;
    T[T[id].r].p = id;
   }

  for(i=0;i<n;i++){
    if(T[i].p==-1){
      break;
    }
  }
  
    printf("Preorder\n");
    preParse(T ,i);
    printf("\n");
    printf("Inorder\n");
    inParse(T ,i);
    printf("\n");
    printf("Postorder\n");
    postParse(T ,i);
    printf("\n");
  
  return 0;
}


void preParse(Node *T ,int i){
  if(i == -1) return;
  printf(" %d",i);
  preParse(T ,T[i].l);
  preParse(T ,T[i].r);
}

void inParse(Node *T ,int i){
  if(i == -1) return;
  inParse(T ,T[i].l);
  printf(" %d",i);
  inParse(T ,T[i].r);
}

void postParse(Node *T ,int i){
  if(i == -1) return;
  postParse(T ,T[i].l);
  postParse(T ,T[i].r);
  printf(" %d",i);
}

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

int main() {
	long long n;
	vector<long long> t, x, y;
	long long dt, dis;
	bool judge = true;

	cin >> n;

	t.resize(n + 1);
	x.resize(n + 1);
	y.resize(n + 1);

	t[0] = 0;
	x[0] = 0;
	y[0] = 0;

	for (int i = 1; i <= n; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}

	for (int j = 0; j < n; j++) {
		dt = t[j + 1] - t[j];
		dis = abs(x[j + 1] - x[j]) + abs(y[j + 1] - y[j]);
		if (dt < dis || dis % 2 != dt % 2) {
			judge = false;
		}
	}
	
	if (judge) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 2560
#pragma GCC optimize("O3")
#pragma GCC target("avx")

#include <iostream>
#include <vector>
#include <functional>
#include <queue>

constexpr int MAX_N = 50;
constexpr int MAX_A = 50;
constexpr int MAX_STATE = MAX_N * MAX_A + 1;
long long int dp[MAX_N][MAX_STATE];

int SIZE[MAX_N];
struct train{
    int to;
    int fare;
    int dist;
    constexpr train(void): to(), fare(), dist(){}
    constexpr train(const int to, const int fare, const int dist):to(to), fare(fare), dist(dist){}
} edge[MAX_N][MAX_N];

struct station_t{
    int coin;
    int time;
    constexpr station_t(void):coin(), time(){}
} station[MAX_N];

struct dijkstra_info{
    long long int d;
    int vertex;
    int coin;
    constexpr dijkstra_info(void):d(), vertex(), coin(){}
    constexpr dijkstra_info(const long long int d, const int vertex, const int coin):d(d), vertex(vertex),coin(coin){}
    inline bool operator < (const dijkstra_info& other) const {
        if(d != other.d) return d > other.d;
        if(coin != other.coin) return coin < other.coin;
        return vertex > other.vertex;
    }
};


int main(void){
    std::cin.sync_with_stdio(false); std::cin.tie(nullptr);
    std::cout.sync_with_stdio(false); std::cout.tie(nullptr);
    int n, m, S; std::cin >> n >> m >> S;
    for(int i = 0; i < n; ++i) std::fill(dp[i], dp[i] + MAX_STATE, 1LL << 60);
    for(int i = 0; i < m; ++i){
        int u, v, a, b; std::cin >> u >> v >> a >> b; --u; --v;

        edge[u][SIZE[u]++] = {v, a, b}; edge[v][SIZE[v]++] = {u, a, b};
    }
    for(int i = 0; i < n; ++i) std::cin >> station[i].coin >> station[i].time;
    const int Need = 50 * n; if(Need < S) S = Need;

    std::priority_queue<dijkstra_info> PQ;
    PQ.emplace(0, 0, S); dp[0][S] = 0;
    while(not PQ.empty()){
        const auto [d, v, c] = PQ.top(); PQ.pop();

        if(d > dp[v][c]) continue;
        for(int nc = c - station[v].coin; nc >= 0 and dp[v][nc] > dp[v][c]; nc -= station[v].coin) dp[v][nc] = dp[v][c];
        {
            const int nc = c + station[v].coin; const long long int nd = d + station[v].time;
            if(0 <= nc and nc <= Need and dp[v][nc] > nd){ dp[v][nc] = nd; PQ.emplace(nd, v, nc); }
        }
        for(int i = 0; i < SIZE[v]; ++i){
            const int nc = c - edge[v][i].fare; if(nc < 0) continue;
            const long long int nd = d + edge[v][i].dist;
            if(dp[edge[v][i].to][nc] > nd){
                dp[edge[v][i].to][nc] = nd; PQ.emplace(nd, edge[v][i].to, nc);
            }
        }
    }
    for(int i = 1; i < n; ++i){
        long long int res = 1LL << 60;
        for(int j = 0; j < Need; ++j) if(dp[i][j] < res) res = dp[i][j];
        std::cout << res << '\n';
    }
    return 0;
}

Measured memory_bytes: 4872
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

///Astalavista Code........~boy_with_no_gf
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 2e6 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
inline void PP(int n) { cout << n << " ";}
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].first << " " << v[i].second << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << ' ' ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}

// <=================================================================================================================================
// <=================================================================================================================================

void fun(){
	int n;cin>>n;
	vi arr(n);
	for(int i=0;i<n;i++)cin>>arr[i];
	vi pre(n+1,0);
	for(int i=n-1;i>=0;i--){
		pre[i]=pre[i+1]+arr[i];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		ans=(ans%M+((arr[i]%M)*(pre[i+1]%M))%M)%M;	
	}
	cout<<ans;
}

signed  main() {
    lets_go

    int t;
    t=1;
//    cin >> t;
    while (t--) {

    fun();

    }



    return 0;

}


Measured memory_bytes: 6304
#include <iostream>
#include <algorithm>
#include <queue>
#include <cassert>
#include <random>
#include <ctime>
#include <chrono>
using namespace std; typedef long long ll; const int IN=1e9;
typedef pair<int,int> P; const ll m=1e9+7;
const P INF = {1e9, 1e9}; typedef pair<P,P> P2;
int main() {
  int h,w,k; cin>>h>>w>>k;
  string s[h]; for(int i=0;i<h;i++) cin>>s[i];

  int sx,sy;
  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) if (s[i][j]=='S') sx=i, sy=j;
  }
  int px[4]={1,-1,0,0};
  int py[4]={0,0,1,-1};
  P an[h][w]; for(int i=0;i<h;i++) for(int j=0;j<w;j++) an[i][j]=INF;
  an[sx][sy]={0,k}; // コスト、進んだ回数
  priority_queue<P2, vector<P2>, greater<P2>> que;
  que.push({{0,k},{sx,sy}});

  while(!que.empty()) {
    P point=que.top().first;
    int nx=que.top().second.first;
    int ny=que.top().second.second;
    que.pop();
    //cout<<point.first<<" "<<point.second<<" "<<nx<<" "<<ny<<endl;
    if (point > an[nx][ny]) continue;
    if (point.second == k) point.first++, point.second=0;
    point.second++;

    for(int i=0;i<4;i++) {
      int tx=nx+px[i], ty=ny+py[i];
      if (point.first!=1 || s[tx][ty]=='.') {
        if (an[tx][ty] > point) {
          an[tx][ty]=point;
          if (tx != 0 && tx != h-1 && ty != 0 && ty != w-1)
            que.push({point, {tx,ty}});
        } 
      } else {
        P point2={2,1};
        if (an[tx][ty] > point2) {
          an[tx][ty]=point2;
          if (tx != 0 && tx != h-1 && ty != 0 && ty != w-1)
            que.push({point2, {tx,ty}});
        }
      }
    }
  }
  
  /*for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      cout<<"("<<an[i][j].first<<","<<an[i][j].second<<") ";
    } cout<<endl;
  }*/
  int answer=1e9;
  for(int i=0;i<h;i++) {
    answer=min(answer,an[i][0].first); answer=min(answer,an[i][w-1].first);
  }
  for(int j=0;j<w;j++) {
    answer=min(answer,an[0][j].first); answer=min(answer,an[h-1][j].first);
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 11508
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int H1,M1,H2,M2,K;
    scanf("%d%d%d%d%d",&H1,&M1,&H2,&M2,&K);
    printf("%d\n",(60*H2+M2)-(60*H1+M1)-K);
    return 0;
}


Measured memory_bytes: 3816
s = input()
sl = len(s)
dp = {}
ct = [0] * sl
for x in range(sl):
    dp[(0, x)] = x - 1 if s[x] == 'L' else x + 1
for i in range(17):
    for j in range(sl):
        dp[(i + 1, j)] = dp[(i, dp[(i, j)])]
for x in range(sl): ct[dp[(17, x)]] += 1
print(' '.join([str(ct[x]) for x in range(sl)]))

Measured memory_bytes: 243972
#include <iostream>
#include <algorithm>

int main() {
    using namespace std;

    int X;
    cin >> X;

    int r = 1;
    for (int i=2; i<X; i++) {
        int s = i*i;
        while (s <= X) {
            r = max(r, s);
            s *= i;
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256