akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
typedef long long int ll;

ll dp[200200][2];
ll dp2[200200][2][2];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<2;j++){
			dp[i][j]=-1e18;
		}
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				dp2[i][j][k]=-1e18;
			}
		}
	}
	if(n%2==0){
		int u=n/2;
		dp[1][0]=a[0];
		dp[1][1]=a[1];
		for(int i=1;i<u;i++){
			for(int j=0;j<2;j++){
				if(j==0){
					dp[i+1][0]=max(dp[i+1][0],dp[i][j]+a[2*i]);
				}
				dp[i+1][1]=max(dp[i+1][1],dp[i][j]+a[2*i+1]);
			}
		}
		cout << max(dp[u][0],dp[u][1]) << endl;
	}
	else{
		int u=n/2;
		// a[n]を使わない場合
		dp[1][0]=a[0];
		dp[1][1]=a[1];
		for(int i=1;i<u;i++){
			for(int j=0;j<2;j++){
				if(j==0){
					dp[i+1][0]=max(dp[i+1][0],dp[i][j]+a[2*i]);
				}
				dp[i+1][1]=max(dp[i+1][1],dp[i][j]+a[2*i+1]);
			}
		}
		dp2[1][0][0]=a[n-1]+a[0];
		dp2[1][1][0]=a[n-1]+a[1];
		dp2[1][0][1]=a[n-1];
		for(int i=1;i<u;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
					//if(dp2[i][j][k]==-1e18)continue;
					if(k==0){
						dp2[i+1][0][1]=max(dp2[i+1][0][1],dp2[i][j][k]);
					}
					if(j==0){
						dp2[i+1][0][k]=max(dp2[i+1][0][k],dp2[i][j][k]+a[i*2]);
					}
					if(i!=u-1)dp2[i+1][1][k]=max(dp2[i+1][1][k],dp2[i][j][k]+a[i*2+1]);
				}
			}
		}
		cout << max({dp[u][0],dp[u][1],dp2[u][0][1],dp2[u][1][1]}) << endl;
	}
}

Measured memory_bytes: 14216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,p,q;
 while(cin>>p){
    n=1000;
    int x[p];
    for(i=0;i<p;i++)cin>>x[i];
  j=0; q=0;
  for(i=1;i<p;i++){ q=max(q,n);
   if(x[i]>x[i-1]){
    j=n/x[i-1];
    n%=x[i-1];
    n+=(j*x[i]);
   }

 q=max(q,n);
   // cout<<n<<" ";
  }

  cout<<q<<endl;
 }


    return 0;
}


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

signed main(void)
{
	int a;
	map<int, int> m;
	

	for(int i = 0; i < 3; i++)
	{
		cin >> a;
		m[a]++;
	}
	for(auto p: m)
	{
		if (p.second == 1)
		{
			cout << p.first << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>


int main()
{
	for(int i = 1; i < 10; i++) {
		for(int k = 1; k < 10; k++) {
			int l = i * k;
			std::cout << i << "x" << k << "=" << l<< std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
using System;

namespace ATCODER123
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] S = Console.ReadLine().Split(' ');
            int N = int.Parse(S[0]);
            int D = int.Parse(S[1]);

            string[] Xn;

            int Ans = 0;

            var X = new int[N, D];
            for (int i = 0; i < N; i++)
            {
                Xn = Console.ReadLine().Split(' ');
                for (int j = 0; j < D; j++)
                {
                    X[i, j] = int.Parse(Xn[j]);
                }
            }

            int Checker = 0;
            double Dchecker;
            for (int i = 0; i < N; i++)
            {
                for (int j = i; j < N; j++)
                {
                    for (int k = 0; k < D; k++)
                    {
                        Checker += (X[i, k] - X[j, k]) * (X[i, k] - X[j, k]);

                    }

                    Dchecker = Math.Sqrt((double)Checker);
                   // Console.WriteLine(Dchecker);
                    if (Dchecker == (int)Dchecker)
                    {
                        Ans++;
                    }
                    Checker = 0;


                }
                Ans--;
            }
            Console.WriteLine(Ans);

        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N, K;

int main() {
  cin >> N >> K;

  double ans = 0.0;
  for (int i = 1; i <= N; ++i) {
    int r = ceil(log2(double(K) / i));
    ans += pow(0.5, max(0, r));
  }

  printf("%.12lf\n", ans / N);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
ll price[50];
ll algolevel[50][50];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, i, j, k, l, m;
    cin >> n >> m >> k;
    for (i = 0; i < n;i++){
        cin >> price[i];
        for (j = 0; j < m;j++)
            cin >> algolevel[i][j];
    }
    ll minprice = 1e18;
    for (i = 0; i <= ((1LL << n) - 1);i++){
        int flag = 0;
        for (l = 0; l < m;l++){
            ll currlevel = 0;
            for (j = 0; j < n;j++){
                if(getbit(i,j)==1)
                    currlevel += algolevel[j][l];
            }
            if(currlevel<k){
                flag = 1;
                break;
            }
        }
        ll cnt = 0;
        if(flag==0){
            for (j = 0; j < n;j++)
                cnt += (price[j] * (getbit(i, j) == 1));
            minprice = min(minprice, cnt);
        }
    }
    if(minprice==1e18){
        cout << "-1\n";
    }
    else{
        cout << minprice << "\n";
    }
    return 0;
}

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

using namespace std;

#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define DFOR(a, b, c) for (register int a = b, _n = c; a > _n; --a)
#define EREP(a, b) for (register int a = first[b]; ~a; a = edge[a].nxt)
#define GREP(a, b) for (register int& a = cur[b]; ~a; a = edge[a].nxt)

const int SIZE = 200005;
const int Mod = 998244353;

int n;
long long ans = 0;
inline void Add (int x) {
    ans = ((ans + x) % Mod + Mod) % Mod;
}
struct Node {
    int x, y;
} a[SIZE];
struct cmpx {
    bool operator () (const Node& x1, const Node& x2) const {
        return x1.x < x2.x;
    }
};

int X[SIZE], Y[SIZE];
int F[SIZE];
int sum[SIZE];

void Update (int x) {
    while (x <= n) {
        ++sum[x];
        x += x & -x;
    }
}
int Sum (int x) {
    int res = 0;
    while (x) {
        res += sum[x];
        x ^= x & -x;
    }
    return res;
}

void _main () {
    scanf ("%d", &n);

    F[0] = 1;
    REP (i, 1, n) F[i] = F[i - 1] * 2 % Mod;

    REP (i, 1, n) {
        scanf ("%d%d", &a[i].x, &a[i].y);
        X[i] = a[i].x;
        Y[i] = a[i].y;
    }
    sort(X + 1, X + n + 1);
    sort(Y + 1, Y + n + 1);
    int x = unique(X + 1, X + n + 1) - X - 1;
    int y = unique(Y + 1, Y + n + 1) - Y - 1;

    REP (i, 1, n) {
        a[i].x = lower_bound(X + 1, X + x + 1, a[i].x) - X;
        a[i].y = lower_bound(Y + 1, Y + y + 1, a[i].y) - Y;
    }

    ans = 1LL * n * (F[n] - 1) % Mod;

    REP (i, 1, n) {
        Add(-2 * (F[i - 1] - 1));
        Add(-2 * (F[n - i] - 1));
    }

    sort(a + 1, a + n + 1, cmpx());

    REP (i, 1, n) {
        Add(F[Sum(a[i].y)] - 1);
        Add(F[i - Sum(a[i].y) - 1] - 1);
        Update(a[i].y);
    }

    memset(sum, 0, sizeof sum);
    DREP (i, n, 1) {
        Add(F[Sum(a[i].y)] - 1);
        Add(F[n - i - Sum(a[i].y)] - 1);
        Update(a[i].y);
    }

    printf ("%lld\n", ans);
}

int main () {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    _main();   
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int h[N];
  rep(i, N) cin >> h[i];
  sort(h, h+N);
  int ans = 1e9;
  rep(i, N-K+1) ans = min(ans, h[i+K-1]-h[i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std ;
int main(){
string s;
cin>>s;
int c = 0;
for(int i = 0 , j = s.size()-1;i<=(s.size()/2)&&j>=(s.size()/2);i++,j--){
    if(s[i]!=s[j])
    c++;
}
    cout<<c<<endl;
}

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

const ll days = 5e15;

int main() {
    string s;
    ll k;
    cin >> s >> k;
    for (char c : s) {
        int d = c - '0';
        if (d == 1) k--;
        else {
            k = 0;
        }
        if (k <= 0) {
            cout << c << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3588
import java.util.Arrays;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  Scanner sc;

  Main() {
    sc = new Scanner(System.in);
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    String[] keitai = {
        "",
        ".,!? ",
        "abc",
        "def",
        "ghi",
        "jkl",
        "mno",
        "pqrs",
        "tuv",
        "wxyz"
    };
    String reg = "\\d*?0";
    Pattern pt = Pattern.compile(reg);

    int n = ni();

    for (int i = 0; i < n; ++i) {
      Matcher mc = pt.matcher(sc.next());
      while (mc.find()) {
        int l = mc.group().length() - 1;
        char c = mc.group().charAt(0);
        if (l > 0) {
          int idx = c - '0';
          System.out.print(keitai[idx].charAt((l - 1) % keitai[idx].length()));
        }
      }
      System.out.println();
    }
  }

  int ni() {
    return sc.nextInt();
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 35284
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ld> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    ld sumd = 0;
    rep(i, N)
    {
        sumd += A[i];
    }
    ld coff = (ld)(sumd / 4 / M);
    int count = 0;
    rep(i, N)
    {
        if (A[i] >= coff)
        {
            count++;
        }
    }
    if (count >= M)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t;
    cin >> s >> t;
    int ns = s.size();
    int nt = t.size();
    if (ns > nt) cout << "GREATER" << endl;
    else if (ns < nt) cout << "LESS" << endl;
    else {
        rep(i, ns) {
            int sx = s[i] - '0';
            int tx = t[i] - '0';
            if (sx == tx) continue;
            cout << (sx>tx?"GREATER":"LESS") << endl;
            return 0;
        }
        cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256
#include<algorithm> 
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cstdio>
#include<ctime>

using namespace std;

inline int read() {
	int res=0,fh=1;
	char ch=getchar();
	while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
	if(ch=='-')fh=-1,ch=getchar();
	while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
	return fh*res;
}

const int maxn=100010;
int n;
string s;
int a[maxn],ans[maxn];
bool gg[maxn];//gg[i]=1 则i与i+1为断点
bool cc[maxn];//cc[i]=1 则i与i+1为循环 
bool dd[maxn];//dd[i]=1 则i-1与i为循环 
int main()
{
	memset(gg,0,sizeof gg);
	memset(cc,0,sizeof cc);
	memset(a,0,sizeof a);
	memset(dd,0,sizeof dd);
	memset(ans,0,sizeof ans);
	cin>>s;n=s.length();
	for(int i=0;i<n;i++) a[i+1]=(s[i]=='R');
	for(int i=2;i<=n;i++){
		if(a[i]==1&&a[i-1]==0) gg[i-1]=1;
		if(a[i]==0&&a[i-1]==1) ans[i-1]=ans[i]=cc[i-1]=dd[i]=1;
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(cc[i]==0&&dd[i]==0) cnt++;
		if(cc[i]==1){
			ans[i]+=cnt/2;
			ans[i+1]+=cnt/2+(cnt&1);
		}
		if(gg[i]) cnt=0;
	}
	cnt=0;
	for(int i=n;i>=1;i--){
		if(cc[i]==0&&dd[i]==0) cnt++;
		if(dd[i]==1){
			ans[i]+=cnt/2;
			ans[i-1]+=cnt/2+(cnt&1);
		}
		if(gg[i-1]) cnt=0;
	}
	for(int i=1;i<=n;i++) printf("%d ",ans[i]);puts("");
	return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  
  if(n==m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3640
#![allow(non_snake_case)]                                                   
use std::cmp::Ordering;   
use std::io::{stdin, BufRead, BufReader};
use std::f64;


fn main(){
    let input = BufReader::new(stdin());
    let mut V:Vec<i32> = Vec::new();
    for line in input.lines() {
        let values: Vec<i32> = line.unwrap()
            .split_whitespace()
            .filter_map(|x| x.parse::<i32>().ok())
            .collect();
        let mut d=values[0];
        let mut res=0;
        
        while d<600{
            res=res+(values[0]*(d*d));
            d=d+values[0];
        }
        println!("{}",res);
    }
    
}
    

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
 
pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);



Measured memory_bytes: 5032
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define ri register int
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> poly;
#define pb push_back
const int rlen=1<<18|1,inf=0x3f3f3f3f;
const ll Inf=1e18;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline ll readl() {
  ll ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline int Read(char*s) {
  int tp=0;
  char ch=gc();
  while(!isdigit(ch)&&!isalpha(ch)) ch=gc();
  while(isdigit(ch)||isalpha(ch)) s[++tp]=ch,ch=gc();
  return tp;
}
namespace modular {
  const int mod=1e9+7;
  inline int add(int a,int b) { return a+b<mod?a+b:a+b-mod; }
  inline int dec(int a,int b) { return a<b?a-b+mod:a-b; }
  inline int mul(int a,int b) { return (ll)a*b%mod; }
  inline void Add(int&a,int b) { a=a+b<mod?a+b:a+b-mod; }
  inline void Dec(int&a,int b) { a=a<b?a-b+mod:a-b; }
  inline void Mul(int&a,int b) { a=(ll)a*b%mod; }
  inline int ksm(int a,int p) { int ret=1;for(;p;p>>=1,Mul(a,a)) (p&1)&&(Mul(ret,a),1);return ret; }
  inline int Inv(int a) { return ksm(a,mod-2); }
  inline int sqr(int a) { return mul(a,a); }
  inline int cub(int a) { return (ll)a*a%mod*a%mod; }
}
using namespace modular;
template<typename T> inline void ckmax(T&a,T b) { a<b?a=b:0; }
template<typename T> inline void ckmin(T&a,T b) { a>b?a=b:0; }
template<typename T> inline T gcd(T a,T b) { T t;while(b)t=a,a=b,b=t-t/a*a;return a; }
template<typename T> inline T Abs(T x) { return x<0?-x:x; }
inline int rd() { return rand()|(rand()<<15); }
const int N=1e6+5;
char s[N];
int n;
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  n=Read(s);
  if(n&1) return cout<<"No",0;
  for(ri i=1;i<=n;++i) if(((i&1)&&s[i]!='h')||(!(i&1)&&s[i]!='i')) return cout<<"No",0;
  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;

int main(){
  int a,b;
  cin >> a >> b;
  cout << (b-a)*(b-a+1) /2 -b <<endl;
}

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

int main()
{
    string s;
    cin>>s;
    long long int n=s.length(),i,sum=0;
    for(i=0;i<n;i++){
        sum+=s[i]-'0';
    }
    if(sum%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}


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

int main() {
	int m, f, r;
	char score;

	while(1){
		cin >> m >> f >> r;

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

		if (m == -1 || f == -1 ) score = 'F';
		else if (m + f >= 80) score = 'A';
		else if (m + f >= 65) score = 'B';
		else if (m + f >= 50 || r >= 50) score = 'C';
		else if (m + f >= 30) score = 'D';
		else score = 'F';

		cout << score << endl;
	}

	return 0;
}


Measured memory_bytes: 3080
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int a[2][3][2];    // (x/y)(-/0/+)(min/max)

double calc( double t )
{
    double range[2][2]={{a[0][1][0], a[0][1][1]}, {a[1][1][0], a[1][1][1]}};

    range[0][0]=MIN(range[0][0],(a[0][0][0]-t));
    range[0][0]=MIN(range[0][0],(a[0][2][0]+t));
    range[0][1]=MAX(range[0][1],(a[0][0][1]-t));
    range[0][1]=MAX(range[0][1],(a[0][2][1]+t));
    range[1][0]=MIN(range[1][0],(a[1][0][0]-t));
    range[1][0]=MIN(range[1][0],(a[1][2][0]+t));
    range[1][1]=MAX(range[1][1],(a[1][0][1]-t));
    range[1][1]=MAX(range[1][1],(a[1][2][1]+t));

    return (range[0][1]-range[0][0])*(range[1][1]-range[1][0]);
}

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    int i,j;
    for(i=0; i<2; i++) {
        for(j=0; j<3; j++) {
            a[i][j][0]=INF;  a[i][j][1]=-INF;
        }
    }

    for(i=0; i<n; i++) {
        int x,y;
        char str[3]={0};
        scanf("%d%d%s", &x, &y, str);
        if(str[0]=='R') {
            a[0][2][0]=MIN(a[0][2][0], x);
            a[0][2][1]=MAX(a[0][2][1], x);
            a[1][1][0]=MIN(a[1][1][0], y);
            a[1][1][1]=MAX(a[1][1][1], y);
        }
        else if(str[0]=='L') {
            a[0][0][0]=MIN(a[0][0][0], x);
            a[0][0][1]=MAX(a[0][0][1], x);
            a[1][1][0]=MIN(a[1][1][0], y);
            a[1][1][1]=MAX(a[1][1][1], y);
        }
        else if(str[0]=='U') {
            a[0][1][0]=MIN(a[0][1][0], x);
            a[0][1][1]=MAX(a[0][1][1], x);
            a[1][2][0]=MIN(a[1][2][0], y);
            a[1][2][1]=MAX(a[1][2][1], y);
        }
        else {
            a[0][1][0]=MIN(a[0][1][0], x);
            a[0][1][1]=MAX(a[0][1][1], x);
            a[1][0][0]=MIN(a[1][0][0], y);
            a[1][0][1]=MAX(a[1][0][1], y);
        }
    }

    double ans = (double)INF * (double)INF;
    int t;
    for(t=0; t<=400000000; t++) {
        double val = calc( (double)t/2 );
        ans = MIN(ans, val);
    }
    printf("%.10lf\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int h,w,ans = 0,bcnt = 0,wcnt = 0;
string field[410];
bool visited[410][410];

void dfs(int x,int y){
	visited[x][y] = true;
	if(field[x][y] == '#') bcnt++;
	else wcnt++;
	for(int i = 0;i < 4;i++){
		int nx = x + dx[i],ny = y + dy[i];
		if(in(nx,ny,h,w) && !visited[nx][ny] && field[nx][ny] != field[x][y]){
			dfs(nx,ny);
		}
	}
}

signed main(){
	cin >> h >> w;
	for(int i = 0;i < h;i++) cin >> field[i];
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(!visited[i][j]){
				wcnt = 0;
				bcnt = 0;
				dfs(i,j);
				ans += wcnt * bcnt;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 15616
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	ll a,b;
	cin>>a>>b;
	ll c=gcd(a,b);
	cout<<a*b/c<<endl;
	return 0;
}/*『你强归你强，我永不示弱』*/





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

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// typedef struct 
// {
//     ll h;
//     ll v;
// } box;


// int cmp_qwe(const void*a, const void*b){return ((box*)b)->a - ((box*)a)->a;}

// ll dp[3000][3000];
// box u[2000];
ll list[300000];
ll lsum[2020];

int main(){
  ll n, a=0, u=1, sum=0;
  
  char s[300000];

  scanf("%s", s);

  for (n = 0; s[n] != '\0'; n++){}
  
  for (int i = n-1; i > -1 ; i--)
  {
      list[i] = (s[i] - '0') * u % 2019;

      a = (a+list[i]) % 2019;
      
      sum += lsum[a];
      if(a == 0) sum++;
      lsum[a]++;

      u = u * 10 % 2019;
  }
  
  printf("%lld", sum);

  return 0;
}

Measured memory_bytes: 3492
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ctime>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define in(i,arr) for(auto &i:arr)cin>>i;
#define all(x) (x).begin(), (x).end()   // sort(all(v)) instead sort(v.begin(),v.end())
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define vi vector<int>
#define vl vector<int>
#define pb push_back
#define eb empalce_back
int pow(int base,int to)
{   int ans=1;
    while(to>0) {
        if (to & 1)
            ans *= base, to--;
        else base *= base, to /= 2;
    }
    return ans;

}
int main()
{ fast;
//  string s,t;
//  cin>>s>>t;
//  int count=0;
//  int ma=0;
//  int temp;
//  for(int i=0;i<t.size();i++)
//  {   temp=i;
//      for(int j=i;j<s.size()-(t.size()-i);j++)
//      {
//          if(s[j]==t[i])
//              i++,count++,ma=max(ma,count);
//          else {i=temp;count=0;}
//      }
//      i=temp+1;
//  }
////for(int k=0;k<s.size();k++){
////for (int i=k,j=0;i<s.size(),j<t.size();i++)
////{
////    if(s[i]==t[j])
////        j++,count++;
////    else ma=max(ma,count),j++,count=0;
////
////}}
//  cout<<t.size()-ma;
  int n;
  cin>>n;
  ll arr[n];
  in(i,arr);ll ans=0;
  ll arr1[n];
  arr1[n-1]=arr[n-1];
 for(int i=n-2;i>=0;i--)
 {
     arr1[i]=(arr1[i+1]%mod+arr[i]%mod)%mod;
 }
 for(int i=0;i<n-1;i++)
 {
     ans=(ans%mod+((arr[i]%mod)*(arr1[i+1]%mod))%mod)%mod;
 }
 cout<<ans;



}



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

int main()
{
    int N;
    cin >> N;
    if (N % 2 != 0)
    {
        cout << 0 << endl;
    }
    else
    {
        vector<int> vec(N);
        for (int i = 0; i < N; i++)
        {
            cin >> vec.at(i);
        }
        sort(vec.begin(), vec.end());
        cout << vec.at(N / 2) - vec.at(N / 2 - 1) << endl;
    }
}

Measured memory_bytes: 640
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(sc, out);
            out.flush();
        }
    }

    private void solve(Scanner sc, PrintWriter out) {
        int n = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>(n);
        for (int i = 0; i < n; i++) {
            int d = sc.nextInt();
            map.compute(d, (key, old) -> (old == null) ? 1 : old + 1);
        }

        

        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int t = sc.nextInt();
            int tmp = map.compute(t, (key, old) -> (old == null) ? -1 : old - 1);
            if (tmp < 0) {
                out.println("NO");
                return;
            }
        }

        out.println("YES");
    }
}

Measured memory_bytes: 130952
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    string S1, S2;
    int L = 0, R = 0;
    rep(i, N) {
        if (S[i] == '(') L++;
        else if (S[i] == ')') R++;
        if (L < R) {
            S1 += '(';
            L++;
        }
    }
    while(R < L) {
        S2 += ')';
        R++;
    }
    cout << S1 << S << S2 << endl;
    

    return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
ll N;
ll H[100001]={};
int main() {
	cin>>N;

	for(int i=0;i<N;i++){
		cin>>H[i];
	}
	int R=0;
	for(int i=N-1;i>0;i--){
		if(H[i-1]>H[i]){
			if(H[i-1]-H[i]>1){
				R=1;
				break;
			}else{
				H[i-1]-=1;
			}
		}

	}

	//出力
	if(R==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std ;
int main () {
  int A , B , C ; cin >> A >> B >> C ;
  int ans = max <int >({
    10 * A + B + C ,
    A + 10 * B + C ,
    A + B + 10 * C ,
  });
  cout << ans << endl ;
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;

    bool check=true;
    if(s[0]=='A' && 'a'<=s[1] && s[1]<='z' && 'a'<=s[s.length()-1] && s[s.length()-1]<='z'){
        int cnt=0;
        for(int i=2;i<s.length()-1;i++){
            if(s[i]=='C') cnt++;
            else if(!('a'<=s[i] && s[i]<='z')){
                check=false;
                break;
            }
            if(cnt>=2){
                check=false;
                break;
            }
        }
        if(cnt==0) check=false;
    }
    else check=false;

    if(check) cout << "AC";
    else cout << "WA";
    cout << endl;
}

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

int fst[1000010], nxt[2000010], lst[1000010], des[2000010];
int Ans[1000010], s[1000010], cnt = 1;

void add(int u, int v) {
	if (!fst[u]) fst[u] = ++cnt;
	else nxt[lst[u]] = ++cnt;
	lst[u] = cnt, des[cnt] = v;
}

inline void dfs(int now, int fa) {
	for (int i = fst[now]; i; i = nxt[i])
		if (des[i] != fa) 
			if (s[des[i]] < s[now]) {
				if (Ans[des[i]] == -1) dfs(des[i], now);
				if (Ans[des[i]] == 0) {
					Ans[now] = 1;
					return ;
				}
			}
	Ans[now] = 0;
}

int main() {
	
	// freopen("C.in", "r", stdin);
	// freopen("C.out", "w", stdout);

	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &s[i]);
	for (int i = 1, u, v; i < n; ++i)
		scanf("%d%d", &u, &v), add(u, v), add(v, u);
	for (int i = 1; i <= n; ++i) Ans[i] = -1;
	for (int i = 1; i <= n; ++i) {
		if (Ans[i] == -1)
			dfs(i, 0);
		if (Ans[i]) printf("%d ", i);
	}

	// fclose(stdin);
	// fclose(stdout);

	return 0;

}

Measured memory_bytes: 10496
#include<algorithm>
#include<iostream>
#include<string.h>
#include<utility>
#include<stdio.h>
#include<vector>
#include<string>
#include<math.h>
#include<cmath>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#pragma warning(disable:4244)
#define PI 3.1415926536
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll ll_inf = 9223372036854775807;
const int int_inf = 2147483647;
const short short_inf = 32767;
const char char_inf = 127;
ll GCD(ll a, ll b) { return a ? GCD(b, a % b) : a; }
inline ll read() {
	ll c = getchar(), Nig = 1, x = 0;
	while (!isdigit(c) && c != '-')c = getchar();
	if (c == '-')Nig = -1, c = getchar();
	while (isdigit(c))x = ((x << 1) + (x << 3)) + (c ^ '0'), c = getchar();
	return Nig * x;
}
inline void out(ll a)
{
	if (a < 0)putchar('-'), a = -a;
	if (a >= 10)out(a / 10);
	putchar(a % 10 + '0');
}
ll qpow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)res = (res * x) % mod;
		x = (x * x) % mod; n >>= 1;
	}
	return res;
}
#define read read()
ll dp[250000][40];
ll save[250000];
ll n;
ll RMQ(ll s, ll v)
{
	ll k = (ll)(log(v - s + 1) * 1.0 / log(2.0));
	return save[dp[s][k]] < save[dp[v - ((ll)1 << k) + 1][k]] ? dp[s][k] : dp[v - ((ll)1 << k) + 1][k];
}
ll sum = 0;
bool judge(ll l, ll r)
{
	if (l == r)
	{
		sum += (ll)save[l];
		return 1;
	}
	return 0;
}
void dfs(ll L, ll R)
{
	if (judge(L, R))return;
	ll temp = RMQ(L, R);
	sum = sum + (ll)(temp - L + 1) * (R - temp + 1) * save[temp];
	if (L <= temp - 1)dfs(L, temp - 1);
	if (R >= temp + 1)dfs(temp + 1, R);
}
void ANS(int i, int j)
{
	dp[i][j] = save[dp[i][j - 1]] < save[dp[i + ((ll)1 << (j - 1))][j - 1]] ? dp[i][j - 1] : dp[i + ((ll)1 << (j - 1))][j - 1];
}
int main()
{
	n = read;
	for (ll i = 0; i < n; i++)save[i] = read;
	for (ll i = 0; i < n; i++)dp[i][0] = i;
	for (ll j = 1; ((ll)1 << j) <= n; j++)
		for (ll i = 0; i + ((ll)1 << j) - 1 < n; i++)ANS(i, j);
	dfs(0, n - 1);
	cout << sum << endl;
}

Measured memory_bytes: 75264
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    int four = 0;
    int two = 0;
    int other = 0;
    rep(i, N) {
        int A; cin >> A;
        if (A % 4 == 0) four++;
        else if (A % 2 == 0) two++;
        else other++;
    }

    if ((other <= four && (two == 0 || two > 1))
        || (other + two) - four == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
def bfs(n, path):
    check = [0]*n
    check[0] = 1
    que = [0]
    while que:
        u = que.pop()
        for v in path[u]:
            if check[v] == 0:
                check[v] = 1
                que.append(v)
    if check != [1]*n:
        return 1
    else:
        return 0

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

A = []
B = []
for i in range(m):
    a, b = map(int, input().split())
    A += [a-1]
    B += [b-1]
ans = 0

for i in range(m):
    edges = [[] for _ in range(n)]
    for j in range(m):
        if j != i:
            edges[A[j]] += [B[j]]
            edges[B[j]] += [A[j]]
    ans += bfs(n, edges)
print(ans)


Measured memory_bytes: 3064
from itertools import permutations

n = int(input())
nums1 = list(map(int,input().split(" ")))
nums2 = list(map(int,input().split(" ")))

t1 = tuple(nums1)
t2 = tuple(nums2)

index = 1
a = b = -1

for perm in permutations(list(range(1,n+1))):
    if perm == t1:
        a = index
    if perm == t2:
        b = index
    index += 1

print(abs(a-b))

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

using namespace std;

bool nice[100000];
int height[100000];

int main()
{
	int n, m;

	cin >> n >> m;

	for (int i = 1; i <= n; ++i)
	{
		cin >> height[i];
		nice[i] = true;
	}

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

		if (height[a] >= height[b])
		{
			nice[b] = false;
		}
		if (height[b] >= height[a])
		{
			nice[a] = false;
		}

	}

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

		if (nice[i])
		{
			++ans;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 4080
#include <cassert>
#include <cstddef>
#include <utility>
#include <vector>


template <class Abelian> class PotentializedUnionFind {

public:
	using value_type = Abelian;
	using difference_type = std::ptrdiff_t;
	using container_type = std::vector<std::pair<difference_type, value_type>>;
	using const_reference = const value_type &;
	using size_type = typename container_type::size_type;

protected:
	container_type c;

private:
	value_type potential(size_type x) {
		value_type ret = {};
		while (c[x].first >= static_cast<difference_type>(0)) {
			if (c[static_cast<size_type>(c[x].first)].first >=
				static_cast<difference_type>(0)) {
				c[x].second =
					c[static_cast<size_type>(c[x].first)].second + c[x].second;
				c[x].first = c[static_cast<size_type>(c[x].first)].first;
			}
			ret = ret + c[x].second;
			x = static_cast<size_type>(c[x].first);
		}
		return std::move(ret);
	}

public:
	PotentializedUnionFind() : c() {}
	explicit PotentializedUnionFind(const size_type size)
		: c(size, std::make_pair(-1, value_type())) {}

	size_type size() const { return c.size(); }
	bool empty() const { return c.empty(); }

	size_type find(size_type x) {
		assert(x < size());
		while (c[x].first >= static_cast<difference_type>(0)) {
			if (c[static_cast<size_type>(c[x].first)].first >=
				static_cast<difference_type>(0)) {
				c[x].second =
					c[static_cast<size_type>(c[x].first)].second + c[x].second;
				c[x].first = c[static_cast<size_type>(c[x].first)].first;
			}
			x = static_cast<size_type>(c[x].first);
		}
		return x;
	}
	value_type diff(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		return potential(y) + (-potential(x));
	}
	bool same(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		return find(x) == find(y);
	}
	size_type size(const size_type x) {
		assert(x < size());
		return static_cast<size_type>(-c[find(x)].first);
	}

	bool unite(size_type x, size_type y, value_type d) {
		assert(x < size());
		assert(y < size());
		d = d + diff(y, x);
		x = find(x);
		y = find(y);
		if (x == y)
			return false;
		if (c[x].first > c[y].first)
		std::swap(x, y), d = -d;
		c[x].first += c[y].first;
		c[y] = std::make_pair(static_cast<difference_type &&>(x), std::move(d));
		return true;
	}
};

#include<iostream>

int main() {
	int n, m;
	std::cin >> n >> m;
	PotentializedUnionFind<int> T(n);
	while (m--) {
		int l, r, d;
		std::cin >> l >> r >> d;
		--l;--r;
		if (!T.unite(l, r, d)) {
			if (T.diff(l, r) != d) {
				std::cout << "No" << std::endl;
				return 0;
			}
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int a,b,c,d; cin >> a>>b>>c>>d;
    if(a != c) {
        cout << 1 << endl;
    }else {
        cout << 0 << endl;
    }

    return 0;
}



Measured memory_bytes: 256
// 高橋君は
// N
//  枚の AtCoder せんべいを
// K
//  人の AtCoder 参加者になるべく公平に配ることにしました。
// N
//  枚すべてのせんべいを配るとき、せんべいを最も多くもらった人と最も少なくもらった人のもらったせんべいの枚数の差(の絶対値)の最小値を求めてください。
//




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

using namespace std;


int main(int argc, char const *argv[])
{
  int N,K;
  std::cin >> N >> K;
  if(N%K==0){
    cout << "0"<< endl;
  }else{
    cout << "1"<< endl;
  }

  return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
y = Y // 1000
ans = [-1, -1, -1]
# 10*a + 5*b + c == y and N == a + b + c
for a in range(N+1):
    for b in range(N+1):
        c1 = y - 10 * a - 5 * b
        c2 = N - b - a
        if c1 == c2 and c2 >= 0:
            ans = [a, b, c1]
            break
print(" ".join(map(str, ans)))

Measured memory_bytes: 3060
#include <stdio.h>
 
int main(void)
{
    int n, i, a, b, c;
 
    scanf("%d", &n);
    for (i = 0; i < n; ++i) {
        scanf("%d %d %d", &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: 580
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
candidate=set()
result=0
x=1
while x**2<=(sum(a)+1):
	if sum(a)%x==0:
		candidate.add(x)
		candidate.add(int(sum(a)/x))
	x+=1
# print(candidate)
for i in candidate:
	b=[0]*len(a)
	for j in range(len(a)):
		b[j]=int(a[j]%i)
	b.sort()
	if sum(b[:int(len(b)-sum(b)/i)])<=k:
		result=max(result,i)

	# need=0
	# need+=sum(b)/i
	# if need<=k:
print(result)



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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;

#define sync std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define loopi(n) for(int i=0;i<n;i++)
#define loopj(n) for(int j=0;j<n;j++)
#define loop(a,b,c) for(int i=a;i<=b;i=i+c)

#define     deb(x)      cout<<#x<<"="<<x<<endl
#define     all(x)      (x).begin(),(x).end()
#define     reset(a)    memset(a,0,sizeof(a))
#define     sz(x)       ((int)(x.size()))
#define     pb          push_back
#define     pf          push_front
#define     pob	        pop_back
#define     pof         pop_front
#define     ins         insert
#define     F           first
#define     S           second
#define     mkp         make_pair
#define     mkt         make_tuple
#define     bitcount(x) __builtin_popcountll(x)
#define     gcd(a,b)    (__gcd(a,b))
#define     lcm(a,b)    ((a*b)/gcd(a,b))
#define PI 3.1415926535897932384626
 
const int mod = 1e9+7;
const int N = 1e5+5;

//==========================================//

void solve()
{
	string a,b,ans;
	cin>>a>>b;
	int n=a.length(),m=b.length();
	int dp[n+1][m+1];
	
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(a[i-1]==b[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	//cout<<dp[n][m]<<endl;
	int i=n,j=m;
	while(i>0 && j>0)
	{
		if(dp[i][j]==dp[i][j-1])
			j--;
		else if(dp[i][j]==dp[i-1][j])
			i--;
		else
			ans=b[j-1]+ans,i--,j--;
	}
	cout<<ans;
}
int main()
{
	sync;

	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
}


Measured memory_bytes: 38728
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int x; cin >> x;
	if (x < 1200)cout << "ABC" << endl;
	else cout << "ARC" << endl;
	return 0;
}

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

using namespace std;

int main(void) {
  int n, m, x;
  cin >> n >> m >> x;
  vector <int> a(m);
  for(int i = 0; i < m; i++) {
    cin  >> a[i];
  }

  int t;
  for(int i = 0; i < m; i++) {
    if(x < a[i]) {
      t = i;
      break;
    }
  }
  int mn = min(t, m - t);
  cout << mn << endl;
}

Measured memory_bytes: 256
D, N = list(map(int, input().split()))

if D==0:
    if N==100:
        print(N+1)
    else:
        print(N)
    
elif D==1:
    if N!=100:
        print(N*100)
    else:
        print(N*100+100)
   
else:
    if N!=100:
        print(N*10000)
    else:
        print(N*10000+10000)
   

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

pair<string, int> solve(int n) {
    vector<int> pos(n + 1), time(n + 1);
    for (int i = 1; i <= n; i++) cin >> pos[i] >> time[i];
    vector<vector<int>> dp(n + 1, vector<int>(4, INF));
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        int diff_t = time[i] - time[i - 1];
        {   // 直接取りに行ける場合
            int dist = abs(pos[i] - pos[i - 1]);
            for (int k = 0; k <= 2; k++) {
                if (dist * (k + 1) <= diff_t) {
                    chmin(dp[i][k + 1], dp[i - 1][k] + dist);
                }
            }
        }
        {   // 家に戻る場合
            int dist = pos[i - 1] + pos[i];
            for (int k = 0; k <= 3; k++) {
                if (pos[i - 1] * (k + 1) + pos[i] <= diff_t) {
                    chmin(dp[i][1], dp[i - 1][k] + dist);
                }
            }
        }
        if (*min_element(dp[i].begin(), dp[i].end()) == INF) return {"NG", i};
    }
    return {"OK", *min_element(dp[n].begin(), dp[n].end()) + pos[n]};
}

int main() {
    int n;
    while (cin >> n, n) {
        auto res = solve(n);
        cout << res.first << " " << res.second << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include<iostream>
using namespace std;
int main(){
string s;
cin>>s;
int l,r;
for(int i=0;i<s.size();i++)
if(s[i]=='A'){
l=i;
break;}
for(int i=s.size()-1;i>=0;i--)
if(s[i]=='Z'){
r=i;
break;}
cout<<r-l+1<<endl;}

Measured memory_bytes: 640
#include <iostream>
int main()
{
    char s[4];
    char p;
    int i;
    scanf("%s",s);
    for(i=0;i<4;i++)
    {
        if(p==s[i])
        {
            printf("Bad");
            return 0;
        }
        p=s[i];
    }
    printf("Good");
    return 0;
}

Measured memory_bytes: 256