akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll dp[3010][3010][2];
int N;
int a[3010];
ll rec(int l,int r,int t){
	if(r<l)return 0ll;
	if(dp[l][r][t]!=-LLINF)return dp[l][r][t];
	if(t==0){
		return dp[l][r][t]=max(rec(l+1,r,!t)+a[l],rec(l,r-1,!t)+a[r]);
	}else{
		return dp[l][r][t]=min(rec(l+1,r,!t)-a[l],rec(l,r-1,!t)-a[r]);	
	}
}
int main(){
	cin >> N;
	for(int i=0;i<N;i++)cin >> a[i];
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			for(int k=0;k<2;k++){
				dp[i][j][k]=-LLINF;
			}
		}
	}
	cout << rec(0,N-1,0) << endl;
	return 0;
}

Measured memory_bytes: 141696
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N; i++){
    int l;
    int r;
    cin >> l >> r ;
    sum += r-l+1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = [s[1:n].count("E")]
for i in range(1, n):
    #ans.append(s[:i].count('W') + s[i+1:].count('E'))
    ans.append(ans[i-1]-int(s[i] is "E")+int(s[i-1] is "W"))
print(min(ans))

Measured memory_bytes: 15544
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;


public class Main{
	public static void main(String[] args)throws Exception{
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();//the number of piles
		int m=sc.nextInt();//the number of fences
		double[] x=new double[n];
		double[] y=new double[n];
		double sum=0;
		for(int i=0;i<n;i++){
			x[i]=sc.nextDouble();
			y[i]=sc.nextDouble();
		}
		Kruskal kl=new Kruskal(n);
		for(int i=0;i<m;i++){
			int from=sc.nextInt()-1;
			int to=sc.nextInt()-1;
			double d=Math.sqrt((x[from]-x[to])*(x[from]-x[to])+(y[from]-y[to])*(y[from]-y[to]));
			kl.addEdge(from, to, d);
			kl.addEdge(from, to, d);
//			tr(from,to,d);
			sum+=d;
		}
		double total=kl.get_minimum_spanning_tree();
		System.out.println(sum-total);
	}

	class Kruskal{
		int n;//the number of vertices
		double weight_sum=-1;
		List<Edge>[] edges;//adjacency list
		PriorityQueue<Edge> pq;
		Kruskal(int n){
			this.n=n;
//			edges=new List[n];
//			for(int i=0;i<n;i++){
//				edges[i]=new ArrayList<Edge>();
//			}
			pq=new PriorityQueue<Edge>();
		}

		double get_minimum_spanning_tree(){
			DJSet ds=new DJSet(n);
			weight_sum=0;
			while(!pq.isEmpty()){
				Edge e=pq.poll();
				if(ds.same(e.from, e.to))continue;
				weight_sum+=e.cost;
				ds.setUnion(e.from, e.to);
			}
//			if(ds.size(0)!=n)return -1;
return weight_sum;
		}
		void addEdge(int from,int to,double cost){
//			edges[from].add(new Edge(from,to,cost));
			pq.add(new Edge(from,to,cost));
		}
	}

	class Edge implements Comparable<Edge>{
		int from;
		int to;
		double cost;
		Edge(int from,int to,double cost){
			this.from=from;
			this.to=to;
			this.cost=cost;
		}
		public int compareTo(Edge o){
			return this.cost>o.cost?-1:this.cost<o.cost?1:0;
		}
	}
	class DJSet{
		int n;//the number of vertices
		int[] d;
		DJSet(int n){
			this.n=n;
			d=new int[n];
			Arrays.fill(d, -1);
		}
		int root(int x){
			return d[x]<0?x:root(d[x]);
		}
		boolean setUnion(int x,int y){
			x=root(x);
			y=root(y);
			if(x!=y){
				if(x<y){
					int d=x;
					x=y;
					y=d;
				}
				//x>y
				d[y]+=d[x];
				d[x]=y;
			}
			return x!=y;
		}
		boolean same(int x,int y){
			return root(x)==root(y);
		}
		int size(int x){
			return d[root(x)]*(-1);
		}
	}


	void tr(Object...objects){System.out.println(Arrays.deepToString(objects));}
}

Measured memory_bytes: 73800
H,W = list(map(int, input().split()))

a = []
for i in range(H):
  a.append(list(map(int, input().split())))

m = []
for i in range(H-1):
  for j in range(W):
    if a[i][j] % 2 == 1:
      s = str(i+1) + " " + str(j+1) + " " + \
      	str(i+2) + " " + str(j+1)
      m.append(s)
      a[i+1][j] += 1

for i in range(W-1):
  if a[-1][i] % 2 == 1:
    s = str(H) + " " + str(i+1) + " " + \
      	str(H) + " " + str(i+2)
    m.append(s)
    a[-1][i+1] += 1
    
print(len(m))
for i in range(len(m)):
  print(m[i])

Measured memory_bytes: 16344
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

class Circle {
private:
	int x;
	int y;
	int radius;

public:
	Circle(vector<int>&iList) {
		x = iList[2];
		y = iList[3];
		radius = iList[4];
	}
	int Right() {
		return x + radius;
	}
	int Top() {
		return y + radius;
	};
	int Bottom() {
		return y - radius;
	}
	int Left() {
		return x - radius;
	}
};

class Rectangle {
private:
	int x;
	int y;

public:
	bool IsItemOnThis(Circle *circle);

	int Right() {
		return x;
	}
	int Top() {
		return y;
	};
	int Bottom() {
		return 0;
	}
	int Left() {
		return 0;
	}
	Rectangle(vector<int>&iList) {
		x = iList[0];
		y = iList[1];
	}
};

bool Rectangle::IsItemOnThis(Circle *circle) {
	
	//長方形の内部に入ってれば
	 return ((circle->Right() <= Right()) &&
		(circle->Top() <= Top()) &&
		(circle->Left() >= Left()) &&
		(circle->Bottom() >= Bottom()));
}

void GetSplitSpace(string str, vector<string> &list) {

	stringstream ss(str);
	string item;
	while (getline(ss, item, ' ')) {
		list.push_back(item);
	}
}

void ConvertToInt(vector<string> &list, vector<int> &iList) {

	for (unsigned int i = 0; i < list.size(); i++) {
		iList.push_back(stoi(list[i]));
	}
}

int main()
{
	string str;

	//標準入力から１行取得する
	getline(cin, str);

	vector<string> list;
	//取得した行を空白区切りで配列に順次格納（５つの整数）
	GetSplitSpace(str, list);

	vector<int> iList;
	//整数に変換
	ConvertToInt(list, iList);

	//変数に入れる処理
	Circle *circle = new Circle(iList);
	Rectangle *rect = new Rectangle(iList);

	//内部ならYESと出力
	if (rect->IsItemOnThis(circle)) {
		cout << "Yes" << endl;
	}
	//一部でもはみ出るならNoと出力
	else {
		cout << "No" << endl;
	}
	delete circle;
	delete rect;

    return 0;
}



Measured memory_bytes: 3228
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static List<List<Integer>> ptnList = new ArrayList<>();

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		int count = 0;

		int l = s.length();
		int h = l / 2;

		for(int i = 0; i < h; i++) {
			String s1 = s.substring(i, i + 1);
			String s2 = s.substring(l - i - 1, l - i);
			if(s1.equals(s2) == false) {
				count++;
			}
		}

		System.out.println(count);

	}

}


Measured memory_bytes: 22612
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	int n;
	int a, b, c;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c;
		if((a * a + b* b == c * c) || (a * a + c * c == b * b) || (b * b + c * c == a * a))
			cout << "YES\n";
		else
			cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 1120
#include<bits/stdc++.h>
using namespace std;
int n ;
int dp[100002][4];
int A[100002],B[100002],C[100002];
int f(int rem,int c)
{
    if(rem==0)
        return dp[rem][c]=0 ;
    if(dp[rem][c]!=-1)
        return dp[rem][c];
    if(c==1)
    {
        return dp[rem][c]=A[rem]+max(f(rem-1,2),f(rem-1,3));
    }
    if(c==2)
    {
        return dp[rem][c]=B[rem]+max(f(rem-1,1),f(rem-1,3));
    }
    if(c==3)
    {
        return dp[rem][c]=C[rem]+max(f(rem-1,1),f(rem-1,2));
    }
}
int main()
{
    scanf("%d",&n);
    for(int i = 1 ; i<=3;++i)
    {
        for(int j = 0 ; j<=n ; ++j)
        {
            dp[j][i]=-1;
        }
    }
    for(int i = 1; i<=n;++i)
    {
        scanf("%d%d%d",&A[i],&B[i],&C[i]);
    }

    printf("%d",max(f(n,1),max(f(n,2),f(n,3))));
}


Measured memory_bytes: 7680
using System;
using System.Collections.Generic;
using System.Linq;
namespace CsProgramSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            List<List<int>> li = new List<List<int>>();
            List<int> temp = new List<int>();
            int c = 0;
            while (true)
            {
                temp = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList();
                foreach(var i in temp)
                {
                    if (i == 0) c++;
                }
                if (c != 2)
                    li.Add(temp);
                else break;
                c = 0;
            }
            foreach(List<int> l in li)
            {
                l.Sort();
                int[] us = l.ToArray();
                Console.WriteLine(string.Format("{0} {1}", us[0], us[1]));
            }
        }
    }
}


Measured memory_bytes: 18496
import sys
input = sys.stdin.readline

def main():
    s = list(input().rstrip())
    k = int(input())


    if len(s) == 1:
        print(k//2)
    else:
        sa = s[:]

        c1 = 0
        c2 = 0

        for i in range(len(s) - 1):
            if sa[i] == sa[i+1]:
                c1 += 1
                sa[i+1] = '1'


        if sa[0] == sa[-1]:
            s[0] = '2'
            c2 += 1

            for i in range(len(s) - 1):
                if s[i] == s[i+1]:
                    c2 += 1
                    s[i+1] = '2'


            if s[-1] == sa[0]:
                print(c1 + c2*(k-1))
            elif s[-1] != sa[0]:
                if k % 2 == 0:
                    x = k // 2
                    print(c1*x + c2*x)
                else:
                    x = k // 2
                    print(c1*(x+1) + c2*x)
        else:
            print(c1*k)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Q;
  string S;
  cin >> N >> Q >> S;
  
  vector<int>l(Q);
  vector<int>r(Q);
  for (int i = 0; i < Q; i++) {
    cin >> l.at(i) >> r.at(i);
  }
   
  vector<int>A(N);
  A.at(0) = 0;
  for (int i = 1; i < N; i++) {
    if (S.at(i) == 'C' && S.at(i-1) == 'A'){
      A.at(i) = A.at(i-1) + 1;
    }
    else {
      A.at(i) = A.at(i-1);
    }
  }
  
  for (int i = 0; i < Q; i++) {
    cout << A.at(r.at(i)-1) - A.at(l.at(i)-1) << endl;
  }
}
  

Measured memory_bytes: 4524
#define REP(i, n) for (int i = 0; i < (n); ++i)

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  long long sum = 0;
  REP(i, s.length()) {
      if(s[i] == '0') sum++;
  }
  cout << min({sum, (long long) (s.length() - sum)}) * 2 << endl;
  return 0;
}


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

using namespace std;

int main(){
	long a, b, c, d;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;

	long ac, ad, bc, bd;
	ac = a * c;
	ad = a * d;
	bc = b * c;
	bd = b * d;

	cout << max({ac, ad, bc, bd});

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int c[n],s[n],f[n];
    for(int i=0;i<n-1;i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    
    for(int i=0;i<n;i++){
        int t=0;
        for(int j=i;j<n-1;j++){
            if(t<s[j]){
                t=s[j]; //駅出発時
            }else if(t%f[j]==0);
            else t=t+f[j]-t%f[j]; //駅の到着と出発がかみ合わない場合
            t+=c[j];
        }
        cout << t << endl;
    }
}

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int D;
    cin >> D;
    vint downrate(26);
    Graph<int> uppoint(D, vint(26));
    rep(i, 26) {
        cin >> downrate[i];
    }

    rep(i, D) {
        rep(j, 26) {
            cin >> uppoint[i][j];
        }
    }

    // ll satisfy = 0;
    // vint schedule(D);
    // rep(i, D) {
    //     cin >> schedule[i];
    //     schedule[i]--;
    //     satisfy += uppoint[i][schedule[i]];
    //     lastDay[schedule[i]] = i;
        // rep(j, 26) {
        //     satisfy -= (i - lastDay[j]) * downrate[j];
        // }
    //     cout << satisfy << endl;
    // }

    vint lastDay(26, -1);
    
    ll satisfy = 0;
    rep(i, D) {
        ll satisfylossmax = 0;
        ll satisfyid = -1;
        rep(j, 26) {
            ll satisfyloss = (i - lastDay[j]) * downrate[j] + uppoint[i][j];
            if (satisfylossmax < satisfyloss) {
                satisfylossmax = satisfyloss;
                satisfyid = j;
            }
        }

        satisfy += uppoint[i][satisfyid];
        lastDay[satisfyid] = i;
        rep(j, 26) {
            satisfy -= (i - lastDay[j]) * downrate[j];
        }
        cout << satisfyid+1 << endl;
    }
}

Measured memory_bytes: 3680
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"


int n, m;
vvi a;

bool read() {
	if  (scanf("%d%d", &n, &m) < 2) {
		return 0;
	}
	a.assign(n, vi(m));
	forn(i, n) {
		forn(j, m) {
			scanf("%d", &a[i][j]);
			--a[i][j];
		}
	}
	return 1;
}

const int INF = 1e9;

int solve() {
	int ans = INF;
	vi alive(m, 1);
	forn(it, m) {
		vi cnt(m, 0);
		forn(i, n) {
			bool was = 0;
			forn(j, m) {
				if  (alive[a[i][j]]) {
					++cnt[a[i][j]];
					was = 1;
					break;
				}
			}
			assert(was);
		}

		int mx = max_element(all(cnt)) - cnt.begin();
		ans = min(ans, cnt[mx]);
		alive[mx] = 0;
	}
	return ans;
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		printf("%d\n", solve());
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

signed main(){
    string s;
    cin>>s;
    
    int l = s.size();
    
    map<char,int> hist;
    
    rep(i,s.size()){
        hist[s[i]]++;
    }
    
    ll ans = l*(l-1)/2;
    
    for(auto e:hist){
        ans -= e.second*(e.second-1)/2;
    }
    
    cout<<ans+1<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int res[100001];

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    string s; cin >> s;
    int n = s.length();
    vector<pii> v;
    vector<int> pos;  // R idx of [R, L]
    int r = 0, l = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == 'R') r++;
        else l++;

        if (s[i] == 'R' && s[i + 1] == 'L') {
            if (!v.empty()) {
                v[v.size() - 1].second = l;
                l = 0;
            }
            v.emplace_back(r, 0);
            r = 0;
            pos.push_back(i);
        }
    }
    v[v.size() - 1].second = l + 1;

    for (int i = 0; i < pos.size(); i++) {
        // cout << pos[i] << '\n';
        // cout << v[i].first << ' ' << v[i].second << '\n';

        int r = v[i].first, l = v[i].second;
        int len = r + l;
        if (len % 2 == 0) {
            res[pos[i]] = res[pos[i] + 1] = len / 2;
        } else {
            if (r % 2) {
                res[pos[i]] = len / 2 + 1;
                res[pos[i] + 1] = len / 2;
            } else {
                res[pos[i]] = len / 2;
                res[pos[i] + 1] = len / 2 + 1;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << res[i] << ' ';
    }
    cout << '\n';

    return 0;
}


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

#pragma warning(disable:4996)
using namespace std;
using ld =long double;

int ans=0;

int N, K;
pair<int,int> dfs(const vector<vector<int>>&edges, const int now, const int from) {
	int sum=0;
	vector<int>v(2,0);
	int one_num=0;
	int ch_num=1;
	bool flag=false;
	int ch_big_num=0;
	for (auto e : edges[now]) {
		if(e==from)continue;
		else {
			auto k=dfs(edges,e,now);

			int put_reward=k.first;
			int not_reward=0;
			if (k.second >= K) {
				not_reward=1;
				if (put_reward != 0) {
					flag=true;
				}
				put_reward=1;
				ch_big_num++;
			}
			else {
				flag=true;
			}
			ch_num+=k.second;
			put_reward=max(put_reward,k.first);

			if (put_reward >= 1) {
				sum++;
				v.push_back(put_reward);

				sort(v.begin(), v.end(), greater<int>());
				if (v.size() == 3)v.pop_back();
			}
		}
	}
	
	int nans=sum;
	if(!flag)nans--;
	if(v[0]>=1)nans+=v[0]-1;
	if(v[1]>=1)nans+=v[1]-1;
	if (ch_num <= N - K) {
		ans=max(ans,nans+1);
	}
	else {
		ans=max(ans,nans);
	}
	int kans=sum;
	if(v[0]>=1)kans+=v[0]-1;
	kans=max(kans,ch_big_num);
	return make_pair(kans,ch_num);
}

int main() {cin>>N>>K;
	vector<vector<int>>edges(N);
	for (int i = 1; i < N; ++i) {
		int a,b;cin>>a>>b;a--;b--;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	dfs(edges,0,-1);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 20464
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	int ans = 0;
  	cin >> s;
  	for(int i=0;i<s.size()/2;i++){
		if(s[i]!=s[s.size()-i-1])ans++;
    }
  	cout << ans;
}


Measured memory_bytes: 256
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val a = Array(n){ i ->  Pair(i, readLine()!!.toInt()) }
    a.sortByDescending { it.second }
    val max = a[0]
    val prevMax = a[1]
    for(i in a.indices){
        if(i == max.first){
            println(prevMax.second)
        }else{
            println(max.second)
        }
    }
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N,i; cin>>N>>i;
    cout<<N-i+1<<endl;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a,b,c,d = na()
if abs(c-a) <= d:
    print("Yes")
elif abs(b-a) <= d and abs(c-b) <= d:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const int MAX_N = 1000;
int par[MAX_N];//親
int pank[MAX_N];//木の深さ

//n要素で初期化
void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        pank[i]=0;
    }
}

//木の根を求める
int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x==y)return;
    if(pank[x]<pank[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(pank[x]==pank[y])pank[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same(int x,int y){
    return find(x)==find(y);
}
const int inf = 1e6;
int main(void){
    int n;cin>>n;
    char c[n][n];
    vector<vector<int>> t(n,vector<int>(n,inf));
    rep(i,n)rep(j,n){
        cin>>c[i][j];
        if(c[i][j]=='1')t[i][j]=1;
    }
    rep(i,n)t[i][i]=0;
    init(n*2+10);
    rep(i,n)rep(j,n){
        if(c[i][j]=='0')continue;
        if(same(i,j)||same(i+n,j+n)){
            cout<<-1<<endl;
            return 0;
        }else{
            unite(i,j+n);
            unite(j,i+n);
        }
    }
    int res=0;
    rep(k,n)rep(i,n)rep(j,n) chmin(t[i][j],t[i][k]+t[k][j]);
    rep(i,n)rep(j,n) chmax(res,t[i][j]);
    cout<<res+1<<endl;
}

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

using namespace std;
 
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i)
void fastscan(int &x)
 {
        bool neg=false;
        register int c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    } 
string alpha = "abcdefghijklmnopqrstuvwxyz";
const int mod = 1e9+7;
const int inf = 2e18+5;
const int nax = 100010;
const int mod1 = 998244353;

signed main()
 {
   
  string s,l,r;
  cin>>s;
  int n = s.size();
  l.assign(s,0,(n-1)/2);
  r.assign(s,(n+1)/2,(n-1)/2);
  string t1 = s,t2 = l,t3 = r;
  reverse(s.begin(),s.end());
  reverse(l.begin(),l.end());
  reverse(r.begin(),r.end());
  //cerr<<t1<<END<<t2<<END<<t3;
  if(t1!=s)
    {
     cout<<"No";
     return 0;
    } 
    if(t2!=l)
    {
     cout<<"No";
     return 0;
    } 
    if(t3!=r)
    {
     cout<<"No";
     return 0;
    } 
  
     cout<<"Yes";
  
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main(){    
char search[21], word[21];    
int count=0;    
int i;        
scanf("%s", search);    
while(1){        
scanf(" %s", word);        
if(strcmp(word, "END_OF_TEXT")==0)break;        
for(i=0;word[i]!='\0';i++){            
word[i]=tolower(word[i]);        }        
if(strcmp(word, search)==0){            
count++;        }    }    
printf("%d\n", count);    
return 0;
}


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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




int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};



void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


// 繰り返し二乗法
ll power(ll a, ll b){
  if(a==1)return a;
  // if(a==0)re
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

const int MAX=2100000;
 
ll fact[MAX], fact_inv[MAX];
 
void init_fact(ll n){
  fact[0]=1;
  // 階乗の計算
  rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
  fact_inv[n]=power(fact[n], MOD-2);
  // 逆元の計算
  for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}
 
ll comb(ll n, ll r){
  return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
 
ll perm(ll n, ll r){
  return (fact[n]*fact_inv[n-r])%MOD;
}






int main() {
  cout<<fixed<<setprecision(10);

  ll r; cin>>r;

  if(r < 1200) puts("ABC");
  else if ( r < 2800) puts("ARC");
  else puts("AGC");


}






Measured memory_bytes: 768
import sys

n, y = map(int,input().split())

for i in range(n+1) :
    for j in range(n + 1):
        k = n - i - j
        if k >= 0 and i * 10000 + j * 5000 + k * 1000 == y :
            print(i,j,k)
            sys.exit()

print('-1 -1 -1')

Measured memory_bytes: 9052
rect_cnt = dia_cnt = 0

while True:
  try:
    a, b, c = map(int, input().split(","))
    
    rect_cnt += (a ** 2 + b ** 2 ==  c ** 2)
    dia_cnt += (a == b)

  except EOFError:
    break

print(rect_cnt)
print(dia_cnt)


Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int d = sc.nextInt();
		int n = sc.nextInt();

		if (n == 100) {
			n = 101;
		}
		switch (d) {
		case 0:
			System.out.println(n);
			break;

		case 1:
			System.out.println(n * 100);
			break;

		case 2:
			System.out.println(n * 10000);
		}

	}
}

Measured memory_bytes: 24148
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(c) (c).begin(), (c).end()
#define P pair<int, int>
#define chmin(x, y) x = min(x, y)

int main()
{
  int x, n;
  cin >> x >> n;
  vector<int> d(102);
  rep(i, n)
  {
    int p;
    cin >> p;
    d[p] = 1;
  }

  P ans(999, 0);
  for (int i = 0; i <= 101; i++)
  {
    if (d[i] == 1)
      continue;
    int dif = abs(x - i);
    ans = min(ans, P(dif, i));
  }

  cout << ans.second << endl;
}


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

using namespace std;
#define ll long long int
int main()
{
    int n;
    cin>>n;
    int W;
    cin>>W;
    int w[n];
    int v[n];
    for(int i=0;i<n;++i){
        cin>>w[i]>>v[i];
    }
    ll dp[n+1][W+1];
    for(int i=0;i<=n;++i){
        for(int j=0;j<=W;++j){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else if(j>=w[i-1]){
                dp[i][j] = max(dp[i-1][j-w[i-1]]+v[i-1], dp[i-1][j]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout<<dp[n][W];
    return 0;
}


Measured memory_bytes: 82360
#include<iostream>
#include<string>

using namespace std;

string s;
int cnt;


int main(){


	cin >> s;


	for (int i = 0; i < 4; i++) {
		if (s[i] == s[i + 1]) {
			cnt++;
		}
	}
	if (cnt == 0){
		cout << "Good" << endl;
	}
	else cout << "Bad" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b;
  scanf("%d %d", &a, &b);
  int max = a+b;
  if(max < a-b) max = a-b;
  if(max < a*b) max = a*b;
  printf("%d", max);
  return 0;
}
  


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

int main() {
  using pp=pair<int,int>;
  vector<pp> V(4);
  pp a, b, c, d, t, tmp;
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  V[0].first=x1;
  V[0].second=y1;
  V[1].first=x2;
  V[1].second=y2;
  t.first = V[1].first - V[0].first;
  t.second = V[1].second - V[0].second;
  tmp=t;
  for (int i=0; i<2; i++) {
    tmp.first = V[i+1].first - V[i].first;
    tmp.second = V[i+1].second - V[i].second;
    t.first=-tmp.second;
    t.second=tmp.first;
    V[i+2].first=V[i+1].first+t.first;
    V[i+2].second=V[i+1].second+t.second;
  }
  cout << V[2].first << " " << V[2].second << " " << V[3].first << " " << V[3].second << endl;
} 


Measured memory_bytes: 3584
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll cur, nxt;
    cin >> cur;
    int tmp = 0;
    int ret = 0;
    for(int i=0;i<n-1;++i)
    {
        cin >> nxt;
        if(cur >= nxt)
        {
            tmp++;
        }
        else
        {
            ret = max(ret, tmp);
            tmp = 0;
        }
        cur = nxt;
    }
    ret = max(ret, tmp);
    cout << ret << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n ;
ll a[200009], ans;
ll solve(ll b)
{
	ll sum=0;
	for (int i=1; i<=n; i++)
	{
		b++;
		sum+=abs(b-a[i]);
	}
	return sum;
}
int main()
{
	IO;
	cin>>n;
	for (int i=1; i<=n; i++)
		cin>>a[i];
	ll low=-1e9-9, high=1e9+9, m1, m2;
	while (low<=high)
	{
		m1=low+(high-low)/3;
		m2=high-(high-low)/3;
		if (solve(m1)<=solve(m2))
			ans=solve(m1), high=m2-1;
		else
			low=m1+1, ans=solve(m2);
	}
	cout<<ans;

}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int i,d=0;
	char hutu[100],hanten[100];
	
	scanf("%s",hutu);
	
	for(i=0;hutu[i] != '\0';i++){
	}
	for(i-=1;i>=0;i--){
		hanten[d]=hutu[i];
		d+=1;
	}
	hanten[d]='\0';
	printf("%s\n",hanten);
	return 0;
}

Measured memory_bytes: 520
def calculator(op, x, y):
    if op == '+':
        return x + y
    elif op == '-':
        return y - x
    else:
        return x * y


raw = [r for r in input().split()]
for i in range(len(raw)):
    try:
        raw[i] = int(raw[i])
    except:
        continue

arr = []
buff = 0
for i in range(len(raw)):
    if isinstance(raw[i], int):
        arr.append(raw[i])
    else:
        buff = calculator(raw[i], arr.pop(), arr.pop())
        arr.append(buff)

print(*arr)



Measured memory_bytes: 5600
#include<stdio.h>
#define MAX 2000000

int H,A[MAX+1];

void swap(int *a,int *b){
  int tmp;
  tmp=*a;
  *a=*b;
  *b = tmp;

}
void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;

  if(l <= H && A[l] > A[i])largest=l;
  else largest=i;
  if(r<=H && A[r] > A[largest])largest=r;
  if(largest!=i){
    swap(&A[i],&A[largest]);
    maxHeapify(largest);
  }
}

int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--)maxHeapify(i);
  for(i=1;i<=H;i++){
    printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}



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

int main() {
    int N;
    std::cin >> N;
    int count = 0;
    for (int i = 0; i < N; i++) {
        int val;
        std::cin >> val;
        if (val != i + 1) {
            count++;
        }
    }
    if (count > 2) {
        std::cout << "NO" << std::endl;
    } else {
        std::cout << "YES" << std::endl;
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
 long long H, W;
  unsigned long long count=0;
  cin >> H >> W;
  if(H!=1&&W!=1){
    if(H%2!=0&&W%2!=0){//両方奇数
      count = H * W /2 + 1;
    }
    else count = H * W / 2;//少なくとも一方は偶数
  }
  else
    count = 1;
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

void solve() {
    int x;
    cin >> x;
    string s;
    cin >> s;
    int r = 0;
    int w = 0;
    for (char i : s) {
        if (i == 'R') {
            r++;
        }
    }
    int ans = r;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'R') {
            r--;
        } else {
            w++;
        }
        ans = min(max(w, r), ans);
    }
    cout << ans;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();

    return 0;
}

Measured memory_bytes: 3776
import static java.lang.System.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(in);
        int N = sc.nextInt();
        int[] a = new int [N];
        int[] count = new int[200001];
        Set<Integer> set = new HashSet<>();
        for (int i=0; i<N; i++) {
            int num = sc.nextInt();
            a[i] = num;
            count[num] += 1;
            set.add(num);
        }
        long ans = 0;
        ArrayList<Integer> list = new ArrayList<>(set);
        for (int j=0; j<list.size(); j++) {
            int cnum = count[list.get(j)];
            ans += ((long)cnum*(long)(cnum-1)/2);
        }
        for (int k=0; k<N; k++)
            out.println(ans-(count[a[k]]-1));
    }
}

Measured memory_bytes: 70840
#include <stdio.h>
int main(void){
	int a, b, c;
	scanf("%d",  &a);
    scanf( "%d",  &b);
    scanf( "%d",  &c);
    int x = b-a;
    int y = c-b;
   if(x==y){
    printf("YES");}
    else if(x != y){
   	printf("NO");
}


}

Measured memory_bytes: 128
n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = 1000000000000000000000000000000000000000000000000000000000000000000000000000
for i in range(n-k+1):
    ki = x[i + k - 1] - x[i]
    ans = min(ans,ki + abs(x[i]),ki + abs(x[i + k - 1]))
print(ans)

Measured memory_bytes: 14536
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    double sum=0.0,x;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        sum+=(1/x);
    }
     printf("%.12lf\n",1/sum);
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int n = in.i();
        int[][] gcd = new int[n + 1][n + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                gcd[i][j] = gcd(i, j); 
            }
        }
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                int g = gcd[i][j];
                for (int k = 1; k <= n; k++) {
                    ans += gcd[k][g];
                }
            }
        }
        out.println(ans);
    }

    static int gcd(int a, int b){
        int r = b%a;
        return r == 0 ? a : gcd(r, a);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


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

int main(){
  string s;
  cin>>s;
  string a="",b="";
  int ans=0;
  for(int i=0;i<s.size();i++){
    a+=s[i];
    if(a!=b){
      ans++;
      b=a;
      a="";
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a%(b*2+1)==0)
	{
		cout<<a/(b*2+1);
		return 0;
}
else
{
cout<<a/(b*2+1)+1;
return 0;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

int dp[100005];
void solve(){	
	int n;
	cin>>n;
	memset(dp, inf, sizeof(dp));
	int arr[n];
	for(int i=0;i<n;i++) cin>>arr[i];
	dp[0] = 0;
	dp[1] = abs(arr[1]-arr[0]);
	FOR(i, 2, n){
		dp[i] = min(abs(arr[i]-arr[i-1])+dp[i-1], abs(arr[i]-arr[i-2])+dp[i-2]);
		//cout<<dp[i]<<" ";
	}
	cout<<dp[n-1]<<endl;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main() {
	int H, W; cin >> H >> W;
	char c[100][100];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++)
			cin >> c[i][j];
	}
	bool blackH[100];
	bool blackW[100];
	for (int i = 0; i < H; i++)
		blackH[i] = false;
	for (int i = 0; i < W; i++)
		blackW[i] = false;

	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) {
			if (c[j][i] == '#') {
				blackW[i] = true;
				break;
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (c[i][j] == '#') {
				blackH[i] = true;
				break;
			}
		}
	}
	
	for (int i = 0; i < H; i++) {
		if (blackH[i]) {
			for (int j = 0; j < W; j++) {
				if (blackW[j])
					cout << c[i][j];
			}
			cout << endl;
		}
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

using namespace std;

/**
 * main
 */
int main () {
  string S_;
  cin >> S_;

  list<char> S;
  for (const char c : S_) {
    S.push_back(c);
  }

  int Q;
  cin >> Q;

  bool is_reversed = false;
  while (Q--) {
    int type;
    scanf("%d", &type);

    if (type == 1) {
      is_reversed = !is_reversed;
    } else if (type == 2) {
      int F;
      char C;
      scanf("%d %c", &F, &C);

      if (!is_reversed && F == 1 || is_reversed && F == 2) {
        S.push_front(C);
      } else {
        S.push_back(C);
      }
    }
  }

  if (is_reversed) {
    for (auto it = S.rbegin(); it != S.rend(); it++) {
      printf("%c", *it);
    }
    printf("\n");
  } else {
    for (auto it = S.begin(); it != S.end(); it++) {
      printf("%c", *it);
    }
    printf("\n");
  }
}


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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll gcd(ll a, ll b) {//最大公約数
	if (a < b)swap(a, b);
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	if (a < b)swap(a, b);
	return (a / gcd(a, b))*b;
}

int main() {

	int c[3][3];
	rep(i, 3) rep(j, 3)cin >> c[i][j];
	int a[3], b[3];
	a[0] = 0;
	rep(i, 3)b[i] = c[0][i];
	for (int i = 1; i < 3; i++)a[i] = c[i][0] - b[0];

	bool flag = true;

	rep(i, 3)rep(j, 3)if (c[i][j] != a[i] + b[j])flag = false;

	if (flag)pr("Yes");
	else pr("No");

	//system("pause");
	return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    vi a(N);
    REP(i, N) {
        cin >> a[i];
    }
    map<int, int> mp;
    REP(i, N) {
        mp[a[i]]++;
        mp[a[i]] &= 1;
    }
    int ans = 0;
    for(auto itr = mp.begin(); itr!= mp.end(); ++itr) {
        if(itr->second) ans++;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

const int INF = 1 << 30;

int main()
{
  int N, A[100];
  bool cnt[8] = {};
  cin >> N;
  bool only = true;
  int st = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    only &= A[i] >= 3200;
    if(A[i] >= 3200) {
      ++st;
      continue;
    }
    cnt[A[i] / 400]++;
  }
  if(only) {
    cout << 1 << endl;
    cout << N << endl;
  } else {
    int ret = 0;
    for(int i = 0; i < 8; i++) ret += cnt[i];
    cout << ret << endl;
    cout << ret + st << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl a(n);cin>>a;
	int ans=0;
	range(i,1,n-1){
		vl b={a[i-1],a[i],a[i+1]};
		sort(all(b));
		if(b[1]==a[i])ans++;
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans1,ans2;
int a[110];
bool cmp(int x,int y)
{
	return x>y;
} 
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++)
	{
	        if(i%2==0)
	        ans2+=a[i];
			else
			ans1+=a[i];
	}
	cout<<ans1-ans2;
	return 0;
	 
} 

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

using std::cout;
using std::cin;
using std::endl;

int main() {
	char a, b, c;
	cin >> a >> b >> c;
	if (a == '7' || b == '7' || c == '7')
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	cout << endl;
}

Measured memory_bytes: 3596
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a = INT()
b = INT()
h = INT()
ans = (a + b) * h /2
print(int(ans))


Measured memory_bytes: 5188
#include <iostream>
     
using namespace std;
typedef long long ll;

ll gcd(ll l, ll m){
    ll tmp;
    // cout << l << m << endl;
    if(m > l){
        tmp = m;
        m = l;
        l = tmp;
    }
    while ((1)){
        ll s;
        s = l % m;
        if(s == 0) return m;
        tmp = m;
        m = s;
        l = tmp;
    }
}

    
ll gcd3(ll l, ll m, ll n){
    return gcd(gcd(l,m),n);
}

int main() {
    int k;
    ll ans=0;
    cin >> k;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                ans += gcd3(a,b,c);
            }
        }
    }  
    cout << ans << endl;
    
}


Measured memory_bytes: 3632