akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
    
    //変数の宣言
    int x, y;
    
    //繰り返し処理をするときは「　for文　」を使う
    for(int i=1; i<=10000; i++){
        //各Caseの値を入力
        cin >> x >> y;
        
        //if文を使用してxの値とyの値が「 0 」なら終了の条件を考える
        if(x == 0 && y == 0){
            break;  
        }
        
        //else if： ifを満たしてない・成立してない条件下で条件を考える 
        else if(x < y){
            swap(x, y);
        }
        
        //xの値とyの値を交換する　➡　coutで表示の順番を入れ替えるだけ
        cout << y << " " << x << endl;
    }
    
    return 0;
    
}




/****************************************複数の条件式****************************************************
 
 
かつ・AND　➡　&&  ➡　　両方の条件が成立するときのみ成立の所へ行ける
またわ・OR　➡　||　➡　片方の条件が成立する　又は　　両方の条件が成立する　ときは成立の場所へ行ける
         
     
*********************************************************************************************************/




/****************************************　breakとは　***************************************************


☆繰り返し処理を終了・出処理から出たいときに使用

    
*********************************************************************************************************/



/****************************************　swapとは　***************************************************


☆s数字を入れ替える
    swap(a,b) ➡　a と  b の　値を入れ替える　
    
    
*********************************************************************************************************/














Measured memory_bytes: 3072
<?php
fscanf(STDIN,"%d %d",$N,$K);
$S = fgets(STDIN);
//$K-1文字目(0からカウントのため)を取得し、小文字を求める
$target = substr($S,$K-1,1);
$lowTarget = strtolower($target);
//$Sの$K-1文字目から1文字を$lowTargetに置換
echo substr_replace($S, $lowTarget, $K-1, 1); 

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define TO(x,t,f) ((x)?(t):(f))
#define YesNo(a) cout<<((a)?"Yes":"No")<<endl;
#define YESNO(a) cout<<((a)?"YES":"NO")<<endl;

int main(){
	ll N,K,Q;
	cin >> N >> K >> Q;
	ll A[N+1];
	FOR(i,0,N+1)A[i]=-Q+K;
	FOR(i,0,Q){
		ll a;
		cin >> a;
		A[a]++;
	}
	FOR(i,1,N+1){
		YesNo(A[i]>0);
	}
}

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

int main() {
    string s;
    cin >> s;
    int K;
    cin >> K;
    
    set<string> A;
    for(int i=0; i<s.size(); ++i) {
        for(int j=0; j < K && i + j < s.size(); ++j) {
            A.insert(s.substr(i, j+1));
        }
    }
    auto itr = A.begin();
    for(int i=0; i<K-1; ++i) ++itr;
    cout << *itr << endl;
}

Measured memory_bytes: 1664
suits = {"S":0, "H":1, "C":2, "D":3}
cards = [[0 for i2 in range(13)] for i1 in ("S", "H", "C", "D")]
n = int(input())

for i in range(n):
    (suit, rank) = input().split(" ")
    cards[suits[suit]][int(rank) - 1] = 1

for suit in ("S", "H", "C", "D"):
    for number in range(13):
        if cards[suits[suit]][number] != 1:
            print(suit, number + 1)

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

void solve(){
	int a[3];
	REP(i, 0, 3){
		cin >> a[i];
	}
	sort(a, a + 3);
	int ans = 0;
	while(a[0] <= a[1] - 2){
		a[0] += 2;
		ans++;
	}
	if (a[0] == a[1]){
		ans += a[2] - a[0];
	} else {
		ans += a[2] - a[0] + 1;
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 101
void Search(int);

int number,G[MAX][MAX],d[MAX],count=0,k=0;
int F[MAX] = {0};

 
int main(void){
  int i,j,k,l,u,a,t;
  
  for(i = 0;i < number;i++){
    d[i] = 0;
  }
   
  scanf("%d",&number);
  
  for(i = 0;i < number + 1;i++){
    for(j = 0;j < number + 1;j++){
      G[i][j] = 0;
    }
  }
  
  for(i = 0;i < number;i++){
  
    scanf("%d %d ",&k,&u);
  
    for(j = 0;j < u;j++){
      scanf("%d",&a);
      G[k - 1][a - 1] = 1;
    }
  }
 
  for(i = 0;i < number;i++){
    if(d[i] == 0)
    Search (i);
  }
      
  for(i = 0;i < number;i++){
    printf("%d %d %d\n",i+1,d[i],F[i]);
  }
 
  return 0;
 }


void Search(int u){
  int i,j,v;
  count++; 
  d[u] = count;
  
  for(v = 0;v < number;v++){
    if(G[u][v] == 1 && d[v] == 0 ){
      Search(v);
    }
  }
  count++;
  F[u] = count;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

int factorial (int n){
    int res = 1;
    FOR(i, 1, n) res *= i;
    return res;
}

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  map<int, pair<int, int>> loc;
  REP(i, n) {
    int x, y;
    cin >> x >> y;
    loc[i] = make_pair(x, y);
  }
  vector<int> v(n);
  REP(i, n) v[i] = i;
  double ans = 0;
  do {
    FOR(i, 1, n - 1) {
      int nx = loc[v[i]].first;
      int ny = loc[v[i]].second;
      int px = loc[v[i - 1]].first;
      int py = loc[v[i - 1]].second;
      ans += sqrt((nx - px) * (nx - px) + (ny - py) * (ny - py));
    }
  } while (next_permutation(v.begin(), v.end()));
  ans /= factorial(n);
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class FastReader{
	BufferedReader br;
	StringTokenizer tok;
	
	FastReader(){
		br=new BufferedReader(new InputStreamReader(System.in));
	}
	
	String next() {
		if(tok==null || (!tok.hasMoreTokens())) {
			try {
				tok = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return tok.nextToken();
	}
	int nextInt() {
		return Integer.parseInt(this.next());
	}
	String nextLine() {
		String s="";
		try {
			s = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return s;
	}
}

public class Main {
	
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int n=fr.nextInt();
		int arr[] = new int[n]; 
		for(int i=0; i<n; i++)
			arr[i] = fr.nextInt();
		int dp[] = new int[n];
		dp[1] = Math.abs(arr[1]-arr[0]);
		for(int i=2; i<n; i++) 
			dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2]));
		System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 31836
n = int(input())
listA = list(map(int, input().split()))
sumOriginal =0
index =0
while index<len(listA):
    if index == 0:
        sumOriginal+=(max(listA[index], 0)-min(listA[index], 0))
    elif index == len(listA)-1:
        sumOriginal+=(max(listA[index], 0)-min(listA[index], 0))
        sumOriginal+=(max(listA[index], listA[index-1])-min(listA[index], listA[index-1]))
    else:
        sumOriginal+=(max(listA[index], listA[index-1])-min(listA[index], listA[index-1]))
    index+=1

index2=0
listForAnswer =[]
while index2<len(listA):
    sumAnswer=0
    if index2 ==0:
        sumAnswer = sumOriginal-(max(listA[index2], 0)-min(listA[index2], 0))
        sumAnswer-=(max(listA[index2], listA[index2+1])-min(listA[index2], listA[index2+1]))
        sumAnswer+=(max(listA[index2+1], 0)-min(listA[index2+1], 0))
    elif index2 ==len(listA)-1:
        sumAnswer =sumOriginal-(max(listA[index2], 0)-min(listA[index2], 0))
        sumAnswer-=(max(listA[index2], listA[index2-1])-min(listA[index2], listA[index2-1]))
        sumAnswer+=(max(listA[index2-1], 0)-min(listA[index2-1], 0))
    else:
        sumAnswer =sumOriginal-(max(listA[index2], listA[index2+1])-min(listA[index2], listA[index2+1]))
        sumAnswer-=(max(listA[index2], listA[index2-1])-min(listA[index2], listA[index2-1]))
        sumAnswer+=(max(listA[index2-1], listA[index2+1])-min(listA[index2-1], listA[index2+1]))
    listForAnswer.append(sumAnswer)
    index2+=1

for ans in listForAnswer:
    print(ans)


Measured memory_bytes: 13936
import math 

n,a,b = map(int,input().split(" "))

result = 0

for i in range(1,n+1):
    tmp = 0
    tmp_i = i
    for j in range(int(math.log10(i))+1):
        tmp = tmp + tmp_i%10
        tmp_i  = tmp_i//10
    if a <= tmp <= b:
        result += i
print(result)

Measured memory_bytes: 3060
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


if __name__ == '__main__':
    a, b = list(map(int, input().split()))
    print(a * b)

    #print('\33[32m' + 'end' + '\033[0m') # debug


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

#define ll                 long long
#define ull                unsigned long long
#define ld                 long double
#define fastio             ios_base::sync_with_stdio(false);cin.tie(NULL);
#define NO                 cout << "NO" << endl
#define YES                cout << "YES" << endl
#define vec                vector<ll>
#define pi                 pair<ll, ll>
#define intarr(arr, n)     ll arr[n]; for (ll i = 0; i < n; i++) cin >> arr[i]
#define intvec(v, n)       for (ll i = 0; i < n; i++) { ll x;cin >> x; v.pb(x);}
#define loop(i, a, b, c)   for (ll i = a; i < b; i += c)
#define pb                 push_back
#define mkp                make_pair
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  cout << endl
#define endl               "\n"
#define mod2               998244353
#define mod                1000000007
#define mem(dp, a)         memset(dp, a, sizeof(dp));
#define all(v)             v.begin(), v.end()
#define ump                unordered_map<ll, ll>
#define ff                 first
#define ss                 second
#define PI                 3.14159265358979
#define minh               priority_queue<ll>
#define maxh               priority_queue<ll,vector<ll>,greater<ll>>
#define flush              cout<<flush


ll Ceil(ll a, ll b)
{
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}

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

ll inv(ll a)
{
  ll p = mod;
  ll b = p - 2, ans = 1;
  for (; b > 0; a = a * a % p, b >>= 1)
    if (b & 1)
      ans = ans * a % p;
  return ans;
}

ll ncrmod(ll n, ll m)
{
  ll p = mod;
  if (m > n)
    return 0;
  ll up = 1, down = 1;
  for (ll i = n - m + 1; i < n + 1; i++)
    up *= i, up %= p;
  for (ll i = 1; i < m + 1; i++)
    down *= i, down %= p;
  return up * inv(down) % p;
}

ll powmod(ll a, ll n)
{
  if (!n)
    return 1;
  ll pt = powmod(a, n / 2);
  pt *= pt, pt %= mod;
  if (n & 1)
    pt *= a, pt %= mod;
  return pt;
}

// void factorize(long long int n)
// {
//   ll count = 0;

//   while (!(n % 2)) {
//     n >>= 1;
//     count++;
//   }

//   if (count)
//   {
//     sum2 += count;
//   }

//   for (long long i = 3; i <= sqrt(n); i += 2) {
//     count = 0;
//     while (n % i == 0) {
//       count++;
//       n = n / i;
//     }
//     if (count)
//     {
//       if (i & 1)sum += count;
//     }
//   }
//   if (n > 2)
//   {
//     sum++;
//   }
// }

void solve()
{
  ll n;
  cin >> n;
  intarr(a, n);
  ll xorr = a[0] ^ a[1];
  for (ll i = 2; i < n; i++)
    xorr = xorr ^ a[i];

  for (ll i = 0; i < n; i++) {
    ll ans = xorr ^ a[i];
    cout << ans << " ";
  }
}
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  fastio;
  ll t;
  t = 1;
  //cin >> t;
  while (t--)
  {
    solve();
  }

  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

  return 0;
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(1e5)+5;


vector<ll> aa;
vector<ll> bb;
vector<ll> cc;

int main()
{
    idfc;

    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    int i,j;
    int e;
    while(a--)
    {
        cin>>e;
        aa.pb(e);
    }
    while(b--)
    {
        cin>>e;
        bb.pb(e);
    }
    sort(aa.begin(),aa.end(),greater<>());
    sort(bb.begin(),bb.end(),greater<>());
 //   int i;

    for(i=0;i<x;i++)
    {
        cc.pb(aa[i]);
    }
    for(i=0;i<y;i++)cc.pb(bb[i]);

    while(c--)
    {
        cin>>e;
        cc.pb(e);
    }
    sort(cc.begin(),cc.end(),greater<>());

    ll ans=0;
    for(i=0;i<(x+y);i++)ans+=cc[i];
    cout<<ans;

    return 0;
}

Measured memory_bytes: 8932
#include<iostream>

using namespace std;

typedef long long ll;

const int N = 100001;
const ll INT32 = 2147483647;

ll dp[100][N];


int main(){
  for(int i = 0; i<100; i++){
    dp[i][0]=0;
    for(int j = 1; j < N; j++){
      dp[i][j]=INT32;
    }
  }
  int n;
  ll k;
  cin >> n >> k;
  int v;
  ll w;
  cin >> w >> v;
  dp[0][v] = w;
  for(int i = 1; i < n; i++){
    cin >> w >> v;
    for(int j = 0; j < N-1; j++){
      dp[i][j]=min(dp[i-1][j],dp[i][j]);
      if(j+v<N)
        dp[i][j+v]=min(dp[i][j+v],dp[i-1][j]+w);
    }
  }
  for(int i = N-1; i >= 0; i--){
    for(int j = 0; j < 100; j++){
      if(dp[j][i]<=k){
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, ma, mi;
	cin >> n >> ma;
	mi = ma;
	for(int i=0;i<n-1;i++){
		int a;
		cin >> a;
		ma = max(ma, a);
		mi = min(mi, a);
	}
	cout << ma - mi << endl;
}

Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
 
int main() {
  int ans,min,max;
  
  cin >> min >> max;
  ans=max-min+1;
  int tmp=min;
  int l;
  string s;
  for(int i=0;i<max-min+1;i++){
    l=tmp;
    s = std::to_string(l);
    int size=s.size();
    bool judge=true;
    for(int j=0;j<size/2;j++){
      if(s.at(j)!=s.at(s.size()-j-1)){
        judge=false;
      }
      if(!judge){
        ans--;
        break;
      }
    }
    tmp++;
  }
  cout << ans << endl;
}
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n;
int main() {
	cin >> n;
	int ret = 1;
	for(int i = 1; i <= n; i++) ret = 1LL * ret * i % mod;
	cout << ret << endl;
	return 0;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,a,b) for (ll i = (a) ; i <= (b); ++i)
#define RFOR(i,a,b) for (ll i = (a) ; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい


void Main(){
	ll n, m, ans=0;
	cin >> n;
	VI a(n);
	rep(i, n){
		cin >> a[i];
	}

	rep(i, n){
		if(i%2 == 1) continue;
		if(a[i] % 2 == 1) ans++;
	}

	cout << ans << endl;

}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
  string a, b;
  cin >> a >> b;

  int num = stoi(a + b);

  int root = sqrt(num);

  if (root * root == num) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3608
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
r, s, p = map(int, readline().split())
t = input()
ans = [0, 0, 0]
check = t[:k]
for i in range(k, n):
    if t[i] == check[i - k]:
        check += 'a'
    else:
        check += t[i]
for i in range(k):
    if t[i] == 'r':
        ans[0] += 1
    elif t[i] == 's':
        ans[1] += 1
    else:
        ans[2] += 1
for i in range(k, n):
    if check[i] != check[i - k]:
        if check[i] == 'r':
            ans[0] += 1
        elif check[i] == 's':
            ans[1] += 1
        elif check[i] == 'p':
            ans[2] += 1
print(ans[0] * p + ans[1] * r + ans[2] * s)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,pos=1,ans=0;cin>>n;
  lvector A(3*n);rep(i,3*n) cin>>A[i];
  sort(RALL(A));
  rep(i,n) ans+=A[pos+2*i];
  print(ans);
  return 0;
}

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

using u32 = uint32_t;

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

	std::string s;
	std::cin >> s;

	std::vector<std::vector<u32>> v;

	v.resize(n+1);

	for(u32 i = 0; i < n+1; i++)
	{
		v[i].resize(n+1,0);
	}

	u32 max = 0;

	for(u32 i = 1; i < n+1; i++)
	{
		for(u32 j = i+1; j < n+1; j++)
		{
			if(s[i-1] == s[j-1])
			{
				v[i][j] = std::min(v[i-1][j-1] + 1, j-i);
				if(v[i][j] > max) max = v[i][j];
			}
		}
	}
/*
	std::cout << "  x ";

	for(u32 i = 0; i < n; i++)
	{
		std::cout << s[i] << " ";
	}

	std::cout << "\n";

	for(u32 i = 0; i < n+1; i++)
	{
		if(i==0) std::cout << "x ";
		else std::cout << s[i-1] << " ";

		for(u32 j = 0; j < n+1; j++)
		{
			std::cout << v[i][j] << " ";
		}
		std::cout << "\n";
	}
*/
	std::cout << max << '\n';

	return 0;
}

Measured memory_bytes: 98176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long A[N];
  for(int i=0;i<N;i++) cin >> A[i];
  int mai = 0;
  for(int i=0;i<N;i++){
    if(A[i] < 0){
      mai++;
      A[i] = -A[i];
    }
  }
  long long mini = 100000000000;
  long long goukei = 0;
  if(mai % 2 != 0){
    for(int i=0;i<N;i++){
      mini = min(mini, A[i]);
      goukei += A[i];
    }
    cout << goukei - 2*mini << endl;
  }
  else{
    for(int i=0;i<N;i++){
      goukei += A[i];
    }
    cout << goukei << endl;
  }
}
        


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

int main() {
    /* Input */
    long int A, B, C, K;
    cin >> A >> B >> C >> K;

    /* Main Logic */
    long int useA = min(A, K);
    K = K - useA;

    long int useB = min(B, K);
    K = K - useB;

    long int useC = K;

    long int ans = useA - useC; 

    /* Output */
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
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(a>b){a=b;return 1;}return 0;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int h,w;
vector<vint> c;

vector<bool> used;

int dp(int s){
	if(s==1)return 0;
	int res = 999999;
	rep(i, 10){
		if(used[i])continue;
		used[i] = true;
		chmin(res, c[s][i] + dp(i));
		used[i] = false;
	}
	return res;
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
	c = vector<vint>(10,vint(10));
	cin>>h>>w;
	rep(i, 10){
		rep(j, 10){
			cin>>c[i][j];
		}
	}
	vint cost(10);
	cost[1] = 0;
	rep(i, 10){
		if(i == 1)continue;
		used = vector<bool>(10, false);
		used[i] = true;
		cost[i] = dp(i);
	}

	ll ans = 0;

	rep(i, h){
		rep(j, w){
			int a;cin>>a;
			if(a==-1){
				continue;
			}else{
				ans += cost[a];
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
def divisor(n):
    i = 1
    table = []
    append = table.append
    while i * i <= n:
        if n%i == 0:
            append((i-1)+(n//i-1))
        i += 1
    table = list(set(table))
    return min(table)

print(divisor(int(input())))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    ll n, k;
    cin>>n>>k;
    ll p[n], c[n];
    lp(0,n) cin>>p[i], p[i]--;
    lp(0,n) cin>>c[i];
    ll ans = LONG_MIN;
    lp(0,n){
        int strt = i;
        ll cyclesum=0, cntvert = 0;
        do{
            cntvert++;
            cyclesum += c[strt];
            strt = p[strt];
        }while(strt!=i);
        ll temp = 0;
        ll path = 0;
        do{
            temp++;
            path += c[strt];
            ll no = (k-temp)/cntvert;
            ans  = max(ans, path+no*max(cyclesum,0ll));
            strt = p[strt];
        }while(strt!=i and temp<k);
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    int a[n+1],b[n+1],c[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];

    long long sum=b[a[1]];
    for(int i=2;i<=n;i++)
    {
        sum+=b[a[i]];
        if(a[i]==a[i-1]+1)
            sum+=c[a[i-1]];
    }
    cout<<sum<<endl;
}


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

using namespace std;

#define MAX 500000
#define SENTINEL 2e9

struct card {
	int value;
	char suit;
};

card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(card A[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; ++i) L[i] = A[left + i];
	for (int i = 0; i < n2; ++i) R[i] = A[mid + i];
	L[n1].value = R[n2].value = SENTINEL;
	int i = 0, j = 0;
	for (int k = left; k < right; ++k) {
		if (L[i].value <= R[j].value) A[k] = L[i++];
		else A[k] = R[j++];
	}
}

void mergeSort(card A[], int left, int right) {
	if (left < right - 1) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int partition(card A[], int p, int r) {
	card x = A[r];
	int i = p - 1;
	for (int j = p; j < r; ++j) {
		if (A[j].value <= x.value) {
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}

void quickSort(card A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quickSort(A, p, q - 1);
		quickSort(A, q + 1, r);
	}
}

card A[100000], B[100000];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> A[i].suit >> A[i].value;
		B[i] = A[i];
	}
	mergeSort(A, 0, n);
	quickSort(B, 0, n - 1);
	bool flag = true;
	for (int i = 0; i < n; ++i)
		if (A[i].suit != B[i].suit) flag = false;
	cout << (flag ? "Stable" : "Not stable") << endl;
	for (int i = 0; i < n; ++i)	cout << B[i].suit << " " << B[i].value << endl;

	return 0;
}


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

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    if (a+b > c+d) cout << "Left" << endl;
    else if (a+b == c+d) cout << "Balanced" << endl;
    else cout << "Right" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      String judge = "No";
      
      for(int i=0; i<26; i++){
	    for(int j=0; j<15; j++){
          if(i*4 + j*7 == N){
            judge = "Yes";
          } else if(i*4 + j*7 > N){
            break;
          }
        }
      }  
      
      System.out.println(judge);
    }  
}  

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

int main() {
  int n;
  cin >> n;
  vector<int> l(2*n);
  for(int i=0;i<2*n;i++) cin >> l[i];
  sort(l.begin(), l.end());
  int ans = 0;
  for(int i=0;i<2*n;i+=2) {
    ans += l[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (int)(count); i++)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
const int MODULO = 100000 ;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;

using namespace std;

int main()
{
	int n; cin>>n;
	while(n--){
		string s; cin>>s;
		char c[100] = {};
		int i = 0,l = 50;
		for(; i * 3 < sz(s); i++){
			c[l] = s[i*3];
			if(3*i+1 < sz(s)){
				if(s[3*i+1] == '-') l++;
				else l--;
			}
		}
		while(c[l-1]) l--;
		puts(c+l);
	}
	return 0;
}

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

int N, K;
int mn = 10000;
int dfs(int a, int n)
{
  if (n == N)
  {
    mn = min(mn, a);
    return mn;
  }
  dfs(2 * a, n + 1);
  dfs(a + K, n + 1);
}

int main()
{
  cin >> N >> K;
  cout << dfs(1, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc087/tasks/abc087_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int x, a, b;

  cin >> x >> a >> b;

  cout << (x - a) % b << '\n';

  return 0;
}


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

        long long n,i,p=0;
        cin>>n;
        long long a[n];
        for(i=0;i<n;i++)
        cin>>a[i];
        for(i=1;i<n;i++){
            if(a[i]<a[i-1])
            {
                p=p+a[i-1]-a[i];a[i]=a[i-1];
            }
        }cout<<p;

    return 0;
}


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

bool isSame(string S,string T)
{
	return S == T.substr(0,T.size()-1);
}

int main()
{
	string S,T;
	cin>>S>>T;
	if(isSame(S,T))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3596
n=int(input())
a=input()
b=input()
c=input()
ans=0
for i in range(n):
    if a[i]==b[i]==c[i]:
        continue
    elif a[i]!=b[i] and a[i]!=c[i] and b[i]!=c[i]:
        ans+=2
    else:
        ans+=1
print(ans)


Measured memory_bytes: 9172
//hi
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long int LL;
int s[100005];
vector<int> v[100005];
int vis[100005];
unordered_map<int,int> pos;
unordered_set<int> st1, st2;
void dfs(int now){
	vis[now]=1;
	st1.insert(now);
	st2.insert(pos[now]);
	for(auto x : v[now]){
		if(!vis[x]) dfs(x);
	}
}
int main(void){
    int n,m;
    scanf("%d%d",&n,&m);
    int i;
    for(i=1;i<=n;i++){
		scanf("%d",&s[i]);
		pos[s[i]]=i;
	}
    for(i=0;i<m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		v[s[x]].PB(s[y]);
		v[s[y]].PB(s[x]);
	}
	int ans=0;
	for(i=1;i<=n;i++){
		if(!vis[i]){
			st1.clear();
			st2.clear();
			dfs(i);
			for(auto x : st1){
				if(st2.find(x)!=st2.end()) ans++;
			}
		}
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 22820
#include <bits/stdc++.h>
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define all(V) (V).begin(), (V).end()
#define unq(V) (V).resize(unique(all(V))-(V).begin())
using namespace std;
typedef long long ll;
typedef vector<ll> vlm;
typedef vector<int> vim;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

string S;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin>>S; 
	int n=S.size();
	if (n%2) { cout<<"No\n"; return 0; }
	for (int i=0; i<n; i+=2) if (S[i]!='h'||S[i+1]!='i') { cout<<"No\n"; return 0; }
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
int path=0;
int N,M;
void dfs(multimap<int,int> mp, vector<int> visited, int state){
  visited[state-1] = 1;
  for(int i=0; i < N; i++){
    if(visited[i] == 0) break;
    if(i == N-1) path += 1;
  }
  auto r = mp.equal_range(state);
  for(auto itr=r.first; itr != r.second; itr++){
    if(visited[(itr->second)-1] == 0)
      dfs(mp, visited, itr->second);
  }
}
int main()
{
  cin >> N >> M;
  vector<int> visited(N);
  for(int i=0; i < N; i++)
    visited[i] = 0;
  multimap<int, int> mp;
  for(int i=0; i < M; i++){
    int fst,snd;
    cin >> fst >> snd;
    mp.insert(make_pair(fst,snd));
    mp.insert(make_pair(snd,fst));
  }
  dfs(mp,visited,1);
  cout << path << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<stack>
using namespace std;
int main()
{
    int a,b,k;
    while(scanf("%d %d %d",&a,&b,&k)!=EOF)
    {
        stack<int> q;
        if(k>(b-a+1)/2)
        {
            for(int i=a;i<=b;i++)
            {
                printf("%d\n",i);
            }
        }
        else
        {
            for(int i=a,cnt=0;;i++,cnt++)
            {
                if(cnt>=k)  break;
                printf("%d\n",i);
            }
            for(int i=b,cnt=0;;i--,cnt++)
            {
                if(cnt>=k)  break;
                q.push(i);
            }
            while(!q.empty())
            {
                printf("%d\n",q.top());
                q.pop();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		List<Double> list = new ArrayList<Double>();

		String str = "";
		while((str=br.readLine())!=null){

			list.add(Double.parseDouble(str));
		}


		Collections.sort(list);

		System.out.println(list.get(list.size() - 1) - list.get(0));
	}

}

Measured memory_bytes: 24284
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 2000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int ans[105][105];
int h,w,n;
pi a[100005];

int main(){
  cin>>h>>w>>n;
  rep(i,n){
    a[i].first=i+1;
    cin>>a[i].second;
  }
  int cnt=0;
  rep(i,h){
    if(i%2==0){
      rep(j,w){
	ans[i][j]=a[cnt].first;
	a[cnt].second--;
	if(a[cnt].second==0)cnt++;
      }
    }else{
      rrep(j,w-1){
	ans[i][j]=a[cnt].first;
	a[cnt].second--;
	if(a[cnt].second==0)cnt++;
      }
    }
  }
  rep(i,h){
    rep(j,w)cout<<ans[i][j]<<" ";
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
/*
    ( ´-ω･)︻┻┳══━一一一一一一一				(× _ ×)
	
	Stay Low. Go Fast
	Kill First. Die Last
	One Shot. One Kill
	No Luck. Pure Skill 
*/

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

/*************************** MACROS **************************/
#define ld long double
#define ll long long  
#define ull unsigned long long
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x;i>=y;i--)
#define vll vector<ll>
#define pb push_back
#define S second
#define F first
#define B begin()
#define E end()
#define W(x) while(x--)
#define pll pair< ll,ll >
#define vpll vector< pll >
#define qll queue<ll>
#define dqll deque<ll>
#define qpll queue<pll>
#define dqpll deque<pll>
#define pqll priority_queue<ll>
#define pqpll priority_queue<pll>
#define Line cout<<"\n**************************\n\n";

/*************************** CONST ******************************/

const ll MOD = 1000000007;
const ll MOD1 = 998244353;
const ll MIN_LL = -1e18;
const ll MAX_LL = 1e18;
const int MAX_INT = 1e9;
const int MIN_INT = -1e9;
const ld pie = 3.1415926535;
 
/************************** POW UTIL *****************************/
 
ll fpow(ll n,ll p){;ll m=1;while(p){if(p%2)m*=n;p>>=1;n*=n;}return m;}
ll mfpow(ll n,ll p,ll M){ll m=1;n%=M;while(p){if(p%2)m=(m*n)%M;n=(n*n)%M;p>>=1;}return m%M;}
 
/************************* PRINT UTIL *****************************/

template<class T> inline ostream& operator<<(ostream& o,vector<T> v){for(auto i:v)o<<i<<" ";return o;};
template<class T> inline ostream& operator<<(ostream& o,set<T> s){for(auto i:s)o<<i<<" ";return o;}
template<class T> inline ostream& operator<<(ostream& o,multiset<T> s){for(auto i:s)cout<<i<<" ";return o;}
template<class T1,class T2> inline ostream& operator<<(ostream& o,pair<T1,T2> p){o<<p.F<<" "<<p.S<<"\n";return o;}
template<class T1,class T2> inline ostream& operator<<(ostream& o,map<T1,T2> m){for(auto p:m)o<<p.F<<" "<<p.S<<"\n";return o;}

/*************************** VARIABLES **************************/

const vll days={31,28,31,30,31,30,31,31,30,31,30,31};
 
bool br,br1,br2; 
char ch,ch1,ch2;
 

ll n,m,k,x,y,z,mini,maxi,l,r,sum,t,w;
pll p,p1,p2;

string s,s1,s2;

set<ll> st,st1,st2;
multiset<ll> mst; 

map<ll,ll> mp;

/**************************** FXNS ****************************/

bool a[110];

void solve()
{

	cin>>x>>n;

	loop(i,0,n)
	{
		cin>>y;
		a[y] = true;
	}

	mini = MAX_LL;
	
	loop(i,0,110)if(!a[i] && mini > abs(x-i))
	{
		mini = abs(x-i);
		y = i;
	}

	cout<<y<<endl;

}
 
/*************************** MAIN ****************************/
 
int main(){
 
 
	// #ifndef ONLINE_JUDGE
	        // freopen("input.txt", "rt", stdin);
	        // freopen("output.txt", "wt", stdout);
	// #endif
 
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);

	solve();
 
	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

int ar[3][3], f[101];

void solve() {
        lp(i, 3) lp(j, 3) cin >> ar[i][j];
        int n; cin>> n;
        lp(i, n) { int a; cin >> a; f[a]++; }
        bool isok= 1, isok1= 1, isok2= 1;
        lp(i, 3) {
                isok= 1;
                lp(j, 3) if (!f[ar[i][j]]) isok= 0;
                if (isok) { cout << "Yes\n"; return; }

                isok= 1;
                lp(j, 3) if (!f[ar[j][i]]) isok= 0;
                if (isok) { cout << "Yes\n"; return; }

                if (!f[ar[i][i]]) isok1= 0;

                if (!f[ar[i][2- i]]) isok2= 0;
        }
        if(isok1|| isok2) { cout << "Yes\n"; return; }
        else cout << "No";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;


int N, K;
int x[100010];


signed main(){
    cin >> N >> K;
    rep(i, 0, N) cin >> x[i];

    int ans = INF;
    rep(i, 0, N-K+1){
        if(i != 0 && 0 < x[i-1]) continue;
        if(i != N-K && x[i+K] < 0) continue;
        if(x[i+K-1] <= 0) chmin(ans, abs(x[i]));
        else if(0 <= x[i]) chmin(ans, x[i+K-1]);
        else chmin(ans, min(2*abs(x[i])+x[i+K-1], 2*x[i+K-1]+abs(x[i])));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
ll n,k;
class lazyseg{
    private:
        ll n;
        vector<ll>a,t,lazy;
        //void pushdown(int v){
		//}
        void upd(int v,int l,int r,int tl,int tr,ll val){
            if(l > r)return;
            t[v]+=(r-l+1)*1LL*val;
            t[v]%=MOD;
            if(l == tl && r == tr){
                lazy[v]+=val;
                lazy[v]%=MOD;
                return;
            }
            int tm = (tl+tr)/2;
            upd(2*v,l,min(r,tm),tl,tm,val);
            upd(2*v+1,max(l,tm+1),r,tm+1,tr,val);
            //merge(v);
        }
        ll query(int v,int l,int r,int tl,int tr){
            if(l > r)return 0;
            if(l == tl && r == tr){
                return t[v];
            }
            int tm = (tl+tr)/2;
            return query(2*v,l,min(tm,r),tl,tm)%MOD+
                   (query(2*v+1,max(l,tm+1),r,tm+1,tr)+
                   (r-l+1)*1LL*lazy[v])%MOD;
        }
	   void build(int v,int tl,int tr){
		   if(tl == tr)t[v] = a[tl];
		   else{
		   	   int tm = (tl+tr)/2;
			   build(2*v,tl,tm);
			   build(2*v+1,tm+1,tr);
			   t[v] = t[2*v]+t[2*v+1];
	   	   }
	   }         
    public:
    lazyseg(ll _n,vector<ll>_a = {}){
        n = _n;
        t.resize(4*n);
        lazy.resize(4*n);
        a = _a;
    }
    void reset(){
        t.assign(4*n,0);
        lazy.assign(4*n,0);
    }
    
    //inline void merge(int v){
    //    t[v] = t[2*v]+t[2*v+1];
    //} i will include this later as sum aggregates also need r-l+1 to merge
    inline void merge(int v){
		t[v] = (t[2*v+1]+t[2*v])%MOD;
	}
		
    inline ll query(int l,int r){
        return query(1,l,r,1,n);
    }
    inline void upd(int l,int r,ll val){
        upd(1,l,r,1,n,val);
    }
    void build(){
        build(1,1,n);
	}
    
};
int main()
{
	cin>>n>>k;
	vector<ll>item;
	vector<ll>l(k),r(k);
	lazyseg s(n);
	for(int i=0;i<k;i++)cin>>l[i]>>r[i];
	s.upd(1,1,1);
	for(int j=1;j<=n;j++){
		ll add = s.query(j,j);
		 for(int i=0;i<k;i++){
			if(l[i]+j <= n){
				ll R = min(j+r[i],n);
				s.upd(l[i]+j,R,add);
			}
		}
	}
	cout<<s.query(n,n);
}


Measured memory_bytes: 15668
x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()
ab=[a[i]+b[j] for j in range(y) for i in range(x)]
ab.sort(reverse=True)
ab=ab[:k]
l=len(ab)
abc=[ab[i]+c[j] for j in range(z) for i in range(l)]
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])


Measured memory_bytes: 160564
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
 
int main(void) {
    std::string fake_S, S;
    std::cin >> fake_S >> S;
    std::cout << "A" << S[0] << "C" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200100
using namespace std;
const int INF=1008610086;
const int MOD=1e9+7;
inline void read(int &a){
	int f=a=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=1;ch=getchar();}
	while(ch<='9'&&ch>='0') a=a*10+ch-'0',ch=getchar();
	if(f) a=-a;
}
struct Node{
	int x,v,l,r;
}a[N];
inline bool cmpx(Node a,Node b){
	return a.x<b.x;
}
inline bool cmpv(Node a,Node b){
	return a.v<b.v;
}
int n,f[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		read(a[i].x);
		read(a[i].v);
	}
	sort(a+1,a+n+1,cmpv);
	for(int i=1;i<=n;i++) a[i].v=i;
	sort(a+1,a+n+1,cmpx);
	int ma=-INF,mi=INF;
	for(int i=1;i<=n;i++){
		ma=max(ma,a[i].v);
		a[i].r=ma;
	}
	for(int i=n;i;i--){
		mi=min(mi,a[i].v);
		a[i].l=mi;
	}
	int l=0,r=1;
	int sum=1;
	f[0]=a[0].l=1;
	a[n+1].l=a[n+1].r=n+1;
	for(int i=1;i<=n+1;i++){
		while(l<r&&a[i].l>a[l].r+1) sum=(sum-f[l++]+MOD)%MOD;
		f[i]=sum;sum=(sum+f[i])%MOD;
		r++;
	}
	printf("%d\n",f[n+1]);
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
using namespace std;
int main()
{
    int A,B,C;
    cin>>A>>B>>C;
    if((A==B&&A!=C)||(A==C&&A!=B)||(B==C&&B!=A))
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    int A,B,C;
    int N,M,K,X,Y,W,H;
    int ans;
    string S;
    int temp[100]={0};
    bool f=false;
    bool fir=true;

int main(){
    cin>>A>>B;
    A+B<10?cout<<A+B<<endl:cout<<"error"<<endl;

    return 0;

}


Measured memory_bytes: 256