akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  ll a = n / 100;
  ll b=n % 10;
  if(a==b){
    print("Yes");
  }
  else{
    print("No");
  }
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

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

const int MAXN = 1e5+10;

ll A[MAXN];
ll sum[MAXN];
map<int,int>m1;

int main(){
	ll N,M;
	scanf("%d %d",&N,&M);
	for(int i=0;i<N;i++){
		scanf("%lld",&A[i]);
	}
	memset(sum,0,sizeof(sum));
	sum[0] = A[0];
	m1.insert(make_pair(A[0]%M,1));
	for(int i=1;i<N;i++){
		sum[i] = sum[i-1]+A[i];
		int c = sum[i]%M;
		map<int,int>::iterator iter = m1.find(c);
		ll a=0;
		ll b=0;
		if(iter!=m1.end()){
			a = iter->first;
			b = iter->second;
			m1.erase(iter);
			m1.insert(make_pair(a,b+1));
		}else{
			a = c;
			m1.insert(make_pair(a,1));
		}
	}
	ll ans = 0;
	map<int,int>::iterator iter;
	for(iter=m1.begin();iter!=m1.end();iter++){
		ll a= iter->first;
		ll b= iter->second;
		if(a==0)	ans+=b;
		ans += b*(b-1)/2;
	}
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 4736
//Serene
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
#define ll long long
#define db double
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
const int maxn=100+7,W=90;
const ll mod=1e9+7;
ll Td,n,m,ans,sum,f[maxn];

char cc;ll ff;
template<typename T>void read(T& aa) {
	aa=0;ff=1; cc=getchar();
	while(cc!='-'&&(cc<'0'||cc>'9')) cc=getchar();
	if(cc=='-') ff=-1,cc=getchar();
	while(cc>='0'&&cc<='9') aa=aa*10+cc-'0',cc=getchar();
	aa*=ff;
}

struct Node{
	ll x,y;
	Node(){}
	Node(ll x,ll y):x(x),y(y){}
}o;
vector<Node> G[maxn];

int main() {
	ll x,y,s; f[0]=f[1]=1;
	For(i,2,W) f[i]=f[i-1]+f[i-2];
	G[1].push_back(Node(1,2)); G[1].push_back(Node(1,3));
	G[1].push_back(Node(1,4));
	For(i,1,W-3) {
		s=G[i].size();
		For(j,0,s-1) {
			o=G[i][j]; x=o.y; y=o.x+x;
			while(y<=f[i+3]+f[i]) {
				G[i+1].push_back(Node(x,y));
				y+=x;
			}
		}
	}
	
	read(Td);
	while(Td--) {
		read(n); read(m);
		if(n>m) swap(n,m);
		for(ans=1;f[ans+1]<=n&&f[ans+2]<=m;++ans) ;
		printf("%lld ",ans);
		if(ans==1) {
			printf("%lld\n",n*m%mod);
			continue;
		}
		s=G[ans-1].size(); sum=0;
		For(i,0,s-1) {
			o=G[ans-1][i]; x=o.x; y=o.y;
			if(y<=n) sum+=(m-x)/y%mod;
			if(y<=m) sum+=(n-x)/y%mod;
			sum%=mod;
		}
		printf("%lld\n",sum);
	}
	return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int maxn = 2e5 + 10;
char s[maxn];
int n, sum;

int main() {
	scanf("%s", s);
	n = strlen(s);
	for (int i = 0; i < n; ++i)
		sum += (s[i] - '0');
	puts(sum % 9 == 0 ? "Yes" : "No"); 
	return 0;
}

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

using namespace std;

using int64 = long long;

bool Solve() {
  int n;
  cin >> n;
  vector<int> xs(n);
  vector<int> v_count(n);
  int max_d = 0;
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    v_count[xs[i]]++;
    max_d = max(xs[i], max_d);
  }

  if (max_d % 2 == 1) {
    int k = (max_d + 1) / 2;
    if (v_count[k] != 2) return false;
    for (int x : xs) if (x < k) return false;
    for (int i = k + 1; i <= max_d; i++) {
      if (v_count[i] < 2) return false;
    }
    return true;
  } else {
    int k = max_d / 2;
    if (v_count[k] != 1) return false;
    for (int x : xs) if (x < k) return false;
    for (int i = k + 1; i <= max_d; i++) {
      if (v_count[i] < 2) return false;
    }
    return true;
  }
}

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

  if (Solve()) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
}

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

using namespace std;

int main() {

	long long	 a, b;
	cin >> a >> b;

	if (a > 2 && b > 2) {
		cout << a * b - a - a - b - b + 4 << endl;
	}
	else if (a == 2 || b == 2) {
		cout << 0 << endl;
	}
	else if(a==1 && b==1){
		cout << 1 << endl;
	}
	else { cout << max(a, b) - 2; }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)


N = int(input())
G = [[] for i in range(N)]

for i in range(N-1):
    a,b,w = map(int,input().split())
    G[a-1].append([b,w])
    G[b-1].append([a,w])
S = [-1]*N

def dfs(x,w,c):
    if w%2 !=0:
        c = 1-c
    S[x]=c
    for i in range(len(G[x])):
        x1 = G[x][i][0]-1
        if S[x1] != -1:
            continue
        w1 = G[x][i][1]
        dfs(x1,w1,c)

dfs(G[0][0][0]-1,G[0][0][1],0)
for i in range(N):
    print(S[i])

Measured memory_bytes: 86368
#include<stdio.h>
#include<string.h>
int main()
{
    char a[3][3];
    int i,j;
    while(scanf("%c%c%c",&a[0][0],&a[0][1],&a[0][2])!=EOF)
    {
        for(i=1;i<=2;i++)
        {
            getchar();
            for(j=0;j<=2;j++)
                scanf("%c",&a[i][j]);
        }
        getchar();
        printf("%c%c%c\n",a[0][0],a[1][1],a[2][2]);
    }
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define NUM ((long long)1000000007)
#define int long long

using namespace std;

signed main()
{
    ios::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
k = int(input())

for _ in range(k):
    if a >= b:
        b *= 2
    elif b >= c:
        c *= 2
    # print(a, b, c)

if (a < b) and (b < c):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9152
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

#define MAXQ 50

using namespace std;
typedef tuple<int,int,int,int> t;

int maximum = 0;
int N,M;
int A[11];
vector<t> v;

void calc(){
  int sum = 0;
  /*for(int i=0;i<N;i++){
    cout << A[i+1];
    }
    cout << endl;*/
  for(int i=0;i<v.size();i++){
    int a,b,c,d;
    a = get<0>(v[i]);
    b = get<1>(v[i]);
    c = get<2>(v[i]);
    d = get<3>(v[i]);
    if(A[b] - A[a] == c){
      sum = sum + d;
    }
  }
  if(sum > maximum){
    maximum = sum;
  }
}

void iter(int curnum,int num){
  // curnum > 10なら計算して修了
  if(curnum > N){
    calc();
    return;
  }
  //cout << curnum << " " << num << endl;
  //そうでないとき 1.この値を入れて次のAに渡す or 2. 次に進む
  // 1
  A[curnum] = num;
  iter(curnum+1,num);
  //2 次があるならやる
  if(num < M){
    iter(curnum,num+1);
  }
  return;
}

int main(void){
  int Q;
  cin >> N >> M >> Q;
  int a,b,c,d;
  //int A[10];
  A[1] = 1;
  for(int i=0;i<Q;i++){
    cin >> a >> b >> c >> d;
    t tmp(a,b,c,d);
    v.push_back(tmp);
  }
  iter(2,1);
  cout << maximum << endl;
  return 0;
}


Measured memory_bytes: 3568
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();


		long sum =0;

		for(int i=1;i<=n;i++) {

			if(i%3==0 || i%5==0) {
				continue;
			}else {
				sum += i;
			}


		}

		System.out.println(sum);
		scan.close();
	}

}


Measured memory_bytes: 27148
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    mp[a[i]]++;
  }
  int ans = 0;
  for (auto a : mp) {
    ans += (a.second % 2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5376
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, H: "List[int]"):
    H.sort()
    ans = 0
    for i in range(N-K):
        ans += H[i]
    print(ans)

    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28852
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int 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 LL readl() {
    LL 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;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
LL n, a[104], b[104], c[104];
int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) cin >> b[i];
	for (int i = 1; i < n; ++i) cin >> c[i];
	LL ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans += b[a[i]];
		if (i > 1 && a[i] == a[i - 1] + 1) ans += c[a[i - 1]];
	}
	cout << ans;
	return 0;
}

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

int GetLowerApproximatedArea(int Delta)
{
	int LowerApproximatedArea = 0;
	for(int i = 0; Delta * i < 600; i++){
		LowerApproximatedArea += Delta * Delta * i * Delta * i;
	}
	return LowerApproximatedArea;
}

int main()
{
	while(true){
		int Delta;
		cin >> Delta;
		if(cin.eof() == true) break;
		cout << GetLowerApproximatedArea(Delta) << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include <stdio.h>
#include <stdint.h>

int main(void)
{
  int N, i;
  int64_t sum = 0;
  scanf("%d", &N);
  
  for(i=1; i<=N; i++)
    if(i%3!=0 && i%5!=0)
      sum += i;
  
  printf("%ld", sum);
  
  return 0;
}

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

using namespace std;

int main()
{
    int x,a,b,i,j;
    cin>>x>>a>>b;
    i=abs(x-a);
    j=abs(x-b);
    if(i>j)
        cout<<"B"<<endl;
    else
        cout<<"A"<<endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;
 
#[fastout()]
fn main(){
    input!{
        X:usize,Y:usize,A:usize,B:usize,C:usize,
    }
    let mut p=vec![];
    let mut q=vec![];
    let mut r=vec![];
    for _ in 0..A{
        input!{a:i64}
        p.push(a);
    }
    for _ in 0..B{
        input!{b:i64}
        q.push(b);
    }
    for _ in 0..C{
        input!{c:i64}
        r.push(c);
    }
    p.sort_by(|a,b| b.cmp(a));
    q.sort_by(|a,b| b.cmp(a));
    r.sort_by(|a,b| b.cmp(a));
    let mut XY=vec![];
    for i in 0..X{
        XY.push(p[i]);
    }
    for i in 0..Y{
        XY.push(q[i]);
    }
    XY.sort();
    let mut j=0;
    for i in 0..X+Y{
        if j>=C{
            break;
        }
        if XY[i]<r[j]{
            XY[i]=r[j];
            j+=1;
        }
    }
    let mut ans:i64=0;
    for i in 0..X+Y{
        ans+=XY[i];
    }
    println!("{}",ans);
}

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

using namespace std;

int main() {
  string s;
  while(getline(cin,s) && s!="."){
    bool flag=true;
    stack<int> q;
    for(int i=0;i<s.size();++i){
      if(s[i]=='(')
	q.push(0);
      else if(s[i]=='[')
	q.push(1);
      else if(s[i]==')'){
	if(q.empty() || q.top()!=0) flag=false;
	else q.pop();
      } else if(s[i]==']'){
	if(q.empty() || q.top()!=1) flag=false;
	else q.pop();
      }
    }
    if(q.empty() && flag)
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3180
#include <stdio.h>
 
int main(){
    int n, b, f, r, v, i, j, k;
    int cnt[4][3][10] = {0};
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d%d%d%d", &b, &f, &r, &v);
        cnt[b-1][f-1][r-1] += v;
    }
    for(i=0; i<4; i++){
        for(j=0; j<3; j++){
            for(k=0; k<10; k++){
                printf(" %d", cnt[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3) printf("####################\n");
    }
    return 0;
}


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

int main(int argc,char *argv[]){
	int H,W;
	int count;
	while(1) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			count = i % 2;
			for (int j = 0; j < W; j++){			
				if (count++ % 2 == 0){
					cout << "#";
				} else {
					cout << ".";
				}
			}
			cout << "\n";
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 3048
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		while(true){
			int num1 = scan.nextInt();
			int num2 = scan.nextInt();
			
			if(num1 == 0 && num2 == 0){
				break;
				
			}
			else{
				System.out.println(Math.min(num1,num2) + " " + Math.max(num1,num2));
			}
		}
	}
}

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

using namespace std;

using ll = long long;

int main(){
    ll n; cin >> n;
    vector<ll> v;
    for(ll i = 0; i < n; ++i){
        ll tmp; cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end(), greater<ll>());
    ll ans = 0, f = 0;
    for(ll i = 0; i < n - 1; ++i){
        if(f && v[i] == v[i + 1]){
            cout << ans * v[i];
            return 0;
        }
        else if(v[i] == v[i + 1] && !f)ans = v[i], f = 1, i += 1;

    }
    cout << 0;
    return 0;
}


Measured memory_bytes: 1400
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

int n;
int h[26];
char s[30];

int main() {
	int i, j; char t; bool f;
	scanf("%s", s+1); n = strlen(s+1);
	if(n < 26) {
		rep(i, 1, n) h[s[i]-'a'] = 1;
		rep(i, 0, 25)
			if(!h[i]) {s[++n] = i+'a'; break;}
	} else {
		f = 0;
		dep(i, n-1, 1)
		if(s[i+1] > s[i]) {
			t = 'z'+1;
			rep(j, i+1, n) if(s[j] > s[i]) t = min(t, s[j]);
			s[n=i] = t;
			f = 1; break;
		}
		if(!f) {puts("-1"); return 0;}
	}
	rep(i, 1, n) printf("%c", s[i]); puts("");
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin python3
# -*- coding: utf-8 -*-

# ダイクストラ法
# 重み付きグラフ関係により最短経路のリストを作る
# 有向グラフで優先度付きキューで探索

from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')

def dijkstra(s,n,g):
    seen = [False]*n
    cost = [INF]*n
    cost[s] = 0 #スタートはコスト0
    next_q = [(0,s)]
    heapify(next_q)
    while len(next_q)>0:
        c, i = heappop(next_q)
        if cost[i] < c:
            continue
        for nedge, ncost in g[i]:
            nc = cost[i]+ncost
            if cost[nedge]>nc:
                cost[nedge] = nc
                heappush(next_q,(nc, nedge))
    return cost

def main():
    N = int(input())
    graph_F = [[] for _ in range(N)]
#    graph_R = [[] for _ in range(N)]
    #リストの作成
    for _ in range(N-1):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        graph_F[a].append((b,c))
        graph_F[b].append((a,c))
#        graph_R[b].append((a,c))

    Q, K = map(int, input().split())
    K -= 1
    F = dijkstra(K,N,graph_F)
    for _ in range(Q):
        x, y = map(int, input().split())
        print(F[x-1]+F[y-1])

if __name__ == '__main__':
    main()

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

using namespace std;

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

	bool seats[100001]{};

	for (int i = 0; i < n; i++)
	{
		int l, r;
		cin >> l >> r;
		for (int t = l; t <= r; t++)
		{
			seats[t] = true;
		}
	}

	int ans = 0;

	for (int i = 1; i < 100001; i++)
	{
		if (seats[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var N, D, X int
	fmt.Scan(&N, &D, &X)
	var count int
	for i := 1; i <= N; i++ {
		var A int
		fmt.Scan(&A)
		for i := 0; A*i+1 <= D; i++ {
			count++
		}
	}
	fmt.Println(count + X)
}

Measured memory_bytes: 512
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int A[3][3];
  	bool open[3][3];
  	for(int i=0;i<3;i++){
  		for(int j=0;j<3;j++){
  			cin >> A[i][j];
  			open[i][j] = false;
  		}
  	}

  	int N;
  	cin >> N;
  	int b;
  	for(int l=0;l<N;l++){
  		cin >> b;
  		for(int i=0;i<3;i++){
	  		for(int j=0;j<3;j++){
	  			if(A[i][j]==b) open[i][j] = true;
	  		}
	  	}
  	}

  	for(int i=0;i<3;i++){
  		if(open[i][0]==true && open[i][1]==true && open[i][2]==true){
  			cout << "Yes" <<endl;
  			return 0;
  		}
  	}

  	for(int j=0;j<3;j++){
  		if(open[0][j]==true && open[1][j]==true && open[2][j]==true){
  			cout << "Yes" <<endl;
  			return 0;
  		}
  	}

  	if(open[0][0]==true && open[1][1]==true && open[2][2]==true){
		cout << "Yes" <<endl;
		return 0;
  	}
  	if(open[0][2]==true && open[1][1]==true && open[2][0]==true){
		cout << "Yes" <<endl;
		return 0;
  	}

  	cout << "No" <<endl;

  	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp

signed main(){
	int a,b,c; cin>>a>>b>>c;
	if(a==b) cout<<c;
	else if(a==c) cout<<b;
	else if(b==c) cout<<a;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
#define MOD 1000000007
 
ll m[200010],p[200010];
int mcnt,pcnt;
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		if(t>=0)p[pcnt++]=t;
		else m[mcnt++]=-t;
	}
	//正の数・負の数をそれぞれソート
	sortup(m,mcnt);
	sortup(p,pcnt);
	
	//K==Nのとき
	if(k==n){
		ll ans=1;
		rep(i,0,mcnt)ans=ans*(MOD-m[i])%MOD;
		rep(i,0,pcnt)ans=ans*p[i]%MOD;
		printf("%lld",ans);
		return 0;
	}
	
	//Kが奇数かつ負のみのとき
	if(k%2==1&&mcnt==n){
		ll ans=1;
		rep(i,0,k)ans=ans*(MOD-m[i])%MOD;		
		printf("%lld",ans);
		return 0;
	}
	
	ll ans=1;
	while(k){
		// 負の数を2個とる or 正の数を1個とる
		if(k>=2 && mcnt>=2 &&(pcnt<=1 || (pcnt>=2 && m[mcnt-1]*m[mcnt-2]>=p[pcnt-1]*p[pcnt-2]))){
			ans=ans*m[--mcnt]%MOD;
			ans=ans*m[--mcnt]%MOD;
			k-=2;
		}else{
			ans=ans*p[--pcnt]%MOD;
			k--;
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 4152
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int nb_cas;
    cin>>nb_cas;
    cin.ignore();
    while(nb_cas--)
    {
        string texte;
        getline(cin,texte);
        int nb_op;
        cin>>nb_op;
        int curseur = 0;
        for(int c=0;c<nb_op;c++)
        {
            string s1,s2;
            cin>>s1;
            cin.ignore();
            getline(cin,s2);

            if(s1=="forward")
            {
                if(s2=="char") curseur++;
                else
                {
                    while(curseur<texte.size()&&texte[curseur]==' ') curseur++;
                    while(curseur<texte.size()&&texte[curseur]!=' ') curseur++;
                }
                curseur = min(curseur,(int)texte.size());
            }

            else if(s1=="backward")
            {
                if(s2=="char") curseur--;
                else
                {
                    while(curseur>0&&texte[curseur-1]==' ') curseur--;
                    while(curseur>0&&texte[curseur-1]!=' ') curseur--;
                }
                curseur = max(curseur,0);
            }
            else if(s1=="delete")
            {
                if(s2=="char"&&curseur<texte.size())
                {
                    texte.erase(texte.begin()+curseur);
                }
                else if(s2=="word")
                {
                    int finMot = curseur;
                    while(finMot<texte.size()&&texte[finMot]==' ') finMot++;
                    if(finMot == texte.size()) continue;
                    while(finMot<texte.size()&&texte[finMot]!=' ')
                    {
                        finMot ++;
                    }
                    texte = texte.substr(0,curseur)+(finMot < texte.size()?texte.substr(finMot):"");
                }
            }
            else
            {
                while(s2[0]!='"') s2=s2.substr(1);
                while(s2[s2.size()-1]!='"') s2 = s2.substr(s2.size()-1);
                s2 = s2.substr(1,s2.size()-2);
                texte = texte.substr(0,curseur)+s2+(curseur<(int)texte.size()?texte.substr(curseur):"");
                curseur += s2.size();
            }
        }
        cout<<texte.substr(0,curseur)+"^"+(curseur<(int)texte.size()?texte.substr(curseur):"")<<endl;
    }
}

Measured memory_bytes: 1236
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >> s;
    string ans = "";
    for(int i = 0;i < 1 << (s.size() - 1);i++){
          int sum = s[0] - '0';
          string t = s.substr(0,1);
          for(int j = 1;j < s.size();j++){
                if(i & (1 << (j - 1))){
                      sum += (s[j] - '0');
                      t += "+" + s.substr(j,1);
                }else{
                      sum -= (s[j] - '0');
                      t += "-" + s.substr(j,1);
                }
          }
          
          if(sum == 7){
                ans = t + "=7";
              
          }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int,int>a, pair<int,int>b) {
	if (a.first == b.first) {
		return a.second > b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {
	int n;
	cin >> n;
	vint a(n + 1, 0);
	rep(i, n) {
		int x;
		cin >> x;
		a[i + 1] = a[i] + x;
	}
	int ans = a[n];
	rep(i, n) {
		ans = min(ans, abs(a[i] * 2 - a[n]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s = r.readLine();
		StringTokenizer st = new StringTokenizer(s," ");
		int a,b;
		while(true){
			try {
				a = Integer.parseInt(st.nextToken().toString());
				b = Integer.parseInt(st.nextToken().toString());
				a+=b;
				for(b=0;a!=0;a=a/10) {
					b++;
				}
				System.out.println(b);
				s = r.readLine();
				if (s==null) break;
				st = new StringTokenizer(s," ");
			} catch (NoSuchElementException e) {
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 10000
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int n;
    long long int k;
    cin>>n>>k;
    long long int d[100001]={};//個数
    long long int s[100001]={};//累積和
    int a;
    int b;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        d[a]+=b;
    }
    for(int i=1;;i++){
        s[i]=s[i-1]+d[i];
        if(k<=s[i]){
            cout<<i<<endl;
            return 0;
        }
    }

    return 0;

}

Measured memory_bytes: 1152
M,D = list(map(int, input().split()))

ans = 0
for m in range(1,M+1):
  for d in range(2,D+1):
    if d // 10 < 2 or d % 10 < 2:
      continue
    if (d//10) * (d%10) == m:
      ans += 1
      
print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 11 05:38:56 2019

@author: shinjisu
"""


# ABC 200点問題
import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def dmp(x):
    global debug
    if debug:
        print(x)


debug = True


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


def prob096():  # Maximum Sum
    X = getIntList()
    K = getInt()
    dmp((X, K))
    total = sum(X) - max(X) + max(X)*2**K
    return total


def prob097():  # Exponential
    X = getInt()
    dmp(X)
    if X == 1:
        return 1
    for n in range(X, 0, -1):
        dmp(n)
        for b in range(2, int(math.sqrt(X))+1):
            a = n
            exp = True
            while a > 1:
                if a % b != 0:
                    exp = False
                    break
                a //= b
            if exp:
                break
        if exp:
            break
    return n


def prob098():  # Cut and Count
    N = getInt()
    S = input()
    dmp((N, S))
    maxChCount = 0
    for i in range(1, N):
        before = S[:i]
        after = S[i:]
        dmp((before, after))
        chCount = 0
        for j in range(26):
            ch = chr(ord('a')+j)
            if ch in before and ch in after:
                chCount += 1
        maxChCount = max(maxChCount, chCount)
    return maxChCount


debug = False  # True False
print(prob098())


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

int a[200100];
int n;

int around(int k){
	int res = INF;
	rep(i,n){
		int dist = 0;
		if(i == 0) dist = max(k - a[n-1] + a[0], a[1] - a[0]);
		else dist = max(a[i+1] - a[i], a[i] - a[i-1]);
  	    dist = k - dist;
  	    res = min(dist, res);
	}
	return res;
}


int main(){
  int k;
  cin >> k >> n;
  rep(i,n) cin >> a[i];

  int ans = around(k);


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



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans1 = a * x + b * y;
    ll ans2 = 0;
    if (x <= y) ans2 = 2 * c * x + b * (y - x);
    else ans2 = 2 * c * y + a * (x - y);
    ll ans3 = 2 * c * max(x, y);

    cout << min({ans1, ans2, ans3}) << endl;

    return 0;
}


Measured memory_bytes: 3552
N = int(input())
A = list(map(int, input().split()))

Amean = sum(A)/len(A)
res = 0
minFrameDist = 100
index = 0
for (i, a) in enumerate(A):
  frameDist = abs(Amean-a)
  if frameDist < minFrameDist:
    res = i
    minFrameDist = frameDist

print(res)

Measured memory_bytes: 38384
n = int(input())
p = []
max = 0

for i in range(n):
  a = int(input())
  p.append(a)
  if max < a:
    max = a

ans = max/2

for i in range(n):
    if p[i] == max:
        p[i] = 0
        break

for i in range(n):
  ans += p[i]

print(int(ans))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> points(n,k);
    for(int i=0;i<q;i++)
    {
        int a;
        cin>>a;
        points[a-1]+=1;
    }
    for(int i=0;i<points.size();i++)
    {
        if(points[i]-q>=1)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<int, int> P;
typedef pair<P, P> PP;
class Min {
public:
	int operator()(int a, int b) const {
		return min(a, b);
	}
};
template<typename T, typename BiOp>
struct SegmentTree {
	vector<T> data;
	T e;
	BiOp op;
	int size;
	SegmentTree(int n, T e, BiOp op) :e(e), op(op) {
		size = 1;
		while (size < n) size *= 2;
		data.resize(size * 2 - 1);
		for (int i = 0; i < size * 2 - 1; i++) data[i] = e;
	}
	void update(int k, T v) {
		k += size - 1;
		data[k] = v;
		while (k > 0) {
			k = (k - 1) / 2;
			data[k] = op(data[k * 2 + 1], data[k * 2 + 2]);
		}
	}
	T query(int a, int b, int k, int l, int r) const {
		if (b <= l || r <= a) return e;
		if (a <= l && r <= b) {
			return data[k];
		}
		return op(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}
	T query(int a, int b) const {
		return query(a, b, 0, 0, size);
	}
	T get(int i) {
		return data[i + size - 1];
	}
};
int p[200000];
int pos[200000];
P get_min(SegmentTree<int, Min> &even, SegmentTree<int, Min> &odd, int l, int r) {
	if (l % 2 == 0) {
		int a = even.query(l, r);
		int b = odd.query(pos[a], r);
		return P(a, b);
	}
	else {
		int a = odd.query(l, r);
		int b = even.query(pos[a], r);
		return P(a, b);
	}
}
int main() {
	int N;
	cin >> N;
	SegmentTree<int, Min> even(N, 1 << 30, Min()), odd(N, 1 << 30, Min());
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		p[i]--;
		pos[p[i]] = i;
		if (i % 2 == 0) even.update(i, p[i]);
		else odd.update(i, p[i]);
	}
	P head = get_min(even, odd, 0, N);
	priority_queue<PP, vector<PP>, greater<PP>> Q;
	Q.push(PP(P(head.first, head.second), P(0, N)));
	vector<int> ans;
	while (!Q.empty()) {
		PP now = Q.top(); Q.pop();
		ans.push_back(now.first.first + 1);
		ans.push_back(now.first.second + 1);
		int a = pos[now.first.first], b = pos[now.first.second];
		int l = now.second.first, r = now.second.second;
		if (l < a) {
			Q.push(PP(get_min(even, odd, l, a), P(l, a)));
		}
		if (b - a > 1) {
			Q.push(PP(get_min(even, odd, a + 1, b), P(a + 1, b)));
		}
		if (b + 1 < r) {
			Q.push(PP(get_min(even, odd, b + 1, r), P(b + 1, r)));
		}
	}
	for (int i = 0; i < N; i++) cout << ans[i] << " ";
	cout << endl;
 }

Measured memory_bytes: 8692
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()

int main(){
	int x; cin >> x;
	cout << !x << endl;
	return 0;
}

Measured memory_bytes: 3592
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, a, b, c, d) = readIntegerList()
    val s = readLine()!!

    for (i in a until (c - 2)) {
        if (s[i] == '#' && s[i + 1] == '#') {
            println("No")
            return
        }
    }

    for (i in b until (d - 2)) {
        if (s[i] == '#' && s[i + 1] == '#') {
            println("No")
            return
        }
    }

    if (c < d) {
        println("Yes")
    } else {
        for (i in (b - 2) until (d - 1)) {
            if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
                println("Yes")
                return
            }
        }

        println("No")
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 41240
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
ll gcd(ll a,ll b){
  if(!b) return a;
  return gcd(b,a%b);
}
int main(){
    ll a,b,ans;
    cin>>a>>b;
    cout<<a*b/gcd(a,b);
}

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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  long A,B,K;
  cin>>A>>B>>K;

  if(A+B<=K){
    cout<<0<<' '<<0<<endl;
    return 0;
  }

  if(A>=K){
    A-=K;
  }else{
    B-=K-A;
    A=0;
  }

  cout<<A<<' '<<B<<endl;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const L = parseInt(arg[0].split(" ")[1]);
    
    let list = [];
    
    
    for(let i=0; i<N; i++) {
        let taste = (L + (parseInt(i) + 1)) - 1;

        list.push(taste);
    }
    
    let max = list.reduce((m,n)=>m+n);
    let min = Infinity;
    let target;
    
    for(let i=0; i<N; i++) {
        /*
        let temp = Math.abs(max - Math.abs(max - list[i]));
        console.log("temp:" + temp);
        
        if(temp < Math.abs(max - temp)) {
            min = Math.abs(max - temp);
        }
        console.log("min" + min)
        console.log("----")
        */
        
        //let temp = Math.abs(max - (Math.abs(max - list[i])));
        let temp = max - list[i];
        let abs  = Math.abs(max - temp);
        
        if(abs < min) {
            min = abs;
            target = i;
        }

    }
    list.splice(target, 1);
    
    console.log(list.reduce((m,n)=>m+n));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  int a, b, c;
  int k, sum = 0;
  cin >> a >> b >> c;
  cin >> k;

  vector<int> v;
  int max_pos = 0;

  v.push_back(a);
  v.push_back(b);
  v.push_back(c);

  for (int l = 0; l < 3; l++) {
    if (v[max_pos] < v[l]) {
      max_pos = l;
    }
  }


  for (int l = 0; l < k; l++) {
    v[max_pos] *= 2;
  }

  for (int x: v) sum += x;

  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	sort(a.begin(),a.end());
	//cout<<a<<endl;
	if(a[0]==a[1] && a[2]==a[3] && a[0]!=a[2])
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;



int main(){
    int N, M; cin >> N >> M;
    vector<vector<int>> to(N);
    rep(i,M){
        int u, v; cin >> u >> v;
        u--;
        v--;
        to[u].push_back(v);
    }
    int S, T; cin >> S >> T;
    S--;
    T--;

    vector<vector<int>> dist(N, vector<int>(3,-1));
    dist[S][0] = 0;
    
    queue<pair<int, int>> que;
    que.push(make_pair(S,0));
    
    while(!que.empty()){
        int vertex = que.front().first;
        int count = que.front().second;
        int nc = (count+1)%3;
        que.pop();
        for (auto nv : to[vertex]){
            if (dist[nv][nc] != -1) continue;
            dist[nv][nc] = dist[vertex][count]+1;
            que.push(make_pair(nv, nc));
        }
    }

    int ans = dist[T][0];
    if (ans != -1) ans /= 3;
    cout << ans << endl;
}



Measured memory_bytes: 14316
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define print(n) std::cout << n << std::endl
#define FOR(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(abs(x-a) < abs(x-b))print("A");
    else print("B");
}

Measured memory_bytes: 256
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N=int(input())
    A=list(map(int,input().split()))
    A.append(0)
    len =0
    previous=0

    for i in range(N+1):
        len += abs(A[i] - previous)
        previous =A[i]


    previous =0
    for i in range(N):
        print(len -abs(A[i]-previous)-abs(A[i+1]-A[i])+abs(A[i+1] -previous))
        previous =A[i]







if __name__ == "__main__":
    main()


Measured memory_bytes: 85608
import java.util.*;
import java.io.*;

class Main {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] s3=br.readLine().split(" ");
		int n=Integer.parseInt(s3[0].trim());
		int k=Integer.parseInt(s3[1].trim());
		String[] s=br.readLine().split(" ");
		int[] a=new int[n];
		int i=0;
		for(String s1:s) {
			a[i]=Integer.parseInt(s[i].trim());
			i++;
		}
		System.out.println(algo(a,n,k));
		
		
		

	}
	
	public static int algo(int[] a,int n,int k) {
		int[] dp=new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
//		dp[0]=0;
		dp[0]=0;
		for(int i=1;i<n;i++) {
			for(int k1=1;k1<=k;k1++) {
			if(i-k1>=0) {
				int x=dp[i-k1]+Math.abs(a[i]-a[i-k1]);
				dp[i]=Math.min(dp[i],x);
			}
			
			}
		}
		return dp[n-1];
		
	}
	
	
	
	

}


Measured memory_bytes: 45180
/*
A3018.
 */
#include <stdio.h>
int main()
{
  int i;
  long long n,k,ret;
  scanf("%lld",&n);
  for(i=0,k=1;i<64;i++,k<<=1)
    if((k & n) ==0)
      {
	ret=k;
	break;
      }
  printf("%lld\n",ret);
  return(0);
}



Measured memory_bytes: 2056
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char S[200],t,u,D[200],R[200];
int i,j,L,c[200],p;
char ch(char c)
{
	if(c==']')return '[';
	if(c=='[')return ']';
	return c;
}

void rev(int s,int e)
{
	for(;s<=e;s++,e--)
	{
		t=R[s];
		R[s]=ch(R[e]);
		R[e]=ch(t);
	}
}

int f_e(int s)
{
	int c=0,e=s;
	for(;e<p;e++)
	{
		if(R[e]==']')c--;
		if(R[e]=='[')c++;
		if(!c)break;
	}
	return e;
}

int main()
{
	for(;gets(S)&&S[0]!='.';)
	{
		p=0;
		memset(c,0,sizeof(c));
		memset(R,0,sizeof(R));
		L=strlen(S);
		for(i=0;i<L;i++)
		{
			if(S[i]=='-')c[p]--;
			else if(S[i]=='+')c[p]++;
			else
			{
				D[p]=S[i];
				p++;
			}
		}
		for(i=0;i<p;i++)
		{
			if(D[i]=='?')R[i]='A';
			else if(D[i]=='['||D[i]==']')R[i]=D[i];
			else R[i]='A'+(D[i]-'A'+c[i]%26+26)%26;
		}
		for(i=0;i<p;i++)
			if(R[i]=='[')
			{
				rev(i,f_e(i));
			}
		for(i=0;i<p;i++)
			if(R[i]!='['&&R[i]!=']')
				putchar(R[i]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 524
#include<stdio.h>

int main(void){
int W,H,x,y,r,flg=0;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(x-r<0||x+r>W)flg=0;
else if(y-r<0||y+r>H)flg=0;
else flg=1;

if(flg==1)printf("Yes\n");
else printf("No\n");
return 0;
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define lb long double
using namespace std;
struct Po{lb x,y;}p1,p2,np,x,nx;
int t; 
void get(Po &x){scanf("%Lf %Lf",&x.x,&x.y);}
Po operator -(Po x,Po y){return (Po){x.x-y.x,x.y-y.y};}
Po operator +(Po x,Po y){return (Po){x.x+y.x,x.y+y.y};}
lb operator ^(Po x,Po y){return x.x*y.x+x.y*y.y;}
Po operator *(Po x,lb y){return (Po){x.x*y,x.y*y};}
lb le2(Po x){return x.x*x.x+x.y*x.y;}
int main(){
	get(p1);get(p2);np=p2-p1;lb lp=le2(np);
	scanf("%d",&t);
	while (t--){
		get(x);
		nx=np*((np^(x-p1))/lp);
		x=p1+p1+nx+nx-x;
		printf("%.10Lf %.10Lf\n",x.x,x.y);
	}
	return 0;
}


Measured memory_bytes: 3236
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define triplerep(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))

typedef long long ll;

int main() {
    int a, b, c, k;
    
    scnd4(a,b,c,k);
    int m = max(a,max(b,c));
    cout << (a+b+c-m)+m*pow(2,k) << endl;
    
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

ll ans;
string str;

void check(int a, int b, int c){
    int cou = 0;
    REP(i, str.size()){
        if(cou == 0 && (str[i] - '0') == a)cou++;
        else if(cou == 1 && (str[i] - '0') == b)cou++;
        else if(cou == 2 && (str[i] - '0') == c)cou++;
        if(cou == 3){
            ans++;
            //cout << a << b << c << endl;
            return;
        }
    }
}

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

    ll n;cin >> n;
    cin >> str;
    REP(i, 10){
        REP(j, 10){
            REP(k, 10){
                check(i, j, k);
            }
        }
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String output = "";
		while(sc.hasNext()){
			String temp = sc.next();
			int ans = temp.length();
			if(temp.contains(".") || temp.contains(" ") || temp.contains(",")){
				ans -= 1;
				temp = temp.substring(0, temp.length() - 1);
			}
			if(ans >= 3 && 6 >= ans){
				output += temp + " ";
			}
		}
		output = output.substring(0, output.length() -1);
		System.out.println(output);
		
	}
}

Measured memory_bytes: 26040
/* 深さ優先探索
 １．一番最初に訪問する頂点をスタックに入れる
 ２．スタックに頂点が積まれている限り...
 　- スタックのトップにある頂点uを訪問する
   - 現在訪問中の頂点uから次の頂点vへ移動する時に、vをスタックへ積む。
   　uに未訪問の隣接する頂点がなければuをスタックから削除する
*/

#include <iostream>
#include <stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

// uに隣接するvを番号順に取得
int next(int u) {
	for (int v = nt[u]; v < n; v++) {
		nt[u] = v + 1;
		if (M[u][v]) return v; // 隣接する頂点vを返す
	}
	return -1; // 隣接する頂点がないなら-1を返す
}

// スタックを用いて深さ優先探索
void dfs_visit(int r) {
	for (int i = 0; i < n; i++) nt[i] = 0;

	stack<int> S;
	S.push(r);
	color[r] = GRAY; // 現在訪問中の頂点
	d[r] = ++tt;

	while (!S.empty()) {
		int u = S.top();
		int v = next(u);
		if (v != -1) {
			if (color[v] == WHITE) {
				color[v] = GRAY; // 頂点を訪問中にする
				d[v] = ++tt;
				S.push(v);
			}
		}
		else {
			S.pop();
			color[u] = BLACK; // 頂点を訪問完了にする
			f[u] = ++tt;
		}
	}

}

void dfs() {
	// 初期化
	for (int i = 0; i < n; i++) {
		color[i] = WHITE; // 全頂点を未訪問に設定
		nt[i] = 0; // 経過時刻を表すタイムスタンプを0に設定
	}
	tt = 0;

	// 未訪問のuを始点として深さ優先探索
	for (int u = 0; u < n; u++) {
		if (color[u] == WHITE) dfs_visit(u);
	}

	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << d[i] << " " << f[i] << endl;
	}
}

int main() {
	int u, k, v; // 訪問中の頂点u, 次数k, 次に訪問する頂点v

	cin >> n;
	for (int i = 0; i < n; i++) { // 配列0で初期化
		for (int j = 0; j < n; j++) M[i][j] = 0;
	}

	// 無向グラフを作成
	for (int i = 0; i < n; i++) {
		cin >> u >> k; // 頂点uと出次数kを入力
		u--; // 1 -> 0オリジンに変換
		for (int j = 0; j < k; j++) {
			cin >> v; // 次に訪問する未訪問頂点v入力
			v--; // 0オリジンへ変換
			M[u][v] = 1;
		}
	}

	dfs();

	return 0;
}


Measured memory_bytes: 3136