akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <complex>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

using P = complex<double>;

int main() {
	int n {in};
	vector<P> v(n);
	for (P &i: v) {
		int x {in}, y {in};
		i = P(x, y);
	}
	v.push_back(v[0]);
	double a {};
	for (int i: range(n))
		a += imag(v[i] * conj(v[i + 1]));
	printf("%.1f\n", abs(a/2));
}


Measured memory_bytes: 2720
#include<iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

void searchVector(const vector<int>& vec,vector<int>& check) {
	check.clear();
	for (int i = 0; i < vec.size();i++) {
		check.push_back(vec[i]);
	}
}

int main() {
	int N, input;
	int a = 0, b = 0, counter = 0;
	vector<int> P, Q;
	cin >> N;
	vector<int>D;
	vector<int>check;
	for (int i = 0; i < N; i++) {
		D.push_back(i + 1);
	}
	for (int i = 0; i < N; i++) {
		cin >> input;
		P.push_back(input);
	}
	for (int i = 0; i < N; i++) {
		cin >> input;
		Q.push_back(input);
	}
	do {
		counter++;
		searchVector(D, check);
		if (P == check) {
			a = counter;
		}
		if (Q == check) {
			b = counter;
		}
	} while (std::next_permutation(D.begin(), D.end()));
	cout << abs(a - b);
	return 0;
}

Measured memory_bytes: 256
using AtCoderBeginnerContest144.Questions;
using AtCoderBeginnerContest144.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest144.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var ab = inputStream.ReadIntArray();
            var a = ab[0];
            var b = ab[1];
            if (a < 10 && b < 10)
            {
                yield return a * b;
            }
            else
            {
                yield return -1;
            }
        }
    }
}


namespace AtCoderBeginnerContest144
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest144.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest144.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
// 2 2 -> 0
// 2 1 -> 2
// 2 0 -> 0
// 1 2 -> -2
// 1 1 -> 0
// 1 0 -> 0
// 0 2 -> 0
// 0 1 -> 0
// 0 0 -> 0
 
 
int main(){
    string s,t;
    cin>>s>>t;
    int len_t=t.length();
    int len_s=s.length();
    int ans=0;
    for(int i=0;i<=len_s-len_t;i++){
        string temp=s.substr(i,len_t);
        // cout<<temp<<endl;
        int cnt=0;
        for(int j=0;j<len_t;j++){
            if(temp[j]==t[j]){
                cnt++;
            }
        }
        ans=max(ans,cnt);
 
    }
    // cout<<ans<<endl;
    cout<<len_t-ans<<endl;
}

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

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

  ll D; cin >> D;
  vector<ll> C(26); for (ll i = 0; i < 26; i++) cin >> C[i];
  vector<vector<ll>> S(D, vector<ll>(26, 0));
  for (ll i = 0; i < D; i++) {
    for (ll j = 0; j < 26; j++) {
      cin >> S[i][j];
    }
  }

  ll cnt = 0;
  vector<ll> T(D, 0);
  vector<ll> last(26, 0);

  ll ans = 0;
  for (ll i = 0; i < D; i++) {
    ll t = 0;
    for (ll j = 0; j < 26; j++) {
      if ( C[j] * (i + 1 - last[j]) > C[t] * (i + 1 - last[t]) ) t = j;
    }
    T[i] = t;
    ans += S[i][T[i]];
    last[T[i]] = i + 1;
    ll temp = 0;
    for (ll j = 0; j < 26; j++) {
      temp += C[j] * (i + 1 - last[j]);
    }
    ans -= temp;
  }
  for (ll i = 0; i < D; i++) {
    cout << (T[i] + 1) << '\n';
  }
  // cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3720
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef long long int ll;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define m0(x) memset(x,0,sizeof(x))

int main(void)
{
	int a[3],b[3],count[4],flag=0;
	m0(count);
	rep(i,3) scanf("%d %d",&a[i],&b[i]);
	rep(i,4){
		rep(j,3){
			if(a[j]==i+1) count[i]++;
			if(b[j]==i+1) count[i]++;
		}
		//printf("%d\n",count[i]);
		if(count[i]==3||count[i]==0) {
			flag=1;
		}
	}
	//printf("%d\n",flag);
	if(flag==1) printf("NO\n");
	else printf("YES\n");


	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i < n; ++i)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}

void solve() {
  // main coding
  int INF=1e9;
  int n,k; cin>>n>>k;
  vector<int> H(n);
  rep(i,n) cin>>H[i];
  vector<int> dp(n,INF);
  dp[0]=0;
  rep(i,n) rep1(j,k+1) {
    if(i-j>=0) dp[i]=min(dp[i],dp[i-j]+abs(H[i]-H[i-j]));
  }
  cout<<dp[n-1]<<endl;
}

int main() {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
using namespace std;
int n,m;
int num[100003],deg[100003];
vector <int> g[100003];
bool vis[100003];
int parents[100003];
void dfs1(int x,int pr){ 
	vis[x]=1;
	parents[x]=pr;
	for (int i=0;i<g[x].size();i++)
		deg[g[x][i]]--;
	for (int i=0;i<g[x].size();i++){
		if (!vis[g[x][i]] && deg[g[x][i]]==0){
			dfs1(g[x][i],x);
		}
	}
}
int main(){
	memset (parents,0,sizeof(parents)); 
	memset (vis,0,sizeof(vis));
	cin>>n>>m;
	for (int i=0;i<m+n-1;i++){
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		vis[y]=1; 
		deg[y]++;
	}
	int res=1;
	for (int i=1;i<=n;i++) if (!vis[i]) res=i; 
	memset (vis,0,sizeof(vis));
	dfs1(res,0);
	for (int i=1;i<=n;i++) cout<<parents[i]<<"\n";
}

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n,k,s;
    cin >> n >> k >> s;
    REP(i,k){
        cout << s;
        if(i!=n-1)cout << " ";
    }
    REP(i,n-k){
        if(s!=INF)cout << INF;
        else cout << INF-1;
        if(i!=(n-k-1))cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#define N 100
 
#define WHITE  0
#define GRAY  1
#define BLACK 2
 
int n, M[N][N];
int color[N], d[N], f[N];
int t;
 
void dfs_visit(int);
void dfs();
 
 
int main(){
 
  int u, k, v; 
  int i, j;
 
  scanf("%d", &n);
 
  for ( i = 0; i <n; i++ ){
    for ( j = 0; j <n; j++ ) {
      M[i][j] = 0;
    }
  }
   
  for ( i = 0; i < n; i++ ){
     
    scanf("%d %d", &u, &k);
    u--;
 
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
 
    }
  }
   
  dfs();
 
  return 0;
}
 
 
 
void dfs_visit(int u){
 
  int v;
 
  color[u] = GRAY;
  t++;
  d[u] = t;
 
  for ( v = 0; v < n; v++ ){
    if ( M[u][v] == 0 ) continue;
    if ( color[v] == WHITE ){
      dfs_visit(v);
    }
  }
 
  color[u] = BLACK;
  f[u] = ++t;
}
 
void dfs(){
 
  int i, u;
 
  for ( i = 0; i < n; i++ ){
    color[i] = WHITE;
  }
   
  t = 0;
 
  for ( u = 0; u < n; u++ ){
    if ( color[u] == WHITE ){
      dfs_visit(u);
    }
  }
  for ( i = 0; i < n; i++ ){
    printf("%d %d %d\n", i+1, d[i], f[i]);
  }
}

Measured memory_bytes: 636
#include<stdio.h>
#include<stdlib.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(){
  int i,j,k=0;
  int N;
  scanf("%d",&N);
  int A[N];
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    k+=A[i];
  }
  
  if(k%10 != 0){
    printf("%d\n",k);
    return 0;
  }
  else{
    qsort(A, sizeof(A) / sizeof(int), sizeof(int), asc);
    for(j=0;j<N;j++){
      if(A[j] % 10 != 0){
        k -= A[j];
        break;
      }
    }
    if(j!=N){
      printf("%d\n",k);
      return 0;
    }
    else{
      puts("0");
      return 0;
    }
  }
  return 0;
}
  
  

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

int D;

ll sum_score(vector<int> &contest_no, vector<vector<int>> &s,vector<int> &c,vector<int> new_day){
    //スコアの合計を求める
    ll score_daysum=0;

    rep(z,D){
        int x = contest_no[z]-1;
        //cout << x << " ";
        score_daysum += s[z][x];
        new_day[x] = z+1;
        rep(i,26){
            score_daysum -= c[i] * ((z+1) - new_day[i]);
        }
        //cout << score_daysum << endl;
    }
    return score_daysum;
}

int main(){
    cin >> D;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(26));
    rep(i,D){
        rep(j,26){
            cin >> s[i][j];
        }
    }


    vector<int> day(26,0);
    vector<int> contest_no;
    rep(z,D){
        int m_contest=1;
        ll m_score=-1e9;
        rep(i,26){
            if(m_score <  s[z][i] + c[i] * ((z+1) - day[i])){
                m_score = s[z][i] + c[i] * ((z+1) - day[i]);
                m_contest = i+1;
            }
        }
        day[m_contest - 1] = z+1;

        contest_no.push_back(m_contest);
    }


    while(clock() < 1800000){
        int day1=rand()%D;
        int contest = rand()%26+1;
        vector<int> new_day(26,0);
        //変える前のデータ保持
        int old_score=sum_score(contest_no, s ,c, new_day);
        int old_contest = contest_no[day1];

        // //データを入れ替える
        contest_no[day1]=contest;

        // // //スコアの合計を改めて計算
        int new_score = sum_score(contest_no, s ,c,new_day);

        //新旧のスコアを比較
        if(old_score > new_score){
         contest_no[day1] = old_contest;
        }
    }
    //解の出力
    for(int i:contest_no){
        cout << i << endl;
    }
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

signed main() {
#ifdef LOCAL
  assert(freopen("a.in", "r", stdin));
#endif
  int n, a, b;
  cin >> n >> a >> b;
  if ((a + b) % 2 == 1) {
    cout << "Borys" << endl;
  } else {
    cout << "Alice" << endl;
  }
}


Measured memory_bytes: 764
t = int(input())
vec = ((1, 0), (0, -1), (-1, 0), (0, 1))
for _ in range(t):
  def check(x, y, lst, checked):
    checked[y][x] = False
    color = mp[y][x]
    for dx, dy in vec:
      nx, ny = x + dx, y + dy
      if color == mp[ny][nx] and checked[ny][nx] == None:
        lst.append((nx, ny))
        check(nx, ny, lst, checked)
  
  mp = [list("X" * 8)] + [list("X" + input() + "X") for _ in range(12)] + [list("X" * 8)]
  cnt = 0
  
  while True:
    checked = [[None] * 8 for _ in range(14)]
    for y in range(1, 13):
      for x in range(1, 7):
        if mp[y][x] in ("O", ".", "X"):
          checked[y][x] = False
        elif checked[y][x] == None:
          lst = [(x, y)]
          check(x, y, lst, checked)
          length = len(lst)
          if length < 4:continue
          for nx, ny in lst:
            checked[ny][nx] = True
  
    if not any(any(lst) for lst in checked):
      break
    
    for y in range(1, 13):
      for x in range(1, 7):
        if mp[y][x] == "O":
          for dx, dy in vec:
            nx, ny = x + dx, y + dy
            if mp[ny][nx] != "O" and checked[ny][nx]:
              checked[y][x] = True
    
    for y in range(1, 13):
      for x in range(1, 7):
        if checked[y][x]:
          mp[y][x] = "."
  
    for x in range(1, 7):
      s = ""
      for y in range(12, 0, -1):
        s = mp[y][x] + s
      s = s.replace(".", "")
      s = "." * (12 - len(s)) + s
      for y in range(12, 0, -1):
        mp[y][x] = s[y - 1]
  
    cnt += 1
  
  print(cnt)


Measured memory_bytes: 5624
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 800005
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (lli)(x.size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;


void solve()
{

   lli x;
   cin>>x;
   cout<<(x^1);





}



int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputa.txt", "r", stdin);
     freopen("outputa.txt", "w", stdout);
    #endif
     // test
     {
        solve();
        nl
     }
    
}
//a+b=a?b+2?(a&b)
//__builtin_popcnt(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";

Measured memory_bytes: 3636
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	s := readString()
	t := readString()

	bs := []byte(s)
	for i, j := 0, len(bs)-1; i < j; i, j = i+1, j-1 {
		bs[i], bs[j] = bs[j], bs[i]
	}
	if string(bs) == t {
		println("YES")
	} else {
		println("NO")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;
const int mod=1e9+7;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main(){
    fast;
    string s;
    cin>>s;
    if(s[1]=='R') cout<<"ABC";
    else cout<<"ARC";
}


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

using namespace std;

#define INF 1e9

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

    while(1){
        int x,y,z;
        cin>>x>>y>>z;

        if(x==0)break;

        int ans=0;

        for(int i=1;i<=1000;i++){
            for(int j=1;i+j<=1000;j++){
                if((int)i*(100+x)/100+(int)j*(100+x)/100==z){
                    int m=(i*(100+y))/100,n=(j*(100+y))/100;
                    ans=max(ans,m+n);
                    //cout<<i<<" "<<j<<endl;
                }
            }
        }

        cout<<ans<<endl;

    }

}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int rem=n%10;
  
     if(rem==3)
      cout<<"bon\n";
     else if(rem==0 || rem==1 || rem==6 || rem== 8)
       cout<<"pon\n";
  
      else
        cout<<"hon\n";
  
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
 
int F[105][105];
int xg,yg;
 
 
void DFS(int Y,int X,int c){
  if(F[Y][X] != c){
    return;
  }
 
  F[Y][X] = -1;
  DFS(Y-1,X  ,c);
  DFS(Y  ,X+1,c);
  DFS(Y+1,X  ,c);
  DFS(Y  ,X-1,c);
}
 
 
int main(){
  int w,h,xs,ys,n;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0)
      break;
for(int i=0; i<102; i++){
      for(int j=0; j<102; j++){
        F[i][j]=0;
      }
    }
     
    cin >> xs >> ys >> xg >> yg >> n;
 
 
    for(int i=0;i<n;i++){
      int c,d,x,y;
      cin >> c >> d >> x >> y;
      if(d == 0){
        for(int j=0;j<4;j++){
          F[x+j][y] = c;
          F[x+j][y+1] = c;
        }
      } else {
        for(int j=0;j<4;j++){
          F[x][y+j] = c;
          F[x+1][y+j] = c;
        }
      }
    }
if(F[xs][ys]==0){
      cout << "NG" << endl;
      continue;
    }
  DFS(xs,ys,F[xs][ys]);
 
  if(F[xg][yg] == -1){
    cout << "OK" << endl;
  } else {
    cout << "NG" <<endl;
  }
  }
}


Measured memory_bytes: 3140
#include<stdio.h>
int main(void)
{
	int l,a,b,c,d,x,y,z;
	scanf("%d %d %d %d %d",&l,&a,&b,&c,&d);
	x=a/c;
	if(a%c>0){
		x+=1;
	}
	y=b/d;
	if(b%d>0){
		y+=1;
	}
	if(x>y){
		z=l-x;
	}
	else{
		z=l-y;
	}
	printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 2668
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}
template<typename T, size_t N> istream & operator>>(istream & s, array<T, N> & a) { RF(e, a) { s >> e; } return s; }
template<typename T, size_t N> ostream & operator<<(ostream & s, array<T, N> const & a) {
	inc(i, SI(a)) { s << (i == 0 ? "" : " ") << a[i]; }
	return s;
}

int main() {
	IN(LL, n);
	vector<array<LL, 2>> a(n - 1);
	cin >> a;
	
	LL ans = 0;
	inc(i, n) { ans += (i + 1) * (n - i); }
	RF(e, a) {
		sort(ALL(e));
		e[0]--;
		e[1]--;
		ans -= (e[0] + 1) * (n - e[1]);
	}
	OUT(ans);
}


Measured memory_bytes: 6416
import bisect    
    
N = int(input())
b = list(int(i) for i in input().split())
b.sort()
sum_N = 0
for i,x in enumerate(b):
    s = i+1
    for y in range(i+1,N,1):
        index = bisect.bisect_left(b,x+b[y])
        sum_N += max(0,index - y -1)
print(sum_N)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b; cin >> a >> b;
	bool ok = 0;
	for (int i = 1; i < 4; i++) {
		if ((a * b * i) % 2 == 1) ok = 1;
	}
	if (ok)cout << "Yes";
	else cout << "No";


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,x=0,y=0;
    string str;
    cin>>str;
    for(i=0;str[i];i++)
    {
        if(i%2==0 && str[i]=='1')
            x++;
        else if(i%2==1 && str[i]=='0')
            x++;
    }
    for(i=0;str[i];i++)
    {
        if(i%2==0 && str[i]=='0')
            y++;
        else if(i%2==1 && str[i]=='1')
            y++;
    }
    cout<<min(x,y)<<endl;

    return  0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

string s;
int q;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s >> q;
	deque<char> que;
	for(auto &i : s) que.push_back(i);
	bool rev = false;
	for(int i = 0; i < q; i++){
		int t;
		cin >> t;
		if(t == 1) rev ^= true;
		else{
			int f;
			char c;
			cin >> f >> c;
			if(f == 1 && !rev) que.push_front(c);
			else if(f == 1 && rev) que.push_back(c);
			else if(f == 2 && !rev) que.push_back(c);
			else que.push_front(c);
		}
	}
	if(rev){
		for(auto i = que.rbegin(); i != que.rend(); i++) cout << *i;
		cout << "\n";
	}else{
		for(auto &i : que) cout << i;
			cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, M, A, B, C;
    string s1, s2;
    cin >> A >> B >> C;
    if(A % C == 0){
        cout << B / C - A / C  + 1<< endl; 
    }else
    cout << B / C - A / C << endl;

}

Measured memory_bytes: 3620
#include <stdio.h>

#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, time, data[N][N], color[N], d[N], f[N]; 

void dfs();
void visit(int);

int main() {
  int i, j, k, l, u, v;
  
  scanf("%d", &n);

  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      data[i][j] = 0;
    }
  }

  for (i = 0; i < n; i++) {
    scanf("%d%d", &u, &k);
    
    for (j = 0; j < k; j++) {
      scanf("%d", &l);
      data[u][l] = 1;
    }
  }
  
  dfs();

  for (i = 1; i <= n; i++) {
    printf("%d %d %d\n", i, d[i], f[i]);
  }


  return 0;
}


void dfs() {
  int i;

  for (i = 1; i <= n; i++) {
    color[i] = WHITE;
  }
  time = 0;
  for (i = 1; i <= n; i++) {
    if (color[i] == WHITE) visit(i);
  }

}


void visit(int u) {
  int i;
  
  color[u] = GRAY;
  d[u] = ++time;
  
  for (i = 1; i <= n; i++) {
    if (data[u][i] == 0) continue;
    if (color[i] == WHITE) {
      visit(i);
    }
  }
  color[u] = BLACK;
  f[u] = ++time;
}



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

using namespace std;
#define PROBLEM "D"

int main(){

	#ifdef DBG
	freopen("problem" PROBLEM ".in", "r", stdin);
	freopen("problem" PROBLEM ".out", "w", stdout);
	#endif

	int N, M;

	cin >> N >> M;

	int arr[100010];
	memset(arr, 0, sizeof(arr));
	for(int i = 0 ; i < M ; i++){

		cin >> arr[i];
	}

	sort(arr, arr+M);

	vector<int> dis;
	for(int i = 0 ; i < M-1 ; i++){

		dis.push_back(abs(arr[i] - arr[i+1]));
	}
	sort(dis.begin(), dis.end());

	int tmp = N-1;
	int ans = 0;
	while(tmp--){

		if(dis.empty())
			break;
		dis.pop_back();
	}
	ans = accumulate(dis.begin(), dis.end(), 0);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1276
fun main(args: Array<String>) {
    val N = nextInt()
    fun dfs(s: String, mx: Char) {
        if (s.length == N) println(s)
        else {
            var c = 'a'
            while (c <= mx) {
                dfs(s + c, if (c == mx) mx + 1 else mx)
                c += 1
            }
        }
    }
    dfs("", 'a')
}
fun Long.isEven() = (this % 2L) == 0L
fun Long.isOdd() = !this.isEven()
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun nextLong() = java.lang.Long.parseLong(next())
fun nextLong(offset: Long = 0L) = nextLong() + offset
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }
fun listOfLong(offset: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + offset }
fun listOfDouble() = listOfString().map { it.toDouble() }


Measured memory_bytes: 39040
#include<stdio.h>
int main(void){
  int a,b,c,n,i;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
  scanf("%d %d %d\n",&a,&b,&c);
  if(a*a==b*b+c*c||b*b==c*c+a*a||c*c==a*a+b*b)printf("YES\n");
  else printf("NO\n");
  }
  return(0);
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

const int column = 50;

int main() {
    vector<ll> build(column, column - 1);
    ll k;
    cin >> k;

    ll l = k / column;
    rep(i, column) build[i] += l;
    ll m = k % column;
    rep(i, m) build[i] += column - m + 1;
    for (ll i = m; i < column; i++) {
        build[i] -= m;
    }

    cout << column << endl;
    for (ll n : build) cout << n << ' ';
    cout << endl;

}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pb push_back
#define p push

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

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph;




signed main(){
	IOS;

	ll n; 
	cin >> n;
	char c; 
	vi vec(n);
	ll res = 0;
	ll r = 0, g = 0, b = 0;
	for (int i = 0; i < n; i++){
		cin >> c;
		vec[i] = c;
		if (c == 'R'){
			r++;
			res += g*b;
		}
		else if (c == 'G'){
			g++;
			res += r*b;
		}
		else{
			b++;
			res += r*g;
		}
		for (int t = 0; t < i; t++){
			int left = 2 * t - i;
			if (left >= 0 && vec[t] != vec[i] && vec[left] != vec[i] && vec[left] != vec[t]) res--;
		}

	}
	cout << res << endl;
	

	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
 
using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
 
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007
 
typedef long long ll;
typedef tuple<int,int,bool> Tb;


int abc104_c(){
    //入力
    int a,b,c;
	cin >> a >> b >> c;
  
    //処理
  
    //出力
    if(a==b) cout << c << ENT;
    else if(a==c) cout << b << ENT;
    else if(b==c) cout << a << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 998244353
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll a, b;

	cin>>a>>b;

	if(a<9&&b<9){
		cout<<"Yay!"<<endl;
	}else{
		cout<<":("<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
  
signed main() {
    fast;
    string s;
    cin>>s;
    if (s[2]==s[3] && s[4]==s[5])
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/ruby
# encoding: utf-8

s = gets.chomp

if (s[0] == s[1] and s[2] == s[3] and s[1] != s[2]) or (s[0] == s[3] and s[1] == s[2] and s[0] != s[1]) or (s[0] == s[2] and s[1] == s[3] and s[0] != s[1])
  puts "Yes"
else
  puts "No"
end

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

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


int main(void){

	int c[3][3];
	rep(i, 3){
		rep(j, 3){
			cin >> c[i][j];
		}
	}

	int a[3], b[3];
	rep(a1, c[0][0]){
		a[0]=a1;
		b[0]=c[0][0]-a1;
		b[1]=c[0][1]-a1;
		b[2]=c[0][2]-a1;
		a[1]=c[1][0]-b[0];
		a[2]=c[2][0]-b[0];
		rep(i, 3){
			rep(j, 3){
				if(c[i][j] != (a[i]+b[j])){
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL-1
double EPS=1e-9;
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef complex<double> P;
typedef pair<int, ll> pill;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
long long int MOD = 998244353;
vector<pair<pii,ll> > datas;
bool check=true;

const int BT = 1 << 17 ;
int N;
vector<ll> A;
int main(){
	cin>>N;
	ll sum=0;
	rep(i,N){
		ll x;
		cin>>x;
		A.pb(x);
		sum+=x;
	}
	ll ans=sum;
	ll now=0;
	rep(i,N){
		now+=A[i];
		ans=min(ans,abs(sum-2*now));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2420
#include <cstdio>
#include <cstdlib>
#include <queue>
using namespace std;
const int N=1e6;
bool vis[N];
deque <pair<int,int> > q;
int k;
void bfs()
{
	while(!q.empty())
	{
		pair <int,int> t=q.front();
		q.pop_front();
		if(vis[t.first]) continue;
		vis[t.first]=true;
		if(!t.first)
		{
			printf("%d\n",t.second);
			exit(0);
		}
		q.push_front(make_pair(t.first*10%k,t.second));
		q.push_back(make_pair((t.first+1)%k,t.second+1));
	}
}
int main()
{
	scanf("%d",&k);
	q.push_front(make_pair(1,1));
	bfs();
	return 0;
}


Measured memory_bytes: 1152
use std::io;
use io_ext::Reader;

fn main() {
    let stdin = io::stdin();
    let mut r = Reader::new(io::BufReader::new(stdin.lock()));
    let n: u64 = r.read_line().parse().unwrap();
    println!("{}", (n - 1) / 2);
}

/// Extension of io module.
pub mod io_ext {
    use std::io::BufRead;

    pub struct Reader<R> {
        buf: String,
        inner: R,
    }

    impl<R> Reader<R> {
        #[inline]
        pub fn new(inner: R) -> Self {
            Reader { buf: String::new(), inner: inner }
        }

        #[inline]
        pub fn into_inner(self) -> R {
            self.inner
        }
    }

    impl<R: BufRead> Reader<R> {
        #[allow(deprecated)]
        #[inline]
        pub fn read_line(&mut self) -> &str {
            self.buf.clear();
            self.inner.read_line(&mut self.buf).unwrap_or_else(|e| panic!("{}", e));
            self.buf.trim_right()
        }
    }
}

/// Module supporting to parse strings.
pub mod parse {
    use std::str::FromStr;
    use std::borrow::Borrow;

    pub trait ParseNext: Iterator {
        fn parse_next<F: FromStr>(&mut self) -> F;
    }

    impl<'a, S: Borrow<str>, I: Iterator<Item=S>> ParseNext for I {
        fn parse_next<F: FromStr>(&mut self) -> F {
            if let Some(s) = self.next() {
                match s.borrow().parse() {
                    Ok(x) => x,
                    Err(_) => panic!("provided string cannot be parsed")
                }
            } else {
                panic!("iterator has no next element")
            }
        }
    }
}


Measured memory_bytes: 4352
from itertools import product


def main():
    n, *target = map(int, input().split())
    arr = [int(input()) for i in range(n)]

    tests = product("0123", repeat=n)
    test_arr = [[] for _ in range(3)]
    min_cost = float("inf")

    for test in tests:
        cost = 0

        if "1" not in test or "2" not in test or "3" not in test:
            continue

        for i in range(3):
            test_arr[i] = [arr[x] for x in range(n) if test[x] == str(i + 1)]
            cost += (len(test_arr[i]) - 1) * 10
            cost += abs(sum(test_arr[i]) - target[i])

        if min_cost > cost:
            min_cost = cost

    print(min_cost)


main()


Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        String s = sc.next();
        System.out.println(s.substring(0,3));
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25344
#include <bits/stdc++.h>
#include <array>
#define int long long
using namespace std;
const int mod = 998244353;
const int N = 2e5 + 1;
struct node {
  int l, r, sum = 0, add = 0;
};
vector<node> t(4 * N);
void build(int l, int r, int v = 1) {
  t[v].l = l;
  t[v].r = r;
  if (l == r)
    return;
  int m = (r + l) >> 1;
  build(l, m, 2 * v);
  build(m + 1, r, 2 * v + 1);
}
void push(int v) {
  if (t[v].add == 0) return;
  if (t[v].l != t[v].r) {
    t[2 * v].add += t[v].add;
    t[2 * v + 1].add += t[v].add;
  }
  t[v].sum = (t[v].sum + t[v].add) % mod;
  t[v].add = 0;
}
void upd(int l, int r, int x, int v = 1) {
  push(v);
  if (l > r)
    return;
  if (t[v].l > r || t[v].r < l)
    return;
  if (l <= t[v].l && t[v].r <= r) {
    t[v].add = (t[v].add + x) % mod;
    return;
  }
  upd(l, r, x, 2 * v);
  upd(l, r, x, 2 * v + 1);
  t[v].sum = (t[2 * v].sum + t[2 * v + 1].sum) % mod;
}
int get(int pos, int v = 1) {
  push(v);
  if (pos > t[v].r || pos < t[v].l)
    return 0;
  if (t[v].l == t[v].r && t[v].l == pos)
    return t[v].sum % mod;
  return (get(pos, 2 * v) + get(pos, 2 * v + 1)) % mod;
}
signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, k;
  cin >> n >> k;
  build(1, n);
  upd(1, 1, +1);
  vector<array<int, 2>> seg(k);
  for (int i = 0; i < k; ++i)
    cin >> seg[i][0] >> seg[i][1];
  for (int pos = 1; pos <= n - 1; ++pos) {
    for (int s = 0; s < k; ++s) {
      upd(seg[s][0] + pos, min(n, seg[s][1] + pos), get(pos));
    }
  }
  cout << get(n);
  return 0;
}

Measured memory_bytes: 28108
N, M = map(int, input().split()) 
left = 1
right = N
for _ in range(M):
    L, R = map(int, input().split())
    if left < L:
        left = L
    if R < right:
        right = R
    if left > right:
        print(0)
        exit()
print(right - left + 1)

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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    string str;
    cin >> str;
    vi ans(SZ(str));
    set<int> s;
    loop(i,SZ(str)-1){
        if(str[i] == 'R' && str[i+1] == 'L')s.insert(i);
    }

    loop(i,SZ(str)){
        if(str[i] == 'L')continue;
        auto it = s.lower_bound(i);
        if(abs(*it - i) % 2 == 0){
            ans[*it]++;
        }else{
            ans[*it + 1]++;
        }
    }

    loop(i,SZ(str)){
        if(str[i] == 'R')continue;
        auto it = s.lower_bound(i);
        it--;
        if(abs(*it - i) % 2 == 1){
            ans[*it + 1]++;
        }else{
            ans[*it]++;
        }
    }

    loop(i,SZ(str))cout << ans[i] << " ";
    cout << endl;



    return 0;
}


Measured memory_bytes: 3280