akhauriyash/Code-Regression huggingface dataset:
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    in >> n;
    vector<ll> a(n);
    REP(i, n) in >> a[i];
    SORT(a);
    ll pre_a = 0;
    ll count_a = 0;
    ll max1 = 0, max2 = 0;
    REP(i, n){
        if (pre_a != a[i]){
            if (count_a == 2 or count_a == 3){
                if (a[i-1] > max1){
                    max2 = max1;
                    max1 = a[i-1];
                }else if(a[i] > max2){
                    max2 = a[i-1];
                }
            }else if(count_a >= 4){
                if (a[i-1] > max1){
                    max1 = a[i-1]; max2 = a[i-1];
                }else if(a[i-1] > max2){
                    max2 = a[i-1];
                }
            }
            count_a = 1;
        }else{
            count_a += 1;
        }
        pre_a = a[i];
        if (i == n-1){
            if (count_a == 2 or count_a == 3){
                if (a[i-1] > max1){
                    max2 = max1;
                    max1 = a[i-1];
                }else if(a[i] > max2){
                    max2 = a[i-1];
                }
            }else if(count_a >= 4){
                if (a[i-1] > max1){
                    max1 = a[i-1]; max2 = a[i-1];
                }else if(a[i-1] > max2){
                    max2 = a[i-1];
                }
            }
        }
    }
    out << max1 * max2 << endl;
}


Measured memory_bytes: 1024
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let s: u64 = read_as_vec()[0];
    let n10pow9: u64 = 1_000_000_000;
    let y = (s + n10pow9 - 1) / n10pow9;
    let x = n10pow9 * y - s;

    println!("0 0 1000000000 1 {} {}", x, y);
}


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  = 3.141592653589793238463;
const int N = 1e5+10;
const ll INF = 1LL << 60;

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


// Main Code

int maxL[N];

int main()
{
	int n, m;
	cin>>n>>m;
	rep(i, 0, m)
	{
		int x, y;
		cin>>x>>y;
		chmax(maxL[y], x);
	}
	int ans = 0;
	int r = 1;
	repn(i, 1, n)
	{
		if(maxL[i] >= r)
		{
			r = i;
			ans++;
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){

  int q;
  set <int> a;
  cin>>q;

  for(int i=0;i<q;i++){
    int n,x;
    cin>>n>>x;
    if(n) cout<<(a.end()!=a.find(x))<<endl;
    else{
      a.insert(x);
      cout<<a.size()<<endl;
    }
  }
  return 0;

}



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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> H){
    std::vector<long long> dH((int)N, 0);
    dH[0] = H[0] - 0;
    for(int i = 0; i < (int)N; ++i) dH[i+1] = H[i+1] - H[i];
    //for(int i = 0; i < (int)N; ++i) cout << dH[i] << endl;
    bool ans = false;
    bool cont = false;
    for(int i = 0; i < (int)N; ++i){
        if(dH[i] < -1) ans = true;
        else{
            if(cont){
                if(dH[i] == -1){
                    ans = true;
                }else if(dH[i] == 0){
                }else cont = false;
            }else{
                if(dH[i] == -1){
                    cont = true;
                }
            }
        }
        if(ans) break;
    }
    if(ans) cout << NO << endl;
    else cout << YES << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>

#define REP(i,n) for(int i=0;i<n;i++)
#define maxi(a,b) (((a) > (b)) ? (a) : (b))
#define mini(a,b) (((a) < (b)) ? (a) : (b))

using namespace std;

vector<string> split(const string &str, char delim);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    /********************************************************/
    string str;
    cin >> str;

    int n = 0;
    int w = 0;
    int s = 0;
    int e = 0;

    for(int i = 0; i < str.length(); i++){
        string c = str.substr(i, 1);
        if(c == "N"){
            n = 1;
        }
        if(c == "W"){
            w = 1;
        }
        if(c == "S"){
            s = 1;
        }
        if(c == "E"){
            e = 1;
        }
    }


    if(n == s && w == e){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    /********************************************************/
    return 0;
}


vector<string> split(const string &str, char delim) {
    vector<string> res;
    size_t current = 0, found;
    while ((found = str.find_first_of(delim, current)) != string::npos) {
        res.push_back(string(str, current, found - current));
        current = found + 1;
    }
    res.push_back(string(str, current, str.size() - current));
    return res;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(){


	int n;

	int *a;
	cin>>n;
	a = new int[n];

	int kisuu =0;
	int guusuu=0;

	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%2==0){
			guusuu++;
		}else{
			kisuu++;
		}
	}

	guusuu += kisuu/2;
	kisuu = kisuu%2;

	//奇数＋奇数＝偶数
	//偶数＋偶数＝偶数

	if(kisuu==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n;
int a[1001][1001];
int cur[1001];
bool used[1001];
int main(){
    cin>>n;
    rep(i,n)rep(j,n-1){
        cin>>a[i][j];
        --a[i][j];
    }
    queue<int> q,nq;
    rep(i,n) q.push(i);
    int cnt=0,cnt2=0;
    while(1){
        ++cnt;
        memset(used,0,sizeof(used));
        while(!q.empty()){
            int v=q.front();q.pop();
            if(used[v]||cur[v]==n-1) continue;
            int w=a[v][cur[v]];
            if(!used[w]&&a[w][cur[w]]==v){
                used[v]=true;
                used[w]=true;
                ++cur[v];
                if(cur[v]==n-1) ++cnt2;
                else nq.push(v);
                ++cur[w];
                if(cur[w]==n-1) ++cnt2;
                else nq.push(w);
            }
            else if(used[w])nq.push(v);
        }
        if(cnt2==n) break;
        if(nq.empty()){
            cout<<-1<<endl;
            return 0;
        }
        swap(nq,q);
    } 
    cout<<cnt<<endl;
    return 0;
}


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

int main() {
  int A,B;
  cin>>A>>B;
  if(A>B){
    cout<<A+A-1<< endl;
  }
  if(A<B){
    cout<<B+B-1<< endl;
  }
  if(A==B){
    cout<<2*A<< endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int  main()
{
int n;
cin>>n;
int arr[n][3];
for(int i=0;i<n;i++)
{
	cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
}
for(int i=1;i<n;i++)
{
	for(int j=0;j<3;j++)
	{
 		arr[i][j]+=max(arr[i-1][(j+1)%3],arr[i-1][(j+2)%3]);
	}
}
// for(int i=0;i<n;i++)
// {
// 	for(int j=0;j<3;j++)
// 	{
//  		cout<<arr[i][j]<<" ";
// 	}
// 	cout<<endl;
// }
cout<<max(max(arr[n-1][0],arr[n-1][1]),arr[n-1][2])<<endl;
	return 0;
}

Measured memory_bytes: 1408
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<usize>();
    let b = read::<usize>();
    println!("{}", if a * b % 2 == 0 { "No" } else { "Yes" });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long ld;
int read(){int x;scanf("%d",&x);return x;}
const int MAXN=5005;
int N,K,num;
int head[MAXN],dep[MAXN],ans,res;
bool vis[MAXN];
int l[MAXN],r[MAXN];
struct line{
	int nxt,to;	
}e[MAXN];
void add(int u,int v){
	e[num]=(line){head[u],v},head[u]=num,num++;
	e[num]=(line){head[v],u},head[v]=num,num++;
} 
void dfs(int u,int fa){
	vis[u]=true,dep[u]=dep[fa]+1;
	if(dep[u]>K/2) res++;
	for(int i=head[u];~i;i=e[i].nxt){
		if(e[i].to!=fa&&!vis[e[i].to]) dfs(e[i].to,u);
	}
}
int main(){
	memset(head,-1,sizeof(head));
	N=read(),K=read(),dep[0]=-1,ans=N;
	for(int i=1;i<N;i++){
		l[i]=read(),r[i]=read();
		add(l[i],r[i]);
	}
	if(K%2==0){
		for(int i=1;i<=N;i++){
			memset(vis,0,sizeof(vis));
			res=0,dfs(i,0);
			ans=min(res,ans);
		}
	}
	else{
		for(int i=1;i<N;i++){
			memset(vis,0,sizeof(vis));
			vis[l[i]]=true,vis[r[i]]=true;
			res=0,dfs(l[i],0),dfs(r[i],0);
			ans=min(res,ans);
		}
	}
	printf("%d\n",ans);
	return 0;	
} 

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var edges = new Dictionary<int, List<int>>(n);
        for (int i = 1; i <= n; ++i)
            edges[i] = new List<int>();
        for (int count = n - 1; count != 0; --count)
        {
            var line = Console.ReadLine().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            edges[a].Add(b);
            edges[b].Add(a);
        }

        var past = new bool[n + 1];
        var current = new List<int>(){ 1 };
        var next = new List<int>();
        int end = 0;

        for (int count = 1; count > 0; count = current.Count)
        {
            end = current[0];
            next.Clear();

            for (int i = 0; i < count; ++i)
            {
                var c = current[i];
                past[c] = true;

                var points = edges[c];
                for (int j = 0, pc = points.Count; j < pc; ++j)
                {
                    var point = points[j];
                    if (!past[point])
                        next.Add(point);
                }
            }

            var tmp = current;
            current = next;
            next = tmp;
        }

        int dia = 0;
        current.Add(end);
        for (var count = 1; count > 0; count = current.Count, ++dia)
        {
            next.Clear();
            for (int i = 0; i < count; ++i)
            {
                var c = current[i];
                past[c] = false;

                var points = edges[c];
                for (int j = 0, pc = points.Count; j < pc; ++j)
                {
                    var point = points[j];
                    if (past[point])
                        next.Add(point);
                }
            }

            var tmp = current;
            current = next;
            next = tmp;
        }

        Console.WriteLine(dia % 3 == 2 ? "Second" : "First");
    }
}


Measured memory_bytes: 44224
px, py = map(int, input().split())
cx, cy, r = map(int, input().split())
dx, dy = px - cx, py - cy
s2 = dx ** 2 + dy ** 2
df = (s2 - r ** 2) ** 0.5
ix1, ix2 = (dx * r + dy * df) * r / s2, (dx * r - dy * df) * r / s2
iy1, iy2 = (dy * r - dx * df) * r / s2, (dy * r + dx * df) * r / s2
if (ix1, iy1) > (ix2, iy2):
    ix1, ix2 = ix2, ix1
    iy1, iy2 = iy2, iy1
print(ix1 + cx, iy1 + cy)
print(ix2 + cx, iy2 + cy)

Measured memory_bytes: 7712
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int a;
    string s;
    cin >> a >> s;

    if (a >= 3200) {
        cout << s << '\n';
    } else {
        cout << "red" << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int ans = 0;
  rep(i, n) {
    if(h[i] >=k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3716
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>
#include<float.h>

int main(){
	int n, t, a, h, ans;
	float diff, min = FLT_MAX;
	scanf("%d\n", &n);
	scanf("%d %d\n", &t, &a);
	for(int i=1; i<n+1; i++){
		scanf("%d", &h);
		diff = fabs(t - (float)h * 0.006 - a);
		if(diff < min) {
			min = diff;
			ans = i;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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


int main(){
	string S;
	bool check=0;
	cin >>S;
	int n=(int)S.length();
	for(int i=0;i<n;i++){
		if(2*(i/2)==i){
			if(S[i]=='L') check=1;
		}else{
			if(S[i]=='R') check=1;
		}
	}
	if(check==1){
		cout <<"No"<<endl;
	}else{
		cout <<"Yes"<<endl;
	}
	return 0;
}

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

typedef long long ll;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

typedef long double D;
typedef complex<D> P;

#define X real()
#define Y imag()

const D eps=1e-8;
const D inf=1e12;
const D PI=acos(-1);

namespace std{
  bool operator<(const P& a,const P& b){
    return a.X==b.X?a.Y<b.Y:a.X<b.X;
  }
}
bool cmp_x(const P& a,const P& b){ return abs(a.X-b.X)<eps?a.Y<b.Y:a.X<b.X; }
bool cmp_y(const P& a,const P& b){ return abs(a.Y-b.Y)<eps?a.X<b.X:a.Y<b.Y; }
bool cmp_a(const P& a,const P& b){ return arg(a)==arg(b)?norm(a)<norm(b):arg(a)<arg(b); }
D cross(P a,P b){ return (conj(a)*b).Y; }
D dot(P a,P b){ return (conj(a)*b).X; }
D toRag(D deg){ return deg*PI/180.0; }
P rot(P base,P a,D theta){ return base+polar(abs(a-base),arg(a-base)+theta); }

struct L : public vector<P> { // line and segment
  L(P a,P b){
    push_back(a);
    push_back(b);
  }
};

struct C{
  P p; D r;
  C(P p,D r):p(p),r(r){}
};

enum RELATION{SAME=1,CONTAINED=2,OVER=4,NO_CROSS=8,ONE_CROSS=16,ONE_CONTAINED_CROSS=32,ONE_OVER_CROSS=64,TWO_CROSS=128};
int cRel(C c1, C c2) {
  D d=abs(c1.p-c2.p);
  D dr1=c1.r-c2.r,dr2=c2.r-c1.r;
  D ar=c1.r+c2.r;
  if(d<eps&&c1.r==c2.r)return SAME;
  if(d<dr1)return OVER;
  if(d<dr2)return CONTAINED;
  if(d==dr1)return ONE_OVER_CROSS;
  if(d==dr2)return ONE_CONTAINED_CROSS;
  if(d==ar)return ONE_CROSS;
  if(d>ar)return NO_CROSS;
  return TWO_CROSS;
}

// 2????????±?????\???
L tanC(C c,D t){
    P p=c.p+polar(c.r,t);
    P d=polar(c.r,t)*P(0,1);
    return L(p-d,p+d);
}
vector<L> tanCC(C c1,C c2){
  vector<L> res;
  D d=arg(c2.p-c1.p),d2=arg(c1.p-c2.p);
  D i=acos((c1.r+c2.r)/abs(c2.p-c1.p));
  D o=acos((c1.r-c2.r)/abs(c2.p-c1.p));
  int r=cRel(c1,c2);
  if(r==NO_CROSS){
    res.push_back(tanC(c1,d+i));
    res.push_back(tanC(c1,d-i));
  }
  if(!(r&(SAME|CONTAINED|OVER|ONE_CONTAINED_CROSS|ONE_OVER_CROSS))){
    res.push_back(tanC(c1,d+o));
    res.push_back(tanC(c1,d-o));
  }
  if(r&(ONE_CROSS|ONE_CONTAINED_CROSS|ONE_OVER_CROSS)){
    if(r&ONE_CONTAINED_CROSS) res.push_back(tanC(c2,d2));
    else res.push_back(tanC(c1,d));
  }
  return res;
}

P projection(L l,P p){
  P b=l[1]-l[0],c=p-l[0];
  return l[0]+b*(c/b).X;
}


int main(){
	cin.sync_with_stdio(false);
  vector<C> cs;
  rep(i,2){
    D x,y,r;
    cin>>x>>y>>r;
    cs.push_back(C(P(x,y),r));
  }
  vector<L> ls=tanCC(cs[1],cs[0]);
  vector<P> res;
  rep(i,ls.size()){
    P ans=projection(ls[i],cs[0].p);
    res.push_back(ans);
  }
  sort(all(res),cmp_x);
  rep(i,res.size()){
    printf("%.10Lf %.10Lf\n", res[i].X,res[i].Y);
  }
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    int ans = n - 1;
    REP(i,n-1){
        if (s[i] != s[i + 1]) ans--;
    }
    chmax(ans, min(n - 1, ans + 2 * k));
    cout << ans << endl;
    return 0;
}


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

const int N = 1010, M = 200010;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}


int n, m, fr[M], to[M], nxt[M], tt, s, t, id[N], h[N];
bool vis[N][N], can[M];
vector<int> E[N];

void addedge (int u,int v) {
	fr[++tt] = u, to[tt] = v;
	nxt[tt] = h[u], h[u] = tt;
	E[u].push_back(v);
}

void dfs (int u) {
	vis[s][u] = true;
	if (id[u]) return;
	id[u] = t;
	for (auto v : E[u]) {
		if(!id[v] && v != s) dfs(v);
	}
}

int main () {
	cin >> n >> m;
	for(int i = 1, u, v; i <= m; i++) read(u), read(v), addedge(u,v);
	
	for(s = 1; s <= n; s++) {
		memset(id, 0, sizeof(id));
		vector<int> son;

		for(int i = h[s], v; v = to[i], i; i=nxt[i]) son.push_back(v), dfs(t = v);
		reverse(son.begin(),son.end());
		for(int i = h[s], v; v = to[i], i; i=nxt[i]) {
			if(id[v] != v) can[i] = 1;
		}

		memset(id, 0, sizeof(id));
		for(auto v : son) dfs(t = v);
		for(int i = h[s], v; v = to[i], i; i = nxt[i]) {
			if(id[v] != v) can[i] = 1;
		}
	}

	for(int i = 1; i <= m; i++) {
		int u = fr[i], v = to[i];
		if(can[i] == vis[v][u]) cout << "same\n";
		else cout << "diff\n";
	}
	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main() {
    double r;
    cin>>r;
    cout<<2*r*M_PI<<endl;
}


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

int main() {
	int K; //入力整数
	cin >> K;
	int odd; //奇数
	int even;//偶数
	
	if(K%2 == 0){
		odd = K/2;
		even = K/2;
	}else{
		odd = K/2;
		even = K/2 + 1;
	}
	
	cout << odd * even << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define lout cout
#else
stringstream devnull;
#define lout devnull
#endif

int main()
{
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  lout << a << " " << b << " " << c << " " << d << endl;
  string s;
  cin >> s;
  s = "#" + s + "#";

  // auto can_reach = [&](int start, int end) {
  //   for (int i = start; i + 1 <= end; i++)
  //   {
  //     if (s[i] == '#' && s[i + 1] == '#')
  //       return false;
  //   }
  //   return true;
  // };

  auto can_reach = [&s](int start, int end) {
    return s.substr(start, end - start + 1).find("##") == string::npos;
  };

  if (!(can_reach(a, c) && can_reach(b, d)))
  {
    lout << "can_reach" << endl;
    puts("No");
    return 0;
  }

  if (c < d)
  {
    puts("Yes");
    return 0;
  }

  bool snuke_can_over = false;
  for (int i = b; i <= d; i++)
    if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.')
      snuke_can_over = true;

  // if (!snuke_can_over)

  if (s.substr(b - 1, d - b + 3).find("...") == string::npos)
  {
    lout << "snukecanover" << endl;
    puts("No");
    return 0;
  }
  else
  {
    puts("Yes");
    return 0;
  }
}


Measured memory_bytes: 772
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);

    if(a<b && b<c)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");

    return 0;
}



Measured memory_bytes: 2044
loop do
	a, op, b = gets.chomp.split(" ") 
	a = a.to_i
	b = b.to_i
	case op
	when "+" then
		puts a + b
	when "-" then
		puts a - b
	when "*" then
		puts a * b
	when "/" then
		puts a / b
	else
		break
	end
end

Measured memory_bytes: 6096
#include<stdio.h>
char A, B, T, a, b;
int main(void){
	A=getchar();
	a=1; b=0;
	T=getchar();
	if(T==A){a++;}else if(b==0){B=T; b=1;}else if(b>0 && T==B){b++;}
	T=getchar();
	if(T==A){a++;}else if(b==0){B=T; b=1;}else if(b>0 && T==B){b++;}
	T=getchar();
	if(T==A){a++;}else if(b==0){B=T; b=1;}else if(b>0 && T==B){b++;}
	if(a==2 && b==2){
		puts("Yes");
	}else{
		puts("No");
	}
}



Measured memory_bytes: 128
#include <cstdio>
#include <vector>
using namespace std;
int n,m;
vector<int> al[100005];
int main(){
    scanf("%d%d",&n,&m);
    int a,b;
    while (m--){
        scanf("%d%d",&a,&b);
        al[a].push_back(b);
        al[b].push_back(a);
    }

    int rings=0;
    for (int x=1;x<=n;x++) if (al[x].size()&1){
        printf("No\n");
        return 0;
    }

    int curr,prev;
    for (int x=1;x<=n;x++){
        if (al[x].size()>2){
            for (vector<int>::iterator it=al[x].begin();it!=al[x].end();it++){
                curr=(*it),prev=x;
                while (al[curr].size()==2){
                    if (prev==al[curr][0]){
                        prev=curr;
                        curr=al[prev][1];
                    }
                    else{
                        prev=curr;
                        curr=al[prev][0];
                    }
                }
                if (curr==x) rings+=2;
                else rings++;
            }
        }
    }

    printf((rings>=12)?"Yes\n":"No\n");
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]){
    	cout << "YES" << endl;
    }else{
    	cout << "NO" << endl;
    }
    return 0;
}


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

int main() {
  int a,b; cin >> a >> b;
  int sum = a+b;
  if (sum >= 10) cout << "error" << endl;
  else cout << sum << endl;
  return 0;
}


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

int main(){
    string s;
    bool res = false;

    cin >> s;

    for(int i = 0; i < s.length(); i++){
        if(s[i] == '7'){
            res = true;
            break;
        }
    }

    if(res){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3620
def main():
    N = int(input())
    S = input()

    merge = []
    sura = S[0]

    merge.append(sura)

    for i in range(1, N):

        if sura == S[i]:
            continue
        else:
            sura = S[i]
            merge.append(S[i])

    print(len(merge))


if __name__ == "__main__":
    main()


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

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    int sizea = a.size();
    int sizeb = b.size();
    int sizec = c.size();
    if (a[sizea - 1] == b[0] && b[sizeb - 1] == c[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
x_y = input().split()
x_y = [int(i) for i in x_y]
x = x_y[0]
y = x_y[1]
# if x[0]*4 < x[i] or x[0]*2 > x[i]:
#     print('No')
s = 0
a = False
while s != x+1:
    if (x-s)*4 + s*2 > y:
        if x == s:
            print('No')
            break
    elif (x-s)*4 + s*2 == y:
        print('Yes')
        break
    elif (x-s)*4 + s*2 < y:
        print('No')
        break
    s+=1

Measured memory_bytes: 9208
#include<stdio.h>
int a[100005];
int main()
{
    int n,i,max,min,x;
    scanf("%d",&n);
    max=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(max<a[i])
            max=a[i];
    }
    if(n==2)
    {
        x=a[0]>=a[1]?a[0]:a[1];
        min=a[0]<a[1]?a[0]:a[1];
         printf("%d %d\n",x,min);
    }
    else
    {
        min=0;
    for(i=0;i<n;i++)
    {
        if(a[i]<(max/2))
        {
            if(min<(a[i]))
            {
                 min=a[i];
                 x=i;
            }

        }
        else
        {
            if(min<(max-a[i]))
            {
                 min=max-a[i];
                 x=i;
            }

        }
    }
    printf("%d %d\n",max,a[x]);
    }

    return 0;
}


Measured memory_bytes: 512
var
 ans:qword;
 a,b,c,i,j,z:longint;
 s:array[1..10000]of string;
 k:array[1..10000]of longint;
begin
 readln(a,b,c);
  for i:=1 to a do
   begin
        str(i,s[i]);
        for j:=1 to length(s[i]) do
        begin
            val(s[i][j],z);
            k[i]:=k[i]+z;
        end;
        if(k[i]>=b)and(k[i]<=c)then inc(ans,i);
   end;
  writeln(ans);
end.

Measured memory_bytes: 512
fun main(args: Array<String>) {
    var a = 0
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(" ").map { it.toInt() }
    val l2 = readLine()!!.split(" ").map { it.toInt() }
    for(i in 0 until n){
        if(l[i] - l2[i] > 0) a += (l[i] - l2[i])
    }
    println(a)
}

Measured memory_bytes: 36140
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Queue<Character> result = new LinkedList<Character>();
		try (Scanner sc = new Scanner (System.in)){
			while (true) {
				int m = sc.nextInt();
				int f = sc.nextInt();
				int r = sc.nextInt();

				if ((m == -1) && (f == -1) && (r == -1)) break;

				char a = Judge(m,f,r);
				result.add(a);
			}
			int a = result.size();
			for (int i = 0; i < a; i++)  {
				System.out.println(result.remove());
			}
		}
	}

	static char Judge(int m,int f,int r) {
		if (m == -1) return 'F';
		else if (f == -1) return 'F';
		else if (m + f >= 80) return 'A';
		else if (m + f >= 65) return 'B';
		else if (m + f >= 50) return 'C';
		else if (m + f >= 30) {
			if (r >= 50) return 'C';
			else return 'D';
		}
		return 'F';
	}

}


Measured memory_bytes: 26172
a,b = map(int,input().split())
len_b = (len(str(b)))
tmp = 1 
for i in range(len_b):
    tmp = tmp*10

a = a*tmp
result = a+b
flag = False
for i in range(1,400):
    if result == i**2:
        flag = True
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>

using namespace std;

#define FOR(i, a, b) for(i=a; i<b; ++i)

#define MAXN

int a, b;

void solver() {
  return;
}

int main() {
  scanf("%d %d", &a, &b);
  printf("%d\n", a*b-(a+b-1));
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define MOD 1000000007
using namespace std;
typedef long long LL;
#define R freopen("555input.txt","r",stdin);
#define N 205
int ans,i,j,k,n,T,a,b,c,d,e,f,x,y,l,sum,wtr,swt;
struct fs
{
    int s,m;
}ma;
int main()
{

ma.m=1;
    cin>>a>>b>>c>>d>>e>>f;
    for(i=0;i<=f/(a*100);i++)
    {
        for(j=0;j<=f/(b*100);j++)
        {
            for(k=0;k<=f/c;k++)
            {
                for(l=0;l<=f/d;l++)
                {
                    sum=100*(a*i+b*j)+c*k+d*l;
                    wtr=a*i+b*j;
                    swt=c*k+d*l;
                    if(sum>f||swt>e*wtr)continue;
                    if(ma.s*wtr<=swt*ma.m)
                    {
                        ma.s=swt;
                        ma.m=wtr;
                        ans=sum;
                    }
                }
            }
        }
    }
cout<<ans<<" "<<ma.s;

    return 0;
}


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

#define _USE_MATH_DEFINES

#include <math.h>

using namespace std;

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

    int N;
    cin >> N;

    vector<int> subs(N + 1, 0);

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

    for (int i = 1; i <= N; i++)
        cout << subs[i] << endl;

    return 0;
}


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

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

// code starts
int main()
{
	double r;cin>>r;
	double PI = acos(-1);
	r=r*2.0*PI;
	cout<<fixed<<setprecision(10)<<r<<endl;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
using namespace std;
 
#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
 
#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)
 
typedef long long ll;
typedef pair<int, int> pii;

int N, M;
vector<int> cs, xs;

const int INF = 1<<29;

const int MAX_N = 20010;

int dp[MAX_N][256];

inline int dbl(int n) { return n*n; }

int main()
{
	while (cin >> N >> M, N|M) {
		cs = vector<int>(M);
		xs = vector<int>(N);

		rep(i, M) cin >> cs[i];
		rep(i, N) cin >> xs[i];

		rep(i, MAX_N) rep(j, 256) dp[i][j] = INF;
		dp[0][128] = 0;
		for (int i = 1; i <= N; i++) {
			for (int u = 0; u <= 255; u++) {
				if (dp[i-1][u] == INF) continue;
				for (int j = 0; j < M; j++) {
					int t = u + cs[j];
					t = t<0?0:t>255?255:t;
					dp[i][t] = min(dp[i][t], dp[i-1][u]+dbl(t-xs[i-1]));
				}
			}
		}
		cout << *min_element(dp[N], dp[N]+256) << endl;
	}
	return 0;
}

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

char c[40][15];

int main(){
	int n;
	while (scanf("%d", &n), n){
		int want[] = { 5, 7, 5, 7, 7 };
		int cnt = 0;
		int j = 0;
		for (int i = 0; i < n; i++){
			scanf("%s", c[i]);
		}
		int t;
		for (t = 0; t < n; t++){
			for (int i = t; i < n; i++){
				cnt += strlen(c[i]);
				if (cnt == want[j]){
					cnt = 0;
					if (++j == 5)break;
				}
				if (cnt > want[j])break;
			}
			if (j == 5)break;
			j = 0;
			cnt = 0;
		}
		printf("%d\n", t+1);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#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 rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T & a, const T & b) { if (b < a) { a = b; return 1; } return 0; }

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, d;
	ll c;
	//char c;
	ll h, w;
	ll k;
	string s, t;
	//ll s, t;
	ll l_ans = 0;
	string s_ans = "NG";

	cin >> h >> w;
	vector<string> cv(h);
	rep(i, h) cin >> cv[i];

	s_ans = "Yes";
	bool is_ok = false;
	rep(i, h)rep(j, w) {
		if (cv[i][j] == '#') {
			int dw[] = { -1,0,1,0 }, dh[] = { 0,1,0,-1 };
			is_ok = false;
			rep(k, 4) {
				int nh = i + dh[k];
				int nw = j + dw[k];
				if (nh >= 0 && nh <= h - 1 && nw >= 0 && nw <= w - 1) {
					if (cv[nh][nw] == '#') {
						is_ok = true;
						break;
					}
				}
			}
			if (!is_ok) {
				s_ans = "No";
				break;
			}
		}
	}

	cout << s_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(){

  int n;
  cin>>n;

  vector <int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];

  int q;
  cin>>q;

  for(int i=0;i<q;i++){
    int b,m,e;
    cin>>b>>m>>e;

    rotate(a.begin()+b,a.begin()+m,a.begin()+e);

  }

  int i=0;
  for(int e:a) cout<<(i++?" ":"")<<e;
  cout<<endl;

  return 0;

}



Measured memory_bytes: 3128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	a := nextInt()
	b := nextInt()

	if a > b {
		fmt.Println(0)
		return
	}
	if n == 1 {
		if a != b {
			fmt.Println(0)
		} else {
			fmt.Println(1)
		}
		return
	}

	lower := a*(n-1) + b
	upper := a + b*(n-1)

	fmt.Println(upper - lower + 1)
	return
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
#define rep(i,l,p) for(int i=l;i<=p;i++)
#define mp make_pair
typedef pair<long long,int> P;
typedef long long ll;
const int N = 1e5+5;
int n;
ll a[N],b[N],sum[N];
priority_queue<P> q;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i,1,n){
        cin >> a[i] >> b[i];
        sum[i] = a[i]+b[i];
        q.push(mp(sum[i],i));
    }

    ll sumt = 0,suma = 0;
    int t = 0;
    while(!q.empty()){
        int id = q.top().second; q.pop();
        t++;
        if(t&1){
            sumt += a[id];
        }else{
            suma += b[id];
        }
    }

    cout << sumt - suma <<endl;
}


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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 2e6+5;


void solve() {

  int k;
  cin>>k;
  cout<<360/__gcd(360ll,k);

}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}



int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[2][101];
  cin>>n;
  for(int i=0;i<2;i++)
    for(int j=0;j<n;j++)
      cin>>a[i][j];
  for(int i=1;i<n;i++)
    a[0][i]+=a[0][i-1];
  a[1][0]+=a[0][0];
  for(int i=1;i<n;i++)
    a[1][i]+=max(a[1][i-1],a[0][i]);
  cout<<a[1][n-1]<<endl;
  return 0;
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

const int MOD = 1e9+7;

int main() {
    ll N,M; cin >> N >> M;
    vector<ll> S(N), T(M);

    REP(i,N) cin >> S[i];
    REP(j,M) cin >> T[j];

    vector<vector<ll>> dp(N+1, vector<ll>(M+1,0));
    vector<vector<ll>> sum(N+1, vector<ll>(M+1,0));

    REP(i,N){
        REP(j,M){
            if(S[i] == T[j]){
                dp[i+1][j+1] = sum[i][j] + 1;
                dp[i+1][j+1] %= MOD;
            }
            sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] + dp[i+1][j+1];
            sum[i+1][j+1] %= MOD;

            sum[i+1][j+1] += MOD - sum[i][j];
            sum[i+1][j+1] %= MOD;
        }
    }

    ll ans = 1;
    REP(i,N+1){
        REP(j,M+1){
            ans += dp[i][j];
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 65776
#include "bits/stdc++.h"

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

	std::vector<int> a(n + 2);
	for (int i = 1; i <= n; i++) {
		std::cin >> a[i];
	}

	int sum = 0;
	for (int i = 0; i < a.size() - 1; i++) {
		sum += abs(a[i] - a[i + 1]);
	}

	for (int i = 1; i <= n; i++) {
		int ans = sum
			- abs(a[i - 1] - a[i])
			- abs(a[i] - a[i + 1])
			+ abs(a[i - 1] - a[i + 1]);

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

	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cmath>
#include <functional>
#include <limits>
#include <map>
#include <bitset>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)
#define digit 30
int main(){
    ll n;
    cin >> n;
    ll a[n+1];
    bitset<digit> sum(0);
    rep1(i,n){
        cin >> a[i];
        bitset<digit> tmp(a[i]);
        sum = (sum ^ tmp);
    }

    rep1(i,n){
        bitset<digit> tmp(a[i]);
        if(i != n){
            cout << (sum ^ tmp).to_ulong() << " ";
        }else{
            cout << (sum ^ tmp).to_ulong() << endl;
        }
    }

    return 0;
}

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

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

	int ans = 0, d[3] = {3,5,7};
	for (int i = 3; i < 10; i++){ // 桁数
		for (int bit = 0; bit < pow(3, i); bit++){
			int a = 0, p = bit;
			for (int j = 0; j < i; j++){
				a += d[p%3] * pow(10, j);
				p /= 3;
			}

			if(a > n){
				i = 10000;
				break;
			}

			// 以下,条件に合うかチェック
			string s = to_string(a);
			bool check[4] = {0};
			for (int j = 0; j < s.size(); j++){
				if(s[j] == '3') check[0] = 1;
				else if(s[j] == '5') check[1] = 1;
				else if(s[j] == '7') check[2] = 1;
				else check[3] = 1;
			}
			if(check[0] && check[1] && check[2] && !check[3]){
				ans++;
			}
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i, n) reps(i, 0, n)
#define deps(i, a, n) for (int i = (a); i >= (n); --i)
#define dep(i, n) deps(i, n, 0)
#define inf 2147483647
#define int long long
#define mod 1000000007

signed main(void)
{
	int n; cin >> n;
	int f[3000] = {1, 0, 0, 1};
	if (n > 3) reps (i, 4, n + 1) f[i] = (f[i - 1] + f[i - 3]) % mod;
	cout << f[n];
}


Measured memory_bytes: 3648
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var acum = new long[N+2];
            acum[0] = acum[N] = 0;
            var sum = Math.Abs(acum[1] = array[0]);

            for (var i = 1; i < N; i++)
            {
                sum += Math.Abs(array[i] - array[i - 1]);
                acum[i + 1] = array[i];
            }
            sum += Math.Abs(array[N - 1]);

            for (var i = 1; i <= N; i++)
            {
                Console.WriteLine(sum + Math.Abs(acum[i-1] - acum[i+1]) - (Math.Abs(acum[i-1]-acum[i])+Math.Abs(acum[i] - acum[i+1])));
            }
        }
    }
}


Measured memory_bytes: 26844
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <bitset>
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 1e9+7;

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

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

int main(void){
    
    int a,b,ans;
    char s;
    
    scanf("%d %c %d",&a,&s,&b);
    if(s == '+'){
        printf("%d\n",a+b);
    }else{
        printf("%d\n",a-b);
        
    }
    return 0;
}


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



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
 
 
//defines
typedef long long ll;
typedef long double ld;

    
ll a,b,c,n,m,k,t=1;

void solve()
{ 
    cin>>a>>b;
  a--;b--;
  if(b==0)cout<<0;
    else if(a>=b)cout<<1LL;
    else cout<<(b/a)+min(b%a,1LL);
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int64_t prod = 1;
  int64_t x{};
  constexpr auto kMax = static_cast<int64_t>(1000000000000000000LL);
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == 0) {
      prod = 0;
      break;
    }
    if (x <= kMax / prod) {
      prod *= x;
    } else {
      prod = kMax + 1;
    }
  }
  if (prod > kMax) {
    prod = -1;
  }
  cout << prod << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    ll x, y;
    cin >> x >> y;
    bool w = true;
    int cou = 1;
    ll now = x;
    while(w) {
        if(now * 2 <= y) {
            cou++; 
            now *= 2;
        }
        else w = false;
    }
    cout << cou << endl;

    return 0;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

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

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

int N;
vector<int> a;

map<int, i64> memo[200010];
i64 dp(int i, int cnt) {
    if (i >= N) {
        return (cnt == N / 2) ? 0 : -LINF;
    }
    if (cnt > N / 2 || cnt < i / 2 - 1) return -LINF;

    if (memo[i].count(cnt)) return memo[i][cnt];

    i64 ret = -LINF;
    chmax(ret, dp(i + 1, cnt));
    chmax(ret, dp(i + 2, cnt + 1) + a[i]);

    return memo[i][cnt] = ret;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    read(N);
    a.resize(N);
    read(a);

    print(dp(0, 0));

    return 0;
}


Measured memory_bytes: 49404